@homefile/components-v2 2.21.0 → 2.21.2

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.
@@ -414,7 +414,8 @@
414
414
  },
415
415
  "details": "Provide details about your home’s",
416
416
  "homeMonitor": "Homie",
417
- "homeMonitoring": "Homie is learning about your home.",
417
+ "homeMonitoring": "I’m learning about your home",
418
+ "homeMonitoringAlerts": "I have {{ count }} new messages for you.",
418
419
  "monitorAlerts": {
419
420
  "collapse": "Collapse Alert",
420
421
  "homeAction": "Home Action",
@@ -1,4 +1,4 @@
1
1
  import { PropsWithChildren } from 'react';
2
- export declare const HomeMonitor: ({ children, zIndex }: PropsWithChildren<{
2
+ export declare const HomeMonitor: ({ children, zIndex, }: PropsWithChildren<{
3
3
  zIndex?: string;
4
4
  }>) => import("react/jsx-runtime").JSX.Element;
@@ -1,6 +1,6 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
2
  import { t } from 'i18next';
3
3
  import { HomeAssistantWrapper } from '..';
4
- export const HomeMonitor = ({ children, zIndex }) => {
4
+ export const HomeMonitor = ({ children, zIndex, }) => {
5
5
  return (_jsx(HomeAssistantWrapper, { zIndex: zIndex, showAirplane: true, title: t('homeAssistant.homeMonitor'), children: children }));
6
6
  };
@@ -3,15 +3,17 @@ import { AlertFields, BackendAlertCard, TabsHeader } from '../..';
3
3
  import { getCategoryStyles } from '../../../utils/Alerts.utils';
4
4
  import { Divider } from '@chakra-ui/react';
5
5
  export const BackendAlert = ({ category, form, callback }) => {
6
- var _a, _b, _c, _d, _e;
6
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
7
7
  const { headerBg, alertIcon, alertIconBg, alertTitle } = getCategoryStyles(category);
8
8
  const alert = form === null || form === void 0 ? void 0 : form.find((item) => item.type === 'alert');
9
- const tabs = (_b = (_a = alert === null || alert === void 0 ? void 0 : alert.children) === null || _a === void 0 ? void 0 : _a.map((tab) => {
9
+ const hasChildren = Number((_a = alert === null || alert === void 0 ? void 0 : alert.children) === null || _a === void 0 ? void 0 : _a.length) > 0;
10
+ const isSingleTab = ((_b = alert === null || alert === void 0 ? void 0 : alert.children) === null || _b === void 0 ? void 0 : _b.length) === 1;
11
+ const tabs = (_d = (_c = alert === null || alert === void 0 ? void 0 : alert.children) === null || _c === void 0 ? void 0 : _c.map((tab) => {
10
12
  var _a;
11
13
  return ({
12
14
  label: tab.name,
13
15
  component: (_jsx(AlertFields, { fields: (_a = tab.children) !== null && _a !== void 0 ? _a : [], callback: callback })),
14
16
  });
15
- })) !== null && _b !== void 0 ? _b : [];
16
- return (_jsxs(BackendAlertCard, { alertBg: headerBg, alertIcon: alertIcon, alertTitle: alertTitle, bg: alertIconBg, icon: (_c = alert === null || alert === void 0 ? void 0 : alert.icon) !== null && _c !== void 0 ? _c : '', title: (_d = alert === null || alert === void 0 ? void 0 : alert.label) !== null && _d !== void 0 ? _d : '', description: (_e = alert === null || alert === void 0 ? void 0 : alert.description) !== null && _e !== void 0 ? _e : '', children: [_jsx(Divider, {}), _jsx(TabsHeader, { tabList: tabs })] }));
17
+ })) !== null && _d !== void 0 ? _d : [];
18
+ return (_jsxs(BackendAlertCard, { alertBg: headerBg, alertIcon: alertIcon, alertTitle: alertTitle, bg: alertIconBg, icon: (_e = alert === null || alert === void 0 ? void 0 : alert.icon) !== null && _e !== void 0 ? _e : '', title: (_f = alert === null || alert === void 0 ? void 0 : alert.label) !== null && _f !== void 0 ? _f : '', description: (_g = alert === null || alert === void 0 ? void 0 : alert.description) !== null && _g !== void 0 ? _g : '', children: [_jsx(Divider, {}), hasChildren && !isSingleTab && _jsx(TabsHeader, { tabList: tabs }), hasChildren && isSingleTab && (_jsx(AlertFields, { fields: (_k = (_j = (_h = alert === null || alert === void 0 ? void 0 : alert.children) === null || _h === void 0 ? void 0 : _h[0]) === null || _j === void 0 ? void 0 : _j.children) !== null && _k !== void 0 ? _k : [], callback: callback }))] }));
17
19
  };
@@ -1 +1,3 @@
1
- export declare const HomefileMonitoring: () => import("react/jsx-runtime").JSX.Element;
1
+ export declare const HomefileMonitoring: ({ alertCount }: {
2
+ alertCount?: number | undefined;
3
+ }) => import("react/jsx-runtime").JSX.Element;
@@ -1,7 +1,24 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { useEffect, useState } from 'react';
2
3
  import { t } from 'i18next';
3
- import { Box, Flex, Text } from '@chakra-ui/react';
4
+ import { Box, Center, Flex, Text, Image, SlideFade } from '@chakra-ui/react';
4
5
  import { HomieAnimation } from '../..';
5
- export const HomefileMonitoring = () => {
6
- return (_jsx(Box, { p: "base", borderRadius: "lg", bg: "#C5E9F4", h: "66px", zIndex: "2", flex: "1", children: _jsxs(Flex, { align: "center", children: [_jsx(Box, { boxSize: "47px", children: _jsx(HomieAnimation, { animation: "homie-v3" }) }), _jsx(Text, { children: t('homeAssistant.homeMonitoring') })] }) }));
6
+ import { Exclamation } from '../../../assets/images';
7
+ export const HomefileMonitoring = ({ alertCount = 0 }) => {
8
+ const [showMonitoring, setShowMonitoring] = useState(true);
9
+ const [showAlerts, setShowAlerts] = useState(false);
10
+ useEffect(() => {
11
+ if (alertCount > 0) {
12
+ const timeout1 = setTimeout(() => setShowMonitoring(false), 2000);
13
+ const timeout2 = setTimeout(() => setShowAlerts(true), 3000);
14
+ return () => {
15
+ clearTimeout(timeout1);
16
+ clearTimeout(timeout2);
17
+ };
18
+ }
19
+ }, [alertCount]);
20
+ 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", children: [_jsx(Box, { boxSize: "47px", children: _jsx(HomieAnimation, { animation: "homie-v3" }) }), _jsx(Text, { children: t('homeAssistant.homeMonitoring') })] }) }) })] }));
21
+ };
22
+ const MonitoringAlerts = ({ alertCount = 0, showAlerts = false }) => {
23
+ 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 }) })] }) }) }));
7
24
  };
