@homefile/components-v2 2.11.4 → 2.11.6
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/folderPanel/displayFiles/GridFile.js +2 -2
- package/dist/components/folderPanel/displayFiles/ListFile.js +2 -2
- package/dist/components/forms/dynamicForm/fields/AIGridField.js +13 -6
- package/dist/interfaces/forms/dynamicForm/fields/GridField.interface.d.ts +2 -2
- package/dist/mocks/folderPanel/DisplayFiles.mock.js +10 -0
- package/package.json +1 -1
- package/src/components/folderPanel/displayFiles/GridFile.tsx +2 -2
- package/src/components/folderPanel/displayFiles/ListFile.tsx +2 -2
- package/src/components/forms/dynamicForm/fields/AIGridField.tsx +16 -8
- package/src/interfaces/forms/dynamicForm/fields/GridField.interface.ts +2 -2
- package/src/mocks/folderPanel/DisplayFiles.mock.ts +10 -0
|
@@ -16,7 +16,7 @@ import { DocIcon } from '../../../assets/images';
|
|
|
16
16
|
import { fileTypes, getFileExtension } from '../../../helpers';
|
|
17
17
|
export const GridFile = (_a) => {
|
|
18
18
|
var { menu = [], onClick, onMove } = _a, props = __rest(_a, ["menu", "onClick", "onMove"]);
|
|
19
|
-
const { _id, title, updatedAt, files = [], receipt } = props;
|
|
19
|
+
const { _id, title, updatedAt, files = [], receipt, report } = props;
|
|
20
20
|
const fileExtension = getFileExtension(files, !!receipt);
|
|
21
21
|
const itemForm = {
|
|
22
22
|
_id,
|
|
@@ -24,5 +24,5 @@ export const GridFile = (_a) => {
|
|
|
24
24
|
updatedAt,
|
|
25
25
|
icon: fileTypes[fileExtension] || DocIcon,
|
|
26
26
|
};
|
|
27
|
-
return (_jsxs(WrapItem, { maxW: "7rem", position: "relative", children: [_jsx(Box, { position: "absolute", top: "0", right: "1", zIndex: "docked", children: _jsx(IconMenuWithMove, { disabled: menu.length < 1 ? true : false, icon: _jsx(MoreHorizontal, { size: 28 }), itemForm: itemForm, menuItems: menu, onMove: () => onMove(itemForm) }) }), _jsx(Button, { variant: "folder", px: "base", pb: "base", pt: "6", onClick: () => onClick(props), children: _jsxs(Stack, { spacing: "1", align: "center", children: [_jsx(Image, { src: fileTypes[fileExtension] || DocIcon, w: "46px", h: "49px", alt: fileExtension, transition: "all 0.2s ease-in-out" }), _jsxs(Box, { children: [_jsx(Text, { isTruncated: true, maxWidth: "5rem", fontSize: "sm", children: title }), _jsx(Text, { variant: "date", children: updatedAt })] })] }) })] }));
|
|
27
|
+
return (_jsxs(WrapItem, { maxW: "7rem", position: "relative", children: [_jsx(Box, { position: "absolute", top: "0", right: "1", zIndex: "docked", children: _jsx(IconMenuWithMove, { disabled: menu.length < 1 ? true : false, icon: _jsx(MoreHorizontal, { size: 28 }), itemForm: itemForm, menuItems: menu, onMove: () => onMove(itemForm) }) }), _jsx(Button, { variant: "folder", px: "base", pb: "base", pt: "6", onClick: () => onClick(props), children: _jsxs(Stack, { spacing: "1", align: "center", children: [_jsx(Image, { src: (report && report.length > 0) ? DocIcon : fileTypes[fileExtension] || DocIcon, w: "46px", h: "49px", alt: fileExtension, transition: "all 0.2s ease-in-out" }), _jsxs(Box, { children: [_jsx(Text, { isTruncated: true, maxWidth: "5rem", fontSize: "sm", children: title }), _jsx(Text, { variant: "date", children: updatedAt })] })] }) })] }));
|
|
28
28
|
};
|
|
@@ -16,7 +16,7 @@ import { DocIcon } from '../../../assets/images';
|
|
|
16
16
|
import { fileTypes, getFileExtension } from '../../../helpers';
|
|
17
17
|
export const ListFile = (_a) => {
|
|
18
18
|
var { menu = [], onClick, onMove } = _a, props = __rest(_a, ["menu", "onClick", "onMove"]);
|
|
19
|
-
const { _id, title, updatedAt, files = [], receipt } = props;
|
|
19
|
+
const { _id, title, updatedAt, files = [], receipt, report } = props;
|
|
20
20
|
const fileExtension = getFileExtension(files, !!receipt);
|
|
21
21
|
const itemForm = {
|
|
22
22
|
_id,
|
|
@@ -24,5 +24,5 @@ export const ListFile = (_a) => {
|
|
|
24
24
|
updatedAt,
|
|
25
25
|
icon: fileTypes[fileExtension] || DocIcon,
|
|
26
26
|
};
|
|
27
|
-
return (_jsx(Box, { bg: "neutral.white", w: "100%", transition: "all 0.2s ease-in-out", _hover: { bg: 'lightGreen.1' }, children: _jsxs(Flex, { children: [_jsxs(Flex, { gap: "base", p: "base", as: "button", flex: "1", onClick: () => onClick(props), children: [_jsx(Image, { src: fileTypes[fileExtension] || DocIcon, minW: "32px", h: "auto", alt: fileExtension, transition: "all 0.2s ease-in-out" }), _jsxs(Box, { mt: "-1", children: [_jsx(Text, { variant: "date", textTransform: "uppercase", textAlign: "left", children: fileExtension === '' ? 'Doc' : fileExtension }), _jsx(Text, { textOverflow: "ellipsis", noOfLines: 1, fontSize: "sm", textAlign: "left", children: title })] })] }), _jsxs(Flex, { align: "center", gap: "2", h: "fit-content", p: "1", pr: "base", children: [_jsx(Text, { variant: "date", w: "fit-content", children: updatedAt }), _jsx(IconMenuWithMove, { disabled: menu.length < 1 ? true : false, icon: _jsx(MoreHorizontal, { size: 28 }), itemForm: itemForm, menuItems: menu, onMove: () => onMove(itemForm) })] })] }) }));
|
|
27
|
+
return (_jsx(Box, { bg: "neutral.white", w: "100%", transition: "all 0.2s ease-in-out", _hover: { bg: 'lightGreen.1' }, children: _jsxs(Flex, { children: [_jsxs(Flex, { gap: "base", p: "base", as: "button", flex: "1", onClick: () => onClick(props), children: [_jsx(Image, { src: (report && report.length > 0) ? DocIcon : fileTypes[fileExtension] || DocIcon, minW: "32px", h: "auto", alt: fileExtension, transition: "all 0.2s ease-in-out" }), _jsxs(Box, { mt: "-1", children: [_jsx(Text, { variant: "date", textTransform: "uppercase", textAlign: "left", children: fileExtension === '' ? 'Doc' : fileExtension }), _jsx(Text, { textOverflow: "ellipsis", noOfLines: 1, fontSize: "sm", textAlign: "left", children: title })] })] }), _jsxs(Flex, { align: "center", gap: "2", h: "fit-content", p: "1", pr: "base", children: [_jsx(Text, { variant: "date", w: "fit-content", children: updatedAt }), _jsx(IconMenuWithMove, { disabled: menu.length < 1 ? true : false, icon: _jsx(MoreHorizontal, { size: 28 }), itemForm: itemForm, menuItems: menu, onMove: () => onMove(itemForm) })] })] }) }));
|
|
28
28
|
};
|
|
@@ -4,8 +4,10 @@ import { Flex, IconButton, Text } from '@chakra-ui/react';
|
|
|
4
4
|
import { TextField, SingleImage, Plus } from '../../..';
|
|
5
5
|
import { fieldIcons } from '../../../../helpers';
|
|
6
6
|
import { colors } from '../../../../theme/colors';
|
|
7
|
+
import { useState } from 'react';
|
|
7
8
|
export const AIGridField = ({ children, onAISend, onRemove, onUpload, }) => {
|
|
8
9
|
var _a, _b, _c, _d, _e, _f;
|
|
10
|
+
const [file, setFile] = useState(undefined);
|
|
9
11
|
const { watch } = useFormContext();
|
|
10
12
|
const textChild = children === null || children === void 0 ? void 0 : children.find(({ type }) => type === 'text' || type === 'string');
|
|
11
13
|
const textProps = {
|
|
@@ -25,16 +27,21 @@ export const AIGridField = ({ children, onAISend, onRemove, onUpload, }) => {
|
|
|
25
27
|
? fieldIcons[imageField.icon]
|
|
26
28
|
: undefined,
|
|
27
29
|
};
|
|
28
|
-
const
|
|
30
|
+
const model = watch(String(textChild === null || textChild === void 0 ? void 0 : textChild.id));
|
|
31
|
+
const handleUpload = (files) => {
|
|
32
|
+
const file = files[0];
|
|
33
|
+
setFile(file);
|
|
34
|
+
onUpload === null || onUpload === void 0 ? void 0 : onUpload(files);
|
|
35
|
+
};
|
|
29
36
|
const handleAISend = () => {
|
|
30
37
|
const form = {};
|
|
31
|
-
if (
|
|
32
|
-
form.
|
|
38
|
+
if (model) {
|
|
39
|
+
form.model = model;
|
|
33
40
|
}
|
|
34
|
-
else if (
|
|
35
|
-
form.
|
|
41
|
+
else if (file) {
|
|
42
|
+
form.file = file;
|
|
36
43
|
}
|
|
37
44
|
onAISend === null || onAISend === void 0 ? void 0 : onAISend(form);
|
|
38
45
|
};
|
|
39
|
-
return (_jsxs(Flex, { align: "center", gap: "base", children: [_jsx(SingleImage, Object.assign({}, imageProps, { onUpload:
|
|
46
|
+
return (_jsxs(Flex, { align: "center", gap: "base", children: [_jsx(SingleImage, Object.assign({}, imageProps, { onUpload: handleUpload, onRemove: onRemove, value: imageField === null || imageField === void 0 ? void 0 : imageField.value })), _jsx(Text, { fontFamily: "secondary", textAlign: "center", children: "OR" }), _jsx(TextField, Object.assign({}, textProps)), _jsx(IconButton, { "aria-label": "Add new address line", variant: "iconOutlined", icon: _jsx(Plus, { size: 28, stroke: colors.blue[3] }), onClick: handleAISend, h: "input.md", disabled: !(model === null || model === void 0 ? void 0 : model.length) && !(imageField === null || imageField === void 0 ? void 0 : imageField.value) })] }));
|
|
40
47
|
};
|
|
@@ -23,6 +23,16 @@ export const DisplayFilesMock = [
|
|
|
23
23
|
],
|
|
24
24
|
updatedAt: '2021-08-01T00:00:00.000Z',
|
|
25
25
|
receipt: 'receipt',
|
|
26
|
+
// report: [
|
|
27
|
+
// {
|
|
28
|
+
// "name": "Brand/Manufacturer",
|
|
29
|
+
// "description": "",
|
|
30
|
+
// "comments": "",
|
|
31
|
+
// "value": "",
|
|
32
|
+
// "type": "text",
|
|
33
|
+
// "id": "10"
|
|
34
|
+
// }
|
|
35
|
+
// ]
|
|
26
36
|
},
|
|
27
37
|
// {
|
|
28
38
|
// _id: '2',
|
package/package.json
CHANGED
|
@@ -10,7 +10,7 @@ export const GridFile = ({
|
|
|
10
10
|
onMove,
|
|
11
11
|
...props
|
|
12
12
|
}: DisplayFileI) => {
|
|
13
|
-
const { _id, title, updatedAt, files = [], receipt } = props
|
|
13
|
+
const { _id, title, updatedAt, files = [], receipt, report } = props
|
|
14
14
|
|
|
15
15
|
const fileExtension = getFileExtension(files, !!receipt)
|
|
16
16
|
|
|
@@ -41,7 +41,7 @@ export const GridFile = ({
|
|
|
41
41
|
>
|
|
42
42
|
<Stack spacing="1" align="center">
|
|
43
43
|
<Image
|
|
44
|
-
src={fileTypes[fileExtension] || DocIcon}
|
|
44
|
+
src={(report && report.length > 0) ? DocIcon : fileTypes[fileExtension] || DocIcon}
|
|
45
45
|
w="46px"
|
|
46
46
|
h="49px"
|
|
47
47
|
alt={fileExtension}
|
|
@@ -10,7 +10,7 @@ export const ListFile = ({
|
|
|
10
10
|
onMove,
|
|
11
11
|
...props
|
|
12
12
|
}: DisplayFileI) => {
|
|
13
|
-
const { _id, title, updatedAt, files = [], receipt } = props
|
|
13
|
+
const { _id, title, updatedAt, files = [], receipt, report } = props
|
|
14
14
|
|
|
15
15
|
const fileExtension = getFileExtension(files, !!receipt)
|
|
16
16
|
|
|
@@ -37,7 +37,7 @@ export const ListFile = ({
|
|
|
37
37
|
onClick={() => onClick(props)}
|
|
38
38
|
>
|
|
39
39
|
<Image
|
|
40
|
-
src={fileTypes[fileExtension] || DocIcon}
|
|
40
|
+
src={(report && report.length > 0) ? DocIcon : fileTypes[fileExtension] || DocIcon}
|
|
41
41
|
minW="32px"
|
|
42
42
|
h="auto"
|
|
43
43
|
alt={fileExtension}
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { useFormContext } from 'react-hook-form'
|
|
2
2
|
import { Flex, IconButton, Text } from '@chakra-ui/react'
|
|
3
|
-
import { IconTypes, AIGridFieldI, AIFormI } from '@/interfaces'
|
|
3
|
+
import { IconTypes, AIGridFieldI, AIFormI, FolderFileI } from '@/interfaces'
|
|
4
4
|
import { TextField, SingleImage, Plus } from '@/components'
|
|
5
5
|
import { fieldIcons } from '@/helpers'
|
|
6
6
|
import { colors } from '@/theme/colors'
|
|
7
|
+
import { useState } from 'react'
|
|
7
8
|
|
|
8
9
|
export const AIGridField = ({
|
|
9
10
|
children,
|
|
@@ -11,6 +12,7 @@ export const AIGridField = ({
|
|
|
11
12
|
onRemove,
|
|
12
13
|
onUpload,
|
|
13
14
|
}: AIGridFieldI) => {
|
|
15
|
+
const [file, setFile] = useState<FolderFileI | undefined>(undefined)
|
|
14
16
|
const { watch } = useFormContext()
|
|
15
17
|
|
|
16
18
|
const textChild = children?.find(
|
|
@@ -37,15 +39,21 @@ export const AIGridField = ({
|
|
|
37
39
|
: undefined,
|
|
38
40
|
}
|
|
39
41
|
|
|
40
|
-
const
|
|
42
|
+
const model = watch(String(textChild?.id))
|
|
43
|
+
|
|
44
|
+
const handleUpload = (files: FolderFileI[]) => {
|
|
45
|
+
const file = files[0]
|
|
46
|
+
setFile(file)
|
|
47
|
+
onUpload?.(files)
|
|
48
|
+
}
|
|
41
49
|
|
|
42
50
|
const handleAISend = () => {
|
|
43
51
|
const form: AIFormI = {}
|
|
44
52
|
|
|
45
|
-
if (
|
|
46
|
-
form.
|
|
47
|
-
} else if (
|
|
48
|
-
form.
|
|
53
|
+
if (model) {
|
|
54
|
+
form.model = model
|
|
55
|
+
} else if (file) {
|
|
56
|
+
form.file = file
|
|
49
57
|
}
|
|
50
58
|
onAISend?.(form)
|
|
51
59
|
}
|
|
@@ -54,7 +62,7 @@ export const AIGridField = ({
|
|
|
54
62
|
<Flex align="center" gap="base">
|
|
55
63
|
<SingleImage
|
|
56
64
|
{...imageProps}
|
|
57
|
-
onUpload={
|
|
65
|
+
onUpload={handleUpload}
|
|
58
66
|
onRemove={onRemove}
|
|
59
67
|
value={imageField?.value as string}
|
|
60
68
|
/>
|
|
@@ -68,7 +76,7 @@ export const AIGridField = ({
|
|
|
68
76
|
icon={<Plus size={28} stroke={colors.blue[3]} />}
|
|
69
77
|
onClick={handleAISend}
|
|
70
78
|
h="input.md"
|
|
71
|
-
disabled={!
|
|
79
|
+
disabled={!model?.length && !imageField?.value}
|
|
72
80
|
/>
|
|
73
81
|
</Flex>
|
|
74
82
|
)
|
|
@@ -25,6 +25,16 @@ export const DisplayFilesMock: FileInfoI[] = [
|
|
|
25
25
|
],
|
|
26
26
|
updatedAt: '2021-08-01T00:00:00.000Z',
|
|
27
27
|
receipt: 'receipt',
|
|
28
|
+
// report: [
|
|
29
|
+
// {
|
|
30
|
+
// "name": "Brand/Manufacturer",
|
|
31
|
+
// "description": "",
|
|
32
|
+
// "comments": "",
|
|
33
|
+
// "value": "",
|
|
34
|
+
// "type": "text",
|
|
35
|
+
// "id": "10"
|
|
36
|
+
// }
|
|
37
|
+
// ]
|
|
28
38
|
},
|
|
29
39
|
// {
|
|
30
40
|
// _id: '2',
|