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.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  import { twMerge } from 'tailwind-merge';
2
- import React2, { createContext, forwardRef, useState, useImperativeHandle, useEffect, useMemo, useContext, useRef, Children, useCallback } from 'react';
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';
@@ -21045,33 +21045,30 @@ function AsyncStateCard({
21045
21045
  title,
21046
21046
  message,
21047
21047
  actionText,
21048
- actionLoading,
21048
+ actionLoading = false,
21049
21049
  onAction,
21050
21050
  className
21051
21051
  }) {
21052
21052
  const isError = type === "error";
21053
- return /* @__PURE__ */ jsx(
21054
- "div",
21053
+ return /* @__PURE__ */ jsx("div", { className: "flex min-h-[240px] w-full items-center justify-center py-6", children: /* @__PURE__ */ jsx(
21054
+ Card_default,
21055
21055
  {
21056
- className: cn(
21057
- "flex min-h-[220px] w-full items-center justify-center rounded-xl border p-6",
21058
- "border-eui-dark-300/10 bg-white/70 shadow-sm",
21059
- "dark:border-eui-light-400/10 dark:bg-eui-dark-900/40",
21060
- className
21061
- ),
21062
- children: /* @__PURE__ */ jsxs("div", { className: "flex max-w-md flex-col items-center gap-4 text-center", children: [
21056
+ ghost: true,
21057
+ borderVariant: isError ? "danger" : "secondary",
21058
+ styles: cn("w-full max-w-xl", className),
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: [
21063
21060
  /* @__PURE__ */ jsx(
21064
21061
  "div",
21065
21062
  {
21066
21063
  className: cn(
21067
21064
  "flex h-12 w-12 items-center justify-center rounded-full text-xl font-bold",
21068
- isError ? "bg-eui-danger-500/10 text-eui-danger-500" : "bg-eui-dark-500/10 text-eui-dark-500 dark:bg-eui-light-500/10 dark:text-eui-light-400"
21065
+ isError ? "bg-eui-danger-500/10 text-eui-danger-500" : "bg-eui-secondary-500/10 text-eui-secondary-500"
21069
21066
  ),
21070
21067
  children: isError ? "!" : "\u2013"
21071
21068
  }
21072
21069
  ),
21073
- /* @__PURE__ */ jsxs("div", { className: "space-y-2", children: [
21074
- /* @__PURE__ */ jsx("h3", { className: "text-lg font-semibold text-eui-dark-900 dark:text-eui-light-50", children: title }),
21070
+ /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-2", children: [
21071
+ /* @__PURE__ */ jsx("h3", { className: "text-lg font-semibold text-eui-dark-900 dark:text-eui-light-600", children: title }),
21075
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 })
21076
21073
  ] }),
21077
21074
  onAction && actionText && /* @__PURE__ */ jsx(
@@ -21083,13 +21080,12 @@ function AsyncStateCard({
21083
21080
  disabled: actionLoading,
21084
21081
  onClick: onAction,
21085
21082
  variant: isError ? "danger" : "primary",
21086
- appearance: "solid",
21087
21083
  size: "sm"
21088
21084
  }
21089
21085
  )
21090
- ] })
21086
+ ] }) })
21091
21087
  }
21092
- );
21088
+ ) });
21093
21089
  }
21094
21090
  var AsyncStateCard_default = React2.memo(AsyncStateCard);
21095
21091
 
@@ -21142,17 +21138,59 @@ function AsyncComponentWrapper({
21142
21138
  emptyFallback,
21143
21139
  errorFallback,
21144
21140
  showFetchingIndicator = true,
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 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]);
21156
21194
  const renderLoading = () => {
21157
21195
  if (loadingFallback) return loadingFallback;
21158
21196
  if (loadingType === "skeleton") {
@@ -21182,8 +21220,8 @@ function AsyncComponentWrapper({
21182
21220
  title: errorTitle,
21183
21221
  message: errorMessage,
21184
21222
  actionText: onRetry ? retryText : void 0,
21185
- actionLoading: isFetching,
21186
- onAction: onRetry,
21223
+ actionLoading: isRetrying,
21224
+ onAction: handleRetry,
21187
21225
  className: stateClassName
21188
21226
  }
21189
21227
  );
@@ -21200,7 +21238,7 @@ function AsyncComponentWrapper({
21200
21238
  }
21201
21239
  );
21202
21240
  };
21203
- if (isLoading) {
21241
+ if (shouldShowLoading) {
21204
21242
  return /* @__PURE__ */ jsx("div", { className, "aria-live": "polite", children: renderLoading() });
21205
21243
  }
21206
21244
  if (isError) {