@canonical/react-components 0.40.1 → 0.42.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.
Files changed (127) hide show
  1. package/dist/__mocks__/nanoid.js +0 -2
  2. package/dist/components/Accordion/Accordion.js +13 -37
  3. package/dist/components/Accordion/AccordionSection/AccordionSection.js +8 -14
  4. package/dist/components/Accordion/AccordionSection/index.js +0 -2
  5. package/dist/components/Accordion/index.js +0 -2
  6. package/dist/components/ActionButton/ActionButton.js +36 -68
  7. package/dist/components/ActionButton/index.js +0 -2
  8. package/dist/components/ArticlePagination/ArticlePagination.js +5 -15
  9. package/dist/components/ArticlePagination/index.js +0 -2
  10. package/dist/components/Badge/Badge.js +10 -28
  11. package/dist/components/Badge/index.js +0 -2
  12. package/dist/components/Button/Button.js +12 -25
  13. package/dist/components/Button/index.js +0 -4
  14. package/dist/components/Card/Card.js +6 -17
  15. package/dist/components/Card/index.js +0 -2
  16. package/dist/components/CheckboxInput/CheckableInput/CheckableInput.js +6 -20
  17. package/dist/components/CheckboxInput/CheckableInput/index.js +0 -2
  18. package/dist/components/CheckboxInput/CheckboxInput.js +3 -13
  19. package/dist/components/CheckboxInput/index.js +0 -2
  20. package/dist/components/Chip/Chip.js +18 -35
  21. package/dist/components/Chip/index.js +0 -2
  22. package/dist/components/Code/Code.js +5 -23
  23. package/dist/components/Code/index.js +0 -2
  24. package/dist/components/CodeSnippet/CodeSnippet.js +2 -12
  25. package/dist/components/CodeSnippet/CodeSnippetBlock.js +10 -18
  26. package/dist/components/CodeSnippet/CodeSnippetDropdown.js +5 -14
  27. package/dist/components/CodeSnippet/index.js +0 -3
  28. package/dist/components/Col/Col.js +15 -25
  29. package/dist/components/Col/index.js +0 -4
  30. package/dist/components/ContextualMenu/ContextualMenu.js +70 -105
  31. package/dist/components/ContextualMenu/ContextualMenuDropdown/ContextualMenuDropdown.js +51 -88
  32. package/dist/components/ContextualMenu/ContextualMenuDropdown/index.js +0 -2
  33. package/dist/components/ContextualMenu/index.js +0 -2
  34. package/dist/components/Field/Field.js +35 -51
  35. package/dist/components/Field/index.js +0 -2
  36. package/dist/components/Form/Form.js +4 -14
  37. package/dist/components/Form/index.js +0 -2
  38. package/dist/components/Icon/Icon.js +3 -14
  39. package/dist/components/Icon/index.js +0 -4
  40. package/dist/components/Input/Input.js +21 -39
  41. package/dist/components/Input/index.js +0 -2
  42. package/dist/components/Label/Label.js +7 -13
  43. package/dist/components/Label/index.js +0 -2
  44. package/dist/components/Link/Link.js +10 -22
  45. package/dist/components/Link/index.js +0 -2
  46. package/dist/components/List/List.js +18 -31
  47. package/dist/components/List/index.js +0 -2
  48. package/dist/components/Loader/Loader.js +0 -7
  49. package/dist/components/Loader/index.js +0 -2
  50. package/dist/components/MainTable/MainTable.js +60 -112
  51. package/dist/components/MainTable/index.js +0 -2
  52. package/dist/components/Modal/Modal.js +7 -34
  53. package/dist/components/Modal/index.js +0 -2
  54. package/dist/components/ModularTable/ModularTable.d.ts +9 -1
  55. package/dist/components/ModularTable/ModularTable.js +74 -63
  56. package/dist/components/ModularTable/index.js +0 -2
  57. package/dist/components/Navigation/Navigation.js +46 -82
  58. package/dist/components/Navigation/NavigationLink/NavigationLink.js +15 -30
  59. package/dist/components/Navigation/NavigationLink/index.js +0 -2
  60. package/dist/components/Navigation/NavigationMenu/NavigationMenu.js +12 -35
  61. package/dist/components/Navigation/NavigationMenu/index.js +0 -2
  62. package/dist/components/Navigation/index.js +0 -2
  63. package/dist/components/Notification/Notification.d.ts +6 -1
  64. package/dist/components/Notification/Notification.js +31 -46
  65. package/dist/components/Notification/index.js +0 -4
  66. package/dist/components/Pagination/Pagination.js +14 -44
  67. package/dist/components/Pagination/PaginationButton/PaginationButton.js +7 -14
  68. package/dist/components/Pagination/PaginationButton/index.js +0 -2
  69. package/dist/components/Pagination/PaginationItem/PaginationItem.js +3 -8
  70. package/dist/components/Pagination/PaginationItem/index.js +0 -2
  71. package/dist/components/Pagination/index.js +0 -2
  72. package/dist/components/PasswordToggle/PasswordToggle.js +21 -50
  73. package/dist/components/PasswordToggle/index.js +0 -2
  74. package/dist/components/RadioInput/RadioInput.js +1 -11
  75. package/dist/components/RadioInput/index.js +0 -2
  76. package/dist/components/Row/Row.js +2 -12
  77. package/dist/components/Row/index.js +0 -2
  78. package/dist/components/SearchAndFilter/FilterPanelSection/FilterPanelSection.js +27 -49
  79. package/dist/components/SearchAndFilter/FilterPanelSection/index.js +0 -2
  80. package/dist/components/SearchAndFilter/SearchAndFilter.d.ts +9 -1
  81. package/dist/components/SearchAndFilter/SearchAndFilter.js +84 -105
  82. package/dist/components/SearchAndFilter/index.js +0 -2
  83. package/dist/components/SearchAndFilter/utils.js +1 -7
  84. package/dist/components/SearchBox/SearchBox.js +18 -38
  85. package/dist/components/SearchBox/index.js +0 -2
  86. package/dist/components/Select/Select.js +20 -33
  87. package/dist/components/Select/index.js +0 -2
  88. package/dist/components/Slider/Slider.js +16 -32
  89. package/dist/components/Slider/index.js +0 -2
  90. package/dist/components/Spinner/Spinner.js +8 -19
  91. package/dist/components/Spinner/index.js +0 -2
  92. package/dist/components/StatusLabel/StatusLabel.js +4 -15
  93. package/dist/components/StatusLabel/index.js +0 -4
  94. package/dist/components/Strip/Strip.js +25 -36
  95. package/dist/components/Strip/index.js +0 -2
  96. package/dist/components/SummaryButton/SummaryButton.js +4 -10
  97. package/dist/components/SummaryButton/index.js +0 -2
  98. package/dist/components/Switch/Switch.js +3 -12
  99. package/dist/components/Switch/index.js +0 -2
  100. package/dist/components/Table/Table.js +6 -16
  101. package/dist/components/Table/index.js +0 -2
  102. package/dist/components/TableCell/TableCell.js +10 -20
  103. package/dist/components/TableCell/index.js +0 -2
  104. package/dist/components/TableHeader/TableHeader.js +2 -11
  105. package/dist/components/TableHeader/index.js +0 -2
  106. package/dist/components/TableRow/TableRow.js +1 -10
  107. package/dist/components/TableRow/index.js +0 -2
  108. package/dist/components/Tabs/Tabs.js +7 -17
  109. package/dist/components/Tabs/index.js +0 -2
  110. package/dist/components/Textarea/Textarea.js +23 -36
  111. package/dist/components/Textarea/index.js +0 -2
  112. package/dist/components/Tooltip/Tooltip.js +42 -87
  113. package/dist/components/Tooltip/index.js +0 -4
  114. package/dist/enums.js +4 -6
  115. package/dist/hooks/index.js +0 -8
  116. package/dist/hooks/useClickOutside.js +2 -7
  117. package/dist/hooks/useId.js +0 -4
  118. package/dist/hooks/useListener.js +0 -8
  119. package/dist/hooks/useOnEscapePressed.js +0 -3
  120. package/dist/hooks/usePagination.js +13 -25
  121. package/dist/hooks/usePrevious.js +0 -3
  122. package/dist/hooks/useThrottle.js +1 -15
  123. package/dist/hooks/useWindowFitment.d.ts +12 -0
  124. package/dist/hooks/useWindowFitment.js +22 -17
  125. package/dist/index.js +0 -52
  126. package/dist/utils.js +3 -10
  127. package/package.json +36 -35
