@homefile/components-v2 2.17.3 → 2.17.4

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.
@@ -2,7 +2,6 @@ import { Box, Stack } from '@chakra-ui/react'
2
2
  import { TileBodyI } from '@/interfaces'
3
3
  import {
4
4
  PartnerFooter,
5
- SingleFields,
6
5
  TileBodyFields,
7
6
  TileFooterFields,
8
7
  TileHeaderFields,
@@ -1,2 +1,2 @@
1
1
  import { BackendAlertI } from '../../../interfaces';
2
- export declare const BackendAlert: ({ category, icon, id, title, tabs, summary, }: BackendAlertI) => import("react/jsx-runtime").JSX.Element;
2
+ export declare const BackendAlert: ({ category, form }: BackendAlertI) => import("react/jsx-runtime").JSX.Element;
@@ -1,7 +1,9 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
2
  import { BackendAlertCard } from '../..';
3
3
  import { getCategoryStyles } from '../../../utils/Alerts.utils';
4
- export const BackendAlert = ({ category, icon, id, title, tabs, summary, }) => {
4
+ export const BackendAlert = ({ category, form }) => {
5
+ var _a, _b, _c;
5
6
  const { headerBg, alertIcon, alertIconBg, alertTitle } = getCategoryStyles(category);
6
- return (_jsx(BackendAlertCard, { alertBg: headerBg, alertIcon: alertIcon, alertTitle: alertTitle, bg: alertIconBg, icon: icon, title: title, description: summary, children: "content" }));
7
+ const alertHeader = form === null || form === void 0 ? void 0 : form.find((item) => item.type === 'alertHeader');
8
+ return (_jsx(BackendAlertCard, { alertBg: headerBg, alertIcon: alertIcon, alertTitle: alertTitle, bg: alertIconBg, icon: (_a = alertHeader === null || alertHeader === void 0 ? void 0 : alertHeader.icon) !== null && _a !== void 0 ? _a : '', title: (_b = alertHeader === null || alertHeader === void 0 ? void 0 : alertHeader.label) !== null && _b !== void 0 ? _b : '', description: (_c = alertHeader === null || alertHeader === void 0 ? void 0 : alertHeader.description) !== null && _c !== void 0 ? _c : '', children: "content" }));
7
9
  };
@@ -1,3 +1,3 @@
1
1
  import { PropsWithChildren } from 'react';
2
2
  import { BackendAlertCardI } from '../../../interfaces';
3
- export declare const BackendAlertCard: ({ alertBg, alertIcon, alertTitle, children, ...props }: PropsWithChildren<BackendAlertCardI>) => import("react/jsx-runtime").JSX.Element;
3
+ export declare const BackendAlertCard: ({ alertBg, alertIcon, alertTitle, children, icon, ...props }: PropsWithChildren<BackendAlertCardI>) => import("react/jsx-runtime").JSX.Element;
@@ -14,8 +14,9 @@ import { t } from 'i18next';
14
14
  import { Box, Button, Collapse, Flex, useDisclosure } from '@chakra-ui/react';
15
15
  import { AlertHeader, AlertTemplate, AlertTitle } from '../..';
16
16
  import { Warranty } from '../../../assets/images';
17
+ import { fieldIcons } from '../../../helpers';
17
18
  export const BackendAlertCard = (_a) => {
18
- var { alertBg = 'error.2', alertIcon = Warranty, alertTitle = t('homeAssistant.monitorAlerts.protection'), children } = _a, props = __rest(_a, ["alertBg", "alertIcon", "alertTitle", "children"]);
19
+ var { alertBg = 'error.2', alertIcon = Warranty, alertTitle = t('homeAssistant.monitorAlerts.protection'), children, icon = 'warning' } = _a, props = __rest(_a, ["alertBg", "alertIcon", "alertTitle", "children", "icon"]);
19
20
  const { isOpen, onToggle } = useDisclosure();
20
- return (_jsxs(Box, { display: "flex", flexDir: "column", bg: "neutral.white", boxShadow: "lg", borderRadius: "lg", overflow: "hidden", maxW: "420px", children: [_jsx(AlertHeader, { bg: alertBg }), _jsx(AlertTitle, { alertIcon: alertIcon, alertTitle: alertTitle }), _jsx(AlertTemplate, Object.assign({}, props)), _jsx(Collapse, { in: isOpen, animateOpacity: true, children: _jsx(Box, { p: "base", bg: "lightBlue.1", children: children }) }), _jsx(Flex, { py: "base", bg: "lightBlue.1", justify: "flex-end", children: _jsx(Button, { variant: "leftRounded", w: "fit-content", px: "8", fontSize: "sm", fontWeight: "medium", onClick: onToggle, bg: isOpen ? 'blue.8' : 'blue.2', children: t(`homeAssistant.monitorAlerts.${isOpen ? 'collapse' : 'review'}`) }) })] }));
21
+ return (_jsxs(Box, { display: "flex", flexDir: "column", bg: "neutral.white", boxShadow: "lg", borderRadius: "lg", overflow: "hidden", maxW: "420px", children: [_jsx(AlertHeader, { bg: alertBg }), _jsx(AlertTitle, { alertIcon: alertIcon, alertTitle: alertTitle }), _jsx(AlertTemplate, Object.assign({}, props, { icon: fieldIcons[icon] })), _jsx(Collapse, { in: isOpen, animateOpacity: true, children: _jsx(Box, { p: "base", bg: "lightBlue.1", children: children }) }), _jsx(Flex, { py: "base", bg: "lightBlue.1", justify: "flex-end", children: _jsx(Button, { variant: "leftRounded", w: "fit-content", px: "8", fontSize: "sm", fontWeight: "medium", onClick: onToggle, bg: isOpen ? 'blue.8' : 'blue.2', children: t(`homeAssistant.monitorAlerts.${isOpen ? 'collapse' : 'review'}`) }) })] }));
21
22
  };
@@ -1,4 +1,4 @@
1
- import { Fire, House, LargeAppliances, Target, Temperature, Water, } from '../../assets/images';
1
+ import { Fire, GearTime, House, LargeAppliances, Target, Temperature, Water, } from '../../assets/images';
2
2
  export const homeAssistantSteps = [
3
3
  {
4
4
  title: 'Goals',
@@ -30,24 +30,24 @@ export const CATEGORY_CONFIG = {
30
30
  label: 'Protection Monitor',
31
31
  color: '#DB1DA1',
32
32
  accent: '#FDDDF8',
33
- icon: Fire,
33
+ icon: GearTime,
34
34
  },
35
35
  maintain: {
36
36
  label: 'Maintenance Monitor',
37
37
  color: '#8CC421',
38
38
  accent: '#B9DEF2',
39
- icon: LargeAppliances,
39
+ icon: GearTime,
40
40
  },
41
41
  budget: {
42
42
  label: 'Budget Monitor',
43
43
  color: '#1D8BDB',
44
44
  accent: '#B9DEF2',
45
- icon: Target,
45
+ icon: GearTime,
46
46
  },
47
47
  improve: {
48
48
  label: 'Improvement Monitor',
49
49
  color: '#8516A7',
50
50
  accent: '#B9DEF2',
51
- icon: House,
51
+ icon: GearTime,
52
52
  },
53
53
  };
@@ -1,5 +1,5 @@
1
- import { AIGridFieldI, FolderFileI, MenuItemI, PartnerFooterI, TileCtaI } from '../..';
2
- export type KindTypes = 'ai-image' | 'ai-grid' | 'checkbox' | 'checkbox-agreement' | 'checkbox-group' | 'currency' | 'date' | 'email' | 'file' | 'grid' | 'group' | 'hidden' | 'notes' | 'number' | 'radio' | 'rating' | 'select' | 'string' | 'switch' | 'telephone' | 'text' | 'textarea' | 'default' | UIKindTypes | HomeItemTypes;
1
+ import { AIGridFieldI, AlertFieldType, FolderFileI, MenuItemI, PartnerFooterI, TileCtaI } from '../..';
2
+ export type KindTypes = 'ai-image' | 'ai-grid' | 'checkbox' | 'checkbox-agreement' | 'checkbox-group' | 'currency' | 'date' | 'email' | 'file' | 'grid' | 'group' | 'hidden' | 'notes' | 'number' | 'radio' | 'rating' | 'select' | 'string' | 'switch' | 'telephone' | 'text' | 'textarea' | 'default' | UIKindTypes | HomeItemTypes | AlertFieldType;
3
3
  export type UIKindTypes = 'tile-body' | 'tile-body-logo' | 'tile-body-header' | 'tile-body-section' | 'tile-body-section-grid' | 'tile-body-partner-image' | 'tile-body-description' | 'tile-form' | 'tile-body-action' | 'vertical-icon' | 'primary-cta' | 'secondary-cta';
4
4
  export type HomeItemTypes = 'appliances' | 'images' | 'guidelines' | 'item-related' | 'item-icon-btn';
5
5
  export type IconTypes = 'barcode' | 'battery' | 'billing' | 'book' | 'book-opened' | 'calc' | 'calendar' | 'check' | 'co2' | 'contact' | 'date' | 'default' | 'detector' | 'electricity' | 'goldbars' | 'heart' | 'image' | 'notes' | 'palette' | 'people' | 'price' | 'rating' | 'receipt' | 'registry' | 'sprinkler' | 'tools' | 'wind' | '68' | 'calendar2' | 'water' | 'calendar-drop' | 'umbrella' | 'heater' | 'roof' | 'foundation' | 'solar-panel' | 'pool' | 'drop' | 'mobile-drop' | 'light' | 'plate' | 'pressure-washer' | 'house' | 'target' | 'title' | 'company' | UIIconTypes;
@@ -1,15 +1,7 @@
1
+ import { DynamicFormI } from '..';
1
2
  export type AlertCategory = 'safeguard' | 'maintain' | 'budget' | 'improve';
2
3
  export type AlertTabType = 'details' | 'filter-size' | 'purchase' | 'hire-out';
3
- export interface AlertTab<T = unknown> {
4
- key: AlertTabType;
5
- label: string;
6
- data: T;
7
- }
8
- export interface BackendAlertI {
9
- id: string;
4
+ export type AlertFieldType = 'alertHeader' | 'text' | 'iconSection' | 'tabList' | 'list';
5
+ export interface BackendAlertI extends DynamicFormI {
10
6
  category: AlertCategory;
11
- icon: string;
12
- title: string;
13
- summary: string;
14
- tabs?: AlertTab[];
15
7
  }
@@ -4,3 +4,4 @@ export declare const contactFieldsMock: ReportI[];
4
4
  export declare const tileUIMock: ReportI[];
5
5
  export declare const viewingHomeItemMock: ReportI[];
6
6
  export declare const unknownFormMock: Record<string, any>;
7
+ export declare const alertFieldsMock: ReportI[];
@@ -839,3 +839,14 @@ export const unknownFormMock = {
839
839
  updatedAt: '2025-04-17T19:26:39.435Z',
840
840
  __v: 0,
841
841
  };
842
+ export const alertFieldsMock = [
843
+ {
844
+ id: faker.database.mongodbObjectId(),
845
+ name: 'Filter',
846
+ label: 'Time to change your heating & cooling air filter.',
847
+ description: 'Changing your air filter every 30 days ensures efficient system performance and improves indoor air quality by trapping dust and allergens.',
848
+ icon: 'wind',
849
+ value: false,
850
+ type: 'alertHeader',
851
+ },
852
+ ];
@@ -0,0 +1,5 @@
1
+ import { Meta } from '@storybook/react';
2
+ import { BackendAlertI } from '../../../interfaces';
3
+ declare const _default: Meta<BackendAlertI>;
4
+ export default _default;
5
+ export declare const BackendAlertComponent: (args: BackendAlertI) => import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,14 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { BackendAlert } from '../../../components';
3
+ import { alertFieldsMock } from '../../../mocks';
4
+ export default {
5
+ title: 'Components/HomeAssistant/MonitorAlerts',
6
+ component: BackendAlert,
7
+ args: {
8
+ category: 'budget',
9
+ form: alertFieldsMock,
10
+ },
11
+ };
12
+ export const BackendAlertComponent = (args) => {
13
+ return _jsx(BackendAlert, Object.assign({}, args));
14
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@homefile/components-v2",
3
- "version": "2.17.3",
3
+ "version": "2.17.4",
4
4
  "author": "Homefile",
5
5
  "license": "UNLICENSED",
6
6
  "typings": "dist/index.d.ts",
@@ -2,7 +2,6 @@ import { Box, Stack } from '@chakra-ui/react'
2
2
  import { TileBodyI } from '@/interfaces'
3
3
  import {
4
4
  PartnerFooter,
5
- SingleFields,
6
5
  TileBodyFields,
7
6
  TileFooterFields,
8
7
  TileHeaderFields,
@@ -2,25 +2,19 @@ import { BackendAlertCard } from '@/components'
2
2
  import { BackendAlertI } from '@/interfaces'
3
3
  import { getCategoryStyles } from '@/utils/Alerts.utils'
4
4
 
5
- export const BackendAlert = ({
6
- category,
7
- icon,
8
- id,
9
- title,
10
- tabs,
11
- summary,
12
- }: BackendAlertI) => {
5
+ export const BackendAlert = ({ category, form }: BackendAlertI) => {
13
6
  const { headerBg, alertIcon, alertIconBg, alertTitle } =
14
7
  getCategoryStyles(category)
8
+ const alertHeader = form?.find((item) => item.type === 'alertHeader')
15
9
  return (
16
10
  <BackendAlertCard
17
11
  alertBg={headerBg}
18
12
  alertIcon={alertIcon}
19
13
  alertTitle={alertTitle}
20
14
  bg={alertIconBg}
21
- icon={icon}
22
- title={title}
23
- description={summary}
15
+ icon={alertHeader?.icon ?? ''}
16
+ title={alertHeader?.label ?? ''}
17
+ description={alertHeader?.description ?? ''}
24
18
  >
25
19
  content
26
20
  </BackendAlertCard>
@@ -2,14 +2,16 @@ import { PropsWithChildren } from 'react'
2
2
  import { t } from 'i18next'
3
3
  import { Box, Button, Collapse, Flex, useDisclosure } from '@chakra-ui/react'
4
4
  import { AlertHeader, AlertTemplate, AlertTitle } from '@/components'
5
- import { BackendAlertCardI } from '@/interfaces'
5
+ import { BackendAlertCardI, IconTypes } from '@/interfaces'
6
6
  import { Warranty } from '@/assets/images'
7
+ import { fieldIcons } from '@/helpers'
7
8
 
8
9
  export const BackendAlertCard = ({
9
10
  alertBg = 'error.2',
10
11
  alertIcon = Warranty,
11
12
  alertTitle = t('homeAssistant.monitorAlerts.protection'),
12
13
  children,
14
+ icon = 'warning',
13
15
  ...props
14
16
  }: PropsWithChildren<BackendAlertCardI>) => {
15
17
  const { isOpen, onToggle } = useDisclosure()
@@ -25,7 +27,7 @@ export const BackendAlertCard = ({
25
27
  >
26
28
  <AlertHeader bg={alertBg} />
27
29
  <AlertTitle alertIcon={alertIcon} alertTitle={alertTitle} />
28
- <AlertTemplate {...props} />
30
+ <AlertTemplate {...props} icon={fieldIcons[icon as IconTypes]} />
29
31
  <Collapse in={isOpen} animateOpacity>
30
32
  <Box p="base" bg="lightBlue.1">
31
33
  {children}
@@ -1,5 +1,6 @@
1
1
  import {
2
2
  Fire,
3
+ GearTime,
3
4
  House,
4
5
  LargeAppliances,
5
6
  Target,
@@ -48,24 +49,24 @@ export const CATEGORY_CONFIG: Record<AlertCategory, CategoryConfigI> = {
48
49
  label: 'Protection Monitor',
49
50
  color: '#DB1DA1',
50
51
  accent: '#FDDDF8',
51
- icon: Fire,
52
+ icon: GearTime,
52
53
  },
53
54
  maintain: {
54
55
  label: 'Maintenance Monitor',
55
56
  color: '#8CC421',
56
57
  accent: '#B9DEF2',
57
- icon: LargeAppliances,
58
+ icon: GearTime,
58
59
  },
59
60
  budget: {
60
61
  label: 'Budget Monitor',
61
62
  color: '#1D8BDB',
62
63
  accent: '#B9DEF2',
63
- icon: Target,
64
+ icon: GearTime,
64
65
  },
65
66
  improve: {
66
67
  label: 'Improvement Monitor',
67
68
  color: '#8516A7',
68
69
  accent: '#B9DEF2',
69
- icon: House,
70
+ icon: GearTime,
70
71
  },
71
72
  }
@@ -1,5 +1,6 @@
1
1
  import {
2
2
  AIGridFieldI,
3
+ AlertFieldType,
3
4
  FolderFileI,
4
5
  MenuItemI,
5
6
  PartnerFooterI,
@@ -32,6 +33,7 @@ export type KindTypes =
32
33
  | 'default'
33
34
  | UIKindTypes
34
35
  | HomeItemTypes
36
+ | AlertFieldType
35
37
 
36
38
  export type UIKindTypes =
37
39
  | 'tile-body'
@@ -1,18 +1,16 @@
1
+ import { DynamicFormI } from '@/interfaces'
2
+
1
3
  export type AlertCategory = 'safeguard' | 'maintain' | 'budget' | 'improve'
2
4
 
3
5
  export type AlertTabType = 'details' | 'filter-size' | 'purchase' | 'hire-out'
4
6
 
5
- export interface AlertTab<T = unknown> {
6
- key: AlertTabType
7
- label: string
8
- data: T
9
- }
7
+ export type AlertFieldType =
8
+ | 'alertHeader'
9
+ | 'text'
10
+ | 'iconSection'
11
+ | 'tabList'
12
+ | 'list'
10
13
 
11
- export interface BackendAlertI {
12
- id: string
14
+ export interface BackendAlertI extends DynamicFormI {
13
15
  category: AlertCategory
14
- icon: string
15
- title: string
16
- summary: string
17
- tabs?: AlertTab[]
18
16
  }
@@ -853,3 +853,16 @@ export const unknownFormMock: Record<string, any> = {
853
853
  updatedAt: '2025-04-17T19:26:39.435Z',
854
854
  __v: 0,
855
855
  }
856
+
857
+ export const alertFieldsMock: ReportI[] = [
858
+ {
859
+ id: faker.database.mongodbObjectId(),
860
+ name: 'Filter',
861
+ label: 'Time to change your heating & cooling air filter.',
862
+ description:
863
+ 'Changing your air filter every 30 days ensures efficient system performance and improves indoor air quality by trapping dust and allergens.',
864
+ icon: 'wind',
865
+ value: false,
866
+ type: 'alertHeader',
867
+ },
868
+ ]
@@ -0,0 +1,17 @@
1
+ import { Meta } from '@storybook/react'
2
+ import { BackendAlert } from '@/components'
3
+ import { BackendAlertI } from '@/interfaces'
4
+ import { alertFieldsMock } from '@/mocks'
5
+
6
+ export default {
7
+ title: 'Components/HomeAssistant/MonitorAlerts',
8
+ component: BackendAlert,
9
+ args: {
10
+ category: 'budget',
11
+ form: alertFieldsMock,
12
+ },
13
+ } as Meta<BackendAlertI>
14
+
15
+ export const BackendAlertComponent = (args: BackendAlertI) => {
16
+ return <BackendAlert {...args} />
17
+ }