@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
package/dist/__mocks__/nanoid.js
CHANGED
|
@@ -4,11 +4,11 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.nanoid = void 0;
|
|
7
|
-
|
|
8
|
-
beforeEach(
|
|
7
|
+
let id = 0;
|
|
8
|
+
beforeEach(() => {
|
|
9
9
|
id = 0;
|
|
10
10
|
});
|
|
11
|
-
|
|
11
|
+
const nanoid = () => {
|
|
12
12
|
id++;
|
|
13
13
|
return "mock-nanoid-".concat(id);
|
|
14
14
|
};
|
|
@@ -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
|
});
|
|
@@ -8,46 +7,35 @@ exports.default = void 0;
|
|
|
8
7
|
var _classnames = _interopRequireDefault(require("classnames"));
|
|
9
8
|
var _react = _interopRequireWildcard(require("react"));
|
|
10
9
|
var _AccordionSection = _interopRequireDefault(require("./AccordionSection"));
|
|
11
|
-
var
|
|
12
|
-
|
|
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; }
|
|
10
|
+
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); }
|
|
11
|
+
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
12
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
16
|
-
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
17
|
-
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."); }
|
|
18
|
-
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); }
|
|
19
|
-
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; }
|
|
20
|
-
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; } }
|
|
21
|
-
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
22
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); }
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
expandedSection = _useState2[0],
|
|
49
|
-
setExpandedSection = _useState2[1];
|
|
50
|
-
var setExpanded = function setExpanded(id, title) {
|
|
14
|
+
const generateSections = (sections, setExpanded, expanded, titleElement) => sections.map((_ref, i) => {
|
|
15
|
+
let {
|
|
16
|
+
key,
|
|
17
|
+
...props
|
|
18
|
+
} = _ref;
|
|
19
|
+
return /*#__PURE__*/_react.default.createElement(_AccordionSection.default, _extends({
|
|
20
|
+
expanded: expanded,
|
|
21
|
+
key: key || i,
|
|
22
|
+
sectionKey: key === null || key === void 0 ? void 0 : key.toString(),
|
|
23
|
+
setExpanded: setExpanded,
|
|
24
|
+
titleElement: titleElement
|
|
25
|
+
}, props));
|
|
26
|
+
});
|
|
27
|
+
const Accordion = _ref2 => {
|
|
28
|
+
let {
|
|
29
|
+
className,
|
|
30
|
+
expanded,
|
|
31
|
+
externallyControlled,
|
|
32
|
+
onExpandedChange,
|
|
33
|
+
sections,
|
|
34
|
+
titleElement,
|
|
35
|
+
...asideProps
|
|
36
|
+
} = _ref2;
|
|
37
|
+
const [expandedSection, setExpandedSection] = (0, _react.useState)(expanded);
|
|
38
|
+
const setExpanded = (id, title) => {
|
|
51
39
|
setExpandedSection(id);
|
|
52
40
|
onExpandedChange && onExpandedChange(id, title);
|
|
53
41
|
};
|
|
@@ -60,5 +48,4 @@ var Accordion = function Accordion(_ref2) {
|
|
|
60
48
|
className: "p-accordion__list"
|
|
61
49
|
}, generateSections(sections, setExpanded, externallyControlled ? expanded : expandedSection, titleElement)));
|
|
62
50
|
};
|
|
63
|
-
var _default = Accordion;
|
|
64
|
-
exports.default = _default;
|
|
51
|
+
var _default = exports.default = Accordion;
|
|
@@ -7,21 +7,22 @@ exports.default = void 0;
|
|
|
7
7
|
var _react = _interopRequireDefault(require("react"));
|
|
8
8
|
var _useId = require("../../../hooks/useId");
|
|
9
9
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
headingLevel =
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
10
|
+
const AccordionSection = _ref => {
|
|
11
|
+
let {
|
|
12
|
+
content,
|
|
13
|
+
expanded,
|
|
14
|
+
onTitleClick,
|
|
15
|
+
sectionKey,
|
|
16
|
+
setExpanded,
|
|
17
|
+
title,
|
|
18
|
+
titleElement,
|
|
19
|
+
headingLevel = 3
|
|
20
|
+
} = _ref;
|
|
21
|
+
const sectionId = (0, _useId.useId)();
|
|
22
|
+
const tabId = (0, _useId.useId)();
|
|
23
|
+
const key = sectionKey || sectionId;
|
|
24
|
+
const isExpanded = expanded === key;
|
|
25
|
+
const Title = titleElement || "div";
|
|
25
26
|
return /*#__PURE__*/_react.default.createElement("li", {
|
|
26
27
|
className: "p-accordion__group"
|
|
27
28
|
}, /*#__PURE__*/_react.default.createElement(Title, {
|
|
@@ -33,7 +34,7 @@ var AccordionSection = function AccordionSection(_ref) {
|
|
|
33
34
|
"aria-expanded": isExpanded ? "true" : "false",
|
|
34
35
|
className: "p-accordion__tab",
|
|
35
36
|
id: tabId,
|
|
36
|
-
onClick:
|
|
37
|
+
onClick: () => {
|
|
37
38
|
if (isExpanded) {
|
|
38
39
|
setExpanded(null, null);
|
|
39
40
|
} else {
|
|
@@ -51,5 +52,4 @@ var AccordionSection = function AccordionSection(_ref) {
|
|
|
51
52
|
role: "tabpanel"
|
|
52
53
|
}, content));
|
|
53
54
|
};
|
|
54
|
-
var _default = AccordionSection;
|
|
55
|
-
exports.default = _default;
|
|
55
|
+
var _default = exports.default = AccordionSection;
|
|
@@ -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
|
});
|
|
@@ -8,63 +7,37 @@ exports.default = exports.SUCCESS_DURATION = exports.Label = exports.LOADER_MIN_
|
|
|
8
7
|
var _classnames = _interopRequireDefault(require("classnames"));
|
|
9
8
|
var _react = _interopRequireWildcard(require("react"));
|
|
10
9
|
var _Icon = _interopRequireDefault(require("../Icon"));
|
|
11
|
-
|
|
12
|
-
function
|
|
13
|
-
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; }
|
|
10
|
+
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); }
|
|
11
|
+
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; }
|
|
14
12
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
15
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); }
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
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; }
|
|
20
|
-
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; } }
|
|
21
|
-
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
22
|
-
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
|
-
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; }
|
|
24
|
-
var LOADER_MIN_DURATION = 400; // minimium duration (ms) loader displays
|
|
25
|
-
exports.LOADER_MIN_DURATION = LOADER_MIN_DURATION;
|
|
26
|
-
var SUCCESS_DURATION = 2000; // duration (ms) success tick is displayed
|
|
27
|
-
exports.SUCCESS_DURATION = SUCCESS_DURATION;
|
|
28
|
-
var Label = /*#__PURE__*/function (Label) {
|
|
14
|
+
const LOADER_MIN_DURATION = exports.LOADER_MIN_DURATION = 400; // minimium duration (ms) loader displays
|
|
15
|
+
const SUCCESS_DURATION = exports.SUCCESS_DURATION = 2000; // duration (ms) success tick is displayed
|
|
16
|
+
let Label = exports.Label = /*#__PURE__*/function (Label) {
|
|
29
17
|
Label["WAITING"] = "Waiting for action to complete";
|
|
30
18
|
Label["SUCCESS"] = "Action completed";
|
|
31
19
|
return Label;
|
|
32
20
|
}({});
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
children
|
|
37
|
-
className
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
height = _useState2[0],
|
|
50
|
-
setHeight = _useState2[1];
|
|
51
|
-
var _useState3 = (0, _react.useState)(),
|
|
52
|
-
_useState4 = _slicedToArray(_useState3, 2),
|
|
53
|
-
width = _useState4[0],
|
|
54
|
-
setWidth = _useState4[1];
|
|
55
|
-
var _useState5 = (0, _react.useState)(false),
|
|
56
|
-
_useState6 = _slicedToArray(_useState5, 2),
|
|
57
|
-
showLoader = _useState6[0],
|
|
58
|
-
setShowLoader = _useState6[1];
|
|
59
|
-
var _useState7 = (0, _react.useState)(false),
|
|
60
|
-
_useState8 = _slicedToArray(_useState7, 2),
|
|
61
|
-
showSuccess = _useState8[0],
|
|
62
|
-
setShowSuccess = _useState8[1];
|
|
63
|
-
var ref = (0, _react.useRef)(null);
|
|
21
|
+
const ActionButton = _ref => {
|
|
22
|
+
let {
|
|
23
|
+
appearance,
|
|
24
|
+
children,
|
|
25
|
+
className,
|
|
26
|
+
disabled = false,
|
|
27
|
+
inline = false,
|
|
28
|
+
loading = false,
|
|
29
|
+
success = false,
|
|
30
|
+
...buttonProps
|
|
31
|
+
} = _ref;
|
|
32
|
+
const [height, setHeight] = (0, _react.useState)();
|
|
33
|
+
const [width, setWidth] = (0, _react.useState)();
|
|
34
|
+
const [showLoader, setShowLoader] = (0, _react.useState)(false);
|
|
35
|
+
const [showSuccess, setShowSuccess] = (0, _react.useState)(false);
|
|
36
|
+
const ref = (0, _react.useRef)(null);
|
|
64
37
|
|
|
65
38
|
// Set up loader timer
|
|
66
|
-
(0, _react.useEffect)(
|
|
67
|
-
|
|
39
|
+
(0, _react.useEffect)(() => {
|
|
40
|
+
let loaderTimeout;
|
|
68
41
|
if (loading) {
|
|
69
42
|
// Explicitly set button dimensions
|
|
70
43
|
if (ref.current && !!ref.current.getBoundingClientRect()) {
|
|
@@ -74,7 +47,7 @@ var ActionButton = function ActionButton(_ref) {
|
|
|
74
47
|
setShowLoader(true);
|
|
75
48
|
}
|
|
76
49
|
if (!loading && showLoader) {
|
|
77
|
-
loaderTimeout = window.setTimeout(
|
|
50
|
+
loaderTimeout = window.setTimeout(() => {
|
|
78
51
|
setShowLoader(false);
|
|
79
52
|
if (success) {
|
|
80
53
|
setShowSuccess(true);
|
|
@@ -85,33 +58,29 @@ var ActionButton = function ActionButton(_ref) {
|
|
|
85
58
|
setHeight(null);
|
|
86
59
|
setWidth(null);
|
|
87
60
|
}
|
|
88
|
-
return
|
|
89
|
-
return window.clearTimeout(loaderTimeout);
|
|
90
|
-
};
|
|
61
|
+
return () => window.clearTimeout(loaderTimeout);
|
|
91
62
|
}, [loading, showLoader, success]);
|
|
92
63
|
|
|
93
64
|
// Set up success timer
|
|
94
|
-
(0, _react.useEffect)(
|
|
95
|
-
|
|
65
|
+
(0, _react.useEffect)(() => {
|
|
66
|
+
let successTimeout;
|
|
96
67
|
if (showSuccess) {
|
|
97
|
-
successTimeout = window.setTimeout(
|
|
68
|
+
successTimeout = window.setTimeout(() => {
|
|
98
69
|
setHeight(null);
|
|
99
70
|
setWidth(null);
|
|
100
71
|
setShowSuccess(false);
|
|
101
72
|
}, SUCCESS_DURATION);
|
|
102
73
|
}
|
|
103
|
-
return
|
|
104
|
-
return window.clearTimeout(successTimeout);
|
|
105
|
-
};
|
|
74
|
+
return () => window.clearTimeout(successTimeout);
|
|
106
75
|
}, [showSuccess]);
|
|
107
|
-
|
|
76
|
+
const buttonClasses = (0, _classnames.default)(className, "p-action-button", appearance ? "p-button--".concat(appearance) : "p-button", {
|
|
108
77
|
"is-processing": showLoader || showSuccess,
|
|
109
78
|
"is-disabled": disabled,
|
|
110
79
|
"is-inline": inline
|
|
111
80
|
});
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
81
|
+
const showIcon = showLoader || showSuccess;
|
|
82
|
+
const icon = showLoader && "spinner" || showSuccess && "success" || null;
|
|
83
|
+
const iconLight = appearance === "positive" || appearance === "negative";
|
|
115
84
|
|
|
116
85
|
// This component uses the base button element instead of the Button component
|
|
117
86
|
// as the button requires a ref and Button would have to be updated to use
|
|
@@ -132,5 +101,4 @@ var ActionButton = function ActionButton(_ref) {
|
|
|
132
101
|
name: icon
|
|
133
102
|
}) : children);
|
|
134
103
|
};
|
|
135
|
-
var _default = ActionButton;
|
|
136
|
-
exports.default = _default;
|
|
104
|
+
var _default = exports.default = ActionButton;
|
|
@@ -6,18 +6,17 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.default = void 0;
|
|
7
7
|
var _classnames = _interopRequireDefault(require("classnames"));
|
|
8
8
|
var _react = _interopRequireDefault(require("react"));
|
|
9
|
-
var _excluded = ["className", "nextURL", "nextLabel", "previousURL", "previousLabel"];
|
|
10
9
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
11
10
|
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
11
|
+
const ArticlePagination = _ref => {
|
|
12
|
+
let {
|
|
13
|
+
className,
|
|
14
|
+
nextURL,
|
|
15
|
+
nextLabel,
|
|
16
|
+
previousURL,
|
|
17
|
+
previousLabel,
|
|
18
|
+
...props
|
|
19
|
+
} = _ref;
|
|
21
20
|
return /*#__PURE__*/_react.default.createElement("footer", _extends({
|
|
22
21
|
className: (0, _classnames.default)(className, "p-article-pagination")
|
|
23
22
|
}, props), previousURL && previousLabel && /*#__PURE__*/_react.default.createElement("a", {
|
|
@@ -36,5 +35,4 @@ var ArticlePagination = function ArticlePagination(_ref) {
|
|
|
36
35
|
className: "p-article-pagination__title"
|
|
37
36
|
}, nextLabel)));
|
|
38
37
|
};
|
|
39
|
-
var _default = ArticlePagination;
|
|
40
|
-
exports.default = _default;
|
|
38
|
+
var _default = exports.default = ArticlePagination;
|
|
@@ -1,21 +1,14 @@
|
|
|
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
|
exports.default = exports.BadgeType = void 0;
|
|
8
7
|
var _classnames = _interopRequireDefault(require("classnames"));
|
|
9
8
|
var _react = _interopRequireDefault(require("react"));
|
|
10
|
-
var _excluded = ["value", "badgeType", "className", "isNegative"];
|
|
11
9
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
12
10
|
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
13
|
-
|
|
14
|
-
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
15
|
-
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); }
|
|
16
|
-
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; }
|
|
17
|
-
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; }
|
|
18
|
-
var BadgeType = {
|
|
11
|
+
const BadgeType = exports.BadgeType = {
|
|
19
12
|
ROUNDED_LARGE_NUMBER: "ROUNDED_LARGE_NUMBER",
|
|
20
13
|
UNDEFINED_LARGE_NUMBER: "UNDEFINED_LARGE_NUMBER"
|
|
21
14
|
};
|
|
@@ -23,45 +16,47 @@ var BadgeType = {
|
|
|
23
16
|
/**
|
|
24
17
|
* The props for the Badge component.
|
|
25
18
|
*/
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
19
|
+
|
|
20
|
+
const MAX_VAL = 999;
|
|
21
|
+
const units = ["", "k", "M", "B", "T"];
|
|
22
|
+
const round = function (value) {
|
|
23
|
+
let unit = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
|
|
31
24
|
if (value < 1000) {
|
|
32
|
-
|
|
25
|
+
const truncatedValue = Number(value.toString().slice(0, 3));
|
|
33
26
|
return "".concat(truncatedValue).concat(units[unit]);
|
|
34
27
|
}
|
|
35
28
|
if (unit >= units.length - 1) {
|
|
36
29
|
return "999T";
|
|
37
30
|
}
|
|
38
|
-
|
|
31
|
+
const newValue = value / 1000;
|
|
39
32
|
return round(newValue, unit + 1);
|
|
40
33
|
};
|
|
41
|
-
|
|
34
|
+
const clamp = value => {
|
|
42
35
|
if (value > MAX_VAL) {
|
|
43
36
|
return "".concat(MAX_VAL, "+");
|
|
44
37
|
}
|
|
45
38
|
return value;
|
|
46
39
|
};
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
40
|
+
const Badge = _ref => {
|
|
41
|
+
let {
|
|
42
|
+
value,
|
|
43
|
+
badgeType = BadgeType.UNDEFINED_LARGE_NUMBER,
|
|
44
|
+
className,
|
|
45
|
+
isNegative,
|
|
46
|
+
...spanProps
|
|
47
|
+
} = _ref;
|
|
48
|
+
const badgeClassName = (0, _classnames.default)({
|
|
49
|
+
["p-badge--negative"]: !!isNegative,
|
|
50
|
+
"p-badge": !isNegative
|
|
51
|
+
}, className);
|
|
52
|
+
let safeValue = Math.round(value);
|
|
57
53
|
if (value < 0) {
|
|
58
54
|
console.error("The value used in the badge should be positive");
|
|
59
55
|
safeValue = 0;
|
|
60
56
|
}
|
|
61
|
-
|
|
57
|
+
const formattedValue = badgeType === BadgeType.ROUNDED_LARGE_NUMBER ? round(safeValue) : clamp(safeValue);
|
|
62
58
|
return /*#__PURE__*/_react.default.createElement("span", _extends({}, spanProps, {
|
|
63
59
|
className: badgeClassName
|
|
64
60
|
}), formattedValue);
|
|
65
61
|
};
|
|
66
|
-
var _default = Badge;
|
|
67
|
-
exports.default = _default;
|
|
62
|
+
var _default = exports.default = Badge;
|
|
@@ -6,12 +6,9 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.default = exports.ButtonAppearance = void 0;
|
|
7
7
|
var _classnames = _interopRequireDefault(require("classnames"));
|
|
8
8
|
var _react = _interopRequireDefault(require("react"));
|
|
9
|
-
var _excluded = ["appearance", "children", "className", "dense", "disabled", "element", "hasIcon", "inline", "onClick", "small"];
|
|
10
9
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
11
10
|
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
12
|
-
|
|
13
|
-
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; }
|
|
14
|
-
var ButtonAppearance = {
|
|
11
|
+
const ButtonAppearance = exports.ButtonAppearance = {
|
|
15
12
|
BASE: "base",
|
|
16
13
|
BRAND: "brand",
|
|
17
14
|
DEFAULT: "",
|
|
@@ -24,36 +21,35 @@ var ButtonAppearance = {
|
|
|
24
21
|
* The type of the Button props.
|
|
25
22
|
* @template P - The type of the props if providing a component to `element`
|
|
26
23
|
*/
|
|
27
|
-
|
|
24
|
+
|
|
28
25
|
/**
|
|
29
26
|
* A component for the Vanilla button.
|
|
30
27
|
* @template P - The type of the props if providing a component to `element`
|
|
31
28
|
*/
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
Component =
|
|
40
|
-
hasIcon
|
|
41
|
-
inline
|
|
42
|
-
onClick
|
|
43
|
-
small
|
|
44
|
-
buttonProps
|
|
45
|
-
|
|
29
|
+
const Button = _ref => {
|
|
30
|
+
let {
|
|
31
|
+
appearance,
|
|
32
|
+
children,
|
|
33
|
+
className,
|
|
34
|
+
dense,
|
|
35
|
+
disabled,
|
|
36
|
+
element: Component = "button",
|
|
37
|
+
hasIcon,
|
|
38
|
+
inline,
|
|
39
|
+
onClick,
|
|
40
|
+
small,
|
|
41
|
+
...buttonProps
|
|
42
|
+
} = _ref;
|
|
43
|
+
const classes = (0, _classnames.default)(appearance ? "p-button--".concat(appearance) : "p-button", {
|
|
46
44
|
"has-icon": hasIcon,
|
|
47
45
|
"is-dense": dense,
|
|
48
46
|
"is-disabled": Component !== "button" && disabled,
|
|
49
47
|
"is-inline": inline,
|
|
50
48
|
"is-small": small
|
|
51
49
|
}, className);
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
var disabledProp = Component === "button" ? {
|
|
56
|
-
disabled: disabled
|
|
50
|
+
const onClickDisabled = e => e.preventDefault();
|
|
51
|
+
const disabledProp = Component === "button" ? {
|
|
52
|
+
disabled
|
|
57
53
|
} : {
|
|
58
54
|
"aria-disabled": disabled
|
|
59
55
|
};
|
|
@@ -62,5 +58,4 @@ var Button = function Button(_ref) {
|
|
|
62
58
|
onClick: disabled ? onClickDisabled : onClick
|
|
63
59
|
}, disabledProp, buttonProps), children);
|
|
64
60
|
};
|
|
65
|
-
var _default = Button;
|
|
66
|
-
exports.default = _default;
|
|
61
|
+
var _default = exports.default = Button;
|
|
@@ -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, "ButtonAppearance", {
|
|
8
7
|
enumerable: true,
|
|
9
|
-
get: function
|
|
8
|
+
get: function () {
|
|
10
9
|
return _Button.ButtonAppearance;
|
|
11
10
|
}
|
|
12
11
|
});
|
|
13
12
|
Object.defineProperty(exports, "default", {
|
|
14
13
|
enumerable: true,
|
|
15
|
-
get: function
|
|
14
|
+
get: function () {
|
|
16
15
|
return _Button.default;
|
|
17
16
|
}
|
|
18
17
|
});
|
|
19
18
|
var _Button = _interopRequireWildcard(require("./Button"));
|
|
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; }
|