@openedx/paragon 21.6.0 → 21.6.1
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/DataTable/FilterStatus.js +7 -2
- package/dist/DataTable/FilterStatus.js.map +1 -1
- package/package.json +1 -1
- package/src/Breadcrumb/README.md +6 -6
- package/src/DataTable/FilterStatus.jsx +6 -2
- package/src/DataTable/tests/FilterStatus.test.jsx +2 -1
- package/src/DataTable/tests/SmartStatus.test.jsx +2 -0
- package/src/Menu/README.md +0 -2
|
@@ -14,12 +14,17 @@ function FilterStatus(_ref) {
|
|
|
14
14
|
} = _ref;
|
|
15
15
|
const {
|
|
16
16
|
state,
|
|
17
|
-
setAllFilters
|
|
17
|
+
setAllFilters,
|
|
18
|
+
headers
|
|
18
19
|
} = useContext(DataTableContext);
|
|
19
20
|
if (!setAllFilters) {
|
|
20
21
|
return null;
|
|
21
22
|
}
|
|
22
|
-
const
|
|
23
|
+
const headersMap = headers.reduce((cur, acc) => {
|
|
24
|
+
cur[acc.id] = acc.Header;
|
|
25
|
+
return cur;
|
|
26
|
+
}, {});
|
|
27
|
+
const filterNames = state.filters ? state.filters.map(filter => headersMap[filter.id]) : [];
|
|
23
28
|
const filterTexts = /*#__PURE__*/React.createElement("p", null, "Filtered by ", filterNames.join(', '));
|
|
24
29
|
return /*#__PURE__*/React.createElement("div", {
|
|
25
30
|
className: className
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FilterStatus.js","names":["React","useContext","PropTypes","FormattedMessage","DataTableContext","Button","FilterStatus","_ref","className","variant","size","clearFiltersText","buttonClassName","showFilteredFields","state","setAllFilters","filterNames","filters","map","filter","
|
|
1
|
+
{"version":3,"file":"FilterStatus.js","names":["React","useContext","PropTypes","FormattedMessage","DataTableContext","Button","FilterStatus","_ref","className","variant","size","clearFiltersText","buttonClassName","showFilteredFields","state","setAllFilters","headers","headersMap","reduce","cur","acc","id","Header","filterNames","filters","map","filter","filterTexts","createElement","join","onClick","undefined","defaultMessage","description","defaultProps","propTypes","string","oneOfType","element","bool"],"sources":["../../src/DataTable/FilterStatus.jsx"],"sourcesContent":["import React, { useContext } from 'react';\nimport PropTypes from 'prop-types';\nimport { FormattedMessage } from 'react-intl';\nimport DataTableContext from './DataTableContext';\nimport Button from '../Button';\n\nfunction FilterStatus({\n className, variant, size, clearFiltersText, buttonClassName, showFilteredFields,\n}) {\n const { state, setAllFilters, headers } = useContext(DataTableContext);\n if (!setAllFilters) {\n return null;\n }\n\n const headersMap = headers.reduce((cur, acc) => {\n cur[acc.id] = acc.Header;\n return cur;\n }, {});\n const filterNames = state.filters ? state.filters.map((filter) => headersMap[filter.id]) : [];\n const filterTexts = <p>Filtered by {filterNames.join(', ')}</p>;\n\n return (\n <div className={className}>\n {showFilteredFields && filterTexts}\n <Button\n className={buttonClassName}\n variant={variant}\n size={size}\n onClick={() => setAllFilters([])}\n >\n {clearFiltersText === undefined\n ? (\n <FormattedMessage\n id=\"pgn.DataTable.FilterStatus.clearFiltersText\"\n defaultMessage=\"Clear filters\"\n description=\"A text that appears on the `Clear filters` button\"\n />\n )\n : clearFiltersText}\n </Button>\n </div>\n );\n}\n\nFilterStatus.defaultProps = {\n /** Specifies class name to append to the base element. */\n className: null,\n /** Specifies class name to append to the button. */\n buttonClassName: 'pgn__smart-status-button',\n /** The visual style of the `FilterStatus`. */\n variant: 'link',\n /** The size of the `FilterStatus`. */\n size: 'inline',\n /** A text that appears on the `Clear filters` button, defaults to 'Clear filters'. */\n clearFiltersText: undefined,\n /** Whether to display applied filters. */\n showFilteredFields: true,\n};\n\nFilterStatus.propTypes = {\n className: PropTypes.string,\n buttonClassName: PropTypes.string,\n variant: PropTypes.string,\n size: PropTypes.string,\n clearFiltersText: PropTypes.oneOfType([PropTypes.element, PropTypes.string]),\n showFilteredFields: PropTypes.bool,\n};\n\nexport default FilterStatus;\n"],"mappings":"AAAA,OAAOA,KAAK,IAAIC,UAAU,QAAQ,OAAO;AACzC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aAAA,CAACzB,gBAAgB;IACfkB,EAAE,EAAC,6CAA6C;IAChDW,cAAc,EAAC,eAAe;IAC9BC,WAAW,EAAC;EAAmD,CAChE,CAAC,GAEFtB,gBACE,CACL,CAAC;AAEV;AAEAL,YAAY,CAAC4B,YAAY,GAAG;EAC1B;EACA1B,SAAS,EAAE,IAAI;EACf;EACAI,eAAe,EAAE,0BAA0B;EAC3C;EACAH,OAAO,EAAE,MAAM;EACf;EACAC,IAAI,EAAE,QAAQ;EACd;EACAC,gBAAgB,EAAEoB,SAAS;EAC3B;EACAlB,kBAAkB,EAAE;AACtB,CAAC;AAEDP,YAAY,CAAC6B,SAAS,GAAG;EACvB3B,SAAS,EAAEN,SAAS,CAACkC,MAAM;EAC3BxB,eAAe,EAAEV,SAAS,CAACkC,MAAM;EACjC3B,OAAO,EAAEP,SAAS,CAACkC,MAAM;EACzB1B,IAAI,EAAER,SAAS,CAACkC,MAAM;EACtBzB,gBAAgB,EAAET,SAAS,CAACmC,SAAS,CAAC,CAACnC,SAAS,CAACoC,OAAO,EAAEpC,SAAS,CAACkC,MAAM,CAAC,CAAC;EAC5EvB,kBAAkB,EAAEX,SAAS,CAACqC;AAChC,CAAC;AAED,eAAejC,YAAY"}
|
package/package.json
CHANGED
package/src/Breadcrumb/README.md
CHANGED
|
@@ -38,9 +38,9 @@ Use as a secondary navigation pattern to help convey hierarchy and enable naviga
|
|
|
38
38
|
```jsx live
|
|
39
39
|
<Breadcrumb ariaLabel="Breadcrumb mobile view"
|
|
40
40
|
links={[
|
|
41
|
-
{ label: 'Link 1', href: '
|
|
42
|
-
{ label: 'Link 2', href: '
|
|
43
|
-
{ label: 'Link 3', href: '
|
|
41
|
+
{ label: 'Link 1', href: '#link-1' },
|
|
42
|
+
{ label: 'Link 2', href: '#link-2' },
|
|
43
|
+
{ label: 'Link 3', href: '#link-3' },
|
|
44
44
|
]}
|
|
45
45
|
isMobile
|
|
46
46
|
/>
|
|
@@ -56,9 +56,9 @@ Use as a secondary navigation pattern to help convey hierarchy and enable naviga
|
|
|
56
56
|
<div className="bg-dark-700 p-4">
|
|
57
57
|
<Breadcrumb ariaLabel="Breadcrumb inverse pallete"
|
|
58
58
|
links={[
|
|
59
|
-
{label: 'Link 1', href: '
|
|
60
|
-
{label: 'Link 2', href: '
|
|
61
|
-
{label: 'Link 3', href: '
|
|
59
|
+
{label: 'Link 1', href: '#link-1'},
|
|
60
|
+
{label: 'Link 2', href: '#link-2'},
|
|
61
|
+
{label: 'Link 3', href: '#link-3'},
|
|
62
62
|
]}
|
|
63
63
|
variant="dark"
|
|
64
64
|
isMobile={isExtraSmall}
|
|
@@ -7,12 +7,16 @@ import Button from '../Button';
|
|
|
7
7
|
function FilterStatus({
|
|
8
8
|
className, variant, size, clearFiltersText, buttonClassName, showFilteredFields,
|
|
9
9
|
}) {
|
|
10
|
-
const { state, setAllFilters } = useContext(DataTableContext);
|
|
10
|
+
const { state, setAllFilters, headers } = useContext(DataTableContext);
|
|
11
11
|
if (!setAllFilters) {
|
|
12
12
|
return null;
|
|
13
13
|
}
|
|
14
14
|
|
|
15
|
-
const
|
|
15
|
+
const headersMap = headers.reduce((cur, acc) => {
|
|
16
|
+
cur[acc.id] = acc.Header;
|
|
17
|
+
return cur;
|
|
18
|
+
}, {});
|
|
19
|
+
const filterNames = state.filters ? state.filters.map((filter) => headersMap[filter.id]) : [];
|
|
16
20
|
const filterTexts = <p>Filtered by {filterNames.join(', ')}</p>;
|
|
17
21
|
|
|
18
22
|
return (
|
|
@@ -7,8 +7,9 @@ import FilterStatus from '../FilterStatus';
|
|
|
7
7
|
import DataTableContext from '../DataTableContext';
|
|
8
8
|
|
|
9
9
|
const filterNames = ['color', 'breed', 'discipline'];
|
|
10
|
+
const headers = [{ id: 'color', Header: 'color' }, { id: 'breed', Header: 'breed' }, { id: 'discipline', Header: 'discipline' }];
|
|
10
11
|
const filters = filterNames.map((name) => ({ id: name }));
|
|
11
|
-
const instance = { state: { filters }, setAllFilters: () => {} };
|
|
12
|
+
const instance = { state: { filters }, setAllFilters: () => {}, headers };
|
|
12
13
|
const filterProps = {
|
|
13
14
|
buttonClassName: 'buttonClass',
|
|
14
15
|
variant: 'variant',
|
|
@@ -9,6 +9,7 @@ import RowStatus from '../RowStatus';
|
|
|
9
9
|
import SelectionStatus from '../selection/SelectionStatus';
|
|
10
10
|
|
|
11
11
|
const filters = [{ id: 'name' }, { id: 'age' }];
|
|
12
|
+
const headers = [{ id: 'name', Header: 'name' }, { id: 'age', Header: 'age' }];
|
|
12
13
|
const filterNames = ['name', 'age'];
|
|
13
14
|
const itemCount = 101;
|
|
14
15
|
const instance = {
|
|
@@ -22,6 +23,7 @@ const instance = {
|
|
|
22
23
|
SelectionStatusComponent: SelectionStatus,
|
|
23
24
|
FilterStatusComponent: FilterStatus,
|
|
24
25
|
RowStatusComponent: RowStatus,
|
|
26
|
+
headers,
|
|
25
27
|
};
|
|
26
28
|
|
|
27
29
|
// eslint-disable-next-line react/prop-types
|
package/src/Menu/README.md
CHANGED
|
@@ -12,8 +12,6 @@ devStatus: 'Done'
|
|
|
12
12
|
notes: ''
|
|
13
13
|
---
|
|
14
14
|
|
|
15
|
-
## Menu
|
|
16
|
-
|
|
17
15
|
An arrow-key navigable ``Menu`` which consists of ``MenuItems``. A ``Menu`` can be employed to produce its common variants, including dropdown menus, select menus, and others. ``Menus`` are keyboard navigable with both tab and arrow keys.
|
|
18
16
|
|
|
19
17
|
## MenuItem
|