@canonical/react-components 0.47.2 → 0.47.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.
- package/README.md +2 -5
- package/dist/components/NotificationProvider/NotificationProvider.js +12 -16
- package/dist/components/NotificationProvider/types.d.ts +4 -0
- package/dist/components/PasswordToggle/PasswordToggle.js +4 -2
- package/dist/components/Select/Select.js +4 -2
- package/dist/components/Slider/Slider.js +4 -1
- package/dist/components/TablePagination/TablePagination.scss +1 -1
- package/dist/components/Textarea/Textarea.js +4 -2
- package/package.json +7 -5
package/README.md
CHANGED
|
@@ -1,13 +1,10 @@
|
|
|
1
1
|
# React components for Vanilla Framework
|
|
2
|
+
 
|
|
2
3
|
|
|
3
4
|
This is a collection of components designed to be the way to consume [Vanilla Framework](http://vanillaframework.io) when using React.
|
|
4
5
|
|
|
5
|
-
|
|
6
|
+
**[Storybook](https://canonical.github.io/react-components/)** contains component docs with usage instructions.
|
|
6
7
|
|
|
7
|
-
See the [component docs](https://canonical.github.io/react-components/) for usage instructions.
|
|
8
|
-
|
|
9
|
-

|
|
10
|
-

|
|
11
8
|
|
|
12
9
|
## Requirements
|
|
13
10
|
|
|
@@ -6,7 +6,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.NotificationProvider = exports.NotificationConsumer = void 0;
|
|
7
7
|
exports.useNotify = useNotify;
|
|
8
8
|
var _react = _interopRequireWildcard(require("react"));
|
|
9
|
-
var _reactRouterDom = require("react-router-dom");
|
|
10
9
|
var _isEqual = _interopRequireDefault(require("lodash/isEqual"));
|
|
11
10
|
var _messageBuilder = require("./messageBuilder");
|
|
12
11
|
var _Notification = _interopRequireWildcard(require("../Notification/Notification"));
|
|
@@ -24,7 +23,9 @@ const NotifyContext = /*#__PURE__*/(0, _react.createContext)({
|
|
|
24
23
|
});
|
|
25
24
|
const NotificationProvider = _ref => {
|
|
26
25
|
let {
|
|
27
|
-
children
|
|
26
|
+
children,
|
|
27
|
+
state,
|
|
28
|
+
pathname
|
|
28
29
|
} = _ref;
|
|
29
30
|
const [notification, setNotification] = (0, _react.useState)(null);
|
|
30
31
|
const clear = () => notification !== null && setNotification(null);
|
|
@@ -34,6 +35,14 @@ const NotificationProvider = _ref => {
|
|
|
34
35
|
}
|
|
35
36
|
return value;
|
|
36
37
|
};
|
|
38
|
+
(0, _react.useEffect)(() => {
|
|
39
|
+
if (state !== null && state !== void 0 && state.queuedNotification) {
|
|
40
|
+
setDeduplicated(state.queuedNotification);
|
|
41
|
+
window.history.replaceState({}, "");
|
|
42
|
+
} else {
|
|
43
|
+
clear();
|
|
44
|
+
}
|
|
45
|
+
}, [state, pathname]);
|
|
37
46
|
const helper = {
|
|
38
47
|
notification,
|
|
39
48
|
clear,
|
|
@@ -49,20 +58,7 @@ const NotificationProvider = _ref => {
|
|
|
49
58
|
};
|
|
50
59
|
exports.NotificationProvider = NotificationProvider;
|
|
51
60
|
function useNotify() {
|
|
52
|
-
|
|
53
|
-
const {
|
|
54
|
-
state,
|
|
55
|
-
pathname
|
|
56
|
-
} = (0, _reactRouterDom.useLocation)();
|
|
57
|
-
(0, _react.useEffect)(() => {
|
|
58
|
-
if (state !== null && state !== void 0 && state.queuedNotification) {
|
|
59
|
-
ctx.setDeduplicated(state.queuedNotification);
|
|
60
|
-
window.history.replaceState({}, "");
|
|
61
|
-
} else {
|
|
62
|
-
ctx.clear();
|
|
63
|
-
}
|
|
64
|
-
}, [state, pathname]);
|
|
65
|
-
return ctx;
|
|
61
|
+
return (0, _react.useContext)(NotifyContext);
|
|
66
62
|
}
|
|
67
63
|
const NotificationConsumer = () => {
|
|
68
64
|
const notify = useNotify();
|
|
@@ -2,6 +2,10 @@ import { ReactNode } from "react";
|
|
|
2
2
|
import { ValueOf } from "../../types";
|
|
3
3
|
import { NotificationSeverity } from "../Notification";
|
|
4
4
|
export interface NotifyProviderProps {
|
|
5
|
+
state?: {
|
|
6
|
+
queuedNotification: NotificationType | null;
|
|
7
|
+
};
|
|
8
|
+
pathname?: string;
|
|
5
9
|
children: ReactNode;
|
|
6
10
|
}
|
|
7
11
|
export interface NotificationAction {
|
|
@@ -41,6 +41,8 @@ const PasswordToggle = /*#__PURE__*/_react.default.forwardRef((_ref, ref) => {
|
|
|
41
41
|
const validationId = (0, _hooks.useId)();
|
|
42
42
|
const helpId = (0, _hooks.useId)();
|
|
43
43
|
const hasError = !!error;
|
|
44
|
+
const defaultPasswordToggleId = (0, _hooks.useId)();
|
|
45
|
+
const passwordToggleId = id || defaultPasswordToggleId;
|
|
44
46
|
const togglePassword = () => {
|
|
45
47
|
if (isPassword) {
|
|
46
48
|
setIsPassword(false);
|
|
@@ -60,7 +62,7 @@ const PasswordToggle = /*#__PURE__*/_react.default.forwardRef((_ref, ref) => {
|
|
|
60
62
|
}, /*#__PURE__*/_react.default.createElement("div", {
|
|
61
63
|
className: "p-form-password-toggle"
|
|
62
64
|
}, /*#__PURE__*/_react.default.createElement(_Label.default, {
|
|
63
|
-
forId:
|
|
65
|
+
forId: passwordToggleId,
|
|
64
66
|
required: required
|
|
65
67
|
}, label), /*#__PURE__*/_react.default.createElement(_Button.default, {
|
|
66
68
|
appearance: "base",
|
|
@@ -79,7 +81,7 @@ const PasswordToggle = /*#__PURE__*/_react.default.forwardRef((_ref, ref) => {
|
|
|
79
81
|
"aria-errormessage": hasError ? validationId : null,
|
|
80
82
|
"aria-invalid": hasError,
|
|
81
83
|
className: (0, _classnames.default)("p-form-validation__input", className),
|
|
82
|
-
id:
|
|
84
|
+
id: passwordToggleId,
|
|
83
85
|
readOnly: readOnly,
|
|
84
86
|
ref: ref,
|
|
85
87
|
type: isPassword ? "password" : "text"
|
|
@@ -47,6 +47,8 @@ const Select = _ref2 => {
|
|
|
47
47
|
} = _ref2;
|
|
48
48
|
const selectRef = (0, _react.useRef)(null);
|
|
49
49
|
const validationId = (0, _hooks.useId)();
|
|
50
|
+
const defaultSelectId = (0, _hooks.useId)();
|
|
51
|
+
const selectId = id || defaultSelectId;
|
|
50
52
|
const helpId = (0, _hooks.useId)();
|
|
51
53
|
const hasError = !!error;
|
|
52
54
|
(0, _react.useEffect)(() => {
|
|
@@ -58,7 +60,7 @@ const Select = _ref2 => {
|
|
|
58
60
|
caution: caution,
|
|
59
61
|
className: wrapperClassName,
|
|
60
62
|
error: error,
|
|
61
|
-
forId:
|
|
63
|
+
forId: selectId,
|
|
62
64
|
help: help,
|
|
63
65
|
helpId: helpId,
|
|
64
66
|
isSelect: true,
|
|
@@ -73,7 +75,7 @@ const Select = _ref2 => {
|
|
|
73
75
|
"aria-errormessage": hasError ? validationId : null,
|
|
74
76
|
"aria-invalid": hasError,
|
|
75
77
|
className: (0, _classnames.default)("p-form-validation__input", className),
|
|
76
|
-
id:
|
|
78
|
+
id: selectId,
|
|
77
79
|
onChange: evt => onChange && onChange(evt),
|
|
78
80
|
ref: selectRef
|
|
79
81
|
}, selectProps), generateOptions(options)));
|
|
@@ -30,6 +30,8 @@ const Slider = _ref => {
|
|
|
30
30
|
} = _ref;
|
|
31
31
|
const validationId = (0, _hooks.useId)();
|
|
32
32
|
const helpId = (0, _hooks.useId)();
|
|
33
|
+
const defaultSliderId = (0, _hooks.useId)();
|
|
34
|
+
const sliderId = id || defaultSliderId;
|
|
33
35
|
const hasError = !!error;
|
|
34
36
|
let style = {};
|
|
35
37
|
if ((_navigator = navigator) !== null && _navigator !== void 0 && (_navigator = _navigator.userAgent) !== null && _navigator !== void 0 && _navigator.includes("AppleWebKit")) {
|
|
@@ -46,6 +48,7 @@ const Slider = _ref => {
|
|
|
46
48
|
caution: caution,
|
|
47
49
|
error: error,
|
|
48
50
|
help: help,
|
|
51
|
+
forId: sliderId,
|
|
49
52
|
helpId: helpId,
|
|
50
53
|
label: label,
|
|
51
54
|
required: required,
|
|
@@ -57,7 +60,7 @@ const Slider = _ref => {
|
|
|
57
60
|
"aria-errormessage": hasError ? validationId : null,
|
|
58
61
|
"aria-invalid": hasError,
|
|
59
62
|
disabled: disabled,
|
|
60
|
-
id:
|
|
63
|
+
id: sliderId,
|
|
61
64
|
max: max,
|
|
62
65
|
min: min,
|
|
63
66
|
onChange: onChange,
|
|
@@ -40,6 +40,8 @@ const Textarea = _ref => {
|
|
|
40
40
|
const helpId = (0, _hooks.useId)();
|
|
41
41
|
const hasError = !!error;
|
|
42
42
|
const [innerValue, setInnervalue] = (0, _react.useState)(props.defaultValue);
|
|
43
|
+
const defaultTextAreaId = (0, _hooks.useId)();
|
|
44
|
+
const textAreaId = id || defaultTextAreaId;
|
|
43
45
|
(0, _react.useEffect)(() => {
|
|
44
46
|
if (takeFocus) {
|
|
45
47
|
textareaRef.current.focus();
|
|
@@ -59,7 +61,7 @@ const Textarea = _ref => {
|
|
|
59
61
|
caution: caution,
|
|
60
62
|
className: wrapperClassName,
|
|
61
63
|
error: error,
|
|
62
|
-
forId:
|
|
64
|
+
forId: textAreaId,
|
|
63
65
|
help: help,
|
|
64
66
|
helpId: helpId,
|
|
65
67
|
label: label,
|
|
@@ -73,7 +75,7 @@ const Textarea = _ref => {
|
|
|
73
75
|
"aria-errormessage": hasError ? validationId : null,
|
|
74
76
|
"aria-invalid": hasError,
|
|
75
77
|
className: (0, _classnames.default)("p-form-validation__input", className),
|
|
76
|
-
id:
|
|
78
|
+
id: textAreaId,
|
|
77
79
|
onKeyUp: evt => {
|
|
78
80
|
onKeyUp && onKeyUp(evt);
|
|
79
81
|
},
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@canonical/react-components",
|
|
3
|
-
"version": "0.47.
|
|
3
|
+
"version": "0.47.4",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"module": "dist/index.js",
|
|
6
6
|
"author": "Huw Wilkins <huw.wilkins@canonical.com>",
|
|
@@ -27,6 +27,8 @@
|
|
|
27
27
|
"@babel/preset-typescript": "7.23.3",
|
|
28
28
|
"@percy/cli": "1.27.6",
|
|
29
29
|
"@percy/storybook": "4.3.7",
|
|
30
|
+
"@semantic-release/changelog": "6.0.3",
|
|
31
|
+
"@semantic-release/git": "10.0.1",
|
|
30
32
|
"@storybook/addon-a11y": "7.6.7",
|
|
31
33
|
"@storybook/addon-essentials": "7.6.7",
|
|
32
34
|
"@storybook/addon-interactions": "7.6.7",
|
|
@@ -41,7 +43,6 @@
|
|
|
41
43
|
"@testing-library/jest-dom": "5.17.0",
|
|
42
44
|
"@testing-library/react": "14.1.2",
|
|
43
45
|
"@testing-library/user-event": "14.5.2",
|
|
44
|
-
"@types/react-router-dom": "5.3.3",
|
|
45
46
|
"@typescript-eslint/eslint-plugin": "5.62.0",
|
|
46
47
|
"@typescript-eslint/parser": "5.62.0",
|
|
47
48
|
"babel-jest": "27.5.1",
|
|
@@ -72,6 +73,7 @@
|
|
|
72
73
|
"react-dom": "18.2.0",
|
|
73
74
|
"sass": "1.69.7",
|
|
74
75
|
"sass-loader": "10.5.1",
|
|
76
|
+
"semantic-release": "23.0.0",
|
|
75
77
|
"storybook": "7.6.7",
|
|
76
78
|
"style-loader": "3.3.3",
|
|
77
79
|
"stylelint": "15.11.0",
|
|
@@ -95,7 +97,6 @@
|
|
|
95
97
|
"classnames": "2.5.1",
|
|
96
98
|
"nanoid": "3.3.7",
|
|
97
99
|
"prop-types": "15.8.1",
|
|
98
|
-
"react-router-dom": "6.21.1",
|
|
99
100
|
"react-table": "7.8.0",
|
|
100
101
|
"react-useportal": "1.0.19"
|
|
101
102
|
},
|
|
@@ -129,7 +130,6 @@
|
|
|
129
130
|
"lint-package-json": "npmPkgJsonLint .",
|
|
130
131
|
"lint": "yarn lint-package-json && yarn lint-js && yarn lint-style",
|
|
131
132
|
"percy": "yarn build-docs && percy storybook ./docs",
|
|
132
|
-
"prepublishOnly": "yarn clean && yarn install && yarn build",
|
|
133
133
|
"serve": "yarn docs",
|
|
134
134
|
"start": "yarn docs",
|
|
135
135
|
"test": "jest",
|
|
@@ -137,7 +137,9 @@
|
|
|
137
137
|
"unlink-packages": "yarn unlink && cd node_modules/react && yarn unlink && cd ../react-dom && yarn unlink",
|
|
138
138
|
"cypress:test": "wait-on http://localhost:${PORT:-9009} && cypress run --env port=${PORT:-9009}",
|
|
139
139
|
"cypress:run": "cypress run --env port=${PORT:-9009}",
|
|
140
|
-
"cypress:open": "cypress open --env port=${PORT:-9009}"
|
|
140
|
+
"cypress:open": "cypress open --env port=${PORT:-9009}",
|
|
141
|
+
"semantic-release": "semantic-release",
|
|
142
|
+
"semantic-release-dry-run": "semantic-release --dry-run --no-ci"
|
|
141
143
|
},
|
|
142
144
|
"eslintConfig": {
|
|
143
145
|
"extends": "react-app"
|