@serhii.olishevskyi/docs 1.2.17 → 1.2.19

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.d.mts CHANGED
@@ -1,6 +1,6 @@
1
1
  import * as React$1 from 'react';
2
2
  import React__default, { ReactNode } from 'react';
3
- import { TextFieldProps, SelectProps, SelectChangeEvent, FormControlLabelProps, SwitchProps, CheckboxProps, IconButtonProps, TooltipProps, SxProps, Theme, TypographyProps } from '@mui/material';
3
+ import { TextFieldProps, SelectProps, SelectChangeEvent, FormControlLabelProps, SwitchProps, CheckboxProps, ButtonProps, IconButtonProps, TooltipProps, SxProps, Theme, TypographyProps } from '@mui/material';
4
4
  import { SystemProps } from '@mui/system';
5
5
  import * as _supabase_supabase_js from '@supabase/supabase-js';
6
6
  import { SupabaseClient, User, Session } from '@supabase/supabase-js';
@@ -155,6 +155,22 @@ type CheckboxComponentProps = Omit<FormControlLabelProps, 'control' | 'label' |
155
155
  checkboxProps?: CheckboxProps;
156
156
  };
157
157
 
158
+ type ButtonComponentProps = Omit<ButtonProps, 'children'> & {
159
+ /**
160
+ * Метка кнопки. Если передана строка, она автоматически
161
+ * оборачивается в <TranslateText> для локализации.
162
+ */
163
+ label?: ReactNode;
164
+ /**
165
+ * Кастомный неймспейс для перевода (если нужен)
166
+ */
167
+ overrideNamespace?: string;
168
+ /**
169
+ * Дочерние элементы (используются, если не передан label)
170
+ */
171
+ children?: ReactNode;
172
+ };
173
+
158
174
  interface CopyClipboardButtonComponentProps extends Omit<IconButtonProps, 'onClick'> {
159
175
  overrideNamespace?: string;
160
176
  /** Текст, який буде скопійовано в буфер обміну */
@@ -399,6 +415,15 @@ type CollapsedWidgetContainerProps = {
399
415
  onExpanded?: (expanded: boolean) => void;
400
416
  };
401
417
 
418
+ interface ErrorAlertWidgetProps {
419
+ overrideNamespace?: string;
420
+ title?: ReactNode;
421
+ message: ReactNode;
422
+ onRetry?: () => void;
423
+ retryText?: ReactNode;
424
+ isRetrying?: boolean;
425
+ }
426
+
402
427
  declare const UI: {
403
428
  Inputs: {
404
429
  TextField: React$1.FC<TextFieldComponentProps>;
@@ -411,6 +436,7 @@ declare const UI: {
411
436
  Url: typeof UrlComponent;
412
437
  };
413
438
  Buttons: {
439
+ Button: React$1.ForwardRefExoticComponent<Omit<ButtonComponentProps, "ref"> & React$1.RefAttributes<HTMLButtonElement>>;
414
440
  CopyClipboardButton: React$1.FC<CopyClipboardButtonComponentProps>;
415
441
  RefreshButton: React$1.FC<RefreshButtonComponentProps>;
416
442
  };
@@ -432,6 +458,9 @@ declare const UI: {
432
458
  PageLinkWidget: React$1.FC<PageLinkWidgetProps>;
433
459
  CollapsedWidgetContainer: (props: React$1.PropsWithChildren<CollapsedWidgetContainerProps>) => React$1.JSX.Element;
434
460
  };
461
+ Misc: {
462
+ ErrorAlertWidget: React$1.FC<ErrorAlertWidgetProps>;
463
+ };
435
464
  };
436
465
  };
437
466
 
@@ -785,4 +814,4 @@ declare const Utils: {
785
814
  };
786
815
  };
787
816
 
