@homefile/components-v2 2.14.27 → 2.14.29

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.
@@ -6,11 +6,10 @@ import { fieldIcons } from '../../../../helpers';
6
6
  import { colors } from '../../../../theme/colors';
7
7
  import { useState } from 'react';
8
8
  export const AIGridField = ({ children, onAISend, onRemove, onUpload, }) => {
9
- var _a, _b, _c, _d, _e, _f;
9
+ var _a, _b, _c, _d, _e, _f, _g;
10
10
  const [file, setFile] = useState(undefined);
11
11
  const { watch } = useFormContext();
12
12
  const textChild = children === null || children === void 0 ? void 0 : children.find(({ type }) => type === 'text' || type === 'string');
13
- console.log('text', textChild);
14
13
  const textProps = {
15
14
  id: (_a = textChild === null || textChild === void 0 ? void 0 : textChild.id) !== null && _a !== void 0 ? _a : '',
16
15
  value: (_b = textChild === null || textChild === void 0 ? void 0 : textChild.value) !== null && _b !== void 0 ? _b : '',
@@ -28,6 +27,8 @@ export const AIGridField = ({ children, onAISend, onRemove, onUpload, }) => {
28
27
  ? fieldIcons[imageField.icon]
29
28
  : undefined,
30
29
  };
30
+ const imageId = (_g = imageField === null || imageField === void 0 ? void 0 : imageField.id) !== null && _g !== void 0 ? _g : '';
31
+ const imageValue = watch(imageId);
31
32
  const model = watch(String(textChild === null || textChild === void 0 ? void 0 : textChild.id));
32
33
  const handleUpload = (files) => {
33
34
  const file = files[0];
@@ -44,5 +45,5 @@ export const AIGridField = ({ children, onAISend, onRemove, onUpload, }) => {
44
45
  }
45
46
  onAISend === null || onAISend === void 0 ? void 0 : onAISend(form);
46
47
  };
47
- return (_jsxs(Flex, { align: "flex-end", gap: "base", children: [_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) })] }));
48
+ return (_jsxs(Flex, { align: "flex-end", gap: "base", children: [_jsxs(Flex, { align: "center", gap: "base", children: [_jsx(SingleImage, Object.assign({}, imageProps, { onUpload: handleUpload, onRemove: onRemove, value: String(imageValue) })), _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) && !imageValue })] }));
48
49
  };
@@ -51,7 +51,6 @@ export const useDynamicForm = ({ fields, onUpload }) => {
51
51
  };
52
52
  useEffect(() => {
53
53
  handleSetDefaultValues(fields);
54
- setStateFields(fields);
55
54
  }, [fields]);
56
55
  return {
57
56
  form,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@homefile/components-v2",
3
- "version": "2.14.27",
3
+ "version": "2.14.29",
4
4
  "author": "Homefile",
5
5
  "license": "UNLICENSED",
6
6
  "typings": "dist/index.d.ts",
@@ -14,13 +14,11 @@ export const AIGridField = ({
14
14
  }: AIGridFieldI) => {
15
15
  const [file, setFile] = useState<FolderFileI | undefined>(undefined)
16
16
  const { watch } = useFormContext()
17
-
17
+
18
18
  const textChild = children?.find(
19
19
  ({ type }) => type === 'text' || type === 'string'
20
20
  )
21
21
 
22
- console.log('text', textChild)
23
-
24
22
  const textProps = {
25
23
  id: textChild?.id ?? '',
26
24
  value: textChild?.value ?? '',
@@ -40,6 +38,9 @@ export const AIGridField = ({
40
38
  : undefined,
41
39
  }
42
40
 
41
+ const imageId = imageField?.id ?? ''
42
+ const imageValue = watch(imageId)
43
+
43
44
  const model = watch(String(textChild?.id))
44
45
 
45
46
  const handleUpload = (files: FolderFileI[]) => {
@@ -66,7 +67,7 @@ export const AIGridField = ({
66
67
  {...imageProps}
67
68
  onUpload={handleUpload}
68
69
  onRemove={onRemove}
69
- value={imageField?.value as string}
70
+ value={String(imageValue)}
70
71
  />
71
72
  <Text fontFamily="secondary" textAlign="center">
72
73
  OR
@@ -79,7 +80,7 @@ export const AIGridField = ({
79
80
  icon={<Plus size={28} stroke={colors.blue[3]} />}
80
81
  onClick={handleAISend}
81
82
  h="input.md"
82
- disabled={!model?.length && !imageField?.value}
83
+ disabled={!model?.length && !imageValue}
83
84
  />
84
85
  </Flex>
85
86
  )
@@ -18,6 +18,7 @@ export const useDynamicForm = ({ fields, onUpload }: UseDynamicFormI) => {
18
18
  const visibleFields = stateFields.filter(
19
19
  (field) => field.visible || field.visible === undefined
20
20
  )
21
+
21
22
  const hiddenFields = stateFields.filter((field) => field.visible === false)
22
23
 
23
24
  const form = useForm()
@@ -90,7 +91,6 @@ export const useDynamicForm = ({ fields, onUpload }: UseDynamicFormI) => {
90
91
 
91
92
  useEffect(() => {
92
93
  handleSetDefaultValues(fields)
93
- setStateFields(fields)
94
94
  }, [fields])
95
95
 
96
96
  return {