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.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { twMerge } from 'tailwind-merge';
|
|
2
|
-
import React2, { createContext, forwardRef, useState, useImperativeHandle, useEffect, useMemo,
|
|
2
|
+
import React2, { createContext, forwardRef, useState, useImperativeHandle, useEffect, useMemo, useRef, useCallback, useContext, Children } from 'react';
|
|
3
3
|
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
4
4
|
import { BsStarFill, BsStarHalf, BsStar, BsChevronDown, BsFillDiamondFill } from 'react-icons/bs';
|
|
5
5
|
import { FaSun, FaMoon, FaGripVertical, FaTrash, FaPlus, FaTimes, FaBars, FaCircle, FaEyeSlash, FaEye } from 'react-icons/fa';
|
|
@@ -21050,14 +21050,12 @@ function AsyncStateCard({
|
|
|
21050
21050
|
className
|
|
21051
21051
|
}) {
|
|
21052
21052
|
const isError = type === "error";
|
|
21053
|
-
return /* @__PURE__ */ jsx(
|
|
21053
|
+
return /* @__PURE__ */ jsx(
|
|
21054
21054
|
Card_default,
|
|
21055
21055
|
{
|
|
21056
|
-
|
|
21056
|
+
ghost: true,
|
|
21057
21057
|
borderVariant: isError ? "danger" : "secondary",
|
|
21058
|
-
|
|
21059
|
-
hoverAnimation: "softLift",
|
|
21060
|
-
styles: cn("w-full max-w-xl", className),
|
|
21058
|
+
styles: cn("w-full", className),
|
|
21061
21059
|
children: /* @__PURE__ */ jsx(CardContent_default, { children: /* @__PURE__ */ jsxs("div", { className: "flex flex-col items-center justify-center gap-5 px-4 py-8 text-center", children: [
|
|
21062
21060
|
/* @__PURE__ */ jsx(
|
|
21063
21061
|
"div",
|
|
@@ -21070,7 +21068,7 @@ function AsyncStateCard({
|
|
|
21070
21068
|
}
|
|
21071
21069
|
),
|
|
21072
21070
|
/* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-2", children: [
|
|
21073
|
-
/* @__PURE__ */ jsx("h3", { className: "text-lg font-semibold text-eui-dark-900 dark:text-eui-light-
|
|
21071
|
+
/* @__PURE__ */ jsx("h3", { className: "text-lg font-semibold text-eui-dark-900 dark:text-eui-light-600", children: title }),
|
|
21074
21072
|
isError ? /* @__PURE__ */ jsx(FormResponse_default, { text: message, variant: "danger" }) : /* @__PURE__ */ jsx("p", { className: "text-sm text-eui-dark-500 dark:text-eui-light-400", children: message })
|
|
21075
21073
|
] }),
|
|
21076
21074
|
onAction && actionText && /* @__PURE__ */ jsx(
|
|
@@ -21082,13 +21080,12 @@ function AsyncStateCard({
|
|
|
21082
21080
|
disabled: actionLoading,
|
|
21083
21081
|
onClick: onAction,
|
|
21084
21082
|
variant: isError ? "danger" : "primary",
|
|
21085
|
-
appearance: "solid",
|
|
21086
21083
|
size: "sm"
|
|
21087
21084
|
}
|
|
21088
21085
|
)
|
|
21089
21086
|
] }) })
|
|
21090
21087
|
}
|
|
21091
|
-
)
|
|
21088
|
+
);
|
|
21092
21089
|
}
|
|
21093
21090
|
var AsyncStateCard_default = React2.memo(AsyncStateCard);
|
|
21094
21091
|
|
|
@@ -21142,18 +21139,58 @@ function AsyncComponentWrapper({
|
|
|
21142
21139
|
errorFallback,
|
|
21143
21140
|
showFetchingIndicator = true,
|
|
21144
21141
|
showLoadingOnRetry = true,
|
|
21142
|
+
retryLoadingFallbackMs = 700,
|
|
21145
21143
|
onRetry,
|
|
21146
21144
|
errorFormatter,
|
|
21147
21145
|
className,
|
|
21148
21146
|
contentClassName,
|
|
21149
21147
|
stateClassName
|
|
21150
21148
|
}) {
|
|
21149
|
+
const [isRetrying, setIsRetrying] = useState(false);
|
|
21150
|
+
const retryTimerRef = useRef(null);
|
|
21151
21151
|
const errorMessage = useMemo(() => {
|
|
21152
21152
|
if (!isError) return "";
|
|
21153
21153
|
return errorFormatter ? errorFormatter(error) : getDefaultErrorMessage(error);
|
|
21154
21154
|
}, [isError, error, errorFormatter]);
|
|
21155
21155
|
const hasSuccess = isSuccess ?? (!isLoading && !isError && !isUninitialized);
|
|
21156
|
-
const
|
|
21156
|
+
const shouldShowRetryLoading = showLoadingOnRetry && (isRetrying || isFetching && isError);
|
|
21157
|
+
const shouldShowLoading = isLoading || shouldShowRetryLoading;
|
|
21158
|
+
const clearRetryTimer = useCallback(() => {
|
|
21159
|
+
if (retryTimerRef.current) {
|
|
21160
|
+
clearTimeout(retryTimerRef.current);
|
|
21161
|
+
retryTimerRef.current = null;
|
|
21162
|
+
}
|
|
21163
|
+
}, []);
|
|
21164
|
+
const handleRetry = useCallback(() => {
|
|
21165
|
+
if (!onRetry) return;
|
|
21166
|
+
clearRetryTimer();
|
|
21167
|
+
setIsRetrying(true);
|
|
21168
|
+
try {
|
|
21169
|
+
const result = onRetry();
|
|
21170
|
+
if (result && typeof result === "object" && "finally" in result) {
|
|
21171
|
+
void result.finally(() => {
|
|
21172
|
+
setIsRetrying(false);
|
|
21173
|
+
});
|
|
21174
|
+
return;
|
|
21175
|
+
}
|
|
21176
|
+
retryTimerRef.current = setTimeout(() => {
|
|
21177
|
+
setIsRetrying(false);
|
|
21178
|
+
}, retryLoadingFallbackMs);
|
|
21179
|
+
} catch (retryError) {
|
|
21180
|
+
setIsRetrying(false);
|
|
21181
|
+
throw retryError;
|
|
21182
|
+
}
|
|
21183
|
+
}, [onRetry, clearRetryTimer, retryLoadingFallbackMs]);
|
|
21184
|
+
useEffect(() => {
|
|
21185
|
+
if (!isLoading && !isFetching && !isError) {
|
|
21186
|
+
setIsRetrying(false);
|
|
21187
|
+
}
|
|
21188
|
+
}, [isLoading, isFetching, isError]);
|
|
21189
|
+
useEffect(() => {
|
|
21190
|
+
return () => {
|
|
21191
|
+
clearRetryTimer();
|
|
21192
|
+
};
|
|
21193
|
+
}, [clearRetryTimer]);
|
|
21157
21194
|
const renderLoading = () => {
|
|
21158
21195
|
if (loadingFallback) return loadingFallback;
|
|
21159
21196
|
if (loadingType === "skeleton") {
|
|
@@ -21183,8 +21220,8 @@ function AsyncComponentWrapper({
|
|
|
21183
21220
|
title: errorTitle,
|
|
21184
21221
|
message: errorMessage,
|
|
21185
21222
|
actionText: onRetry ? retryText : void 0,
|
|
21186
|
-
actionLoading:
|
|
21187
|
-
onAction:
|
|
21223
|
+
actionLoading: isRetrying,
|
|
21224
|
+
onAction: handleRetry,
|
|
21188
21225
|
className: stateClassName
|
|
21189
21226
|
}
|
|
21190
21227
|
);
|