elseware-ui 2.36.6 → 2.36.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/index.css +39 -45
- package/dist/index.css.map +1 -1
- package/dist/index.d.mts +4 -2
- package/dist/index.d.ts +4 -2
- package/dist/index.js +57 -19
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +58 -20
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -2230,14 +2230,16 @@ interface AsyncComponentWrapperProps {
|
|
|
2230
2230
|
emptyFallback?: React__default.ReactNode;
|
|
2231
2231
|
errorFallback?: React__default.ReactNode | ((message: string) => React__default.ReactNode);
|
|
2232
2232
|
showFetchingIndicator?: boolean;
|
|
2233
|
-
|
|
2233
|
+
showLoadingOnRetry?: boolean;
|
|
2234
|
+
retryLoadingFallbackMs?: number;
|
|
2235
|
+
onRetry?: () => void | Promise<unknown>;
|
|
2234
2236
|
errorFormatter?: (error: unknown) => string;
|
|
2235
2237
|
className?: string;
|
|
2236
2238
|
contentClassName?: string;
|
|
2237
2239
|
stateClassName?: string;
|
|
2238
2240
|
}
|
|
2239
2241
|
|
|
2240
|
-
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, 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;
|
|
2241
2243
|
declare const _default: React__default.MemoExoticComponent<typeof AsyncComponentWrapper>;
|
|
2242
2244
|
|
|
2243
2245
|
interface GlowWrapperProps {
|
package/dist/index.d.ts
CHANGED
|
@@ -2230,14 +2230,16 @@ interface AsyncComponentWrapperProps {
|
|
|
2230
2230
|
emptyFallback?: React__default.ReactNode;
|
|
2231
2231
|
errorFallback?: React__default.ReactNode | ((message: string) => React__default.ReactNode);
|
|
2232
2232
|
showFetchingIndicator?: boolean;
|
|
2233
|
-
|
|
2233
|
+
showLoadingOnRetry?: boolean;
|
|
2234
|
+
retryLoadingFallbackMs?: number;
|
|
2235
|
+
onRetry?: () => void | Promise<unknown>;
|
|
2234
2236
|
errorFormatter?: (error: unknown) => string;
|
|
2235
2237
|
className?: string;
|
|
2236
2238
|
contentClassName?: string;
|
|
2237
2239
|
stateClassName?: string;
|
|
2238
2240
|
}
|
|
2239
2241
|
|
|
2240
|
-
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, 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;
|
|
2241
2243
|
declare const _default: React__default.MemoExoticComponent<typeof AsyncComponentWrapper>;
|
|
2242
2244
|
|
|
2243
2245
|
interface GlowWrapperProps {
|
package/dist/index.js
CHANGED
|
@@ -21073,33 +21073,30 @@ function AsyncStateCard({
|
|
|
21073
21073
|
title,
|
|
21074
21074
|
message,
|
|
21075
21075
|
actionText,
|
|
21076
|
-
actionLoading,
|
|
21076
|
+
actionLoading = false,
|
|
21077
21077
|
onAction,
|
|
21078
21078
|
className
|
|
21079
21079
|
}) {
|
|
21080
21080
|
const isError = type === "error";
|
|
21081
|
-
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
21082
|
-
|
|
21081
|
+
return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex min-h-[240px] w-full items-center justify-center py-6", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
21082
|
+
Card_default,
|
|
21083
21083
|
{
|
|
21084
|
-
|
|
21085
|
-
|
|
21086
|
-
|
|
21087
|
-
|
|
21088
|
-
className
|
|
21089
|
-
),
|
|
21090
|
-
children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex max-w-md flex-col items-center gap-4 text-center", children: [
|
|
21084
|
+
ghost: true,
|
|
21085
|
+
borderVariant: isError ? "danger" : "secondary",
|
|
21086
|
+
styles: cn("w-full max-w-xl", className),
|
|
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: [
|
|
21091
21088
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
21092
21089
|
"div",
|
|
21093
21090
|
{
|
|
21094
21091
|
className: cn(
|
|
21095
21092
|
"flex h-12 w-12 items-center justify-center rounded-full text-xl font-bold",
|
|
21096
|
-
isError ? "bg-eui-danger-500/10 text-eui-danger-500" : "bg-eui-
|
|
21093
|
+
isError ? "bg-eui-danger-500/10 text-eui-danger-500" : "bg-eui-secondary-500/10 text-eui-secondary-500"
|
|
21097
21094
|
),
|
|
21098
21095
|
children: isError ? "!" : "\u2013"
|
|
21099
21096
|
}
|
|
21100
21097
|
),
|
|
21101
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "
|
|
21102
|
-
/* @__PURE__ */ jsxRuntime.jsx("h3", { className: "text-lg font-semibold text-eui-dark-900 dark:text-eui-light-
|
|
21098
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-2", children: [
|
|
21099
|
+
/* @__PURE__ */ jsxRuntime.jsx("h3", { className: "text-lg font-semibold text-eui-dark-900 dark:text-eui-light-600", children: title }),
|
|
21103
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 })
|
|
21104
21101
|
] }),
|
|
21105
21102
|
onAction && actionText && /* @__PURE__ */ jsxRuntime.jsx(
|
|
@@ -21111,13 +21108,12 @@ function AsyncStateCard({
|
|
|
21111
21108
|
disabled: actionLoading,
|
|
21112
21109
|
onClick: onAction,
|
|
21113
21110
|
variant: isError ? "danger" : "primary",
|
|
21114
|
-
appearance: "solid",
|
|
21115
21111
|
size: "sm"
|
|
21116
21112
|
}
|
|
21117
21113
|
)
|
|
21118
|
-
] })
|
|
21114
|
+
] }) })
|
|
21119
21115
|
}
|
|
21120
|
-
);
|
|
21116
|
+
) });
|
|
21121
21117
|
}
|
|
21122
21118
|
var AsyncStateCard_default = React2__default.default.memo(AsyncStateCard);
|
|
21123
21119
|
|
|
@@ -21170,17 +21166,59 @@ function AsyncComponentWrapper({
|
|
|
21170
21166
|
emptyFallback,
|
|
21171
21167
|
errorFallback,
|
|
21172
21168
|
showFetchingIndicator = true,
|
|
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 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]);
|
|
21184
21222
|
const renderLoading = () => {
|
|
21185
21223
|
if (loadingFallback) return loadingFallback;
|
|
21186
21224
|
if (loadingType === "skeleton") {
|
|
@@ -21210,8 +21248,8 @@ function AsyncComponentWrapper({
|
|
|
21210
21248
|
title: errorTitle,
|
|
21211
21249
|
message: errorMessage,
|
|
21212
21250
|
actionText: onRetry ? retryText : void 0,
|
|
21213
|
-
actionLoading:
|
|
21214
|
-
onAction:
|
|
21251
|
+
actionLoading: isRetrying,
|
|
21252
|
+
onAction: handleRetry,
|
|
21215
21253
|
className: stateClassName
|
|
21216
21254
|
}
|
|
21217
21255
|
);
|
|
@@ -21228,7 +21266,7 @@ function AsyncComponentWrapper({
|
|
|
21228
21266
|
}
|
|
21229
21267
|
);
|
|
21230
21268
|
};
|
|
21231
|
-
if (
|
|
21269
|
+
if (shouldShowLoading) {
|
|
21232
21270
|
return /* @__PURE__ */ jsxRuntime.jsx("div", { className, "aria-live": "polite", children: renderLoading() });
|
|
21233
21271
|
}
|
|
21234
21272
|
if (isError) {
|