@@ -16,5 +16,10 @@ export const HomeMonitorComponent = () => {
16
16
  action('onStepClick')(step);
17
17
  };
18
18
  const weatherData = mapForecastToWidget(weatherDataMock, 'TX, Houston');
19
- return (_jsx(HomeMonitor, { children: _jsxs(Stack, { spacing: "base", children: [_jsxs(Flex, { gap: "base", children: [_jsx(HomefileMonitoring, {}), _jsx(WeatherWidget, Object.assign({}, weatherData))] }), _jsx(HomeMonitorSteps, { menuItems: menuMock, stepsWithAlerts: [], onStepClick: handleAlertClick })] }) }));
19
+ const alerts = [
20
+ { step: 1, count: 2 },
21
+ { step: 3, count: 1 },
22
+ ];
23
+ const alertsCount = alerts.reduce((acc, alert) => acc + alert.count, 0);
24
+ return (_jsx(HomeMonitor, { children: _jsxs(Stack, { spacing: "base", children: [_jsxs(Flex, { gap: "base", children: [_jsx(HomefileMonitoring, { alertCount: alertsCount }), _jsx(WeatherWidget, Object.assign({}, weatherData))] }), _jsx(HomeMonitorSteps, { menuItems: menuMock, alerts: alerts, onStepClick: handleAlertClick })] }) }));
20
25
  };
@@ -3,3 +3,4 @@ import { BackendAlertI } from '../../../interfaces';
3
3
  declare const _default: Meta<BackendAlertI>;
4
4
  export default _default;
5
5
  export declare const BackendAlertComponent: (args: BackendAlertI) => import("react/jsx-runtime").JSX.Element;
