@hitachivantara/uikit-react-core 5.36.4 → 5.36.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 (90) hide show
  1. package/dist/cjs/components/AppSwitcher/Action/Action.cjs +4 -2
  2. package/dist/cjs/components/AppSwitcher/Action/Action.cjs.map +1 -1
  3. package/dist/cjs/components/AppSwitcher/Action/Action.styles.cjs +6 -8
  4. package/dist/cjs/components/AppSwitcher/Action/Action.styles.cjs.map +1 -1
  5. package/dist/cjs/components/AppSwitcher/AppSwitcher.cjs +4 -2
  6. package/dist/cjs/components/AppSwitcher/AppSwitcher.cjs.map +1 -1
  7. package/dist/cjs/components/AppSwitcher/AppSwitcher.styles.cjs +4 -3
  8. package/dist/cjs/components/AppSwitcher/AppSwitcher.styles.cjs.map +1 -1
  9. package/dist/cjs/components/BreadCrumb/Page/Page.cjs +1 -1
  10. package/dist/cjs/components/Button/Button.cjs +0 -3
  11. package/dist/cjs/components/Button/Button.cjs.map +1 -1
  12. package/dist/cjs/components/Calendar/utils.cjs.map +1 -1
  13. package/dist/cjs/components/Dialog/Dialog.cjs +2 -5
  14. package/dist/cjs/components/Dialog/Dialog.cjs.map +1 -1
  15. package/dist/cjs/components/Dropdown/Dropdown.cjs +0 -3
  16. package/dist/cjs/components/Dropdown/Dropdown.cjs.map +1 -1
  17. package/dist/cjs/components/OverflowTooltip/OverflowTooltip.cjs +9 -2
  18. package/dist/cjs/components/OverflowTooltip/OverflowTooltip.cjs.map +1 -1
  19. package/dist/cjs/components/OverflowTooltip/OverflowTooltip.styles.cjs +2 -2
  20. package/dist/cjs/components/OverflowTooltip/OverflowTooltip.styles.cjs.map +1 -1
  21. package/dist/cjs/components/Table/TableCell/TableCell.cjs +5 -8
  22. package/dist/cjs/components/Table/TableCell/TableCell.cjs.map +1 -1
  23. package/dist/cjs/components/Table/TableRow/TableRow.cjs +3 -20
  24. package/dist/cjs/components/Table/TableRow/TableRow.cjs.map +1 -1
  25. package/dist/cjs/components/Tooltip/Tooltip.cjs +2 -1
  26. package/dist/cjs/components/Tooltip/Tooltip.cjs.map +1 -1
  27. package/dist/cjs/components/TreeView/internals/DescendantProvider.cjs +0 -3
  28. package/dist/cjs/components/TreeView/internals/DescendantProvider.cjs.map +1 -1
  29. package/dist/cjs/components/TreeView/internals/TreeViewProvider.cjs +0 -3
  30. package/dist/cjs/components/TreeView/internals/TreeViewProvider.cjs.map +1 -1
  31. package/dist/cjs/components/Typography/utils.cjs +3 -13
  32. package/dist/cjs/components/Typography/utils.cjs.map +1 -1
  33. package/dist/cjs/components/VerticalNavigation/TreeView/descendants.cjs +0 -3
  34. package/dist/cjs/components/VerticalNavigation/TreeView/descendants.cjs.map +1 -1
  35. package/dist/cjs/hooks/useControlled.cjs +0 -3
  36. package/dist/cjs/hooks/useControlled.cjs.map +1 -1
  37. package/dist/cjs/providers/Provider.cjs +3 -2
  38. package/dist/cjs/providers/Provider.cjs.map +1 -1
  39. package/dist/cjs/utils/document.cjs +11 -0
  40. package/dist/cjs/utils/document.cjs.map +1 -0
  41. package/dist/cjs/utils/theme.cjs +5 -7
  42. package/dist/cjs/utils/theme.cjs.map +1 -1
  43. package/dist/esm/components/AppSwitcher/Action/Action.js +4 -2
  44. package/dist/esm/components/AppSwitcher/Action/Action.js.map +1 -1
  45. package/dist/esm/components/AppSwitcher/Action/Action.styles.js +6 -8
  46. package/dist/esm/components/AppSwitcher/Action/Action.styles.js.map +1 -1
  47. package/dist/esm/components/AppSwitcher/AppSwitcher.js +4 -2
  48. package/dist/esm/components/AppSwitcher/AppSwitcher.js.map +1 -1
  49. package/dist/esm/components/AppSwitcher/AppSwitcher.styles.js +4 -3
  50. package/dist/esm/components/AppSwitcher/AppSwitcher.styles.js.map +1 -1
  51. package/dist/esm/components/BreadCrumb/Page/Page.js +1 -1
  52. package/dist/esm/components/Button/Button.js +0 -3
  53. package/dist/esm/components/Button/Button.js.map +1 -1
  54. package/dist/esm/components/Calendar/utils.js.map +1 -1
  55. package/dist/esm/components/Dialog/Dialog.js +2 -5
  56. package/dist/esm/components/Dialog/Dialog.js.map +1 -1
  57. package/dist/esm/components/Dropdown/Dropdown.js +0 -3
  58. package/dist/esm/components/Dropdown/Dropdown.js.map +1 -1
  59. package/dist/esm/components/OverflowTooltip/OverflowTooltip.js +9 -2
  60. package/dist/esm/components/OverflowTooltip/OverflowTooltip.js.map +1 -1
  61. package/dist/esm/components/OverflowTooltip/OverflowTooltip.styles.js +2 -2
  62. package/dist/esm/components/OverflowTooltip/OverflowTooltip.styles.js.map +1 -1
  63. package/dist/esm/components/Table/TableCell/TableCell.js +6 -9
  64. package/dist/esm/components/Table/TableCell/TableCell.js.map +1 -1
  65. package/dist/esm/components/Table/TableRow/TableRow.js +4 -21
  66. package/dist/esm/components/Table/TableRow/TableRow.js.map +1 -1
  67. package/dist/esm/components/Tooltip/Tooltip.js +2 -1
  68. package/dist/esm/components/Tooltip/Tooltip.js.map +1 -1
  69. package/dist/esm/components/TreeView/internals/DescendantProvider.js +0 -3
  70. package/dist/esm/components/TreeView/internals/DescendantProvider.js.map +1 -1
  71. package/dist/esm/components/TreeView/internals/TreeViewProvider.js +0 -3
  72. package/dist/esm/components/TreeView/internals/TreeViewProvider.js.map +1 -1
  73. package/dist/esm/components/Typography/utils.js +3 -13
  74. package/dist/esm/components/Typography/utils.js.map +1 -1
  75. package/dist/esm/components/VerticalNavigation/TreeView/descendants.js +0 -3
  76. package/dist/esm/components/VerticalNavigation/TreeView/descendants.js.map +1 -1
  77. package/dist/esm/hooks/useControlled.js +0 -3
  78. package/dist/esm/hooks/useControlled.js.map +1 -1
  79. package/dist/esm/providers/Provider.js +4 -3
  80. package/dist/esm/providers/Provider.js.map +1 -1
  81. package/dist/esm/utils/document.js +11 -0
  82. package/dist/esm/utils/document.js.map +1 -0
  83. package/dist/esm/utils/theme.js +5 -7
  84. package/dist/esm/utils/theme.js.map +1 -1
  85. package/dist/types/index.d.ts +7 -3
  86. package/package.json +5 -5
  87. package/dist/cjs/components/AppSwitcher/TitleWithTooltip.cjs +0 -22
  88. package/dist/cjs/components/AppSwitcher/TitleWithTooltip.cjs.map +0 -1
  89. package/dist/esm/components/AppSwitcher/TitleWithTooltip.js +0 -22
  90. package/dist/esm/components/AppSwitcher/TitleWithTooltip.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"Dialog.js","sources":["../../../../src/components/Dialog/Dialog.tsx"],"sourcesContent":["import { useCallback, useMemo } from \"react\";\n\nimport MuiDialog, { DialogProps as MuiDialogProps } from \"@mui/material/Dialog\";\n\nimport { Close } from \"@hitachivantara/uikit-react-icons\";\nimport { theme } from \"@hitachivantara/uikit-styles\";\n\nimport { useDefaultProps } from \"@core/hooks/useDefaultProps\";\n\nimport { HvButton } from \"@core/components/Button\";\nimport { HvTooltip } from \"@core/components/Tooltip\";\nimport { HvBaseProps } from \"@core/types/generic\";\nimport { ExtractNames } from \"@core/utils/classes\";\nimport { setId } from \"@core/utils/setId\";\nimport { useTheme } from \"@core/hooks/useTheme\";\nimport { hexToRgbA } from \"@core/utils/hexToRgbA\";\n\nimport { staticClasses, useClasses } from \"./Dialog.styles\";\nimport { DialogContext } from \"./context\";\n\nexport { staticClasses as dialogClasses };\n\nexport type HvDialogClasses = ExtractNames<typeof useClasses>;\n\nexport interface HvDialogProps\n extends Omit<MuiDialogProps, \"fullScreen\" | \"classes\" | \"open\">,\n HvBaseProps {\n /** Current state of the Dialog. */\n open?: boolean;\n /** Callback fired when the component requests to be closed. */\n onClose?: (event: any, reason?: \"escapeKeyDown\" | \"backdropClick\") => void;\n /** @inheritdoc */\n maxWidth?: MuiDialogProps[\"maxWidth\"];\n /** @inheritdoc */\n fullWidth?: MuiDialogProps[\"fullWidth\"];\n /**\n * Element id that should be focus when the Dialog opens.\n * Auto-focusing elements can cause usability issues, so this should be avoided.\n * @deprecated Use `autoFocus` on the element instead, if auto-focusing is required.\n */\n firstFocusable?: string;\n /** Title for the button close. */\n buttonTitle?: string;\n /** Set the dialog to fullscreen mode. */\n fullscreen?: boolean;\n /** Prevent closing the dialog when clicking on the backdrop. */\n disableBackdropClick?: boolean;\n /** A Jss Object used to override or extend the styles applied to the component. */\n classes?: HvDialogClasses;\n /** Variant of the dialog. Adds a status bar to the top of the dialog. If not provided, no status bar is added. */\n variant?: \"success\" | \"error\" | \"warning\";\n /** @ignore */\n ref?: MuiDialogProps[\"ref\"];\n /** @ignore */\n component?: MuiDialogProps[\"component\"];\n}\n\nexport const HvDialog = (props: HvDialogProps) => {\n const {\n variant,\n classes: classesProp,\n className,\n id,\n children,\n open = false,\n onClose,\n firstFocusable,\n buttonTitle = \"Close\",\n fullscreen = false,\n disableBackdropClick = false,\n ...others\n } = useDefaultProps(\"HvDialog\", props);\n\n const { classes, css, cx } = useClasses(classesProp);\n const { rootId, colors } = useTheme();\n\n const measuredRef = useCallback(() => {\n if (!firstFocusable) return;\n\n const element = document.getElementById(firstFocusable);\n element?.focus();\n }, [firstFocusable]);\n\n const contextValue = useMemo(() => ({ fullscreen }), [fullscreen]);\n\n return (\n <MuiDialog\n container={\n typeof window !== \"undefined\"\n ? // TODO: review\n // eslint-disable-next-line ssr-friendly/no-dom-globals-in-react-fc\n document.getElementById(rootId || \"\") || document.body\n : undefined\n }\n className={cx(classes.root, className)}\n classes={{ container: css({ position: \"relative\" }) }}\n id={id}\n ref={measuredRef}\n open={open}\n fullScreen={fullscreen}\n onClose={(event, reason) => {\n // `disableBackdropClick` property was removed in MUI5\n // and we want to maintain that functionality\n if (disableBackdropClick) return;\n\n onClose?.(event, reason);\n }}\n slotProps={{\n backdrop: {\n classes: {\n root: cx(\n css({\n background: hexToRgbA(colors?.atmo4 || theme.colors.atmo4, 0.8),\n }),\n classes.background\n ),\n },\n },\n }}\n PaperProps={{\n classes: {\n root: cx(\n css({ position: \"absolute\" }),\n classes.paper,\n variant && cx(classes.statusBar, classes[variant]),\n {\n [classes.fullscreen]: fullscreen,\n }\n ),\n },\n }}\n aria-modal\n {...others}\n >\n <HvTooltip placement=\"top\" title={buttonTitle}>\n <HvButton\n id={setId(id, \"close\")}\n className={classes.closeButton}\n variant=\"secondaryGhost\"\n onClick={(event) => onClose?.(event, undefined)}\n >\n <Close role=\"none\" />\n </HvButton>\n </HvTooltip>\n <DialogContext.Provider value={contextValue}>\n {children}\n </DialogContext.Provider>\n </MuiDialog>\n );\n};\n"],"names":["HvDialog","props","variant","classes","classesProp","className","id","children","open","onClose","firstFocusable","buttonTitle","fullscreen","disableBackdropClick","others","useDefaultProps","css","cx","useClasses","rootId","colors","useTheme","measuredRef","useCallback","element","document","getElementById","focus","contextValue","useMemo","window","body","undefined","root","container","position","event","reason","backdrop","background","hexToRgbA","atmo4","theme","paper","statusBar","setId","closeButton"],"mappings":";;;;;;;;;;;;;;AAyDaA,MAAAA,WAAWA,CAACC,UAAyB;AAC1C,QAAA;AAAA,IACJC;AAAAA,IACAC,SAASC;AAAAA,IACTC;AAAAA,IACAC;AAAAA,IACAC;AAAAA,IACAC,OAAO;AAAA,IACPC;AAAAA,IACAC;AAAAA,IACAC,cAAc;AAAA,IACdC,aAAa;AAAA,IACbC,uBAAuB;AAAA,IACvB,GAAGC;AAAAA,EAAAA,IACDC,gBAAgB,YAAYd,KAAK;AAE/B,QAAA;AAAA,IAAEE;AAAAA,IAASa;AAAAA,IAAKC;AAAAA,EAAAA,IAAOC,WAAWd,WAAW;AAC7C,QAAA;AAAA,IAAEe;AAAAA,IAAQC;AAAAA,MAAWC,SAAS;AAE9BC,QAAAA,cAAcC,YAAY,MAAM;AACpC,QAAI,CAACb;AAAgB;AAEfc,UAAAA,UAAUC,SAASC,eAAehB,cAAc;AACtDc,aAASG,MAAM;AAAA,EAAA,GACd,CAACjB,cAAc,CAAC;AAEbkB,QAAAA,eAAeC,QAAQ,OAAO;AAAA,IAAEjB;AAAAA,EAAAA,IAAe,CAACA,UAAU,CAAC;AAEjE,SACG,qBAAA,WAAA,EACC,WACE,OAAOkB,WAAW;AAAA;AAAA;AAAA,IAGdL,SA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/components/Dialog/Dialog.tsx"],"sourcesContent":["import { useCallback, useMemo } from \"react\";\n\nimport MuiDialog, { DialogProps as MuiDialogProps } from \"@mui/material/Dialog\";\n\nimport { Close } from \"@hitachivantara/uikit-react-icons\";\nimport { theme } from \"@hitachivantara/uikit-styles\";\n\nimport { useDefaultProps } from \"@core/hooks/useDefaultProps\";\n\nimport { HvButton } from \"@core/components/Button\";\nimport { HvTooltip } from \"@core/components/Tooltip\";\nimport { HvBaseProps } from \"@core/types/generic\";\nimport { getElementById } from \"@core/utils/document\";\nimport { ExtractNames } from \"@core/utils/classes\";\nimport { setId } from \"@core/utils/setId\";\nimport { useTheme } from \"@core/hooks/useTheme\";\nimport { hexToRgbA } from \"@core/utils/hexToRgbA\";\n\nimport { staticClasses, useClasses } from \"./Dialog.styles\";\nimport { DialogContext } from \"./context\";\n\nexport { staticClasses as dialogClasses };\n\nexport type HvDialogClasses = ExtractNames<typeof useClasses>;\n\nexport interface HvDialogProps\n extends Omit<MuiDialogProps, \"fullScreen\" | \"classes\" | \"open\">,\n HvBaseProps {\n /** Current state of the Dialog. */\n open?: boolean;\n /** Callback fired when the component requests to be closed. */\n onClose?: (event: any, reason?: \"escapeKeyDown\" | \"backdropClick\") => void;\n /** @inheritdoc */\n maxWidth?: MuiDialogProps[\"maxWidth\"];\n /** @inheritdoc */\n fullWidth?: MuiDialogProps[\"fullWidth\"];\n /**\n * Element id that should be focus when the Dialog opens.\n * Auto-focusing elements can cause usability issues, so this should be avoided.\n * @deprecated Use `autoFocus` on the element instead, if auto-focusing is required.\n */\n firstFocusable?: string;\n /** Title for the button close. */\n buttonTitle?: string;\n /** Set the dialog to fullscreen mode. */\n fullscreen?: boolean;\n /** Prevent closing the dialog when clicking on the backdrop. */\n disableBackdropClick?: boolean;\n /** A Jss Object used to override or extend the styles applied to the component. */\n classes?: HvDialogClasses;\n /** Variant of the dialog. Adds a status bar to the top of the dialog. If not provided, no status bar is added. */\n variant?: \"success\" | \"error\" | \"warning\";\n /** @ignore */\n ref?: MuiDialogProps[\"ref\"];\n /** @ignore */\n component?: MuiDialogProps[\"component\"];\n}\n\nexport const HvDialog = (props: HvDialogProps) => {\n const {\n variant,\n classes: classesProp,\n className,\n id,\n children,\n open = false,\n onClose,\n firstFocusable,\n buttonTitle = \"Close\",\n fullscreen = false,\n disableBackdropClick = false,\n ...others\n } = useDefaultProps(\"HvDialog\", props);\n\n const { classes, css, cx } = useClasses(classesProp);\n const { rootId, colors } = useTheme();\n\n const measuredRef = useCallback(() => {\n if (!firstFocusable) return;\n\n const element = document.getElementById(firstFocusable);\n element?.focus();\n }, [firstFocusable]);\n\n const contextValue = useMemo(() => ({ fullscreen }), [fullscreen]);\n\n return (\n <MuiDialog\n container={getElementById(rootId)}\n className={cx(classes.root, className)}\n classes={{ container: css({ position: \"relative\" }) }}\n id={id}\n ref={measuredRef}\n open={open}\n fullScreen={fullscreen}\n onClose={(event, reason) => {\n // `disableBackdropClick` property was removed in MUI5\n // and we want to maintain that functionality\n if (disableBackdropClick) return;\n\n onClose?.(event, reason);\n }}\n slotProps={{\n backdrop: {\n classes: {\n root: cx(\n css({\n background: hexToRgbA(colors?.atmo4 || theme.colors.atmo4, 0.8),\n }),\n classes.background\n ),\n },\n },\n }}\n PaperProps={{\n classes: {\n root: cx(\n css({ position: \"absolute\" }),\n classes.paper,\n variant && cx(classes.statusBar, classes[variant]),\n {\n [classes.fullscreen]: fullscreen,\n }\n ),\n },\n }}\n aria-modal\n {...others}\n >\n <HvTooltip placement=\"top\" title={buttonTitle}>\n <HvButton\n id={setId(id, \"close\")}\n className={classes.closeButton}\n variant=\"secondaryGhost\"\n onClick={(event) => onClose?.(event, undefined)}\n >\n <Close role=\"none\" />\n </HvButton>\n </HvTooltip>\n <DialogContext.Provider value={contextValue}>\n {children}\n </DialogContext.Provider>\n </MuiDialog>\n );\n};\n"],"names":["HvDialog","props","variant","classes","classesProp","className","id","children","open","onClose","firstFocusable","buttonTitle","fullscreen","disableBackdropClick","others","useDefaultProps","css","cx","useClasses","rootId","colors","useTheme","measuredRef","useCallback","element","document","getElementById","focus","contextValue","useMemo","root","container","position","event","reason","backdrop","background","hexToRgbA","atmo4","theme","paper","statusBar","setId","closeButton","undefined"],"mappings":";;;;;;;;;;;;;;;AA0DaA,MAAAA,WAAWA,CAACC,UAAyB;AAC1C,QAAA;AAAA,IACJC;AAAAA,IACAC,SAASC;AAAAA,IACTC;AAAAA,IACAC;AAAAA,IACAC;AAAAA,IACAC,OAAO;AAAA,IACPC;AAAAA,IACAC;AAAAA,IACAC,cAAc;AAAA,IACdC,aAAa;AAAA,IACbC,uBAAuB;AAAA,IACvB,GAAGC;AAAAA,EAAAA,IACDC,gBAAgB,YAAYd,KAAK;AAE/B,QAAA;AAAA,IAAEE;AAAAA,IAASa;AAAAA,IAAKC;AAAAA,EAAAA,IAAOC,WAAWd,WAAW;AAC7C,QAAA;AAAA,IAAEe;AAAAA,IAAQC;AAAAA,MAAWC,SAAS;AAE9BC,QAAAA,cAAcC,YAAY,MAAM;AACpC,QAAI,CAACb;AAAgB;AAEfc,UAAAA,UAAUC,SAASC,eAAehB,cAAc;AACtDc,aAASG,MAAM;AAAA,EAAA,GACd,CAACjB,cAAc,CAAC;AAEbkB,QAAAA,eAAeC,QAAQ,OAAO;AAAA,IAAEjB;AAAAA,EAAAA,IAAe,CAACA,UAAU,CAAC;AAEjE,SACG,qBAAA,WAAA,EACC,WAAWc,eAAeP,MAAM,GAChC,WAAWF,GAAGd,QAAQ2B,MAAMzB,SAAS,GACrC,SAAS;AAAA,IAAE0B,WAAWf,IAAI;AAAA,MAAEgB,UAAU;AAAA,IAAA,CAAY;AAAA,EAAA,GAClD,IACA,KAAKV,aACL,MACA,YAAYV,YACZ,SAAS,CAACqB,OAAOC,WAAW;AAGtBrB,QAAAA;AAAsB;AAE1BJ,cAAUwB,OAAOC,MAAM;AAAA,KAEzB,WAAW;AAAA,IACTC,UAAU;AAAA,MACRhC,SAAS;AAAA,QACP2B,MAAMb,GACJD,IAAI;AAAA,UACFoB,YAAYC,UAAUjB,QAAQkB,SAASC,MAAMnB,OAAOkB,OAAO,GAAG;AAAA,QAAA,CAC/D,GACDnC,QAAQiC,UACV;AAAA,MACF;AAAA,IACF;AAAA,KAEF,YAAY;AAAA,IACVjC,SAAS;AAAA,MACP2B,MAAMb,GACJD,IAAI;AAAA,QAAEgB,UAAU;AAAA,MAAA,CAAY,GAC5B7B,QAAQqC,OACRtC,WAAWe,GAAGd,QAAQsC,WAAWtC,QAAQD,OAAO,CAAC,GACjD;AAAA,QACE,CAACC,QAAQS,UAAU,GAAGA;AAAAA,MAAAA,CAE1B;AAAA,IACF;AAAA,EAEF,GAAA,cAAU,MACV,GAAIE,QAEJ,UAAA;AAAA,IAAA,oBAAC,WAAU,EAAA,WAAU,OAAM,OAAOH,aAChC,UAAA,oBAAC,UACC,EAAA,IAAI+B,MAAMpC,IAAI,OAAO,GACrB,WAAWH,QAAQwC,aACnB,SAAQ,kBACR,SAAUV,CAAUxB,UAAAA,UAAUwB,OAAOW,MAAS,GAE9C,UAAA,oBAAC,OAAM,EAAA,MAAK,OAAM,CAAA,EACpB,CAAA,GACF;AAAA,wBACC,cAAc,UAAd,EAAuB,OAAOhB,cAC5BrB,UACH;AAAA,EACF,EAAA,CAAA;AAEJ;"}
