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.mjs
CHANGED
|
@@ -21040,6 +21040,59 @@ function UnderConstructionBanner({
|
|
|
21040
21040
|
}) {
|
|
21041
21041
|
return /* @__PURE__ */ jsx("div", { className: "my-5", children: /* @__PURE__ */ jsx(Info_default, { children: text ? text : "This component is currently under construction and will be made available soon" }) });
|
|
21042
21042
|
}
|
|
21043
|
+
function AsyncStateCard({
|
|
21044
|
+
type,
|
|
21045
|
+
title,
|
|
21046
|
+
message,
|
|
21047
|
+
actionText,
|
|
21048
|
+
actionLoading = false,
|
|
21049
|
+
onAction,
|
|
21050
|
+
className
|
|
21051
|
+
}) {
|
|
21052
|
+
const isError = type === "error";
|
|
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
|
+
{
|
|
21056
|
+
bgVariant: "default",
|
|
21057
|
+
borderVariant: isError ? "danger" : "secondary",
|
|
21058
|
+
shape: "softRoundedSquare",
|
|
21059
|
+
hoverAnimation: "softLift",
|
|
21060
|
+
styles: cn("w-full max-w-xl", className),
|
|
21061
|
+
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
|
+
/* @__PURE__ */ jsx(
|
|
21063
|
+
"div",
|
|
21064
|
+
{
|
|
21065
|
+
className: cn(
|
|
21066
|
+
"flex h-12 w-12 items-center justify-center rounded-full text-xl font-bold",
|
|
21067
|
+
isError ? "bg-eui-danger-500/10 text-eui-danger-500" : "bg-eui-secondary-500/10 text-eui-secondary-500"
|
|
21068
|
+
),
|
|
21069
|
+
children: isError ? "!" : "\u2013"
|
|
21070
|
+
}
|
|
21071
|
+
),
|
|
21072
|
+
/* @__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-50", children: title }),
|
|
21074
|
+
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
|
+
] }),
|
|
21076
|
+
onAction && actionText && /* @__PURE__ */ jsx(
|
|
21077
|
+
Button_default,
|
|
21078
|
+
{
|
|
21079
|
+
type: "button",
|
|
21080
|
+
text: actionText,
|
|
21081
|
+
loading: actionLoading,
|
|
21082
|
+
disabled: actionLoading,
|
|
21083
|
+
onClick: onAction,
|
|
21084
|
+
variant: isError ? "danger" : "primary",
|
|
21085
|
+
appearance: "solid",
|
|
21086
|
+
size: "sm"
|
|
21087
|
+
}
|
|
21088
|
+
)
|
|
21089
|
+
] }) })
|
|
21090
|
+
}
|
|
21091
|
+
) });
|
|
21092
|
+
}
|
|
21093
|
+
var AsyncStateCard_default = React2.memo(AsyncStateCard);
|
|
21094
|
+
|
|
21095
|
+
// src/components/utils/async-component-wrapper/asyncError.utils.ts
|
|
21043
21096
|
var getDefaultErrorMessage = (error) => {
|
|
21044
21097
|
if (!error) return "Something went wrong.";
|
|
21045
21098
|
if (typeof error === "string") return error;
|
|
@@ -21074,37 +21127,44 @@ function AsyncComponentWrapper({
|
|
|
21074
21127
|
isEmpty = false,
|
|
21075
21128
|
loadingText = "Loading...",
|
|
21076
21129
|
fetchingText = "Updating...",
|
|
21130
|
+
emptyTitle = "No data found",
|
|
21077
21131
|
emptyText = "No data available.",
|
|
21132
|
+
errorTitle = "Something went wrong",
|
|
21133
|
+
retryText = "Retry",
|
|
21078
21134
|
loadingType = "spinner",
|
|
21079
21135
|
skeletonCount = 3,
|
|
21080
21136
|
skeletonClassName = "h-24 w-full rounded-md",
|
|
21137
|
+
skeletonWrapperClassName = "flex flex-col gap-3 py-4",
|
|
21081
21138
|
spinnerProps,
|
|
21082
21139
|
fetchingSpinnerProps,
|
|
21083
21140
|
loadingFallback,
|
|
21084
21141
|
emptyFallback,
|
|
21085
21142
|
errorFallback,
|
|
21086
21143
|
showFetchingIndicator = true,
|
|
21144
|
+
showLoadingOnRetry = true,
|
|
21087
21145
|
onRetry,
|
|
21088
21146
|
errorFormatter,
|
|
21089
21147
|
className,
|
|
21090
|
-
contentClassName
|
|
21148
|
+
contentClassName,
|
|
21149
|
+
stateClassName
|
|
21091
21150
|
}) {
|
|
21092
21151
|
const errorMessage = useMemo(() => {
|
|
21093
21152
|
if (!isError) return "";
|
|
21094
21153
|
return errorFormatter ? errorFormatter(error) : getDefaultErrorMessage(error);
|
|
21095
21154
|
}, [isError, error, errorFormatter]);
|
|
21096
21155
|
const hasSuccess = isSuccess ?? (!isLoading && !isError && !isUninitialized);
|
|
21156
|
+
const shouldShowLoading = isLoading || showLoadingOnRetry && isFetching && isError;
|
|
21097
21157
|
const renderLoading = () => {
|
|
21098
21158
|
if (loadingFallback) return loadingFallback;
|
|
21099
21159
|
if (loadingType === "skeleton") {
|
|
21100
|
-
return /* @__PURE__ */ jsx("div", { className:
|
|
21160
|
+
return /* @__PURE__ */ jsx("div", { className: cn(skeletonWrapperClassName), children: Array.from({ length: skeletonCount }).map((_, index) => /* @__PURE__ */ jsx(Skeleton, { className: skeletonClassName }, index)) });
|
|
21101
21161
|
}
|
|
21102
21162
|
return /* @__PURE__ */ jsx(
|
|
21103
21163
|
Spinner_default,
|
|
21104
21164
|
{
|
|
21105
21165
|
centered: true,
|
|
21106
21166
|
label: loadingText,
|
|
21107
|
-
type: "
|
|
21167
|
+
type: "bars",
|
|
21108
21168
|
size: "md",
|
|
21109
21169
|
variant: "primary",
|
|
21110
21170
|
...spinnerProps
|
|
@@ -21115,27 +21175,33 @@ function AsyncComponentWrapper({
|
|
|
21115
21175
|
if (typeof errorFallback === "function") {
|
|
21116
21176
|
return errorFallback(errorMessage);
|
|
21117
21177
|
}
|
|
21118
|
-
if (errorFallback)
|
|
21119
|
-
|
|
21120
|
-
|
|
21121
|
-
|
|
21122
|
-
|
|
21123
|
-
|
|
21124
|
-
|
|
21125
|
-
|
|
21126
|
-
|
|
21127
|
-
|
|
21128
|
-
|
|
21129
|
-
|
|
21130
|
-
|
|
21131
|
-
)
|
|
21132
|
-
] });
|
|
21178
|
+
if (errorFallback) return errorFallback;
|
|
21179
|
+
return /* @__PURE__ */ jsx(
|
|
21180
|
+
AsyncStateCard_default,
|
|
21181
|
+
{
|
|
21182
|
+
type: "error",
|
|
21183
|
+
title: errorTitle,
|
|
21184
|
+
message: errorMessage,
|
|
21185
|
+
actionText: onRetry ? retryText : void 0,
|
|
21186
|
+
actionLoading: false,
|
|
21187
|
+
onAction: onRetry,
|
|
21188
|
+
className: stateClassName
|
|
21189
|
+
}
|
|
21190
|
+
);
|
|
21133
21191
|
};
|
|
21134
21192
|
const renderEmpty = () => {
|
|
21135
21193
|
if (emptyFallback) return emptyFallback;
|
|
21136
|
-
return /* @__PURE__ */ jsx(
|
|
21194
|
+
return /* @__PURE__ */ jsx(
|
|
21195
|
+
AsyncStateCard_default,
|
|
21196
|
+
{
|
|
21197
|
+
type: "empty",
|
|
21198
|
+
title: emptyTitle,
|
|
21199
|
+
message: emptyText,
|
|
21200
|
+
className: stateClassName
|
|
21201
|
+
}
|
|
21202
|
+
);
|
|
21137
21203
|
};
|
|
21138
|
-
if (
|
|
21204
|
+
if (shouldShowLoading) {
|
|
21139
21205
|
return /* @__PURE__ */ jsx("div", { className, "aria-live": "polite", children: renderLoading() });
|
|
21140
21206
|
}
|
|
21141
21207
|
if (isError) {
|
|
@@ -21148,12 +21214,12 @@ function AsyncComponentWrapper({
|
|
|
21148
21214
|
return null;
|
|
21149
21215
|
}
|
|
21150
21216
|
return /* @__PURE__ */ jsxs("div", { className, children: [
|
|
21151
|
-
showFetchingIndicator && isFetching && /* @__PURE__ */ jsxs("div", { className: "mb-3 flex items-center gap-2 text-sm text-
|
|
21217
|
+
showFetchingIndicator && isFetching && /* @__PURE__ */ jsxs("div", { className: "mb-3 flex items-center gap-2 text-sm text-eui-dark-500 dark:text-eui-light-400", children: [
|
|
21152
21218
|
/* @__PURE__ */ jsx(
|
|
21153
21219
|
Spinner_default,
|
|
21154
21220
|
{
|
|
21155
21221
|
size: "xs",
|
|
21156
|
-
type: "
|
|
21222
|
+
type: "bars",
|
|
21157
21223
|
variant: "primary",
|
|
21158
21224
|
showLabel: false,
|
|
21159
21225
|
ariaLabel: fetchingText,
|