788
- export { type AIConfig, type AIGenerateOptions, AIProvider, type AIProviderProps, type AIProviderType, AppSettingsProvider, AuthProvider, BreadcrumbProvider, type CheckboxComponentProps, type CollapsedWidgetContainerProps, type CompanyMember, type ConfirmOptions, type ConfirmResult, ConfirmationProvider, type ConfirmationProviderProps, type CopyClipboardButtonComponentProps, type DialogSeverity, type DisplayState, type EmailInputComponentProps, type ExpandableNoteComponentProps, type FullCompanyMemberItem, Hooks, type Language, LocalizationProvider, type Membership, type MembershipRole, type MyAvatarComponentProps, type NumberInputComponentProps, type PageLink, type PageLinkWidgetProps, Providers, type RefreshButtonComponentProps, type SaveCompanyUserPayload, type SearchComponentProps, type SelectComponentProps, type SelectOption, Services, type SupabaseConfig, SupabaseProvider, type SupabaseProviderProps, type SwitchComponentProps, type TextFieldComponentProps, type ThemeColors, type ThemeConfig, type ThemeMode, ThemeProvider, ToastProvider, type ToastType, type TranslatableTooltipComponentProps, TranslateProvider, TranslateText, TranslationEditProvider, type TypographyConfig, UI, type UrlComponentProps as UrlProps, type UserAvatarComponentProps, type UserGroupedSessions, type UserPopoverComponentProps, type UserProfile, type UserRoleChipComponentProps, type UserSessionItem, type UserSettings, UserSettingsProvider, type UserStatusChipComponentProps, type UserStatusType, Utils, defaultUserSettings, initI18n, useAI, useAppSettings, useAppTheme, useAuth, useBreadcrumb, useConfirmation, useLocalization, useSupabase, useToast, useTranslationEdit, useTranslationNamespace, useUserSettings };
817
+ export { type AIConfig, type AIGenerateOptions, AIProvider, type AIProviderProps, type AIProviderType, AppSettingsProvider, AuthProvider, BreadcrumbProvider, type ButtonComponentProps, type CheckboxComponentProps, type CollapsedWidgetContainerProps, type CompanyMember, type ConfirmOptions, type ConfirmResult, ConfirmationProvider, type ConfirmationProviderProps, type CopyClipboardButtonComponentProps, type DialogSeverity, type DisplayState, type EmailInputComponentProps, type ErrorAlertWidgetProps, type ExpandableNoteComponentProps, type FullCompanyMemberItem, Hooks, type Language, LocalizationProvider, type Membership, type MembershipRole, type MyAvatarComponentProps, type NumberInputComponentProps, type PageLink, type PageLinkWidgetProps, Providers, type RefreshButtonComponentProps, type SaveCompanyUserPayload, type SearchComponentProps, type SelectComponentProps, type SelectOption, Services, type SupabaseConfig, SupabaseProvider, type SupabaseProviderProps, type SwitchComponentProps, type TextFieldComponentProps, type ThemeColors, type ThemeConfig, type ThemeMode, ThemeProvider, ToastProvider, type ToastType, type TranslatableTooltipComponentProps, TranslateProvider, TranslateText, TranslationEditProvider, type TypographyConfig, UI, type UrlComponentProps as UrlProps, type UserAvatarComponentProps, type UserGroupedSessions, type UserPopoverComponentProps, type UserProfile, type UserRoleChipComponentProps, type UserSessionItem, type UserSettings, UserSettingsProvider, type UserStatusChipComponentProps, type UserStatusType, Utils, defaultUserSettings, initI18n, useAI, useAppSettings, useAppTheme, useAuth, useBreadcrumb, useConfirmation, useLocalization, useSupabase, useToast, useTranslationEdit, useTranslationNamespace, useUserSettings };
package/dist/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import * as React$1 from 'react';
2
2
  import React__default, { ReactNode } from 'react';
3
- import { TextFieldProps, SelectProps, SelectChangeEvent, FormControlLabelProps, SwitchProps, CheckboxProps, IconButtonProps, TooltipProps, SxProps, Theme, TypographyProps } from '@mui/material';
3
+ import { TextFieldProps, SelectProps, SelectChangeEvent, FormControlLabelProps, SwitchProps, CheckboxProps, ButtonProps, IconButtonProps, TooltipProps, SxProps, Theme, TypographyProps } from '@mui/material';
4
4
  import { SystemProps } from '@mui/system';
5
5
  import * as _supabase_supabase_js from '@supabase/supabase-js';
6
6
  import { SupabaseClient, User, Session } from '@supabase/supabase-js';
@@ -155,6 +155,22 @@ type CheckboxComponentProps = Omit<FormControlLabelProps, 'control' | 'label' |
155
155
  checkboxProps?: CheckboxProps;
156
156
  };
157
157
 
