@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.
Files changed (152) hide show
  1. package/dist/__mocks__/nanoid.js +3 -3
  2. package/dist/components/Accordion/Accordion.js +28 -41
  3. package/dist/components/Accordion/AccordionSection/AccordionSection.js +18 -18
  4. package/dist/components/Accordion/AccordionSection/index.js +1 -1
  5. package/dist/components/Accordion/index.js +1 -1
  6. package/dist/components/ActionButton/ActionButton.js +34 -66
  7. package/dist/components/ActionButton/index.js +1 -1
  8. package/dist/components/ArticlePagination/ArticlePagination.js +10 -12
  9. package/dist/components/ArticlePagination/index.js +1 -1
  10. package/dist/components/Badge/Badge.js +24 -29
  11. package/dist/components/Badge/index.js +1 -1
  12. package/dist/components/Button/Button.js +21 -26
  13. package/dist/components/Button/index.js +4 -5
  14. package/dist/components/Card/Card.js +12 -14
  15. package/dist/components/Card/index.js +1 -1
  16. package/dist/components/CheckboxInput/CheckableInput/CheckableInput.js +15 -19
  17. package/dist/components/CheckboxInput/CheckableInput/index.js +1 -1
  18. package/dist/components/CheckboxInput/CheckboxInput.js +7 -10
  19. package/dist/components/CheckboxInput/index.js +1 -1
  20. package/dist/components/Chip/Chip.js +23 -33
  21. package/dist/components/Chip/index.js +1 -1
  22. package/dist/components/Code/Code.js +14 -17
  23. package/dist/components/Code/index.js +1 -1
  24. package/dist/components/CodeSnippet/CodeSnippet.js +9 -14
  25. package/dist/components/CodeSnippet/CodeSnippetBlock.js +24 -29
  26. package/dist/components/CodeSnippet/CodeSnippetDropdown.js +11 -11
  27. package/dist/components/CodeSnippet/index.js +2 -2
  28. package/dist/components/Col/Col.js +24 -26
  29. package/dist/components/Col/index.js +4 -5
  30. package/dist/components/ConfirmationButton/ConfirmationButton.js +18 -21
  31. package/dist/components/ConfirmationButton/index.js +1 -1
  32. package/dist/components/ConfirmationModal/ConfirmationModal.js +11 -15
  33. package/dist/components/ConfirmationModal/index.js +1 -1
  34. package/dist/components/ContextualMenu/ContextualMenu.js +89 -107
  35. package/dist/components/ContextualMenu/ContextualMenuDropdown/ContextualMenuDropdown.d.ts +4 -4
  36. package/dist/components/ContextualMenu/ContextualMenuDropdown/ContextualMenuDropdown.js +97 -107
  37. package/dist/components/ContextualMenu/ContextualMenuDropdown/index.js +1 -1
  38. package/dist/components/ContextualMenu/index.js +1 -1
  39. package/dist/components/EmptyState/EmptyState.js +9 -11
  40. package/dist/components/EmptyState/index.js +1 -1
  41. package/dist/components/Field/Field.js +66 -65
  42. package/dist/components/Field/index.js +1 -1
  43. package/dist/components/Form/Form.js +9 -11
  44. package/dist/components/Form/index.js +1 -1
  45. package/dist/components/Icon/Icon.js +9 -12
  46. package/dist/components/Icon/index.js +4 -5
  47. package/dist/components/Input/Input.js +38 -45
  48. package/dist/components/Input/index.js +1 -1
  49. package/dist/components/Label/Label.js +9 -11
  50. package/dist/components/Label/index.js +1 -1
  51. package/dist/components/Link/Link.js +12 -18
  52. package/dist/components/Link/index.js +1 -1
  53. package/dist/components/List/List.js +50 -54
  54. package/dist/components/List/index.js +1 -1
  55. package/dist/components/Loader/Loader.js +2 -3
  56. package/dist/components/Loader/index.js +1 -1
  57. package/dist/components/MainTable/MainTable.js +87 -104
  58. package/dist/components/MainTable/index.js +1 -1
  59. package/dist/components/Modal/Modal.js +37 -38
  60. package/dist/components/Modal/index.js +1 -1
  61. package/dist/components/ModularTable/ModularTable.js +63 -77
  62. package/dist/components/ModularTable/index.js +1 -1
  63. package/dist/components/Navigation/Navigation.js +63 -97
  64. package/dist/components/Navigation/NavigationLink/NavigationLink.js +32 -35
  65. package/dist/components/Navigation/NavigationLink/index.js +1 -1
  66. package/dist/components/Navigation/NavigationMenu/NavigationMenu.js +26 -45
  67. package/dist/components/Navigation/NavigationMenu/index.js +1 -1
  68. package/dist/components/Navigation/index.js +1 -1
  69. package/dist/components/Notification/Notification.js +49 -59
  70. package/dist/components/Notification/index.js +4 -5
  71. package/dist/components/NotificationProvider/NotificationProvider.js +47 -68
  72. package/dist/components/NotificationProvider/index.js +7 -7
  73. package/dist/components/NotificationProvider/messageBuilder.js +9 -9
  74. package/dist/components/NotificationProvider/types.d.ts +1 -0
  75. package/dist/components/Pagination/Pagination.js +50 -69
  76. package/dist/components/Pagination/PaginationButton/PaginationButton.js +11 -12
  77. package/dist/components/Pagination/PaginationButton/index.js +1 -1
  78. package/dist/components/Pagination/PaginationItem/PaginationItem.js +7 -7
  79. package/dist/components/Pagination/PaginationItem/index.js +1 -1
  80. package/dist/components/Pagination/index.js +1 -1
  81. package/dist/components/PasswordToggle/PasswordToggle.d.ts +1 -1
  82. package/dist/components/PasswordToggle/PasswordToggle.js +25 -40
  83. package/dist/components/PasswordToggle/index.js +1 -1
  84. package/dist/components/RadioInput/RadioInput.js +6 -8
  85. package/dist/components/RadioInput/index.js +1 -1
  86. package/dist/components/Row/Row.js +7 -9
  87. package/dist/components/Row/index.js +1 -1
  88. package/dist/components/SearchAndFilter/FilterPanelSection/FilterPanelSection.js +38 -51
  89. package/dist/components/SearchAndFilter/FilterPanelSection/index.js +1 -1
  90. package/dist/components/SearchAndFilter/SearchAndFilter.js +75 -135
  91. package/dist/components/SearchAndFilter/index.js +1 -1
  92. package/dist/components/SearchAndFilter/utils.js +4 -8
  93. package/dist/components/SearchBox/SearchBox.js +25 -33
  94. package/dist/components/SearchBox/index.js +1 -1
  95. package/dist/components/Select/Select.js +38 -44
  96. package/dist/components/Select/index.js +1 -1
  97. package/dist/components/Slider/Slider.js +27 -35
  98. package/dist/components/Slider/index.js +1 -1
  99. package/dist/components/Spinner/Spinner.js +10 -15
  100. package/dist/components/Spinner/index.js +1 -1
  101. package/dist/components/StatusLabel/StatusLabel.js +11 -13
  102. package/dist/components/StatusLabel/index.js +4 -5
  103. package/dist/components/Strip/Strip.js +27 -34
  104. package/dist/components/Strip/index.js +1 -1
  105. package/dist/components/SummaryButton/SummaryButton.js +9 -8
  106. package/dist/components/SummaryButton/index.js +1 -1
  107. package/dist/components/Switch/Switch.js +7 -10
  108. package/dist/components/Switch/index.js +1 -1
  109. package/dist/components/Table/Table.js +9 -13
  110. package/dist/components/Table/index.js +1 -1
  111. package/dist/components/TableCell/TableCell.js +11 -17
  112. package/dist/components/TableCell/index.js +1 -1
  113. package/dist/components/TableHeader/TableHeader.js +7 -9
  114. package/dist/components/TableHeader/index.js +1 -1
  115. package/dist/components/TablePagination/TablePagination.d.ts +37 -0
  116. package/dist/components/TablePagination/TablePagination.js +125 -0
  117. package/dist/components/TablePagination/TablePagination.scss +40 -0
  118. package/dist/components/TablePagination/TablePaginationControls/TablePaginationControls.d.ts +16 -0
  119. package/dist/components/TablePagination/TablePaginationControls/TablePaginationControls.js +66 -0
  120. package/dist/components/TablePagination/TablePaginationControls/index.d.ts +2 -0
  121. package/dist/components/TablePagination/TablePaginationControls/index.js +13 -0
  122. package/dist/components/TablePagination/index.d.ts +2 -0
  123. package/dist/components/TablePagination/index.js +13 -0
  124. package/dist/components/TableRow/TableRow.js +6 -8
  125. package/dist/components/TableRow/index.js +1 -1
  126. package/dist/components/Tabs/Tabs.js +17 -17
  127. package/dist/components/Tabs/index.js +1 -1
  128. package/dist/components/Textarea/Textarea.js +51 -45
  129. package/dist/components/Textarea/index.js +1 -1
  130. package/dist/components/Tooltip/Tooltip.d.ts +5 -1
  131. package/dist/components/Tooltip/Tooltip.js +76 -79
  132. package/dist/components/Tooltip/index.js +4 -5
  133. package/dist/enums.js +2 -3
  134. package/dist/hooks/index.d.ts +1 -1
  135. package/dist/hooks/index.js +16 -10
  136. package/dist/hooks/useId.js +1 -3
  137. package/dist/hooks/useListener.d.ts +2 -1
  138. package/dist/hooks/useListener.js +25 -24
  139. package/dist/hooks/useOnClickOutside.d.ts +12 -0
  140. package/dist/hooks/useOnClickOutside.js +45 -0
  141. package/dist/hooks/useOnEscapePressed.d.ts +3 -1
  142. package/dist/hooks/useOnEscapePressed.js +13 -6
  143. package/dist/hooks/usePagination.js +17 -29
  144. package/dist/hooks/usePrevious.js +4 -4
  145. package/dist/hooks/useThrottle.js +16 -25
  146. package/dist/hooks/useWindowFitment.js +30 -28
  147. package/dist/index.d.ts +3 -1
  148. package/dist/index.js +86 -74
  149. package/dist/utils.js +6 -13
  150. package/package.json +42 -35
  151. package/dist/hooks/useClickOutside.d.ts +0 -6
  152. package/dist/hooks/useClickOutside.js +0 -32
