@canonical/react-components 0.41.0 → 0.43.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/__mocks__/nanoid.js +0 -2
- package/dist/components/Accordion/Accordion.js +13 -37
- package/dist/components/Accordion/AccordionSection/AccordionSection.js +8 -14
- package/dist/components/Accordion/AccordionSection/index.js +0 -2
- package/dist/components/Accordion/index.js +0 -2
- package/dist/components/ActionButton/ActionButton.js +36 -65
- package/dist/components/ActionButton/index.js +0 -2
- package/dist/components/ArticlePagination/ArticlePagination.js +5 -15
- package/dist/components/ArticlePagination/index.js +0 -2
- package/dist/components/Badge/Badge.js +10 -28
- package/dist/components/Badge/index.js +0 -2
- package/dist/components/Button/Button.js +12 -25
- package/dist/components/Button/index.js +0 -4
- package/dist/components/Card/Card.js +7 -18
- package/dist/components/Card/index.js +0 -2
- package/dist/components/CheckboxInput/CheckableInput/CheckableInput.js +6 -20
- package/dist/components/CheckboxInput/CheckableInput/index.js +0 -2
- package/dist/components/CheckboxInput/CheckboxInput.js +3 -13
- package/dist/components/CheckboxInput/index.js +0 -2
- package/dist/components/Chip/Chip.js +14 -30
- package/dist/components/Chip/index.js +0 -2
- package/dist/components/Code/Code.js +5 -23
- package/dist/components/Code/index.js +0 -2
- package/dist/components/CodeSnippet/CodeSnippet.js +2 -12
- package/dist/components/CodeSnippet/CodeSnippetBlock.js +10 -18
- package/dist/components/CodeSnippet/CodeSnippetDropdown.js +5 -14
- package/dist/components/CodeSnippet/index.js +0 -3
- package/dist/components/Col/Col.js +15 -25
- package/dist/components/Col/index.js +0 -4
- 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/ContextualMenu.js +66 -101
- package/dist/components/ContextualMenu/ContextualMenuDropdown/ContextualMenuDropdown.d.ts +2 -1
- package/dist/components/ContextualMenu/ContextualMenuDropdown/ContextualMenuDropdown.js +48 -85
- package/dist/components/ContextualMenu/ContextualMenuDropdown/index.js +0 -2
- package/dist/components/ContextualMenu/index.js +0 -2
- 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/Field/Field.js +35 -51
- package/dist/components/Field/index.js +0 -2
- package/dist/components/Form/Form.js +4 -14
- package/dist/components/Form/index.js +0 -2
- package/dist/components/Icon/Icon.js +3 -14
- package/dist/components/Icon/Icon.stories.scss +1 -0
- package/dist/components/Icon/index.js +0 -4
- package/dist/components/Input/Input.js +21 -39
- package/dist/components/Input/index.js +0 -2
- package/dist/components/Label/Label.js +7 -13
- package/dist/components/Label/index.js +0 -2
- package/dist/components/Link/Link.js +10 -22
- package/dist/components/Link/index.js +0 -2
- package/dist/components/List/List.d.ts +5 -5
- package/dist/components/List/List.js +17 -32
- package/dist/components/List/index.js +0 -2
- package/dist/components/Loader/Loader.js +0 -7
- package/dist/components/Loader/index.js +0 -2
- package/dist/components/MainTable/MainTable.js +59 -111
- package/dist/components/MainTable/index.js +0 -2
- package/dist/components/Modal/Modal.js +7 -34
- package/dist/components/Modal/index.js +0 -2
- package/dist/components/ModularTable/ModularTable.d.ts +9 -1
- package/dist/components/ModularTable/ModularTable.js +39 -46
- package/dist/components/ModularTable/index.js +0 -2
- package/dist/components/Navigation/Navigation.js +46 -82
- package/dist/components/Navigation/NavigationLink/NavigationLink.js +15 -30
- package/dist/components/Navigation/NavigationLink/index.js +0 -2
- package/dist/components/Navigation/NavigationMenu/NavigationMenu.js +12 -35
- package/dist/components/Navigation/NavigationMenu/index.js +0 -2
- package/dist/components/Navigation/index.js +0 -2
- package/dist/components/Notification/Notification.d.ts +6 -0
- package/dist/components/Notification/Notification.js +29 -42
- package/dist/components/Notification/index.js +0 -4
- 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/Pagination/Pagination.js +14 -44
- package/dist/components/Pagination/PaginationButton/PaginationButton.js +3 -10
- package/dist/components/Pagination/PaginationButton/index.js +0 -2
- package/dist/components/Pagination/PaginationItem/PaginationItem.js +3 -8
- package/dist/components/Pagination/PaginationItem/index.js +0 -2
- package/dist/components/Pagination/index.js +0 -2
- package/dist/components/PasswordToggle/PasswordToggle.js +16 -45
- package/dist/components/PasswordToggle/index.js +0 -2
- package/dist/components/RadioInput/RadioInput.js +1 -11
- package/dist/components/RadioInput/index.js +0 -2
- package/dist/components/Row/Row.js +2 -12
- package/dist/components/Row/index.js +0 -2
- package/dist/components/SearchAndFilter/FilterPanelSection/FilterPanelSection.js +27 -49
- package/dist/components/SearchAndFilter/FilterPanelSection/index.js +0 -2
- package/dist/components/SearchAndFilter/SearchAndFilter.d.ts +9 -1
- package/dist/components/SearchAndFilter/SearchAndFilter.js +68 -104
- package/dist/components/SearchAndFilter/index.js +0 -2
- package/dist/components/SearchAndFilter/utils.js +1 -7
- package/dist/components/SearchBox/SearchBox.js +14 -34
- package/dist/components/SearchBox/index.js +0 -2
- package/dist/components/Select/Select.js +20 -33
- package/dist/components/Select/index.js +0 -2
- package/dist/components/Slider/Slider.js +16 -32
- package/dist/components/Slider/index.js +0 -2
- package/dist/components/Spinner/Spinner.js +8 -19
- package/dist/components/Spinner/index.js +0 -2
- package/dist/components/StatusLabel/StatusLabel.js +4 -15
- package/dist/components/StatusLabel/index.js +0 -4
- package/dist/components/Strip/Strip.js +25 -36
- package/dist/components/Strip/index.js +0 -2
- package/dist/components/SummaryButton/SummaryButton.js +4 -10
- package/dist/components/SummaryButton/index.js +0 -2
- package/dist/components/Switch/Switch.js +3 -12
- package/dist/components/Switch/index.js +0 -2
- package/dist/components/Table/Table.js +6 -16
- package/dist/components/Table/index.js +0 -2
- package/dist/components/TableCell/TableCell.js +10 -20
- package/dist/components/TableCell/index.js +0 -2
- package/dist/components/TableHeader/TableHeader.js +2 -11
- package/dist/components/TableHeader/index.js +0 -2
- package/dist/components/TableRow/TableRow.js +1 -10
- package/dist/components/TableRow/index.js +0 -2
- package/dist/components/Tabs/Tabs.js +7 -17
- package/dist/components/Tabs/index.js +0 -2
- package/dist/components/Textarea/Textarea.js +23 -36
- package/dist/components/Textarea/index.js +0 -2
- package/dist/components/Tooltip/Tooltip.js +38 -88
- package/dist/components/Tooltip/index.js +0 -4
- package/dist/enums.js +0 -2
- package/dist/hooks/index.js +0 -8
- package/dist/hooks/useClickOutside.js +2 -7
- package/dist/hooks/useId.js +0 -4
- package/dist/hooks/useListener.js +0 -8
- package/dist/hooks/useOnEscapePressed.js +0 -3
- package/dist/hooks/usePagination.js +13 -25
- package/dist/hooks/usePrevious.js +0 -3
- package/dist/hooks/useThrottle.js +1 -15
- package/dist/hooks/useWindowFitment.js +6 -13
- package/dist/index.d.ts +8 -0
- package/dist/index.js +64 -52
- package/dist/utils.js +3 -10
- package/package.json +31 -28
|
@@ -1,89 +1,63 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
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
|
-
|
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
|
6
5
|
value: true
|
|
7
6
|
});
|
|
8
7
|
exports.default = void 0;
|
|
9
|
-
|
|
10
8
|
var _react = _interopRequireWildcard(require("react"));
|
|
11
|
-
|
|
12
9
|
var _classnames = _interopRequireDefault(require("classnames"));
|
|
13
|
-
|
|
14
10
|
var _NavigationLink = _interopRequireDefault(require("./NavigationLink"));
|
|
15
|
-
|
|
16
11
|
var _NavigationMenu = _interopRequireDefault(require("./NavigationMenu"));
|
|
17
|
-
|
|
18
12
|
var _SearchBox = _interopRequireDefault(require("../SearchBox"));
|
|
19
|
-
|
|
20
13
|
var _hooks = require("../../hooks");
|
|
21
|
-
|
|
22
14
|
var _enums = require("../../enums");
|
|
23
|
-
|
|
24
15
|
var _excluded = ["url", "src", "title", "icon", "aria-current", "aria-label"],
|
|
25
|
-
|
|
26
|
-
|
|
16
|
+
_excluded2 = ["fullWidth", "generateLink", "items", "itemsRight", "leftNavProps", "logo", "navProps", "rightNavProps", "searchProps", "theme"];
|
|
27
17
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
28
|
-
|
|
29
18
|
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); }
|
|
30
|
-
|
|
31
19
|
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; }
|
|
32
|
-
|
|
33
20
|
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
34
|
-
|
|
35
21
|
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."); }
|
|
36
|
-
|
|
37
22
|
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); }
|
|
38
|
-
|
|
39
|
-
function
|
|
40
|
-
|
|
41
|
-
function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
|
|
42
|
-
|
|
23
|
+
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; }
|
|
24
|
+
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; } }
|
|
43
25
|
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
44
|
-
|
|
45
26
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
46
|
-
|
|
47
27
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
48
|
-
|
|
49
|
-
function
|
|
50
|
-
|
|
28
|
+
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; }
|
|
29
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
30
|
+
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); }
|
|
51
31
|
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); }
|
|
52
|
-
|
|
53
32
|
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; }
|
|
54
|
-
|
|
55
33
|
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; }
|
|
56
|
-
|
|
57
34
|
/**
|
|
58
35
|
* Narrow the type of the nav item to a NavMenu.
|
|
59
36
|
*/
|
|
60
37
|
var isMenu = function isMenu(item) {
|
|
61
38
|
return "items" in item;
|
|
62
39
|
};
|
|
40
|
+
|
|
63
41
|
/**
|
|
64
42
|
* Narrow the type of the logo prop to LogoProps.
|
|
65
43
|
*/
|
|
66
|
-
|
|
67
|
-
|
|
68
44
|
var isLogoProps = function isLogoProps(logo) {
|
|
69
45
|
return ! /*#__PURE__*/(0, _react.isValidElement)(logo);
|
|
70
46
|
};
|
|
47
|
+
|
|
71
48
|
/**
|
|
72
49
|
* Display the standard logo if the props were provided otherwise display the
|
|
73
50
|
* full element provided.
|
|
74
51
|
*/
|
|
75
|
-
|
|
76
|
-
|
|
77
52
|
var generateLogo = function generateLogo(logo, generateLink) {
|
|
78
53
|
if (isLogoProps(logo)) {
|
|
79
54
|
var url = logo.url,
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
55
|
+
src = logo.src,
|
|
56
|
+
title = logo.title,
|
|
57
|
+
icon = logo.icon,
|
|
58
|
+
ariaCurrent = logo["aria-current"],
|
|
59
|
+
ariaLabel = logo["aria-label"],
|
|
60
|
+
logoProps = _objectWithoutProperties(logo, _excluded);
|
|
87
61
|
var content = /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement("div", {
|
|
88
62
|
className: "p-navigation__logo-tag"
|
|
89
63
|
}, icon !== null && icon !== void 0 ? icon : /*#__PURE__*/_react.default.createElement("img", {
|
|
@@ -93,7 +67,6 @@ var generateLogo = function generateLogo(logo, generateLink) {
|
|
|
93
67
|
})), /*#__PURE__*/_react.default.createElement("span", {
|
|
94
68
|
className: "p-navigation__logo-title"
|
|
95
69
|
}, title));
|
|
96
|
-
|
|
97
70
|
return /*#__PURE__*/_react.default.createElement("div", _extends({
|
|
98
71
|
className: "p-navigation__tagged-logo"
|
|
99
72
|
}, logoProps), /*#__PURE__*/_react.default.createElement(_NavigationLink.default, {
|
|
@@ -107,11 +80,11 @@ var generateLogo = function generateLogo(logo, generateLink) {
|
|
|
107
80
|
}
|
|
108
81
|
}));
|
|
109
82
|
}
|
|
110
|
-
|
|
111
83
|
return /*#__PURE__*/_react.default.createElement("div", {
|
|
112
84
|
className: "p-navigation__logo"
|
|
113
85
|
}, logo);
|
|
114
86
|
};
|
|
87
|
+
|
|
115
88
|
/**
|
|
116
89
|
* Generate the JSX for a set of nav items. This will map the items to menus,
|
|
117
90
|
* links or generated components.
|
|
@@ -120,8 +93,6 @@ var generateLogo = function generateLogo(logo, generateLink) {
|
|
|
120
93
|
* @param generateLink The optional function used to generate link components.
|
|
121
94
|
* @returns A list of navigation item elements.
|
|
122
95
|
*/
|
|
123
|
-
|
|
124
|
-
|
|
125
96
|
var generateItems = function generateItems(items, closeMobileMenu, generateLink) {
|
|
126
97
|
return items.map(function (item, i) {
|
|
127
98
|
return isMenu(item) ? /*#__PURE__*/_react.default.createElement(_NavigationMenu.default, _extends({}, item, {
|
|
@@ -138,7 +109,6 @@ var generateItems = function generateItems(items, closeMobileMenu, generateLink)
|
|
|
138
109
|
className: (0, _classnames.default)("p-navigation__link", item.className),
|
|
139
110
|
onClick: function onClick(evt) {
|
|
140
111
|
var _item$onClick;
|
|
141
|
-
|
|
142
112
|
(_item$onClick = item.onClick) === null || _item$onClick === void 0 ? void 0 : _item$onClick.call(item, evt);
|
|
143
113
|
closeMobileMenu();
|
|
144
114
|
}
|
|
@@ -146,60 +116,51 @@ var generateItems = function generateItems(items, closeMobileMenu, generateLink)
|
|
|
146
116
|
}));
|
|
147
117
|
});
|
|
148
118
|
};
|
|
149
|
-
|
|
150
119
|
var Navigation = function Navigation(_ref) {
|
|
151
120
|
var fullWidth = _ref.fullWidth,
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
121
|
+
generateLink = _ref.generateLink,
|
|
122
|
+
items = _ref.items,
|
|
123
|
+
itemsRight = _ref.itemsRight,
|
|
124
|
+
leftNavProps = _ref.leftNavProps,
|
|
125
|
+
logo = _ref.logo,
|
|
126
|
+
navProps = _ref.navProps,
|
|
127
|
+
rightNavProps = _ref.rightNavProps,
|
|
128
|
+
searchProps = _ref.searchProps,
|
|
129
|
+
theme = _ref.theme,
|
|
130
|
+
headerProps = _objectWithoutProperties(_ref, _excluded2);
|
|
163
131
|
var searchRef = (0, _react.useRef)();
|
|
164
|
-
|
|
165
132
|
var _useState = (0, _react.useState)(false),
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
133
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
134
|
+
mobileMenuOpen = _useState2[0],
|
|
135
|
+
setMobileMenuOpen = _useState2[1];
|
|
170
136
|
var _useState3 = (0, _react.useState)(false),
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
137
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
138
|
+
searchOpen = _useState4[0],
|
|
139
|
+
setSearchOpen = _useState4[1];
|
|
140
|
+
// Display the search box if the props have been provided.
|
|
141
|
+
var hasSearch = !!searchProps;
|
|
142
|
+
// Close the mobile menu when the search box is opened.
|
|
178
143
|
var toggleSearch = function toggleSearch(open) {
|
|
179
144
|
setSearchOpen(open !== null && open !== void 0 ? open : !searchOpen);
|
|
180
145
|
setMobileMenuOpen(false);
|
|
181
|
-
};
|
|
182
|
-
|
|
183
|
-
|
|
146
|
+
};
|
|
147
|
+
// Close the search box when the mobile menu is opened.
|
|
184
148
|
var toggleMobileMenu = function toggleMobileMenu() {
|
|
185
149
|
setMobileMenuOpen(!mobileMenuOpen);
|
|
186
150
|
setSearchOpen(false);
|
|
187
151
|
};
|
|
188
|
-
|
|
189
152
|
var closeMobileMenu = function closeMobileMenu() {
|
|
190
153
|
if (mobileMenuOpen) {
|
|
191
154
|
setMobileMenuOpen(false);
|
|
192
155
|
}
|
|
193
|
-
};
|
|
194
|
-
|
|
195
|
-
|
|
156
|
+
};
|
|
157
|
+
// Hide the searchbox when the escape key is pressed.
|
|
196
158
|
(0, _hooks.useOnEscapePressed)(function () {
|
|
197
159
|
return toggleSearch(false);
|
|
198
160
|
});
|
|
199
161
|
(0, _react.useEffect)(function () {
|
|
200
162
|
if (searchOpen) {
|
|
201
163
|
var _searchRef$current;
|
|
202
|
-
|
|
203
164
|
// Focus on the searchbox when it appears. This done in a useEffect so
|
|
204
165
|
// that the state change to display the searchbox has already occured and
|
|
205
166
|
// the input has been made visible.
|
|
@@ -219,7 +180,8 @@ var Navigation = function Navigation(_ref) {
|
|
|
219
180
|
className: "p-navigation__banner"
|
|
220
181
|
}, generateLogo(logo, generateLink), /*#__PURE__*/_react.default.createElement("ul", {
|
|
221
182
|
className: "p-navigation__items"
|
|
222
|
-
},
|
|
183
|
+
},
|
|
184
|
+
// When the header has a search box then this button is used to
|
|
223
185
|
// toggle the search box at mobile size.
|
|
224
186
|
hasSearch ? /*#__PURE__*/_react.default.createElement("li", {
|
|
225
187
|
className: "p-navigation__item"
|
|
@@ -243,7 +205,8 @@ var Navigation = function Navigation(_ref) {
|
|
|
243
205
|
className: "p-navigation__items"
|
|
244
206
|
}, leftNavProps), items ? generateItems(items, closeMobileMenu, generateLink) : null), itemsRight || hasSearch ? /*#__PURE__*/_react.default.createElement("ul", _extends({
|
|
245
207
|
className: "p-navigation__items"
|
|
246
|
-
}, rightNavProps), itemsRight ? generateItems(itemsRight, closeMobileMenu, generateLink) : null,
|
|
208
|
+
}, rightNavProps), itemsRight ? generateItems(itemsRight, closeMobileMenu, generateLink) : null,
|
|
209
|
+
// When the header has a search box then this button is used to
|
|
247
210
|
// toggle the search box at non-mobile size.
|
|
248
211
|
hasSearch ? /*#__PURE__*/_react.default.createElement("li", {
|
|
249
212
|
className: "p-navigation__item"
|
|
@@ -255,14 +218,16 @@ var Navigation = function Navigation(_ref) {
|
|
|
255
218
|
}
|
|
256
219
|
}, /*#__PURE__*/_react.default.createElement("span", {
|
|
257
220
|
className: "p-navigation__search-label"
|
|
258
|
-
}, "Search"))) : null) : null,
|
|
221
|
+
}, "Search"))) : null) : null,
|
|
222
|
+
// When the header has a search box and the user has opened the search
|
|
259
223
|
// form then this search box is displayed.
|
|
260
224
|
hasSearch ? /*#__PURE__*/_react.default.createElement("div", {
|
|
261
225
|
className: "p-navigation__search",
|
|
262
226
|
"aria-hidden": !searchOpen
|
|
263
227
|
}, /*#__PURE__*/_react.default.createElement(_SearchBox.default, {
|
|
264
228
|
ref: searchRef
|
|
265
|
-
})) : null)),
|
|
229
|
+
})) : null)),
|
|
230
|
+
// When the header has a search box and the user has opened the search
|
|
266
231
|
// form then this element is overlayed over the whole page.
|
|
267
232
|
hasSearch ? /*#__PURE__*/_react.default.createElement("div", {
|
|
268
233
|
className: "p-navigation__search-overlay",
|
|
@@ -271,6 +236,5 @@ var Navigation = function Navigation(_ref) {
|
|
|
271
236
|
}
|
|
272
237
|
}) : null);
|
|
273
238
|
};
|
|
274
|
-
|
|
275
239
|
var _default = Navigation;
|
|
276
240
|
exports.default = _default;
|
|
@@ -1,74 +1,59 @@
|
|
|
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); }
|
|
3
4
|
Object.defineProperty(exports, "__esModule", {
|
|
4
5
|
value: true
|
|
5
6
|
});
|
|
6
7
|
exports.default = void 0;
|
|
7
|
-
|
|
8
8
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
9
|
-
|
|
10
9
|
var _react = _interopRequireDefault(require("react"));
|
|
11
|
-
|
|
12
10
|
var _utils = require("../../../utils");
|
|
13
|
-
|
|
14
11
|
var _excluded = ["isSelected"],
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
12
|
+
_excluded2 = ["isSelected", "label", "url"],
|
|
13
|
+
_excluded3 = ["isSelected", "label", "url"];
|
|
18
14
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
19
|
-
|
|
20
15
|
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); }
|
|
21
|
-
|
|
22
16
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
23
|
-
|
|
24
17
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
25
|
-
|
|
26
|
-
function
|
|
27
|
-
|
|
18
|
+
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; }
|
|
19
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
20
|
+
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); }
|
|
28
21
|
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; }
|
|
29
|
-
|
|
30
22
|
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; }
|
|
31
|
-
|
|
32
23
|
/**
|
|
33
24
|
* This component is used internally to display links inside the Navigation component.
|
|
34
25
|
*/
|
|
35
26
|
var NavigationLink = function NavigationLink(_ref) {
|
|
36
27
|
var generateLink = _ref.generateLink,
|
|
37
|
-
|
|
38
|
-
|
|
28
|
+
link = _ref.link;
|
|
39
29
|
// const ariaCurrent = isSelected ? "page" : undefined;
|
|
40
30
|
if (generateLink) {
|
|
41
31
|
var isSelected = link.isSelected,
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
32
|
+
linkProps = _objectWithoutProperties(link, _excluded);
|
|
33
|
+
// If a function has been provided then use it to generate the link element.
|
|
45
34
|
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, generateLink(_objectSpread({
|
|
46
35
|
isSelected: isSelected,
|
|
47
36
|
"aria-current": isSelected ? "page" : undefined
|
|
48
37
|
}, linkProps)));
|
|
49
38
|
} else if ((0, _utils.isNavigationAnchor)(link)) {
|
|
50
39
|
var _isSelected = link.isSelected,
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
40
|
+
label = link.label,
|
|
41
|
+
url = link.url,
|
|
42
|
+
_linkProps = _objectWithoutProperties(link, _excluded2);
|
|
55
43
|
return /*#__PURE__*/_react.default.createElement("a", _extends({}, _linkProps, {
|
|
56
44
|
href: url,
|
|
57
45
|
"aria-current": _isSelected ? "page" : undefined
|
|
58
46
|
}), label);
|
|
59
47
|
} else if ((0, _utils.isNavigationButton)(link)) {
|
|
60
48
|
var _isSelected2 = link.isSelected,
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
49
|
+
_label = link.label,
|
|
50
|
+
_url = link.url,
|
|
51
|
+
_linkProps2 = _objectWithoutProperties(link, _excluded3);
|
|
65
52
|
return /*#__PURE__*/_react.default.createElement("button", _extends({}, _linkProps2, {
|
|
66
53
|
"aria-current": _isSelected2 ? "page" : undefined
|
|
67
54
|
}), _label);
|
|
68
55
|
}
|
|
69
|
-
|
|
70
56
|
return null;
|
|
71
57
|
};
|
|
72
|
-
|
|
73
58
|
var _default = NavigationLink;
|
|
74
59
|
exports.default = _default;
|
|
@@ -9,7 +9,5 @@ Object.defineProperty(exports, "default", {
|
|
|
9
9
|
return _NavigationLink.default;
|
|
10
10
|
}
|
|
11
11
|
});
|
|
12
|
-
|
|
13
12
|
var _NavigationLink = _interopRequireDefault(require("./NavigationLink"));
|
|
14
|
-
|
|
15
13
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
@@ -1,67 +1,45 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
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
|
-
|
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
|
6
5
|
value: true
|
|
7
6
|
});
|
|
8
7
|
exports.default = void 0;
|
|
9
|
-
|
|
10
8
|
var _react = _interopRequireWildcard(require("react"));
|
|
11
|
-
|
|
12
9
|
var _classnames = _interopRequireDefault(require("classnames"));
|
|
13
|
-
|
|
14
10
|
var _NavigationLink = _interopRequireDefault(require("../NavigationLink"));
|
|
15
|
-
|
|
16
11
|
var _hooks = require("../../../hooks");
|
|
17
|
-
|
|
18
12
|
var _excluded = ["alignRight", "generateLink", "items", "label"];
|
|
19
|
-
|
|
20
13
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
21
|
-
|
|
22
14
|
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); }
|
|
23
|
-
|
|
24
15
|
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; }
|
|
25
|
-
|
|
26
16
|
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); }
|
|
27
|
-
|
|
28
17
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
29
|
-
|
|
30
18
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
31
|
-
|
|
32
|
-
function
|
|
33
|
-
|
|
19
|
+
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; }
|
|
20
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
21
|
+
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); }
|
|
34
22
|
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
35
|
-
|
|
36
23
|
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."); }
|
|
37
|
-
|
|
38
24
|
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); }
|
|
39
|
-
|
|
40
|
-
function
|
|
41
|
-
|
|
42
|
-
function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
|
|
43
|
-
|
|
25
|
+
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; }
|
|
26
|
+
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; } }
|
|
44
27
|
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
45
|
-
|
|
46
28
|
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; }
|
|
47
|
-
|
|
48
29
|
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; }
|
|
49
|
-
|
|
50
30
|
/**
|
|
51
31
|
* This component is used internally to display menus inside the Navigation component.
|
|
52
32
|
*/
|
|
53
33
|
var NavigationMenu = function NavigationMenu(_ref) {
|
|
54
34
|
var alignRight = _ref.alignRight,
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
35
|
+
generateLink = _ref.generateLink,
|
|
36
|
+
items = _ref.items,
|
|
37
|
+
label = _ref.label,
|
|
38
|
+
props = _objectWithoutProperties(_ref, _excluded);
|
|
60
39
|
var _useState = (0, _react.useState)(false),
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
40
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
41
|
+
isOpen = _useState2[0],
|
|
42
|
+
setIsOpen = _useState2[1];
|
|
65
43
|
var closeMenu = (0, _react.useCallback)(function () {
|
|
66
44
|
return setIsOpen(false);
|
|
67
45
|
}, [setIsOpen]);
|
|
@@ -96,6 +74,5 @@ var NavigationMenu = function NavigationMenu(_ref) {
|
|
|
96
74
|
}));
|
|
97
75
|
})));
|
|
98
76
|
};
|
|
99
|
-
|
|
100
77
|
var _default = NavigationMenu;
|
|
101
78
|
exports.default = _default;
|
|
@@ -9,7 +9,5 @@ Object.defineProperty(exports, "default", {
|
|
|
9
9
|
return _NavigationMenu.default;
|
|
10
10
|
}
|
|
11
11
|
});
|
|
12
|
-
|
|
13
12
|
var _NavigationMenu = _interopRequireDefault(require("./NavigationMenu"));
|
|
14
|
-
|
|
15
13
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
@@ -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,41 +1,29 @@
|
|
|
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
|
-
|
|
5
3
|
Object.defineProperty(exports, "__esModule", {
|
|
6
4
|
value: true
|
|
7
5
|
});
|
|
8
|
-
exports.default = exports.NotificationSeverity = exports.Label = void 0;
|
|
9
|
-
|
|
6
|
+
exports.default = exports.NotificationSeverity = exports.Label = exports.DefaultTitles = void 0;
|
|
10
7
|
var _classnames = _interopRequireDefault(require("classnames"));
|
|
11
|
-
|
|
12
8
|
var _react = _interopRequireWildcard(require("react"));
|
|
13
|
-
|
|
14
9
|
var _Button = _interopRequireWildcard(require("../Button"));
|
|
15
|
-
|
|
16
10
|
var _utils = require("../../utils");
|
|
17
|
-
|
|
18
11
|
var _excluded = ["actions", "borderless", "children", "className", "close", "inline", "onDismiss", "severity", "status", "timeout", "timestamp", "title", "titleElement", "type"];
|
|
19
|
-
|
|
12
|
+
var _DefaultTitles;
|
|
20
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); }
|
|
21
|
-
|
|
22
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; }
|
|
23
|
-
|
|
24
15
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
25
|
-
|
|
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); }
|
|
26
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); }
|
|
27
|
-
|
|
28
|
-
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
29
|
-
|
|
30
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; }
|
|
31
|
-
|
|
32
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; }
|
|
33
|
-
|
|
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); }
|
|
34
23
|
var Label = /*#__PURE__*/function (Label) {
|
|
35
24
|
Label["Close"] = "Close notification";
|
|
36
25
|
return Label;
|
|
37
26
|
}({});
|
|
38
|
-
|
|
39
27
|
exports.Label = Label;
|
|
40
28
|
var NotificationSeverity = {
|
|
41
29
|
CAUTION: "caution",
|
|
@@ -44,30 +32,33 @@ var NotificationSeverity = {
|
|
|
44
32
|
POSITIVE: "positive"
|
|
45
33
|
};
|
|
46
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);
|
|
47
36
|
|
|
37
|
+
/**
|
|
38
|
+
* The props for the Notification component.
|
|
39
|
+
*/
|
|
40
|
+
exports.DefaultTitles = DefaultTitles;
|
|
48
41
|
var Notification = function Notification(_ref) {
|
|
49
42
|
var _classNames;
|
|
50
|
-
|
|
51
43
|
var actions = _ref.actions,
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
44
|
+
_ref$borderless = _ref.borderless,
|
|
45
|
+
borderless = _ref$borderless === void 0 ? false : _ref$borderless,
|
|
46
|
+
children = _ref.children,
|
|
47
|
+
className = _ref.className,
|
|
48
|
+
close = _ref.close,
|
|
49
|
+
_ref$inline = _ref.inline,
|
|
50
|
+
inline = _ref$inline === void 0 ? false : _ref$inline,
|
|
51
|
+
onDismiss = _ref.onDismiss,
|
|
52
|
+
_ref$severity = _ref.severity,
|
|
53
|
+
severity = _ref$severity === void 0 ? NotificationSeverity.INFORMATION : _ref$severity,
|
|
54
|
+
status = _ref.status,
|
|
55
|
+
timeout = _ref.timeout,
|
|
56
|
+
timestamp = _ref.timestamp,
|
|
57
|
+
title = _ref.title,
|
|
58
|
+
_ref$titleElement = _ref.titleElement,
|
|
59
|
+
TitleComponent = _ref$titleElement === void 0 ? "h5" : _ref$titleElement,
|
|
60
|
+
type = _ref.type,
|
|
61
|
+
props = _objectWithoutProperties(_ref, _excluded);
|
|
71
62
|
var timeoutId = (0, _react.useRef)(null);
|
|
72
63
|
var hasActions = (actions === null || actions === void 0 ? void 0 : actions.length) > 0;
|
|
73
64
|
var showMeta = !!timestamp || hasActions;
|
|
@@ -77,16 +68,13 @@ var Notification = function Notification(_ref) {
|
|
|
77
68
|
return onDismiss();
|
|
78
69
|
}, timeout);
|
|
79
70
|
}
|
|
80
|
-
|
|
81
71
|
return function () {
|
|
82
72
|
return clearTimeout(timeoutId.current);
|
|
83
73
|
};
|
|
84
74
|
}, [onDismiss, timeout]);
|
|
85
|
-
|
|
86
75
|
if (_utils.IS_DEV && (close || status || type)) {
|
|
87
76
|
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");
|
|
88
77
|
}
|
|
89
|
-
|
|
90
78
|
return /*#__PURE__*/_react.default.createElement("div", _extends({
|
|
91
79
|
className: (0, _classnames.default)(className, (_classNames = {}, _defineProperty(_classNames, "p-notification--".concat(severity), !!severity), _defineProperty(_classNames, "p-notification", !severity), _defineProperty(_classNames, "is-borderless", borderless), _defineProperty(_classNames, "is-inline", inline), _classNames))
|
|
92
80
|
}, props), /*#__PURE__*/_react.default.createElement("div", {
|
|
@@ -118,6 +106,5 @@ var Notification = function Notification(_ref) {
|
|
|
118
106
|
}, action.label);
|
|
119
107
|
})) : null));
|
|
120
108
|
};
|
|
121
|
-
|
|
122
109
|
var _default = Notification;
|
|
123
110
|
exports.default = _default;
|