@homefile/components-v2 2.14.29 → 2.14.30

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
- import { FileFieldI } from '../../../../interfaces';
2
- export declare const SingleImage: ({ onRemove, onUpload, uploading, value, }: FileFieldI) => import("react/jsx-runtime").JSX.Element;
1
+ import { SingleImageI } from '../../../../interfaces';
2
+ export declare const SingleImage: ({ onRemove, onUpload, uploading, value, }: SingleImageI) => import("react/jsx-runtime").JSX.Element;
@@ -2,15 +2,13 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { AspectRatio, Box, Flex, IconButton, Image } from '@chakra-ui/react';
3
3
  import { colors } from '../../../../theme/colors';
4
4
  import { Close, MobileFileUploader } from '../../..';
5
- import { handleMapFile } from '../../../../utils';
6
5
  export const SingleImage = ({ onRemove, onUpload, uploading = false, value, }) => {
7
6
  const handleInputChange = (event) => {
8
7
  var _a;
9
8
  const fileList = (_a = event.target.files) !== null && _a !== void 0 ? _a : [];
10
9
  const files = Array.from(fileList);
11
10
  if (files.length > 0) {
12
- const selectedFiles = handleMapFile({ files });
13
- onUpload === null || onUpload === void 0 ? void 0 : onUpload(selectedFiles);
11
+ onUpload === null || onUpload === void 0 ? void 0 : onUpload(files);
14
12
  }
15
13
  };
16
14
  return (_jsxs(Flex, { gap: "2", align: "center", h: "input.md", children: [_jsx(MobileFileUploader, { handleInputChange: handleInputChange, "aria-label": "upload image", minW: "72px" }), value && (_jsxs(Box, { position: "relative", minW: "30px", children: [_jsx(IconButton, { variant: "ghost", "aria-label": "close", maxW: "fit-content", onClick: () => onRemove === null || onRemove === void 0 ? void 0 : onRemove(value), 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: value, objectFit: "cover", alt: "image" }) })] }))] }));
@@ -2,11 +2,11 @@ import { FieldValues } from 'react-hook-form';
2
2
  import { FolderFileI, ReportI } from '../../interfaces';
3
3
  interface FilesUploadI {
4
4
  id: string;
5
- files: FolderFileI[];
5
+ files: FolderFileI[] | File[];
6
6
  }
7
7
  interface UseDynamicFormI {
8
8
  fields: ReportI[];
9
- onUpload?: (filesByFieldId: Record<string, FolderFileI[]>) => void;
9
+ onUpload?: (filesByFieldId: Record<string, FolderFileI[] | File[]>) => void;
10
10
  }