@@ -5,19 +5,17 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.default = void 0;
7
7
  var _react = _interopRequireDefault(require("react"));
8
- var _excluded = ["children", "sort"];
9
8
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
10
9
  function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
11
- function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
12
- function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
13
- var TableHeader = function TableHeader(_ref) {
14
- var children = _ref.children,
15
- sort = _ref.sort,
16
- props = _objectWithoutProperties(_ref, _excluded);
10
+ const TableHeader = _ref => {
11
+ let {
12
+ children,
13
+ sort,
14
+ ...props
15
+ } = _ref;
17
16
  return /*#__PURE__*/_react.default.createElement("th", _extends({
18
17
  role: "columnheader",
19
18
  "aria-sort": sort
20
19
  }, props), children);
21
20
  };
22
- var _default = TableHeader;
23
- exports.default = _default;
21
+ var _default = exports.default = TableHeader;
@@ -5,7 +5,7 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  Object.defineProperty(exports, "default", {
7
7
  enumerable: true,
8
- get: function get() {
8
+ get: function () {
9
9
  return _TableHeader.default;
10
10
  }
11
11
  });
@@ -0,0 +1,37 @@
1
+ import React, { HTMLAttributes, PropsWithChildren, ReactNode } from "react";
2
+ import "./TablePagination.scss";
3
+ export type Props = PropsWithChildren<{
4
+ /**
5
+ * list of data elements to be paginated. This component is un-opinionated about
6
+ * the structure of the data but it should be identical to the data structure
7
+ * reuiqred by the child table component
8
+ */
9
+ data: unknown[];
10
+ /**
11
+ * prop name of the child table component that receives paginated data.
12
+ * default value is set to @constant rows, which is the data prop for the @func MainTable component
13
+ */
14
+ dataForwardProp?: string;
15
+ /**
16
+ * the name of the item associated to each row within the table.
17
+ */
18
+ itemName?: string;
19
+ /**
20
+ * custom styling for the pagination container
21
+ */
22
+ className?: string;
23
+ /**
24
+ * custom description to be displayed by the pagination
25
+ */
26
+ description?: ReactNode;
27
+ /**
28
+ * custom per page limits express as an array of numbers.
29
+ */
30
+ pageLimits?: number[];
31
+ /**
32
+ * place the pagination component above or below the table?
33
+ */
34
+ position?: "above" | "below";
35
+ }> & HTMLAttributes<HTMLDivElement>;
36
+ declare const TablePagination: ({ data, className, itemName, description, position, dataForwardProp, pageLimits, children, ...divProps }: Props) => React.JSX.Element;
37
+ export default TablePagination;
@@ -0,0 +1,125 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+ var _react = _interopRequireWildcard(require("react"));
8
+ var _classnames = _interopRequireDefault(require("classnames"));
9
+ var _hooks = require("../../hooks");
10
+ var _Select = _interopRequireDefault(require("../Select"));
11
+ var _TablePaginationControls = _interopRequireDefault(require("./TablePaginationControls"));
12
+ require("./TablePagination.scss");
13
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
14
+ function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
15
+ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
16
+ 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); }
17
+ /**
18
+ * Determine if we are working with a small screen.
19
+ * 'small screen' in this case is relative to the width of the description div
20
+ */
21
+ const figureSmallScreen = descriptionRef => {
22
+ const descriptionElement = descriptionRef.current;
23
+ if (!descriptionElement) {
24
+ return true;
25
+ }
26
+ return descriptionElement.getBoundingClientRect().width < 230;
27
+ };
28
+
29
+ /**
30
+ * Iterate direct react child components and override the value of the prop specified by @param dataForwardProp
31
+ * for those child components.
32
+ * @param children - react node children to iterate
33
+ * @param dataForwardProp - the name of the prop from the children components to override
34
+ * @param data - actual data to be passed to the prop specified by @param dataForwardProp
35
+ */
36
+ const renderChildren = (children, dataForwardProp, data) => {
37
+ return _react.Children.map(children, child => {
38
+ return /*#__PURE__*/(0, _react.cloneElement)(child, {
39
+ [dataForwardProp]: data
40
+ });
41
+ });
42
+ };
43
+ const DEFAULT_PAGE_LIMITS = [50, 100, 200];
44
+ const generatePagingOptions = pageLimits => {
45
+ return pageLimits.map(limit => ({
46
+ value: limit,
47
+ label: "".concat(limit, "/page")
48
+ }));
49
+ };
50
+ const TablePagination = _ref => {
51
+ let {
52
+ data,
53
+ className,
54
+ itemName = "item",
55
+ description,
56
+ position = "above",
57
+ dataForwardProp = "rows",
58
+ pageLimits = DEFAULT_PAGE_LIMITS,
59
+ children,
60
+ ...divProps
61
+ } = _ref;
62
+ const descriptionRef = (0, _react.useRef)(null);
63
+ const [isSmallScreen, setSmallScreen] = (0, _react.useState)(false);
64
+ const [pageSize, setPageSize] = (0, _react.useState)(() => {
65
+ return generatePagingOptions(pageLimits)[0].value;
66
+ });
67
+ const {
68
+ paginate,
69
+ currentPage,
70
+ pageData,
71
+ totalItems
72
+ } = (0, _hooks.usePagination)(data, {
73
+ itemsPerPage: pageSize,
74
+ autoResetPage: true
75
+ });
76
+ (0, _react.useEffect)(() => {
77
+ const handleResize = () => {
78
+ setSmallScreen(figureSmallScreen(descriptionRef));
79
+ };
80
+ window.addEventListener("resize", handleResize);
81
+ return () => {
82
+ window.removeEventListener("resize", handleResize);
83
+ };
84
+ }, [isSmallScreen]);
85
+ const handlePageSizeChange = e => {
86
+ paginate(1);
87
+ setPageSize(parseInt(e.target.value));
88
+ };
89
+ const getDescription = () => {
90
+ if (description) {
91
+ return description;
92
+ }
93
+ const visibleCount = pageData.length;
94
+ if (isSmallScreen) {
95
+ return "".concat(visibleCount, " out of ").concat(totalItems);
96
+ }
97
+ if (visibleCount === totalItems && visibleCount > 1) {
98
+ return "Showing all ".concat(totalItems, " ").concat(itemName, "s");
99
+ }
100
+ return "Showing ".concat(visibleCount, " out of ").concat(totalItems, " ").concat(itemName).concat(totalItems !== 1 ? "s" : "");
101
+ };
102
+ const totalPages = Math.ceil(data.length / pageSize);
103
+ const clonedChildren = renderChildren(children, dataForwardProp, pageData);
104
+ return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, position === "below" && clonedChildren, /*#__PURE__*/_react.default.createElement("div", _extends({
105
+ className: (0, _classnames.default)("pagination", className)
106
+ }, divProps, {
107
+ role: "navigation"
108
+ }), /*#__PURE__*/_react.default.createElement("div", {
109
+ className: "description",
110
+ ref: descriptionRef
111
+ }, getDescription()), /*#__PURE__*/_react.default.createElement(_TablePaginationControls.default, {
112
+ onPageChange: paginate,
113
+ currentPage: currentPage,
114
+ totalPages: totalPages
115
+ }), /*#__PURE__*/_react.default.createElement(_Select.default, {
116
+ className: "items-per-page",
117
+ label: "Items per page",
118
+ labelClassName: "u-off-screen",
119
+ id: "itemsPerPage",
120
+ options: generatePagingOptions(pageLimits),
121
+ onChange: handlePageSizeChange,
122
+ value: pageSize
123
+ })), position === "above" && clonedChildren);
124
+ };
125
+ var _default = exports.default = TablePagination;
@@ -0,0 +1,40 @@
1
+ @import "~vanilla-framework/scss/settings";
2
+
3
+ .pagination {
4
+ align-items: baseline;
5
+ display: flex;
6
+ margin-top: 1.2rem;
7
+
8
+ .description {
9
+ flex-grow: 1;
10
+ }
11
+
12
+ .back {
13
+ margin: 0 $spv--large;
14
+
15
+ .p-icon--chevron-down {
16
+ rotate: 90deg;
17
+ }
18
+ }
19
+
20
+ .next {
21
+ margin: 0 $spv--large;
22
+
23
+ .p-icon--chevron-down {
24
+ rotate: 270deg;
25
+ }
26
+ }
27
+
28
+ .pagination-input {
29
+ margin-right: $spv--small;
30
+ min-width: 0;
31
+ width: 3rem;
32
+ }
33
+
34
+ .pagination-select {
35
+ margin-bottom: 0;
36
+ margin-left: $spv--x-large;
37
+ min-width: 0;
38
+ width: 7rem;
39
+ }
40
+ }
@@ -0,0 +1,16 @@
1
+ export type Props = {
2
+ /**
3
+ * Callback function to handle a change in page number
4
+ */
5
+ onPageChange: (pageNumber: number) => void;
6
+ /**
7
+ * The current page of the data
8
+ */
9
+ currentPage: number;
10
+ /**
11
+ * The total number of pages that exists within the data
12
+ */
13
+ totalPages: number;
14
+ };
15
+ declare const TablePaginationControls: ({ onPageChange, currentPage, totalPages, }: Props) => JSX.Element;
16
+ export default TablePaginationControls;
@@ -0,0 +1,66 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+ var _propTypes = _interopRequireDefault(require("prop-types"));
8
+ var _Button = _interopRequireDefault(require("../../Button"));
9
+ var _Icon = _interopRequireDefault(require("../../Icon"));
10
+ var _Input = _interopRequireDefault(require("../../Input"));
11
+ var _react = _interopRequireDefault(require("react"));
12
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
13
+ const TablePaginationControls = _ref => {
14
+ let {
15
+ onPageChange,
16
+ currentPage,
17
+ totalPages
18
+ } = _ref;
19
+ const handleDecrementPage = currentPage => {
20
+ if (currentPage > 1) {
21
+ onPageChange(currentPage - 1);
22
+ }
23
+ };
24
+ const handleIncrementPage = (currentPage, totalPages) => {
25
+ if (currentPage < totalPages) {
26
+ onPageChange(currentPage + 1);
27
+ }
28
+ };
29
+ const handleInputPageChange = e => {
30
+ const newPage = Math.min(totalPages, Math.max(1, parseInt(e.target.value)));
31
+ onPageChange(newPage);
32
+ };
33
+ return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_Button.default, {
34
+ "aria-label": "Previous page",
35
+ className: "back",
36
+ appearance: "base",
37
+ hasIcon: true,
38
+ disabled: currentPage === 1,
39
+ onClick: () => handleDecrementPage(currentPage)
40
+ }, /*#__PURE__*/_react.default.createElement(_Icon.default, {
41
+ name: "chevron-down"
42
+ })), /*#__PURE__*/_react.default.createElement(_Input.default, {
43
+ id: "paginationPageInput",
44
+ label: "Page number",
45
+ labelClassName: "u-off-screen",
46
+ className: "u-no-margin--bottom pagination-input",
47
+ onChange: handleInputPageChange,
48
+ value: currentPage,
49
+ type: "number"
50
+ }), " ", "of\xA0", totalPages, /*#__PURE__*/_react.default.createElement(_Button.default, {
51
+ "aria-label": "Next page",
52
+ className: "next",
53
+ appearance: "base",
54
+ hasIcon: true,
55
+ disabled: currentPage === totalPages,
56
+ onClick: () => handleIncrementPage(currentPage, totalPages)
57
+ }, /*#__PURE__*/_react.default.createElement(_Icon.default, {
58
+ name: "chevron-down"
59
+ })));
60
+ };
61
+ TablePaginationControls.propTypes = {
62
+ onPageChange: _propTypes.default.func.isRequired,
63
+ currentPage: _propTypes.default.number.isRequired,
64
+ totalPages: _propTypes.default.number.isRequired
65
+ };
66
+ var _default = exports.default = TablePaginationControls;
@@ -0,0 +1,2 @@
1
+ export { default } from "./TablePaginationControls";
2
+ export type { Props as TablePaginationControlsProps } from "./TablePaginationControls";
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ Object.defineProperty(exports, "default", {
7
+ enumerable: true,
8
+ get: function () {
9
+ return _TablePaginationControls.default;
10
+ }
11
+ });
12
+ var _TablePaginationControls = _interopRequireDefault(require("./TablePaginationControls"));
13
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
@@ -0,0 +1,2 @@
1
+ export { default } from "./TablePagination";
2
+ export type { Props as TablePaginationProps } from "./TablePagination";
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ Object.defineProperty(exports, "default", {
7
+ enumerable: true,
8
+ get: function () {
9
+ return _TablePagination.default;
10
+ }
11
+ });
12
+ var _TablePagination = _interopRequireDefault(require("./TablePagination"));
13
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
@@ -5,17 +5,15 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.default = void 0;
7
7
  var _react = _interopRequireDefault(require("react"));
