@rh-support/components 2.0.4 → 2.0.7-beta.1
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/lib/cjs/AlertMessage/AlertMessage.js +5 -5
- package/lib/cjs/AlertMessage/index.d.ts +0 -1
- package/lib/cjs/AlertMessage/index.d.ts.map +1 -1
- package/lib/cjs/AlertMessage/index.js +1 -1
- package/lib/cjs/ConfirmationModal/ConfirmationContext.d.ts +0 -1
- package/lib/cjs/ConfirmationModal/ConfirmationContext.d.ts.map +1 -1
- package/lib/cjs/ConfirmationModal/ConfirmationContext.js +13 -41
- package/lib/cjs/ConfirmationModal/ConfirmationDialog.d.ts +4 -2
- package/lib/cjs/ConfirmationModal/ConfirmationDialog.d.ts.map +1 -1
- package/lib/cjs/ConfirmationModal/ConfirmationDialog.js +7 -6
- package/lib/cjs/ConfirmationModal/ConfirmationModal.stories.d.ts +0 -6
- package/lib/cjs/ConfirmationModal/ConfirmationModal.stories.d.ts.map +1 -1
- package/lib/cjs/ConfirmationModal/ConfirmationModal.stories.js +29 -69
- package/lib/cjs/CoverSpinner/CoverSpinner.d.ts +0 -1
- package/lib/cjs/CoverSpinner/CoverSpinner.d.ts.map +1 -1
- package/lib/cjs/CoverSpinner/CoverSpinner.js +1 -1
- package/lib/cjs/CustomContentLoader/CustomContentLoader.d.ts.map +1 -1
- package/lib/cjs/CustomContentLoader/CustomContentLoader.js +25 -25
- package/lib/cjs/CustomTextInput/CustomTextInput.d.ts +0 -1
- package/lib/cjs/CustomTextInput/CustomTextInput.d.ts.map +1 -1
- package/lib/cjs/CustomTextInput/CustomTextInput.js +10 -21
- package/lib/cjs/DropDownList/AsyncDropDownList.js +5 -5
- package/lib/cjs/DropDownList/DropDownList.d.ts +0 -1
- package/lib/cjs/DropDownList/DropDownList.d.ts.map +1 -1
- package/lib/cjs/DropDownList/DropDownList.js +45 -75
- package/lib/cjs/DropDownList/DropdownWrapper.js +7 -18
- package/lib/cjs/DropDownList/MultiSelectDropdownList.js +3 -3
- package/lib/cjs/DropDownList/SearchableList.d.ts +1 -0
- package/lib/cjs/DropDownList/SearchableList.d.ts.map +1 -1
- package/lib/cjs/DropDownList/SearchableList.js +45 -55
- package/lib/cjs/DropDownList/SelectList.js +15 -26
- package/lib/cjs/DropDownList/async.js +28 -38
- package/lib/cjs/DropDownList/dropdownList.css +1 -1
- package/lib/cjs/DropDownList/dropdownUtils.d.ts.map +1 -1
- package/lib/cjs/DropDownList/dropdownUtils.js +9 -19
- package/lib/cjs/DropDownList/types.d.ts +1 -0
- package/lib/cjs/DropDownList/types.d.ts.map +1 -1
- package/lib/cjs/DropDownList/withMulti.js +15 -26
- package/lib/cjs/ErrorBoundary/ErrorBoundary.js +18 -47
- package/lib/cjs/ErrorBoundary/ErrorBoundaryFallbackComponent.d.ts +0 -1
- package/lib/cjs/ErrorBoundary/ErrorBoundaryFallbackComponent.d.ts.map +1 -1
- package/lib/cjs/ErrorBoundary/ErrorBoundaryFallbackComponent.js +10 -10
- package/lib/cjs/ErrorPages/Generic403.d.ts +0 -1
- package/lib/cjs/ErrorPages/Generic403.d.ts.map +1 -1
- package/lib/cjs/ErrorPages/Generic403.js +2 -2
- package/lib/cjs/FeedbackForm/FeedbackForm.d.ts +0 -1
- package/lib/cjs/FeedbackForm/FeedbackForm.d.ts.map +1 -1
- package/lib/cjs/FeedbackForm/FeedbackForm.js +24 -52
- package/lib/cjs/Functional/CaseContactsSelectorExternal.d.ts.map +1 -1
- package/lib/cjs/Functional/CaseContactsSelectorExternal.js +81 -154
- package/lib/cjs/InlineEdit/InlineEdit.d.ts +1 -0
- package/lib/cjs/InlineEdit/InlineEdit.d.ts.map +1 -1
- package/lib/cjs/InlineEdit/InlineEdit.js +58 -144
- package/lib/cjs/InlineEdit/NewInlineEdit.d.ts +1 -0
- package/lib/cjs/InlineEdit/NewInlineEdit.d.ts.map +1 -1
- package/lib/cjs/InlineEdit/NewInlineEdit.js +62 -147
- package/lib/cjs/InlineEdit/inlineEdit.css +4 -0
- package/lib/cjs/InlineEdit/newInlineEdit.css +4 -0
- package/lib/cjs/LanguageSelector/LanguageSelector.d.ts +0 -1
- package/lib/cjs/LanguageSelector/LanguageSelector.d.ts.map +1 -1
- package/lib/cjs/LanguageSelector/LanguageSelector.js +10 -26
- package/lib/cjs/LoadingDots/LoadingDots.d.ts +0 -1
- package/lib/cjs/LoadingDots/LoadingDots.d.ts.map +1 -1
- package/lib/cjs/LoadingDots/LoadingDots.js +4 -4
- package/lib/cjs/LoadingDots/index.d.ts +0 -1
- package/lib/cjs/LoadingDots/index.d.ts.map +1 -1
- package/lib/cjs/LoadingDots/index.js +1 -1
- package/lib/cjs/LoadingIndicator/LoadingIndicator.d.ts +0 -1
- package/lib/cjs/LoadingIndicator/LoadingIndicator.d.ts.map +1 -1
- package/lib/cjs/LoadingIndicator/LoadingIndicator.js +3 -3
- package/lib/cjs/LoginModal/LoginModal.d.ts +0 -1
- package/lib/cjs/LoginModal/LoginModal.d.ts.map +1 -1
- package/lib/cjs/LoginModal/LoginModal.js +3 -3
- package/lib/cjs/MarkdownEditor/MarkdownEditor.js +113 -165
- package/lib/cjs/MoreOrLess/MoreOrLess.js +20 -40
- package/lib/cjs/PaginatedList/PaginatedList.js +15 -31
- package/lib/cjs/PaginationCompact/PaginationCompact.d.ts +0 -1
- package/lib/cjs/PaginationCompact/PaginationCompact.d.ts.map +1 -1
- package/lib/cjs/PaginationCompact/PaginationCompact.js +14 -31
- package/lib/cjs/PhoneInput/CountryData.d.ts +3 -0
- package/lib/cjs/PhoneInput/CountryData.d.ts.map +1 -0
- package/lib/cjs/PhoneInput/CountryData.js +583 -0
- package/lib/cjs/PhoneInput/PhoneInput.d.ts +19 -0
- package/lib/cjs/PhoneInput/PhoneInput.d.ts.map +1 -0
- package/lib/cjs/PhoneInput/PhoneInput.js +284 -0
- package/lib/cjs/PhoneInput/PhoneInput.scss +753 -0
- package/lib/cjs/PhoneInput/flags.png +0 -0
- package/lib/cjs/PhoneInput/index.d.ts +2 -0
- package/lib/cjs/PhoneInput/index.d.ts.map +1 -0
- package/lib/cjs/PhoneInput/index.js +13 -0
- package/lib/cjs/ProgressBar/CircularProgressBar/CircularProgressBar.d.ts +0 -1
- package/lib/cjs/ProgressBar/CircularProgressBar/CircularProgressBar.d.ts.map +1 -1
- package/lib/cjs/ProgressBar/CircularProgressBar/CircularProgressBar.js +14 -14
- package/lib/cjs/ProgressBar/CircularProgressBar/Path.js +20 -18
- package/lib/cjs/ProgressBar/ProgressBar.js +8 -19
- package/lib/cjs/PromisifyModal/PromisifyModal.js +19 -36
- package/lib/cjs/SubscriptionAbuse/SubscriptionAbuseModal.d.ts +0 -1
- package/lib/cjs/SubscriptionAbuse/SubscriptionAbuseModal.d.ts.map +1 -1
- package/lib/cjs/SubscriptionAbuse/SubscriptionAbuseModal.js +5 -5
- package/lib/cjs/SubscriptionAbuse/const.d.ts +0 -1
- package/lib/cjs/SubscriptionAbuse/const.d.ts.map +1 -1
- package/lib/cjs/SubscriptionAbuse/const.js +3 -3
- package/lib/cjs/SupportFeedbackForm/SupportFeedbackForm.d.ts +0 -1
- package/lib/cjs/SupportFeedbackForm/SupportFeedbackForm.d.ts.map +1 -1
- package/lib/cjs/SupportFeedbackForm/SupportFeedbackForm.js +8 -24
- package/lib/cjs/SupportFeedbackForm/SupportFeedbackModal.d.ts +0 -1
- package/lib/cjs/SupportFeedbackForm/SupportFeedbackModal.d.ts.map +1 -1
- package/lib/cjs/SupportFeedbackForm/SupportFeedbackModal.js +50 -120
- package/lib/cjs/Table/PFTable.js +52 -89
- package/lib/cjs/Table/Table.js +12 -29
- package/lib/cjs/Table/TableColumnSelector.d.ts +0 -1
- package/lib/cjs/Table/TableColumnSelector.d.ts.map +1 -1
- package/lib/cjs/Table/TableColumnSelector.js +14 -15
- package/lib/cjs/Table/TablePagination.d.ts +0 -1
- package/lib/cjs/Table/TablePagination.d.ts.map +1 -1
- package/lib/cjs/Table/TablePagination.js +8 -8
- package/lib/cjs/Table/TableProvider.js +6 -6
- package/lib/cjs/TermsAndConditions/AcceptTermsModal.d.ts +0 -1
- package/lib/cjs/TermsAndConditions/AcceptTermsModal.d.ts.map +1 -1
- package/lib/cjs/TermsAndConditions/AcceptTermsModal.js +46 -100
- package/lib/cjs/TextAreaAutosize/TextAreaAutosize.js +35 -62
- package/lib/cjs/TextAreaResizable/TextAreaResizable.js +12 -25
- package/lib/cjs/ToastNotification/ToastNotification.js +35 -70
- package/lib/cjs/TopContentSearch/TopContentSearch.js +48 -113
- package/lib/cjs/ValueChangedIcon/ValueChangedIcon.js +13 -29
- package/lib/cjs/helperFunctions/errorMessage.d.ts +0 -1
- package/lib/cjs/helperFunctions/errorMessage.d.ts.map +1 -1
- package/lib/cjs/helperFunctions/errorMessage.js +13 -13
- package/lib/cjs/hooks/useBreakpoint.js +26 -43
- package/lib/cjs/hooks/useCopyToClipboard.js +8 -24
- package/lib/cjs/hooks/useDebounce.js +13 -38
- package/lib/cjs/hooks/useFetch.js +47 -123
- package/lib/cjs/hooks/useForceUpdate.js +2 -18
- package/lib/cjs/hooks/useForkRef.js +3 -3
- package/lib/cjs/hooks/useIsMounted.js +4 -4
- package/lib/cjs/hooks/useLRUCache.js +11 -11
- package/lib/cjs/hooks/useLocalStorage.js +7 -23
- package/lib/cjs/hooks/useOnScreen.js +5 -24
- package/lib/cjs/hooks/usePolling.js +8 -30
- package/lib/cjs/hooks/usePrevious.js +3 -3
- package/lib/cjs/hooks/useTitle.js +4 -4
- package/lib/cjs/hooks/useUndo.js +49 -72
- package/lib/cjs/index.d.ts +1 -0
- package/lib/cjs/index.d.ts.map +1 -1
- package/lib/cjs/index.js +1 -0
- package/lib/esm/AlertMessage/AlertMessage.js +2 -2
- package/lib/esm/AlertMessage/index.d.ts +0 -1
- package/lib/esm/AlertMessage/index.d.ts.map +1 -1
- package/lib/esm/AlertMessage/index.js +1 -1
- package/lib/esm/ConfirmationModal/ConfirmationContext.d.ts +0 -1
- package/lib/esm/ConfirmationModal/ConfirmationContext.d.ts.map +1 -1
- package/lib/esm/ConfirmationModal/ConfirmationDialog.d.ts +4 -2
- package/lib/esm/ConfirmationModal/ConfirmationDialog.d.ts.map +1 -1
- package/lib/esm/ConfirmationModal/ConfirmationDialog.js +3 -2
- package/lib/esm/ConfirmationModal/ConfirmationModal.stories.d.ts +0 -6
- package/lib/esm/ConfirmationModal/ConfirmationModal.stories.d.ts.map +1 -1
- package/lib/esm/ConfirmationModal/ConfirmationModal.stories.js +19 -18
- package/lib/esm/CoverSpinner/CoverSpinner.d.ts +0 -1
- package/lib/esm/CoverSpinner/CoverSpinner.d.ts.map +1 -1
- package/lib/esm/CustomContentLoader/CustomContentLoader.d.ts.map +1 -1
- package/lib/esm/CustomContentLoader/CustomContentLoader.js +23 -23
- package/lib/esm/CustomTextInput/CustomTextInput.d.ts +0 -1
- package/lib/esm/CustomTextInput/CustomTextInput.d.ts.map +1 -1
- package/lib/esm/CustomTextInput/CustomTextInput.js +1 -1
- package/lib/esm/DropDownList/DropDownList.d.ts +0 -1
- package/lib/esm/DropDownList/DropDownList.d.ts.map +1 -1
- package/lib/esm/DropDownList/SearchableList.d.ts +1 -0
- package/lib/esm/DropDownList/SearchableList.d.ts.map +1 -1
- package/lib/esm/DropDownList/SearchableList.js +6 -2
- package/lib/esm/DropDownList/dropdownList.css +1 -1
- package/lib/esm/DropDownList/dropdownUtils.d.ts.map +1 -1
- package/lib/esm/DropDownList/dropdownUtils.js +1 -0
- package/lib/esm/DropDownList/types.d.ts +1 -0
- package/lib/esm/DropDownList/types.d.ts.map +1 -1
- package/lib/esm/ErrorBoundary/ErrorBoundaryFallbackComponent.d.ts +0 -1
- package/lib/esm/ErrorBoundary/ErrorBoundaryFallbackComponent.d.ts.map +1 -1
- package/lib/esm/ErrorPages/Generic403.d.ts +0 -1
- package/lib/esm/ErrorPages/Generic403.d.ts.map +1 -1
- package/lib/esm/FeedbackForm/FeedbackForm.d.ts +0 -1
- package/lib/esm/FeedbackForm/FeedbackForm.d.ts.map +1 -1
- package/lib/esm/Functional/CaseContactsSelectorExternal.d.ts.map +1 -1
- package/lib/esm/Functional/CaseContactsSelectorExternal.js +2 -2
- package/lib/esm/InlineEdit/InlineEdit.d.ts +1 -0
- package/lib/esm/InlineEdit/InlineEdit.d.ts.map +1 -1
- package/lib/esm/InlineEdit/InlineEdit.js +3 -3
- package/lib/esm/InlineEdit/NewInlineEdit.d.ts +1 -0
- package/lib/esm/InlineEdit/NewInlineEdit.d.ts.map +1 -1
- package/lib/esm/InlineEdit/NewInlineEdit.js +3 -3
- package/lib/esm/InlineEdit/inlineEdit.css +4 -0
- package/lib/esm/InlineEdit/newInlineEdit.css +4 -0
- package/lib/esm/LanguageSelector/LanguageSelector.d.ts +0 -1
- package/lib/esm/LanguageSelector/LanguageSelector.d.ts.map +1 -1
- package/lib/esm/LoadingDots/LoadingDots.d.ts +0 -1
- package/lib/esm/LoadingDots/LoadingDots.d.ts.map +1 -1
- package/lib/esm/LoadingDots/LoadingDots.js +1 -1
- package/lib/esm/LoadingDots/index.d.ts +0 -1
- package/lib/esm/LoadingDots/index.d.ts.map +1 -1
- package/lib/esm/LoadingDots/index.js +1 -1
- package/lib/esm/LoadingIndicator/LoadingIndicator.d.ts +0 -1
- package/lib/esm/LoadingIndicator/LoadingIndicator.d.ts.map +1 -1
- package/lib/esm/LoginModal/LoginModal.d.ts +0 -1
- package/lib/esm/LoginModal/LoginModal.d.ts.map +1 -1
- package/lib/esm/PaginationCompact/PaginationCompact.d.ts +0 -1
- package/lib/esm/PaginationCompact/PaginationCompact.d.ts.map +1 -1
- package/lib/esm/PhoneInput/CountryData.d.ts +3 -0
- package/lib/esm/PhoneInput/CountryData.d.ts.map +1 -0
- package/lib/esm/PhoneInput/CountryData.js +580 -0
- package/lib/esm/PhoneInput/PhoneInput.d.ts +19 -0
- package/lib/esm/PhoneInput/PhoneInput.d.ts.map +1 -0
- package/lib/esm/PhoneInput/PhoneInput.js +257 -0
- package/lib/esm/PhoneInput/PhoneInput.scss +753 -0
- package/lib/esm/PhoneInput/flags.png +0 -0
- package/lib/esm/PhoneInput/index.d.ts +2 -0
- package/lib/esm/PhoneInput/index.d.ts.map +1 -0
- package/lib/esm/PhoneInput/index.js +1 -0
- package/lib/esm/ProgressBar/CircularProgressBar/CircularProgressBar.d.ts +0 -1
- package/lib/esm/ProgressBar/CircularProgressBar/CircularProgressBar.d.ts.map +1 -1
- package/lib/esm/SubscriptionAbuse/SubscriptionAbuseModal.d.ts +0 -1
- package/lib/esm/SubscriptionAbuse/SubscriptionAbuseModal.d.ts.map +1 -1
- package/lib/esm/SubscriptionAbuse/const.d.ts +0 -1
- package/lib/esm/SubscriptionAbuse/const.d.ts.map +1 -1
- package/lib/esm/SupportFeedbackForm/SupportFeedbackForm.d.ts +0 -1
- package/lib/esm/SupportFeedbackForm/SupportFeedbackForm.d.ts.map +1 -1
- package/lib/esm/SupportFeedbackForm/SupportFeedbackModal.d.ts +0 -1
- package/lib/esm/SupportFeedbackForm/SupportFeedbackModal.d.ts.map +1 -1
- package/lib/esm/Table/TableColumnSelector.d.ts +0 -1
- package/lib/esm/Table/TableColumnSelector.d.ts.map +1 -1
- package/lib/esm/Table/TablePagination.d.ts +0 -1
- package/lib/esm/Table/TablePagination.d.ts.map +1 -1
- package/lib/esm/TermsAndConditions/AcceptTermsModal.d.ts +0 -1
- package/lib/esm/TermsAndConditions/AcceptTermsModal.d.ts.map +1 -1
- package/lib/esm/TextAreaResizable/TextAreaResizable.js +1 -1
- package/lib/esm/helperFunctions/errorMessage.d.ts +0 -1
- package/lib/esm/helperFunctions/errorMessage.d.ts.map +1 -1
- package/lib/esm/index.d.ts +1 -0
- package/lib/esm/index.d.ts.map +1 -1
- package/lib/esm/index.js +1 -0
- package/package.json +16 -30
- package/lib/cjs/AlertMessage/AlertMessage.stories.d.ts +0 -12
- package/lib/cjs/AlertMessage/AlertMessage.stories.d.ts.map +0 -1
- package/lib/cjs/AlertMessage/AlertMessage.stories.js +0 -29
- package/lib/cjs/DropDownList/Dropdownlist.stories.d.ts +0 -17
- package/lib/cjs/DropDownList/Dropdownlist.stories.d.ts.map +0 -1
- package/lib/cjs/DropDownList/Dropdownlist.stories.js +0 -253
- package/lib/cjs/LoadingDots/LoadingDots.stories.d.ts +0 -10
- package/lib/cjs/LoadingDots/LoadingDots.stories.d.ts.map +0 -1
- package/lib/cjs/LoadingDots/LoadingDots.stories.js +0 -16
- package/lib/cjs/LoadingIndicator/LoadingIndicator.stories.d.ts +0 -11
- package/lib/cjs/LoadingIndicator/LoadingIndicator.stories.d.ts.map +0 -1
- package/lib/cjs/LoadingIndicator/LoadingIndicator.stories.js +0 -18
- package/lib/cjs/Table/PFTable.stories.d.ts +0 -20
- package/lib/cjs/Table/PFTable.stories.d.ts.map +0 -1
- package/lib/cjs/Table/PFTable.stories.js +0 -81
- package/lib/cjs/demo/Demo.css +0 -3
- package/lib/cjs/demo/Demo.d.ts +0 -13
- package/lib/cjs/demo/Demo.d.ts.map +0 -1
- package/lib/cjs/demo/Demo.js +0 -42
- package/lib/cjs/demo/Demo.md +0 -0
- package/lib/cjs/demo/Demo.scss +0 -3
- package/lib/cjs/demo/index.d.ts +0 -3
- package/lib/cjs/demo/index.d.ts.map +0 -1
- package/lib/cjs/demo/index.js +0 -23
- package/lib/esm/AlertMessage/AlertMessage.stories.d.ts +0 -12
- package/lib/esm/AlertMessage/AlertMessage.stories.d.ts.map +0 -1
- package/lib/esm/AlertMessage/AlertMessage.stories.js +0 -20
- package/lib/esm/DropDownList/Dropdownlist.stories.d.ts +0 -17
- package/lib/esm/DropDownList/Dropdownlist.stories.d.ts.map +0 -1
- package/lib/esm/DropDownList/Dropdownlist.stories.js +0 -156
- package/lib/esm/LoadingDots/LoadingDots.stories.d.ts +0 -10
- package/lib/esm/LoadingDots/LoadingDots.stories.d.ts.map +0 -1
- package/lib/esm/LoadingDots/LoadingDots.stories.js +0 -8
- package/lib/esm/LoadingIndicator/LoadingIndicator.stories.d.ts +0 -11
- package/lib/esm/LoadingIndicator/LoadingIndicator.stories.d.ts.map +0 -1
- package/lib/esm/LoadingIndicator/LoadingIndicator.stories.js +0 -9
- package/lib/esm/Table/PFTable.stories.d.ts +0 -20
- package/lib/esm/Table/PFTable.stories.d.ts.map +0 -1
- package/lib/esm/Table/PFTable.stories.js +0 -73
- package/lib/esm/demo/Demo.css +0 -3
- package/lib/esm/demo/Demo.d.ts +0 -13
- package/lib/esm/demo/Demo.d.ts.map +0 -1
- package/lib/esm/demo/Demo.js +0 -26
- package/lib/esm/demo/Demo.md +0 -0
- package/lib/esm/demo/Demo.scss +0 -3
- package/lib/esm/demo/index.d.ts +0 -3
- package/lib/esm/demo/index.d.ts.map +0 -1
- package/lib/esm/demo/index.js +0 -2
|
@@ -1,15 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __assign = (this && this.__assign) || function () {
|
|
3
|
-
__assign = Object.assign || function(t) {
|
|
4
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
-
s = arguments[i];
|
|
6
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
-
t[p] = s[p];
|
|
8
|
-
}
|
|
9
|
-
return t;
|
|
10
|
-
};
|
|
11
|
-
return __assign.apply(this, arguments);
|
|
12
|
-
};
|
|
13
2
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
14
3
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
15
4
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -19,129 +8,64 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
19
8
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
20
9
|
});
|
|
21
10
|
};
|
|
22
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
23
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
24
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
25
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
26
|
-
function step(op) {
|
|
27
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
28
|
-
while (_) try {
|
|
29
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
30
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
31
|
-
switch (op[0]) {
|
|
32
|
-
case 0: case 1: t = op; break;
|
|
33
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
34
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
35
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
36
|
-
default:
|
|
37
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
38
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
39
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
40
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
41
|
-
if (t[2]) _.ops.pop();
|
|
42
|
-
_.trys.pop(); continue;
|
|
43
|
-
}
|
|
44
|
-
op = body.call(thisArg, _);
|
|
45
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
46
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
47
|
-
}
|
|
48
|
-
};
|
|
49
|
-
var __read = (this && this.__read) || function (o, n) {
|
|
50
|
-
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
51
|
-
if (!m) return o;
|
|
52
|
-
var i = m.call(o), r, ar = [], e;
|
|
53
|
-
try {
|
|
54
|
-
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
55
|
-
}
|
|
56
|
-
catch (error) { e = { error: error }; }
|
|
57
|
-
finally {
|
|
58
|
-
try {
|
|
59
|
-
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
60
|
-
}
|
|
61
|
-
finally { if (e) throw e.error; }
|
|
62
|
-
}
|
|
63
|
-
return ar;
|
|
64
|
-
};
|
|
65
|
-
var __spreadArray = (this && this.__spreadArray) || function (to, from) {
|
|
66
|
-
for (var i = 0, il = from.length, j = to.length; i < il; i++, j++)
|
|
67
|
-
to[j] = from[i];
|
|
68
|
-
return to;
|
|
69
|
-
};
|
|
70
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
71
12
|
exports.useFetch = void 0;
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
13
|
+
const react_1 = require("react");
|
|
14
|
+
const useIsMounted_1 = require("./useIsMounted");
|
|
15
|
+
const usePrevious_1 = require("./usePrevious");
|
|
75
16
|
// type IUseFetchFn = <T,A extends any[]>(fn: (...args:) => Promise<T>, options?: IUseFetchOptions<T>) => IUseFetch<T,A>;
|
|
76
|
-
function useFetch(fn,
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
17
|
+
function useFetch(fn, { initialData = null, resolve = false, resolveCondition = [], isAbortable = false, propgateErrors = false, postProcessor = undefined, } = {}) {
|
|
18
|
+
const isMounted = useIsMounted_1.useIsMounted();
|
|
19
|
+
const [{ data, isFetching, error }, setState] = react_1.useReducer((s, a) => (Object.assign(Object.assign({}, s), a)), { data: initialData, isFetching: resolve, error: null });
|
|
20
|
+
const [abortSignal, setAbortSignal] = react_1.useState(null);
|
|
21
|
+
const prevAbortSignal = usePrevious_1.usePrevious(abortSignal);
|
|
22
|
+
const clearResponse = () => setState({ data: initialData });
|
|
23
|
+
const request = (...args) => __awaiter(this, void 0, void 0, function* () {
|
|
24
|
+
var _a;
|
|
25
|
+
try {
|
|
26
|
+
if (isAbortable && 'AbortController' in window) {
|
|
27
|
+
if (prevAbortSignal) {
|
|
28
|
+
prevAbortSignal.abort();
|
|
29
|
+
}
|
|
30
|
+
const controller = new AbortController();
|
|
31
|
+
setAbortSignal(controller);
|
|
32
|
+
args.push(controller.signal);
|
|
33
|
+
}
|
|
34
|
+
isMounted && setState({ isFetching: true, error: null });
|
|
35
|
+
let response = yield fn(...args);
|
|
36
|
+
response = postProcessor ? postProcessor(response) : response;
|
|
37
|
+
isMounted && setState({ data: response, isFetching: false });
|
|
38
|
+
return response;
|
|
88
39
|
}
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
if (prevAbortSignal) {
|
|
98
|
-
prevAbortSignal.abort();
|
|
99
|
-
}
|
|
100
|
-
controller = new AbortController();
|
|
101
|
-
setAbortSignal(controller);
|
|
102
|
-
args.push(controller.signal);
|
|
103
|
-
}
|
|
104
|
-
isMounted && setState({ isFetching: true, error: null });
|
|
105
|
-
return [4 /*yield*/, fn.apply(void 0, __spreadArray([], __read(args)))];
|
|
106
|
-
case 1:
|
|
107
|
-
response = _b.sent();
|
|
108
|
-
response = postProcessor ? postProcessor(response) : response;
|
|
109
|
-
isMounted && setState({ data: response, isFetching: false });
|
|
110
|
-
return [2 /*return*/, response];
|
|
111
|
-
case 2:
|
|
112
|
-
err_1 = _b.sent();
|
|
113
|
-
isAbortError = ((_a = err_1) === null || _a === void 0 ? void 0 : _a.code) === 20;
|
|
114
|
-
if (isAbortError) {
|
|
115
|
-
// TODO handle abort error and loader behaviour
|
|
116
|
-
}
|
|
117
|
-
else {
|
|
118
|
-
if (!propgateErrors) {
|
|
119
|
-
// AlertUtil.addErrorMessage(err);
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
// Don
|
|
123
|
-
isMounted && !isAbortError && setState({ error: err_1, data: null, isFetching: false });
|
|
124
|
-
if (propgateErrors && !isAbortError) {
|
|
125
|
-
throw err_1;
|
|
126
|
-
}
|
|
127
|
-
return [3 /*break*/, 3];
|
|
128
|
-
case 3: return [2 /*return*/];
|
|
40
|
+
catch (err) {
|
|
41
|
+
const isAbortError = ((_a = err) === null || _a === void 0 ? void 0 : _a.code) === 20;
|
|
42
|
+
if (isAbortError) {
|
|
43
|
+
// TODO handle abort error and loader behaviour
|
|
44
|
+
}
|
|
45
|
+
else {
|
|
46
|
+
if (!propgateErrors) {
|
|
47
|
+
// AlertUtil.addErrorMessage(err);
|
|
129
48
|
}
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
49
|
+
}
|
|
50
|
+
// Don
|
|
51
|
+
isMounted && !isAbortError && setState({ error: err, data: null, isFetching: false });
|
|
52
|
+
if (propgateErrors && !isAbortError) {
|
|
53
|
+
throw err;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
});
|
|
57
|
+
react_1.useEffect(() => {
|
|
134
58
|
// if (resolve) {
|
|
135
59
|
// request();
|
|
136
60
|
// }
|
|
137
61
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
138
62
|
}, resolveCondition);
|
|
139
63
|
return {
|
|
140
|
-
clearResponse
|
|
141
|
-
data
|
|
142
|
-
isFetching
|
|
143
|
-
request
|
|
144
|
-
error
|
|
64
|
+
clearResponse,
|
|
65
|
+
data,
|
|
66
|
+
isFetching,
|
|
67
|
+
request,
|
|
68
|
+
error,
|
|
145
69
|
};
|
|
146
70
|
}
|
|
147
71
|
exports.useFetch = useFetch;
|
|
@@ -1,24 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
// Copied from https://github.com/react-restart/hooks/blob/master/src/useForceUpdate.ts
|
|
3
|
-
var __read = (this && this.__read) || function (o, n) {
|
|
4
|
-
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
5
|
-
if (!m) return o;
|
|
6
|
-
var i = m.call(o), r, ar = [], e;
|
|
7
|
-
try {
|
|
8
|
-
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
9
|
-
}
|
|
10
|
-
catch (error) { e = { error: error }; }
|
|
11
|
-
finally {
|
|
12
|
-
try {
|
|
13
|
-
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
14
|
-
}
|
|
15
|
-
finally { if (e) throw e.error; }
|
|
16
|
-
}
|
|
17
|
-
return ar;
|
|
18
|
-
};
|
|
19
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
20
4
|
exports.useForceUpdate = void 0;
|
|
21
|
-
|
|
5
|
+
const react_1 = require("react");
|
|
22
6
|
/**
|
|
23
7
|
* Returns a function that triggers a component update. the hook equivalent to
|
|
24
8
|
* `this.forceUpdate()` in a class component. In most cases using a state value directly
|
|
@@ -38,7 +22,7 @@ var react_1 = require("react");
|
|
|
38
22
|
function useForceUpdate() {
|
|
39
23
|
// The toggling state value is designed to defeat React optimizations for skipping
|
|
40
24
|
// updates when they are stricting equal to the last state value
|
|
41
|
-
|
|
25
|
+
const [, dispatch] = react_1.useReducer((state) => !state, false);
|
|
42
26
|
return dispatch;
|
|
43
27
|
}
|
|
44
28
|
exports.useForceUpdate = useForceUpdate;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.useForkRef = void 0;
|
|
4
|
-
|
|
4
|
+
const react_1 = require("react");
|
|
5
5
|
function setRef(ref, value) {
|
|
6
6
|
if (typeof ref === 'function') {
|
|
7
7
|
ref(value);
|
|
@@ -16,11 +16,11 @@ function useForkRef(refA, refB) {
|
|
|
16
16
|
* This means react will call the old forkRef with `null` and the new forkRef
|
|
17
17
|
* with the ref. Cleanup naturally emerges from this behavior
|
|
18
18
|
*/
|
|
19
|
-
return react_1.useMemo(
|
|
19
|
+
return react_1.useMemo(() => {
|
|
20
20
|
if (refA == null && refB == null) {
|
|
21
21
|
return null;
|
|
22
22
|
}
|
|
23
|
-
return
|
|
23
|
+
return (refValue) => {
|
|
24
24
|
setRef(refA, refValue);
|
|
25
25
|
setRef(refB, refValue);
|
|
26
26
|
};
|
|
@@ -4,12 +4,12 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.useIsMounted = void 0;
|
|
7
|
-
|
|
7
|
+
const react_1 = __importDefault(require("react"));
|
|
8
8
|
function useIsMounted() {
|
|
9
|
-
|
|
10
|
-
react_1.default.useLayoutEffect(
|
|
9
|
+
const mounted = react_1.default.useRef(false);
|
|
10
|
+
react_1.default.useLayoutEffect(() => {
|
|
11
11
|
mounted.current = true;
|
|
12
|
-
return
|
|
12
|
+
return () => {
|
|
13
13
|
mounted.current = false;
|
|
14
14
|
};
|
|
15
15
|
}, []);
|
|
@@ -1,27 +1,27 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.useLRUCache = void 0;
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
4
|
+
const utils_1 = require("@rh-support/utils");
|
|
5
|
+
const react_1 = require("react");
|
|
6
|
+
const useForceUpdate_1 = require("./useForceUpdate");
|
|
7
7
|
function useLRUCache(maxSize) {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
8
|
+
const lruCacheRef = react_1.useRef(new utils_1.LRUCache(maxSize));
|
|
9
|
+
const forceUpdate = useForceUpdate_1.useForceUpdate();
|
|
10
|
+
const setInCache = (key, value) => {
|
|
11
11
|
lruCacheRef.current.set(key, value);
|
|
12
12
|
forceUpdate();
|
|
13
13
|
};
|
|
14
|
-
|
|
14
|
+
const getFromCache = (key) => {
|
|
15
15
|
return lruCacheRef.current.get(key);
|
|
16
16
|
};
|
|
17
|
-
|
|
17
|
+
const clearCache = () => {
|
|
18
18
|
lruCacheRef.current.clear();
|
|
19
19
|
forceUpdate();
|
|
20
20
|
};
|
|
21
21
|
return {
|
|
22
|
-
setInCache
|
|
23
|
-
getFromCache
|
|
24
|
-
clearCache
|
|
22
|
+
setInCache,
|
|
23
|
+
getFromCache,
|
|
24
|
+
clearCache,
|
|
25
25
|
cache: lruCacheRef.current,
|
|
26
26
|
};
|
|
27
27
|
}
|
|
@@ -1,29 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __read = (this && this.__read) || function (o, n) {
|
|
3
|
-
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
4
|
-
if (!m) return o;
|
|
5
|
-
var i = m.call(o), r, ar = [], e;
|
|
6
|
-
try {
|
|
7
|
-
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
8
|
-
}
|
|
9
|
-
catch (error) { e = { error: error }; }
|
|
10
|
-
finally {
|
|
11
|
-
try {
|
|
12
|
-
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
13
|
-
}
|
|
14
|
-
finally { if (e) throw e.error; }
|
|
15
|
-
}
|
|
16
|
-
return ar;
|
|
17
|
-
};
|
|
18
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
19
3
|
exports.useLocalStorage = void 0;
|
|
20
|
-
|
|
4
|
+
const react_1 = require("react");
|
|
21
5
|
// For usage please refer
|
|
22
6
|
// https://github.com/streamich/react-use/blob/master/docs/useLocalStorage.md
|
|
23
|
-
|
|
24
|
-
|
|
7
|
+
const useLocalStorage = (key, initialValue, raw) => {
|
|
8
|
+
const [state, setState] = react_1.useState(() => {
|
|
25
9
|
try {
|
|
26
|
-
|
|
10
|
+
const localStorageValue = localStorage.getItem(key);
|
|
27
11
|
if (typeof localStorageValue !== 'string') {
|
|
28
12
|
localStorage.setItem(key, raw ? String(initialValue) : JSON.stringify(initialValue));
|
|
29
13
|
return initialValue;
|
|
@@ -38,10 +22,10 @@ var useLocalStorage = function (key, initialValue, raw) {
|
|
|
38
22
|
// can throw, too.
|
|
39
23
|
return initialValue;
|
|
40
24
|
}
|
|
41
|
-
})
|
|
42
|
-
react_1.useEffect(
|
|
25
|
+
});
|
|
26
|
+
react_1.useEffect(() => {
|
|
43
27
|
try {
|
|
44
|
-
|
|
28
|
+
const serializedState = raw ? String(state) : JSON.stringify(state);
|
|
45
29
|
localStorage.setItem(key, serializedState);
|
|
46
30
|
}
|
|
47
31
|
catch (_a) {
|
|
@@ -1,33 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __read = (this && this.__read) || function (o, n) {
|
|
3
|
-
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
4
|
-
if (!m) return o;
|
|
5
|
-
var i = m.call(o), r, ar = [], e;
|
|
6
|
-
try {
|
|
7
|
-
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
8
|
-
}
|
|
9
|
-
catch (error) { e = { error: error }; }
|
|
10
|
-
finally {
|
|
11
|
-
try {
|
|
12
|
-
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
13
|
-
}
|
|
14
|
-
finally { if (e) throw e.error; }
|
|
15
|
-
}
|
|
16
|
-
return ar;
|
|
17
|
-
};
|
|
18
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
19
3
|
exports.useOnScreen = void 0;
|
|
20
|
-
|
|
4
|
+
const react_1 = require("react");
|
|
21
5
|
function useOnScreen(ref) {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
return setIntersecting(entry.isIntersecting);
|
|
26
|
-
});
|
|
27
|
-
react_1.useEffect(function () {
|
|
6
|
+
const [isIntersecting, setIntersecting] = react_1.useState(false);
|
|
7
|
+
const observer = new IntersectionObserver(([entry]) => setIntersecting(entry.isIntersecting));
|
|
8
|
+
react_1.useEffect(() => {
|
|
28
9
|
observer.observe(ref.current);
|
|
29
10
|
// Remove the observer as soon as the component is unmounted
|
|
30
|
-
return
|
|
11
|
+
return () => {
|
|
31
12
|
observer.disconnect();
|
|
32
13
|
};
|
|
33
14
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
@@ -1,37 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __read = (this && this.__read) || function (o, n) {
|
|
3
|
-
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
4
|
-
if (!m) return o;
|
|
5
|
-
var i = m.call(o), r, ar = [], e;
|
|
6
|
-
try {
|
|
7
|
-
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
8
|
-
}
|
|
9
|
-
catch (error) { e = { error: error }; }
|
|
10
|
-
finally {
|
|
11
|
-
try {
|
|
12
|
-
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
13
|
-
}
|
|
14
|
-
finally { if (e) throw e.error; }
|
|
15
|
-
}
|
|
16
|
-
return ar;
|
|
17
|
-
};
|
|
18
|
-
var __spreadArray = (this && this.__spreadArray) || function (to, from) {
|
|
19
|
-
for (var i = 0, il = from.length, j = to.length; i < il; i++, j++)
|
|
20
|
-
to[j] = from[i];
|
|
21
|
-
return to;
|
|
22
|
-
};
|
|
23
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
24
3
|
exports.usePolling = void 0;
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
function usePolling(intervalCb, dependencies) {
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
var fetch = function () { return !document.hidden && intervalCb.apply(void 0, __spreadArray([], __read(depsRef.current))); };
|
|
4
|
+
const react_1 = require("react");
|
|
5
|
+
const refreshInterval = 120 * 1000;
|
|
6
|
+
function usePolling(intervalCb, dependencies = []) {
|
|
7
|
+
const depsRef = react_1.useRef(dependencies);
|
|
8
|
+
const fetch = () => !document.hidden && intervalCb(...depsRef.current);
|
|
31
9
|
depsRef.current = dependencies;
|
|
32
|
-
react_1.useEffect(
|
|
33
|
-
|
|
34
|
-
return
|
|
10
|
+
react_1.useEffect(() => {
|
|
11
|
+
const id = setInterval(fetch, refreshInterval);
|
|
12
|
+
return () => {
|
|
35
13
|
clearInterval(id);
|
|
36
14
|
};
|
|
37
15
|
// setInterval should only be called once and cleared on unmount
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.usePrevious = void 0;
|
|
4
|
-
|
|
4
|
+
const react_1 = require("react");
|
|
5
5
|
function usePrevious(value) {
|
|
6
|
-
|
|
7
|
-
react_1.useEffect(
|
|
6
|
+
const ref = react_1.useRef();
|
|
7
|
+
react_1.useEffect(() => {
|
|
8
8
|
ref.current = value;
|
|
9
9
|
}, [value]);
|
|
10
10
|
return ref.current;
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.useDocumentTitle = void 0;
|
|
4
|
-
|
|
4
|
+
const react_1 = require("react");
|
|
5
5
|
function useDocumentTitle(title) {
|
|
6
|
-
|
|
7
|
-
react_1.useEffect(
|
|
6
|
+
const originalTitle = document.title;
|
|
7
|
+
react_1.useEffect(() => {
|
|
8
8
|
document.title = title;
|
|
9
|
-
return
|
|
9
|
+
return () => {
|
|
10
10
|
document.title = originalTitle;
|
|
11
11
|
};
|
|
12
12
|
}, [title, originalTitle]);
|
package/lib/cjs/hooks/useUndo.js
CHANGED
|
@@ -1,28 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __read = (this && this.__read) || function (o, n) {
|
|
3
|
-
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
4
|
-
if (!m) return o;
|
|
5
|
-
var i = m.call(o), r, ar = [], e;
|
|
6
|
-
try {
|
|
7
|
-
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
8
|
-
}
|
|
9
|
-
catch (error) { e = { error: error }; }
|
|
10
|
-
finally {
|
|
11
|
-
try {
|
|
12
|
-
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
13
|
-
}
|
|
14
|
-
finally { if (e) throw e.error; }
|
|
15
|
-
}
|
|
16
|
-
return ar;
|
|
17
|
-
};
|
|
18
|
-
var __spreadArray = (this && this.__spreadArray) || function (to, from) {
|
|
19
|
-
for (var i = 0, il = from.length, j = to.length; i < il; i++, j++)
|
|
20
|
-
to[j] = from[i];
|
|
21
|
-
return to;
|
|
22
|
-
};
|
|
23
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
24
3
|
exports.useUndo = exports.UndoRedoActionConstant = void 0;
|
|
25
|
-
|
|
4
|
+
const react_1 = require("react");
|
|
26
5
|
var UndoRedoActionConstant;
|
|
27
6
|
(function (UndoRedoActionConstant) {
|
|
28
7
|
UndoRedoActionConstant["undoPresent"] = "UNDO_PRESENT";
|
|
@@ -30,70 +9,68 @@ var UndoRedoActionConstant;
|
|
|
30
9
|
UndoRedoActionConstant["setPresent"] = "SET_PRESENT";
|
|
31
10
|
UndoRedoActionConstant["resetPresent"] = "RESET_PRESENT";
|
|
32
11
|
})(UndoRedoActionConstant = exports.UndoRedoActionConstant || (exports.UndoRedoActionConstant = {}));
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
return state;
|
|
60
|
-
}
|
|
61
|
-
return {
|
|
62
|
-
past: __spreadArray(__spreadArray([], __read(past)), [present]),
|
|
63
|
-
present: action.payload.present,
|
|
64
|
-
future: [],
|
|
65
|
-
};
|
|
66
|
-
}
|
|
67
|
-
case UndoRedoActionConstant.resetPresent: {
|
|
68
|
-
return {
|
|
69
|
-
past: [],
|
|
70
|
-
present: action.payload.present,
|
|
71
|
-
future: [],
|
|
72
|
-
};
|
|
12
|
+
const undoRedoReducer = () => (state, action) => {
|
|
13
|
+
const { past, present, future } = state;
|
|
14
|
+
switch (action.type) {
|
|
15
|
+
case UndoRedoActionConstant.undoPresent: {
|
|
16
|
+
const previous = past[past.length - 1];
|
|
17
|
+
const newPast = past.slice(0, past.length - 1);
|
|
18
|
+
const t = {
|
|
19
|
+
past: newPast,
|
|
20
|
+
present: previous,
|
|
21
|
+
future: [present, ...future],
|
|
22
|
+
};
|
|
23
|
+
return t;
|
|
24
|
+
}
|
|
25
|
+
case UndoRedoActionConstant.redoPresent: {
|
|
26
|
+
const next = future[0];
|
|
27
|
+
const newFuture = future.slice(1);
|
|
28
|
+
const t1 = {
|
|
29
|
+
past: [...past, present],
|
|
30
|
+
present: next,
|
|
31
|
+
future: newFuture,
|
|
32
|
+
};
|
|
33
|
+
return t1;
|
|
34
|
+
}
|
|
35
|
+
case UndoRedoActionConstant.setPresent: {
|
|
36
|
+
if (action.payload.present === present) {
|
|
37
|
+
return state;
|
|
73
38
|
}
|
|
39
|
+
return {
|
|
40
|
+
past: [...past, present],
|
|
41
|
+
present: action.payload.present,
|
|
42
|
+
future: [],
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
case UndoRedoActionConstant.resetPresent: {
|
|
46
|
+
return {
|
|
47
|
+
past: [],
|
|
48
|
+
present: action.payload.present,
|
|
49
|
+
future: [],
|
|
50
|
+
};
|
|
74
51
|
}
|
|
75
|
-
}
|
|
52
|
+
}
|
|
76
53
|
};
|
|
77
54
|
function useUndo(initialPresent) {
|
|
78
|
-
|
|
55
|
+
const [state, dispatch] = react_1.useReducer(undoRedoReducer(), {
|
|
79
56
|
past: [],
|
|
80
57
|
present: initialPresent,
|
|
81
58
|
future: [],
|
|
82
|
-
})
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
59
|
+
});
|
|
60
|
+
const canUndo = state.past.length !== 0;
|
|
61
|
+
const canRedo = state.future.length !== 0;
|
|
62
|
+
const undo = react_1.useCallback(() => {
|
|
86
63
|
if (canUndo) {
|
|
87
64
|
dispatch({ type: UndoRedoActionConstant.undoPresent });
|
|
88
65
|
}
|
|
89
66
|
}, [canUndo]);
|
|
90
|
-
|
|
67
|
+
const redo = react_1.useCallback(() => {
|
|
91
68
|
if (canRedo) {
|
|
92
69
|
dispatch({ type: UndoRedoActionConstant.redoPresent });
|
|
93
70
|
}
|
|
94
71
|
}, [canRedo]);
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
return { state
|
|
72
|
+
const setURValue = react_1.useCallback((present) => dispatch({ type: UndoRedoActionConstant.setPresent, payload: { present } }), []);
|
|
73
|
+
const resetURValue = react_1.useCallback((present) => dispatch({ type: UndoRedoActionConstant.resetPresent, payload: { present } }), []);
|
|
74
|
+
return { state, setURValue, resetURValue, undo, redo, canUndo, canRedo };
|
|
98
75
|
}
|
|
99
76
|
exports.useUndo = useUndo;
|
package/lib/cjs/index.d.ts
CHANGED
package/lib/cjs/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAC;AACnC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,eAAe,CAAC;AAC9B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,iBAAiB,CAAC;AAChC,cAAc,cAAc,CAAC;AAC7B,cAAc,cAAc,CAAC;AAC7B,cAAc,SAAS,CAAC;AACxB,cAAc,kBAAkB,CAAC;AACjC,cAAc,cAAc,CAAC;AAC7B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,SAAS,CAAC;AACxB,cAAc,cAAc,CAAC;AAC7B,cAAc,qBAAqB,CAAC;AACpC,cAAc,uBAAuB,CAAC;AACtC,cAAc,oBAAoB,CAAC;AACnC,cAAc,iBAAiB,CAAC;AAChC,cAAc,cAAc,CAAC;AAC7B,cAAc,oBAAoB,CAAC;AACnC,cAAc,eAAe,CAAC;AAC9B,cAAc,oBAAoB,CAAC;AACnC,cAAc,qBAAqB,CAAC;AACpC,cAAc,oBAAoB,CAAC;AACnC,cAAc,qBAAqB,CAAC;AACpC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,uBAAuB,CAAC;AACtC,cAAc,mBAAmB,CAAC;AAClC,cAAc,kBAAkB,CAAC;AACjC,cAAc,qBAAqB,CAAC;AACpC,cAAc,sBAAsB,CAAC;AACrC,cAAc,qBAAqB,CAAC;AACpC,cAAc,mBAAmB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAC;AACnC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,eAAe,CAAC;AAC9B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,iBAAiB,CAAC;AAChC,cAAc,cAAc,CAAC;AAC7B,cAAc,cAAc,CAAC;AAC7B,cAAc,SAAS,CAAC;AACxB,cAAc,kBAAkB,CAAC;AACjC,cAAc,cAAc,CAAC;AAC7B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,SAAS,CAAC;AACxB,cAAc,cAAc,CAAC;AAC7B,cAAc,qBAAqB,CAAC;AACpC,cAAc,uBAAuB,CAAC;AACtC,cAAc,oBAAoB,CAAC;AACnC,cAAc,iBAAiB,CAAC;AAChC,cAAc,cAAc,CAAC;AAC7B,cAAc,oBAAoB,CAAC;AACnC,cAAc,eAAe,CAAC;AAC9B,cAAc,oBAAoB,CAAC;AACnC,cAAc,qBAAqB,CAAC;AACpC,cAAc,oBAAoB,CAAC;AACnC,cAAc,qBAAqB,CAAC;AACpC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,uBAAuB,CAAC;AACtC,cAAc,mBAAmB,CAAC;AAClC,cAAc,kBAAkB,CAAC;AACjC,cAAc,qBAAqB,CAAC;AACpC,cAAc,sBAAsB,CAAC;AACrC,cAAc,qBAAqB,CAAC;AACpC,cAAc,mBAAmB,CAAC;AAClC,cAAc,cAAc,CAAC"}
|
package/lib/cjs/index.js
CHANGED
|
@@ -42,3 +42,4 @@ __exportStar(require("./SubscriptionAbuse"), exports);
|
|
|
42
42
|
__exportStar(require("./TermsAndConditions"), exports);
|
|
43
43
|
__exportStar(require("./TextAreaResizable"), exports);
|
|
44
44
|
__exportStar(require("./CustomTextInput"), exports);
|
|
45
|
+
__exportStar(require("./PhoneInput"), exports);
|