@canonical/react-components 0.47.1 → 0.47.2
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/__mocks__/nanoid.js +3 -3
- package/dist/components/Accordion/Accordion.js +28 -41
- package/dist/components/Accordion/AccordionSection/AccordionSection.js +18 -18
- package/dist/components/Accordion/AccordionSection/index.js +1 -1
- package/dist/components/Accordion/index.js +1 -1
- package/dist/components/ActionButton/ActionButton.js +34 -66
- package/dist/components/ActionButton/index.js +1 -1
- package/dist/components/ArticlePagination/ArticlePagination.js +10 -12
- package/dist/components/ArticlePagination/index.js +1 -1
- package/dist/components/Badge/Badge.js +24 -29
- package/dist/components/Badge/index.js +1 -1
- package/dist/components/Button/Button.js +21 -26
- package/dist/components/Button/index.js +4 -5
- package/dist/components/Card/Card.js +12 -14
- package/dist/components/Card/index.js +1 -1
- package/dist/components/CheckboxInput/CheckableInput/CheckableInput.js +15 -19
- package/dist/components/CheckboxInput/CheckableInput/index.js +1 -1
- package/dist/components/CheckboxInput/CheckboxInput.js +7 -10
- package/dist/components/CheckboxInput/index.js +1 -1
- package/dist/components/Chip/Chip.js +23 -33
- package/dist/components/Chip/index.js +1 -1
- package/dist/components/Code/Code.js +14 -17
- package/dist/components/Code/index.js +1 -1
- package/dist/components/CodeSnippet/CodeSnippet.js +9 -14
- package/dist/components/CodeSnippet/CodeSnippetBlock.js +24 -29
- package/dist/components/CodeSnippet/CodeSnippetDropdown.js +11 -11
- package/dist/components/CodeSnippet/index.js +2 -2
- package/dist/components/Col/Col.js +24 -26
- package/dist/components/Col/index.js +4 -5
- package/dist/components/ConfirmationButton/ConfirmationButton.js +18 -21
- package/dist/components/ConfirmationButton/index.js +1 -1
- package/dist/components/ConfirmationModal/ConfirmationModal.js +11 -15
- package/dist/components/ConfirmationModal/index.js +1 -1
- package/dist/components/ContextualMenu/ContextualMenu.js +89 -107
- package/dist/components/ContextualMenu/ContextualMenuDropdown/ContextualMenuDropdown.d.ts +4 -4
- package/dist/components/ContextualMenu/ContextualMenuDropdown/ContextualMenuDropdown.js +97 -107
- package/dist/components/ContextualMenu/ContextualMenuDropdown/index.js +1 -1
- package/dist/components/ContextualMenu/index.js +1 -1
- package/dist/components/EmptyState/EmptyState.js +9 -11
- package/dist/components/EmptyState/index.js +1 -1
- package/dist/components/Field/Field.js +66 -65
- package/dist/components/Field/index.js +1 -1
- package/dist/components/Form/Form.js +9 -11
- package/dist/components/Form/index.js +1 -1
- package/dist/components/Icon/Icon.js +9 -12
- package/dist/components/Icon/index.js +4 -5
- package/dist/components/Input/Input.js +38 -45
- package/dist/components/Input/index.js +1 -1
- package/dist/components/Label/Label.js +9 -11
- package/dist/components/Label/index.js +1 -1
- package/dist/components/Link/Link.js +12 -18
- package/dist/components/Link/index.js +1 -1
- package/dist/components/List/List.js +50 -54
- package/dist/components/List/index.js +1 -1
- package/dist/components/Loader/Loader.js +2 -3
- package/dist/components/Loader/index.js +1 -1
- package/dist/components/MainTable/MainTable.js +87 -104
- package/dist/components/MainTable/index.js +1 -1
- package/dist/components/Modal/Modal.js +37 -38
- package/dist/components/Modal/index.js +1 -1
- package/dist/components/ModularTable/ModularTable.js +63 -77
- package/dist/components/ModularTable/index.js +1 -1
- package/dist/components/Navigation/Navigation.js +63 -97
- package/dist/components/Navigation/NavigationLink/NavigationLink.js +32 -35
- package/dist/components/Navigation/NavigationLink/index.js +1 -1
- package/dist/components/Navigation/NavigationMenu/NavigationMenu.js +26 -45
- package/dist/components/Navigation/NavigationMenu/index.js +1 -1
- package/dist/components/Navigation/index.js +1 -1
- package/dist/components/Notification/Notification.js +49 -59
- package/dist/components/Notification/index.js +4 -5
- package/dist/components/NotificationProvider/NotificationProvider.js +47 -68
- package/dist/components/NotificationProvider/index.js +7 -7
- package/dist/components/NotificationProvider/messageBuilder.js +9 -9
- package/dist/components/NotificationProvider/types.d.ts +1 -0
- package/dist/components/Pagination/Pagination.js +50 -69
- package/dist/components/Pagination/PaginationButton/PaginationButton.js +11 -12
- package/dist/components/Pagination/PaginationButton/index.js +1 -1
- package/dist/components/Pagination/PaginationItem/PaginationItem.js +7 -7
- package/dist/components/Pagination/PaginationItem/index.js +1 -1
- package/dist/components/Pagination/index.js +1 -1
- package/dist/components/PasswordToggle/PasswordToggle.d.ts +1 -1
- package/dist/components/PasswordToggle/PasswordToggle.js +25 -40
- package/dist/components/PasswordToggle/index.js +1 -1
- package/dist/components/RadioInput/RadioInput.js +6 -8
- package/dist/components/RadioInput/index.js +1 -1
- package/dist/components/Row/Row.js +7 -9
- package/dist/components/Row/index.js +1 -1
- package/dist/components/SearchAndFilter/FilterPanelSection/FilterPanelSection.js +38 -51
- package/dist/components/SearchAndFilter/FilterPanelSection/index.js +1 -1
- package/dist/components/SearchAndFilter/SearchAndFilter.js +75 -135
- package/dist/components/SearchAndFilter/index.js +1 -1
- package/dist/components/SearchAndFilter/utils.js +4 -8
- package/dist/components/SearchBox/SearchBox.js +25 -33
- package/dist/components/SearchBox/index.js +1 -1
- package/dist/components/Select/Select.js +38 -44
- package/dist/components/Select/index.js +1 -1
- package/dist/components/Slider/Slider.js +27 -35
- package/dist/components/Slider/index.js +1 -1
- package/dist/components/Spinner/Spinner.js +10 -15
- package/dist/components/Spinner/index.js +1 -1
- package/dist/components/StatusLabel/StatusLabel.js +11 -13
- package/dist/components/StatusLabel/index.js +4 -5
- package/dist/components/Strip/Strip.js +27 -34
- package/dist/components/Strip/index.js +1 -1
- package/dist/components/SummaryButton/SummaryButton.js +9 -8
- package/dist/components/SummaryButton/index.js +1 -1
- package/dist/components/Switch/Switch.js +7 -10
- package/dist/components/Switch/index.js +1 -1
- package/dist/components/Table/Table.js +9 -13
- package/dist/components/Table/index.js +1 -1
- package/dist/components/TableCell/TableCell.js +11 -17
- package/dist/components/TableCell/index.js +1 -1
- package/dist/components/TableHeader/TableHeader.js +7 -9
- package/dist/components/TableHeader/index.js +1 -1
- package/dist/components/TablePagination/TablePagination.d.ts +37 -0
- package/dist/components/TablePagination/TablePagination.js +125 -0
- package/dist/components/TablePagination/TablePagination.scss +40 -0
- package/dist/components/TablePagination/TablePaginationControls/TablePaginationControls.d.ts +16 -0
- package/dist/components/TablePagination/TablePaginationControls/TablePaginationControls.js +66 -0
- package/dist/components/TablePagination/TablePaginationControls/index.d.ts +2 -0
- package/dist/components/TablePagination/TablePaginationControls/index.js +13 -0
- package/dist/components/TablePagination/index.d.ts +2 -0
- package/dist/components/TablePagination/index.js +13 -0
- package/dist/components/TableRow/TableRow.js +6 -8
- package/dist/components/TableRow/index.js +1 -1
- package/dist/components/Tabs/Tabs.js +17 -17
- package/dist/components/Tabs/index.js +1 -1
- package/dist/components/Textarea/Textarea.js +51 -45
- package/dist/components/Textarea/index.js +1 -1
- package/dist/components/Tooltip/Tooltip.d.ts +5 -1
- package/dist/components/Tooltip/Tooltip.js +76 -79
- package/dist/components/Tooltip/index.js +4 -5
- package/dist/enums.js +2 -3
- package/dist/hooks/index.d.ts +1 -1
- package/dist/hooks/index.js +16 -10
- package/dist/hooks/useId.js +1 -3
- package/dist/hooks/useListener.d.ts +2 -1
- package/dist/hooks/useListener.js +25 -24
- package/dist/hooks/useOnClickOutside.d.ts +12 -0
- package/dist/hooks/useOnClickOutside.js +45 -0
- package/dist/hooks/useOnEscapePressed.d.ts +3 -1
- package/dist/hooks/useOnEscapePressed.js +13 -6
- package/dist/hooks/usePagination.js +17 -29
- package/dist/hooks/usePrevious.js +4 -4
- package/dist/hooks/useThrottle.js +16 -25
- package/dist/hooks/useWindowFitment.js +30 -28
- package/dist/index.d.ts +3 -1
- package/dist/index.js +86 -74
- package/dist/utils.js +6 -13
- package/package.json +42 -35
- package/dist/hooks/useClickOutside.d.ts +0 -6
- package/dist/hooks/useClickOutside.js +0 -32
|
@@ -8,75 +8,68 @@ var _classnames = _interopRequireDefault(require("classnames"));
|
|
|
8
8
|
var _react = _interopRequireWildcard(require("react"));
|
|
9
9
|
var _Button = _interopRequireWildcard(require("../Button"));
|
|
10
10
|
var _utils = require("../../utils");
|
|
11
|
-
|
|
12
|
-
var
|
|
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
|
-
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; }
|
|
11
|
+
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
12
|
+
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
15
13
|
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); }
|
|
17
14
|
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
|
-
|
|
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; }
|
|
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; }
|
|
21
|
-
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
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); }
|
|
23
|
-
var Label = /*#__PURE__*/function (Label) {
|
|
15
|
+
let Label = exports.Label = /*#__PURE__*/function (Label) {
|
|
24
16
|
Label["Close"] = "Close notification";
|
|
25
17
|
return Label;
|
|
26
18
|
}({});
|
|
27
|
-
exports.
|
|
28
|
-
var NotificationSeverity = {
|
|
19
|
+
const NotificationSeverity = exports.NotificationSeverity = {
|
|
29
20
|
CAUTION: "caution",
|
|
30
21
|
INFORMATION: "information",
|
|
31
22
|
NEGATIVE: "negative",
|
|
32
23
|
POSITIVE: "positive"
|
|
33
24
|
};
|
|
34
|
-
exports.
|
|
35
|
-
|
|
25
|
+
const DefaultTitles = exports.DefaultTitles = {
|
|
26
|
+
[NotificationSeverity.CAUTION]: "Warning",
|
|
27
|
+
[NotificationSeverity.INFORMATION]: "Info",
|
|
28
|
+
[NotificationSeverity.NEGATIVE]: "Error",
|
|
29
|
+
[NotificationSeverity.POSITIVE]: "Success"
|
|
30
|
+
};
|
|
36
31
|
|
|
37
32
|
/**
|
|
38
33
|
* The props for the Notification component.
|
|
39
34
|
*/
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
var hasActions = (actions === null || actions === void 0 ? void 0 : actions.length) > 0;
|
|
64
|
-
var showMeta = !!timestamp || hasActions;
|
|
65
|
-
(0, _react.useEffect)(function () {
|
|
35
|
+
|
|
36
|
+
const Notification = _ref => {
|
|
37
|
+
let {
|
|
38
|
+
actions,
|
|
39
|
+
borderless = false,
|
|
40
|
+
children,
|
|
41
|
+
className,
|
|
42
|
+
close,
|
|
43
|
+
inline = false,
|
|
44
|
+
onDismiss,
|
|
45
|
+
severity = NotificationSeverity.INFORMATION,
|
|
46
|
+
status,
|
|
47
|
+
timeout,
|
|
48
|
+
timestamp,
|
|
49
|
+
title,
|
|
50
|
+
titleElement: TitleComponent = "h5",
|
|
51
|
+
type,
|
|
52
|
+
...props
|
|
53
|
+
} = _ref;
|
|
54
|
+
const timeoutId = (0, _react.useRef)(null);
|
|
55
|
+
const hasActions = (actions === null || actions === void 0 ? void 0 : actions.length) > 0;
|
|
56
|
+
const showMeta = !!timestamp || hasActions;
|
|
57
|
+
(0, _react.useEffect)(() => {
|
|
66
58
|
if (timeout && onDismiss) {
|
|
67
|
-
timeoutId.current = setTimeout(
|
|
68
|
-
return onDismiss();
|
|
69
|
-
}, timeout);
|
|
59
|
+
timeoutId.current = setTimeout(() => onDismiss(), timeout);
|
|
70
60
|
}
|
|
71
|
-
return
|
|
72
|
-
return clearTimeout(timeoutId.current);
|
|
73
|
-
};
|
|
61
|
+
return () => clearTimeout(timeoutId.current);
|
|
74
62
|
}, [onDismiss, timeout]);
|
|
75
63
|
if (_utils.IS_DEV && (close || status || type)) {
|
|
76
64
|
console.warn("The Notification component is using deprecated props. Refer to the deprecated list for details: https://canonical.github.io/react-components/?path=/docs/notification--information#deprecated");
|
|
77
65
|
}
|
|
78
66
|
return /*#__PURE__*/_react.default.createElement("div", _extends({
|
|
79
|
-
className: (0, _classnames.default)(className,
|
|
67
|
+
className: (0, _classnames.default)(className, {
|
|
68
|
+
["p-notification--".concat(severity)]: !!severity,
|
|
69
|
+
"p-notification": !severity,
|
|
70
|
+
"is-borderless": borderless,
|
|
71
|
+
"is-inline": inline
|
|
72
|
+
})
|
|
80
73
|
}, props), /*#__PURE__*/_react.default.createElement("div", {
|
|
81
74
|
className: "p-notification__content"
|
|
82
75
|
}, title && /*#__PURE__*/_react.default.createElement(TitleComponent, {
|
|
@@ -96,15 +89,12 @@ var Notification = function Notification(_ref) {
|
|
|
96
89
|
"data-testid": "notification-timestamp"
|
|
97
90
|
}, timestamp), hasActions ? /*#__PURE__*/_react.default.createElement("div", {
|
|
98
91
|
className: "p-notification__actions"
|
|
99
|
-
}, actions.map(
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
}, action.label);
|
|
107
|
-
})) : null));
|
|
92
|
+
}, actions.map((action, i) => /*#__PURE__*/_react.default.createElement(_Button.default, {
|
|
93
|
+
appearance: _Button.ButtonAppearance.LINK,
|
|
94
|
+
className: "p-notification__action",
|
|
95
|
+
"data-testid": "notification-action",
|
|
96
|
+
key: "".concat(action.label, "-").concat(i),
|
|
97
|
+
onClick: action.onClick
|
|
98
|
+
}, action.label))) : null));
|
|
108
99
|
};
|
|
109
|
-
var _default = Notification;
|
|
110
|
-
exports.default = _default;
|
|
100
|
+
var _default = exports.default = Notification;
|
|
@@ -1,21 +1,20 @@
|
|
|
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
6
|
Object.defineProperty(exports, "NotificationSeverity", {
|
|
8
7
|
enumerable: true,
|
|
9
|
-
get: function
|
|
8
|
+
get: function () {
|
|
10
9
|
return _Notification.NotificationSeverity;
|
|
11
10
|
}
|
|
12
11
|
});
|
|
13
12
|
Object.defineProperty(exports, "default", {
|
|
14
13
|
enumerable: true,
|
|
15
|
-
get: function
|
|
14
|
+
get: function () {
|
|
16
15
|
return _Notification.default;
|
|
17
16
|
}
|
|
18
17
|
});
|
|
19
18
|
var _Notification = _interopRequireWildcard(require("./Notification"));
|
|
20
|
-
function _getRequireWildcardCache(
|
|
21
|
-
function _interopRequireWildcard(
|
|
19
|
+
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
20
|
+
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
@@ -1,6 +1,5 @@
|
|
|
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
|
});
|
|
@@ -12,71 +11,37 @@ var _isEqual = _interopRequireDefault(require("lodash/isEqual"));
|
|
|
12
11
|
var _messageBuilder = require("./messageBuilder");
|
|
13
12
|
var _Notification = _interopRequireWildcard(require("../Notification/Notification"));
|
|
14
13
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
15
|
-
function _getRequireWildcardCache(
|
|
16
|
-
function _interopRequireWildcard(
|
|
17
|
-
|
|
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)({
|
|
14
|
+
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
15
|
+
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
16
|
+
const NotifyContext = /*#__PURE__*/(0, _react.createContext)({
|
|
24
17
|
notification: null,
|
|
25
|
-
clear:
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
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
|
-
}
|
|
18
|
+
clear: () => undefined,
|
|
19
|
+
failure: () => undefined,
|
|
20
|
+
success: () => undefined,
|
|
21
|
+
info: () => undefined,
|
|
22
|
+
queue: () => undefined,
|
|
23
|
+
setDeduplicated: () => undefined
|
|
40
24
|
});
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
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) {
|
|
25
|
+
const NotificationProvider = _ref => {
|
|
26
|
+
let {
|
|
27
|
+
children
|
|
28
|
+
} = _ref;
|
|
29
|
+
const [notification, setNotification] = (0, _react.useState)(null);
|
|
30
|
+
const clear = () => notification !== null && setNotification(null);
|
|
31
|
+
const setDeduplicated = value => {
|
|
54
32
|
if (!(0, _isEqual.default)(value, notification)) {
|
|
55
33
|
setNotification(value);
|
|
56
34
|
}
|
|
57
35
|
return value;
|
|
58
36
|
};
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
window.history.replaceState({}, "");
|
|
63
|
-
} else {
|
|
64
|
-
clear();
|
|
65
|
-
}
|
|
66
|
-
}, [state, pathname]);
|
|
67
|
-
var helper = {
|
|
68
|
-
notification: notification,
|
|
69
|
-
clear: clear,
|
|
37
|
+
const helper = {
|
|
38
|
+
notification,
|
|
39
|
+
clear,
|
|
70
40
|
queue: _messageBuilder.queue,
|
|
71
|
-
failure:
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
return setDeduplicated((0, _messageBuilder.info)(message, title));
|
|
76
|
-
},
|
|
77
|
-
success: function success(message) {
|
|
78
|
-
return setDeduplicated((0, _messageBuilder.success)(message));
|
|
79
|
-
}
|
|
41
|
+
failure: (title, error, message, actions) => setDeduplicated((0, _messageBuilder.failure)(title, error, message, actions)),
|
|
42
|
+
info: (message, title) => setDeduplicated((0, _messageBuilder.info)(message, title)),
|
|
43
|
+
success: message => setDeduplicated((0, _messageBuilder.success)(message)),
|
|
44
|
+
setDeduplicated
|
|
80
45
|
};
|
|
81
46
|
return /*#__PURE__*/_react.default.createElement(NotifyContext.Provider, {
|
|
82
47
|
value: helper
|
|
@@ -84,12 +49,25 @@ var NotificationProvider = function NotificationProvider(_ref) {
|
|
|
84
49
|
};
|
|
85
50
|
exports.NotificationProvider = NotificationProvider;
|
|
86
51
|
function useNotify() {
|
|
87
|
-
|
|
52
|
+
const ctx = (0, _react.useContext)(NotifyContext);
|
|
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;
|
|
88
66
|
}
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
(0, _react.useEffect)(
|
|
67
|
+
const NotificationConsumer = () => {
|
|
68
|
+
const notify = useNotify();
|
|
69
|
+
const ref = (0, _react.useRef)(null);
|
|
70
|
+
(0, _react.useEffect)(() => {
|
|
93
71
|
var _ref$current;
|
|
94
72
|
if ((_ref$current = ref.current) !== null && _ref$current !== void 0 && _ref$current.hasAttribute("scrollIntoView")) {
|
|
95
73
|
ref.current.scrollIntoView({
|
|
@@ -102,11 +80,12 @@ var NotificationConsumer = function NotificationConsumer() {
|
|
|
102
80
|
if (!notify.notification) {
|
|
103
81
|
return null;
|
|
104
82
|
}
|
|
105
|
-
|
|
106
|
-
actions
|
|
107
|
-
title
|
|
108
|
-
type
|
|
109
|
-
message
|
|
83
|
+
const {
|
|
84
|
+
actions,
|
|
85
|
+
title,
|
|
86
|
+
type,
|
|
87
|
+
message
|
|
88
|
+
} = notify.notification;
|
|
110
89
|
return /*#__PURE__*/_react.default.createElement("div", {
|
|
111
90
|
ref: ref
|
|
112
91
|
}, /*#__PURE__*/_react.default.createElement(_Notification.default, {
|
|
@@ -5,43 +5,43 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
Object.defineProperty(exports, "NotificationConsumer", {
|
|
7
7
|
enumerable: true,
|
|
8
|
-
get: function
|
|
8
|
+
get: function () {
|
|
9
9
|
return _NotificationProvider.NotificationConsumer;
|
|
10
10
|
}
|
|
11
11
|
});
|
|
12
12
|
Object.defineProperty(exports, "NotificationProvider", {
|
|
13
13
|
enumerable: true,
|
|
14
|
-
get: function
|
|
14
|
+
get: function () {
|
|
15
15
|
return _NotificationProvider.NotificationProvider;
|
|
16
16
|
}
|
|
17
17
|
});
|
|
18
18
|
Object.defineProperty(exports, "failure", {
|
|
19
19
|
enumerable: true,
|
|
20
|
-
get: function
|
|
20
|
+
get: function () {
|
|
21
21
|
return _messageBuilder.failure;
|
|
22
22
|
}
|
|
23
23
|
});
|
|
24
24
|
Object.defineProperty(exports, "info", {
|
|
25
25
|
enumerable: true,
|
|
26
|
-
get: function
|
|
26
|
+
get: function () {
|
|
27
27
|
return _messageBuilder.info;
|
|
28
28
|
}
|
|
29
29
|
});
|
|
30
30
|
Object.defineProperty(exports, "queue", {
|
|
31
31
|
enumerable: true,
|
|
32
|
-
get: function
|
|
32
|
+
get: function () {
|
|
33
33
|
return _messageBuilder.queue;
|
|
34
34
|
}
|
|
35
35
|
});
|
|
36
36
|
Object.defineProperty(exports, "success", {
|
|
37
37
|
enumerable: true,
|
|
38
|
-
get: function
|
|
38
|
+
get: function () {
|
|
39
39
|
return _messageBuilder.success;
|
|
40
40
|
}
|
|
41
41
|
});
|
|
42
42
|
Object.defineProperty(exports, "useNotify", {
|
|
43
43
|
enumerable: true,
|
|
44
|
-
get: function
|
|
44
|
+
get: function () {
|
|
45
45
|
return _NotificationProvider.useNotify;
|
|
46
46
|
}
|
|
47
47
|
});
|
|
@@ -7,7 +7,7 @@ exports.success = exports.queue = exports.info = exports.failure = void 0;
|
|
|
7
7
|
var _react = _interopRequireDefault(require("react"));
|
|
8
8
|
var _Notification = require("../Notification");
|
|
9
9
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
10
|
-
|
|
10
|
+
const queue = notification => {
|
|
11
11
|
return {
|
|
12
12
|
state: {
|
|
13
13
|
queuedNotification: notification
|
|
@@ -15,26 +15,26 @@ var queue = function queue(notification) {
|
|
|
15
15
|
};
|
|
16
16
|
};
|
|
17
17
|
exports.queue = queue;
|
|
18
|
-
|
|
18
|
+
const info = (message, title) => {
|
|
19
19
|
return {
|
|
20
|
-
message
|
|
21
|
-
title
|
|
20
|
+
message,
|
|
21
|
+
title,
|
|
22
22
|
type: _Notification.NotificationSeverity.INFORMATION
|
|
23
23
|
};
|
|
24
24
|
};
|
|
25
25
|
exports.info = info;
|
|
26
|
-
|
|
26
|
+
const success = message => {
|
|
27
27
|
return {
|
|
28
|
-
message
|
|
28
|
+
message,
|
|
29
29
|
type: _Notification.NotificationSeverity.POSITIVE
|
|
30
30
|
};
|
|
31
31
|
};
|
|
32
32
|
exports.success = success;
|
|
33
|
-
|
|
33
|
+
const failure = (title, error, message, actions) => {
|
|
34
34
|
return {
|
|
35
|
-
actions
|
|
35
|
+
actions,
|
|
36
36
|
message: error && error instanceof Error ? /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, message, " ", error.message) : message,
|
|
37
|
-
title
|
|
37
|
+
title,
|
|
38
38
|
type: _Notification.NotificationSeverity.NEGATIVE
|
|
39
39
|
};
|
|
40
40
|
};
|
|
@@ -27,4 +27,5 @@ export interface NotificationHelper {
|
|
|
27
27
|
info: (message: ReactNode, title?: string) => NotificationType;
|
|
28
28
|
success: (message: ReactNode) => NotificationType;
|
|
29
29
|
queue: (notification: NotificationType) => QueuedNotification;
|
|
30
|
+
setDeduplicated: (value: NotificationType) => NotificationType;
|
|
30
31
|
}
|
|
@@ -8,22 +8,17 @@ var _classnames = _interopRequireDefault(require("classnames"));
|
|
|
8
8
|
var _react = _interopRequireDefault(require("react"));
|
|
9
9
|
var _PaginationButton = _interopRequireDefault(require("./PaginationButton"));
|
|
10
10
|
var _PaginationItem = _interopRequireDefault(require("./PaginationItem"));
|
|
11
|
-
var _excluded = ["itemsPerPage", "totalItems", "paginate", "currentPage", "scrollToTop", "truncateThreshold", "centered", "showLabels", "hideNumbers", "onForward", "onBack", "forwardDisabled", "backDisabled", "forwardLabel", "backLabel"];
|
|
12
11
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
13
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); }
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
var generatePaginationItems = function generatePaginationItems(pageNumbers, currentPage, truncateThreshold, changePage) {
|
|
20
|
-
var lastPage = pageNumbers.length;
|
|
21
|
-
var truncated = lastPage > truncateThreshold;
|
|
22
|
-
var visiblePages;
|
|
13
|
+
const scrollTop = () => window.scrollTo(0, 0);
|
|
14
|
+
const generatePaginationItems = (pageNumbers, currentPage, truncateThreshold, changePage) => {
|
|
15
|
+
const lastPage = pageNumbers.length;
|
|
16
|
+
const truncated = lastPage > truncateThreshold;
|
|
17
|
+
let visiblePages;
|
|
23
18
|
if (truncated) {
|
|
24
19
|
// the default range for pages outside the start and end threshold
|
|
25
|
-
|
|
26
|
-
|
|
20
|
+
let start = currentPage - 2;
|
|
21
|
+
let end = currentPage + 1;
|
|
27
22
|
// on page 1, also show pages 2, 3 and 4
|
|
28
23
|
if (currentPage === 1) {
|
|
29
24
|
start = 1;
|
|
@@ -43,16 +38,14 @@ var generatePaginationItems = function generatePaginationItems(pageNumbers, curr
|
|
|
43
38
|
} else {
|
|
44
39
|
visiblePages = pageNumbers;
|
|
45
40
|
}
|
|
46
|
-
|
|
41
|
+
const items = [];
|
|
47
42
|
if (truncated) {
|
|
48
43
|
// render first in sequence
|
|
49
44
|
items.push( /*#__PURE__*/_react.default.createElement(_PaginationItem.default, {
|
|
50
45
|
key: 1,
|
|
51
46
|
number: 1,
|
|
52
47
|
isActive: currentPage === 1,
|
|
53
|
-
onClick:
|
|
54
|
-
return changePage(1);
|
|
55
|
-
}
|
|
48
|
+
onClick: () => changePage(1)
|
|
56
49
|
}));
|
|
57
50
|
if (!visiblePages.includes(2)) {
|
|
58
51
|
items.push( /*#__PURE__*/_react.default.createElement(PaginationItemSeparator, {
|
|
@@ -60,16 +53,12 @@ var generatePaginationItems = function generatePaginationItems(pageNumbers, curr
|
|
|
60
53
|
}));
|
|
61
54
|
}
|
|
62
55
|
}
|
|
63
|
-
items.push(visiblePages.map(
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
return changePage(number);
|
|
70
|
-
}
|
|
71
|
-
});
|
|
72
|
-
}));
|
|
56
|
+
items.push(visiblePages.map(number => /*#__PURE__*/_react.default.createElement(_PaginationItem.default, {
|
|
57
|
+
key: number,
|
|
58
|
+
number: number,
|
|
59
|
+
isActive: number === currentPage,
|
|
60
|
+
onClick: () => changePage(number)
|
|
61
|
+
})));
|
|
73
62
|
if (truncated) {
|
|
74
63
|
// render last in sequence
|
|
75
64
|
if (!visiblePages.includes(lastPage - 1)) {
|
|
@@ -81,18 +70,14 @@ var generatePaginationItems = function generatePaginationItems(pageNumbers, curr
|
|
|
81
70
|
key: lastPage,
|
|
82
71
|
number: lastPage,
|
|
83
72
|
isActive: currentPage === lastPage,
|
|
84
|
-
onClick:
|
|
85
|
-
return changePage(lastPage);
|
|
86
|
-
}
|
|
73
|
+
onClick: () => changePage(lastPage)
|
|
87
74
|
}));
|
|
88
75
|
}
|
|
89
76
|
return items;
|
|
90
77
|
};
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
}, "\u2026");
|
|
95
|
-
};
|
|
78
|
+
const PaginationItemSeparator = () => /*#__PURE__*/_react.default.createElement("li", {
|
|
79
|
+
className: "p-pagination__item p-pagination__item--truncation"
|
|
80
|
+
}, "\u2026");
|
|
96
81
|
|
|
97
82
|
// Props that are used in both types of paginations.
|
|
98
83
|
|
|
@@ -103,51 +88,52 @@ var PaginationItemSeparator = function PaginationItemSeparator() {
|
|
|
103
88
|
// Used when number of items per page, number of total items,
|
|
104
89
|
// current page and paginate function are undefined.
|
|
105
90
|
// Pagination is handled by onForward and onBack function.
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
truncateThreshold =
|
|
114
|
-
centered
|
|
115
|
-
showLabels
|
|
116
|
-
hideNumbers
|
|
117
|
-
onForward
|
|
118
|
-
onBack
|
|
119
|
-
forwardDisabled
|
|
120
|
-
backDisabled
|
|
121
|
-
forwardLabel
|
|
122
|
-
backLabel
|
|
123
|
-
navProps
|
|
124
|
-
|
|
125
|
-
|
|
91
|
+
const Pagination = _ref => {
|
|
92
|
+
let {
|
|
93
|
+
itemsPerPage,
|
|
94
|
+
totalItems,
|
|
95
|
+
paginate,
|
|
96
|
+
currentPage,
|
|
97
|
+
scrollToTop,
|
|
98
|
+
truncateThreshold = 10,
|
|
99
|
+
centered,
|
|
100
|
+
showLabels,
|
|
101
|
+
hideNumbers,
|
|
102
|
+
onForward,
|
|
103
|
+
onBack,
|
|
104
|
+
forwardDisabled,
|
|
105
|
+
backDisabled,
|
|
106
|
+
forwardLabel,
|
|
107
|
+
backLabel,
|
|
108
|
+
...navProps
|
|
109
|
+
} = _ref;
|
|
110
|
+
const isNumberedPagination = !!itemsPerPage && !!totalItems && !!currentPage && !!paginate;
|
|
111
|
+
const pageNumbers = [];
|
|
126
112
|
if (isNumberedPagination) {
|
|
127
113
|
// return early if no pagination is required
|
|
128
114
|
if (totalItems <= itemsPerPage) {
|
|
129
115
|
return null;
|
|
130
116
|
}
|
|
131
|
-
for (
|
|
117
|
+
for (let i = 1; i <= Math.ceil(totalItems / itemsPerPage); i++) {
|
|
132
118
|
pageNumbers.push(i);
|
|
133
119
|
}
|
|
134
120
|
}
|
|
135
|
-
|
|
121
|
+
const changeNumberedPage = page => {
|
|
136
122
|
paginate(page);
|
|
137
123
|
if (page > currentPage) {
|
|
138
|
-
onForward === null || onForward === void 0
|
|
124
|
+
onForward === null || onForward === void 0 || onForward(page);
|
|
139
125
|
}
|
|
140
126
|
if (page < currentPage) {
|
|
141
|
-
onBack === null || onBack === void 0
|
|
127
|
+
onBack === null || onBack === void 0 || onBack(page);
|
|
142
128
|
}
|
|
143
129
|
scrollToTop && scrollTop();
|
|
144
130
|
};
|
|
145
|
-
|
|
131
|
+
const changeButtonsOnlyPage = direction => {
|
|
146
132
|
if (direction === "forward") {
|
|
147
|
-
onForward === null || onForward === void 0
|
|
133
|
+
onForward === null || onForward === void 0 || onForward(undefined);
|
|
148
134
|
}
|
|
149
135
|
if (direction === "back") {
|
|
150
|
-
onBack === null || onBack === void 0
|
|
136
|
+
onBack === null || onBack === void 0 || onBack(undefined);
|
|
151
137
|
}
|
|
152
138
|
scrollToTop && scrollTop();
|
|
153
139
|
};
|
|
@@ -162,21 +148,16 @@ var Pagination = function Pagination(_ref) {
|
|
|
162
148
|
key: "back",
|
|
163
149
|
direction: "back",
|
|
164
150
|
disabled: backDisabled || currentPage === 1,
|
|
165
|
-
onClick:
|
|
166
|
-
return isNumberedPagination ? changeNumberedPage(currentPage - 1) : changeButtonsOnlyPage("back");
|
|
167
|
-
},
|
|
151
|
+
onClick: () => isNumberedPagination ? changeNumberedPage(currentPage - 1) : changeButtonsOnlyPage("back"),
|
|
168
152
|
showLabel: showLabels,
|
|
169
153
|
label: backLabel
|
|
170
154
|
}), isNumberedPagination && !hideNumbers ? generatePaginationItems(pageNumbers, currentPage, truncateThreshold, changeNumberedPage) : null, /*#__PURE__*/_react.default.createElement(_PaginationButton.default, {
|
|
171
155
|
key: "forward",
|
|
172
156
|
direction: "forward",
|
|
173
157
|
disabled: forwardDisabled || currentPage === pageNumbers.length,
|
|
174
|
-
onClick:
|
|
175
|
-
return isNumberedPagination ? changeNumberedPage(currentPage + 1) : changeButtonsOnlyPage("forward");
|
|
176
|
-
},
|
|
158
|
+
onClick: () => isNumberedPagination ? changeNumberedPage(currentPage + 1) : changeButtonsOnlyPage("forward"),
|
|
177
159
|
showLabel: showLabels,
|
|
178
160
|
label: forwardLabel
|
|
179
161
|
})));
|
|
180
162
|
};
|
|
181
|
-
var _default = Pagination;
|
|
182
|
-
exports.default = _default;
|
|
163
|
+
var _default = exports.default = Pagination;
|