8
- var _excluded = ["children"];
9
8
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
10
9
  function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
11
- function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
12
- function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
13
- var TableRow = function TableRow(_ref) {
14
- var children = _ref.children,
15
- trProps = _objectWithoutProperties(_ref, _excluded);
10
+ const TableRow = _ref => {
11
+ let {
12
+ children,
13
+ ...trProps
14
+ } = _ref;
16
15
  return /*#__PURE__*/_react.default.createElement("tr", _extends({
17
16
  role: "row"
18
17
  }, trProps), children);
19
18
  };
20
- var _default = TableRow;
21
- exports.default = _default;
19
+ var _default = exports.default = TableRow;
@@ -5,7 +5,7 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  Object.defineProperty(exports, "default", {
7
7
  enumerable: true,
8
- get: function get() {
8
+ get: function () {
9
9
  return _TableRow.default;
10
10
  }
11
11
  });
@@ -6,27 +6,28 @@ 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 = ["active", "className", "component", "label", "listItemClassName"];
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
- 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; }
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 Tabs = function Tabs(_ref) {
15
- var className = _ref.className,
16
- links = _ref.links,
17
- listClassName = _ref.listClassName;
11
+ const Tabs = _ref => {
12
+ let {
13
+ className,
14
+ links,
15
+ listClassName
16
+ } = _ref;
18
17
  return /*#__PURE__*/_react.default.createElement("nav", {
19
18
  className: (0, _classnames.default)("p-tabs", className)
20
19
  }, /*#__PURE__*/_react.default.createElement("ul", {
21
20
  className: (0, _classnames.default)("p-tabs__list", listClassName)
22
- }, links.map(function (link, i) {
23
- var active = link.active,
24
- className = link.className,
25
- component = link.component,
26
- label = link.label,
27
- listItemClassName = link.listItemClassName,
28
- rest = _objectWithoutProperties(link, _excluded);
29
- var Component = component || "a";
21
+ }, links.map((link, i) => {
22
+ const {
23
+ active,
24
+ className,
25
+ component,
26
+ label,
27
+ listItemClassName,
28
+ ...rest
29
+ } = link;
30
+ const Component = component || "a";
30
31
  return /*#__PURE__*/_react.default.createElement("li", {
31
32
  className: (0, _classnames.default)("p-tabs__item", listItemClassName),
32
33
  key: i
@@ -37,5 +38,4 @@ var Tabs = function Tabs(_ref) {
37
38
  }, rest), label));
38
39
  })));
39
40
  };
40
- var _default = Tabs;
41
- exports.default = _default;
41
+ var _default = exports.default = Tabs;
@@ -5,7 +5,7 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  Object.defineProperty(exports, "default", {
7
7
  enumerable: true,
8
- get: function get() {
8
+ get: function () {
9
9
  return _Tabs.default;
10
10
  }
11
11
  });
@@ -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
  });
@@ -9,50 +8,53 @@ var _classnames = _interopRequireDefault(require("classnames"));
9
8
  var _react = _interopRequireWildcard(require("react"));
10
9
  var _Field = _interopRequireDefault(require("../Field"));
11
10
  var _hooks = require("../../hooks");
12
- var _excluded = ["caution", "className", "error", "grow", "help", "id", "label", "labelClassName", "onKeyUp", "required", "stacked", "style", "success", "takeFocus", "wrapperClassName"];
13
- function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
14
- function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
11
+ function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
12
+ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
15
13
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
16
14
  function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
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; }
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; }
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); }
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
15
  /**
25
16
  * The props for the Textarea component.
26
17
  */
