elseware-ui 2.36.5 → 2.36.6
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 +60 -0
- package/dist/index.css.map +1 -1
- package/dist/index.d.mts +9 -2
- package/dist/index.d.ts +9 -2
- package/dist/index.js +86 -21
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +86 -21
- 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,10 +2216,14 @@ 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;
|
|
@@ -2229,8 +2234,10 @@ interface AsyncComponentWrapperProps {
|
|
|
2229
2234
|
errorFormatter?: (error: unknown) => string;
|
|
2230
2235
|
className?: string;
|
|
2231
2236
|
contentClassName?: string;
|
|
2237
|
+
stateClassName?: string;
|
|
2232
2238
|
}
|
|
2233
|
-
|
|
2239
|
+
|
|
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;
|
|
2234
2241
|
declare const _default: React__default.MemoExoticComponent<typeof AsyncComponentWrapper>;
|
|
2235
2242
|
|
|
2236
2243
|
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,10 +2216,14 @@ 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;
|
|
@@ -2229,8 +2234,10 @@ interface AsyncComponentWrapperProps {
|
|
|
2229
2234
|
errorFormatter?: (error: unknown) => string;
|
|
2230
2235
|
className?: string;
|
|
2231
2236
|
contentClassName?: string;
|
|
2237
|
+
stateClassName?: string;
|
|
2232
2238
|
}
|
|
2233
|
-
|
|
2239
|
+
|
|
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;
|
|
2234
2241
|
declare const _default: React__default.MemoExoticComponent<typeof AsyncComponentWrapper>;
|
|
2235
2242
|
|
|
2236
2243
|
interface GlowWrapperProps {
|
package/dist/index.js
CHANGED
|
@@ -21068,6 +21068,60 @@ 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,
|
|
21077
|
+
onAction,
|
|
21078
|
+
className
|
|
21079
|
+
}) {
|
|
21080
|
+
const isError = type === "error";
|
|
21081
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
21082
|
+
"div",
|
|
21083
|
+
{
|
|
21084
|
+
className: cn(
|
|
21085
|
+
"flex min-h-[220px] w-full items-center justify-center rounded-xl border p-6",
|
|
21086
|
+
"border-eui-dark-300/10 bg-white/70 shadow-sm",
|
|
21087
|
+
"dark:border-eui-light-400/10 dark:bg-eui-dark-900/40",
|
|
21088
|
+
className
|
|
21089
|
+
),
|
|
21090
|
+
children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex max-w-md flex-col items-center gap-4 text-center", children: [
|
|
21091
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
21092
|
+
"div",
|
|
21093
|
+
{
|
|
21094
|
+
className: cn(
|
|
21095
|
+
"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-dark-500/10 text-eui-dark-500 dark:bg-eui-light-500/10 dark:text-eui-light-400"
|
|
21097
|
+
),
|
|
21098
|
+
children: isError ? "!" : "\u2013"
|
|
21099
|
+
}
|
|
21100
|
+
),
|
|
21101
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-2", children: [
|
|
21102
|
+
/* @__PURE__ */ jsxRuntime.jsx("h3", { className: "text-lg font-semibold text-eui-dark-900 dark:text-eui-light-50", children: title }),
|
|
21103
|
+
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
|
+
] }),
|
|
21105
|
+
onAction && actionText && /* @__PURE__ */ jsxRuntime.jsx(
|
|
21106
|
+
Button_default,
|
|
21107
|
+
{
|
|
21108
|
+
type: "button",
|
|
21109
|
+
text: actionText,
|
|
21110
|
+
loading: actionLoading,
|
|
21111
|
+
disabled: actionLoading,
|
|
21112
|
+
onClick: onAction,
|
|
21113
|
+
variant: isError ? "danger" : "primary",
|
|
21114
|
+
appearance: "solid",
|
|
21115
|
+
size: "sm"
|
|
21116
|
+
}
|
|
21117
|
+
)
|
|
21118
|
+
] })
|
|
21119
|
+
}
|
|
21120
|
+
);
|
|
21121
|
+
}
|
|
21122
|
+
var AsyncStateCard_default = React2__default.default.memo(AsyncStateCard);
|
|
21123
|
+
|
|
21124
|
+
// src/components/utils/async-component-wrapper/asyncError.utils.ts
|
|
21071
21125
|
var getDefaultErrorMessage = (error) => {
|
|
21072
21126
|
if (!error) return "Something went wrong.";
|
|
21073
21127
|
if (typeof error === "string") return error;
|
|
@@ -21102,10 +21156,14 @@ function AsyncComponentWrapper({
|
|
|
21102
21156
|
isEmpty = false,
|
|
21103
21157
|
loadingText = "Loading...",
|
|
21104
21158
|
fetchingText = "Updating...",
|
|
21159
|
+
emptyTitle = "No data found",
|
|
21105
21160
|
emptyText = "No data available.",
|
|
21161
|
+
errorTitle = "Something went wrong",
|
|
21162
|
+
retryText = "Retry",
|
|
21106
21163
|
loadingType = "spinner",
|
|
21107
21164
|
skeletonCount = 3,
|
|
21108
21165
|
skeletonClassName = "h-24 w-full rounded-md",
|
|
21166
|
+
skeletonWrapperClassName = "flex flex-col gap-3 py-4",
|
|
21109
21167
|
spinnerProps,
|
|
21110
21168
|
fetchingSpinnerProps,
|
|
21111
21169
|
loadingFallback,
|
|
@@ -21115,7 +21173,8 @@ function AsyncComponentWrapper({
|
|
|
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 "";
|
|
@@ -21125,14 +21184,14 @@ function AsyncComponentWrapper({
|
|
|
21125
21184
|
const renderLoading = () => {
|
|
21126
21185
|
if (loadingFallback) return loadingFallback;
|
|
21127
21186
|
if (loadingType === "skeleton") {
|
|
21128
|
-
return /* @__PURE__ */ jsxRuntime.jsx("div", { className:
|
|
21187
|
+
return /* @__PURE__ */ jsxRuntime.jsx("div", { className: cn(skeletonWrapperClassName), children: Array.from({ length: skeletonCount }).map((_, index) => /* @__PURE__ */ jsxRuntime.jsx(Skeleton, { className: skeletonClassName }, index)) });
|
|
21129
21188
|
}
|
|
21130
21189
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
21131
21190
|
Spinner_default,
|
|
21132
21191
|
{
|
|
21133
21192
|
centered: true,
|
|
21134
21193
|
label: loadingText,
|
|
21135
|
-
type: "
|
|
21194
|
+
type: "bars",
|
|
21136
21195
|
size: "md",
|
|
21137
21196
|
variant: "primary",
|
|
21138
21197
|
...spinnerProps
|
|
@@ -21143,25 +21202,31 @@ function AsyncComponentWrapper({
|
|
|
21143
21202
|
if (typeof errorFallback === "function") {
|
|
21144
21203
|
return errorFallback(errorMessage);
|
|
21145
21204
|
}
|
|
21146
|
-
if (errorFallback)
|
|
21147
|
-
|
|
21148
|
-
|
|
21149
|
-
|
|
21150
|
-
|
|
21151
|
-
|
|
21152
|
-
|
|
21153
|
-
|
|
21154
|
-
|
|
21155
|
-
|
|
21156
|
-
|
|
21157
|
-
|
|
21158
|
-
|
|
21159
|
-
)
|
|
21160
|
-
] });
|
|
21205
|
+
if (errorFallback) return errorFallback;
|
|
21206
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
21207
|
+
AsyncStateCard_default,
|
|
21208
|
+
{
|
|
21209
|
+
type: "error",
|
|
21210
|
+
title: errorTitle,
|
|
21211
|
+
message: errorMessage,
|
|
21212
|
+
actionText: onRetry ? retryText : void 0,
|
|
21213
|
+
actionLoading: isFetching,
|
|
21214
|
+
onAction: onRetry,
|
|
21215
|
+
className: stateClassName
|
|
21216
|
+
}
|
|
21217
|
+
);
|
|
21161
21218
|
};
|
|
21162
21219
|
const renderEmpty = () => {
|
|
21163
21220
|
if (emptyFallback) return emptyFallback;
|
|
21164
|
-
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
21221
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
21222
|
+
AsyncStateCard_default,
|
|
21223
|
+
{
|
|
21224
|
+
type: "empty",
|
|
21225
|
+
title: emptyTitle,
|
|
21226
|
+
message: emptyText,
|
|
21227
|
+
className: stateClassName
|
|
21228
|
+
}
|
|
21229
|
+
);
|
|
21165
21230
|
};
|
|
21166
21231
|
if (isLoading) {
|
|
21167
21232
|
return /* @__PURE__ */ jsxRuntime.jsx("div", { className, "aria-live": "polite", children: renderLoading() });
|
|
@@ -21176,12 +21241,12 @@ function AsyncComponentWrapper({
|
|
|
21176
21241
|
return null;
|
|
21177
21242
|
}
|
|
21178
21243
|
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-
|
|
21244
|
+
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
21245
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
21181
21246
|
Spinner_default,
|
|
21182
21247
|
{
|
|
21183
21248
|
size: "xs",
|
|
21184
|
-
type: "
|
|
21249
|
+
type: "bars",
|
|
21185
21250
|
variant: "primary",
|
|
21186
21251
|
showLabel: false,
|
|
21187
21252
|
ariaLabel: fetchingText,
|