@onewelcome/react-lib-components 8.0.0 → 8.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (105) hide show
  1. package/dist/cjs/DataGrid/DataGrid.cjs.js +1 -1
  2. package/dist/cjs/DataGrid/DataGrid.cjs.js.map +1 -1
  3. package/dist/cjs/DataGrid/DataGridFilters/DataGridFilter.cjs.js +1 -1
  4. package/dist/cjs/DataGrid/DataGridFilters/DataGridFilter.cjs.js.map +1 -1
  5. package/dist/cjs/DataGrid/DataGridFilters/DataGridFilter.module.scss.cjs.js +1 -1
  6. package/dist/cjs/DataGrid/DataGridFilters/DataGridFilterPopover.cjs.js +1 -1
  7. package/dist/cjs/DataGrid/DataGridFilters/DataGridFilterPopover.cjs.js.map +1 -1
  8. package/dist/cjs/DataGrid/DataGridFilters/DataGridFilterTag.cjs.js +1 -1
  9. package/dist/cjs/DataGrid/DataGridFilters/DataGridFilterTag.cjs.js.map +1 -1
  10. package/dist/cjs/DataGrid/DataGridFilters/DataGridToolbar.cjs.js +1 -1
  11. package/dist/cjs/DataGrid/DataGridFilters/DataGridToolbar.cjs.js.map +1 -1
  12. package/dist/cjs/DataGrid/DataGridFilters/DataGridToolbar.module.scss.cjs.js +1 -1
  13. package/dist/cjs/DataGrid/DataGridFilters/DataGridToolbarWrapper.cjs.js +1 -1
  14. package/dist/cjs/DataGrid/DataGridFilters/DataGridToolbarWrapper.cjs.js.map +1 -1
  15. package/dist/cjs/DataGrid/DataGridFilters/useFiltersReducer.cjs.js +2 -0
  16. package/dist/cjs/DataGrid/DataGridFilters/useFiltersReducer.cjs.js.map +1 -0
  17. package/dist/cjs/DataGrid/DataGridHeader/DataGridHeaderCell.cjs.js +1 -1
  18. package/dist/cjs/DataGrid/DataGridHeader/DataGridHeaderCell.cjs.js.map +1 -1
  19. package/dist/cjs/DataGrid/DataGridHeader/DataGridHeaderCell.module.scss.cjs.js +1 -1
  20. package/dist/cjs/Icon/Icon.cjs.js +1 -1
  21. package/dist/cjs/Icon/Icon.cjs.js.map +1 -1
  22. package/dist/cjs/Icon/Icon.module.scss.cjs.js +1 -1
  23. package/dist/cjs/Notifications/BaseModal/BaseModal.cjs.js +1 -1
  24. package/dist/cjs/Notifications/BaseModal/BaseModal.cjs.js.map +1 -1
  25. package/dist/cjs/src/components/DataGrid/DataGrid.d.ts +5 -1
  26. package/dist/cjs/src/components/DataGrid/DataGridFilters/DataGridFilter.d.ts +3 -3
  27. package/dist/cjs/src/components/DataGrid/DataGridFilters/DataGridFilterPopover.d.ts +3 -2
  28. package/dist/cjs/src/components/DataGrid/DataGridFilters/DataGridFilterTag.d.ts +2 -1
  29. package/dist/cjs/src/components/DataGrid/DataGridFilters/DataGridToolbar.d.ts +2 -1
  30. package/dist/cjs/src/components/DataGrid/DataGridFilters/DataGridToolbarWrapper.d.ts +8 -5
  31. package/dist/cjs/src/components/DataGrid/DataGridFilters/useFiltersReducer.d.ts +8 -0
  32. package/dist/cjs/src/components/DataGrid/DataGridFilters/useFiltersReducer.test.d.ts +1 -0
  33. package/dist/cjs/src/components/DataGrid/testUtils.d.ts +1 -0
  34. package/dist/cjs/src/components/Icon/Icon.d.ts +2 -1
  35. package/dist/cjs/src/hooks/useRepeatFocus.cjs.js +2 -0
  36. package/dist/cjs/src/hooks/useRepeatFocus.cjs.js.map +1 -0
  37. package/dist/cjs/src/index.cjs.js +1 -1
  38. package/dist/cjs/src/index.d.ts +1 -0
  39. package/dist/esm/DataGrid/DataGrid.esm.js +5 -5
  40. package/dist/esm/DataGrid/DataGrid.esm.js.map +1 -1
  41. package/dist/esm/DataGrid/DataGridFilters/DataGridFilter.esm.js +7 -14
  42. package/dist/esm/DataGrid/DataGridFilters/DataGridFilter.esm.js.map +1 -1
  43. package/dist/esm/DataGrid/DataGridFilters/DataGridFilter.module.scss.esm.js +2 -2
  44. package/dist/esm/DataGrid/DataGridFilters/DataGridFilterPopover.esm.js +11 -3
  45. package/dist/esm/DataGrid/DataGridFilters/DataGridFilterPopover.esm.js.map +1 -1
  46. package/dist/esm/DataGrid/DataGridFilters/DataGridFilterTag.esm.js +5 -7
  47. package/dist/esm/DataGrid/DataGridFilters/DataGridFilterTag.esm.js.map +1 -1
  48. package/dist/esm/DataGrid/DataGridFilters/DataGridToolbar.esm.js +16 -31
  49. package/dist/esm/DataGrid/DataGridFilters/DataGridToolbar.esm.js.map +1 -1
  50. package/dist/esm/DataGrid/DataGridFilters/DataGridToolbar.module.scss.esm.js +2 -2
  51. package/dist/esm/DataGrid/DataGridFilters/DataGridToolbarWrapper.esm.js +4 -2
  52. package/dist/esm/DataGrid/DataGridFilters/DataGridToolbarWrapper.esm.js.map +1 -1
  53. package/dist/esm/DataGrid/DataGridFilters/useFiltersReducer.esm.js +59 -0
  54. package/dist/esm/DataGrid/DataGridFilters/useFiltersReducer.esm.js.map +1 -0
  55. package/dist/esm/DataGrid/DataGridHeader/DataGridHeaderCell.esm.js +3 -5
  56. package/dist/esm/DataGrid/DataGridHeader/DataGridHeaderCell.esm.js.map +1 -1
  57. package/dist/esm/DataGrid/DataGridHeader/DataGridHeaderCell.module.scss.esm.js +2 -2
  58. package/dist/esm/Icon/Icon.esm.js +1 -0
  59. package/dist/esm/Icon/Icon.esm.js.map +1 -1
  60. package/dist/esm/Icon/Icon.module.scss.esm.js +2 -2
  61. package/dist/esm/Notifications/BaseModal/BaseModal.esm.js +1 -1
  62. package/dist/esm/Notifications/BaseModal/BaseModal.esm.js.map +1 -1
  63. package/dist/esm/src/components/DataGrid/DataGrid.d.ts +5 -1
  64. package/dist/esm/src/components/DataGrid/DataGridFilters/DataGridFilter.d.ts +3 -3
  65. package/dist/esm/src/components/DataGrid/DataGridFilters/DataGridFilterPopover.d.ts +3 -2
  66. package/dist/esm/src/components/DataGrid/DataGridFilters/DataGridFilterTag.d.ts +2 -1
  67. package/dist/esm/src/components/DataGrid/DataGridFilters/DataGridToolbar.d.ts +2 -1
  68. package/dist/esm/src/components/DataGrid/DataGridFilters/DataGridToolbarWrapper.d.ts +8 -5
  69. package/dist/esm/src/components/DataGrid/DataGridFilters/useFiltersReducer.d.ts +8 -0
  70. package/dist/esm/src/components/DataGrid/DataGridFilters/useFiltersReducer.test.d.ts +1 -0
  71. package/dist/esm/src/components/DataGrid/testUtils.d.ts +1 -0
  72. package/dist/esm/src/components/Icon/Icon.d.ts +2 -1
  73. package/dist/esm/{Notifications/BaseModal → src/hooks}/useRepeatFocus.esm.js +12 -1
  74. package/dist/esm/src/hooks/useRepeatFocus.esm.js.map +1 -0
  75. package/dist/esm/src/index.d.ts +1 -0
  76. package/dist/esm/src/index.esm.js +1 -0
  77. package/dist/esm/src/index.esm.js.map +1 -1
  78. package/package.json +1 -1
  79. package/src/components/DataGrid/DataGrid.tsx +26 -7
  80. package/src/components/DataGrid/DataGridFilters/DataGridFilter.module.scss +21 -11
  81. package/src/components/DataGrid/DataGridFilters/DataGridFilter.tsx +15 -19
  82. package/src/components/DataGrid/DataGridFilters/DataGridFilterPopover.tsx +15 -2
  83. package/src/components/DataGrid/DataGridFilters/DataGridFilterTag.tsx +18 -7
  84. package/src/components/DataGrid/DataGridFilters/DataGridToolbar.module.scss +39 -22
  85. package/src/components/DataGrid/DataGridFilters/DataGridToolbar.tsx +23 -42
  86. package/src/components/DataGrid/DataGridFilters/DataGridToolbarWrapper.tsx +10 -5
  87. package/src/components/DataGrid/DataGridFilters/useFiltersReducer.tsx +66 -0
  88. package/src/components/DataGrid/DataGridHeader/DataGridHeaderCell.module.scss +8 -1
  89. package/src/components/DataGrid/DataGridHeader/DataGridHeaderCell.tsx +3 -8
  90. package/src/components/DataGrid/testUtils.ts +14 -16
  91. package/src/components/Icon/Icon.module.scss +5 -0
  92. package/src/components/Icon/Icon.tsx +2 -1
  93. package/src/components/Notifications/BaseModal/BaseModal.tsx +1 -1
  94. package/src/font/icomoon.eot +0 -0
  95. package/src/font/icomoon.svg +1 -0
  96. package/src/font/icomoon.ttf +0 -0
  97. package/src/font/icomoon.woff +0 -0
  98. package/src/font/selection.json +1 -1
  99. package/src/{components/Notifications/BaseModal → hooks}/useRepeatFocus.tsx +12 -2
  100. package/src/index.ts +1 -0
  101. package/dist/cjs/Notifications/BaseModal/useRepeatFocus.cjs.js +0 -2
  102. package/dist/cjs/Notifications/BaseModal/useRepeatFocus.cjs.js.map +0 -1
  103. package/dist/esm/Notifications/BaseModal/useRepeatFocus.esm.js.map +0 -1
  104. /package/dist/cjs/src/{components/Notifications/BaseModal → hooks}/useRepeatFocus.d.ts +0 -0
  105. /package/dist/esm/src/{components/Notifications/BaseModal → hooks}/useRepeatFocus.d.ts +0 -0
