@elliemae/ds-data-table 3.0.0-next.53 → 3.0.0-next.56
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/DataTable.js +2 -8
- package/dist/cjs/DataTable.js.map +2 -2
- package/dist/cjs/addons/Filters/Components/CurrencyRangeFilter/index.js +2 -2
- package/dist/cjs/addons/Filters/Components/CurrencyRangeFilter/index.js.map +2 -2
- package/dist/cjs/addons/Filters/Components/NumberRangeFilter/index.js +2 -2
- package/dist/cjs/addons/Filters/Components/NumberRangeFilter/index.js.map +2 -2
- package/dist/cjs/addons/Filters/Components/SelectFilter/BaseSelectFilter.js +2 -2
- package/dist/cjs/addons/Filters/Components/SelectFilter/BaseSelectFilter.js.map +2 -2
- package/dist/cjs/configs/useDatatableConfig.js +20 -3
- package/dist/cjs/configs/useDatatableConfig.js.map +2 -2
- package/dist/cjs/{redux/reducers/headersReducers/logic.js → configs/useInternalStateConfig.js} +38 -12
- package/dist/cjs/configs/useInternalStateConfig.js.map +7 -0
- package/dist/cjs/exported-related/FilterPopover.js +2 -2
- package/dist/cjs/exported-related/FilterPopover.js.map +2 -2
- package/dist/cjs/exported-related/RowRenderer/DefaultRowContentRenderer.js +3 -3
- package/dist/cjs/exported-related/RowRenderer/DefaultRowContentRenderer.js.map +2 -2
- package/dist/cjs/exported-related/RowRenderer/index.js +3 -3
- package/dist/cjs/exported-related/RowRenderer/index.js.map +1 -1
- package/dist/cjs/exported-related/RowRenderer/useRowRendererHandlers.js +10 -10
- package/dist/cjs/exported-related/RowRenderer/useRowRendererHandlers.js.map +2 -2
- package/dist/cjs/parts/Filters/index.js +2 -2
- package/dist/cjs/parts/Filters/index.js.map +2 -2
- package/dist/cjs/parts/Headers/HeaderCell.js +6 -13
- package/dist/cjs/parts/Headers/HeaderCell.js.map +2 -2
- package/dist/cjs/parts/Row.js +6 -10
- package/dist/cjs/parts/Row.js.map +2 -2
- package/dist/cjs/parts/RowVariants/RowVariantHeader.js +4 -4
- package/dist/cjs/parts/RowVariants/RowVariantHeader.js.map +2 -2
- package/dist/cjs/parts/RowVariants/RowVariantPrimary.js +2 -2
- package/dist/cjs/parts/RowVariants/RowVariantPrimary.js.map +1 -1
- package/dist/cjs/parts/RowVariants/RowVariantSecondary.js +2 -2
- package/dist/cjs/parts/RowVariants/RowVariantSecondary.js.map +1 -1
- package/dist/cjs/parts/RowVariants/RowVariantSkeleton.js +2 -2
- package/dist/cjs/parts/RowVariants/RowVariantSkeleton.js.map +2 -2
- package/dist/cjs/parts/RowVariants/index.js.map +1 -1
- package/dist/cjs/parts/RowVariants/types.js.map +1 -1
- package/dist/cjs/parts/TableContent.js +1 -6
- package/dist/cjs/parts/TableContent.js.map +2 -2
- package/dist/cjs/parts/VirtualRowsList.js +3 -11
- package/dist/cjs/parts/VirtualRowsList.js.map +2 -2
- package/dist/cjs/types/props.js.map +1 -1
- package/dist/esm/DataTable.js +3 -9
- package/dist/esm/DataTable.js.map +2 -2
- package/dist/esm/addons/Filters/Components/CurrencyRangeFilter/index.js +3 -3
- package/dist/esm/addons/Filters/Components/CurrencyRangeFilter/index.js.map +2 -2
- package/dist/esm/addons/Filters/Components/NumberRangeFilter/index.js +3 -3
- package/dist/esm/addons/Filters/Components/NumberRangeFilter/index.js.map +2 -2
- package/dist/esm/addons/Filters/Components/SelectFilter/BaseSelectFilter.js +3 -3
- package/dist/esm/addons/Filters/Components/SelectFilter/BaseSelectFilter.js.map +2 -2
- package/dist/esm/configs/useDatatableConfig.js +22 -3
- package/dist/esm/configs/useDatatableConfig.js.map +2 -2
- package/dist/esm/configs/useInternalStateConfig.js +55 -0
- package/dist/esm/configs/useInternalStateConfig.js.map +7 -0
- package/dist/esm/exported-related/FilterPopover.js +3 -3
- package/dist/esm/exported-related/FilterPopover.js.map +2 -2
- package/dist/esm/exported-related/RowRenderer/DefaultRowContentRenderer.js +3 -3
- package/dist/esm/exported-related/RowRenderer/DefaultRowContentRenderer.js.map +2 -2
- package/dist/esm/exported-related/RowRenderer/index.js +3 -3
- package/dist/esm/exported-related/RowRenderer/index.js.map +1 -1
- package/dist/esm/exported-related/RowRenderer/useRowRendererHandlers.js +10 -10
- package/dist/esm/exported-related/RowRenderer/useRowRendererHandlers.js.map +2 -2
- package/dist/esm/parts/Filters/index.js +3 -3
- package/dist/esm/parts/Filters/index.js.map +2 -2
- package/dist/esm/parts/Headers/HeaderCell.js +6 -13
- package/dist/esm/parts/Headers/HeaderCell.js.map +2 -2
- package/dist/esm/parts/Row.js +6 -10
- package/dist/esm/parts/Row.js.map +2 -2
- package/dist/esm/parts/RowVariants/RowVariantHeader.js +4 -4
- package/dist/esm/parts/RowVariants/RowVariantHeader.js.map +2 -2
- package/dist/esm/parts/RowVariants/RowVariantPrimary.js +2 -2
- package/dist/esm/parts/RowVariants/RowVariantPrimary.js.map +1 -1
- package/dist/esm/parts/RowVariants/RowVariantSecondary.js +2 -2
- package/dist/esm/parts/RowVariants/RowVariantSecondary.js.map +1 -1
- package/dist/esm/parts/RowVariants/RowVariantSkeleton.js +2 -2
- package/dist/esm/parts/RowVariants/RowVariantSkeleton.js.map +2 -2
- package/dist/esm/parts/RowVariants/index.js.map +1 -1
- package/dist/esm/parts/TableContent.js +1 -6
- package/dist/esm/parts/TableContent.js.map +2 -2
- package/dist/esm/parts/VirtualRowsList.js +3 -11
- package/dist/esm/parts/VirtualRowsList.js.map +2 -2
- package/package.json +1 -1
- package/dist/cjs/redux/reducers/headersReducers/defaults.js +0 -28
- package/dist/cjs/redux/reducers/headersReducers/defaults.js.map +0 -7
- package/dist/cjs/redux/reducers/headersReducers/headersReducers.js +0 -50
- package/dist/cjs/redux/reducers/headersReducers/headersReducers.js.map +0 -7
- package/dist/cjs/redux/reducers/headersReducers/index.js +0 -23
- package/dist/cjs/redux/reducers/headersReducers/index.js.map +0 -7
- package/dist/cjs/redux/reducers/headersReducers/logic.js.map +0 -7
- package/dist/cjs/redux/reducers/headersReducers/useDispatchHeadersActions.js +0 -39
- package/dist/cjs/redux/reducers/headersReducers/useDispatchHeadersActions.js.map +0 -7
- package/dist/cjs/redux/reducers/index.js +0 -40
- package/dist/cjs/redux/reducers/index.js.map +0 -7
- package/dist/cjs/redux/reducers/rowsReducers/actions_types.js +0 -40
- package/dist/cjs/redux/reducers/rowsReducers/actions_types.js.map +0 -7
- package/dist/cjs/redux/reducers/rowsReducers/defaults.js +0 -48
- package/dist/cjs/redux/reducers/rowsReducers/defaults.js.map +0 -7
- package/dist/cjs/redux/reducers/rowsReducers/index.js +0 -23
- package/dist/cjs/redux/reducers/rowsReducers/index.js.map +0 -7
- package/dist/cjs/redux/reducers/rowsReducers/logic.js +0 -58
- package/dist/cjs/redux/reducers/rowsReducers/logic.js.map +0 -7
- package/dist/cjs/redux/reducers/rowsReducers/rowsReducer.js +0 -80
- package/dist/cjs/redux/reducers/rowsReducers/rowsReducer.js.map +0 -7
- package/dist/cjs/redux/reducers/rowsReducers/useDispatchRowsActions.js +0 -54
- package/dist/cjs/redux/reducers/rowsReducers/useDispatchRowsActions.js.map +0 -7
- package/dist/cjs/redux/storeConfig.js +0 -31
- package/dist/cjs/redux/storeConfig.js.map +0 -7
- package/dist/esm/redux/reducers/headersReducers/defaults.js +0 -6
- package/dist/esm/redux/reducers/headersReducers/defaults.js.map +0 -7
- package/dist/esm/redux/reducers/headersReducers/headersReducers.js +0 -28
- package/dist/esm/redux/reducers/headersReducers/headersReducers.js.map +0 -7
- package/dist/esm/redux/reducers/headersReducers/index.js +0 -4
- package/dist/esm/redux/reducers/headersReducers/index.js.map +0 -7
- package/dist/esm/redux/reducers/headersReducers/logic.js +0 -29
- package/dist/esm/redux/reducers/headersReducers/logic.js.map +0 -7
- package/dist/esm/redux/reducers/headersReducers/useDispatchHeadersActions.js +0 -17
- package/dist/esm/redux/reducers/headersReducers/useDispatchHeadersActions.js.map +0 -7
- package/dist/esm/redux/reducers/index.js +0 -18
- package/dist/esm/redux/reducers/index.js.map +0 -7
- package/dist/esm/redux/reducers/rowsReducers/actions_types.js +0 -18
- package/dist/esm/redux/reducers/rowsReducers/actions_types.js.map +0 -7
- package/dist/esm/redux/reducers/rowsReducers/defaults.js +0 -26
- package/dist/esm/redux/reducers/rowsReducers/defaults.js.map +0 -7
- package/dist/esm/redux/reducers/rowsReducers/index.js +0 -4
- package/dist/esm/redux/reducers/rowsReducers/index.js.map +0 -7
- package/dist/esm/redux/reducers/rowsReducers/logic.js +0 -36
- package/dist/esm/redux/reducers/rowsReducers/logic.js.map +0 -7
- package/dist/esm/redux/reducers/rowsReducers/rowsReducer.js +0 -67
- package/dist/esm/redux/reducers/rowsReducers/rowsReducer.js.map +0 -7
- package/dist/esm/redux/reducers/rowsReducers/useDispatchRowsActions.js +0 -41
- package/dist/esm/redux/reducers/rowsReducers/useDispatchRowsActions.js.map +0 -7
- package/dist/esm/redux/storeConfig.js +0 -9
- package/dist/esm/redux/storeConfig.js.map +0 -7
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/parts/VirtualRowsList.tsx", "../../../../../scripts/build/transpile/react-shim.js"],
|
|
4
|
-
"sourcesContent": ["import React, { useContext, useMemo, useCallback } from 'react';\nimport {
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADAvB,mBAAwD;AACxD,
|
|
4
|
+
"sourcesContent": ["import React, { useContext, useMemo, useCallback } from 'react';\nimport { RowLoading } from './RowLoading'; // imported this way to avoid circular dependencies\nimport { EmptyContent } from './EmptyContent'; // imported this way to avoid circular dependencies\nimport { RowsWithContext as Rows } from './Rows'; // imported this way to avoid circular dependencies\nimport { Headers } from './Headers'; // imported this way to avoid circular dependencies\nimport { Footer } from './Footer'; // imported this way to avoid circular dependencies\nimport { DataTableContext } from '../DataTableContext';\nimport { FIXED_SIZES } from '../configs/fixedSizes';\nimport { StyledVirtualListWrapper, StyledTableContentWrapper } from '../styled';\nimport { MemoizedLoader as Loader } from './Loader';\nimport { DATA_TESTID } from '../configs/constants';\n\nexport const VirtualRowsList = () => {\n const {\n virtualListRef,\n tableProps: { height, width, isLoading, isLoadingAppended },\n virtualListHelpers,\n layoutHelpers: { totalColumnsWidth },\n flattenedData,\n setFocusedRowId,\n } = useContext(DataTableContext);\n const { totalSize, scrollToIndex } = virtualListHelpers;\n\n const isEmptyContent = useMemo(() => !isLoading && flattenedData.length === 0, [isLoading, flattenedData.length]);\n\n const tableHeight = useMemo(() => {\n if (typeof height === 'string')\n return height.includes('%') ? height : Number.parseInt(height, 10) - FIXED_SIZES.PAGINATION_HEIGHT;\n return height;\n }, [height]);\n\n const onKeyDown = useCallback(\n (e: React.KeyboardEvent) => {\n if (e.ctrlKey && e.code === 'End') {\n scrollToIndex(flattenedData.length - 1);\n setFocusedRowId(flattenedData[flattenedData.length - 1].uid);\n } else if (e.ctrlKey && e.code === 'Home') {\n scrollToIndex(0, { align: 'center' });\n setFocusedRowId(flattenedData[0].uid);\n }\n },\n [scrollToIndex, setFocusedRowId, flattenedData],\n );\n\n return (\n <StyledVirtualListWrapper\n ref={virtualListRef}\n height={tableHeight}\n width={width}\n data-testid={DATA_TESTID.DATA_TABLE_SCROLLABLE_CONTAINER}\n onKeyDown={onKeyDown}\n tabIndex={-1}\n >\n <StyledTableContentWrapper role=\"rowgroup\" height={totalSize || '100%'}>\n <Headers />\n {isEmptyContent && <EmptyContent width={totalColumnsWidth} />}\n {isLoading ? <Loader /> : null}\n {!isLoading && !isEmptyContent && (\n <>\n <Rows />\n <Footer />\n {isLoadingAppended && <RowLoading />}\n </>\n )}\n </StyledTableContentWrapper>\n </StyledVirtualListWrapper>\n );\n};\n\nexport default VirtualRowsList;\n", "import * as React from 'react';\nexport { React };\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADAvB,mBAAwD;AACxD,wBAA2B;A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1D,YAAY,mDAAC,kCAAO,IAAK,MACzB,CAAC,aAAa,CAAC,kBACd,wFACE,mDAAC,iCAAK,GACN,mDAAC,0BAAO,GACP,qBAAqB,mDAAC,kCAAW,CACpC,CAEJ,CACF;AAEJ;AAEA,IAAO,0BAAQ;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/types/props.tsx", "../../../../../scripts/build/transpile/react-shim.js"],
|
|
4
|
-
"sourcesContent": ["/* eslint-disable max-lines */\nimport React, { MutableRefObject } from 'react';\nimport { useVirtual } from 'react-virtual/types';\nimport { ColsLayoutStyle } from '../configs/constants';\n\nexport type TypescriptGenericFunc = (...args: unknown[]) => unknown;\ninterface FilterOptionT {\n dsId: string;\n type: string;\n value: string;\n label: string;\n}\n\nexport type TypescriptColumn = {\n id?: string;\n Header: string | React.ComponentType<any>;\n accessor?: string;\n filter?: string;\n filterOptions?: FilterOptionT[] | (() => FilterOptionT[]);\n filterMinWidth?: number | string;\n Filter?: React.ComponentType<FilterProps>;\n Cell?: React.ComponentType<any>;\n editable?: string | TypescriptGenericFunc;\n disableDnD?: boolean;\n width?: number;\n minWidth?: number;\n maxWidth?: number;\n padding?: number;\n columns?: TypescriptColumn[];\n canSort?: boolean;\n isSortedDesc?: boolean;\n canResize?: boolean;\n isFocuseable?: boolean;\n textWrap?: 'wrap' | 'wrap-all' | 'truncate';\n ref?: React.MutableRefObject<HTMLTableColElement>;\n required?: boolean;\n alwaysDisplayEditIcon?: boolean;\n};\n\nexport type TypescriptRow = {\n [key: string]: any;\n subRows: TypescriptRow[];\n tableRowDetails: React.ComponentType<any>;\n dimsumHeaderValue: string;\n};\n\nexport type RowVariant = 'ds-header-group-row' | 'ds-primary-row' | 'ds-secondary-row';\n\nexport type TypescriptRenderRowActionsConfig = {\n columnWidth: number;\n renderer: (...args: any[]) => JSX.Element;\n};\n\nexport type TypescriptRenderRowActions = false | TypescriptRenderRowActionsConfig;\n\nexport type TypescriptAppliedFilter = {\n id: string;\n type: string;\n value: any;\n};\n\nexport type TypescriptPagination = {\n page?: any[];\n pageIndex?: number;\n canPreviousPage?: boolean;\n canNextPage?: boolean;\n pageSize?: number;\n showPerPageSelector?: boolean;\n perPageOptions?: number[];\n perPageStep?: number;\n minPerPage?: number;\n maxPerPage?: number;\n onPageSizeChange?: (pageSize: number) => void;\n onPreviousPage?: () => void;\n onNextPage?: () => void;\n onPageChange?: (page: number) => void;\n pageCount?: number;\n pageDetails?: string[];\n pageDetailsTitle?: string;\n};\n\nexport type TypescriptSortBy = {\n id: string;\n desc: boolean;\n};\n\nexport type TypescriptSelectionItem = true | 'mixed' | false;\n\nexport type TypescriptSelection = Record<string | number, TypescriptSelectionItem>;\n\nexport type UniqueRowAccessorType = string | string[] | ((row: TypescriptRow) => string);\n\nexport type TypescriptProps = {\n columns: TypescriptColumn[];\n data: TypescriptRow[];\n height?: string;\n width?: string;\n renderRowActions?: TypescriptRenderRowActions;\n getRowVariant?: (\n row: TypescriptRow,\n defaultCellsRenderer: React.ComponentType<any>,\n ) => RowVariant | React.ComponentType<any>;\n isExpandable?: boolean;\n uniqueRowAccessor?: UniqueRowAccessorType;\n disabledRows?: Record<string, boolean>;\n expandedRows?: Record<string, boolean>;\n cellRendererProps?: Record<string, any>;\n noSelectionColumn?: boolean;\n selectSingle?: boolean;\n selection?: TypescriptSelection;\n groupedRowsRenderHeader?: TypescriptGenericFunc | string;\n isResizeable?: boolean;\n withFilterBar?: boolean;\n filters?: { id: string; type: string; value: any }[];\n filterBarProps?: {\n customPillRenderer?: React.ComponentType<any>;\n extraOptions?: { type: string; id: string; label: string; onClick?: TypescriptGenericFunc }[];\n };\n actionRef: React.RefObject<any>;\n pagination?: false | TypescriptPagination;\n colsLayoutStyle: ColsLayoutStyle;\n hiddenColumns: string[];\n dragAndDropRows?: boolean;\n maxDragAndDropLevel?: number;\n textWrap?: 'wrap' | 'wrap-all' | 'truncate';\n customSortLogic?: boolean;\n noResultsMessage?: string;\n noResultsSecondaryMessage?: string;\n noResultsButtonLabel?: string;\n isLoading?: boolean;\n isLoadingAppended?: boolean;\n dragAndDropColumns?: boolean;\n onColumnsReorder?: (newData: any[], indexes: { targetIndex: number; fromIndex: number }) => void;\n onColumnResize?: (headerId: string, width: number) => void;\n isNoMoreDataAppended?: boolean;\n noMoreDataMessage?: string;\n noResultsPlaceholder?: TypescriptGenericFunc;\n onRowExpand?: (expandedRows: Record<string, boolean>, toggledRow: string) => void;\n onRowsReorder?: (\n newData: any[],\n indexes: { targetIndex: number; fromIndex: number },\n considerExpanding: string,\n ) => void;\n onRowClick?: TypescriptGenericFunc;\n onRowFocus?: TypescriptGenericFunc;\n onCellValueChange: (cellChange: { value: any; property: any; rowIndex: number }) => void;\n onSelectionChange?: (newSelection: TypescriptSelection) => void;\n onFiltersChange?: TypescriptGenericFunc;\n onFilteredDataChange?: TypescriptGenericFunc;\n onPageChanged?: TypescriptGenericFunc;\n onNoResultsButtonClick?: TypescriptGenericFunc;\n onColumnSortChange: (newSortRequest: { column: any; direction: any }) => void;\n};\n\nexport interface FilterProps {\n column: TypescriptColumn;\n ctx: TypescriptContext;\n onFiltersChange?: (filters: { id: string; type: string; value: any }[]) => void;\n onValueChange: (type: string, value: any) => void;\n patchHeaderFilterButtonAndMenu: (headerId: string, newState: any) => void;\n patchHeader: (headerId: string, newHeader: any) => void;\n filterValue?: any;\n reduxHeader?: any;\n innerRef: MutableRefObject<HTMLDivElement>;\n}\n\nexport type TypescriptContext = {\n tableProps: Partial<TypescriptProps>;\n virtualListRef: React.RefObject<HTMLDivElement>;\n columnHeaderRef: React.RefObject<HTMLDivElement>;\n flattenedData: TypescriptRow[];\n allDataFlattened: TypescriptRow[];\n visibleColumns: TypescriptColumn[];\n virtualListHelpers?: ReturnType<typeof useVirtual>;\n layoutHelpers: {\n totalColumnsWidth?: number | string;\n gridLayout?: string[];\n setGridLayout?: React.Dispatch<React.SetStateAction<string[]>>;\n };\n paginationHelpers: TypescriptPagination;\n};\n", "import * as React from 'react';\nexport { React };\n"],
|
|
4
|
+
"sourcesContent": ["/* eslint-disable max-lines */\nimport React, { MutableRefObject } from 'react';\nimport { useVirtual } from 'react-virtual/types';\nimport { ColsLayoutStyle } from '../configs/constants';\n\nexport type TypescriptGenericFunc = (...args: unknown[]) => unknown;\ninterface FilterOptionT {\n dsId: string;\n type: string;\n value: string;\n label: string;\n}\n\nexport type TypescriptColumn = {\n id?: string;\n Header: string | React.ComponentType<any>;\n accessor?: string;\n filter?: string;\n filterOptions?: FilterOptionT[] | (() => FilterOptionT[]);\n filterMinWidth?: number | string;\n Filter?: React.ComponentType<FilterProps>;\n Cell?: React.ComponentType<any>;\n editable?: string | TypescriptGenericFunc;\n disableDnD?: boolean;\n width?: number;\n minWidth?: number;\n maxWidth?: number;\n padding?: number;\n columns?: TypescriptColumn[];\n canSort?: boolean;\n isSortedDesc?: boolean;\n canResize?: boolean;\n isFocuseable?: boolean;\n textWrap?: 'wrap' | 'wrap-all' | 'truncate';\n ref?: React.MutableRefObject<HTMLTableColElement>;\n required?: boolean;\n alwaysDisplayEditIcon?: boolean;\n};\n\nexport type TypescriptRow = {\n [key: string]: any;\n subRows: TypescriptRow[];\n tableRowDetails: React.ComponentType<any>;\n dimsumHeaderValue: string;\n};\n\nexport type RowVariant = 'ds-header-group-row' | 'ds-primary-row' | 'ds-secondary-row';\n\nexport type TypescriptRenderRowActionsConfig = {\n columnWidth: number;\n renderer: (...args: any[]) => JSX.Element;\n};\n\nexport type TypescriptRenderRowActions = false | TypescriptRenderRowActionsConfig;\n\nexport type TypescriptAppliedFilter = {\n id: string;\n type: string;\n value: any;\n};\n\nexport type TypescriptPagination = {\n page?: any[];\n pageIndex?: number;\n canPreviousPage?: boolean;\n canNextPage?: boolean;\n pageSize?: number;\n showPerPageSelector?: boolean;\n perPageOptions?: number[];\n perPageStep?: number;\n minPerPage?: number;\n maxPerPage?: number;\n onPageSizeChange?: (pageSize: number) => void;\n onPreviousPage?: () => void;\n onNextPage?: () => void;\n onPageChange?: (page: number) => void;\n pageCount?: number;\n pageDetails?: string[];\n pageDetailsTitle?: string;\n};\n\nexport type TypescriptSortBy = {\n id: string;\n desc: boolean;\n};\n\nexport type TypescriptSelectionItem = true | 'mixed' | false;\n\nexport type TypescriptSelection = Record<string | number, TypescriptSelectionItem>;\n\nexport type UniqueRowAccessorType = string | string[] | ((row: TypescriptRow) => string);\n\nexport interface ReduxHeader {\n hideFilterMenu: boolean;\n hideFilterButton: boolean;\n showDnDHandle: boolean;\n withTabStops: boolean;\n}\n\nexport type TypescriptProps = {\n columns: TypescriptColumn[];\n data: TypescriptRow[];\n height?: string;\n width?: string;\n renderRowActions?: TypescriptRenderRowActions;\n getRowVariant?: (\n row: TypescriptRow,\n defaultCellsRenderer: React.ComponentType<any>,\n ) => RowVariant | React.ComponentType<any>;\n isExpandable?: boolean;\n uniqueRowAccessor?: UniqueRowAccessorType;\n disabledRows?: Record<string, boolean>;\n expandedRows?: Record<string, boolean>;\n cellRendererProps?: Record<string, any>;\n noSelectionColumn?: boolean;\n selectSingle?: boolean;\n selection?: TypescriptSelection;\n groupedRowsRenderHeader?: TypescriptGenericFunc | string;\n isResizeable?: boolean;\n withFilterBar?: boolean;\n filters?: { id: string; type: string; value: any }[];\n filterBarProps?: {\n customPillRenderer?: React.ComponentType<any>;\n extraOptions?: { type: string; id: string; label: string; onClick?: TypescriptGenericFunc }[];\n };\n actionRef: React.RefObject<any>;\n pagination?: false | TypescriptPagination;\n colsLayoutStyle: ColsLayoutStyle;\n hiddenColumns: string[];\n dragAndDropRows?: boolean;\n maxDragAndDropLevel?: number;\n textWrap?: 'wrap' | 'wrap-all' | 'truncate';\n customSortLogic?: boolean;\n noResultsMessage?: string;\n noResultsSecondaryMessage?: string;\n noResultsButtonLabel?: string;\n isLoading?: boolean;\n isLoadingAppended?: boolean;\n dragAndDropColumns?: boolean;\n onColumnsReorder?: (newData: any[], indexes: { targetIndex: number; fromIndex: number }) => void;\n onColumnResize?: (headerId: string, width: number) => void;\n isNoMoreDataAppended?: boolean;\n noMoreDataMessage?: string;\n noResultsPlaceholder?: TypescriptGenericFunc;\n onRowExpand?: (expandedRows: Record<string, boolean>, toggledRow: string) => void;\n onRowsReorder?: (\n newData: any[],\n indexes: { targetIndex: number; fromIndex: number },\n considerExpanding: string,\n ) => void;\n onRowClick?: TypescriptGenericFunc;\n onRowFocus?: TypescriptGenericFunc;\n onCellValueChange: (cellChange: { value: any; property: any; rowIndex: number }) => void;\n onSelectionChange?: (newSelection: TypescriptSelection) => void;\n onFiltersChange?: TypescriptGenericFunc;\n onFilteredDataChange?: TypescriptGenericFunc;\n onPageChanged?: TypescriptGenericFunc;\n onNoResultsButtonClick?: TypescriptGenericFunc;\n onColumnSortChange: (newSortRequest: { column: any; direction: any }) => void;\n};\n\nexport interface FilterProps {\n column: TypescriptColumn;\n ctx: TypescriptContext;\n onFiltersChange?: (filters: { id: string; type: string; value: any }[]) => void;\n onValueChange: (type: string, value: any) => void;\n patchHeaderFilterButtonAndMenu: (headerId: string, newState: any) => void;\n patchHeader: (headerId: string, newHeader: any) => void;\n filterValue?: any;\n reduxHeader?: any;\n innerRef: MutableRefObject<HTMLDivElement>;\n}\n\nexport type TypescriptContext = {\n tableProps: Partial<TypescriptProps>;\n virtualListRef: React.RefObject<HTMLDivElement>;\n columnHeaderRef: React.RefObject<HTMLDivElement>;\n flattenedData: TypescriptRow[];\n allDataFlattened: TypescriptRow[];\n visibleColumns: TypescriptColumn[];\n virtualListHelpers?: ReturnType<typeof useVirtual>;\n layoutHelpers: {\n totalColumnsWidth?: number | string;\n gridLayout?: string[];\n setGridLayout?: React.Dispatch<React.SetStateAction<string[]>>;\n };\n paginationHelpers: TypescriptPagination;\n drilldownRowId: string | null;\n setDrilldownRowId: React.Dispatch<React.SetStateAction<string | null>>;\n focusedRowId: string | null;\n setFocusedRowId: React.Dispatch<React.SetStateAction<string | null>>;\n reduxHeaders: Record<string, ReduxHeader>;\n patchHeader: (headerId: string, newHeader: ReduxHeader) => void;\n patchHeaderFilterButtonAndMenu: (headerId: string, value: boolean) => void;\n};\n", "import * as React from 'react';\nexport { React };\n"],
|
|
5
5
|
"mappings": ";;;;;;;;;;;;;;;;AAAA;AAAA;ACAA,YAAuB;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/dist/esm/DataTable.js
CHANGED
|
@@ -15,12 +15,9 @@ var __spreadValues = (a, b) => {
|
|
|
15
15
|
return a;
|
|
16
16
|
};
|
|
17
17
|
import * as React from "react";
|
|
18
|
-
import React2, { useRef
|
|
19
|
-
import { Provider } from "react-redux";
|
|
20
|
-
import { configureStore } from "@reduxjs/toolkit";
|
|
18
|
+
import React2, { useRef } from "react";
|
|
21
19
|
import { describe } from "@elliemae/ds-utilities";
|
|
22
20
|
import { TableContent } from "./parts/TableContent";
|
|
23
|
-
import { storeConfig } from "./redux/storeConfig";
|
|
24
21
|
import { DataTableContext, defaultProps } from "./DataTableContext";
|
|
25
22
|
import { DATA_TESTID } from "./configs/constants";
|
|
26
23
|
import { useDatatableConfig } from "./configs/useDatatableConfig";
|
|
@@ -29,16 +26,13 @@ import { DataTableSchema } from "./DataTableSchema";
|
|
|
29
26
|
import { StyledDataTableWrapper } from "./styled";
|
|
30
27
|
const DataTable = (props) => {
|
|
31
28
|
const { withFilterBar } = props;
|
|
32
|
-
const reduxStore = useMemo(() => configureStore(storeConfig), []);
|
|
33
29
|
const tableWrapperRef = useRef();
|
|
34
30
|
const tableContentWrapperRef = useRef();
|
|
35
31
|
const ctx = useDatatableConfig(props);
|
|
36
32
|
const {
|
|
37
33
|
tableProps: { height, width }
|
|
38
34
|
} = ctx;
|
|
39
|
-
return /* @__PURE__ */ React2.createElement(Provider, {
|
|
40
|
-
store: reduxStore
|
|
41
|
-
}, /* @__PURE__ */ React2.createElement(DataTableContext.Provider, {
|
|
35
|
+
return /* @__PURE__ */ React2.createElement(DataTableContext.Provider, {
|
|
42
36
|
value: ctx
|
|
43
37
|
}, /* @__PURE__ */ React2.createElement(StyledDataTableWrapper, {
|
|
44
38
|
ref: tableWrapperRef,
|
|
@@ -47,7 +41,7 @@ const DataTable = (props) => {
|
|
|
47
41
|
width
|
|
48
42
|
}, withFilterBar ? /* @__PURE__ */ React2.createElement(FiltersBar, null) : null, /* @__PURE__ */ React2.createElement(TableContent, {
|
|
49
43
|
ref: tableContentWrapperRef
|
|
50
|
-
})))
|
|
44
|
+
})));
|
|
51
45
|
};
|
|
52
46
|
DataTable.propTypes = DataTableSchema;
|
|
53
47
|
DataTable.defaultProps = __spreadValues({}, defaultProps);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../scripts/build/transpile/react-shim.js", "../../src/DataTable.tsx"],
|
|
4
|
-
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import React, { useRef
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;AAAA;ACAA;AACA;AACA;
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import React, { useRef } from 'react';\nimport { describe } from '@elliemae/ds-utilities';\nimport { TableContent } from './parts/TableContent';\nimport { TypescriptProps } from './types/props';\nimport { DataTableContext, defaultProps } from './DataTableContext';\nimport { DATA_TESTID } from './configs/constants';\nimport { useDatatableConfig } from './configs/useDatatableConfig';\nimport { FiltersBar } from './parts/FilterBar/FiltersBar';\nimport { DataTableSchema } from './DataTableSchema';\nimport { StyledDataTableWrapper } from './styled';\n\nexport const DataTable = (props: TypescriptProps): JSX.Element => {\n const { withFilterBar } = props;\n\n const tableWrapperRef = useRef();\n const tableContentWrapperRef = useRef();\n\n const ctx = useDatatableConfig(props);\n\n const {\n tableProps: { height, width },\n } = ctx;\n\n return (\n <DataTableContext.Provider value={ctx}>\n <StyledDataTableWrapper\n ref={tableWrapperRef}\n data-testid={DATA_TESTID.DATA_TABLE_WRAPPER}\n height={height}\n width={width}\n >\n {withFilterBar ? <FiltersBar /> : null}\n <TableContent ref={tableContentWrapperRef} />\n </StyledDataTableWrapper>\n </DataTableContext.Provider>\n );\n};\n\nDataTable.propTypes = DataTableSchema;\nDataTable.defaultProps = { ...defaultProps };\n\nexport const DataTableWithSchema = describe(DataTable).description('Data Table');\nDataTableWithSchema.propTypes = DataTableSchema;\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;AAAA;ACAA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AAEO,MAAM,YAAY,CAAC,UAAwC;AAChE,QAAM,EAAE,kBAAkB;AAE1B,QAAM,kBAAkB,OAAO;AAC/B,QAAM,yBAAyB,OAAO;AAEtC,QAAM,MAAM,mBAAmB,KAAK;AAEpC,QAAM;AAAA,IACJ,YAAY,EAAE,QAAQ;AAAA,MACpB;AAEJ,SACE,qCAAC,iBAAiB,UAAjB;AAAA,IAA0B,OAAO;AAAA,KAChC,qCAAC;AAAA,IACC,KAAK;AAAA,IACL,eAAa,YAAY;AAAA,IACzB;AAAA,IACA;AAAA,KAEC,gBAAgB,qCAAC,gBAAW,IAAK,MAClC,qCAAC;AAAA,IAAa,KAAK;AAAA,GAAwB,CAC7C,CACF;AAEJ;AAEA,UAAU,YAAY;AACtB,UAAU,eAAe,mBAAK;AAEvB,MAAM,sBAAsB,SAAS,SAAS,EAAE,YAAY,YAAY;AAC/E,oBAAoB,YAAY;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -18,14 +18,14 @@ var __spreadValues = (a, b) => {
|
|
|
18
18
|
};
|
|
19
19
|
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
20
20
|
import * as React from "react";
|
|
21
|
-
import React2 from "react";
|
|
21
|
+
import React2, { useContext } from "react";
|
|
22
22
|
import { Grid } from "@elliemae/ds-grid";
|
|
23
23
|
import { DSInputMask, MASK_TYPES } from "@elliemae/ds-form";
|
|
24
24
|
import { DSFormLayoutBlockItem } from "@elliemae/ds-form-layout-blocks";
|
|
25
25
|
import { SearchXsmall } from "@elliemae/ds-icons";
|
|
26
26
|
import { FilterPopover, FILTER_TYPES } from "../../../../exported-related";
|
|
27
27
|
import { DATA_TESTID } from "../../../../configs/constants";
|
|
28
|
-
import
|
|
28
|
+
import DataTableContext from "../../../../DataTableContext";
|
|
29
29
|
const opts = {
|
|
30
30
|
prefix: "",
|
|
31
31
|
suffix: "",
|
|
@@ -37,6 +37,7 @@ const opts = {
|
|
|
37
37
|
};
|
|
38
38
|
const CurrencyRangeFilter = (props) => {
|
|
39
39
|
const { column, filterValue = { from: null, to: null }, reduxHeader, onValueChange, innerRef } = props;
|
|
40
|
+
const { patchHeader } = useContext(DataTableContext);
|
|
40
41
|
const handleFromChange = (e) => {
|
|
41
42
|
const nextValue = __spreadProps(__spreadValues({}, filterValue), {
|
|
42
43
|
from: e.target.value
|
|
@@ -49,7 +50,6 @@ const CurrencyRangeFilter = (props) => {
|
|
|
49
50
|
});
|
|
50
51
|
onValueChange(FILTER_TYPES.CURRENCY_RANGE, nextValue);
|
|
51
52
|
};
|
|
52
|
-
const { patchHeader } = useDispatchHeadersActions();
|
|
53
53
|
const closePopover = (e) => {
|
|
54
54
|
if (e.code === "Escape") {
|
|
55
55
|
patchHeader(column.id, { hideFilterMenu: true, hideFilterButton: false });
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../../../../scripts/build/transpile/react-shim.js", "../../../../../../src/addons/Filters/Components/CurrencyRangeFilter/index.tsx"],
|
|
4
|
-
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "/* eslint-disable react/prop-types */\nimport React from 'react';\nimport { Grid } from '@elliemae/ds-grid';\nimport { DSInputMask, MASK_TYPES } from '@elliemae/ds-form';\nimport { DSFormLayoutBlockItem } from '@elliemae/ds-form-layout-blocks';\nimport { SearchXsmall } from '@elliemae/ds-icons';\nimport { FilterPopover, FILTER_TYPES } from '../../../../exported-related';\nimport { FilterProps } from '../../../../types/props';\nimport { DATA_TESTID } from '../../../../configs/constants';\nimport
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;AAAA;ACCA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AAEA,MAAM,OAAO;AAAA,EACX,QAAQ;AAAA,EACR,QAAQ;AAAA,EACR,cAAc;AAAA,EACd,cAAc;AAAA,EACd,2BAA2B;AAAA,EAC3B,gBAAgB;AAAA,EAChB,eAAe;AACjB;AAEO,MAAM,sBAAwD,CAAC,UAAU;AAC9E,QAAM,EAAE,QAAQ,cAAc,EAAE,MAAM,MAAM,IAAI,KAAK,GAAG,aAAa,eAAe,aAAa;
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "/* eslint-disable react/prop-types */\nimport React, { useContext } from 'react';\nimport { Grid } from '@elliemae/ds-grid';\nimport { DSInputMask, MASK_TYPES } from '@elliemae/ds-form';\nimport { DSFormLayoutBlockItem } from '@elliemae/ds-form-layout-blocks';\nimport { SearchXsmall } from '@elliemae/ds-icons';\nimport { FilterPopover, FILTER_TYPES } from '../../../../exported-related';\nimport { FilterProps } from '../../../../types/props';\nimport { DATA_TESTID } from '../../../../configs/constants';\nimport DataTableContext from '../../../../DataTableContext';\n\nconst opts = {\n prefix: '',\n suffix: '',\n allowDecimal: true,\n decimalLimit: 2,\n includeThousandsSeparator: false,\n requireDecimal: true,\n allowNegative: true,\n};\n\nexport const CurrencyRangeFilter: React.ComponentType<FilterProps> = (props) => {\n const { column, filterValue = { from: null, to: null }, reduxHeader, onValueChange, innerRef } = props;\n\n const { patchHeader } = useContext(DataTableContext);\n\n const handleFromChange = (e) => {\n const nextValue = {\n ...filterValue,\n from: e.target.value,\n };\n onValueChange(FILTER_TYPES.CURRENCY_RANGE, nextValue);\n };\n const handleToChange = (e) => {\n const nextValue = {\n ...filterValue,\n to: e.target.value,\n };\n onValueChange(FILTER_TYPES.CURRENCY_RANGE, nextValue);\n };\n\n // workaround to close menu with esc key since DSInputMask has stoppropagation on key down\n const closePopover = (e) => {\n if (e.code === 'Escape') {\n patchHeader(column.id, { hideFilterMenu: true, hideFilterButton: false });\n innerRef.current.focus();\n }\n };\n\n const idPreffix = 'datatable-currency-range';\n return (\n <FilterPopover\n reduxHeader={reduxHeader}\n column={column}\n columnId={column.id}\n menuContent={\n <Grid\n data-testid={DATA_TESTID.DATA_TABLE_CURRENCY_RANGE_CONTROLLER}\n gutter=\"xxxs\"\n padding=\"xxs\"\n cols={['auto', 'auto']}\n style={{ background: 'white' }}\n >\n <DSFormLayoutBlockItem label=\"Min\" inputID={`${idPreffix}-min-${column.id}`}>\n <DSInputMask\n containerProps={{ style: { textAlign: 'right' } }}\n id={`${idPreffix}-min-${column.id}`}\n value={`${filterValue?.from ?? ''}`}\n onChange={handleFromChange}\n placeholder=\"0.00\"\n mask={(number) => MASK_TYPES.NUMBER(opts)(number)}\n autoFocus\n onKeyDown={(e) => {\n closePopover(e);\n }}\n />\n </DSFormLayoutBlockItem>\n <DSFormLayoutBlockItem label=\"Max\" inputID={`${idPreffix}-max-${column.id}`}>\n <DSInputMask\n containerProps={{ style: { textAlign: 'right' } }}\n id={`${idPreffix}-max-${column.id}`}\n value={`${filterValue?.to ?? ''}`}\n onChange={handleToChange}\n placeholder=\"0.00\"\n mask={(number) => MASK_TYPES.NUMBER(opts)(number)}\n onKeyDown={(e) => {\n closePopover(e);\n }}\n />\n </DSFormLayoutBlockItem>\n </Grid>\n }\n triggerIcon={<SearchXsmall />}\n customStyles={{ width: column.ref?.current?.offsetWidth ?? '0px' }}\n innerRef={innerRef}\n ariaLabel=\"Open Currency Range Filter\"\n />\n );\n};\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;AAAA;ACCA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AAEA,MAAM,OAAO;AAAA,EACX,QAAQ;AAAA,EACR,QAAQ;AAAA,EACR,cAAc;AAAA,EACd,cAAc;AAAA,EACd,2BAA2B;AA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EAAE,MAAM;AAAA,MAChD,WAAS;AAAA,MACT,WAAW,CAAC,MAAM;AAChB,qBAAa,CAAC;AAAA,MAChB;AAAA,KACF,CACF,GACA,qCAAC;AAAA,MAAsB,OAAM;AAAA,MAAM,SAAS,GAAG,iBAAiB,OAAO;AAAA,OACrE,qCAAC;AAAA,MACC,gBAAgB,EAAE,OAAO,EAAE,WAAW,QAAQ,EAAE;AAAA,MAChD,IAAI,GAAG,iBAAiB,OAAO;AAAA,MAC/B,OAAO,GAAG,aAAa,MAAM;AAAA,MAC7B,UAAU;AAAA,MACV,aAAY;AAAA,MACZ,MAAM,CAAC,WAAW,WAAW,OAAO,IAAI,EAAE,MAAM;AAAA,MAChD,WAAW,CAAC,MAAM;AAChB,qBAAa,CAAC;AAAA,MAChB;AAAA,KACF,CACF,CACF;AAAA,IAEF,aAAa,qCAAC,kBAAa;AAAA,IAC3B,cAAc,EAAE,OAAO,OAAO,KAAK,SAAS,eAAe,MAAM;AAAA,IACjE;AAAA,IACA,WAAU;AAAA,GACZ;AAEJ;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -18,14 +18,14 @@ var __spreadValues = (a, b) => {
|
|
|
18
18
|
};
|
|
19
19
|
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
20
20
|
import * as React from "react";
|
|
21
|
-
import React2 from "react";
|
|
21
|
+
import React2, { useContext } from "react";
|
|
22
22
|
import { Grid } from "@elliemae/ds-grid";
|
|
23
23
|
import { DSInputMask, MASK_TYPES } from "@elliemae/ds-form";
|
|
24
24
|
import { DSFormLayoutBlockItem } from "@elliemae/ds-form-layout-blocks";
|
|
25
25
|
import { SearchXsmall } from "@elliemae/ds-icons";
|
|
26
26
|
import { FilterPopover, FILTER_TYPES } from "../../../../exported-related";
|
|
27
27
|
import { DATA_TESTID } from "../../../../configs/constants";
|
|
28
|
-
import
|
|
28
|
+
import DataTableContext from "../../../../DataTableContext";
|
|
29
29
|
const opts = {
|
|
30
30
|
prefix: "",
|
|
31
31
|
suffix: "",
|
|
@@ -36,6 +36,7 @@ const opts = {
|
|
|
36
36
|
};
|
|
37
37
|
const NumberRangeFilter = (props) => {
|
|
38
38
|
const { column, filterValue = { from: null, to: null }, reduxHeader, onValueChange, innerRef } = props;
|
|
39
|
+
const { patchHeader } = useContext(DataTableContext);
|
|
39
40
|
const handleFromChange = (e) => {
|
|
40
41
|
const from = e.target.value !== "" ? parseInt(e.target.value, 10) : "";
|
|
41
42
|
const nextValue = __spreadProps(__spreadValues({}, filterValue), {
|
|
@@ -50,7 +51,6 @@ const NumberRangeFilter = (props) => {
|
|
|
50
51
|
});
|
|
51
52
|
onValueChange(FILTER_TYPES.CURRENCY_RANGE, nextValue);
|
|
52
53
|
};
|
|
53
|
-
const { patchHeader } = useDispatchHeadersActions();
|
|
54
54
|
const closePopover = (e) => {
|
|
55
55
|
if (e.code === "Escape") {
|
|
56
56
|
patchHeader(column.id, { hideFilterMenu: true, hideFilterButton: false });
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../../../../scripts/build/transpile/react-shim.js", "../../../../../../src/addons/Filters/Components/NumberRangeFilter/index.tsx"],
|
|
4
|
-
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "/* eslint-disable react/prop-types */\nimport React from 'react';\nimport { Grid } from '@elliemae/ds-grid';\nimport { DSInputMask, MASK_TYPES } from '@elliemae/ds-form';\nimport { DSFormLayoutBlockItem } from '@elliemae/ds-form-layout-blocks';\nimport { SearchXsmall } from '@elliemae/ds-icons';\nimport { FilterPopover, FILTER_TYPES } from '../../../../exported-related';\nimport { FilterProps } from '../../../../types/props';\nimport { DATA_TESTID } from '../../../../configs/constants';\nimport
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;AAAA;ACCA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AAEA,MAAM,OAAO;AAAA,EACX,QAAQ;AAAA,EACR,QAAQ;AAAA,EACR,cAAc;AAAA,EACd,2BAA2B;AAAA,EAC3B,gBAAgB;AAAA,EAChB,eAAe;AACjB;AAEO,MAAM,oBAAsD,CAAC,UAAU;AAC5E,QAAM,EAAE,QAAQ,cAAc,EAAE,MAAM,MAAM,IAAI,KAAK,GAAG,aAAa,eAAe,aAAa;
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "/* eslint-disable react/prop-types */\nimport React, { useContext } from 'react';\nimport { Grid } from '@elliemae/ds-grid';\nimport { DSInputMask, MASK_TYPES } from '@elliemae/ds-form';\nimport { DSFormLayoutBlockItem } from '@elliemae/ds-form-layout-blocks';\nimport { SearchXsmall } from '@elliemae/ds-icons';\nimport { FilterPopover, FILTER_TYPES } from '../../../../exported-related';\nimport { FilterProps } from '../../../../types/props';\nimport { DATA_TESTID } from '../../../../configs/constants';\nimport DataTableContext from '../../../../DataTableContext';\n\nconst opts = {\n prefix: '',\n suffix: '',\n allowDecimal: false,\n includeThousandsSeparator: false,\n requireDecimal: false,\n allowNegative: true,\n};\n\nexport const NumberRangeFilter: React.ComponentType<FilterProps> = (props) => {\n const { column, filterValue = { from: null, to: null }, reduxHeader, onValueChange, innerRef } = props;\n\n const { patchHeader } = useContext(DataTableContext);\n\n const handleFromChange = (e) => {\n const from = e.target.value !== '' ? parseInt(e.target.value, 10) : '';\n const nextValue = {\n ...filterValue,\n from,\n };\n onValueChange(FILTER_TYPES.CURRENCY_RANGE, nextValue);\n };\n const handleToChange = (e) => {\n const to = e.target.value !== '' ? parseInt(e.target.value, 10) : '';\n const nextValue = {\n ...filterValue,\n to,\n };\n onValueChange(FILTER_TYPES.CURRENCY_RANGE, nextValue);\n };\n\n // workaround to close menu with esc key since DSInputMask has stoppropagation on key down\n const closePopover = (e) => {\n if (e.code === 'Escape') {\n patchHeader(column.id, { hideFilterMenu: true, hideFilterButton: false });\n innerRef.current.focus();\n }\n };\n const idPreffix = 'datatable-number-range';\n return (\n <FilterPopover\n reduxHeader={reduxHeader}\n column={column}\n columnId={column.id}\n menuContent={\n <Grid\n data-testid={DATA_TESTID.DATA_TABLE_NUMBER_RANGE_CONTROLLER}\n gutter=\"xxxs\"\n padding=\"xxs\"\n cols={['auto', 'auto']}\n style={{ background: 'white' }}\n >\n <DSFormLayoutBlockItem label=\"Low\" inputID={`${idPreffix}-low-${column.id}`}>\n <DSInputMask\n containerProps={{ style: { textAlign: 'right' } }}\n id={`${idPreffix}-low-${column.id}`}\n value={`${filterValue?.from ?? ''}`}\n onChange={handleFromChange}\n placeholder=\"0\"\n mask={(number) => MASK_TYPES.NUMBER(opts)(number)}\n autoFocus\n onKeyDown={(e) => {\n closePopover(e);\n }}\n />\n </DSFormLayoutBlockItem>\n <DSFormLayoutBlockItem label=\"High\" inputID={`${idPreffix}-high-${column.id}`}>\n <DSInputMask\n containerProps={{ style: { textAlign: 'right' } }}\n id={`${idPreffix}-high-${column.id}`}\n value={`${filterValue?.to ?? ''}`}\n onChange={handleToChange}\n placeholder=\"0\"\n mask={(number) => MASK_TYPES.NUMBER(opts)(number)}\n onKeyDown={(e) => {\n closePopover(e);\n }}\n />\n </DSFormLayoutBlockItem>\n </Grid>\n }\n triggerIcon={<SearchXsmall />}\n customStyles={{ width: column.ref?.current?.offsetWidth ?? '0px' }}\n innerRef={innerRef}\n ariaLabel=\"Open Number Range Filter\"\n />\n );\n};\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;AAAA;ACCA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AAEA,MAAM,OAAO;AAAA,EACX,QAAQ;AAAA,EACR,QAAQ;AAAA,EACR,cAAc;AAAA,EACd,2BAA2B;AAAA,EAC3B,gBAAgB;AAAA,EAChB,eAAe;AACjB;AAEO,MAAM,oBAAsD,CAAC,UAAU;AAC5E,QAAM,EAAE,QAAQ,cAAc,EAAE,MAAM,MAAM,IAAI,KAAK,GAAG,aAAa,eAAe,aAAa;AAEjG,QAAM,EAAE,gBAAgB,WAAW,gBAAg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MAChB;AAAA,KACF,CACF,GACA,qCAAC;AAAA,MAAsB,OAAM;AAAA,MAAO,SAAS,GAAG,kBAAkB,OAAO;AAAA,OACvE,qCAAC;AAAA,MACC,gBAAgB,EAAE,OAAO,EAAE,WAAW,QAAQ,EAAE;AAAA,MAChD,IAAI,GAAG,kBAAkB,OAAO;AAAA,MAChC,OAAO,GAAG,aAAa,MAAM;AAAA,MAC7B,UAAU;AAAA,MACV,aAAY;AAAA,MACZ,MAAM,CAAC,WAAW,WAAW,OAAO,IAAI,EAAE,MAAM;AAAA,MAChD,WAAW,CAAC,MAAM;AAChB,qBAAa,CAAC;AAAA,MAChB;AAAA,KACF,CACF,CACF;AAAA,IAEF,aAAa,qCAAC,kBAAa;AAAA,IAC3B,cAAc,EAAE,OAAO,OAAO,KAAK,SAAS,eAAe,MAAM;AAAA,IACjE;AAAA,IACA,WAAU;AAAA,GACZ;AAEJ;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
|
-
import React2, { useState, useEffect, useMemo } from "react";
|
|
2
|
+
import React2, { useState, useEffect, useMemo, useContext } from "react";
|
|
3
3
|
import { Grid } from "@elliemae/ds-grid";
|
|
4
4
|
import { DSComboBox } from "@elliemae/ds-controlled-form";
|
|
5
5
|
import { SearchXsmall } from "@elliemae/ds-icons";
|
|
6
6
|
import { FilterPopover } from "../../../../exported-related";
|
|
7
7
|
import { DATA_TESTID } from "../../../../configs";
|
|
8
|
-
import
|
|
8
|
+
import DataTableContext from "../../../../DataTableContext";
|
|
9
9
|
const BaseSelectFilter = (props) => {
|
|
10
10
|
const {
|
|
11
11
|
isMulti = false,
|
|
@@ -20,7 +20,7 @@ const BaseSelectFilter = (props) => {
|
|
|
20
20
|
innerRef,
|
|
21
21
|
onValueChange
|
|
22
22
|
} = props;
|
|
23
|
-
const { patchHeaderFilterButtonAndMenu } =
|
|
23
|
+
const { patchHeaderFilterButtonAndMenu } = useContext(DataTableContext);
|
|
24
24
|
const filterOptions = useMemo(() => {
|
|
25
25
|
if (!userFilterOptions) {
|
|
26
26
|
const automaticFilters = [
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../../../../scripts/build/transpile/react-shim.js", "../../../../../../src/addons/Filters/Components/SelectFilter/BaseSelectFilter.tsx"],
|
|
4
|
-
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "/* eslint-disable react/prop-types */\nimport React, { useState, useEffect, useMemo, useCallback } from 'react';\nimport { Grid } from '@elliemae/ds-grid';\nimport { DSComboBox } from '@elliemae/ds-controlled-form';\nimport { SearchXsmall } from '@elliemae/ds-icons';\nimport { FilterPopover } from '../../../../exported-related';\nimport { FilterProps } from '../../../../types/props';\nimport { DATA_TESTID } from '../../../../configs';\nimport
|
|
5
|
-
"mappings": "AAAA;ACCA;AACA;AACA;AACA;AACA;AAEA;AACA;AAgBO,MAAM,mBAAuE,CAAC,UAAU;AAC7F,QAAM;AAAA,IACJ,UAAU;AAAA,IACV,gBAAgB;AAAA,IAChB;AAAA,IACA;AAAA,IACA,QAAQ,EAAE,IAAI,eAAe,mBAAmB;AAAA,IAChD,KAAK;AAAA,MACH,YAAY,EAAE;AAAA;AAAA,IAEhB;AAAA,IACA;AAAA,IACA;AAAA,MACE;AAEJ,QAAM,EAAE,mCAAmC,
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "/* eslint-disable react/prop-types */\nimport React, { useState, useEffect, useMemo, useCallback, useContext } from 'react';\nimport { Grid } from '@elliemae/ds-grid';\nimport { DSComboBox } from '@elliemae/ds-controlled-form';\nimport { SearchXsmall } from '@elliemae/ds-icons';\nimport { FilterPopover } from '../../../../exported-related';\nimport { FilterProps } from '../../../../types/props';\nimport { DATA_TESTID } from '../../../../configs';\nimport DataTableContext from '../../../../DataTableContext';\n\ninterface FilterOptionT {\n dsId: string;\n type: string;\n value: string;\n label: string;\n}\n\ninterface BaseSelectProps {\n isSingle?: boolean;\n isMulti?: boolean;\n selectedItems?: FilterOptionT[] | FilterOptionT;\n type: string;\n}\n\nexport const BaseSelectFilter: React.ComponentType<FilterProps & BaseSelectProps> = (props) => {\n const {\n isMulti = false,\n selectedItems = null,\n column,\n type,\n column: { id, filterOptions: userFilterOptions, filterMinWidth },\n ctx: {\n tableProps: { data },\n },\n reduxHeader,\n innerRef,\n onValueChange,\n } = props;\n\n const { patchHeaderFilterButtonAndMenu } = useContext(DataTableContext);\n\n const filterOptions: FilterOptionT[] = useMemo(() => {\n // If the user didn't provide options, use the available ones\n if (!userFilterOptions) {\n const automaticFilters = [\n ...new Set(data.map((datum) => datum?.[id]?.toString()).filter((val) => val !== undefined)),\n ].map((item) => ({\n type: 'option',\n dsId: item,\n value: item,\n label: item,\n }));\n\n return automaticFilters;\n }\n\n // If user provided the array itself, use it\n if (Array.isArray(userFilterOptions)) return userFilterOptions;\n // Otherwise, it is a function\n return userFilterOptions();\n }, [data, id, userFilterOptions]);\n\n const handleOnChange = (value) => {\n onValueChange(type, value);\n if (!isMulti) patchHeaderFilterButtonAndMenu(column.id, true);\n };\n\n const [filters, setFilteredOptions] = useState(filterOptions);\n\n useEffect(() => {\n setFilteredOptions(filterOptions);\n }, [filterOptions]);\n\n const Select = (\n <Grid\n data-testid={\n isMulti ? DATA_TESTID.DATA_TABLE_MULTISELECT_CONTROLLER : DATA_TESTID.DATA_TABLE_SINGLESELECT_CONTROLLER\n }\n style={{ background: '#fff', position: 'relative', width: filterMinWidth }}\n >\n <DSComboBox\n inline\n autoFocus\n allOptions={filterOptions}\n filteredOptions={filters}\n onChange={handleOnChange}\n selectedValues={selectedItems}\n onFilter={setFilteredOptions}\n menuMaxHeight={300}\n />\n </Grid>\n );\n\n const handleOnClickOutside = () => {\n setFilteredOptions(filterOptions);\n };\n return (\n <FilterPopover\n reduxHeader={reduxHeader}\n column={column}\n columnId={column.id}\n menuContent={Select}\n triggerIcon={<SearchX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AO,EAAE,YAAY,QAAQ,UAAU,YAAY,OAAO,eAAe;AAAA,KAEzE,qCAAC;AAAA,IACC,QAAM;AAAA,IACN,WAAS;AAAA,IACT,YAAY;AAAA,IACZ,iBAAiB;AAAA,IACjB,UAAU;AAAA,IACV,gBAAgB;AAAA,IAChB,UAAU;AAAA,IACV,eAAe;AAAA,GACjB,CACF;AAGF,QAAM,uBAAuB,MAAM;AACjC,uBAAmB,aAAa;AAAA,EAClC;AACA,SACE,qCAAC;AAAA,IACC;AAAA,IACA;AAAA,IACA,UAAU,OAAO;AAAA,IACjB,aAAa;AAAA,IACb,aAAa,qCAAC,kBAAa;AAAA,IAC3B;AAAA,IACA,WAAU;AAAA,IACV,oBAAoB;AAAA,GACtB;AAEJ;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,3 +1,19 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
3
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
4
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
5
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
6
|
+
var __spreadValues = (a, b) => {
|
|
7
|
+
for (var prop in b || (b = {}))
|
|
8
|
+
if (__hasOwnProp.call(b, prop))
|
|
9
|
+
__defNormalProp(a, prop, b[prop]);
|
|
10
|
+
if (__getOwnPropSymbols)
|
|
11
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
12
|
+
if (__propIsEnum.call(b, prop))
|
|
13
|
+
__defNormalProp(a, prop, b[prop]);
|
|
14
|
+
}
|
|
15
|
+
return a;
|
|
16
|
+
};
|
|
1
17
|
import * as React from "react";
|
|
2
18
|
import { useEffect, useMemo, useRef, useState } from "react";
|
|
3
19
|
import { useVirtual } from "react-virtual";
|
|
@@ -6,6 +22,7 @@ import { useRowFlattenization } from "./useRowFlattenization";
|
|
|
6
22
|
import { usePaginationConfig } from "./usePaginationConfig";
|
|
7
23
|
import { useTableColsWithAddons } from "./useTableColsWithAddons";
|
|
8
24
|
import { ColsLayoutStyle } from "./constants";
|
|
25
|
+
import { useInternalStateConfig } from "./useInternalStateConfig";
|
|
9
26
|
const useDatatableConfig = (props) => {
|
|
10
27
|
const virtualListRef = useRef(null);
|
|
11
28
|
const columnHeaderRef = useRef(null);
|
|
@@ -38,7 +55,8 @@ const useDatatableConfig = (props) => {
|
|
|
38
55
|
setGridLayout,
|
|
39
56
|
totalColumnsWidth
|
|
40
57
|
}), [gridLayout, setGridLayout, totalColumnsWidth]);
|
|
41
|
-
const
|
|
58
|
+
const internalState = useInternalStateConfig();
|
|
59
|
+
const ctx = useMemo(() => __spreadValues({
|
|
42
60
|
tableProps: props,
|
|
43
61
|
layoutHelpers,
|
|
44
62
|
paginationHelpers,
|
|
@@ -48,7 +66,7 @@ const useDatatableConfig = (props) => {
|
|
|
48
66
|
allDataFlattened,
|
|
49
67
|
virtualListRef,
|
|
50
68
|
columnHeaderRef
|
|
51
|
-
}), [
|
|
69
|
+
}, internalState), [
|
|
52
70
|
props,
|
|
53
71
|
layoutHelpers,
|
|
54
72
|
paginationHelpers,
|
|
@@ -58,7 +76,8 @@ const useDatatableConfig = (props) => {
|
|
|
58
76
|
flattenedData,
|
|
59
77
|
allDataFlattened,
|
|
60
78
|
virtualListRef,
|
|
61
|
-
columnHeaderRef
|
|
79
|
+
columnHeaderRef,
|
|
80
|
+
internalState
|
|
62
81
|
]);
|
|
63
82
|
return ctx;
|
|
64
83
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../scripts/build/transpile/react-shim.js", "../../../src/configs/useDatatableConfig.tsx"],
|
|
4
|
-
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import { useEffect, useMemo, useRef, useState } from 'react';\nimport { useVirtual } from 'react-virtual';\nimport { columnsToGrid } from '../helpers/columnsToGrid';\nimport { TypescriptColumn, TypescriptContext, TypescriptProps } from '../types/props';\nimport { useRowFlattenization } from './useRowFlattenization';\nimport { usePaginationConfig } from './usePaginationConfig';\nimport { useTableColsWithAddons } from './useTableColsWithAddons';\nimport { ColsLayoutStyle } from './constants';\n\nexport const useDatatableConfig = (props: TypescriptProps): TypescriptContext => {\n const virtualListRef = useRef<HTMLDivElement>(null);\n const columnHeaderRef = useRef<HTMLDivElement>(null);\n\n // ===========================================================================\n // Column config\n // ===========================================================================\n const tableColsWithAddons = useTableColsWithAddons(props);\n\n const visibleColumns = useMemo(\n () => tableColsWithAddons.filter((col: TypescriptColumn) => !props.hiddenColumns.includes(col.accessor)),\n [props.hiddenColumns, tableColsWithAddons],\n );\n\n // ===========================================================================\n // Virtualization\n // ===========================================================================\n\n const [dataLength, setDataLength] = useState(1);\n\n // estimateSize should not be really required given what was stated on\n // https://github.com/tannerlinsley/react-virtual/issues/23\n const virtualListHelpers = useVirtual({\n size: dataLength,\n parentRef: virtualListRef,\n overscan: 15,\n paddingStart: columnHeaderRef.current?.getBoundingClientRect()?.height ?? 24,\n });\n\n // ===========================================================================\n // Action ref setup\n // ===========================================================================\n useEffect(() => {\n if (props.actionRef) {\n props.actionRef.current.scrollToIndex = virtualListHelpers.scrollToIndex;\n props.actionRef.current.scrollToOffset = virtualListHelpers.scrollToOffset;\n }\n }, [props.actionRef, virtualListHelpers.scrollToIndex, virtualListHelpers.scrollToOffset]);\n\n // ===========================================================================\n // Data flattenization and pagination\n // ===========================================================================\n\n const [flattenedData, allDataFlattened] = useRowFlattenization(props);\n\n const [paginatedData, paginationHelpers] = usePaginationConfig(props, flattenedData);\n\n // Redo virtualization until we match the lengths\n if (dataLength !== (paginatedData || flattenedData).length) setDataLength((paginatedData || flattenedData).length);\n\n // ===========================================================================\n // Layout config\n // ===========================================================================\n\n const [gridLayout, setGridLayout] = useState(columnsToGrid(visibleColumns, props.colsLayoutStyle));\n\n // We need to listen and update the state based on this props\n useEffect(() => {\n setGridLayout(columnsToGrid(visibleColumns, props.colsLayoutStyle));\n }, [visibleColumns, props.colsLayoutStyle]);\n\n const totalColumnsWidth = useMemo(\n () =>\n props.colsLayoutStyle === ColsLayoutStyle.Fixed\n ? gridLayout.reduce((acc: number, cur: string) => acc + Number.parseInt(cur, 10), 0)\n : '100%',\n [props.colsLayoutStyle, gridLayout],\n );\n\n const layoutHelpers = useMemo(\n () => ({\n gridLayout,\n setGridLayout,\n totalColumnsWidth,\n }),\n [gridLayout, setGridLayout, totalColumnsWidth],\n );\n\n const ctx = useMemo(\n () => ({\n tableProps: props,\n layoutHelpers,\n paginationHelpers,\n visibleColumns,\n virtualListHelpers,\n flattenedData: paginatedData || flattenedData,\n allDataFlattened,\n virtualListRef,\n columnHeaderRef,\n }),\n [\n props,\n layoutHelpers,\n paginationHelpers,\n visibleColumns,\n virtualListHelpers,\n paginatedData,\n flattenedData,\n allDataFlattened,\n virtualListRef,\n columnHeaderRef,\n ],\n );\n\n return ctx;\n};\n"],
|
|
5
|
-
"mappings": "AAAA;ACAA;AACA;AACA;AAEA;AACA;AACA;AACA;AAEO,MAAM,qBAAqB,CAAC,UAA8C;AAC/E,QAAM,iBAAiB,OAAuB,IAAI;AAClD,QAAM,kBAAkB,OAAuB,IAAI;AAKnD,QAAM,sBAAsB,uBAAuB,KAAK;AAExD,QAAM,iBAAiB,QACrB,MAAM,oBAAoB,OAAO,CAAC,QAA0B,CAAC,MAAM,cAAc,SAAS,IAAI,QAAQ,CAAC,GACvG,CAAC,MAAM,eAAe,mBAAmB,CAC3C;AAMA,QAAM,CAAC,YAAY,iBAAiB,SAAS,CAAC;AAI9C,QAAM,qBAAqB,WAAW;AAAA,IACpC,MAAM;AAAA,IACN,WAAW;AAAA,IACX,UAAU;AAAA,IACV,cAAc,gBAAgB,SAAS,sBAAsB,GAAG,UAAU;AAAA,EAC5E,CAAC;AAKD,YAAU,MAAM;AACd,QAAI,MAAM,WAAW;AACnB,YAAM,UAAU,QAAQ,gBAAgB,mBAAmB;AAC3D,YAAM,UAAU,QAAQ,iBAAiB,mBAAmB;AAAA,IAC9D;AAAA,EACF,GAAG,CAAC,MAAM,WAAW,mBAAmB,eAAe,mBAAmB,cAAc,CAAC;AAMzF,QAAM,CAAC,eAAe,oBAAoB,qBAAqB,KAAK;AAEpE,QAAM,CAAC,eAAe,qBAAqB,oBAAoB,OAAO,aAAa;AAGnF,MAAI,eAAgB,kBAAiB,eAAe;AAAQ,kBAAe,kBAAiB,eAAe,MAAM;AAMjH,QAAM,CAAC,YAAY,iBAAiB,SAAS,cAAc,gBAAgB,MAAM,eAAe,CAAC;AAGjG,YAAU,MAAM;AACd,kBAAc,cAAc,gBAAgB,MAAM,eAAe,CAAC;AAAA,EACpE,GAAG,CAAC,gBAAgB,MAAM,eAAe,CAAC;AAE1C,QAAM,oBAAoB,QACxB,MACE,MAAM,oBAAoB,gBAAgB,QACtC,WAAW,OAAO,CAAC,KAAa,QAAgB,MAAM,OAAO,SAAS,KAAK,EAAE,GAAG,CAAC,IACjF,QACN,CAAC,MAAM,iBAAiB,UAAU,CACpC;AAEA,QAAM,gBAAgB,QACpB,MAAO;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,EACF,IACA,CAAC,YAAY,eAAe,iBAAiB,CAC/C;
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import { useEffect, useMemo, useRef, useState } from 'react';\nimport { useVirtual } from 'react-virtual';\nimport { columnsToGrid } from '../helpers/columnsToGrid';\nimport { TypescriptColumn, TypescriptContext, TypescriptProps } from '../types/props';\nimport { useRowFlattenization } from './useRowFlattenization';\nimport { usePaginationConfig } from './usePaginationConfig';\nimport { useTableColsWithAddons } from './useTableColsWithAddons';\nimport { ColsLayoutStyle } from './constants';\nimport { useInternalStateConfig } from './useInternalStateConfig';\n\nexport const useDatatableConfig = (props: TypescriptProps): TypescriptContext => {\n const virtualListRef = useRef<HTMLDivElement>(null);\n const columnHeaderRef = useRef<HTMLDivElement>(null);\n\n // ===========================================================================\n // Column config\n // ===========================================================================\n const tableColsWithAddons = useTableColsWithAddons(props);\n\n const visibleColumns = useMemo(\n () => tableColsWithAddons.filter((col: TypescriptColumn) => !props.hiddenColumns.includes(col.accessor)),\n [props.hiddenColumns, tableColsWithAddons],\n );\n\n // ===========================================================================\n // Virtualization\n // ===========================================================================\n\n const [dataLength, setDataLength] = useState(1);\n\n // estimateSize should not be really required given what was stated on\n // https://github.com/tannerlinsley/react-virtual/issues/23\n const virtualListHelpers = useVirtual({\n size: dataLength,\n parentRef: virtualListRef,\n overscan: 15,\n paddingStart: columnHeaderRef.current?.getBoundingClientRect()?.height ?? 24,\n });\n\n // ===========================================================================\n // Action ref setup\n // ===========================================================================\n useEffect(() => {\n if (props.actionRef) {\n props.actionRef.current.scrollToIndex = virtualListHelpers.scrollToIndex;\n props.actionRef.current.scrollToOffset = virtualListHelpers.scrollToOffset;\n }\n }, [props.actionRef, virtualListHelpers.scrollToIndex, virtualListHelpers.scrollToOffset]);\n\n // ===========================================================================\n // Data flattenization and pagination\n // ===========================================================================\n\n const [flattenedData, allDataFlattened] = useRowFlattenization(props);\n\n const [paginatedData, paginationHelpers] = usePaginationConfig(props, flattenedData);\n\n // Redo virtualization until we match the lengths\n if (dataLength !== (paginatedData || flattenedData).length) setDataLength((paginatedData || flattenedData).length);\n\n // ===========================================================================\n // Layout config\n // ===========================================================================\n\n const [gridLayout, setGridLayout] = useState(columnsToGrid(visibleColumns, props.colsLayoutStyle));\n\n // We need to listen and update the state based on this props\n useEffect(() => {\n setGridLayout(columnsToGrid(visibleColumns, props.colsLayoutStyle));\n }, [visibleColumns, props.colsLayoutStyle]);\n\n const totalColumnsWidth = useMemo(\n () =>\n props.colsLayoutStyle === ColsLayoutStyle.Fixed\n ? gridLayout.reduce((acc: number, cur: string) => acc + Number.parseInt(cur, 10), 0)\n : '100%',\n [props.colsLayoutStyle, gridLayout],\n );\n\n const layoutHelpers = useMemo(\n () => ({\n gridLayout,\n setGridLayout,\n totalColumnsWidth,\n }),\n [gridLayout, setGridLayout, totalColumnsWidth],\n );\n\n // ===========================================================================\n // Internal state config\n // ===========================================================================\n\n const internalState = useInternalStateConfig();\n\n const ctx = useMemo(\n () => ({\n tableProps: props,\n layoutHelpers,\n paginationHelpers,\n visibleColumns,\n virtualListHelpers,\n flattenedData: paginatedData || flattenedData,\n allDataFlattened,\n virtualListRef,\n columnHeaderRef,\n ...internalState,\n }),\n [\n props,\n layoutHelpers,\n paginationHelpers,\n visibleColumns,\n virtualListHelpers,\n paginatedData,\n flattenedData,\n allDataFlattened,\n virtualListRef,\n columnHeaderRef,\n internalState,\n ],\n );\n\n return ctx;\n};\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;AAAA;ACAA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AAEO,MAAM,qBAAqB,CAAC,UAA8C;AAC/E,QAAM,iBAAiB,OAAuB,IAAI;AAClD,QAAM,kBAAkB,OAAuB,IAAI;AAKnD,QAAM,sBAAsB,uBAAuB,KAAK;AAExD,QAAM,iBAAiB,QACrB,MAAM,oBAAoB,OAAO,CAAC,QAA0B,CAAC,MAAM,cAAc,SAAS,IAAI,QAAQ,CAAC,GACvG,CAAC,MAAM,eAAe,mBAAmB,CAC3C;AAMA,QAAM,CAAC,YAAY,iBAAiB,SAAS,CAAC;AAI9C,QAAM,qBAAqB,WAAW;AAAA,IACpC,MAAM;AAAA,IACN,WAAW;AAAA,IACX,UAAU;AAAA,IACV,cAAc,gBAAgB,SAAS,sBAAsB,GAAG,UAAU;AAAA,EAC5E,CAAC;AAKD,YAAU,MAAM;AACd,QAAI,MAAM,WAAW;AACnB,YAAM,UAAU,QAAQ,gBAAgB,mBAAmB;AAC3D,YAAM,UAAU,QAAQ,iBAAiB,mBAAmB;AAAA,IAC9D;AAAA,EACF,GAAG,CAAC,MAAM,WAAW,mBAAmB,eAAe,mBAAmB,cAAc,CAAC;AAMzF,QAAM,CAAC,eAAe,oBAAoB,qBAAqB,KAAK;AAEpE,QAAM,CAAC,eAAe,qBAAqB,oBAAoB,OAAO,aAAa;AAGnF,MAAI,eAAgB,kBAAiB,eAAe;AAAQ,kBAAe,kBAAiB,eAAe,MAAM;AAMjH,QAAM,CAAC,YAAY,iBAAiB,SAAS,cAAc,gBAAgB,MAAM,eAAe,CAAC;AAGjG,YAAU,MAAM;AACd,kBAAc,cAAc,gBAAgB,MAAM,eAAe,CAAC;AAAA,EACpE,GAAG,CAAC,gBAAgB,MAAM,eAAe,CAAC;AAE1C,QAAM,oBAAoB,QACxB,MACE,MAAM,oBAAoB,gBAAgB,QACtC,WAAW,OAAO,CAAC,KAAa,QAAgB,MAAM,OAAO,SAAS,KAAK,EAAE,GAAG,CAAC,IACjF,QACN,CAAC,MAAM,iBAAiB,UAAU,CACpC;AAEA,QAAM,gBAAgB,QACpB,MAAO;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,EACF,IACA,CAAC,YAAY,eAAe,iBAAiB,CAC/C;AAMA,QAAM,gBAAgB,uBAAuB;AAE7C,QAAM,MAAM,QACV,MAAO;AAAA,IACL,YAAY;AAAA,IACZ;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,eAAe,iBAAiB;AAAA,IAChC;AAAA,IACA;AAAA,IACA;AAAA,KACG,gBAEL;AAAA,IACE;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF,CACF;AAEA,SAAO;AACT;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
3
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
4
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
5
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
6
|
+
var __spreadValues = (a, b) => {
|
|
7
|
+
for (var prop in b || (b = {}))
|
|
8
|
+
if (__hasOwnProp.call(b, prop))
|
|
9
|
+
__defNormalProp(a, prop, b[prop]);
|
|
10
|
+
if (__getOwnPropSymbols)
|
|
11
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
12
|
+
if (__propIsEnum.call(b, prop))
|
|
13
|
+
__defNormalProp(a, prop, b[prop]);
|
|
14
|
+
}
|
|
15
|
+
return a;
|
|
16
|
+
};
|
|
17
|
+
import * as React from "react";
|
|
18
|
+
import { useCallback, useMemo, useState } from "react";
|
|
19
|
+
const useInternalStateConfig = () => {
|
|
20
|
+
const [drilldownRowId, setDrilldownRowId] = useState(null);
|
|
21
|
+
const [focusedRowId, setFocusedRowId] = useState(null);
|
|
22
|
+
const [reduxHeaders, setReduxHeaders] = useState({});
|
|
23
|
+
const patchHeader = useCallback((headerId, newHeader) => {
|
|
24
|
+
setReduxHeaders((prevReduxHeaders) => {
|
|
25
|
+
const nextReduxHeaders = __spreadValues({}, prevReduxHeaders);
|
|
26
|
+
nextReduxHeaders[headerId] = __spreadValues(__spreadValues({}, nextReduxHeaders?.[headerId] ?? {}), newHeader);
|
|
27
|
+
return nextReduxHeaders;
|
|
28
|
+
});
|
|
29
|
+
}, []);
|
|
30
|
+
const patchHeaderFilterButtonAndMenu = useCallback((headerId, value) => {
|
|
31
|
+
const newState = { hideFilterMenu: value, hideFilterButton: value };
|
|
32
|
+
patchHeader(headerId, newState);
|
|
33
|
+
}, []);
|
|
34
|
+
return useMemo(() => ({
|
|
35
|
+
drilldownRowId,
|
|
36
|
+
setDrilldownRowId,
|
|
37
|
+
focusedRowId,
|
|
38
|
+
setFocusedRowId,
|
|
39
|
+
reduxHeaders,
|
|
40
|
+
patchHeader,
|
|
41
|
+
patchHeaderFilterButtonAndMenu
|
|
42
|
+
}), [
|
|
43
|
+
drilldownRowId,
|
|
44
|
+
setDrilldownRowId,
|
|
45
|
+
focusedRowId,
|
|
46
|
+
setFocusedRowId,
|
|
47
|
+
reduxHeaders,
|
|
48
|
+
patchHeader,
|
|
49
|
+
patchHeaderFilterButtonAndMenu
|
|
50
|
+
]);
|
|
51
|
+
};
|
|
52
|
+
export {
|
|
53
|
+
useInternalStateConfig
|
|
54
|
+
};
|
|
55
|
+
//# sourceMappingURL=useInternalStateConfig.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../scripts/build/transpile/react-shim.js", "../../../src/configs/useInternalStateConfig.tsx"],
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import { useCallback, useMemo, useState } from 'react';\nimport { ReduxHeader } from '../types/props';\n\nexport const useInternalStateConfig = () => {\n const [drilldownRowId, setDrilldownRowId] = useState<string | null>(null);\n const [focusedRowId, setFocusedRowId] = useState<string | null>(null);\n\n // TODO: @uluduena partition this state better\n const [reduxHeaders, setReduxHeaders] = useState<Record<string, ReduxHeader>>({});\n\n const patchHeader = useCallback((headerId: string, newHeader: Partial<ReduxHeader>) => {\n setReduxHeaders((prevReduxHeaders) => {\n const nextReduxHeaders = { ...prevReduxHeaders };\n nextReduxHeaders[headerId] = { ...(nextReduxHeaders?.[headerId] ?? {}), ...newHeader };\n return nextReduxHeaders;\n });\n }, []);\n\n const patchHeaderFilterButtonAndMenu = useCallback((headerId: string, value: boolean) => {\n const newState = { hideFilterMenu: value, hideFilterButton: value };\n patchHeader(headerId, newState);\n }, []);\n\n return useMemo(\n () => ({\n drilldownRowId,\n setDrilldownRowId,\n focusedRowId,\n setFocusedRowId,\n reduxHeaders,\n patchHeader,\n patchHeaderFilterButtonAndMenu,\n }),\n [\n drilldownRowId,\n setDrilldownRowId,\n focusedRowId,\n setFocusedRowId,\n reduxHeaders,\n patchHeader,\n patchHeaderFilterButtonAndMenu,\n ],\n );\n};\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;AAAA;ACAA;AAGO,MAAM,yBAAyB,MAAM;AAC1C,QAAM,CAAC,gBAAgB,qBAAqB,SAAwB,IAAI;AACxE,QAAM,CAAC,cAAc,mBAAmB,SAAwB,IAAI;AAGpE,QAAM,CAAC,cAAc,mBAAmB,SAAsC,CAAC,CAAC;AAEhF,QAAM,cAAc,YAAY,CAAC,UAAkB,cAAoC;AACrF,oBAAgB,CAAC,qBAAqB;AACpC,YAAM,mBAAmB,mBAAK;AAC9B,uBAAiB,YAAY,kCAAM,mBAAmB,aAAa,CAAC,IAAO;AAC3E,aAAO;AAAA,IACT,CAAC;AAAA,EACH,GAAG,CAAC,CAAC;AAEL,QAAM,iCAAiC,YAAY,CAAC,UAAkB,UAAmB;AACvF,UAAM,WAAW,EAAE,gBAAgB,OAAO,kBAAkB,MAAM;AAClE,gBAAY,UAAU,QAAQ;AAAA,EAChC,GAAG,CAAC,CAAC;AAEL,SAAO,QACL,MAAO;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF,IACA;AAAA,IACE;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF,CACF;AACF;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -18,11 +18,11 @@ var __spreadValues = (a, b) => {
|
|
|
18
18
|
};
|
|
19
19
|
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
20
20
|
import * as React from "react";
|
|
21
|
-
import React2, { useCallback, useEffect, useState } from "react";
|
|
21
|
+
import React2, { useCallback, useContext, useEffect, useState } from "react";
|
|
22
22
|
import { DSButton } from "@elliemae/ds-button";
|
|
23
23
|
import { DSPopperJS } from "@elliemae/ds-popperjs";
|
|
24
24
|
import styled from "styled-components";
|
|
25
|
-
import
|
|
25
|
+
import DataTableContext from "../DataTableContext";
|
|
26
26
|
import { DATA_TESTID } from "../configs/constants";
|
|
27
27
|
const FilterButton = styled.span`
|
|
28
28
|
display: inline-grid;
|
|
@@ -59,7 +59,7 @@ const FilterPopover = ({
|
|
|
59
59
|
hideFilterButton: true,
|
|
60
60
|
hideFilterMenu: true
|
|
61
61
|
};
|
|
62
|
-
const { patchHeaderFilterButtonAndMenu, patchHeader } =
|
|
62
|
+
const { patchHeaderFilterButtonAndMenu, patchHeader } = useContext(DataTableContext);
|
|
63
63
|
const isIconVisible = !hideFilterButton || !hideFilterMenu;
|
|
64
64
|
const isMenuOpen = !hideFilterMenu;
|
|
65
65
|
const handleClickOutsideMenu = (e) => {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../scripts/build/transpile/react-shim.js", "../../../src/exported-related/FilterPopover.tsx"],
|
|
4
|
-
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "/* eslint-disable react/prop-types */\n/* eslint-disable jsx-a11y/no-static-element-interactions */\nimport React, { MutableRefObject, useCallback, useEffect, useState } from 'react';\nimport { DSButton } from '@elliemae/ds-button';\nimport { DSPopperJS } from '@elliemae/ds-popperjs';\nimport styled from 'styled-components';\nimport
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;AAAA;ACEA;AACA;AACA;AACA;AACA;AACA;AAGA,MAAM,eAAe,OAAO;AAAA;AAAA,IAExB,CAAC,UAAW,MAAM,OAAO,yCAAyC;AAAA;AAGtE,MAAM,SAAS,OAAO,QAAQ;AAAA;AAAA;AAAA;AAK9B,MAAM,gBAAgB,OAAO;AAAA;AAAA;AAgB7B,MAAM,aAAa,CAAC,EAAE,SACpB,qCAAC;AAAA,EACC,eAAY;AAAA,EACZ,UAAU;AAAA,EACV,SAAS,CAAC,MAAM;AACd,MAAE,gBAAgB;AAClB,OAAG;AAAA,EACL;AAAA,CACF;AAGK,MAAM,gBAAyD,CAAC;AAAA,EACrE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,iBAAiB,MAAM;AAAA,EACvB,qBAAqB,MAAM;AAAA,EAC3B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,MACI;AACJ,QAAM,EAAE,kBAAkB,mBAAmB,eAAe;AAAA,IAC1D,kBAAkB;AAAA,IAClB,gBAAgB;AAAA,EAClB;AACA,QAAM,EAAE,gCAAgC,gBAAgB,
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "/* eslint-disable react/prop-types */\n/* eslint-disable jsx-a11y/no-static-element-interactions */\nimport React, { MutableRefObject, useCallback, useContext, useEffect, useState } from 'react';\nimport { DSButton } from '@elliemae/ds-button';\nimport { DSPopperJS } from '@elliemae/ds-popperjs';\nimport styled from 'styled-components';\nimport DataTableContext from '../DataTableContext';\nimport { DATA_TESTID } from '../configs/constants';\nimport { ReduxHeader, TypescriptColumn } from '../types/props';\n\nconst FilterButton = styled.span<{ hide: boolean }>`\n display: inline-grid;\n ${(props) => (props.hide ? 'opacity: 0; display: none; width: 0;' : '')}\n`;\n\nconst Button = styled(DSButton)`\n position: relative;\n justify-self: flex-end;\n`;\n\nconst PopperContent = styled.div`\n background-color: #fff;\n`;\ninterface FilterPopoverProps {\n column: TypescriptColumn;\n columnId: string;\n triggerIcon: JSX.Element;\n menuContent: JSX.Element;\n onTriggerClick?: (id: string, e: UIEvent) => void;\n onClickOutsideMenu?: (id: string, e: UIEvent) => void;\n reduxHeader: ReduxHeader;\n innerRef: MutableRefObject<HTMLDivElement>;\n ariaLabel: string;\n customStyles?: React.CSSProperties;\n}\n\nconst ButtonTrap = ({ cb }) => (\n <span\n aria-hidden=\"true\"\n tabIndex={0}\n onFocus={(e) => {\n e.stopPropagation();\n cb();\n }}\n />\n);\n\nexport const FilterPopover: React.ComponentType<FilterPopoverProps> = ({\n column,\n columnId,\n triggerIcon,\n menuContent,\n onTriggerClick = () => null,\n onClickOutsideMenu = () => null,\n reduxHeader,\n innerRef,\n ariaLabel,\n customStyles,\n}) => {\n const { hideFilterButton, hideFilterMenu } = reduxHeader || {\n hideFilterButton: true,\n hideFilterMenu: true,\n };\n const { patchHeaderFilterButtonAndMenu, patchHeader } = useContext(DataTableContext);\n const isIconVisible = !hideFilterButton || !hideFilterMenu;\n const isMenuOpen = !hideFilterMenu;\n\n const handleClickOutsideMenu = (e) => {\n onClickOutsideMenu(columnId, e);\n if (isMenuOpen) patchHeaderFilterButtonAndMenu(columnId, true);\n };\n\n useEffect(() => {\n const closeMenu = () => {\n patchHeaderFilterButtonAndMenu(columnId, true);\n };\n window.addEventListener('blur', closeMenu);\n\n return () => {\n window.removeEventListener('blur', closeMenu);\n };\n }, [columnId, patchHeaderFilterButtonAndMenu]);\n\n const handleTriggerClick = (e) => {\n onTriggerClick(columnId, e);\n patchHeaderFilterButtonAndMenu(columnId, false);\n e.stopPropagation();\n };\n\n const [referenceElement, setReferenceElement] = useState(null);\n\n const buttonTrapCallback = useCallback(() => {\n patchHeader(columnId, { hideFilterMenu: true, hideFilterButton: false });\n referenceElement?.focus();\n }, [columnId, patchHeader, referenceElement]);\n return (\n <div\n // This is here to prevent propagation, and not trigger the sort functionality\n onClick={(e) => e.stopPropagation()}\n onKeyDown={(e) => {\n e.stopPropagation();\n if (e.code === 'Escape') {\n patchHeader(columnId, { hideFilterMenu: true, hideFilterButton: false });\n referenceElement.focus();\n }\n // Stop propagation for some reason is not enough to prevent scrolling of the datatable\n // so we just prevent default behaviour in this case\n if (['ArrowUp', 'ArrowDown'].includes(e.code)) {\n e.preventDefault();\n }\n }}\n style={{ display: 'flex' }}\n >\n <FilterButton hide={!isIconVisible} data-testid={DATA_TESTID.DATA_TABLE_FILTER_BUTTON}>\n <Button\n onClick={handleTriggerClick}\n buttonType=\"text\"\n aria-label={ariaLabel}\n aria-hidden=\"true\"\n size=\"s\"\n leftIcon={triggerIcon}\n // implement treeview mergerefs\n innerRef={(_ref) => {\n if (isIconVisible) setReferenceElement(_ref);\n innerRef.current = _ref;\n }}\n tabIndex={reduxHeader?.withTabStops ? 0 : -1}\n />\n </FilterButton>\n {referenceElement && (\n <DSPopperJS\n referenceElement={referenceElement}\n showPopover={isMenuOpen}\n closeContextMenu={handleClickOutsideMenu}\n data-testid={DATA_TESTID.DATA_TABLE_FILTER_MENU_CONTENT}\n startPlacementPreference=\"bottom-end\"\n customOffset={[5, 4]}\n withoutArrow\n zIndex={10}\n withoutAnimation\n extraPopperStyles={{\n ...customStyles,\n minWidth: column.ref?.current?.offsetWidth ?? '0px',\n }}\n placementOrderPreference={['bottom-end']}\n >\n <PopperContent>\n <ButtonTrap cb={buttonTrapCallback} />\n {menuContent}\n <ButtonTrap cb={buttonTrapCallback} />\n </PopperContent>\n </DSPopperJS>\n )}\n </div>\n );\n};\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;AAAA;ACEA;AACA;AACA;AACA;AACA;AACA;AAGA,MAAM,eAAe,OAAO;AAAA;AAAA,IAExB,CAAC,UAAW,MAAM,OAAO,yCAAyC;AAAA;AAGtE,MAAM,SAAS,OAAO,QAAQ;AAAA;AAAA;AAAA;AAK9B,MAAM,gBAAgB,OAAO;AAAA;AAAA;AAgB7B,MAAM,aAAa,CAAC,EAAE,SACpB,qCAAC;AAAA,EACC,eAAY;AAAA,EACZ,UAAU;AAAA,EACV,SAAS,CAAC,MAAM;AACd,MAAE,gBAAgB;AAClB,OAAG;AAAA,EACL;AAAA,CACF;AAGK,MAAM,gBAAyD,CAAC;AAAA,EACrE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,iBAAiB,MAAM;AAAA,EACvB,qBAAqB,MAAM;AAAA,EAC3B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,MACI;AACJ,QAAM,EAAE,kBAAkB,mBAAmB,eAAe;AAAA,IAC1D,kBAAkB;AAAA,IAClB,gBAAgB;AAAA,EAClB;AACA,QAAM,EAAE,gCAAgC,gBAAgB,WAAW,gBAAgB;A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AAA,IACX,cAAY;AAAA,IACZ,eAAY;AAAA,IACZ,MAAK;AAAA,IACL,UAAU;AAAA,IAEV,UAAU,CAAC,SAAS;AAClB,UAAI;AAAe,4BAAoB,IAAI;AAC3C,eAAS,UAAU;AAAA,IACrB;AAAA,IACA,UAAU,aAAa,eAAe,IAAI;AAAA,GAC5C,CACF,GACC,oBACC,qCAAC;AAAA,IACC;AAAA,IACA,aAAa;AAAA,IACb,kBAAkB;AAAA,IAClB,eAAa,YAAY;AAAA,IACzB,0BAAyB;AAAA,IACzB,cAAc,CAAC,GAAG,CAAC;AAAA,IACnB,cAAY;AAAA,IACZ,QAAQ;AAAA,IACR,kBAAgB;AAAA,IAChB,mBAAmB,iCACd,eADc;AAAA,MAEjB,UAAU,OAAO,KAAK,SAAS,eAAe;AAAA,IAChD;AAAA,IACA,0BAA0B,CAAC,YAAY;AAAA,KAEvC,qCAAC,qBACC,qCAAC;AAAA,IAAW,IAAI;AAAA,GAAoB,GACnC,aACD,qCAAC;AAAA,IAAW,IAAI;AAAA,GAAoB,CACtC,CACF,CAEJ;AAEJ;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -47,7 +47,7 @@ const DefaultRowContentRenderer = (props) => {
|
|
|
47
47
|
backgroundColor = "white",
|
|
48
48
|
dropIndicatorPosition,
|
|
49
49
|
focusedRowId,
|
|
50
|
-
|
|
50
|
+
drilldownRowId,
|
|
51
51
|
compact
|
|
52
52
|
} = props;
|
|
53
53
|
const rowRef = useRef(null);
|
|
@@ -108,7 +108,7 @@ const DefaultRowContentRenderer = (props) => {
|
|
|
108
108
|
onMouseDown: handleSelectDisableRow
|
|
109
109
|
}), /* @__PURE__ */ React2.createElement(Cells, {
|
|
110
110
|
row,
|
|
111
|
-
isRowSelected:
|
|
111
|
+
isRowSelected: drilldownRowId === row.uid,
|
|
112
112
|
isDragOverlay,
|
|
113
113
|
key: row.uid
|
|
114
114
|
})), isExpandable && row.isExpanded && DetailsView && /* @__PURE__ */ React2.createElement(DetailsWrapper, null, /* @__PURE__ */ React2.createElement(DetailsView, {
|
|
@@ -130,7 +130,7 @@ const DefaultRowContentRenderer = (props) => {
|
|
|
130
130
|
isDragOverlay,
|
|
131
131
|
noSelectionColumn,
|
|
132
132
|
handleSelectDisableRow,
|
|
133
|
-
|
|
133
|
+
drilldownRowId,
|
|
134
134
|
detailsIndent
|
|
135
135
|
]);
|
|
136
136
|
return PureRowContent;
|