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.mjs CHANGED
@@ -21040,6 +21040,60 @@ 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,
21049
+ onAction,
21050
+ className
21051
+ }) {
21052
+ const isError = type === "error";
21053
+ return /* @__PURE__ */ jsx(
21054
+ "div",
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: [
21063
+ /* @__PURE__ */ jsx(
21064
+ "div",
21065
+ {
21066
+ className: cn(
21067
+ "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"
21069
+ ),
21070
+ children: isError ? "!" : "\u2013"
21071
+ }
21072
+ ),
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 }),
21075
+ 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
+ ] }),
21077
+ onAction && actionText && /* @__PURE__ */ jsx(
21078
+ Button_default,
21079
+ {
21080
+ type: "button",
21081
+ text: actionText,
21082
+ loading: actionLoading,
21083
+ disabled: actionLoading,
21084
+ onClick: onAction,
21085
+ variant: isError ? "danger" : "primary",
21086
+ appearance: "solid",
21087
+ size: "sm"
21088
+ }
21089
+ )
21090
+ ] })
21091
+ }
21092
+ );
21093
+ }
21094
+ var AsyncStateCard_default = React2.memo(AsyncStateCard);
21095
+
21096
+ // src/components/utils/async-component-wrapper/asyncError.utils.ts
21043
21097
  var getDefaultErrorMessage = (error) => {
21044
21098
  if (!error) return "Something went wrong.";
21045
21099
  if (typeof error === "string") return error;
@@ -21074,10 +21128,14 @@ function AsyncComponentWrapper({
21074
21128
  isEmpty = false,
21075
21129
  loadingText = "Loading...",
21076
21130
  fetchingText = "Updating...",
21131
+ emptyTitle = "No data found",
21077
21132
  emptyText = "No data available.",
21133
+ errorTitle = "Something went wrong",
21134
+ retryText = "Retry",
21078
21135
  loadingType = "spinner",
21079
21136
  skeletonCount = 3,
21080
21137
  skeletonClassName = "h-24 w-full rounded-md",
21138
+ skeletonWrapperClassName = "flex flex-col gap-3 py-4",
21081
21139
  spinnerProps,
21082
21140
  fetchingSpinnerProps,
21083
21141
  loadingFallback,
@@ -21087,7 +21145,8 @@ function AsyncComponentWrapper({
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 "";
@@ -21097,14 +21156,14 @@ function AsyncComponentWrapper({
21097
21156
  const renderLoading = () => {
21098
21157
  if (loadingFallback) return loadingFallback;
21099
21158
  if (loadingType === "skeleton") {
21100
- return /* @__PURE__ */ jsx("div", { className: "flex flex-col gap-3 py-4", children: Array.from({ length: skeletonCount }).map((_, index) => /* @__PURE__ */ jsx(Skeleton, { className: skeletonClassName }, index)) });
21159
+ return /* @__PURE__ */ jsx("div", { className: cn(skeletonWrapperClassName), children: Array.from({ length: skeletonCount }).map((_, index) => /* @__PURE__ */ jsx(Skeleton, { className: skeletonClassName }, index)) });
21101
21160
  }
21102
21161
  return /* @__PURE__ */ jsx(
21103
21162
  Spinner_default,
21104
21163
  {
21105
21164
  centered: true,
21106
21165
  label: loadingText,
21107
- type: "border",
21166
+ type: "bars",
21108
21167
  size: "md",
21109
21168
  variant: "primary",
21110
21169
  ...spinnerProps
@@ -21115,25 +21174,31 @@ function AsyncComponentWrapper({
21115
21174
  if (typeof errorFallback === "function") {
21116
21175
  return errorFallback(errorMessage);
21117
21176
  }
21118
- if (errorFallback) {
21119
- return errorFallback;
21120
- }
21121
- return /* @__PURE__ */ jsxs("div", { className: "p-5", children: [
21122
- /* @__PURE__ */ jsx(FormResponse_default, { text: errorMessage, variant: "danger" }),
21123
- onRetry && /* @__PURE__ */ jsx(
21124
- "button",
21125
- {
21126
- type: "button",
21127
- onClick: onRetry,
21128
- className: "mt-3 rounded-md border px-4 py-2",
21129
- children: "Retry"
21130
- }
21131
- )
21132
- ] });
21177
+ if (errorFallback) return errorFallback;
21178
+ return /* @__PURE__ */ jsx(
21179
+ AsyncStateCard_default,
21180
+ {
21181
+ type: "error",
21182
+ title: errorTitle,
21183
+ message: errorMessage,
21184
+ actionText: onRetry ? retryText : void 0,
21185
+ actionLoading: isFetching,
21186
+ onAction: onRetry,
21187
+ className: stateClassName
21188
+ }
21189
+ );
21133
21190
  };
21134
21191
  const renderEmpty = () => {
21135
21192
  if (emptyFallback) return emptyFallback;
21136
- return /* @__PURE__ */ jsx("div", { className: "py-10 text-center text-gray-500", children: emptyText });
21193
+ return /* @__PURE__ */ jsx(
21194
+ AsyncStateCard_default,
21195
+ {
21196
+ type: "empty",
21197
+ title: emptyTitle,
21198
+ message: emptyText,
21199
+ className: stateClassName
21200
+ }
21201
+ );
21137
21202
  };
21138
21203
  if (isLoading) {
21139
21204
  return /* @__PURE__ */ jsx("div", { className, "aria-live": "polite", children: renderLoading() });
@@ -21148,12 +21213,12 @@ function AsyncComponentWrapper({
21148
21213
  return null;
21149
21214
  }
21150
21215
  return /* @__PURE__ */ jsxs("div", { className, children: [
21151
- showFetchingIndicator && isFetching && /* @__PURE__ */ jsxs("div", { className: "mb-3 flex items-center gap-2 text-sm text-gray-500", children: [
21216
+ 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
21217
  /* @__PURE__ */ jsx(
21153
21218
  Spinner_default,
21154
21219
  {
21155
21220
  size: "xs",
21156
- type: "border",
21221
+ type: "bars",
21157
21222
  variant: "primary",
21158
21223
  showLabel: false,
21159
21224
  ariaLabel: fetchingText,