@homefile/components-v2 2.14.28 → 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,7 +6,7 @@ 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');
@@ -27,6 +27,8 @@ export const AIGridField = ({ children, onAISend, onRemove, onUpload, }) => {
27
27
  ? fieldIcons[imageField.icon]
28
28
  : undefined,
29
29
  };
30
+ const imageId = (_g = imageField === null || imageField === void 0 ? void 0 : imageField.id) !== null && _g !== void 0 ? _g : '';
31
+ const imageValue = watch(imageId);
30
32
  const model = watch(String(textChild === null || textChild === void 0 ? void 0 : textChild.id));
31
33
  const handleUpload = (files) => {
32
34
  const file = files[0];
@@ -43,5 +45,5 @@ export const AIGridField = ({ children, onAISend, onRemove, onUpload, }) => {
43
45
  }
44
46
  onAISend === null || onAISend === void 0 ? void 0 : onAISend(form);
45
47
  };
46
- 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 })] }));
47
49
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@homefile/components-v2",
3
- "version": "2.14.28",
3
+ "version": "2.14.29",
4
4
  "author": "Homefile",
5
5
  "license": "UNLICENSED",
6
6
  "typings": "dist/index.d.ts",
@@ -14,7 +14,7 @@ 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
  )
@@ -38,6 +38,9 @@ export const AIGridField = ({
38
38
  : undefined,
39
39
  }
40
40
 
41
+ const imageId = imageField?.id ?? ''
42
+ const imageValue = watch(imageId)
43
+
41
44
  const model = watch(String(textChild?.id))
42
45
 
43
46
  const handleUpload = (files: FolderFileI[]) => {
@@ -64,7 +67,7 @@ export const AIGridField = ({
64
67
  {...imageProps}
65
68
  onUpload={handleUpload}
66
69
  onRemove={onRemove}
67
- value={imageField?.value as string}
70
+ value={String(imageValue)}
68
71
  />
69
72
  <Text fontFamily="secondary" textAlign="center">
70
73
  OR
@@ -77,7 +80,7 @@ export const AIGridField = ({
77
80
  icon={<Plus size={28} stroke={colors.blue[3]} />}
78
81
  onClick={handleAISend}
79
82
  h="input.md"
80
- disabled={!model?.length && !imageField?.value}
83
+ disabled={!model?.length && !imageValue}
81
84
  />
82
85
  </Flex>
83
86
  )