158
+ type ButtonComponentProps = Omit<ButtonProps, 'children'> & {
159
+ /**
160
+ * Метка кнопки. Если передана строка, она автоматически
161
+ * оборачивается в <TranslateText> для локализации.
162
+ */
163
+ label?: ReactNode;
164
+ /**
165
+ * Кастомный неймспейс для перевода (если нужен)
166
+ */
167
+ overrideNamespace?: string;
168
+ /**
169
+ * Дочерние элементы (используются, если не передан label)
170
+ */
171
+ children?: ReactNode;
172
+ };
173
+
158
174
  interface CopyClipboardButtonComponentProps extends Omit<IconButtonProps, 'onClick'> {
159
175
  overrideNamespace?: string;
160
176
  /** Текст, який буде скопійовано в буфер обміну */
@@ -399,6 +415,15 @@ type CollapsedWidgetContainerProps = {
399
415
  onExpanded?: (expanded: boolean) => void;
400
416
  };
401
417
 
418
+ interface ErrorAlertWidgetProps {
419
+ overrideNamespace?: string;
420
+ title?: ReactNode;
421
+ message: ReactNode;
422
+ onRetry?: () => void;
423
+ retryText?: ReactNode;
424
+ isRetrying?: boolean;
425
+ }
426
+
402
427
  declare const UI: {
403
428
  Inputs: {
404
429
  TextField: React$1.FC<TextFieldComponentProps>;
@@ -411,6 +436,7 @@ declare const UI: {
411
436
  Url: typeof UrlComponent;
412
437
  };
413
438
  Buttons: {
439
+ Button: React$1.ForwardRefExoticComponent<Omit<ButtonComponentProps, "ref"> & React$1.RefAttributes<HTMLButtonElement>>;
414
440
  CopyClipboardButton: React$1.FC<CopyClipboardButtonComponentProps>;
415
441
  RefreshButton: React$1.FC<RefreshButtonComponentProps>;
416
442
  };
@@ -432,6 +458,9 @@ declare const UI: {
432
458
  PageLinkWidget: React$1.FC<PageLinkWidgetProps>;
433
459
  CollapsedWidgetContainer: (props: React$1.PropsWithChildren<CollapsedWidgetContainerProps>) => React$1.JSX.Element;
434
460
  };
461
+ Misc: {
462
+ ErrorAlertWidget: React$1.FC<ErrorAlertWidgetProps>;
463
+ };
435
464
  };
436
465
  };
437
466
 
@@ -785,4 +814,4 @@ declare const Utils: {
785
814
  };
786
815
  };
787
816
 
788
- export { type AIConfig, type AIGenerateOptions, AIProvider, type AIProviderProps, type AIProviderType, AppSettingsProvider, AuthProvider, BreadcrumbProvider, type CheckboxComponentProps, type CollapsedWidgetContainerProps, type CompanyMember, type ConfirmOptions, type ConfirmResult, ConfirmationProvider, type ConfirmationProviderProps, type CopyClipboardButtonComponentProps, type DialogSeverity, type DisplayState, type EmailInputComponentProps, type ExpandableNoteComponentProps, type FullCompanyMemberItem, Hooks, type Language, LocalizationProvider, type Membership, type MembershipRole, type MyAvatarComponentProps, type NumberInputComponentProps, type PageLink, type PageLinkWidgetProps, Providers, type RefreshButtonComponentProps, type SaveCompanyUserPayload, type SearchComponentProps, type SelectComponentProps, type SelectOption, Services, type SupabaseConfig, SupabaseProvider, type SupabaseProviderProps, type SwitchComponentProps, type TextFieldComponentProps, type ThemeColors, type ThemeConfig, type ThemeMode, ThemeProvider, ToastProvider, type ToastType, type TranslatableTooltipComponentProps, TranslateProvider, TranslateText, TranslationEditProvider, type TypographyConfig, UI, type UrlComponentProps as UrlProps, type UserAvatarComponentProps, type UserGroupedSessions, type UserPopoverComponentProps, type UserProfile, type UserRoleChipComponentProps, type UserSessionItem, type UserSettings, UserSettingsProvider, type UserStatusChipComponentProps, type UserStatusType, Utils, defaultUserSettings, initI18n, useAI, useAppSettings, useAppTheme, useAuth, useBreadcrumb, useConfirmation, useLocalization, useSupabase, useToast, useTranslationEdit, useTranslationNamespace, useUserSettings };
817
+ export { type AIConfig, type AIGenerateOptions, AIProvider, type AIProviderProps, type AIProviderType, AppSettingsProvider, AuthProvider, BreadcrumbProvider, type ButtonComponentProps, type CheckboxComponentProps, type CollapsedWidgetContainerProps, type CompanyMember, type ConfirmOptions, type ConfirmResult, ConfirmationProvider, type ConfirmationProviderProps, type CopyClipboardButtonComponentProps, type DialogSeverity, type DisplayState, type EmailInputComponentProps, type ErrorAlertWidgetProps, type ExpandableNoteComponentProps, type FullCompanyMemberItem, Hooks, type Language, LocalizationProvider, type Membership, type MembershipRole, type MyAvatarComponentProps, type NumberInputComponentProps, type PageLink, type PageLinkWidgetProps, Providers, type RefreshButtonComponentProps, type SaveCompanyUserPayload, type SearchComponentProps, type SelectComponentProps, type SelectOption, Services, type SupabaseConfig, SupabaseProvider, type SupabaseProviderProps, type SwitchComponentProps, type TextFieldComponentProps, type ThemeColors, type ThemeConfig, type ThemeMode, ThemeProvider, ToastProvider, type ToastType, type TranslatableTooltipComponentProps, TranslateProvider, TranslateText, TranslationEditProvider, type TypographyConfig, UI, type UrlComponentProps as UrlProps, type UserAvatarComponentProps, type UserGroupedSessions, type UserPopoverComponentProps, type UserProfile, type UserRoleChipComponentProps, type UserSessionItem, type UserSettings, UserSettingsProvider, type UserStatusChipComponentProps, type UserStatusType, Utils, defaultUserSettings, initI18n, useAI, useAppSettings, useAppTheme, useAuth, useBreadcrumb, useConfirmation, useLocalization, useSupabase, useToast, useTranslationEdit, useTranslationNamespace, useUserSettings };
package/dist/index.js CHANGED
@@ -4930,6 +4930,207 @@ var RefreshButtonComponent = ({
4930
4930
  ) });