27
18
 
28
- var Textarea = function Textarea(_ref) {
29
- var caution = _ref.caution,
30
- className = _ref.className,
31
- error = _ref.error,
32
- _ref$grow = _ref.grow,
33
- grow = _ref$grow === void 0 ? false : _ref$grow,
34
- help = _ref.help,
35
- id = _ref.id,
36
- label = _ref.label,
37
- labelClassName = _ref.labelClassName,
38
- _onKeyUp = _ref.onKeyUp,
39
- required = _ref.required,
40
- stacked = _ref.stacked,
41
- style = _ref.style,
42
- success = _ref.success,
43
- _ref$takeFocus = _ref.takeFocus,
44
- takeFocus = _ref$takeFocus === void 0 ? false : _ref$takeFocus,
45
- wrapperClassName = _ref.wrapperClassName,
46
- props = _objectWithoutProperties(_ref, _excluded);
47
- var textareaRef = (0, _react.useRef)(null);
48
- var validationId = (0, _hooks.useId)();
49
- var helpId = (0, _hooks.useId)();
50
- var hasError = !!error;
51
- (0, _react.useEffect)(function () {
19
+ const Textarea = _ref => {
20
+ let {
21
+ caution,
22
+ className,
23
+ error,
24
+ grow = false,
25
+ help,
26
+ id,
27
+ label,
28
+ labelClassName,
29
+ onKeyUp,
30
+ required,
31
+ stacked,
32
+ style,
33
+ success,
34
+ takeFocus = false,
35
+ wrapperClassName,
36
+ ...props
37
+ } = _ref;
38
+ const textareaRef = (0, _react.useRef)(null);
39
+ const validationId = (0, _hooks.useId)();
40
+ const helpId = (0, _hooks.useId)();
41
+ const hasError = !!error;
42
+ const [innerValue, setInnervalue] = (0, _react.useState)(props.defaultValue);
43
+ (0, _react.useEffect)(() => {
52
44
  if (takeFocus) {
53
45
  textareaRef.current.focus();
54
46
  }
55
47
  }, [takeFocus]);
48
+ (0, _react.useLayoutEffect)(() => {
49
+ if (grow) {
50
+ const textArea = textareaRef.current;
51
+ if (textArea) {
52
+ textArea.style.height = "0px";
53
+ const scrollHeight = textArea.scrollHeight;
54
+ textArea.style.height = "".concat(scrollHeight, "px");
55
+ }
56
+ }
57
+ }, [textareaRef, grow, innerValue, props.value]);
56
58
  return /*#__PURE__*/_react.default.createElement(_Field.default, {
57
59
  caution: caution,
58
60
  className: wrapperClassName,
@@ -72,20 +74,24 @@ var Textarea = function Textarea(_ref) {
72
74
  "aria-invalid": hasError,
73
75
  className: (0, _classnames.default)("p-form-validation__input", className),
74
76
  id: id,
75
- onKeyUp: function onKeyUp(evt) {
76
- _onKeyUp && _onKeyUp(evt);
77
- if (grow) {
78
- evt.currentTarget.style.height = evt.currentTarget.scrollHeight + "px";
77
+ onKeyUp: evt => {
78
+ onKeyUp && onKeyUp(evt);
79
+ },
80
+ onChange: evt => {
81
+ if (!props.value) {
82
+ setInnervalue(evt.target.value);
79
83
  }
80
84
  },
81
85
  ref: textareaRef,
82
- style: grow && _objectSpread({
86
+ style: grow && {
83
87
  minHeight: "5rem",
84
88
  resize: "none",
85
89
  overflow: "hidden",
86
- boxSizing: "border-box"
87
- }, style) || style
88
- }, props)));
90
+ boxSizing: "border-box",
91
+ ...style
92
+ } || style
93
+ }, props, {
94
+ value: props.value || innerValue
95
+ })));
89
96
  };