@@ -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 _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; }
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 _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; }
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
- generateLink = _ref.generateLink,
56
- items = _ref.items,
57
- label = _ref.label,
58
- props = _objectWithoutProperties(_ref, _excluded);
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
- _useState2 = _slicedToArray(_useState, 2),
62
- isOpen = _useState2[0],
63
- setIsOpen = _useState2[1];
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 }; }
@@ -9,7 +9,5 @@ Object.defineProperty(exports, "default", {
9
9
  return _Navigation.default;
10
10
  }
11
11
  });
12
-
13
12
  var _Navigation = _interopRequireDefault(require("./Navigation"));
14
-
15
13
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
@@ -1,3 +1,4 @@
1
+ import { ElementType } from "react";
1
2
  import type { HTMLProps, ReactNode } from "react";
2
3
  import type { ClassName, PropsWithSpread, ValueOf } from "../../types";
3
4
  export declare enum Label {
@@ -65,10 +66,14 @@ export type Props = PropsWithSpread<{
65
66
  * The title of the notification.
66
67
  */
67
68
  title?: ReactNode;
69
+ /**
70
+ * Optional element or component to use for the title.
71
+ */
72
+ titleElement?: ElementType;
68
73
  /**
69
74
  * **Deprecated**. Use `severity` instead.
70
75
  */
71
76
  type?: never;
72
77
  }, HTMLProps<HTMLDivElement>>;
73
- declare const Notification: ({ actions, borderless, children, className, close, inline, onDismiss, severity, status, timeout, timestamp, title, type, ...props }: Props) => JSX.Element;
78
+ declare const Notification: ({ actions, borderless, children, className, close, inline, onDismiss, severity, status, timeout, timestamp, title, titleElement: TitleComponent, type, ...props }: Props) => JSX.Element;
74
79
  export default Notification;
@@ -1,72 +1,61 @@
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 = exports.NotificationSeverity = exports.Label = void 0;
9
-
10
8
  var _classnames = _interopRequireDefault(require("classnames"));
11
-
12
9
  var _react = _interopRequireWildcard(require("react"));
13
-
14
10
  var _Button = _interopRequireWildcard(require("../Button"));
15
-
16
11
  var _utils = require("../../utils");
17
-
18
- var _excluded = ["actions", "borderless", "children", "className", "close", "inline", "onDismiss", "severity", "status", "timeout", "timestamp", "title", "type"];
19
-
12
+ var _excluded = ["actions", "borderless", "children", "className", "close", "inline", "onDismiss", "severity", "status", "timeout", "timestamp", "title", "titleElement", "type"];
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
-
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
- 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
-
17
+ 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
+ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
19
+ 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); }
30
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; }
31
-
32
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; }
33
-
34
- var Label;
35
- exports.Label = Label;
36
-
37
- (function (Label) {
22
+ var Label = /*#__PURE__*/function (Label) {
38
23
  Label["Close"] = "Close notification";
39
- })(Label || (exports.Label = Label = {}));
40
-
24
+ return Label;
25
+ }({});
26
+ exports.Label = Label;
41
27
  var NotificationSeverity = {
42
28
  CAUTION: "caution",
43
29
  INFORMATION: "information",
44
30
  NEGATIVE: "negative",
45
31
  POSITIVE: "positive"
46
32
  };
