@openedx/paragon 22.0.0-alpha.23 → 22.0.0-alpha.25
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/bin/paragon-scripts.js +1 -1
- package/dist/Button/index.js +2 -2
- package/dist/Button/index.js.map +1 -1
- package/dist/Button/index.scss +3 -3
- package/dist/ColorPicker/index.js +48 -18
- package/dist/ColorPicker/index.js.map +1 -1
- package/dist/Container/index.js +6 -2
- package/dist/Container/index.js.map +1 -1
- package/dist/DataTable/index.js +2 -1
- package/dist/DataTable/index.js.map +1 -1
- package/dist/DataTable/selection/BaseSelectionStatus.js +3 -2
- package/dist/DataTable/selection/BaseSelectionStatus.js.map +1 -1
- package/dist/Dropdown/index.js.map +1 -1
- package/dist/Dropzone/index.js +2 -3
- package/dist/Dropzone/index.js.map +1 -1
- package/dist/Form/FormAutosuggest.js +9 -4
- package/dist/Form/FormAutosuggest.js.map +1 -1
- package/dist/Form/FormSwitch.js +3 -0
- package/dist/Form/FormSwitch.js.map +1 -1
- package/dist/Hyperlink/index.js +7 -6
- package/dist/Hyperlink/index.js.map +1 -1
- package/dist/Icon/index.js +18 -11
- package/dist/Icon/index.js.map +1 -1
- package/dist/IconButton/index.js +1 -1
- package/dist/IconButton/index.js.map +1 -1
- package/dist/Layout/index.js.map +1 -1
- package/dist/Menu/MenuItem.js +2 -2
- package/dist/Menu/MenuItem.js.map +1 -1
- package/dist/Modal/ModalDialog.js +3 -0
- package/dist/Modal/ModalDialog.js.map +1 -1
- package/dist/Popover/index.js +8 -8
- package/dist/Popover/index.js.map +1 -1
- package/dist/ProductTour/Checkpoint.js +10 -8
- package/dist/ProductTour/Checkpoint.js.map +1 -1
- package/dist/ProductTour/messages.js +16 -0
- package/dist/SearchField/SearchFieldAdvanced.js +12 -7
- package/dist/SearchField/SearchFieldAdvanced.js.map +1 -1
- package/dist/SearchField/SearchFieldLabel.js +3 -3
- package/dist/SearchField/SearchFieldLabel.js.map +1 -1
- package/dist/SearchField/index.js +0 -1
- package/dist/SearchField/index.js.map +1 -1
- package/dist/Tabs/index.js +13 -13
- package/dist/Tabs/index.js.map +1 -1
- package/dist/core.css +8 -6
- package/dist/core.css.map +1 -1
- package/dist/core.min.css +1 -1
- package/dist/hooks/useIndexOfLastVisibleChild.js +33 -38
- package/dist/hooks/useIndexOfLastVisibleChild.js.map +1 -1
- package/dist/i18n/messages/ar.json +2 -1
- package/dist/i18n/messages/ca.json +2 -1
- package/dist/i18n/messages/es_419.json +2 -1
- package/dist/i18n/messages/es_AR.json +2 -1
- package/dist/i18n/messages/es_ES.json +2 -1
- package/dist/i18n/messages/fr.json +2 -1
- package/dist/i18n/messages/he.json +2 -1
- package/dist/i18n/messages/id.json +2 -1
- package/dist/i18n/messages/it_IT.json +2 -1
- package/dist/i18n/messages/ko_KR.json +2 -1
- package/dist/i18n/messages/pl.json +2 -1
- package/dist/i18n/messages/pt_BR.json +2 -1
- package/dist/i18n/messages/pt_PT.json +2 -1
- package/dist/i18n/messages/ru.json +2 -1
- package/dist/i18n/messages/th.json +2 -1
- package/dist/i18n/messages/tr_TR.json +2 -1
- package/dist/i18n/messages/uk.json +2 -1
- package/dist/i18n/messages/zh_CN.json +2 -1
- package/dist/light.css +11 -11
- package/dist/light.css.map +1 -1
- package/dist/light.min.css +1 -1
- package/icons/es5/RightSidebarFilled.js +15 -0
- package/icons/es5/RightSidebarOutlined.js +15 -0
- package/icons/es5/index.js +2 -0
- package/icons/jsx/RightSidebarFilled.jsx +19 -0
- package/icons/jsx/RightSidebarOutlined.jsx +19 -0
- package/icons/jsx/index.jsx +2 -0
- package/icons/svg/right_sidebar_filled.svg +3 -0
- package/icons/svg/right_sidebar_outlined.svg +3 -0
- package/lib/utils.js +23 -2
- package/package.json +3 -3
- package/src/Button/README.md +94 -68
- package/src/Button/index.jsx +2 -2
- package/src/Button/index.scss +3 -3
- package/src/ColorPicker/ColorPicker.test.jsx +24 -2
- package/src/ColorPicker/index.jsx +56 -16
- package/src/Container/index.jsx +4 -0
- package/src/DataTable/README.md +3 -3
- package/src/DataTable/index.jsx +2 -1
- package/src/DataTable/selection/BaseSelectionStatus.jsx +2 -2
- package/src/DataTable/tablefilters.mdx +3 -3
- package/src/DataTable/tests/DataTable.test.jsx +31 -0
- package/src/Dropdown/index.jsx +4 -0
- package/src/Dropzone/index.jsx +2 -3
- package/src/Form/FormAutosuggest.jsx +11 -5
- package/src/Form/FormSwitch.jsx +3 -0
- package/src/Form/form-autosuggest.mdx +80 -72
- package/src/Form/tests/FormAutosuggest.test.jsx +21 -0
- package/src/Hyperlink/index.jsx +7 -6
- package/src/Icon/index.jsx +18 -11
- package/src/IconButton/index.jsx +1 -1
- package/src/Layout/index.jsx +1 -4
- package/src/Menu/MenuItem.jsx +2 -2
- package/src/Modal/ModalDialog.jsx +3 -0
- package/src/Overlay/README.md +1 -1
- package/src/Popover/README.md +0 -1
- package/src/Popover/index.jsx +11 -11
- package/src/ProductTour/Checkpoint.jsx +9 -6
- package/src/ProductTour/messages.js +16 -0
- package/src/SearchField/SearchFieldAdvanced.jsx +12 -7
- package/src/SearchField/SearchFieldLabel.jsx +3 -3
- package/src/SearchField/index.jsx +0 -1
- package/src/SelectableBox/tests/SelectableBoxSet.test.jsx +1 -1
- package/src/Tabs/index.jsx +19 -13
- package/src/hooks/tests/useIndexOfLastVisibleChild.test.jsx +3 -3
- package/src/hooks/useIndexOfLastVisibleChild.jsx +36 -38
- package/src/hooks/useIndexOfLastVisibleChild.mdx +3 -3
- package/src/i18n/messages/ar.json +2 -1
- package/src/i18n/messages/ca.json +2 -1
- package/src/i18n/messages/es_419.json +2 -1
- package/src/i18n/messages/es_AR.json +2 -1
- package/src/i18n/messages/es_ES.json +2 -1
- package/src/i18n/messages/fr.json +2 -1
- package/src/i18n/messages/he.json +2 -1
- package/src/i18n/messages/id.json +2 -1
- package/src/i18n/messages/it_IT.json +2 -1
- package/src/i18n/messages/ko_KR.json +2 -1
- package/src/i18n/messages/pl.json +2 -1
- package/src/i18n/messages/pt_BR.json +2 -1
- package/src/i18n/messages/pt_PT.json +2 -1
- package/src/i18n/messages/ru.json +2 -1
- package/src/i18n/messages/th.json +2 -1
- package/src/i18n/messages/tr_TR.json +2 -1
- package/src/i18n/messages/uk.json +2 -1
- package/src/i18n/messages/zh_CN.json +2 -1
- package/styles/css/core/variables.css +5 -3
- package/styles/css/themes/light/variables.css +11 -11
- package/tokens/src/core/components/Button/core.json +8 -4
- package/tokens/src/themes/light/alias/color.json +10 -10
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
2
|
+
import * as React from "react";
|
|
3
|
+
const SvgRightSidebarFilled = props => /*#__PURE__*/React.createElement("svg", _extends({
|
|
4
|
+
width: 24,
|
|
5
|
+
height: 24,
|
|
6
|
+
viewBox: "0 0 24 24",
|
|
7
|
+
fill: "none",
|
|
8
|
+
xmlns: "http://www.w3.org/2000/svg"
|
|
9
|
+
}, props), /*#__PURE__*/React.createElement("path", {
|
|
10
|
+
fillRule: "evenodd",
|
|
11
|
+
clipRule: "evenodd",
|
|
12
|
+
d: "M2 22V2h20v20H2ZM14 4H4v16h10V4Z",
|
|
13
|
+
fill: "currentColor"
|
|
14
|
+
}));
|
|
15
|
+
export default SvgRightSidebarFilled;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
2
|
+
import * as React from "react";
|
|
3
|
+
const SvgRightSidebarOutlined = props => /*#__PURE__*/React.createElement("svg", _extends({
|
|
4
|
+
width: 24,
|
|
5
|
+
height: 24,
|
|
6
|
+
viewBox: "0 0 24 24",
|
|
7
|
+
fill: "none",
|
|
8
|
+
xmlns: "http://www.w3.org/2000/svg"
|
|
9
|
+
}, props), /*#__PURE__*/React.createElement("path", {
|
|
10
|
+
fillRule: "evenodd",
|
|
11
|
+
clipRule: "evenodd",
|
|
12
|
+
d: "M2 2v20h20V2H2Zm18 2h-4v16h4V4ZM4 4h10v16H4V4Z",
|
|
13
|
+
fill: "currentColor"
|
|
14
|
+
}));
|
|
15
|
+
export default SvgRightSidebarOutlined;
|
package/icons/es5/index.js
CHANGED
|
@@ -1694,6 +1694,8 @@ export { default as RestoreFromTrash } from "./RestoreFromTrash";
|
|
|
1694
1694
|
export { default as RestorePage } from "./RestorePage";
|
|
1695
1695
|
export { default as Reviews } from "./Reviews";
|
|
1696
1696
|
export { default as RiceBowl } from "./RiceBowl";
|
|
1697
|
+
export { default as RightSidebarFilled } from "./RightSidebarFilled";
|
|
1698
|
+
export { default as RightSidebarOutlined } from "./RightSidebarOutlined";
|
|
1697
1699
|
export { default as RingVolume } from "./RingVolume";
|
|
1698
1700
|
export { default as Rocket } from "./Rocket";
|
|
1699
1701
|
export { default as RocketLaunch } from "./RocketLaunch";
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
const SvgRightSidebarFilled = (props) => (
|
|
3
|
+
<svg
|
|
4
|
+
width={24}
|
|
5
|
+
height={24}
|
|
6
|
+
viewBox="0 0 24 24"
|
|
7
|
+
fill="none"
|
|
8
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
9
|
+
{...props}
|
|
10
|
+
>
|
|
11
|
+
<path
|
|
12
|
+
fillRule="evenodd"
|
|
13
|
+
clipRule="evenodd"
|
|
14
|
+
d="M2 22V2h20v20H2ZM14 4H4v16h10V4Z"
|
|
15
|
+
fill="currentColor"
|
|
16
|
+
/>
|
|
17
|
+
</svg>
|
|
18
|
+
);
|
|
19
|
+
export default SvgRightSidebarFilled;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
const SvgRightSidebarOutlined = (props) => (
|
|
3
|
+
<svg
|
|
4
|
+
width={24}
|
|
5
|
+
height={24}
|
|
6
|
+
viewBox="0 0 24 24"
|
|
7
|
+
fill="none"
|
|
8
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
9
|
+
{...props}
|
|
10
|
+
>
|
|
11
|
+
<path
|
|
12
|
+
fillRule="evenodd"
|
|
13
|
+
clipRule="evenodd"
|
|
14
|
+
d="M2 2v20h20V2H2Zm18 2h-4v16h4V4ZM4 4h10v16H4V4Z"
|
|
15
|
+
fill="currentColor"
|
|
16
|
+
/>
|
|
17
|
+
</svg>
|
|
18
|
+
);
|
|
19
|
+
export default SvgRightSidebarOutlined;
|
package/icons/jsx/index.jsx
CHANGED
|
@@ -1694,6 +1694,8 @@ export { default as RestoreFromTrash } from "./RestoreFromTrash";
|
|
|
1694
1694
|
export { default as RestorePage } from "./RestorePage";
|
|
1695
1695
|
export { default as Reviews } from "./Reviews";
|
|
1696
1696
|
export { default as RiceBowl } from "./RiceBowl";
|
|
1697
|
+
export { default as RightSidebarFilled } from "./RightSidebarFilled";
|
|
1698
|
+
export { default as RightSidebarOutlined } from "./RightSidebarOutlined";
|
|
1697
1699
|
export { default as RingVolume } from "./RingVolume";
|
|
1698
1700
|
export { default as Rocket } from "./Rocket";
|
|
1699
1701
|
export { default as RocketLaunch } from "./RocketLaunch";
|
package/lib/utils.js
CHANGED
|
@@ -1,4 +1,25 @@
|
|
|
1
|
-
|
|
1
|
+
const axios = require('axios');
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Sends request to the Netlify function to inform about specified event.
|
|
5
|
+
* @param {string} eventId - tracking event id
|
|
6
|
+
* @param {object} properties - tracking properties
|
|
7
|
+
*/
|
|
8
|
+
function sendTrackInfo(eventId, properties) {
|
|
9
|
+
const { BASE_URL, TRACK_ANONYMOUS_ANALYTICS } = process.env;
|
|
10
|
+
if (TRACK_ANONYMOUS_ANALYTICS) {
|
|
11
|
+
const url = `${BASE_URL}/.netlify/functions/sendTrackData`;
|
|
12
|
+
axios.post(url, { eventId, properties })
|
|
13
|
+
.then(result => {
|
|
14
|
+
// eslint-disable-next-line no-console
|
|
15
|
+
console.log(`Track info is successfully sent (status ${result.status})`);
|
|
16
|
+
}).catch(error => {
|
|
17
|
+
// eslint-disable-next-line no-console
|
|
18
|
+
console.log(`Track info request failed (${error})`);
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
|
|
2
23
|
function capitalize(str) {
|
|
3
24
|
if (typeof str !== 'string' || str.length === 0) {
|
|
4
25
|
return '';
|
|
@@ -6,4 +27,4 @@ function capitalize(str) {
|
|
|
6
27
|
return str.charAt(0).toUpperCase() + str.slice(1);
|
|
7
28
|
}
|
|
8
29
|
|
|
9
|
-
module.exports = { capitalize };
|
|
30
|
+
module.exports = { sendTrackInfo, capitalize };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@openedx/paragon",
|
|
3
|
-
"version": "22.0.0-alpha.
|
|
3
|
+
"version": "22.0.0-alpha.25",
|
|
4
4
|
"description": "Accessible, responsive UI component library based on Bootstrap.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.js",
|
|
@@ -116,11 +116,11 @@
|
|
|
116
116
|
"@formatjs/cli": "^5.0.2",
|
|
117
117
|
"@semantic-release/changelog": "^6.0.1",
|
|
118
118
|
"@semantic-release/git": "^10.0.1",
|
|
119
|
-
"@testing-library/jest-dom": "^
|
|
119
|
+
"@testing-library/jest-dom": "^6.1.4",
|
|
120
120
|
"@testing-library/react": "^12.1.4",
|
|
121
121
|
"@testing-library/react-hooks": "^8.0.1",
|
|
122
122
|
"@testing-library/user-event": "^13.5.0",
|
|
123
|
-
"@types/jest": "^
|
|
123
|
+
"@types/jest": "^29.5.10",
|
|
124
124
|
"@types/react": "17.0.0",
|
|
125
125
|
"@types/react-dom": "17.0.11",
|
|
126
126
|
"@types/react-test-renderer": "^18.0.0",
|
package/src/Button/README.md
CHANGED
|
@@ -20,11 +20,11 @@ This component utilizes `Button` from React-Bootstrap and extends it with an abi
|
|
|
20
20
|
|
|
21
21
|
return (
|
|
22
22
|
<Stack gap={2} direction={ isExtraSmall ? "vertical" : "horizontal" }>
|
|
23
|
-
<Button variant="brand"
|
|
24
|
-
<Button variant="outline-brand"
|
|
25
|
-
<Button variant="primary"
|
|
26
|
-
<Button variant="outline-primary"
|
|
27
|
-
<Button variant="tertiary"
|
|
23
|
+
<Button variant="brand">Brand</Button>
|
|
24
|
+
<Button variant="outline-brand">Outline Brand</Button>
|
|
25
|
+
<Button variant="primary">Primary</Button>
|
|
26
|
+
<Button variant="outline-primary">Outline Primary</Button>
|
|
27
|
+
<Button variant="tertiary">Tertiary</Button>
|
|
28
28
|
</Stack>
|
|
29
29
|
)}
|
|
30
30
|
```
|
|
@@ -41,11 +41,11 @@ This component utilizes `Button` from React-Bootstrap and extends it with an abi
|
|
|
41
41
|
gap={2}
|
|
42
42
|
direction={ isExtraSmall ? "vertical" : "horizontal" }
|
|
43
43
|
>
|
|
44
|
-
<Button variant="inverse-brand"
|
|
45
|
-
<Button variant="inverse-outline-brand"
|
|
46
|
-
<Button variant="inverse-primary"
|
|
47
|
-
<Button variant="inverse-outline-primary"
|
|
48
|
-
<Button variant="inverse-tertiary"
|
|
44
|
+
<Button variant="inverse-brand">Brand</Button>
|
|
45
|
+
<Button variant="inverse-outline-brand">Outline Brand</Button>
|
|
46
|
+
<Button variant="inverse-primary">Primary</Button>
|
|
47
|
+
<Button variant="inverse-outline-primary">Outline Primary</Button>
|
|
48
|
+
<Button variant="inverse-tertiary">Tertiary</Button>
|
|
49
49
|
</Stack>
|
|
50
50
|
)}
|
|
51
51
|
```
|
|
@@ -63,20 +63,20 @@ This component utilizes `Button` from React-Bootstrap and extends it with an abi
|
|
|
63
63
|
gap={2}
|
|
64
64
|
direction={ isExtraSmall ? "vertical" : "horizontal" }
|
|
65
65
|
>
|
|
66
|
-
<Button variant="success"
|
|
67
|
-
<Button variant="danger"
|
|
68
|
-
<Button variant="outline-success"
|
|
69
|
-
<Button variant="outline-danger"
|
|
66
|
+
<Button variant="success">Success</Button>
|
|
67
|
+
<Button variant="danger">Danger</Button>
|
|
68
|
+
<Button variant="outline-success">Success</Button>
|
|
69
|
+
<Button variant="outline-danger">Danger</Button>
|
|
70
70
|
</Stack>
|
|
71
71
|
<Stack
|
|
72
72
|
gap={2}
|
|
73
73
|
direction={ isExtraSmall ? "vertical" : "horizontal" }
|
|
74
74
|
>
|
|
75
|
-
<Button variant="link"
|
|
76
|
-
<Button variant="light"
|
|
77
|
-
<Button variant="dark"
|
|
78
|
-
<Button variant="outline-light"
|
|
79
|
-
<Button variant="outline-dark"
|
|
75
|
+
<Button variant="link">Link</Button>
|
|
76
|
+
<Button variant="light">Light</Button>
|
|
77
|
+
<Button variant="dark">Dark</Button>
|
|
78
|
+
<Button variant="outline-light">Light</Button>
|
|
79
|
+
<Button variant="outline-dark">Dark</Button>
|
|
80
80
|
</Stack>
|
|
81
81
|
</>
|
|
82
82
|
)}
|
|
@@ -90,34 +90,41 @@ This component utilizes `Button` from React-Bootstrap and extends it with an abi
|
|
|
90
90
|
|
|
91
91
|
return (
|
|
92
92
|
<>
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
93
|
+
<Stack
|
|
94
|
+
className="mb-2"
|
|
95
|
+
gap={2}
|
|
96
|
+
direction={ isExtraSmall ? "vertical" : "horizontal" }
|
|
97
|
+
>
|
|
98
|
+
<Button variant="primary" size="lg">
|
|
99
|
+
Large button
|
|
100
|
+
</Button>
|
|
101
|
+
<Button variant="outline-primary" size="lg">
|
|
102
|
+
Large button
|
|
103
|
+
</Button>
|
|
104
|
+
</Stack>
|
|
105
|
+
<Stack
|
|
106
|
+
className="mb-2"
|
|
107
|
+
gap={2}
|
|
108
|
+
direction={ isExtraSmall ? "vertical" : "horizontal" }
|
|
109
|
+
>
|
|
110
|
+
<Button variant="primary" size="sm">
|
|
111
|
+
Small button
|
|
112
|
+
</Button>
|
|
113
|
+
<Button variant="outline-primary" size="sm">
|
|
114
|
+
Small button
|
|
115
|
+
</Button>
|
|
116
|
+
</Stack>
|
|
117
|
+
<Stack
|
|
118
|
+
className="mb-2"
|
|
119
|
+
gap={2}
|
|
120
|
+
direction={ isExtraSmall ? "vertical" : "horizontal" }
|
|
121
|
+
>
|
|
122
|
+
<Button variant="link" size="inline">Inline button</Button>
|
|
123
|
+
<Button variant="link" size="inline">Inline button</Button>
|
|
124
|
+
</Stack>
|
|
119
125
|
</>
|
|
120
|
-
)
|
|
126
|
+
)
|
|
127
|
+
}
|
|
121
128
|
```
|
|
122
129
|
|
|
123
130
|
### When to use the inline size
|
|
@@ -125,13 +132,11 @@ This component utilizes `Button` from React-Bootstrap and extends it with an abi
|
|
|
125
132
|
Use inline size buttons for when a button sits with a line of text.
|
|
126
133
|
|
|
127
134
|
```jsx live
|
|
128
|
-
|
|
129
|
-
<
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
</p>
|
|
134
|
-
</>
|
|
135
|
+
<p>
|
|
136
|
+
<span className="mr-1">2 items selected.</span>
|
|
137
|
+
<Button variant="link" size="inline" className="mr-1">Select all</Button>
|
|
138
|
+
<Button variant="link" size="inline">Clear</Button>
|
|
139
|
+
</p>
|
|
135
140
|
```
|
|
136
141
|
|
|
137
142
|
## Block Buttons
|
|
@@ -150,21 +155,41 @@ Use inline size buttons for when a button sits with a line of text.
|
|
|
150
155
|
### Disabled
|
|
151
156
|
|
|
152
157
|
```jsx live
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
+
() => {
|
|
159
|
+
const isExtraSmall = useMediaQuery({ maxWidth: breakpoints.extraSmall.maxWidth });
|
|
160
|
+
|
|
161
|
+
return (
|
|
162
|
+
<Stack
|
|
163
|
+
className="mb-2"
|
|
164
|
+
gap={2}
|
|
165
|
+
direction={ isExtraSmall ? "vertical" : "horizontal" }
|
|
166
|
+
>
|
|
167
|
+
<Button variant="primary" disabled>Primary disabled</Button>
|
|
168
|
+
<Button variant="secondary" disabled>Secondary disabled</Button>
|
|
169
|
+
<Button as="a" href="https://edx.org" disabled>Link disabled</Button>
|
|
170
|
+
</Stack>
|
|
171
|
+
)
|
|
172
|
+
}
|
|
158
173
|
```
|
|
159
174
|
|
|
160
175
|
### With empty href
|
|
161
176
|
For link to be `disabled`, it must have href defined with some value.
|
|
162
177
|
|
|
163
178
|
```jsx live
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
179
|
+
() => {
|
|
180
|
+
const isExtraSmall = useMediaQuery({ maxWidth: breakpoints.extraSmall.maxWidth });
|
|
181
|
+
|
|
182
|
+
return (
|
|
183
|
+
<Stack
|
|
184
|
+
className="mb-2"
|
|
185
|
+
gap={2}
|
|
186
|
+
direction={ isExtraSmall ? "vertical" : "horizontal" }
|
|
187
|
+
>
|
|
188
|
+
<Button as="a" disabled>No href</Button>
|
|
189
|
+
<Button as="a" href="" disabled>Empty string href</Button>
|
|
190
|
+
</Stack>
|
|
191
|
+
)
|
|
192
|
+
}
|
|
168
193
|
```
|
|
169
194
|
|
|
170
195
|
### With Icons before or after
|
|
@@ -179,23 +204,24 @@ For link to be `disabled`, it must have href defined with some value.
|
|
|
179
204
|
gap={2}
|
|
180
205
|
direction={ isExtraSmall ? "vertical" : "horizontal" }
|
|
181
206
|
>
|
|
182
|
-
<Button variant="brand" iconBefore={ArrowBack}
|
|
207
|
+
<Button variant="brand" iconBefore={ArrowBack}>
|
|
183
208
|
Brand
|
|
184
209
|
</Button>
|
|
185
|
-
<Button variant="outline-brand" iconAfter={ArrowDropDown}
|
|
210
|
+
<Button variant="outline-brand" iconAfter={ArrowDropDown}>
|
|
186
211
|
Outline Brand
|
|
187
212
|
</Button>
|
|
188
|
-
<Button variant="primary" iconBefore={Remove} iconAfter={Add}
|
|
213
|
+
<Button variant="primary" iconBefore={Remove} iconAfter={Add}>
|
|
189
214
|
Primary
|
|
190
215
|
</Button>
|
|
191
|
-
<Button variant="outline-primary" iconBefore={Highlight}
|
|
216
|
+
<Button variant="outline-primary" iconBefore={Highlight}>
|
|
192
217
|
Outline Primary
|
|
193
218
|
</Button>
|
|
194
|
-
<Button variant="tertiary" iconAfter={Add}
|
|
219
|
+
<Button variant="tertiary" iconAfter={Add}>
|
|
195
220
|
Tertiary
|
|
196
221
|
</Button>
|
|
197
222
|
</Stack>
|
|
198
|
-
)
|
|
223
|
+
)
|
|
224
|
+
}
|
|
199
225
|
```
|
|
200
226
|
|
|
201
227
|
## Stateful buttons
|
package/src/Button/index.jsx
CHANGED
|
@@ -51,10 +51,10 @@ Button.propTypes = {
|
|
|
51
51
|
variant: PropTypes.string,
|
|
52
52
|
/** An icon component to render.
|
|
53
53
|
* Example import of a Paragon icon component: `import { Check } from '@edx/paragon/icons';` */
|
|
54
|
-
iconBefore: PropTypes.oneOfType([PropTypes.
|
|
54
|
+
iconBefore: PropTypes.oneOfType([PropTypes.elementType, PropTypes.node]),
|
|
55
55
|
/** An icon component to render.
|
|
56
56
|
* Example import of a Paragon icon component: `import { Check } from '@edx/paragon/icons';` */
|
|
57
|
-
iconAfter: PropTypes.oneOfType([PropTypes.
|
|
57
|
+
iconAfter: PropTypes.oneOfType([PropTypes.elementType, PropTypes.node]),
|
|
58
58
|
};
|
|
59
59
|
|
|
60
60
|
Button.defaultProps = {
|
package/src/Button/index.scss
CHANGED
|
@@ -41,15 +41,15 @@
|
|
|
41
41
|
bottom: calc(var(--pgn-spacing-btn-focus-distance-to-border) * -1);
|
|
42
42
|
left: calc(var(--pgn-spacing-btn-focus-distance-to-border) * -1);
|
|
43
43
|
border: solid var(--pgn-size-btn-focus-width) var(--pgn-btn-focus-outline-color, var(--pgn-color-body-base));
|
|
44
|
-
border-radius: var(--pgn-size-btn-focus-border-radius);
|
|
44
|
+
border-radius: var(--pgn-size-btn-focus-border-radius-base);
|
|
45
45
|
}
|
|
46
46
|
|
|
47
47
|
&.btn-lg::before {
|
|
48
|
-
border-radius: var(--pgn-size-btn-focus-border-radius);
|
|
48
|
+
border-radius: var(--pgn-size-btn-focus-border-radius-lg);
|
|
49
49
|
}
|
|
50
50
|
|
|
51
51
|
&.btn-sm::before {
|
|
52
|
-
border-radius: var(--pgn-size-btn-focus-border-radius);
|
|
52
|
+
border-radius: var(--pgn-size-btn-focus-border-radius-sm);
|
|
53
53
|
}
|
|
54
54
|
|
|
55
55
|
&:active,
|
|
@@ -29,13 +29,35 @@ describe('picker works as expected', () => {
|
|
|
29
29
|
const color = 'wassap';
|
|
30
30
|
const setColor = jest.fn();
|
|
31
31
|
it('validates hex color', async () => {
|
|
32
|
-
|
|
32
|
+
render(<ColorPicker color={color} setColor={setColor} />);
|
|
33
|
+
|
|
33
34
|
await act(async () => {
|
|
34
35
|
await userEvent.click(screen.getByRole('button'));
|
|
35
36
|
});
|
|
37
|
+
expect(screen.queryByTestId('hex-input').value).toEqual('#wassap');
|
|
36
38
|
expect(screen.queryByText('Colors must be in hexadecimal format.')).toBeInTheDocument();
|
|
37
39
|
|
|
38
|
-
|
|
40
|
+
await act(async () => {
|
|
41
|
+
await userEvent.clear(screen.getByTestId('hex-input'));
|
|
42
|
+
await userEvent.paste(screen.getByTestId('hex-input'), '32116c');
|
|
43
|
+
});
|
|
44
|
+
expect(screen.queryByTestId('hex-input').value).toEqual('#32116c');
|
|
45
|
+
expect(screen.queryByText('Colors must be in hexadecimal format.')).not.toBeInTheDocument();
|
|
46
|
+
|
|
47
|
+
await act(async () => {
|
|
48
|
+
await userEvent.clear(screen.getByTestId('hex-input'));
|
|
49
|
+
await userEvent.paste(screen.getByTestId('hex-input'), 'yuk');
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
expect(screen.queryByTestId('hex-input').value).toEqual('#yuk');
|
|
53
|
+
expect(screen.queryByText('Colors must be in hexadecimal format.')).toBeInTheDocument();
|
|
54
|
+
|
|
55
|
+
await act(async () => {
|
|
56
|
+
await userEvent.clear(screen.getByTestId('hex-input'));
|
|
57
|
+
await userEvent.paste(screen.getByTestId('hex-input'), '#fad');
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
expect(screen.queryByTestId('hex-input').value).toEqual('#fad');
|
|
39
61
|
expect(screen.queryByText('Colors must be in hexadecimal format.')).not.toBeInTheDocument();
|
|
40
62
|
});
|
|
41
63
|
});
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React
|
|
1
|
+
import React from 'react';
|
|
2
2
|
import PropTypes from 'prop-types';
|
|
3
3
|
import classNames from 'classnames';
|
|
4
4
|
import { HexColorPicker } from 'react-colorful';
|
|
@@ -15,24 +15,63 @@ function ColorPicker({
|
|
|
15
15
|
}) {
|
|
16
16
|
const [isOpen, open, close] = useToggle(false);
|
|
17
17
|
const [target, setTarget] = React.useState(null);
|
|
18
|
-
const [hexValid, setHexValid] = React.useState(true);
|
|
19
18
|
|
|
20
|
-
const
|
|
19
|
+
const colorIsValid = (colorToValidate) => {
|
|
21
20
|
const hexRegex = /^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$/;
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
21
|
+
return hexRegex.test(colorToValidate);
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
const formatHexColorString = (colorString) => {
|
|
25
|
+
if (!colorString.startsWith('#')) {
|
|
26
|
+
return `#${colorString}`.slice(0, 7);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
return colorString.slice(0, 7);
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
const [hexValid, setHexValid] = React.useState(() => (color === '' || colorIsValid(formatHexColorString(color))));
|
|
33
|
+
|
|
34
|
+
const [hexColorString, setHexColorString] = React.useState(() => {
|
|
35
|
+
if (color === '') {
|
|
36
|
+
return '';
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
return formatHexColorString(color);
|
|
40
|
+
});
|
|
41
|
+
const [colorToDisplay, setColorToDisplay] = React.useState(() => {
|
|
42
|
+
const formattedColor = formatHexColorString(color);
|
|
43
|
+
if (colorIsValid(formattedColor)) {
|
|
44
|
+
return formattedColor;
|
|
26
45
|
}
|
|
27
|
-
|
|
46
|
+
|
|
47
|
+
return '#fff';
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
const setValidatedColor = (newColor) => {
|
|
51
|
+
if (newColor === '') {
|
|
28
52
|
setHexValid(true);
|
|
29
|
-
|
|
30
|
-
|
|
53
|
+
setColor('');
|
|
54
|
+
setHexColorString('');
|
|
55
|
+
setColorToDisplay('#fff');
|
|
56
|
+
return;
|
|
31
57
|
}
|
|
32
|
-
}, [setColor]);
|
|
33
58
|
|
|
34
|
-
|
|
35
|
-
|
|
59
|
+
const formattedColor = formatHexColorString(newColor);
|
|
60
|
+
|
|
61
|
+
if (colorIsValid(formattedColor)) {
|
|
62
|
+
setHexValid(true);
|
|
63
|
+
setColor(formattedColor);
|
|
64
|
+
setHexColorString(formattedColor);
|
|
65
|
+
setColorToDisplay(formattedColor);
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
setHexValid(false);
|
|
70
|
+
setHexColorString(formattedColor);
|
|
71
|
+
|
|
72
|
+
// ensure the picker value stays in sync with the textbox
|
|
73
|
+
setColor(formattedColor);
|
|
74
|
+
};
|
|
36
75
|
|
|
37
76
|
return (
|
|
38
77
|
<>
|
|
@@ -65,16 +104,17 @@ function ColorPicker({
|
|
|
65
104
|
className="pgn__color-modal rounded shadow"
|
|
66
105
|
style={{ textAlign: 'start' }}
|
|
67
106
|
>
|
|
68
|
-
<HexColorPicker color={
|
|
107
|
+
<HexColorPicker color={colorToDisplay} onChange={setValidatedColor} />
|
|
69
108
|
<Form.Group className="pgn__hex-form" size="sm">
|
|
70
109
|
<div>
|
|
71
110
|
<Form.Label className="pgn__hex-label">Hex</Form.Label>
|
|
72
111
|
<Form.Control
|
|
73
112
|
className="pgn__hex-field"
|
|
74
113
|
isInvalid={!hexValid}
|
|
75
|
-
value={
|
|
76
|
-
onChange={(e) =>
|
|
114
|
+
value={hexColorString}
|
|
115
|
+
onChange={(e) => setValidatedColor(e.target.value)}
|
|
77
116
|
data-testid="hex-input"
|
|
117
|
+
spellCheck="false"
|
|
78
118
|
/>
|
|
79
119
|
</div>
|
|
80
120
|
{!hexValid && (
|
package/src/Container/index.jsx
CHANGED
|
@@ -28,11 +28,14 @@ Container.propTypes = {
|
|
|
28
28
|
...RBContainer.propTypes,
|
|
29
29
|
/** Override the base element */
|
|
30
30
|
as: PropTypes.elementType,
|
|
31
|
+
/** Specifies the contents of the container */
|
|
31
32
|
children: PropTypes.node,
|
|
32
33
|
/** Fill all available space at any breakpoint */
|
|
33
34
|
fluid: PropTypes.bool,
|
|
34
35
|
/** Set the maximum width for the container */
|
|
35
36
|
size: PropTypes.oneOf(Object.keys(SIZE_CLASS_NAMES)),
|
|
37
|
+
/** Overrides underlying component base CSS class name */
|
|
38
|
+
bsPrefix: PropTypes.string,
|
|
36
39
|
};
|
|
37
40
|
|
|
38
41
|
Container.defaultProps = {
|
|
@@ -40,6 +43,7 @@ Container.defaultProps = {
|
|
|
40
43
|
children: undefined,
|
|
41
44
|
fluid: true,
|
|
42
45
|
size: undefined,
|
|
46
|
+
bsPrefix: 'container',
|
|
43
47
|
};
|
|
44
48
|
|
|
45
49
|
export default Container;
|
package/src/DataTable/README.md
CHANGED
|
@@ -28,11 +28,11 @@ designStatus: 'Done'
|
|
|
28
28
|
devStatus: 'In progress'
|
|
29
29
|
---
|
|
30
30
|
|
|
31
|
-
The DataTable component is a wrapper that uses the <a href="https://
|
|
31
|
+
The DataTable component is a wrapper that uses the <a href="https://github.com/TanStack/table/tree/v7/docs/src/pages/docs" target="_blank" rel="noopener noreferrer">react-table</a> library to
|
|
32
32
|
create tables. It can be used as is, or its subcomponents can be used on their own, allowing the developer full control.
|
|
33
33
|
|
|
34
34
|
Paragon also exports all React hooks from ``react-table`` allowing the developers to use them and make customizations more freely without adding ``react-table`` as a separate dependency to their project.
|
|
35
|
-
For full list of available hooks view <a href="https://
|
|
35
|
+
For full list of available hooks view <a href="https://github.com/TanStack/table/tree/v7/docs/src/pages/docs/api" target="_blank" rel="noopener noreferrer">react-table API reference</a>.
|
|
36
36
|
|
|
37
37
|
## How children get information
|
|
38
38
|
|
|
@@ -49,7 +49,7 @@ const instance = useContext(DataTableContext)
|
|
|
49
49
|
For small tables (less than ~10,000 rows), filtering, sorting and pagination can be done quickly and easily on the frontend.
|
|
50
50
|
|
|
51
51
|
In this example, a default TextFilter component is used for all columns. A default filter can be passed in,
|
|
52
|
-
or a filter component can be defined on the column. See <a href="https://
|
|
52
|
+
or a filter component can be defined on the column. See <a href="https://github.com/TanStack/table/blob/v7/docs/src/pages/docs/api/useFilters.md" target="_blank" rel="noopener noreferrer">react-table filters documentation</a>
|
|
53
53
|
for more information.
|
|
54
54
|
|
|
55
55
|
```jsx live
|
package/src/DataTable/index.jsx
CHANGED
|
@@ -187,6 +187,7 @@ function DataTable({
|
|
|
187
187
|
|
|
188
188
|
const enhancedInstance = {
|
|
189
189
|
...instance,
|
|
190
|
+
manualFilters,
|
|
190
191
|
itemCount,
|
|
191
192
|
numBreakoutFilters,
|
|
192
193
|
bulkActions,
|
|
@@ -329,7 +330,7 @@ DataTable.propTypes = {
|
|
|
329
330
|
/** Function that will fetch table data. Called when page size, page index or filters change.
|
|
330
331
|
* Meant to be used with manual filters and pagination */
|
|
331
332
|
fetchData: PropTypes.func,
|
|
332
|
-
/** Initial state passed to react-table's documentation https://
|
|
333
|
+
/** Initial state passed to react-table's documentation https://github.com/TanStack/table/blob/v7/docs/src/pages/docs/api/useTable.md */
|
|
333
334
|
initialState: PropTypes.shape({
|
|
334
335
|
pageSize: requiredWhen(PropTypes.number, 'isPaginated'),
|
|
335
336
|
pageIndex: requiredWhen(PropTypes.number, 'isPaginated'),
|
|
@@ -22,11 +22,11 @@ function BaseSelectionStatus({
|
|
|
22
22
|
}) {
|
|
23
23
|
const {
|
|
24
24
|
itemCount, filteredRows, isPaginated, state,
|
|
25
|
-
isSelectable, maxSelectedRows,
|
|
25
|
+
isSelectable, maxSelectedRows, manualFilters,
|
|
26
26
|
} = useContext(DataTableContext);
|
|
27
27
|
const hasAppliedFilters = state?.filters?.length > 0;
|
|
28
28
|
const isAllRowsSelected = numSelectedRows === itemCount;
|
|
29
|
-
const filteredItems = filteredRows?.length || itemCount;
|
|
29
|
+
const filteredItems = manualFilters ? itemCount : (filteredRows?.length || itemCount);
|
|
30
30
|
const hasMaxSelectedRows = isSelectable && maxSelectedRows;
|
|
31
31
|
|
|
32
32
|
const intlAllSelectedText = allSelectedText || (
|