elseware-ui 2.36.5 → 2.36.7
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 +45 -0
- package/dist/index.css.map +1 -1
- package/dist/index.d.mts +10 -2
- package/dist/index.d.ts +10 -2
- package/dist/index.js +88 -22
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +88 -22
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -2204,6 +2204,7 @@ declare const ThemeSwitch: () => React__default.JSX.Element | null;
|
|
|
2204
2204
|
|
|
2205
2205
|
declare const ShapeSwitch: () => React__default.JSX.Element;
|
|
2206
2206
|
|
|
2207
|
+
type AsyncLoadingType = "spinner" | "skeleton";
|
|
2207
2208
|
interface AsyncComponentWrapperProps {
|
|
2208
2209
|
children: React__default.ReactNode;
|
|
2209
2210
|
isLoading?: boolean;
|
|
@@ -2215,22 +2216,29 @@ interface AsyncComponentWrapperProps {
|
|
|
2215
2216
|
isEmpty?: boolean;
|
|
2216
2217
|
loadingText?: string;
|
|
2217
2218
|
fetchingText?: string;
|
|
2219
|
+
emptyTitle?: string;
|
|
2218
2220
|
emptyText?: string;
|
|
2219
|
-
|
|
2221
|
+
errorTitle?: string;
|
|
2222
|
+
retryText?: string;
|
|
2223
|
+
loadingType?: AsyncLoadingType;
|
|
2220
2224
|
skeletonCount?: number;
|
|
2221
2225
|
skeletonClassName?: string;
|
|
2226
|
+
skeletonWrapperClassName?: string;
|
|
2222
2227
|
spinnerProps?: Partial<SpinnerProps>;
|
|
2223
2228
|
fetchingSpinnerProps?: Partial<SpinnerProps>;
|
|
2224
2229
|
loadingFallback?: React__default.ReactNode;
|
|
2225
2230
|
emptyFallback?: React__default.ReactNode;
|
|
2226
2231
|
errorFallback?: React__default.ReactNode | ((message: string) => React__default.ReactNode);
|
|
2227
2232
|
showFetchingIndicator?: boolean;
|
|
2233
|
+
showLoadingOnRetry?: boolean;
|
|
2228
2234
|
onRetry?: () => void;
|
|
2229
2235
|
errorFormatter?: (error: unknown) => string;
|
|
2230
2236
|
className?: string;
|
|
2231
2237
|
contentClassName?: string;
|
|
2238
|
+
stateClassName?: string;
|
|
2232
2239
|
}
|
|
2233
|
-
|
|
2240
|
+
|
|
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;
|
|
2234
2242
|
declare const _default: React__default.MemoExoticComponent<typeof AsyncComponentWrapper>;
|
|
2235
2243
|
|
|
2236
2244
|
interface GlowWrapperProps {
|
package/dist/index.d.ts
CHANGED
|
@@ -2204,6 +2204,7 @@ declare const ThemeSwitch: () => React__default.JSX.Element | null;
|
|
|
2204
2204
|
|
|
2205
2205
|
declare const ShapeSwitch: () => React__default.JSX.Element;
|
|
2206
2206
|
|
|
2207
|
+
type AsyncLoadingType = "spinner" | "skeleton";
|
|
2207
2208
|
interface AsyncComponentWrapperProps {
|
|
2208
2209
|
children: React__default.ReactNode;
|
|
2209
2210
|
isLoading?: boolean;
|
|
@@ -2215,22 +2216,29 @@ interface AsyncComponentWrapperProps {
|
|
|
2215
2216
|
isEmpty?: boolean;
|
|
2216
2217
|
loadingText?: string;
|
|
2217
2218
|
fetchingText?: string;
|
|
2219
|
+
emptyTitle?: string;
|
|
2218
2220
|
emptyText?: string;
|
|
2219
|
-
|
|
2221
|
+
errorTitle?: string;
|
|
2222
|
+
retryText?: string;
|
|
2223
|
+
loadingType?: AsyncLoadingType;
|
|
2220
2224
|
skeletonCount?: number;
|
|
2221
2225
|
skeletonClassName?: string;
|
|
2226
|
+
skeletonWrapperClassName?: string;
|
|
2222
2227
|
spinnerProps?: Partial<SpinnerProps>;
|
|
2223
2228
|
fetchingSpinnerProps?: Partial<SpinnerProps>;
|
|
2224
2229
|
loadingFallback?: React__default.ReactNode;
|
|
2225
2230
|
emptyFallback?: React__default.ReactNode;
|
|
2226
2231
|
errorFallback?: React__default.ReactNode | ((message: string) => React__default.ReactNode);
|
|
2227
2232
|
showFetchingIndicator?: boolean;
|
|
2233
|
+
showLoadingOnRetry?: boolean;
|
|
2228
2234
|
onRetry?: () => void;
|
|
2229
2235
|
errorFormatter?: (error: unknown) => string;
|
|
2230
2236
|
className?: string;
|
|
2231
2237
|
contentClassName?: string;
|
|
2238
|
+
stateClassName?: string;
|
|
2232
2239
|
}
|
|
2233
|
-
|
|
2240
|
+
|
|
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;
|
|
2234
2242
|
declare const _default: React__default.MemoExoticComponent<typeof AsyncComponentWrapper>;
|
|
2235
2243
|
|
|
2236
2244
|
interface GlowWrapperProps {
|
package/dist/index.js
CHANGED
|
@@ -21068,6 +21068,59 @@ function UnderConstructionBanner({
|
|
|
21068
21068
|
}) {
|
|
21069
21069
|
return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "my-5", children: /* @__PURE__ */ jsxRuntime.jsx(Info_default, { children: text ? text : "This component is currently under construction and will be made available soon" }) });
|
|
21070
21070
|
}
|
|
21071
|
+
function AsyncStateCard({
|
|
21072
|
+
type,
|
|
21073
|
+
title,
|
|
21074
|
+
message,
|
|
21075
|
+
actionText,
|
|
21076
|
+
actionLoading = false,
|
|
21077
|
+
onAction,
|
|
21078
|
+
className
|
|
21079
|
+
}) {
|
|
21080
|
+
const isError = type === "error";
|
|
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
|
+
{
|
|
21084
|
+
bgVariant: "default",
|
|
21085
|
+
borderVariant: isError ? "danger" : "secondary",
|
|
21086
|
+
shape: "softRoundedSquare",
|
|
21087
|
+
hoverAnimation: "softLift",
|
|
21088
|
+
styles: cn("w-full max-w-xl", className),
|
|
21089
|
+
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
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
21091
|
+
"div",
|
|
21092
|
+
{
|
|
21093
|
+
className: cn(
|
|
21094
|
+
"flex h-12 w-12 items-center justify-center rounded-full text-xl font-bold",
|
|
21095
|
+
isError ? "bg-eui-danger-500/10 text-eui-danger-500" : "bg-eui-secondary-500/10 text-eui-secondary-500"
|
|
21096
|
+
),
|
|
21097
|
+
children: isError ? "!" : "\u2013"
|
|
21098
|
+
}
|
|
21099
|
+
),
|
|
21100
|
+
/* @__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-50", children: title }),
|
|
21102
|
+
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
|
+
] }),
|
|
21104
|
+
onAction && actionText && /* @__PURE__ */ jsxRuntime.jsx(
|
|
21105
|
+
Button_default,
|
|
21106
|
+
{
|
|
21107
|
+
type: "button",
|
|
21108
|
+
text: actionText,
|
|
21109
|
+
loading: actionLoading,
|
|
21110
|
+
disabled: actionLoading,
|
|
21111
|
+
onClick: onAction,
|
|
21112
|
+
variant: isError ? "danger" : "primary",
|
|
21113
|
+
appearance: "solid",
|
|
21114
|
+
size: "sm"
|
|
21115
|
+
}
|
|
21116
|
+
)
|
|
21117
|
+
] }) })
|
|
21118
|
+
}
|
|
21119
|
+
) });
|
|
21120
|
+
}
|
|
21121
|
+
var AsyncStateCard_default = React2__default.default.memo(AsyncStateCard);
|
|
21122
|
+
|
|
21123
|
+
// src/components/utils/async-component-wrapper/asyncError.utils.ts
|
|
21071
21124
|
var getDefaultErrorMessage = (error) => {
|
|
21072
21125
|
if (!error) return "Something went wrong.";
|
|
21073
21126
|
if (typeof error === "string") return error;
|
|
@@ -21102,37 +21155,44 @@ function AsyncComponentWrapper({
|
|
|
21102
21155
|
isEmpty = false,
|
|
21103
21156
|
loadingText = "Loading...",
|
|
21104
21157
|
fetchingText = "Updating...",
|
|
21158
|
+
emptyTitle = "No data found",
|
|
21105
21159
|
emptyText = "No data available.",
|
|
21160
|
+
errorTitle = "Something went wrong",
|
|
21161
|
+
retryText = "Retry",
|
|
21106
21162
|
loadingType = "spinner",
|
|
21107
21163
|
skeletonCount = 3,
|
|
21108
21164
|
skeletonClassName = "h-24 w-full rounded-md",
|
|
21165
|
+
skeletonWrapperClassName = "flex flex-col gap-3 py-4",
|
|
21109
21166
|
spinnerProps,
|
|
21110
21167
|
fetchingSpinnerProps,
|
|
21111
21168
|
loadingFallback,
|
|
21112
21169
|
emptyFallback,
|
|
21113
21170
|
errorFallback,
|
|
21114
21171
|
showFetchingIndicator = true,
|
|
21172
|
+
showLoadingOnRetry = true,
|
|
21115
21173
|
onRetry,
|
|
21116
21174
|
errorFormatter,
|
|
21117
21175
|
className,
|
|
21118
|
-
contentClassName
|
|
21176
|
+
contentClassName,
|
|
21177
|
+
stateClassName
|
|
21119
21178
|
}) {
|
|
21120
21179
|
const errorMessage = React2.useMemo(() => {
|
|
21121
21180
|
if (!isError) return "";
|
|
21122
21181
|
return errorFormatter ? errorFormatter(error) : getDefaultErrorMessage(error);
|
|
21123
21182
|
}, [isError, error, errorFormatter]);
|
|
21124
21183
|
const hasSuccess = isSuccess ?? (!isLoading && !isError && !isUninitialized);
|
|
21184
|
+
const shouldShowLoading = isLoading || showLoadingOnRetry && isFetching && isError;
|
|
21125
21185
|
const renderLoading = () => {
|
|
21126
21186
|
if (loadingFallback) return loadingFallback;
|
|
21127
21187
|
if (loadingType === "skeleton") {
|
|
21128
|
-
return /* @__PURE__ */ jsxRuntime.jsx("div", { className:
|
|
21188
|
+
return /* @__PURE__ */ jsxRuntime.jsx("div", { className: cn(skeletonWrapperClassName), children: Array.from({ length: skeletonCount }).map((_, index) => /* @__PURE__ */ jsxRuntime.jsx(Skeleton, { className: skeletonClassName }, index)) });
|
|
21129
21189
|
}
|
|
21130
21190
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
21131
21191
|
Spinner_default,
|
|
21132
21192
|
{
|
|
21133
21193
|
centered: true,
|
|
21134
21194
|
label: loadingText,
|
|
21135
|
-
type: "
|
|
21195
|
+
type: "bars",
|
|
21136
21196
|
size: "md",
|
|
21137
21197
|
variant: "primary",
|
|
21138
21198
|
...spinnerProps
|
|
@@ -21143,27 +21203,33 @@ function AsyncComponentWrapper({
|
|
|
21143
21203
|
if (typeof errorFallback === "function") {
|
|
21144
21204
|
return errorFallback(errorMessage);
|
|
21145
21205
|
}
|
|
21146
|
-
if (errorFallback)
|
|
21147
|
-
|
|
21148
|
-
|
|
21149
|
-
|
|
21150
|
-
|
|
21151
|
-
|
|
21152
|
-
|
|
21153
|
-
|
|
21154
|
-
|
|
21155
|
-
|
|
21156
|
-
|
|
21157
|
-
|
|
21158
|
-
|
|
21159
|
-
)
|
|
21160
|
-
] });
|
|
21206
|
+
if (errorFallback) return errorFallback;
|
|
21207
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
21208
|
+
AsyncStateCard_default,
|
|
21209
|
+
{
|
|
21210
|
+
type: "error",
|
|
21211
|
+
title: errorTitle,
|
|
21212
|
+
message: errorMessage,
|
|
21213
|
+
actionText: onRetry ? retryText : void 0,
|
|
21214
|
+
actionLoading: false,
|
|
21215
|
+
onAction: onRetry,
|
|
21216
|
+
className: stateClassName
|
|
21217
|
+
}
|
|
21218
|
+
);
|
|
21161
21219
|
};
|
|
21162
21220
|
const renderEmpty = () => {
|
|
21163
21221
|
if (emptyFallback) return emptyFallback;
|
|
21164
|
-
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
21222
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
21223
|
+
AsyncStateCard_default,
|
|
21224
|
+
{
|
|
21225
|
+
type: "empty",
|
|
21226
|
+
title: emptyTitle,
|
|
21227
|
+
message: emptyText,
|
|
21228
|
+
className: stateClassName
|
|
21229
|
+
}
|
|
21230
|
+
);
|
|
21165
21231
|
};
|
|
21166
|
-
if (
|
|
21232
|
+
if (shouldShowLoading) {
|
|
21167
21233
|
return /* @__PURE__ */ jsxRuntime.jsx("div", { className, "aria-live": "polite", children: renderLoading() });
|
|
21168
21234
|
}
|
|
21169
21235
|
if (isError) {
|
|
@@ -21176,12 +21242,12 @@ function AsyncComponentWrapper({
|
|
|
21176
21242
|
return null;
|
|
21177
21243
|
}
|
|
21178
21244
|
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className, children: [
|
|
21179
|
-
showFetchingIndicator && isFetching && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "mb-3 flex items-center gap-2 text-sm text-
|
|
21245
|
+
showFetchingIndicator && isFetching && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "mb-3 flex items-center gap-2 text-sm text-eui-dark-500 dark:text-eui-light-400", children: [
|
|
21180
21246
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
21181
21247
|
Spinner_default,
|
|
21182
21248
|
{
|
|
21183
21249
|
size: "xs",
|
|
21184
|
-
type: "
|
|
21250
|
+
type: "bars",
|
|
21185
21251
|
variant: "primary",
|
|
21186
21252
|
showLabel: false,
|
|
21187
21253
|
ariaLabel: fetchingText,
|