47
- exports.NotificationSeverity = NotificationSeverity;
48
33
 
34
+ /**
35
+ * The props for the Notification component.
36
+ */
37
+ exports.NotificationSeverity = NotificationSeverity;
49
38
  var Notification = function Notification(_ref) {
50
39
  var _classNames;
51
-
52
40
  var actions = _ref.actions,
53
- _ref$borderless = _ref.borderless,
54
- borderless = _ref$borderless === void 0 ? false : _ref$borderless,
55
- children = _ref.children,
56
- className = _ref.className,
57
- close = _ref.close,
58
- _ref$inline = _ref.inline,
59
- inline = _ref$inline === void 0 ? false : _ref$inline,
60
- onDismiss = _ref.onDismiss,
61
- _ref$severity = _ref.severity,
62
- severity = _ref$severity === void 0 ? NotificationSeverity.INFORMATION : _ref$severity,
63
- status = _ref.status,
64
- timeout = _ref.timeout,
65
- timestamp = _ref.timestamp,
66
- title = _ref.title,
67
- type = _ref.type,
68
- props = _objectWithoutProperties(_ref, _excluded);
69
-
41
+ _ref$borderless = _ref.borderless,
42
+ borderless = _ref$borderless === void 0 ? false : _ref$borderless,
43
+ children = _ref.children,
44
+ className = _ref.className,
45
+ close = _ref.close,
46
+ _ref$inline = _ref.inline,
47
+ inline = _ref$inline === void 0 ? false : _ref$inline,
48
+ onDismiss = _ref.onDismiss,
49
+ _ref$severity = _ref.severity,
50
+ severity = _ref$severity === void 0 ? NotificationSeverity.INFORMATION : _ref$severity,
51
+ status = _ref.status,
52
+ timeout = _ref.timeout,
53
+ timestamp = _ref.timestamp,
54
+ title = _ref.title,
55
+ _ref$titleElement = _ref.titleElement,
56
+ TitleComponent = _ref$titleElement === void 0 ? "h5" : _ref$titleElement,
57
+ type = _ref.type,
58
+ props = _objectWithoutProperties(_ref, _excluded);
70
59
  var timeoutId = (0, _react.useRef)(null);
71
60
  var hasActions = (actions === null || actions === void 0 ? void 0 : actions.length) > 0;
72
61
  var showMeta = !!timestamp || hasActions;
@@ -76,21 +65,18 @@ var Notification = function Notification(_ref) {
76
65
  return onDismiss();
77
66
  }, timeout);