4931
4931
  };
4932
4932
 
4933
+ // src/UI/widgets/misc/ErrorAlertWidget.tsx
4934
+ var import_material26 = require("@mui/material");
4935
+ var import_Replay = __toESM(require("@mui/icons-material/Replay"));
4936
+ init_context();
4937
+ var import_jsx_runtime36 = require("react/jsx-runtime");
4938
+ var ErrorIllustration = ({ size = 64 }) => {
4939
+ const theme = (0, import_material26.useTheme)();
4940
+ const mainColor = theme.palette.error.main;
4941
+ const lightColor = theme.palette.error.light;
4942
+ return /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
4943
+ import_material26.Box,
4944
+ {
4945
+ sx: {
4946
+ display: "flex",
4947
+ alignItems: "center",
4948
+ justifyContent: "center",
4949
+ flexShrink: 0
4950
+ },
4951
+ children: /* @__PURE__ */ (0, import_jsx_runtime36.jsxs)(
4952
+ "svg",
4953
+ {
4954
+ width: size,
4955
+ height: size,
4956
+ viewBox: "0 0 100 100",
4957
+ fill: "none",
4958
+ xmlns: "http://www.w3.org/2000/svg",
4959
+ children: [
4960
+ /* @__PURE__ */ (0, import_jsx_runtime36.jsxs)(
4961
+ "circle",
4962
+ {
4963
+ cx: "50",
4964
+ cy: "50",
4965
+ r: "42",
4966
+ fill: lightColor,
4967
+ fillOpacity: "0.25",
4968
+ children: [
4969
+ /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
4970
+ "animate",
4971
+ {
4972
+ attributeName: "r",
4973
+ values: "38;44;38",
4974
+ dur: "3s",
4975
+ repeatCount: "indefinite"
4976
+ }
4977
+ ),
4978
+ /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
4979
+ "animate",
4980
+ {
4981
+ attributeName: "fill-opacity",
4982
+ values: "0.2;0.4;0.2",
4983
+ dur: "3s",
4984
+ repeatCount: "indefinite"
4985
+ }
4986
+ )
4987
+ ]
4988
+ }
4989
+ ),
4990
+ /* @__PURE__ */ (0, import_jsx_runtime36.jsx)("circle", { cx: "50", cy: "50", r: "34", fill: lightColor, fillOpacity: "0.35" }),
4991
+ /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
4992
+ "path",
4993
+ {
4994
+ d: "M50 20L80 72H20L50 20Z",
4995
+ fill: mainColor,
4996
+ stroke: theme.palette.background.paper,
4997
+ strokeWidth: "3",
4998
+ strokeLinejoin: "round"
4999
+ }
5000
+ ),
5001
+ /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
5002
+ "path",
5003
+ {
5004
+ d: "M50 36V54",
5005
+ stroke: "#FFFFFF",
5006
+ strokeWidth: "4",
5007
+ strokeLinecap: "round"
5008
+ }
5009
+ ),
5010
+ /* @__PURE__ */ (0, import_jsx_runtime36.jsx)("circle", { cx: "50", cy: "62", r: "2.5", fill: "#FFFFFF" }),
5011
+ /* @__PURE__ */ (0, import_jsx_runtime36.jsx)("circle", { cx: "16", cy: "30", r: "3", fill: mainColor, opacity: "0.4" }),
5012
+ /* @__PURE__ */ (0, import_jsx_runtime36.jsx)("circle", { cx: "84", cy: "30", r: "2", fill: mainColor, opacity: "0.6" }),
5013
+ /* @__PURE__ */ (0, import_jsx_runtime36.jsx)("circle", { cx: "88", cy: "68", r: "3", fill: mainColor, opacity: "0.3" })
5014
+ ]
5015
+ }
5016
+ )
5017
+ }
5018
+ );
5019
+ };
5020
+ var ErrorAlertWidget = ({
5021
+ overrideNamespace,
5022
+ title = "An error occurred",
5023
+ message,
5024
+ onRetry,
5025
+ retryText = "Retry",
5026
+ isRetrying = false
5027
+ }) => {
5028
+ return /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
5029
+ import_material26.Alert,
5030
+ {
5031
+ severity: "error",
5032
+ icon: false,
5033
+ sx: {
5034
+ borderRadius: 1,
5035
+ p: 2.5,
5036
+ m: 3,
5037
+ border: "1px solid",
5038
+ borderColor: "error.light",
5039
+ bgcolor: (theme) => theme.palette.mode === "dark" ? "rgba(211, 47, 47, 0.08)" : "rgba(211, 47, 47, 0.04)",
5040
+ boxShadow: "0 4px 20px rgba(0, 0, 0, 0.05)",
5041
+ "& .MuiAlert-message": {
5042
+ width: "100%",
5043
+ p: 0
5044
+ }
5045
+ },
5046
+ children: /* @__PURE__ */ (0, import_jsx_runtime36.jsxs)(
5047
+ import_material26.Box,
5048
+ {
5049
+ sx: {
5050
+ display: "flex",
5051
+ flexDirection: { xs: "column", sm: "row" },
5052
+ alignItems: { xs: "flex-start", sm: "center" },
5053
+ gap: 2
5054
+ },
5055
+ children: [
5056
+ /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(ErrorIllustration, { size: 68 }),
5057
+ /* @__PURE__ */ (0, import_jsx_runtime36.jsxs)(import_material26.Box, { sx: { flexGrow: 1 }, children: [
5058
+ typeof title === "string" ? /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
5059
+ import_material26.Typography,
5060
+ {
5061
+ variant: "subtitle1",
5062
+ sx: { fontWeight: 600, color: "error.main", mb: 0.5 },
5063
+ children: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(TranslateText, { overrideNamespace, children: title })
5064
+ }
5065
+ ) : title,
5066
+ typeof message === "string" ? /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(import_material26.Typography, { variant: "body2", color: "text.secondary", children: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(TranslateText, { overrideNamespace, children: message }) }) : message
5067
+ ] }),
5068
+ onRetry && /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
5069
+ import_material26.Box,
5070
+ {
5071
+ sx: {
5072
+ alignSelf: { xs: "flex-end", sm: "center" },
5073
+ mt: { xs: 1, sm: 0 }
5074
+ },
5075
+ children: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
5076
+ import_material26.Button,
5077
+ {
5078
+ variant: "outlined",
5079
+ color: "error",
5080
+ size: "small",
5081
+ disabled: isRetrying,
5082
+ onClick: onRetry,
5083
+ startIcon: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
5084
+ import_Replay.default,
5085
+ {
5086
+ sx: {
5087
+ animation: isRetrying ? "spin 1s linear infinite" : "none",
5088
+ "@keyframes spin": {
5089
+ "0%": { transform: "rotate(0deg)" },
5090
+ "100%": { transform: "rotate(360deg)" }
5091
+ }
5092
+ }
5093
+ }
5094
+ ),
5095
+ sx: {
5096
+ //borderRadius: 2,
5097
+ textTransform: "none",
5098
+ fontWeight: 600,
5099
+ px: 2,
5100
+ py: 0.75,
5101
+ whiteSpace: "nowrap"
5102
+ },
5103
+ children: retryText
5104
+ }
5105
+ )
5106
+ }
5107
+ )
5108
+ ]
5109
+ }
5110
+ )
5111
+ }
5112
+ );
5113
+ };
5114
+
5115
+ // src/UI/components/buttons/ButtonComponent.tsx
5116
+ var import_react31 = require("react");
5117
+ var import_material27 = require("@mui/material");
5118
+ init_context();
5119
+ var import_jsx_runtime37 = require("react/jsx-runtime");
5120
+ var ButtonComponent = (0, import_react31.forwardRef)(
5121
+ ({ label, children, overrideNamespace, ...props }, ref) => {
5122
+ const renderContent = (content) => {
5123
+ if (typeof content === "string") {
5124
+ return /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(TranslateText, { overrideNamespace, children: content });
5125
+ }
5126
+ return content;
5127
+ };
5128
+ const contentToRender = label !== void 0 ? label : children;
5129
+ return /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(import_material27.Button, { ref, ...props, children: renderContent(contentToRender) });
5130
+ }
5131
+ );
5132
+ ButtonComponent.displayName = "ButtonComponent";
5133
+
4933
5134
  // src/UI/index.ts
