elseware-ui 2.36.7 → 2.36.9
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/index.css +21 -21
- package/dist/index.css.map +1 -1
- package/dist/index.d.mts +3 -2
- package/dist/index.d.ts +3 -2
- package/dist/index.js +48 -11
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +49 -12
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -2231,14 +2231,15 @@ interface AsyncComponentWrapperProps {
|
|
|
2231
2231
|
errorFallback?: React__default.ReactNode | ((message: string) => React__default.ReactNode);
|
|
2232
2232
|
showFetchingIndicator?: boolean;
|
|
2233
2233
|
showLoadingOnRetry?: boolean;
|
|
2234
|
-
|
|
2234
|
+
retryLoadingFallbackMs?: number;
|
|
2235
|
+
onRetry?: () => void | Promise<unknown>;
|
|
2235
2236
|
errorFormatter?: (error: unknown) => string;
|
|
2236
2237
|
className?: string;
|
|
2237
2238
|
contentClassName?: string;
|
|
2238
2239
|
stateClassName?: string;
|
|
2239
2240
|
}
|
|
2240
2241
|
|
|
2241
|
-
declare function AsyncComponentWrapper({ children, isLoading, isFetching, isSuccess, isError, isUninitialized, error, isEmpty, loadingText, fetchingText, emptyTitle, emptyText, errorTitle, retryText, loadingType, skeletonCount, skeletonClassName, skeletonWrapperClassName, spinnerProps, fetchingSpinnerProps, loadingFallback, emptyFallback, errorFallback, showFetchingIndicator, showLoadingOnRetry, onRetry, errorFormatter, className, contentClassName, stateClassName, }: AsyncComponentWrapperProps): React__default.JSX.Element | null;
|
|
2242
|
+
declare function AsyncComponentWrapper({ children, isLoading, isFetching, isSuccess, isError, isUninitialized, error, isEmpty, loadingText, fetchingText, emptyTitle, emptyText, errorTitle, retryText, loadingType, skeletonCount, skeletonClassName, skeletonWrapperClassName, spinnerProps, fetchingSpinnerProps, loadingFallback, emptyFallback, errorFallback, showFetchingIndicator, showLoadingOnRetry, retryLoadingFallbackMs, onRetry, errorFormatter, className, contentClassName, stateClassName, }: AsyncComponentWrapperProps): React__default.JSX.Element | null;
|
|
2242
2243
|
declare const _default: React__default.MemoExoticComponent<typeof AsyncComponentWrapper>;
|
|
2243
2244
|
|
|
2244
2245
|
interface GlowWrapperProps {
|
package/dist/index.d.ts
CHANGED
|
@@ -2231,14 +2231,15 @@ interface AsyncComponentWrapperProps {
|
|
|
2231
2231
|
errorFallback?: React__default.ReactNode | ((message: string) => React__default.ReactNode);
|
|
2232
2232
|
showFetchingIndicator?: boolean;
|
|
2233
2233
|
showLoadingOnRetry?: boolean;
|
|
2234
|
-
|
|
2234
|
+
retryLoadingFallbackMs?: number;
|
|
2235
|
+
onRetry?: () => void | Promise<unknown>;
|
|
2235
2236
|
errorFormatter?: (error: unknown) => string;
|
|
2236
2237
|
className?: string;
|
|
2237
2238
|
contentClassName?: string;
|
|
2238
2239
|
stateClassName?: string;
|
|
2239
2240
|
}
|
|
2240
2241
|
|
|
2241
|
-
declare function AsyncComponentWrapper({ children, isLoading, isFetching, isSuccess, isError, isUninitialized, error, isEmpty, loadingText, fetchingText, emptyTitle, emptyText, errorTitle, retryText, loadingType, skeletonCount, skeletonClassName, skeletonWrapperClassName, spinnerProps, fetchingSpinnerProps, loadingFallback, emptyFallback, errorFallback, showFetchingIndicator, showLoadingOnRetry, onRetry, errorFormatter, className, contentClassName, stateClassName, }: AsyncComponentWrapperProps): React__default.JSX.Element | null;
|
|
2242
|
+
declare function AsyncComponentWrapper({ children, isLoading, isFetching, isSuccess, isError, isUninitialized, error, isEmpty, loadingText, fetchingText, emptyTitle, emptyText, errorTitle, retryText, loadingType, skeletonCount, skeletonClassName, skeletonWrapperClassName, spinnerProps, fetchingSpinnerProps, loadingFallback, emptyFallback, errorFallback, showFetchingIndicator, showLoadingOnRetry, retryLoadingFallbackMs, onRetry, errorFormatter, className, contentClassName, stateClassName, }: AsyncComponentWrapperProps): React__default.JSX.Element | null;
|
|
2242
2243
|
declare const _default: React__default.MemoExoticComponent<typeof AsyncComponentWrapper>;
|
|
2243
2244
|
|
|
2244
2245
|
interface GlowWrapperProps {
|
package/dist/index.js
CHANGED
|
@@ -21078,14 +21078,12 @@ function AsyncStateCard({
|
|
|
21078
21078
|
className
|
|
21079
21079
|
}) {
|
|
21080
21080
|
const isError = type === "error";
|
|
21081
|
-
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
21081
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
21082
21082
|
Card_default,
|
|
21083
21083
|
{
|
|
21084
|
-
|
|
21084
|
+
ghost: true,
|
|
21085
21085
|
borderVariant: isError ? "danger" : "secondary",
|
|
21086
|
-
|
|
21087
|
-
hoverAnimation: "softLift",
|
|
21088
|
-
styles: cn("w-full max-w-xl", className),
|
|
21086
|
+
styles: cn("w-full", className),
|
|
21089
21087
|
children: /* @__PURE__ */ jsxRuntime.jsx(CardContent_default, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col items-center justify-center gap-5 px-4 py-8 text-center", children: [
|
|
21090
21088
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
21091
21089
|
"div",
|
|
@@ -21098,7 +21096,7 @@ function AsyncStateCard({
|
|
|
21098
21096
|
}
|
|
21099
21097
|
),
|
|
21100
21098
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-2", children: [
|
|
21101
|
-
/* @__PURE__ */ jsxRuntime.jsx("h3", { className: "text-lg font-semibold text-eui-dark-900 dark:text-eui-light-
|
|
21099
|
+
/* @__PURE__ */ jsxRuntime.jsx("h3", { className: "text-lg font-semibold text-eui-dark-900 dark:text-eui-light-600", children: title }),
|
|
21102
21100
|
isError ? /* @__PURE__ */ jsxRuntime.jsx(FormResponse_default, { text: message, variant: "danger" }) : /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-sm text-eui-dark-500 dark:text-eui-light-400", children: message })
|
|
21103
21101
|
] }),
|
|
21104
21102
|
onAction && actionText && /* @__PURE__ */ jsxRuntime.jsx(
|
|
@@ -21110,13 +21108,12 @@ function AsyncStateCard({
|
|
|
21110
21108
|
disabled: actionLoading,
|
|
21111
21109
|
onClick: onAction,
|
|
21112
21110
|
variant: isError ? "danger" : "primary",
|
|
21113
|
-
appearance: "solid",
|
|
21114
21111
|
size: "sm"
|
|
21115
21112
|
}
|
|
21116
21113
|
)
|
|
21117
21114
|
] }) })
|
|
21118
21115
|
}
|
|
21119
|
-
)
|
|
21116
|
+
);
|
|
21120
21117
|
}
|
|
21121
21118
|
var AsyncStateCard_default = React2__default.default.memo(AsyncStateCard);
|
|
21122
21119
|
|
|
@@ -21170,18 +21167,58 @@ function AsyncComponentWrapper({
|
|
|
21170
21167
|
errorFallback,
|
|
21171
21168
|
showFetchingIndicator = true,
|
|
21172
21169
|
showLoadingOnRetry = true,
|
|
21170
|
+
retryLoadingFallbackMs = 700,
|
|
21173
21171
|
onRetry,
|
|
21174
21172
|
errorFormatter,
|
|
21175
21173
|
className,
|
|
21176
21174
|
contentClassName,
|
|
21177
21175
|
stateClassName
|
|
21178
21176
|
}) {
|
|
21177
|
+
const [isRetrying, setIsRetrying] = React2.useState(false);
|
|
21178
|
+
const retryTimerRef = React2.useRef(null);
|
|
21179
21179
|
const errorMessage = React2.useMemo(() => {
|
|
21180
21180
|
if (!isError) return "";
|
|
21181
21181
|
return errorFormatter ? errorFormatter(error) : getDefaultErrorMessage(error);
|
|
21182
21182
|
}, [isError, error, errorFormatter]);
|
|
21183
21183
|
const hasSuccess = isSuccess ?? (!isLoading && !isError && !isUninitialized);
|
|
21184
|
-
const
|
|
21184
|
+
const shouldShowRetryLoading = showLoadingOnRetry && (isRetrying || isFetching && isError);
|
|
21185
|
+
const shouldShowLoading = isLoading || shouldShowRetryLoading;
|
|
21186
|
+
const clearRetryTimer = React2.useCallback(() => {
|
|
21187
|
+
if (retryTimerRef.current) {
|
|
21188
|
+
clearTimeout(retryTimerRef.current);
|
|
21189
|
+
retryTimerRef.current = null;
|
|
21190
|
+
}
|
|
21191
|
+
}, []);
|
|
21192
|
+
const handleRetry = React2.useCallback(() => {
|
|
21193
|
+
if (!onRetry) return;
|
|
21194
|
+
clearRetryTimer();
|
|
21195
|
+
setIsRetrying(true);
|
|
21196
|
+
try {
|
|
21197
|
+
const result = onRetry();
|
|
21198
|
+
if (result && typeof result === "object" && "finally" in result) {
|
|
21199
|
+
void result.finally(() => {
|
|
21200
|
+
setIsRetrying(false);
|
|
21201
|
+
});
|
|
21202
|
+
return;
|
|
21203
|
+
}
|
|
21204
|
+
retryTimerRef.current = setTimeout(() => {
|
|
21205
|
+
setIsRetrying(false);
|
|
21206
|
+
}, retryLoadingFallbackMs);
|
|
21207
|
+
} catch (retryError) {
|
|
21208
|
+
setIsRetrying(false);
|
|
21209
|
+
throw retryError;
|
|
21210
|
+
}
|
|
21211
|
+
}, [onRetry, clearRetryTimer, retryLoadingFallbackMs]);
|
|
21212
|
+
React2.useEffect(() => {
|
|
21213
|
+
if (!isLoading && !isFetching && !isError) {
|
|
21214
|
+
setIsRetrying(false);
|
|
21215
|
+
}
|
|
21216
|
+
}, [isLoading, isFetching, isError]);
|
|
21217
|
+
React2.useEffect(() => {
|
|
21218
|
+
return () => {
|
|
21219
|
+
clearRetryTimer();
|
|
21220
|
+
};
|
|
21221
|
+
}, [clearRetryTimer]);
|
|
21185
21222
|
const renderLoading = () => {
|
|
21186
21223
|
if (loadingFallback) return loadingFallback;
|
|
21187
21224
|
if (loadingType === "skeleton") {
|
|
@@ -21211,8 +21248,8 @@ function AsyncComponentWrapper({
|
|
|
21211
21248
|
title: errorTitle,
|
|
21212
21249
|
message: errorMessage,
|
|
21213
21250
|
actionText: onRetry ? retryText : void 0,
|
|
21214
|
-
actionLoading:
|
|
21215
|
-
onAction:
|
|
21251
|
+
actionLoading: isRetrying,
|
|
21252
|
+
onAction: handleRetry,
|
|
21216
21253
|
className: stateClassName
|
|
21217
21254
|
}
|
|
21218
21255
|
);
|