@canonical/react-components 0.23.0 → 0.24.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/README.md +4 -4
- package/dist/components/Input/Input.d.ts +1 -1
- package/dist/components/Input/Input.js +2 -1
- package/dist/components/Modal/Modal.js +26 -4
- package/dist/components/Notification/Notification.js +5 -5
- package/dist/components/PasswordToggle/PasswordToggle.d.ts +1 -1
- package/dist/components/Tabs/Tabs.js +1 -1
- package/dist/components/Tooltip/Tooltip.js +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.js +8 -0
- package/package.json +43 -42
package/README.md
CHANGED
|
@@ -6,7 +6,7 @@ This is a collection of components designed to be the way to consume [Vanilla Fr
|
|
|
6
6
|
|
|
7
7
|
See the [component docs](https://canonical-web-and-design.github.io/react-components/) for usage instructions.
|
|
8
8
|
|
|
9
|
-

|
|
10
10
|

|
|
11
11
|
|
|
12
12
|
## Requirements
|
|
@@ -36,9 +36,9 @@ Please file any issues at [GitHub](https://github.com/canonical-web-and-design/r
|
|
|
36
36
|
You might want to:
|
|
37
37
|
|
|
38
38
|
- [View the source](https://github.com/canonical-web-and-design/react-components) on GitHub.
|
|
39
|
-
- Read about [developing components](https://github.com/canonical-web-and-design/react-components/blob/
|
|
40
|
-
- Find out how to [publish to NPM](https://github.com/canonical-web-and-design/react-components/blob/
|
|
41
|
-
- Know how to [publish the docs](https://github.com/canonical-web-and-design/react-components/blob/
|
|
39
|
+
- Read about [developing components](https://github.com/canonical-web-and-design/react-components/blob/main/HACKING.md).
|
|
40
|
+
- Find out how to [publish to NPM](https://github.com/canonical-web-and-design/react-components/blob/main/PUBLISH-NPM-PACKAGE.md).
|
|
41
|
+
- Know how to [publish the docs](https://github.com/canonical-web-and-design/react-components/blob/main/PUBLISHING-DOCS.md) to GitHub Pages.
|
|
42
42
|
|
|
43
43
|
## Developing locally using this repository
|
|
44
44
|
|
|
@@ -38,6 +38,7 @@ var Modal = function Modal(_ref) {
|
|
|
38
38
|
var focusableElementSelectors = 'a[href]:not([tabindex="-1"]), button:not([disabled]), textarea:not([disabled]):not([tabindex="-1"]), input:not([disabled]):not([tabindex="-1"]), select:not([disabled]):not([tabindex="-1"]), area[href]:not([tabindex="-1"]), iframe:not([tabindex="-1"]), [tabindex]:not([tabindex="-1"]), [contentEditable=true]:not([tabindex="-1"])';
|
|
39
39
|
var descriptionId = (0, _react.useRef)((0, _nanoid.nanoid)());
|
|
40
40
|
var titleId = (0, _react.useRef)((0, _nanoid.nanoid)());
|
|
41
|
+
var shouldClose = (0, _react.useRef)(false);
|
|
41
42
|
var modalRef = (0, _react.useRef)(null);
|
|
42
43
|
var focusableModalElements = (0, _react.useRef)(null);
|
|
43
44
|
|
|
@@ -79,9 +80,31 @@ var Modal = function Modal(_ref) {
|
|
|
79
80
|
document.removeEventListener("keydown", keyDown);
|
|
80
81
|
};
|
|
81
82
|
});
|
|
83
|
+
|
|
84
|
+
var handleContentOnMouseDown = function handleContentOnMouseDown() {
|
|
85
|
+
shouldClose.current = false;
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
var handleContentOnMouseUp = function handleContentOnMouseUp() {
|
|
89
|
+
shouldClose.current = false;
|
|
90
|
+
};
|
|
91
|
+
|
|
92
|
+
var handleOverlayOnMouseDown = function handleOverlayOnMouseDown(event) {
|
|
93
|
+
if (event.target === modalRef.current) {
|
|
94
|
+
shouldClose.current = true;
|
|
95
|
+
}
|
|
96
|
+
};
|
|
97
|
+
|
|
98
|
+
var handleOverlayOnClick = function handleOverlayOnClick() {
|
|
99
|
+
if (shouldClose.current) {
|
|
100
|
+
close();
|
|
101
|
+
}
|
|
102
|
+
};
|
|
103
|
+
|
|
82
104
|
return /*#__PURE__*/_react.default.createElement("div", _extends({
|
|
83
105
|
className: (0, _classnames.default)("p-modal", className),
|
|
84
|
-
onClick:
|
|
106
|
+
onClick: handleOverlayOnClick,
|
|
107
|
+
onMouseDown: handleOverlayOnMouseDown
|
|
85
108
|
}, wrapperProps, {
|
|
86
109
|
ref: modalRef
|
|
87
110
|
}), /*#__PURE__*/_react.default.createElement("section", {
|
|
@@ -90,9 +113,8 @@ var Modal = function Modal(_ref) {
|
|
|
90
113
|
"aria-modal": "true",
|
|
91
114
|
"aria-labelledby": titleId.current,
|
|
92
115
|
"aria-describedby": descriptionId.current,
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
}
|
|
116
|
+
onMouseDown: handleContentOnMouseDown,
|
|
117
|
+
onMouseUp: handleContentOnMouseUp
|
|
96
118
|
}, !!title && /*#__PURE__*/_react.default.createElement("header", {
|
|
97
119
|
className: "p-modal__header"
|
|
98
120
|
}, /*#__PURE__*/_react.default.createElement("h2", {
|
|
@@ -83,27 +83,27 @@ var Notification = function Notification(_ref) {
|
|
|
83
83
|
className: "p-notification__content"
|
|
84
84
|
}, title && /*#__PURE__*/_react.default.createElement("h5", {
|
|
85
85
|
className: "p-notification__title",
|
|
86
|
-
"data-
|
|
86
|
+
"data-testid": "notification-title"
|
|
87
87
|
}, title), inline && /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, "\u2002"), /*#__PURE__*/_react.default.createElement("p", {
|
|
88
88
|
className: "p-notification__message"
|
|
89
89
|
}, children), onDismiss && /*#__PURE__*/_react.default.createElement("button", {
|
|
90
90
|
"aria-label": "Close notification",
|
|
91
91
|
className: "p-notification__close",
|
|
92
|
-
"data-
|
|
92
|
+
"data-testid": "notification-close-button",
|
|
93
93
|
onClick: onDismiss
|
|
94
94
|
}, "Close")), showMeta && /*#__PURE__*/_react.default.createElement("div", {
|
|
95
95
|
className: "p-notification__meta",
|
|
96
|
-
"data-
|
|
96
|
+
"data-testid": "notification-meta"
|
|
97
97
|
}, timestamp && /*#__PURE__*/_react.default.createElement("span", {
|
|
98
98
|
className: "p-notification__timestamp",
|
|
99
|
-
"data-
|
|
99
|
+
"data-testid": "notification-timestamp"
|
|
100
100
|
}, timestamp), hasActions ? /*#__PURE__*/_react.default.createElement("div", {
|
|
101
101
|
className: "p-notification__actions"
|
|
102
102
|
}, actions.map(function (action, i) {
|
|
103
103
|
return /*#__PURE__*/_react.default.createElement(_Button.default, {
|
|
104
104
|
appearance: _Button.ButtonAppearance.LINK,
|
|
105
105
|
className: "p-notification__action",
|
|
106
|
-
"data-
|
|
106
|
+
"data-testid": "notification-action",
|
|
107
107
|
key: "".concat(action.label, "-").concat(i),
|
|
108
108
|
onClick: action.onClick
|
|
109
109
|
}, action.label);
|
|
@@ -87,5 +87,5 @@ declare const PasswordToggle: React.ForwardRefExoticComponent<{
|
|
|
87
87
|
* Optional class(es) to pass to the wrapping Field component
|
|
88
88
|
*/
|
|
89
89
|
wrapperClassName?: string;
|
|
90
|
-
} & Omit<React.InputHTMLAttributes<HTMLInputElement>, "label" | "
|
|
90
|
+
} & Omit<React.InputHTMLAttributes<HTMLInputElement>, "label" | "className" | "error" | "id" | "readOnly" | "required" | "help" | "success" | "caution" | "wrapperClassName"> & React.RefAttributes<HTMLInputElement>>;
|
|
91
91
|
export default PasswordToggle;
|
|
@@ -42,7 +42,7 @@ var Tabs = function Tabs(_ref) {
|
|
|
42
42
|
}, /*#__PURE__*/_react.default.createElement(Component, _extends({
|
|
43
43
|
"aria-selected": active,
|
|
44
44
|
className: (0, _classnames.default)("p-tabs__link", className),
|
|
45
|
-
"data-
|
|
45
|
+
"data-testid": "tab-link-".concat(label)
|
|
46
46
|
}, rest), label));
|
|
47
47
|
})));
|
|
48
48
|
};
|
|
@@ -226,7 +226,7 @@ var Tooltip = function Tooltip(_ref) {
|
|
|
226
226
|
}
|
|
227
227
|
}, children), isOpen && /*#__PURE__*/_react.default.createElement(Portal, null, /*#__PURE__*/_react.default.createElement("span", {
|
|
228
228
|
className: (0, _classnames.default)("p-tooltip--".concat(adjustedPosition), "is-detached", tooltipClassName),
|
|
229
|
-
"data-
|
|
229
|
+
"data-testid": "tooltip-portal",
|
|
230
230
|
style: positionStyle
|
|
231
231
|
}, /*#__PURE__*/_react.default.createElement("span", {
|
|
232
232
|
className: "p-tooltip__message",
|
package/dist/index.d.ts
CHANGED
|
@@ -22,6 +22,7 @@ export { default as ModularTable } from "./components/ModularTable";
|
|
|
22
22
|
export { default as Modal } from "./components/Modal";
|
|
23
23
|
export { default as Notification, NotificationSeverity, } from "./components/Notification";
|
|
24
24
|
export { default as Pagination } from "./components/Pagination";
|
|
25
|
+
export { default as PasswordToggle } from "./components/PasswordToggle";
|
|
25
26
|
export { default as RadioInput } from "./components/RadioInput";
|
|
26
27
|
export { default as Row } from "./components/Row";
|
|
27
28
|
export { default as SearchAndFilter } from "./components/SearchAndFilter";
|
package/dist/index.js
CHANGED
|
@@ -173,6 +173,12 @@ Object.defineProperty(exports, "Pagination", {
|
|
|
173
173
|
return _Pagination.default;
|
|
174
174
|
}
|
|
175
175
|
});
|
|
176
|
+
Object.defineProperty(exports, "PasswordToggle", {
|
|
177
|
+
enumerable: true,
|
|
178
|
+
get: function get() {
|
|
179
|
+
return _PasswordToggle.default;
|
|
180
|
+
}
|
|
181
|
+
});
|
|
176
182
|
Object.defineProperty(exports, "RadioInput", {
|
|
177
183
|
enumerable: true,
|
|
178
184
|
get: function get() {
|
|
@@ -318,6 +324,8 @@ var _Notification = _interopRequireWildcard(require("./components/Notification")
|
|
|
318
324
|
|
|
319
325
|
var _Pagination = _interopRequireDefault(require("./components/Pagination"));
|
|
320
326
|
|
|
327
|
+
var _PasswordToggle = _interopRequireDefault(require("./components/PasswordToggle"));
|
|
328
|
+
|
|
321
329
|
var _RadioInput = _interopRequireDefault(require("./components/RadioInput"));
|
|
322
330
|
|
|
323
331
|
var _Row = _interopRequireDefault(require("./components/Row"));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@canonical/react-components",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.24.0",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"module": "dist/index.js",
|
|
6
6
|
"author": "Huw Wilkins <huw.wilkins@canonical.com>",
|
|
@@ -22,47 +22,48 @@
|
|
|
22
22
|
},
|
|
23
23
|
"homepage": "/react-components/",
|
|
24
24
|
"devDependencies": {
|
|
25
|
-
"@babel/cli": "7.
|
|
26
|
-
"@babel/preset-typescript": "7.
|
|
25
|
+
"@babel/cli": "7.16.0",
|
|
26
|
+
"@babel/preset-typescript": "7.16.0",
|
|
27
27
|
"@percy/storybook": "3.3.1",
|
|
28
|
-
"@storybook/addon-a11y": "6.3.
|
|
29
|
-
"@storybook/addon-controls": "6.3.
|
|
30
|
-
"@storybook/addon-docs": "6.3.
|
|
31
|
-
"@storybook/addons": "6.3.
|
|
32
|
-
"@storybook/react": "6.3.
|
|
33
|
-
"@storybook/theming": "6.3.
|
|
34
|
-
"@testing-library/
|
|
28
|
+
"@storybook/addon-a11y": "6.3.12",
|
|
29
|
+
"@storybook/addon-controls": "6.3.12",
|
|
30
|
+
"@storybook/addon-docs": "6.3.12",
|
|
31
|
+
"@storybook/addons": "6.3.12",
|
|
32
|
+
"@storybook/react": "6.3.12",
|
|
33
|
+
"@storybook/theming": "6.3.12",
|
|
34
|
+
"@testing-library/cypress": "8.0.2",
|
|
35
|
+
"@testing-library/dom": "8.11.1",
|
|
35
36
|
"@testing-library/react-hooks": "7.0.2",
|
|
36
|
-
"@testing-library/user-event": "13.
|
|
37
|
-
"@typescript-eslint/eslint-plugin": "4.
|
|
38
|
-
"@typescript-eslint/parser": "4.
|
|
39
|
-
"@wojtekmaj/enzyme-adapter-react-17": "0.6.
|
|
37
|
+
"@testing-library/user-event": "13.5.0",
|
|
38
|
+
"@typescript-eslint/eslint-plugin": "4.33.0",
|
|
39
|
+
"@typescript-eslint/parser": "4.33.0",
|
|
40
|
+
"@wojtekmaj/enzyme-adapter-react-17": "0.6.5",
|
|
40
41
|
"babel-eslint": "10.1.0",
|
|
41
|
-
"babel-jest": "27.
|
|
42
|
-
"babel-loader": "8.2.
|
|
42
|
+
"babel-jest": "27.3.1",
|
|
43
|
+
"babel-loader": "8.2.3",
|
|
43
44
|
"babel-plugin-module-resolver": "4.1.0",
|
|
44
45
|
"babel-plugin-typescript-to-proptypes": "1.4.2",
|
|
45
|
-
"concurrently": "6.
|
|
46
|
+
"concurrently": "6.4.0",
|
|
46
47
|
"css-loader": "5.2.7",
|
|
47
|
-
"cypress": "7.
|
|
48
|
+
"cypress": "7.7.0",
|
|
48
49
|
"deepmerge": "4.2.2",
|
|
49
50
|
"enzyme": "3.11.0",
|
|
50
51
|
"enzyme-adapter-react-16": "1.15.6",
|
|
51
52
|
"enzyme-to-json": "3.6.2",
|
|
52
|
-
"eslint": "7.
|
|
53
|
+
"eslint": "7.32.0",
|
|
53
54
|
"eslint-config-prettier": "8.3.0",
|
|
54
55
|
"eslint-config-react-app": "6.0.0",
|
|
55
|
-
"eslint-plugin-cypress": "2.
|
|
56
|
-
"eslint-plugin-flowtype": "5.
|
|
57
|
-
"eslint-plugin-import": "2.
|
|
58
|
-
"eslint-plugin-jsx-a11y": "6.
|
|
56
|
+
"eslint-plugin-cypress": "2.12.1",
|
|
57
|
+
"eslint-plugin-flowtype": "5.10.0",
|
|
58
|
+
"eslint-plugin-import": "2.25.3",
|
|
59
|
+
"eslint-plugin-jsx-a11y": "6.5.1",
|
|
59
60
|
"eslint-plugin-prettier": "3.4.1",
|
|
60
|
-
"eslint-plugin-react": "7.
|
|
61
|
-
"eslint-plugin-react-hooks": "4.
|
|
62
|
-
"jest": "27.
|
|
61
|
+
"eslint-plugin-react": "7.27.1",
|
|
62
|
+
"eslint-plugin-react-hooks": "4.3.0",
|
|
63
|
+
"jest": "27.3.1",
|
|
63
64
|
"node-sass": "6.0.1",
|
|
64
|
-
"npm-package-json-lint": "5.
|
|
65
|
-
"prettier": "2.
|
|
65
|
+
"npm-package-json-lint": "5.4.2",
|
|
66
|
+
"prettier": "2.4.1",
|
|
66
67
|
"react": "17.0.2",
|
|
67
68
|
"react-docgen-typescript-loader": "3.7.2",
|
|
68
69
|
"react-dom": "17.0.2",
|
|
@@ -73,21 +74,21 @@
|
|
|
73
74
|
"stylelint-config-standard": "22.0.0",
|
|
74
75
|
"stylelint-order": "4.1.0",
|
|
75
76
|
"stylelint-prettier": "1.2.0",
|
|
76
|
-
"stylelint-scss": "3.
|
|
77
|
-
"ts-jest": "27.0.
|
|
78
|
-
"tsc-alias": "1.
|
|
79
|
-
"typescript": "4.
|
|
80
|
-
"vanilla-framework": "2.37.
|
|
77
|
+
"stylelint-scss": "3.21.0",
|
|
78
|
+
"ts-jest": "27.0.7",
|
|
79
|
+
"tsc-alias": "1.4.1",
|
|
80
|
+
"typescript": "4.5.2",
|
|
81
|
+
"vanilla-framework": "2.37.1",
|
|
81
82
|
"wait-on": "5.3.0"
|
|
82
83
|
},
|
|
83
84
|
"dependencies": {
|
|
84
|
-
"@types/jest": "
|
|
85
|
-
"@types/node": "
|
|
86
|
-
"@types/react": "17.0.
|
|
87
|
-
"@types/react-dom": "17.0.
|
|
88
|
-
"@types/react-table": "7.7.
|
|
85
|
+
"@types/jest": "27.0.3",
|
|
86
|
+
"@types/node": "16.11.9",
|
|
87
|
+
"@types/react": "17.0.36",
|
|
88
|
+
"@types/react-dom": "17.0.11",
|
|
89
|
+
"@types/react-table": "7.7.8",
|
|
89
90
|
"classnames": "2.3.1",
|
|
90
|
-
"nanoid": "3.1.
|
|
91
|
+
"nanoid": "3.1.30",
|
|
91
92
|
"prop-types": "15.7.2",
|
|
92
93
|
"react-table": "7.7.0",
|
|
93
94
|
"react-useportal": "1.0.14"
|
|
@@ -95,7 +96,7 @@
|
|
|
95
96
|
"peerDependencies": {
|
|
96
97
|
"react": "17.0.2",
|
|
97
98
|
"react-dom": "17.0.2",
|
|
98
|
-
"vanilla-framework": "2.37.
|
|
99
|
+
"vanilla-framework": "2.37.1"
|
|
99
100
|
},
|
|
100
101
|
"scripts": {
|
|
101
102
|
"build": "rm -rf dist && yarn build-local; yarn build-declaration",
|
|
@@ -104,7 +105,7 @@
|
|
|
104
105
|
"build-watch": "yarn run build-local --watch",
|
|
105
106
|
"build-docs": "build-storybook -c .storybook -o docs",
|
|
106
107
|
"clean": "rm -rf node_modules dist .out",
|
|
107
|
-
"docs": "start-storybook --port ${PORT}",
|
|
108
|
+
"docs": "start-storybook --port ${PORT:-9009}",
|
|
108
109
|
"link-packages": "yarn install && yarn build && yarn link && cd node_modules/react && yarn link && cd ../react-dom && yarn link",
|
|
109
110
|
"lint-js": "eslint src",
|
|
110
111
|
"lint-style": "stylelint src",
|
|
@@ -117,7 +118,7 @@
|
|
|
117
118
|
"test": "jest",
|
|
118
119
|
"test-cypress": "concurrently 'yarn run docs' 'yarn run cypress:test' -k -s first",
|
|
119
120
|
"unlink-packages": "yarn unlink && cd node_modules/react && yarn unlink && cd ../react-dom && yarn unlink",
|
|
120
|
-
"cypress:test": "wait-on http://localhost:${PORT} && cypress run --env port=${PORT}",
|
|
121
|
+
"cypress:test": "wait-on http://localhost:${PORT:-9009} && cypress run --env port=${PORT:-9009}",
|
|
121
122
|
"cypress:run": "cypress run",
|
|
122
123
|
"cypress:open": "cypress open"
|
|
123
124
|
},
|