@eztrak/shared 0.13.6 → 0.13.8
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/{chunk-PXUB5ZF7.mjs → chunk-4SOWLOGR.mjs} +84 -3
- package/dist/{chunk-PXUB5ZF7.mjs.map → chunk-4SOWLOGR.mjs.map} +1 -1
- package/dist/{chunk-YWS7JMII.mjs → chunk-DSP67UYZ.mjs} +50 -2
- package/dist/chunk-DSP67UYZ.mjs.map +1 -0
- package/dist/chunk-UIDXC5S2.mjs +60 -0
- package/dist/chunk-UIDXC5S2.mjs.map +1 -0
- package/dist/components/index.d.mts +15 -1
- package/dist/components/index.d.ts +15 -1
- package/dist/components/index.js +115 -0
- package/dist/components/index.js.map +1 -1
- package/dist/components/index.mjs +4 -2
- package/dist/handleApiError-CwVIJOqO.d.mts +49 -0
- package/dist/handleApiError-CwVIJOqO.d.ts +49 -0
- package/dist/index.d.mts +4 -2
- package/dist/index.d.ts +4 -2
- package/dist/index.js +173 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +11 -3
- package/dist/utils/index.d.mts +11 -35
- package/dist/utils/index.d.ts +11 -35
- package/dist/utils/index.js +92 -1
- package/dist/utils/index.js.map +1 -1
- package/dist/utils/index.mjs +8 -2
- package/package.json +5 -3
- package/dist/chunk-5HXJ4WHA.mjs +0 -16
- package/dist/chunk-5HXJ4WHA.mjs.map +0 -1
- package/dist/chunk-YWS7JMII.mjs.map +0 -1
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
type RtkQueryError = {
|
|
2
|
+
status?: number | string;
|
|
3
|
+
originalStatus?: number;
|
|
4
|
+
data?: {
|
|
5
|
+
errors?: Record<string, string[]>;
|
|
6
|
+
message?: string;
|
|
7
|
+
title?: string;
|
|
8
|
+
};
|
|
9
|
+
message?: string;
|
|
10
|
+
error?: string;
|
|
11
|
+
};
|
|
12
|
+
interface HandleApiErrorOptions {
|
|
13
|
+
showAlert?: boolean;
|
|
14
|
+
fallbackMessage?: string;
|
|
15
|
+
}
|
|
16
|
+
type ErrorSuggestedAction = "retry" | "refresh" | "contact-support" | "none";
|
|
17
|
+
type ErrorClassification = {
|
|
18
|
+
isRetryable: boolean;
|
|
19
|
+
userMessage: string;
|
|
20
|
+
technicalMessage: string;
|
|
21
|
+
suggestedAction: ErrorSuggestedAction;
|
|
22
|
+
};
|
|
23
|
+
/** Returns true for transient network/server errors that warrant automatic retry. */
|
|
24
|
+
declare function isRetryableError(error: RtkQueryError | null | undefined): boolean;
|
|
25
|
+
/** Classifies RTK Query errors for user messaging and retry guidance. */
|
|
26
|
+
declare function classifyError(error: RtkQueryError | null | undefined): ErrorClassification;
|
|
27
|
+
declare function formatValidationErrorsHtml(errors: Record<string, string[]>): string;
|
|
28
|
+
/** Handles RTK Query errors with built-in toast.error or SweetAlert (when showAlert is true). */
|
|
29
|
+
declare function handleApiError(error: RtkQueryError | null | undefined, { showAlert, fallbackMessage }?: HandleApiErrorOptions): void;
|
|
30
|
+
interface ConfirmationAlertOptions {
|
|
31
|
+
title?: string;
|
|
32
|
+
text?: string;
|
|
33
|
+
html?: string;
|
|
34
|
+
icon?: "warning" | "info" | "question" | "error" | "success";
|
|
35
|
+
confirmButtonText?: string;
|
|
36
|
+
cancelButtonText?: string;
|
|
37
|
+
confirmButtonColor?: string;
|
|
38
|
+
cancelButtonColor?: string;
|
|
39
|
+
showLoaderOnConfirm?: boolean;
|
|
40
|
+
/** Type exactly — trimmed, case-sensitive. */
|
|
41
|
+
inputExpectedValue?: string;
|
|
42
|
+
inputPlaceholder?: string;
|
|
43
|
+
reverseButtons?: boolean;
|
|
44
|
+
focusCancel?: boolean;
|
|
45
|
+
zIndex?: number;
|
|
46
|
+
}
|
|
47
|
+
declare function confirmationAlert(onConfirm: () => void | Promise<void>, options?: ConfirmationAlertOptions): void;
|
|
48
|
+
|
|
49
|
+
export { type ConfirmationAlertOptions as C, type ErrorClassification as E, type HandleApiErrorOptions as H, type RtkQueryError as R, type ErrorSuggestedAction as a, confirmationAlert as b, classifyError as c, formatValidationErrorsHtml as f, handleApiError as h, isRetryableError as i };
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
type RtkQueryError = {
|
|
2
|
+
status?: number | string;
|
|
3
|
+
originalStatus?: number;
|
|
4
|
+
data?: {
|
|
5
|
+
errors?: Record<string, string[]>;
|
|
6
|
+
message?: string;
|
|
7
|
+
title?: string;
|
|
8
|
+
};
|
|
9
|
+
message?: string;
|
|
10
|
+
error?: string;
|
|
11
|
+
};
|
|
12
|
+
interface HandleApiErrorOptions {
|
|
13
|
+
showAlert?: boolean;
|
|
14
|
+
fallbackMessage?: string;
|
|
15
|
+
}
|
|
16
|
+
type ErrorSuggestedAction = "retry" | "refresh" | "contact-support" | "none";
|
|
17
|
+
type ErrorClassification = {
|
|
18
|
+
isRetryable: boolean;
|
|
19
|
+
userMessage: string;
|
|
20
|
+
technicalMessage: string;
|
|
21
|
+
suggestedAction: ErrorSuggestedAction;
|
|
22
|
+
};
|
|
23
|
+
/** Returns true for transient network/server errors that warrant automatic retry. */
|
|
24
|
+
declare function isRetryableError(error: RtkQueryError | null | undefined): boolean;
|
|
25
|
+
/** Classifies RTK Query errors for user messaging and retry guidance. */
|
|
26
|
+
declare function classifyError(error: RtkQueryError | null | undefined): ErrorClassification;
|
|
27
|
+
declare function formatValidationErrorsHtml(errors: Record<string, string[]>): string;
|
|
28
|
+
/** Handles RTK Query errors with built-in toast.error or SweetAlert (when showAlert is true). */
|
|
29
|
+
declare function handleApiError(error: RtkQueryError | null | undefined, { showAlert, fallbackMessage }?: HandleApiErrorOptions): void;
|
|
30
|
+
interface ConfirmationAlertOptions {
|
|
31
|
+
title?: string;
|
|
32
|
+
text?: string;
|
|
33
|
+
html?: string;
|
|
34
|
+
icon?: "warning" | "info" | "question" | "error" | "success";
|
|
35
|
+
confirmButtonText?: string;
|
|
36
|
+
cancelButtonText?: string;
|
|
37
|
+
confirmButtonColor?: string;
|
|
38
|
+
cancelButtonColor?: string;
|
|
39
|
+
showLoaderOnConfirm?: boolean;
|
|
40
|
+
/** Type exactly — trimmed, case-sensitive. */
|
|
41
|
+
inputExpectedValue?: string;
|
|
42
|
+
inputPlaceholder?: string;
|
|
43
|
+
reverseButtons?: boolean;
|
|
44
|
+
focusCancel?: boolean;
|
|
45
|
+
zIndex?: number;
|
|
46
|
+
}
|
|
47
|
+
declare function confirmationAlert(onConfirm: () => void | Promise<void>, options?: ConfirmationAlertOptions): void;
|
|
48
|
+
|
|
49
|
+
export { type ConfirmationAlertOptions as C, type ErrorClassification as E, type HandleApiErrorOptions as H, type RtkQueryError as R, type ErrorSuggestedAction as a, confirmationAlert as b, classifyError as c, formatValidationErrorsHtml as f, handleApiError as h, isRetryableError as i };
|
package/dist/index.d.mts
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { CreateBaseQueryWithRetryOptions, PermissionRecord, TransformedPermissions, USER_STATE_STORAGE_KEY, capitalizeText, checkIfExistsInArray, cn, convertCommaDataToArray, createBaseQueryWithRetry, currencyFormatter, deserializeJson, flattenTableData, formatDate, formatDateTime, formatNumber, get, getApiError, getErrorMessages, getFieldsByCategory, getFieldsByInputType, getFieldsByName, getItem, getItemFromLocalStorage, isEmpty, loadUserState, normalizeApiListItems, parseCurrencyValueToNumber, removeByPropertyValues, removeItem, saveItemLocalStorage, saveUserState, set, setItem, storeItemInLocalStorage, toDateInputValue, toLowerCaseText, transformPermissions, truncateFileName, truncateText } from './utils/index.mjs';
|
|
2
|
+
export { C as ConfirmationAlertOptions, E as ErrorClassification, a as ErrorSuggestedAction, H as HandleApiErrorOptions, R as RtkQueryError, c as classifyError, b as confirmationAlert, f as formatValidationErrorsHtml, h as handleApiError, i as isRetryableError } from './handleApiError-CwVIJOqO.mjs';
|
|
2
3
|
export { UseGridHeightOptions, useGridHeight, usePaginationUrlSync } from './hooks/index.mjs';
|
|
3
|
-
export { CardSkeleton, CardSkeletonProps, CardSkeletonVariant, CellEditPayload, CellEditorInputType, CustomCellEditor, CustomCellEditorProps, CustomCellEditorRef, CustomPagination, CustomPaginationClassNames, CustomPaginationProps, DropdownFilter, DropdownFilterProps, DropdownOption, EztrakTab, EztrakTabs, EztrakTabsClassNames, EztrakTabsProps, LayoutStatus, Loader, LoaderProps, Modal, ModalProps, PaginationData, PopupActionHandler, PopupCellRenderer, PopupCellRendererParams, PopupCellRendererProps, PopupDropDownContent, ResetColumnsButton, ResetColumnsButtonProps, ResetFiltersButton, ResetFiltersButtonProps, ResetFiltersButtonVariant, SearchInput, SearchInputProps, TableLayoutToolbarControls, TableLayoutToolbarControlsProps, ToolTip, ToolTipProps, TooltipText, TooltipTextProps, dropdownStyles } from './components/index.mjs';
|
|
4
|
+
export { CardSkeleton, CardSkeletonProps, CardSkeletonVariant, CellEditPayload, CellEditorInputType, CustomCellEditor, CustomCellEditorProps, CustomCellEditorRef, CustomPagination, CustomPaginationClassNames, CustomPaginationProps, DropdownFilter, DropdownFilterProps, DropdownOption, EztrakTab, EztrakTabs, EztrakTabsClassNames, EztrakTabsProps, LayoutStatus, Loader, LoaderProps, Modal, ModalProps, PaginationData, PopupActionHandler, PopupCellRenderer, PopupCellRendererParams, PopupCellRendererProps, PopupDropDownContent, ResetColumnsButton, ResetColumnsButtonProps, ResetFiltersButton, ResetFiltersButtonProps, ResetFiltersButtonVariant, SearchInput, SearchInputProps, TableErrorBoundary, TableErrorBoundaryProps, TableLayoutToolbarControls, TableLayoutToolbarControlsProps, ToolTip, ToolTipProps, TooltipText, TooltipTextProps, dropdownStyles } from './components/index.mjs';
|
|
4
5
|
import 'clsx';
|
|
6
|
+
import '@reduxjs/toolkit/query';
|
|
5
7
|
import 'react-router-dom';
|
|
6
8
|
import 'react';
|
|
7
9
|
import 'react-select';
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { CreateBaseQueryWithRetryOptions, PermissionRecord, TransformedPermissions, USER_STATE_STORAGE_KEY, capitalizeText, checkIfExistsInArray, cn, convertCommaDataToArray, createBaseQueryWithRetry, currencyFormatter, deserializeJson, flattenTableData, formatDate, formatDateTime, formatNumber, get, getApiError, getErrorMessages, getFieldsByCategory, getFieldsByInputType, getFieldsByName, getItem, getItemFromLocalStorage, isEmpty, loadUserState, normalizeApiListItems, parseCurrencyValueToNumber, removeByPropertyValues, removeItem, saveItemLocalStorage, saveUserState, set, setItem, storeItemInLocalStorage, toDateInputValue, toLowerCaseText, transformPermissions, truncateFileName, truncateText } from './utils/index.js';
|
|
2
|
+
export { C as ConfirmationAlertOptions, E as ErrorClassification, a as ErrorSuggestedAction, H as HandleApiErrorOptions, R as RtkQueryError, c as classifyError, b as confirmationAlert, f as formatValidationErrorsHtml, h as handleApiError, i as isRetryableError } from './handleApiError-CwVIJOqO.js';
|
|
2
3
|
export { UseGridHeightOptions, useGridHeight, usePaginationUrlSync } from './hooks/index.js';
|
|
3
|
-
export { CardSkeleton, CardSkeletonProps, CardSkeletonVariant, CellEditPayload, CellEditorInputType, CustomCellEditor, CustomCellEditorProps, CustomCellEditorRef, CustomPagination, CustomPaginationClassNames, CustomPaginationProps, DropdownFilter, DropdownFilterProps, DropdownOption, EztrakTab, EztrakTabs, EztrakTabsClassNames, EztrakTabsProps, LayoutStatus, Loader, LoaderProps, Modal, ModalProps, PaginationData, PopupActionHandler, PopupCellRenderer, PopupCellRendererParams, PopupCellRendererProps, PopupDropDownContent, ResetColumnsButton, ResetColumnsButtonProps, ResetFiltersButton, ResetFiltersButtonProps, ResetFiltersButtonVariant, SearchInput, SearchInputProps, TableLayoutToolbarControls, TableLayoutToolbarControlsProps, ToolTip, ToolTipProps, TooltipText, TooltipTextProps, dropdownStyles } from './components/index.js';
|
|
4
|
+
export { CardSkeleton, CardSkeletonProps, CardSkeletonVariant, CellEditPayload, CellEditorInputType, CustomCellEditor, CustomCellEditorProps, CustomCellEditorRef, CustomPagination, CustomPaginationClassNames, CustomPaginationProps, DropdownFilter, DropdownFilterProps, DropdownOption, EztrakTab, EztrakTabs, EztrakTabsClassNames, EztrakTabsProps, LayoutStatus, Loader, LoaderProps, Modal, ModalProps, PaginationData, PopupActionHandler, PopupCellRenderer, PopupCellRendererParams, PopupCellRendererProps, PopupDropDownContent, ResetColumnsButton, ResetColumnsButtonProps, ResetFiltersButton, ResetFiltersButtonProps, ResetFiltersButtonVariant, SearchInput, SearchInputProps, TableErrorBoundary, TableErrorBoundaryProps, TableLayoutToolbarControls, TableLayoutToolbarControlsProps, ToolTip, ToolTipProps, TooltipText, TooltipTextProps, dropdownStyles } from './components/index.js';
|
|
4
5
|
import 'clsx';
|
|
6
|
+
import '@reduxjs/toolkit/query';
|
|
5
7
|
import 'react-router-dom';
|
|
6
8
|
import 'react';
|
|
7
9
|
import 'react-select';
|
package/dist/index.js
CHANGED
|
@@ -41,15 +41,18 @@ __export(src_exports, {
|
|
|
41
41
|
ResetColumnsButton: () => ResetColumnsButton,
|
|
42
42
|
ResetFiltersButton: () => ResetFiltersButton,
|
|
43
43
|
SearchInput: () => SearchInput,
|
|
44
|
+
TableErrorBoundary: () => TableErrorBoundary,
|
|
44
45
|
TableLayoutToolbarControls: () => TableLayoutToolbarControls,
|
|
45
46
|
ToolTip: () => ToolTip,
|
|
46
47
|
TooltipText: () => TooltipText,
|
|
47
48
|
USER_STATE_STORAGE_KEY: () => USER_STATE_STORAGE_KEY,
|
|
48
49
|
capitalizeText: () => capitalizeText,
|
|
49
50
|
checkIfExistsInArray: () => checkIfExistsInArray,
|
|
51
|
+
classifyError: () => classifyError,
|
|
50
52
|
cn: () => cn,
|
|
51
53
|
confirmationAlert: () => confirmationAlert,
|
|
52
54
|
convertCommaDataToArray: () => convertCommaDataToArray,
|
|
55
|
+
createBaseQueryWithRetry: () => createBaseQueryWithRetry,
|
|
53
56
|
currencyFormatter: () => currencyFormatter,
|
|
54
57
|
deserializeJson: () => deserializeJson,
|
|
55
58
|
dropdownStyles: () => dropdownStyles,
|
|
@@ -68,6 +71,7 @@ __export(src_exports, {
|
|
|
68
71
|
getItemFromLocalStorage: () => getItemFromLocalStorage,
|
|
69
72
|
handleApiError: () => handleApiError,
|
|
70
73
|
isEmpty: () => isEmpty,
|
|
74
|
+
isRetryableError: () => isRetryableError,
|
|
71
75
|
loadUserState: () => loadUserState,
|
|
72
76
|
normalizeApiListItems: () => normalizeApiListItems,
|
|
73
77
|
parseCurrencyValueToNumber: () => parseCurrencyValueToNumber,
|
|
@@ -350,6 +354,52 @@ function transformPermissions(permissions) {
|
|
|
350
354
|
// src/utils/handleApiError.ts
|
|
351
355
|
var import_react_hot_toast = __toESM(require("react-hot-toast"));
|
|
352
356
|
var import_sweetalert2 = __toESM(require("sweetalert2"));
|
|
357
|
+
function isRetryableError(error) {
|
|
358
|
+
if (!error) return false;
|
|
359
|
+
const status = error.status ?? error.originalStatus;
|
|
360
|
+
if (status === "FETCH_ERROR" || status === "TIMEOUT_ERROR" || status === "PARSING_ERROR") {
|
|
361
|
+
return true;
|
|
362
|
+
}
|
|
363
|
+
if (typeof status === "number") {
|
|
364
|
+
if (status === 502 || status === 503 || status === 504) return true;
|
|
365
|
+
if (status >= 500 && status < 600) return true;
|
|
366
|
+
}
|
|
367
|
+
return false;
|
|
368
|
+
}
|
|
369
|
+
function classifyError(error) {
|
|
370
|
+
if (!error) {
|
|
371
|
+
return {
|
|
372
|
+
isRetryable: false,
|
|
373
|
+
userMessage: "An error occurred.",
|
|
374
|
+
technicalMessage: "Unknown error",
|
|
375
|
+
suggestedAction: "none"
|
|
376
|
+
};
|
|
377
|
+
}
|
|
378
|
+
const status = error.status ?? error.originalStatus;
|
|
379
|
+
const data = error.data;
|
|
380
|
+
if (status === "FETCH_ERROR" || status === "TIMEOUT_ERROR" || status === "PARSING_ERROR") {
|
|
381
|
+
return {
|
|
382
|
+
isRetryable: true,
|
|
383
|
+
userMessage: "Network error. Please check your connection.",
|
|
384
|
+
technicalMessage: "Network request failed",
|
|
385
|
+
suggestedAction: "retry"
|
|
386
|
+
};
|
|
387
|
+
}
|
|
388
|
+
if (typeof status === "number" && status >= 500 && status < 600) {
|
|
389
|
+
return {
|
|
390
|
+
isRetryable: true,
|
|
391
|
+
userMessage: "Server is temporarily unavailable. Please try again.",
|
|
392
|
+
technicalMessage: `Server error: ${status}`,
|
|
393
|
+
suggestedAction: "retry"
|
|
394
|
+
};
|
|
395
|
+
}
|
|
396
|
+
return {
|
|
397
|
+
isRetryable: false,
|
|
398
|
+
userMessage: data?.message || data?.title || error.error || "An error occurred. Please try again.",
|
|
399
|
+
technicalMessage: typeof status === "number" || typeof status === "string" ? `Client error: ${status}` : "Request failed",
|
|
400
|
+
suggestedAction: "none"
|
|
401
|
+
};
|
|
402
|
+
}
|
|
353
403
|
function formatValidationErrorsHtml(errors) {
|
|
354
404
|
const items = Object.keys(errors).flatMap(
|
|
355
405
|
(field) => (errors[field] || []).map((msg) => `<li>${msg}</li>`)
|
|
@@ -396,7 +446,7 @@ function handleApiError(error, { showAlert = false, fallbackMessage } = {}) {
|
|
|
396
446
|
if (status === 404) {
|
|
397
447
|
return;
|
|
398
448
|
}
|
|
399
|
-
const message = fallbackMessage || data?.message || data?.title || error.error || "An error occurred. Please try again.";
|
|
449
|
+
const message = fallbackMessage || data?.message || data?.title || error.error || error.message || "An error occurred. Please try again.";
|
|
400
450
|
import_react_hot_toast.default.error(message);
|
|
401
451
|
}
|
|
402
452
|
var BRAND_ORANGE = "#FF7335";
|
|
@@ -489,6 +539,45 @@ function confirmationAlert(onConfirm, options = {}) {
|
|
|
489
539
|
});
|
|
490
540
|
}
|
|
491
541
|
|
|
542
|
+
// src/utils/createBaseQueryWithRetry.ts
|
|
543
|
+
var import_query = require("@reduxjs/toolkit/query");
|
|
544
|
+
function getRequestMethod(args) {
|
|
545
|
+
if (typeof args === "string") return "GET";
|
|
546
|
+
if (args && typeof args === "object" && "method" in args) {
|
|
547
|
+
const method = args.method;
|
|
548
|
+
return (method || "GET").toUpperCase();
|
|
549
|
+
}
|
|
550
|
+
return "GET";
|
|
551
|
+
}
|
|
552
|
+
function createBaseQueryWithRetry(baseQueryWithReauth, {
|
|
553
|
+
maxRetries = 3,
|
|
554
|
+
maxBackoffMs = 8e3
|
|
555
|
+
} = {}) {
|
|
556
|
+
const retryableQuery = (0, import_query.retry)(
|
|
557
|
+
async (args, api, extraOptions) => {
|
|
558
|
+
const result = await baseQueryWithReauth(args, api, extraOptions);
|
|
559
|
+
if (result.error && !isRetryableError(result.error)) {
|
|
560
|
+
import_query.retry.fail(result.error);
|
|
561
|
+
}
|
|
562
|
+
return result;
|
|
563
|
+
},
|
|
564
|
+
{
|
|
565
|
+
maxRetries,
|
|
566
|
+
backoff: (attempt) => new Promise(
|
|
567
|
+
(resolve) => setTimeout(resolve, Math.min(1e3 * 2 ** attempt, maxBackoffMs))
|
|
568
|
+
)
|
|
569
|
+
}
|
|
570
|
+
);
|
|
571
|
+
const baseQueryWithConditionalRetry = async (args, api, extraOptions) => {
|
|
572
|
+
const method = getRequestMethod(args);
|
|
573
|
+
if (method !== "GET") {
|
|
574
|
+
return baseQueryWithReauth(args, api, extraOptions);
|
|
575
|
+
}
|
|
576
|
+
return retryableQuery(args, api, extraOptions);
|
|
577
|
+
};
|
|
578
|
+
return baseQueryWithConditionalRetry;
|
|
579
|
+
}
|
|
580
|
+
|
|
492
581
|
// src/hooks/usePaginationUrlSync.ts
|
|
493
582
|
var import_react = require("react");
|
|
494
583
|
var usePaginationUrlSync = (searchParams, setSearchParams, page, setPage, perPage, setPerPage, defaultPage = 1, defaultPerPage = 20) => {
|
|
@@ -2091,6 +2180,85 @@ function PopupCellRenderer({
|
|
|
2091
2180
|
}
|
|
2092
2181
|
) });
|
|
2093
2182
|
}
|
|
2183
|
+
|
|
2184
|
+
// src/components/table-error-boundary/TableErrorBoundary.tsx
|
|
2185
|
+
var import_react11 = require("react");
|
|
2186
|
+
var import_fa6 = require("react-icons/fa6");
|
|
2187
|
+
var import_jsx_runtime13 = require("react/jsx-runtime");
|
|
2188
|
+
var TableErrorBoundary = ({
|
|
2189
|
+
isError,
|
|
2190
|
+
isLoading = false,
|
|
2191
|
+
refetch,
|
|
2192
|
+
children,
|
|
2193
|
+
error,
|
|
2194
|
+
errorMessage,
|
|
2195
|
+
className,
|
|
2196
|
+
minHeight = "280px"
|
|
2197
|
+
}) => {
|
|
2198
|
+
const message = (0, import_react11.useMemo)(() => {
|
|
2199
|
+
if (errorMessage) return errorMessage;
|
|
2200
|
+
if (error) return classifyError(error).userMessage;
|
|
2201
|
+
return "Unable to load table data. Please try again.";
|
|
2202
|
+
}, [error, errorMessage]);
|
|
2203
|
+
if (isLoading && !isError) {
|
|
2204
|
+
return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|
|
2205
|
+
"div",
|
|
2206
|
+
{
|
|
2207
|
+
className: cn(
|
|
2208
|
+
"flex w-full items-center justify-center rounded-xl bg-neutral-50",
|
|
2209
|
+
className
|
|
2210
|
+
),
|
|
2211
|
+
style: { minHeight },
|
|
2212
|
+
role: "status",
|
|
2213
|
+
"aria-live": "polite",
|
|
2214
|
+
"aria-busy": "true",
|
|
2215
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(Loader, { size: "40px" })
|
|
2216
|
+
}
|
|
2217
|
+
);
|
|
2218
|
+
}
|
|
2219
|
+
if (isError) {
|
|
2220
|
+
return /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(
|
|
2221
|
+
"div",
|
|
2222
|
+
{
|
|
2223
|
+
className: cn(
|
|
2224
|
+
"flex w-full flex-col items-center justify-center gap-4 rounded-xl border border-red-100 bg-red-50 px-6 py-10 text-center",
|
|
2225
|
+
className
|
|
2226
|
+
),
|
|
2227
|
+
style: { minHeight },
|
|
2228
|
+
role: "alert",
|
|
2229
|
+
"aria-live": "assertive",
|
|
2230
|
+
children: [
|
|
2231
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|
|
2232
|
+
import_fa6.FaTriangleExclamation,
|
|
2233
|
+
{
|
|
2234
|
+
className: "text-red-500",
|
|
2235
|
+
size: 32,
|
|
2236
|
+
"aria-hidden": true
|
|
2237
|
+
}
|
|
2238
|
+
),
|
|
2239
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("div", { className: "max-w-md space-y-1", children: [
|
|
2240
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)("p", { className: "text-base font-semibold text-gray-800", children: "Failed to load data" }),
|
|
2241
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)("p", { className: "text-sm text-gray-600", children: message })
|
|
2242
|
+
] }),
|
|
2243
|
+
refetch && /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(
|
|
2244
|
+
"button",
|
|
2245
|
+
{
|
|
2246
|
+
type: "button",
|
|
2247
|
+
onClick: () => refetch(),
|
|
2248
|
+
disabled: isLoading,
|
|
2249
|
+
className: "inline-flex items-center gap-2 rounded-lg bg-primary-150 px-4 py-2 text-sm font-medium text-white transition-colors hover:opacity-90 disabled:cursor-not-allowed disabled:opacity-60",
|
|
2250
|
+
children: [
|
|
2251
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_fa6.FaArrowsRotate, { className: cn(isLoading && "animate-spin") }),
|
|
2252
|
+
isLoading ? "Retrying..." : "Try again"
|
|
2253
|
+
]
|
|
2254
|
+
}
|
|
2255
|
+
)
|
|
2256
|
+
]
|
|
2257
|
+
}
|
|
2258
|
+
);
|
|
2259
|
+
}
|
|
2260
|
+
return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_jsx_runtime13.Fragment, { children });
|
|
2261
|
+
};
|
|
2094
2262
|
// Annotate the CommonJS export names for ESM import in node:
|
|
2095
2263
|
0 && (module.exports = {
|
|
2096
2264
|
CardSkeleton,
|
|
@@ -2104,15 +2272,18 @@ function PopupCellRenderer({
|
|
|
2104
2272
|
ResetColumnsButton,
|
|
2105
2273
|
ResetFiltersButton,
|
|
2106
2274
|
SearchInput,
|
|
2275
|
+
TableErrorBoundary,
|
|
2107
2276
|
TableLayoutToolbarControls,
|
|
2108
2277
|
ToolTip,
|
|
2109
2278
|
TooltipText,
|
|
2110
2279
|
USER_STATE_STORAGE_KEY,
|
|
2111
2280
|
capitalizeText,
|
|
2112
2281
|
checkIfExistsInArray,
|
|
2282
|
+
classifyError,
|
|
2113
2283
|
cn,
|
|
2114
2284
|
confirmationAlert,
|
|
2115
2285
|
convertCommaDataToArray,
|
|
2286
|
+
createBaseQueryWithRetry,
|
|
2116
2287
|
currencyFormatter,
|
|
2117
2288
|
deserializeJson,
|
|
2118
2289
|
dropdownStyles,
|
|
@@ -2131,6 +2302,7 @@ function PopupCellRenderer({
|
|
|
2131
2302
|
getItemFromLocalStorage,
|
|
2132
2303
|
handleApiError,
|
|
2133
2304
|
isEmpty,
|
|
2305
|
+
isRetryableError,
|
|
2134
2306
|
loadUserState,
|
|
2135
2307
|
normalizeApiListItems,
|
|
2136
2308
|
parseCurrencyValueToNumber,
|