elseware-ui 2.14.4 → 2.14.5

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.
@@ -8,7 +8,7 @@ export interface AdvancedTableProps<T> {
8
8
  isLoading?: boolean;
9
9
  isSuccess?: boolean;
10
10
  isError?: boolean;
11
- error?: string;
11
+ error?: unknown;
12
12
  }
13
13
  declare function AdvancedTable<T extends Record<string, any>>({ title, columns, data, defaultPageSize, pageSizeOptions, isLoading, isSuccess, isError, error, }: AdvancedTableProps<T>): import("react/jsx-runtime").JSX.Element;
14
14
  export default AdvancedTable;
@@ -7,7 +7,7 @@ export interface TableProps {
7
7
  isLoading?: boolean;
8
8
  isSuccess?: boolean;
9
9
  isError?: boolean;
10
- error?: string;
10
+ error?: unknown;
11
11
  enableSelect: boolean;
12
12
  maxRowCount?: number;
13
13
  }
@@ -8,7 +8,7 @@ export interface ModalProps {
8
8
  isLoading?: boolean;
9
9
  isSuccess?: boolean;
10
10
  isError?: boolean;
11
- error?: string;
11
+ error?: unknown;
12
12
  styles?: string;
13
13
  }
14
14
  declare function Modal({ title, show, handleOnClose, children, isLoading, isSuccess, isError, error, styles, enableCloseOnClickOutside, }: ModalProps): import("react/jsx-runtime").JSX.Element;
@@ -4,7 +4,11 @@ export interface AsyncComponentWrapperProps {
4
4
  isLoading?: boolean;
5
5
  isSuccess?: boolean;
6
6
  isError?: boolean;
7
- error?: string;
7
+ error?: unknown;
8
+ /**
9
+ * Optional custom formatter if you want full control
10
+ */
11
+ errorFormatter?: (error: unknown) => string;
8
12
  }
9
- declare function AsyncComponentWrapper({ children, isLoading, isSuccess, isError, error, }: AsyncComponentWrapperProps): import("react/jsx-runtime").JSX.Element;
13
+ declare function AsyncComponentWrapper({ children, isLoading, isSuccess, isError, error, errorFormatter, }: AsyncComponentWrapperProps): import("react/jsx-runtime").JSX.Element;
10
14
  export default AsyncComponentWrapper;
package/build/index.es.js CHANGED
@@ -7809,9 +7809,47 @@ function FormResponse(_a) {
7809
7809
  _b)) }, { children: text })) })));
7810
7810
  }
7811
7811
 
7812
+ // Helper to normalize different error shapes into a readable string
7813
+ var getDefaultErrorMessage = function (error) {
7814
+ var _a;
7815
+ if (!error)
7816
+ return "Something went wrong.";
7817
+ if (typeof error === "string")
7818
+ return error;
7819
+ if (error instanceof Error)
7820
+ return error.message;
7821
+ if (typeof error === "object") {
7822
+ var anyErr = error;
7823
+ // RTK Query style: { status, data: { message } }
7824
+ if (((_a = anyErr === null || anyErr === void 0 ? void 0 : anyErr.data) === null || _a === void 0 ? void 0 : _a.message) && typeof anyErr.data.message === "string") {
7825
+ return anyErr.data.message;
7826
+ }
7827
+ // Some APIs: { message: "..." }
7828
+ if ((anyErr === null || anyErr === void 0 ? void 0 : anyErr.message) && typeof anyErr.message === "string") {
7829
+ return anyErr.message;
7830
+ }
7831
+ // Fallback: show status if present
7832
+ if (anyErr === null || anyErr === void 0 ? void 0 : anyErr.status) {
7833
+ return "Request failed with status ".concat(anyErr.status);
7834
+ }
7835
+ // Last resort: stringify object
7836
+ try {
7837
+ return JSON.stringify(error);
7838
+ }
7839
+ catch (_b) {
7840
+ return "An unknown error occurred.";
7841
+ }
7842
+ }
7843
+ return "An unknown error occurred.";
7844
+ };
7812
7845
  function AsyncComponentWrapper(_a) {
7813
- var children = _a.children, isLoading = _a.isLoading, _b = _a.isSuccess, isSuccess = _b === void 0 ? true : _b, isError = _a.isError, error = _a.error;
7814
- return (jsxs("div", { children: [isLoading && (jsx("div", __assign$1({ className: "flex w-full py-10 items-center justify-center" }, { children: jsx(AiOutlineLoading, { className: "animate-spin" }) }))), isError && (jsx("div", __assign$1({ className: "p-5" }, { children: jsx(FormResponse, { text: error, variant: "danger" }) }))), isSuccess && jsx("div", { children: children })] }));
7846
+ var children = _a.children, isLoading = _a.isLoading, _b = _a.isSuccess, isSuccess = _b === void 0 ? true : _b, isError = _a.isError, error = _a.error, errorFormatter = _a.errorFormatter;
7847
+ var errorMessage = isError && error
7848
+ ? errorFormatter
7849
+ ? errorFormatter(error)
7850
+ : getDefaultErrorMessage(error)
7851
+ : undefined;
7852
+ return (jsxs("div", { children: [isLoading && (jsx("div", __assign$1({ className: "flex w-full py-10 items-center justify-center" }, { children: jsx(AiOutlineLoading, { className: "animate-spin" }) }))), isError && errorMessage && (jsx("div", __assign$1({ className: "p-5" }, { children: jsx(FormResponse, { text: errorMessage, variant: "danger" }) }))), isSuccess && jsx("div", { children: children })] }));
7815
7853
  }
