@homefile/components-v2 2.11.0 → 2.11.1

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.
@@ -27,10 +27,13 @@ export const AIGridField = ({ children, onAISend, onRemove, onUpload, }) => {
27
27
  };
28
28
  const code = watch(String(textChild === null || textChild === void 0 ? void 0 : textChild.id));
29
29
  const handleAISend = () => {
30
- const form = {
31
- code,
32
- image: imageField === null || imageField === void 0 ? void 0 : imageField.value,
33
- };
30
+ const form = {};
31
+ if (code) {
32
+ form.code = code;
33
+ }
34
+ else if (imageField === null || imageField === void 0 ? void 0 : imageField.value) {
35
+ form.image = imageField.value;
36
+ }
34
37
  onAISend === null || onAISend === void 0 ? void 0 : onAISend(form);
35
38
  };
36
39
  return (_jsxs(Flex, { align: "center", gap: "base", children: [_jsx(SingleImage, Object.assign({}, imageProps, { onUpload: onUpload, 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: !(code === null || code === void 0 ? void 0 : code.length) && !(imageField === null || imageField === void 0 ? void 0 : imageField.value) })] }));
@@ -7,8 +7,7 @@ export interface GridFieldI {
7
7
  export interface AIGridFieldI extends GridFieldI {
8
8
  onAISend?: (form?: AIFormI) => void;
9
9
  }
10
- interface AIFormI {
10
+ export interface AIFormI {
11
11
  code?: string;
12
12
  image?: string;
13
13
  }
14
- export {};
@@ -1,6 +1,6 @@
1
1
  import { Meta } from '@storybook/react';
2
2
  import { DynamicFormI } from '../../../interfaces';
3
- declare const _default: Meta;
3
+ declare const _default: Meta<DynamicFormI>;
4
4
  export default _default;
5
5
  export declare const DynamicFormComponent: (args: DynamicFormI) => import("react/jsx-runtime").JSX.Element;
6
6
  export declare const DynamicUIFormComponent: (args: DynamicFormI) => import("react/jsx-runtime").JSX.Element;
@@ -19,7 +19,8 @@ export default {
19
19
  faker.image.urlPicsumPhotos(),
20
20
  faker.image.urlPicsumPhotos(),
21
21
  ],
22
- onAiSend: action('onAiSend'),
22
+ onAISend: action('onAiSend'),
23
+ onRemoveImage: action('onRemoveImage'),
23
24
  onUpload: action('onUpload'),
24
25
  menuItems: menuMock,
25
26
  socialLinks: socialLinksMock,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@homefile/components-v2",
3
- "version": "2.11.0",
3
+ "version": "2.11.1",
4
4
  "author": "Homefile",
5
5
  "license": "UNLICENSED",
6
6
  "typings": "dist/index.d.ts",
@@ -1,6 +1,6 @@
1
1
  import { useFormContext } from 'react-hook-form'
2
2
  import { Flex, IconButton, Text } from '@chakra-ui/react'
3
- import { IconTypes, AIGridFieldI } from '@/interfaces'
3
+ import { IconTypes, AIGridFieldI, AIFormI } from '@/interfaces'
4
4
  import { TextField, SingleImage, Plus } from '@/components'
5
5
  import { fieldIcons } from '@/helpers'
6
6
  import { colors } from '@/theme/colors'
@@ -40,9 +40,12 @@ export const AIGridField = ({
40
40
  const code = watch(String(textChild?.id))
41
41
 
42
42
  const handleAISend = () => {
43
- const form = {
44
- code,
45
- image: imageField?.value as string,
43
+ const form: AIFormI = {}
44
+
45
+ if (code) {
46
+ form.code = code
47
+ } else if (imageField?.value) {
48
+ form.image = imageField.value as string
46
49
  }
47
50
  onAISend?.(form)
48
51
  }
@@ -10,7 +10,7 @@ export interface AIGridFieldI extends GridFieldI {
10
10
  onAISend?: (form?: AIFormI) => void
11
11
  }
12
12
 
13
- interface AIFormI {
13
+ export interface AIFormI {
14
14
  code?: string
15
15
  image?: string
16
16
  }
@@ -21,13 +21,14 @@ export default {
21
21
  faker.image.urlPicsumPhotos(),
22
22
  faker.image.urlPicsumPhotos(),
23
23
  ],
24
- onAiSend: action('onAiSend'),
24
+ onAISend: action('onAiSend'),
25
+ onRemoveImage: action('onRemoveImage'),
25
26
  onUpload: action('onUpload'),
26
27
  menuItems: menuMock,
27
28
  socialLinks: socialLinksMock,
28
29
  websiteUrl: 'http://www.audreyscheckdesign.com',
29
30
  },
30
- } as Meta
31
+ } as Meta<DynamicFormI>
31
32
 
32
33
  export const DynamicFormComponent = (args: DynamicFormI) => {
33
34
  return (