@eztrak/shared 0.13.5 → 0.13.7
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-YWS7JMII.mjs → chunk-2JMFMMKR.mjs} +49 -1
- package/dist/chunk-2JMFMMKR.mjs.map +1 -0
- package/dist/{chunk-PXUB5ZF7.mjs → chunk-AO27YNP3.mjs} +84 -3
- package/dist/{chunk-PXUB5ZF7.mjs.map → chunk-AO27YNP3.mjs.map} +1 -1
- package/dist/chunk-PLAAQZDU.mjs +60 -0
- package/dist/chunk-PLAAQZDU.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-Dgh_d-CX.d.mts +48 -0
- package/dist/handleApiError-Dgh_d-CX.d.ts +48 -0
- package/dist/index.d.mts +4 -2
- package/dist/index.d.ts +4 -2
- package/dist/index.js +186 -0
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +14 -3
- package/dist/utils/index.d.mts +19 -35
- package/dist/utils/index.d.ts +19 -35
- package/dist/utils/index.js +105 -0
- package/dist/utils/index.js.map +1 -1
- package/dist/utils/index.mjs +11 -2
- package/package.json +5 -3
- package/dist/chunk-HGLO5LDS.mjs +0 -1
- package/dist/chunk-HGLO5LDS.mjs.map +0 -1
- package/dist/chunk-YWS7JMII.mjs.map +0 -1
|
@@ -0,0 +1,48 @@
|
|
|
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
|
+
error?: string;
|
|
10
|
+
};
|
|
11
|
+
interface HandleApiErrorOptions {
|
|
12
|
+
showAlert?: boolean;
|
|
13
|
+
fallbackMessage?: string;
|
|
14
|
+
}
|
|
15
|
+
type ErrorSuggestedAction = "retry" | "refresh" | "contact-support" | "none";
|
|
16
|
+
type ErrorClassification = {
|
|
17
|
+
isRetryable: boolean;
|
|
18
|
+
userMessage: string;
|
|
19
|
+
technicalMessage: string;
|
|
20
|
+
suggestedAction: ErrorSuggestedAction;
|
|
21
|
+
};
|
|
22
|
+
/** Returns true for transient network/server errors that warrant automatic retry. */
|
|
23
|
+
declare function isRetryableError(error: RtkQueryError | null | undefined): boolean;
|
|
24
|
+
/** Classifies RTK Query errors for user messaging and retry guidance. */
|
|
25
|
+
declare function classifyError(error: RtkQueryError | null | undefined): ErrorClassification;
|
|
26
|
+
declare function formatValidationErrorsHtml(errors: Record<string, string[]>): string;
|
|
27
|
+
/** Handles RTK Query errors with built-in toast.error or SweetAlert (when showAlert is true). */
|
|
28
|
+
declare function handleApiError(error: RtkQueryError | null | undefined, { showAlert, fallbackMessage }?: HandleApiErrorOptions): void;
|
|
29
|
+
interface ConfirmationAlertOptions {
|
|
30
|
+
title?: string;
|
|
31
|
+
text?: string;
|
|
32
|
+
html?: string;
|
|
33
|
+
icon?: "warning" | "info" | "question" | "error" | "success";
|
|
34
|
+
confirmButtonText?: string;
|
|
35
|
+
cancelButtonText?: string;
|
|
36
|
+
confirmButtonColor?: string;
|
|
37
|
+
cancelButtonColor?: string;
|
|
38
|
+
showLoaderOnConfirm?: boolean;
|
|
39
|
+
/** Type exactly — trimmed, case-sensitive. */
|
|
40
|
+
inputExpectedValue?: string;
|
|
41
|
+
inputPlaceholder?: string;
|
|
42
|
+
reverseButtons?: boolean;
|
|
43
|
+
focusCancel?: boolean;
|
|
44
|
+
zIndex?: number;
|
|
45
|
+
}
|
|
46
|
+
declare function confirmationAlert(onConfirm: () => void | Promise<void>, options?: ConfirmationAlertOptions): void;
|
|
47
|
+
|
|
48
|
+
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,48 @@
|
|
|
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
|
+
error?: string;
|
|
10
|
+
};
|
|
11
|
+
interface HandleApiErrorOptions {
|
|
12
|
+
showAlert?: boolean;
|
|
13
|
+
fallbackMessage?: string;
|
|
14
|
+
}
|
|
15
|
+
type ErrorSuggestedAction = "retry" | "refresh" | "contact-support" | "none";
|
|
16
|
+
type ErrorClassification = {
|
|
17
|
+
isRetryable: boolean;
|
|
18
|
+
userMessage: string;
|
|
19
|
+
technicalMessage: string;
|
|
20
|
+
suggestedAction: ErrorSuggestedAction;
|
|
21
|
+
};
|
|
22
|
+
/** Returns true for transient network/server errors that warrant automatic retry. */
|
|
23
|
+
declare function isRetryableError(error: RtkQueryError | null | undefined): boolean;
|
|
24
|
+
/** Classifies RTK Query errors for user messaging and retry guidance. */
|
|
25
|
+
declare function classifyError(error: RtkQueryError | null | undefined): ErrorClassification;
|
|
26
|
+
declare function formatValidationErrorsHtml(errors: Record<string, string[]>): string;
|
|
27
|
+
/** Handles RTK Query errors with built-in toast.error or SweetAlert (when showAlert is true). */
|
|
28
|
+
declare function handleApiError(error: RtkQueryError | null | undefined, { showAlert, fallbackMessage }?: HandleApiErrorOptions): void;
|
|
29
|
+
interface ConfirmationAlertOptions {
|
|
30
|
+
title?: string;
|
|
31
|
+
text?: string;
|
|
32
|
+
html?: string;
|
|
33
|
+
icon?: "warning" | "info" | "question" | "error" | "success";
|
|
34
|
+
confirmButtonText?: string;
|
|
35
|
+
cancelButtonText?: string;
|
|
36
|
+
confirmButtonColor?: string;
|
|
37
|
+
cancelButtonColor?: string;
|
|
38
|
+
showLoaderOnConfirm?: boolean;
|
|
39
|
+
/** Type exactly — trimmed, case-sensitive. */
|
|
40
|
+
inputExpectedValue?: string;
|
|
41
|
+
inputPlaceholder?: string;
|
|
42
|
+
reverseButtons?: boolean;
|
|
43
|
+
focusCancel?: boolean;
|
|
44
|
+
zIndex?: number;
|
|
45
|
+
}
|
|
46
|
+
declare function confirmationAlert(onConfirm: () => void | Promise<void>, options?: ConfirmationAlertOptions): void;
|
|
47
|
+
|
|
48
|
+
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-Dgh_d-CX.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-Dgh_d-CX.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,
|
|
@@ -80,6 +84,7 @@ __export(src_exports, {
|
|
|
80
84
|
storeItemInLocalStorage: () => storeItemInLocalStorage,
|
|
81
85
|
toDateInputValue: () => toDateInputValue,
|
|
82
86
|
toLowerCaseText: () => toLowerCaseText,
|
|
87
|
+
transformPermissions: () => transformPermissions,
|
|
83
88
|
truncateFileName: () => truncateFileName,
|
|
84
89
|
truncateText: () => truncateText,
|
|
85
90
|
useGridHeight: () => useGridHeight,
|
|
@@ -334,9 +339,67 @@ var getItemFromLocalStorage = getItem;
|
|
|
334
339
|
var storeItemInLocalStorage = setItem;
|
|
335
340
|
var saveItemLocalStorage = setItem;
|
|
336
341
|
|
|
342
|
+
// src/utils/permissions.ts
|
|
343
|
+
function transformPermissions(permissions) {
|
|
344
|
+
return permissions.reduce((acc, permission) => {
|
|
345
|
+
const { moduleName, permission: perm, permissionId } = permission;
|
|
346
|
+
if (!acc[moduleName]) {
|
|
347
|
+
acc[moduleName] = {};
|
|
348
|
+
}
|
|
349
|
+
acc[moduleName][perm] = permissionId;
|
|
350
|
+
return acc;
|
|
351
|
+
}, {});
|
|
352
|
+
}
|
|
353
|
+
|
|
337
354
|
// src/utils/handleApiError.ts
|
|
338
355
|
var import_react_hot_toast = __toESM(require("react-hot-toast"));
|
|
339
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
|
+
}
|
|
340
403
|
function formatValidationErrorsHtml(errors) {
|
|
341
404
|
const items = Object.keys(errors).flatMap(
|
|
342
405
|
(field) => (errors[field] || []).map((msg) => `<li>${msg}</li>`)
|
|
@@ -476,6 +539,45 @@ function confirmationAlert(onConfirm, options = {}) {
|
|
|
476
539
|
});
|
|
477
540
|
}
|
|
478
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
|
+
|
|
479
581
|
// src/hooks/usePaginationUrlSync.ts
|
|
480
582
|
var import_react = require("react");
|
|
481
583
|
var usePaginationUrlSync = (searchParams, setSearchParams, page, setPage, perPage, setPerPage, defaultPage = 1, defaultPerPage = 20) => {
|
|
@@ -2078,6 +2180,85 @@ function PopupCellRenderer({
|
|
|
2078
2180
|
}
|
|
2079
2181
|
) });
|
|
2080
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
|
+
};
|
|
2081
2262
|
// Annotate the CommonJS export names for ESM import in node:
|
|
2082
2263
|
0 && (module.exports = {
|
|
2083
2264
|
CardSkeleton,
|
|
@@ -2091,15 +2272,18 @@ function PopupCellRenderer({
|
|
|
2091
2272
|
ResetColumnsButton,
|
|
2092
2273
|
ResetFiltersButton,
|
|
2093
2274
|
SearchInput,
|
|
2275
|
+
TableErrorBoundary,
|
|
2094
2276
|
TableLayoutToolbarControls,
|
|
2095
2277
|
ToolTip,
|
|
2096
2278
|
TooltipText,
|
|
2097
2279
|
USER_STATE_STORAGE_KEY,
|
|
2098
2280
|
capitalizeText,
|
|
2099
2281
|
checkIfExistsInArray,
|
|
2282
|
+
classifyError,
|
|
2100
2283
|
cn,
|
|
2101
2284
|
confirmationAlert,
|
|
2102
2285
|
convertCommaDataToArray,
|
|
2286
|
+
createBaseQueryWithRetry,
|
|
2103
2287
|
currencyFormatter,
|
|
2104
2288
|
deserializeJson,
|
|
2105
2289
|
dropdownStyles,
|
|
@@ -2118,6 +2302,7 @@ function PopupCellRenderer({
|
|
|
2118
2302
|
getItemFromLocalStorage,
|
|
2119
2303
|
handleApiError,
|
|
2120
2304
|
isEmpty,
|
|
2305
|
+
isRetryableError,
|
|
2121
2306
|
loadUserState,
|
|
2122
2307
|
normalizeApiListItems,
|
|
2123
2308
|
parseCurrencyValueToNumber,
|
|
@@ -2130,6 +2315,7 @@ function PopupCellRenderer({
|
|
|
2130
2315
|
storeItemInLocalStorage,
|
|
2131
2316
|
toDateInputValue,
|
|
2132
2317
|
toLowerCaseText,
|
|
2318
|
+
transformPermissions,
|
|
2133
2319
|
truncateFileName,
|
|
2134
2320
|
truncateText,
|
|
2135
2321
|
useGridHeight,
|