@homefile/components-v2 2.23.5 → 2.23.7
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.
- package/dist/components/dragDrop/DragDropArea.d.ts +1 -1
- package/dist/components/dragDrop/DragDropArea.js +2 -2
- package/dist/components/forms/dynamicForm/ItemFormPanel/ItemFormPanel.d.ts +1 -1
- package/dist/components/forms/dynamicForm/ItemFormPanel/ItemFormPanel.js +4 -4
- package/dist/components/forms/dynamicForm/fields/FileField.js +1 -1
- package/dist/components/householdItems/ItemNameHeader.d.ts +1 -1
- package/dist/components/householdItems/ItemNameHeader.js +2 -2
- package/dist/hooks/folderPanel/useFilesUploader.js +2 -0
- package/dist/interfaces/dragDrop/DragDropArea.interface.d.ts +1 -0
- package/dist/interfaces/forms/ItemFormPanel/ItemFormPanel.interface.d.ts +1 -1
- package/dist/interfaces/headers/ItemNameHeader.interface.d.ts +1 -0
- package/package.json +1 -1
- package/src/components/dragDrop/DragDropArea.tsx +10 -2
- package/src/components/forms/dynamicForm/ItemFormPanel/ItemFormPanel.tsx +33 -34
- package/src/components/forms/dynamicForm/fields/FileField.tsx +1 -0
- package/src/components/householdItems/ItemNameHeader.tsx +2 -1
- package/src/hooks/folderPanel/useFilesUploader.ts +1 -0
- package/src/interfaces/dragDrop/DragDropArea.interface.ts +1 -0
- package/src/interfaces/forms/ItemFormPanel/ItemFormPanel.interface.ts +1 -1
- package/src/interfaces/headers/ItemNameHeader.interface.ts +1 -0
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { DragDropAreaI } from '../../interfaces';
|
|
2
|
-
export declare const DragDropArea: ({ align, direction, errorMessage, getInputProps, getRootProps, height, message, message2, variant, multiple, }: DragDropAreaI) => import("react/jsx-runtime").JSX.Element;
|
|
2
|
+
export declare const DragDropArea: ({ align, direction, errorMessage, getInputProps, getRootProps, height, message, message2, variant, multiple, disabled, }: DragDropAreaI) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -2,7 +2,7 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
2
2
|
import { t } from 'i18next';
|
|
3
3
|
import { Container, Flex, Stack, Text } from '@chakra-ui/react';
|
|
4
4
|
import { Upload } from '..';
|
|
5
|
-
export const DragDropArea = ({ align = 'center', direction = 'row', errorMessage, getInputProps, getRootProps, height = '4rem', message = t('dragDrop.message'), message2 = t('dragDrop.message2'), variant = 'dragDropDashed', multiple = false, }) => {
|
|
5
|
+
export const DragDropArea = ({ align = 'center', direction = 'row', errorMessage, getInputProps, getRootProps, height = '4rem', message = t('dragDrop.message'), message2 = t('dragDrop.message2'), variant = 'dragDropDashed', multiple = false, disabled = false, }) => {
|
|
6
6
|
const hasError = !!errorMessage;
|
|
7
|
-
return (_jsxs(Stack, { spacing: "1", children: [_jsxs(Container, Object.assign({ variant: variant, minW: "full", h: height }, getRootProps(), { children: [_jsx("input", Object.assign({}, getInputProps({ multiple }))), _jsx(Flex, { h: height, align: align, justify: "center", p: "base", children: _jsxs(Flex, { align: "center", direction: direction, gap: "2", children: [_jsx(Upload, {}), _jsxs(Flex, { align: "center", gap: "1", children: [message && _jsx(Text, { variant: "dragDrop", children: message }), message2 && _jsx(Text, { variant: "dragDropLink", children: message2 })] })] }) })] })), hasError && _jsx(Text, { variant: "error", children: errorMessage })] }));
|
|
7
|
+
return (_jsxs(Stack, { spacing: "1", children: [_jsxs(Container, Object.assign({ variant: variant, minW: "full", h: height, _disabled: { opacity: 0.5 }, "aria-disabled": disabled }, getRootProps(), { children: [_jsx("input", Object.assign({}, getInputProps({ multiple, disabled }))), _jsx(Flex, { h: height, align: align, justify: "center", p: "base", children: _jsxs(Flex, { align: "center", direction: direction, gap: "2", children: [_jsx(Upload, {}), _jsxs(Flex, { align: "center", gap: "1", children: [message && _jsx(Text, { variant: "dragDrop", children: message }), message2 && _jsx(Text, { variant: "dragDropLink", children: message2 })] })] }) })] })), hasError && _jsx(Text, { variant: "error", children: errorMessage })] }));
|
|
8
8
|
};
|
|
@@ -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, onClearForm, onDuplicate }: 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;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
2
|
import { useMemo } from 'react';
|
|
3
|
-
import { DrawerBody, DrawerHeader, DrawerFooter, Box
|
|
4
|
-
import { PanelHeader, FooterDrawer, ItemFormFooter, Overlay, Loading } from '../../..';
|
|
5
|
-
export const ItemFormPanel = ({ children, onClose, onSubmitForm, panelIcon, panelTitle, showOverlay = false, onClearForm, onDuplicate }) => {
|
|
3
|
+
import { DrawerBody, DrawerHeader, DrawerFooter, Box } from '@chakra-ui/react';
|
|
4
|
+
import { PanelHeader, FooterDrawer, ItemFormFooter, Overlay, Loading, } from '../../..';
|
|
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, { onClearForm: onClearForm, onDuplicate: onDuplicate, 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, {})) }), onSubmitForm && (_jsx(FooterDrawer, { isOpen: !showOverlay, children: _jsx(DrawerFooter, { w: "100%", py: "0", children: _jsx(ItemFormFooter, { onClearForm: onClearForm, onDuplicate: onDuplicate, onSave: onSubmitForm, onCancel: onClose }) }) }))] }));
|
|
19
19
|
};
|
|
@@ -10,6 +10,6 @@ export const FileField = ({ description, icon, onRemove, onUpload, uploading = f
|
|
|
10
10
|
displayImages,
|
|
11
11
|
});
|
|
12
12
|
const isStringArray = Array.isArray(thumbnails) && typeof thumbnails[0] === 'string';
|
|
13
|
-
return (_jsxs(Flex, { gap: "base", align: "center", flex: "auto", children: [icon && _jsx(Image, { h: "auto", w: "icon.md", src: icon, marginTop: "2" }), _jsxs(Stack, { spacing: "base", flex: "auto", children: [description && _jsx(Text, { fontFamily: "secondary", children: description }), _jsx(DragDropArea, { errorMessage: errorMessage, getInputProps: getInputProps, getRootProps: getRootProps, height: "85px", multiple: !singleFileUpload }), _jsx(Grid, { gridTemplateColumns: `repeat(auto-fill, minmax(22px, 1fr))`, gap: "base", children: isStringArray &&
|
|
13
|
+
return (_jsxs(Flex, { gap: "base", align: "center", flex: "auto", children: [icon && _jsx(Image, { h: "auto", w: "icon.md", src: icon, marginTop: "2" }), _jsxs(Stack, { spacing: "base", flex: "auto", children: [description && _jsx(Text, { fontFamily: "secondary", children: description }), _jsx(DragDropArea, { errorMessage: errorMessage, getInputProps: getInputProps, getRootProps: getRootProps, height: "85px", multiple: !singleFileUpload, disabled: uploading }), _jsx(Grid, { gridTemplateColumns: `repeat(auto-fill, minmax(22px, 1fr))`, gap: "base", children: isStringArray &&
|
|
14
14
|
thumbnails.map((file, index) => (_jsxs(Box, { position: "relative", children: [_jsx(IconButton, { variant: "ghost", "aria-label": "close", maxW: "fit-content", onClick: () => onRemove === null || onRemove === void 0 ? void 0 : onRemove(file), icon: _jsx(Close, { size: 11, stroke: colors.error['2'] }), disabled: uploading, position: "absolute", bg: "neutral.white", p: "0.5", borderRadius: "full", top: "-2", right: "-2", zIndex: "1" }), _jsx(AspectRatio, { maxW: "100%", ratio: 1, children: _jsx(Image, { src: file, objectFit: "cover", alt: `file-${index}` }) })] }, file))) })] })] }));
|
|
15
15
|
};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { ItemNameHeaderI } from '../../interfaces';
|
|
2
|
-
export declare const ItemNameHeader: ({ id, value, onSave, onValueChange, padding, required, }: ItemNameHeaderI) => import("react/jsx-runtime").JSX.Element;
|
|
2
|
+
export declare const ItemNameHeader: ({ id, value, onSave, onValueChange, padding, required, showSaveButton, }: ItemNameHeaderI) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -4,7 +4,7 @@ import { Box, Flex, Button } from '@chakra-ui/react';
|
|
|
4
4
|
import { TextInput } from '..';
|
|
5
5
|
import { isEmptyField } from '../../utils';
|
|
6
6
|
import { useState, useEffect } from 'react';
|
|
7
|
-
export const ItemNameHeader = ({ id = '', value = '', onSave, onValueChange, padding = 'base', required = true, }) => {
|
|
7
|
+
export const ItemNameHeader = ({ id = '', value = '', onSave, onValueChange, padding = 'base', required = true, showSaveButton = true, }) => {
|
|
8
8
|
const [name, setName] = useState(value);
|
|
9
9
|
useEffect(() => {
|
|
10
10
|
setName(value);
|
|
@@ -13,5 +13,5 @@ export const ItemNameHeader = ({ id = '', value = '', onSave, onValueChange, pad
|
|
|
13
13
|
setName(e.target.value);
|
|
14
14
|
onValueChange === null || onValueChange === void 0 ? void 0 : onValueChange(e.target.value);
|
|
15
15
|
};
|
|
16
|
-
return (_jsx(Box, { bg: "lightBlue.2", p: padding, w: "100%", children: _jsxs(Flex, { gap: "base", align: "center", children: [_jsx(TextInput, { errorMessage: `${t('householdItems.headers.itemName')} ${t('forms.required')}`, hasError: required && isEmptyField(name), id: id, handleChange: handleChange, placeholder: t('householdItems.headers.placeholder'), value: name }), name && (_jsx(Button, { variant: "secondary", maxW: "fit-content", maxH: "input.md", onClick: () => onSave(name), children: t('createDocument.buttons.save') }))] }) }));
|
|
16
|
+
return (_jsx(Box, { bg: "lightBlue.2", p: padding, w: "100%", children: _jsxs(Flex, { gap: "base", align: "center", children: [_jsx(TextInput, { errorMessage: `${t('householdItems.headers.itemName')} ${t('forms.required')}`, hasError: required && isEmptyField(name), id: id, handleChange: handleChange, placeholder: t('householdItems.headers.placeholder'), value: name }), name && showSaveButton && (_jsx(Button, { variant: "secondary", maxW: "fit-content", maxH: "input.md", onClick: () => onSave(name), children: t('createDocument.buttons.save') }))] }) }));
|
|
17
17
|
};
|
|
@@ -35,6 +35,8 @@ export const useFilesUploader = ({ onUpload, uploading, displayImages = [], }) =
|
|
|
35
35
|
}
|
|
36
36
|
}, [hasError]);
|
|
37
37
|
useEffect(() => {
|
|
38
|
+
if (!acceptedFiles.length)
|
|
39
|
+
return;
|
|
38
40
|
onUpload === null || onUpload === void 0 ? void 0 : onUpload(acceptedFiles);
|
|
39
41
|
}, [acceptedFiles]);
|
|
40
42
|
useEffect(() => {
|
|
@@ -3,6 +3,7 @@ export interface DragDropAreaI {
|
|
|
3
3
|
align?: string;
|
|
4
4
|
btnText?: string;
|
|
5
5
|
direction?: 'row' | 'column';
|
|
6
|
+
disabled?: boolean;
|
|
6
7
|
errorMessage?: string;
|
|
7
8
|
getInputProps: <T extends DropzoneInputProps>(props?: T | undefined) => T;
|
|
8
9
|
getRootProps: <T extends DropzoneRootProps>(props?: T | undefined) => T;
|
package/package.json
CHANGED
|
@@ -14,12 +14,20 @@ export const DragDropArea = ({
|
|
|
14
14
|
message2 = t('dragDrop.message2'),
|
|
15
15
|
variant = 'dragDropDashed',
|
|
16
16
|
multiple = false,
|
|
17
|
+
disabled = false,
|
|
17
18
|
}: DragDropAreaI) => {
|
|
18
19
|
const hasError = !!errorMessage
|
|
19
20
|
return (
|
|
20
21
|
<Stack spacing="1">
|
|
21
|
-
<Container
|
|
22
|
-
|
|
22
|
+
<Container
|
|
23
|
+
variant={variant}
|
|
24
|
+
minW="full"
|
|
25
|
+
h={height}
|
|
26
|
+
_disabled={{ opacity: 0.5 }}
|
|
27
|
+
aria-disabled={disabled}
|
|
28
|
+
{...getRootProps()}
|
|
29
|
+
>
|
|
30
|
+
<input {...getInputProps({ multiple, disabled })} />
|
|
23
31
|
<Flex h={height} align={align} justify="center" p="base">
|
|
24
32
|
<Flex align="center" direction={direction} gap="2">
|
|
25
33
|
<Upload />
|
|
@@ -1,16 +1,11 @@
|
|
|
1
1
|
import { PropsWithChildren, ReactNode, useMemo } from 'react'
|
|
2
|
-
import {
|
|
3
|
-
DrawerBody,
|
|
4
|
-
DrawerHeader,
|
|
5
|
-
DrawerFooter,
|
|
6
|
-
Box,
|
|
7
|
-
} from '@chakra-ui/react'
|
|
2
|
+
import { DrawerBody, DrawerHeader, DrawerFooter, Box } from '@chakra-ui/react'
|
|
8
3
|
import {
|
|
9
4
|
PanelHeader,
|
|
10
5
|
FooterDrawer,
|
|
11
6
|
ItemFormFooter,
|
|
12
7
|
Overlay,
|
|
13
|
-
Loading
|
|
8
|
+
Loading,
|
|
14
9
|
} from '@/components'
|
|
15
10
|
import { ItemFormPanelI } from '@/interfaces'
|
|
16
11
|
|
|
@@ -22,9 +17,8 @@ export const ItemFormPanel = ({
|
|
|
22
17
|
panelTitle,
|
|
23
18
|
showOverlay = false,
|
|
24
19
|
onClearForm,
|
|
25
|
-
onDuplicate
|
|
20
|
+
onDuplicate,
|
|
26
21
|
}: PropsWithChildren<ItemFormPanelI>) => {
|
|
27
|
-
|
|
28
22
|
const { firstChild, otherChildren } = useMemo(() => {
|
|
29
23
|
let firstChild: ReactNode | null = null
|
|
30
24
|
let otherChildren: ReactNode = children
|
|
@@ -36,7 +30,7 @@ export const ItemFormPanel = ({
|
|
|
36
30
|
otherChildren = children.slice(1)
|
|
37
31
|
}
|
|
38
32
|
}
|
|
39
|
-
|
|
33
|
+
|
|
40
34
|
return { firstChild, otherChildren }
|
|
41
35
|
}, [children])
|
|
42
36
|
|
|
@@ -51,31 +45,36 @@ export const ItemFormPanel = ({
|
|
|
51
45
|
</DrawerHeader>
|
|
52
46
|
|
|
53
47
|
<DrawerBody p="0" overflowX="hidden" bg="lightBlue.1">
|
|
54
|
-
{
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
<
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
)
|
|
72
|
-
}
|
|
48
|
+
{firstChild ? (
|
|
49
|
+
<>
|
|
50
|
+
{firstChild}
|
|
51
|
+
<Box position="relative" mb="200px">
|
|
52
|
+
<Overlay
|
|
53
|
+
showOverlay={showOverlay}
|
|
54
|
+
position="absolute"
|
|
55
|
+
w="inherit"
|
|
56
|
+
h="inherit"
|
|
57
|
+
zIndex="9"
|
|
58
|
+
/>
|
|
59
|
+
{otherChildren}
|
|
60
|
+
</Box>
|
|
61
|
+
</>
|
|
62
|
+
) : (
|
|
63
|
+
<Loading />
|
|
64
|
+
)}
|
|
73
65
|
</DrawerBody>
|
|
74
|
-
|
|
75
|
-
<
|
|
76
|
-
<
|
|
77
|
-
|
|
78
|
-
|
|
66
|
+
{onSubmitForm && (
|
|
67
|
+
<FooterDrawer isOpen={!showOverlay}>
|
|
68
|
+
<DrawerFooter w="100%" py="0">
|
|
69
|
+
<ItemFormFooter
|
|
70
|
+
onClearForm={onClearForm}
|
|
71
|
+
onDuplicate={onDuplicate}
|
|
72
|
+
onSave={onSubmitForm}
|
|
73
|
+
onCancel={onClose}
|
|
74
|
+
/>
|
|
75
|
+
</DrawerFooter>
|
|
76
|
+
</FooterDrawer>
|
|
77
|
+
)}
|
|
79
78
|
</>
|
|
80
79
|
)
|
|
81
80
|
}
|
|
@@ -12,6 +12,7 @@ export const ItemNameHeader = ({
|
|
|
12
12
|
onValueChange,
|
|
13
13
|
padding = 'base',
|
|
14
14
|
required = true,
|
|
15
|
+
showSaveButton = true,
|
|
15
16
|
}: ItemNameHeaderI) => {
|
|
16
17
|
const [name, setName] = useState(value)
|
|
17
18
|
|
|
@@ -36,7 +37,7 @@ export const ItemNameHeader = ({
|
|
|
36
37
|
placeholder={t('householdItems.headers.placeholder')}
|
|
37
38
|
value={name}
|
|
38
39
|
/>
|
|
39
|
-
{name && (
|
|
40
|
+
{name && showSaveButton && (
|
|
40
41
|
<Button
|
|
41
42
|
variant="secondary"
|
|
42
43
|
maxW="fit-content"
|
|
@@ -4,6 +4,7 @@ export interface DragDropAreaI {
|
|
|
4
4
|
align?: string
|
|
5
5
|
btnText?: string
|
|
6
6
|
direction?: 'row' | 'column'
|
|
7
|
+
disabled?: boolean
|
|
7
8
|
errorMessage?: string
|
|
8
9
|
getInputProps: <T extends DropzoneInputProps>(props?: T | undefined) => T
|
|
9
10
|
getRootProps: <T extends DropzoneRootProps>(props?: T | undefined) => T
|