@hitachivantara/uikit-react-core 5.7.0 → 5.7.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/components/Banner/BannerContent/BannerContent.cjs +1 -1
- package/dist/cjs/components/Banner/BannerContent/BannerContent.cjs.map +1 -1
- package/dist/cjs/components/Card/Card.cjs +8 -8
- package/dist/cjs/components/Card/Card.cjs.map +1 -1
- package/dist/cjs/components/Card/Content/Content.cjs +3 -3
- package/dist/cjs/components/Card/Content/Content.cjs.map +1 -1
- package/dist/cjs/components/Card/Header/Header.cjs +10 -10
- package/dist/cjs/components/Card/Header/Header.cjs.map +1 -1
- package/dist/cjs/components/Card/Media/Media.cjs +4 -4
- package/dist/cjs/components/Card/Media/Media.cjs.map +1 -1
- package/dist/cjs/components/DatePicker/DatePicker.cjs +21 -20
- package/dist/cjs/components/DatePicker/DatePicker.cjs.map +1 -1
- package/dist/cjs/components/Dialog/Dialog.cjs +7 -7
- package/dist/cjs/components/Dialog/Dialog.cjs.map +1 -1
- package/dist/cjs/components/DropDownMenu/DropDownMenu.cjs +7 -6
- package/dist/cjs/components/DropDownMenu/DropDownMenu.cjs.map +1 -1
- package/dist/cjs/components/FilterGroup/Counter/Counter.cjs +4 -4
- package/dist/cjs/components/FilterGroup/Counter/Counter.cjs.map +1 -1
- package/dist/cjs/components/FilterGroup/FilterContent/FilterContent.cjs +12 -12
- package/dist/cjs/components/FilterGroup/FilterContent/FilterContent.cjs.map +1 -1
- package/dist/cjs/components/FilterGroup/FilterGroup.cjs +7 -7
- package/dist/cjs/components/FilterGroup/FilterGroup.cjs.map +1 -1
- package/dist/cjs/components/FilterGroup/LeftPanel/LeftPanel.cjs +3 -3
- package/dist/cjs/components/FilterGroup/LeftPanel/LeftPanel.cjs.map +1 -1
- package/dist/cjs/components/FilterGroup/RightPanel/RightPanel.cjs +8 -7
- package/dist/cjs/components/FilterGroup/RightPanel/RightPanel.cjs.map +1 -1
- package/dist/cjs/components/InlineEditor/InlineEditor.cjs +9 -9
- package/dist/cjs/components/InlineEditor/InlineEditor.cjs.map +1 -1
- package/dist/cjs/components/InlineEditor/InlineEditor.styles.cjs +16 -14
- package/dist/cjs/components/InlineEditor/InlineEditor.styles.cjs.map +1 -1
- package/dist/cjs/components/QueryBuilder/RuleGroup/RuleGroup.cjs +5 -5
- package/dist/cjs/components/QueryBuilder/RuleGroup/RuleGroup.cjs.map +1 -1
- package/dist/cjs/components/ScrollTo/Horizontal/HorizontalScrollListItem/HorizontalScrollListItem.cjs +5 -5
- package/dist/cjs/components/ScrollTo/Horizontal/HorizontalScrollListItem/HorizontalScrollListItem.cjs.map +1 -1
- package/dist/cjs/components/ScrollTo/Horizontal/ScrollToHorizontal.cjs +11 -9
- package/dist/cjs/components/ScrollTo/Horizontal/ScrollToHorizontal.cjs.map +1 -1
- package/dist/cjs/components/ScrollTo/Vertical/ScrollToVertical.cjs +4 -4
- package/dist/cjs/components/ScrollTo/Vertical/ScrollToVertical.cjs.map +1 -1
- package/dist/cjs/components/ScrollTo/Vertical/VerticalScrollListItem/VerticalScrollListItem.cjs +8 -7
- package/dist/cjs/components/ScrollTo/Vertical/VerticalScrollListItem/VerticalScrollListItem.cjs.map +1 -1
- package/dist/esm/components/Banner/BannerContent/BannerContent.js +1 -1
- package/dist/esm/components/Banner/BannerContent/BannerContent.js.map +1 -1
- package/dist/esm/components/Card/Card.js +8 -8
- package/dist/esm/components/Card/Card.js.map +1 -1
- package/dist/esm/components/Card/Content/Content.js +3 -3
- package/dist/esm/components/Card/Content/Content.js.map +1 -1
- package/dist/esm/components/Card/Header/Header.js +10 -10
- package/dist/esm/components/Card/Header/Header.js.map +1 -1
- package/dist/esm/components/Card/Media/Media.js +4 -4
- package/dist/esm/components/Card/Media/Media.js.map +1 -1
- package/dist/esm/components/DatePicker/DatePicker.js +21 -20
- package/dist/esm/components/DatePicker/DatePicker.js.map +1 -1
- package/dist/esm/components/Dialog/Dialog.js +7 -7
- package/dist/esm/components/Dialog/Dialog.js.map +1 -1
- package/dist/esm/components/DropDownMenu/DropDownMenu.js +7 -6
- package/dist/esm/components/DropDownMenu/DropDownMenu.js.map +1 -1
- package/dist/esm/components/FilterGroup/Counter/Counter.js +4 -4
- package/dist/esm/components/FilterGroup/Counter/Counter.js.map +1 -1
- package/dist/esm/components/FilterGroup/FilterContent/FilterContent.js +12 -12
- package/dist/esm/components/FilterGroup/FilterContent/FilterContent.js.map +1 -1
- package/dist/esm/components/FilterGroup/FilterGroup.js +7 -7
- package/dist/esm/components/FilterGroup/FilterGroup.js.map +1 -1
- package/dist/esm/components/FilterGroup/LeftPanel/LeftPanel.js +3 -3
- package/dist/esm/components/FilterGroup/LeftPanel/LeftPanel.js.map +1 -1
- package/dist/esm/components/FilterGroup/RightPanel/RightPanel.js +8 -7
- package/dist/esm/components/FilterGroup/RightPanel/RightPanel.js.map +1 -1
- package/dist/esm/components/InlineEditor/InlineEditor.js +9 -9
- package/dist/esm/components/InlineEditor/InlineEditor.js.map +1 -1
- package/dist/esm/components/InlineEditor/InlineEditor.styles.js +16 -14
- package/dist/esm/components/InlineEditor/InlineEditor.styles.js.map +1 -1
- package/dist/esm/components/QueryBuilder/RuleGroup/RuleGroup.js +5 -5
- package/dist/esm/components/QueryBuilder/RuleGroup/RuleGroup.js.map +1 -1
- package/dist/esm/components/ScrollTo/Horizontal/HorizontalScrollListItem/HorizontalScrollListItem.js +5 -5
- package/dist/esm/components/ScrollTo/Horizontal/HorizontalScrollListItem/HorizontalScrollListItem.js.map +1 -1
- package/dist/esm/components/ScrollTo/Horizontal/ScrollToHorizontal.js +11 -9
- package/dist/esm/components/ScrollTo/Horizontal/ScrollToHorizontal.js.map +1 -1
- package/dist/esm/components/ScrollTo/Vertical/ScrollToVertical.js +4 -4
- package/dist/esm/components/ScrollTo/Vertical/ScrollToVertical.js.map +1 -1
- package/dist/esm/components/ScrollTo/Vertical/VerticalScrollListItem/VerticalScrollListItem.js +8 -7
- package/dist/esm/components/ScrollTo/Vertical/VerticalScrollListItem/VerticalScrollListItem.js.map +1 -1
- package/package.json +5 -5
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Dialog.js","sources":["../../../../src/components/Dialog/Dialog.tsx"],"sourcesContent":["import React, { useCallback, useRef } from \"react\";\nimport { clsx } from \"clsx\";\nimport MuiDialog, { DialogProps as MuiDialogProps } from \"@mui/material/Dialog\";\nimport { Close } from \"@hitachivantara/uikit-react-icons\";\nimport { theme } from \"@hitachivantara/uikit-styles\";\nimport isNil from \"lodash/isNil\";\nimport { HvBaseProps } from \"@core/types/generic\";\nimport { StyledBackdrop, StyledClose, styles } from \"./Dialog.styles\";\nimport {\n isKeypress,\n keyboardCodes,\n setId,\n getFocusableList,\n} from \"@core/utils\";\nimport { withTooltip } from \"@core/hocs\";\nimport dialogClasses, { HvDialogClasses } from \"./dialogClasses\";\nimport { useTheme } from \"@core/hooks\";\nimport { ClassNames } from \"@emotion/react\";\n\nexport interface HvDialogProps\n extends Omit<MuiDialogProps, \"fullScreen\" | \"classes\" | \"open\">,\n HvBaseProps {\n /** Id to be applied to the root node. */\n id?: string;\n /** Current state of the Dialog. */\n open?: boolean;\n /** Function executed on close. */\n onClose?: (\n event: React.SyntheticEvent,\n reason?: \"escapeKeyDown\" | \"backdropClick\"\n ) => void;\n /** Element id that should be focus when the Dialog opens. */\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}\n\nexport const HvDialog = ({\n classes,\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}: HvDialogProps) => {\n delete (others as any).fullScreen;\n\n const { activeTheme, selectedMode, rootId } = useTheme();\n\n const focusableQueue = useRef<{\n first?: HTMLElement;\n last?: HTMLElement;\n }>({ first: undefined, last: undefined });\n\n // Because the `disableBackdropClick` property was deprecated in MUI5\n // and we want to maintain that functionality to the user we're wrapping\n // the onClose call here to make that check.\n const wrappedClose = (\n event,\n bypassValidation: boolean = false,\n reason?: \"escapeKeyDown\" | \"backdropClick\"\n ) => {\n if (bypassValidation) {\n onClose?.(event, reason);\n } else if (!disableBackdropClick) {\n onClose?.(event, reason);\n }\n };\n\n const measuredRef = useCallback(\n (node) => {\n if (node) {\n const focusableList = getFocusableList(node);\n focusableQueue.current = {\n first: focusableList[1],\n last: focusableList[focusableList.length - 2],\n };\n if (isNil(firstFocusable)) focusableList[1].focus();\n else {\n const element =\n firstFocusable && document.getElementById(firstFocusable);\n if (element) element.focus();\n else {\n console.warn(`firstFocusable element ${firstFocusable} not found.`);\n\n focusableList[1].focus();\n }\n }\n }\n },\n [firstFocusable]\n );\n\n const keyDownHandler = (event) => {\n if (\n isKeypress(event, keyboardCodes.Tab) &&\n !isNil(event.target) &&\n !isNil(focusableQueue)\n ) {\n if (event.shiftKey && event.target === focusableQueue.current.first) {\n focusableQueue.current.last?.focus();\n event.preventDefault();\n }\n if (!event.shiftKey && event.target === focusableQueue.current.last) {\n focusableQueue.current.first?.focus();\n event.preventDefault();\n }\n }\n // Needed as this handler overrides the one in the material ui Modal.\n else if (isKeypress(event, keyboardCodes.Esc)) {\n if (\n \"onEscapeKeyDown\" in others &&\n typeof others.onEscapeKeyDown === \"function\"\n ) {\n others.onEscapeKeyDown(event);\n }\n\n if (!others.disableEscapeKeyDown) {\n // Swallow the event, in case someone is listening for the escape key on the body.\n event.stopPropagation();\n\n wrappedClose(event, true, \"escapeKeyDown\");\n }\n }\n };\n\n const closeButtonDisplay = () => <Close role=\"presentation\" />;\n\n const CloseButtonTooltipWrapper = buttonTitle\n ? withTooltip(closeButtonDisplay, buttonTitle, \"top\")\n : closeButtonDisplay;\n\n return (\n <ClassNames>\n {({ css }) => (\n <MuiDialog\n container={document.getElementById(rootId || \"\") || document.body}\n className={clsx(dialogClasses.root, classes?.root, className)}\n id={id}\n ref={measuredRef}\n open={open}\n fullScreen={fullscreen}\n onClose={(event, reason) => wrappedClose(event, undefined, reason)}\n onKeyDown={keyDownHandler}\n fullWidth\n maxWidth={false}\n slots={{\n backdrop: (backdropProps) => (\n <StyledBackdrop\n open={open}\n onClick={(event) => wrappedClose(event)}\n $backColor={\n activeTheme?.colors?.modes[selectedMode].atmo4 ||\n theme.colors.atmo4\n }\n {...backdropProps}\n />\n ),\n }}\n classes={{ container: css({ position: \"relative\" }) }}\n BackdropProps={{\n classes: {\n root: clsx(classes?.background, dialogClasses.background),\n },\n }}\n PaperProps={{\n classes: {\n root: clsx(\n css(styles.paper),\n classes?.paper,\n dialogClasses.paper,\n css({ position: \"absolute\" }),\n fullscreen &&\n clsx(\n dialogClasses.fullscreen,\n classes?.fullscreen,\n \"fullscreen\"\n )\n ),\n },\n }}\n aria-modal\n {...others}\n >\n <StyledClose\n id={setId(id, \"close\")}\n className={clsx(dialogClasses.closeButton, classes?.closeButton)}\n variant=\"secondaryGhost\"\n onClick={(event) => wrappedClose(event, true, undefined)}\n aria-label={buttonTitle}\n >\n <CloseButtonTooltipWrapper />\n </StyledClose>\n {children && typeof children === \"object\"\n ? React.Children.map(\n children,\n (c: React.ReactNode) =>\n c &&\n React.cloneElement(c as React.ReactElement, { fullscreen })\n )\n : children}\n </MuiDialog>\n )}\n </ClassNames>\n );\n};\n"],"names":["HvDialog","classes","className","id","children","open","onClose","firstFocusable","buttonTitle","fullscreen","disableBackdropClick","others","fullScreen","activeTheme","selectedMode","rootId","useTheme","focusableQueue","useRef","first","undefined","last","wrappedClose","event","bypassValidation","reason","measuredRef","useCallback","node","focusableList","getFocusableList","current","length","isNil","focus","element","document","getElementById","warn","keyDownHandler","isKeypress","keyboardCodes","Tab","target","shiftKey","preventDefault","Esc","onEscapeKeyDown","disableEscapeKeyDown","stopPropagation","closeButtonDisplay","_jsx","Close","role","CloseButtonTooltipWrapper","withTooltip","ClassNames","css","MuiDialog","container","body","clsx","dialogClasses","root","ref","onKeyDown","fullWidth","maxWidth","slots","backdrop","backdropProps","StyledBackdrop","onClick","$backColor","colors","modes","atmo4","theme","position","BackdropProps","background","PaperProps","styles","paper","StyledClose","setId","closeButton","variant","React","Children","map","c","cloneElement"],"mappings":";;;;;;;;;;;;;;;;AA2CO,MAAMA,WAAWA,CAAC;AAAA,EACvBC;AAAAA,EACAC;AAAAA,EACAC;AAAAA,EACAC;AAAAA,EACAC,OAAO;AAAA,EACPC;AAAAA,EACAC;AAAAA,EACAC,cAAc;AAAA,EACdC,aAAa;AAAA,EACbC,uBAAuB;AAAA,EACvB,GAAGC;AACU,MAAM;AACnB,SAAQA,OAAeC;AAEjB,QAAA;AAAA,IAAEC;AAAAA,IAAaC;AAAAA,IAAcC;AAAAA,MAAWC,SAAU;AAExD,QAAMC,iBAAiBC,OAGpB;AAAA,IAAEC,OAAOC;AAAAA,IAAWC,MAAMD;AAAAA,EAAAA,CAAW;AAKxC,QAAME,eAAeA,CACnBC,OACAC,mBAA4B,OAC5BC,WACG;AACH,QAAID,kBAAkB;AACpBlB,yCAAUiB,OAAOE;AAAAA,IAAM,WACd,CAACf,sBAAsB;AAChCJ,yCAAUiB,OAAOE;AAAAA,IACnB;AAAA,EAAA;AAGIC,QAAAA,cAAcC,YACjBC,CAAS,SAAA;AACR,QAAIA,MAAM;AACFC,YAAAA,gBAAgBC,iBAAiBF,IAAI;AAC3CX,qBAAec,UAAU;AAAA,QACvBZ,OAAOU,cAAc,CAAC;AAAA,QACtBR,MAAMQ,cAAcA,cAAcG,SAAS,CAAC;AAAA,MAAA;AAE9C,UAAIC,MAAM1B,cAAc;AAAiB,sBAAA,CAAC,EAAE2B;WACvC;AACH,cAAMC,UACJ5B,kBAAkB6B,SAASC,eAAe9B,cAAc;AACtD4B,YAAAA;AAASA,kBAAQD,MAAK;AAAA,aACrB;AACKI,kBAAAA,KAAM,0BAAyB/B,2BAA2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oBAACG,2BAAyB,EAAA;AAAA,MAAG,CAAA,GAE9BlD,YAAY,OAAOA,aAAa,WAC7BoF,eAAMC,SAASC,IACbtF,UACA,CAACuF,MACCA,KACAH,eAAMI,aAAaD,GAAyB;AAAA,QAAElF;AAAAA,MAAAA,CAAY,CAAC,IAE/DL,QAAQ;AAAA,IAAA,CAAA;AAAA,EAAA,CAGL;AAEjB;"}
|
|
1
|
+
{"version":3,"file":"Dialog.js","sources":["../../../../src/components/Dialog/Dialog.tsx"],"sourcesContent":["import React, { useCallback, useRef } from \"react\";\nimport MuiDialog, { DialogProps as MuiDialogProps } from \"@mui/material/Dialog\";\nimport { Close } from \"@hitachivantara/uikit-react-icons\";\nimport { theme } from \"@hitachivantara/uikit-styles\";\nimport isNil from \"lodash/isNil\";\nimport { HvBaseProps } from \"@core/types/generic\";\nimport { StyledBackdrop, StyledClose, styles } from \"./Dialog.styles\";\nimport {\n isKeypress,\n keyboardCodes,\n setId,\n getFocusableList,\n} from \"@core/utils\";\nimport { withTooltip } from \"@core/hocs\";\nimport dialogClasses, { HvDialogClasses } from \"./dialogClasses\";\nimport { useTheme } from \"@core/hooks\";\nimport { ClassNames } from \"@emotion/react\";\n\nexport interface HvDialogProps\n extends Omit<MuiDialogProps, \"fullScreen\" | \"classes\" | \"open\">,\n HvBaseProps {\n /** Id to be applied to the root node. */\n id?: string;\n /** Current state of the Dialog. */\n open?: boolean;\n /** Function executed on close. */\n onClose?: (\n event: React.SyntheticEvent,\n reason?: \"escapeKeyDown\" | \"backdropClick\"\n ) => void;\n /** Element id that should be focus when the Dialog opens. */\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}\n\nexport const HvDialog = ({\n classes,\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}: HvDialogProps) => {\n delete (others as any).fullScreen;\n\n const { activeTheme, selectedMode, rootId } = useTheme();\n\n const focusableQueue = useRef<{\n first?: HTMLElement;\n last?: HTMLElement;\n }>({ first: undefined, last: undefined });\n\n // Because the `disableBackdropClick` property was deprecated in MUI5\n // and we want to maintain that functionality to the user we're wrapping\n // the onClose call here to make that check.\n const wrappedClose = (\n event,\n bypassValidation: boolean = false,\n reason?: \"escapeKeyDown\" | \"backdropClick\"\n ) => {\n if (bypassValidation) {\n onClose?.(event, reason);\n } else if (!disableBackdropClick) {\n onClose?.(event, reason);\n }\n };\n\n const measuredRef = useCallback(\n (node) => {\n if (node) {\n const focusableList = getFocusableList(node);\n focusableQueue.current = {\n first: focusableList[1],\n last: focusableList[focusableList.length - 2],\n };\n if (isNil(firstFocusable)) focusableList[1].focus();\n else {\n const element =\n firstFocusable && document.getElementById(firstFocusable);\n if (element) element.focus();\n else {\n console.warn(`firstFocusable element ${firstFocusable} not found.`);\n\n focusableList[1].focus();\n }\n }\n }\n },\n [firstFocusable]\n );\n\n const keyDownHandler = (event) => {\n if (\n isKeypress(event, keyboardCodes.Tab) &&\n !isNil(event.target) &&\n !isNil(focusableQueue)\n ) {\n if (event.shiftKey && event.target === focusableQueue.current.first) {\n focusableQueue.current.last?.focus();\n event.preventDefault();\n }\n if (!event.shiftKey && event.target === focusableQueue.current.last) {\n focusableQueue.current.first?.focus();\n event.preventDefault();\n }\n }\n // Needed as this handler overrides the one in the material ui Modal.\n else if (isKeypress(event, keyboardCodes.Esc)) {\n if (\n \"onEscapeKeyDown\" in others &&\n typeof others.onEscapeKeyDown === \"function\"\n ) {\n others.onEscapeKeyDown(event);\n }\n\n if (!others.disableEscapeKeyDown) {\n // Swallow the event, in case someone is listening for the escape key on the body.\n event.stopPropagation();\n\n wrappedClose(event, true, \"escapeKeyDown\");\n }\n }\n };\n\n const closeButtonDisplay = () => <Close role=\"presentation\" />;\n\n const CloseButtonTooltipWrapper = buttonTitle\n ? withTooltip(closeButtonDisplay, buttonTitle, \"top\")\n : closeButtonDisplay;\n\n return (\n <ClassNames>\n {({ css, cx }) => (\n <MuiDialog\n container={document.getElementById(rootId || \"\") || document.body}\n className={cx(dialogClasses.root, className, classes?.root)}\n id={id}\n ref={measuredRef}\n open={open}\n fullScreen={fullscreen}\n onClose={(event, reason) => wrappedClose(event, undefined, reason)}\n onKeyDown={keyDownHandler}\n fullWidth\n maxWidth={false}\n slots={{\n backdrop: (backdropProps) => (\n <StyledBackdrop\n open={open}\n onClick={(event) => wrappedClose(event)}\n $backColor={\n activeTheme?.colors?.modes[selectedMode].atmo4 ||\n theme.colors.atmo4\n }\n {...backdropProps}\n />\n ),\n }}\n classes={{ container: css({ position: \"relative\" }) }}\n BackdropProps={{\n classes: {\n root: cx(dialogClasses.background, classes?.background),\n },\n }}\n PaperProps={{\n classes: {\n root: cx(\n dialogClasses.paper,\n fullscreen && cx(dialogClasses.fullscreen, \"fullscreen\"),\n css(styles.paper),\n css({ position: \"absolute\" }),\n classes?.paper,\n fullscreen && classes?.fullscreen\n ),\n },\n }}\n aria-modal\n {...others}\n >\n <StyledClose\n id={setId(id, \"close\")}\n className={cx(dialogClasses.closeButton, classes?.closeButton)}\n variant=\"secondaryGhost\"\n onClick={(event) => wrappedClose(event, true, undefined)}\n aria-label={buttonTitle}\n >\n <CloseButtonTooltipWrapper />\n </StyledClose>\n {children && typeof children === \"object\"\n ? React.Children.map(\n children,\n (c: React.ReactNode) =>\n c &&\n React.cloneElement(c as React.ReactElement, { fullscreen })\n )\n : children}\n </MuiDialog>\n )}\n </ClassNames>\n );\n};\n"],"names":["HvDialog","classes","className","id","children","open","onClose","firstFocusable","buttonTitle","fullscreen","disableBackdropClick","others","fullScreen","activeTheme","selectedMode","rootId","useTheme","focusableQueue","useRef","first","undefined","last","wrappedClose","event","bypassValidation","reason","measuredRef","useCallback","node","focusableList","getFocusableList","current","length","isNil","focus","element","document","getElementById","warn","keyDownHandler","isKeypress","keyboardCodes","Tab","target","shiftKey","preventDefault","Esc","onEscapeKeyDown","disableEscapeKeyDown","stopPropagation","closeButtonDisplay","_jsx","Close","role","CloseButtonTooltipWrapper","withTooltip","ClassNames","css","cx","MuiDialog","container","body","dialogClasses","root","ref","onKeyDown","fullWidth","maxWidth","slots","backdrop","backdropProps","StyledBackdrop","onClick","$backColor","colors","modes","atmo4","theme","position","BackdropProps","background","PaperProps","paper","styles","StyledClose","setId","closeButton","variant","React","Children","map","c","cloneElement"],"mappings":";;;;;;;;;;;;;;;AA0CO,MAAMA,WAAWA,CAAC;AAAA,EACvBC;AAAAA,EACAC;AAAAA,EACAC;AAAAA,EACAC;AAAAA,EACAC,OAAO;AAAA,EACPC;AAAAA,EACAC;AAAAA,EACAC,cAAc;AAAA,EACdC,aAAa;AAAA,EACbC,uBAAuB;AAAA,EACvB,GAAGC;AACU,MAAM;AACnB,SAAQA,OAAeC;AAEjB,QAAA;AAAA,IAAEC;AAAAA,IAAaC;AAAAA,IAAcC;AAAAA,MAAWC,SAAU;AAExD,QAAMC,iBAAiBC,OAGpB;AAAA,IAAEC,OAAOC;AAAAA,IAAWC,MAAMD;AAAAA,EAAAA,CAAW;AAKxC,QAAME,eAAeA,CACnBC,OACAC,mBAA4B,OAC5BC,WACG;AACH,QAAID,kBAAkB;AACpBlB,yCAAUiB,OAAOE;AAAAA,IAAM,WACd,CAACf,sBAAsB;AAChCJ,yCAAUiB,OAAOE;AAAAA,IACnB;AAAA,EAAA;AAGIC,QAAAA,cAAcC,YACjBC,CAAS,SAAA;AACR,QAAIA,MAAM;AACFC,YAAAA,gBAAgBC,iBAAiBF,IAAI;AAC3CX,qBAAec,UAAU;AAAA,QACvBZ,OAAOU,cAAc,CAAC;AAAA,QACtBR,MAAMQ,cAAcA,cAAcG,SAAS,CAAC;AAAA,MAAA;AAE9C,UAAIC,MAAM1B,cAAc;AAAiB,sBAAA,CAAC,EAAE2B;WACvC;AACH,c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wB,aAAarF,mCAASqF,WAAW;AAAA,QAC7DC,SAAQ;AAAA,QACRf,SAAUjD,CAAAA,UAAUD,aAAaC,OAAO,MAAMH,MAAS;AAAA,QACvD,cAAYZ;AAAAA,QAAYJ,UAExB+C,oBAACG,2BAAyB,EAAA;AAAA,MAAG,CAAA,GAE9BlD,YAAY,OAAOA,aAAa,WAC7BoF,eAAMC,SAASC,IACbtF,UACA,CAACuF,MACCA,KACAH,eAAMI,aAAaD,GAAyB;AAAA,QAAElF;AAAAA,MAAAA,CAAY,CAAC,IAE/DL,QAAQ;AAAA,IAAA,CAAA;AAAA,EAAA,CAGL;AAEjB;"}
|
|
@@ -74,19 +74,20 @@ const HvDropDownMenu = ({
|
|
|
74
74
|
};
|
|
75
75
|
return /* @__PURE__ */ jsx(ClassNames, {
|
|
76
76
|
children: ({
|
|
77
|
-
css
|
|
77
|
+
css,
|
|
78
|
+
cx
|
|
78
79
|
}) => /* @__PURE__ */ jsx(StyledBaseDropDown, {
|
|
79
80
|
id,
|
|
80
|
-
className:
|
|
81
|
+
className: cx(dropDownMenuClasses.container, className, classes == null ? void 0 : classes.container),
|
|
81
82
|
classes: {
|
|
82
|
-
root:
|
|
83
|
+
root: cx(dropDownMenuClasses.root, css({
|
|
83
84
|
display: "inline-block",
|
|
84
85
|
width: "auto",
|
|
85
86
|
"&.focus-visible $icon": {
|
|
86
87
|
...outlineStyles
|
|
87
88
|
}
|
|
88
|
-
})),
|
|
89
|
-
container:
|
|
89
|
+
}), classes == null ? void 0 : classes.root),
|
|
90
|
+
container: cx(dropDownMenuClasses.baseContainer, classes == null ? void 0 : classes.baseContainer)
|
|
90
91
|
},
|
|
91
92
|
expanded: open && !disabled,
|
|
92
93
|
component: headerComponent,
|
|
@@ -115,7 +116,7 @@ const HvDropDownMenu = ({
|
|
|
115
116
|
},
|
|
116
117
|
onKeyDown: handleKeyDown,
|
|
117
118
|
classes: {
|
|
118
|
-
root:
|
|
119
|
+
root: cx(dropDownMenuClasses.menuList, classes == null ? void 0 : classes.menuList)
|
|
119
120
|
}
|
|
120
121
|
})
|
|
121
122
|
})
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DropDownMenu.js","sources":["../../../../src/components/DropDownMenu/DropDownMenu.tsx"],"sourcesContent":["import { clsx } from \"clsx\";\nimport { useMemo } from \"react\";\nimport { ClassNames } from \"@emotion/react\";\nimport { theme } from \"@hitachivantara/uikit-styles\";\nimport { MoreOptionsVertical } from \"@hitachivantara/uikit-react-icons\";\n\nimport { useControlled } from \"@core/hooks\";\nimport { HvBaseProps } from \"@core/types\";\nimport withId from \"@core/hocs/withId\";\nimport {\n isKeypress,\n keyboardCodes,\n outlineStyles,\n setId,\n getPrevNextFocus,\n} from \"@core/utils\";\n\nimport {\n HvBaseDropdownProps,\n HvButtonVariant,\n HvList,\n HvListValue,\n} from \"@core/components\";\nimport {\n StyledBaseDropDown,\n StyledButton,\n StyledPanel,\n} from \"./DropDownMenu.styles\";\nimport dropDownMenuClasses, {\n HvDropDownMenuClasses,\n} from \"./dropDownMenuClasses\";\n\nexport interface HvDropDownMenuProps\n extends HvBaseProps<HTMLDivElement, \"onClick\"> {\n /** Icon. */\n icon?: React.ReactElement;\n /**\n * A list containing the elements to be rendered.\n *\n * - label: The label of the element to be rendered.\n * - selected: The selection state of the element.\n * - disabled: The disabled state of the element.\n * - icon: The icon node to be rendered on the left.\n * - showNavIcon: If true renders the navigation icon on the right.\n */\n dataList: HvListValue[];\n /** Placement of the dropdown. */\n placement?: \"left\" | \"right\";\n /** Disable the portal behavior. The children stay within it's parent DOM hierarchy. */\n disablePortal?: boolean;\n /** Function executed on toggle of the dropdown. Should receive the open status. */\n onToggle?: (event: Event, open: boolean) => void;\n /** Function executed in each onClick. Should received the clicked element. */\n onClick?: (\n event: React.ChangeEvent<HTMLLIElement>,\n value: HvListValue\n ) => void;\n /** Keep the Dropdown Menu opened after clicking one option */\n keepOpened?: boolean;\n /** Defines if the component is disabled. */\n disabled?: boolean;\n /** If true it should be displayed open. */\n expanded?: boolean;\n /** When uncontrolled, defines the initial expanded state. */\n defaultExpanded?: boolean;\n /** The variant to be used in the header. */\n category?: HvButtonVariant;\n /** A Jss Object used to override or extend the styles applied to the component. */\n classes?: HvDropDownMenuClasses;\n}\n\n/**\n * A drop-down menu is a graphical control element, similar to a list box, that allows the user to choose a value from a list.\n */\nconst HvDropDownMenu = ({\n id,\n classes,\n className,\n icon,\n placement = \"right\",\n dataList,\n disablePortal = false,\n onToggle,\n onClick,\n keepOpened = true,\n disabled = false,\n expanded,\n defaultExpanded = false,\n category = \"secondaryGhost\",\n ...others\n}: HvDropDownMenuProps) => {\n const [open, setOpen] = useControlled(expanded, Boolean(defaultExpanded));\n const focusNodes = getPrevNextFocus(setId(id, \"icon-button\"));\n\n const listId = setId(id, \"list\");\n\n const handleClose = (event) => {\n // this will only run if uncontrolled\n setOpen(false);\n onToggle?.(event, false);\n };\n\n // If the ESCAPE key is pressed inside the list, the close handler must be called.\n const handleKeyDown = (event) => {\n if (isKeypress(event, keyboardCodes.Tab)) {\n const node = event.shiftKey ? focusNodes.prevFocus : focusNodes.nextFocus;\n if (node) setTimeout(() => node.focus(), 0);\n handleClose(event);\n }\n event.preventDefault();\n };\n\n const setFocusToContent = (containerRef) => {\n containerRef?.getElementsByTagName(\"li\")[0]?.focus();\n };\n\n const headerComponent = (\n <StyledButton\n icon\n variant={category}\n id={setId(id, \"icon-button\")}\n className={clsx(\n dropDownMenuClasses.icon,\n classes?.icon,\n open && clsx(dropDownMenuClasses.iconSelected, classes?.iconSelected)\n )}\n aria-expanded={open}\n disabled={disabled}\n aria-label=\"Dropdown menu\"\n $open={open}\n >\n {icon || (\n <MoreOptionsVertical color={disabled ? \"secondary_60\" : undefined} />\n )}\n </StyledButton>\n );\n\n const condensed = useMemo(() => dataList.every((el) => !el.icon), [dataList]);\n const popperStyle: HvBaseDropdownProps[\"popperProps\"] = {\n style: {\n zIndex: theme.zIndices.tooltip,\n width: \"auto\",\n position: \"relative\",\n },\n };\n\n return (\n <ClassNames>\n {({ css }) => (\n <StyledBaseDropDown\n id={id}\n className={clsx(\n className,\n dropDownMenuClasses.container,\n classes?.container\n )}\n classes={{\n root: clsx(\n dropDownMenuClasses.root,\n classes?.root,\n css({\n display: \"inline-block\",\n width: \"auto\",\n \"&.focus-visible $icon\": {\n ...outlineStyles,\n },\n })\n ),\n container: clsx(\n dropDownMenuClasses.baseContainer,\n classes?.baseContainer\n ),\n }}\n expanded={open && !disabled}\n component={headerComponent}\n aria-haspopup=\"menu\"\n placement={placement}\n variableWidth\n disablePortal={disablePortal}\n onToggle={(e, s) => {\n // this will only run if uncontrolled\n setOpen(s);\n onToggle?.(e, s);\n }}\n disabled={disabled}\n onContainerCreation={setFocusToContent}\n popperProps={popperStyle}\n {...others}\n >\n <StyledPanel>\n <HvList\n id={listId}\n values={dataList}\n selectable={false}\n condensed={condensed}\n onClick={(event, item) => {\n if (!keepOpened) handleClose(event);\n onClick?.(event, item);\n }}\n onKeyDown={handleKeyDown}\n classes={{\n root: clsx(dropDownMenuClasses.menuList, classes?.menuList),\n }}\n />\n </StyledPanel>\n </StyledBaseDropDown>\n )}\n </ClassNames>\n );\n};\n\nexport default withId(HvDropDownMenu);\n"],"names":["HvDropDownMenu","id","classes","className","icon","placement","dataList","disablePortal","onToggle","onClick","keepOpened","disabled","expanded","defaultExpanded","category","others","open","setOpen","useControlled","Boolean","focusNodes","getPrevNextFocus","setId","listId","handleClose","event","handleKeyDown","isKeypress","keyboardCodes","Tab","node","shiftKey","prevFocus","nextFocus","setTimeout","focus","preventDefault","setFocusToContent","containerRef","getElementsByTagName","headerComponent","StyledButton","variant","clsx","dropDownMenuClasses","iconSelected","$open","children","_jsx","MoreOptionsVertical","color","undefined","condensed","useMemo","every","el","popperStyle","style","zIndex","theme","zIndices","tooltip","width","position","ClassNames","css","StyledBaseDropDown","container","root","display","outlineStyles","baseContainer","component","variableWidth","e","s","onContainerCreation","popperProps","StyledPanel","HvList","values","selectable","item","onK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,IAAIsB;AAAAA,UACJyD,QAAQ1E;AAAAA,UACR2E,YAAY;AAAA,UACZ7B;AAAAA,UACA3C,SAASA,CAACgB,OAAOyD,SAAS;AACxB,gBAAI,CAACxE;AAAYc,0BAAYC,KAAK;AAClChB,+CAAUgB,OAAOyD;AAAAA,UACnB;AAAA,UACAC,WAAWzD;AAAAA,UACXxB,SAAS;AAAA,YACPkE,MAAMzB,KAAKC,oBAAoBwC,UAAUlF,mCAASkF,QAAQ;AAAA,UAC5D;AAAA,QAAA,CAAE;AAAA,MAAA,CACF;AAAA,IAAA,CACU;AAAA,EAAA,CAGP;AAEjB;AAEA,MAAeC,mBAAAA,OAAOrF,cAAc;"}
|
|
1
|
+
{"version":3,"file":"DropDownMenu.js","sources":["../../../../src/components/DropDownMenu/DropDownMenu.tsx"],"sourcesContent":["import { clsx } from \"clsx\";\nimport { useMemo } from \"react\";\nimport { ClassNames } from \"@emotion/react\";\nimport { theme } from \"@hitachivantara/uikit-styles\";\nimport { MoreOptionsVertical } from \"@hitachivantara/uikit-react-icons\";\nimport { useControlled } from \"@core/hooks\";\nimport { HvBaseProps } from \"@core/types\";\nimport withId from \"@core/hocs/withId\";\nimport {\n isKeypress,\n keyboardCodes,\n outlineStyles,\n setId,\n getPrevNextFocus,\n} from \"@core/utils\";\n\nimport {\n HvBaseDropdownProps,\n HvButtonVariant,\n HvList,\n HvListValue,\n} from \"@core/components\";\nimport {\n StyledBaseDropDown,\n StyledButton,\n StyledPanel,\n} from \"./DropDownMenu.styles\";\nimport dropDownMenuClasses, {\n HvDropDownMenuClasses,\n} from \"./dropDownMenuClasses\";\n\nexport interface HvDropDownMenuProps\n extends HvBaseProps<HTMLDivElement, \"onClick\"> {\n /** Icon. */\n icon?: React.ReactElement;\n /**\n * A list containing the elements to be rendered.\n *\n * - label: The label of the element to be rendered.\n * - selected: The selection state of the element.\n * - disabled: The disabled state of the element.\n * - icon: The icon node to be rendered on the left.\n * - showNavIcon: If true renders the navigation icon on the right.\n */\n dataList: HvListValue[];\n /** Placement of the dropdown. */\n placement?: \"left\" | \"right\";\n /** Disable the portal behavior. The children stay within it's parent DOM hierarchy. */\n disablePortal?: boolean;\n /** Function executed on toggle of the dropdown. Should receive the open status. */\n onToggle?: (event: Event, open: boolean) => void;\n /** Function executed in each onClick. Should received the clicked element. */\n onClick?: (\n event: React.ChangeEvent<HTMLLIElement>,\n value: HvListValue\n ) => void;\n /** Keep the Dropdown Menu opened after clicking one option */\n keepOpened?: boolean;\n /** Defines if the component is disabled. */\n disabled?: boolean;\n /** If true it should be displayed open. */\n expanded?: boolean;\n /** When uncontrolled, defines the initial expanded state. */\n defaultExpanded?: boolean;\n /** The variant to be used in the header. */\n category?: HvButtonVariant;\n /** A Jss Object used to override or extend the styles applied to the component. */\n classes?: HvDropDownMenuClasses;\n}\n\n/**\n * A drop-down menu is a graphical control element, similar to a list box, that allows the user to choose a value from a list.\n */\nconst HvDropDownMenu = ({\n id,\n classes,\n className,\n icon,\n placement = \"right\",\n dataList,\n disablePortal = false,\n onToggle,\n onClick,\n keepOpened = true,\n disabled = false,\n expanded,\n defaultExpanded = false,\n category = \"secondaryGhost\",\n ...others\n}: HvDropDownMenuProps) => {\n const [open, setOpen] = useControlled(expanded, Boolean(defaultExpanded));\n const focusNodes = getPrevNextFocus(setId(id, \"icon-button\"));\n\n const listId = setId(id, \"list\");\n\n const handleClose = (event) => {\n // this will only run if uncontrolled\n setOpen(false);\n onToggle?.(event, false);\n };\n\n // If the ESCAPE key is pressed inside the list, the close handler must be called.\n const handleKeyDown = (event) => {\n if (isKeypress(event, keyboardCodes.Tab)) {\n const node = event.shiftKey ? focusNodes.prevFocus : focusNodes.nextFocus;\n if (node) setTimeout(() => node.focus(), 0);\n handleClose(event);\n }\n event.preventDefault();\n };\n\n const setFocusToContent = (containerRef) => {\n containerRef?.getElementsByTagName(\"li\")[0]?.focus();\n };\n\n const headerComponent = (\n <StyledButton\n icon\n variant={category}\n id={setId(id, \"icon-button\")}\n className={clsx(\n dropDownMenuClasses.icon,\n classes?.icon,\n open && clsx(dropDownMenuClasses.iconSelected, classes?.iconSelected)\n )}\n aria-expanded={open}\n disabled={disabled}\n aria-label=\"Dropdown menu\"\n $open={open}\n >\n {icon || (\n <MoreOptionsVertical color={disabled ? \"secondary_60\" : undefined} />\n )}\n </StyledButton>\n );\n\n const condensed = useMemo(() => dataList.every((el) => !el.icon), [dataList]);\n const popperStyle: HvBaseDropdownProps[\"popperProps\"] = {\n style: {\n zIndex: theme.zIndices.tooltip,\n width: \"auto\",\n position: \"relative\",\n },\n };\n\n return (\n <ClassNames>\n {({ css, cx }) => (\n <StyledBaseDropDown\n id={id}\n className={cx(\n dropDownMenuClasses.container,\n className,\n classes?.container\n )}\n classes={{\n root: cx(\n dropDownMenuClasses.root,\n css({\n display: \"inline-block\",\n width: \"auto\",\n \"&.focus-visible $icon\": {\n ...outlineStyles,\n },\n }),\n classes?.root\n ),\n container: cx(\n dropDownMenuClasses.baseContainer,\n classes?.baseContainer\n ),\n }}\n expanded={open && !disabled}\n component={headerComponent}\n aria-haspopup=\"menu\"\n placement={placement}\n variableWidth\n disablePortal={disablePortal}\n onToggle={(e, s) => {\n // this will only run if uncontrolled\n setOpen(s);\n onToggle?.(e, s);\n }}\n disabled={disabled}\n onContainerCreation={setFocusToContent}\n popperProps={popperStyle}\n {...others}\n >\n <StyledPanel>\n <HvList\n id={listId}\n values={dataList}\n selectable={false}\n condensed={condensed}\n onClick={(event, item) => {\n if (!keepOpened) handleClose(event);\n onClick?.(event, item);\n }}\n onKeyDown={handleKeyDown}\n classes={{\n root: cx(dropDownMenuClasses.menuList, classes?.menuList),\n }}\n />\n </StyledPanel>\n </StyledBaseDropDown>\n )}\n </ClassNames>\n );\n};\n\nexport default withId(HvDropDownMenu);\n"],"names":["HvDropDownMenu","id","classes","className","icon","placement","dataList","disablePortal","onToggle","onClick","keepOpened","disabled","expanded","defaultExpanded","category","others","open","setOpen","useControlled","Boolean","focusNodes","getPrevNextFocus","setId","listId","handleClose","event","handleKeyDown","isKeypress","keyboardCodes","Tab","node","shiftKey","prevFocus","nextFocus","setTimeout","focus","preventDefault","setFocusToContent","containerRef","getElementsByTagName","headerComponent","StyledButton","variant","clsx","dropDownMenuClasses","iconSelected","$open","children","_jsx","MoreOptionsVertical","color","undefined","condensed","useMemo","every","el","popperStyle","style","zIndex","theme","zIndices","tooltip","width","position","ClassNames","css","cx","StyledBaseDropDown","container","root","display","outlineStyles","baseContainer","component","variableWidth","e","s","onContainerCreation","popperProps","StyledPanel","HvList","values","selectable","item","onKeyDown","menuList","withId"],"mappings":";;;;;;;;;;;;;;;;AAyEA,MAAMA,iBAAiBA,CAAC;AAAA,EACtBC;AAAAA,EACAC;AAAAA,EACAC;AAAAA,EACAC;AAAAA,EACAC,YAAY;AAAA,EACZC;AAAAA,EACAC,gBAAgB;AAAA,EAChBC;AAAAA,EACAC;AAAAA,EACAC,aAAa;AAAA,EACbC,WAAW;AAAA,EACXC;AAAAA,EACAC,kBAAkB;AAAA,EAClBC,WAAW;AAAA,EACX,GAAGC;AACgB,MAAM;AACnB,QAAA,CAACC,MAAMC,OAAO,IAAIC,cAAcN,UAAUO,QAAQN,eAAe,CAAC;AACxE,QAAMO,aAAaC,iBAAiBC,MAAMrB,IAAI,aAAa,CAAC;AAEtDsB,QAAAA,SAASD,MAAMrB,IAAI,MAAM;AAE/B,QAAMuB,cAAeC,CAAU,UAAA;AAE7BR,YAAQ,KAAK;AACbT,yCAAWiB,OAAO;AAAA,EAAK;AAIzB,QAAMC,gBAAiBD,CAAU,UAAA;AAC/B,QAAIE,WAAWF,OAAOG,cAAcC,GAAG,GAAG;AACxC,YAAMC,OAAOL,MAAMM,WAAWX,WAAWY,YAAYZ,WAAWa;AAC5DH,UAAAA;AAAMI,mBAAW,MAAMJ,KAAKK,MAAK,GAAI,CAAC;AAC1CX,kBAAYC,KAAK;AAAA,IACnB;AACAA,UAAMW,eAAgB;AAAA,EAAA;AAGxB,QAAMC,oBAAqBC,CAAiB,iB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AACL;AAAAA,MACnB8D,WAAWjC;AAAAA,MACX,iBAAc;AAAA,MACdnC;AAAAA,MACAqE,eAAa;AAAA,MACbnE;AAAAA,MACAC,UAAUA,CAACmE,GAAGC,MAAM;AAElB3D,gBAAQ2D,CAAC;AACTpE,6CAAWmE,GAAGC;AAAAA,MAChB;AAAA,MACAjE;AAAAA,MACAkE,qBAAqBxC;AAAAA,MACrByC,aAAatB;AAAAA,MAAY,GACrBzC;AAAAA,MAAMgC,8BAETgC,aAAW;AAAA,QAAAhC,8BACTiC,QAAM;AAAA,UACL/E,IAAIsB;AAAAA,UACJ0D,QAAQ3E;AAAAA,UACR4E,YAAY;AAAA,UACZ9B;AAAAA,UACA3C,SAASA,CAACgB,OAAO0D,SAAS;AACxB,gBAAI,CAACzE;AAAYc,0BAAYC,KAAK;AAClChB,+CAAUgB,OAAO0D;AAAAA,UACnB;AAAA,UACAC,WAAW1D;AAAAA,UACXxB,SAAS;AAAA,YACPmE,MAAMH,GAAGtB,oBAAoByC,UAAUnF,mCAASmF,QAAQ;AAAA,UAC1D;AAAA,QAAA,CAAE;AAAA,MAAA,CACF;AAAA,IAAA,CACU;AAAA,EAAA,CAGP;AAEjB;AAEA,MAAeC,mBAAAA,OAAOtF,cAAc;"}
|
|
@@ -2,7 +2,6 @@ import { useContext } from "react";
|
|
|
2
2
|
import { HvFilterGroupContext } from "../FilterGroupContext.js";
|
|
3
3
|
import { styles } from "./Counter.styles.js";
|
|
4
4
|
import { ClassNames } from "@emotion/react";
|
|
5
|
-
import { clsx } from "clsx";
|
|
6
5
|
import filterGroupCounterClasses from "./counterClasses.js";
|
|
7
6
|
import { jsx, jsxs } from "@emotion/react/jsx-runtime";
|
|
8
7
|
const getExistingFiltersById = (idx, filterValues, filterOptions) => {
|
|
@@ -37,11 +36,12 @@ const HvFilterGroupCounter = ({
|
|
|
37
36
|
const totalCounter = options.reduce((acc, option) => acc + option.data.length, 0);
|
|
38
37
|
return /* @__PURE__ */ jsx(ClassNames, {
|
|
39
38
|
children: ({
|
|
40
|
-
css
|
|
39
|
+
css,
|
|
40
|
+
cx
|
|
41
41
|
}) => /* @__PURE__ */ jsxs("div", {
|
|
42
|
-
className:
|
|
42
|
+
className: cx(filterGroupCounterClasses.root, css(styles.root), className, classes == null ? void 0 : classes.root),
|
|
43
43
|
children: [partialCounter > 0 ? /* @__PURE__ */ jsx("p", {
|
|
44
|
-
className:
|
|
44
|
+
className: cx(filterGroupCounterClasses.partialCounter, css(styles.partialCounter), classes == null ? void 0 : classes.partialCounter),
|
|
45
45
|
children: partialCounter
|
|
46
46
|
}) : partialCounter, ` / ${totalCounter}`]
|
|
47
47
|
})
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Counter.js","sources":["../../../../../src/components/FilterGroup/Counter/Counter.tsx"],"sourcesContent":["import { useContext } from \"react\";\nimport { HvFilterGroupContext } from \"../FilterGroupContext\";\nimport { styles } from \"./Counter.styles\";\nimport { HvFilterGroupFilters, HvFilterGroupValue } from \"../FilterGroup\";\nimport { ClassNames } from \"@emotion/react\";\nimport
|
|
1
|
+
{"version":3,"file":"Counter.js","sources":["../../../../../src/components/FilterGroup/Counter/Counter.tsx"],"sourcesContent":["import { useContext } from \"react\";\nimport { HvFilterGroupContext } from \"../FilterGroupContext\";\nimport { styles } from \"./Counter.styles\";\nimport { HvFilterGroupFilters, HvFilterGroupValue } from \"../FilterGroup\";\nimport { ClassNames } from \"@emotion/react\";\nimport filterGroupCounterClasses, {\n HvFilterGroupCounterClasses,\n} from \"./counterClasses\";\n\nexport interface HvFilterGroupCounterProps {\n className?: string;\n id?: string;\n classes?: HvFilterGroupCounterClasses;\n}\n\nconst getExistingFiltersById = (\n idx: number,\n filterValues: HvFilterGroupValue,\n filterOptions: HvFilterGroupFilters\n) => {\n let total = 0;\n filterValues[idx]?.forEach((fv) => {\n if (filterOptions[idx]?.data.find((f) => f.id === fv)) {\n total += 1;\n }\n });\n return total;\n};\n\nexport const HvFilterGroupCounter = ({\n className,\n id,\n classes,\n}: HvFilterGroupCounterProps) => {\n const {\n filterOptions,\n filterValues = [],\n appliedFilters = [],\n } = useContext(HvFilterGroupContext);\n\n const options =\n id && filterOptions.find((option) => option.id === id)\n ? ([\n filterOptions.find((option) => option.id === id),\n ] as HvFilterGroupFilters)\n : filterOptions;\n const optionIdx = filterOptions.findIndex((option) => option.id === id);\n\n let groupsCounter = 0;\n appliedFilters\n ?.flat()\n ?.filter((elem) => elem !== undefined)\n .forEach((fg, i) => {\n groupsCounter += getExistingFiltersById(i, filterValues, filterOptions);\n });\n\n const partialCounter = id\n ? getExistingFiltersById(optionIdx, filterValues, filterOptions) || 0\n : groupsCounter;\n\n const totalCounter = options.reduce(\n (acc, option) => acc + option.data.length,\n 0\n );\n\n return (\n <ClassNames>\n {({ css, cx }) => (\n <div\n className={cx(\n filterGroupCounterClasses.root,\n css(styles.root),\n className,\n classes?.root\n )}\n >\n {partialCounter > 0 ? (\n <p\n className={cx(\n filterGroupCounterClasses.partialCounter,\n css(styles.partialCounter),\n classes?.partialCounter\n )}\n >\n {partialCounter}\n </p>\n ) : (\n partialCounter\n )}\n {` / ${totalCounter}`}\n </div>\n )}\n </ClassNames>\n );\n};\n"],"names":["getExistingFiltersById","idx","filterValues","filterOptions","total","forEach","fv","data","find","f","id","HvFilterGroupCounter","className","classes","appliedFilters","useContext","HvFilterGroupContext","options","option","optionIdx","findIndex","groupsCounter","flat","filter","elem","undefined","fg","i","partialCounter","totalCounter","reduce","acc","length","ClassNames","children","css","cx","filterGroupCounterClasses","root","styles"],"mappings":";;;;;;AAeA,MAAMA,yBAAyBA,CAC7BC,KACAC,cACAC,kBACG;;AACH,MAAIC,QAAQ;AACCH,qBAAAA,GAAG,MAAHA,mBAAMI,QAASC,CAAO,OAAA;;AAC7BH,SAAAA,MAAAA,cAAcF,GAAG,MAAjBE,gBAAAA,IAAoBI,KAAKC,KAAMC,CAAMA,MAAAA,EAAEC,OAAOJ,KAAK;AAC5C,eAAA;AAAA,IACX;AA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B;"}
|
|
@@ -3,7 +3,6 @@ import filterGroupContentClasses from "./filterContentClasses.js";
|
|
|
3
3
|
import { HvFilterGroupContext } from "../FilterGroupContext.js";
|
|
4
4
|
import { useState, useContext, useRef, useMemo } from "react";
|
|
5
5
|
import { Filters } from "@hitachivantara/uikit-react-icons";
|
|
6
|
-
import { clsx } from "clsx";
|
|
7
6
|
import { ClassNames } from "@emotion/react";
|
|
8
7
|
import { jsxs, Fragment, jsx } from "@emotion/react/jsx-runtime";
|
|
9
8
|
import { HvFilterGroupLeftPanel } from "../LeftPanel/LeftPanel.js";
|
|
@@ -82,15 +81,16 @@ const HvFilterGroupContent = ({
|
|
|
82
81
|
}), [labels == null ? void 0 : labels.placeholder]);
|
|
83
82
|
return /* @__PURE__ */ jsx(ClassNames, {
|
|
84
83
|
children: ({
|
|
85
|
-
css
|
|
84
|
+
css,
|
|
85
|
+
cx
|
|
86
86
|
}) => /* @__PURE__ */ jsxs(HvBaseDropdown, {
|
|
87
87
|
id: setId(id, "dropdown"),
|
|
88
88
|
role: "combobox",
|
|
89
89
|
classes: {
|
|
90
|
-
root:
|
|
91
|
-
panel:
|
|
92
|
-
selection:
|
|
93
|
-
header:
|
|
90
|
+
root: cx(filterGroupContentClasses.dropdown, classes == null ? void 0 : classes.dropdown),
|
|
91
|
+
panel: cx(filterGroupContentClasses.panel, css(styles.panel), classes == null ? void 0 : classes.panel),
|
|
92
|
+
selection: cx(filterGroupContentClasses.baseDropdownSelection, css(styles.baseDropdownSelection), classes == null ? void 0 : classes.baseDropdownSelection),
|
|
93
|
+
header: cx(filterGroupContentClasses.header, css(styles.header), classes == null ? void 0 : classes.header)
|
|
94
94
|
},
|
|
95
95
|
disabled,
|
|
96
96
|
disablePortal,
|
|
@@ -119,22 +119,22 @@ const HvFilterGroupContent = ({
|
|
|
119
119
|
ref: focusTarget,
|
|
120
120
|
tabIndex: -1
|
|
121
121
|
}), /* @__PURE__ */ jsxs("div", {
|
|
122
|
-
className:
|
|
122
|
+
className: cx(filterGroupContentClasses.root, css(styles.root), classes == null ? void 0 : classes.root),
|
|
123
123
|
style: {
|
|
124
124
|
height
|
|
125
125
|
},
|
|
126
126
|
children: [/* @__PURE__ */ jsx(HvFilterGroupLeftPanel, {
|
|
127
127
|
id,
|
|
128
|
-
className:
|
|
128
|
+
className: cx(filterGroupContentClasses.leftSidePanel, css(styles.leftSidePanel), classes == null ? void 0 : classes.leftSidePanel),
|
|
129
129
|
emptyElement: leftEmptyElement
|
|
130
130
|
}), /* @__PURE__ */ jsx(HvFilterGroupRightPanel, {
|
|
131
131
|
id,
|
|
132
|
-
className:
|
|
132
|
+
className: cx(filterGroupContentClasses.rightSidePanel, css(styles.rightSidePanel), classes == null ? void 0 : classes.rightSidePanel),
|
|
133
133
|
emptyElement: rightEmptyElement,
|
|
134
134
|
labels
|
|
135
135
|
})]
|
|
136
136
|
}), /* @__PURE__ */ jsxs(HvActionBar, {
|
|
137
|
-
className:
|
|
137
|
+
className: cx(filterGroupContentClasses.actionBar, css(styles.actionBar), classes == null ? void 0 : classes.actionBar),
|
|
138
138
|
children: [/* @__PURE__ */ jsx(HvButton, {
|
|
139
139
|
id: setId(id, "clearFilters-button"),
|
|
140
140
|
disabled: defaultValue ? (defaultValue == null ? void 0 : defaultValue.flat().length) === (filterValues == null ? void 0 : filterValues.flat().length) : (filterValues == null ? void 0 : filterValues.flat().length) === 0,
|
|
@@ -143,14 +143,14 @@ const HvFilterGroupContent = ({
|
|
|
143
143
|
children: labels == null ? void 0 : labels.clearLabel
|
|
144
144
|
}), /* @__PURE__ */ jsx("div", {
|
|
145
145
|
"aria-hidden": "true",
|
|
146
|
-
className:
|
|
146
|
+
className: cx(filterGroupContentClasses.space, css(styles.space), classes == null ? void 0 : classes.space),
|
|
147
147
|
children: " "
|
|
148
148
|
}), /* @__PURE__ */ jsx(HvButton, {
|
|
149
149
|
id: setId(id, "apply-button"),
|
|
150
150
|
disabled: applyDisabled,
|
|
151
151
|
variant: activeTheme == null ? void 0 : activeTheme.filterGroup.applyButtonVariant,
|
|
152
152
|
onClick: onApplyHandler,
|
|
153
|
-
className:
|
|
153
|
+
className: cx(filterGroupContentClasses.applyButton, css(styles.applyButton), classes == null ? void 0 : classes.applyButton),
|
|
154
154
|
children: labels == null ? void 0 : labels.applyLabel
|
|
155
155
|
}), /* @__PURE__ */ jsx(HvButton, {
|
|
156
156
|
id: setId(id, "cancel-button"),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FilterContent.js","sources":["../../../../../src/components/FilterGroup/FilterContent/FilterContent.tsx"],"sourcesContent":["import {\n HvActionBar,\n HvBaseDropdown,\n HvBaseDropdownProps,\n HvButton,\n HvButtonVariant,\n HvFormStatus,\n HvTypography,\n} from \"@core/components\";\nimport { setId } from \"@core/utils\";\nimport {\n HvFilterGroupLabels,\n HvFilterGroupValue,\n HvFilterGroupHorizontalPlacement,\n} from \"../FilterGroup\";\nimport { styles } from \"./FilterContent.styles\";\nimport filterGroupContentClasses, {\n HvFilterGroupContentClasses,\n} from \"./filterContentClasses\";\nimport { HvFilterGroupContext } from \"../FilterGroupContext\";\nimport { useContext, useMemo, useRef, useState } from \"react\";\nimport { Filters } from \"@hitachivantara/uikit-react-icons\";\nimport { clsx } from \"clsx\";\nimport { HvFilterGroupCounter } from \"../Counter\";\nimport { ClassNames } from \"@emotion/react\";\nimport { HvFilterGroupLeftPanel } from \"../LeftPanel\";\nimport { HvFilterGroupRightPanel } from \"../RightPanel\";\nimport { useTheme } from \"@core/hooks\";\n\nexport interface HvFilterGroupContentProps\n extends Omit<HvBaseDropdownProps, \"onChange\"> {\n description?: React.ReactNode;\n status?: HvFormStatus;\n onChange?: (\n event: React.MouseEvent<HTMLButtonElement>,\n value?: HvFilterGroupValue\n ) => void;\n onCancel?: (event: React.MouseEvent<HTMLButtonElement> | Event) => void;\n onClear?: (event: React.MouseEvent<HTMLButtonElement>) => void;\n labels?: HvFilterGroupLabels;\n horizontalPlacement?: HvFilterGroupHorizontalPlacement;\n disablePortal?: boolean;\n escapeWithReference?: boolean;\n height?: string | number;\n leftEmptyElement?: React.ReactNode;\n rightEmptyElement?: React.ReactNode;\n disabled?: boolean;\n classes?: HvFilterGroupContentClasses;\n}\n\nexport const HvFilterGroupContent = ({\n id,\n status,\n disabled = false,\n \"aria-label\": ariaLabel,\n \"aria-labelledby\": ariaLabelledBy,\n description,\n \"aria-describedby\": ariaDescribedBy,\n onChange,\n onCancel,\n onClear,\n labels,\n horizontalPlacement = \"right\",\n disablePortal = true,\n escapeWithReference = true,\n height,\n leftEmptyElement,\n rightEmptyElement,\n classes,\n ...others\n}: HvFilterGroupContentProps) => {\n const { activeTheme } = useTheme();\n\n const [filterGroupOpen, setFilterGroupOpen] = useState<boolean>(false);\n\n const {\n defaultValue,\n filterValues,\n rollbackFilters,\n clearFilters,\n applyFilters,\n applyDisabled,\n } = useContext(HvFilterGroupContext);\n\n const focusTarget = useRef<HTMLDivElement>(null);\n\n const focusOnContainer = () => {\n focusTarget.current?.focus();\n };\n\n const onApplyHandler = (event: React.MouseEvent<HTMLButtonElement>) => {\n applyFilters();\n onChange?.(event, filterValues);\n setFilterGroupOpen(false);\n };\n\n const onCancelHandler = (\n event: React.MouseEvent<HTMLButtonElement> | Event\n ) => {\n rollbackFilters();\n onCancel?.(event);\n setFilterGroupOpen(false);\n };\n\n const onClearHandler = (event: React.MouseEvent<HTMLButtonElement>) => {\n clearFilters();\n onClear?.(event);\n };\n\n const handleToggle = (event: Event, open: boolean) => {\n /* \n If evt is null this toggle wasn't triggered by the user.\n instead it was triggered by the baseDropdown useEffect after\n the datepicker changed the expanded value this baseDropdown behavior needs a review\n */\n if (event === null) return;\n setFilterGroupOpen(open);\n if (!open) onCancelHandler?.(event);\n };\n\n const Header = useMemo(\n () => (\n <>\n <Filters />\n <HvTypography variant=\"label\">{labels?.placeholder}</HvTypography>\n </>\n ),\n [labels?.placeholder]\n );\n\n return (\n <ClassNames>\n {({ css }) => (\n <HvBaseDropdown\n id={setId(id, \"dropdown\")}\n role=\"combobox\"\n classes={{\n root: clsx(classes?.dropdown, filterGroupContentClasses.dropdown),\n panel: clsx(\n classes?.panel,\n filterGroupContentClasses.panel,\n css(styles.panel)\n ),\n selection: clsx(\n classes?.baseDropdownSelection,\n filterGroupContentClasses.baseDropdownSelection,\n css(styles.baseDropdownSelection)\n ),\n header: clsx(\n classes?.header,\n filterGroupContentClasses.header,\n css(styles.header)\n ),\n }}\n disabled={disabled}\n disablePortal={disablePortal}\n variableWidth\n placement={horizontalPlacement}\n expanded={filterGroupOpen}\n onToggle={handleToggle}\n onClickOutside={onCancelHandler}\n onContainerCreation={focusOnContainer}\n placeholder={Header}\n adornment={<HvFilterGroupCounter />}\n popperProps={{\n modifiers: [\n { name: \"preventOverflow\", enabled: escapeWithReference },\n ],\n }}\n aria-haspopup=\"dialog\"\n aria-label={ariaLabel}\n aria-labelledby={ariaLabelledBy}\n aria-invalid={status === \"invalid\" ? true : undefined}\n aria-errormessage={\n status === \"invalid\" ? setId(id, \"error\") : undefined\n }\n aria-describedby={\n [description && setId(id, \"description\"), ariaDescribedBy]\n .join(\" \")\n .trim() || undefined\n }\n {...others}\n >\n <div ref={focusTarget} tabIndex={-1} />\n <div\n className={clsx(\n classes?.root,\n filterGroupContentClasses.root,\n css(styles.root)\n )}\n style={{ height }}\n >\n <HvFilterGroupLeftPanel\n id={id}\n className={clsx(\n classes?.leftSidePanel,\n filterGroupContentClasses.leftSidePanel,\n css(styles.leftSidePanel)\n )}\n emptyElement={leftEmptyElement}\n />\n <HvFilterGroupRightPanel\n id={id}\n className={clsx(\n classes?.rightSidePanel,\n filterGroupContentClasses.rightSidePanel,\n css(styles.rightSidePanel)\n )}\n emptyElement={rightEmptyElement}\n labels={labels}\n />\n </div>\n <HvActionBar\n className={clsx(\n classes?.actionBar,\n filterGroupContentClasses.actionBar,\n css(styles.actionBar)\n )}\n >\n <HvButton\n id={setId(id, \"clearFilters-button\")}\n disabled={\n defaultValue\n ? defaultValue?.flat().length === filterValues?.flat().length\n : filterValues?.flat().length === 0\n }\n variant=\"secondaryGhost\"\n onClick={onClearHandler}\n >\n {labels?.clearLabel}\n </HvButton>\n <div\n aria-hidden=\"true\"\n className={clsx(\n classes?.space,\n filterGroupContentClasses.space,\n css(styles.space)\n )}\n >\n \n </div>\n <HvButton\n id={setId(id, \"apply-button\")}\n disabled={applyDisabled}\n variant={\n activeTheme?.filterGroup.applyButtonVariant as HvButtonVariant\n }\n onClick={onApplyHandler}\n className={clsx(\n filterGroupContentClasses.applyButton,\n css(styles.applyButton),\n classes?.applyButton\n )}\n >\n {labels?.applyLabel}\n </HvButton>\n <HvButton\n id={setId(id, \"cancel-button\")}\n variant={\n activeTheme?.filterGroup.cancelButtonVariant as HvButtonVariant\n }\n onClick={onCancelHandler}\n >\n {labels?.cancelLabel}\n </HvButton>\n </HvActionBar>\n </HvBaseDropdown>\n )}\n </ClassNames>\n );\n};\n"],"names":["HvFilterGroupContent","id","status","disabled","ariaLabel","ariaLabelledBy","description","ariaDescribedBy","onChange","onCancel","onClear","labels","horizontalPlacement","disablePortal","escapeWithReference","height","leftEmptyElement","rightEmptyElement","classes","others","activeTheme","useTheme","filterGroupOpen","setFilterGroupOpen","useState","defaultValue","filterValues","rollbackFilters","clearFilters","applyFilters","applyDisabled","useContext","HvFilterGroupContext","focusTarget","useRef","focusOnContainer","current","focus","onApplyHandler","event","onCancelHandler","onClearHandler","handleToggle","open","Header","useMemo","_jsxs","_Fragment","children","Filters","HvTypography","variant","placeholder","ClassNames","css","HvBaseDropdown","setId","role","root","clsx","dropdown","filterGroupContentClasses","panel","styles","selection","baseDropdownSelection","header","variableWidth","placement","expanded","onToggle","onClickOutside","onContainerCreation","adornment","_jsx","HvFilterGroupCounter","popperProps","modifiers","name","enabled","undefined","join","trim","ref","tabIndex","className","style","HvFilterGroupLeftPanel","leftSidePanel","emptyElement","HvFilterGroupRightPanel","rightSidePanel","HvActionBar","actionBar","HvButton","flat","length","onClick","clearLabel","space","filterGroup","applyButtonV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ASiF,OACTtC,0BAA0BsC,OAC1B7C,IAAIS,OAAOoC,KAAK,CAAC;AAAA,UACjBnD,UACH;AAAA,QAAA,CAEK,GACN0B,oBAACoB,UAAQ;AAAA,UACP7F,IAAIuD,MAAMvD,IAAI,cAAc;AAAA,UAC5BE,UAAU2B;AAAAA,UACVqB,SACE/B,2CAAagF,YAAYC;AAAAA,UAE3BJ,SAAS3D;AAAAA,UACT+C,WAAW1B,KACTE,0BAA0ByC,aAC1BhD,IAAIS,OAAOuC,WAAW,GACtBpF,mCAASoF,WAAW;AAAA,UACpBtD,UAEDrC,iCAAQ4F;AAAAA,QAAAA,CACA,GACX7B,oBAACoB,UAAQ;AAAA,UACP7F,IAAIuD,MAAMvD,IAAI,eAAe;AAAA,UAC7BkD,SACE/B,2CAAagF,YAAYI;AAAAA,UAE3BP,SAASzD;AAAAA,UAAgBQ,UAExBrC,iCAAQ8F;AAAAA,QAAAA,CACA,CAAA;AAAA,MAAA,CACC,CAAA;AAAA,IAAA,CAAA;AAAA,EAAA,CAGP;AAEjB;"}
|
|
1
|
+
{"version":3,"file":"FilterContent.js","sources":["../../../../../src/components/FilterGroup/FilterContent/FilterContent.tsx"],"sourcesContent":["import {\n HvActionBar,\n HvBaseDropdown,\n HvBaseDropdownProps,\n HvButton,\n HvButtonVariant,\n HvFormStatus,\n HvTypography,\n} from \"@core/components\";\nimport { setId } from \"@core/utils\";\nimport {\n HvFilterGroupLabels,\n HvFilterGroupValue,\n HvFilterGroupHorizontalPlacement,\n} from \"../FilterGroup\";\nimport { styles } from \"./FilterContent.styles\";\nimport filterGroupContentClasses, {\n HvFilterGroupContentClasses,\n} from \"./filterContentClasses\";\nimport { HvFilterGroupContext } from \"../FilterGroupContext\";\nimport { useContext, useMemo, useRef, useState } from \"react\";\nimport { Filters } from \"@hitachivantara/uikit-react-icons\";\nimport { HvFilterGroupCounter } from \"../Counter\";\nimport { ClassNames } from \"@emotion/react\";\nimport { HvFilterGroupLeftPanel } from \"../LeftPanel\";\nimport { HvFilterGroupRightPanel } from \"../RightPanel\";\nimport { useTheme } from \"@core/hooks\";\n\nexport interface HvFilterGroupContentProps\n extends Omit<HvBaseDropdownProps, \"onChange\"> {\n description?: React.ReactNode;\n status?: HvFormStatus;\n onChange?: (\n event: React.MouseEvent<HTMLButtonElement>,\n value?: HvFilterGroupValue\n ) => void;\n onCancel?: (event: React.MouseEvent<HTMLButtonElement> | Event) => void;\n onClear?: (event: React.MouseEvent<HTMLButtonElement>) => void;\n labels?: HvFilterGroupLabels;\n horizontalPlacement?: HvFilterGroupHorizontalPlacement;\n disablePortal?: boolean;\n escapeWithReference?: boolean;\n height?: string | number;\n leftEmptyElement?: React.ReactNode;\n rightEmptyElement?: React.ReactNode;\n disabled?: boolean;\n classes?: HvFilterGroupContentClasses;\n}\n\nexport const HvFilterGroupContent = ({\n id,\n status,\n disabled = false,\n \"aria-label\": ariaLabel,\n \"aria-labelledby\": ariaLabelledBy,\n description,\n \"aria-describedby\": ariaDescribedBy,\n onChange,\n onCancel,\n onClear,\n labels,\n horizontalPlacement = \"right\",\n disablePortal = true,\n escapeWithReference = true,\n height,\n leftEmptyElement,\n rightEmptyElement,\n classes,\n ...others\n}: HvFilterGroupContentProps) => {\n const { activeTheme } = useTheme();\n\n const [filterGroupOpen, setFilterGroupOpen] = useState<boolean>(false);\n\n const {\n defaultValue,\n filterValues,\n rollbackFilters,\n clearFilters,\n applyFilters,\n applyDisabled,\n } = useContext(HvFilterGroupContext);\n\n const focusTarget = useRef<HTMLDivElement>(null);\n\n const focusOnContainer = () => {\n focusTarget.current?.focus();\n };\n\n const onApplyHandler = (event: React.MouseEvent<HTMLButtonElement>) => {\n applyFilters();\n onChange?.(event, filterValues);\n setFilterGroupOpen(false);\n };\n\n const onCancelHandler = (\n event: React.MouseEvent<HTMLButtonElement> | Event\n ) => {\n rollbackFilters();\n onCancel?.(event);\n setFilterGroupOpen(false);\n };\n\n const onClearHandler = (event: React.MouseEvent<HTMLButtonElement>) => {\n clearFilters();\n onClear?.(event);\n };\n\n const handleToggle = (event: Event, open: boolean) => {\n /* \n If evt is null this toggle wasn't triggered by the user.\n instead it was triggered by the baseDropdown useEffect after\n the datepicker changed the expanded value this baseDropdown behavior needs a review\n */\n if (event === null) return;\n setFilterGroupOpen(open);\n if (!open) onCancelHandler?.(event);\n };\n\n const Header = useMemo(\n () => (\n <>\n <Filters />\n <HvTypography variant=\"label\">{labels?.placeholder}</HvTypography>\n </>\n ),\n [labels?.placeholder]\n );\n\n return (\n <ClassNames>\n {({ css, cx }) => (\n <HvBaseDropdown\n id={setId(id, \"dropdown\")}\n role=\"combobox\"\n classes={{\n root: cx(filterGroupContentClasses.dropdown, classes?.dropdown),\n panel: cx(\n filterGroupContentClasses.panel,\n css(styles.panel),\n classes?.panel\n ),\n selection: cx(\n filterGroupContentClasses.baseDropdownSelection,\n css(styles.baseDropdownSelection),\n classes?.baseDropdownSelection\n ),\n header: cx(\n filterGroupContentClasses.header,\n css(styles.header),\n classes?.header\n ),\n }}\n disabled={disabled}\n disablePortal={disablePortal}\n variableWidth\n placement={horizontalPlacement}\n expanded={filterGroupOpen}\n onToggle={handleToggle}\n onClickOutside={onCancelHandler}\n onContainerCreation={focusOnContainer}\n placeholder={Header}\n adornment={<HvFilterGroupCounter />}\n popperProps={{\n modifiers: [\n { name: \"preventOverflow\", enabled: escapeWithReference },\n ],\n }}\n aria-haspopup=\"dialog\"\n aria-label={ariaLabel}\n aria-labelledby={ariaLabelledBy}\n aria-invalid={status === \"invalid\" ? true : undefined}\n aria-errormessage={\n status === \"invalid\" ? setId(id, \"error\") : undefined\n }\n aria-describedby={\n [description && setId(id, \"description\"), ariaDescribedBy]\n .join(\" \")\n .trim() || undefined\n }\n {...others}\n >\n <div ref={focusTarget} tabIndex={-1} />\n <div\n className={cx(\n filterGroupContentClasses.root,\n css(styles.root),\n classes?.root\n )}\n style={{ height }}\n >\n <HvFilterGroupLeftPanel\n id={id}\n className={cx(\n filterGroupContentClasses.leftSidePanel,\n css(styles.leftSidePanel),\n classes?.leftSidePanel\n )}\n emptyElement={leftEmptyElement}\n />\n <HvFilterGroupRightPanel\n id={id}\n className={cx(\n filterGroupContentClasses.rightSidePanel,\n css(styles.rightSidePanel),\n classes?.rightSidePanel\n )}\n emptyElement={rightEmptyElement}\n labels={labels}\n />\n </div>\n <HvActionBar\n className={cx(\n filterGroupContentClasses.actionBar,\n css(styles.actionBar),\n classes?.actionBar\n )}\n >\n <HvButton\n id={setId(id, \"clearFilters-button\")}\n disabled={\n defaultValue\n ? defaultValue?.flat().length === filterValues?.flat().length\n : filterValues?.flat().length === 0\n }\n variant=\"secondaryGhost\"\n onClick={onClearHandler}\n >\n {labels?.clearLabel}\n </HvButton>\n <div\n aria-hidden=\"true\"\n className={cx(\n filterGroupContentClasses.space,\n css(styles.space),\n classes?.space\n )}\n >\n \n </div>\n <HvButton\n id={setId(id, \"apply-button\")}\n disabled={applyDisabled}\n variant={\n activeTheme?.filterGroup.applyButtonVariant as HvButtonVariant\n }\n onClick={onApplyHandler}\n className={cx(\n filterGroupContentClasses.applyButton,\n css(styles.applyButton),\n classes?.applyButton\n )}\n >\n {labels?.applyLabel}\n </HvButton>\n <HvButton\n id={setId(id, \"cancel-button\")}\n variant={\n activeTheme?.filterGroup.cancelButtonVariant as HvButtonVariant\n }\n onClick={onCancelHandler}\n >\n {labels?.cancelLabel}\n </HvButton>\n </HvActionBar>\n </HvBaseDropdown>\n )}\n </ClassNames>\n );\n};\n"],"names":["HvFilterGroupContent","id","status","disabled","ariaLabel","ariaLabelledBy","description","ariaDescribedBy","onChange","onCancel","onClear","labels","horizontalPlacement","disablePortal","escapeWithReference","height","leftEmptyElement","rightEmptyElement","classes","others","activeTheme","useTheme","filterGroupOpen","setFilterGroupOpen","useState","defaultValue","filterValues","rollbackFilters","clearFilters","applyFilters","applyDisabled","useContext","HvFilterGroupContext","focusTarget","useRef","focusOnContainer","current","focus","onApplyHandler","event","onCancelHandler","onClearHandler","handleToggle","open","Header","useMemo","_jsxs","_Fragment","children","Filters","HvTypography","variant","placeholder","ClassNames","css","cx","HvBaseDropdown","setId","role","root","filterGroupContentClasses","dropdown","panel","styles","selection","baseDropdownSelection","header","variableWidth","placement","expanded","onToggle","onClickOutside","onContainerCreation","adornment","_jsx","HvFilterGroupCounter","popperProps","modifiers","name","enabled","undefined","join","trim","ref","tabIndex","className","style","HvFilterGroupLeftPanel","leftSidePanel","emptyElement","HvFilterGroupRightPanel","rightSidePanel","HvActionBar","actionBar","HvButton","flat","length","onClick","clearLabel","space","filterGroup","applyButtonVariant","applyButton","applyLabel","cancelButtonVariant","cancelLabel"],"mappings":";;;;;;;;;;;;;;;;AAiDO,MAAMA,uBAAuBA,CAAC;AAAA,EACnCC;AAAAA,EACAC;AAAAA,EACAC,WAAW;AAAA,EACX,cAAcC;AAAAA,EACd,mBAAmBC;AAAAA,EACnBC;AAAAA,EACA,oBAAoBC;AAAAA,EACpBC;AAAAA,EACAC;AAAAA,EACAC;AAAAA,EACAC;AAAAA,EACAC,sBAAsB;AAAA,EACtBC,gBAAgB;AAAA,EAChBC,sBAAsB;AAAA,EACtBC;AAAAA,EACAC;AAAAA,EACAC;AAAAA,EACAC;AAAAA,EACA,GAAGC;AACsB,MAAM;AACzB,QAAA;AAAA,IAAEC;AAAAA,MAAgBC,SAAU;AAElC,QAAM,CAACC,iBAAiBC,kBAAkB,IAAIC,SAAkB,KAAK;AAE/D,QAAA;AAAA,IACJC;AAAAA,IACAC;AAAAA,IACAC;AAAAA,IACAC;AAAAA,IACAC;AAAAA,IACAC;AAAAA,EAAAA,IACEC,WAAWC,oBAAoB;AAE7BC,QAAAA,cAAcC,OAAuB,IAAI;AAE/C,QAAMC,mBAAmBA,MAAM;;AAC7BF,sBAAYG,YAAZH,mBAAqBI;AAAAA,EAAO;AAGxBC,QAAAA,iBAAiBA,CAACC,UAA+C;AACvD;AACd/B,yCAAW+B,OAAOb;AAClBH,uBAAmB,KAAK;AAAA,EAAA;AAGpBiB,QAAAA,kBAAkBA,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AAA,QAClB7C,UAAA,CAEF0B,oBAACoB,UAAQ;AAAA,UACP7F,IAAIwD,MAAMxD,IAAI,qBAAqB;AAAA,UACnCE,UACEsB,gBACIA,6CAAcsE,OAAOC,aAAWtE,6CAAcqE,OAAOC,WACrDtE,6CAAcqE,OAAOC,YAAW;AAAA,UAEtC7C,SAAQ;AAAA,UACR8C,SAASxD;AAAAA,UAAeO,UAEvBrC,iCAAQuF;AAAAA,QAAAA,CAAU,GAErBxB,oBAAA,OAAA;AAAA,UACE,eAAY;AAAA,UACZW,WAAW9B,GACTK,0BAA0BuC,OAC1B7C,IAAIS,OAAOoC,KAAK,GAChBjF,mCAASiF,KAAK;AAAA,UACdnD,UACH;AAAA,QAAA,CAEK,GACN0B,oBAACoB,UAAQ;AAAA,UACP7F,IAAIwD,MAAMxD,IAAI,cAAc;AAAA,UAC5BE,UAAU2B;AAAAA,UACVqB,SACE/B,2CAAagF,YAAYC;AAAAA,UAE3BJ,SAAS3D;AAAAA,UACT+C,WAAW9B,GACTK,0BAA0B0C,aAC1BhD,IAAIS,OAAOuC,WAAW,GACtBpF,mCAASoF,WAAW;AAAA,UACpBtD,UAEDrC,iCAAQ4F;AAAAA,QAAAA,CACA,GACX7B,oBAACoB,UAAQ;AAAA,UACP7F,IAAIwD,MAAMxD,IAAI,eAAe;AAAA,UAC7BkD,SACE/B,2CAAagF,YAAYI;AAAAA,UAE3BP,SAASzD;AAAAA,UAAgBQ,UAExBrC,iCAAQ8F;AAAAA,QAAAA,CACA,CAAA;AAAA,MAAA,CACC,CAAA;AAAA,IAAA,CAAA;AAAA,EAAA,CAGP;AAEjB;"}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import filterGroupClasses from "./filterGroupClasses.js";
|
|
2
|
-
import { clsx } from "clsx";
|
|
3
2
|
import { styles } from "./FilterGroup.styles.js";
|
|
4
3
|
import { HvFilterGroupProvider } from "./FilterGroupContext.js";
|
|
5
4
|
import { ClassNames } from "@emotion/react";
|
|
@@ -58,7 +57,8 @@ const HvFilterGroup = ({
|
|
|
58
57
|
const canShowError = status !== void 0 || required;
|
|
59
58
|
return /* @__PURE__ */ jsx(ClassNames, {
|
|
60
59
|
children: ({
|
|
61
|
-
css
|
|
60
|
+
css,
|
|
61
|
+
cx
|
|
62
62
|
}) => /* @__PURE__ */ jsxs(HvFormElement, {
|
|
63
63
|
id,
|
|
64
64
|
name,
|
|
@@ -66,18 +66,18 @@ const HvFilterGroup = ({
|
|
|
66
66
|
status,
|
|
67
67
|
disabled,
|
|
68
68
|
required,
|
|
69
|
-
className:
|
|
69
|
+
className: cx(filterGroupClasses.root, className, classes == null ? void 0 : classes.root),
|
|
70
70
|
...others,
|
|
71
71
|
children: [(hasLabel || hasDescription) && /* @__PURE__ */ jsxs("div", {
|
|
72
|
-
className:
|
|
72
|
+
className: cx(filterGroupClasses.labelContainer, css(styles.labelContainer), classes == null ? void 0 : classes.labelContainer),
|
|
73
73
|
children: [hasLabel && /* @__PURE__ */ jsx(HvLabel, {
|
|
74
74
|
id: setId(elementId, "label"),
|
|
75
75
|
htmlFor: setId(elementId, "input"),
|
|
76
76
|
label,
|
|
77
|
-
className:
|
|
77
|
+
className: cx(filterGroupClasses.label, css(styles.label), classes == null ? void 0 : classes.label)
|
|
78
78
|
}), hasDescription && /* @__PURE__ */ jsx(HvInfoMessage, {
|
|
79
79
|
id: setId(elementId, "description"),
|
|
80
|
-
className:
|
|
80
|
+
className: cx(filterGroupClasses.description, classes == null ? void 0 : classes.description),
|
|
81
81
|
children: description
|
|
82
82
|
})]
|
|
83
83
|
}), /* @__PURE__ */ jsxs(HvFilterGroupProvider, {
|
|
@@ -103,7 +103,7 @@ const HvFilterGroup = ({
|
|
|
103
103
|
}), canShowError && /* @__PURE__ */ jsx(HvWarningText, {
|
|
104
104
|
id: setId(elementId, "error"),
|
|
105
105
|
disableBorder: true,
|
|
106
|
-
className:
|
|
106
|
+
className: cx(filterGroupClasses.error, classes == null ? void 0 : classes.error),
|
|
107
107
|
children: validationMessage
|
|
108
108
|
})]
|
|
109
109
|
})]
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FilterGroup.js","sources":["../../../../src/components/FilterGroup/FilterGroup.tsx"],"sourcesContent":["import {\n HvFormElement,\n HvFormElementProps,\n HvFormStatus,\n HvInfoMessage,\n HvLabel,\n HvWarningText,\n} from \"@core/components\";\nimport filterGroupClasses, { HvFilterGroupClasses } from \"./filterGroupClasses\";\nimport {\n HvFilterGroupContent,\n HvFilterGroupContentProps,\n} from \"./FilterContent\";\nimport { clsx } from \"clsx\";\nimport { useControlled, useLabels, useUniqueId } from \"@core/hooks\";\nimport { styles } from \"./FilterGroup.styles\";\nimport { setId } from \"@core/utils\";\nimport { HvFilterGroupProvider } from \"./FilterGroupContext\";\nimport { ClassNames } from \"@emotion/react\";\n\nexport type HvFilterGroupValue = (string | number)[][];\n\nexport interface HvFilterGroupLabels {\n /** Apply button label. */\n applyLabel?: string;\n /** Cancel button label. */\n cancelLabel?: string;\n /** Cancel button label. */\n clearLabel?: string;\n /** Placeholder label. */\n placeholder?: string;\n /** SearchBox placeholder label. */\n searchBoxPlaceholder?: string;\n /** Select All placeholder label. */\n selectAll?: string;\n /** Multi selection conjunction placeholder label. */\n multiSelectionConjunction?: string;\n}\n\nexport type HvFilterGroupFilters = {\n id: string;\n name: string;\n data: {\n id: string | number;\n name: string;\n }[];\n}[];\n\nexport type HvFilterGroupHorizontalPlacement = \"left\" | \"right\";\n\nexport interface HvFilterGroupProps\n extends Omit<\n HvFormElementProps,\n \"onChange\" | \"defaultValue\" | \"statusMessage\"\n > {\n /** The initial value of the input when in single calendar mode. */\n filters: HvFilterGroupFilters;\n /** The form element name. */\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?: React.ReactNode;\n /** Provide additional descriptive text for the form element. */\n description?: React.ReactNode;\n /** Indicates that the form element is disabled. */\n disabled?: boolean;\n /** Indicates that user input is required on the form element. */\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?: HvFormStatus;\n /** The error message to show when `status` is \"invalid\". Defaults to \"Required\". */\n statusMessage?: React.ReactNode;\n /** The callback fired when the cancel button is clicked. */\n onCancel?: (event: React.MouseEvent<HTMLButtonElement> | Event) => void;\n /** The callback fired when the clear filters button is clicked. */\n onClear?: (event: React.MouseEvent<HTMLButtonElement>) => void;\n /** The callback fired when the value changes. */\n onChange?: (\n event: React.MouseEvent<HTMLButtonElement>,\n value?: HvFilterGroupValue\n ) => void;\n /** An Object containing the various text associated with the input. */\n labels?: HvFilterGroupLabels;\n /** The placeholder value when nothing is selected. */\n placeholder?: string;\n /** The default value of the filter group. If defined the clear action will reset to it. */\n defaultValue?: HvFilterGroupValue;\n /** The value of the filter group. */\n value?: HvFilterGroupValue;\n /** The placement where the filter group should be placed according to the input. Options are `left` or `right`. */\n horizontalPlacement?: HvFilterGroupHorizontalPlacement;\n /** Disable the portal behavior. The children stay within it's parent DOM hierarchy. */\n disablePortal?: boolean;\n /** Sets if the filter container should be out of the screen or stay visible. */\n escapeWithReference?: boolean;\n /** The height of the filter panel, between 295 and 425. Defaults to 350 */\n height?: number | string;\n /** The filter content props */\n filterContentProps?: Partial<HvFilterGroupContentProps>;\n /** A Jss Object used to override or extend the styles applied to the component. */\n classes?: HvFilterGroupClasses;\n}\n\nconst DEFAULT_LABELS: HvFilterGroupLabels = {\n applyLabel: \"Apply\",\n cancelLabel: \"Cancel\",\n clearLabel: \"Clear Filters\",\n placeholder: \"Filters\",\n searchBoxPlaceholder: \"Search\",\n selectAll: \"All\",\n multiSelectionConjunction: \"/\",\n};\n\n/**\n * This component implements one potential use-case of the Filter Group pattern Design System Specifies.\n * Due to the enormous variety of capabilities required for this, we strongly recommend checking the code of the component and extend it yourself,\n * while we do not provide a better approach for building this component with smaller and more composable parts.\n */\nexport const HvFilterGroup = ({\n className,\n id,\n name,\n required = false,\n disabled = false,\n label,\n \"aria-label\": ariaLabel,\n \"aria-labelledby\": ariaLabelledBy,\n description,\n \"aria-describedby\": ariaDescribedBy,\n onChange,\n onCancel,\n onClear,\n status,\n statusMessage,\n labels: labelsProp,\n defaultValue,\n value,\n filters,\n horizontalPlacement = \"right\",\n disablePortal = true,\n escapeWithReference = true,\n height = 350,\n filterContentProps,\n classes,\n ...others\n}: HvFilterGroupProps) => {\n const [validationMessage] = useControlled(statusMessage, \"Required\");\n\n const elementId = useUniqueId(id, \"hvfiltergroup\");\n\n const labels = useLabels(DEFAULT_LABELS, labelsProp);\n\n const hasLabel = label != null;\n\n const hasDescription = description != null;\n\n // Error message area will only be needed if the status is being controlled\n // or if required is true\n const canShowError = status !== undefined || required;\n\n return (\n <ClassNames>\n {({ css }) => (\n <HvFormElement\n id={id}\n name={name}\n value={value}\n status={status}\n disabled={disabled}\n required={required}\n className={clsx(className, classes?.root, filterGroupClasses.root)}\n {...others}\n >\n {(hasLabel || hasDescription) && (\n <div\n className={clsx(\n classes?.labelContainer,\n filterGroupClasses.labelContainer,\n css(styles.labelContainer)\n )}\n >\n {hasLabel && (\n <HvLabel\n id={setId(elementId, \"label\")}\n htmlFor={setId(elementId, \"input\")}\n label={label}\n className={clsx(\n classes?.label,\n filterGroupClasses.label,\n css(styles.label)\n )}\n />\n )}\n\n {hasDescription && (\n <HvInfoMessage\n id={setId(elementId, \"description\")}\n className={clsx(\n classes?.description,\n filterGroupClasses.description\n )}\n >\n {description}\n </HvInfoMessage>\n )}\n </div>\n )}\n <HvFilterGroupProvider\n defaultValue={defaultValue}\n value={value}\n filters={filters}\n >\n <HvFilterGroupContent\n id={elementId}\n disabled={disabled}\n disablePortal={disablePortal}\n variableWidth\n placement={horizontalPlacement}\n escapeWithReference={escapeWithReference}\n aria-label={ariaLabel}\n aria-labelledby={ariaLabelledBy}\n status={status}\n onChange={onChange}\n onCancel={onCancel}\n onClear={onClear}\n labels={labels}\n height={height}\n {...filterContentProps}\n />\n {canShowError && (\n <HvWarningText\n id={setId(elementId, \"error\")}\n disableBorder\n className={clsx(classes?.error, filterGroupClasses.error)}\n >\n {validationMessage}\n </HvWarningText>\n )}\n </HvFilterGroupProvider>\n </HvFormElement>\n )}\n </ClassNames>\n );\n};\n"],"names":["DEFAULT_LABELS","applyLabel","cancelLabel","clearLabel","placeholder","searchBoxPlaceholder","selectAll","multiSelectionConjunction","HvFilterGroup","className","id","name","required","disabled","label","ariaLabel","ariaLabelledBy","description","ariaDescribedBy","onChange","onCancel","onClear","status","statusMessage","labels","labelsProp","defaultValue","value","filters","horizontalPlacement","disablePortal","escapeWithReference","height","filterContentProps","classes","others","validationMessage","useControlled","elementId","useUniqueId","useLabels","hasLabel","hasDescription","canShowError","undefined","ClassNames","children","css","HvFormElement","clsx","root","filterGroupClasses","labelContainer","styles","_jsx","HvLabel","setId","htmlFor","HvInfoMessage","_jsxs","HvFilterGroupProvider","HvFilterGroupContent","variableWidth","placement","HvWarningText","disableBorder","error"],"mappings":";;;;;;;;;;;;;;;AAkHA,MAAMA,iBAAsC;AAAA,EAC1CC,YAAY;AAAA,EACZC,aAAa;AAAA,EACbC,YAAY;AAAA,EACZC,aAAa;AAAA,EACbC,sBAAsB;AAAA,EACtBC,WAAW;AAAA,EACXC,2BAA2B;AAC7B;AAOO,MAAMC,gBAAgBA,CAAC;AAAA,EAC5BC;AAAAA,EACAC;AAAAA,EACAC;AAAAA,EACAC,WAAW;AAAA,EACXC,WAAW;AAAA,EACXC;AAAAA,EACA,cAAcC;AAAAA,EACd,mBAAmBC;AAAAA,EACnBC;AAAAA,EACA,oBAAoBC;AAAAA,EACpBC;AAAAA,EACAC;AAAAA,EACAC;AAAAA,EACAC;AAAAA,EACAC;AAAAA,EACAC,QAAQC;AAAAA,EACRC;AAAAA,EACAC;AAAAA,EACAC;AAAAA,EACAC,sBAAsB;AAAA,EACtBC,gB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AAA,QACAC;AAAAA,QACAC;AAAAA,QAAiBkB,UAAA,CAEjBQ,oBAACO,sBAAoB;AAAA,UACnBnD,IAAI4B;AAAAA,UACJzB;AAAAA,UACAiB;AAAAA,UACAgC,eAAa;AAAA,UACbC,WAAWlC;AAAAA,UACXE;AAAAA,UACA,cAAYhB;AAAAA,UACZ,mBAAiBC;AAAAA,UACjBM;AAAAA,UACAH;AAAAA,UACAC;AAAAA,UACAC;AAAAA,UACAG;AAAAA,UACAQ;AAAAA,UAAe,GACXC;AAAAA,QAAAA,CAAkB,GAEvBU,gBACCW,oBAACU,eAAa;AAAA,UACZtD,IAAI8C,MAAMlB,WAAW,OAAO;AAAA,UAC5B2B,eAAa;AAAA,UACbxD,WAAWwC,KAAKf,mCAASgC,OAAOf,mBAAmBe,KAAK;AAAA,UAAEpB,UAEzDV;AAAAA,QAAAA,CAEJ,CAAA;AAAA,MAAA,CACqB,CAAA;AAAA,IAAA,CAAA;AAAA,EAAA,CAGjB;AAEjB;"}
|
|
1
|
+
{"version":3,"file":"FilterGroup.js","sources":["../../../../src/components/FilterGroup/FilterGroup.tsx"],"sourcesContent":["import {\n HvFormElement,\n HvFormElementProps,\n HvFormStatus,\n HvInfoMessage,\n HvLabel,\n HvWarningText,\n} from \"@core/components\";\nimport filterGroupClasses, { HvFilterGroupClasses } from \"./filterGroupClasses\";\nimport {\n HvFilterGroupContent,\n HvFilterGroupContentProps,\n} from \"./FilterContent\";\nimport { useControlled, useLabels, useUniqueId } from \"@core/hooks\";\nimport { styles } from \"./FilterGroup.styles\";\nimport { setId } from \"@core/utils\";\nimport { HvFilterGroupProvider } from \"./FilterGroupContext\";\nimport { ClassNames } from \"@emotion/react\";\n\nexport type HvFilterGroupValue = (string | number)[][];\n\nexport interface HvFilterGroupLabels {\n /** Apply button label. */\n applyLabel?: string;\n /** Cancel button label. */\n cancelLabel?: string;\n /** Cancel button label. */\n clearLabel?: string;\n /** Placeholder label. */\n placeholder?: string;\n /** SearchBox placeholder label. */\n searchBoxPlaceholder?: string;\n /** Select All placeholder label. */\n selectAll?: string;\n /** Multi selection conjunction placeholder label. */\n multiSelectionConjunction?: string;\n}\n\nexport type HvFilterGroupFilters = {\n id: string;\n name: string;\n data: {\n id: string | number;\n name: string;\n }[];\n}[];\n\nexport type HvFilterGroupHorizontalPlacement = \"left\" | \"right\";\n\nexport interface HvFilterGroupProps\n extends Omit<\n HvFormElementProps,\n \"onChange\" | \"defaultValue\" | \"statusMessage\"\n > {\n /** The initial value of the input when in single calendar mode. */\n filters: HvFilterGroupFilters;\n /** The form element name. */\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?: React.ReactNode;\n /** Provide additional descriptive text for the form element. */\n description?: React.ReactNode;\n /** Indicates that the form element is disabled. */\n disabled?: boolean;\n /** Indicates that user input is required on the form element. */\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?: HvFormStatus;\n /** The error message to show when `status` is \"invalid\". Defaults to \"Required\". */\n statusMessage?: React.ReactNode;\n /** The callback fired when the cancel button is clicked. */\n onCancel?: (event: React.MouseEvent<HTMLButtonElement> | Event) => void;\n /** The callback fired when the clear filters button is clicked. */\n onClear?: (event: React.MouseEvent<HTMLButtonElement>) => void;\n /** The callback fired when the value changes. */\n onChange?: (\n event: React.MouseEvent<HTMLButtonElement>,\n value?: HvFilterGroupValue\n ) => void;\n /** An Object containing the various text associated with the input. */\n labels?: HvFilterGroupLabels;\n /** The placeholder value when nothing is selected. */\n placeholder?: string;\n /** The default value of the filter group. If defined the clear action will reset to it. */\n defaultValue?: HvFilterGroupValue;\n /** The value of the filter group. */\n value?: HvFilterGroupValue;\n /** The placement where the filter group should be placed according to the input. Options are `left` or `right`. */\n horizontalPlacement?: HvFilterGroupHorizontalPlacement;\n /** Disable the portal behavior. The children stay within it's parent DOM hierarchy. */\n disablePortal?: boolean;\n /** Sets if the filter container should be out of the screen or stay visible. */\n escapeWithReference?: boolean;\n /** The height of the filter panel, between 295 and 425. Defaults to 350 */\n height?: number | string;\n /** The filter content props */\n filterContentProps?: Partial<HvFilterGroupContentProps>;\n /** A Jss Object used to override or extend the styles applied to the component. */\n classes?: HvFilterGroupClasses;\n}\n\nconst DEFAULT_LABELS: HvFilterGroupLabels = {\n applyLabel: \"Apply\",\n cancelLabel: \"Cancel\",\n clearLabel: \"Clear Filters\",\n placeholder: \"Filters\",\n searchBoxPlaceholder: \"Search\",\n selectAll: \"All\",\n multiSelectionConjunction: \"/\",\n};\n\n/**\n * This component implements one potential use-case of the Filter Group pattern Design System Specifies.\n * Due to the enormous variety of capabilities required for this, we strongly recommend checking the code of the component and extend it yourself,\n * while we do not provide a better approach for building this component with smaller and more composable parts.\n */\nexport const HvFilterGroup = ({\n className,\n id,\n name,\n required = false,\n disabled = false,\n label,\n \"aria-label\": ariaLabel,\n \"aria-labelledby\": ariaLabelledBy,\n description,\n \"aria-describedby\": ariaDescribedBy,\n onChange,\n onCancel,\n onClear,\n status,\n statusMessage,\n labels: labelsProp,\n defaultValue,\n value,\n filters,\n horizontalPlacement = \"right\",\n disablePortal = true,\n escapeWithReference = true,\n height = 350,\n filterContentProps,\n classes,\n ...others\n}: HvFilterGroupProps) => {\n const [validationMessage] = useControlled(statusMessage, \"Required\");\n\n const elementId = useUniqueId(id, \"hvfiltergroup\");\n\n const labels = useLabels(DEFAULT_LABELS, labelsProp);\n\n const hasLabel = label != null;\n\n const hasDescription = description != null;\n\n // Error message area will only be needed if the status is being controlled\n // or if required is true\n const canShowError = status !== undefined || required;\n\n return (\n <ClassNames>\n {({ css, cx }) => (\n <HvFormElement\n id={id}\n name={name}\n value={value}\n status={status}\n disabled={disabled}\n required={required}\n className={cx(filterGroupClasses.root, className, classes?.root)}\n {...others}\n >\n {(hasLabel || hasDescription) && (\n <div\n className={cx(\n filterGroupClasses.labelContainer,\n css(styles.labelContainer),\n classes?.labelContainer\n )}\n >\n {hasLabel && (\n <HvLabel\n id={setId(elementId, \"label\")}\n htmlFor={setId(elementId, \"input\")}\n label={label}\n className={cx(\n filterGroupClasses.label,\n css(styles.label),\n classes?.label\n )}\n />\n )}\n\n {hasDescription && (\n <HvInfoMessage\n id={setId(elementId, \"description\")}\n className={cx(\n filterGroupClasses.description,\n classes?.description\n )}\n >\n {description}\n </HvInfoMessage>\n )}\n </div>\n )}\n <HvFilterGroupProvider\n defaultValue={defaultValue}\n value={value}\n filters={filters}\n >\n <HvFilterGroupContent\n id={elementId}\n disabled={disabled}\n disablePortal={disablePortal}\n variableWidth\n placement={horizontalPlacement}\n escapeWithReference={escapeWithReference}\n aria-label={ariaLabel}\n aria-labelledby={ariaLabelledBy}\n status={status}\n onChange={onChange}\n onCancel={onCancel}\n onClear={onClear}\n labels={labels}\n height={height}\n {...filterContentProps}\n />\n {canShowError && (\n <HvWarningText\n id={setId(elementId, \"error\")}\n disableBorder\n className={cx(filterGroupClasses.error, classes?.error)}\n >\n {validationMessage}\n </HvWarningText>\n )}\n </HvFilterGroupProvider>\n </HvFormElement>\n )}\n </ClassNames>\n );\n};\n"],"names":["DEFAULT_LABELS","applyLabel","cancelLabel","clearLabel","placeholder","searchBoxPlaceholder","selectAll","multiSelectionConjunction","HvFilterGroup","className","id","name","required","disabled","label","ariaLabel","ariaLabelledBy","description","ariaDescribedBy","onChange","onCancel","onClear","status","statusMessage","labels","labelsProp","defaultValue","value","filters","horizontalPlacement","disablePortal","escapeWithReference","height","filterContentProps","classes","others","validationMessage","useControlled","elementId","useUniqueId","useLabels","hasLabel","hasDescription","canShowError","undefined","ClassNames","children","css","cx","HvFormElement","filterGroupClasses","root","labelContainer","styles","_jsx","HvLabel","setId","htmlFor","HvInfoMessage","_jsxs","HvFilterGroupProvider","HvFilterGroupContent","variableWidth","placement","HvWarningText","disableBorder","error"],"mappings":";;;;;;;;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roupContext } from "../FilterGroupContext.js";
|
|
3
3
|
import { ClassNames } from "@emotion/react";
|
|
4
4
|
import { styles } from "./LeftPanel.styles.js";
|
|
5
|
-
import { clsx } from "clsx";
|
|
6
5
|
import filterGroupLeftPanelClasses from "./leftPanelClasses.js";
|
|
7
6
|
import { jsx } from "@emotion/react/jsx-runtime";
|
|
8
7
|
import { HvFilterGroupCounter } from "../Counter/Counter.js";
|
|
@@ -24,7 +23,8 @@ const HvFilterGroupLeftPanel = ({
|
|
|
24
23
|
} = useContext(HvFilterGroupContext);
|
|
25
24
|
return /* @__PURE__ */ jsx(ClassNames, {
|
|
26
25
|
children: ({
|
|
27
|
-
css
|
|
26
|
+
css,
|
|
27
|
+
cx
|
|
28
28
|
}) => /* @__PURE__ */ jsx(HvPanel, {
|
|
29
29
|
id: setId(id, "leftPanel"),
|
|
30
30
|
className,
|
|
@@ -36,7 +36,7 @@ const HvFilterGroupLeftPanel = ({
|
|
|
36
36
|
const ItemText = wrapperTooltip(true, group.name, group.name);
|
|
37
37
|
return /* @__PURE__ */ jsx(HvListItem, {
|
|
38
38
|
id: group.id,
|
|
39
|
-
className:
|
|
39
|
+
className: cx(filterGroupLeftPanelClasses.listItem, css(styles.listItem), classes == null ? void 0 : classes.listItem),
|
|
40
40
|
onClick: () => setActiveGroup(index),
|
|
41
41
|
selected: filterOptions[activeGroup].id === group.id,
|
|
42
42
|
endAdornment: /* @__PURE__ */ jsx(HvFilterGroupCounter, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LeftPanel.js","sources":["../../../../../src/components/FilterGroup/LeftPanel/LeftPanel.tsx"],"sourcesContent":["import { useContext } from \"react\";\nimport { HvFilterGroupContext } from \"../FilterGroupContext\";\nimport { HvListContainer, HvListItem, HvPanel } from \"@core/components\";\nimport { setId, wrapperTooltip } from \"@core/utils\";\nimport { HvFilterGroupCounter } from \"../Counter\";\nimport { ClassNames } from \"@emotion/react\";\nimport { styles } from \"./LeftPanel.styles\";\nimport
|
|
1
|
+
{"version":3,"file":"LeftPanel.js","sources":["../../../../../src/components/FilterGroup/LeftPanel/LeftPanel.tsx"],"sourcesContent":["import { useContext } from \"react\";\nimport { HvFilterGroupContext } from \"../FilterGroupContext\";\nimport { HvListContainer, HvListItem, HvPanel } from \"@core/components\";\nimport { setId, wrapperTooltip } from \"@core/utils\";\nimport { HvFilterGroupCounter } from \"../Counter\";\nimport { ClassNames } from \"@emotion/react\";\nimport { styles } from \"./LeftPanel.styles\";\nimport filterGroupLeftPanelClasses, {\n HvFilterGroupLeftPanelClasses,\n} from \"./leftPanelClasses\";\n\nexport interface HvFilterGroupLeftPanelProps {\n id?: string;\n className?: string;\n emptyElement?: React.ReactNode;\n classes?: HvFilterGroupLeftPanelClasses;\n}\n\nexport const HvFilterGroupLeftPanel = ({\n id,\n className,\n emptyElement,\n classes,\n}: HvFilterGroupLeftPanelProps) => {\n const { filterOptions, activeGroup, setActiveGroup } =\n useContext(HvFilterGroupContext);\n\n return (\n <ClassNames>\n {({ css, cx }) => (\n <HvPanel id={setId(id, \"leftPanel\")} className={className}>\n {filterOptions.length > 0 ? (\n <HvListContainer\n id={setId(id, \"leftPanel-list\")}\n condensed\n interactive\n >\n {filterOptions.map((group, index) => {\n const ItemText = wrapperTooltip(true, group.name, group.name);\n\n return (\n <HvListItem\n id={group.id}\n key={group.name}\n className={cx(\n filterGroupLeftPanelClasses.listItem,\n css(styles.listItem),\n classes?.listItem\n )}\n onClick={() => setActiveGroup(index)}\n selected={filterOptions[activeGroup].id === group.id}\n endAdornment={<HvFilterGroupCounter id={group.id} />}\n >\n <ItemText />\n </HvListItem>\n );\n })}\n </HvListContainer>\n ) : (\n emptyElement\n )}\n </HvPanel>\n )}\n </ClassNames>\n );\n};\n"],"names":["HvFilterGroupLeftPanel","id","className","emptyElement","classes","filterOptions","activeGroup","setActiveGroup","useContext","HvFilterGroupContext","ClassNames","children","css","cx","HvPanel","setId","length","HvListContainer","condensed","interactive","map","group","index","ItemText","wrapperTooltip","name","HvListItem","filterGroupLeftPanelClasses","listItem","styles","onClick","selected","endAdornment","HvFilterGroupCounter","_jsx"],"mappings":";;;;;;;;;;;;AAkBO,MAAMA,yBAAyBA,CAAC;AAAA,EACrCC;AAAAA,EACAC;AAAAA,EACAC;AAAAA,EACAC;AAC2B,MAAM;AAC3B,QAAA;AAAA,IAAEC;AAAAA,IAAeC;AAAAA,IAAaC;AAAAA,EAAAA,IAClCC,WAAWC,oBAAoB;AAEjC,6BACGC,YAAU;AAAA,IAAAC,UACRA,CAAC;AAAA,MAAEC;AAAAA,MAAKC;AAAAA,IAAAA,0BACNC,SAAO;AAAA,MAACb,IAAIc,MAAMd,IAAI,WAAW;AAAA,MAAGC;AAAAA,MAAqBS,UACvDN,cAAcW,SAAS,wBACrBC,iBAAe;AAAA,QACdhB,IAAIc,MAAMd,IAAI,gBAAgB;AAAA,QAC9BiB,WAAS;AAAA,QACTC,aAAW;AAAA,QAAAR,UAEVN,cAAce,IAAI,CAACC,OAAOC,UAAU;AACnC,gBAAMC,WAAWC,eAAe,MAAMH,MAAMI,MAAMJ,MAAMI,IAAI;AAE5D,qCACGC,YAAU;AAAA,YACTzB,IAAIoB,MAAMpB;AAAAA,YAEVC,WAAWW,GACTc,4BAA4BC,UAC5BhB,IAAIiB,OAAOD,QAAQ,GACnBxB,mCAASwB,QAAQ;AAAA,YAEnBE,SAASA,MAAMvB,eAAee,KAAK;AAAA,YACnCS,UAAU1B,cAAcC,WAAW,EAAEL,OAAOoB,MAAMpB;AAAAA,YAClD+B,kCAAeC,sBAAoB;AAAA,cAAChC,IAAIoB,MAAMpB;AAAAA,YAAAA,CAAO;AAAA,YAAAU,UAErDuB,oBAACX,UAAQ,EAAA;AAAA,UAAA,GAVJF,MAAMI,IAAI;AAAA,QAAA,CAapB;AAAA,MAAC,CAAA,IAGJtB;AAAAA,IAAAA,CACD;AAAA,EAAA,CAGM;AAEjB;"}
|
|
@@ -3,7 +3,6 @@ import { HvFilterGroupContext } from "../FilterGroupContext.js";
|
|
|
3
3
|
import cloneDeep from "lodash/cloneDeep";
|
|
4
4
|
import { ClassNames } from "@emotion/react";
|
|
5
5
|
import { styles } from "./RightPanel.styles.js";
|
|
6
|
-
import { clsx } from "clsx";
|
|
7
6
|
import filterGroupRightPanelClasses from "./rightPanelClasses.js";
|
|
8
7
|
import { jsx, jsxs, Fragment } from "@emotion/react/jsx-runtime";
|
|
9
8
|
import { HvTypography } from "../../Typography/Typography.js";
|
|
@@ -84,14 +83,15 @@ const HvFilterGroupRightPanel = ({
|
|
|
84
83
|
});
|
|
85
84
|
return /* @__PURE__ */ jsx(ClassNames, {
|
|
86
85
|
children: ({
|
|
87
|
-
css
|
|
86
|
+
css,
|
|
87
|
+
cx
|
|
88
88
|
}) => /* @__PURE__ */ jsx("div", {
|
|
89
|
-
className:
|
|
89
|
+
className: cx(filterGroupRightPanelClasses.selectAllContainer, css(styles.selectAllContainer), classes == null ? void 0 : classes.selectAllContainer),
|
|
90
90
|
children: /* @__PURE__ */ jsx(HvCheckBox, {
|
|
91
91
|
id: setId(id, "select-all"),
|
|
92
92
|
label: defaultLabel,
|
|
93
93
|
onChange: () => handleSelectAll(),
|
|
94
|
-
className:
|
|
94
|
+
className: cx(filterGroupRightPanelClasses.selectAll, css(styles.selectAll), classes == null ? void 0 : classes.selectAll),
|
|
95
95
|
indeterminate: anySelected && !allSelected,
|
|
96
96
|
checked: allSelected
|
|
97
97
|
})
|
|
@@ -100,7 +100,8 @@ const HvFilterGroupRightPanel = ({
|
|
|
100
100
|
}, [activeFilterValues == null ? void 0 : activeFilterValues.length, activeGroupOptions.length, allSelected, anySelected, handleSelectAll, id, labels]);
|
|
101
101
|
return /* @__PURE__ */ jsx(ClassNames, {
|
|
102
102
|
children: ({
|
|
103
|
-
css
|
|
103
|
+
css,
|
|
104
|
+
cx
|
|
104
105
|
}) => /* @__PURE__ */ jsx(HvPanel, {
|
|
105
106
|
id: setId(id, "rightPanel"),
|
|
106
107
|
className,
|
|
@@ -108,7 +109,7 @@ const HvFilterGroupRightPanel = ({
|
|
|
108
109
|
children: [/* @__PURE__ */ jsx(HvInput, {
|
|
109
110
|
id: setId(id, "search"),
|
|
110
111
|
classes: {
|
|
111
|
-
root:
|
|
112
|
+
root: cx(filterGroupRightPanelClasses.search, css(styles.search), classes == null ? void 0 : classes.search)
|
|
112
113
|
},
|
|
113
114
|
type: "search",
|
|
114
115
|
placeholder: labels == null ? void 0 : labels.searchBoxPlaceholder,
|
|
@@ -117,7 +118,7 @@ const HvFilterGroupRightPanel = ({
|
|
|
117
118
|
}), /* @__PURE__ */ jsx(SelectAll, {}), /* @__PURE__ */ jsx(HvList, {
|
|
118
119
|
id: setId(id, "list"),
|
|
119
120
|
values: listValues,
|
|
120
|
-
className:
|
|
121
|
+
className: cx(filterGroupRightPanelClasses.list, css(styles.list), classes == null ? void 0 : classes.list),
|
|
121
122
|
multiSelect: true,
|
|
122
123
|
useSelector: true,
|
|
123
124
|
showSelectAll: false,
|