@homefile/components-v2 2.8.38 → 2.8.40

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 { FormFooterI } from '../../../../interfaces';
2
- export declare const ItemFormFooter: ({ onSave, onCancel }: FormFooterI) => import("react/jsx-runtime").JSX.Element;
2
+ export declare const ItemFormFooter: ({ onSave, onCancel, onClearForm, onDuplicate }: FormFooterI) => import("react/jsx-runtime").JSX.Element;
@@ -1,13 +1,23 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
2
  import { t } from 'i18next';
3
3
  import { FooterButtons } from '../../..';
4
- export const ItemFormFooter = ({ onSave, onCancel }) => {
4
+ export const ItemFormFooter = ({ onSave, onCancel, onClearForm, onDuplicate }) => {
5
5
  const buttonsFooter = {
6
6
  button1: {
7
7
  buttonStyle: 'primaryFooter',
8
8
  label: t('buttons.save'),
9
9
  onClick: onSave,
10
10
  },
11
+ button2: (onDuplicate == undefined) ? undefined : {
12
+ buttonStyle: 'secondaryFooter',
13
+ label: t('Duplicate'),
14
+ onClick: onDuplicate,
15
+ },
16
+ button3: (onClearForm == undefined) ? undefined : {
17
+ buttonStyle: 'secondaryFooter',
18
+ label: t('Add Another'),
19
+ onClick: onClearForm,
20
+ },
11
21
  };
12
- return _jsx(FooterButtons, { button1: buttonsFooter.button1 });
22
+ return _jsx(FooterButtons, { button1: buttonsFooter.button1, button2: buttonsFooter.button2, button3: buttonsFooter.button3 });
13
23
  };
@@ -1,3 +1,3 @@
1
1
  import { PropsWithChildren } from 'react';
2
2
  import { ItemFormPanelI } from '../../../../interfaces';
3
- export declare const ItemFormPanel: ({ children, onClose, onSubmitForm, panelIcon, panelTitle, showOverlay, }: PropsWithChildren<ItemFormPanelI>) => import("react/jsx-runtime").JSX.Element;
3
+ export declare const ItemFormPanel: ({ children, onClose, onSubmitForm, panelIcon, panelTitle, showOverlay, onClearForm, onDuplicate }: PropsWithChildren<ItemFormPanelI>) => import("react/jsx-runtime").JSX.Element;
@@ -2,7 +2,7 @@ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-run
2
2
  import { useMemo } from 'react';
3
3
  import { DrawerBody, DrawerHeader, DrawerFooter, Box, } from '@chakra-ui/react';
4
4
  import { PanelHeader, FooterDrawer, ItemFormFooter, Overlay, Loading } from '../../..';
5
- export const ItemFormPanel = ({ children, onClose, onSubmitForm, panelIcon, panelTitle, showOverlay = false, }) => {
5
+ export const ItemFormPanel = ({ children, onClose, onSubmitForm, panelIcon, panelTitle, showOverlay = false, onClearForm, onDuplicate }) => {
6
6
  const { firstChild, otherChildren } = useMemo(() => {
7
7
  let firstChild = null;
8
8
  let otherChildren = children;
@@ -15,5 +15,5 @@ export const ItemFormPanel = ({ children, onClose, onSubmitForm, panelIcon, pane
15
15
  }
16
16
  return { firstChild, otherChildren };
17
17
  }, [children]);
18
- return (_jsxs(_Fragment, { children: [_jsx(DrawerHeader, { p: "0", children: _jsx(PanelHeader, { handleCloseButton: onClose, icon: panelIcon, title: panelTitle }) }), _jsx(DrawerBody, { p: "0", overflowX: "hidden", bg: "lightBlue.1", children: firstChild ? (_jsxs(_Fragment, { children: [firstChild, _jsxs(Box, { position: "relative", mb: "200px", children: [_jsx(Overlay, { showOverlay: showOverlay, position: "absolute", w: "inherit", h: "inherit", zIndex: "9" }), otherChildren] })] })) : (_jsx(Loading, {})) }), _jsx(FooterDrawer, { isOpen: !showOverlay, children: _jsx(DrawerFooter, { w: "100%", py: "0", children: _jsx(ItemFormFooter, { onSave: onSubmitForm, onCancel: onClose }) }) })] }));
18
+ return (_jsxs(_Fragment, { children: [_jsx(DrawerHeader, { p: "0", children: _jsx(PanelHeader, { handleCloseButton: onClose, icon: panelIcon, title: panelTitle }) }), _jsx(DrawerBody, { p: "0", overflowX: "hidden", bg: "lightBlue.1", children: firstChild ? (_jsxs(_Fragment, { children: [firstChild, _jsxs(Box, { position: "relative", mb: "200px", children: [_jsx(Overlay, { showOverlay: showOverlay, position: "absolute", w: "inherit", h: "inherit", zIndex: "9" }), otherChildren] })] })) : (_jsx(Loading, {})) }), _jsx(FooterDrawer, { isOpen: !showOverlay, children: _jsx(DrawerFooter, { w: "100%", py: "0", children: _jsx(ItemFormFooter, { onClearForm: onClearForm, onDuplicate: onDuplicate, onSave: onSubmitForm, onCancel: onClose }) }) })] }));
19
19
  };
@@ -8,8 +8,9 @@ import { ApplianceSteps, SimpleDynamicForm, FooterButtons, HomeAssistantPanelSte
8
8
  import { homeAssistantSteps } from '../../../helpers';
9
9
  import { useSimpleDynamicForm } from '../../../hooks';
10
10
  export const HomeAssistantPanel = ({ children, currentForm, currentStep, onApplianceClick, onBack, onClose, onNext, onSave, backDisabled, nextDisabled, hasCompleted, isLoading }) => {
11
+ var _a, _b;
11
12
  const [addedAppliances, updateAddedAppliances] = useState([]);
12
- const { title } = homeAssistantSteps[currentStep - 1];
13
+ const title = (_b = (_a = homeAssistantSteps === null || homeAssistantSteps === void 0 ? void 0 : homeAssistantSteps[currentStep - 1]) === null || _a === void 0 ? void 0 : _a.title) !== null && _b !== void 0 ? _b : "";
13
14
  const text = `${t('homeAssistant.details')} ${title.toLowerCase()}:`;
14
15
  const isAppliances = currentStep === 4;
15
16
  useEffect(() => {
@@ -1,4 +1,6 @@
1
1
  export interface FormFooterI {
2
2
  onSave: () => void;
3
3
  onCancel: () => void;
4
+ onClearForm?: () => void;
5
+ onDuplicate?: () => void;
4
6
  }
@@ -4,4 +4,6 @@ export interface ItemFormPanelI {
4
4
  panelIcon: string;
5
5
  panelTitle: string;
6
6
  showOverlay?: boolean;
7
+ onClearForm?: () => void;
8
+ onDuplicate?: () => void;
7
9
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@homefile/components-v2",
3
- "version": "2.8.38",
3
+ "version": "2.8.40",
4
4
  "author": "Homefile",
5
5
  "license": "UNLICENSED",
6
6
  "typings": "dist/index.d.ts",
@@ -2,14 +2,24 @@ import { t } from 'i18next'
2
2
  import { FooterButtons } from '@/components'
3
3
  import { FormFooterI } from '@/interfaces'
4
4
 
5
- export const ItemFormFooter = ({ onSave, onCancel }: FormFooterI) => {
5
+ export const ItemFormFooter = ({ onSave, onCancel, onClearForm, onDuplicate }: FormFooterI) => {
6
6
  const buttonsFooter = {
7
7
  button1: {
8
8
  buttonStyle: 'primaryFooter',
9
9
  label: t('buttons.save'),
10
10
  onClick: onSave,
11
11
  },
12
+ button2: (onDuplicate == undefined) ? undefined : {
13
+ buttonStyle: 'secondaryFooter',
14
+ label: t('Duplicate'),
15
+ onClick: onDuplicate,
16
+ },
17
+ button3: (onClearForm == undefined) ? undefined : {
18
+ buttonStyle: 'secondaryFooter',
19
+ label: t('Add Another'),
20
+ onClick: onClearForm,
21
+ },
12
22
  }
13
23
 
14
- return <FooterButtons button1={buttonsFooter.button1} />
24
+ return <FooterButtons button1={buttonsFooter.button1} button2={buttonsFooter.button2} button3={buttonsFooter.button3} />
15
25
  }
@@ -21,6 +21,8 @@ export const ItemFormPanel = ({
21
21
  panelIcon,
22
22
  panelTitle,
23
23
  showOverlay = false,
24
+ onClearForm,
25
+ onDuplicate
24
26
  }: PropsWithChildren<ItemFormPanelI>) => {
25
27
 
26
28
  const { firstChild, otherChildren } = useMemo(() => {
@@ -71,7 +73,7 @@ export const ItemFormPanel = ({
71
73
  </DrawerBody>
72
74
  <FooterDrawer isOpen={!showOverlay}>
73
75
  <DrawerFooter w="100%" py="0">
74
- <ItemFormFooter onSave={onSubmitForm} onCancel={onClose} />
76
+ <ItemFormFooter onClearForm={onClearForm} onDuplicate={onDuplicate} onSave={onSubmitForm} onCancel={onClose} />
75
77
  </DrawerFooter>
76
78
  </FooterDrawer>
77
79
  </>
@@ -36,7 +36,7 @@ export const HomeAssistantPanel = ({
36
36
  isLoading
37
37
  }: PropsWithChildren<HomeAssistantPanelI>) => {
38
38
  const [addedAppliances, updateAddedAppliances] = useState<AppliancesType[]>([])
39
- const { title } = homeAssistantSteps[currentStep - 1]
39
+ const title = homeAssistantSteps?.[currentStep - 1]?.title ?? "";
40
40
  const text = `${t('homeAssistant.details')} ${title.toLowerCase()}:`
41
41
  const isAppliances = currentStep === 4
42
42
 
@@ -1,4 +1,6 @@
1
1
  export interface FormFooterI {
2
2
  onSave: () => void
3
3
  onCancel: () => void
4
+ onClearForm?: () => void
5
+ onDuplicate?: () => void
4
6
  }
@@ -4,4 +4,6 @@ export interface ItemFormPanelI {
4
4
  panelIcon: string
5
5
  panelTitle: string
6
6
  showOverlay?: boolean
7
+ onClearForm?: () => void
8
+ onDuplicate?: () => void
7
9
  }