@@ -3,7 +3,7 @@ import { createPortal } from 'react-dom';
3
3
  import { useGetDomRoot } from '../../src/hooks/useGetDomRoot.esm.js';
4
4
  import classes from './BaseModal.module.scss.esm.js';
5
5
  import { labelId, descriptionId } from './BaseModalContext.esm.js';
6
- import { useRepeatFocus } from './useRepeatFocus.esm.js';
6
+ import { useRepeatFocus } from '../../src/hooks/useRepeatFocus.esm.js';
7
7
 
8
8
  /*
9
9
  * Copyright 2022 OneWelcome B.V.
@@ -1 +1 @@
1
- {"version":3,"file":"BaseModal.esm.js","sources":["../../../../../../src/components/Notifications/BaseModal/BaseModal.tsx"],"sourcesContent":["/*\n * Copyright 2022 OneWelcome B.V.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport React, {\n ForwardRefRenderFunction,\n ComponentPropsWithRef,\n useEffect,\n useRef,\n ReactElement,\n RefObject,\n createRef\n} from \"react\";\nimport { createPortal } from \"react-dom\";\nimport { useGetDomRoot } from \"../../../hooks/useGetDomRoot\";\nimport classes from \"./BaseModal.module.scss\";\nimport { labelId, descriptionId } from \"./BaseModalContext\";\nimport { useRepeatFocus } from \"./useRepeatFocus\";\n\nconst SCROLL_PROPERTY_NAME = \"overflow\";\nconst SCROLL_PROPERTY_VALUE = \"hidden\";\n\nexport interface Props extends ComponentPropsWithRef<\"div\"> {\n id: string;\n children: React.ReactNode;\n open: boolean;\n onClose?: (event?: React.MouseEvent<HTMLElement>) => unknown;\n className?: string;\n containerProps?: ComponentPropsWithRef<\"div\">;\n backdropProps?: ComponentPropsWithRef<\"div\">;\n labelledby?: string;\n describedby?: string;\n disableEscapeKeyDown?: boolean;\n disableBackdrop?: boolean;\n forceContainerOpen?: boolean;\n zIndex?: number;\n domRoot?: HTMLElement;\n}\n\nexport const useSetBodyScroll = (open: boolean) => {\n const hideBodyScroll = () => {\n document.body.style[SCROLL_PROPERTY_NAME] = SCROLL_PROPERTY_VALUE;\n };\n\n const showBodyScroll = () => {\n const allModalsClosed =\n document.querySelectorAll(\"[role=dialog][data-hidden=false]\").length === 0;\n if (allModalsClosed) {\n document.body.style.removeProperty(SCROLL_PROPERTY_NAME);\n }\n };\n\n useEffect(() => {\n if (open) {\n hideBodyScroll();\n } else {\n showBodyScroll();\n }\n }, [open]);\n};\n\nconst BaseModalComponent: ForwardRefRenderFunction<HTMLDivElement, Props> = (\n {\n id,\n children,\n open,\n onClose,\n className = \"\",\n containerProps,\n backdropProps,\n labelledby,\n describedby,\n disableEscapeKeyDown = false,\n disableBackdrop = false,\n forceContainerOpen = false,\n zIndex,\n domRoot,\n ...rest\n }: Props,\n ref\n) => {\n useSetBodyScroll(open);\n const wrappingDivRef = useRef<HTMLDivElement>(null);\n const modalRef = (ref as RefObject<HTMLDivElement>) || createRef<HTMLDivElement>();\n const { root } = useGetDomRoot(domRoot, wrappingDivRef);\n\n const handleEscKeyPress = (event: React.KeyboardEvent<HTMLDivElement>) => {\n if (!disableEscapeKeyDown && event.key === \"Escape\") {\n event.stopPropagation();\n onClose?.();\n }\n };\n\n useRepeatFocus(modalRef);\n\n useEffect(() => {\n if (open) {\n modalRef.current?.focus();\n }\n }, [open]);\n\n const handleBackdropClick = () => !disableBackdrop && onClose && onClose();\n\n const renderChildren = () =>\n React.Children.map(children, child => {\n if (React.isValidElement(child)) {\n return React.cloneElement(child as ReactElement, {\n onClose: child.props.onClose ?? onClose\n });\n }\n return child;\n });\n\n return (\n <div ref={wrappingDivRef}>\n {createPortal(\n <div\n {...rest}\n ref={modalRef}\n id={id}\n className={`${classes[\"modal\"]} ${open ? classes[\"visible\"] : \"\"} ${className}`}\n role=\"dialog\"\n aria-modal=\"true\"\n aria-labelledby={labelledby ?? labelId(id)}\n aria-describedby={describedby ?? descriptionId(id)}\n aria-hidden={!open}\n tabIndex={-1}\n data-hidden={!open}\n onKeyDown={handleEscKeyPress}\n style={{ zIndex }}\n >\n <div\n {...backdropProps}\n aria-hidden={true}\n className={`${classes[\"backdrop\"]} ${backdropProps?.className ?? \"\"}`}\n onClick={handleBackdropClick}\n ></div>\n {forceContainerOpen ? (\n <div\n {...containerProps}\n aria-hidden={!open}\n data-element=\"dialog\"\n hidden={!open}\n style={{ zIndex: zIndex && zIndex + 1 }}\n className={`${classes[\"container\"]} ${containerProps?.className ?? \"\"}`}\n >\n {renderChildren()}\n </div>\n ) : (\n open && (\n <div\n {...containerProps}\n data-element=\"dialog\"\n style={{ zIndex: zIndex && zIndex + 1 }}\n className={`${classes[\"container\"]} ${containerProps?.className ?? \"\"}`}\n >\n {renderChildren()}\n </div>\n )\n )}\n </div>,\n root\n )}\n </div>\n );\n};\n\nexport const BaseModal = React.forwardRef(BaseModalComponent);\n"],"names":[],"mappings":";;;;;;;AAAA;;;;;;;;;;;;;;AAcG;AAiBH,MAAM,oBAAoB,GAAG,UAAU,CAAC;AACxC,MAAM,qBAAqB,GAAG,QAAQ,CAAC;AAmB1B,MAAA,gBAAgB,GAAG,CAAC,IAAa,KAAI;IAChD,MAAM,cAAc,GAAG,MAAK;QAC1B,QAAQ,CAAC,IA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EN,IAAI,KACF,KAAA,CAAA,aAAA,CAAA,KAAA,EAAA,EAAA,GACM,cAAc,EACL,cAAA,EAAA,QAAQ,EACrB,KAAK,EAAE,EAAE,MAAM,EAAE,MAAM,IAAI,MAAM,GAAG,CAAC,EAAE,EACvC,SAAS,EAAE,CAAA,EAAG,OAAO,CAAC,WAAW,CAAC,CAAA,CAAA,EAAI,CAAA,EAAA,GAAA,cAAc,KAAd,IAAA,IAAA,cAAc,uBAAd,cAAc,CAAE,SAAS,MAAA,IAAA,IAAA,EAAA,KAAA,KAAA,CAAA,GAAA,EAAA,GAAI,EAAE,CAAA,CAAE,IAEtE,cAAc,EAAE,CACb,CACP,CACF,CACG,EACN,IAAI,CACL,CACG,EACN;AACJ,CAAC,CAAC;AAEW,MAAA,SAAS,GAAG,KAAK,CAAC,UAAU,CAAC,kBAAkB;;;;"}
1
+ {"version":3,"file":"BaseModal.esm.js","sources":["../../../../../../src/components/Notifications/BaseModal/BaseModal.tsx"],"sourcesContent":["/*\n * Copyright 2022 OneWelcome B.V.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport React, {\n ForwardRefRenderFunction,\n ComponentPropsWithRef,\n useEffect,\n useRef,\n ReactElement,\n RefObject,\n createRef\n} from \"react\";\nimport { createPortal } from \"react-dom\";\nimport { useGetDomRoot } from \"../../../hooks/useGetDomRoot\";\nimport classes from \"./BaseModal.module.scss\";\nimport { labelId, descriptionId } from \"./BaseModalContext\";\nimport { useRepeatFocus } from \"../../../hooks/useRepeatFocus\";\n\nconst SCROLL_PROPERTY_NAME = \"overflow\";\nconst SCROLL_PROPERTY_VALUE = \"hidden\";\n\nexport interface Props extends ComponentPropsWithRef<\"div\"> {\n id: string;\n children: React.ReactNode;\n open: boolean;\n onClose?: (event?: React.MouseEvent<HTMLElement>) => unknown;\n className?: string;\n containerProps?: ComponentPropsWithRef<\"div\">;\n backdropProps?: ComponentPropsWithRef<\"div\">;\n labelledby?: string;\n describedby?: string;\n disableEscapeKeyDown?: boolean;\n disableBackdrop?: boolean;\n forceContainerOpen?: boolean;\n zIndex?: number;\n domRoot?: HTMLElement;\n}\n\nexport const useSetBodyScroll = (open: boolean) => {\n const hideBodyScroll = () => {\n document.body.style[SCROLL_PROPERTY_NAME] = SCROLL_PROPERTY_VALUE;\n };\n\n const showBodyScroll = () => {\n const allModalsClosed =\n document.querySelectorAll(\"[role=dialog][data-hidden=false]\").length === 0;\n if (allModalsClosed) {\n document.body.style.removeProperty(SCROLL_PROPERTY_NAME);\n }\n };\n\n useEffect(() => {\n if (open) {\n hideBodyScroll();\n } else {\n showBodyScroll();\n }\n }, [open]);\n};\n\nconst BaseModalComponent: ForwardRefRenderFunction<HTMLDivElement, Props> = (\n {\n id,\n children,\n open,\n onClose,\n className = \"\",\n containerProps,\n backdropProps,\n labelledby,\n describedby,\n disableEscapeKeyDown = false,\n disableBackdrop = false,\n forceContainerOpen = false,\n zIndex,\n domRoot,\n ...rest\n }: Props,\n ref\n) => {\n useSetBodyScroll(open);\n const wrappingDivRef = useRef<HTMLDivElement>(null);\n const modalRef = (ref as RefObject<HTMLDivElement>) || createRef<HTMLDivElement>();\n const { root } = useGetDomRoot(domRoot, wrappingDivRef);\n\n const handleEscKeyPress = (event: React.KeyboardEvent<HTMLDivElement>) => {\n if (!disableEscapeKeyDown && event.key === \"Escape\") {\n event.stopPropagation();\n onClose?.();\n }\n };\n\n useRepeatFocus(modalRef);\n\n useEffect(() => {\n if (open) {\n modalRef.current?.focus();\n }\n }, [open]);\n\n const handleBackdropClick = () => !disableBackdrop && onClose && onClose();\n\n const renderChildren = () =>\n React.Children.map(children, child => {\n if (React.isValidElement(child)) {\n return React.cloneElement(child as ReactElement, {\n onClose: child.props.onClose ?? onClose\n });\n }\n return child;\n });\n\n return (\n <div ref={wrappingDivRef}>\n {createPortal(\n <div\n {...rest}\n ref={modalRef}\n id={id}\n className={`${classes[\"modal\"]} ${open ? classes[\"visible\"] : \"\"} ${className}`}\n role=\"dialog\"\n aria-modal=\"true\"\n aria-labelledby={labelledby ?? labelId(id)}\n aria-describedby={describedby ?? descriptionId(id)}\n aria-hidden={!open}\n tabIndex={-1}\n data-hidden={!open}\n onKeyDown={handleEscKeyPress}\n style={{ zIndex }}\n >\n <div\n {...backdropProps}\n aria-hidden={true}\n className={`${classes[\"backdrop\"]} ${backdropProps?.className ?? \"\"}`}\n onClick={handleBackdropClick}\n ></div>\n {forceContainerOpen ? (\n <div\n {...containerProps}\n aria-hidden={!open}\n data-element=\"dialog\"\n hidden={!open}\n style={{ zIndex: zIndex && zIndex + 1 }}\n className={`${classes[\"container\"]} ${containerProps?.className ?? \"\"}`}\n >\n {renderChildren()}\n </div>\n ) : (\n open && (\n <div\n {...containerProps}\n data-element=\"dialog\"\n style={{ zIndex: zIndex && zIndex + 1 }}\n className={`${classes[\"container\"]} ${containerProps?.className ?? \"\"}`}\n >\n {renderChildren()}\n </div>\n )\n )}\n </div>,\n root\n )}\n </div>\n );\n};\n\nexport const BaseModal = React.forwardRef(BaseModalComponent);\n"],"names":[],"mappings":";;;;;;;AAAA;;;;;;;;;;;;;;AAcG;AAiBH,MAAM,oBAAoB,GAAG,UAAU,CAAC;AACxC,MAAM,qBAAqB,GAAG,QAAQ,CAAC;AAmB1B,MAAA,gBAAgB,GAAG,CAAC,IAAa,KAAI;IAChD,MAAM,cAAc,GAAG,MAAK;QAC1B,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,oBAAoB,CAAC,GAAG,qBAAqB,CAAC;AACpE,KAAC,CAAC;IAEF,MAAM,cAAc,GAAG,MAAK;AAC1B,QAAA,MAAM,eAAe,GACnB,QAAQ,CAAC,g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,CAAC,EAAE,EACvC,SAAS,EAAE,CAAA,EAAG,OAAO,CAAC,WAAW,CAAC,CAAA,CAAA,EAAI,CAAA,EAAA,GAAA,cAAc,KAAd,IAAA,IAAA,cAAc,uBAAd,cAAc,CAAE,SAAS,MAAA,IAAA,IAAA,EAAA,KAAA,KAAA,CAAA,GAAA,EAAA,GAAI,EAAE,CAAA,CAAE,IAEtE,cAAc,EAAE,CACb,CACP,CACF,CACG,EACN,IAAI,CACL,CACG,EACN;AACJ,CAAC,CAAC;AAEW,MAAA,SAAS,GAAG,KAAK,CAAC,UAAU,CAAC,kBAAkB;;;;"}
@@ -1,5 +1,5 @@
1
1
  import { ComponentPropsWithRef, ReactElement, Ref } from "react";
2
- import { Props as ButtonProps } from "../Button/Button";
2
+ import { Button, Props as ButtonProps } from "../Button/Button";
3
3
  import { HeaderCell, OnSortFunction, Sort } from "./datagrid.interfaces";
4
4
  import { Props as PaginationProps } from "../Pagination/Pagination";
5
5
  import { Spacing } from "../../hooks/useSpacing";
@@ -14,6 +14,9 @@ export interface Props<T> extends Omit<ComponentPropsWithRef<"div">, "children">
14
14
  initialSort?: Sort;
15
15
  onSort?: OnSortFunction;
16
16
  headers: HeaderCell[];
17
+ /**
18
+ * @deprecated use the `toolbarButtons` prop instead
19
+ */
17
20
  actions?: {
18
21
  enableAddBtn?: boolean;
19
22
  enableColumnsBtn?: boolean;
@@ -29,6 +32,7 @@ export interface Props<T> extends Omit<ComponentPropsWithRef<"div">, "children">
29
32
  enableExpandableRow?: boolean;
30
33
  filters?: DataGridToolbarProps;
31
34
  search?: DataGridSearchbarProps;
35
+ toolbarButtons?: ReactElement<ButtonProps, typeof Button> | ReactElement<ButtonProps, typeof Button>[];
32
36
  isLoading?: boolean;
33
37
  enableMultiSorting?: boolean;
34
38
  spacing?: Spacing;
@@ -1,15 +1,15 @@
1
1
  import React from "react";
2
- import { DataGridColumnMetadata, Filter, FilterEditorMode, FiltersAction, PopoverTranslations, TagTranslations } from "./DataGridFilters.interfaces";
2
+ import { DataGridColumnMetadata, Filter, FilterEditorMode, PopoverTranslations, TagTranslations } from "./DataGridFilters.interfaces";
3
3
  export type Props = {
4
4
  mode: FilterEditorMode;
5
5
  domRoot?: HTMLElement;
6
6
  filter?: Filter;
7
7
  columnsMetadata: DataGridColumnMetadata[];
8
- dispatch: React.Dispatch<FiltersAction>;
9
8
  onFilterAdd?: (filter: Filter) => void;
10
9
  onFilterEdit?: (filter: Filter) => void;
11
10
  onFilterDelete?: (id: string) => void;
12
11
  tagTranslations?: TagTranslations;
13
12
  popoverTranslations?: PopoverTranslations;
13
+ customEditTagContent?: React.ReactElement;
14
14
  };
15
- export declare const DataGridFilter: ({ mode, filter, domRoot, columnsMetadata, dispatch, onFilterAdd, onFilterEdit, onFilterDelete, tagTranslations, popoverTranslations }: Props) => React.JSX.Element;
15
+ export declare const DataGridFilter: ({ mode, filter, domRoot, columnsMetadata, onFilterAdd, onFilterEdit, onFilterDelete, tagTranslations, popoverTranslations, customEditTagContent }: Props) => React.JSX.Element;
@@ -1,7 +1,8 @@
1
1
  import React from "react";
2
2
  import { DataGridColumnMetadata, PopoverTranslations } from "./DataGridFilters.interfaces";
3
3
  export type Props = {
4
- anchorRef?: React.RefObject<HTMLOrSVGElement>;
4
+ popoverRef: React.RefObject<HTMLDivElement>;
5
+ anchorRef?: React.RefObject<HTMLDivElement>;
5
6
  isOpen: boolean;
6
7
  column: string;
7
8
  columnsMetadata: DataGridColumnMetadata[];
@@ -19,4 +20,4 @@ export type Props = {
19
20
  setPickedValues: (pickedValues: React.SetStateAction<string[]>) => void;
20
21
  translations?: PopoverTranslations;
21
22
  };
22
- export declare const DataGridFilterPopover: ({ anchorRef, isOpen, column, columnsMetadata, values, pickedValues, operator, operators, onFilterSubmit, resetFields, setFilterOpen, setColumn, setOperator, setOperators, setValues, setPickedValues, translations }: Props) => React.JSX.Element;
23
+ export declare const DataGridFilterPopover: ({ popoverRef, anchorRef, isOpen, column, columnsMetadata, values, pickedValues, operator, operators, onFilterSubmit, resetFields, setFilterOpen, setColumn, setOperator, setOperators, setValues, setPickedValues, translations }: Props) => React.JSX.Element;
@@ -1,7 +1,8 @@
1
1
  import React, { ComponentPropsWithRef, ForwardRefRenderFunction } from "react";
2
2
  import { Filter, FilterEditorMode, TagTranslations } from "./DataGridFilters.interfaces";
3
3
  export interface DataGridFilterTagProps extends ComponentPropsWithRef<"div"> {
4
- triggerRef: React.Ref<HTMLDivElement>;
4
+ customEditTagContent?: React.ReactElement;
5
+ triggerRef: React.Ref<HTMLButtonElement>;
5
6
  filter?: Filter;
6
7
  mode: FilterEditorMode;
7
8
  onFilterRemove: () => void;
@@ -2,6 +2,7 @@ import React from "react";
2
2
  import { DataGridColumnMetadata, Filter, FiltersTranslations } from "./DataGridFilters.interfaces";
3
3
  export interface DataGridToolbarProps {
4
4
  columnsMetadata: DataGridColumnMetadata[];
5
+ customEditTagContent?: React.ReactElement;
5
6
  filterValues?: Filter[];
6
7
  translations?: FiltersTranslations;
7
8
  onFilterAdd?: (filter: Filter) => void;
@@ -9,4 +10,4 @@ export interface DataGridToolbarProps {
9
10
  onFilterDelete?: (id: string) => void;
10
11
  onFiltersClear?: () => void;
11
12
  }
12
- export declare const DataGridToolbar: ({ columnsMetadata, filterValues, translations, onFilterAdd, onFilterEdit, onFilterDelete, onFiltersClear }: DataGridToolbarProps) => React.JSX.Element;
13
+ export declare const DataGridToolbar: ({ columnsMetadata, filterValues, translations, onFilterAdd, onFilterEdit, onFilterDelete, onFiltersClear, customEditTagContent }: DataGridToolbarProps) => React.JSX.Element;
@@ -1,7 +1,10 @@
1
- import React, { ComponentPropsWithRef, ForwardRefRenderFunction } from "react";
2
- type Props = ComponentPropsWithRef<"div">;
1
+ import React, { ComponentPropsWithRef, ForwardRefRenderFunction, ReactElement } from "react";
2
+ import { Button } from "../../Button/Button";
3
+ import { ButtonProps } from "../../..";
4
+ interface Props extends ComponentPropsWithRef<"div"> {
5
+ filters?: React.JSX.Element;
6
+ buttons?: ReactElement<ButtonProps, typeof Button> | ReactElement<ButtonProps, typeof Button>[];
7
+ }
3
8
  export declare const DataGridToolbarWrapperComponent: ForwardRefRenderFunction<HTMLDivElement, Props>;
4
- export declare const DataGridToolbarWrapper: React.ForwardRefExoticComponent<Omit<Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & {
5
- ref?: ((instance: HTMLDivElement | null) => void | React.DO_NOT_USE_OR_YOU_WILL_BE_FIRED_CALLBACK_REF_RETURN_VALUES[keyof React.DO_NOT_USE_OR_YOU_WILL_BE_FIRED_CALLBACK_REF_RETURN_VALUES]) | React.RefObject<HTMLDivElement> | null | undefined;
6
- }, "ref"> & React.RefAttributes<HTMLDivElement>>;
9
+ export declare const DataGridToolbarWrapper: React.ForwardRefExoticComponent<Omit<Props, "ref"> & React.RefAttributes<HTMLDivElement>>;
7
10
  export {};
@@ -0,0 +1,8 @@
1
+ import { Filter, FiltersState } from "./DataGridFilters.interfaces";
2
+ export declare const useFiltersReducer: (filterValues: Filter[] | undefined) => {
3
+ state: FiltersState;
4
+ addFilter: (filter: Filter) => void;
5
+ deleteFilter: (id: string) => void;
6
+ editFilter: (filter: Filter) => void;
7
+ clearFilters: () => void;
8
+ };
@@ -9,5 +9,6 @@ export declare const useMockFilteringLogic: <T>(data: T[], filterValues: Filter[
9
9
  onFilterDelete: (id: string) => void;
10
10
  onFiltersClear: () => void;
11
11
  gridData: T[];
12
+ setGridData: import("react").Dispatch<import("react").SetStateAction<T[]>>;
12
13
  filters: Filter[];
13
14
  };
@@ -80,7 +80,8 @@ export declare enum Icons {
80
80
  FileAltIcon = "file-alt",
81
81
  AddCircle = "add-circle",
82
82
  ZoomIn = "zoom-in",
83
- ZoomOut = "zoom-out"
83
+ ZoomOut = "zoom-out",
84
+ ArrowUp = "arrow-up"
84
85
  }
85
86
  type Tag = "span" | "div" | "i";
86
87
  export interface Props extends ComponentPropsWithRef<"div"> {
@@ -22,7 +22,18 @@ import { useEffect } from 'react';
22
22
  */
23
23
  const useRepeatFocus = (ref) => {
24
24
  const getFocusableElement = (element, position) => {
25
- const focusableSelectors = 'button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])';
25
+ const baseSelectors = [
26
+ "button",
27
+ "[href]",
28
+ "input",
29
+ "select",
30
+ "textarea",
31
+ "[tabindex]",
32
+ "[contenteditable]"
33
+ ];
34
+ const focusableSelectors = baseSelectors
35
+ .map(selector => `${selector}:not([tabindex="-1"])`)
36
+ .join(", ");
26
37
  const focusableElements = element.querySelectorAll(focusableSelectors);
27
38
  if (position === "first") {
28
39
  return focusableElements[0] || null;
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useRepeatFocus.esm.js","sources":["../../../../../../src/hooks/useRepeatFocus.tsx"],"sourcesContent":["/*\n * Copyright 2022 OneWelcome B.V.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { RefObject, useEffect } from \"react\";\n\n/**\n * @description This is a hook that will make sure that when a modal is open and the user tabs through the it,\n * the focus will be repeated and the user will not lose their entire focusable element to an element in the background\n * that is being blocked by the modal.\n */\n\nexport const useRepeatFocus = (ref: RefObject<HTMLDivElement>) => {\n const getFocusableElement = (\n element: HTMLElement,\n position: \"first\" | \"last\"\n ): HTMLElement | null => {\n const baseSelectors = [\n \"button\",\n \"[href]\",\n \"input\",\n \"select\",\n \"textarea\",\n \"[tabindex]\",\n \"[contenteditable]\"\n ];\n const focusableSelectors = baseSelectors\n .map(selector => `${selector}:not([tabindex=\"-1\"])`)\n .join(\", \");\n const focusableElements = element.querySelectorAll<HTMLElement>(focusableSelectors);\n\n if (position === \"first\") {\n return focusableElements[0] || null;\n } else if (position === \"last\") {\n return focusableElements[focusableElements.length - 1] || null;\n }\n\n return null;\n };\n\n useEffect(() => {\n if (!ref.current || !open) return;\n\n const lastFocusableElement = getFocusableElement(ref.current, \"last\");\n const firstFocusableElement = getFocusableElement(ref.current, \"first\");\n\n if (!lastFocusableElement || !firstFocusableElement) return;\n\n const handleTabKeyPress = (event: KeyboardEvent) => {\n if (event.key !== \"Tab\") return;\n\n if (event.shiftKey) {\n if (document.activeElement === firstFocusableElement) {\n event.preventDefault();\n lastFocusableElement?.focus();\n }\n } else if (document.activeElement === lastFocusableElement) {\n event.preventDefault();\n firstFocusableElement?.focus();\n }\n };\n\n lastFocusableElement.addEventListener(\"keydown\", handleTabKeyPress);\n firstFocusableElement.addEventListener(\"keydown\", handleTabKeyPress);\n\n return () => {\n lastFocusableElement.removeEventListener(\"keydown\", handleTabKeyPress);\n firstFocusableElement.removeEventListener(\"keydown\", handleTabKeyPress);\n };\n }, [ref, open]);\n};\n"],"names":[],"mappings":";;AAAA;;;;;;;;;;;;;;AAcG;AAIH;;;;AAIG;AAEU,MAAA,cAAc,GAAG,CAAC,GAA8B,KAAI;AAC/D,IAAA,MAAM,mBAAmB,GAAG,CAC1B,OAAoB,EACpB,QAA0B,KACJ;AACtB,QAAA,MAAM,aAAa,GAAG;YACpB,QAAQ;YACR,QAAQ;YACR,OAAO;YACP,QAAQ;YACR,UAAU;YACV,YAAY;YACZ,mBAAmB;SACpB,CAAC;QACF,MAAM,kBAAkB,GAAG,aAAa;aACrC,GAAG,CAAC,QAAQ,IAAI,CAAG,EAAA,QAAQ,uBAAuB,CAAC;aACnD,IAAI,CAAC,IAAI,CAAC,CAAC;QACd,MAAM,iBAAiB,GAAG,OAAO,CAAC,gBAAgB,CAAc,kBAAkB,CAAC,CAAC;AAEpF,QAAA,IAAI,QAAQ,KAAK,OAAO,EAAE;AACxB,YAAA,OAAO,iBAAiB,CAAC,CAAC,CAAC,IAAI,IAAI,CAAC;SACrC;AAAM,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AE,iBAAiB,CAAC,CAAC;AAErE,QAAA,OAAO,MAAK;AACV,YAAA,oBAAoB,CAAC,mBAAmB,CAAC,SAAS,EAAE,iBAAiB,CAAC,CAAC;AACvE,YAAA,qBAAqB,CAAC,mBAAmB,CAAC,SAAS,EAAE,iBAAiB,CAAC,CAAC;AAC1E,SAAC,CAAC;AACJ,KAAC,EAAE,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC,CAAC;AAClB;;;;"}
@@ -126,6 +126,7 @@ export { DataGridDrawerItem } from "./components/DataGrid/DataGridBody/DataGridD
126
126
  export type { Props as DataGridDrawerItemProps } from "./components/DataGrid/DataGridBody/DataGridDrawer/DataGridDrawerItem";
127
127
  export { DataGridCell } from "./components/DataGrid/DataGridBody/DataGridCell/DataGridCell";
128
128
  export type { Props as DataGridCellProps } from "./components/DataGrid/DataGridBody/DataGridCell/DataGridCell";
129
+ export { useFiltersReducer } from "./components/DataGrid/DataGridFilters/useFiltersReducer";
129
130
  export { Banner } from "./components/Notifications/Banner/Banner";
130
131
  export type { Props as BannerProps } from "./components/Notifications/Banner/Banner";
131
132
  /** Admin */
@@ -64,6 +64,7 @@ export { DataGrid } from '../DataGrid/DataGrid.esm.js';
64
64
  export { DataGridRow } from '../DataGrid/DataGridBody/DataGridRow/DataGridRow.esm.js';
65
65
  export { DataGridDrawerItem } from '../DataGrid/DataGridBody/DataGridDrawer/DataGridDrawerItem.esm.js';
66
66
  export { DataGridCell } from '../DataGrid/DataGridBody/DataGridCell/DataGridCell.esm.js';
67
+ export { useFiltersReducer } from '../DataGrid/DataGridFilters/useFiltersReducer.esm.js';
67
68
  export { Banner } from '../Notifications/Banner/Banner.esm.js';
68
69
  export { MicrofrontendContainer } from '../admin/layout/MicrofrontendContainer/MicrofrontendContainer.esm.js';
69
70
  //# sourceMappingURL=index.esm.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.esm.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"index.esm.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "homepage": "http://onewelcome.github.io/react-lib-components",
3
3
  "name": "@onewelcome/react-lib-components",
4
- "version": "8.0.0",
4
+ "version": "8.1.0",
5
5
  "license": "Apache-2.0",
6
6
  "author": "OneWelcome B.V.",
7
7
  "main": "dist/cjs/src/index.cjs.js",
@@ -14,8 +14,15 @@
14
14
  * limitations under the License.
15
15
  */
16
16
 
17
- import React, { ComponentPropsWithRef, ReactElement, Ref, useEffect, useState } from "react";
18
- import { Props as ButtonProps } from "../Button/Button";
17
+ import React, {
18
+ ComponentPropsWithRef,
19
+ Fragment,
20
+ ReactElement,
21
+ Ref,
22
+ useEffect,
23
+ useState
24
+ } from "react";
25
+ import { Button, Props as ButtonProps } from "../Button/Button";
19
26
  import classes from "./DataGrid.module.scss";
20
27
  import { DataGridHeader } from "./DataGridHeader/DataGridHeader";
21
28
  import { DataGridActions } from "./DataGridActions/DataGridActions";
@@ -33,6 +40,9 @@ export interface Props<T> extends Omit<ComponentPropsWithRef<"div">, "children">
33
40
  initialSort?: Sort;
34
41
  onSort?: OnSortFunction;
35
42
  headers: HeaderCell[];
43
+ /**
44
+ * @deprecated use the `toolbarButtons` prop instead
45
+ */
36
46
  actions?: {
37
47
  enableAddBtn?: boolean;
38
48
  enableColumnsBtn?: boolean;
@@ -48,6 +58,9 @@ export interface Props<T> extends Omit<ComponentPropsWithRef<"div">, "children">
48
58
  enableExpandableRow?: boolean;
49
59
  filters?: DataGridToolbarProps;
50
60
  search?: DataGridSearchbarProps;
61
+ toolbarButtons?:
62
+ | ReactElement<ButtonProps, typeof Button>
63
+ | ReactElement<ButtonProps, typeof Button>[];
51
64
  isLoading?: boolean;
52
65
  enableMultiSorting?: boolean;
53
66
  spacing?: Spacing;
@@ -66,6 +79,7 @@ const DataGridInner = <T extends {}>(
66
79
  enableExpandableRow,
67
80
  filters,
68
81
  search,
82
+ toolbarButtons,
69
83
  isLoading,
70
84
  enableMultiSorting,
71
85
  emptyLabel,
@@ -133,11 +147,16 @@ const DataGridInner = <T extends {}>(
133
147
  paddingBottom: styleWithSpacing?.paddingBottom
134
148
  }}
135
149
  >
136
- {filters || search ? (
137
- <DataGridToolbarWrapper>
138
- {search && <DataGridSearchbar {...search} />}
139
- {filters && <DataGridToolbar {...filters} />}
140
- </DataGridToolbarWrapper>
150
+ {filters || search || toolbarButtons ? (
151
+ <DataGridToolbarWrapper
152
+ filters={
153
+ <Fragment>
154
+ {search && <DataGridSearchbar {...search} />}
155
+ {filters && <DataGridToolbar {...filters} />}
156
+ </Fragment>
157
+ }
158
+ buttons={toolbarButtons}
159
+ />
141
160
  ) : (
142
161
  <DataGridActions
143
162
  {...actions}
@@ -21,10 +21,19 @@
21
21
  justify-content: center;
22
22
  align-items: center;
23
23
  gap: 0.375rem;
24
+ min-height: 1.5rem;
24
25
  padding: 0.25rem 0.75rem 0.25rem 0.5rem;
25
26
  border-radius: 3.125rem;
26
27
  background-color: var(--color-blue-grey100);
27
28
 
29
+ &:hover {
30
+ background-color: var(--color-blue-grey200);
31
+ }
32
+
33
+ &:active {
34
+ background-color: var(--color-primary100);
35
+ }
36
+
28
37
  .filter-button {
29
38
  display: flex;
30
39
  justify-content: flex-start;
@@ -39,18 +48,13 @@
39
48
  margin-right: -0.25rem;
40
49
  }
41
50
 
42
- &:hover {
43
- border-radius: 0.125rem;
44
- background-color: var(--color-black10);
45
- }
46
-
47
- &:active {
48
- background-color: var(--color-blue-grey400);
49
- }
50
-
51
51
  @include mixins.focusVisibleOutline($outlineOffset: 0);
52
52
  }
53
53
 
54
+ .remove-button {
55
+ border-radius: 1.25rem;
56
+ }
57
+
54
58
  .caption {
55
59
  font-size: var(--font-size-data-grid);
56
60
  line-height: var(--data-grid-line-height);
@@ -84,8 +88,7 @@
84
88
  display: flex;
85
89
  gap: 1rem;
86
90
 
87
- & > *:last-child,
88
- *:first-child {
91
+ & > *:first-child {
89
92
  flex-grow: 1.8;
90
93
  flex-shrink: 0;
91
94
  margin-top: 0;
@@ -96,6 +99,13 @@
96
99
  flex-shrink: 0;
97
100
  margin-top: 0;
98
101
  }
102
+
103
+ & > *:last-child {
104
+ flex-basis: 15rem;
105
+ flex-grow: 1.8;
106
+ flex-shrink: 0;
107
+ margin-top: 0;
108
+ }
99
109
  }
100
110
 
101
111
  .actions {
@@ -14,14 +14,13 @@
14
14
  * limitations under the License.
15
15
  */
16
16
 
17
- import React, { Fragment, createRef, useState } from "react";
17
+ import React, { Fragment, useRef, useState } from "react";
18
18
  import { createPortal } from "react-dom";
19
19
  import { useGetDomRoot } from "../../../hooks/useGetDomRoot";
20
20
  import {
21
21
  DataGridColumnMetadata,
22
22
  Filter,
23
23
  FilterEditorMode,
24
- FiltersAction,
25
24
  PopoverTranslations,
26
25
  TagTranslations
27
26
  } from "./DataGridFilters.interfaces";
@@ -35,12 +34,12 @@ export type Props = {
35
34
  domRoot?: HTMLElement;
36
35
  filter?: Filter;
37
36
  columnsMetadata: DataGridColumnMetadata[];
38
- dispatch: React.Dispatch<FiltersAction>;
39
37
  onFilterAdd?: (filter: Filter) => void;
40
38
  onFilterEdit?: (filter: Filter) => void;
41
39
  onFilterDelete?: (id: string) => void;
42
40
  tagTranslations?: TagTranslations;
43
41
  popoverTranslations?: PopoverTranslations;
42
+ customEditTagContent?: React.ReactElement;
44
43
  };
45
44
 
46
45
  export const DataGridFilter = ({
@@ -48,14 +47,17 @@ export const DataGridFilter = ({
48
47
  filter,
49
48
  domRoot,
50
49
  columnsMetadata,
51
- dispatch,
52
50
  onFilterAdd,
53
51
  onFilterEdit,
54
52
  onFilterDelete,
55
53
  tagTranslations,
56
- popoverTranslations
54
+ popoverTranslations,
55
+ customEditTagContent
57
56
  }: Props) => {
58
- const wrappingDivRef = createRef<HTMLDivElement>();
57
+ const wrappingDivRef = useRef<HTMLDivElement>(null);
58
+ const triggerRef = useRef<HTMLButtonElement>(null);
59
+ const popoverRef = useRef<HTMLDivElement>(null);
60
+
59
61
  const [filterOpen, setFilterOpen] = useState(false);
60
62
  const { root } = useGetDomRoot(domRoot, wrappingDivRef);
61
63
  const {
@@ -76,19 +78,9 @@ export const DataGridFilter = ({
76
78
  const onFilterSubmit = () => {
77
79
  if (mode === "ADD") {
78
80
  const id = generateID();
79
-
80
- dispatch({
81
- type: "add",
82
- payload: { id, column, operator, value: pickedValues }
83
- });
84
81
  onFilterAdd && onFilterAdd({ id, column, operator, value: pickedValues });
85
82
  } else if (mode === "EDIT" && filter) {
86
83
  const { id } = filter;
87
-
88
- dispatch({
89
- type: "edit",
90
- payload: { id, column, operator, value: pickedValues }
91
- });
92
84
  onFilterEdit && onFilterEdit({ id, column, operator, value: pickedValues });
93
85
  }
94
86
 
@@ -100,9 +92,8 @@ export const DataGridFilter = ({
100
92
  if (!filter) {
101
93
  return;
102
94
  }
103
- const { id } = filter;
104
95
 
105
- dispatch({ type: "remove", payload: { id } });
96
+ const { id } = filter;
106
97
  onFilterDelete && onFilterDelete(id);
107
98
 
108
99
  resetFields();
@@ -121,13 +112,18 @@ export const DataGridFilter = ({
121
112
  mode={mode}
122
113
  onFilterOpen={onFilterOpen}
123
114
  onFilterRemove={onFilterRemove}
124
- triggerRef={wrappingDivRef}
115
+ triggerRef={triggerRef}
116
+ ref={wrappingDivRef}
125
117
  filter={filter}
118
+ translations={tagTranslations}
119
+ customEditTagContent={customEditTagContent}
126
120
  />
127
121
  {createPortal(
128
122
  <DataGridFilterPopover
123
+ popoverRef={popoverRef}
129
124
  anchorRef={wrappingDivRef}
130
125
  isOpen={filterOpen}
126
+ translations={popoverTranslations}
131
127
  column={column}
132
128
  columnsMetadata={columnsMetadata}
133
129
  values={values}
@@ -14,7 +14,7 @@
14
14
  * limitations under the License.
15
15
  */
16
16
 
17
- import React from "react";
17
+ import React, { useEffect } from "react";
18
18
  import classes from "./DataGridFilter.module.scss";
19
19
  import { Button } from "../../Button/Button";
20
20
  import { Option } from "../../Form/Select/SingleSelect/Option";
@@ -27,9 +27,11 @@ import {
27
27
  DefaultOperators,
28
28
  PopoverTranslations
29
29
  } from "./DataGridFilters.interfaces";
30
+ import { useRepeatFocus } from "../../../hooks/useRepeatFocus";
30
31
 
31
32
  export type Props = {
32
- anchorRef?: React.RefObject<HTMLOrSVGElement>;
33
+ popoverRef: React.RefObject<HTMLDivElement>;
34
+ anchorRef?: React.RefObject<HTMLDivElement>;
33
35
  isOpen: boolean;
34
36
  column: string;
35
37
  columnsMetadata: DataGridColumnMetadata[];
@@ -49,6 +51,7 @@ export type Props = {
49
51
  };
50
52
 
51
53
  export const DataGridFilterPopover = ({
54
+ popoverRef,
52
55
  anchorRef,
53
56
  isOpen,
54
57
  column,
@@ -76,9 +79,19 @@ export const DataGridFilterPopover = ({
76
79
  submitButtonTitle = "Apply",
77
80
  cancelButtonTitle = "Cancel"
78
81
  } = translations || {};
82
+ useRepeatFocus(popoverRef);
83
+
84
+ useEffect(() => {
85
+ if (isOpen) {
86
+ popoverRef.current?.focus();
87
+ }
88
+ }, [isOpen]);
89
+
79
90
  return (
80
91
  <Popover
92
+ tabIndex={-1}
81
93
  anchorEl={anchorRef}
94
+ ref={popoverRef}
82
95
  show={isOpen}
83
96
  placement={{ horizontal: "left", vertical: "bottom" }}
84
97
  transformOrigin={{ horizontal: "left", vertical: "top" }}
@@ -22,7 +22,8 @@ import classes from "./DataGridFilter.module.scss";
22
22
  import { Filter, FilterEditorMode, TagTranslations } from "./DataGridFilters.interfaces";
23
23
 
24
24
  export interface DataGridFilterTagProps extends ComponentPropsWithRef<"div"> {
25
- triggerRef: React.Ref<HTMLDivElement>;
25
+ customEditTagContent?: React.ReactElement;
26
+ triggerRef: React.Ref<HTMLButtonElement>;
26
27
  filter?: Filter;
27
28
  mode: FilterEditorMode;
28
29
  onFilterRemove: () => void;
@@ -38,7 +39,6 @@ const EditTagContent = ({ filter }: { filter: Filter }) => {
38
39
  {column} {operator} {value.length > 0 && <b>{value[0]}</b>}
39
40
  {value.length >= 2 && (
40
41
  <>
41
- {" "}
42
42
  or <b> {value.length - 1} other</b>
43
43
  </>
44
44
  )}
@@ -57,7 +57,7 @@ export const DataGridFilterTagComponent: ForwardRefRenderFunction<
57
57
  onFilterRemove,
58
58
  onFilterOpen,
59
59
  translations,
60
-
60
+ customEditTagContent,
61
61
  ...rest
62
62
  }: DataGridFilterTagProps,
63
63
  ref
@@ -67,8 +67,13 @@ export const DataGridFilterTagComponent: ForwardRefRenderFunction<
67
67
  const shouldRenderEditTag = mode === "EDIT" && filter;
68
68
 
69
69
  return (
70
- <div {...rest} ref={triggerRef} className={classes["filter-wrapper"]}>
71
- <button type="button" className={classes["filter-button"]} onClick={onFilterOpen}>
70
+ <div {...rest} ref={ref} className={classes["filter-wrapper"]}>
71
+ <button
72
+ ref={triggerRef}
73
+ type="button"
74
+ className={classes["filter-button"]}
75
+ onClick={onFilterOpen}
76
+ >
72
77
  {shouldRenderAddTag && (
73
78
  <Fragment>
74
79
  <Icon icon={Icons.AddCircle} />
@@ -79,11 +84,17 @@ export const DataGridFilterTagComponent: ForwardRefRenderFunction<
79
84
  )}
80
85
  {shouldRenderEditTag && (
81
86
  <Typography variant="body" className={classes["caption"]}>
82
- <EditTagContent filter={filter} />
87
+ {customEditTagContent ? (
88
+ React.cloneElement(customEditTagContent, { filter })
89
+ ) : (
90
+ <EditTagContent filter={filter} />
91
+ )}
83
92
  </Typography>
84
93
  )}
85
94
  </button>
86
- {shouldRenderEditTag && <RemoveButton onRemove={onFilterRemove} />}
95
+ {shouldRenderEditTag && (
96
+ <RemoveButton className={classes["remove-button"]} onRemove={onFilterRemove} />
97
+ )}
87
98
  </div>
88
99
  );
89
100
  };