@canonical/react-components 0.47.0 → 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 +45 -40
- 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 +55 -74
- 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 +56 -49
- package/dist/hooks/useClickOutside.d.ts +0 -6
- package/dist/hooks/useClickOutside.js +0 -32
|
@@ -8,71 +8,60 @@ var _classnames = _interopRequireDefault(require("classnames"));
|
|
|
8
8
|
var _react = _interopRequireDefault(require("react"));
|
|
9
9
|
var _PaginationButton = _interopRequireDefault(require("./PaginationButton"));
|
|
10
10
|
var _PaginationItem = _interopRequireDefault(require("./PaginationItem"));
|
|
11
|
-
var _excluded = ["itemsPerPage", "totalItems", "paginate", "currentPage", "scrollToTop", "truncateThreshold", "centered", "showLabels", "hideNumbers", "onForward", "onBack", "forwardDisabled", "backDisabled", "forwardLabel", "backLabel"];
|
|
12
11
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
13
12
|
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
var generatePaginationItems = function generatePaginationItems(pageNumbers, currentPage, truncateThreshold, changePage) {
|
|
20
|
-
var lastPage = pageNumbers.length;
|
|
21
|
-
var truncated = lastPage > truncateThreshold;
|
|
22
|
-
var visiblePages;
|
|
13
|
+
const scrollTop = () => window.scrollTo(0, 0);
|
|
14
|
+
const generatePaginationItems = (pageNumbers, currentPage, truncateThreshold, changePage) => {
|
|
15
|
+
const lastPage = pageNumbers.length;
|
|
16
|
+
const truncated = lastPage > truncateThreshold;
|
|
17
|
+
let visiblePages;
|
|
23
18
|
if (truncated) {
|
|
24
19
|
// the default range for pages outside the start and end threshold
|
|
25
|
-
|
|
26
|
-
|
|
20
|
+
let start = currentPage - 2;
|
|
21
|
+
let end = currentPage + 1;
|
|
27
22
|
// on page 1, also show pages 2, 3 and 4
|
|
28
23
|
if (currentPage === 1) {
|
|
29
24
|
start = 1;
|
|
30
|
-
end = currentPage + 3;
|
|
25
|
+
end = Math.min(lastPage - 1, currentPage + 3);
|
|
31
26
|
}
|
|
32
27
|
// on page 2, show page 1, and also pages 3, and 4
|
|
33
28
|
if (currentPage === 2) {
|
|
34
29
|
start = 1;
|
|
35
|
-
end = currentPage +
|
|
30
|
+
end = Math.min(lastPage - 1, currentPage + 3);
|
|
36
31
|
}
|
|
37
32
|
// on the last page and page before last, also show the 3 previous pages
|
|
38
33
|
if (currentPage === lastPage || currentPage === lastPage - 1) {
|
|
39
|
-
start = lastPage - 4;
|
|
34
|
+
start = Math.max(1, lastPage - 4);
|
|
40
35
|
end = lastPage - 1;
|
|
41
36
|
}
|
|
42
37
|
visiblePages = pageNumbers.slice(start, end);
|
|
43
38
|
} else {
|
|
44
39
|
visiblePages = pageNumbers;
|
|
45
40
|
}
|
|
46
|
-
|
|
41
|
+
const items = [];
|
|
47
42
|
if (truncated) {
|
|
48
43
|
// render first in sequence
|
|
49
44
|
items.push( /*#__PURE__*/_react.default.createElement(_PaginationItem.default, {
|
|
50
45
|
key: 1,
|
|
51
46
|
number: 1,
|
|
52
47
|
isActive: currentPage === 1,
|
|
53
|
-
onClick:
|
|
54
|
-
return changePage(1);
|
|
55
|
-
}
|
|
48
|
+
onClick: () => changePage(1)
|
|
56
49
|
}));
|
|
57
|
-
if (!
|
|
50
|
+
if (!visiblePages.includes(2)) {
|
|
58
51
|
items.push( /*#__PURE__*/_react.default.createElement(PaginationItemSeparator, {
|
|
59
52
|
key: "sep1"
|
|
60
53
|
}));
|
|
61
54
|
}
|
|
62
55
|
}
|
|
63
|
-
items.push(visiblePages.map(
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
return changePage(number);
|
|
70
|
-
}
|
|
71
|
-
});
|
|
72
|
-
}));
|
|
56
|
+
items.push(visiblePages.map(number => /*#__PURE__*/_react.default.createElement(_PaginationItem.default, {
|
|
57
|
+
key: number,
|
|
58
|
+
number: number,
|
|
59
|
+
isActive: number === currentPage,
|
|
60
|
+
onClick: () => changePage(number)
|
|
61
|
+
})));
|
|
73
62
|
if (truncated) {
|
|
74
63
|
// render last in sequence
|
|
75
|
-
if (!
|
|
64
|
+
if (!visiblePages.includes(lastPage - 1)) {
|
|
76
65
|
items.push( /*#__PURE__*/_react.default.createElement(PaginationItemSeparator, {
|
|
77
66
|
key: "sep2"
|
|
78
67
|
}));
|
|
@@ -81,18 +70,14 @@ var generatePaginationItems = function generatePaginationItems(pageNumbers, curr
|
|
|
81
70
|
key: lastPage,
|
|
82
71
|
number: lastPage,
|
|
83
72
|
isActive: currentPage === lastPage,
|
|
84
|
-
onClick:
|
|
85
|
-
return changePage(lastPage);
|
|
86
|
-
}
|
|
73
|
+
onClick: () => changePage(lastPage)
|
|
87
74
|
}));
|
|
88
75
|
}
|
|
89
76
|
return items;
|
|
90
77
|
};
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
}, "\u2026");
|
|
95
|
-
};
|
|
78
|
+
const PaginationItemSeparator = () => /*#__PURE__*/_react.default.createElement("li", {
|
|
79
|
+
className: "p-pagination__item p-pagination__item--truncation"
|
|
80
|
+
}, "\u2026");
|
|
96
81
|
|
|
97
82
|
// Props that are used in both types of paginations.
|
|
98
83
|
|
|
@@ -103,51 +88,52 @@ var PaginationItemSeparator = function PaginationItemSeparator() {
|
|
|
103
88
|
// Used when number of items per page, number of total items,
|
|
104
89
|
// current page and paginate function are undefined.
|
|
105
90
|
// Pagination is handled by onForward and onBack function.
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
truncateThreshold =
|
|
114
|
-
centered
|
|
115
|
-
showLabels
|
|
116
|
-
hideNumbers
|
|
117
|
-
onForward
|
|
118
|
-
onBack
|
|
119
|
-
forwardDisabled
|
|
120
|
-
backDisabled
|
|
121
|
-
forwardLabel
|
|
122
|
-
backLabel
|
|
123
|
-
navProps
|
|
124
|
-
|
|
125
|
-
|
|
91
|
+
const Pagination = _ref => {
|
|
92
|
+
let {
|
|
93
|
+
itemsPerPage,
|
|
94
|
+
totalItems,
|
|
95
|
+
paginate,
|
|
96
|
+
currentPage,
|
|
97
|
+
scrollToTop,
|
|
98
|
+
truncateThreshold = 10,
|
|
99
|
+
centered,
|
|
100
|
+
showLabels,
|
|
101
|
+
hideNumbers,
|
|
102
|
+
onForward,
|
|
103
|
+
onBack,
|
|
104
|
+
forwardDisabled,
|
|
105
|
+
backDisabled,
|
|
106
|
+
forwardLabel,
|
|
107
|
+
backLabel,
|
|
108
|
+
...navProps
|
|
109
|
+
} = _ref;
|
|
110
|
+
const isNumberedPagination = !!itemsPerPage && !!totalItems && !!currentPage && !!paginate;
|
|
111
|
+
const pageNumbers = [];
|
|
126
112
|
if (isNumberedPagination) {
|
|
127
113
|
// return early if no pagination is required
|
|
128
114
|
if (totalItems <= itemsPerPage) {
|
|
129
115
|
return null;
|
|
130
116
|
}
|
|
131
|
-
for (
|
|
117
|
+
for (let i = 1; i <= Math.ceil(totalItems / itemsPerPage); i++) {
|
|
132
118
|
pageNumbers.push(i);
|
|
133
119
|
}
|
|
134
120
|
}
|
|
135
|
-
|
|
121
|
+
const changeNumberedPage = page => {
|
|
136
122
|
paginate(page);
|
|
137
123
|
if (page > currentPage) {
|
|
138
|
-
onForward === null || onForward === void 0
|
|
124
|
+
onForward === null || onForward === void 0 || onForward(page);
|
|
139
125
|
}
|
|
140
126
|
if (page < currentPage) {
|
|
141
|
-
onBack === null || onBack === void 0
|
|
127
|
+
onBack === null || onBack === void 0 || onBack(page);
|
|
142
128
|
}
|
|
143
129
|
scrollToTop && scrollTop();
|
|
144
130
|
};
|
|
145
|
-
|
|
131
|
+
const changeButtonsOnlyPage = direction => {
|
|
146
132
|
if (direction === "forward") {
|
|
147
|
-
onForward === null || onForward === void 0
|
|
133
|
+
onForward === null || onForward === void 0 || onForward(undefined);
|
|
148
134
|
}
|
|
149
135
|
if (direction === "back") {
|
|
150
|
-
onBack === null || onBack === void 0
|
|
136
|
+
onBack === null || onBack === void 0 || onBack(undefined);
|
|
151
137
|
}
|
|
152
138
|
scrollToTop && scrollTop();
|
|
153
139
|
};
|
|
@@ -162,21 +148,16 @@ var Pagination = function Pagination(_ref) {
|
|
|
162
148
|
key: "back",
|
|
163
149
|
direction: "back",
|
|
164
150
|
disabled: backDisabled || currentPage === 1,
|
|
165
|
-
onClick:
|
|
166
|
-
return isNumberedPagination ? changeNumberedPage(currentPage - 1) : changeButtonsOnlyPage("back");
|
|
167
|
-
},
|
|
151
|
+
onClick: () => isNumberedPagination ? changeNumberedPage(currentPage - 1) : changeButtonsOnlyPage("back"),
|
|
168
152
|
showLabel: showLabels,
|
|
169
153
|
label: backLabel
|
|
170
154
|
}), isNumberedPagination && !hideNumbers ? generatePaginationItems(pageNumbers, currentPage, truncateThreshold, changeNumberedPage) : null, /*#__PURE__*/_react.default.createElement(_PaginationButton.default, {
|
|
171
155
|
key: "forward",
|
|
172
156
|
direction: "forward",
|
|
173
157
|
disabled: forwardDisabled || currentPage === pageNumbers.length,
|
|
174
|
-
onClick:
|
|
175
|
-
return isNumberedPagination ? changeNumberedPage(currentPage + 1) : changeButtonsOnlyPage("forward");
|
|
176
|
-
},
|
|
158
|
+
onClick: () => isNumberedPagination ? changeNumberedPage(currentPage + 1) : changeButtonsOnlyPage("forward"),
|
|
177
159
|
showLabel: showLabels,
|
|
178
160
|
label: forwardLabel
|
|
179
161
|
})));
|
|
180
162
|
};
|
|
181
|
-
var _default = Pagination;
|
|
182
|
-
exports.default = _default;
|
|
163
|
+
var _default = exports.default = Pagination;
|
|
@@ -7,20 +7,20 @@ exports.default = exports.Label = void 0;
|
|
|
7
7
|
var _classnames = _interopRequireDefault(require("classnames"));
|
|
8
8
|
var _react = _interopRequireDefault(require("react"));
|
|
9
9
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
10
|
-
|
|
10
|
+
let Label = exports.Label = /*#__PURE__*/function (Label) {
|
|
11
11
|
Label["Next"] = "Next page";
|
|
12
12
|
Label["Previous"] = "Previous page";
|
|
13
13
|
return Label;
|
|
14
14
|
}({});
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
onClick
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
15
|
+
const PaginationButton = _ref => {
|
|
16
|
+
let {
|
|
17
|
+
direction,
|
|
18
|
+
onClick,
|
|
19
|
+
disabled = false,
|
|
20
|
+
showLabel,
|
|
21
|
+
label
|
|
22
|
+
} = _ref;
|
|
23
|
+
const buttonLabel = label || (direction === "back" ? Label.Previous : Label.Next);
|
|
24
24
|
return /*#__PURE__*/_react.default.createElement("li", {
|
|
25
25
|
className: "p-pagination__item"
|
|
26
26
|
}, /*#__PURE__*/_react.default.createElement("button", {
|
|
@@ -35,5 +35,4 @@ var PaginationButton = function PaginationButton(_ref) {
|
|
|
35
35
|
className: "p-icon--chevron-down"
|
|
36
36
|
}, buttonLabel), direction === "back" && showLabel && /*#__PURE__*/_react.default.createElement("span", null, buttonLabel)));
|
|
37
37
|
};
|
|
38
|
-
var _default = PaginationButton;
|
|
39
|
-
exports.default = _default;
|
|
38
|
+
var _default = exports.default = PaginationButton;
|
|
@@ -7,11 +7,12 @@ exports.default = void 0;
|
|
|
7
7
|
var _classnames = _interopRequireDefault(require("classnames"));
|
|
8
8
|
var _react = _interopRequireDefault(require("react"));
|
|
9
9
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
isActive =
|
|
10
|
+
const PaginationItem = _ref => {
|
|
11
|
+
let {
|
|
12
|
+
number,
|
|
13
|
+
onClick,
|
|
14
|
+
isActive = false
|
|
15
|
+
} = _ref;
|
|
15
16
|
return /*#__PURE__*/_react.default.createElement("li", {
|
|
16
17
|
className: "p-pagination__item"
|
|
17
18
|
}, /*#__PURE__*/_react.default.createElement("button", {
|
|
@@ -23,5 +24,4 @@ var PaginationItem = function PaginationItem(_ref) {
|
|
|
23
24
|
type: "button"
|
|
24
25
|
}, number));
|
|
25
26
|
};
|
|
26
|
-
var _default = PaginationItem;
|
|
27
|
-
exports.default = _default;
|
|
27
|
+
var _default = exports.default = PaginationItem;
|
|
@@ -99,5 +99,5 @@ declare const PasswordToggle: React.ForwardRefExoticComponent<{
|
|
|
99
99
|
* Optional class(es) to pass to the wrapping Field component
|
|
100
100
|
*/
|
|
101
101
|
wrapperClassName?: string;
|
|
102
|
-
} & Omit<React.InputHTMLAttributes<HTMLInputElement>, "
|
|
102
|
+
} & Omit<React.InputHTMLAttributes<HTMLInputElement>, "className" | "error" | "label" | "id" | "type" | "readOnly" | "required" | "help" | "success" | "caution" | "wrapperClassName"> & React.RefAttributes<HTMLInputElement>>;
|
|
103
103
|
export default PasswordToggle;
|
|
@@ -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
|
});
|
|
@@ -11,20 +10,11 @@ var _Button = _interopRequireDefault(require("../Button"));
|
|
|
11
10
|
var _Field = _interopRequireDefault(require("../Field"));
|
|
12
11
|
var _Label = _interopRequireDefault(require("../Label"));
|
|
13
12
|
var _hooks = require("../../hooks");
|
|
14
|
-
|
|
15
|
-
function
|
|
16
|
-
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; }
|
|
13
|
+
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); }
|
|
14
|
+
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; }
|
|
17
15
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
18
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); }
|
|
19
|
-
|
|
20
|
-
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."); }
|
|
21
|
-
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); }
|
|
22
|
-
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; }
|
|
23
|
-
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; } }
|
|
24
|
-
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
25
|
-
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; }
|
|
26
|
-
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; }
|
|
27
|
-
var Label = /*#__PURE__*/function (Label) {
|
|
17
|
+
let Label = exports.Label = /*#__PURE__*/function (Label) {
|
|
28
18
|
Label["Hide"] = "Hide";
|
|
29
19
|
Label["Show"] = "Show";
|
|
30
20
|
return Label;
|
|
@@ -32,28 +22,26 @@ var Label = /*#__PURE__*/function (Label) {
|
|
|
32
22
|
/**
|
|
33
23
|
* The props for the Password Toggle component.
|
|
34
24
|
*/
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
className
|
|
39
|
-
error
|
|
40
|
-
help
|
|
41
|
-
id
|
|
42
|
-
label
|
|
43
|
-
readOnly
|
|
44
|
-
required
|
|
45
|
-
success
|
|
46
|
-
type
|
|
47
|
-
wrapperClassName
|
|
48
|
-
inputProps
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
var hasError = !!error;
|
|
56
|
-
var togglePassword = function togglePassword() {
|
|
25
|
+
const PasswordToggle = /*#__PURE__*/_react.default.forwardRef((_ref, ref) => {
|
|
26
|
+
let {
|
|
27
|
+
caution,
|
|
28
|
+
className,
|
|
29
|
+
error,
|
|
30
|
+
help,
|
|
31
|
+
id,
|
|
32
|
+
label,
|
|
33
|
+
readOnly,
|
|
34
|
+
required,
|
|
35
|
+
success,
|
|
36
|
+
type,
|
|
37
|
+
wrapperClassName,
|
|
38
|
+
...inputProps
|
|
39
|
+
} = _ref;
|
|
40
|
+
const [isPassword, setIsPassword] = (0, _react.useState)(true);
|
|
41
|
+
const validationId = (0, _hooks.useId)();
|
|
42
|
+
const helpId = (0, _hooks.useId)();
|
|
43
|
+
const hasError = !!error;
|
|
44
|
+
const togglePassword = () => {
|
|
57
45
|
if (isPassword) {
|
|
58
46
|
setIsPassword(false);
|
|
59
47
|
} else {
|
|
@@ -81,9 +69,7 @@ var PasswordToggle = /*#__PURE__*/_react.default.forwardRef(function (_ref, ref)
|
|
|
81
69
|
hasIcon: true,
|
|
82
70
|
"aria-controls": id,
|
|
83
71
|
"aria-live": "polite",
|
|
84
|
-
onClick:
|
|
85
|
-
return togglePassword();
|
|
86
|
-
}
|
|
72
|
+
onClick: () => togglePassword()
|
|
87
73
|
}, /*#__PURE__*/_react.default.createElement("span", {
|
|
88
74
|
className: "p-form-password-toggle__label"
|
|
89
75
|
}, isPassword ? Label.Show : Label.Hide), /*#__PURE__*/_react.default.createElement("i", {
|
|
@@ -99,5 +85,4 @@ var PasswordToggle = /*#__PURE__*/_react.default.forwardRef(function (_ref, ref)
|
|
|
99
85
|
type: isPassword ? "password" : "text"
|
|
100
86
|
}, inputProps)));
|
|
101
87
|
});
|
|
102
|
-
var _default = PasswordToggle;
|
|
103
|
-
exports.default = _default;
|
|
88
|
+
var _default = exports.default = PasswordToggle;
|
|
@@ -6,18 +6,16 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.default = void 0;
|
|
7
7
|
var _react = _interopRequireDefault(require("react"));
|
|
8
8
|
var _CheckableInput = _interopRequireDefault(require("../CheckboxInput/CheckableInput"));
|
|
9
|
-
var _excluded = ["label"];
|
|
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
|
-
|
|
11
|
+
const RadioInput = _ref => {
|
|
12
|
+
let {
|
|
13
|
+
label,
|
|
14
|
+
...radioProps
|
|
15
|
+
} = _ref;
|
|
17
16
|
return /*#__PURE__*/_react.default.createElement(_CheckableInput.default, _extends({
|
|
18
17
|
inputType: "radio",
|
|
19
18
|
label: label
|
|
20
19
|
}, radioProps));
|
|
21
20
|
};
|
|
22
|
-
var _default = RadioInput;
|
|
23
|
-
exports.default = _default;
|
|
21
|
+
var _default = exports.default = RadioInput;
|
|
@@ -6,18 +6,16 @@ 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 = ["children", "className"];
|
|
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
|
-
|
|
11
|
+
const Row = _ref => {
|
|
12
|
+
let {
|
|
13
|
+
children,
|
|
14
|
+
className,
|
|
15
|
+
...props
|
|
16
|
+
} = _ref;
|
|
18
17
|
return /*#__PURE__*/_react.default.createElement("div", _extends({
|
|
19
18
|
className: (0, _classnames.default)(className, "row")
|
|
20
19
|
}, props), children);
|
|
21
20
|
};
|
|
22
|
-
var _default = Row;
|
|
23
|
-
exports.default = _default;
|
|
21
|
+
var _default = exports.default = Row;
|