@homefile/components-v2 2.8.37 → 2.8.39

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
  };
@@ -17,7 +17,6 @@ export const ReadOnlyGrid = (_a) => {
17
17
  var { children, onClick } = _a, props = __rest(_a, ["children", "onClick"]);
18
18
  return (_jsx(Flex, Object.assign({ align: "stretch", gap: "base", borderBottom: "1px dashed", borderColor: "lightBlue.6", p: "base" }, props, { children: children === null || children === void 0 ? void 0 : children.map(({ children, id, name, value, type, icon }) => {
19
19
  const baseProps = {
20
- key: `${id}-${name}-${value}-${type}`,
21
20
  id,
22
21
  value,
23
22
  icon: icon && fieldIcons[icon],
@@ -31,9 +30,9 @@ export const ReadOnlyGrid = (_a) => {
31
30
  case 'select':
32
31
  case 'string':
33
32
  case 'currency':
34
- return (_jsx(ReadOnlyInput, Object.assign({}, baseProps, { border: "none", flex: "auto", p: "0" })));
33
+ return (_jsx(ReadOnlyInput, Object.assign({}, baseProps, { border: "none", flex: "auto", p: "0" }), `${id}-${name}-${value}-${type}`));
35
34
  case 'date':
36
- return _jsx(ReadOnlyDate, Object.assign({}, baseProps, { name: name, p: "0" }));
35
+ return _jsx(ReadOnlyDate, Object.assign({}, baseProps, { name: name, p: "0" }), `${id}-${name}-${value}-${type}`);
37
36
  case 'guidelines':
38
37
  return (_jsx(ReadOnlyGuidelines, { name: name, children: children, onClick: onClick }, id));
39
38
  case 'item-related':
@@ -5,7 +5,6 @@ import { fieldIcons } from '../../../../helpers';
5
5
  export const ReadOnlyGroup = ({ children }) => {
6
6
  return (_jsx(Stack, { align: "stretch", spacing: "base", p: "base", borderBottom: "1px dashed", borderColor: "lightBlue.6", children: children === null || children === void 0 ? void 0 : children.map(({ children, id, name, value, type, icon }) => {
7
7
  const baseProps = {
8
- key: `${id}-${name}-${value}-${type}`,
9
8
  id,
10
9
  value,
11
10
  icon: icon && fieldIcons[icon],
@@ -19,7 +18,7 @@ export const ReadOnlyGroup = ({ children }) => {
19
18
  case 'select':
20
19
  case 'string':
21
20
  case 'currency':
22
- return (_jsx(ReadOnlyInput, Object.assign({}, baseProps, { border: "none", flex: "auto", p: "0" })));
21
+ return (_jsx(ReadOnlyInput, Object.assign({}, baseProps, { border: "none", flex: "auto", p: "0" }), `${id}-${name}-${value}-${type}`));
23
22
  case 'date':
24
23
  return _jsx(ReadOnlyDate, Object.assign({}, baseProps, { name: name }));
25
24
  case 'grid':
@@ -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.37",
3
+ "version": "2.8.39",
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
  </>
@@ -24,7 +24,6 @@ export const ReadOnlyGrid = ({
24
24
  >
25
25
  {children?.map(({ children, id, name, value, type, icon }) => {
26
26
  const baseProps = {
27
- key: `${id}-${name}-${value}-${type}`,
28
27
  id,
29
28
  value,
30
29
  icon: icon && (fieldIcons[icon] as IconTypes),
@@ -39,10 +38,10 @@ export const ReadOnlyGrid = ({
39
38
  case 'string':
40
39
  case 'currency':
41
40
  return (
42
- <ReadOnlyInput {...baseProps} border="none" flex="auto" p="0" />
41
+ <ReadOnlyInput key={`${id}-${name}-${value}-${type}`} {...baseProps} border="none" flex="auto" p="0" />
43
42
  )
44
43
  case 'date':
45
- return <ReadOnlyDate {...baseProps} name={name} p="0" />
44
+ return <ReadOnlyDate key={`${id}-${name}-${value}-${type}`} {...baseProps} name={name} p="0" />
46
45
 
47
46
  case 'guidelines':
48
47
  return (
@@ -3,7 +3,7 @@ import { IconTypes, ReportI } from '@/interfaces'
3
3
  import { ReadOnlyDate, ReadOnlyGrid, ReadOnlyInput } from '@/components'
4
4
  import { fieldIcons } from '@/helpers'
5
5
 
6
- export const ReadOnlyGroup = ({ children }: Pick<ReportI, 'children'>) => {
6
+ export const ReadOnlyGroup = ({ children}: Pick<ReportI, 'children'>) => {
7
7
  return (
8
8
  <Stack
9
9
  align="stretch"
@@ -14,7 +14,6 @@ export const ReadOnlyGroup = ({ children }: Pick<ReportI, 'children'>) => {
14
14
  >
15
15
  {children?.map(({ children, id, name, value, type, icon }) => {
16
16
  const baseProps = {
17
- key: `${id}-${name}-${value}-${type}`,
18
17
  id,
19
18
  value,
20
19
  icon: icon && (fieldIcons[icon] as IconTypes),
@@ -29,7 +28,7 @@ export const ReadOnlyGroup = ({ children }: Pick<ReportI, 'children'>) => {
29
28
  case 'string':
30
29
  case 'currency':
31
30
  return (
32
- <ReadOnlyInput {...baseProps} border="none" flex="auto" p="0" />
31
+ <ReadOnlyInput key={`${id}-${name}-${value}-${type}`} {...baseProps} border="none" flex="auto" p="0" />
33
32
  )
34
33
  case 'date':
35
34
  return <ReadOnlyDate {...baseProps} name={name} />
@@ -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
  }