@onewelcome/react-lib-components 7.1.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.
- package/dist/cjs/DataGrid/DataGrid.cjs.js +1 -1
- package/dist/cjs/DataGrid/DataGrid.cjs.js.map +1 -1
- package/dist/cjs/DataGrid/DataGridBody/DataGridBody.cjs.js +1 -1
- package/dist/cjs/DataGrid/DataGridBody/DataGridBody.cjs.js.map +1 -1
- package/dist/cjs/DataGrid/DataGridBody/DataGridCell/DataGridCell.cjs.js +1 -1
- package/dist/cjs/DataGrid/DataGridBody/DataGridCell/DataGridCell.cjs.js.map +1 -1
- package/dist/cjs/DataGrid/DataGridBody/DataGridRow/DataGridRow.cjs.js +1 -1
- package/dist/cjs/DataGrid/DataGridBody/DataGridRow/DataGridRow.cjs.js.map +1 -1
- package/dist/cjs/DataGrid/DataGridFilters/DataGridFilter.cjs.js +1 -1
- package/dist/cjs/DataGrid/DataGridFilters/DataGridFilter.cjs.js.map +1 -1
- package/dist/cjs/DataGrid/DataGridFilters/DataGridFilter.module.scss.cjs.js +1 -1
- package/dist/cjs/DataGrid/DataGridFilters/DataGridFilterPopover.cjs.js +1 -1
- package/dist/cjs/DataGrid/DataGridFilters/DataGridFilterPopover.cjs.js.map +1 -1
- package/dist/cjs/DataGrid/DataGridFilters/DataGridFilterTag.cjs.js +1 -1
- package/dist/cjs/DataGrid/DataGridFilters/DataGridFilterTag.cjs.js.map +1 -1
- package/dist/cjs/DataGrid/DataGridFilters/DataGridSearchbar.cjs.js +2 -0
- package/dist/cjs/DataGrid/DataGridFilters/DataGridSearchbar.cjs.js.map +1 -0
- package/dist/cjs/DataGrid/DataGridFilters/DataGridToolbar.cjs.js +1 -1
- package/dist/cjs/DataGrid/DataGridFilters/DataGridToolbar.cjs.js.map +1 -1
- package/dist/cjs/DataGrid/DataGridFilters/DataGridToolbar.module.scss.cjs.js +1 -1
- package/dist/cjs/DataGrid/DataGridFilters/DataGridToolbarWrapper.cjs.js +2 -0
- package/dist/cjs/DataGrid/DataGridFilters/DataGridToolbarWrapper.cjs.js.map +1 -0
- package/dist/cjs/DataGrid/DataGridFilters/useFiltersReducer.cjs.js +2 -0
- package/dist/cjs/DataGrid/DataGridFilters/useFiltersReducer.cjs.js.map +1 -0
- package/dist/cjs/DataGrid/DataGridHeader/DataGridHeaderCell.cjs.js +1 -1
- package/dist/cjs/DataGrid/DataGridHeader/DataGridHeaderCell.cjs.js.map +1 -1
- package/dist/cjs/DataGrid/DataGridHeader/DataGridHeaderCell.module.scss.cjs.js +1 -1
- package/dist/cjs/Form/FileUpload/FileUpload.module.scss.cjs.js +1 -1
- package/dist/cjs/Form/Select/MultiSelect/MultiSelect.cjs.js +1 -1
- package/dist/cjs/Form/Select/MultiSelect/MultiSelect.cjs.js.map +1 -1
- package/dist/cjs/Form/Select/SingleSelect/Select.cjs.js +1 -1
- package/dist/cjs/Form/Select/SingleSelect/Select.cjs.js.map +1 -1
- package/dist/cjs/Icon/Icon.cjs.js +1 -1
- package/dist/cjs/Icon/Icon.cjs.js.map +1 -1
- package/dist/cjs/Icon/Icon.module.scss.cjs.js +1 -1
- package/dist/cjs/Notifications/BaseModal/BaseModal.cjs.js +1 -1
- package/dist/cjs/Notifications/BaseModal/BaseModal.cjs.js.map +1 -1
- package/dist/cjs/src/components/DataGrid/DataGrid.d.ts +8 -5
- package/dist/cjs/src/components/DataGrid/DataGridBody/DataGridBody.d.ts +1 -0
- package/dist/cjs/src/components/DataGrid/DataGridBody/DataGridCell/DataGridCell.d.ts +1 -0
- package/dist/cjs/src/components/DataGrid/DataGridBody/DataGridRow/DataGridRow.d.ts +1 -0
- package/dist/cjs/src/components/DataGrid/DataGridFilters/DataGridFilter.d.ts +3 -3
- package/dist/cjs/src/components/DataGrid/DataGridFilters/DataGridFilterPopover.d.ts +3 -2
- package/dist/cjs/src/components/DataGrid/DataGridFilters/DataGridFilterTag.d.ts +2 -1
- package/dist/cjs/src/components/DataGrid/DataGridFilters/DataGridSearchbar.d.ts +10 -0
- package/dist/cjs/src/components/DataGrid/DataGridFilters/DataGridToolbar.d.ts +4 -4
- package/dist/cjs/src/components/DataGrid/DataGridFilters/DataGridToolbarWrapper.d.ts +10 -0
- package/dist/cjs/src/components/DataGrid/DataGridFilters/useFiltersReducer.d.ts +8 -0
- package/dist/cjs/src/components/DataGrid/DataGridFilters/useFiltersReducer.test.d.ts +1 -0
- package/dist/cjs/src/components/DataGrid/testUtils.d.ts +1 -0
- package/dist/cjs/src/components/Icon/Icon.d.ts +2 -1
- package/dist/cjs/src/hooks/useRepeatFocus.cjs.js +2 -0
- package/dist/cjs/src/hooks/useRepeatFocus.cjs.js.map +1 -0
- package/dist/cjs/src/index.cjs.js +1 -1
- package/dist/cjs/src/index.d.ts +1 -0
- package/dist/esm/DataGrid/DataGrid.esm.js +8 -4
- package/dist/esm/DataGrid/DataGrid.esm.js.map +1 -1
- package/dist/esm/DataGrid/DataGridBody/DataGridBody.esm.js +2 -1
- package/dist/esm/DataGrid/DataGridBody/DataGridBody.esm.js.map +1 -1
- package/dist/esm/DataGrid/DataGridBody/DataGridCell/DataGridCell.esm.js +22 -3
- package/dist/esm/DataGrid/DataGridBody/DataGridCell/DataGridCell.esm.js.map +1 -1
- package/dist/esm/DataGrid/DataGridBody/DataGridRow/DataGridRow.esm.js +2 -1
- package/dist/esm/DataGrid/DataGridBody/DataGridRow/DataGridRow.esm.js.map +1 -1
- package/dist/esm/DataGrid/DataGridFilters/DataGridFilter.esm.js +7 -14
- package/dist/esm/DataGrid/DataGridFilters/DataGridFilter.esm.js.map +1 -1
- package/dist/esm/DataGrid/DataGridFilters/DataGridFilter.module.scss.esm.js +2 -2
- package/dist/esm/DataGrid/DataGridFilters/DataGridFilterPopover.esm.js +11 -3
- package/dist/esm/DataGrid/DataGridFilters/DataGridFilterPopover.esm.js.map +1 -1
- package/dist/esm/DataGrid/DataGridFilters/DataGridFilterTag.esm.js +5 -7
- package/dist/esm/DataGrid/DataGridFilters/DataGridFilterTag.esm.js.map +1 -1
- package/dist/esm/DataGrid/DataGridFilters/DataGridSearchbar.esm.js +43 -0
- package/dist/esm/DataGrid/DataGridFilters/DataGridSearchbar.esm.js.map +1 -0
- package/dist/esm/DataGrid/DataGridFilters/DataGridToolbar.esm.js +18 -34
- package/dist/esm/DataGrid/DataGridFilters/DataGridToolbar.esm.js.map +1 -1
- package/dist/esm/DataGrid/DataGridFilters/DataGridToolbar.module.scss.esm.js +2 -2
- package/dist/esm/DataGrid/DataGridFilters/DataGridToolbarWrapper.esm.js +27 -0
- package/dist/esm/DataGrid/DataGridFilters/DataGridToolbarWrapper.esm.js.map +1 -0
- package/dist/esm/DataGrid/DataGridFilters/useFiltersReducer.esm.js +59 -0
- package/dist/esm/DataGrid/DataGridFilters/useFiltersReducer.esm.js.map +1 -0
- package/dist/esm/DataGrid/DataGridHeader/DataGridHeaderCell.esm.js +3 -5
- package/dist/esm/DataGrid/DataGridHeader/DataGridHeaderCell.esm.js.map +1 -1
- package/dist/esm/DataGrid/DataGridHeader/DataGridHeaderCell.module.scss.esm.js +2 -2
- package/dist/esm/Form/FileUpload/FileUpload.module.scss.esm.js +1 -1
- package/dist/esm/Form/Select/MultiSelect/MultiSelect.esm.js +1 -1
- package/dist/esm/Form/Select/MultiSelect/MultiSelect.esm.js.map +1 -1
- package/dist/esm/Form/Select/SingleSelect/Select.esm.js +1 -1
- package/dist/esm/Form/Select/SingleSelect/Select.esm.js.map +1 -1
- package/dist/esm/Icon/Icon.esm.js +1 -0
- package/dist/esm/Icon/Icon.esm.js.map +1 -1
- package/dist/esm/Icon/Icon.module.scss.esm.js +2 -2
- package/dist/esm/Notifications/BaseModal/BaseModal.esm.js +1 -1
- package/dist/esm/Notifications/BaseModal/BaseModal.esm.js.map +1 -1
- package/dist/esm/src/components/DataGrid/DataGrid.d.ts +8 -5
- package/dist/esm/src/components/DataGrid/DataGridBody/DataGridBody.d.ts +1 -0
- package/dist/esm/src/components/DataGrid/DataGridBody/DataGridCell/DataGridCell.d.ts +1 -0
- package/dist/esm/src/components/DataGrid/DataGridBody/DataGridRow/DataGridRow.d.ts +1 -0
- package/dist/esm/src/components/DataGrid/DataGridFilters/DataGridFilter.d.ts +3 -3
- package/dist/esm/src/components/DataGrid/DataGridFilters/DataGridFilterPopover.d.ts +3 -2
- package/dist/esm/src/components/DataGrid/DataGridFilters/DataGridFilterTag.d.ts +2 -1
- package/dist/esm/src/components/DataGrid/DataGridFilters/DataGridSearchbar.d.ts +10 -0
- package/dist/esm/src/components/DataGrid/DataGridFilters/DataGridToolbar.d.ts +4 -4
- package/dist/esm/src/components/DataGrid/DataGridFilters/DataGridToolbarWrapper.d.ts +10 -0
- package/dist/esm/src/components/DataGrid/DataGridFilters/useFiltersReducer.d.ts +8 -0
- package/dist/esm/src/components/DataGrid/DataGridFilters/useFiltersReducer.test.d.ts +1 -0
- package/dist/esm/src/components/DataGrid/testUtils.d.ts +1 -0
- package/dist/esm/src/components/Icon/Icon.d.ts +2 -1
- package/dist/esm/{Notifications/BaseModal → src/hooks}/useRepeatFocus.esm.js +12 -1
- package/dist/esm/src/hooks/useRepeatFocus.esm.js.map +1 -0
- package/dist/esm/src/index.d.ts +1 -0
- package/dist/esm/src/index.esm.js +1 -0
- package/dist/esm/src/index.esm.js.map +1 -1
- package/package.json +1 -1
- package/src/components/DataGrid/DataGrid.tsx +32 -8
- package/src/components/DataGrid/DataGridBody/DataGridBody.tsx +3 -0
- package/src/components/DataGrid/DataGridBody/DataGridCell/DataGridCell.tsx +34 -2
- package/src/components/DataGrid/DataGridBody/DataGridRow/DataGridRow.tsx +3 -0
- package/src/components/DataGrid/DataGridFilters/DataGridFilter.module.scss +21 -11
- package/src/components/DataGrid/DataGridFilters/DataGridFilter.tsx +15 -19
- package/src/components/DataGrid/DataGridFilters/DataGridFilterPopover.tsx +15 -2
- package/src/components/DataGrid/DataGridFilters/DataGridFilterTag.tsx +18 -7
- package/src/components/DataGrid/DataGridFilters/DataGridSearchbar.tsx +68 -0
- package/src/components/DataGrid/DataGridFilters/DataGridToolbar.module.scss +40 -18
- package/src/components/DataGrid/DataGridFilters/DataGridToolbar.tsx +34 -62
- package/src/components/DataGrid/DataGridFilters/DataGridToolbarWrapper.tsx +38 -0
- package/src/components/DataGrid/DataGridFilters/useFiltersReducer.tsx +66 -0
- package/src/components/DataGrid/DataGridHeader/DataGridHeaderCell.module.scss +8 -1
- package/src/components/DataGrid/DataGridHeader/DataGridHeaderCell.tsx +3 -8
- package/src/components/DataGrid/testUtils.ts +14 -16
- package/src/components/Form/FileUpload/FileUpload.module.scss +1 -2
- package/src/components/Form/Select/MultiSelect/MultiSelect.tsx +1 -3
- package/src/components/Form/Select/SingleSelect/Select.tsx +1 -3
- package/src/components/Icon/Icon.module.scss +5 -0
- package/src/components/Icon/Icon.tsx +2 -1
- package/src/components/Notifications/BaseModal/BaseModal.tsx +1 -1
- package/src/font/icomoon.eot +0 -0
- package/src/font/icomoon.svg +1 -0
- package/src/font/icomoon.ttf +0 -0
- package/src/font/icomoon.woff +0 -0
- package/src/font/selection.json +1 -1
- package/src/{components/Notifications/BaseModal → hooks}/useRepeatFocus.tsx +12 -2
- package/src/index.ts +1 -0
- package/dist/cjs/Notifications/BaseModal/useRepeatFocus.cjs.js +0 -2
- package/dist/cjs/Notifications/BaseModal/useRepeatFocus.cjs.js.map +0 -1
- package/dist/esm/Notifications/BaseModal/useRepeatFocus.esm.js.map +0 -1
- /package/dist/cjs/src/{components/Notifications/BaseModal → hooks}/useRepeatFocus.d.ts +0 -0
- /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 '
|
|
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 \"
|
|
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,G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,KAAA,CAAA,GAAA,EAAA,GAAA,EAAE,EAAE,EAEtE,EAAA,cAAc,EAAE,CACb,KAEN,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,9 +1,10 @@
|
|
|
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";
|
|
6
6
|
import { DataGridToolbarProps } from "./DataGridFilters/DataGridToolbar";
|
|
7
|
+
import { DataGridSearchbarProps } from "./DataGridFilters/DataGridSearchbar";
|
|
7
8
|
export interface Props<T> extends Omit<ComponentPropsWithRef<"div">, "children"> {
|
|
8
9
|
children: ({ item, index }: {
|
|
9
10
|
item: T;
|
|
@@ -13,6 +14,9 @@ export interface Props<T> extends Omit<ComponentPropsWithRef<"div">, "children">
|
|
|
13
14
|
initialSort?: Sort;
|
|
14
15
|
onSort?: OnSortFunction;
|
|
15
16
|
headers: HeaderCell[];
|
|
17
|
+
/**
|
|
18
|
+
* @deprecated use the `toolbarButtons` prop instead
|
|
19
|
+
*/
|
|
16
20
|
actions?: {
|
|
17
21
|
enableAddBtn?: boolean;
|
|
18
22
|
enableColumnsBtn?: boolean;
|
|
@@ -26,10 +30,9 @@ export interface Props<T> extends Omit<ComponentPropsWithRef<"div">, "children">
|
|
|
26
30
|
paginationProps?: PaginationProps;
|
|
27
31
|
disableContextMenuColumn?: boolean;
|
|
28
32
|
enableExpandableRow?: boolean;
|
|
29
|
-
filters?:
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
};
|
|
33
|
+
filters?: DataGridToolbarProps;
|
|
34
|
+
search?: DataGridSearchbarProps;
|
|
35
|
+
toolbarButtons?: ReactElement<ButtonProps, typeof Button> | ReactElement<ButtonProps, typeof Button>[];
|
|
33
36
|
isLoading?: boolean;
|
|
34
37
|
enableMultiSorting?: boolean;
|
|
35
38
|
spacing?: Spacing;
|
|
@@ -3,6 +3,7 @@ export interface Props extends ComponentPropsWithRef<"td"> {
|
|
|
3
3
|
children?: ReactElement | string | number;
|
|
4
4
|
isLoading?: boolean;
|
|
5
5
|
spacing?: React.CSSProperties;
|
|
6
|
+
searchValue?: string;
|
|
6
7
|
cellIndex?: number;
|
|
7
8
|
columnLength?: number;
|
|
8
9
|
disableContextMenuColumn?: boolean;
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import { DataGridColumnMetadata, Filter, FilterEditorMode,
|
|
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,
|
|
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
|
-
|
|
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
|
-
|
|
4
|
+
customEditTagContent?: React.ReactElement;
|
|
5
|
+
triggerRef: React.Ref<HTMLButtonElement>;
|
|
5
6
|
filter?: Filter;
|
|
6
7
|
mode: FilterEditorMode;
|
|
7
8
|
onFilterRemove: () => void;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { InputWrapperProps } from "../../..";
|
|
3
|
+
export interface DataGridSearchbarProps {
|
|
4
|
+
onSearch: (value: string) => void;
|
|
5
|
+
initialSearchValue?: string;
|
|
6
|
+
debounceTime?: number;
|
|
7
|
+
placeholder?: string;
|
|
8
|
+
inputWrapperProps?: InputWrapperProps;
|
|
9
|
+
}
|
|
10
|
+
export declare const DataGridSearchbar: ({ onSearch, initialSearchValue, debounceTime, inputWrapperProps, placeholder }: DataGridSearchbarProps) => React.JSX.Element;
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import React
|
|
1
|
+
import React from "react";
|
|
2
2
|
import { DataGridColumnMetadata, Filter, FiltersTranslations } from "./DataGridFilters.interfaces";
|
|
3
|
-
export interface DataGridToolbarProps
|
|
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,5 +10,4 @@ export interface DataGridToolbarProps extends ComponentPropsWithRef<"div"> {
|
|
|
9
10
|
onFilterDelete?: (id: string) => void;
|
|
10
11
|
onFiltersClear?: () => void;
|
|
11
12
|
}
|
|
12
|
-
export declare const
|
|
13
|
-
export declare const DataGridToolbar: React.ForwardRefExoticComponent<Omit<DataGridToolbarProps, "ref"> & React.RefAttributes<HTMLDivElement>>;
|
|
13
|
+
export declare const DataGridToolbar: ({ columnsMetadata, filterValues, translations, onFilterAdd, onFilterEdit, onFilterDelete, onFiltersClear, customEditTagContent }: DataGridToolbarProps) => React.JSX.Element;
|
|
@@ -0,0 +1,10 @@
|
|
|
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
|
+
}
|
|
8
|
+
export declare const DataGridToolbarWrapperComponent: ForwardRefRenderFunction<HTMLDivElement, Props>;
|
|
9
|
+
export declare const DataGridToolbarWrapper: React.ForwardRefExoticComponent<Omit<Props, "ref"> & React.RefAttributes<HTMLDivElement>>;
|
|
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
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -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
|
|
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,UAA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C/B;aACF;AAAM,iBAAA,IAAI,QAAQ,CAAC,aAAa,KAAK,oBAAoB,EAAE;gBAC1D,KAAK,CAAC,cAAc,EAAE,CAAC;AACvB,gBAAA,qBAAqB,aAArB,qBAAqB,KAAA,KAAA,CAAA,GAAA,KAAA,CAAA,GAArB,qBAAqB,CAAE,KAAK,EAAE,CAAC;aAChC;AACH,SAAC,CAAC;AAEF,QAAA,oBAAoB,CAAC,gBAAgB,CAAC,SAAS,EAAE,iBAAiB,CAAC,CAAC;AACpE,QAAA,qBAAqB,CAAC,gBAAgB,CAAC,SAAS,EAAE,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;;;;"}
|
package/dist/esm/src/index.d.ts
CHANGED
|
@@ -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
|
@@ -14,8 +14,15 @@
|
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
16
|
|
|
17
|
-
import React, {
|
|
18
|
-
|
|
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";
|
|
@@ -24,6 +31,8 @@ import { HeaderCell, OnSortFunction, Sort } from "./datagrid.interfaces";
|
|
|
24
31
|
import { Pagination, Props as PaginationProps } from "../Pagination/Pagination";
|
|
25
32
|
import { Spacing, useSpacing } from "../../hooks/useSpacing";
|
|
26
33
|
import { DataGridToolbar, DataGridToolbarProps } from "./DataGridFilters/DataGridToolbar";
|
|
34
|
+
import { DataGridToolbarWrapper } from "./DataGridFilters/DataGridToolbarWrapper";
|
|
35
|
+
import { DataGridSearchbar, DataGridSearchbarProps } from "./DataGridFilters/DataGridSearchbar";
|
|
27
36
|
|
|
28
37
|
export interface Props<T> extends Omit<ComponentPropsWithRef<"div">, "children"> {
|
|
29
38
|
children: ({ item, index }: { item: T; index: number }) => ReactElement;
|
|
@@ -31,6 +40,9 @@ export interface Props<T> extends Omit<ComponentPropsWithRef<"div">, "children">
|
|
|
31
40
|
initialSort?: Sort;
|
|
32
41
|
onSort?: OnSortFunction;
|
|
33
42
|
headers: HeaderCell[];
|
|
43
|
+
/**
|
|
44
|
+
* @deprecated use the `toolbarButtons` prop instead
|
|
45
|
+
*/
|
|
34
46
|
actions?: {
|
|
35
47
|
enableAddBtn?: boolean;
|
|
36
48
|
enableColumnsBtn?: boolean;
|
|
@@ -44,10 +56,11 @@ export interface Props<T> extends Omit<ComponentPropsWithRef<"div">, "children">
|
|
|
44
56
|
paginationProps?: PaginationProps;
|
|
45
57
|
disableContextMenuColumn?: boolean;
|
|
46
58
|
enableExpandableRow?: boolean;
|
|
47
|
-
filters?:
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
59
|
+
filters?: DataGridToolbarProps;
|
|
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;
|
|
@@ -65,6 +78,8 @@ const DataGridInner = <T extends {}>(
|
|
|
65
78
|
disableContextMenuColumn,
|
|
66
79
|
enableExpandableRow,
|
|
67
80
|
filters,
|
|
81
|
+
search,
|
|
82
|
+
toolbarButtons,
|
|
68
83
|
isLoading,
|
|
69
84
|
enableMultiSorting,
|
|
70
85
|
emptyLabel,
|
|
@@ -132,8 +147,16 @@ const DataGridInner = <T extends {}>(
|
|
|
132
147
|
paddingBottom: styleWithSpacing?.paddingBottom
|
|
133
148
|
}}
|
|
134
149
|
>
|
|
135
|
-
{filters
|
|
136
|
-
<
|
|
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
|
+
/>
|
|
137
160
|
) : (
|
|
138
161
|
<DataGridActions
|
|
139
162
|
{...actions}
|
|
@@ -164,6 +187,7 @@ const DataGridInner = <T extends {}>(
|
|
|
164
187
|
disableContextMenuColumn={disableContextMenuColumn}
|
|
165
188
|
emptyLabel={emptyLabel}
|
|
166
189
|
spacing={styleWithSpacing}
|
|
190
|
+
searchValue={search?.initialSearchValue}
|
|
167
191
|
>
|
|
168
192
|
{children}
|
|
169
193
|
</DataGridBody>
|
|
@@ -27,6 +27,7 @@ export interface Props<T> extends Omit<ComponentPropsWithRef<"tbody">, "children
|
|
|
27
27
|
headers: HeaderCell[];
|
|
28
28
|
isLoading?: boolean;
|
|
29
29
|
disableContextMenuColumn?: boolean;
|
|
30
|
+
searchValue?: string;
|
|
30
31
|
emptyLabel?: string;
|
|
31
32
|
spacing?: React.CSSProperties;
|
|
32
33
|
}
|
|
@@ -42,6 +43,7 @@ const DataGridBodyInner = <T extends {}>(
|
|
|
42
43
|
disableContextMenuColumn,
|
|
43
44
|
emptyLabel,
|
|
44
45
|
spacing,
|
|
46
|
+
searchValue,
|
|
45
47
|
...rest
|
|
46
48
|
}: Props<T>,
|
|
47
49
|
ref: Ref<HTMLTableSectionElement>
|
|
@@ -77,6 +79,7 @@ const DataGridBodyInner = <T extends {}>(
|
|
|
77
79
|
|
|
78
80
|
return data?.map((item, index) => {
|
|
79
81
|
return React.cloneElement(children({ item, index }), {
|
|
82
|
+
searchValue: searchValue,
|
|
80
83
|
headers,
|
|
81
84
|
spacing,
|
|
82
85
|
disableContextMenuColumn
|
|
@@ -14,7 +14,12 @@
|
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
16
|
|
|
17
|
-
import React, {
|
|
17
|
+
import React, {
|
|
18
|
+
ForwardRefRenderFunction,
|
|
19
|
+
ComponentPropsWithRef,
|
|
20
|
+
ReactElement,
|
|
21
|
+
Fragment
|
|
22
|
+
} from "react";
|
|
18
23
|
import { Typography } from "../../../Typography/Typography";
|
|
19
24
|
import classes from "./DataGridCell.module.scss";
|
|
20
25
|
|
|
@@ -22,6 +27,7 @@ export interface Props extends ComponentPropsWithRef<"td"> {
|
|
|
22
27
|
children?: ReactElement | string | number;
|
|
23
28
|
isLoading?: boolean;
|
|
24
29
|
spacing?: React.CSSProperties;
|
|
30
|
+
searchValue?: string;
|
|
25
31
|
cellIndex?: number;
|
|
26
32
|
columnLength?: number;
|
|
27
33
|
disableContextMenuColumn?: boolean;
|
|
@@ -33,6 +39,7 @@ const DataGridCellComponent: ForwardRefRenderFunction<HTMLTableCellElement, Prop
|
|
|
33
39
|
className,
|
|
34
40
|
isLoading,
|
|
35
41
|
spacing,
|
|
42
|
+
searchValue,
|
|
36
43
|
cellIndex,
|
|
37
44
|
columnLength,
|
|
38
45
|
disableContextMenuColumn,
|
|
@@ -52,6 +59,31 @@ const DataGridCellComponent: ForwardRefRenderFunction<HTMLTableCellElement, Prop
|
|
|
52
59
|
cellStyle.paddingRight = spacing?.paddingRight;
|
|
53
60
|
}
|
|
54
61
|
|
|
62
|
+
//NOTE: we might want to migrate to Highlight API once it's supported by Firefox
|
|
63
|
+
const renderContent = () => {
|
|
64
|
+
if (typeof children === "string" && searchValue) {
|
|
65
|
+
if (!children.toLowerCase().includes(searchValue.toLowerCase())) {
|
|
66
|
+
return children;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
const matchingSequence = new RegExp(searchValue, "i").exec(children);
|
|
70
|
+
|
|
71
|
+
const parts = children.split(matchingSequence?.[0] ?? "");
|
|
72
|
+
return parts.map((part, i) => {
|
|
73
|
+
if (i === parts.length - 1) return <Fragment key={`${part}-${i}`}>{part}</Fragment>;
|
|
74
|
+
|
|
75
|
+
return (
|
|
76
|
+
<Fragment key={`${part}-${i}`}>
|
|
77
|
+
{part}
|
|
78
|
+
<mark data-testid={`${matchingSequence}-mark`}>{matchingSequence}</mark>
|
|
79
|
+
</Fragment>
|
|
80
|
+
);
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
return children;
|
|
85
|
+
};
|
|
86
|
+
|
|
55
87
|
return (
|
|
56
88
|
<td
|
|
57
89
|
{...rest}
|
|
@@ -62,7 +94,7 @@ const DataGridCellComponent: ForwardRefRenderFunction<HTMLTableCellElement, Prop
|
|
|
62
94
|
{isLoading && <div className={classes["loading"]} aria-busy="true" aria-live="polite"></div>}
|
|
63
95
|
{!isLoading && (
|
|
64
96
|
<Typography className={classes["text"]} variant="body" tag="span">
|
|
65
|
-
{
|
|
97
|
+
{renderContent()}
|
|
66
98
|
</Typography>
|
|
67
99
|
)}
|
|
68
100
|
</td>
|
|
@@ -27,6 +27,7 @@ export interface Props extends ComponentPropsWithRef<"tr"> {
|
|
|
27
27
|
headers?: HeaderCell[];
|
|
28
28
|
isLoading?: boolean;
|
|
29
29
|
spacing?: React.CSSProperties;
|
|
30
|
+
searchValue?: string;
|
|
30
31
|
disableContextMenuColumn?: boolean;
|
|
31
32
|
expandableRowProps?: {
|
|
32
33
|
enableExpandableRow: boolean;
|
|
@@ -42,6 +43,7 @@ const DataGridRowComponent: ForwardRefRenderFunction<HTMLTableRowElement, Props>
|
|
|
42
43
|
children,
|
|
43
44
|
className,
|
|
44
45
|
headers,
|
|
46
|
+
searchValue,
|
|
45
47
|
isLoading,
|
|
46
48
|
spacing,
|
|
47
49
|
expandableRowProps,
|
|
@@ -61,6 +63,7 @@ const DataGridRowComponent: ForwardRefRenderFunction<HTMLTableRowElement, Props>
|
|
|
61
63
|
const visibleCells = React.Children.map(children as React.ReactElement[], (child, index) => {
|
|
62
64
|
if (child) {
|
|
63
65
|
const cellWithSpacing = React.cloneElement(child, {
|
|
66
|
+
searchValue,
|
|
64
67
|
spacing: spacing,
|
|
65
68
|
cellIndex: index,
|
|
66
69
|
columnLength: headers?.length,
|
|
@@ -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
|
-
& > *:
|
|
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 {
|