@homefile/components-v2 2.40.1 → 2.40.3

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.
@@ -1,2 +1,2 @@
1
1
  import { HomeMonitorButtonI } from '../../interfaces';
2
- export declare const HomeMonitorButton: ({ alertCount, currentStep, onStepClick, status, step, }: HomeMonitorButtonI) => import("react/jsx-runtime").JSX.Element;
2
+ export declare const HomeMonitorButton: ({ alertCount, currentStep, onStepClick, status, step, menuItems, index, }: HomeMonitorButtonI) => import("react/jsx-runtime").JSX.Element;
@@ -1,51 +1,52 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { useEffect, useMemo, useState } from 'react';
2
3
  import { Box, Center, Image, Stack, Text } from '@chakra-ui/react';
3
- import { getIconAltText } from '../../utils';
4
4
  import { keyframes } from '@emotion/react';
5
- export const HomeMonitorButton = ({ alertCount = 0, currentStep, onStepClick, status = 'ok', step, }) => {
5
+ import { getIconAltText } from '../../utils';
6
+ import { IconMenu, MoreHorizontal } from '../../components';
7
+ import { homeAssistantProxy } from '../../proxies';
8
+ const COLLAPSE_AFTER_MS = 2000;
9
+ const INITIAL_BOTTOM = 0;
10
+ const COLLAPSED_BOTTOM = -60;
11
+ export const HomeMonitorButton = ({ alertCount = 0, currentStep, onStepClick, status = 'ok', step, menuItems = [], index, }) => {
12
+ const [bottomOffset, setBottomOffset] = useState(INITIAL_BOTTOM);
13
+ const [isHovered, setIsHovered] = useState(false);
6
14
  const buttonId = `homeMonitorButton-${currentStep}`;
7
- const iconAltText = getIconAltText(step.icon);
15
+ const iconAltText = useMemo(() => getIconAltText(step.icon), [step.icon]);
8
16
  const alert = status === 'alert';
9
- const ok = status === 'ok';
10
- return (_jsx(Box, Object.assign({ position: "relative", id: buttonId, zIndex: "2", boxShadow: "lg" }, setStyles(status), { children: _jsxs(Box, { position: "relative", bg: "neutral.white", borderRadius: "lg", zIndex: "2", children: [_jsx(Box, { bg: alert ? 'error.2' : 'green.1', boxSize: "10px", borderRadius: "full", position: "absolute", top: "10px", left: "8px", zIndex: "8" }), _jsxs(Stack, { position: "relative", zIndex: "2", as: "button", spacing: "7px", border: "1px solid transparent", align: "center", justify: "center", w: "100%", p: "base", pt: "20px", onClick: () => onStepClick(currentStep), filter: ok ? 'grayscale(1) opacity(0.6)' : '', children: [!alert && (_jsx(Box, { boxSize: "36px", children: _jsx(Image, { src: step.icon, alt: iconAltText, w: "100%", h: "100%", fit: "contain" }) })), alert && (_jsx(Center, { boxSize: "32px", bg: "error.2", borderRadius: "full", color: "neutral.white", lineHeight: "1", fontWeight: "bold", children: alertCount })), _jsx(Center, { h: "28px", children: _jsx(Text, { fontSize: "14px", textTransform: "uppercase", textAlign: "center", lineHeight: "14px", fontFamily: "secondary", children: step.title }) })] })] }) })));
17
+ const isDisabled = menuItems.length === 0;
18
+ const { setSelectedId } = homeAssistantProxy;
19
+ const isCollapsed = bottomOffset < 0 && !isHovered;
20
+ useEffect(() => {
21
+ const timeout = window.setTimeout(() => {
22
+ setBottomOffset(COLLAPSED_BOTTOM);
23
+ }, COLLAPSE_AFTER_MS);
24
+ return () => window.clearTimeout(timeout);
25
+ }, []);
26
+ const handleStepClick = () => {
27
+ setIsHovered(false);
28
+ onStepClick(currentStep);
29
+ };
30
+ return (_jsx(Box, Object.assign({ position: "relative", id: buttonId, boxShadow: "lg", bottom: `${bottomOffset}px`, minH: "106px", onMouseEnter: () => setIsHovered(true), onMouseLeave: () => setIsHovered(false), onPointerEnter: () => setIsHovered(true), onPointerLeave: () => setIsHovered(false) }, getContainerStyles(status), { children: _jsxs(Box, { position: "relative", bg: "neutral.white", borderRadius: "lg", children: [_jsx(Box, { bg: alert ? 'error.2' : 'green.1', boxSize: "10px", borderRadius: "full", position: "absolute", top: "10px", left: "8px" }), _jsx(Box, { position: "absolute", top: "2px", right: "6px", zIndex: "1400", children: _jsx(IconMenu, { zIndex: "2", icon: _jsx(MoreHorizontal, { size: 26 }), itemForm: index + 1, menuItems: menuItems, disabled: isDisabled, onClick: () => setSelectedId(`homeMonitorButton-${index + 1}`) }) }), !isCollapsed && (_jsxs(Stack, { position: "relative", zIndex: "2", as: "button", spacing: "7px", border: "1px solid transparent", align: "center", justify: "center", w: "100%", p: "base", pt: "20px", onClick: handleStepClick, children: [!alert && (_jsx(Box, { boxSize: "36px", children: _jsx(Image, { src: step.icon, alt: iconAltText, w: "100%", h: "100%", fit: "contain" }) })), alert && (_jsx(Center, { boxSize: "36px", bg: "error.2", borderRadius: "full", color: "neutral.white", lineHeight: "1", fontWeight: "bold", children: alertCount })), _jsx(Center, { h: "28px", children: _jsx(Text, { fontSize: "14px", textTransform: "uppercase", textAlign: "center", lineHeight: "14px", fontFamily: "secondary", children: step.title }) })] }))] }) })));
11
31
  };
12
32
  const alertGradient = keyframes `
13
- 0% {
14
- background-position: 0% 50%;
15
- }
16
- 100% {
17
- background-position: 100% 50%;
18
- }
33
+ 0% { background-position: 0% 50%; }
34
+ 100% { background-position: 100% 50%; }
19
35
  `;
20
- const setStyles = (status) => {
21
- switch (status) {
22
- case 'alert':
23
- return {
24
- background: 'white',
25
- cursor: 'pointer',
26
- transition: 'all 0.3s',
27
- borderRadius: 'lg',
28
- border: 'none',
29
- _before: {
30
- content: '""',
31
- position: 'absolute',
32
- inset: '-2px',
33
- borderRadius: 'inherit',
34
- background: 'linear-gradient(270deg,rgb(123, 6, 105),rgb(233, 175, 236), #F544DA)',
35
- backgroundSize: '400% 400%',
36
- animation: `${alertGradient} 2s linear infinite`,
37
- animationDirection: 'alternate',
38
- zIndex: -1,
39
- pointerEvents: 'none',
40
- },
41
- _hover: {
42
- bg: 'lightGreen.7',
43
- },
44
- };
45
- case 'ok':
46
- return {
47
- bg: 'neutral.white',
48
- borderRadius: 'lg',
49
- };
36
+ const getContainerStyles = (status) => {
37
+ const base = {
38
+ cursor: 'pointer',
39
+ transition: 'all 0.3s',
40
+ borderRadius: 'lg',
41
+ border: '2px solid transparent',
42
+ boxSizing: 'border-box',
43
+ _hover: {
44
+ bottom: 0,
45
+ },
46
+ };
47
+ if (status === 'alert') {
48
+ return Object.assign(Object.assign({}, base), { background: `linear-gradient(#FFFFFF, #FFFFFF) padding-box, ` +
49
+ `linear-gradient(270deg, rgb(123, 6, 105), rgb(233, 175, 236), #F544DA) border-box`, backgroundSize: '100% 100%, 400% 400%', backgroundPosition: '0% 50%, 0% 50%', animation: `${alertGradient} 2s linear infinite`, animationDirection: 'alternate' });
50
50
  }
51
+ return Object.assign(Object.assign({}, base), { bg: 'neutral.white' });
51
52
  };
@@ -1,16 +1,13 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
2
  import { Fragment } from 'react';
3
3
  import { Box, Flex } from '@chakra-ui/react';
4
- import { HomeMonitorButton, IconMenu, MoreHorizontal } from '../../components';
4
+ import { HomeMonitorButton } from '../../components';
5
5
  import { homeAssistantSteps } from '../../helpers';
6
- import { homeAssistantProxy } from '../../proxies';
7
6
  export const HomeMonitorSteps = ({ alerts = [], menuItems = [], onStepClick, steps = homeAssistantSteps, }) => {
8
- const { setSelectedId } = homeAssistantProxy;
9
- const isDisabled = menuItems.length === 0;
10
7
  const handleStepClick = (step) => onStepClick(step);
11
8
  return (_jsx(Flex, { gap: "base", justify: "center", children: steps.map((step, index) => {
12
9
  var _a;
13
- return (_jsx(Box, { position: "relative", flex: "1", children: _jsxs(Fragment, { children: [_jsx(HomeMonitorButton, { alertCount: (_a = alerts.find((alert) => alert.step === index + 1)) === null || _a === void 0 ? void 0 : _a.count, currentStep: index + 1, onStepClick: handleStepClick, status: getStatus(index + 1, alerts), step: step }), _jsx(Box, { position: "absolute", top: "2px", right: "6px", zIndex: "1400", children: _jsx(IconMenu, { zIndex: "2", icon: _jsx(MoreHorizontal, { size: 26 }), itemForm: index + 1, menuItems: menuItems, disabled: isDisabled, onClick: () => setSelectedId(`homeMonitorButton-${index + 1}`) }) })] }) }, step === null || step === void 0 ? void 0 : step.title));
10
+ return (_jsx(Box, { position: "relative", flex: "1", children: _jsx(Fragment, { children: _jsx(HomeMonitorButton, { alertCount: (_a = alerts.find((alert) => alert.step === index + 1)) === null || _a === void 0 ? void 0 : _a.count, currentStep: index + 1, onStepClick: handleStepClick, status: getStatus(index + 1, alerts), step: step, alerts: alerts, menuItems: menuItems, index: index }) }) }, step === null || step === void 0 ? void 0 : step.title));
14
11
  }) }));
15
12
  };
16
13
  const getStatus = (index, alerts) => {
@@ -9,6 +9,7 @@ export const HomefileMonitoring = ({ alertCount = 0 }) => {
9
9
  const [showMonitoring, setShowMonitoring] = useState(true);
10
10
  const [showAlerts, setShowAlerts] = useState(false);
11
11
  useEffect(() => {
12
+ const timeout = setTimeout(() => setShowMonitoring(false), 15000);
12
13
  if (alertCount > 0) {
13
14
  const timeout1 = setTimeout(() => setShowMonitoring(false), 2000);
14
15
  const timeout2 = setTimeout(() => setShowAlerts(true), 3000);
@@ -17,8 +18,9 @@ export const HomefileMonitoring = ({ alertCount = 0 }) => {
17
18
  clearTimeout(timeout2);
18
19
  };
19
20
  }
21
+ return () => clearTimeout(timeout);
20
22
  }, [alertCount]);
21
- return (_jsxs(Box, { flex: "1", zIndex: "2", children: [showAlerts && (_jsx(MonitoringAlerts, { alertCount: alertCount, showAlerts: showAlerts })), _jsx(SlideFade, { in: showMonitoring, offsetY: "-20px", transition: { enter: { duration: 0.5 } }, children: _jsx(Box, { p: "base", borderBottomRadius: "lg", bg: "#C5E9F4", flex: "1", children: _jsxs(Flex, { align: "center", gap: "1", children: [_jsx(CustomCircularLoader, { icon: Brain, color: "#12988C", trackColor: "#A2CFE0", size: "46px", thickness: "6px" }), _jsx(Text, { children: t('homeAssistant.homeMonitoring') })] }) }) })] }));
23
+ return (_jsxs(Box, { flex: "1", zIndex: "2", children: [showAlerts && (_jsx(MonitoringAlerts, { alertCount: alertCount, showAlerts: showAlerts })), _jsx(SlideFade, { in: showMonitoring, offsetY: "-20px", transition: { enter: { duration: 0.5 }, exit: { duration: 0.5 } }, children: _jsx(Box, { p: "base", borderBottomRadius: "lg", bg: "#C5E9F4", flex: "1", children: _jsxs(Flex, { align: "center", gap: "1", children: [_jsx(CustomCircularLoader, { icon: Brain, color: "#12988C", trackColor: "#A2CFE0", size: "46px", thickness: "6px" }), _jsx(Text, { children: t('homeAssistant.homeMonitoring') })] }) }) })] }));
22
24
  };
23
25
  const MonitoringAlerts = ({ alertCount = 0, showAlerts = false }) => {
24
26
  return (_jsx(SlideFade, { in: showAlerts, offsetY: "-20px", transition: { enter: { duration: 0.5 } }, children: _jsx(Box, { px: "base", borderBottomRadius: "lg", bg: "#F444DA", children: _jsxs(Flex, { align: "center", gap: "1", h: "66px", children: [_jsxs(Center, { p: "1", position: "relative", h: "24px", w: "24px", children: [_jsx(Box, { borderRadius: "full", bg: "neutral.white", opacity: 0.3, h: "full", w: "full", position: "absolute", top: "50%", left: "50%", transform: "translate(-50%, -50%)" }), _jsx(Image, { src: Exclamation, h: "100%", w: "auto" })] }), _jsx(Text, { color: "neutral.white", children: t('homeAssistant.homeMonitoringAlerts', { count: alertCount }) })] }) }) }));
@@ -9,11 +9,11 @@ export interface HomeMonitortStepsI {
9
9
  onStepClick: (step: number) => void;
10
10
  steps?: HomeAssistantStepI[];
11
11
  }
12
- export interface HomeMonitorButtonI {
12
+ export interface HomeMonitorButtonI extends Pick<HomeMonitortStepsI, 'alerts' | 'menuItems' | 'onStepClick'> {
13
13
  alertCount?: number;
14
14
  currentStep: number;
15
- onStepClick: HomeMonitortStepsI['onStepClick'];
16
15
  status: 'alert' | 'ok';
17
16
  step: HomeAssistantStepI;
17
+ index: number;
18
18
  }
19
19
  export {};
@@ -21,7 +21,7 @@ export const DisplayFilesMock = [
21
21
  __v: 0,
22
22
  },
23
23
  ],
24
- updatedAt: '2021-08-01T00:00:00.000Z',
24
+ updatedAt: '2025-12-23T18:08:41.575Z',
25
25
  receipt: 'receipt',
26
26
  // report: [
27
27
  // {
@@ -22,7 +22,7 @@ export const formatDateWithAt = ({ date, locale = 'en-US', }) => {
22
22
  return '';
23
23
  const timeFormat = new Intl.DateTimeFormat(locale, {
24
24
  timeStyle: 'short',
25
- timeZone: 'UTC',
25
+ // timeZone: 'UTC',
26
26
  })
27
27
  .format(new Date(date))
28
28
  .replaceAll(' ', '');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@homefile/components-v2",
3
- "version": "2.40.1",
3
+ "version": "2.40.3",
4
4
  "author": "Homefile",
5
5
  "license": "UNLICENSED",
6
6
  "typings": "dist/index.d.ts",