78
67
  }
79
-
80
68
  return function () {
81
69
  return clearTimeout(timeoutId.current);
82
70
  };
83
71
  }, [onDismiss, timeout]);
84
-
85
72
  if (_utils.IS_DEV && (close || status || type)) {
86
73
  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");
87
74
  }
88
-
89
75
  return /*#__PURE__*/_react.default.createElement("div", _extends({
90
76
  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))
91
77
  }, props), /*#__PURE__*/_react.default.createElement("div", {
92
78
  className: "p-notification__content"
93
- }, title && /*#__PURE__*/_react.default.createElement("h5", {
79
+ }, title && /*#__PURE__*/_react.default.createElement(TitleComponent, {
94
80
  className: "p-notification__title",
95
81
  "data-testid": "notification-title"
96
82
  }, title), inline && /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, "\u2002"), /*#__PURE__*/_react.default.createElement("p", {
@@ -117,6 +103,5 @@ var Notification = function Notification(_ref) {
117
103
  }, action.label);
118
104
  })) : null));
119
105
  };
120
-
121
106
  var _default = Notification;
122
107
  exports.default = _default;
@@ -1,7 +1,6 @@
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
  });
@@ -17,9 +16,6 @@ Object.defineProperty(exports, "default", {
17
16
  return _Notification.default;
18
17
  }
19
18
  });
20
-
21
19
  var _Notification = _interopRequireWildcard(require("./Notification"));
22
-
23
20
  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); }
24
-
25
21
  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; }
@@ -4,63 +4,46 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = void 0;
7
-
8
7
  var _classnames = _interopRequireDefault(require("classnames"));
9
-
10
8
  var _react = _interopRequireDefault(require("react"));
11
-
12
9
  var _PaginationButton = _interopRequireDefault(require("./PaginationButton"));
13
-
14
10
  var _PaginationItem = _interopRequireDefault(require("./PaginationItem"));
15
-
16
11
  var _excluded = ["itemsPerPage", "totalItems", "paginate", "currentPage", "scrollToTop", "truncateThreshold", "centered"];
17
-
18
12
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
19
-
20
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); }
21
-
22
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; }
23
-
24
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; }
25
-
26
16
  var scrollTop = function scrollTop() {
27
17
  return window.scrollTo(0, 0);
28
18
  };
