@openedx/paragon 22.20.2 → 22.20.4

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.
@@ -1,17 +1,21 @@
1
1
  import React, { useContext, useMemo } from 'react';
2
+ import { useIntl } from 'react-intl';
2
3
  import DataTableContext from './DataTableContext';
3
4
  import { DropdownButton } from '../Dropdown';
4
5
  import useWindowSize from '../hooks/useWindowSizeHook';
5
6
  import breakpoints from '../utils/breakpoints';
7
+ import messages from './messages';
6
8
 
7
9
  /** The first filter will be as an input, additional filters will be available in a dropdown. */
8
10
  function DropdownFilters() {
11
+ const intl = useIntl();
9
12
  const {
10
13
  width
11
14
  } = useWindowSize();
12
15
  const {
13
16
  columns,
14
- numBreakoutFilters
17
+ numBreakoutFilters,
18
+ filtersTitle
15
19
  } = useContext(DataTableContext);
16
20
  const [breakoutFilters, otherFilters] = useMemo(() => {
17
21
  if (!columns) {
@@ -26,6 +30,7 @@ function DropdownFilters() {
26
30
  const dropdownFilters = availableFilters.slice(numberOfBreakoutFilters);
27
31
  return [boFilters, dropdownFilters];
28
32
  }, [columns, width, numBreakoutFilters]);
33
+ const dropdownTitle = filtersTitle || intl.formatMessage(messages.filtersDropdownTitle);
29
34
  return /*#__PURE__*/React.createElement("div", {
30
35
  className: "pgn__data-table-filters"
31
36
  }, breakoutFilters.length > 0 && breakoutFilters.map(column => /*#__PURE__*/React.createElement("div", {
@@ -34,7 +39,7 @@ function DropdownFilters() {
34
39
  }, column.render('Filter'))), otherFilters.length > 0 && /*#__PURE__*/React.createElement(DropdownButton, {
35
40
  variant: "outline-primary",
36
41
  id: "table-filters-dropdown",
37
- title: "Filters"
42
+ title: dropdownTitle
38
43
  }, otherFilters.map(column => /*#__PURE__*/React.createElement("div", {
39
44
  key: column.Header,
40
45
  className: "pgn__data-table-filters-dropdown-item"
@@ -1 +1 @@
1
- {"version":3,"file":"DropdownFilters.js","names":["React","useContext","useMemo","DataTableContext","DropdownButton","useWindowSize","breakpoints","DropdownFilters","width","columns","numBreakoutFilters","breakoutFilters","otherFilters","availableFilters","filter","column","canFilter","small","minWidth","numberOfBreakoutFilters","boFilters","slice","dropdownFilters","createElement","className","length","map","key","Header","render","variant","id","title"],"sources":["../../src/DataTable/DropdownFilters.jsx"],"sourcesContent":["import React, { useContext, useMemo } from 'react';\nimport DataTableContext from './DataTableContext';\nimport { DropdownButton } from '../Dropdown';\nimport useWindowSize from '../hooks/useWindowSizeHook';\nimport breakpoints from '../utils/breakpoints';\n\n/** The first filter will be as an input, additional filters will be available in a dropdown. */\nfunction DropdownFilters() {\n const { width } = useWindowSize();\n const { columns, numBreakoutFilters } = useContext(DataTableContext);\n\n const [breakoutFilters, otherFilters] = useMemo(() => {\n if (!columns) {\n return [[], []];\n }\n const availableFilters = columns.filter((column) => column.canFilter);\n if (width < breakpoints.small.minWidth) {\n return [[], availableFilters];\n }\n\n const numberOfBreakoutFilters = numBreakoutFilters || 1;\n const boFilters = availableFilters.slice(0, numberOfBreakoutFilters);\n const dropdownFilters = availableFilters.slice(numberOfBreakoutFilters);\n\n return [boFilters, dropdownFilters];\n }, [columns, width, numBreakoutFilters]);\n\n return (\n <div className=\"pgn__data-table-filters\">\n {breakoutFilters.length > 0 && breakoutFilters.map((column) => (\n <div className=\"pgn__data-table-filters-breakout-filter\" key={column.Header}>\n {column.render('Filter')}\n </div>\n ))}\n {otherFilters.length > 0 && (\n <DropdownButton variant=\"outline-primary\" id=\"table-filters-dropdown\" title=\"Filters\">\n {otherFilters.map((column) => (\n <div\n key={column.Header}\n className=\"pgn__data-table-filters-dropdown-item\"\n >\n {column.render('Filter')}\n </div>\n ))}\n </DropdownButton>\n )}\n </div>\n );\n}\n\nexport default DropdownFilters;\n"],"mappings":"AAAA,OAAOA,KAAK,IAAIC,UAAU,EAAEC,OAAO,QAAQ,OAAO;AAClD,OAAOC,gBAAgB,MAAM,oBAAoB;AACjD,SAASC,cAAc,QAAQ,aAAa;AAC5C,OAAOC,aAAa,MAAM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uB,aAAA,CAACnB,cAAc;IAAC0B,OAAO,EAAC,iBAAiB;IAACC,EAAE,EAAC,wBAAwB;IAACC,KAAK,EAAC;EAAS,GAClFpB,YAAY,CAACc,GAAG,CAAEX,MAAM,iBACvBf,KAAA,CAAAuB,aAAA;IACEI,GAAG,EAAEZ,MAAM,CAACa,MAAO;IACnBJ,SAAS,EAAC;EAAuC,GAEhDT,MAAM,CAACc,MAAM,CAAC,QAAQ,CACpB,CACN,CACa,CAEf,CAAC;AAEV;AAEA,eAAetB,eAAe","ignoreList":[]}
1
+ {"version":3,"file":"DropdownFilters.js","names":["React","useContext","useMemo","useIntl","DataTableContext","DropdownButton","useWindowSize","breakpoints","messages","DropdownFilters","intl","width","columns","numBreakoutFilters","filtersTitle","breakoutFilters","otherFilters","availableFilters","filter","column","canFilter","small","minWidth","numberOfBreakoutFilters","boFilters","slice","dropdownFilters","dropdownTitle","formatMessage","filtersDropdownTitle","createElement","className","length","map","key","Header","render","variant","id","title"],"sources":["../../src/DataTable/DropdownFilters.jsx"],"sourcesContent":["import React, { useContext, useMemo } from 'react';\nimport { useIntl } from 'react-intl';\nimport DataTableContext from './DataTableContext';\nimport { DropdownButton } from '../Dropdown';\nimport useWindowSize from '../hooks/useWindowSizeHook';\nimport breakpoints from '../utils/breakpoints';\nimport messages from './messages';\n\n/** The first filter will be as an input, additional filters will be available in a dropdown. */\nfunction DropdownFilters() {\n const intl = useIntl();\n const { width } = useWindowSize();\n const {\n columns, numBreakoutFilters, filtersTitle,\n } = useContext(DataTableContext);\n\n const [breakoutFilters, otherFilters] = useMemo(() => {\n if (!columns) {\n return [[], []];\n }\n const availableFilters = columns.filter((column) => column.canFilter);\n if (width < breakpoints.small.minWidth) {\n return [[], availableFilters];\n }\n\n const numberOfBreakoutFilters = numBreakoutFilters || 1;\n const boFilters = availableFilters.slice(0, numberOfBreakoutFilters);\n const dropdownFilters = availableFilters.slice(numberOfBreakoutFilters);\n\n return [boFilters, dropdownFilters];\n }, [columns, width, numBreakoutFilters]);\n\n const dropdownTitle = filtersTitle || intl.formatMessage(messages.filtersDropdownTitle);\n\n return (\n <div className=\"pgn__data-table-filters\">\n {breakoutFilters.length > 0 && breakoutFilters.map((column) => (\n <div className=\"pgn__data-table-filters-breakout-filter\" key={column.Header}>\n {column.render('Filter')}\n </div>\n ))}\n {otherFilters.length > 0 && (\n <DropdownButton variant=\"outline-primary\" id=\"table-filters-dropdown\" title={dropdownTitle}>\n {otherFilters.map((column) => (\n <div\n key={column.Header}\n className=\"pgn__data-table-filters-dropdown-item\"\n >\n {column.render('Filter')}\n </div>\n ))}\n </DropdownButton>\n )}\n </div>\n );\n}\n\nexport default DropdownFilters;\n"],"mappings":"AAAA,OAAOA,KAAK,IAAIC,UAAU,EAAEC,OAAO,QAAQ,OAAO;AAClD,SAASC,OAAO,QAAQ,YAAY;AACpC,OAAOC,gBAAgB,MAAM,oBAAoB;AACjD,SAASC,cAAc,QAAQ,aAAa;AAC5C,OAAOC,aAAa,MAAM,4BAA4B;AACtD,OAAOC,WAAW,MAAM,sBAAsB;AAC9C,OAAOC,QAAQ,MAAM,YAAY;;AAEjC;AACA,SAASC,eAAeA,CAAA,EAAG;EACzB,MAAMC,IAAI,GAAGP,OAAO,CAAC,CAAC;EACtB,MAAM;IAAEQ;EAAM,CAAC,GAAGL,aAAa,CAAC,CAAC;EACjC,MAAM;IACJM,OAAO;IAAEC,kBAAkB;IAAEC;EAC/B,CAAC,GAAGb,UAAU,CAACG,gBAAgB,CAAC;EAEhC,MAAM,CAACW,eAAe,EAAEC,YAAY,CAAC,GAAGd,OAAO,CAAC,MAAM;IACpD,IAAI,CAACU,OAAO,EAAE;MACZ,OAAO,CAAC,EAAE,EAAE,EAAE,CAAC;IACjB;IACA,MAAMK,gBAAgB,GAAGL,OAAO,CAACM,MAAM,CAAEC,MAAM,IAAKA,MAAM,CAACC,SAAS,CAAC;IACrE,IAAIT,KAAK,GAAGJ,WAAW,CAACc,KAAK,CAACC,QAAQ,EAAE;MACtC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59
59
  showFiltersInSidebar,
60
+ filtersTitle,
60
61
  dataViewToggleOptions,
61
62
  disableElevation,
62
63
  isLoading,
@@ -220,13 +221,16 @@ function DataTable(_ref) {
220
221
  manualSelectColumn,
221
222
  maxSelectedRows,
222
223
  onMaxSelectedRows,
224
+ filtersTitle,
223
225
  ...selectionProps,
224
226
  ...selectionActions,
225
227
  ...props
226
228
  };
227
229
  return /*#__PURE__*/React.createElement(DataTableContext.Provider, {
228
230
  value: enhancedInstance
229
- }, /*#__PURE__*/React.createElement(DataTableLayout, null, /*#__PURE__*/React.createElement("div", {
231
+ }, /*#__PURE__*/React.createElement(DataTableLayout, {
232
+ filtersTitle: filtersTitle
233
+ }, /*#__PURE__*/React.createElement("div", {
230
234
  className: classNames('pgn__data-table-wrapper', {
231
235
  'hide-shadow': !!disableElevation
232
236
  })
@@ -257,6 +261,7 @@ DataTable.defaultProps = {
257
261
  FilterStatusComponent: FilterStatus,
258
262
  RowStatusComponent: RowStatus,
259
263
  showFiltersInSidebar: false,
264
+ filtersTitle: undefined,
260
265
  dataViewToggleOptions: {
261
266
  isDataViewToggleEnabled: false,
262
267
  onDataViewToggle: () => {},
@@ -396,6 +401,8 @@ DataTable.propTypes = {
396
401
  children: PropTypes.node,
397
402
  /** If true filters will be shown on sidebar instead */
398
403
  showFiltersInSidebar: PropTypes.bool,
404
+ /** Title of the filters section */
405
+ filtersTitle: PropTypes.string,
399
406
  /** options for data view toggle */
400
407
  dataViewToggleOptions: PropTypes.shape({
401
408
  /** Whether to show a toggle button group which allows view switching between card and table views */
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["React","useEffect","useMemo","useReducer","PropTypes","useTable","useMountedLayoutEffect","classNames","Table","getVisibleColumns","requiredWhen","requiredWhenNot","getTableArgs","TableControlBar","EmptyTableContent","TableFooter","BulkActions","DropdownFilters","FilterStatus","RowStatus","SelectionStatus","ControlledSelectionStatus","SmartStatus","TableFilters","TableHeaderCell","TableCell","TableHeaderRow","TablePagination","TablePaginationMinimal","DataTableContext","TableActions","ControlledSelect","ControlledSelectHeader","DataTableLayout","ExpandAll","ExpandRow","useDataTableSelections","useSelectionActions","selectionsReducer","initialState","initialSelectionsState","DataTable","_ref","columns","data","defaultColumnValues","additionalColumns","isSelectable","isPaginated","manualPagination","pageCount","itemCount","isFilterable","manualFilters","fetchData","isSortable","manualSortBy","isExpandable","renderRowSubComponent","bulkActions","tableActions","numBreakoutFilters","initialTableOptions","EmptyTableComponent","manualSelectColumn","showFiltersInSidebar","dataViewToggleOptions","disableElevation","isLoading","children","onSelectedRowsChanged","maxSelectedRows","onMaxSelectedRows","props","defaultColumn","tableOptions","updatedTableOptions","stateReducer","newState","action","previousState","type","value","selectedRowIds","rowIndex","parseInt","id","selectedRowsOrdered","newSelectedRowsOrdered","filter","item","selections","selectionsDispatch","tableArgs","push","hooks","visibleColumns","selectionProps","selectedRows","length","selectedRowsById","forEach","row","useControlledState","state","selectedFlatRows","controlledTableSelections","instance","pageSize","tableStatePageSize","pageIndex","tableStatePageIndex","sortBy","tableStateSortBy","filters","tableStateFilters","tableStateSelectedRowIds","selectionActions","page","isAllPageRowsSelected","enhancedInstance","createElement","Provider","className","Fragment","content","defaultProps","undefined","SelectionStatusComponent","FilterStatusComponent","RowStatusComponent","isDataViewToggleEnabled","onDataViewToggle","defaultActiveStateValue","togglePlacement","propTypes","arrayOf","shape","Header","oneOfType","elementType","node","isRequired","accessor","string","Cell","Filter","filterChoices","name","number","bool","disableSortBy","func","buttonText","handleClick","variant","disabled","element","oneOf","EmptyTable"],"sources":["../../src/DataTable/index.jsx"],"sourcesContent":["import React, {\n useEffect, useMemo, useReducer,\n} from 'react';\nimport PropTypes from 'prop-types';\nimport { useTable, useMountedLayoutEffect } from 'react-table';\n\nimport classNames from 'classnames';\nimport Table from './Table';\nimport getVisibleColumns from './utils/getVisibleColumns';\nimport { requiredWhen, requiredWhenNot } from '../utils/propTypes';\nimport getTableArgs from './utils/getTableArgs';\nimport TableControlBar from './TableControlBar';\nimport EmptyTableContent from './EmptyTable';\nimport TableFooter from './TableFooter';\nimport BulkActions from './BulkActions';\nimport DropdownFilters from './DropdownFilters';\nimport FilterStatus from './FilterStatus';\nimport RowStatus from './RowStatus';\nimport SelectionStatus from './selection/SelectionStatus';\nimport ControlledSelectionStatus from './selection/ControlledSelectionStatus';\nimport SmartStatus from './SmartStatus';\nimport TableFilters from './TableFilters';\nimport TableHeaderCell from './TableHeaderCell';\nimport TableCell from './TableCell';\nimport TableHeaderRow from './TableHeaderRow';\nimport TablePagination from './TablePagination';\nimport TablePaginationMinimal from './TablePaginationMinimal';\nimport DataTableContext from './DataTableContext';\nimport TableActions from './TableActions';\nimport ControlledSelect from './selection/ControlledSelect';\nimport ControlledSelectHeader from './selection/ControlledSelectHeader';\nimport DataTableLayout from './DataTableLayout';\nimport ExpandAll from './ExpandAll';\nimport ExpandRow from './ExpandRow';\n\nimport { useDataTableSelections, useSelectionActions } from './hooks';\nimport selectionsReducer, {\n initialState as initialSelectionsState,\n} from './selection/data/reducer';\n\nfunction DataTable({\n columns, data, defaultColumnValues, additionalColumns, isSelectable,\n isPaginated, manualPagination, pageCount, itemCount,\n isFilterable, manualFilters, fetchData, initialState,\n isSortable, manualSortBy,\n isExpandable, renderRowSubComponent,\n bulkActions, tableActions, numBreakoutFilters,\n initialTableOptions,\n EmptyTableComponent,\n manualSelectColumn,\n showFiltersInSidebar,\n dataViewToggleOptions,\n disableElevation,\n isLoading,\n children,\n onSelectedRowsChanged,\n maxSelectedRows,\n onMaxSelectedRows,\n ...props\n}) {\n const defaultColumn = useMemo(\n () => (defaultColumnValues),\n [defaultColumnValues],\n );\n const tableOptions = useMemo(() => {\n const updatedTableOptions = {\n stateReducer: (newState, action, previousState) => {\n switch (action.type) {\n // Note: we override the `toggleAllRowsSelected` action\n // from react-table because it only clears the selections on the\n // currently visible page; it does not clear the `selectedRowIds`\n // as we would expect for selections on different pages. Instead, we\n // force `selectedRowIds` to be cleared when `toggleAllRowsSelected(false)`\n // is called.\n case 'toggleAllRowsSelected': {\n if (action.value) {\n return newState;\n }\n return {\n ...newState,\n selectedRowIds: {},\n };\n }\n /**\n * Note: We override the `toggleRowSelected` action from react-table\n * because we need to preserve the order of the selected rows.\n * while `selectedRowIds` is an object that contains the selected rows as key-value pairs,\n * it does not maintain the order of selection. Therefore, we have added the `selectedRowsOrdered` property\n * to keep track of the order in which the rows were selected.\n */\n case 'toggleRowSelected': {\n const rowIndex = parseInt(action.id, 10);\n const { selectedRowsOrdered = [] } = previousState;\n\n let newSelectedRowsOrdered;\n if (action.value) {\n newSelectedRowsOrdered = [...selectedRowsOrdered, rowIndex];\n } else {\n newSelectedRowsOrdered = selectedRowsOrdered.filter((item) => item !== rowIndex);\n }\n\n return {\n ...newState,\n selectedRowsOrdered: newSelectedRowsOrdered,\n };\n }\n default:\n return newState;\n }\n },\n ...initialTableOptions,\n };\n return {\n columns,\n data,\n defaultColumn,\n manualFilters,\n manualPagination,\n manualSortBy,\n initialState,\n ...updatedTableOptions,\n };\n }, [initialTableOptions, columns, data, defaultColumn, manualFilters, manualPagination, manualSortBy, initialState]);\n\n const [selections, selectionsDispatch] = useReducer(selectionsReducer, initialSelectionsState);\n\n if (isPaginated && manualPagination) {\n // pageCount is required when pagination is manual, if it's not there passing -1 as per react-table docs\n tableOptions.pageCount = pageCount || -1;\n }\n\n // NB: Table args *must* be in a particular order\n const tableArgs = getTableArgs({\n tableOptions, isFilterable, isSelectable, isPaginated, isSortable, isExpandable,\n });\n // adds selection column and action columns as necessary\n tableArgs.push(hooks => {\n hooks.visibleColumns.push(\n visibleColumns => getVisibleColumns(isSelectable, visibleColumns, additionalColumns, manualSelectColumn),\n );\n });\n\n // Pass any controlled selections from context to the appropriate ``useTable`` arguments to maintain\n // correct selection states on rows, both from a data perspective and in the UI.\n const selectionProps = {};\n const { selectedRows } = selections;\n if (selectedRows.length > 0) {\n const selectedRowsById = {};\n selectedRows.forEach((row) => {\n selectedRowsById[row.id] = true;\n });\n tableArgs.push(hooks => {\n hooks.useControlledState.push(\n (state) => ({ ...state, selectedRowIds: selectedRowsById }),\n );\n });\n selectionProps.selectedFlatRows = selectedRows;\n }\n const controlledTableSelections = [selections, selectionsDispatch];\n\n // Use the state and functions returned from useTable to build your UI\n const instance = useTable(...tableArgs);\n\n const {\n pageSize: tableStatePageSize,\n pageIndex: tableStatePageIndex,\n sortBy: tableStateSortBy,\n filters: tableStateFilters,\n selectedRowIds: tableStateSelectedRowIds,\n } = instance.state;\n\n useEffect(() => {\n if (fetchData) {\n fetchData({\n pageSize: tableStatePageSize,\n pageIndex: tableStatePageIndex,\n sortBy: tableStateSortBy,\n filters: tableStateFilters,\n });\n }\n }, [fetchData, tableStatePageSize, tableStatePageIndex, tableStateSortBy, tableStateFilters]);\n\n useMountedLayoutEffect(() => {\n if (onSelectedRowsChanged) {\n onSelectedRowsChanged(tableStateSelectedRowIds);\n }\n }, [tableStateSelectedRowIds, onSelectedRowsChanged]);\n\n const selectionActions = useSelectionActions(instance, controlledTableSelections);\n\n useDataTableSelections({\n selections,\n selectionsDispatch,\n itemCount,\n selectedRows,\n page: instance.page,\n isAllPageRowsSelected: instance.isAllPageRowsSelected,\n });\n\n const enhancedInstance = {\n ...instance,\n manualFilters,\n itemCount,\n numBreakoutFilters,\n bulkActions,\n tableActions,\n controlledTableSelections,\n showFiltersInSidebar,\n dataViewToggleOptions,\n renderRowSubComponent,\n disableElevation,\n isLoading,\n isSelectable,\n isPaginated,\n manualSelectColumn,\n maxSelectedRows,\n onMaxSelectedRows,\n ...selectionProps,\n ...selectionActions,\n ...props,\n };\n\n return (\n <DataTableContext.Provider value={enhancedInstance}>\n <DataTableLayout>\n <div className={classNames('pgn__data-table-wrapper', {\n 'hide-shadow': !!disableElevation,\n })}\n >\n {children || (\n <>\n <TableControlBar />\n <Table />\n <EmptyTableComponent content=\"No results found\" />\n <TableFooter />\n </>\n )}\n </div>\n </DataTableLayout>\n </DataTableContext.Provider>\n );\n}\n\nDataTable.defaultProps = {\n additionalColumns: [],\n defaultColumnValues: {},\n isFilterable: false,\n isPaginated: false,\n isSelectable: false,\n isSortable: false,\n manualFilters: false,\n manualPagination: false,\n manualSortBy: false,\n fetchData: null,\n initialState: {},\n initialTableOptions: {},\n EmptyTableComponent: EmptyTableContent,\n children: null,\n bulkActions: [],\n tableActions: [],\n numBreakoutFilters: 1,\n manualSelectColumn: undefined,\n SelectionStatusComponent: SelectionStatus,\n FilterStatusComponent: FilterStatus,\n RowStatusComponent: RowStatus,\n showFiltersInSidebar: false,\n dataViewToggleOptions: {\n isDataViewToggleEnabled: false,\n onDataViewToggle: () => {},\n defaultActiveStateValue: 'card',\n togglePlacement: 'left',\n },\n disableElevation: false,\n renderRowSubComponent: undefined,\n isExpandable: false,\n isLoading: false,\n onSelectedRowsChanged: undefined,\n maxSelectedRows: undefined,\n onMaxSelectedRows: undefined,\n};\n\nDataTable.propTypes = {\n /** Definition of table columns */\n columns: PropTypes.arrayOf(PropTypes.shape({\n /** User visible column name */\n Header: PropTypes.oneOfType([PropTypes.elementType, PropTypes.node]).isRequired,\n /** String used to access the correct cell data for this column */\n accessor: requiredWhenNot(PropTypes.string, 'Cell'),\n /** Specifies a function that receives `row` as argument and returns cell content */\n Cell: PropTypes.oneOfType([PropTypes.elementType, PropTypes.node]),\n /** Specifies filter component */\n Filter: PropTypes.elementType,\n /** Specifies filter type */\n filter: PropTypes.string,\n /** Specifies filter choices */\n filterChoices: PropTypes.arrayOf(PropTypes.shape({\n name: PropTypes.string,\n number: PropTypes.number,\n value: PropTypes.string,\n })),\n })).isRequired,\n /** Data to be displayed in the table */\n data: PropTypes.arrayOf(PropTypes.shape({})).isRequired,\n /** table rows can be selected */\n isSelectable: PropTypes.bool,\n /** Alternate column for selecting rows. See react table useSort docs for more information */\n manualSelectColumn: PropTypes.shape({\n id: PropTypes.string.isRequired,\n Header: PropTypes.oneOfType([PropTypes.elementType, PropTypes.node]).isRequired,\n Cell: PropTypes.oneOfType([PropTypes.elementType, PropTypes.node]),\n disableSortBy: PropTypes.bool.isRequired,\n }),\n /** Table columns can be sorted */\n isSortable: PropTypes.bool,\n /** Indicates that sorting will be done via backend API. A fetchData function must be provided */\n manualSortBy: PropTypes.bool,\n /** Paginate the table */\n isPaginated: PropTypes.bool,\n /** Indicates that pagination will be done manually. A fetchData function must be provided */\n manualPagination: PropTypes.bool,\n // eslint-disable-next-line react/require-default-props\n pageCount: requiredWhen(PropTypes.number, 'manualPagination'),\n /** Table rows can be filtered, using a default filter in the default column values, or in the column definition */\n isFilterable: PropTypes.bool,\n /** Indicates that filtering will be done via a backend API. A fetchData function must be provided */\n manualFilters: PropTypes.bool,\n\n /** defaults that will be set on each column. Will be overridden by individual column values */\n defaultColumnValues: PropTypes.shape({\n /** A default filter component for the column */\n Filter: PropTypes.elementType,\n }),\n /** Actions or other additional non-data columns can be added here */\n additionalColumns: PropTypes.arrayOf(PropTypes.shape({\n /** id must be unique from other columns ids */\n id: PropTypes.string.isRequired,\n /** column header that will be displayed to the user */\n Header: PropTypes.oneOfType([PropTypes.elementType, PropTypes.node]),\n /** Component that renders in the added column. It will receive the row as a prop */\n Cell: PropTypes.oneOfType([PropTypes.elementType, PropTypes.node]),\n })),\n /** Function that will fetch table data. Called when page size, page index or filters change.\n * Meant to be used with manual filters and pagination */\n fetchData: PropTypes.func,\n /** Initial state passed to react-table's documentation https://github.com/TanStack/table/blob/v7/docs/src/pages/docs/api/useTable.md */\n initialState: PropTypes.shape({\n pageSize: requiredWhen(PropTypes.number, 'isPaginated'),\n pageIndex: requiredWhen(PropTypes.number, 'isPaginated'),\n filters: requiredWhen(PropTypes.arrayOf(PropTypes.shape()), 'manualFilters'),\n sortBy: requiredWhen(PropTypes.arrayOf(PropTypes.shape()), 'manualSortBy'),\n selectedRowIds: PropTypes.shape(),\n selectedRowsOrdered: PropTypes.arrayOf(PropTypes.number),\n }),\n /** Table options passed to react-table's useTable hook. Will override some options passed in to DataTable, such\n as: data, columns, defaultColumn, manualFilters, manualPagination, manualSortBy, and initialState */\n initialTableOptions: PropTypes.shape({}),\n /** Actions to be performed on the table. Called with the table instance. Not displayed if rows are selected. */\n itemCount: PropTypes.number.isRequired,\n /** Actions to be performed on selected rows of the table. Called with the selected rows.\n * Only displayed if rows are selected. */\n bulkActions: PropTypes.oneOfType([\n PropTypes.arrayOf(\n PropTypes.oneOfType([\n PropTypes.shape({\n /** Bulk action button text */\n buttonText: PropTypes.string.isRequired,\n /** handleClick will be passed the selected rows */\n handleClick: PropTypes.func.isRequired,\n /** classnames for button class */\n className: PropTypes.string,\n /** optional button variant; only relevant for the first two buttons */\n variant: PropTypes.string,\n /** disables button */\n disabled: PropTypes.bool,\n }),\n /** function passed selected items, should return action object */\n PropTypes.func,\n /** A custom component representing an action */\n PropTypes.element,\n ]),\n ),\n /** Function for rendering custom components */\n PropTypes.func,\n /** A custom component representing an action */\n PropTypes.element,\n ]),\n /** Function for rendering custom components, called with the table instance */\n tableActions: PropTypes.oneOfType([\n PropTypes.arrayOf(\n PropTypes.oneOfType([\n PropTypes.shape({\n /** Bulk action button text */\n buttonText: PropTypes.string.isRequired,\n /** handleClick will be passed the selected rows */\n handleClick: PropTypes.func.isRequired,\n /** classnames for button class */\n className: PropTypes.string,\n /** optional button variant; only relevant for the first two buttons */\n variant: PropTypes.string,\n /** disables button */\n disabled: PropTypes.bool,\n }),\n /** function passed table instance, should return action object */\n PropTypes.func,\n /** A custom component representing an action */\n PropTypes.element,\n ]),\n ),\n /** Function for rendering custom components */\n PropTypes.func,\n /** A custom component representing an action */\n PropTypes.element,\n ]),\n /** Number between one and four filters that can be shown on the top row. */\n numBreakoutFilters: PropTypes.oneOf([1, 2, 3, 4]),\n /** Component to be displayed when the table is empty */\n EmptyTableComponent: PropTypes.elementType,\n /** Component to be displayed for row status, ie, 10 of 20 rows. Displayed by default in the TableControlBar */\n RowStatusComponent: PropTypes.elementType,\n /** Component to be displayed for selection status. Displayed when there are selected rows and no active filters */\n SelectionStatusComponent: PropTypes.elementType,\n /** Component to be displayed for filter status. Displayed when there are active filters. */\n FilterStatusComponent: PropTypes.elementType,\n /** If children are not provided a table with control bar and footer will be rendered */\n children: PropTypes.node,\n /** If true filters will be shown on sidebar instead */\n showFiltersInSidebar: PropTypes.bool,\n /** options for data view toggle */\n dataViewToggleOptions: PropTypes.shape({\n /** Whether to show a toggle button group which allows view switching between card and table views */\n isDataViewToggleEnabled: PropTypes.bool,\n /** Callback invoked when the toggle buttons are clicked, with value of selected button passed in */\n onDataViewToggle: PropTypes.func,\n /** default value for toggle active state */\n defaultActiveStateValue: PropTypes.string,\n /** placement of toggle 'bottom' will push it to the bottom row in\n * actions section. Only 'left' and 'bottom' are supported */\n togglePlacement: PropTypes.string,\n }),\n /** Remove the default box shadow on the component */\n disableElevation: PropTypes.bool,\n /** A function that will render contents of expanded row, accepts `row` as a prop. */\n renderRowSubComponent: PropTypes.func,\n /** Indicates whether table supports expandable rows. */\n isExpandable: PropTypes.bool,\n /** Indicates whether the table should show loading states. */\n isLoading: PropTypes.bool,\n /** Callback function called when row selections change. */\n onSelectedRowsChanged: PropTypes.func,\n /** Indicates the max of rows selectable in the table. Requires isSelectable prop */\n maxSelectedRows: PropTypes.number,\n /** Callback after selected max rows. Requires isSelectable and maxSelectedRows props */\n onMaxSelectedRows: PropTypes.func,\n};\n\nDataTable.BulkActions = BulkActions;\nDataTable.EmptyTable = EmptyTableContent;\nDataTable.DropdownFilters = DropdownFilters;\nDataTable.FilterStatus = FilterStatus;\nDataTable.RowStatus = RowStatus;\nDataTable.SelectionStatus = SelectionStatus;\nDataTable.SmartStatus = SmartStatus;\nDataTable.Table = Table;\nDataTable.TableCell = TableCell;\nDataTable.TableControlBar = TableControlBar;\nDataTable.TableFilters = TableFilters;\nDataTable.TableFooter = TableFooter;\nDataTable.TableHeaderCell = TableHeaderCell;\nDataTable.TableHeaderRow = TableHeaderRow;\nDataTable.TablePagination = TablePagination;\nDataTable.TablePaginationMinimal = TablePaginationMinimal;\nDataTable.TableActions = TableActions;\nDataTable.ControlledSelectionStatus = ControlledSelectionStatus;\nDataTable.ControlledSelect = ControlledSelect;\nDataTable.ControlledSelectHeader = ControlledSelectHeader;\nDataTable.ExpandAll = ExpandAll;\nDataTable.ExpandRow = ExpandRow;\n\nexport default DataTable;\n"],"mappings":"AAAA,OAAOA,KAAK,IACVC,SAAS,EAAEC,OAAO,EAAEC,UAAU,QACzB,OAAO;AACd,OAAOC,SAAS,MAAM,YAAY;AAClC,SAASC,QAAQ,EAAEC,sBAAsB,QAAQ,aAAa;AAE9D,OAAOC,UAAU,MAAM,YAAY;AACnC,OAAOC,KAAK,MAAM,SAAS;AAC3B,OAAOC,iBAAiB,MAAM,2BAA2B;AACzD,SAASC,YAAY,EAAEC,eAAe,QAAQ,oBAAoB;AAClE,OAAOC,YAAY,MAAM,sBAAsB;AAC/C,OAAOC,eAAe,MAAM,mBAAmB;AAC/C,OAAOC,iBAAiB,MAAM,cAAc;AAC5C,OAAOC,WAAW,MAAM,eAAe;AACvC,OAAOC,WAAW,MAAM,eAAe;AACvC,OAAOC,eAAe,MAAM,mBAAmB;AAC/C,OAAOC,YAAY,MAAM,gBAAgB;AACzC,OAAOC,SAAS,MAAM,aAAa;AACnC,OAAOC,eAAe,MAAM,6BAA6B;AACzD,OAAOC,yBAAyB,MAAM,uCAAuC;AAC7E,OAAOC,WAAW,MAAM,eAAe;AACvC,OAAOC,YAAY,MAAM,gBAAgB;AACzC,OAAOC,eAAe,MAAM,mBAAmB;AAC/C,OAAOC,SAAS,MAAM,aAAa;AACnC,OAAOC,cAAc,MAAM,kBAAkB;AAC7C,OAAOC,eAAe,MAAM,mBAAmB;AAC/C,OAAOC,sBAAsB,MAAM,0BAA0B;AAC7D,OAAOC,gBAAgB,MAAM,oBAAoB;AACjD,OAAOC,YAAY,MAAM,gBAAgB;AACzC,OAAOC,gBAAgB,MAAM,8BAA8B;AAC3D,OAAOC,sBAAsB,MAAM,oCAAoC;AACvE,OAAOC,eAAe,MAAM,mBAAmB;AAC/C,OAAOC,SAAS,MA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":3,"file":"index.js","names":["React","useEffect","useMemo","useReducer","PropTypes","useTable","useMountedLayoutEffect","classNames","Table","getVisibleColumns","requiredWhen","requiredWhenNot","getTableArgs","TableControlBar","EmptyTableContent","TableFooter","BulkActions","DropdownFilters","FilterStatus","RowStatus","SelectionStatus","ControlledSelectionStatus","SmartStatus","TableFilters","TableHeaderCell","TableCell","TableHeaderRow","TablePagination","TablePaginationMinimal","DataTableContext","TableActions","ControlledSelect","ControlledSelectHeader","DataTableLayout","ExpandAll","ExpandRow","useDataTableSelections","useSelectionActions","selectionsReducer","initialState","initialSelectionsState","DataTable","_ref","columns","data","defaultColumnValues","additionalColumns","isSelectable","isPaginated","manualPagination","pageCount","itemCount","isFilterable","manualFilters","fetchData","isSortable","manualSortBy","isExpandable","renderRowSubComponent","bulkActions","tableActions","numBreakoutFilters","initialTableOptions","EmptyTableComponent","manualSelectColumn","showFiltersInSidebar","filtersTitle","dataViewToggleOptions","disableElevation","isLoading","children","onSelectedRowsChanged","maxSelectedRows","onMaxSelectedRows","props","defaultColumn","tableOptions","updatedTableOptions","stateReducer","newState","action","previousState","type","value","selectedRowIds","rowIndex","parseInt","id","selectedRowsOrdered","newSelectedRowsOrdered","filter","item","selections","selectionsDispatch","tableArgs","push","hooks","visibleColumns","selectionProps","selectedRows","length","selectedRowsById","forEach","row","useControlledState","state","selectedFlatRows","controlledTableSelections","instance","pageSize","tableStatePageSize","pageIndex","tableStatePageIndex","sortBy","tableStateSortBy","filters","tableStateFilters","tableStateSelectedRowIds","selectionActions","page","isAllPageRowsSelected","enhancedInstance","createElement","Provider","className","Fragment","content","defaultProps","undefined","SelectionStatusComponent","FilterStatusComponent","RowStatusComponent","isDataViewToggleEnabled","onDataViewToggle","defaultActiveStateValue","togglePlacement","propTypes","arrayOf","shape","Header","oneOfType","elementType","node","isRequired","accessor","string","Cell","Filter","filterChoices","name","number","bool","disableSortBy","func","buttonText","handleClick","variant","disabled","element","oneOf","EmptyTable"],"sources":["../../src/DataTable/index.jsx"],"sourcesContent":["import React, {\n useEffect, useMemo, useReducer,\n} from 'react';\nimport PropTypes from 'prop-types';\nimport { useTable, useMountedLayoutEffect } from 'react-table';\n\nimport classNames from 'classnames';\nimport Table from './Table';\nimport getVisibleColumns from './utils/getVisibleColumns';\nimport { requiredWhen, requiredWhenNot } from '../utils/propTypes';\nimport getTableArgs from './utils/getTableArgs';\nimport TableControlBar from './TableControlBar';\nimport EmptyTableContent from './EmptyTable';\nimport TableFooter from './TableFooter';\nimport BulkActions from './BulkActions';\nimport DropdownFilters from './DropdownFilters';\nimport FilterStatus from './FilterStatus';\nimport RowStatus from './RowStatus';\nimport SelectionStatus from './selection/SelectionStatus';\nimport ControlledSelectionStatus from './selection/ControlledSelectionStatus';\nimport SmartStatus from './SmartStatus';\nimport TableFilters from './TableFilters';\nimport TableHeaderCell from './TableHeaderCell';\nimport TableCell from './TableCell';\nimport TableHeaderRow from './TableHeaderRow';\nimport TablePagination from './TablePagination';\nimport TablePaginationMinimal from './TablePaginationMinimal';\nimport DataTableContext from './DataTableContext';\nimport TableActions from './TableActions';\nimport ControlledSelect from './selection/ControlledSelect';\nimport ControlledSelectHeader from './selection/ControlledSelectHeader';\nimport DataTableLayout from './DataTableLayout';\nimport ExpandAll from './ExpandAll';\nimport ExpandRow from './ExpandRow';\n\nimport { useDataTableSelections, useSelectionActions } from './hooks';\nimport selectionsReducer, {\n initialState as initialSelectionsState,\n} from './selection/data/reducer';\n\nfunction DataTable({\n columns, data, defaultColumnValues, additionalColumns, isSelectable,\n isPaginated, manualPagination, pageCount, itemCount,\n isFilterable, manualFilters, fetchData, initialState,\n isSortable, manualSortBy,\n isExpandable, renderRowSubComponent,\n bulkActions, tableActions, numBreakoutFilters,\n initialTableOptions,\n EmptyTableComponent,\n manualSelectColumn,\n showFiltersInSidebar,\n filtersTitle,\n dataViewToggleOptions,\n disableElevation,\n isLoading,\n children,\n onSelectedRowsChanged,\n maxSelectedRows,\n onMaxSelectedRows,\n ...props\n}) {\n const defaultColumn = useMemo(\n () => (defaultColumnValues),\n [defaultColumnValues],\n );\n const tableOptions = useMemo(() => {\n const updatedTableOptions = {\n stateReducer: (newState, action, previousState) => {\n switch (action.type) {\n // Note: we override the `toggleAllRowsSelected` action\n // from react-table because it only clears the selections on the\n // currently visible page; it does not clear the `selectedRowIds`\n // as we would expect for selections on different pages. Instead, we\n // force `selectedRowIds` to be cleared when `toggleAllRowsSelected(false)`\n // is called.\n case 'toggleAllRowsSelected': {\n if (action.value) {\n return newState;\n }\n return {\n ...newState,\n selectedRowIds: {},\n };\n }\n /**\n * Note: We override the `toggleRowSelected` action from react-table\n * because we need to preserve the order of the selected rows.\n * while `selectedRowIds` is an object that contains the selected rows as key-value pairs,\n * it does not maintain the order of selection. Therefore, we have added the `selectedRowsOrdered` property\n * to keep track of the order in which the rows were selected.\n */\n case 'toggleRowSelected': {\n const rowIndex = parseInt(action.id, 10);\n const { selectedRowsOrdered = [] } = previousState;\n\n let newSelectedRowsOrdered;\n if (action.value) {\n newSelectedRowsOrdered = [...selectedRowsOrdered, rowIndex];\n } else {\n newSelectedRowsOrdered = selectedRowsOrdered.filter((item) => item !== rowIndex);\n }\n\n return {\n ...newState,\n selectedRowsOrdered: newSelectedRowsOrdered,\n };\n }\n default:\n return newState;\n }\n },\n ...initialTableOptions,\n };\n return {\n columns,\n data,\n defaultColumn,\n manualFilters,\n manualPagination,\n manualSortBy,\n initialState,\n ...updatedTableOptions,\n };\n }, [initialTableOptions, columns, data, defaultColumn, manualFilters, manualPagination, manualSortBy, initialState]);\n\n const [selections, selectionsDispatch] = useReducer(selectionsReducer, initialSelectionsState);\n\n if (isPaginated && manualPagination) {\n // pageCount is required when pagination is manual, if it's not there passing -1 as per react-table docs\n tableOptions.pageCount = pageCount || -1;\n }\n\n // NB: Table args *must* be in a particular order\n const tableArgs = getTableArgs({\n tableOptions, isFilterable, isSelectable, isPaginated, isSortable, isExpandable,\n });\n // adds selection column and action columns as necessary\n tableArgs.push(hooks => {\n hooks.visibleColumns.push(\n visibleColumns => getVisibleColumns(isSelectable, visibleColumns, additionalColumns, manualSelectColumn),\n );\n });\n\n // Pass any controlled selections from context to the appropriate ``useTable`` arguments to maintain\n // correct selection states on rows, both from a data perspective and in the UI.\n const selectionProps = {};\n const { selectedRows } = selections;\n if (selectedRows.length > 0) {\n const selectedRowsById = {};\n selectedRows.forEach((row) => {\n selectedRowsById[row.id] = true;\n });\n tableArgs.push(hooks => {\n hooks.useControlledState.push(\n (state) => ({ ...state, selectedRowIds: selectedRowsById }),\n );\n });\n selectionProps.selectedFlatRows = selectedRows;\n }\n const controlledTableSelections = [selections, selectionsDispatch];\n\n // Use the state and functions returned from useTable to build your UI\n const instance = useTable(...tableArgs);\n\n const {\n pageSize: tableStatePageSize,\n pageIndex: tableStatePageIndex,\n sortBy: tableStateSortBy,\n filters: tableStateFilters,\n selectedRowIds: tableStateSelectedRowIds,\n } = instance.state;\n\n useEffect(() => {\n if (fetchData) {\n fetchData({\n pageSize: tableStatePageSize,\n pageIndex: tableStatePageIndex,\n sortBy: tableStateSortBy,\n filters: tableStateFilters,\n });\n }\n }, [fetchData, tableStatePageSize, tableStatePageIndex, tableStateSortBy, tableStateFilters]);\n\n useMountedLayoutEffect(() => {\n if (onSelectedRowsChanged) {\n onSelectedRowsChanged(tableStateSelectedRowIds);\n }\n }, [tableStateSelectedRowIds, onSelectedRowsChanged]);\n\n const selectionActions = useSelectionActions(instance, controlledTableSelections);\n\n useDataTableSelections({\n selections,\n selectionsDispatch,\n itemCount,\n selectedRows,\n page: instance.page,\n isAllPageRowsSelected: instance.isAllPageRowsSelected,\n });\n\n const enhancedInstance = {\n ...instance,\n manualFilters,\n itemCount,\n numBreakoutFilters,\n bulkActions,\n tableActions,\n controlledTableSelections,\n showFiltersInSidebar,\n dataViewToggleOptions,\n renderRowSubComponent,\n disableElevation,\n isLoading,\n isSelectable,\n isPaginated,\n manualSelectColumn,\n maxSelectedRows,\n onMaxSelectedRows,\n filtersTitle,\n ...selectionProps,\n ...selectionActions,\n ...props,\n };\n\n return (\n <DataTableContext.Provider value={enhancedInstance}>\n <DataTableLayout filtersTitle={filtersTitle}>\n <div className={classNames('pgn__data-table-wrapper', {\n 'hide-shadow': !!disableElevation,\n })}\n >\n {children || (\n <>\n <TableControlBar />\n <Table />\n <EmptyTableComponent content=\"No results found\" />\n <TableFooter />\n </>\n )}\n </div>\n </DataTableLayout>\n </DataTableContext.Provider>\n );\n}\n\nDataTable.defaultProps = {\n additionalColumns: [],\n defaultColumnValues: {},\n isFilterable: false,\n isPaginated: false,\n isSelectable: false,\n isSortable: false,\n manualFilters: false,\n manualPagination: false,\n manualSortBy: false,\n fetchData: null,\n initialState: {},\n initialTableOptions: {},\n EmptyTableComponent: EmptyTableContent,\n children: null,\n bulkActions: [],\n tableActions: [],\n numBreakoutFilters: 1,\n manualSelectColumn: undefined,\n SelectionStatusComponent: SelectionStatus,\n FilterStatusComponent: FilterStatus,\n RowStatusComponent: RowStatus,\n showFiltersInSidebar: false,\n filtersTitle: undefined,\n dataViewToggleOptions: {\n isDataViewToggleEnabled: false,\n onDataViewToggle: () => {},\n defaultActiveStateValue: 'card',\n togglePlacement: 'left',\n },\n disableElevation: false,\n renderRowSubComponent: undefined,\n isExpandable: false,\n isLoading: false,\n onSelectedRowsChanged: undefined,\n maxSelectedRows: undefined,\n onMaxSelectedRows: undefined,\n};\n\nDataTable.propTypes = {\n /** Definition of table columns */\n columns: PropTypes.arrayOf(PropTypes.shape({\n /** User visible column name */\n Header: PropTypes.oneOfType([PropTypes.elementType, PropTypes.node]).isRequired,\n /** String used to access the correct cell data for this column */\n accessor: requiredWhenNot(PropTypes.string, 'Cell'),\n /** Specifies a function that receives `row` as argument and returns cell content */\n Cell: PropTypes.oneOfType([PropTypes.elementType, PropTypes.node]),\n /** Specifies filter component */\n Filter: PropTypes.elementType,\n /** Specifies filter type */\n filter: PropTypes.string,\n /** Specifies filter choices */\n filterChoices: PropTypes.arrayOf(PropTypes.shape({\n name: PropTypes.string,\n number: PropTypes.number,\n value: PropTypes.string,\n })),\n })).isRequired,\n /** Data to be displayed in the table */\n data: PropTypes.arrayOf(PropTypes.shape({})).isRequired,\n /** table rows can be selected */\n isSelectable: PropTypes.bool,\n /** Alternate column for selecting rows. See react table useSort docs for more information */\n manualSelectColumn: PropTypes.shape({\n id: PropTypes.string.isRequired,\n Header: PropTypes.oneOfType([PropTypes.elementType, PropTypes.node]).isRequired,\n Cell: PropTypes.oneOfType([PropTypes.elementType, PropTypes.node]),\n disableSortBy: PropTypes.bool.isRequired,\n }),\n /** Table columns can be sorted */\n isSortable: PropTypes.bool,\n /** Indicates that sorting will be done via backend API. A fetchData function must be provided */\n manualSortBy: PropTypes.bool,\n /** Paginate the table */\n isPaginated: PropTypes.bool,\n /** Indicates that pagination will be done manually. A fetchData function must be provided */\n manualPagination: PropTypes.bool,\n // eslint-disable-next-line react/require-default-props\n pageCount: requiredWhen(PropTypes.number, 'manualPagination'),\n /** Table rows can be filtered, using a default filter in the default column values, or in the column definition */\n isFilterable: PropTypes.bool,\n /** Indicates that filtering will be done via a backend API. A fetchData function must be provided */\n manualFilters: PropTypes.bool,\n\n /** defaults that will be set on each column. Will be overridden by individual column values */\n defaultColumnValues: PropTypes.shape({\n /** A default filter component for the column */\n Filter: PropTypes.elementType,\n }),\n /** Actions or other additional non-data columns can be added here */\n additionalColumns: PropTypes.arrayOf(PropTypes.shape({\n /** id must be unique from other columns ids */\n id: PropTypes.string.isRequired,\n /** column header that will be displayed to the user */\n Header: PropTypes.oneOfType([PropTypes.elementType, PropTypes.node]),\n /** Component that renders in the added column. It will receive the row as a prop */\n Cell: PropTypes.oneOfType([PropTypes.elementType, PropTypes.node]),\n })),\n /** Function that will fetch table data. Called when page size, page index or filters change.\n * Meant to be used with manual filters and pagination */\n fetchData: PropTypes.func,\n /** Initial state passed to react-table's documentation https://github.com/TanStack/table/blob/v7/docs/src/pages/docs/api/useTable.md */\n initialState: PropTypes.shape({\n pageSize: requiredWhen(PropTypes.number, 'isPaginated'),\n pageIndex: requiredWhen(PropTypes.number, 'isPaginated'),\n filters: requiredWhen(PropTypes.arrayOf(PropTypes.shape()), 'manualFilters'),\n sortBy: requiredWhen(PropTypes.arrayOf(PropTypes.shape()), 'manualSortBy'),\n selectedRowIds: PropTypes.shape(),\n selectedRowsOrdered: PropTypes.arrayOf(PropTypes.number),\n }),\n /** Table options passed to react-table's useTable hook. Will override some options passed in to DataTable, such\n as: data, columns, defaultColumn, manualFilters, manualPagination, manualSortBy, and initialState */\n initialTableOptions: PropTypes.shape({}),\n /** Actions to be performed on the table. Called with the table instance. Not displayed if rows are selected. */\n itemCount: PropTypes.number.isRequired,\n /** Actions to be performed on selected rows of the table. Called with the selected rows.\n * Only displayed if rows are selected. */\n bulkActions: PropTypes.oneOfType([\n PropTypes.arrayOf(\n PropTypes.oneOfType([\n PropTypes.shape({\n /** Bulk action button text */\n buttonText: PropTypes.string.isRequired,\n /** handleClick will be passed the selected rows */\n handleClick: PropTypes.func.isRequired,\n /** classnames for button class */\n className: PropTypes.string,\n /** optional button variant; only relevant for the first two buttons */\n variant: PropTypes.string,\n /** disables button */\n disabled: PropTypes.bool,\n }),\n /** function passed selected items, should return action object */\n PropTypes.func,\n /** A custom component representing an action */\n PropTypes.element,\n ]),\n ),\n /** Function for rendering custom components */\n PropTypes.func,\n /** A custom component representing an action */\n PropTypes.element,\n ]),\n /** Function for rendering custom components, called with the table instance */\n tableActions: PropTypes.oneOfType([\n PropTypes.arrayOf(\n PropTypes.oneOfType([\n PropTypes.shape({\n /** Bulk action button text */\n buttonText: PropTypes.string.isRequired,\n /** handleClick will be passed the selected rows */\n handleClick: PropTypes.func.isRequired,\n /** classnames for button class */\n className: PropTypes.string,\n /** optional button variant; only relevant for the first two buttons */\n variant: PropTypes.string,\n /** disables button */\n disabled: PropTypes.bool,\n }),\n /** function passed table instance, should return action object */\n PropTypes.func,\n /** A custom component representing an action */\n PropTypes.element,\n ]),\n ),\n /** Function for rendering custom components */\n PropTypes.func,\n /** A custom component representing an action */\n PropTypes.element,\n ]),\n /** Number between one and four filters that can be shown on the top row. */\n numBreakoutFilters: PropTypes.oneOf([1, 2, 3, 4]),\n /** Component to be displayed when the table is empty */\n EmptyTableComponent: PropTypes.elementType,\n /** Component to be displayed for row status, ie, 10 of 20 rows. Displayed by default in the TableControlBar */\n RowStatusComponent: PropTypes.elementType,\n /** Component to be displayed for selection status. Displayed when there are selected rows and no active filters */\n SelectionStatusComponent: PropTypes.elementType,\n /** Component to be displayed for filter status. Displayed when there are active filters. */\n FilterStatusComponent: PropTypes.elementType,\n /** If children are not provided a table with control bar and footer will be rendered */\n children: PropTypes.node,\n /** If true filters will be shown on sidebar instead */\n showFiltersInSidebar: PropTypes.bool,\n /** Title of the filters section */\n filtersTitle: PropTypes.string,\n /** options for data view toggle */\n dataViewToggleOptions: PropTypes.shape({\n /** Whether to show a toggle button group which allows view switching between card and table views */\n isDataViewToggleEnabled: PropTypes.bool,\n /** Callback invoked when the toggle buttons are clicked, with value of selected button passed in */\n onDataViewToggle: PropTypes.func,\n /** default value for toggle active state */\n defaultActiveStateValue: PropTypes.string,\n /** placement of toggle 'bottom' will push it to the bottom row in\n * actions section. Only 'left' and 'bottom' are supported */\n togglePlacement: PropTypes.string,\n }),\n /** Remove the default box shadow on the component */\n disableElevation: PropTypes.bool,\n /** A function that will render contents of expanded row, accepts `row` as a prop. */\n renderRowSubComponent: PropTypes.func,\n /** Indicates whether table supports expandable rows. */\n isExpandable: PropTypes.bool,\n /** Indicates whether the table should show loading states. */\n isLoading: PropTypes.bool,\n /** Callback function called when row selections change. */\n onSelectedRowsChanged: PropTypes.func,\n /** Indicates the max of rows selectable in the table. Requires isSelectable prop */\n maxSelectedRows: PropTypes.number,\n /** Callback after selected max rows. Requires isSelectable and maxSelectedRows props */\n onMaxSelectedRows: PropTypes.func,\n};\n\nDataTable.BulkActions = BulkActions;\nDataTable.EmptyTable = EmptyTableContent;\nDataTable.DropdownFilters = DropdownFilters;\nDataTable.FilterStatus = FilterStatus;\nDataTable.RowStatus = RowStatus;\nDataTable.SelectionStatus = SelectionStatus;\nDataTable.SmartStatus = SmartStatus;\nDataTable.Table = Table;\nDataTable.TableCell = TableCell;\nDataTable.TableControlBar = TableControlBar;\nDataTable.TableFilters = TableFilters;\nDataTable.TableFooter = TableFooter;\nDataTable.TableHeaderCell = TableHeaderCell;\nDataTable.TableHeaderRow = TableHeaderRow;\nDataTable.TablePagination = TablePagination;\nDataTable.TablePaginationMinimal = TablePaginationMinimal;\nDataTable.TableActions = TableActions;\nDataTable.ControlledSelectionStatus = ControlledSelectionStatus;\nDataTable.ControlledSelect = ControlledSelect;\nDataTable.ControlledSelectHeader = ControlledSelectHeader;\nDataTable.ExpandAll = ExpandAll;\nDataTable.ExpandRow = ExpandRow;\n\nexport default DataTable;\n"],"mappings":"AAAA,OAAOA,KAAK,IACVC,SAAS,EAAEC,OAAO,EAAEC,UAAU,QACzB,OAAO;AACd,OAAOC,SAAS,MAAM,YAAY;AAClC,SAASC,QAAQ,EAAEC,sBAAsB,QAAQ,aAAa;AAE9D,OAAOC,UAAU,MAAM,YAAY;AACnC,OAAOC,KAAK,MAAM,SAAS;AAC3B,OAAOC,iBAAiB,MAAM,2BAA2B;AACzD,SAASC,YAAY,EAAEC,eAAe,QAAQ,oBAAoB;AAClE,OAAOC,YAAY,MAAM,sBAAsB;AAC/C,OAAOC,eAAe,MAAM,mBAAmB;AAC/C,OAAOC,iBAAiB,MAAM,cAAc;AAC5C,OAAOC,WAAW,MAAM,eAAe;AACvC,OAAOC,WAAW,MAAM,eAAe;AACvC,OAAOC,eAAe,MAAM,mBAAmB;AAC/C,OAAOC,YAAY,MAAM,gBAAgB;AACzC,OAAOC,SAAS,MAAM,aAAa;AACnC,OAAOC,eAAe,MAAM,6BAA6B;AACzD,OAAOC,yBAAyB,MAAM,uCAAuC;AAC7E,OAAOC,WAAW,MAAM,eAAe;AACvC,OAAOC,YAAY,MAAM,gBAAgB;AACzC,OAAOC,eAAe,MAAM,m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kB,SAAS,CAAC1B,WAAW,GAAGA,WAAW;AACnC0B,SAAS,CAACjB,eAAe,GAAGA,eAAe;AAC3CiB,SAAS,CAACf,cAAc,GAAGA,cAAc;AACzCe,SAAS,CAACd,eAAe,GAAGA,eAAe;AAC3Cc,SAAS,CAACb,sBAAsB,GAAGA,sBAAsB;AACzDa,SAAS,CAACX,YAAY,GAAGA,YAAY;AACrCW,SAAS,CAACpB,yBAAyB,GAAGA,yBAAyB;AAC/DoB,SAAS,CAACV,gBAAgB,GAAGA,gBAAgB;AAC7CU,SAAS,CAACT,sBAAsB,GAAGA,sBAAsB;AACzDS,SAAS,CAACP,SAAS,GAAGA,SAAS;AAC/BO,SAAS,CAACN,SAAS,GAAGA,SAAS;AAE/B,eAAeM,SAAS","ignoreList":[]}
@@ -6,6 +6,11 @@ const messages = defineMessages({
6
6
  defaultMessage: 'table pagination',
7
7
  description: 'Accessibile name for the navigation element of a pagination component',
8
8
  },
9
+ filtersDropdownTitle: {
10
+ id: 'pgn.DataTable.filtersDropdownTitle',
11
+ defaultMessage: 'Filters',
12
+ description: 'Title of the filters dropdown',
13
+ },
9
14
  });
10
15
 
11
16
  export default messages;
@@ -13,7 +13,8 @@ const ProductTour = /*#__PURE__*/React.forwardRef((_ref, ref) => {
13
13
  startingIndex,
14
14
  onEscape,
15
15
  onEnd,
16
- onBack,
16
+ onAdvance: tourOnAdvance,
17
+ onBack: tourOnBack,
17
18
  onDismiss: tourOnDismiss,
18
19
  advanceButtonText: tourAdvanceButtonText,
19
20
  dismissAltText: tourDismissAltText,
@@ -28,6 +29,7 @@ const ProductTour = /*#__PURE__*/React.forwardRef((_ref, ref) => {
28
29
  title,
29
30
  body,
30
31
  onAdvance,
32
+ onBack,
31
33
  onDismiss,
32
34
  advanceButtonText,
33
35
  dismissAltText,
@@ -78,12 +80,16 @@ const ProductTour = /*#__PURE__*/React.forwardRef((_ref, ref) => {
78
80
  setIndex(index + 1);
79
81
  if (onAdvance) {
80
82
  onAdvance();
83
+ } else if (tourOnAdvance) {
84
+ tourOnAdvance();
81
85
  }
82
86
  };
83
87
  const handleBack = () => {
84
88
  setIndex(index - 1);
85
89
  if (onBack) {
86
90
  onBack();
91
+ } else if (tourOnBack) {
92
+ tourOnBack();
87
93
  }
88
94
  };
89
95
  const handleDismiss = () => {
@@ -91,7 +97,7 @@ const ProductTour = /*#__PURE__*/React.forwardRef((_ref, ref) => {
91
97
  setIsTourEnabled(false);
92
98
  if (onDismiss) {
93
99
  onDismiss();
94
- } else {
100
+ } else if (tourOnDismiss) {
95
101
  tourOnDismiss();
96
102
  }
97
103
  setCurrentCheckpointData(null);
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["React","useEffect","useState","PropTypes","withDeprecatedProps","DeprTypes","Checkpoint","ProductTour","forwardRef","_ref","ref","tours","tourValue","find","tour","enabled","checkpoints","startingIndex","onEscape","onEnd","onBack","onDismiss","tourOnDismiss","advanceButtonText","tourAdvanceButtonText","dismissAltText","tourDismissAltText","endButtonText","tourEndButtonText","backButtonText","tourBackButtonText","currentCheckpointData","setCurrentCheckpointData","index","setIndex","isTourEnabled","setIsTourEnabled","prunedCheckpoints","setPrunedCheckpoints","title","body","onAdvance","placement","target","pruneCheckpoints","checkpointList","checkpointsWithRenderedTargets","filter","checkpoint","document","querySelector","length","handleEsc","event","key","global","addEventListener","removeEventListener","handleAdvance","handleBack","handleDismiss","handleEnd","checkpointIndex","createElement","totalCheckpoints","defaultProps","propTypes","arrayOf","shape","node","string","func","oneOf","isRequired","bool","number","tourId","hasDismissButtonText","obj","dismissButtonText","deprType","FORMAT","message","expect","propValue","Array","isArray","some","transform","map","updatedTour","warningMessage","console","warn","rest"],"sources":["../../src/ProductTour/index.jsx"],"sourcesContent":["import React, { useEffect, useState } from 'react';\nimport PropTypes from 'prop-types';\nimport withDeprecatedProps, { DeprTypes } from '../withDeprecatedProps';\n\nimport Checkpoint from './Checkpoint';\n\nconst ProductTour = React.forwardRef(({ tours }, ref) => {\n const tourValue = tours.find((tour) => tour.enabled);\n const {\n enabled,\n checkpoints = [],\n startingIndex,\n onEscape,\n onEnd,\n onBack,\n onDismiss: tourOnDismiss,\n advanceButtonText: tourAdvanceButtonText,\n dismissAltText: tourDismissAltText,\n endButtonText: tourEndButtonText,\n backButtonText: tourBackButtonText,\n } = tourValue || {};\n const [currentCheckpointData, setCurrentCheckpointData] = useState(null);\n const [index, setIndex] = useState(0);\n const [isTourEnabled, setIsTourEnabled] = useState(false);\n const [prunedCheckpoints, setPrunedCheckpoints] = useState([]);\n const {\n title,\n body,\n onAdvance,\n onDismiss,\n advanceButtonText,\n dismissAltText,\n endButtonText,\n backButtonText,\n placement,\n target,\n } = currentCheckpointData || {};\n\n /**\n * Takes a list of checkpoints and verifies that each target string provided is\n * an element in the DOM.\n */\n const pruneCheckpoints = (checkpointList) => {\n const checkpointsWithRenderedTargets = checkpointList.filter(\n (checkpoint) => !!document.querySelector(checkpoint.target),\n );\n setPrunedCheckpoints(checkpointsWithRenderedTargets);\n };\n\n useEffect(() => {\n if (enabled && checkpoints) {\n setIsTourEnabled(enabled);\n pruneCheckpoints(checkpoints);\n setIndex(startingIndex || 0);\n }\n }, [enabled, checkpoints, startingIndex]);\n\n useEffect(() => {\n if (isTourEnabled && prunedCheckpoints.length) {\n setCurrentCheckpointData(prunedCheckpoints[index]);\n }\n }, [index, isTourEnabled, prunedCheckpoints]);\n\n useEffect(() => {\n const handleEsc = (event) => {\n if (event.key === 'Escape') {\n setIsTourEnabled(false);\n if (onEscape) {\n onEscape();\n }\n }\n };\n global.addEventListener('keydown', handleEsc);\n\n return () => {\n global.removeEventListener('keydown', handleEsc);\n };\n }, [onEscape]);\n\n if (!tourValue || !currentCheckpointData || !isTourEnabled) {\n return null;\n }\n\n const handleAdvance = () => {\n setIndex(index + 1);\n if (onAdvance) {\n onAdvance();\n }\n };\n\n const handleBack = () => {\n setIndex(index - 1);\n if (onBack) {\n onBack();\n }\n };\n\n const handleDismiss = () => {\n setIndex(0);\n setIsTourEnabled(false);\n if (onDismiss) {\n onDismiss();\n } else {\n tourOnDismiss();\n }\n setCurrentCheckpointData(null);\n };\n /* eslint-disable */\n /**\n * Takes the final checkpoint array index value and looks for an existing onEnd callback.\n * \n * If an onEnd callback exist on checkpointIndex value and it is the final checkpoint \n * in the array, the onEnd callback will be called for the parent, and individual onEnd object. \n * \n * @param {Integer} checkpointIndex \n */\n /* eslint-enable */\n const handleEnd = (checkpointIndex) => {\n setIndex(0);\n setIsTourEnabled(false);\n if (prunedCheckpoints[checkpointIndex].onEnd) {\n prunedCheckpoints[checkpointIndex].onEnd();\n } else if (onEnd) {\n onEnd(prunedCheckpoints[checkpointIndex]);\n }\n setCurrentCheckpointData(null);\n };\n return (\n <Checkpoint\n advanceButtonText={advanceButtonText || tourAdvanceButtonText}\n body={body}\n currentCheckpointData={currentCheckpointData}\n dismissAltText={dismissAltText || tourDismissAltText}\n endButtonText={endButtonText || tourEndButtonText}\n backButtonText={backButtonText || tourBackButtonText}\n index={index}\n onBack={handleBack}\n onAdvance={handleAdvance}\n onDismiss={handleDismiss}\n onEnd={handleEnd}\n placement={placement}\n target={target}\n title={title}\n totalCheckpoints={prunedCheckpoints.length}\n ref={ref}\n />\n );\n});\n\nProductTour.defaultProps = {\n tours: {\n advanceButtonText: '',\n backButtonText: '',\n checkpoints: {\n advanceButtonText: '',\n backButtonText: '',\n body: '',\n dismissAltText: '',\n endButtonText: '',\n onAdvance: () => {},\n onDismiss: () => {},\n onBack: () => {},\n placement: 'top',\n title: '',\n },\n dismissAltText: '',\n endButtonText: '',\n onBack: () => {},\n onDismiss: () => {},\n onEnd: () => {},\n onEscape: () => {},\n startingIndex: 0,\n },\n};\n\nProductTour.propTypes = {\n tours: PropTypes.arrayOf(PropTypes.shape({\n /** The text displayed on all buttons used to advance the tour. */\n advanceButtonText: PropTypes.node,\n /** The text displayed on all buttons used to go back in the tour */\n backButtonText: PropTypes.string,\n /** An array comprised of checkpoint objects supporting the following values: */\n checkpoints: PropTypes.arrayOf(PropTypes.shape({\n /** The text displayed on the button used to advance the tour for the given Checkpoint\n * (overrides the* `advanceButtonText` defined in the parent tour object). */\n advanceButtonText: PropTypes.node,\n /** The text displayed on the button used to go back in the tour for the given Checkpoint\n * (overrides the* `backButtonText` defined in the parent tour object). */\n backButtonText: PropTypes.string,\n /** The text displayed in the body of the Checkpoint */\n body: PropTypes.node,\n /** The text used in the alt for the icon used to dismiss the tour for the given Checkpoint */\n dismissAltText: PropTypes.string,\n /** The text displayed on the button used to end the tour for the given Checkpoint\n * (overrides the `endButtonText` defined in the parent tour object). */\n endButtonText: PropTypes.node,\n /** A function that runs when triggering the `onClick` event of the advance\n * button for the given Checkpoint. */\n onAdvance: PropTypes.func,\n /** A function that runs when triggering the `onClick` event of the dismiss\n * button for the given Checkpoint (overrides the `onDismiss` function defined in the parent tour object). */\n onDismiss: PropTypes.func,\n /** A function that runs when triggering the `onClick` event of the advance\n * button if the given Checkpoint is the only or last Checkpoint in a tour. */\n onEnd: PropTypes.func,\n /** A string that dictates the alignment of the Checkpoint around its target. */\n placement: PropTypes.oneOf([\n 'top', 'top-start', 'top-end', 'right-start', 'right', 'right-end',\n 'left-start', 'left', 'left-end', 'bottom', 'bottom-start', 'bottom-end',\n ]),\n /** The CSS selector for the Checkpoint's desired target. */\n target: PropTypes.string.isRequired,\n /** The text displayed in the title of the Checkpoint */\n title: PropTypes.node,\n })),\n /** The text used in the alt for the icon used to dismiss the tour for the given Checkpoint */\n dismissAltText: PropTypes.string,\n /** Whether the tour is enabled. If there are multiple tours defined, only one should be enabled at a time. */\n enabled: PropTypes.bool.isRequired,\n /** The text displayed on the button used to end the tour. */\n endButtonText: PropTypes.node,\n /** A function that runs when triggering the `onBack` event of the back button. */\n onBack: PropTypes.func,\n /** A function that runs when triggering the `onClick` event of the dismiss button. */\n onDismiss: PropTypes.func,\n /** A function that runs when triggering the `onClick` event of the end button. */\n onEnd: PropTypes.func,\n /** A function that runs when pressing the Escape key. */\n onEscape: PropTypes.func,\n /** The index of the desired `Checkpoint` to render when the tour starts. */\n startingIndex: PropTypes.number,\n /** The ID of the tour */\n tourId: PropTypes.string.isRequired,\n })),\n};\n\n/**\n * Checks if the given object has a deprecated/legacy `dismissButtonText` property.\n * @param {Object} obj - The object to check\n * @returns {boolean} - True if the object has a deprecated/legacy `dismissButtonText` property, false otherwise\n */\nconst hasDismissButtonText = (obj) => {\n if ('dismissButtonText' in obj && !!obj.dismissButtonText) {\n return true;\n }\n return false;\n};\n\nexport default withDeprecatedProps(ProductTour, 'ProductTour', {\n tours: {\n deprType: DeprTypes.FORMAT,\n message: \"The dismissButtonText options in the 'tours' prop have been moved to 'dismissAltText'.\",\n /**\n * Determines whether the given prop value contains the deprecated/legacy `dismissButtonText` property.\n * @param {Object[]} propValue - The tours prop value to check\n * @returns {boolean} True if the prop value contains the deprecated/legacy `dismissButtonText`\n * property, false otherwise\n */\n expect: (propValue) => {\n if (!Array.isArray(propValue)) {\n return true;\n }\n return !propValue.some((tour) => {\n if (hasDismissButtonText(tour)) {\n return true;\n }\n return Array.isArray(tour.checkpoints)\n && tour.checkpoints.some(hasDismissButtonText);\n });\n },\n /**\n * Transforms the given prop value by updating the\n * deprecated/legacy `dismissButtonText` property to\n * `dismissAltText`, if the prop value is a string. Otherwise,\n * the original `dismissButtonText` property is ignored.\n * @param {Object[]} propValue - The tours prop value to transform\n * @returns {Object[]} The transformed prop value\n */\n transform: (propValue) => {\n const tours = propValue.map((tour) => {\n const updatedTour = { ...tour };\n\n // Replace tour level dismissButtonText with dismissAltText\n if (hasDismissButtonText(tour)) {\n if (typeof tour.dismissButtonText === 'string') {\n updatedTour.dismissAltText = tour.dismissButtonText;\n } else {\n const warningMessage = \"[Deprecated] ProductTour: The 'dismissButtonText' options within the 'tours' prop now expects a string\";\n // eslint-disable-next-line no-console\n console.warn(warningMessage);\n }\n }\n\n // Replace checkpoint level dismissButtonText with dismissAltText\n if (Array.isArray(tour.checkpoints)) {\n updatedTour.checkpoints = tour.checkpoints.map((checkpoint) => {\n if (hasDismissButtonText(checkpoint)) {\n const { dismissButtonText, ...rest } = checkpoint;\n if (typeof dismissButtonText === 'string') {\n return { ...rest, dismissAltText: dismissButtonText };\n }\n }\n return checkpoint;\n });\n }\n return updatedTour;\n });\n\n // Return the transformed tours\n return tours;\n },\n },\n});\n"],"mappings":"AAAA,OAAOA,KAAK,IAAIC,SAAS,EAAEC,QAAQ,QAAQ,OAAO;AAClD,OAAOC,SAAS,MAAM,YAAY;AAClC,OAAOC,mBAAmB,IAAIC,SAAS,QAAQ,wBAAwB;AAEvE,OAAOC,UAAU,MAAM,cAAc;AAErC,MAAMC,WAAW,gBAAGP,KAAK,CAACQ,UAAU,CAAC,CAAAC,IAAA,EAAYC,GAAG,KAAK;EAAA,IAAnB;IAAEC;EAAM,CAAC,GAAAF,IAAA;EAC7C,MAAMG,SAAS,GAAGD,KAAK,CAACE,IAAI,CAAEC,IAAI,IAAKA,IAAI,CAACC,OAAO,CAAC;EACpD,MAAM;IACJA,OAAO;IACPC,WAAW,GAAG,EAAE;IAChBC,aAAa;IACbC,QAAQ;IACRC,KAAK;IACLC,MAAM;IACNC,SAAS,EAAEC,aAAa;IACxBC,iBAAiB,EAAEC,qBAAqB;IACxCC,cAAc,EAAEC,kBAAkB;IAClCC,aAAa,EAAEC,iBAAiB;IAChCC,cAAc,EAAEC;EAClB,CAAC,GAAGlB,SAAS,IAAI,CAAC,CAAC;EACnB,MAAM,CAACmB,qBAAqB,EAAEC,wBAAwB,CAAC,GAAG9B,QAAQ,CAAC,IAAI,CAAC;EACxE,MAAM,CAAC+B,KAAK,EAAEC,QAAQ,CAAC,GAAGhC,QAAQ,CAAC,CAAC,CAAC;EACrC,MAAM,CAACiC,aAAa,EAAEC,gBAAgB,CAAC,GAAGlC,QAAQ,CAAC,KAAK,CAAC;EACzD,MAAM,CAACmC,iBAAiB,EAAEC,oBAAoB,CAAC,GAAGpC,QAAQ,CAAC,EAAE,CAAC;EAC9D,MAAM;IACJqC,KAAK;IACLC,I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AC9B,IAAI,OAAOA,IAAI,CAACiE,iBAAiB,KAAK,QAAQ,EAAE;YAC9CW,WAAW,CAACjE,cAAc,GAAGX,IAAI,CAACiE,iBAAiB;UACrD,CAAC,MAAM;YACL,MAAMY,cAAc,GAAG,wGAAwG;YAC/H;YACAC,OAAO,CAACC,IAAI,CAACF,cAAc,CAAC;UAC9B;QACF;;QAEA;QACA,IAAIN,KAAK,CAACC,OAAO,CAACxE,IAAI,CAACE,WAAW,CAAC,EAAE;UACnC0E,WAAW,CAAC1E,WAAW,GAAGF,IAAI,CAACE,WAAW,CAACyE,GAAG,CAAEzC,UAAU,IAAK;YAC7D,IAAI6B,oBAAoB,CAAC7B,UAAU,CAAC,EAAE;cACpC,MAAM;gBAAE+B,iBAAiB;gBAAE,GAAGe;cAAK,CAAC,GAAG9C,UAAU;cACjD,IAAI,OAAO+B,iBAAiB,KAAK,QAAQ,EAAE;gBACzC,OAAO;kBAAE,GAAGe,IAAI;kBAAErE,cAAc,EAAEsD;gBAAkB,CAAC;cACvD;YACF;YACA,OAAO/B,UAAU;UACnB,CAAC,CAAC;QACJ;QACA,OAAO0C,WAAW;MACpB,CAAC,CAAC;;MAEF;MACA,OAAO/E,KAAK;IACd;EACF;AACF,CAAC,CAAC","ignoreList":[]}
1
+ {"version":3,"file":"index.js","names":["React","useEffect","useState","PropTypes","withDeprecatedProps","DeprTypes","Checkpoint","ProductTour","forwardRef","_ref","ref","tours","tourValue","find","tour","enabled","checkpoints","startingIndex","onEscape","onEnd","onAdvance","tourOnAdvance","onBack","tourOnBack","onDismiss","tourOnDismiss","advanceButtonText","tourAdvanceButtonText","dismissAltText","tourDismissAltText","endButtonText","tourEndButtonText","backButtonText","tourBackButtonText","currentCheckpointData","setCurrentCheckpointData","index","setIndex","isTourEnabled","setIsTourEnabled","prunedCheckpoints","setPrunedCheckpoints","title","body","placement","target","pruneCheckpoints","checkpointList","checkpointsWithRenderedTargets","filter","checkpoint","document","querySelector","length","handleEsc","event","key","global","addEventListener","removeEventListener","handleAdvance","handleBack","handleDismiss","handleEnd","checkpointIndex","createElement","totalCheckpoints","defaultProps","propTypes","arrayOf","shape","node","string","func","oneOf","isRequired","bool","number","tourId","hasDismissButtonText","obj","dismissButtonText","deprType","FORMAT","message","expect","propValue","Array","isArray","some","transform","map","updatedTour","warningMessage","console","warn","rest"],"sources":["../../src/ProductTour/index.jsx"],"sourcesContent":["import React, { useEffect, useState } from 'react';\nimport PropTypes from 'prop-types';\nimport withDeprecatedProps, { DeprTypes } from '../withDeprecatedProps';\n\nimport Checkpoint from './Checkpoint';\n\nconst ProductTour = React.forwardRef(({ tours }, ref) => {\n const tourValue = tours.find((tour) => tour.enabled);\n const {\n enabled,\n checkpoints = [],\n startingIndex,\n onEscape,\n onEnd,\n onAdvance: tourOnAdvance,\n onBack: tourOnBack,\n onDismiss: tourOnDismiss,\n advanceButtonText: tourAdvanceButtonText,\n dismissAltText: tourDismissAltText,\n endButtonText: tourEndButtonText,\n backButtonText: tourBackButtonText,\n } = tourValue || {};\n const [currentCheckpointData, setCurrentCheckpointData] = useState(null);\n const [index, setIndex] = useState(0);\n const [isTourEnabled, setIsTourEnabled] = useState(false);\n const [prunedCheckpoints, setPrunedCheckpoints] = useState([]);\n const {\n title,\n body,\n onAdvance,\n onBack,\n onDismiss,\n advanceButtonText,\n dismissAltText,\n endButtonText,\n backButtonText,\n placement,\n target,\n } = currentCheckpointData || {};\n\n /**\n * Takes a list of checkpoints and verifies that each target string provided is\n * an element in the DOM.\n */\n const pruneCheckpoints = (checkpointList) => {\n const checkpointsWithRenderedTargets = checkpointList.filter(\n (checkpoint) => !!document.querySelector(checkpoint.target),\n );\n setPrunedCheckpoints(checkpointsWithRenderedTargets);\n };\n\n useEffect(() => {\n if (enabled && checkpoints) {\n setIsTourEnabled(enabled);\n pruneCheckpoints(checkpoints);\n setIndex(startingIndex || 0);\n }\n }, [enabled, checkpoints, startingIndex]);\n\n useEffect(() => {\n if (isTourEnabled && prunedCheckpoints.length) {\n setCurrentCheckpointData(prunedCheckpoints[index]);\n }\n }, [index, isTourEnabled, prunedCheckpoints]);\n\n useEffect(() => {\n const handleEsc = (event) => {\n if (event.key === 'Escape') {\n setIsTourEnabled(false);\n if (onEscape) {\n onEscape();\n }\n }\n };\n global.addEventListener('keydown', handleEsc);\n\n return () => {\n global.removeEventListener('keydown', handleEsc);\n };\n }, [onEscape]);\n\n if (!tourValue || !currentCheckpointData || !isTourEnabled) {\n return null;\n }\n\n const handleAdvance = () => {\n setIndex(index + 1);\n if (onAdvance) {\n onAdvance();\n } else if (tourOnAdvance) {\n tourOnAdvance();\n }\n };\n\n const handleBack = () => {\n setIndex(index - 1);\n if (onBack) {\n onBack();\n } else if (tourOnBack) {\n tourOnBack();\n }\n };\n\n const handleDismiss = () => {\n setIndex(0);\n setIsTourEnabled(false);\n if (onDismiss) {\n onDismiss();\n } else if (tourOnDismiss) {\n tourOnDismiss();\n }\n setCurrentCheckpointData(null);\n };\n /* eslint-disable */\n /**\n * Takes the final checkpoint array index value and looks for an existing onEnd callback.\n * \n * If an onEnd callback exist on checkpointIndex value and it is the final checkpoint \n * in the array, the onEnd callback will be called for the parent, and individual onEnd object. \n * \n * @param {Integer} checkpointIndex \n */\n /* eslint-enable */\n const handleEnd = (checkpointIndex) => {\n setIndex(0);\n setIsTourEnabled(false);\n if (prunedCheckpoints[checkpointIndex].onEnd) {\n prunedCheckpoints[checkpointIndex].onEnd();\n } else if (onEnd) {\n onEnd(prunedCheckpoints[checkpointIndex]);\n }\n setCurrentCheckpointData(null);\n };\n return (\n <Checkpoint\n advanceButtonText={advanceButtonText || tourAdvanceButtonText}\n body={body}\n currentCheckpointData={currentCheckpointData}\n dismissAltText={dismissAltText || tourDismissAltText}\n endButtonText={endButtonText || tourEndButtonText}\n backButtonText={backButtonText || tourBackButtonText}\n index={index}\n onBack={handleBack}\n onAdvance={handleAdvance}\n onDismiss={handleDismiss}\n onEnd={handleEnd}\n placement={placement}\n target={target}\n title={title}\n totalCheckpoints={prunedCheckpoints.length}\n ref={ref}\n />\n );\n});\n\nProductTour.defaultProps = {\n tours: {\n advanceButtonText: '',\n backButtonText: '',\n checkpoints: {\n advanceButtonText: '',\n backButtonText: '',\n body: '',\n dismissAltText: '',\n endButtonText: '',\n onAdvance: () => {},\n onDismiss: () => {},\n onBack: () => {},\n placement: 'top',\n title: '',\n },\n dismissAltText: '',\n endButtonText: '',\n onBack: () => {},\n onDismiss: () => {},\n onEnd: () => {},\n onEscape: () => {},\n startingIndex: 0,\n },\n};\n\nProductTour.propTypes = {\n tours: PropTypes.arrayOf(PropTypes.shape({\n /** The text displayed on all buttons used to advance the tour. */\n advanceButtonText: PropTypes.node,\n /** The text displayed on all buttons used to go back in the tour */\n backButtonText: PropTypes.string,\n /** An array comprised of checkpoint objects supporting the following values: */\n checkpoints: PropTypes.arrayOf(PropTypes.shape({\n /** The text displayed on the button used to advance the tour for the given Checkpoint\n * (overrides the* `advanceButtonText` defined in the parent tour object). */\n advanceButtonText: PropTypes.node,\n /** The text displayed on the button used to go back in the tour for the given Checkpoint\n * (overrides the* `backButtonText` defined in the parent tour object). */\n backButtonText: PropTypes.string,\n /** The text displayed in the body of the Checkpoint */\n body: PropTypes.node,\n /** The text used in the alt for the icon used to dismiss the tour for the given Checkpoint */\n dismissAltText: PropTypes.string,\n /** The text displayed on the button used to end the tour for the given Checkpoint\n * (overrides the `endButtonText` defined in the parent tour object). */\n endButtonText: PropTypes.node,\n /** A function that runs when triggering the `onClick` event of the advance\n * button for the given Checkpoint. */\n onAdvance: PropTypes.func,\n /** A function that runs when triggering the `onClick` event of the dismiss\n * button for the given Checkpoint (overrides the `onDismiss` function defined in the parent tour object). */\n onDismiss: PropTypes.func,\n /** A function that runs when triggering the `onClick` event of the advance\n * button if the given Checkpoint is the only or last Checkpoint in a tour. */\n onEnd: PropTypes.func,\n /** A string that dictates the alignment of the Checkpoint around its target. */\n placement: PropTypes.oneOf([\n 'top', 'top-start', 'top-end', 'right-start', 'right', 'right-end',\n 'left-start', 'left', 'left-end', 'bottom', 'bottom-start', 'bottom-end',\n ]),\n /** The CSS selector for the Checkpoint's desired target. */\n target: PropTypes.string.isRequired,\n /** The text displayed in the title of the Checkpoint */\n title: PropTypes.node,\n })),\n /** The text used in the alt for the icon used to dismiss the tour for the given Checkpoint */\n dismissAltText: PropTypes.string,\n /** Whether the tour is enabled. If there are multiple tours defined, only one should be enabled at a time. */\n enabled: PropTypes.bool.isRequired,\n /** The text displayed on the button used to end the tour. */\n endButtonText: PropTypes.node,\n /** A function that runs when triggering the `onBack` event of the back button. */\n onBack: PropTypes.func,\n /** A function that runs when triggering the `onClick` event of the dismiss button. */\n onDismiss: PropTypes.func,\n /** A function that runs when triggering the `onClick` event of the end button. */\n onEnd: PropTypes.func,\n /** A function that runs when pressing the Escape key. */\n onEscape: PropTypes.func,\n /** The index of the desired `Checkpoint` to render when the tour starts. */\n startingIndex: PropTypes.number,\n /** The ID of the tour */\n tourId: PropTypes.string.isRequired,\n })),\n};\n\n/**\n * Checks if the given object has a deprecated/legacy `dismissButtonText` property.\n * @param {Object} obj - The object to check\n * @returns {boolean} - True if the object has a deprecated/legacy `dismissButtonText` property, false otherwise\n */\nconst hasDismissButtonText = (obj) => {\n if ('dismissButtonText' in obj && !!obj.dismissButtonText) {\n return true;\n }\n return false;\n};\n\nexport default withDeprecatedProps(ProductTour, 'ProductTour', {\n tours: {\n deprType: DeprTypes.FORMAT,\n message: \"The dismissButtonText options in the 'tours' prop have been moved to 'dismissAltText'.\",\n /**\n * Determines whether the given prop value contains the deprecated/legacy `dismissButtonText` property.\n * @param {Object[]} propValue - The tours prop value to check\n * @returns {boolean} True if the prop value contains the deprecated/legacy `dismissButtonText`\n * property, false otherwise\n */\n expect: (propValue) => {\n if (!Array.isArray(propValue)) {\n return true;\n }\n return !propValue.some((tour) => {\n if (hasDismissButtonText(tour)) {\n return true;\n }\n return Array.isArray(tour.checkpoints)\n && tour.checkpoints.some(hasDismissButtonText);\n });\n },\n /**\n * Transforms the given prop value by updating the\n * deprecated/legacy `dismissButtonText` property to\n * `dismissAltText`, if the prop value is a string. Otherwise,\n * the original `dismissButtonText` property is ignored.\n * @param {Object[]} propValue - The tours prop value to transform\n * @returns {Object[]} The transformed prop value\n */\n transform: (propValue) => {\n const tours = propValue.map((tour) => {\n const updatedTour = { ...tour };\n\n // Replace tour level dismissButtonText with dismissAltText\n if (hasDismissButtonText(tour)) {\n if (typeof tour.dismissButtonText === 'string') {\n updatedTour.dismissAltText = tour.dismissButtonText;\n } else {\n const warningMessage = \"[Deprecated] ProductTour: The 'dismissButtonText' options within the 'tours' prop now expects a string\";\n // eslint-disable-next-line no-console\n console.warn(warningMessage);\n }\n }\n\n // Replace checkpoint level dismissButtonText with dismissAltText\n if (Array.isArray(tour.checkpoints)) {\n updatedTour.checkpoints = tour.checkpoints.map((checkpoint) => {\n if (hasDismissButtonText(checkpoint)) {\n const { dismissButtonText, ...rest } = checkpoint;\n if (typeof dismissButtonText === 'string') {\n return { ...rest, dismissAltText: dismissButtonText };\n }\n }\n return checkpoint;\n });\n }\n return updatedTour;\n });\n\n // Return the transformed tours\n return tours;\n },\n },\n});\n"],"mappings":"AAAA,OAAOA,KAAK,IAAIC,SAAS,EAAEC,QAAQ,QAAQ,OAAO;AAClD,OAAOC,SAAS,MAAM,YAAY;AAClC,OAAOC,mBAAmB,IAAIC,SAAS,QAAQ,wBAAwB;AAEvE,OAAOC,UAAU,MAAM,cAAc;AAErC,MAAMC,WAAW,gBAAGP,KAAK,CAACQ,UAAU,CAAC,CAAAC,IAAA,EAAYC,GAAG,KAAK;EAAA,IAAnB;IAAEC;EAAM,CAAC,GAAAF,IAAA;EAC7C,MAAMG,SAAS,GAAGD,KAAK,CAACE,IAAI,CAAEC,IAAI,IAAKA,IAAI,CAACC,OAAO,CAAC;EACpD,MAAM;IACJA,OAAO;IACPC,WAAW,GAAG,EAAE;IAChBC,aAAa;IACbC,QAAQ;IACRC,KAAK;IACLC,SAAS,EAAEC,aAAa;IACxBC,MAA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ACjD,IAAI,OAAO+B,iBAAiB,KAAK,QAAQ,EAAE;gBACzC,OAAO;kBAAE,GAAGe,IAAI;kBAAEpE,cAAc,EAAEqD;gBAAkB,CAAC;cACvD;YACF;YACA,OAAO/B,UAAU;UACnB,CAAC,CAAC;QACJ;QACA,OAAO0C,WAAW;MACpB,CAAC,CAAC;;MAEF;MACA,OAAOjF,KAAK;IACd;EACF;AACF,CAAC,CAAC","ignoreList":[]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openedx/paragon",
3
- "version": "22.20.2",
3
+ "version": "22.20.4",
4
4
  "description": "Accessible, responsive UI component library based on Bootstrap.",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.js",
@@ -1,13 +1,18 @@
1
1
  import React, { useContext, useMemo } from 'react';
2
+ import { useIntl } from 'react-intl';
2
3
  import DataTableContext from './DataTableContext';
3
4
  import { DropdownButton } from '../Dropdown';
4
5
  import useWindowSize from '../hooks/useWindowSizeHook';
5
6
  import breakpoints from '../utils/breakpoints';
7
+ import messages from './messages';
6
8
 
7
9
  /** The first filter will be as an input, additional filters will be available in a dropdown. */
8
10
  function DropdownFilters() {
11
+ const intl = useIntl();
9
12
  const { width } = useWindowSize();
10
- const { columns, numBreakoutFilters } = useContext(DataTableContext);
13
+ const {
14
+ columns, numBreakoutFilters, filtersTitle,
15
+ } = useContext(DataTableContext);
11
16
 
12
17
  const [breakoutFilters, otherFilters] = useMemo(() => {
13
18
  if (!columns) {
@@ -25,6 +30,8 @@ function DropdownFilters() {
25
30
  return [boFilters, dropdownFilters];
26
31
  }, [columns, width, numBreakoutFilters]);
27
32
 
33
+ const dropdownTitle = filtersTitle || intl.formatMessage(messages.filtersDropdownTitle);
34
+
28
35
  return (
29
36
  <div className="pgn__data-table-filters">
30
37
  {breakoutFilters.length > 0 && breakoutFilters.map((column) => (
@@ -33,7 +40,7 @@ function DropdownFilters() {
33
40
  </div>
34
41
  ))}
35
42
  {otherFilters.length > 0 && (
36
- <DropdownButton variant="outline-primary" id="table-filters-dropdown" title="Filters">
43
+ <DropdownButton variant="outline-primary" id="table-filters-dropdown" title={dropdownTitle}>
37
44
  {otherFilters.map((column) => (
38
45
  <div
39
46
  key={column.Header}
@@ -176,7 +176,7 @@ To enable proper selection behavior with backend pagination (i.e., when ``isSele
176
176
  producer: 'Isao Takahata',
177
177
  release_date: 1986,
178
178
  rt_score: 95,
179
- },
179
+ },
180
180
  {
181
181
  id: '12cfb892-aac0-4c5b-94af-521852e46d6a',
182
182
  title: 'Grave of the Fireflies',
@@ -567,7 +567,7 @@ Can be used to show the loading state when ``DataTable`` is asynchronously fetch
567
567
  },
568
568
  ];
569
569
  {/* end example state */}
570
-
570
+
571
571
  return (
572
572
  <>
573
573
  {/* start example form block */}
@@ -634,7 +634,7 @@ You can pass a function to render custom components for bulk actions and table a
634
634
  Enroll
635
635
  </Button>
636
636
  );
637
-
637
+
638
638
  const EnrollAction = ({ selectedFlatRows, ...rest }) => (
639
639
  // Here is access to the selectedFlatRows, isEntireTableSelected, tableInstance
640
640
  <Button variant="danger" onClick={() => console.log('Enroll', selectedFlatRows, rest)}>
@@ -647,13 +647,13 @@ You can pass a function to render custom components for bulk actions and table a
647
647
  Assign
648
648
  </Button>
649
649
  );
650
-
650
+
651
651
  const ExtraAction = ({ text, selectedFlatRows, ...rest }) => (
652
652
  <Button onClick={() => console.log(`Extra Action ${text}`, selectedFlatRows, rest)}>
653
653
  {`Extra Action ${text}`}
654
654
  </Button>
655
655
  );
656
-
656
+
657
657
  return (
658
658
  <DataTable
659
659
  isSelectable
@@ -734,7 +734,7 @@ You can pass a function to render custom components for bulk actions and table a
734
734
  </DataTable>
735
735
  )
736
736
  }
737
-
737
+
738
738
  ```
739
739
 
740
740
  #### Actions with Data view toggle enabled
@@ -889,7 +889,7 @@ a responsive grid of cards.
889
889
  Clear Selection
890
890
  </Component>
891
891
  );
892
-
892
+
893
893
  return (
894
894
  <DataTable
895
895
  isFilterable
@@ -1103,7 +1103,7 @@ Use `columnSizes` prop of `CardView` component to define how many `Cards` are sh
1103
1103
 
1104
1104
  const ExampleCard = ({ className, original }) => {
1105
1105
  const { name, color, famous_for: famousFor } = original;
1106
-
1106
+
1107
1107
  return (
1108
1108
  <Card className={className}>
1109
1109
  <Card.ImageCap src="https://picsum.photos/360/200/" srcAlt="Card image" />
@@ -1195,7 +1195,7 @@ You can also display `Cards` with horizontal view. If the table is selectable co
1195
1195
  <Card.Header title={name} />
1196
1196
  <Card.Section>
1197
1197
  <dl>
1198
- <dt>Color</dt>
1198
+ <dt>Color</dt>
1199
1199
  <dd>{color}</dd>
1200
1200
  <dt>Famous For</dt>
1201
1201
  <dd>{famousFor}</dd>
@@ -1217,7 +1217,7 @@ You can also display `Cards` with horizontal view. If the table is selectable co
1217
1217
  name: 'Lil Bub',
1218
1218
  color: 'brown tabby',
1219
1219
  famous_for: 'weird tongue',
1220
- },
1220
+ },
1221
1221
  {
1222
1222
  name: 'Grumpy Cat',
1223
1223
  color: 'siamese',
@@ -1258,6 +1258,7 @@ For a more desktop friendly view, you can move filters into a sidebar by providi
1258
1258
  ```jsx live
1259
1259
  <DataTable
1260
1260
  showFiltersInSidebar
1261
+ filtersTitle="Color filters"
1261
1262
  isFilterable
1262
1263
  isSortable
1263
1264
  defaultColumnValues={{ Filter: TextFilter }}
@@ -1330,17 +1331,17 @@ For a more desktop friendly view, you can move filters into a sidebar by providi
1330
1331
  ```
1331
1332
 
1332
1333
  ## Expandable rows
1333
- `DataTable` supports expandable rows which once expanded render additional content under the row. Displayed content
1334
+ `DataTable` supports expandable rows which once expanded render additional content under the row. Displayed content
1334
1335
  is controlled by the `renderRowSubComponent` prop, which is a function that receives `row` as its single prop and renders expanded view, you also
1335
1336
  need to pass `isEpandable` prop to `DataTable` to indicate that it should support expand behavior for rows.
1336
- Finally, an additional column is required to be included into `columns` prop which will contain handlers for expand / collapse behavior, see examples below.
1337
+ Finally, an additional column is required to be included into `columns` prop which will contain handlers for expand / collapse behavior, see examples below.
1337
1338
 
1338
1339
  ### Default view
1339
1340
 
1340
1341
  Here we use default expander column offered by Paragon and for each row render value of the `name` attribute as its subcomponent.
1341
1342
 
1342
1343
  ```jsx live
1343
- <DataTable
1344
+ <DataTable
1344
1345
  isExpandable
1345
1346
  itemCount={7}
1346
1347
  renderRowSubComponent={({ row }) => <div className='text-center'>{row.values.name}</div>}
@@ -1457,10 +1458,10 @@ You can create your own custom expander column and use it, see code example belo
1457
1458
  </DataTable>
1458
1459
  </div>
1459
1460
  )
1460
-
1461
+
1461
1462
  return (
1462
1463
  <DataTable
1463
- isExpandable
1464
+ isExpandable
1464
1465
  renderRowSubComponent={renderSubComponent}
1465
1466
  itemCount={3}
1466
1467
  data={[
@@ -1481,7 +1482,7 @@ You can create your own custom expander column and use it, see code example belo
1481
1482
  reason: 'Felt like it',
1482
1483
  },
1483
1484
  {
1484
- name: 'Smoothie',
1485
+ name: 'Smoothie',
1485
1486
  color: 'orange tabby',
1486
1487
  famous_for: 'modeling',
1487
1488
  date_modified: currentDate,
@@ -1527,7 +1528,7 @@ You can create your own cell content by passing the `Cell` property to a specifi
1527
1528
  newColors[index] = cellColors[index] < 3 ? cellColors[index] + 1 : 0;
1528
1529
  setCellColors(newColors);
1529
1530
  };
1530
-
1531
+
1531
1532
  return (
1532
1533
  <DataTable
1533
1534
  isExpandable
@@ -1544,7 +1545,7 @@ You can create your own cell content by passing the `Cell` property to a specifi
1544
1545
  famous_for: 'serving moods',
1545
1546
  },
1546
1547
  {
1547
- name: 'Smoothie',
1548
+ name: 'Smoothie',
1548
1549
  color: 'orange tabby',
1549
1550
  famous_for: 'modeling',
1550
1551
  },
@@ -49,6 +49,7 @@ function DataTable({
49
49
  EmptyTableComponent,
50
50
  manualSelectColumn,
51
51
  showFiltersInSidebar,
52
+ filtersTitle,
52
53
  dataViewToggleOptions,
53
54
  disableElevation,
54
55
  isLoading,
@@ -215,6 +216,7 @@ function DataTable({
215
216
  manualSelectColumn,
216
217
  maxSelectedRows,
217
218
  onMaxSelectedRows,
219
+ filtersTitle,
218
220
  ...selectionProps,
219
221
  ...selectionActions,
220
222
  ...props,
@@ -222,7 +224,7 @@ function DataTable({
222
224
 
223
225
  return (
224
226
  <DataTableContext.Provider value={enhancedInstance}>
225
- <DataTableLayout>
227
+ <DataTableLayout filtersTitle={filtersTitle}>
226
228
  <div className={classNames('pgn__data-table-wrapper', {
227
229
  'hide-shadow': !!disableElevation,
228
230
  })}
@@ -264,6 +266,7 @@ DataTable.defaultProps = {
264
266
  FilterStatusComponent: FilterStatus,
265
267
  RowStatusComponent: RowStatus,
266
268
  showFiltersInSidebar: false,
269
+ filtersTitle: undefined,
267
270
  dataViewToggleOptions: {
268
271
  isDataViewToggleEnabled: false,
269
272
  onDataViewToggle: () => {},
@@ -425,6 +428,8 @@ DataTable.propTypes = {
425
428
  children: PropTypes.node,
426
429
  /** If true filters will be shown on sidebar instead */
427
430
  showFiltersInSidebar: PropTypes.bool,
431
+ /** Title of the filters section */
432
+ filtersTitle: PropTypes.string,
428
433
  /** options for data view toggle */
429
434
  dataViewToggleOptions: PropTypes.shape({
430
435
  /** Whether to show a toggle button group which allows view switching between card and table views */
@@ -6,6 +6,11 @@ const messages = defineMessages({
6
6
  defaultMessage: 'table pagination',
7
7
  description: 'Accessibile name for the navigation element of a pagination component',
8
8
  },
9
+ filtersDropdownTitle: {
10
+ id: 'pgn.DataTable.filtersDropdownTitle',
11
+ defaultMessage: 'Filters',
12
+ description: 'Title of the filters dropdown',
13
+ },
9
14
  });
10
15
 
11
16
  export default messages;
@@ -8,6 +8,7 @@ import DataTable from '..';
8
8
  import DataTableContext from '../DataTableContext';
9
9
  import { TextFilter } from '../..';
10
10
  import { SELECT_ALL_TEST_ID } from '../selection/data/constants';
11
+ import messages from '../messages';
11
12
 
12
13
  const additionalColumns = [
13
14
  {
@@ -162,6 +163,55 @@ describe('<DataTable />', () => {
162
163
  expect(screen.getByText('Action')).toBeInTheDocument();
163
164
  expect(screen.getByText('More')).toBeInTheDocument();
164
165
  });
166
+
167
+ it('displays the custom filters title in the sidebar', () => {
168
+ render(
169
+ <DataTableWrapper
170
+ showFiltersInSidebar
171
+ filtersTitle="Refine Your Search"
172
+ isFilterable
173
+ defaultColumnValues={{ Filter: TextFilter }}
174
+ {...props}
175
+ />,
176
+ );
177
+ expect(screen.getByRole('heading', { name: 'Refine Your Search' })).toBeInTheDocument();
178
+ });
179
+
180
+ it('displays the default filters title in the sidebar', () => {
181
+ render(
182
+ <DataTableWrapper
183
+ showFiltersInSidebar
184
+ isFilterable
185
+ defaultColumnValues={{ Filter: TextFilter }}
186
+ {...props}
187
+ />,
188
+ );
189
+ expect(screen.getByRole('heading', { name: messages.filtersDropdownTitle.defaultMessage })).toBeInTheDocument();
190
+ });
191
+
192
+ it('displays the custom filters title in the filters dropdown', () => {
193
+ render(
194
+ <DataTableWrapper
195
+ filtersTitle="Refine Your Search"
196
+ isFilterable
197
+ defaultColumnValues={{ Filter: TextFilter }}
198
+ {...props}
199
+ />,
200
+ );
201
+ expect(screen.getByRole('button', { name: 'Refine Your Search' })).toBeInTheDocument();
202
+ });
203
+
204
+ it('displays the default filters title in the filters dropdown', () => {
205
+ render(
206
+ <DataTableWrapper
207
+ isFilterable
208
+ defaultColumnValues={{ Filter: TextFilter }}
209
+ {...props}
210
+ />,
211
+ );
212
+ expect(screen.getByRole('button', { name: messages.filtersDropdownTitle.defaultMessage })).toBeInTheDocument();
213
+ });
214
+
165
215
  it('calls useTable with the data and columns', () => {
166
216
  const spy = jest.spyOn(reactTable, 'useTable');
167
217
  render(<DataTableWrapper {...props} />);
@@ -213,7 +263,7 @@ describe('<DataTable />', () => {
213
263
  fetchData: jest.fn(),
214
264
  };
215
265
  render(<DataTableWrapper {...propsWithSelection} />);
216
- const filtersButton = screen.getByRole('button', { name: 'Filters' });
266
+ const filtersButton = screen.getByRole('button', { name: messages.filtersDropdownTitle.defaultMessage });
217
267
 
218
268
  await userEvent.click(filtersButton);
219
269
 
@@ -1,10 +1,12 @@
1
1
  import React from 'react';
2
2
  import { render, screen } from '@testing-library/react';
3
3
  import userEvent from '@testing-library/user-event';
4
+ import { IntlProvider } from 'react-intl';
4
5
 
5
6
  import DropdownFilters from '../DropdownFilters';
6
7
  import { useWindowSize } from '../..';
7
8
  import DataTableContext from '../DataTableContext';
9
+ import messages from '../messages';
8
10
 
9
11
  jest.mock('../../hooks/useWindowSizeHook');
10
12
 
@@ -31,9 +33,11 @@ const instance = {
31
33
  // eslint-disable-next-line react/prop-types
32
34
  function DropdownFiltersWrapper({ value = instance, props }) {
33
35
  return (
34
- <DataTableContext.Provider value={value}>
35
- <DropdownFilters {...props} />
36
- </DataTableContext.Provider>
36
+ <IntlProvider locale="en">
37
+ <DataTableContext.Provider value={value}>
38
+ <DropdownFilters {...props} />
39
+ </DataTableContext.Provider>
40
+ </IntlProvider>
37
41
  );
38
42
  }
39
43
 
@@ -56,7 +60,7 @@ describe('<DropdownFilters />', () => {
56
60
  // filter should be rendered in the dropdown, so should not be present before
57
61
  // clicking the button.
58
62
  expect(screen.queryByText('Occupation filter')).toBeNull();
59
- const filtersButton = screen.getByRole('button', { name: /Filters/i });
63
+ const filtersButton = screen.getByRole('button', { name: messages.filtersDropdownTitle.defaultMessage });
60
64
  await userEvent.click(filtersButton);
61
65
  expect(screen.getByText('Occupation filter')).toBeInTheDocument();
62
66
  });
@@ -65,7 +69,7 @@ describe('<DropdownFilters />', () => {
65
69
  useWindowSize.mockReturnValue({ width: 800 });
66
70
  render(<DropdownFiltersWrapper />);
67
71
  expect(screen.queryByText('DOB filter')).toBeNull();
68
- const filtersButton = screen.getByRole('button', { name: /Filters/i });
72
+ const filtersButton = screen.getByRole('button', { name: messages.filtersDropdownTitle.defaultMessage });
69
73
  await userEvent.click(filtersButton);
70
74
  expect(screen.queryByText('DOB filter')).toBeNull();
71
75
  });
@@ -74,7 +78,7 @@ describe('<DropdownFilters />', () => {
74
78
  useWindowSize.mockReturnValue({ width: 800 });
75
79
  render(<DropdownFiltersWrapper value={{ columns: [instance.columns[1]] }} />);
76
80
  expect(screen.getByText('Occupation filter')).toBeInTheDocument();
77
- expect(screen.queryByRole('button', { name: /Filters/i })).toBeNull();
81
+ expect(screen.queryByRole('button', { name: messages.filtersDropdownTitle.defaultMessage })).toBeNull();
78
82
  });
79
83
  });
80
84
 
@@ -88,7 +92,7 @@ describe('<DropdownFilters />', () => {
88
92
  it('renders all filters in the dropdown', async () => {
89
93
  useWindowSize.mockReturnValue({ width: 500 });
90
94
  render(<DropdownFiltersWrapper />);
91
- const filtersButton = screen.getByRole('button', { name: /Filters/i });
95
+ const filtersButton = screen.getByRole('button', { name: messages.filtersDropdownTitle.defaultMessage });
92
96
  await userEvent.click(filtersButton);
93
97
  expect(screen.getByText('Bears filter')).toBeInTheDocument();
94
98
  expect(screen.getByText('Occupation filter')).toBeInTheDocument();
@@ -19,6 +19,8 @@ describe('<ProductTour />', () => {
19
19
  <div id="target-4">...</div>
20
20
  </>
21
21
  );
22
+ const handleAdvance = jest.fn();
23
+ const handleBack = jest.fn();
22
24
  const handleDismiss = jest.fn();
23
25
  const handleEnd = jest.fn();
24
26
  const handleEscape = jest.fn();
@@ -31,6 +33,8 @@ describe('<ProductTour />', () => {
31
33
  advanceButtonText: 'Next',
32
34
  enabled: false,
33
35
  endButtonText: 'Okay',
36
+ onAdvance: handleAdvance,
37
+ onBack: handleBack,
34
38
  onDismiss: handleDismiss,
35
39
  onEnd: handleEnd,
36
40
  tourId: 'disabledTour',
@@ -48,6 +52,8 @@ describe('<ProductTour />', () => {
48
52
  backButtonText: 'Back',
49
53
  enabled: true,
50
54
  endButtonText: 'Okay',
55
+ onAdvance: handleAdvance,
56
+ onBack: handleBack,
51
57
  onDismiss: handleDismiss,
52
58
  onEnd: handleEnd,
53
59
  tourId: 'enabledTour',
@@ -60,6 +66,7 @@ describe('<ProductTour />', () => {
60
66
  {
61
67
  body: 'Checkpoint 2',
62
68
  target: '#target-2',
69
+ onAdvance: customOnAdvance,
63
70
  },
64
71
  {
65
72
  body: 'Checkpoint 3',
@@ -82,6 +89,7 @@ describe('<ProductTour />', () => {
82
89
 
83
90
  afterEach(() => {
84
91
  popperMock.mockReset();
92
+ jest.resetAllMocks();
85
93
  });
86
94
 
87
95
  // eslint-disable-next-line react/prop-types
@@ -115,6 +123,38 @@ describe('<ProductTour />', () => {
115
123
 
116
124
  // Verify the second Checkpoint has rendered
117
125
  expect(screen.getByText('Checkpoint 2')).toBeInTheDocument();
126
+ expect(handleAdvance).toHaveBeenCalled();
127
+
128
+ await userEvent.click(advanceButton);
129
+ expect(screen.getByText('Checkpoint 3')).toBeInTheDocument();
130
+ expect(customOnAdvance).toHaveBeenCalled();
131
+ });
132
+
133
+ it('onClick of back button rewinds to last checkpoint', async () => {
134
+ render(<ProductTourWrapper tours={[tourData]} />);
135
+ // Verify the first Checkpoint has rendered
136
+ expect(screen.getByRole('heading', { name: 'Checkpoint 1' })).toBeInTheDocument();
137
+
138
+ // Click the advance button
139
+ const advanceButton = screen.getByRole('button', { name: 'Next' });
140
+ await userEvent.click(advanceButton);
141
+
142
+ // go forward to the 3rd checkpoint
143
+ expect(screen.getByText('Checkpoint 2')).toBeInTheDocument();
144
+ await userEvent.click(advanceButton);
145
+ expect(screen.getByText('Checkpoint 3')).toBeInTheDocument();
146
+
147
+ // First back button should use custom on back function
148
+ let backButton = screen.getByRole('button', { name: 'Override back' });
149
+ await userEvent.click(backButton);
150
+ expect(screen.getByText('Checkpoint 2')).toBeInTheDocument();
151
+ expect(customOnBack).toHaveBeenCalled();
152
+
153
+ // Second back button should use the tour's default back function
154
+ backButton = screen.getByRole('button', { name: 'Back' });
155
+ await userEvent.click(backButton);
156
+ expect(screen.getByText('Checkpoint 1')).toBeInTheDocument();
157
+ expect(handleBack).toHaveBeenCalled();
118
158
  });
119
159
 
120
160
  it('onClick of dismiss button disables tour', async () => {
@@ -191,7 +231,6 @@ describe('<ProductTour />', () => {
191
231
 
192
232
  // Verify no Checkpoints have rendered
193
233
  expect(screen.queryByRole('dialog')).not.toBeInTheDocument();
194
- expect(handleEnd).toHaveBeenCalledTimes(1);
195
234
  expect(customOnEnd).not.toHaveBeenCalled();
196
235
  });
197
236
 
@@ -284,7 +323,6 @@ describe('<ProductTour />', () => {
284
323
  expect(screen.getByText('Checkpoint 4')).toBeInTheDocument();
285
324
  const endButton = screen.getByRole('button', { name: 'Override end' });
286
325
  await user.click(endButton);
287
- expect(handleEnd).toBeCalledTimes(1);
288
326
  expect(customOnEnd).toHaveBeenCalledTimes(1);
289
327
  expect(screen.queryByText('Checkpoint 4')).not.toBeInTheDocument();
290
328
  });
@@ -12,7 +12,8 @@ const ProductTour = React.forwardRef(({ tours }, ref) => {
12
12
  startingIndex,
13
13
  onEscape,
14
14
  onEnd,
15
- onBack,
15
+ onAdvance: tourOnAdvance,
16
+ onBack: tourOnBack,
16
17
  onDismiss: tourOnDismiss,
17
18
  advanceButtonText: tourAdvanceButtonText,
18
19
  dismissAltText: tourDismissAltText,
@@ -27,6 +28,7 @@ const ProductTour = React.forwardRef(({ tours }, ref) => {
27
28
  title,
28
29
  body,
29
30
  onAdvance,
31
+ onBack,
30
32
  onDismiss,
31
33
  advanceButtonText,
32
34
  dismissAltText,
@@ -85,6 +87,8 @@ const ProductTour = React.forwardRef(({ tours }, ref) => {
85
87
  setIndex(index + 1);
86
88
  if (onAdvance) {
87
89
  onAdvance();
90
+ } else if (tourOnAdvance) {
91
+ tourOnAdvance();
88
92
  }
89
93
  };
90
94
 
@@ -92,6 +96,8 @@ const ProductTour = React.forwardRef(({ tours }, ref) => {
92
96
  setIndex(index - 1);
93
97
  if (onBack) {
94
98
  onBack();
99
+ } else if (tourOnBack) {
100
+ tourOnBack();
95
101
  }
96
102
  };
97
103
 
@@ -100,7 +106,7 @@ const ProductTour = React.forwardRef(({ tours }, ref) => {
100
106
  setIsTourEnabled(false);
101
107
  if (onDismiss) {
102
108
  onDismiss();
103
- } else {
109
+ } else if (tourOnDismiss) {
104
110
  tourOnDismiss();
105
111
  }
106
112
  setCurrentCheckpointData(null);