@canonical/react-components 0.42.0 → 0.44.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/components/ActionButton/ActionButton.js +4 -0
- package/dist/components/Card/Card.js +1 -1
- package/dist/components/ConfirmationButton/ConfirmationButton.d.ts +25 -0
- package/dist/components/ConfirmationButton/ConfirmationButton.js +59 -0
- package/dist/components/ConfirmationButton/index.d.ts +2 -0
- package/dist/components/ConfirmationButton/index.js +13 -0
- package/dist/components/ConfirmationModal/ConfirmationModal.d.ts +33 -0
- package/dist/components/ConfirmationModal/ConfirmationModal.js +38 -0
- package/dist/components/ConfirmationModal/index.d.ts +2 -0
- package/dist/components/ConfirmationModal/index.js +13 -0
- package/dist/components/ContextualMenu/ContextualMenu.d.ts +3 -3
- package/dist/components/ContextualMenu/ContextualMenuDropdown/ContextualMenuDropdown.d.ts +2 -1
- package/dist/components/ContextualMenu/ContextualMenuDropdown/ContextualMenuDropdown.js +1 -1
- package/dist/components/EmptyState/EmptyState.d.ts +22 -0
- package/dist/components/EmptyState/EmptyState.js +27 -0
- package/dist/components/EmptyState/index.d.ts +2 -0
- package/dist/components/EmptyState/index.js +13 -0
- package/dist/components/Icon/Icon.stories.scss +1 -0
- package/dist/components/List/List.d.ts +5 -5
- package/dist/components/List/List.js +0 -2
- package/dist/components/Notification/Notification.d.ts +6 -0
- package/dist/components/Notification/Notification.js +8 -5
- package/dist/components/NotificationProvider/NotificationProvider.d.ts +5 -0
- package/dist/components/NotificationProvider/NotificationProvider.js +119 -0
- package/dist/components/NotificationProvider/index.d.ts +3 -0
- package/dist/components/NotificationProvider/index.js +49 -0
- package/dist/components/NotificationProvider/messageBuilder.d.ts +6 -0
- package/dist/components/NotificationProvider/messageBuilder.js +41 -0
- package/dist/components/NotificationProvider/types.d.ts +30 -0
- package/dist/components/NotificationProvider/types.js +5 -0
- package/dist/components/Tooltip/Tooltip.js +1 -1
- package/dist/index.d.ts +8 -0
- package/dist/index.js +64 -0
- package/package.json +27 -25
|
@@ -22,7 +22,7 @@ var Card = function Card(_ref) {
|
|
|
22
22
|
props = _objectWithoutProperties(_ref, _excluded);
|
|
23
23
|
var titleId = (0, _hooks.useId)();
|
|
24
24
|
return /*#__PURE__*/_react.default.createElement("div", _extends({
|
|
25
|
-
"aria-labelledby": titleId,
|
|
25
|
+
"aria-labelledby": title ? titleId : undefined,
|
|
26
26
|
className: (0, _classnames.default)(className, {
|
|
27
27
|
"p-card": !highlighted && !overlay,
|
|
28
28
|
"p-card--highlighted": highlighted,
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { ReactElement } from "react";
|
|
2
|
+
import { PropsWithSpread, SubComponentProps } from "../../types";
|
|
3
|
+
import { ActionButtonProps } from "../ActionButton";
|
|
4
|
+
import { ConfirmationModalProps } from "../ConfirmationModal";
|
|
5
|
+
export type Props = PropsWithSpread<{
|
|
6
|
+
/**
|
|
7
|
+
* Additional props to pass to the confirmation modal.
|
|
8
|
+
*/
|
|
9
|
+
confirmationModalProps: SubComponentProps<ConfirmationModalProps>;
|
|
10
|
+
/**
|
|
11
|
+
* An optional text to be shown when hovering over the button.<br/>
|
|
12
|
+
* Defaults to the label of the confirm button in the modal.
|
|
13
|
+
*/
|
|
14
|
+
onHoverText?: string;
|
|
15
|
+
/**
|
|
16
|
+
* Whether to enable the SHIFT+Click shortcut to skip the confirmation modal and perform the action.
|
|
17
|
+
*/
|
|
18
|
+
shiftClickEnabled?: boolean;
|
|
19
|
+
/**
|
|
20
|
+
* Whether to show a hint about the SHIFT+Click shortcut to skip the confirmation modal.
|
|
21
|
+
*/
|
|
22
|
+
showShiftClickHint?: boolean;
|
|
23
|
+
}, ActionButtonProps>;
|
|
24
|
+
export declare const ConfirmationButton: ({ confirmationModalProps, onHoverText, shiftClickEnabled, showShiftClickHint, ...actionButtonProps }: Props) => ReactElement;
|
|
25
|
+
export default ConfirmationButton;
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = exports.ConfirmationButton = void 0;
|
|
7
|
+
var _react = _interopRequireDefault(require("react"));
|
|
8
|
+
var _ActionButton = _interopRequireDefault(require("../ActionButton"));
|
|
9
|
+
var _ConfirmationModal = _interopRequireDefault(require("../ConfirmationModal"));
|
|
10
|
+
var _reactUseportal = _interopRequireDefault(require("react-useportal"));
|
|
11
|
+
var _excluded = ["confirmationModalProps", "onHoverText", "shiftClickEnabled", "showShiftClickHint"];
|
|
12
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
13
|
+
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); }
|
|
14
|
+
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
|
15
|
+
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
16
|
+
var ConfirmationButton = function ConfirmationButton(_ref) {
|
|
17
|
+
var confirmationModalProps = _ref.confirmationModalProps,
|
|
18
|
+
onHoverText = _ref.onHoverText,
|
|
19
|
+
_ref$shiftClickEnable = _ref.shiftClickEnabled,
|
|
20
|
+
shiftClickEnabled = _ref$shiftClickEnable === void 0 ? false : _ref$shiftClickEnable,
|
|
21
|
+
_ref$showShiftClickHi = _ref.showShiftClickHint,
|
|
22
|
+
showShiftClickHint = _ref$showShiftClickHi === void 0 ? false : _ref$showShiftClickHi,
|
|
23
|
+
actionButtonProps = _objectWithoutProperties(_ref, _excluded);
|
|
24
|
+
var _usePortal = (0, _reactUseportal.default)(),
|
|
25
|
+
openPortal = _usePortal.openPortal,
|
|
26
|
+
closePortal = _usePortal.closePortal,
|
|
27
|
+
isOpen = _usePortal.isOpen,
|
|
28
|
+
Portal = _usePortal.Portal;
|
|
29
|
+
var handleCancelModal = function handleCancelModal() {
|
|
30
|
+
closePortal();
|
|
31
|
+
if (confirmationModalProps.close) {
|
|
32
|
+
confirmationModalProps.close();
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
var handleConfirmModal = function handleConfirmModal(e) {
|
|
36
|
+
closePortal();
|
|
37
|
+
confirmationModalProps.onConfirm(e);
|
|
38
|
+
};
|
|
39
|
+
var handleShiftClick = function handleShiftClick(e) {
|
|
40
|
+
if (e.shiftKey) {
|
|
41
|
+
confirmationModalProps.onConfirm(e);
|
|
42
|
+
} else {
|
|
43
|
+
openPortal(e);
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, isOpen && /*#__PURE__*/_react.default.createElement(Portal, null, /*#__PURE__*/_react.default.createElement(_ConfirmationModal.default, _extends({}, confirmationModalProps, {
|
|
47
|
+
close: handleCancelModal,
|
|
48
|
+
confirmButtonLabel: confirmationModalProps.confirmButtonLabel,
|
|
49
|
+
onConfirm: handleConfirmModal
|
|
50
|
+
}), confirmationModalProps.children, showShiftClickHint && /*#__PURE__*/_react.default.createElement("p", {
|
|
51
|
+
className: "p-text--small u-text--muted u-hide--small"
|
|
52
|
+
}, "Next time, you can skip this confirmation by holding", " ", /*#__PURE__*/_react.default.createElement("code", null, "SHIFT"), " and clicking the action."))), /*#__PURE__*/_react.default.createElement(_ActionButton.default, _extends({}, actionButtonProps, {
|
|
53
|
+
onClick: shiftClickEnabled ? handleShiftClick : openPortal,
|
|
54
|
+
title: onHoverText !== null && onHoverText !== void 0 ? onHoverText : confirmationModalProps.confirmButtonLabel
|
|
55
|
+
}), actionButtonProps.children));
|
|
56
|
+
};
|
|
57
|
+
exports.ConfirmationButton = ConfirmationButton;
|
|
58
|
+
var _default = ConfirmationButton;
|
|
59
|
+
exports.default = _default;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
Object.defineProperty(exports, "default", {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: function get() {
|
|
9
|
+
return _ConfirmationButton.default;
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
var _ConfirmationButton = _interopRequireDefault(require("./ConfirmationButton"));
|
|
13
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { MouseEvent, ReactElement } from "react";
|
|
2
|
+
import type { ReactNode } from "react";
|
|
3
|
+
import { PropsWithSpread, ValueOf } from "../../types";
|
|
4
|
+
import { ButtonAppearance } from "../Button";
|
|
5
|
+
import { ModalProps } from "../Modal";
|
|
6
|
+
export type Props = PropsWithSpread<{
|
|
7
|
+
/**
|
|
8
|
+
* Label for the cancel button.
|
|
9
|
+
*/
|
|
10
|
+
cancelButtonLabel?: string;
|
|
11
|
+
/**
|
|
12
|
+
* The content of the modal.
|
|
13
|
+
*/
|
|
14
|
+
children: ReactNode;
|
|
15
|
+
/**
|
|
16
|
+
* Appearance of the confirm button.
|
|
17
|
+
*/
|
|
18
|
+
confirmButtonAppearance?: ValueOf<typeof ButtonAppearance> | string;
|
|
19
|
+
/**
|
|
20
|
+
* Label for the confirm button.
|
|
21
|
+
*/
|
|
22
|
+
confirmButtonLabel: string;
|
|
23
|
+
/**
|
|
24
|
+
* Extra elements to be placed in the button row of the modal.
|
|
25
|
+
*/
|
|
26
|
+
confirmExtra?: ReactNode;
|
|
27
|
+
/**
|
|
28
|
+
* Function to perform the action prompted by the modal.
|
|
29
|
+
*/
|
|
30
|
+
onConfirm: (e: MouseEvent<HTMLElement>) => void;
|
|
31
|
+
}, Omit<ModalProps, "buttonRow">>;
|
|
32
|
+
export declare const ConfirmationModal: ({ cancelButtonLabel, children, confirmButtonAppearance, confirmButtonLabel, confirmExtra, onConfirm, ...props }: Props) => ReactElement;
|
|
33
|
+
export default ConfirmationModal;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = exports.ConfirmationModal = void 0;
|
|
7
|
+
var _react = _interopRequireDefault(require("react"));
|
|
8
|
+
var _Button = _interopRequireDefault(require("../Button"));
|
|
9
|
+
var _Modal = _interopRequireDefault(require("../Modal"));
|
|
10
|
+
var _excluded = ["cancelButtonLabel", "children", "confirmButtonAppearance", "confirmButtonLabel", "confirmExtra", "onConfirm"];
|
|
11
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
12
|
+
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); }
|
|
13
|
+
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
|
14
|
+
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
15
|
+
var ConfirmationModal = function ConfirmationModal(_ref) {
|
|
16
|
+
var _ref$cancelButtonLabe = _ref.cancelButtonLabel,
|
|
17
|
+
cancelButtonLabel = _ref$cancelButtonLabe === void 0 ? "Cancel" : _ref$cancelButtonLabe,
|
|
18
|
+
children = _ref.children,
|
|
19
|
+
_ref$confirmButtonApp = _ref.confirmButtonAppearance,
|
|
20
|
+
confirmButtonAppearance = _ref$confirmButtonApp === void 0 ? "negative" : _ref$confirmButtonApp,
|
|
21
|
+
confirmButtonLabel = _ref.confirmButtonLabel,
|
|
22
|
+
confirmExtra = _ref.confirmExtra,
|
|
23
|
+
onConfirm = _ref.onConfirm,
|
|
24
|
+
props = _objectWithoutProperties(_ref, _excluded);
|
|
25
|
+
return /*#__PURE__*/_react.default.createElement(_Modal.default, _extends({
|
|
26
|
+
buttonRow: /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, confirmExtra, /*#__PURE__*/_react.default.createElement(_Button.default, {
|
|
27
|
+
className: "u-no-margin--bottom",
|
|
28
|
+
onClick: props.close
|
|
29
|
+
}, cancelButtonLabel), /*#__PURE__*/_react.default.createElement(_Button.default, {
|
|
30
|
+
appearance: confirmButtonAppearance,
|
|
31
|
+
className: "u-no-margin--bottom",
|
|
32
|
+
onClick: onConfirm
|
|
33
|
+
}, confirmButtonLabel))
|
|
34
|
+
}, props), children);
|
|
35
|
+
};
|
|
36
|
+
exports.ConfirmationModal = ConfirmationModal;
|
|
37
|
+
var _default = ConfirmationModal;
|
|
38
|
+
exports.default = _default;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
Object.defineProperty(exports, "default", {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: function get() {
|
|
9
|
+
return _ConfirmationModal.default;
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
var _ConfirmationModal = _interopRequireDefault(require("./ConfirmationModal"));
|
|
13
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import type { HTMLProps
|
|
2
|
+
import type { HTMLProps } from "react";
|
|
3
3
|
import type { ButtonProps } from "../Button";
|
|
4
4
|
import type { ContextualMenuDropdownProps } from "./ContextualMenuDropdown";
|
|
5
5
|
import type { MenuLink, Position } from "./ContextualMenuDropdown";
|
|
@@ -19,7 +19,7 @@ export type Props<L> = PropsWithSpread<{
|
|
|
19
19
|
/**
|
|
20
20
|
* The menu content (if the links prop is not supplied).
|
|
21
21
|
*/
|
|
22
|
-
children?:
|
|
22
|
+
children?: ContextualMenuDropdownProps["dropdownContent"];
|
|
23
23
|
/**
|
|
24
24
|
* An optional class to apply to the wrapping element.
|
|
25
25
|
*/
|
|
@@ -79,7 +79,7 @@ export type Props<L> = PropsWithSpread<{
|
|
|
79
79
|
/**
|
|
80
80
|
* The toggle button's label.
|
|
81
81
|
*/
|
|
82
|
-
toggleLabel?:
|
|
82
|
+
toggleLabel?: React.ReactNode | null;
|
|
83
83
|
/**
|
|
84
84
|
* Whether the toggle lable or icon should appear first.
|
|
85
85
|
*/
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { ReactElement } from "react";
|
|
1
2
|
import type { HTMLProps, ReactNode } from "react";
|
|
2
3
|
import type { ButtonProps } from "../../Button";
|
|
3
4
|
import type { WindowFitment } from "../../../hooks";
|
|
@@ -20,7 +21,7 @@ export type Props<L = null> = {
|
|
|
20
21
|
closePortal?: (evt?: MouseEvent) => void;
|
|
21
22
|
constrainPanelWidth?: boolean;
|
|
22
23
|
dropdownClassName?: string;
|
|
23
|
-
dropdownContent?: ReactNode;
|
|
24
|
+
dropdownContent?: ReactNode | ((close: () => void) => ReactElement);
|
|
24
25
|
id?: string;
|
|
25
26
|
isOpen?: boolean;
|
|
26
27
|
links?: MenuLink<L>[];
|
|
@@ -184,7 +184,7 @@ var ContextualMenuDropdown = function ContextualMenuDropdown(_ref) {
|
|
|
184
184
|
minWidth: 0,
|
|
185
185
|
maxWidth: "none"
|
|
186
186
|
} : null
|
|
187
|
-
}, dropdownContent ? dropdownContent : links.map(function (item, i) {
|
|
187
|
+
}, dropdownContent ? typeof dropdownContent === "function" ? dropdownContent(closePortal) : dropdownContent : links.map(function (item, i) {
|
|
188
188
|
if (Array.isArray(item)) {
|
|
189
189
|
return /*#__PURE__*/_react.default.createElement("span", {
|
|
190
190
|
className: "p-contextual-menu__group",
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { ReactNode, HTMLProps, ReactElement } from "react";
|
|
2
|
+
import { PropsWithSpread } from "../../types";
|
|
3
|
+
export type Props = PropsWithSpread<{
|
|
4
|
+
/**
|
|
5
|
+
* The content of the empty state.
|
|
6
|
+
*/
|
|
7
|
+
children?: ReactNode;
|
|
8
|
+
/**
|
|
9
|
+
* Optional class(es) to add to the wrapping element.
|
|
10
|
+
*/
|
|
11
|
+
className?: string;
|
|
12
|
+
/**
|
|
13
|
+
* An image representing the empty state.
|
|
14
|
+
*/
|
|
15
|
+
image: ReactNode;
|
|
16
|
+
/**
|
|
17
|
+
* The title of the empty state.
|
|
18
|
+
*/
|
|
19
|
+
title: string;
|
|
20
|
+
}, HTMLProps<HTMLDivElement>>;
|
|
21
|
+
export declare const EmptyState: ({ children, className, image, title, ...props }: Props) => ReactElement;
|
|
22
|
+
export default EmptyState;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = exports.EmptyState = void 0;
|
|
7
|
+
var _react = _interopRequireDefault(require("react"));
|
|
8
|
+
var _excluded = ["children", "className", "image", "title"];
|
|
9
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
10
|
+
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); }
|
|
11
|
+
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
|
12
|
+
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
13
|
+
var EmptyState = function EmptyState(_ref) {
|
|
14
|
+
var children = _ref.children,
|
|
15
|
+
className = _ref.className,
|
|
16
|
+
image = _ref.image,
|
|
17
|
+
title = _ref.title,
|
|
18
|
+
props = _objectWithoutProperties(_ref, _excluded);
|
|
19
|
+
return /*#__PURE__*/_react.default.createElement("div", _extends({
|
|
20
|
+
className: className
|
|
21
|
+
}, props), image, /*#__PURE__*/_react.default.createElement("h2", {
|
|
22
|
+
className: "p-heading--4"
|
|
23
|
+
}, title), children);
|
|
24
|
+
};
|
|
25
|
+
exports.EmptyState = EmptyState;
|
|
26
|
+
var _default = EmptyState;
|
|
27
|
+
exports.default = _default;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
Object.defineProperty(exports, "default", {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: function get() {
|
|
9
|
+
return _EmptyState.default;
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
var _EmptyState = _interopRequireDefault(require("./EmptyState"));
|
|
13
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import type { HTMLProps, ReactNode } from "react";
|
|
2
|
-
import
|
|
3
|
-
export type ListItem = ReactNode |
|
|
2
|
+
import { ClassName, Headings, PropsWithSpread } from "../../types";
|
|
3
|
+
export type ListItem = ReactNode | PropsWithSpread<{
|
|
4
4
|
content: ReactNode;
|
|
5
|
-
}
|
|
6
|
-
export type SteppedListItem = {
|
|
5
|
+
}, HTMLProps<HTMLLIElement>>;
|
|
6
|
+
export type SteppedListItem = PropsWithSpread<{
|
|
7
7
|
content: ReactNode;
|
|
8
8
|
title: ReactNode;
|
|
9
9
|
titleElement?: Headings;
|
|
10
|
-
}
|
|
10
|
+
}, HTMLProps<HTMLLIElement>>;
|
|
11
11
|
export type Props = {
|
|
12
12
|
/**
|
|
13
13
|
* Optional class(es) to pass to the wrapping element.
|
|
@@ -14,8 +14,6 @@ function _extends() { _extends = Object.assign ? Object.assign.bind() : function
|
|
|
14
14
|
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
|
15
15
|
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
16
16
|
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
17
|
-
// omit global attributes of HTMLProps since they can only be string or undefined
|
|
18
|
-
|
|
19
17
|
var generateItems = function generateItems(_ref) {
|
|
20
18
|
var items = _ref.items,
|
|
21
19
|
ticked = _ref.ticked,
|
|
@@ -10,6 +10,12 @@ export declare const NotificationSeverity: {
|
|
|
10
10
|
readonly NEGATIVE: "negative";
|
|
11
11
|
readonly POSITIVE: "positive";
|
|
12
12
|
};
|
|
13
|
+
export declare const DefaultTitles: {
|
|
14
|
+
caution: string;
|
|
15
|
+
information: string;
|
|
16
|
+
negative: string;
|
|
17
|
+
positive: string;
|
|
18
|
+
};
|
|
13
19
|
type NotificationAction = {
|
|
14
20
|
label: string;
|
|
15
21
|
onClick: () => void;
|
|
@@ -1,24 +1,25 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
4
3
|
Object.defineProperty(exports, "__esModule", {
|
|
5
4
|
value: true
|
|
6
5
|
});
|
|
7
|
-
exports.default = exports.NotificationSeverity = exports.Label = void 0;
|
|
6
|
+
exports.default = exports.NotificationSeverity = exports.Label = exports.DefaultTitles = void 0;
|
|
8
7
|
var _classnames = _interopRequireDefault(require("classnames"));
|
|
9
8
|
var _react = _interopRequireWildcard(require("react"));
|
|
10
9
|
var _Button = _interopRequireWildcard(require("../Button"));
|
|
11
10
|
var _utils = require("../../utils");
|
|
12
11
|
var _excluded = ["actions", "borderless", "children", "className", "close", "inline", "onDismiss", "severity", "status", "timeout", "timestamp", "title", "titleElement", "type"];
|
|
12
|
+
var _DefaultTitles;
|
|
13
13
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
14
14
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
15
15
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
16
|
+
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
16
17
|
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); }
|
|
18
|
+
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
|
19
|
+
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
17
20
|
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
18
21
|
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
19
22
|
function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
20
|
-
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
|
21
|
-
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
22
23
|
var Label = /*#__PURE__*/function (Label) {
|
|
23
24
|
Label["Close"] = "Close notification";
|
|
24
25
|
return Label;
|
|
@@ -30,11 +31,13 @@ var NotificationSeverity = {
|
|
|
30
31
|
NEGATIVE: "negative",
|
|
31
32
|
POSITIVE: "positive"
|
|
32
33
|
};
|
|
34
|
+
exports.NotificationSeverity = NotificationSeverity;
|
|
35
|
+
var DefaultTitles = (_DefaultTitles = {}, _defineProperty(_DefaultTitles, NotificationSeverity.CAUTION, "Warning"), _defineProperty(_DefaultTitles, NotificationSeverity.INFORMATION, "Info"), _defineProperty(_DefaultTitles, NotificationSeverity.NEGATIVE, "Error"), _defineProperty(_DefaultTitles, NotificationSeverity.POSITIVE, "Success"), _DefaultTitles);
|
|
33
36
|
|
|
34
37
|
/**
|
|
35
38
|
* The props for the Notification component.
|
|
36
39
|
*/
|
|
37
|
-
exports.
|
|
40
|
+
exports.DefaultTitles = DefaultTitles;
|
|
38
41
|
var Notification = function Notification(_ref) {
|
|
39
42
|
var _classNames;
|
|
40
43
|
var actions = _ref.actions,
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { FC } from "react";
|
|
2
|
+
import { NotificationHelper, NotifyProviderProps } from "./types";
|
|
3
|
+
export declare const NotificationProvider: FC<NotifyProviderProps>;
|
|
4
|
+
export declare function useNotify(): NotificationHelper;
|
|
5
|
+
export declare const NotificationConsumer: FC;
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.NotificationProvider = exports.NotificationConsumer = void 0;
|
|
8
|
+
exports.useNotify = useNotify;
|
|
9
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
10
|
+
var _reactRouterDom = require("react-router-dom");
|
|
11
|
+
var _isEqual = _interopRequireDefault(require("lodash/isEqual"));
|
|
12
|
+
var _messageBuilder = require("./messageBuilder");
|
|
13
|
+
var _Notification = _interopRequireWildcard(require("../Notification/Notification"));
|
|
14
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
15
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
16
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
17
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
18
|
+
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
19
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
20
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
21
|
+
function _iterableToArrayLimit(arr, i) { var _i = null == arr ? null : "undefined" != typeof Symbol && arr[Symbol.iterator] || arr["@@iterator"]; if (null != _i) { var _s, _e, _x, _r, _arr = [], _n = !0, _d = !1; try { if (_x = (_i = _i.call(arr)).next, 0 === i) { if (Object(_i) !== _i) return; _n = !1; } else for (; !(_n = (_s = _x.call(_i)).done) && (_arr.push(_s.value), _arr.length !== i); _n = !0); } catch (err) { _d = !0, _e = err; } finally { try { if (!_n && null != _i.return && (_r = _i.return(), Object(_r) !== _r)) return; } finally { if (_d) throw _e; } } return _arr; } }
|
|
22
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
23
|
+
var NotifyContext = /*#__PURE__*/(0, _react.createContext)({
|
|
24
|
+
notification: null,
|
|
25
|
+
clear: function clear() {
|
|
26
|
+
return undefined;
|
|
27
|
+
},
|
|
28
|
+
failure: function failure() {
|
|
29
|
+
return undefined;
|
|
30
|
+
},
|
|
31
|
+
success: function success() {
|
|
32
|
+
return undefined;
|
|
33
|
+
},
|
|
34
|
+
info: function info() {
|
|
35
|
+
return undefined;
|
|
36
|
+
},
|
|
37
|
+
queue: function queue() {
|
|
38
|
+
return undefined;
|
|
39
|
+
}
|
|
40
|
+
});
|
|
41
|
+
var NotificationProvider = function NotificationProvider(_ref) {
|
|
42
|
+
var children = _ref.children;
|
|
43
|
+
var _useState = (0, _react.useState)(null),
|
|
44
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
45
|
+
notification = _useState2[0],
|
|
46
|
+
setNotification = _useState2[1];
|
|
47
|
+
var _ref2 = (0, _reactRouterDom.useLocation)(),
|
|
48
|
+
state = _ref2.state,
|
|
49
|
+
pathname = _ref2.pathname;
|
|
50
|
+
var clear = function clear() {
|
|
51
|
+
return notification !== null && setNotification(null);
|
|
52
|
+
};
|
|
53
|
+
var setDeduplicated = function setDeduplicated(value) {
|
|
54
|
+
if (!(0, _isEqual.default)(value, notification)) {
|
|
55
|
+
setNotification(value);
|
|
56
|
+
}
|
|
57
|
+
return value;
|
|
58
|
+
};
|
|
59
|
+
(0, _react.useEffect)(function () {
|
|
60
|
+
if (state !== null && state !== void 0 && state.queuedNotification) {
|
|
61
|
+
setDeduplicated(state.queuedNotification);
|
|
62
|
+
window.history.replaceState({}, "");
|
|
63
|
+
} else {
|
|
64
|
+
clear();
|
|
65
|
+
}
|
|
66
|
+
}, [state, pathname]);
|
|
67
|
+
var helper = {
|
|
68
|
+
notification: notification,
|
|
69
|
+
clear: clear,
|
|
70
|
+
queue: _messageBuilder.queue,
|
|
71
|
+
failure: function failure(title, error, message, actions) {
|
|
72
|
+
return setDeduplicated((0, _messageBuilder.failure)(title, error, message, actions));
|
|
73
|
+
},
|
|
74
|
+
info: function info(message, title) {
|
|
75
|
+
return setDeduplicated((0, _messageBuilder.info)(message, title));
|
|
76
|
+
},
|
|
77
|
+
success: function success(message) {
|
|
78
|
+
return setDeduplicated((0, _messageBuilder.success)(message));
|
|
79
|
+
}
|
|
80
|
+
};
|
|
81
|
+
return /*#__PURE__*/_react.default.createElement(NotifyContext.Provider, {
|
|
82
|
+
value: helper
|
|
83
|
+
}, children);
|
|
84
|
+
};
|
|
85
|
+
exports.NotificationProvider = NotificationProvider;
|
|
86
|
+
function useNotify() {
|
|
87
|
+
return (0, _react.useContext)(NotifyContext);
|
|
88
|
+
}
|
|
89
|
+
var NotificationConsumer = function NotificationConsumer() {
|
|
90
|
+
var notify = useNotify();
|
|
91
|
+
var ref = (0, _react.useRef)(null);
|
|
92
|
+
(0, _react.useEffect)(function () {
|
|
93
|
+
var _ref$current;
|
|
94
|
+
if ((_ref$current = ref.current) !== null && _ref$current !== void 0 && _ref$current.hasAttribute("scrollIntoView")) {
|
|
95
|
+
ref.current.scrollIntoView({
|
|
96
|
+
behavior: "smooth",
|
|
97
|
+
block: "center",
|
|
98
|
+
inline: "start"
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
}, [notify.notification]);
|
|
102
|
+
if (!notify.notification) {
|
|
103
|
+
return null;
|
|
104
|
+
}
|
|
105
|
+
var _notify$notification = notify.notification,
|
|
106
|
+
actions = _notify$notification.actions,
|
|
107
|
+
title = _notify$notification.title,
|
|
108
|
+
type = _notify$notification.type,
|
|
109
|
+
message = _notify$notification.message;
|
|
110
|
+
return /*#__PURE__*/_react.default.createElement("div", {
|
|
111
|
+
ref: ref
|
|
112
|
+
}, /*#__PURE__*/_react.default.createElement(_Notification.default, {
|
|
113
|
+
title: title !== null && title !== void 0 ? title : _Notification.DefaultTitles[type],
|
|
114
|
+
actions: actions,
|
|
115
|
+
severity: type,
|
|
116
|
+
onDismiss: notify.clear
|
|
117
|
+
}, message));
|
|
118
|
+
};
|
|
119
|
+
exports.NotificationConsumer = NotificationConsumer;
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
export { NotificationConsumer, NotificationProvider, useNotify, } from "./NotificationProvider";
|
|
2
|
+
export { info, success, failure, queue } from "./messageBuilder";
|
|
3
|
+
export type { NotificationAction, NotificationType, QueuedNotification, NotificationHelper, } from "./types";
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
Object.defineProperty(exports, "NotificationConsumer", {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: function get() {
|
|
9
|
+
return _NotificationProvider.NotificationConsumer;
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
Object.defineProperty(exports, "NotificationProvider", {
|
|
13
|
+
enumerable: true,
|
|
14
|
+
get: function get() {
|
|
15
|
+
return _NotificationProvider.NotificationProvider;
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
Object.defineProperty(exports, "failure", {
|
|
19
|
+
enumerable: true,
|
|
20
|
+
get: function get() {
|
|
21
|
+
return _messageBuilder.failure;
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
Object.defineProperty(exports, "info", {
|
|
25
|
+
enumerable: true,
|
|
26
|
+
get: function get() {
|
|
27
|
+
return _messageBuilder.info;
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
Object.defineProperty(exports, "queue", {
|
|
31
|
+
enumerable: true,
|
|
32
|
+
get: function get() {
|
|
33
|
+
return _messageBuilder.queue;
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
Object.defineProperty(exports, "success", {
|
|
37
|
+
enumerable: true,
|
|
38
|
+
get: function get() {
|
|
39
|
+
return _messageBuilder.success;
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
Object.defineProperty(exports, "useNotify", {
|
|
43
|
+
enumerable: true,
|
|
44
|
+
get: function get() {
|
|
45
|
+
return _NotificationProvider.useNotify;
|
|
46
|
+
}
|
|
47
|
+
});
|
|
48
|
+
var _NotificationProvider = require("./NotificationProvider");
|
|
49
|
+
var _messageBuilder = require("./messageBuilder");
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { NotificationAction, NotificationType, QueuedNotification } from "./types";
|
|
2
|
+
import { ReactNode } from "react";
|
|
3
|
+
export declare const queue: (notification: NotificationType) => QueuedNotification;
|
|
4
|
+
export declare const info: (message: ReactNode, title?: string) => NotificationType;
|
|
5
|
+
export declare const success: (message: ReactNode) => NotificationType;
|
|
6
|
+
export declare const failure: (title: string, error: unknown, message?: ReactNode, actions?: NotificationAction[]) => NotificationType;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.success = exports.queue = exports.info = exports.failure = void 0;
|
|
7
|
+
var _react = _interopRequireDefault(require("react"));
|
|
8
|
+
var _Notification = require("../Notification");
|
|
9
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
10
|
+
var queue = function queue(notification) {
|
|
11
|
+
return {
|
|
12
|
+
state: {
|
|
13
|
+
queuedNotification: notification
|
|
14
|
+
}
|
|
15
|
+
};
|
|
16
|
+
};
|
|
17
|
+
exports.queue = queue;
|
|
18
|
+
var info = function info(message, title) {
|
|
19
|
+
return {
|
|
20
|
+
message: message,
|
|
21
|
+
title: title,
|
|
22
|
+
type: _Notification.NotificationSeverity.INFORMATION
|
|
23
|
+
};
|
|
24
|
+
};
|
|
25
|
+
exports.info = info;
|
|
26
|
+
var success = function success(message) {
|
|
27
|
+
return {
|
|
28
|
+
message: message,
|
|
29
|
+
type: _Notification.NotificationSeverity.POSITIVE
|
|
30
|
+
};
|
|
31
|
+
};
|
|
32
|
+
exports.success = success;
|
|
33
|
+
var failure = function failure(title, error, message, actions) {
|
|
34
|
+
return {
|
|
35
|
+
actions: actions,
|
|
36
|
+
message: error && error instanceof Error ? /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, message, " ", error.message) : message,
|
|
37
|
+
title: title,
|
|
38
|
+
type: _Notification.NotificationSeverity.NEGATIVE
|
|
39
|
+
};
|
|
40
|
+
};
|
|
41
|
+
exports.failure = failure;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { ReactNode } from "react";
|
|
2
|
+
import { ValueOf } from "../../types";
|
|
3
|
+
import { NotificationSeverity } from "../Notification";
|
|
4
|
+
export interface NotifyProviderProps {
|
|
5
|
+
children: ReactNode;
|
|
6
|
+
}
|
|
7
|
+
export interface NotificationAction {
|
|
8
|
+
label: string;
|
|
9
|
+
onClick: () => void;
|
|
10
|
+
}
|
|
11
|
+
export interface NotificationType {
|
|
12
|
+
actions?: NotificationAction[];
|
|
13
|
+
message: ReactNode;
|
|
14
|
+
title?: string;
|
|
15
|
+
type: ValueOf<typeof NotificationSeverity>;
|
|
16
|
+
}
|
|
17
|
+
export interface QueuedNotification {
|
|
18
|
+
state?: {
|
|
19
|
+
queuedNotification: NotificationType | null;
|
|
20
|
+
};
|
|
21
|
+
pathname?: string;
|
|
22
|
+
}
|
|
23
|
+
export interface NotificationHelper {
|
|
24
|
+
notification: NotificationType | null;
|
|
25
|
+
clear: () => void;
|
|
26
|
+
failure: (title: string, error: unknown, message?: ReactNode, actions?: NotificationAction[]) => NotificationType;
|
|
27
|
+
info: (message: ReactNode, title?: string) => NotificationType;
|
|
28
|
+
success: (message: ReactNode) => NotificationType;
|
|
29
|
+
queue: (notification: NotificationType) => QueuedNotification;
|
|
30
|
+
}
|
|
@@ -228,7 +228,7 @@ var Tooltip = function Tooltip(_ref) {
|
|
|
228
228
|
}
|
|
229
229
|
}, _react.default.Children.map(children, function (child) {
|
|
230
230
|
return child && /*#__PURE__*/_react.default.isValidElement(child) ? /*#__PURE__*/_react.default.cloneElement(child, {
|
|
231
|
-
"aria-describedby": tooltipId
|
|
231
|
+
"aria-describedby": isOpen ? tooltipId : undefined
|
|
232
232
|
}) : child;
|
|
233
233
|
})), isOpen ? /*#__PURE__*/_react.default.createElement(Portal, null, /*#__PURE__*/_react.default.createElement("span", {
|
|
234
234
|
className: (0, _classnames.default)("p-tooltip--".concat(adjustedPosition), "is-detached", tooltipClassName),
|
package/dist/index.d.ts
CHANGED
|
@@ -9,7 +9,10 @@ export { default as Chip } from "./components/Chip";
|
|
|
9
9
|
export { default as Code } from "./components/Code";
|
|
10
10
|
export { default as CodeSnippet, CodeSnippetBlockAppearance, } from "./components/CodeSnippet";
|
|
11
11
|
export { default as Col } from "./components/Col";
|
|
12
|
+
export { default as ConfirmationButton } from "./components/ConfirmationButton";
|
|
13
|
+
export { default as ConfirmationModal } from "./components/ConfirmationModal";
|
|
12
14
|
export { default as ContextualMenu } from "./components/ContextualMenu";
|
|
15
|
+
export { default as EmptyState } from "./components/EmptyState";
|
|
13
16
|
export { default as Field } from "./components/Field";
|
|
14
17
|
export { default as Form } from "./components/Form";
|
|
15
18
|
export { default as Icon, ICONS } from "./components/Icon";
|
|
@@ -23,6 +26,7 @@ export { default as ModularTable } from "./components/ModularTable";
|
|
|
23
26
|
export { default as Navigation } from "./components/Navigation";
|
|
24
27
|
export { default as Modal } from "./components/Modal";
|
|
25
28
|
export { default as Notification, NotificationSeverity, } from "./components/Notification";
|
|
29
|
+
export { NotificationConsumer, NotificationProvider, useNotify, info, success, failure, queue, } from "./components/NotificationProvider";
|
|
26
30
|
export { default as Pagination } from "./components/Pagination";
|
|
27
31
|
export { default as PasswordToggle } from "./components/PasswordToggle";
|
|
28
32
|
export { default as RadioInput } from "./components/RadioInput";
|
|
@@ -54,7 +58,10 @@ export type { ChipProps } from "./components/Chip";
|
|
|
54
58
|
export type { CodeProps } from "./components/Code";
|
|
55
59
|
export type { CodeSnippetProps, CodeSnippetBlockProps, CodeSnippetDropdownProps, } from "./components/CodeSnippet";
|
|
56
60
|
export type { ColProps, ColSize } from "./components/Col";
|
|
61
|
+
export type { ConfirmationButtonProps } from "./components/ConfirmationButton";
|
|
62
|
+
export type { ConfirmationModalProps } from "./components/ConfirmationModal";
|
|
57
63
|
export type { ContextualMenuProps, ContextualMenuDropdownProps, MenuLink, Position, } from "./components/ContextualMenu";
|
|
64
|
+
export type { EmptyStateProps } from "./components/EmptyState";
|
|
58
65
|
export type { FieldProps } from "./components/Field";
|
|
59
66
|
export type { FormProps } from "./components/Form";
|
|
60
67
|
export type { IconProps } from "./components/Icon";
|
|
@@ -67,6 +74,7 @@ export type { ModularTableProps } from "./components/ModularTable";
|
|
|
67
74
|
export type { ModalProps } from "./components/Modal";
|
|
68
75
|
export type { GenerateLink, LogoProps, NavigationProps, NavItem, NavLink, NavLinkAnchor, NavLinkBase, NavLinkButton, } from "./components/Navigation";
|
|
69
76
|
export type { NotificationProps } from "./components/Notification";
|
|
77
|
+
export type { NotificationAction, NotificationType, QueuedNotification, NotificationHelper, } from "./components/NotificationProvider";
|
|
70
78
|
export type { PaginationProps } from "./components/Pagination";
|
|
71
79
|
export type { RadioInputProps } from "./components/RadioInput";
|
|
72
80
|
export type { RowProps } from "./components/Row";
|
package/dist/index.js
CHANGED
|
@@ -82,12 +82,30 @@ Object.defineProperty(exports, "Col", {
|
|
|
82
82
|
return _Col.default;
|
|
83
83
|
}
|
|
84
84
|
});
|
|
85
|
+
Object.defineProperty(exports, "ConfirmationButton", {
|
|
86
|
+
enumerable: true,
|
|
87
|
+
get: function get() {
|
|
88
|
+
return _ConfirmationButton.default;
|
|
89
|
+
}
|
|
90
|
+
});
|
|
91
|
+
Object.defineProperty(exports, "ConfirmationModal", {
|
|
92
|
+
enumerable: true,
|
|
93
|
+
get: function get() {
|
|
94
|
+
return _ConfirmationModal.default;
|
|
95
|
+
}
|
|
96
|
+
});
|
|
85
97
|
Object.defineProperty(exports, "ContextualMenu", {
|
|
86
98
|
enumerable: true,
|
|
87
99
|
get: function get() {
|
|
88
100
|
return _ContextualMenu.default;
|
|
89
101
|
}
|
|
90
102
|
});
|
|
103
|
+
Object.defineProperty(exports, "EmptyState", {
|
|
104
|
+
enumerable: true,
|
|
105
|
+
get: function get() {
|
|
106
|
+
return _EmptyState.default;
|
|
107
|
+
}
|
|
108
|
+
});
|
|
91
109
|
Object.defineProperty(exports, "Field", {
|
|
92
110
|
enumerable: true,
|
|
93
111
|
get: function get() {
|
|
@@ -172,6 +190,18 @@ Object.defineProperty(exports, "Notification", {
|
|
|
172
190
|
return _Notification.default;
|
|
173
191
|
}
|
|
174
192
|
});
|
|
193
|
+
Object.defineProperty(exports, "NotificationConsumer", {
|
|
194
|
+
enumerable: true,
|
|
195
|
+
get: function get() {
|
|
196
|
+
return _NotificationProvider.NotificationConsumer;
|
|
197
|
+
}
|
|
198
|
+
});
|
|
199
|
+
Object.defineProperty(exports, "NotificationProvider", {
|
|
200
|
+
enumerable: true,
|
|
201
|
+
get: function get() {
|
|
202
|
+
return _NotificationProvider.NotificationProvider;
|
|
203
|
+
}
|
|
204
|
+
});
|
|
175
205
|
Object.defineProperty(exports, "NotificationSeverity", {
|
|
176
206
|
enumerable: true,
|
|
177
207
|
get: function get() {
|
|
@@ -310,6 +340,18 @@ Object.defineProperty(exports, "Tooltip", {
|
|
|
310
340
|
return _Tooltip.default;
|
|
311
341
|
}
|
|
312
342
|
});
|
|
343
|
+
Object.defineProperty(exports, "failure", {
|
|
344
|
+
enumerable: true,
|
|
345
|
+
get: function get() {
|
|
346
|
+
return _NotificationProvider.failure;
|
|
347
|
+
}
|
|
348
|
+
});
|
|
349
|
+
Object.defineProperty(exports, "info", {
|
|
350
|
+
enumerable: true,
|
|
351
|
+
get: function get() {
|
|
352
|
+
return _NotificationProvider.info;
|
|
353
|
+
}
|
|
354
|
+
});
|
|
313
355
|
Object.defineProperty(exports, "isNavigationAnchor", {
|
|
314
356
|
enumerable: true,
|
|
315
357
|
get: function get() {
|
|
@@ -322,6 +364,18 @@ Object.defineProperty(exports, "isNavigationButton", {
|
|
|
322
364
|
return _utils.isNavigationButton;
|
|
323
365
|
}
|
|
324
366
|
});
|
|
367
|
+
Object.defineProperty(exports, "queue", {
|
|
368
|
+
enumerable: true,
|
|
369
|
+
get: function get() {
|
|
370
|
+
return _NotificationProvider.queue;
|
|
371
|
+
}
|
|
372
|
+
});
|
|
373
|
+
Object.defineProperty(exports, "success", {
|
|
374
|
+
enumerable: true,
|
|
375
|
+
get: function get() {
|
|
376
|
+
return _NotificationProvider.success;
|
|
377
|
+
}
|
|
378
|
+
});
|
|
325
379
|
Object.defineProperty(exports, "useClickOutside", {
|
|
326
380
|
enumerable: true,
|
|
327
381
|
get: function get() {
|
|
@@ -340,6 +394,12 @@ Object.defineProperty(exports, "useListener", {
|
|
|
340
394
|
return _hooks.useListener;
|
|
341
395
|
}
|
|
342
396
|
});
|
|
397
|
+
Object.defineProperty(exports, "useNotify", {
|
|
398
|
+
enumerable: true,
|
|
399
|
+
get: function get() {
|
|
400
|
+
return _NotificationProvider.useNotify;
|
|
401
|
+
}
|
|
402
|
+
});
|
|
343
403
|
Object.defineProperty(exports, "useOnEscapePressed", {
|
|
344
404
|
enumerable: true,
|
|
345
405
|
get: function get() {
|
|
@@ -381,7 +441,10 @@ var _Chip = _interopRequireDefault(require("./components/Chip"));
|
|
|
381
441
|
var _Code = _interopRequireDefault(require("./components/Code"));
|
|
382
442
|
var _CodeSnippet = _interopRequireWildcard(require("./components/CodeSnippet"));
|
|
383
443
|
var _Col = _interopRequireDefault(require("./components/Col"));
|
|
444
|
+
var _ConfirmationButton = _interopRequireDefault(require("./components/ConfirmationButton"));
|
|
445
|
+
var _ConfirmationModal = _interopRequireDefault(require("./components/ConfirmationModal"));
|
|
384
446
|
var _ContextualMenu = _interopRequireDefault(require("./components/ContextualMenu"));
|
|
447
|
+
var _EmptyState = _interopRequireDefault(require("./components/EmptyState"));
|
|
385
448
|
var _Field = _interopRequireDefault(require("./components/Field"));
|
|
386
449
|
var _Form = _interopRequireDefault(require("./components/Form"));
|
|
387
450
|
var _Icon = _interopRequireWildcard(require("./components/Icon"));
|
|
@@ -395,6 +458,7 @@ var _ModularTable = _interopRequireDefault(require("./components/ModularTable"))
|
|
|
395
458
|
var _Navigation = _interopRequireDefault(require("./components/Navigation"));
|
|
396
459
|
var _Modal = _interopRequireDefault(require("./components/Modal"));
|
|
397
460
|
var _Notification = _interopRequireWildcard(require("./components/Notification"));
|
|
461
|
+
var _NotificationProvider = require("./components/NotificationProvider");
|
|
398
462
|
var _Pagination = _interopRequireDefault(require("./components/Pagination"));
|
|
399
463
|
var _PasswordToggle = _interopRequireDefault(require("./components/PasswordToggle"));
|
|
400
464
|
var _RadioInput = _interopRequireDefault(require("./components/RadioInput"));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@canonical/react-components",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.44.0",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"module": "dist/index.js",
|
|
6
6
|
"author": "Huw Wilkins <huw.wilkins@canonical.com>",
|
|
@@ -22,10 +22,10 @@
|
|
|
22
22
|
},
|
|
23
23
|
"homepage": "https://canonical.github.io/react-components",
|
|
24
24
|
"devDependencies": {
|
|
25
|
-
"@babel/cli": "7.
|
|
26
|
-
"@babel/eslint-parser": "7.
|
|
27
|
-
"@babel/preset-typescript": "7.
|
|
28
|
-
"@percy/cli": "1.
|
|
25
|
+
"@babel/cli": "7.22.5",
|
|
26
|
+
"@babel/eslint-parser": "7.22.5",
|
|
27
|
+
"@babel/preset-typescript": "7.22.5",
|
|
28
|
+
"@percy/cli": "1.26.1",
|
|
29
29
|
"@percy/storybook": "4.3.6",
|
|
30
30
|
"@storybook/addon-a11y": "6.5.16",
|
|
31
31
|
"@storybook/addon-controls": "6.5.16",
|
|
@@ -36,21 +36,22 @@
|
|
|
36
36
|
"@storybook/react": "6.5.16",
|
|
37
37
|
"@storybook/theming": "6.5.16",
|
|
38
38
|
"@testing-library/cypress": "9.0.0",
|
|
39
|
-
"@testing-library/dom": "9.
|
|
39
|
+
"@testing-library/dom": "9.3.1",
|
|
40
40
|
"@testing-library/jest-dom": "5.16.5",
|
|
41
|
-
"@testing-library/react": "
|
|
41
|
+
"@testing-library/react": "14.0.0",
|
|
42
42
|
"@testing-library/user-event": "14.4.3",
|
|
43
|
-
"@
|
|
44
|
-
"@typescript-eslint/
|
|
43
|
+
"@types/react-router-dom": "5.3.3",
|
|
44
|
+
"@typescript-eslint/eslint-plugin": "5.60.1",
|
|
45
|
+
"@typescript-eslint/parser": "5.60.1",
|
|
45
46
|
"babel-jest": "27.5.1",
|
|
46
47
|
"babel-loader": "9.1.2",
|
|
47
48
|
"babel-plugin-module-resolver": "5.0.0",
|
|
48
49
|
"babel-plugin-typescript-to-proptypes": "2.1.0",
|
|
49
|
-
"concurrently": "
|
|
50
|
-
"css-loader": "6.
|
|
51
|
-
"cypress": "12.
|
|
50
|
+
"concurrently": "8.2.0",
|
|
51
|
+
"css-loader": "6.8.1",
|
|
52
|
+
"cypress": "12.16.0",
|
|
52
53
|
"deepmerge": "4.3.1",
|
|
53
|
-
"eslint": "8.
|
|
54
|
+
"eslint": "8.43.0",
|
|
54
55
|
"eslint-config-prettier": "8.8.0",
|
|
55
56
|
"eslint-config-react-app": "7.0.1",
|
|
56
57
|
"eslint-plugin-cypress": "2.13.3",
|
|
@@ -60,17 +61,17 @@
|
|
|
60
61
|
"eslint-plugin-prettier": "4.2.1",
|
|
61
62
|
"eslint-plugin-react": "7.32.2",
|
|
62
63
|
"eslint-plugin-react-hooks": "4.6.0",
|
|
63
|
-
"eslint-plugin-testing-library": "5.
|
|
64
|
+
"eslint-plugin-testing-library": "5.11.0",
|
|
64
65
|
"jest": "27.5.1",
|
|
65
66
|
"npm-package-json-lint": "5.4.2",
|
|
66
67
|
"prettier": "2.8.8",
|
|
67
68
|
"react": "18.2.0",
|
|
68
69
|
"react-docgen-typescript-loader": "3.7.2",
|
|
69
70
|
"react-dom": "18.2.0",
|
|
70
|
-
"sass": "1.
|
|
71
|
+
"sass": "1.63.6",
|
|
71
72
|
"sass-loader": "10.4.1",
|
|
72
|
-
"style-loader": "3.3.
|
|
73
|
-
"stylelint": "
|
|
73
|
+
"style-loader": "3.3.3",
|
|
74
|
+
"stylelint": "15.10.1",
|
|
74
75
|
"stylelint-config-prettier": "9.0.5",
|
|
75
76
|
"stylelint-config-recommended-scss": "5.0.2",
|
|
76
77
|
"stylelint-order": "5.0.0",
|
|
@@ -78,25 +79,26 @@
|
|
|
78
79
|
"ts-jest": "27.1.5",
|
|
79
80
|
"tsc-alias": "1.8.6",
|
|
80
81
|
"typescript": "4.9.5",
|
|
81
|
-
"vanilla-framework": "
|
|
82
|
+
"vanilla-framework": "4.0.0",
|
|
82
83
|
"wait-on": "5.3.0",
|
|
83
|
-
"webpack": "5.
|
|
84
|
+
"webpack": "5.88.0"
|
|
84
85
|
},
|
|
85
86
|
"dependencies": {
|
|
86
87
|
"@types/jest": "27.5.2",
|
|
87
|
-
"@types/node": "18.16.
|
|
88
|
-
"@types/react": "18.2.
|
|
89
|
-
"@types/react-dom": "
|
|
88
|
+
"@types/node": "18.16.18",
|
|
89
|
+
"@types/react": "18.2.14",
|
|
90
|
+
"@types/react-dom": "18.2.6",
|
|
90
91
|
"@types/react-table": "7.7.14",
|
|
91
92
|
"classnames": "2.3.2",
|
|
92
93
|
"nanoid": "3.3.6",
|
|
93
94
|
"prop-types": "15.8.1",
|
|
95
|
+
"react-router-dom": "6.6.1",
|
|
94
96
|
"react-table": "7.8.0",
|
|
95
97
|
"react-useportal": "1.0.18"
|
|
96
98
|
},
|
|
97
99
|
"resolutions": {
|
|
98
|
-
"@types/react": "18.2.
|
|
99
|
-
"@types/react-dom": "
|
|
100
|
+
"@types/react": "18.2.14",
|
|
101
|
+
"@types/react-dom": "18.2.6",
|
|
100
102
|
"postcss": "^8.3.11"
|
|
101
103
|
},
|
|
102
104
|
"peerDependencies": {
|
|
@@ -104,7 +106,7 @@
|
|
|
104
106
|
"@types/react-dom": "^17.0.2 || ^18.0.0",
|
|
105
107
|
"react": "^17.0.2 || ^18.0.0",
|
|
106
108
|
"react-dom": "^17.0.2 || ^18.0.0",
|
|
107
|
-
"vanilla-framework": "3.
|
|
109
|
+
"vanilla-framework": "^3.15.1 || ^4.0.0"
|
|
108
110
|
},
|
|
109
111
|
"scripts": {
|
|
110
112
|
"build": "rm -rf dist && yarn build-local; yarn build-declaration",
|