@openedx/paragon 23.14.8 → 23.15.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/Card/CardBody.d.ts +9 -0
- package/dist/Card/CardBody.js +0 -11
- package/dist/Card/CardBody.js.map +1 -1
- package/dist/Card/CardContext.d.ts +17 -0
- package/dist/Card/CardContext.js +8 -21
- package/dist/Card/CardContext.js.map +1 -1
- package/dist/Card/CardDivider.d.ts +7 -0
- package/dist/Card/CardDivider.js +2 -10
- package/dist/Card/CardDivider.js.map +1 -1
- package/dist/Card/CardFallbackDefaultImage.d.ts +1 -0
- package/dist/Card/CardFallbackDefaultImage.js +1 -0
- package/dist/Card/CardFallbackDefaultImage.js.map +1 -0
- package/dist/Card/CardGrid.d.ts +22 -0
- package/dist/Card/CardGrid.js +6 -31
- package/dist/Card/CardGrid.js.map +1 -1
- package/dist/Chip/constants.js +0 -1
- package/dist/Chip/constants.js.map +1 -1
- package/dist/Container/index.js +0 -1
- package/dist/Container/index.js.map +1 -1
- package/dist/DataTable/CollapsibleButtonGroup.js +0 -1
- package/dist/DataTable/CollapsibleButtonGroup.js.map +1 -1
- package/dist/DataTable/DataTableContext.d.ts +3 -0
- package/dist/DataTable/DataTableContext.js.map +1 -1
- package/dist/DataTable/TableCell.d.ts +14 -0
- package/dist/DataTable/TableCell.js +0 -12
- package/dist/DataTable/TableCell.js.map +1 -1
- package/dist/DataTable/TableHeaderCell.d.ts +26 -0
- package/dist/DataTable/TableHeaderCell.js +4 -32
- package/dist/DataTable/TableHeaderCell.js.map +1 -1
- package/dist/DataTable/filters/CheckboxFilter.js +1 -1
- package/dist/DataTable/filters/CheckboxFilter.js.map +1 -1
- package/dist/DataTable/index.js +7 -2
- package/dist/DataTable/index.js.map +1 -1
- package/dist/Dropdown/index.js +10 -18
- package/dist/Dropdown/index.js.map +1 -1
- package/dist/Menu/MenuItem.d.ts +17 -0
- package/dist/Menu/MenuItem.js +5 -27
- package/dist/Menu/MenuItem.js.map +1 -1
- package/dist/Menu/index.d.ts +16 -0
- package/dist/Menu/index.js +4 -24
- package/dist/Menu/index.js.map +1 -1
- package/dist/Modal/ModalDialogHeader.js +4 -1
- package/dist/Modal/ModalDialogHeader.js.map +1 -1
- package/dist/Modal/ModalLayer.js +7 -12
- package/dist/Modal/ModalLayer.js.map +1 -1
- package/dist/OverflowScroll/data/constants.d.ts +1 -0
- package/dist/OverflowScroll/data/constants.js +1 -2
- package/dist/OverflowScroll/data/constants.js.map +1 -0
- package/dist/PageBanner/index.d.ts +27 -0
- package/dist/PageBanner/index.js +5 -28
- package/dist/PageBanner/index.js.map +1 -1
- package/dist/ProductTour/index.js +5 -7
- package/dist/ProductTour/index.js.map +1 -1
- package/dist/ProgressBar/utils.js +0 -1
- package/dist/SelectableBox/utils.js +1 -1
- package/dist/Sheet/SheetContainer.js +30 -8
- package/dist/Sheet/SheetContainer.js.map +1 -1
- package/dist/Sheet/index.js +15 -5
- package/dist/Sheet/index.js.map +1 -1
- package/dist/Stack/index.d.ts +20 -0
- package/dist/Stack/index.js +3 -28
- package/dist/Stack/index.js.map +1 -1
- package/dist/Sticky/index.js +1 -2
- package/dist/Sticky/index.js.map +1 -1
- package/dist/Tabs/Tab.d.ts +19 -0
- package/dist/Tabs/Tab.js +0 -23
- package/dist/Tabs/Tab.js.map +1 -1
- package/dist/asInput/index.js +7 -14
- package/dist/asInput/index.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -2
- package/dist/index.js.map +1 -1
- package/dist/setupTest.js.map +1 -1
- package/dist/utils/index.js +0 -1
- package/dist/utils/index.js.map +1 -1
- package/lib/version.js +1 -2
- package/package.json +3 -3
- package/src/Card/CardBody.tsx +19 -0
- package/src/Card/CardCarousel/tests/CardCarousel.test.jsx +0 -1
- package/src/Card/{CardContext.jsx → CardContext.tsx} +24 -25
- package/src/Card/CardDivider.tsx +13 -0
- package/src/Card/{CardGrid.jsx → CardGrid.tsx} +28 -35
- package/src/Chip/constants.ts +0 -1
- package/src/ChipCarousel/ChipCarousel.test.jsx +9 -11
- package/src/Container/index.tsx +0 -1
- package/src/DataTable/CollapsibleButtonGroup.jsx +0 -1
- package/src/DataTable/README.md +12 -12
- package/src/DataTable/{TableCell.jsx → TableCell.tsx} +13 -15
- package/src/DataTable/{TableHeaderCell.jsx → TableHeaderCell.tsx} +32 -33
- package/src/DataTable/filters/CheckboxFilter.jsx +1 -1
- package/src/DataTable/filters/tests/CheckboxFilter.test.jsx +31 -0
- package/src/DataTable/index.jsx +6 -2
- package/src/DataTable/selection/tests/utils.js +0 -1
- package/src/DataTable/tablecontrolbar.mdx +4 -4
- package/src/DataTable/tablefilters.mdx +8 -8
- package/src/DataTable/tests/DataTable.test.jsx +6 -4
- package/src/DataTable/tests/TableHeaderCell.test.jsx +0 -1
- package/src/DataTable/utils/tests/getTableArgs.test.js +3 -2
- package/src/DataTable/utils/tests/getVisibleColumns.test.js +0 -2
- package/src/Dropdown/index.jsx +11 -16
- package/src/Form/tests/useCheckboxSetValues.test.jsx +17 -9
- package/src/Menu/MenuItem.tsx +49 -0
- package/src/Menu/{index.jsx → index.tsx} +18 -27
- package/src/Modal/ModalDialogHeader.tsx +5 -1
- package/src/Modal/ModalLayer.tsx +1 -2
- package/src/Modal/tests/ModalLayer.test.tsx +1 -2
- package/src/OverflowScroll/data/{constants.js → constants.ts} +0 -2
- package/src/PageBanner/{index.jsx → index.tsx} +27 -29
- package/src/ProductTour/index.jsx +5 -7
- package/src/ProgressBar/utils.js +0 -1
- package/src/SelectableBox/tests/SelectableBox.test.jsx +0 -1
- package/src/SelectableBox/utils.js +1 -1
- package/src/Sheet/Sheet.test.jsx +63 -3
- package/src/Sheet/SheetContainer.jsx +34 -7
- package/src/Sheet/SheetContainer.test.jsx +34 -1
- package/src/Sheet/__snapshots__/Sheet.test.jsx.snap +15 -6
- package/src/Sheet/index.jsx +12 -2
- package/src/Stack/{index.jsx → index.tsx} +22 -35
- package/src/Sticky/index.jsx +1 -1
- package/src/Tabs/{Tab.jsx → Tab.tsx} +10 -18
- package/src/TransitionReplace/README.md +2 -2
- package/src/TransitionReplace/TransitionReplace.test.jsx +1 -1
- package/src/asInput/index.jsx +0 -3
- package/src/hooks/tests/useToggle.test.tsx +4 -5
- package/src/index.ts +1 -2
- package/src/setupTest.ts +0 -1
- package/src/utils/index.ts +0 -1
- package/src/Card/CardBody.jsx +0 -23
- package/src/Card/CardDivider.jsx +0 -18
- package/src/Menu/MenuItem.jsx +0 -57
- /package/src/Card/{CardFallbackDefaultImage.js → CardFallbackDefaultImage.ts} +0 -0
- /package/src/DataTable/{DataTableContext.jsx → DataTableContext.tsx} +0 -0
package/src/DataTable/README.md
CHANGED
|
@@ -423,17 +423,17 @@ See ``dataViewToggleOptions`` props documentation for all supported props.
|
|
|
423
423
|
Filter: CheckboxFilter,
|
|
424
424
|
filter: 'includesValue',
|
|
425
425
|
filterChoices: [{
|
|
426
|
-
name: '
|
|
426
|
+
name: 'Orange Tabby',
|
|
427
427
|
number: 1,
|
|
428
428
|
value: 'orange tabby',
|
|
429
429
|
},
|
|
430
430
|
{
|
|
431
|
-
name: '
|
|
431
|
+
name: 'Brown Tabby',
|
|
432
432
|
number: 1,
|
|
433
433
|
value: 'brown tabby',
|
|
434
434
|
},
|
|
435
435
|
{
|
|
436
|
-
name: '
|
|
436
|
+
name: 'Siamese',
|
|
437
437
|
number: 1,
|
|
438
438
|
value: 'siamese',
|
|
439
439
|
}],
|
|
@@ -503,17 +503,17 @@ See ``dataViewToggleOptions`` props documentation for all supported props.
|
|
|
503
503
|
Filter: CheckboxFilter,
|
|
504
504
|
filter: 'includesValue',
|
|
505
505
|
filterChoices: [{
|
|
506
|
-
name: '
|
|
506
|
+
name: 'Orange Tabby',
|
|
507
507
|
number: 1,
|
|
508
508
|
value: 'orange tabby',
|
|
509
509
|
},
|
|
510
510
|
{
|
|
511
|
-
name: '
|
|
511
|
+
name: 'Brown Tabby',
|
|
512
512
|
number: 1,
|
|
513
513
|
value: 'brown tabby',
|
|
514
514
|
},
|
|
515
515
|
{
|
|
516
|
-
name: '
|
|
516
|
+
name: 'Siamese',
|
|
517
517
|
number: 1,
|
|
518
518
|
value: 'siamese',
|
|
519
519
|
}]
|
|
@@ -1306,17 +1306,17 @@ For a more desktop friendly view, you can move filters into a sidebar by providi
|
|
|
1306
1306
|
Filter: CheckboxFilter,
|
|
1307
1307
|
filter: 'includesValue',
|
|
1308
1308
|
filterChoices: [{
|
|
1309
|
-
name: '
|
|
1309
|
+
name: 'Orange Tabby',
|
|
1310
1310
|
number: 2,
|
|
1311
1311
|
value: 'orange tabby',
|
|
1312
1312
|
},
|
|
1313
1313
|
{
|
|
1314
|
-
name: '
|
|
1314
|
+
name: 'Brown Tabby',
|
|
1315
1315
|
number: 2,
|
|
1316
1316
|
value: 'brown tabby',
|
|
1317
1317
|
},
|
|
1318
1318
|
{
|
|
1319
|
-
name: '
|
|
1319
|
+
name: 'Siamese',
|
|
1320
1320
|
number: 1,
|
|
1321
1321
|
value: 'siamese',
|
|
1322
1322
|
}]
|
|
@@ -1659,17 +1659,17 @@ After selecting the maximum possible number of rows, you can display an error me
|
|
|
1659
1659
|
filter: 'includesValue',
|
|
1660
1660
|
filterChoices: [
|
|
1661
1661
|
{
|
|
1662
|
-
name: '
|
|
1662
|
+
name: 'Russian white',
|
|
1663
1663
|
number: 1,
|
|
1664
1664
|
value: 'russian white',
|
|
1665
1665
|
},
|
|
1666
1666
|
{
|
|
1667
|
-
name: '
|
|
1667
|
+
name: 'Orange Tabby',
|
|
1668
1668
|
number: 2,
|
|
1669
1669
|
value: 'orange tabby',
|
|
1670
1670
|
},
|
|
1671
1671
|
{
|
|
1672
|
-
name: '
|
|
1672
|
+
name: 'Brown Tabby',
|
|
1673
1673
|
number: 3,
|
|
1674
1674
|
value: 'brown tabby',
|
|
1675
1675
|
},
|
|
@@ -1,8 +1,18 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import PropTypes from 'prop-types';
|
|
1
|
+
import React, { ReactNode, TdHTMLAttributes } from 'react';
|
|
3
2
|
import classNames from 'classnames';
|
|
4
3
|
|
|
5
|
-
|
|
4
|
+
interface TableCellProps {
|
|
5
|
+
/** Props for the td element */
|
|
6
|
+
getCellProps: () => TdHTMLAttributes<HTMLTableCellElement>;
|
|
7
|
+
/** Function that renders the cell contents. Will be called with the string 'Cell' */
|
|
8
|
+
render: (type: 'Cell') => ReactNode;
|
|
9
|
+
/** Table column */
|
|
10
|
+
column: {
|
|
11
|
+
/** Class(es) to be applied to the cells in the given column */
|
|
12
|
+
cellClassName?: string;
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
function TableCell({ getCellProps, render, column }: TableCellProps) {
|
|
6
16
|
const { className, ...rest } = getCellProps();
|
|
7
17
|
return (
|
|
8
18
|
<td {...rest} className={classNames('pgn__data-table-cell-wrap', className, column.cellClassName)}>
|
|
@@ -11,16 +21,4 @@ function TableCell({ getCellProps, render, column }) {
|
|
|
11
21
|
);
|
|
12
22
|
}
|
|
13
23
|
|
|
14
|
-
TableCell.propTypes = {
|
|
15
|
-
/** Props for the td element */
|
|
16
|
-
getCellProps: PropTypes.func.isRequired,
|
|
17
|
-
/** Function that renders the cell contents. Will be called with the string 'Cell' */
|
|
18
|
-
render: PropTypes.func.isRequired,
|
|
19
|
-
/** Table column */
|
|
20
|
-
column: PropTypes.shape({
|
|
21
|
-
/** Class(es) to be applied to the cells in the given column */
|
|
22
|
-
cellClassName: PropTypes.string,
|
|
23
|
-
}).isRequired,
|
|
24
|
-
};
|
|
25
|
-
|
|
26
24
|
export default TableCell;
|
|
@@ -1,10 +1,16 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import PropTypes from 'prop-types';
|
|
3
2
|
import classNames from 'classnames';
|
|
4
3
|
import Icon from '../Icon';
|
|
5
4
|
import { ArrowDropDown, ArrowDropUp, ArrowDropUpDown } from '../../icons';
|
|
6
5
|
|
|
7
|
-
|
|
6
|
+
interface SortIndicatorProps {
|
|
7
|
+
/** Indicates whether or not a column is sorted */
|
|
8
|
+
isSorted: boolean;
|
|
9
|
+
/** Indicates whether the column is sorted in descending order */
|
|
10
|
+
isSortedDesc: boolean;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export function SortIndicator({ isSorted, isSortedDesc }: SortIndicatorProps) {
|
|
8
14
|
if (!isSorted) {
|
|
9
15
|
return <Icon style={{ opacity: 0.5 }} src={ArrowDropUpDown} data-testid="arrow-drop-up-down" />;
|
|
10
16
|
}
|
|
@@ -16,14 +22,32 @@ export function SortIndicator({ isSorted, isSortedDesc }) {
|
|
|
16
22
|
return <Icon src={ArrowDropUp} data-testid="arrow-drop-up" />;
|
|
17
23
|
}
|
|
18
24
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
25
|
+
interface TableHeaderCellProps {
|
|
26
|
+
/** Returns props for the th element */
|
|
27
|
+
getHeaderProps: (...args: any[]) => Record<string, any>;
|
|
28
|
+
/** Indicates whether or not a column is sorted */
|
|
29
|
+
isSorted?: boolean;
|
|
30
|
+
/** Renders the header content. Passed the string 'Header' */
|
|
31
|
+
render: (type: 'Header') => React.ReactNode;
|
|
32
|
+
/** Indicates whether the column is sorted in descending order */
|
|
33
|
+
isSortedDesc?: boolean;
|
|
34
|
+
/** Gets props related to sorting that will be passed to th */
|
|
35
|
+
getSortByToggleProps?: (...args: any[]) => Record<string, any>;
|
|
36
|
+
/** Indicates whether a column is sortable */
|
|
37
|
+
canSort?: boolean;
|
|
38
|
+
/** Class(es) to be applied to header cells */
|
|
39
|
+
headerClassName?: string;
|
|
40
|
+
}
|
|
23
41
|
|
|
24
42
|
function TableHeaderCell({
|
|
25
|
-
getHeaderProps,
|
|
26
|
-
|
|
43
|
+
getHeaderProps,
|
|
44
|
+
render,
|
|
45
|
+
canSort = false,
|
|
46
|
+
getSortByToggleProps = () => ({}),
|
|
47
|
+
isSorted = false,
|
|
48
|
+
isSortedDesc = false,
|
|
49
|
+
headerClassName,
|
|
50
|
+
}: TableHeaderCellProps) {
|
|
27
51
|
const toggleProps = canSort && getSortByToggleProps ? getSortByToggleProps() : {};
|
|
28
52
|
|
|
29
53
|
return (
|
|
@@ -36,29 +60,4 @@ function TableHeaderCell({
|
|
|
36
60
|
);
|
|
37
61
|
}
|
|
38
62
|
|
|
39
|
-
TableHeaderCell.defaultProps = {
|
|
40
|
-
headerClassName: null,
|
|
41
|
-
isSorted: false,
|
|
42
|
-
isSortedDesc: false,
|
|
43
|
-
canSort: false,
|
|
44
|
-
getSortByToggleProps: () => {},
|
|
45
|
-
};
|
|
46
|
-
|
|
47
|
-
TableHeaderCell.propTypes = {
|
|
48
|
-
/** Returns props for the th element */
|
|
49
|
-
getHeaderProps: PropTypes.func.isRequired,
|
|
50
|
-
/** Indicates whether or not a column is sorted */
|
|
51
|
-
isSorted: PropTypes.bool,
|
|
52
|
-
/** Renders the header content. Passed the string 'Header' */
|
|
53
|
-
render: PropTypes.func.isRequired,
|
|
54
|
-
/** Indicates whether the column is sorted in descending order */
|
|
55
|
-
isSortedDesc: PropTypes.bool,
|
|
56
|
-
/** Gets props related to sorting that will be passed to th */
|
|
57
|
-
getSortByToggleProps: PropTypes.func,
|
|
58
|
-
/** Indicates whether a column is sortable */
|
|
59
|
-
canSort: PropTypes.bool,
|
|
60
|
-
/** Class(es) to be applied to header cells */
|
|
61
|
-
headerClassName: PropTypes.string,
|
|
62
|
-
};
|
|
63
|
-
|
|
64
63
|
export default TableHeaderCell;
|
|
@@ -31,7 +31,7 @@ function CheckboxFilter({
|
|
|
31
31
|
{filterChoices.map(({ name, number, value }) => (
|
|
32
32
|
<Form.Checkbox
|
|
33
33
|
key={`${headerBasedId}${name}`}
|
|
34
|
-
value={
|
|
34
|
+
value={value}
|
|
35
35
|
checked={checkedBoxes.includes(value)}
|
|
36
36
|
onChange={() => changeCheckbox(value)}
|
|
37
37
|
aria-label={name}
|
|
@@ -83,4 +83,35 @@ describe('<CheckboxFilter />', () => {
|
|
|
83
83
|
expect(checkbox).not.toBeChecked();
|
|
84
84
|
});
|
|
85
85
|
});
|
|
86
|
+
|
|
87
|
+
it('uses value for filtering when name and value differ', async () => {
|
|
88
|
+
const testChoice = { name: 'Test', value: 'test' };
|
|
89
|
+
const propsWithCaseDifference = {
|
|
90
|
+
column: {
|
|
91
|
+
...props.column,
|
|
92
|
+
filterChoices: [testChoice],
|
|
93
|
+
filterValue: [],
|
|
94
|
+
},
|
|
95
|
+
};
|
|
96
|
+
|
|
97
|
+
const { rerender } = render(<CheckboxFilter {...propsWithCaseDifference} />);
|
|
98
|
+
|
|
99
|
+
const checkbox = screen.getByLabelText(testChoice.name);
|
|
100
|
+
|
|
101
|
+
await userEvent.click(checkbox);
|
|
102
|
+
|
|
103
|
+
expect(setFilterMock).toHaveBeenCalledWith([testChoice.value]);
|
|
104
|
+
|
|
105
|
+
rerender(<CheckboxFilter column={{
|
|
106
|
+
...propsWithCaseDifference.column,
|
|
107
|
+
filterValue: [testChoice.value],
|
|
108
|
+
}}
|
|
109
|
+
/>);
|
|
110
|
+
|
|
111
|
+
expect(checkbox).toBeChecked();
|
|
112
|
+
|
|
113
|
+
await userEvent.click(checkbox);
|
|
114
|
+
|
|
115
|
+
expect(setFilterMock).toHaveBeenCalledWith([]);
|
|
116
|
+
});
|
|
86
117
|
});
|
package/src/DataTable/index.jsx
CHANGED
|
@@ -52,6 +52,7 @@ function DataTable({
|
|
|
52
52
|
filtersTitle,
|
|
53
53
|
dataViewToggleOptions,
|
|
54
54
|
disableElevation,
|
|
55
|
+
className,
|
|
55
56
|
isLoading,
|
|
56
57
|
children,
|
|
57
58
|
onSelectedRowsChanged,
|
|
@@ -224,7 +225,7 @@ function DataTable({
|
|
|
224
225
|
|
|
225
226
|
return (
|
|
226
227
|
<DataTableContext.Provider value={enhancedInstance}>
|
|
227
|
-
<DataTableLayout filtersTitle={filtersTitle}>
|
|
228
|
+
<DataTableLayout filtersTitle={filtersTitle} className={className}>
|
|
228
229
|
<div className={classNames('pgn__data-table-wrapper', {
|
|
229
230
|
'hide-shadow': !!disableElevation,
|
|
230
231
|
})}
|
|
@@ -275,6 +276,7 @@ DataTable.defaultProps = {
|
|
|
275
276
|
},
|
|
276
277
|
disableElevation: false,
|
|
277
278
|
renderRowSubComponent: undefined,
|
|
279
|
+
className: undefined,
|
|
278
280
|
isExpandable: false,
|
|
279
281
|
isLoading: false,
|
|
280
282
|
onSelectedRowsChanged: undefined,
|
|
@@ -321,7 +323,7 @@ DataTable.propTypes = {
|
|
|
321
323
|
isPaginated: PropTypes.bool,
|
|
322
324
|
/** Indicates that pagination will be done manually. A fetchData function must be provided */
|
|
323
325
|
manualPagination: PropTypes.bool,
|
|
324
|
-
|
|
326
|
+
/** Number of pages in the table. Required when manualPagination is true */
|
|
325
327
|
pageCount: requiredWhen(PropTypes.number, 'manualPagination'),
|
|
326
328
|
/** Table rows can be filtered, using a default filter in the default column values, or in the column definition */
|
|
327
329
|
isFilterable: PropTypes.bool,
|
|
@@ -428,6 +430,8 @@ DataTable.propTypes = {
|
|
|
428
430
|
children: PropTypes.node,
|
|
429
431
|
/** If true filters will be shown on sidebar instead */
|
|
430
432
|
showFiltersInSidebar: PropTypes.bool,
|
|
433
|
+
/** Class name for the data table layout */
|
|
434
|
+
className: PropTypes.string,
|
|
431
435
|
/** Title of the filters section */
|
|
432
436
|
filtersTitle: PropTypes.string,
|
|
433
437
|
/** options for data view toggle */
|
|
@@ -2,7 +2,6 @@ import { act } from 'react-dom/test-utils';
|
|
|
2
2
|
|
|
3
3
|
import { CheckboxControl } from '../../../Form';
|
|
4
4
|
|
|
5
|
-
// eslint-disable-next-line import/prefer-default-export
|
|
6
5
|
export const toggleCheckbox = ({ isChecked, wrapper }) => {
|
|
7
6
|
act(() => {
|
|
8
7
|
wrapper.find(CheckboxControl).simulate('change', { target: { checked: isChecked } });
|
|
@@ -73,22 +73,22 @@ It always shows the `SmartStatus` component. If applicable, it displays the `Dro
|
|
|
73
73
|
Filter: CheckboxFilter,
|
|
74
74
|
filter: 'includesValue',
|
|
75
75
|
filterChoices: [{
|
|
76
|
-
name: '
|
|
76
|
+
name: 'Russian white',
|
|
77
77
|
number: 1,
|
|
78
78
|
value: 'russian white',
|
|
79
79
|
},
|
|
80
80
|
{
|
|
81
|
-
name: '
|
|
81
|
+
name: 'Orange Tabby',
|
|
82
82
|
number: 2,
|
|
83
83
|
value: 'orange tabby',
|
|
84
84
|
},
|
|
85
85
|
{
|
|
86
|
-
name: '
|
|
86
|
+
name: 'Brown Tabby',
|
|
87
87
|
number: 3,
|
|
88
88
|
value: 'brown tabby',
|
|
89
89
|
},
|
|
90
90
|
{
|
|
91
|
-
name: '
|
|
91
|
+
name: 'Siamese',
|
|
92
92
|
number: 1,
|
|
93
93
|
value: 'siamese',
|
|
94
94
|
}]
|
|
@@ -104,22 +104,22 @@ all filters will be rendered in the dropdown.
|
|
|
104
104
|
Filter: CheckboxFilter,
|
|
105
105
|
filter: 'includesValue',
|
|
106
106
|
filterChoices: [{
|
|
107
|
-
name: '
|
|
107
|
+
name: 'Russian white',
|
|
108
108
|
number: 1,
|
|
109
109
|
value: 'russian white',
|
|
110
110
|
},
|
|
111
111
|
{
|
|
112
|
-
name: '
|
|
112
|
+
name: 'Orange Tabby',
|
|
113
113
|
number: 2,
|
|
114
114
|
value: 'orange tabby',
|
|
115
115
|
},
|
|
116
116
|
{
|
|
117
|
-
name: '
|
|
117
|
+
name: 'Brown Tabby',
|
|
118
118
|
number: 3,
|
|
119
119
|
value: 'brown tabby',
|
|
120
120
|
},
|
|
121
121
|
{
|
|
122
|
-
name: '
|
|
122
|
+
name: 'Siamese',
|
|
123
123
|
number: 1,
|
|
124
124
|
value: 'siamese',
|
|
125
125
|
}]
|
|
@@ -227,22 +227,22 @@ all filters will be rendered in the dropdown.
|
|
|
227
227
|
Filter: CheckboxFilter,
|
|
228
228
|
filter: 'includesValue',
|
|
229
229
|
filterChoices: [{
|
|
230
|
-
name: '
|
|
230
|
+
name: 'Russian white',
|
|
231
231
|
number: 1,
|
|
232
232
|
value: 'russian white',
|
|
233
233
|
},
|
|
234
234
|
{
|
|
235
|
-
name: '
|
|
235
|
+
name: 'Orange Tabby',
|
|
236
236
|
number: 2,
|
|
237
237
|
value: 'orange tabby',
|
|
238
238
|
},
|
|
239
239
|
{
|
|
240
|
-
name: '
|
|
240
|
+
name: 'Brown Tabby',
|
|
241
241
|
number: 3,
|
|
242
242
|
value: 'brown tabby',
|
|
243
243
|
},
|
|
244
244
|
{
|
|
245
|
-
name: '
|
|
245
|
+
name: 'Siamese',
|
|
246
246
|
number: 1,
|
|
247
247
|
value: 'siamese',
|
|
248
248
|
}]
|
|
@@ -14,13 +14,11 @@ const additionalColumns = [
|
|
|
14
14
|
{
|
|
15
15
|
id: 'action',
|
|
16
16
|
Header: 'Action',
|
|
17
|
-
// eslint-disable-next-line react/prop-types
|
|
18
17
|
Cell: () => <div>extra content</div>,
|
|
19
18
|
},
|
|
20
19
|
{
|
|
21
20
|
id: 'action2',
|
|
22
21
|
Header: 'More',
|
|
23
|
-
// eslint-disable-next-line react/prop-types
|
|
24
22
|
Cell: () => <div>extra content</div>,
|
|
25
23
|
},
|
|
26
24
|
];
|
|
@@ -227,8 +225,12 @@ describe('<DataTable />', () => {
|
|
|
227
225
|
[{ manualFilters: true, pageCount: 1 }, { manualFilters: true, manualPagination: false, manualSortBy: false }],
|
|
228
226
|
[{ manualPagination: true, pageCount: 1 }, { manualFilters: false, manualPagination: true, manualSortBy: false }],
|
|
229
227
|
[{ manualSortBy: true, pageCount: 1 }, { manualFilters: false, manualPagination: false, manualSortBy: true }],
|
|
230
|
-
|
|
231
|
-
|
|
228
|
+
[
|
|
229
|
+
{
|
|
230
|
+
manualSortBy: true, manualFilters: true, manualPagination: true, pageCount: 1,
|
|
231
|
+
},
|
|
232
|
+
{ manualFilters: true, manualPagination: true, manualSortBy: true },
|
|
233
|
+
],
|
|
232
234
|
])('calls useTable with the correct manual settings %#', (additionalProps, expected) => {
|
|
233
235
|
const spy = jest.spyOn(reactTable, 'useTable');
|
|
234
236
|
render(<DataTableWrapper {...props} {...additionalProps} />);
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
/* eslint-disable object-curly-newline */
|
|
2
1
|
import {
|
|
3
2
|
useSortBy, useFilters, useRowSelect, usePagination, useExpanded,
|
|
4
3
|
} from 'react-table';
|
|
@@ -19,7 +18,9 @@ describe('getTableArgs', () => {
|
|
|
19
18
|
[{ tableOptions, isFilterable: true, isSelectable: true }, [tableOptions, useFilters, useRowSelect]],
|
|
20
19
|
[{ tableOptions, isFilterable: true, isExpandable: true }, [tableOptions, useFilters, useExpanded]],
|
|
21
20
|
[
|
|
22
|
-
{
|
|
21
|
+
{
|
|
22
|
+
tableOptions, isFilterable: true, isSelectable: true, isSortable: true, isPaginated: true, isExpandable: true,
|
|
23
|
+
},
|
|
23
24
|
[tableOptions, useFilters, useSortBy, useExpanded, usePagination, useRowSelect],
|
|
24
25
|
],
|
|
25
26
|
[
|
package/src/Dropdown/index.jsx
CHANGED
|
@@ -9,15 +9,14 @@ import Button from '../Button';
|
|
|
9
9
|
import IconButton from '../IconButton';
|
|
10
10
|
|
|
11
11
|
const Dropdown = React.forwardRef(
|
|
12
|
-
|
|
13
|
-
function Dropdown({
|
|
12
|
+
({
|
|
14
13
|
show,
|
|
15
14
|
autoClose,
|
|
16
15
|
onToggle,
|
|
17
16
|
variant,
|
|
18
17
|
className,
|
|
19
18
|
...rest
|
|
20
|
-
}, ref) {
|
|
19
|
+
}, ref) => {
|
|
21
20
|
const [internalShow, setInternalShow] = React.useState(show);
|
|
22
21
|
const isClosingPermitted = (source) => {
|
|
23
22
|
// autoClose=false only permits close on button click
|
|
@@ -89,12 +88,11 @@ Dropdown.defaultProps = {
|
|
|
89
88
|
};
|
|
90
89
|
|
|
91
90
|
const DropdownToggle = React.forwardRef(
|
|
92
|
-
|
|
93
|
-
function DropdownToggle({
|
|
91
|
+
({
|
|
94
92
|
as,
|
|
95
93
|
bsPrefix,
|
|
96
94
|
...otherProps
|
|
97
|
-
}, ref) {
|
|
95
|
+
}, ref) => {
|
|
98
96
|
// hide arrow from the toggle if it is rendered as IconButton
|
|
99
97
|
// because it hinders the positioning of IconButton
|
|
100
98
|
const prefix = as === IconButton ? 'pgn__dropdown-toggle-iconbutton' : bsPrefix;
|
|
@@ -117,16 +115,13 @@ DropdownToggle.defaultProps = {
|
|
|
117
115
|
};
|
|
118
116
|
|
|
119
117
|
Dropdown.Item = React.forwardRef(
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
/>
|
|
128
|
-
);
|
|
129
|
-
},
|
|
118
|
+
({ className, ...otherProps }, ref) => (
|
|
119
|
+
<BaseDropdownItem
|
|
120
|
+
className={classNames(className, 'pgn__dropdown-item')}
|
|
121
|
+
ref={ref}
|
|
122
|
+
{...otherProps}
|
|
123
|
+
/>
|
|
124
|
+
),
|
|
130
125
|
);
|
|
131
126
|
|
|
132
127
|
Dropdown.Item.propTypes = {
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
/* eslint-disable react/button-has-type */
|
|
2
1
|
import React from 'react';
|
|
3
2
|
import { render, screen } from '@testing-library/react';
|
|
4
3
|
import userEvent from '@testing-library/user-event';
|
|
5
4
|
|
|
5
|
+
import Button from '../../Button';
|
|
6
6
|
import useCheckboxSetValues from '../useCheckboxSetValues';
|
|
7
7
|
|
|
8
8
|
const VALUES = 'values';
|
|
@@ -14,10 +14,18 @@ function Example() {
|
|
|
14
14
|
return (
|
|
15
15
|
<>
|
|
16
16
|
<span data-testid={VALUES}>{values.join(' ')}</span>
|
|
17
|
-
<
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
<
|
|
17
|
+
<Button onClick={() => add('provolone')}>
|
|
18
|
+
Add
|
|
19
|
+
</Button>
|
|
20
|
+
<Button onClick={() => remove('provolone')}>
|
|
21
|
+
Remove
|
|
22
|
+
</Button>
|
|
23
|
+
<Button onClick={() => set(['cheddar', 'swiss', 'provolone'])}>
|
|
24
|
+
Set
|
|
25
|
+
</Button>
|
|
26
|
+
<Button onClick={() => clear()}>
|
|
27
|
+
Clear
|
|
28
|
+
</Button>
|
|
21
29
|
</>
|
|
22
30
|
);
|
|
23
31
|
}
|
|
@@ -31,7 +39,7 @@ describe('useCheckboxSetValues', () => {
|
|
|
31
39
|
|
|
32
40
|
it('can append a value', async () => {
|
|
33
41
|
render(<Example />);
|
|
34
|
-
const addButton = screen.
|
|
42
|
+
const addButton = screen.getByRole('button', { name: 'Add' });
|
|
35
43
|
const values = screen.getByTestId(VALUES);
|
|
36
44
|
|
|
37
45
|
await userEvent.click(addButton);
|
|
@@ -41,7 +49,7 @@ describe('useCheckboxSetValues', () => {
|
|
|
41
49
|
|
|
42
50
|
it('can remove a value', async () => {
|
|
43
51
|
render(<Example />);
|
|
44
|
-
const removeButton = screen.
|
|
52
|
+
const removeButton = screen.getByRole('button', { name: 'Remove' });
|
|
45
53
|
const values = screen.getByTestId(VALUES);
|
|
46
54
|
|
|
47
55
|
await userEvent.click(removeButton);
|
|
@@ -51,7 +59,7 @@ describe('useCheckboxSetValues', () => {
|
|
|
51
59
|
|
|
52
60
|
it('can replace all values', async () => {
|
|
53
61
|
render(<Example />);
|
|
54
|
-
const setButton = screen.
|
|
62
|
+
const setButton = screen.getByRole('button', { name: 'Set' });
|
|
55
63
|
const values = screen.getByTestId(VALUES);
|
|
56
64
|
|
|
57
65
|
await userEvent.click(setButton);
|
|
@@ -61,7 +69,7 @@ describe('useCheckboxSetValues', () => {
|
|
|
61
69
|
|
|
62
70
|
it('can clear all values', async () => {
|
|
63
71
|
render(<Example />);
|
|
64
|
-
const clearButton = screen.
|
|
72
|
+
const clearButton = screen.getByRole('button', { name: 'Clear' });
|
|
65
73
|
const values = screen.getByTestId(VALUES);
|
|
66
74
|
|
|
67
75
|
await userEvent.click(clearButton);
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import React, {
|
|
2
|
+
ReactElement, ReactNode, ElementType, createElement, ComponentType,
|
|
3
|
+
} from 'react';
|
|
4
|
+
import classNames from 'classnames';
|
|
5
|
+
import Icon from '../Icon';
|
|
6
|
+
|
|
7
|
+
interface MenuItemProps {
|
|
8
|
+
/** Specifies that this `MenuItem` is selected inside the `SelectMenu` */
|
|
9
|
+
defaultSelected?: boolean;
|
|
10
|
+
/** Specifies class name to append to the base element */
|
|
11
|
+
className?: string;
|
|
12
|
+
/** Specifies the content of the `MenuItem` */
|
|
13
|
+
children: ReactNode;
|
|
14
|
+
/** Specifies the base element */
|
|
15
|
+
as?: ElementType;
|
|
16
|
+
/** Specifies the jsx before the content of the `MenuItem` */
|
|
17
|
+
iconBefore?: ReactElement | ElementType;
|
|
18
|
+
/** Specifies the jsx after the content of the `MenuItem` */
|
|
19
|
+
iconAfter?: ReactElement | ElementType;
|
|
20
|
+
}
|
|
21
|
+
function MenuItem({
|
|
22
|
+
as = 'button',
|
|
23
|
+
children,
|
|
24
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
25
|
+
defaultSelected = false,
|
|
26
|
+
iconAfter,
|
|
27
|
+
iconBefore,
|
|
28
|
+
...props
|
|
29
|
+
}: MenuItemProps) {
|
|
30
|
+
const className = classNames(props.className, 'pgn__menu-item');
|
|
31
|
+
|
|
32
|
+
return createElement(
|
|
33
|
+
as,
|
|
34
|
+
{
|
|
35
|
+
...props,
|
|
36
|
+
className,
|
|
37
|
+
},
|
|
38
|
+
(
|
|
39
|
+
<>
|
|
40
|
+
{iconBefore && <Icon className="btn-icon-before" src={iconBefore as ComponentType} />}
|
|
41
|
+
<span className="pgn__menu-item-text">{children}</span>
|
|
42
|
+
<span className="pgn__menu-item-content-spacer" />
|
|
43
|
+
{iconAfter && <Icon className="btn-icon-after" src={iconAfter as ComponentType} />}
|
|
44
|
+
</>
|
|
45
|
+
),
|
|
46
|
+
);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export default MenuItem;
|