7816
7854
 
7817
7855
  function AdvancedTableContent(_a) {
package/build/index.js CHANGED
@@ -7836,9 +7836,47 @@ function FormResponse(_a) {
7836
7836
  _b)) }, { children: text })) })));
7837
7837
  }
7838
7838
 
7839
+ // Helper to normalize different error shapes into a readable string
7840
+ var getDefaultErrorMessage = function (error) {
7841
+ var _a;
7842
+ if (!error)
7843
+ return "Something went wrong.";
7844
+ if (typeof error === "string")
7845
+ return error;
7846
+ if (error instanceof Error)
7847
+ return error.message;
7848
+ if (typeof error === "object") {
7849
+ var anyErr = error;
7850
+ // RTK Query style: { status, data: { message } }
7851
+ if (((_a = anyErr === null || anyErr === void 0 ? void 0 : anyErr.data) === null || _a === void 0 ? void 0 : _a.message) && typeof anyErr.data.message === "string") {
7852
+ return anyErr.data.message;
7853
+ }
7854
+ // Some APIs: { message: "..." }
7855
+ if ((anyErr === null || anyErr === void 0 ? void 0 : anyErr.message) && typeof anyErr.message === "string") {
7856
+ return anyErr.message;
7857
+ }
7858
+ // Fallback: show status if present
7859
+ if (anyErr === null || anyErr === void 0 ? void 0 : anyErr.status) {
7860
+ return "Request failed with status ".concat(anyErr.status);
7861
+ }
7862
+ // Last resort: stringify object
7863
+ try {
7864
+ return JSON.stringify(error);
7865
+ }
7866
+ catch (_b) {
7867
+ return "An unknown error occurred.";
7868
+ }
7869
+ }
7870
+ return "An unknown error occurred.";
7871
+ };
7839
7872
  function AsyncComponentWrapper(_a) {
7840
- var children = _a.children, isLoading = _a.isLoading, _b = _a.isSuccess, isSuccess = _b === void 0 ? true : _b, isError = _a.isError, error = _a.error;
7841
- return (jsxRuntime.jsxs("div", { children: [isLoading && (jsxRuntime.jsx("div", __assign$1({ className: "flex w-full py-10 items-center justify-center" }, { children: jsxRuntime.jsx(AiOutlineLoading, { className: "animate-spin" }) }))), isError && (jsxRuntime.jsx("div", __assign$1({ className: "p-5" }, { children: jsxRuntime.jsx(FormResponse, { text: error, variant: "danger" }) }))), isSuccess && jsxRuntime.jsx("div", { children: children })] }));
7873
+ var children = _a.children, isLoading = _a.isLoading, _b = _a.isSuccess, isSuccess = _b === void 0 ? true : _b, isError = _a.isError, error = _a.error, errorFormatter = _a.errorFormatter;
7874
+ var errorMessage = isError && error
7875
+ ? errorFormatter
7876
+ ? errorFormatter(error)
7877
+ : getDefaultErrorMessage(error)
7878
+ : undefined;
7879
+ return (jsxRuntime.jsxs("div", { children: [isLoading && (jsxRuntime.jsx("div", __assign$1({ className: "flex w-full py-10 items-center justify-center" }, { children: jsxRuntime.jsx(AiOutlineLoading, { className: "animate-spin" }) }))), isError && errorMessage && (jsxRuntime.jsx("div", __assign$1({ className: "p-5" }, { children: jsxRuntime.jsx(FormResponse, { text: errorMessage, variant: "danger" }) }))), isSuccess && jsxRuntime.jsx("div", { children: children })] }));
7842
7880
  }
7843
7881
 
7844
7882
  function AdvancedTableContent(_a) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "elseware-ui",
3
- "version": "2.14.4",
3
+ "version": "2.14.5",
4
4
  "private": false,
5
5
  "description": "A modern and customizable React UI component library by elseware Technology.",
6
6
  "keywords": [