6
+ export declare const BackendAlertSingleChildrenComponent: (args: BackendAlertI) => import("react/jsx-runtime").JSX.Element;
@@ -14,3 +14,9 @@ export default {
14
14
  export const BackendAlertComponent = (args) => {
15
15
  return _jsx(BackendAlert, Object.assign({}, args));
16
16
  };
17
+ export const BackendAlertSingleChildrenComponent = (args) => {
18
+ var _a, _b;
19
+ return (_jsx(BackendAlert, Object.assign({}, args, { form: [
20
+ Object.assign(Object.assign({}, alertFieldsMock[0]), { children: (_b = (_a = alertFieldsMock === null || alertFieldsMock === void 0 ? void 0 : alertFieldsMock[0]) === null || _a === void 0 ? void 0 : _a.children) === null || _b === void 0 ? void 0 : _b.slice(0, 1) }),
21
+ ] })));
22
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@homefile/components-v2",
3
- "version": "2.21.0",
3
+ "version": "2.21.2",
4
4
  "author": "Homefile",
5
5
  "license": "UNLICENSED",
6
6
  "typings": "dist/index.d.ts",
@@ -414,7 +414,8 @@
414
414
  },
415
415
  "details": "Provide details about your home’s",
416
416
  "homeMonitor": "Homie",
417
- "homeMonitoring": "Homie is learning about your home.",
417
+ "homeMonitoring": "I’m learning about your home",
418
+ "homeMonitoringAlerts": "I have {{ count }} new messages for you.",
418
419
  "monitorAlerts": {
419
420
  "collapse": "Collapse Alert",
420
421
  "homeAction": "Home Action",
@@ -2,9 +2,16 @@ import { PropsWithChildren } from 'react'
2
2
  import { t } from 'i18next'
3
3
  import { HomeAssistantWrapper } from '@/components'
4
4
 
5
- export const HomeMonitor = ({ children, zIndex}: PropsWithChildren<{zIndex?: string}>) => {
5
+ export const HomeMonitor = ({
6
+ children,
7
+ zIndex,
8
+ }: PropsWithChildren<{ zIndex?: string }>) => {
6
9
  return (
7
- <HomeAssistantWrapper zIndex={zIndex} showAirplane title={t('homeAssistant.homeMonitor')}>
10
+ <HomeAssistantWrapper
11
+ zIndex={zIndex}
12
+ showAirplane
13
+ title={t('homeAssistant.homeMonitor')}
14
+ >
8
15
  {children}
9
16
  </HomeAssistantWrapper>
10
17
  )
@@ -7,6 +7,8 @@ export const BackendAlert = ({ category, form, callback }: BackendAlertI) => {
7
7
  const { headerBg, alertIcon, alertIconBg, alertTitle } =
8
8
  getCategoryStyles(category)
9
9
  const alert = form?.find((item) => item.type === 'alert')
10
+ const hasChildren = Number(alert?.children?.length) > 0
11
+ const isSingleTab = alert?.children?.length === 1
10
12
 
11
13
  const tabs =
12
14
  alert?.children?.map(
@@ -30,7 +32,13 @@ export const BackendAlert = ({ category, form, callback }: BackendAlertI) => {
30
32
  description={alert?.description ?? ''}
31
33
  >
32
34
  <Divider />
33
- <TabsHeader tabList={tabs} />
35
+ {hasChildren && !isSingleTab && <TabsHeader tabList={tabs} />}
36
+ {hasChildren && isSingleTab && (
37
+ <AlertFields
38
+ fields={alert?.children?.[0]?.children ?? []}
39
+ callback={callback}
40
+ />
41
+ )}
34
42
  </BackendAlertCard>
35
43
  )
36
44
  }
@@ -1,16 +1,74 @@
1
+ import { useEffect, useState } from 'react'
1
2
  import { t } from 'i18next'
2
- import { Box, Flex, Text } from '@chakra-ui/react'
3
+ import { Box, Center, Flex, Text, Image, SlideFade } from '@chakra-ui/react'
3
4
  import { HomieAnimation } from '@/components'
5
+ import { Exclamation } from '@/assets/images'
4
6
 
5
- export const HomefileMonitoring = () => {
7
+ export const HomefileMonitoring = ({ alertCount = 0 }) => {
8
+ const [showMonitoring, setShowMonitoring] = useState(true)
9
+ const [showAlerts, setShowAlerts] = useState(false)
10
+
11
+ useEffect(() => {
12
+ if (alertCount > 0) {
13
+ const timeout1 = setTimeout(() => setShowMonitoring(false), 2000)
14
+ const timeout2 = setTimeout(() => setShowAlerts(true), 3000)
15
+ return () => {
16
+ clearTimeout(timeout1)
17
+ clearTimeout(timeout2)
18
+ }
19
+ }
20
+ }, [alertCount])
6
21
  return (
7
- <Box p="base" borderRadius="lg" bg="#C5E9F4" h="66px" zIndex="2" flex="1">
8
- <Flex align="center">
9
- <Box boxSize="47px">
10
- <HomieAnimation animation="homie-v3" />
22
+ <Box flex="1" zIndex="2">
23
+ {showAlerts && (
24
+ <MonitoringAlerts alertCount={alertCount} showAlerts={showAlerts} />
25
+ )}
26
+ <SlideFade
27
+ in={showMonitoring}
28
+ offsetY="-20px"
29
+ transition={{ enter: { duration: 0.5 } }}
30
+ >
31
+ <Box p="base" borderBottomRadius="lg" bg="#C5E9F4" flex="1">
32
+ <Flex align="center">
33
+ <Box boxSize="47px">
34
+ <HomieAnimation animation="homie-v3" />
35
+ </Box>
36
+ <Text>{t('homeAssistant.homeMonitoring')}</Text>
37
+ </Flex>
11
38
  </Box>
12
- <Text>{t('homeAssistant.homeMonitoring')}</Text>
13
- </Flex>
39
+ </SlideFade>
14
40
  </Box>
15
41
  )
16
42
  }
43
+
44
+ const MonitoringAlerts = ({ alertCount = 0, showAlerts = false }) => {
45
+ return (
46
+ <SlideFade
47
+ in={showAlerts}
48
+ offsetY="-20px"
49
+ transition={{ enter: { duration: 0.5 } }}
50
+ >
51
+ <Box px="base" borderBottomRadius="lg" bg="#F444DA">
52
+ <Flex align="center" gap="1" h="66px">
53
+ <Center p="1" position="relative" h="24px" w="24px">
54
+ <Box
55
+ borderRadius="full"
56
+ bg="neutral.white"
57
+ opacity={0.3}
58
+ h="full"
59
+ w="full"
60
+ position="absolute"
61
+ top="50%"
62
+ left="50%"
63
+ transform="translate(-50%, -50%)"
64
+ />
65
+ <Image src={Exclamation} h="100%" w="auto" />
66
+ </Center>
67
+ <Text color="neutral.white">
68
+ {t('homeAssistant.homeMonitoringAlerts', { count: alertCount })}
69
+ </Text>
70
+ </Flex>
71
+ </Box>
72
+ </SlideFade>
73
+ )
74
+ }
@@ -28,16 +28,21 @@ export const HomeMonitorComponent = () => {
28
28
  action('onStepClick')(step)
29
29
  }
30
30
  const weatherData = mapForecastToWidget(weatherDataMock, 'TX, Houston')
31
+ const alerts = [
32
+ { step: 1, count: 2 },
33
+ { step: 3, count: 1 },
34
+ ]
35
+ const alertsCount = alerts.reduce((acc, alert) => acc + alert.count, 0)
31
36
  return (
32
37
  <HomeMonitor>
33
38
  <Stack spacing="base">
34
39
  <Flex gap="base">
35
- <HomefileMonitoring />
40
+ <HomefileMonitoring alertCount={alertsCount} />
36
41
  <WeatherWidget {...weatherData} />
37
42
  </Flex>
38
43
  <HomeMonitorSteps
39
44
  menuItems={menuMock}
40
- stepsWithAlerts={[]}
45
+ alerts={alerts}
41
46
  onStepClick={handleAlertClick}
42
47
  />
43
48
  </Stack>
@@ -17,3 +17,17 @@ export default {
17
17
  export const BackendAlertComponent = (args: BackendAlertI) => {
18
18
  return <BackendAlert {...args} />
19
19
  }
20
+
21
+ export const BackendAlertSingleChildrenComponent = (args: BackendAlertI) => {
22
+ return (
23
+ <BackendAlert
24
+ {...args}
25
+ form={[
26
+ {
27
+ ...alertFieldsMock[0],
28
+ children: alertFieldsMock?.[0]?.children?.slice(0, 1),
29
+ },
30
+ ]}
31
+ />
32
+ )
33
+ }