90
- var _default = Textarea;
91
- exports.default = _default;
97
+ var _default = exports.default = Textarea;
@@ -5,7 +5,7 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  Object.defineProperty(exports, "default", {
7
7
  enumerable: true,
8
- get: function get() {
8
+ get: function () {
9
9
  return _Textarea.default;
10
10
  }
11
11
  });
@@ -56,6 +56,10 @@ export type Props = {
56
56
  * The z-index value of the tooltip message element.
57
57
  */
58
58
  zIndex?: number;
59
+ /**
60
+ * Delay in ms after which Tooltip will appear (defaults to 350ms).
61
+ */
62
+ delay?: number;
59
63
  };
60
64
  export declare const adjustForWindow: (position: Position, fitsWindow: WindowFitment) => Position;
61
65
  /**
@@ -70,5 +74,5 @@ export declare const adjustForWindow: (position: Position, fitsWindow: WindowFit
70
74
  * @param tooltipClassName An optional class to apply to the tooltip message element.
71
75
  * @param zIndex The z-index value of the tooltip message element.
72
76
  */
73
- declare const Tooltip: ({ autoAdjust, children, className, followMouse, message, position, positionElementClassName, tooltipClassName, zIndex, }: Props) => JSX.Element;
77
+ declare const Tooltip: ({ autoAdjust, children, className, followMouse, message, position, positionElementClassName, tooltipClassName, zIndex, delay, }: Props) => JSX.Element;
74
78
  export default Tooltip;