@@ -86,9 +86,6 @@ const HvDropdown = forwardRef((props, ref) => {
86
86
  useEffect(() => {
87
87
  setSelectionLabel(getSelectionLabel(labels, placeholder, multiSelect, values));
88
88
  }, [labels, multiSelect, placeholder, values]);
89
- if (virtualized && !height && process.env.NODE_ENV !== "production") {
90
- console.error("Dropdown/List in virtualized mode requires a height. Please define it.");
91
- }
92
89
  const dropdownHeaderRef = useRef();
93
90
  const {
94
91
  ref: refProp,
@@ -1 +1 @@
1
- {"version":3,"file":"Dropdown.js","sources":["../../../../src/components/Dropdown/Dropdown.tsx"],"sourcesContent":["import { forwardRef, useEffect, useRef, useState } from \"react\";\n\nimport { PopperProps, useForkRef } from \"@mui/material\";\n\nimport { useDefaultProps } from \"@core/hooks/useDefaultProps\";\nimport { setId } from \"@core/utils/setId\";\nimport { useLabels, useUniqueId, useControlled } from \"@core/hooks\";\nimport { HvBaseProps } from \"@core/types/generic\";\nimport {\n HvBaseDropdown,\n HvBaseDropdownProps,\n} from \"@core/components/BaseDropdown\";\nimport { HvListValue } from \"@core/components/List\";\nimport {\n isInvalid,\n HvInfoMessage,\n HvWarningText,\n HvFormElement,\n HvLabel,\n} from \"@core/components/Forms\";\nimport { ExtractNames } from \"@core/utils/classes\";\nimport { HvTypography } from \"@core/components/Typography\";\n\nimport { getSelected, getSelectionLabel } from \"./utils\";\nimport { HvDropdownList, HvDropdownListProps } from \"./List\";\nimport { staticClasses, useClasses } from \"./Dropdown.styles\";\nimport { HvDropdownLabelsProps, HvDropdownStatus } from \"./types\";\n\nexport { staticClasses as dropdownClasses };\n\nexport type HvDropdownClasses = ExtractNames<typeof useClasses>;\n\nexport interface HvDropdownProps\n extends HvBaseProps<HTMLDivElement, \"onChange\"> {\n /**\n * A Jss Object used to override or extend the component styles applied.\n */\n classes?: HvDropdownClasses;\n /**\n * The form element name.\n */\n name?: 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?: any;\n /**\n * Provide additional descriptive text for the form element.\n */\n description?: any;\n /**\n * The placeholder value when nothing is selected.\n */\n placeholder?: string;\n /**\n * Indicates that the form element is disabled.\n */\n disabled?: boolean;\n /**\n * Indicates that the form element is in read only mode.\n */\n readOnly?: boolean;\n /**\n * Indicates that user input is required on the form element.\n */\n required?: 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 the state.\n */\n status?: HvDropdownStatus;\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?: any;\n /**\n * Identifies the element that provides an error message for the dropdown.\n *\n * Will only be used when the validation status is invalid.\n */\n \"aria-errormessage\"?: string;\n /**\n * The callback fired when the value changes.\n */\n onChange?: (selected: HvListValue | HvListValue[] | undefined) => void;\n /**\n * The list to be rendered by the dropdown.\n */\n values?: HvListValue[];\n /**\n * If `true` the dropdown is multiSelect, if `false` the dropdown is single select.\n */\n multiSelect?: boolean;\n /**\n * If `true` the dropdown is rendered with a search bar, if `false` there won't be a search bar.\n */\n showSearch?: boolean;\n /**\n * If `true` the dropdown starts opened if `false` it starts closed.\n */\n expanded?: boolean;\n /**\n * When uncontrolled, defines the initial expanded state.\n */\n defaultExpanded?: boolean;\n /**\n * If 'true' the dropdown will notify on the first render.\n */\n notifyChangesOnFirstRender?: boolean;\n /**\n * An object containing all the labels for the dropdown.\n */\n labels?: HvDropdownLabelsProps;\n /**\n * If `true` the dropdown will show tooltips when user mouseenter text in list\n */\n hasTooltips?: boolean;\n /**\n * Disable the portal behavior.\n * The children stay within it's parent DOM hierarchy.\n */\n disablePortal?: boolean;\n /**\n * If `true` the dropdown width depends size of content if `false` the width depends on the header size.\n * Defaults to `false`.\n */\n variableWidth?: boolean;\n /**\n * If `true`, selection can be toggled when single selection.\n */\n singleSelectionToggle?: boolean;\n /**\n * Placement of the dropdown.\n */\n placement?: \"left\" | \"right\";\n /**\n * An object containing props to be wired to the popper component.\n */\n popperProps?: Partial<PopperProps>;\n /**\n * Callback called when the user cancels the changes.\n *\n * Called when the cancel button is used and when the user clicks outside the open container.\n *\n * @param {object} event The event source of the callback.\n */\n onCancel?: (event: Event) => void;\n /**\n * Callback called when dropdown changes the expanded state.\n *\n * @param {object} event The event source of the callback.\n * @param {boolean} open If the dropdown new state is open (`true`) or closed (`false`).\n */\n onToggle?: (event: Event, open: boolean) => void;\n /**\n * Callback called when the user clicks outside the open container.\n *\n * @param {object} event The event source of the callback.\n */\n onClickOutside?: (event: Event) => void;\n /**\n * @ignore\n */\n onFocus?: React.FocusEventHandler<any>;\n /**\n * @ignore\n */\n onBlur?: React.FocusEventHandler<any>;\n /**\n * Experimental. Height of the dropdown, in case you want to control it from a prop. Styles can also be used through dropdownListContainer class. Required in case virtualized is used\n */\n height?: number;\n /**\n * Experimental. Height of the dropdown, in case you want to control it from a prop. Styles can also be used through dropdownListContainer class. Required in case virtualized is used\n */\n maxHeight?: number;\n /**\n * Experimental. Uses dropdown in a virtualized form, where not all options are rendered initially. Good for use cases with a lot of options.\n */\n virtualized?: boolean;\n /**\n * Extra props passed to the dropdown.\n */\n baseDropdownProps?: Partial<HvBaseDropdownProps>;\n /**\n * Extra props passed to the list.\n */\n listProps?: HvDropdownListProps;\n}\n\nconst DEFAULT_LABELS: HvDropdownLabelsProps = {\n select: undefined,\n selectAll: \"All\",\n cancelLabel: \"Cancel\",\n applyLabel: \"Apply\",\n searchPlaceholder: \"Search\",\n multiSelectionConjunction: \"/\",\n};\n\n/**\n * A dropdown list is a graphical control element, similar to a list box, that allows the user to choose one value from a list.\n */\nexport const HvDropdown = forwardRef<HTMLDivElement, HvDropdownProps>(\n (props, ref) => {\n const {\n classes: classesProp,\n className,\n\n id,\n name,\n\n required = false,\n disabled = false,\n readOnly = false,\n\n label,\n \"aria-label\": ariaLabel,\n \"aria-labelledby\": ariaLabelledBy,\n description,\n \"aria-describedby\": ariaDescribedBy,\n\n placeholder = \"Select...\",\n\n onChange,\n\n status,\n statusMessage,\n \"aria-errormessage\": ariaErrorMessage,\n\n onCancel,\n onToggle,\n onClickOutside,\n\n onFocus,\n onBlur,\n\n values,\n multiSelect = false,\n showSearch = false,\n expanded,\n defaultExpanded = false,\n notifyChangesOnFirstRender = false,\n labels: labelsProp,\n hasTooltips = false,\n disablePortal = false,\n singleSelectionToggle = true,\n placement,\n variableWidth = false,\n popperProps = {},\n height,\n maxHeight,\n virtualized = false,\n baseDropdownProps = {},\n listProps = {},\n ...others\n } = useDefaultProps(\"HvDropdown\", props);\n\n const { classes, cx } = useClasses(classesProp);\n\n const labels = useLabels(DEFAULT_LABELS, labelsProp);\n\n const elementId = useUniqueId(id, \"hvdropdown\");\n\n const [validationState, setValidationState] = useControlled(\n status,\n \"standBy\"\n );\n\n const [validationMessage] = useControlled(statusMessage, \"Required\");\n\n const [isOpen, setIsOpen] = useControlled(\n expanded,\n Boolean(defaultExpanded)\n );\n const [selectionLabel, setSelectionLabel] = useState(\n getSelectionLabel(labels, placeholder, multiSelect, values)\n );\n const [internalValues, setInternalValues] = useState(values);\n\n useEffect(() => {\n setInternalValues(values);\n }, [values]);\n\n useEffect(() => {\n setSelectionLabel(\n getSelectionLabel(labels, placeholder, multiSelect, values)\n );\n }, [labels, multiSelect, placeholder, values]);\n\n if (virtualized && !height && process.env.NODE_ENV !== \"production\") {\n // eslint-disable-next-line no-console\n console.error(\n \"Dropdown/List in virtualized mode requires a height. Please define it.\"\n );\n }\n\n const dropdownHeaderRef = useRef<HTMLDivElement>();\n\n const {\n ref: refProp,\n dropdownHeaderRef: dropdownHeaderRefProp,\n ...otherBaseDropdownProps\n } = baseDropdownProps;\n const headerForkedRef = useForkRef(\n dropdownHeaderRefProp,\n dropdownHeaderRef\n );\n\n const dropdownForkedRef = useForkRef(ref, refProp);\n\n const handleToggle: HvBaseDropdownProps[\"onToggle\"] = (event, open) => {\n onToggle?.(event, open);\n\n setIsOpen(open);\n\n if (!open) {\n // also run built-in validation when closing without changes\n // as the user \"touched\" the input\n setValidationState(() => {\n // this will only run if status is uncontrolled\n if (required) {\n const hasSelection = getSelected(internalValues).length > 0;\n\n if (!hasSelection) {\n return \"invalid\";\n }\n }\n\n return \"valid\";\n });\n }\n };\n\n /** Applies the selected values to the state */\n const handleSelection: HvDropdownListProps[\"onChange\"] = (\n listValues,\n commitChanges,\n toggle,\n notifyChanges = true\n ) => {\n const selected = getSelected(listValues);\n\n if (commitChanges) {\n setInternalValues(listValues);\n setSelectionLabel(\n getSelectionLabel(labels, placeholder, multiSelect, listValues)\n );\n\n setValidationState(() => {\n // this will only run if status is uncontrolled\n if (required && selected.length === 0) {\n return \"invalid\";\n }\n\n return \"valid\";\n });\n }\n if (notifyChanges) onChange?.(multiSelect ? selected : selected[0]);\n if (toggle) {\n handleToggle(undefined as any, false);\n\n // focus-ring won't be visible even if using the keyboard:\n // https://github.com/WICG/focus-visible/issues/88\n dropdownHeaderRef.current?.focus({ preventScroll: true });\n }\n };\n\n /**\n * Handles the `Cancel` action. Both single and ranged modes are handled here.\n */\n const handleCancel: HvDropdownListProps[\"onCancel\"] = (evt) => {\n onCancel?.(evt as any);\n\n handleToggle(evt as any, false);\n\n // focus-ring won't be visible even if using the keyboard:\n // https://github.com/WICG/focus-visible/issues/88\n dropdownHeaderRef.current?.focus({ preventScroll: true });\n };\n\n const handleClickOutside: HvBaseDropdownProps[\"onClickOutside\"] = (evt) => {\n onClickOutside?.(evt);\n onCancel?.(evt);\n };\n\n const setFocusToContent: HvBaseDropdownProps[\"onContainerCreation\"] = (\n containerRef\n ) => {\n const inputs = containerRef?.getElementsByTagName(\"input\");\n if (inputs && inputs.length > 0) {\n inputs[0].focus();\n return;\n }\n const listItems =\n containerRef != null\n ? [...containerRef.getElementsByTagName(\"li\")]\n : [];\n listItems.every((listItem) => {\n if (listItem.tabIndex >= 0) {\n listItem.focus();\n return false;\n }\n return true;\n });\n };\n\n const buildHeaderLabel = () => {\n const hasSelection = getSelected(internalValues).length > 0;\n return labels?.select || !multiSelect ? (\n <HvTypography\n component=\"div\"\n variant=\"body\"\n className={cx(classes.placeholder, {\n [classes.selectionDisabled]: disabled,\n [classes.placeholderClosed]: !(isOpen || hasSelection),\n })}\n >\n {selectionLabel.selected}\n </HvTypography>\n ) : (\n <HvTypography\n component=\"div\"\n className={cx(classes.placeholder, {\n [classes.selectionDisabled]: disabled,\n })}\n variant=\"body\"\n >\n <b>{selectionLabel.selected}</b>\n {` ${labels?.multiSelectionConjunction} ${selectionLabel.total}`}\n </HvTypography>\n );\n };\n\n const hasLabel = label != null;\n const hasDescription = description != null;\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;\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 readOnly={readOnly}\n required={required}\n className={cx(\n classes.root,\n {\n [classes.disabled]: disabled,\n },\n className\n )}\n {...others}\n >\n {(hasLabel || hasDescription) && (\n <div className={classes.labelContainer}>\n {hasLabel && (\n <HvLabel\n id={setId(elementId, \"label\")}\n label={label}\n className={classes.label}\n />\n )}\n\n {hasDescription && (\n <HvInfoMessage\n id={setId(elementId, \"description\")}\n className={classes.description}\n >\n {description}\n </HvInfoMessage>\n )}\n </div>\n )}\n <HvBaseDropdown\n ref={dropdownForkedRef}\n id={setId(id, \"dropdown\")}\n classes={{\n root: cx(classes.dropdown, {\n [classes.readOnly]: readOnly,\n }),\n arrow: classes.arrow,\n header: cx(classes.dropdownHeader, {\n [classes.dropdownHeaderInvalid]: isStateInvalid,\n }),\n headerOpen: classes.dropdownHeaderOpen,\n }}\n expanded={isOpen}\n disabled={disabled}\n readOnly={readOnly}\n required={required}\n disablePortal={disablePortal}\n placement={placement}\n popperProps={popperProps}\n placeholder={buildHeaderLabel()}\n onToggle={handleToggle}\n onClickOutside={handleClickOutside}\n onContainerCreation={setFocusToContent}\n role=\"combobox\"\n variableWidth={variableWidth}\n aria-label={ariaLabel}\n aria-labelledby={\n [label && setId(elementId, \"label\"), ariaLabelledBy]\n .join(\" \")\n .trim() || undefined\n }\n aria-invalid={isStateInvalid ? true : undefined}\n aria-errormessage={errorMessageId}\n aria-describedby={\n [description && setId(elementId, \"description\"), ariaDescribedBy]\n .join(\" \")\n .trim() || undefined\n }\n onFocus={onFocus}\n onBlur={onBlur}\n dropdownHeaderRef={headerForkedRef}\n {...otherBaseDropdownProps}\n >\n <HvDropdownList\n id={setId(elementId, \"values\")}\n classes={{\n rootList: classes.rootList,\n dropdownListContainer: classes.dropdownListContainer,\n }}\n values={internalValues}\n multiSelect={multiSelect}\n showSearch={showSearch}\n onChange={handleSelection}\n onCancel={handleCancel}\n labels={labels}\n notifyChangesOnFirstRender={notifyChangesOnFirstRender}\n hasTooltips={hasTooltips}\n singleSelectionToggle={singleSelectionToggle}\n aria-label={ariaLabel}\n aria-labelledby={hasLabel ? setId(elementId, \"label\") : undefined}\n height={height}\n maxHeight={maxHeight}\n virtualized={virtualized}\n {...listProps}\n />\n </HvBaseDropdown>\n {canShowError && (\n <HvWarningText\n id={setId(elementId, \"error\")}\n disableBorder\n className={classes.error}\n >\n {validationMessage}\n </HvWarningText>\n )}\n </HvFormElement>\n );\n }\n);\n"],"names":["DEFAULT_LABELS","select","undefined","selectAll","cancelLabel","applyLabel","searchPlaceholder","multiSelectionConjunction","HvDropdown","forwardRef","props","ref","classes","classesProp","className","id","name","required","disabled","readOnly","label","ariaLabel","ariaLabelledBy","description","ariaDescribedBy","placeholder","onChange","status","statusMessage","ariaErrorMessage","onCancel","onToggle","onClickOutside","onFocus","onBlur","values","multiSelect","showSearch","expanded","defaultExpanded","notifyChangesOnFirstRender","labels","labelsProp","hasTooltips","disablePortal","singleSelectionToggle","placement","variableWidth","popperProps","height","maxHeight","virtualized","baseDropdownProps","listProps","others","useDefaultProps","cx","useClasses","useLabels","elementId","useUniqueId","validationState","setValidationState","useControlled","validationMessage","isOpen","setIsOpen","Boolean","selectionLabel","setSelectionLabel","useState","getSelectionLabel","internalValues","setInternalValues","useEffect","process","env","NODE_ENV","console","error","dropdownHeaderRef","useRef","refProp","dropdownHeaderRefProp","otherBaseDropdownProps","headerForkedRef","useForkRef","dropdownForkedRef","handleToggle","event","open","hasSelection","getSelected","length","handleSelection","listValues","commitChanges","toggle","notifyChanges","selected","current","focus","preventScroll","handleCancel","evt","handleClickOutside","setFocusToContent","containerRef","inputs","getElementsByTagName","listItems","every","listItem","tabIndex","buildHeaderLabel","selectionDisabled","placeholderClosed","total","hasLabel","hasDescription","canShowError","isStateInvalid","isInvalid","errorMessageId","setId","root","labelContainer","dropdown","arrow","header","dropdownHeader","dropdownHeaderInvalid","headerOpen","dropdownHeaderOpen","join","trim","rootList","dropdownListContainer"],"mappings":";;;;;;;;;;;;;;;;;;;AAuMA,MAAMA,iBAAwC;AAAA,EAC5CC,QAAQC;AAAAA,EACRC,WAAW;AAAA,EACXC,aAAa;AAAA,EACbC,YAAY;AAAA,EACZC,mBAAmB;AAAA,EACnBC,2BAA2B;AAC7B;AAKO,MAAMC,aAAaC,WACxB,CAACC,OAAOC,QAAQ;AACR,QAAA;AAAA,IACJC,SAASC;AAAAA,IACTC;AAAAA,IAEAC;AAAAA,IACAC;AAAAA,IAEAC,WAAW;AAAA,IACXC,WAAW;AAAA,IACXC,WAAW;AAAA,IAEXC;AAAAA,IACA,cAAcC;AAAAA,IACd,mBAAmBC;AAAAA,IACnBC;AAAAA,IACA,oBAAoBC;AAAAA,IAEpBC,cAAc;AAAA,IAEdC;AAAAA,IAEAC;AAAAA,IACAC;AAAAA,IACA,qBAAqBC;AAAAA,IAErBC;AAAAA,IACAC;AAAAA,IACAC;AAAAA,IAEAC;AAAAA,IACAC;AAAAA,IAEAC;AAAAA,IACAC,cAAc;AAAA,IACdC,aAAa;AAAA,IACbC;AAAAA,IACAC,kBAAkB;AAAA,IAClBC,6BAA6B;AAAA,IAC7BC,QAAQC;AAAAA,IACRC,cAAc;AAAA,IACdC,gBAAgB;AAAA,IAChBC,wBAAwB;AAAA,IACxBC;AAAAA,IACAC,gBAAgB;AAAA,IAChBC,cAAc,CAAC;AAAA,IACfC;AAAAA,IACAC;AAAAA,IACAC,cAAc;AAAA,IACdC,oBAAoB,CAAC;AAAA,IACrBC,YAAY,CAAC;AAAA,IACb,GAAGC;AAAAA,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,WAAW,QAAQ,GAC7B,SAAS;AAAA,MACP6E,UAAU5H,QAAQ4H;AAAAA,MAClBC,uBAAuB7H,QAAQ6H;AAAAA,IACjC,GACA,QAAQjE,gBACR,aACA,YACA,UAAUsB,iBACV,UAAUS,cACV,QACA,4BACA,aACA,uBACA,cAAYlF,WACZ,mBAAiBiG,WAAWM,MAAMjE,WAAW,OAAO,IAAIzD,QACxD,QACA,WACA,aACImD,GAAAA,UAAAA,CAAU,EAElB,CAAA;AAAA,IACCmE,gBACC,oBAAC,eACC,EAAA,IAAII,MAAMjE,WAAW,OAAO,GAC5B,eAAa,MACb,WAAW/C,QAAQmE,OAElBf,UACH,mBAAA;AAAA,EAEJ,EAAA,CAAA;AAEJ,CACF;"}
1
+ {"version":3,"file":"Dropdown.js","sources":["../../../../src/components/Dropdown/Dropdown.tsx"],"sourcesContent":["import { forwardRef, useEffect, useRef, useState } from \"react\";\n\nimport { PopperProps, useForkRef } from \"@mui/material\";\n\nimport { useDefaultProps } from \"@core/hooks/useDefaultProps\";\nimport { setId } from \"@core/utils/setId\";\nimport { useLabels, useUniqueId, useControlled } from \"@core/hooks\";\nimport { HvBaseProps } from \"@core/types/generic\";\nimport {\n HvBaseDropdown,\n HvBaseDropdownProps,\n} from \"@core/components/BaseDropdown\";\nimport { HvListValue } from \"@core/components/List\";\nimport {\n isInvalid,\n HvInfoMessage,\n HvWarningText,\n HvFormElement,\n HvLabel,\n} from \"@core/components/Forms\";\nimport { ExtractNames } from \"@core/utils/classes\";\nimport { HvTypography } from \"@core/components/Typography\";\n\nimport { getSelected, getSelectionLabel } from \"./utils\";\nimport { HvDropdownList, HvDropdownListProps } from \"./List\";\nimport { staticClasses, useClasses } from \"./Dropdown.styles\";\nimport { HvDropdownLabelsProps, HvDropdownStatus } from \"./types\";\n\nexport { staticClasses as dropdownClasses };\n\nexport type HvDropdownClasses = ExtractNames<typeof useClasses>;\n\nexport interface HvDropdownProps\n extends HvBaseProps<HTMLDivElement, \"onChange\"> {\n /**\n * A Jss Object used to override or extend the component styles applied.\n */\n classes?: HvDropdownClasses;\n /**\n * The form element name.\n */\n name?: 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?: any;\n /**\n * Provide additional descriptive text for the form element.\n */\n description?: any;\n /**\n * The placeholder value when nothing is selected.\n */\n placeholder?: string;\n /**\n * Indicates that the form element is disabled.\n */\n disabled?: boolean;\n /**\n * Indicates that the form element is in read only mode.\n */\n readOnly?: boolean;\n /**\n * Indicates that user input is required on the form element.\n */\n required?: 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 the state.\n */\n status?: HvDropdownStatus;\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?: any;\n /**\n * Identifies the element that provides an error message for the dropdown.\n *\n * Will only be used when the validation status is invalid.\n */\n \"aria-errormessage\"?: string;\n /**\n * The callback fired when the value changes.\n */\n onChange?: (selected: HvListValue | HvListValue[] | undefined) => void;\n /**\n * The list to be rendered by the dropdown.\n */\n values?: HvListValue[];\n /**\n * If `true` the dropdown is multiSelect, if `false` the dropdown is single select.\n */\n multiSelect?: boolean;\n /**\n * If `true` the dropdown is rendered with a search bar, if `false` there won't be a search bar.\n */\n showSearch?: boolean;\n /**\n * If `true` the dropdown starts opened if `false` it starts closed.\n */\n expanded?: boolean;\n /**\n * When uncontrolled, defines the initial expanded state.\n */\n defaultExpanded?: boolean;\n /**\n * If 'true' the dropdown will notify on the first render.\n */\n notifyChangesOnFirstRender?: boolean;\n /**\n * An object containing all the labels for the dropdown.\n */\n labels?: HvDropdownLabelsProps;\n /**\n * If `true` the dropdown will show tooltips when user mouseenter text in list\n */\n hasTooltips?: boolean;\n /**\n * Disable the portal behavior.\n * The children stay within it's parent DOM hierarchy.\n */\n disablePortal?: boolean;\n /**\n * If `true` the dropdown width depends size of content if `false` the width depends on the header size.\n * Defaults to `false`.\n */\n variableWidth?: boolean;\n /**\n * If `true`, selection can be toggled when single selection.\n */\n singleSelectionToggle?: boolean;\n /**\n * Placement of the dropdown.\n */\n placement?: \"left\" | \"right\";\n /**\n * An object containing props to be wired to the popper component.\n */\n popperProps?: Partial<PopperProps>;\n /**\n * Callback called when the user cancels the changes.\n *\n * Called when the cancel button is used and when the user clicks outside the open container.\n *\n * @param {object} event The event source of the callback.\n */\n onCancel?: (event: Event) => void;\n /**\n * Callback called when dropdown changes the expanded state.\n *\n * @param {object} event The event source of the callback.\n * @param {boolean} open If the dropdown new state is open (`true`) or closed (`false`).\n */\n onToggle?: (event: Event, open: boolean) => void;\n /**\n * Callback called when the user clicks outside the open container.\n *\n * @param {object} event The event source of the callback.\n */\n onClickOutside?: (event: Event) => void;\n /**\n * @ignore\n */\n onFocus?: React.FocusEventHandler<any>;\n /**\n * @ignore\n */\n onBlur?: React.FocusEventHandler<any>;\n /**\n * Experimental. Height of the dropdown, in case you want to control it from a prop. Styles can also be used through dropdownListContainer class. Required in case virtualized is used\n */\n height?: number;\n /**\n * Experimental. Height of the dropdown, in case you want to control it from a prop. Styles can also be used through dropdownListContainer class. Required in case virtualized is used\n */\n maxHeight?: number;\n /**\n * Experimental. Uses dropdown in a virtualized form, where not all options are rendered initially. Good for use cases with a lot of options.\n */\n virtualized?: boolean;\n /**\n * Extra props passed to the dropdown.\n */\n baseDropdownProps?: Partial<HvBaseDropdownProps>;\n /**\n * Extra props passed to the list.\n */\n listProps?: HvDropdownListProps;\n}\n\nconst DEFAULT_LABELS: HvDropdownLabelsProps = {\n select: undefined,\n selectAll: \"All\",\n cancelLabel: \"Cancel\",\n applyLabel: \"Apply\",\n searchPlaceholder: \"Search\",\n multiSelectionConjunction: \"/\",\n};\n\n/**\n * A dropdown list is a graphical control element, similar to a list box, that allows the user to choose one value from a list.\n */\nexport const HvDropdown = forwardRef<HTMLDivElement, HvDropdownProps>(\n (props, ref) => {\n const {\n classes: classesProp,\n className,\n\n id,\n name,\n\n required = false,\n disabled = false,\n readOnly = false,\n\n label,\n \"aria-label\": ariaLabel,\n \"aria-labelledby\": ariaLabelledBy,\n description,\n \"aria-describedby\": ariaDescribedBy,\n\n placeholder = \"Select...\",\n\n onChange,\n\n status,\n statusMessage,\n \"aria-errormessage\": ariaErrorMessage,\n\n onCancel,\n onToggle,\n onClickOutside,\n\n onFocus,\n onBlur,\n\n values,\n multiSelect = false,\n showSearch = false,\n expanded,\n defaultExpanded = false,\n notifyChangesOnFirstRender = false,\n labels: labelsProp,\n hasTooltips = false,\n disablePortal = false,\n singleSelectionToggle = true,\n placement,\n variableWidth = false,\n popperProps = {},\n height,\n maxHeight,\n virtualized = false,\n baseDropdownProps = {},\n listProps = {},\n ...others\n } = useDefaultProps(\"HvDropdown\", props);\n\n const { classes, cx } = useClasses(classesProp);\n\n const labels = useLabels(DEFAULT_LABELS, labelsProp);\n\n const elementId = useUniqueId(id, \"hvdropdown\");\n\n const [validationState, setValidationState] = useControlled(\n status,\n \"standBy\"\n );\n\n const [validationMessage] = useControlled(statusMessage, \"Required\");\n\n const [isOpen, setIsOpen] = useControlled(\n expanded,\n Boolean(defaultExpanded)\n );\n const [selectionLabel, setSelectionLabel] = useState(\n getSelectionLabel(labels, placeholder, multiSelect, values)\n );\n const [internalValues, setInternalValues] = useState(values);\n\n useEffect(() => {\n setInternalValues(values);\n }, [values]);\n\n useEffect(() => {\n setSelectionLabel(\n getSelectionLabel(labels, placeholder, multiSelect, values)\n );\n }, [labels, multiSelect, placeholder, values]);\n\n if (import.meta.env.DEV && virtualized && !height) {\n // eslint-disable-next-line no-console\n console.error(\n \"Dropdown/List in virtualized mode requires a height. Please define it.\"\n );\n }\n\n const dropdownHeaderRef = useRef<HTMLDivElement>();\n\n const {\n ref: refProp,\n dropdownHeaderRef: dropdownHeaderRefProp,\n ...otherBaseDropdownProps\n } = baseDropdownProps;\n const headerForkedRef = useForkRef(\n dropdownHeaderRefProp,\n dropdownHeaderRef\n );\n\n const dropdownForkedRef = useForkRef(ref, refProp);\n\n const handleToggle: HvBaseDropdownProps[\"onToggle\"] = (event, open) => {\n onToggle?.(event, open);\n\n setIsOpen(open);\n\n if (!open) {\n // also run built-in validation when closing without changes\n // as the user \"touched\" the input\n setValidationState(() => {\n // this will only run if status is uncontrolled\n if (required) {\n const hasSelection = getSelected(internalValues).length > 0;\n\n if (!hasSelection) {\n return \"invalid\";\n }\n }\n\n return \"valid\";\n });\n }\n };\n\n /** Applies the selected values to the state */\n const handleSelection: HvDropdownListProps[\"onChange\"] = (\n listValues,\n commitChanges,\n toggle,\n notifyChanges = true\n ) => {\n const selected = getSelected(listValues);\n\n if (commitChanges) {\n setInternalValues(listValues);\n setSelectionLabel(\n getSelectionLabel(labels, placeholder, multiSelect, listValues)\n );\n\n setValidationState(() => {\n // this will only run if status is uncontrolled\n if (required && selected.length === 0) {\n return \"invalid\";\n }\n\n return \"valid\";\n });\n }\n if (notifyChanges) onChange?.(multiSelect ? selected : selected[0]);\n if (toggle) {\n handleToggle(undefined as any, false);\n\n // focus-ring won't be visible even if using the keyboard:\n // https://github.com/WICG/focus-visible/issues/88\n dropdownHeaderRef.current?.focus({ preventScroll: true });\n }\n };\n\n /**\n * Handles the `Cancel` action. Both single and ranged modes are handled here.\n */\n const handleCancel: HvDropdownListProps[\"onCancel\"] = (evt) => {\n onCancel?.(evt as any);\n\n handleToggle(evt as any, false);\n\n // focus-ring won't be visible even if using the keyboard:\n // https://github.com/WICG/focus-visible/issues/88\n dropdownHeaderRef.current?.focus({ preventScroll: true });\n };\n\n const handleClickOutside: HvBaseDropdownProps[\"onClickOutside\"] = (evt) => {\n onClickOutside?.(evt);\n onCancel?.(evt);\n };\n\n const setFocusToContent: HvBaseDropdownProps[\"onContainerCreation\"] = (\n containerRef\n ) => {\n const inputs = containerRef?.getElementsByTagName(\"input\");\n if (inputs && inputs.length > 0) {\n inputs[0].focus();\n return;\n }\n const listItems =\n containerRef != null\n ? [...containerRef.getElementsByTagName(\"li\")]\n : [];\n listItems.every((listItem) => {\n if (listItem.tabIndex >= 0) {\n listItem.focus();\n return false;\n }\n return true;\n });\n };\n\n const buildHeaderLabel = () => {\n const hasSelection = getSelected(internalValues).length > 0;\n return labels?.select || !multiSelect ? (\n <HvTypography\n component=\"div\"\n variant=\"body\"\n className={cx(classes.placeholder, {\n [classes.selectionDisabled]: disabled,\n [classes.placeholderClosed]: !(isOpen || hasSelection),\n })}\n >\n {selectionLabel.selected}\n </HvTypography>\n ) : (\n <HvTypography\n component=\"div\"\n className={cx(classes.placeholder, {\n [classes.selectionDisabled]: disabled,\n })}\n variant=\"body\"\n >\n <b>{selectionLabel.selected}</b>\n {` ${labels?.multiSelectionConjunction} ${selectionLabel.total}`}\n </HvTypography>\n );\n };\n\n const hasLabel = label != null;\n const hasDescription = description != null;\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;\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 readOnly={readOnly}\n required={required}\n className={cx(\n classes.root,\n {\n [classes.disabled]: disabled,\n },\n className\n )}\n {...others}\n >\n {(hasLabel || hasDescription) && (\n <div className={classes.labelContainer}>\n {hasLabel && (\n <HvLabel\n id={setId(elementId, \"label\")}\n label={label}\n className={classes.label}\n />\n )}\n\n {hasDescription && (\n <HvInfoMessage\n id={setId(elementId, \"description\")}\n className={classes.description}\n >\n {description}\n </HvInfoMessage>\n )}\n </div>\n )}\n <HvBaseDropdown\n ref={dropdownForkedRef}\n id={setId(id, \"dropdown\")}\n classes={{\n root: cx(classes.dropdown, {\n [classes.readOnly]: readOnly,\n }),\n arrow: classes.arrow,\n header: cx(classes.dropdownHeader, {\n [classes.dropdownHeaderInvalid]: isStateInvalid,\n }),\n headerOpen: classes.dropdownHeaderOpen,\n }}\n expanded={isOpen}\n disabled={disabled}\n readOnly={readOnly}\n required={required}\n disablePortal={disablePortal}\n placement={placement}\n popperProps={popperProps}\n placeholder={buildHeaderLabel()}\n onToggle={handleToggle}\n onClickOutside={handleClickOutside}\n onContainerCreation={setFocusToContent}\n role=\"combobox\"\n variableWidth={variableWidth}\n aria-label={ariaLabel}\n aria-labelledby={\n [label && setId(elementId, \"label\"), ariaLabelledBy]\n .join(\" \")\n .trim() || undefined\n }\n aria-invalid={isStateInvalid ? true : undefined}\n aria-errormessage={errorMessageId}\n aria-describedby={\n [description && setId(elementId, \"description\"), ariaDescribedBy]\n .join(\" \")\n .trim() || undefined\n }\n onFocus={onFocus}\n onBlur={onBlur}\n dropdownHeaderRef={headerForkedRef}\n {...otherBaseDropdownProps}\n >\n <HvDropdownList\n id={setId(elementId, \"values\")}\n classes={{\n rootList: classes.rootList,\n dropdownListContainer: classes.dropdownListContainer,\n }}\n values={internalValues}\n multiSelect={multiSelect}\n showSearch={showSearch}\n onChange={handleSelection}\n onCancel={handleCancel}\n labels={labels}\n notifyChangesOnFirstRender={notifyChangesOnFirstRender}\n hasTooltips={hasTooltips}\n singleSelectionToggle={singleSelectionToggle}\n aria-label={ariaLabel}\n aria-labelledby={hasLabel ? setId(elementId, \"label\") : undefined}\n height={height}\n maxHeight={maxHeight}\n virtualized={virtualized}\n {...listProps}\n />\n </HvBaseDropdown>\n {canShowError && (\n <HvWarningText\n id={setId(elementId, \"error\")}\n disableBorder\n className={classes.error}\n >\n {validationMessage}\n </HvWarningText>\n )}\n </HvFormElement>\n );\n }\n);\n"],"names":["DEFAULT_LABELS","select","undefined","selectAll","cancelLabel","applyLabel","searchPlaceholder","multiSelectionConjunction","HvDropdown","forwardRef","props","ref","classes","classesProp","className","id","name","required","disabled","readOnly","label","ariaLabel","ariaLabelledBy","description","ariaDescribedBy","placeholder","onChange","status","statusMessage","ariaErrorMessage","onCancel","onToggle","onClickOutside","onFocus","onBlur","values","multiSelect","showSearch","expanded","defaultExpanded","notifyChangesOnFirstRender","labels","labelsProp","hasTooltips","disablePortal","singleSelectionToggle","placement","variableWidth","popperProps","height","maxHeight","virtualized","baseDropdownProps","listProps","others","useDefaultProps","cx","useClasses","useLabels","elementId","useUniqueId","validationState","setValidationState","useControlled","validationMessage","isOpen","setIsOpen","Boolean","selectionLabel","setSelectionLabel","useState","getSelectionLabel","internalValues","setInternalValues","useEffect","dropdownHeaderRef","useRef","refProp","dropdownHeaderRefProp","otherBaseDropdownProps","headerForkedRef","useForkRef","dropdownForkedRef","handleToggle","event","open","hasSelection","getSelected","length","handleSelection","listValues","commitChanges","toggle","notifyChanges","selected","current","focus","preventScroll","handleCancel","evt","handleClickOutside","setFocusToContent","containerRef","inputs","getElementsByTagName","listItems","every","listItem","tabIndex","buildHeaderLabel","selectionDisabled","placeholderClosed","total","hasLabel","hasDescription","canShowError","isStateInvalid","isInvalid","errorMessageId","setId","root","labelContainer","dropdown","arrow","header","dropdownHeader","dropdownHeaderInvalid","headerOpen","dropdownHeaderOpen","join","trim","rootList","dropdownListContainer","error"],"mappings":";;;;;;;;;;;;;;;;;;;AAuMA,MAAMA,iBAAwC;AAAA,EAC5CC,QAAQC;AAAAA,EACRC,WAAW;AAAA,EACXC,aAAa;AAAA,EACbC,YAAY;AAAA,EACZC,mBAAmB;AAAA,EACnBC,2BAA2B;AAC7B;AAKO,MAAMC,aAAaC,WACxB,CAACC,OAAOC,QAAQ;AACR,QAAA;AAAA,IACJC,SAASC;AAAAA,IACTC;AAAAA,IAEAC;AAAAA,IACAC;AAAAA,IAEAC,WAAW;AAAA,IACXC,WAAW;AAAA,IACXC,WAAW;AAAA,IAEXC;AAAAA,IACA,cAAcC;AA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IAAAA,GAEtB,UAAU/D,QACV,UACA,UACA,UACA,eACA,WACA,aACA,aAAa4C,iBAAiB,GAC9B,UAAU1B,cACV,gBAAgBiB,oBAChB,qBAAqBC,mBACrB,MAAK,YACL,eACA,cAAYhF,WACZ,mBACE,CAACD,SAASmG,MAAM5D,WAAW,OAAO,GAAGrC,cAAc,EAChD2G,KAAK,GAAG,EACRC,UAAUhI,QAEf,gBAAckH,iBAAiB,OAAOlH,QACtC,qBAAmBoH,gBACnB,oBACE,CAAC/F,eAAegG,MAAM5D,WAAW,aAAa,GAAGnC,eAAe,EAC7DyG,KAAK,GAAG,EACRC,KAAAA,KAAUhI,QAEf,SACA,QACA,mBAAmB8E,iBACnB,GAAID,wBAEJ,UAAA,oBAAC,kBACC,IAAIwC,MAAM5D,WAAW,QAAQ,GAC7B,SAAS;AAAA,MACPwE,UAAUvH,QAAQuH;AAAAA,MAClBC,uBAAuBxH,QAAQwH;AAAAA,IACjC,GACA,QAAQ5D,gBACR,aACA,YACA,UAAUiB,iBACV,UAAUS,cACV,QACA,4BACA,aACA,uBACA,cAAY7E,WACZ,mBAAiB4F,WAAWM,MAAM5D,WAAW,OAAO,IAAIzD,QACxD,QACA,WACA,aACImD,GAAAA,UAAAA,CAAU,EAElB,CAAA;AAAA,IACC8D,gBACC,oBAAC,eACC,EAAA,IAAII,MAAM5D,WAAW,OAAO,GAC5B,eAAa,MACb,WAAW/C,QAAQyH,OAElBrE,UACH,mBAAA;AAAA,EAEJ,EAAA,CAAA;AAEJ,CACF;"}
@@ -23,6 +23,7 @@ const HvOverflowTooltip = (props) => {
23
23
  cx
24
24
  } = useClasses(classesProp);
25
25
  const {
26
+ height = 0,
26
27
  width = 0,
27
28
  ref
28
29
  } = useResizeDetector({
@@ -32,9 +33,15 @@ const HvOverflowTooltip = (props) => {
32
33
  },
33
34
  handleHeight: false
34
35
  });
35
- const scrollWidth = ref.current?.scrollWidth || 0;
36
- const isOverflowing = scrollWidth - width >= 1;
37
36
  const isParag = useMemo(() => paragraphOverflow && isParagraph(data?.toString()), [data, paragraphOverflow]);
37
+ const isOverflowing = useMemo(() => {
38
+ if (isParag) {
39
+ const scrollHeight = ref.current?.scrollHeight || 0;
40
+ return scrollHeight - height >= 1;
41
+ }
42
+ const scrollWidth = ref.current?.scrollWidth || 0;
43
+ return scrollWidth - width >= 1;
44
+ }, [height, isParag, ref, width]);
38
45
  const content = useMemo(() => /* @__PURE__ */ jsx("div", { ref, className: cx({
39
46
  [classes.tooltipAnchor]: !isParag,
40
47
  [classes.tooltipAnchorParagraph]: isParag
@@ -1 +1 @@
1
- {"version":3,"file":"OverflowTooltip.js","sources":["../../../../src/components/OverflowTooltip/OverflowTooltip.tsx"],"sourcesContent":["import { useMemo } from \"react\";\nimport { useResizeDetector } from \"react-resize-detector\";\n\nimport { useDefaultProps } from \"@core/hooks/useDefaultProps\";\nimport { HvBaseProps } from \"@core/types/generic\";\nimport { HvTooltip, HvTooltipProps } from \"@core/components/Tooltip\";\nimport { HvTypography } from \"@core/components/Typography\";\nimport { ExtractNames } from \"@core/utils/classes\";\n\nimport { staticClasses, useClasses } from \"./OverflowTooltip.styles\";\n\nexport { staticClasses as overflowTooltipClasses };\nexport type HvOverflowTooltipClasses = ExtractNames<typeof useClasses>;\n\nexport interface HvOverflowTooltipProps extends HvBaseProps {\n /** The node that will be rendered inside the tooltip. */\n data: React.ReactNode;\n /** If true, the tooltip is shown. */\n open?: boolean;\n /** If `true` the overflow tooltip will always use the paragraph overflow style. */\n paragraphOverflow?: boolean;\n /** Tooltip placement. */\n placement?:\n | \"bottom-end\"\n | \"bottom-start\"\n | \"bottom\"\n | \"left-end\"\n | \"left-start\"\n | \"left\"\n | \"right-end\"\n | \"right-start\"\n | \"right\"\n | \"top-end\"\n | \"top-start\"\n | \"top\";\n /** Extra properties to add to the tooltip. */\n tooltipsProps?: Partial<HvTooltipProps>;\n /** A Jss Object used to override or extend the styles applied to the component. */\n classes?: HvOverflowTooltipClasses;\n}\n\nconst isParagraph = (children = \"\") => /\\s/.test(children);\n\n/**\n * This component generates a tooltip whenever the text is overflowed.\n */\nexport const HvOverflowTooltip = (props: HvOverflowTooltipProps) => {\n const {\n id,\n classes: classesProp,\n className,\n data,\n open,\n paragraphOverflow,\n placement = \"top-start\",\n tooltipsProps,\n } = useDefaultProps(\"HvOverflowTooltip\", props);\n const { classes, cx } = useClasses(classesProp);\n\n const { width = 0, ref } = useResizeDetector({\n refreshMode: \"debounce\",\n refreshOptions: {\n trailing: true,\n },\n handleHeight: false,\n });\n const scrollWidth = ref.current?.scrollWidth || 0;\n // The difference should be higher than a pixel to be considered as overflowing\n const isOverflowing = scrollWidth - width >= 1;\n\n const isParag = useMemo(\n () => paragraphOverflow && isParagraph(data?.toString()),\n [data, paragraphOverflow]\n );\n\n const content = useMemo(\n () => (\n <div\n ref={ref}\n className={cx(\n {\n [classes.tooltipAnchor]: !isParag,\n [classes.tooltipAnchorParagraph]: isParag,\n },\n className\n )}\n >\n {data}\n </div>\n ),\n [\n className,\n classes.tooltipAnchor,\n classes.tooltipAnchorParagraph,\n cx,\n data,\n isParag,\n ref,\n ]\n );\n\n return (\n <HvTooltip\n id={id}\n disableHoverListener={!isOverflowing}\n open={open}\n placement={placement}\n title={\n <HvTypography className={classes.tooltipData} variant=\"body\">\n {data}\n </HvTypography>\n }\n // unset since `content` *is* the label\n aria-label={null as any}\n aria-labelledby={null as any}\n {...tooltipsProps}\n >\n {content}\n </HvTooltip>\n );\n};\n"],"names":["isParagraph","children","test","HvOverflowTooltip","props","id","classes","classesProp","className","data","open","paragraphOverflow","placement","tooltipsProps","useDefaultProps","cx","useClasses","width","ref","useResizeDetector","refreshMode","refreshOptions","trailing","handleHeight","scrollWidth","current","isOverflowing","isParag","useMemo","toString","content","tooltipAnchor","tooltipAnchorParagraph","tooltipData"],"mappings":";;;;;;;;AAyCA,MAAMA,cAAcA,CAACC,WAAW,OAAO,KAAKC,KAAKD,QAAQ;AAK5CE,MAAAA,oBAAoBA,CAACC,UAAkC;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../../src/components/OverflowTooltip/OverflowTooltip.tsx"],"sourcesContent":["import { useMemo } from \"react\";\nimport { useResizeDetector } from \"react-resize-detector\";\n\nimport { useDefaultProps } from \"@core/hooks/useDefaultProps\";\nimport { HvBaseProps } from \"@core/types/generic\";\nimport { HvTooltip, HvTooltipProps } from \"@core/components/Tooltip\";\nimport { HvTypography } from \"@core/components/Typography\";\nimport { ExtractNames } from \"@core/utils/classes\";\n\nimport { staticClasses, useClasses } from \"./OverflowTooltip.styles\";\n\nexport { staticClasses as overflowTooltipClasses };\nexport type HvOverflowTooltipClasses = ExtractNames<typeof useClasses>;\n\nexport interface HvOverflowTooltipProps extends HvBaseProps {\n /** The node that will be rendered inside the tooltip. */\n data: React.ReactNode;\n /** If true, the tooltip is shown. */\n open?: boolean;\n /** If `true`, the overflow tooltip will always use the paragraph overflow style. */\n paragraphOverflow?: boolean;\n /** Tooltip placement. */\n placement?:\n | \"bottom-end\"\n | \"bottom-start\"\n | \"bottom\"\n | \"left-end\"\n | \"left-start\"\n | \"left\"\n | \"right-end\"\n | \"right-start\"\n | \"right\"\n | \"top-end\"\n | \"top-start\"\n | \"top\";\n /** Extra properties to add to the tooltip. */\n tooltipsProps?: Partial<HvTooltipProps>;\n /** A Jss Object used to override or extend the styles applied to the component. */\n classes?: HvOverflowTooltipClasses;\n}\n\nconst isParagraph = (children = \"\") => /\\s/.test(children);\n\n/**\n * This component generates a tooltip whenever the text is overflowed.\n */\nexport const HvOverflowTooltip = (props: HvOverflowTooltipProps) => {\n const {\n id,\n classes: classesProp,\n className,\n data,\n open,\n paragraphOverflow,\n placement = \"top-start\",\n tooltipsProps,\n } = useDefaultProps(\"HvOverflowTooltip\", props);\n\n const { classes, cx } = useClasses(classesProp);\n\n const {\n height = 0,\n width = 0,\n ref,\n } = useResizeDetector({\n refreshMode: \"debounce\",\n refreshOptions: {\n trailing: true,\n },\n handleHeight: false,\n });\n\n const isParag = useMemo(\n () => paragraphOverflow && isParagraph(data?.toString()),\n [data, paragraphOverflow]\n );\n\n // The difference should be higher than a pixel to be considered as overflowing\n const isOverflowing = useMemo(() => {\n if (isParag) {\n const scrollHeight = ref.current?.scrollHeight || 0;\n\n return scrollHeight - height >= 1;\n }\n\n const scrollWidth = ref.current?.scrollWidth || 0;\n\n return scrollWidth - width >= 1;\n }, [height, isParag, ref, width]);\n\n const content = useMemo(\n () => (\n <div\n ref={ref}\n className={cx(\n {\n [classes.tooltipAnchor]: !isParag,\n [classes.tooltipAnchorParagraph]: isParag,\n },\n className\n )}\n >\n {data}\n </div>\n ),\n [\n className,\n classes.tooltipAnchor,\n classes.tooltipAnchorParagraph,\n cx,\n data,\n isParag,\n ref,\n ]\n );\n\n return (\n <HvTooltip\n id={id}\n disableHoverListener={!isOverflowing}\n open={open}\n placement={placement}\n title={\n <HvTypography className={classes.tooltipData} variant=\"body\">\n {data}\n </HvTypography>\n }\n // unset since `content` *is* the label\n aria-label={null as any}\n aria-labelledby={null as any}\n {...tooltipsProps}\n >\n {content}\n </HvTooltip>\n );\n};\n"],"names":["isParagraph","children","test","HvOverflowTooltip","props","id","classes","classesProp","className","data","open","paragraphOverflow","placement","tooltipsProps","useDefaultProps","cx","useClasses","height","width","ref","useResizeDetector","refreshMode","refreshOptions","trailing","handleHeight","isParag","useMemo","toString","isOverflowing","scrollHeight","current","scrollWidth","content","tooltipAnchor","tooltipAnchorParagraph","tooltipData"],"mappings":";;;;;;;;AAyCA,MAAMA,cAAcA,CAACC,WAAW,OAAO,KAAKC,KAAKD,QAAQ;AAK5CE,MAAAA,oBAAoBA,CAACC,UAAkC;AAC5D,QAAA;AAAA,IACJC;AAAAA,IACAC,SAASC;AAAAA,IACTC;AAAAA,IACAC;AAAAA,IACAC;AAAAA,IACAC;AAAAA,IACAC,YAAY;AAAA,IACZC;AAAAA,EAAAA,IACEC,gBAAgB,qBAAqBV,KAAK;AAExC,QAAA;AAAA,IAAEE;AAAAA,IAASS;AAAAA,EAAAA,IAAOC,WAAWT,WAAW;AAExC,QAAA;AAAA,IACJU,SAAS;AAAA,IACTC,QAAQ;AAAA,IACRC;AAAAA,MACEC,kBAAkB;AAAA,IACpBC,aAAa;AAAA,IACbC,gBAAgB;AAAA,MACdC,UAAU;AAAA,IACZ;AAAA,IACAC,cAAc;AAAA,EAAA,CACf;AAED,QAAMC,UAAUC,QACd,MAAMf,qBAAqBX,YAAYS,MAAMkB,SAAS,CAAC,GACvD,CAAClB,MAAME,iBAAiB,CAC1B;AAGMiB,QAAAA,gBAAgBF,QAAQ,MAAM;AAClC,QAAID,SAAS;AACLI,YAAAA,eAAeV,IAAIW,SAASD,gBAAgB;AAElD,aAAOA,eAAeZ,UAAU;AAAA,IAClC;AAEMc,UAAAA,cAAcZ,IAAIW,SAASC,eAAe;AAEhD,WAAOA,cAAcb,SAAS;AAAA,KAC7B,CAACD,QAAQQ,SAASN,KAAKD,KAAK,CAAC;AAEhC,QAAMc,UAAUN,QACd,0BACG,OACC,EAAA,KACA,WAAWX,GACT;AAAA,IACE,CAACT,QAAQ2B,aAAa,GAAG,CAACR;AAAAA,IAC1B,CAACnB,QAAQ4B,sBAAsB,GAAGT;AAAAA,EAAAA,GAEpCjB,SACF,GAECC,UAAAA,KAAAA,CACH,GAEF,CACED,WACAF,QAAQ2B,eACR3B,QAAQ4B,wBACRnB,IACAN,MACAgB,SACAN,GAAG,CAEP;AAGE,SAAA;AAAA,IAAC;AAAA,IAAA;AAAA,MACC;AAAA,MACA,sBAAsB,CAACS;AAAAA,MACvB;AAAA,MACA;AAAA,MACA,2BACG,cAAa,EAAA,WAAWtB,QAAQ6B,aAAa,SAAQ,QACnD1B,UACH,KAAA,CAAA;AAAA,MAGF,cAAY;AAAA,MACZ,mBAAiB;AAAA,MACjB,GAAII;AAAAA,MAEHmB,UAAAA;AAAAA,IAAAA;AAAAA,EAAAA;AAGP;"}
@@ -12,8 +12,8 @@ const {
12
12
  tooltipAnchorParagraph: {
13
13
  overflow: "hidden",
14
14
  display: "-webkit-box",
15
- "-webkit-line-clamp": 2,
16
- "-webkit-box-orient": "vertical"
15
+ WebkitLineClamp: 3,
16
+ WebkitBoxOrient: "vertical"
17
17
  }
18
18
  });
19
19
  export {
@@ -1 +1 @@
1
- {"version":3,"file":"OverflowTooltip.styles.js","sources":["../../../../src/components/OverflowTooltip/OverflowTooltip.styles.tsx"],"sourcesContent":["import { createClasses } from \"@core/utils/classes\";\n\nexport const { staticClasses, useClasses } = createClasses(\n \"HvOverflowTooltip\",\n {\n tooltipData: {},\n tooltipAnchor: {\n whiteSpace: \"nowrap\",\n overflow: \"hidden\",\n textOverflow: \"ellipsis\",\n },\n tooltipAnchorParagraph: {\n overflow: \"hidden\",\n display: \"-webkit-box\",\n \"-webkit-line-clamp\": 2,\n \"-webkit-box-orient\": \"vertical\",\n },\n }\n);\n"],"names":["staticClasses","useClasses","createClasses","tooltipData","tooltipAnchor","whiteSpace","overflow","textOverflow","tooltipAnchorParagraph","display"],"mappings":";AAEa,MAAA;AAAA,EAAEA;AAAAA,EAAeC;AAAW,IAAIC,cAC3C,qBACA;AAAA,EACEC,aAAa,CAAC;AAAA,EACdC,eAAe;AAAA,IACbC,YAAY;AAAA,IACZC,UAAU;AAAA,IACVC,cAAc;AAAA,EAChB;AAAA,EACAC,wBAAwB;AAAA,IACtBF,UAAU;AAAA,IACVG,SAAS;AAAA,IACT,sBAAsB;AAAA,IACtB,sBAAsB;AAAA,EACxB;AACF,CACF;"}
1
+ {"version":3,"file":"OverflowTooltip.styles.js","sources":["../../../../src/components/OverflowTooltip/OverflowTooltip.styles.tsx"],"sourcesContent":["import { createClasses } from \"@core/utils/classes\";\n\nexport const { staticClasses, useClasses } = createClasses(\n \"HvOverflowTooltip\",\n {\n tooltipData: {},\n tooltipAnchor: {\n whiteSpace: \"nowrap\",\n overflow: \"hidden\",\n textOverflow: \"ellipsis\",\n },\n tooltipAnchorParagraph: {\n overflow: \"hidden\",\n display: \"-webkit-box\",\n WebkitLineClamp: 3,\n WebkitBoxOrient: \"vertical\",\n },\n }\n);\n"],"names":["staticClasses","useClasses","createClasses","tooltipData","tooltipAnchor","whiteSpace","overflow","textOverflow","tooltipAnchorParagraph","display","WebkitLineClamp","WebkitBoxOrient"],"mappings":";AAEa,MAAA;AAAA,EAAEA;AAAAA,EAAeC;AAAW,IAAIC,cAC3C,qBACA;AAAA,EACEC,aAAa,CAAC;AAAA,EACdC,eAAe;AAAA,IACbC,YAAY;AAAA,IACZC,UAAU;AAAA,IACVC,cAAc;AAAA,EAChB;AAAA,EACAC,wBAAwB;AAAA,IACtBF,UAAU;AAAA,IACVG,SAAS;AAAA,IACTC,iBAAiB;AAAA,IACjBC,iBAAiB;AAAA,EACnB;AACF,CACF;"}
@@ -1,5 +1,5 @@
1
1
  import { jsx } from "@emotion/react/jsx-runtime";
2
- import { forwardRef, useContext, useState, useEffect } from "react";
2
+ import { forwardRef, useContext, useMemo } from "react";
3
3
  import capitalize from "lodash/capitalize";
4
4
  import { theme } from "@hitachivantara/uikit-styles";
5
5
  import { checkValidHexColorValue } from "../../../utils/checkValidHexColorValue.js";
@@ -45,16 +45,13 @@ const HvTableCell = forwardRef((props, externalRef) => {
45
45
  } = useTheme();
46
46
  const tableContext = useContext(TableContext);
47
47
  const tableSectionContext = useContext(TableSectionContext);
48
- const [sortedColorValue, setSortedColorValue] = useState();
49
- const [sortedColorAlpha, setSortedColorAlpha] = useState();
50
48
  const type = typeProp || tableSectionContext?.type || "body";
51
49
  const Component = component || tableContext?.components?.Td || defaultComponent;
52
- const [sortedColor, setSortedColor] = useState(getSortedColor(sortedColorValue, sortedColorAlpha));
53
- useEffect(() => {
54
- setSortedColorValue(getVarValue(theme.table.rowSortedColor, rootId));
55
- setSortedColorAlpha(getVarValue(theme.table.rowSortedColorAlpha, rootId));
56
- setSortedColor(getSortedColor(sortedColorValue, sortedColorAlpha));
57
- }, [colors, sortedColorValue, sortedColorAlpha, rootId]);
50
+ const sortedColor = useMemo(() => {
51
+ const color = getVarValue(theme.table.rowSortedColor, rootId) || colors?.primary_20;
52
+ const alpha = getVarValue(theme.table.rowSortedColorAlpha, rootId) || "0.1";
53
+ return getSortedColor(color, alpha);
54
+ }, [colors, rootId]);
58
55
  return /* @__PURE__ */ jsx(Component, { ref: externalRef, role: Component === defaultComponent ? null : "cell", style, className: cx(classes.root, classes[type], type === "body" && css({
59
56
  [`&.${staticClasses.sorted}`]: {
60
57
  backgroundColor: sortedColor
@@ -1 +1 @@
1
- {"version":3,"file":"TableCell.js","sources":["../../../../../src/components/Table/TableCell/TableCell.tsx"],"sourcesContent":["import {\n CSSProperties,\n forwardRef,\n TdHTMLAttributes,\n useContext,\n useEffect,\n useState,\n} from \"react\";\nimport capitalize from \"lodash/capitalize\";\n\nimport { theme } from \"@hitachivantara/uikit-styles\";\n\nimport { checkValidHexColorValue } from \"@core/utils/checkValidHexColorValue\";\nimport { ExtractNames } from \"@core/utils/classes\";\nimport { getVarValue } from \"@core/utils/theme\";\nimport { hexToRgbA } from \"@core/utils/hexToRgbA\";\nimport { useTheme } from \"@core/hooks/useTheme\";\n\nimport { useDefaultProps } from \"@core/hooks\";\n\nimport {\n HvTableCellAlign,\n HvTableCellType,\n HvTableCellVariant,\n} from \"../Table\";\nimport TableContext from \"../TableContext\";\nimport TableSectionContext from \"../TableSectionContext\";\nimport { staticClasses, useClasses } from \"./TableCell.styles\";\n\nexport { staticClasses as tableCellClasses };\n\nexport type HvTableCellClasses = ExtractNames<typeof useClasses>;\n\nexport interface HvTableCellProps\n extends Omit<TdHTMLAttributes<HTMLTableCellElement>, \"align\"> {\n /** The component used for the root node. Either a string to use a HTML element or a component. Defaults to td. */\n component?: React.ElementType;\n /** Content to be rendered */\n children?: React.ReactNode;\n /** Inline styles to be applied to the root element. */\n style?: CSSProperties;\n /** Set the text-align on the table cell content. */\n align?: HvTableCellAlign;\n /** Sets the cell's variant. */\n variant?: HvTableCellVariant | \"listcheckbox\" | \"listactions\";\n /** Specify the cell's type. The prop defaults to the value inherited from the parent TableHead, TableBody, or TableFooter components. */\n type?: HvTableCellType;\n /** Whether or not the cell is part of a sorted column. */\n sorted?: boolean;\n /** The cell is part of a sticky column. */\n stickyColumn?: boolean;\n /** The cell is part of the last sticky to the left column. */\n stickyColumnMostLeft?: boolean;\n /** The cell is part of the first sticky to the right column. */\n stickyColumnLeastRight?: boolean;\n /** The cell is part of the first column in the group. */\n groupColumnMostLeft?: boolean;\n /** The cell is part of the last column in the group. */\n groupColumnMostRight?: boolean;\n /** Whether or not the cell is resizable */\n resizable?: boolean;\n /** Whether or not the cell is being resized */\n resizing?: boolean;\n /** A Jss Object used to override or extend the styles applied to the component. */\n classes?: HvTableCellClasses;\n}\n\nconst defaultComponent = \"td\";\n\nconst getSortedColor = (color?: string, alpha?: string) => {\n return checkValidHexColorValue(color) && alpha\n ? hexToRgbA(color, parseFloat(alpha))\n : color;\n};\n\n/**\n * `HvTableCell` acts as a `td` element and inherits styles from its context\n */\nexport const HvTableCell = forwardRef<HTMLElement, HvTableCellProps>(\n (props, externalRef) => {\n const {\n children,\n component,\n className,\n style,\n classes: classesProp,\n align = \"inherit\",\n variant = \"default\",\n type: typeProp,\n stickyColumn = false,\n stickyColumnMostLeft = false,\n stickyColumnLeastRight = false,\n groupColumnMostLeft = false,\n groupColumnMostRight = false,\n sorted = false,\n resizable = false,\n resizing = false,\n ...others\n } = useDefaultProps(\"HvTableCell\", props);\n const { classes, cx, css } = useClasses(classesProp);\n const { colors, rootId } = useTheme();\n const tableContext = useContext(TableContext);\n const tableSectionContext = useContext(TableSectionContext);\n\n const [sortedColorValue, setSortedColorValue] = useState<string>();\n const [sortedColorAlpha, setSortedColorAlpha] = useState<string>();\n\n const type = typeProp || tableSectionContext?.type || \"body\";\n\n const Component =\n component || tableContext?.components?.Td || defaultComponent;\n\n const [sortedColor, setSortedColor] = useState(\n getSortedColor(sortedColorValue, sortedColorAlpha)\n );\n\n useEffect(() => {\n setSortedColorValue(getVarValue(theme.table.rowSortedColor, rootId));\n setSortedColorAlpha(getVarValue(theme.table.rowSortedColorAlpha, rootId));\n\n setSortedColor(getSortedColor(sortedColorValue, sortedColorAlpha));\n }, [colors, sortedColorValue, sortedColorAlpha, rootId]);\n\n return (\n <Component\n ref={externalRef}\n role={Component === defaultComponent ? null : \"cell\"}\n style={style}\n className={cx(\n classes.root,\n classes[type],\n type === \"body\" &&\n css({\n [`&.${staticClasses.sorted}`]: {\n backgroundColor: sortedColor,\n },\n }),\n stickyColumn &&\n css({\n [`&.${staticClasses.sorted}`]: {\n backgroundImage: `linear-gradient(to right, ${sortedColor}, ${sortedColor})`,\n },\n }),\n {\n [classes[`align${capitalize(align)}`]]: align !== \"inherit\",\n [classes.variantList]: tableContext.variant === \"listrow\",\n [classes.variantListHead]:\n tableContext.variant === \"listrow\" && type !== \"body\",\n [classes[`variant${capitalize(variant)}`]]: variant !== \"default\",\n [classes.sorted]: sorted,\n [classes.stickyColumn]: stickyColumn,\n [classes.stickyColumnMostLeft]: stickyColumnMostLeft,\n [classes.stickyColumnLeastRight]: stickyColumnLeastRight,\n [classes.groupColumnMostLeft]: groupColumnMostLeft,\n [classes.groupColumnMostRight]: groupColumnMostRight,\n [classes.resizable]: resizable,\n [classes.resizing]: resizing,\n },\n className\n )}\n {...others}\n >\n {children}\n </Component>\n );\n }\n);\n"],"names":["defaultComponent","getSortedColor","color","alpha","checkValidHexColorValue","hexToRgbA","parseFloat","HvTableCell","forwardRef","props","externalRef","children","component","className","style","classes","classesProp","align","variant","type","typeProp","stickyColumn","stickyColumnMostLeft","stickyColumnLeastRight","groupColumnMostLeft","groupColumnMostRight","sorted","resizable","resizing","others","useDefaultProps","cx","css","useClasses","colors","rootId","useTheme","tableContext","useContext","TableContext","tableSectionContext","TableSectionContext","sortedColorValue","setSortedColorValue","useState","sortedColorAlpha","setSortedColorAlpha","Component","components","Td","sortedColor","setSortedColor","useEffect","getVarValue","theme","table","rowSortedColor","rowSortedColorAlpha","root","staticClasses","backgroundColor","backgroundImage","capitalize","variantList","variantListHead"],"mappings":";;;;;;;;;;;;AAmEA,MAAMA,m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ableCell/TableCell.tsx"],"sourcesContent":["import {\n CSSProperties,\n forwardRef,\n TdHTMLAttributes,\n useContext,\n useMemo,\n} from \"react\";\nimport capitalize from \"lodash/capitalize\";\nimport { theme } from \"@hitachivantara/uikit-styles\";\n\nimport { checkValidHexColorValue } from \"@core/utils/checkValidHexColorValue\";\nimport { ExtractNames } from \"@core/utils/classes\";\nimport { getVarValue } from \"@core/utils/theme\";\nimport { hexToRgbA } from \"@core/utils/hexToRgbA\";\nimport { useTheme } from \"@core/hooks/useTheme\";\nimport { useDefaultProps } from \"@core/hooks\";\n\nimport {\n HvTableCellAlign,\n HvTableCellType,\n HvTableCellVariant,\n} from \"../Table\";\nimport TableContext from \"../TableContext\";\nimport TableSectionContext from \"../TableSectionContext\";\nimport { staticClasses, useClasses } from \"./TableCell.styles\";\n\nexport { staticClasses as tableCellClasses };\n\nexport type HvTableCellClasses = ExtractNames<typeof useClasses>;\n\nexport interface HvTableCellProps\n extends Omit<TdHTMLAttributes<HTMLTableCellElement>, \"align\"> {\n /** The component used for the root node. Either a string to use a HTML element or a component. Defaults to td. */\n component?: React.ElementType;\n /** Content to be rendered */\n children?: React.ReactNode;\n /** Inline styles to be applied to the root element. */\n style?: CSSProperties;\n /** Set the text-align on the table cell content. */\n align?: HvTableCellAlign;\n /** Sets the cell's variant. */\n variant?: HvTableCellVariant | \"listcheckbox\" | \"listactions\";\n /** Specify the cell's type. The prop defaults to the value inherited from the parent TableHead, TableBody, or TableFooter components. */\n type?: HvTableCellType;\n /** Whether or not the cell is part of a sorted column. */\n sorted?: boolean;\n /** The cell is part of a sticky column. */\n stickyColumn?: boolean;\n /** The cell is part of the last sticky to the left column. */\n stickyColumnMostLeft?: boolean;\n /** The cell is part of the first sticky to the right column. */\n stickyColumnLeastRight?: boolean;\n /** The cell is part of the first column in the group. */\n groupColumnMostLeft?: boolean;\n /** The cell is part of the last column in the group. */\n groupColumnMostRight?: boolean;\n /** Whether or not the cell is resizable */\n resizable?: boolean;\n /** Whether or not the cell is being resized */\n resizing?: boolean;\n /** A Jss Object used to override or extend the styles applied to the component. */\n classes?: HvTableCellClasses;\n}\n\nconst defaultComponent = \"td\";\n\nconst getSortedColor = (color?: string, alpha?: string) => {\n return checkValidHexColorValue(color) && alpha\n ? hexToRgbA(color, parseFloat(alpha))\n : color;\n};\n\n/**\n * `HvTableCell` acts as a `td` element and inherits styles from its context\n */\nexport const HvTableCell = forwardRef<HTMLElement, HvTableCellProps>(\n (props, externalRef) => {\n const {\n children,\n component,\n className,\n style,\n classes: classesProp,\n align = \"inherit\",\n variant = \"default\",\n type: typeProp,\n stickyColumn = false,\n stickyColumnMostLeft = false,\n stickyColumnLeastRight = false,\n groupColumnMostLeft = false,\n groupColumnMostRight = false,\n sorted = false,\n resizable = false,\n resizing = false,\n ...others\n } = useDefaultProps(\"HvTableCell\", props);\n const { classes, cx, css } = useClasses(classesProp);\n const { colors, rootId } = useTheme();\n const tableContext = useContext(TableContext);\n const tableSectionContext = useContext(TableSectionContext);\n\n const type = typeProp || tableSectionContext?.type || \"body\";\n\n const Component =\n component || tableContext?.components?.Td || defaultComponent;\n\n const sortedColor = useMemo(() => {\n // \"colors\" makes the \"sortedColor\" change with the color mode and theme\n const color =\n getVarValue(theme.table.rowSortedColor, rootId) || colors?.primary_20;\n const alpha =\n getVarValue(theme.table.rowSortedColorAlpha, rootId) || \"0.1\";\n\n return getSortedColor(color, alpha);\n }, [colors, rootId]);\n\n return (\n <Component\n ref={externalRef}\n role={Component === defaultComponent ? null : \"cell\"}\n style={style}\n className={cx(\n classes.root,\n classes[type],\n type === \"body\" &&\n css({\n [`&.${staticClasses.sorted}`]: {\n backgroundColor: sortedColor,\n },\n }),\n stickyColumn &&\n css({\n [`&.${staticClasses.sorted}`]: {\n backgroundImage: `linear-gradient(to right, ${sortedColor}, ${sortedColor})`,\n },\n }),\n {\n [classes[`align${capitalize(align)}`]]: align !== \"inherit\",\n [classes.variantList]: tableContext.variant === \"listrow\",\n [classes.variantListHead]:\n tableContext.variant === \"listrow\" && type !== \"body\",\n [classes[`variant${capitalize(variant)}`]]: variant !== \"default\",\n [classes.sorted]: sorted,\n [classes.stickyColumn]: stickyColumn,\n [classes.stickyColumnMostLeft]: stickyColumnMostLeft,\n [classes.stickyColumnLeastRight]: stickyColumnLeastRight,\n [classes.groupColumnMostLeft]: groupColumnMostLeft,\n [classes.groupColumnMostRight]: groupColumnMostRight,\n [classes.resizable]: resizable,\n [classes.resizing]: resizing,\n },\n className\n )}\n {...others}\n >\n {children}\n </Component>\n );\n }\n);\n"],"names":["defaultComponent","getSortedColor","color","alpha","checkValidHexColorValue","hexToRgbA","parseFloat","HvTableCell","forwardRef","props","externalRef","children","component","className","style","classes","classesProp","align","variant","type","typeProp","stickyColumn","stickyColumnMostLeft","stickyColumnLeastRight","groupColumnMostLeft","groupColumnMostRight","sorted","resizable","resizing","others","useDefaultProps","cx","css","useClasses","colors","rootId","useTheme","tableContext","useContext","TableContext","tableSectionContext","TableSectionContext","Component","components","Td","sortedColor","useMemo","getVarValue","theme","table","rowSortedColor","primary_20","rowSortedColorAlpha","root","staticClasses","backgroundColor","backgroundImage","capitalize","variantList","variantListHead"],"mappings":";;;;;;;;;;;;AAgEA,MAAMA,mBAAmB;AAEzB,MAAMC,iBAAiBA,CAACC,OAAgBC,UAAmB;AAClDC,SAAAA,wBAAwBF,KAAK,KAAKC,QACrCE,UAAUH,OAAOI,WAAWH,KAAK,CAAC,IAClCD;AACN;AAKO,MAAMK,cAAcC,WACzB,CAACC,OAAOC,gBAAgB;AAChB,QAAA;AAAA,IACJC;AAAAA,IACAC;AAAAA,IACAC;AAAAA,IACAC;AAAAA,IACAC,SAASC;AAAAA,IACTC,QAAQ;AAAA,IACRC,UAAU;AAAA,IACVC,MAAMC;AAAAA,IACNC,eAAe;AAAA,IACfC,uBAAuB;AAAA,IACvBC,yBAAyB;AAAA,IACzBC,sBAAsB;AAAA,IACtBC,uBAAuB;AAAA,IACvBC,SAAS;AAAA,IACTC,YAAY;AAAA,I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CAACH,QAAQ4C,eAAe,GACtBtB,aAAanB,YAAY,aAAaC,SAAS;AAAA,IACjD,CAACJ,QAAS,UAAS0C,WAAWvC,OAAO,CAAE,EAAC,CAAC,GAAGA,YAAY;AAAA,IACxD,CAACH,QAAQW,MAAM,GAAGA;AAAAA,IAClB,CAACX,QAAQM,YAAY,GAAGA;AAAAA,IACxB,CAACN,QAAQO,oBAAoB,GAAGA;AAAAA,IAChC,CAACP,QAAQQ,sBAAsB,GAAGA;AAAAA,IAClC,CAACR,QAAQS,mBAAmB,GAAGA;AAAAA,IAC/B,CAACT,QAAQU,oBAAoB,GAAGA;AAAAA,IAChC,CAACV,QAAQY,SAAS,GAAGA;AAAAA,IACrB,CAACZ,QAAQa,QAAQ,GAAGA;AAAAA,EAEtBf,GAAAA,SACF,GACA,GAAIgB,QAEHlB,SACH,CAAA;AAEJ,CACF;"}
@@ -1,9 +1,6 @@
1
1
  import { jsx } from "@emotion/react/jsx-runtime";
2
- import { forwardRef, useContext, useState, useEffect } from "react";
3
- import { theme } from "@hitachivantara/uikit-styles";
4
- import { checkValidHexColorValue } from "../../../utils/checkValidHexColorValue.js";
2
+ import { forwardRef, useContext } from "react";
5
3
  import { hexToRgbA } from "../../../utils/hexToRgbA.js";
6
- import { getVarValue } from "../../../utils/theme.js";
7
4
  import { useTheme } from "../../../hooks/useTheme.js";
8
5
  import TableContext from "../TableContext.js";
9
6
  import TableSectionContext from "../TableSectionContext.js";
@@ -11,9 +8,6 @@ import { useClasses } from "./TableRow.styles.js";
11
8
  import { staticClasses } from "./TableRow.styles.js";
12
9
  import { useDefaultProps } from "../../../hooks/useDefaultProps.js";
13
10
  const defaultComponent = "tr";
14
- const getStripedColor = (color, opacity = 0.6) => {
15
- return checkValidHexColorValue(color) ? hexToRgbA(color, opacity) : color;
16
- };
17
11
  const HvTableRow = forwardRef((props, externalRef) => {
18
12
  const {
19
13
  classes: classesProp,
@@ -31,30 +25,19 @@ const HvTableRow = forwardRef((props, externalRef) => {
31
25
  css
32
26
  } = useClasses(classesProp);
33
27
  const {
34
- colors,
35
- rootId
28
+ colors
36
29
  } = useTheme();
37
30
  const tableContext = useContext(TableContext);
38
31
  const tableSectionContext = useContext(TableSectionContext);
39
- const [even, setEven] = useState();
40
- const [odd, setOdd] = useState();
41
32
  const type = tableSectionContext?.type || "body";
42
33
  const isList = tableContext.variant === "listrow";
43
34
  const Component = component || tableContext?.components?.Tr || defaultComponent;
44
- const [stripedColorEven, setStripedColorEven] = useState(getStripedColor(even));
45
- const [stripedColorOdd, setStripedColorOdd] = useState(getStripedColor(odd));
46
- useEffect(() => {
47
- setEven(getVarValue(theme.table.rowStripedBackgroundColorEven, rootId));
48
- setOdd(getVarValue(theme.table.rowStripedBackgroundColorOdd, rootId));
49
- setStripedColorEven(getStripedColor(even));
50
- setStripedColorOdd(getStripedColor(odd));
51
- }, [colors, even, odd, rootId]);
52
35
  return /* @__PURE__ */ jsx(Component, { ref: externalRef, className: cx(tableSectionContext.filterClassName, classes.root, classes[type], striped && css({
53
36
  "&:nth-of-type(even)": {
54
- backgroundColor: stripedColorEven
37
+ backgroundColor: hexToRgbA(colors?.atmo1, 0.6)
55
38
  },
56
39
  "&:nth-of-type(odd)": {
57
- backgroundColor: stripedColorOdd
40
+ backgroundColor: "transparent"
58
41
  }
59
42
  }), {
60
43
  [classes.hover]: hover,
@@ -1 +1 @@
1
- {"version":3,"file":"TableRow.js","sources":["../../../../../src/components/Table/TableRow/TableRow.tsx"],"sourcesContent":["import { forwardRef, useContext, useEffect, useState } from \"react\";\n\nimport { theme } from \"@hitachivantara/uikit-styles\";\n\nimport { ExtractNames } from \"@core/utils/classes\";\nimport { checkValidHexColorValue } from \"@core/utils/checkValidHexColorValue\";\nimport { hexToRgbA } from \"@core/utils/hexToRgbA\";\nimport { getVarValue } from \"@core/utils/theme\";\nimport { HvBaseProps } from \"@core/types/generic\";\nimport { useTheme } from \"@core/hooks/useTheme\";\n\nimport { useDefaultProps } from \"@core/hooks\";\n\nimport TableContext from \"../TableContext\";\nimport TableSectionContext from \"../TableSectionContext\";\nimport { staticClasses, useClasses } from \"./TableRow.styles\";\n\nexport { staticClasses as tableRowClasses };\n\nexport type HvTableRowClasses = ExtractNames<typeof useClasses>;\n\nexport interface HvTableRowProps\n extends HvBaseProps<HTMLTableRowElement, \"children\"> {\n /** Content to be rendered */\n children: React.ReactNode;\n /** The component used for the root node. Either a string to use a HTML element or a component. Defaults to tbody. */\n component?: React.ElementType;\n /** Whether the table row will shade on hover. */\n hover?: boolean;\n /** Whether the table row will have the selected shading. */\n selected?: boolean;\n /** Whether the table row is expanded. */\n expanded?: boolean;\n /** Whether the table row background is striped. */\n striped?: boolean;\n /** A Jss Object used to override or extend the styles applied to the component. */\n classes?: HvTableRowClasses;\n}\n\nconst defaultComponent = \"tr\";\n\nconst getStripedColor = (color?: string, opacity: number = 0.6) => {\n return checkValidHexColorValue(color) ? hexToRgbA(color, opacity) : color;\n};\n\n/**\n * `HvTableRow` acts as a `tr` element and inherits styles from its context\n */\nexport const HvTableRow = forwardRef<HTMLElement, HvTableRowProps>(\n (props, externalRef) => {\n const {\n classes: classesProp,\n className,\n component,\n hover = false,\n selected = false,\n expanded = false,\n striped = false,\n ...others\n } = useDefaultProps(\"HvTableRow\", props);\n const { classes, cx, css } = useClasses(classesProp);\n const { colors, rootId } = useTheme();\n const tableContext = useContext(TableContext);\n const tableSectionContext = useContext(TableSectionContext);\n\n const [even, setEven] = useState<string | undefined>();\n const [odd, setOdd] = useState<string | undefined>();\n\n const type = tableSectionContext?.type || \"body\";\n\n const isList = tableContext.variant === \"listrow\";\n\n const Component =\n component || tableContext?.components?.Tr || defaultComponent;\n\n const [stripedColorEven, setStripedColorEven] = useState(\n getStripedColor(even)\n );\n const [stripedColorOdd, setStripedColorOdd] = useState(\n getStripedColor(odd)\n );\n\n useEffect(() => {\n setEven(getVarValue(theme.table.rowStripedBackgroundColorEven, rootId));\n setOdd(getVarValue(theme.table.rowStripedBackgroundColorOdd, rootId));\n\n setStripedColorEven(getStripedColor(even));\n setStripedColorOdd(getStripedColor(odd));\n }, [colors, even, odd, rootId]);\n\n return (\n <Component\n ref={externalRef}\n className={cx(\n tableSectionContext.filterClassName,\n classes.root,\n classes[type],\n striped &&\n css({\n \"&:nth-of-type(even)\": {\n backgroundColor: stripedColorEven,\n },\n \"&:nth-of-type(odd)\": {\n backgroundColor: stripedColorOdd,\n },\n }),\n {\n [classes.hover]: hover,\n [classes.selected]: selected,\n [classes.expanded]: expanded,\n [classes.striped]: striped,\n [classes.variantList]: isList && type === \"body\",\n [classes.variantListHead]: isList && type === \"head\",\n },\n className\n )}\n role={Component === defaultComponent ? null : \"row\"}\n {...others}\n />\n );\n }\n);\n"],"names":["defaultComponent","getStripedColor","color","opacity","checkValidHexColorValue","hexToRgbA","HvTableRow","forwardRef","props","externalRef","classes","classesProp","className","component","hover","selected","expanded","striped","others","useDefaultProps","cx","css","useClasses","colors","rootId","useTheme","tableContext","useContext","TableContext","tableSectionContext","TableSectionContext","even","setEven","useState","odd","setOdd","type","isList","variant","Component","components","Tr","stripedColorEven","setStripedColorEven","stripedColorOdd","setStripedColorOdd","useEffect","getVarValue","theme","table","rowStripedBackgroundColorEven","rowStripedBackgroundColorOdd","filterClassName","root","backgroundColor","variantList","variantListHead"],"mappings":";;;;;;;;;;;;AAuCA,MAAMA,mBAAmB;AAEzB,MAAMC,kBAAkBA,CAACC,OAAgBC,UAAkB,QAAQ;AACjE,SAAOC,wBAAwBF,KAAK,IAAIG,UAAUH,OAAOC,OAAO,IAAID;AACtE;AAKO,MAAMI,aAAaC,WACxB,CAACC,OAAOC,gBAAgB;AAChB,QAAA;AAAA,IACJC,SAASC;AAAAA,IACTC;AAAAA,IACAC;AAAAA,IACAC,QAAQ;AAAA,IACRC,WAAW;AAAA,IACXC,WAAW;AAAA,IACXC,UAAU;AAAA,IACV,GAAGC;AAAAA,EAAAA,IACDC,gBAAgB,cAAcX,KAAK;AACjC,QAAA;AAAA,IAAEE;AAAAA,IAASU;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QAAQO,OAAO,GAAGA;AAAAA,IACnB,CAACP,QAAQ6C,WAAW,GAAGlB,UAAUD,SAAS;AAAA,IAC1C,CAAC1B,QAAQ8C,eAAe,GAAGnB,UAAUD,SAAS;AAAA,EAAA,GAEhDxB,SACF,GACA,MAAM2B,cAAcvC,mBAAmB,OAAO,OAC1CkB,GAAAA,OACJ,CAAA;AAEN,CACF;"}
1
+ {"version":3,"file":"TableRow.js","sources":["../../../../../src/components/Table/TableRow/TableRow.tsx"],"sourcesContent":["import { forwardRef, useContext } from \"react\";\n\nimport { ExtractNames } from \"@core/utils/classes\";\nimport { hexToRgbA } from \"@core/utils/hexToRgbA\";\nimport { HvBaseProps } from \"@core/types/generic\";\nimport { useTheme } from \"@core/hooks/useTheme\";\nimport { useDefaultProps } from \"@core/hooks\";\n\nimport TableContext from \"../TableContext\";\nimport TableSectionContext from \"../TableSectionContext\";\nimport { staticClasses, useClasses } from \"./TableRow.styles\";\n\nexport { staticClasses as tableRowClasses };\n\nexport type HvTableRowClasses = ExtractNames<typeof useClasses>;\n\nexport interface HvTableRowProps\n extends HvBaseProps<HTMLTableRowElement, \"children\"> {\n /** Content to be rendered */\n children: React.ReactNode;\n /** The component used for the root node. Either a string to use a HTML element or a component. Defaults to tbody. */\n component?: React.ElementType;\n /** Whether the table row will shade on hover. */\n hover?: boolean;\n /** Whether the table row will have the selected shading. */\n selected?: boolean;\n /** Whether the table row is expanded. */\n expanded?: boolean;\n /** Whether the table row background is striped. */\n striped?: boolean;\n /** A Jss Object used to override or extend the styles applied to the component. */\n classes?: HvTableRowClasses;\n}\n\nconst defaultComponent = \"tr\";\n\n/**\n * `HvTableRow` acts as a `tr` element and inherits styles from its context\n */\nexport const HvTableRow = forwardRef<HTMLElement, HvTableRowProps>(\n (props, externalRef) => {\n const {\n classes: classesProp,\n className,\n component,\n hover = false,\n selected = false,\n expanded = false,\n striped = false,\n ...others\n } = useDefaultProps(\"HvTableRow\", props);\n const { classes, cx, css } = useClasses(classesProp);\n const { colors } = useTheme();\n const tableContext = useContext(TableContext);\n const tableSectionContext = useContext(TableSectionContext);\n\n const type = tableSectionContext?.type || \"body\";\n\n const isList = tableContext.variant === \"listrow\";\n\n const Component =\n component || tableContext?.components?.Tr || defaultComponent;\n\n return (\n <Component\n ref={externalRef}\n className={cx(\n tableSectionContext.filterClassName,\n classes.root,\n classes[type],\n striped &&\n css({\n \"&:nth-of-type(even)\": {\n backgroundColor: hexToRgbA(colors?.atmo1, 0.6),\n },\n \"&:nth-of-type(odd)\": {\n backgroundColor: \"transparent\",\n },\n }),\n {\n [classes.hover]: hover,\n [classes.selected]: selected,\n [classes.expanded]: expanded,\n [classes.striped]: striped,\n [classes.variantList]: isList && type === \"body\",\n [classes.variantListHead]: isList && type === \"head\",\n },\n className\n )}\n role={Component === defaultComponent ? null : \"row\"}\n {...others}\n />\n );\n }\n);\n"],"names":["defaultComponent","HvTableRow","forwardRef","props","externalRef","classes","classesProp","className","component","hover","selected","expanded","striped","others","useDefaultProps","cx","css","useClasses","colors","useTheme","tableContext","useContext","TableContext","tableSectionContext","TableSectionContext","type","isList","variant","Component","components","Tr","filterClassName","root","backgroundColor","hexToRgbA","atmo1","variantList","variantListHead"],"mappings":";;;;;;;;;AAkCA,MAAMA,mBAAmB;AAKlB,MAAMC,aAAaC,WACxB,CAACC,OAAOC,gBAAgB;AAChB,QAAA;AAAA,IACJC,SAASC;AAAAA,IACTC;AAAAA,IACAC;AAAAA,IACAC,QAAQ;AAAA,IACRC,WAAW;AAAA,IACXC,WAAW;AAAA,IACXC,UAAU;AAAA,IACV,GAAGC;AAAAA,EAAAA,IACDC,gBAAgB,cAAcX,KAAK;AACjC,QAAA;AAAA,IAAEE;AAAAA,IAASU;AAAAA,IAAIC;AAAAA,EAAAA,IAAQC,WAAWX,WAAW;AAC7C,QAAA;AAAA,IAAEY;AAAAA,MAAWC,SAAS;AACtBC,QAAAA,eAAeC,WAAWC,YAAY;AACtCC,QAAAA,sBAAsBF,WAAWG,mBAAmB;AAEpDC,QAAAA,OAAOF,qBAAqBE,QAAQ;AAEpCC,QAAAA,SAASN,aAAaO,YAAY;AAExC,QAAMC,YACJpB,aAAaY,cAAcS,YAAYC,MAAM9B;AAE/C,SACG,oBAAA,WAAA,EACC,KAAKI,aACL,WAAWW,GACTQ,oBAAoBQ,iBACpB1B,QAAQ2B,MACR3B,QAAQoB,IAAI,GACZb,WACEI,IAAI;AAAA,IACF,uBAAuB;AAAA,MACrBiB,iBAAiBC,UAAUhB,QAAQiB,OAAO,GAAG;AAAA,IAC/C;AAAA,IACA,sBAAsB;AAAA,MACpBF,iBAAiB;AAAA,IACnB;AAAA,EAAA,CACD,GACH;AAAA,IACE,CAAC5B,QAAQI,KAAK,GAAGA;AAAAA,IACjB,CAACJ,QAAQK,QAAQ,GAAGA;AAAAA,IACpB,CAACL,QAAQM,QAAQ,GAAGA;AAAAA,IACpB,CAACN,QAAQO,OAAO,GAAGA;AAAAA,IACnB,CAACP,QAAQ+B,WAAW,GAAGV,UAAUD,SAAS;AAAA,IAC1C,CAACpB,QAAQgC,eAAe,GAAGX,UAAUD,SAAS;AAAA,EAAA,GAEhDlB,SACF,GACA,MAAMqB,cAAc5B,mBAAmB,OAAO,OAC1Ca,GAAAA,OACJ,CAAA;AAEN,CACF;"}
@@ -3,6 +3,7 @@ import { forwardRef } from "react";
3
3
  import { Tooltip, Fade } from "@mui/material";
4
4
  import { useTheme } from "../../hooks/useTheme.js";
5
5
  import { useDefaultProps } from "../../hooks/useDefaultProps.js";
6
+ import { getElementById } from "../../utils/document.js";
6
7
  import { useClasses } from "./Tooltip.styles.js";
7
8
  import { staticClasses } from "./Tooltip.styles.js";
8
9
  const HvTooltip = forwardRef((props, ref) => {
@@ -33,7 +34,7 @@ const HvTooltip = forwardRef((props, ref) => {
33
34
  tooltip: useSingle ? classes.tooltip : classes.tooltipMulti,
34
35
  popper: classes.popper
35
36
  }, title, PopperProps: {
36
- container: typeof window !== "undefined" ? document.getElementById(containerId || rootId || "") || document.body : void 0
37
+ container: getElementById(containerId || rootId)
37
38
  }, ...others, children });
38
39
  });
39
40
  export {
@@ -1 +1 @@
1
- {"version":3,"file":"Tooltip.js","sources":["../../../../src/components/Tooltip/Tooltip.tsx"],"sourcesContent":["import { forwardRef, ReactElement } from \"react\";\nimport { Fade, Tooltip, TooltipProps as MuiTooltipProps } from \"@mui/material\";\n\nimport { useTheme } from \"@core/hooks/useTheme\";\nimport { useDefaultProps } from \"@core/hooks/useDefaultProps\";\nimport { ExtractNames } from \"@core/utils/classes\";\n\nimport { staticClasses, useClasses } from \"./Tooltip.styles\";\n\nexport { staticClasses as tooltipClasses };\n\nexport type HvTooltipClasses = ExtractNames<typeof useClasses>;\nexport type HvTooltipPlacementType = MuiTooltipProps[\"placement\"];\n\nexport interface HvTooltipProps extends Omit<MuiTooltipProps, \"classes\"> {\n /**\n * Class names to be applied.\n */\n className?: string;\n /**\n * A Jss Object used to override or extend the styles applied.\n */\n classes?: HvTooltipClasses;\n /**\n * If true, the tooltip is shown.\n */\n open?: boolean;\n /**\n * Tooltip placement.\n */\n placement?: HvTooltipPlacementType;\n /**\n * The number of milliseconds to wait before showing the tooltip.\n * This property won't impact the enter touch delay (enterTouchDelay).\n */\n enterDelay?: number;\n /** @inheritdoc */\n title: MuiTooltipProps[\"title\"];\n /** @inheritdoc */\n TransitionComponent?: MuiTooltipProps[\"TransitionComponent\"];\n /** @inheritdoc */\n TransitionProps?: MuiTooltipProps[\"TransitionProps\"];\n /**\n * Defines if should use a single or multiline tooltip.\n */\n useSingle?: boolean;\n /**\n * Node to apply the tooltip.\n */\n children: ReactElement;\n /**\n * Id attribute value of an HTML Element to have the tooltip appended to it.\n */\n containerId?: string;\n}\n\n/**\n * Tooltips display informative text when users hover over, focus on, or tap an element.\n * Accessibility-wise, the tooltip automatically labels the `children` content.\n */\nexport const HvTooltip = forwardRef((props: HvTooltipProps, ref) => {\n const {\n className,\n classes: classesProp,\n open,\n enterDelay = 300,\n placement = \"top\",\n useSingle = true,\n children,\n title,\n TransitionComponent = Fade,\n TransitionProps = { timeout: 400, placement },\n containerId,\n ...others\n } = useDefaultProps(\"HvTooltip\", props);\n\n const { rootId } = useTheme();\n const { classes } = useClasses(classesProp);\n\n return (\n <Tooltip\n ref={ref}\n open={open ?? undefined}\n enterDelay={enterDelay}\n placement={placement}\n TransitionComponent={TransitionComponent}\n TransitionProps={TransitionProps}\n className={className}\n classes={{\n tooltip: useSingle ? classes.tooltip : classes.tooltipMulti,\n popper: classes.popper,\n }}\n title={title}\n PopperProps={{\n container:\n typeof window !== \"undefined\"\n ? document.getElementById(containerId || rootId || \"\") ||\n document.body\n : undefined,\n }}\n {...others}\n >\n {children}\n </Tooltip>\n );\n});\n"],"names":["HvTooltip","forwardRef","props","ref","className","classes","classesProp","open","enterDelay","placement","useSingle","children","title","TransitionComponent","Fade","TransitionProps","timeout","containerId","others","useDefaultProps","rootId","useTheme","useClasses","undefined","tooltip","tooltipMulti","popper","container","window","document","getElementById","body"],"mappings":";;;;;;;AA4DO,MAAMA,YAAYC,WAAW,CAACC,OAAuBC,QAAQ;AAC5D,QAAA;AAAA,IACJC;AAAAA,IACAC,SAASC;AAAAA,IACTC;AAAAA,IACAC,aAAa;AAAA,IACbC,YAAY;AAAA,IACZC,YAAY;AAAA,IACZC;AAAAA,IACAC;AAAAA,IACAC,sBAAsBC;AAAAA,IACtBC,kBAAkB;AAAA,MAAEC,SAAS;AAAA,MAAKP;AAAAA,IAAU;AAAA,IAC5CQ;AAAAA,IACA,GAAGC;AAAAA,EAAAA,IACDC,gBAAgB,aAAajB,KAAK;AAEhC,QAAA;AAAA,IAAEkB;AAAAA,MAAWC,SAAS;AACtB,QAAA;AAAA,IAAEhB;AAAAA,EAAAA,IAAYiB,WAAWhB,WAAW;AAGxC,SAAA,oBAAC,SACC,EAAA,KACA,MAAMC,QAAQgB,QACd,YACA,WACA,qBACA,iBACA,WACA,SAAS;AAAA,IACPC,SAASd,YAAYL,QAAQmB,UAAUnB,QAAQoB;AAAAA,IAC/CC,QAAQrB,QAAQqB;AAAAA,EAAAA,GAElB,OACA,aAAa;AAAA,IACXC,WACE,OAAOC,WAAW,cACdC,SAASC,eAAeb,eAAeG,UAAU,EAAE,KACnDS,SAASE,OACTR;AAAAA,EAAAA,GAEJL,GAAAA,QAEHP,SACH,CAAA;AAEJ,CAAC;"}
1
+ {"version":3,"file":"Tooltip.js","sources":["../../../../src/components/Tooltip/Tooltip.tsx"],"sourcesContent":["import { forwardRef, ReactElement } from \"react\";\nimport { Fade, Tooltip, TooltipProps as MuiTooltipProps } from \"@mui/material\";\n\nimport { useTheme } from \"@core/hooks/useTheme\";\nimport { useDefaultProps } from \"@core/hooks/useDefaultProps\";\nimport { getElementById } from \"@core/utils/document\";\nimport { ExtractNames } from \"@core/utils/classes\";\n\nimport { staticClasses, useClasses } from \"./Tooltip.styles\";\n\nexport { staticClasses as tooltipClasses };\n\nexport type HvTooltipClasses = ExtractNames<typeof useClasses>;\nexport type HvTooltipPlacementType = MuiTooltipProps[\"placement\"];\n\nexport interface HvTooltipProps extends Omit<MuiTooltipProps, \"classes\"> {\n /**\n * Class names to be applied.\n */\n className?: string;\n /**\n * A Jss Object used to override or extend the styles applied.\n */\n classes?: HvTooltipClasses;\n /**\n * If true, the tooltip is shown.\n */\n open?: boolean;\n /**\n * Tooltip placement.\n */\n placement?: HvTooltipPlacementType;\n /**\n * The number of milliseconds to wait before showing the tooltip.\n * This property won't impact the enter touch delay (enterTouchDelay).\n */\n enterDelay?: number;\n /** @inheritdoc */\n title: MuiTooltipProps[\"title\"];\n /** @inheritdoc */\n TransitionComponent?: MuiTooltipProps[\"TransitionComponent\"];\n /** @inheritdoc */\n TransitionProps?: MuiTooltipProps[\"TransitionProps\"];\n /**\n * Defines if should use a single or multiline tooltip.\n */\n useSingle?: boolean;\n /**\n * Node to apply the tooltip.\n */\n children: ReactElement;\n /**\n * Id attribute value of an HTML Element to have the tooltip appended to it.\n */\n containerId?: string;\n}\n\n/**\n * Tooltips display informative text when users hover over, focus on, or tap an element.\n * Accessibility-wise, the tooltip automatically labels the `children` content.\n */\nexport const HvTooltip = forwardRef((props: HvTooltipProps, ref) => {\n const {\n className,\n classes: classesProp,\n open,\n enterDelay = 300,\n placement = \"top\",\n useSingle = true,\n children,\n title,\n TransitionComponent = Fade,\n TransitionProps = { timeout: 400, placement },\n containerId,\n ...others\n } = useDefaultProps(\"HvTooltip\", props);\n\n const { rootId } = useTheme();\n const { classes } = useClasses(classesProp);\n\n return (\n <Tooltip\n ref={ref}\n open={open ?? undefined}\n enterDelay={enterDelay}\n placement={placement}\n TransitionComponent={TransitionComponent}\n TransitionProps={TransitionProps}\n className={className}\n classes={{\n tooltip: useSingle ? classes.tooltip : classes.tooltipMulti,\n popper: classes.popper,\n }}\n title={title}\n PopperProps={{\n container: getElementById(containerId || rootId),\n }}\n {...others}\n >\n {children}\n </Tooltip>\n );\n});\n"],"names":["HvTooltip","forwardRef","props","ref","className","classes","classesProp","open","enterDelay","placement","useSingle","children","title","TransitionComponent","Fade","TransitionProps","timeout","containerId","others","useDefaultProps","rootId","useTheme","useClasses","undefined","tooltip","tooltipMulti","popper","container","getElementById"],"mappings":";;;;;;;;AA6DO,MAAMA,YAAYC,WAAW,CAACC,OAAuBC,QAAQ;AAC5D,QAAA;AAAA,IACJC;AAAAA,IACAC,SAASC;AAAAA,IACTC;AAAAA,IACAC,aAAa;AAAA,IACbC,YAAY;AAAA,IACZC,YAAY;AAAA,IACZC;AAAAA,IACAC;AAAAA,IACAC,sBAAsBC;AAAAA,IACtBC,kBAAkB;AAAA,MAAEC,SAAS;AAAA,MAAKP;AAAAA,IAAU;AAAA,IAC5CQ;AAAAA,IACA,GAAGC;AAAAA,EAAAA,IACDC,gBAAgB,aAAajB,KAAK;AAEhC,QAAA;AAAA,IAAEkB;AAAAA,MAAWC,SAAS;AACtB,QAAA;AAAA,IAAEhB;AAAAA,EAAAA,IAAYiB,WAAWhB,WAAW;AAGxC,SAAA,oBAAC,SACC,EAAA,KACA,MAAMC,QAAQgB,QACd,YACA,WACA,qBACA,iBACA,WACA,SAAS;AAAA,IACPC,SAASd,YAAYL,QAAQmB,UAAUnB,QAAQoB;AAAAA,IAC/CC,QAAQrB,QAAQqB;AAAAA,EAAAA,GAElB,OACA,aAAa;AAAA,IACXC,WAAWC,eAAeX,eAAeG,MAAM;AAAA,EAAA,GAE7CF,GAAAA,QAEHP,SACH,CAAA;AAEJ,CAAC;"}
@@ -29,9 +29,6 @@ function binaryFindElement(array, element) {
29
29
  return start;
30
30
  }
31
31
  const DescendantContext = React.createContext({});
32
- if (process.env.NODE_ENV !== "production") {
33
- DescendantContext.displayName = "DescendantContext";
34
- }
35
32
  function usePrevious(value) {
36
33
  const ref = React.useRef(null);
37
34
  React.useEffect(() => {
@@ -1 +1 @@
1
- {"version":3,"file":"DescendantProvider.js","sources":["../../../../../src/components/TreeView/internals/DescendantProvider.tsx"],"sourcesContent":["import * as React from \"react\";\nimport { unstable_useEnhancedEffect as useEnhancedEffect } from \"@mui/material/utils\";\n\n/** Credit: https://github.com/reach/reach-ui/blob/86a046f54d53b6420e392b3fa56dd991d9d4e458/packages/descendants/README.md\n * Modified slightly to suit our purposes.\n */\n\n// To replace with .findIndex() once we stop IE11 support.\nfunction findIndex<T>(array: T[], comp: (item: T) => boolean) {\n for (let i = 0; i < array.length; i += 1) {\n if (comp(array[i])) {\n return i;\n }\n }\n\n return -1;\n}\n\nfunction binaryFindElement(\n array: TreeItemDescendant[],\n element: HTMLLIElement\n) {\n let start = 0;\n let end = array.length - 1;\n\n while (start <= end) {\n const middle = Math.floor((start + end) / 2);\n\n if (array[middle].element === element) {\n return middle;\n }\n\n if (\n // eslint-disable-next-line no-bitwise\n array[middle].element.compareDocumentPosition(element) &\n Node.DOCUMENT_POSITION_PRECEDING\n ) {\n end = middle - 1;\n } else {\n start = middle + 1;\n }\n }\n\n return start;\n}\n\nexport interface TreeItemDescendant {\n element: HTMLLIElement;\n id: string;\n}\n\ninterface DescendantContextValue {\n registerDescendant?: (params: TreeItemDescendant & { index: number }) => void;\n unregisterDescendant?: (params: HTMLLIElement) => void;\n descendants?: TreeItemDescendant[];\n parentId?: string | null;\n}\n\nconst DescendantContext = React.createContext<DescendantContextValue>({});\n\nif (process.env.NODE_ENV !== \"production\") {\n DescendantContext.displayName = \"DescendantContext\";\n}\n\nfunction usePrevious<T>(value: T) {\n const ref = React.useRef<T | null>(null);\n React.useEffect(() => {\n ref.current = value;\n }, [value]);\n return ref.current;\n}\n\nconst noop = () => {};\n\n/**\n * This hook registers our descendant by passing it into an array. We can then\n * search that array by to find its index when registering it in the component.\n * We use this for focus management, keyboard navigation, and typeahead\n * functionality for some components.\n *\n * The hook accepts the element node\n *\n * Our main goals with this are:\n * 1) maximum composability,\n * 2) minimal API friction\n * 3) SSR compatibility*\n * 4) concurrent safe\n * 5) index always up-to-date with the tree despite changes\n * 6) works with memoization of any component in the tree (hopefully)\n *\n * * As for SSR, the good news is that we don't actually need the index on the\n * server for most use-cases, as we are only using it to determine the order of\n * composed descendants for keyboard navigation.\n */\nexport function useDescendant(descendant: TreeItemDescendant) {\n const [, forceUpdate] = React.useState<{}>();\n const {\n registerDescendant = noop,\n unregisterDescendant = noop,\n descendants = [],\n parentId = null,\n } = React.useContext(DescendantContext);\n\n // This will initially return -1 because we haven't registered the descendant\n // on the first render. After we register, this will then return the correct\n // index on the following render, and we will re-register descendants\n // so that everything is up-to-date before the user interacts with a\n // collection.\n const index = findIndex(\n descendants,\n (item) => item.element === descendant.element\n );\n\n const previousDescendants = usePrevious(descendants);\n\n // We also need to re-register descendants any time ANY of the other\n // descendants have changed. My brain was melting when I wrote this and it\n // feels a little off, but checking in render and using the result in the\n // effect's dependency array works well enough.\n const someDescendantsHaveChanged = descendants.some(\n (newDescendant, position) => {\n return (\n previousDescendants &&\n previousDescendants[position] &&\n previousDescendants[position].element !== newDescendant.element\n );\n }\n );\n\n // Prevent any flashing\n useEnhancedEffect(() => {\n if (descendant.element) {\n registerDescendant({\n ...descendant,\n index,\n });\n return () => {\n unregisterDescendant(descendant.element!);\n };\n }\n forceUpdate({});\n\n return undefined;\n }, [\n registerDescendant,\n unregisterDescendant,\n index,\n someDescendantsHaveChanged,\n descendant,\n ]);\n\n return { parentId, index };\n}\n\ninterface DescendantProviderProps {\n id?: string;\n children: React.ReactNode;\n}\n\nexport const DescendantProvider = (props: DescendantProviderProps) => {\n const { children, id } = props;\n\n const [items, set] = React.useState<\n (TreeItemDescendant & { index: number })[]\n >([]);\n\n const registerDescendant = React.useCallback(\n ({ element, ...other }: TreeItemDescendant) => {\n set((oldItems) => {\n if (oldItems.length === 0) {\n // If there are no items, register at index 0 and bail.\n return [\n {\n ...other,\n element,\n index: 0,\n },\n ];\n }\n\n const index = binaryFindElement(oldItems, element);\n let newItems: typeof oldItems;\n\n if (oldItems[index] && oldItems[index].element === element) {\n // If the element is already registered, just use the same array\n newItems = oldItems;\n } else {\n // When registering a descendant, we need to make sure we insert in\n // into the array in the same order that it appears in the DOM. So as\n // new descendants are added or maybe some are removed, we always know\n // that the array is up-to-date and correct.\n //\n // So here we look at our registered descendants and see if the new\n // element we are adding appears earlier than an existing descendant's\n // DOM node via `node.compareDocumentPosition`. If it does, we insert\n // the new element at this index. Because `registerDescendant` will be\n // called in an effect every time the descendants state value changes,\n // we should be sure that this index is accurate when descendent\n // elements come or go from our component.\n\n const newItem = {\n ...other,\n element,\n index,\n };\n\n // If an index is not found we will push the element to the end.\n newItems = oldItems.slice();\n newItems.splice(index, 0, newItem);\n }\n newItems.forEach((item, position) => {\n item.index = position;\n });\n return newItems;\n });\n },\n []\n );\n\n const unregisterDescendant = React.useCallback((element: HTMLLIElement) => {\n set((oldItems) => oldItems.filter((item) => element !== item.element));\n }, []);\n\n const value = React.useMemo(\n () => ({\n descendants: items,\n registerDescendant,\n unregisterDescendant,\n parentId: id,\n }),\n [items, registerDescendant, unregisterDescendant, id]\n );\n\n return (\n <DescendantContext.Provider value={value}>\n {children}\n </DescendantContext.Provider>\n );\n};\n"],"names":["findIndex","array","comp","i","length","binaryFindElement","element","start","end","middle","Math","floor","compareDocumentPosition","Node","DOCUMENT_POSITION_PRECEDING","DescendantContext","React","createContext","process","env","NODE_ENV","displayName","usePrevious","value","ref","useRef","useEffect","current","noop","useDescendant","descendant","forceUpdate","useState","registerDescendant","unregisterDescendant","descendants","parentId","useContext","index","item","previousDescendants","someDescendantsHaveChanged","some","newDescendant","position","useEnhancedEffect","undefined","DescendantProvider","props","children","id","items","set","useCallback","other","oldItems","newItems","newItem","slice","splice","forEach","filter","useMemo"],"mappings":";;;AAQA,SAASA,UAAaC,OAAYC,MAA4B;AAC5D,WAASC,IAAI,GAAGA,IAAIF,MAAMG,QAAQD,KAAK,GAAG;AACxC,QAAID,KAAKD,MAAME,CAAC,CAAC,GAAG;AACXA,aAAAA;AAAAA,IACT;AAAA,EACF;AAEO,SAAA;AACT;AAEA,SAASE,kBACPJ,OACAK,SACA;AACA,MAAIC,QAAQ;AACRC,MAAAA,MAAMP,MAAMG,SAAS;AAEzB,SAAOG,SAASC,KAAK;AACnB,UAAMC,SAASC,KAAKC,OAAOJ,QAAQC,OAAO,CAAC;AAE3C,QAAIP,MAAMQ,MAAM,EAAEH,YAAYA,SAAS;AAC9BG,aAAAA;AAAAA,IACT;AAEA;AAAA;AAAA,MAEER,MAAMQ,MAAM,EAAEH,QAAQM,wBAAwBN,OAAO,IACrDO,KAAKC;AAAAA,MACL;AACAN,YAAMC,SAAS;AAAA,IAAA,OACV;AACLF,cAAQE,SAAS;AAAA,IACnB;AAAA,EACF;AAEOF,SAAAA;AACT;AAcA,MAAMQ,oBAAoBC,MAAMC,cAAsC,CAAA,CAAE;AAExE,IAAIC,QAAQC,IAAIC,aAAa,cAAc;AACzCL,oBAAkBM,cAAc;AAClC;AAEA,SAASC,YAAeC,OAAU;AAC1BC,QAAAA,MAAMR,MAAMS,OAAiB,IAAI;AACvCT,QAAMU,UAAU,MAAM;AACpBF,QAAIG,UAAUJ;AAAAA,EAAAA,GACb,CAACA,KA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A;AACZA,UAAAA,SAASnD,WAAW,GAAG;AAEzB,eAAO,CACL;AAAA,UACE,GAAGkD;AAAAA,UACHhD;AAAAA,UACAgC,OAAO;AAAA,QAAA,CACR;AAAA,MAEL;AAEMA,YAAAA,QAAQjC,kBAAkBkD,UAAUjD,OAAO;AAC7CkD,UAAAA;AAEJ,UAAID,SAASjB,KAAK,KAAKiB,SAASjB,KAAK,EAAEhC,YAAYA,SAAS;AAE/CiD,mBAAAA;AAAAA,MAAAA,OACN;AAcL,cAAME,UAAU;AAAA,UACd,GAAGH;AAAAA,UACHhD;AAAAA,UACAgC;AAAAA,QAAAA;AAIFkB,mBAAWD,SAASG;AACXC,iBAAAA,OAAOrB,OAAO,GAAGmB,OAAO;AAAA,MACnC;AACSG,eAAAA,QAAQ,CAACrB,MAAMK,aAAa;AACnCL,aAAKD,QAAQM;AAAAA,MAAAA,CACd;AACMY,aAAAA;AAAAA,IAAAA,CACR;AAAA,EACH,GACA,CACF,CAAA;AAEA,QAAMtB,uBAAuBlB,MAAMqC,YAAY,CAAC/C,YAA2B;AACzE8C,QAAKG,cAAaA,SAASM,OAAQtB,UAASjC,YAAYiC,KAAKjC,OAAO,CAAC;AAAA,EACvE,GAAG,CAAE,CAAA;AAECiB,QAAAA,QAAQP,MAAM8C,QAClB,OAAO;AAAA,IACL3B,aAAagB;AAAAA,IACblB;AAAAA,IACAC;AAAAA,IACAE,UAAUc;AAAAA,EAAAA,IAEZ,CAACC,OAAOlB,oBAAoBC,sBAAsBgB,EAAE,CACtD;AAEA,SACG,oBAAA,kBAAkB,UAAlB,EAA2B,OACzBD,SACH,CAAA;AAEJ;"}
1
+ {"version":3,"file":"DescendantProvider.js","sources":["../../../../../src/components/TreeView/internals/DescendantProvider.tsx"],"sourcesContent":["import * as React from \"react\";\nimport { unstable_useEnhancedEffect as useEnhancedEffect } from \"@mui/material/utils\";\n\n/** Credit: https://github.com/reach/reach-ui/blob/86a046f54d53b6420e392b3fa56dd991d9d4e458/packages/descendants/README.md\n * Modified slightly to suit our purposes.\n */\n\n// To replace with .findIndex() once we stop IE11 support.\nfunction findIndex<T>(array: T[], comp: (item: T) => boolean) {\n for (let i = 0; i < array.length; i += 1) {\n if (comp(array[i])) {\n return i;\n }\n }\n\n return -1;\n}\n\nfunction binaryFindElement(\n array: TreeItemDescendant[],\n element: HTMLLIElement\n) {\n let start = 0;\n let end = array.length - 1;\n\n while (start <= end) {\n const middle = Math.floor((start + end) / 2);\n\n if (array[middle].element === element) {\n return middle;\n }\n\n if (\n // eslint-disable-next-line no-bitwise\n array[middle].element.compareDocumentPosition(element) &\n Node.DOCUMENT_POSITION_PRECEDING\n ) {\n end = middle - 1;\n } else {\n start = middle + 1;\n }\n }\n\n return start;\n}\n\nexport interface TreeItemDescendant {\n element: HTMLLIElement;\n id: string;\n}\n\ninterface DescendantContextValue {\n registerDescendant?: (params: TreeItemDescendant & { index: number }) => void;\n unregisterDescendant?: (params: HTMLLIElement) => void;\n descendants?: TreeItemDescendant[];\n parentId?: string | null;\n}\n\nconst DescendantContext = React.createContext<DescendantContextValue>({});\n\nfunction usePrevious<T>(value: T) {\n const ref = React.useRef<T | null>(null);\n React.useEffect(() => {\n ref.current = value;\n }, [value]);\n return ref.current;\n}\n\nconst noop = () => {};\n\n/**\n * This hook registers our descendant by passing it into an array. We can then\n * search that array by to find its index when registering it in the component.\n * We use this for focus management, keyboard navigation, and typeahead\n * functionality for some components.\n *\n * The hook accepts the element node\n *\n * Our main goals with this are:\n * 1) maximum composability,\n * 2) minimal API friction\n * 3) SSR compatibility*\n * 4) concurrent safe\n * 5) index always up-to-date with the tree despite changes\n * 6) works with memoization of any component in the tree (hopefully)\n *\n * * As for SSR, the good news is that we don't actually need the index on the\n * server for most use-cases, as we are only using it to determine the order of\n * composed descendants for keyboard navigation.\n */\nexport function useDescendant(descendant: TreeItemDescendant) {\n const [, forceUpdate] = React.useState<{}>();\n const {\n registerDescendant = noop,\n unregisterDescendant = noop,\n descendants = [],\n parentId = null,\n } = React.useContext(DescendantContext);\n\n // This will initially return -1 because we haven't registered the descendant\n // on the first render. After we register, this will then return the correct\n // index on the following render, and we will re-register descendants\n // so that everything is up-to-date before the user interacts with a\n // collection.\n const index = findIndex(\n descendants,\n (item) => item.element === descendant.element\n );\n\n const previousDescendants = usePrevious(descendants);\n\n // We also need to re-register descendants any time ANY of the other\n // descendants have changed. My brain was melting when I wrote this and it\n // feels a little off, but checking in render and using the result in the\n // effect's dependency array works well enough.\n const someDescendantsHaveChanged = descendants.some(\n (newDescendant, position) => {\n return (\n previousDescendants &&\n previousDescendants[position] &&\n previousDescendants[position].element !== newDescendant.element\n );\n }\n );\n\n // Prevent any flashing\n useEnhancedEffect(() => {\n if (descendant.element) {\n registerDescendant({\n ...descendant,\n index,\n });\n return () => {\n unregisterDescendant(descendant.element!);\n };\n }\n forceUpdate({});\n\n return undefined;\n }, [\n registerDescendant,\n unregisterDescendant,\n index,\n someDescendantsHaveChanged,\n descendant,\n ]);\n\n return { parentId, index };\n}\n\ninterface DescendantProviderProps {\n id?: string;\n children: React.ReactNode;\n}\n\nexport const DescendantProvider = (props: DescendantProviderProps) => {\n const { children, id } = props;\n\n const [items, set] = React.useState<\n (TreeItemDescendant & { index: number })[]\n >([]);\n\n const registerDescendant = React.useCallback(\n ({ element, ...other }: TreeItemDescendant) => {\n set((oldItems) => {\n if (oldItems.length === 0) {\n // If there are no items, register at index 0 and bail.\n return [\n {\n ...other,\n element,\n index: 0,\n },\n ];\n }\n\n const index = binaryFindElement(oldItems, element);\n let newItems: typeof oldItems;\n\n if (oldItems[index] && oldItems[index].element === element) {\n // If the element is already registered, just use the same array\n newItems = oldItems;\n } else {\n // When registering a descendant, we need to make sure we insert in\n // into the array in the same order that it appears in the DOM. So as\n // new descendants are added or maybe some are removed, we always know\n // that the array is up-to-date and correct.\n //\n // So here we look at our registered descendants and see if the new\n // element we are adding appears earlier than an existing descendant's\n // DOM node via `node.compareDocumentPosition`. If it does, we insert\n // the new element at this index. Because `registerDescendant` will be\n // called in an effect every time the descendants state value changes,\n // we should be sure that this index is accurate when descendent\n // elements come or go from our component.\n\n const newItem = {\n ...other,\n element,\n index,\n };\n\n // If an index is not found we will push the element to the end.\n newItems = oldItems.slice();\n newItems.splice(index, 0, newItem);\n }\n newItems.forEach((item, position) => {\n item.index = position;\n });\n return newItems;\n });\n },\n []\n );\n\n const unregisterDescendant = React.useCallback((element: HTMLLIElement) => {\n set((oldItems) => oldItems.filter((item) => element !== item.element));\n }, []);\n\n const value = React.useMemo(\n () => ({\n descendants: items,\n registerDescendant,\n unregisterDescendant,\n parentId: id,\n }),\n [items, registerDescendant, unregisterDescendant, id]\n );\n\n return (\n <DescendantContext.Provider value={value}>\n {children}\n </DescendantContext.Provider>\n );\n};\n"],"names":["findIndex","array","comp","i","length","binaryFindElement","element","start","end","middle","Math","floor","compareDocumentPosition","Node","DOCUMENT_POSITION_PRECEDING","DescendantContext","React","createContext","usePrevious","value","ref","useRef","useEffect","current","noop","useDescendant","descendant","forceUpdate","useState","registerDescendant","unregisterDescendant","descendants","parentId","useContext","index","item","previousDescendants","someDescendantsHaveChanged","some","newDescendant","position","useEnhancedEffect","undefined","DescendantProvider","props","children","id","items","set","useCallback","other","oldItems","newItems","newItem","slice","splice","forEach","filter","useMemo"],"mappings":";;;AAQA,SAASA,UAAaC,OAAYC,MAA4B;AAC5D,WAASC,IAAI,GAAGA,IAAIF,MAAMG,QAAQD,KAAK,GAAG;AACxC,QAAID,KAAKD,MAAME,CAAC,CAAC,GAAG;AACXA,aAAAA;AAAAA,IACT;AAAA,EACF;AAEO,SAAA;AACT;AAEA,SAASE,kBACPJ,OACAK,SACA;AACA,MAAIC,QAAQ;AACRC,MAAAA,MAAMP,MAAMG,SAAS;AAEzB,SAAOG,SAASC,KAAK;AACnB,UAAMC,SAASC,KAAKC,OAAOJ,QAAQC,OAAO,CAAC;AAE3C,QAAIP,MAAMQ,MAAM,EAAEH,YAAYA,SAAS;AAC9BG,aAAAA;AAAAA,IACT;AAEA;AA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AAAAA,IACAE,UAAUc;AAAAA,EAAAA,IAEZ,CAACC,OAAOlB,oBAAoBC,sBAAsBgB,EAAE,CACtD;AAEA,SACG,oBAAA,kBAAkB,UAAlB,EAA2B,OACzBD,SACH,CAAA;AAEJ;"}
@@ -14,9 +14,6 @@ const DEFAULT_TREE_VIEW_CONTEXT_VALUE = {
14
14
  }
15
15
  };
16
16
  const TreeViewContext = createContext(DEFAULT_TREE_VIEW_CONTEXT_VALUE);
17
- if (process.env.NODE_ENV !== "production") {
18
- TreeViewContext.displayName = "TreeViewContext";
19
- }
20
17
  const TreeViewProvider = (props) => {
21
18
  const {
22
19
  value,
@@ -1 +1 @@
1
- {"version":3,"file":"TreeViewProvider.js","sources":["../../../../../src/components/TreeView/internals/TreeViewProvider.tsx"],"sourcesContent":["import { createContext, useContext } from \"react\";\n\nimport { TreeViewAnyPluginSignature, TreeViewInstance } from \"./types\";\nimport { DescendantProvider } from \"./DescendantProvider\";\n\nexport interface TreeViewContextValue<\n TPlugins extends readonly TreeViewAnyPluginSignature[]\n> {\n treeId: string | undefined;\n instance: TreeViewInstance<TPlugins> | null;\n multiSelect: boolean;\n disabledItemsFocusable: boolean;\n icons: {\n defaultCollapseIcon: React.ReactNode;\n defaultExpandIcon: React.ReactNode;\n defaultParentIcon: React.ReactNode;\n defaultEndIcon: React.ReactNode;\n };\n}\n\nexport const DEFAULT_TREE_VIEW_CONTEXT_VALUE: TreeViewContextValue<any> = {\n instance: null,\n multiSelect: false,\n disabledItemsFocusable: false,\n treeId: undefined,\n icons: {\n defaultCollapseIcon: null,\n defaultExpandIcon: null,\n defaultParentIcon: null,\n defaultEndIcon: null,\n },\n};\n\n/**\n * @ignore - internal component.\n */\nexport const TreeViewContext = createContext<TreeViewContextValue<any>>(\n DEFAULT_TREE_VIEW_CONTEXT_VALUE\n);\n\nif (process.env.NODE_ENV !== \"production\") {\n TreeViewContext.displayName = \"TreeViewContext\";\n}\n\nexport interface TreeViewProviderProps<\n TPlugins extends readonly TreeViewAnyPluginSignature[]\n> {\n value: TreeViewContextValue<TPlugins>;\n children: React.ReactNode;\n}\n\n/**\n * Sets up the contexts for the underlying TreeItem components.\n *\n * @ignore - do not document.\n */\nexport const TreeViewProvider = <\n TPlugins extends readonly TreeViewAnyPluginSignature[]\n>(\n props: TreeViewProviderProps<TPlugins>\n) => {\n const { value, children } = props;\n\n return (\n <TreeViewContext.Provider value={value}>\n <DescendantProvider>{children}</DescendantProvider>\n </TreeViewContext.Provider>\n );\n};\n\nexport const useTreeViewContext = <\n TPlugins extends readonly TreeViewAnyPluginSignature[]\n>() => useContext(TreeViewContext) as TreeViewContextValue<TPlugins>;\n"],"names":["DEFAULT_TREE_VIEW_CONTEXT_VALUE","instance","multiSelect","disabledItemsFocusable","treeId","undefined","icons","defaultCollapseIcon","defaultExpandIcon","defaultParentIcon","defaultEndIcon","TreeViewContext","createContext","process","env","NODE_ENV","displayName","TreeViewProvider","props","value","children","useTreeViewContext","useContext"],"mappings":";;;AAoBO,MAAMA,kCAA6D;AAAA,EACxEC,UAAU;AAAA,EACVC,aAAa;AAAA,EACbC,wBAAwB;AAAA,EACxBC,QAAQC;AAAAA,EACRC,OAAO;AAAA,IACLC,qBAAqB;AAAA,IACrBC,mBAAmB;AAAA,IACnBC,mBAAmB;AAAA,IACnBC,gBAAgB;AAAA,EAClB;AACF;AAKaC,MAAAA,kBAAkBC,cAC7BZ,+BACF;AAEA,IAAIa,QAAQC,IAAIC,aAAa,cAAc;AACzCJ,kBAAgBK,cAAc;AAChC;AAcaC,MAAAA,mBAAmB,CAG9BC,UACG;AACG,QAAA;AAAA,IAAEC;AAAAA,IAAOC;AAAAA,EAAaF,IAAAA;AAG1B,SAAA,oBAAC,gBAAgB,UAAhB,EAAyB,OACxB,UAAC,oBAAA,oBAAA,EAAoBE,SAAS,CAAA,EAChC,CAAA;AAEJ;AAEaC,MAAAA,qBAAqB,MAE3BC,WAAWX,eAAe;"}
1
+ {"version":3,"file":"TreeViewProvider.js","sources":["../../../../../src/components/TreeView/internals/TreeViewProvider.tsx"],"sourcesContent":["import { createContext, useContext } from \"react\";\n\nimport { TreeViewAnyPluginSignature, TreeViewInstance } from \"./types\";\nimport { DescendantProvider } from \"./DescendantProvider\";\n\nexport interface TreeViewContextValue<\n TPlugins extends readonly TreeViewAnyPluginSignature[]\n> {\n treeId: string | undefined;\n instance: TreeViewInstance<TPlugins> | null;\n multiSelect: boolean;\n disabledItemsFocusable: boolean;\n icons: {\n defaultCollapseIcon: React.ReactNode;\n defaultExpandIcon: React.ReactNode;\n defaultParentIcon: React.ReactNode;\n defaultEndIcon: React.ReactNode;\n };\n}\n\nexport const DEFAULT_TREE_VIEW_CONTEXT_VALUE: TreeViewContextValue<any> = {\n instance: null,\n multiSelect: false,\n disabledItemsFocusable: false,\n treeId: undefined,\n icons: {\n defaultCollapseIcon: null,\n defaultExpandIcon: null,\n defaultParentIcon: null,\n defaultEndIcon: null,\n },\n};\n\n/**\n * @ignore - internal component.\n */\nexport const TreeViewContext = createContext<TreeViewContextValue<any>>(\n DEFAULT_TREE_VIEW_CONTEXT_VALUE\n);\n\nexport interface TreeViewProviderProps<\n TPlugins extends readonly TreeViewAnyPluginSignature[]\n> {\n value: TreeViewContextValue<TPlugins>;\n children: React.ReactNode;\n}\n\n/**\n * Sets up the contexts for the underlying TreeItem components.\n *\n * @ignore - do not document.\n */\nexport const TreeViewProvider = <\n TPlugins extends readonly TreeViewAnyPluginSignature[]\n>(\n props: TreeViewProviderProps<TPlugins>\n) => {\n const { value, children } = props;\n\n return (\n <TreeViewContext.Provider value={value}>\n <DescendantProvider>{children}</DescendantProvider>\n </TreeViewContext.Provider>\n );\n};\n\nexport const useTreeViewContext = <\n TPlugins extends readonly TreeViewAnyPluginSignature[]\n>() => useContext(TreeViewContext) as TreeViewContextValue<TPlugins>;\n"],"names":["DEFAULT_TREE_VIEW_CONTEXT_VALUE","instance","multiSelect","disabledItemsFocusable","treeId","undefined","icons","defaultCollapseIcon","defaultExpandIcon","defaultParentIcon","defaultEndIcon","TreeViewContext","createContext","TreeViewProvider","props","value","children","useTreeViewContext","useContext"],"mappings":";;;AAoBO,MAAMA,kCAA6D;AAAA,EACxEC,UAAU;AAAA,EACVC,aAAa;AAAA,EACbC,wBAAwB;AAAA,EACxBC,QAAQC;AAAAA,EACRC,OAAO;AAAA,IACLC,qBAAqB;AAAA,IACrBC,mBAAmB;AAAA,IACnBC,mBAAmB;AAAA,IACnBC,gBAAgB;AAAA,EAClB;AACF;AAKaC,MAAAA,kBAAkBC,cAC7BZ,+BACF;AAcaa,MAAAA,mBAAmB,CAG9BC,UACG;AACG,QAAA;AAAA,IAAEC;AAAAA,IAAOC;AAAAA,EAAaF,IAAAA;AAG1B,SAAA,oBAAC,gBAAgB,UAAhB,EAAyB,OACxB,UAAC,oBAAA,oBAAA,EAAoBE,SAAS,CAAA,EAChC,CAAA;AAEJ;AAEaC,MAAAA,qBAAqB,MAE3BC,WAAWP,eAAe;"}