@homefile/components-v2 2.23.4 → 2.23.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.
@@ -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
  };
@@ -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
  };
@@ -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(() => {
@@ -51,6 +51,7 @@ export const useDynamicForm = ({ fields, onUpload }) => {
51
51
  };
52
52
  useEffect(() => {
53
53
  handleSetDefaultValues(fields);
54
+ setStateFields(fields);
54
55
  }, [fields]);
55
56
  return {
56
57
  form,
@@ -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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@homefile/components-v2",
3
- "version": "2.23.4",
3
+ "version": "2.23.6",
4
4
  "author": "Homefile",
5
5
  "license": "UNLICENSED",
6
6
  "typings": "dist/index.d.ts",
@@ -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 variant={variant} minW="full" h={height} {...getRootProps()}>
22
- <input {...getInputProps({ multiple })} />
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 />
@@ -43,6 +43,7 @@ export const FileField = ({
43
43
  getRootProps={getRootProps}
44
44
  height="85px"
45
45
  multiple={!singleFileUpload}
46
+ disabled={uploading}
46
47
  />
47
48
  <Grid
48
49
  gridTemplateColumns={`repeat(auto-fill, minmax(22px, 1fr))`}
@@ -55,6 +55,7 @@ export const useFilesUploader = ({
55
55
  }, [hasError])
56
56
 
57
57
  useEffect(() => {
58
+ if (!acceptedFiles.length) return
58
59
  onUpload?.(acceptedFiles)
59
60
  }, [acceptedFiles])
60
61
 
@@ -91,6 +91,7 @@ export const useDynamicForm = ({ fields, onUpload }: UseDynamicFormI) => {
91
91
 
92
92
  useEffect(() => {
93
93
  handleSetDefaultValues(fields)
94
+ setStateFields(fields)
94
95
  }, [fields])
95
96
 
96
97
  return {
@@ -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