11
11
  export declare const useDynamicForm: ({ fields, onUpload }: UseDynamicFormI) => {
12
12
  form: import("react-hook-form").UseFormReturn<FieldValues, any, undefined>;
@@ -3,5 +3,5 @@ export interface ItemFormTabsI extends ItemFormTabImageI {
3
3
  form?: ReportI[];
4
4
  onAISend?: AIGridFieldI['onAISend'];
5
5
  searching?: boolean;
6
- formUpload?: (filesByFieldId: Record<string, FolderFileI[]>) => void;
6
+ formUpload?: (filesByFieldId: Record<string, FolderFileI[] | File[]>) => void;
7
7
  }
@@ -28,7 +28,7 @@ export interface DynamicFormI extends Partial<PartnerFooterI> {
28
28
  menuItems?: MenuItemI[];
29
29
  onAISend?: AIGridFieldI['onAISend'];
30
30
  onRemoveImage?: (file: string) => void;
31
- onUpload?: (filesByFieldId: Record<string, FolderFileI[]>) => void;
31
+ onUpload?: (filesByFieldId: Record<string, FolderFileI[] | File[]>) => void;
32
32
  searching?: boolean;
33
33
  showTitle?: boolean;
34
34
  title?: string;
@@ -6,3 +6,6 @@ export interface FileFieldI extends Pick<ReportI, 'description' | 'icon'> {
6
6
  displayImages?: string[];
7
7
  value?: string;
8
8
  }
9
+ export interface SingleImageI extends Omit<FileFieldI, 'onUpload'> {
10
+ onUpload?: (files: File[]) => void;
11
+ }
@@ -1,13 +1,13 @@
1
- import { FolderFileI, ReportI } from '../../..';
1
+ import { ReportI } from '../../..';
2
2
  export interface GridFieldI {
3
3
  children: ReportI['children'];
4
4
  onRemove?: (file: string) => void;
5
- onUpload?: (files: FolderFileI[]) => void;
5
+ onUpload?: (files: File[]) => void;
6
6
  }
7
7
  export interface AIGridFieldI extends GridFieldI {
8
8
  onAISend?: (form?: AIFormI) => void;
9
9
  }
10
10
  export interface AIFormI {
11
11
  model?: string;
12
- file?: FolderFileI;
12
+ file?: File;
13
13
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@homefile/components-v2",
3
- "version": "2.14.29",
3
+ "version": "2.14.30",
4
4
  "author": "Homefile",
5
5
  "license": "UNLICENSED",
6
6
  "typings": "dist/index.d.ts",
@@ -12,7 +12,7 @@ export const AIGridField = ({
12
12
  onRemove,
13
13
  onUpload,
14
14
  }: AIGridFieldI) => {
15
- const [file, setFile] = useState<FolderFileI | undefined>(undefined)
15
+ const [file, setFile] = useState<File | undefined>(undefined)
16
16
  const { watch } = useFormContext()
17
17
 
18
18
  const textChild = children?.find(
@@ -43,7 +43,7 @@ export const AIGridField = ({
43
43
 
44
44
  const model = watch(String(textChild?.id))
45
45
 
46
- const handleUpload = (files: FolderFileI[]) => {
46
+ const handleUpload = (files: File[]) => {
47
47
  const file = files[0]
48
48
  setFile(file)
49
49
  onUpload?.(files)
@@ -2,21 +2,19 @@ import { ChangeEvent } from 'react'
2
2
  import { AspectRatio, Box, Flex, IconButton, Image } from '@chakra-ui/react'
3
3
  import { colors } from '@/theme/colors'
4
4
  import { Close, MobileFileUploader } from '@/components'
5
- import { FileFieldI } from '@/interfaces'
6
- import { handleMapFile } from '@/utils'
5
+ import { SingleImageI } from '@/interfaces'
7
6
 
8
7
  export const SingleImage = ({
9
8
  onRemove,
10
9
  onUpload,
11
10
  uploading = false,
12
11
  value,
13
- }: FileFieldI) => {
12
+ }: SingleImageI) => {
14
13
  const handleInputChange = (event: ChangeEvent<HTMLInputElement>) => {
15
14
  const fileList = event.target.files ?? []
16
15
  const files = Array.from(fileList)
17
16
  if (files.length > 0) {
18
- const selectedFiles = handleMapFile({ files })
19
- onUpload?.(selectedFiles)
17
+ onUpload?.(files)
20
18
  }
21
19
  }
22
20
 
@@ -5,12 +5,12 @@ import { dynamicFormProxy } from '@/proxies'
5
5
 
6
6
  interface FilesUploadI {
7
7
  id: string
8
- files: FolderFileI[]
8
+ files: FolderFileI[] | File[]
9
9
  }
10
10
 
11
11
  interface UseDynamicFormI {
12
12
  fields: ReportI[]
13
- onUpload?: (filesByFieldId: Record<string, FolderFileI[]>) => void
13
+ onUpload?: (filesByFieldId: Record<string, FolderFileI[] | File[]>) => void
14
14
  }
15
15
 
16
16
  export const useDynamicForm = ({ fields, onUpload }: UseDynamicFormI) => {
@@ -1,8 +1,13 @@
1
- import { ItemFormTabImageI, ReportI, AIGridFieldI, FolderFileI } from '@/interfaces'
1
+ import {
2
+ ItemFormTabImageI,
3
+ ReportI,
4
+ AIGridFieldI,
5
+ FolderFileI,
6
+ } from '@/interfaces'
2
7
 
3
8
  export interface ItemFormTabsI extends ItemFormTabImageI {
4
9
  form?: ReportI[]
5
10
  onAISend?: AIGridFieldI['onAISend']
6
11
  searching?: boolean
7
- formUpload?: (filesByFieldId: Record<string, FolderFileI[]>) => void
12
+ formUpload?: (filesByFieldId: Record<string, FolderFileI[] | File[]>) => void
8
13
  }
@@ -136,7 +136,7 @@ export interface DynamicFormI extends Partial<PartnerFooterI> {
136
136
  menuItems?: MenuItemI[]
137
137
  onAISend?: AIGridFieldI['onAISend']
138
138
  onRemoveImage?: (file: string) => void
139
- onUpload?: (filesByFieldId: Record<string, FolderFileI[]>) => void
139
+ onUpload?: (filesByFieldId: Record<string, FolderFileI[] | File[]>) => void
140
140
  searching?: boolean
141
141
  showTitle?: boolean
142
142
  title?: string
@@ -7,3 +7,7 @@ export interface FileFieldI extends Pick<ReportI, 'description' | 'icon'> {
7
7
  displayImages?: string[]
8
8
  value?: string
9
9
  }
10
+
11
+ export interface SingleImageI extends Omit<FileFieldI, 'onUpload'> {
12
+ onUpload?: (files: File[]) => void
13
+ }
@@ -3,7 +3,7 @@ import { FolderFileI, ReportI } from '@/interfaces'
3
3
  export interface GridFieldI {
4
4
  children: ReportI['children']
5
5
  onRemove?: (file: string) => void
6
- onUpload?: (files: FolderFileI[]) => void
6
+ onUpload?: (files: File[]) => void
7
7
  }
8
8
 
9
9
  export interface AIGridFieldI extends GridFieldI {
@@ -12,5 +12,5 @@ export interface AIGridFieldI extends GridFieldI {
12
12
 
13
13
  export interface AIFormI {
14
14
  model?: string
15
- file?: FolderFileI
15
+ file?: File
16
16
  }