29
-
30
19
  var generatePaginationItems = function generatePaginationItems(pageNumbers, currentPage, truncateThreshold, changePage) {
31
20
  var lastPage = pageNumbers.length;
32
21
  var truncated = lastPage > truncateThreshold;
33
22
  var visiblePages;
34
-
35
23
  if (truncated) {
36
24
  // the default range for pages outside the start and end threshold
37
25
  var start = currentPage - 2;
38
- var end = currentPage + 1; // on page 1, also show pages 2, 3 and 4
39
-
26
+ var end = currentPage + 1;
27
+ // on page 1, also show pages 2, 3 and 4
40
28
  if (currentPage === 1) {
41
29
  start = 1;
42
30
  end = currentPage + 3;
43
- } // on page 2, show page 1, and also pages 3, and 4
44
-
45
-
31
+ }
32
+ // on page 2, show page 1, and also pages 3, and 4
46
33
  if (currentPage === 2) {
47
34
  start = 1;
48
35
  end = currentPage + 2;
49
- } // on the last page and page before last, also show the 3 previous pages
50
-
51
-
36
+ }
37
+ // on the last page and page before last, also show the 3 previous pages
52
38
  if (currentPage === lastPage || currentPage === lastPage - 1) {
53
39
  start = lastPage - 4;
54
40
  end = lastPage - 1;
55
41
  }
56
-
57
42
  visiblePages = pageNumbers.slice(start, end);
58
43
  } else {
59
44
  visiblePages = pageNumbers;
60
45
  }
61
-
62
46
  var items = [];
63
-
64
47
  if (truncated) {
65
48
  // render first in sequence
66
49
  items.push( /*#__PURE__*/_react.default.createElement(_PaginationItem.default, {
@@ -71,14 +54,12 @@ var generatePaginationItems = function generatePaginationItems(pageNumbers, curr
71
54
  return changePage(1);
72
55
  }
73
56
  }));
74
-
75
57
  if (![1, 2, 3].includes(currentPage)) {
76
58
  items.push( /*#__PURE__*/_react.default.createElement(PaginationItemSeparator, {
77
59
  key: "sep1"
78
60
  }));
79
61
  }
80
62
  }
81
-
82
63
  items.push(visiblePages.map(function (number) {
83
64
  return /*#__PURE__*/_react.default.createElement(_PaginationItem.default, {
84
65
  key: number,
@@ -89,7 +70,6 @@ var generatePaginationItems = function generatePaginationItems(pageNumbers, curr
89
70
  }
90
71
  });
91
72
  }));
92
-
93
73
  if (truncated) {
94
74
  // render last in sequence
95
75
  if (![lastPage, lastPage - 1, lastPage - 2].includes(currentPage)) {
@@ -97,7 +77,6 @@ var generatePaginationItems = function generatePaginationItems(pageNumbers, curr
97
77
  key: "sep2"
98
78
  }));
99
79
  }
100
-
101
80
  items.push( /*#__PURE__*/_react.default.createElement(_PaginationItem.default, {
102
81
  key: lastPage,
103
82
  number: lastPage,
@@ -107,43 +86,35 @@ var generatePaginationItems = function generatePaginationItems(pageNumbers, curr
107
86
  }
108
87
  }));
109
88
  }
110
-
111
89
  return items;
112
90
  };
113
-
114
91
  var PaginationItemSeparator = function PaginationItemSeparator() {
115
92
  return /*#__PURE__*/_react.default.createElement("li", {
116
93
  className: "p-pagination__item p-pagination__item--truncation"
117
94
  }, "\u2026");
118
95
  };
119
-
120
96
  var Pagination = function Pagination(_ref) {
121
97
  var itemsPerPage = _ref.itemsPerPage,
122
- totalItems = _ref.totalItems,
123
- paginate = _ref.paginate,
124
- currentPage = _ref.currentPage,
125
- scrollToTop = _ref.scrollToTop,
126
- _ref$truncateThreshol = _ref.truncateThreshold,
127
- truncateThreshold = _ref$truncateThreshol === void 0 ? 10 : _ref$truncateThreshol,
128
- centered = _ref.centered,
129
- navProps = _objectWithoutProperties(_ref, _excluded);
130
-
98
+ totalItems = _ref.totalItems,
99
+ paginate = _ref.paginate,
100
+ currentPage = _ref.currentPage,
101
+ scrollToTop = _ref.scrollToTop,
102
+ _ref$truncateThreshol = _ref.truncateThreshold,
103
+ truncateThreshold = _ref$truncateThreshol === void 0 ? 10 : _ref$truncateThreshol,
104
+ centered = _ref.centered,
105
+ navProps = _objectWithoutProperties(_ref, _excluded);
131
106
  // return early if no pagination is required
132
107
  if (totalItems <= itemsPerPage) {
133
108
  return null;
134
109
  }
135
-
136
110
  var pageNumbers = [];
137
-
138
111
  for (var i = 1; i <= Math.ceil(totalItems / itemsPerPage); i++) {
139
112
  pageNumbers.push(i);
140
113
  }
141
-
142
114
  var changePage = function changePage(page) {
143
115
  paginate(page);
144
116
  scrollToTop && scrollTop();
145
117
  };
146
-
147
118
  return /*#__PURE__*/_react.default.createElement("nav", _extends({
148
119
  className: "p-pagination",
149
120
  "aria-label": "Pagination"
@@ -167,6 +138,5 @@ var Pagination = function Pagination(_ref) {
167
138
  }
168
139
  })));