4934
5135
  var UI = {
4935
5136
  Inputs: {
@@ -4943,6 +5144,7 @@ var UI = {
4943
5144
  Url: UrlComponent
4944
5145
  },
4945
5146
  Buttons: {
5147
+ Button: ButtonComponent,
4946
5148
  CopyClipboardButton: CopyClipboardButtonComponent,
4947
5149
  RefreshButton: RefreshButtonComponent
4948
5150
  },
@@ -4966,6 +5168,9 @@ var UI = {
4966
5168
  Pages: {
4967
5169
  PageLinkWidget,
4968
5170
  CollapsedWidgetContainer
5171
+ },
5172
+ Misc: {
5173
+ ErrorAlertWidget
4969
5174
  }
4970
5175
  }
4971
5176
  };
@@ -4993,16 +5198,16 @@ var Services = {
4993
5198
  };
4994
5199
 
4995
5200
  // src/hooks/useUserStatus.ts
4996
- var import_react31 = require("react");
5201
+ var import_react32 = require("react");
4997
5202
  init_deviceId();
4998
5203
  init_context();
4999
5204
  var ONLINE_THRESHOLD_MINUTES = 2;
5000
5205
  var AWAY_THRESHOLD_MINUTES = 15;
5001
5206
  var useUserStatus2 = (userId, initialLastSeenAt, currentAuthUserId) => {
5002
5207
  const supabase = useSupabase();
5003
- const [status, setStatus] = (0, import_react31.useState)("offline");
5004
- const [lastSeen, setLastSeen] = (0, import_react31.useState)(initialLastSeenAt ?? null);
5005
- const lastSeenRef = (0, import_react31.useRef)(initialLastSeenAt ?? null);
5208
+ const [status, setStatus] = (0, import_react32.useState)("offline");
5209
+ const [lastSeen, setLastSeen] = (0, import_react32.useState)(initialLastSeenAt ?? null);
5210
+ const lastSeenRef = (0, import_react32.useRef)(initialLastSeenAt ?? null);
5006
5211
  lastSeenRef.current = lastSeen;
5007
5212
  const calculateStatus = (isOnline, lastSeenIso) => {
5008
5213
  if (isOnline) return "online";
@@ -5018,7 +5223,7 @@ var useUserStatus2 = (userId, initialLastSeenAt, currentAuthUserId) => {
5018
5223
  }
5019
5224
  return "offline";
5020
5225
  };
5021
- (0, import_react31.useEffect)(() => {
5226
+ (0, import_react32.useEffect)(() => {
5022
5227
  if (!userId) return;
5023
5228
  let isMounted = true;
5024
5229
  const isSelf = currentAuthUserId && userId === currentAuthUserId;
package/dist/index.mjs CHANGED
@@ -2016,6 +2016,205 @@ var RefreshButtonComponent = ({
2016
2016
  ) });
2017
2017
  };
2018
2018
 
2019
+ // src/UI/widgets/misc/ErrorAlertWidget.tsx
2020
+ import { Alert, Box as Box9, Button as Button4, Typography as Typography8, useTheme } from "@mui/material";
2021
+ import ReplayIcon from "@mui/icons-material/Replay";
2022
+ import { jsx as jsx16, jsxs as jsxs12 } from "react/jsx-runtime";
2023
+ var ErrorIllustration = ({ size = 64 }) => {
2024
+ const theme = useTheme();
2025
+ const mainColor = theme.palette.error.main;
2026
+ const lightColor = theme.palette.error.light;
2027
+ return /* @__PURE__ */ jsx16(
2028
+ Box9,
2029
+ {
2030
+ sx: {
2031
+ display: "flex",
2032
+ alignItems: "center",
2033
+ justifyContent: "center",
2034
+ flexShrink: 0
2035
+ },
2036
+ children: /* @__PURE__ */ jsxs12(
2037
+ "svg",
2038
+ {
2039
+ width: size,
2040
+ height: size,
2041
+ viewBox: "0 0 100 100",
2042
+ fill: "none",
2043
+ xmlns: "http://www.w3.org/2000/svg",
2044
+ children: [
2045
+ /* @__PURE__ */ jsxs12(
2046
+ "circle",
2047
+ {
2048
+ cx: "50",
2049
+ cy: "50",
2050
+ r: "42",
2051
+ fill: lightColor,
2052
+ fillOpacity: "0.25",
2053
+ children: [
2054
+ /* @__PURE__ */ jsx16(
2055
+ "animate",
2056
+ {
2057
+ attributeName: "r",
2058
+ values: "38;44;38",
2059
+ dur: "3s",
2060
+ repeatCount: "indefinite"
2061
+ }
2062
+ ),
2063
+ /* @__PURE__ */ jsx16(
2064
+ "animate",
2065
+ {
2066
+ attributeName: "fill-opacity",
2067
+ values: "0.2;0.4;0.2",
2068
+ dur: "3s",
2069
+ repeatCount: "indefinite"
2070
+ }
2071
+ )
2072
+ ]
2073
+ }
2074
+ ),
2075
+ /* @__PURE__ */ jsx16("circle", { cx: "50", cy: "50", r: "34", fill: lightColor, fillOpacity: "0.35" }),
2076
+ /* @__PURE__ */ jsx16(
2077
+ "path",
2078
+ {
2079
+ d: "M50 20L80 72H20L50 20Z",
2080
+ fill: mainColor,
2081
+ stroke: theme.palette.background.paper,
2082
+ strokeWidth: "3",
2083
+ strokeLinejoin: "round"
2084
+ }
2085
+ ),
2086
+ /* @__PURE__ */ jsx16(
2087
+ "path",
2088
+ {
2089
+ d: "M50 36V54",
2090
+ stroke: "#FFFFFF",
2091
+ strokeWidth: "4",
2092
+ strokeLinecap: "round"
2093
+ }
2094
+ ),
2095
+ /* @__PURE__ */ jsx16("circle", { cx: "50", cy: "62", r: "2.5", fill: "#FFFFFF" }),
2096
+ /* @__PURE__ */ jsx16("circle", { cx: "16", cy: "30", r: "3", fill: mainColor, opacity: "0.4" }),
2097
+ /* @__PURE__ */ jsx16("circle", { cx: "84", cy: "30", r: "2", fill: mainColor, opacity: "0.6" }),
2098
+ /* @__PURE__ */ jsx16("circle", { cx: "88", cy: "68", r: "3", fill: mainColor, opacity: "0.3" })
2099
+ ]
2100
+ }
2101
+ )
2102
+ }
2103
+ );
2104
+ };
2105
+ var ErrorAlertWidget = ({
2106
+ overrideNamespace,
2107
+ title = "An error occurred",
2108
+ message,
2109
+ onRetry,
2110
+ retryText = "Retry",
2111
+ isRetrying = false
2112
+ }) => {
2113
+ return /* @__PURE__ */ jsx16(
2114
+ Alert,
2115
+ {
2116
+ severity: "error",
2117
+ icon: false,
2118
+ sx: {
2119
+ borderRadius: 1,
2120
+ p: 2.5,
2121
+ m: 3,
2122
+ border: "1px solid",
2123
+ borderColor: "error.light",
2124
+ bgcolor: (theme) => theme.palette.mode === "dark" ? "rgba(211, 47, 47, 0.08)" : "rgba(211, 47, 47, 0.04)",
2125
+ boxShadow: "0 4px 20px rgba(0, 0, 0, 0.05)",
2126
+ "& .MuiAlert-message": {
2127
+ width: "100%",
2128
+ p: 0
2129
+ }
2130
+ },
2131
+ children: /* @__PURE__ */ jsxs12(
2132
+ Box9,
2133
+ {
2134
+ sx: {
2135
+ display: "flex",
2136
+ flexDirection: { xs: "column", sm: "row" },
2137
+ alignItems: { xs: "flex-start", sm: "center" },
2138
+ gap: 2
2139
+ },
2140
+ children: [
2141
+ /* @__PURE__ */ jsx16(ErrorIllustration, { size: 68 }),
2142
+ /* @__PURE__ */ jsxs12(Box9, { sx: { flexGrow: 1 }, children: [
2143
+ typeof title === "string" ? /* @__PURE__ */ jsx16(
2144
+ Typography8,
2145
+ {
2146
+ variant: "subtitle1",
2147
+ sx: { fontWeight: 600, color: "error.main", mb: 0.5 },
2148
+ children: /* @__PURE__ */ jsx16(TranslateText, { overrideNamespace, children: title })
2149
+ }
2150
+ ) : title,
2151
+ typeof message === "string" ? /* @__PURE__ */ jsx16(Typography8, { variant: "body2", color: "text.secondary", children: /* @__PURE__ */ jsx16(TranslateText, { overrideNamespace, children: message }) }) : message
2152
+ ] }),
2153
+ onRetry && /* @__PURE__ */ jsx16(
2154
+ Box9,
2155
+ {
2156
+ sx: {
2157
+ alignSelf: { xs: "flex-end", sm: "center" },
2158
+ mt: { xs: 1, sm: 0 }
2159
+ },
2160
+ children: /* @__PURE__ */ jsx16(
2161
+ Button4,
2162
+ {
2163
+ variant: "outlined",
2164
+ color: "error",
2165
+ size: "small",
2166
+ disabled: isRetrying,
2167
+ onClick: onRetry,
2168
+ startIcon: /* @__PURE__ */ jsx16(
2169
+ ReplayIcon,
2170
+ {
2171
+ sx: {
2172
+ animation: isRetrying ? "spin 1s linear infinite" : "none",
2173
+ "@keyframes spin": {
2174
+ "0%": { transform: "rotate(0deg)" },
2175
+ "100%": { transform: "rotate(360deg)" }
2176
+ }
2177
+ }
2178
+ }
2179
+ ),
2180
+ sx: {
2181
+ //borderRadius: 2,
2182
+ textTransform: "none",
2183
+ fontWeight: 600,
2184
+ px: 2,
2185
+ py: 0.75,
2186
+ whiteSpace: "nowrap"
2187
+ },
2188
+ children: retryText
2189
+ }
2190
+ )
2191
+ }
2192
+ )
2193
+ ]
2194
+ }
2195
+ )
2196
+ }
2197
+ );
2198
+ };
2199
+
2200
+ // src/UI/components/buttons/ButtonComponent.tsx
2201
+ import { forwardRef } from "react";
2202
+ import { Button as Button5 } from "@mui/material";
2203
+ import { jsx as jsx17 } from "react/jsx-runtime";
2204
+ var ButtonComponent = forwardRef(
2205
+ ({ label, children, overrideNamespace, ...props }, ref) => {
2206
+ const renderContent = (content) => {
2207
+ if (typeof content === "string") {
2208
+ return /* @__PURE__ */ jsx17(TranslateText, { overrideNamespace, children: content });
2209
+ }
2210
+ return content;
2211
+ };
2212
+ const contentToRender = label !== void 0 ? label : children;
2213
+ return /* @__PURE__ */ jsx17(Button5, { ref, ...props, children: renderContent(contentToRender) });
2214
+ }
2215
+ );
2216
+ ButtonComponent.displayName = "ButtonComponent";
2217
+
2019
2218
  // src/UI/index.ts
2020
2219
  var UI = {
2021
2220
  Inputs: {
@@ -2029,6 +2228,7 @@ var UI = {
2029
2228
  Url: UrlComponent
2030
2229
  },
2031
2230
  Buttons: {
2231
+ Button: ButtonComponent,
2032
2232
  CopyClipboardButton: CopyClipboardButtonComponent,
2033
2233
  RefreshButton: RefreshButtonComponent
2034
2234
  },
@@ -2052,6 +2252,9 @@ var UI = {
2052
2252
  Pages: {
2053
2253
  PageLinkWidget,
2054
2254
  CollapsedWidgetContainer
2255
+ },
2256
+ Misc: {
2257
+ ErrorAlertWidget
2055
2258
  }
2056
2259
  }
2057
2260
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@serhii.olishevskyi/docs",
3
- "version": "1.2.17",
3
+ "version": "1.2.19",
4
4
  "description": "DOCS.UA react packages",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",