@canonical/react-components 0.41.0 → 0.43.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/__mocks__/nanoid.js +0 -2
- package/dist/components/Accordion/Accordion.js +13 -37
- package/dist/components/Accordion/AccordionSection/AccordionSection.js +8 -14
- package/dist/components/Accordion/AccordionSection/index.js +0 -2
- package/dist/components/Accordion/index.js +0 -2
- package/dist/components/ActionButton/ActionButton.js +36 -65
- package/dist/components/ActionButton/index.js +0 -2
- package/dist/components/ArticlePagination/ArticlePagination.js +5 -15
- package/dist/components/ArticlePagination/index.js +0 -2
- package/dist/components/Badge/Badge.js +10 -28
- package/dist/components/Badge/index.js +0 -2
- package/dist/components/Button/Button.js +12 -25
- package/dist/components/Button/index.js +0 -4
- package/dist/components/Card/Card.js +7 -18
- package/dist/components/Card/index.js +0 -2
- package/dist/components/CheckboxInput/CheckableInput/CheckableInput.js +6 -20
- package/dist/components/CheckboxInput/CheckableInput/index.js +0 -2
- package/dist/components/CheckboxInput/CheckboxInput.js +3 -13
- package/dist/components/CheckboxInput/index.js +0 -2
- package/dist/components/Chip/Chip.js +14 -30
- package/dist/components/Chip/index.js +0 -2
- package/dist/components/Code/Code.js +5 -23
- package/dist/components/Code/index.js +0 -2
- package/dist/components/CodeSnippet/CodeSnippet.js +2 -12
- package/dist/components/CodeSnippet/CodeSnippetBlock.js +10 -18
- package/dist/components/CodeSnippet/CodeSnippetDropdown.js +5 -14
- package/dist/components/CodeSnippet/index.js +0 -3
- package/dist/components/Col/Col.js +15 -25
- package/dist/components/Col/index.js +0 -4
- package/dist/components/ConfirmationButton/ConfirmationButton.d.ts +25 -0
- package/dist/components/ConfirmationButton/ConfirmationButton.js +59 -0
- package/dist/components/ConfirmationButton/index.d.ts +2 -0
- package/dist/components/ConfirmationButton/index.js +13 -0
- package/dist/components/ConfirmationModal/ConfirmationModal.d.ts +33 -0
- package/dist/components/ConfirmationModal/ConfirmationModal.js +38 -0
- package/dist/components/ConfirmationModal/index.d.ts +2 -0
- package/dist/components/ConfirmationModal/index.js +13 -0
- package/dist/components/ContextualMenu/ContextualMenu.d.ts +3 -3
- package/dist/components/ContextualMenu/ContextualMenu.js +66 -101
- package/dist/components/ContextualMenu/ContextualMenuDropdown/ContextualMenuDropdown.d.ts +2 -1
- package/dist/components/ContextualMenu/ContextualMenuDropdown/ContextualMenuDropdown.js +48 -85
- package/dist/components/ContextualMenu/ContextualMenuDropdown/index.js +0 -2
- package/dist/components/ContextualMenu/index.js +0 -2
- package/dist/components/EmptyState/EmptyState.d.ts +22 -0
- package/dist/components/EmptyState/EmptyState.js +27 -0
- package/dist/components/EmptyState/index.d.ts +2 -0
- package/dist/components/EmptyState/index.js +13 -0
- package/dist/components/Field/Field.js +35 -51
- package/dist/components/Field/index.js +0 -2
- package/dist/components/Form/Form.js +4 -14
- package/dist/components/Form/index.js +0 -2
- package/dist/components/Icon/Icon.js +3 -14
- package/dist/components/Icon/Icon.stories.scss +1 -0
- package/dist/components/Icon/index.js +0 -4
- package/dist/components/Input/Input.js +21 -39
- package/dist/components/Input/index.js +0 -2
- package/dist/components/Label/Label.js +7 -13
- package/dist/components/Label/index.js +0 -2
- package/dist/components/Link/Link.js +10 -22
- package/dist/components/Link/index.js +0 -2
- package/dist/components/List/List.d.ts +5 -5
- package/dist/components/List/List.js +17 -32
- package/dist/components/List/index.js +0 -2
- package/dist/components/Loader/Loader.js +0 -7
- package/dist/components/Loader/index.js +0 -2
- package/dist/components/MainTable/MainTable.js +59 -111
- package/dist/components/MainTable/index.js +0 -2
- package/dist/components/Modal/Modal.js +7 -34
- package/dist/components/Modal/index.js +0 -2
- package/dist/components/ModularTable/ModularTable.d.ts +9 -1
- package/dist/components/ModularTable/ModularTable.js +39 -46
- package/dist/components/ModularTable/index.js +0 -2
- package/dist/components/Navigation/Navigation.js +46 -82
- package/dist/components/Navigation/NavigationLink/NavigationLink.js +15 -30
- package/dist/components/Navigation/NavigationLink/index.js +0 -2
- package/dist/components/Navigation/NavigationMenu/NavigationMenu.js +12 -35
- package/dist/components/Navigation/NavigationMenu/index.js +0 -2
- package/dist/components/Navigation/index.js +0 -2
- package/dist/components/Notification/Notification.d.ts +6 -0
- package/dist/components/Notification/Notification.js +29 -42
- package/dist/components/Notification/index.js +0 -4
- package/dist/components/NotificationProvider/NotificationProvider.d.ts +5 -0
- package/dist/components/NotificationProvider/NotificationProvider.js +119 -0
- package/dist/components/NotificationProvider/index.d.ts +3 -0
- package/dist/components/NotificationProvider/index.js +49 -0
- package/dist/components/NotificationProvider/messageBuilder.d.ts +6 -0
- package/dist/components/NotificationProvider/messageBuilder.js +41 -0
- package/dist/components/NotificationProvider/types.d.ts +30 -0
- package/dist/components/NotificationProvider/types.js +5 -0
- package/dist/components/Pagination/Pagination.js +14 -44
- package/dist/components/Pagination/PaginationButton/PaginationButton.js +3 -10
- package/dist/components/Pagination/PaginationButton/index.js +0 -2
- package/dist/components/Pagination/PaginationItem/PaginationItem.js +3 -8
- package/dist/components/Pagination/PaginationItem/index.js +0 -2
- package/dist/components/Pagination/index.js +0 -2
- package/dist/components/PasswordToggle/PasswordToggle.js +16 -45
- package/dist/components/PasswordToggle/index.js +0 -2
- package/dist/components/RadioInput/RadioInput.js +1 -11
- package/dist/components/RadioInput/index.js +0 -2
- package/dist/components/Row/Row.js +2 -12
- package/dist/components/Row/index.js +0 -2
- package/dist/components/SearchAndFilter/FilterPanelSection/FilterPanelSection.js +27 -49
- package/dist/components/SearchAndFilter/FilterPanelSection/index.js +0 -2
- package/dist/components/SearchAndFilter/SearchAndFilter.d.ts +9 -1
- package/dist/components/SearchAndFilter/SearchAndFilter.js +68 -104
- package/dist/components/SearchAndFilter/index.js +0 -2
- package/dist/components/SearchAndFilter/utils.js +1 -7
- package/dist/components/SearchBox/SearchBox.js +14 -34
- package/dist/components/SearchBox/index.js +0 -2
- package/dist/components/Select/Select.js +20 -33
- package/dist/components/Select/index.js +0 -2
- package/dist/components/Slider/Slider.js +16 -32
- package/dist/components/Slider/index.js +0 -2
- package/dist/components/Spinner/Spinner.js +8 -19
- package/dist/components/Spinner/index.js +0 -2
- package/dist/components/StatusLabel/StatusLabel.js +4 -15
- package/dist/components/StatusLabel/index.js +0 -4
- package/dist/components/Strip/Strip.js +25 -36
- package/dist/components/Strip/index.js +0 -2
- package/dist/components/SummaryButton/SummaryButton.js +4 -10
- package/dist/components/SummaryButton/index.js +0 -2
- package/dist/components/Switch/Switch.js +3 -12
- package/dist/components/Switch/index.js +0 -2
- package/dist/components/Table/Table.js +6 -16
- package/dist/components/Table/index.js +0 -2
- package/dist/components/TableCell/TableCell.js +10 -20
- package/dist/components/TableCell/index.js +0 -2
- package/dist/components/TableHeader/TableHeader.js +2 -11
- package/dist/components/TableHeader/index.js +0 -2
- package/dist/components/TableRow/TableRow.js +1 -10
- package/dist/components/TableRow/index.js +0 -2
- package/dist/components/Tabs/Tabs.js +7 -17
- package/dist/components/Tabs/index.js +0 -2
- package/dist/components/Textarea/Textarea.js +23 -36
- package/dist/components/Textarea/index.js +0 -2
- package/dist/components/Tooltip/Tooltip.js +38 -88
- package/dist/components/Tooltip/index.js +0 -4
- package/dist/enums.js +0 -2
- package/dist/hooks/index.js +0 -8
- package/dist/hooks/useClickOutside.js +2 -7
- package/dist/hooks/useId.js +0 -4
- package/dist/hooks/useListener.js +0 -8
- package/dist/hooks/useOnEscapePressed.js +0 -3
- package/dist/hooks/usePagination.js +13 -25
- package/dist/hooks/usePrevious.js +0 -3
- package/dist/hooks/useThrottle.js +1 -15
- package/dist/hooks/useWindowFitment.js +6 -13
- package/dist/index.d.ts +8 -0
- package/dist/index.js +64 -52
- package/dist/utils.js +3 -10
- package/package.json +31 -28
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
4
|
-
|
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
|
6
5
|
value: true
|
|
7
6
|
});
|
|
@@ -17,9 +16,6 @@ Object.defineProperty(exports, "default", {
|
|
|
17
16
|
return _Notification.default;
|
|
18
17
|
}
|
|
19
18
|
});
|
|
20
|
-
|
|
21
19
|
var _Notification = _interopRequireWildcard(require("./Notification"));
|
|
22
|
-
|
|
23
20
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
24
|
-
|
|
25
21
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { FC } from "react";
|
|
2
|
+
import { NotificationHelper, NotifyProviderProps } from "./types";
|
|
3
|
+
export declare const NotificationProvider: FC<NotifyProviderProps>;
|
|
4
|
+
export declare function useNotify(): NotificationHelper;
|
|
5
|
+
export declare const NotificationConsumer: FC;
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
"use strict";
|
|
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
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.NotificationProvider = exports.NotificationConsumer = void 0;
|
|
8
|
+
exports.useNotify = useNotify;
|
|
9
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
10
|
+
var _reactRouterDom = require("react-router-dom");
|
|
11
|
+
var _isEqual = _interopRequireDefault(require("lodash/isEqual"));
|
|
12
|
+
var _messageBuilder = require("./messageBuilder");
|
|
13
|
+
var _Notification = _interopRequireWildcard(require("../Notification/Notification"));
|
|
14
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
15
|
+
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); }
|
|
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; }
|
|
17
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
18
|
+
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."); }
|
|
19
|
+
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); }
|
|
20
|
+
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; }
|
|
21
|
+
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; } }
|
|
22
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
23
|
+
var NotifyContext = /*#__PURE__*/(0, _react.createContext)({
|
|
24
|
+
notification: null,
|
|
25
|
+
clear: function clear() {
|
|
26
|
+
return undefined;
|
|
27
|
+
},
|
|
28
|
+
failure: function failure() {
|
|
29
|
+
return undefined;
|
|
30
|
+
},
|
|
31
|
+
success: function success() {
|
|
32
|
+
return undefined;
|
|
33
|
+
},
|
|
34
|
+
info: function info() {
|
|
35
|
+
return undefined;
|
|
36
|
+
},
|
|
37
|
+
queue: function queue() {
|
|
38
|
+
return undefined;
|
|
39
|
+
}
|
|
40
|
+
});
|
|
41
|
+
var NotificationProvider = function NotificationProvider(_ref) {
|
|
42
|
+
var children = _ref.children;
|
|
43
|
+
var _useState = (0, _react.useState)(null),
|
|
44
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
45
|
+
notification = _useState2[0],
|
|
46
|
+
setNotification = _useState2[1];
|
|
47
|
+
var _ref2 = (0, _reactRouterDom.useLocation)(),
|
|
48
|
+
state = _ref2.state,
|
|
49
|
+
pathname = _ref2.pathname;
|
|
50
|
+
var clear = function clear() {
|
|
51
|
+
return notification !== null && setNotification(null);
|
|
52
|
+
};
|
|
53
|
+
var setDeduplicated = function setDeduplicated(value) {
|
|
54
|
+
if (!(0, _isEqual.default)(value, notification)) {
|
|
55
|
+
setNotification(value);
|
|
56
|
+
}
|
|
57
|
+
return value;
|
|
58
|
+
};
|
|
59
|
+
(0, _react.useEffect)(function () {
|
|
60
|
+
if (state !== null && state !== void 0 && state.queuedNotification) {
|
|
61
|
+
setDeduplicated(state.queuedNotification);
|
|
62
|
+
window.history.replaceState({}, "");
|
|
63
|
+
} else {
|
|
64
|
+
clear();
|
|
65
|
+
}
|
|
66
|
+
}, [state, pathname]);
|
|
67
|
+
var helper = {
|
|
68
|
+
notification: notification,
|
|
69
|
+
clear: clear,
|
|
70
|
+
queue: _messageBuilder.queue,
|
|
71
|
+
failure: function failure(title, error, message, actions) {
|
|
72
|
+
return setDeduplicated((0, _messageBuilder.failure)(title, error, message, actions));
|
|
73
|
+
},
|
|
74
|
+
info: function info(message, title) {
|
|
75
|
+
return setDeduplicated((0, _messageBuilder.info)(message, title));
|
|
76
|
+
},
|
|
77
|
+
success: function success(message) {
|
|
78
|
+
return setDeduplicated((0, _messageBuilder.success)(message));
|
|
79
|
+
}
|
|
80
|
+
};
|
|
81
|
+
return /*#__PURE__*/_react.default.createElement(NotifyContext.Provider, {
|
|
82
|
+
value: helper
|
|
83
|
+
}, children);
|
|
84
|
+
};
|
|
85
|
+
exports.NotificationProvider = NotificationProvider;
|
|
86
|
+
function useNotify() {
|
|
87
|
+
return (0, _react.useContext)(NotifyContext);
|
|
88
|
+
}
|
|
89
|
+
var NotificationConsumer = function NotificationConsumer() {
|
|
90
|
+
var notify = useNotify();
|
|
91
|
+
var ref = (0, _react.useRef)(null);
|
|
92
|
+
(0, _react.useEffect)(function () {
|
|
93
|
+
var _ref$current;
|
|
94
|
+
if ((_ref$current = ref.current) !== null && _ref$current !== void 0 && _ref$current.hasAttribute("scrollIntoView")) {
|
|
95
|
+
ref.current.scrollIntoView({
|
|
96
|
+
behavior: "smooth",
|
|
97
|
+
block: "center",
|
|
98
|
+
inline: "start"
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
}, [notify.notification]);
|
|
102
|
+
if (!notify.notification) {
|
|
103
|
+
return null;
|
|
104
|
+
}
|
|
105
|
+
var _notify$notification = notify.notification,
|
|
106
|
+
actions = _notify$notification.actions,
|
|
107
|
+
title = _notify$notification.title,
|
|
108
|
+
type = _notify$notification.type,
|
|
109
|
+
message = _notify$notification.message;
|
|
110
|
+
return /*#__PURE__*/_react.default.createElement("div", {
|
|
111
|
+
ref: ref
|
|
112
|
+
}, /*#__PURE__*/_react.default.createElement(_Notification.default, {
|
|
113
|
+
title: title !== null && title !== void 0 ? title : _Notification.DefaultTitles[type],
|
|
114
|
+
actions: actions,
|
|
115
|
+
severity: type,
|
|
116
|
+
onDismiss: notify.clear
|
|
117
|
+
}, message));
|
|
118
|
+
};
|
|
119
|
+
exports.NotificationConsumer = NotificationConsumer;
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
export { NotificationConsumer, NotificationProvider, useNotify, } from "./NotificationProvider";
|
|
2
|
+
export { info, success, failure, queue } from "./messageBuilder";
|
|
3
|
+
export type { NotificationAction, NotificationType, QueuedNotification, NotificationHelper, } from "./types";
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
Object.defineProperty(exports, "NotificationConsumer", {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: function get() {
|
|
9
|
+
return _NotificationProvider.NotificationConsumer;
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
Object.defineProperty(exports, "NotificationProvider", {
|
|
13
|
+
enumerable: true,
|
|
14
|
+
get: function get() {
|
|
15
|
+
return _NotificationProvider.NotificationProvider;
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
Object.defineProperty(exports, "failure", {
|
|
19
|
+
enumerable: true,
|
|
20
|
+
get: function get() {
|
|
21
|
+
return _messageBuilder.failure;
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
Object.defineProperty(exports, "info", {
|
|
25
|
+
enumerable: true,
|
|
26
|
+
get: function get() {
|
|
27
|
+
return _messageBuilder.info;
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
Object.defineProperty(exports, "queue", {
|
|
31
|
+
enumerable: true,
|
|
32
|
+
get: function get() {
|
|
33
|
+
return _messageBuilder.queue;
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
Object.defineProperty(exports, "success", {
|
|
37
|
+
enumerable: true,
|
|
38
|
+
get: function get() {
|
|
39
|
+
return _messageBuilder.success;
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
Object.defineProperty(exports, "useNotify", {
|
|
43
|
+
enumerable: true,
|
|
44
|
+
get: function get() {
|
|
45
|
+
return _NotificationProvider.useNotify;
|
|
46
|
+
}
|
|
47
|
+
});
|
|
48
|
+
var _NotificationProvider = require("./NotificationProvider");
|
|
49
|
+
var _messageBuilder = require("./messageBuilder");
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { NotificationAction, NotificationType, QueuedNotification } from "./types";
|
|
2
|
+
import { ReactNode } from "react";
|
|
3
|
+
export declare const queue: (notification: NotificationType) => QueuedNotification;
|
|
4
|
+
export declare const info: (message: ReactNode, title?: string) => NotificationType;
|
|
5
|
+
export declare const success: (message: ReactNode) => NotificationType;
|
|
6
|
+
export declare const failure: (title: string, error: unknown, message?: ReactNode, actions?: NotificationAction[]) => NotificationType;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.success = exports.queue = exports.info = exports.failure = void 0;
|
|
7
|
+
var _react = _interopRequireDefault(require("react"));
|
|
8
|
+
var _Notification = require("../Notification");
|
|
9
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
10
|
+
var queue = function queue(notification) {
|
|
11
|
+
return {
|
|
12
|
+
state: {
|
|
13
|
+
queuedNotification: notification
|
|
14
|
+
}
|
|
15
|
+
};
|
|
16
|
+
};
|
|
17
|
+
exports.queue = queue;
|
|
18
|
+
var info = function info(message, title) {
|
|
19
|
+
return {
|
|
20
|
+
message: message,
|
|
21
|
+
title: title,
|
|
22
|
+
type: _Notification.NotificationSeverity.INFORMATION
|
|
23
|
+
};
|
|
24
|
+
};
|
|
25
|
+
exports.info = info;
|
|
26
|
+
var success = function success(message) {
|
|
27
|
+
return {
|
|
28
|
+
message: message,
|
|
29
|
+
type: _Notification.NotificationSeverity.POSITIVE
|
|
30
|
+
};
|
|
31
|
+
};
|
|
32
|
+
exports.success = success;
|
|
33
|
+
var failure = function failure(title, error, message, actions) {
|
|
34
|
+
return {
|
|
35
|
+
actions: actions,
|
|
36
|
+
message: error && error instanceof Error ? /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, message, " ", error.message) : message,
|
|
37
|
+
title: title,
|
|
38
|
+
type: _Notification.NotificationSeverity.NEGATIVE
|
|
39
|
+
};
|
|
40
|
+
};
|
|
41
|
+
exports.failure = failure;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { ReactNode } from "react";
|
|
2
|
+
import { ValueOf } from "../../types";
|
|
3
|
+
import { NotificationSeverity } from "../Notification";
|
|
4
|
+
export interface NotifyProviderProps {
|
|
5
|
+
children: ReactNode;
|
|
6
|
+
}
|
|
7
|
+
export interface NotificationAction {
|
|
8
|
+
label: string;
|
|
9
|
+
onClick: () => void;
|
|
10
|
+
}
|
|
11
|
+
export interface NotificationType {
|
|
12
|
+
actions?: NotificationAction[];
|
|
13
|
+
message: ReactNode;
|
|
14
|
+
title?: string;
|
|
15
|
+
type: ValueOf<typeof NotificationSeverity>;
|
|
16
|
+
}
|
|
17
|
+
export interface QueuedNotification {
|
|
18
|
+
state?: {
|
|
19
|
+
queuedNotification: NotificationType | null;
|
|
20
|
+
};
|
|
21
|
+
pathname?: string;
|
|
22
|
+
}
|
|
23
|
+
export interface NotificationHelper {
|
|
24
|
+
notification: NotificationType | null;
|
|
25
|
+
clear: () => void;
|
|
26
|
+
failure: (title: string, error: unknown, message?: ReactNode, actions?: NotificationAction[]) => NotificationType;
|
|
27
|
+
info: (message: ReactNode, title?: string) => NotificationType;
|
|
28
|
+
success: (message: ReactNode) => NotificationType;
|
|
29
|
+
queue: (notification: NotificationType) => QueuedNotification;
|
|
30
|
+
}
|
|
@@ -4,63 +4,46 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
|
-
|
|
8
7
|
var _classnames = _interopRequireDefault(require("classnames"));
|
|
9
|
-
|
|
10
8
|
var _react = _interopRequireDefault(require("react"));
|
|
11
|
-
|
|
12
9
|
var _PaginationButton = _interopRequireDefault(require("./PaginationButton"));
|
|
13
|
-
|
|
14
10
|
var _PaginationItem = _interopRequireDefault(require("./PaginationItem"));
|
|
15
|
-
|
|
16
11
|
var _excluded = ["itemsPerPage", "totalItems", "paginate", "currentPage", "scrollToTop", "truncateThreshold", "centered"];
|
|
17
|
-
|
|
18
12
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
19
|
-
|
|
20
13
|
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
21
|
-
|
|
22
14
|
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
|
23
|
-
|
|
24
15
|
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
25
|
-
|
|
26
16
|
var scrollTop = function scrollTop() {
|
|
27
17
|
return window.scrollTo(0, 0);
|
|
28
18
|
};
|
|
29
|
-
|
|
30
19
|
var generatePaginationItems = function generatePaginationItems(pageNumbers, currentPage, truncateThreshold, changePage) {
|
|
31
20
|
var lastPage = pageNumbers.length;
|
|
32
21
|
var truncated = lastPage > truncateThreshold;
|
|
33
22
|
var visiblePages;
|
|
34
|
-
|
|
35
23
|
if (truncated) {
|
|
36
24
|
// the default range for pages outside the start and end threshold
|
|
37
25
|
var start = currentPage - 2;
|
|
38
|
-
var end = currentPage + 1;
|
|
39
|
-
|
|
26
|
+
var end = currentPage + 1;
|
|
27
|
+
// on page 1, also show pages 2, 3 and 4
|
|
40
28
|
if (currentPage === 1) {
|
|
41
29
|
start = 1;
|
|
42
30
|
end = currentPage + 3;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
|
|
31
|
+
}
|
|
32
|
+
// on page 2, show page 1, and also pages 3, and 4
|
|
46
33
|
if (currentPage === 2) {
|
|
47
34
|
start = 1;
|
|
48
35
|
end = currentPage + 2;
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
|
|
36
|
+
}
|
|
37
|
+
// on the last page and page before last, also show the 3 previous pages
|
|
52
38
|
if (currentPage === lastPage || currentPage === lastPage - 1) {
|
|
53
39
|
start = lastPage - 4;
|
|
54
40
|
end = lastPage - 1;
|
|
55
41
|
}
|
|
56
|
-
|
|
57
42
|
visiblePages = pageNumbers.slice(start, end);
|
|
58
43
|
} else {
|
|
59
44
|
visiblePages = pageNumbers;
|
|
60
45
|
}
|
|
61
|
-
|
|
62
46
|
var items = [];
|
|
63
|
-
|
|
64
47
|
if (truncated) {
|
|
65
48
|
// render first in sequence
|
|
66
49
|
items.push( /*#__PURE__*/_react.default.createElement(_PaginationItem.default, {
|
|
@@ -71,14 +54,12 @@ var generatePaginationItems = function generatePaginationItems(pageNumbers, curr
|
|
|
71
54
|
return changePage(1);
|
|
72
55
|
}
|
|
73
56
|
}));
|
|
74
|
-
|
|
75
57
|
if (![1, 2, 3].includes(currentPage)) {
|
|
76
58
|
items.push( /*#__PURE__*/_react.default.createElement(PaginationItemSeparator, {
|
|
77
59
|
key: "sep1"
|
|
78
60
|
}));
|
|
79
61
|
}
|
|
80
62
|
}
|
|
81
|
-
|
|
82
63
|
items.push(visiblePages.map(function (number) {
|
|
83
64
|
return /*#__PURE__*/_react.default.createElement(_PaginationItem.default, {
|
|
84
65
|
key: number,
|
|
@@ -89,7 +70,6 @@ var generatePaginationItems = function generatePaginationItems(pageNumbers, curr
|
|
|
89
70
|
}
|
|
90
71
|
});
|
|
91
72
|
}));
|
|
92
|
-
|
|
93
73
|
if (truncated) {
|
|
94
74
|
// render last in sequence
|
|
95
75
|
if (![lastPage, lastPage - 1, lastPage - 2].includes(currentPage)) {
|
|
@@ -97,7 +77,6 @@ var generatePaginationItems = function generatePaginationItems(pageNumbers, curr
|
|
|
97
77
|
key: "sep2"
|
|
98
78
|
}));
|
|
99
79
|
}
|
|
100
|
-
|
|
101
80
|
items.push( /*#__PURE__*/_react.default.createElement(_PaginationItem.default, {
|
|
102
81
|
key: lastPage,
|
|
103
82
|
number: lastPage,
|
|
@@ -107,43 +86,35 @@ var generatePaginationItems = function generatePaginationItems(pageNumbers, curr
|
|
|
107
86
|
}
|
|
108
87
|
}));
|
|
109
88
|
}
|
|
110
|
-
|
|
111
89
|
return items;
|
|
112
90
|
};
|
|
113
|
-
|
|
114
91
|
var PaginationItemSeparator = function PaginationItemSeparator() {
|
|
115
92
|
return /*#__PURE__*/_react.default.createElement("li", {
|
|
116
93
|
className: "p-pagination__item p-pagination__item--truncation"
|
|
117
94
|
}, "\u2026");
|
|
118
95
|
};
|
|
119
|
-
|
|
120
96
|
var Pagination = function Pagination(_ref) {
|
|
121
97
|
var itemsPerPage = _ref.itemsPerPage,
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
98
|
+
totalItems = _ref.totalItems,
|
|
99
|
+
paginate = _ref.paginate,
|
|
100
|
+
currentPage = _ref.currentPage,
|
|
101
|
+
scrollToTop = _ref.scrollToTop,
|
|
102
|
+
_ref$truncateThreshol = _ref.truncateThreshold,
|
|
103
|
+
truncateThreshold = _ref$truncateThreshol === void 0 ? 10 : _ref$truncateThreshol,
|
|
104
|
+
centered = _ref.centered,
|
|
105
|
+
navProps = _objectWithoutProperties(_ref, _excluded);
|
|
131
106
|
// return early if no pagination is required
|
|
132
107
|
if (totalItems <= itemsPerPage) {
|
|
133
108
|
return null;
|
|
134
109
|
}
|
|
135
|
-
|
|
136
110
|
var pageNumbers = [];
|
|
137
|
-
|
|
138
111
|
for (var i = 1; i <= Math.ceil(totalItems / itemsPerPage); i++) {
|
|
139
112
|
pageNumbers.push(i);
|
|
140
113
|
}
|
|
141
|
-
|
|
142
114
|
var changePage = function changePage(page) {
|
|
143
115
|
paginate(page);
|
|
144
116
|
scrollToTop && scrollTop();
|
|
145
117
|
};
|
|
146
|
-
|
|
147
118
|
return /*#__PURE__*/_react.default.createElement("nav", _extends({
|
|
148
119
|
className: "p-pagination",
|
|
149
120
|
"aria-label": "Pagination"
|
|
@@ -167,6 +138,5 @@ var Pagination = function Pagination(_ref) {
|
|
|
167
138
|
}
|
|
168
139
|
})));
|
|
169
140
|
};
|
|
170
|
-
|
|
171
141
|
var _default = Pagination;
|
|
172
142
|
exports.default = _default;
|
|
@@ -4,26 +4,20 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = exports.Label = void 0;
|
|
7
|
-
|
|
8
7
|
var _classnames = _interopRequireDefault(require("classnames"));
|
|
9
|
-
|
|
10
8
|
var _react = _interopRequireDefault(require("react"));
|
|
11
|
-
|
|
12
9
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
13
|
-
|
|
14
10
|
var Label = /*#__PURE__*/function (Label) {
|
|
15
11
|
Label["Next"] = "Next page";
|
|
16
12
|
Label["Previous"] = "Previous page";
|
|
17
13
|
return Label;
|
|
18
14
|
}({});
|
|
19
|
-
|
|
20
15
|
exports.Label = Label;
|
|
21
|
-
|
|
22
16
|
var PaginationButton = function PaginationButton(_ref) {
|
|
23
17
|
var direction = _ref.direction,
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
18
|
+
onClick = _ref.onClick,
|
|
19
|
+
_ref$disabled = _ref.disabled,
|
|
20
|
+
disabled = _ref$disabled === void 0 ? false : _ref$disabled;
|
|
27
21
|
var label = direction === "back" ? Label.Previous : Label.Next;
|
|
28
22
|
return /*#__PURE__*/_react.default.createElement("li", {
|
|
29
23
|
className: "p-pagination__item"
|
|
@@ -39,6 +33,5 @@ var PaginationButton = function PaginationButton(_ref) {
|
|
|
39
33
|
className: "p-icon--chevron-down"
|
|
40
34
|
}, label)));
|
|
41
35
|
};
|
|
42
|
-
|
|
43
36
|
var _default = PaginationButton;
|
|
44
37
|
exports.default = _default;
|
|
@@ -9,7 +9,5 @@ Object.defineProperty(exports, "default", {
|
|
|
9
9
|
return _PaginationButton.default;
|
|
10
10
|
}
|
|
11
11
|
});
|
|
12
|
-
|
|
13
12
|
var _PaginationButton = _interopRequireDefault(require("./PaginationButton"));
|
|
14
|
-
|
|
15
13
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
@@ -4,18 +4,14 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
|
-
|
|
8
7
|
var _classnames = _interopRequireDefault(require("classnames"));
|
|
9
|
-
|
|
10
8
|
var _react = _interopRequireDefault(require("react"));
|
|
11
|
-
|
|
12
9
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
13
|
-
|
|
14
10
|
var PaginationItem = function PaginationItem(_ref) {
|
|
15
11
|
var number = _ref.number,
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
12
|
+
onClick = _ref.onClick,
|
|
13
|
+
_ref$isActive = _ref.isActive,
|
|
14
|
+
isActive = _ref$isActive === void 0 ? false : _ref$isActive;
|
|
19
15
|
return /*#__PURE__*/_react.default.createElement("li", {
|
|
20
16
|
className: "p-pagination__item"
|
|
21
17
|
}, /*#__PURE__*/_react.default.createElement("button", {
|
|
@@ -27,6 +23,5 @@ var PaginationItem = function PaginationItem(_ref) {
|
|
|
27
23
|
type: "button"
|
|
28
24
|
}, number));
|
|
29
25
|
};
|
|
30
|
-
|
|
31
26
|
var _default = PaginationItem;
|
|
32
27
|
exports.default = _default;
|
|
@@ -9,7 +9,5 @@ Object.defineProperty(exports, "default", {
|
|
|
9
9
|
return _PaginationItem.default;
|
|
10
10
|
}
|
|
11
11
|
});
|
|
12
|
-
|
|
13
12
|
var _PaginationItem = _interopRequireDefault(require("./PaginationItem"));
|
|
14
|
-
|
|
15
13
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
@@ -1,50 +1,29 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
4
|
-
|
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
|
6
5
|
value: true
|
|
7
6
|
});
|
|
8
7
|
exports.default = exports.Label = void 0;
|
|
9
|
-
|
|
10
8
|
var _classnames = _interopRequireDefault(require("classnames"));
|
|
11
|
-
|
|
12
9
|
var _react = _interopRequireWildcard(require("react"));
|
|
13
|
-
|
|
14
10
|
var _Button = _interopRequireDefault(require("../Button"));
|
|
15
|
-
|
|
16
11
|
var _Field = _interopRequireDefault(require("../Field"));
|
|
17
|
-
|
|
18
12
|
var _Label = _interopRequireDefault(require("../Label"));
|
|
19
|
-
|
|
20
13
|
var _hooks = require("../../hooks");
|
|
21
|
-
|
|
22
14
|
var _excluded = ["caution", "className", "error", "help", "id", "label", "readOnly", "required", "success", "type", "wrapperClassName"];
|
|
23
|
-
|
|
24
15
|
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); }
|
|
25
|
-
|
|
26
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; }
|
|
27
|
-
|
|
28
17
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
29
|
-
|
|
30
18
|
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); }
|
|
31
|
-
|
|
32
19
|
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
33
|
-
|
|
34
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."); }
|
|
35
|
-
|
|
36
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); }
|
|
37
|
-
|
|
38
|
-
function
|
|
39
|
-
|
|
40
|
-
function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
|
|
41
|
-
|
|
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; } }
|
|
42
24
|
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
43
|
-
|
|
44
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; }
|
|
45
|
-
|
|
46
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; }
|
|
47
|
-
|
|
48
27
|
var Label = /*#__PURE__*/function (Label) {
|
|
49
28
|
Label["Hide"] = "Hide";
|
|
50
29
|
Label["Show"] = "Show";
|
|
@@ -53,33 +32,27 @@ var Label = /*#__PURE__*/function (Label) {
|
|
|
53
32
|
/**
|
|
54
33
|
* The props for the Password Toggle component.
|
|
55
34
|
*/
|
|
56
|
-
|
|
57
|
-
|
|
58
35
|
exports.Label = Label;
|
|
59
|
-
|
|
60
36
|
var PasswordToggle = /*#__PURE__*/_react.default.forwardRef(function (_ref, ref) {
|
|
61
37
|
var caution = _ref.caution,
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
38
|
+
className = _ref.className,
|
|
39
|
+
error = _ref.error,
|
|
40
|
+
help = _ref.help,
|
|
41
|
+
id = _ref.id,
|
|
42
|
+
label = _ref.label,
|
|
43
|
+
readOnly = _ref.readOnly,
|
|
44
|
+
required = _ref.required,
|
|
45
|
+
success = _ref.success,
|
|
46
|
+
type = _ref.type,
|
|
47
|
+
wrapperClassName = _ref.wrapperClassName,
|
|
48
|
+
inputProps = _objectWithoutProperties(_ref, _excluded);
|
|
74
49
|
var _useState = (0, _react.useState)(true),
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
50
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
51
|
+
isPassword = _useState2[0],
|
|
52
|
+
setIsPassword = _useState2[1];
|
|
79
53
|
var validationId = (0, _hooks.useId)();
|
|
80
54
|
var helpId = (0, _hooks.useId)();
|
|
81
55
|
var hasError = !!error;
|
|
82
|
-
|
|
83
56
|
var togglePassword = function togglePassword() {
|
|
84
57
|
if (isPassword) {
|
|
85
58
|
setIsPassword(false);
|
|
@@ -87,7 +60,6 @@ var PasswordToggle = /*#__PURE__*/_react.default.forwardRef(function (_ref, ref)
|
|
|
87
60
|
setIsPassword(true);
|
|
88
61
|
}
|
|
89
62
|
};
|
|
90
|
-
|
|
91
63
|
return /*#__PURE__*/_react.default.createElement(_Field.default, {
|
|
92
64
|
caution: caution,
|
|
93
65
|
className: wrapperClassName,
|
|
@@ -127,6 +99,5 @@ var PasswordToggle = /*#__PURE__*/_react.default.forwardRef(function (_ref, ref)
|
|
|
127
99
|
type: isPassword ? "password" : "text"
|
|
128
100
|
}, inputProps)));
|
|
129
101
|
});
|
|
130
|
-
|
|
131
102
|
var _default = PasswordToggle;
|
|
132
103
|
exports.default = _default;
|