169
140
  };
170
-
171
141
  var _default = Pagination;
172
142
  exports.default = _default;
@@ -4,26 +4,20 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = exports.Label = void 0;
7
-
8
7
  var _classnames = _interopRequireDefault(require("classnames"));
9
-
10
8
  var _react = _interopRequireDefault(require("react"));
11
-
12
9
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
13
-
14
- var Label;
15
- exports.Label = Label;
16
-
17
- (function (Label) {
10
+ var Label = /*#__PURE__*/function (Label) {
18
11
  Label["Next"] = "Next page";
19
12
  Label["Previous"] = "Previous page";
20
- })(Label || (exports.Label = Label = {}));
21
-
13
+ return Label;
14
+ }({});
15
+ exports.Label = Label;
22
16
  var PaginationButton = function PaginationButton(_ref) {
23
17
  var direction = _ref.direction,
24
- onClick = _ref.onClick,
25
- _ref$disabled = _ref.disabled,
26
- disabled = _ref$disabled === void 0 ? false : _ref$disabled;
18
+ onClick = _ref.onClick,
19
+ _ref$disabled = _ref.disabled,
20
+ disabled = _ref$disabled === void 0 ? false : _ref$disabled;
27
21
  var label = direction === "back" ? Label.Previous : Label.Next;
28
22
  return /*#__PURE__*/_react.default.createElement("li", {
29
23
  className: "p-pagination__item"
@@ -39,6 +33,5 @@ var PaginationButton = function PaginationButton(_ref) {
39
33
  className: "p-icon--chevron-down"
40
34
  }, label)));
41
35
  };
42
-
43
36
  var _default = PaginationButton;
44
37
  exports.default = _default;
@@ -9,7 +9,5 @@ Object.defineProperty(exports, "default", {
9
9
  return _PaginationButton.default;
10
10
  }
11
11
  });
12
-
13
12
  var _PaginationButton = _interopRequireDefault(require("./PaginationButton"));
14
-
15
13
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
@@ -4,18 +4,14 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = void 0;
7
-
8
7
  var _classnames = _interopRequireDefault(require("classnames"));
9
-
10
8
  var _react = _interopRequireDefault(require("react"));
11
-
12
9
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
13
-
14
10
  var PaginationItem = function PaginationItem(_ref) {
15
11
  var number = _ref.number,
16
- onClick = _ref.onClick,
17
- _ref$isActive = _ref.isActive,
18
- isActive = _ref$isActive === void 0 ? false : _ref$isActive;
12
+ onClick = _ref.onClick,
13
+ _ref$isActive = _ref.isActive,
14
+ isActive = _ref$isActive === void 0 ? false : _ref$isActive;
19
15
  return /*#__PURE__*/_react.default.createElement("li", {
20
16
  className: "p-pagination__item"
21
17
  }, /*#__PURE__*/_react.default.createElement("button", {
@@ -27,6 +23,5 @@ var PaginationItem = function PaginationItem(_ref) {
27
23
  type: "button"
28
24
  }, number));
29
25
  };
30
-
31
26
  var _default = PaginationItem;
32
27
  exports.default = _default;
@@ -9,7 +9,5 @@ Object.defineProperty(exports, "default", {
9
9
  return _PaginationItem.default;
10
10
  }
11
11
  });
12
-
13
12
  var _PaginationItem = _interopRequireDefault(require("./PaginationItem"));
14
-
15
13
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
@@ -9,7 +9,5 @@ Object.defineProperty(exports, "default", {
9
9
  return _Pagination.default;
10
10
  }
11
11
  });
12
-
13
12
  var _Pagination = _interopRequireDefault(require("./Pagination"));
14
-
15
13
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }