@homefile/components-v2 2.11.5 → 2.12.0

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.
@@ -187,7 +187,8 @@
187
187
  },
188
188
  "dynamicForm": {
189
189
  "item": "Name this item",
190
- "myRating": "My Rating"
190
+ "myRating": "My Rating",
191
+ "searching": "Fetching product details, one moment please."
191
192
  },
192
193
  "feedback": {
193
194
  "alt": "Feedback sent",
@@ -16,7 +16,7 @@ import { DocIcon } from '../../../assets/images';
16
16
  import { fileTypes, getFileExtension } from '../../../helpers';
17
17
  export const GridFile = (_a) => {
18
18
  var { menu = [], onClick, onMove } = _a, props = __rest(_a, ["menu", "onClick", "onMove"]);
19
- const { _id, title, updatedAt, files = [], receipt } = props;
19
+ const { _id, title, updatedAt, files = [], receipt, report } = props;
20
20
  const fileExtension = getFileExtension(files, !!receipt);
21
21
  const itemForm = {
22
22
  _id,
@@ -24,5 +24,5 @@ export const GridFile = (_a) => {
24
24
  updatedAt,
25
25
  icon: fileTypes[fileExtension] || DocIcon,
26
26
  };
27
- return (_jsxs(WrapItem, { maxW: "7rem", position: "relative", children: [_jsx(Box, { position: "absolute", top: "0", right: "1", zIndex: "docked", children: _jsx(IconMenuWithMove, { disabled: menu.length < 1 ? true : false, icon: _jsx(MoreHorizontal, { size: 28 }), itemForm: itemForm, menuItems: menu, onMove: () => onMove(itemForm) }) }), _jsx(Button, { variant: "folder", px: "base", pb: "base", pt: "6", onClick: () => onClick(props), children: _jsxs(Stack, { spacing: "1", align: "center", children: [_jsx(Image, { src: fileTypes[fileExtension] || DocIcon, w: "46px", h: "49px", alt: fileExtension, transition: "all 0.2s ease-in-out" }), _jsxs(Box, { children: [_jsx(Text, { isTruncated: true, maxWidth: "5rem", fontSize: "sm", children: title }), _jsx(Text, { variant: "date", children: updatedAt })] })] }) })] }));
27
+ return (_jsxs(WrapItem, { maxW: "7rem", position: "relative", children: [_jsx(Box, { position: "absolute", top: "0", right: "1", zIndex: "docked", children: _jsx(IconMenuWithMove, { disabled: menu.length < 1 ? true : false, icon: _jsx(MoreHorizontal, { size: 28 }), itemForm: itemForm, menuItems: menu, onMove: () => onMove(itemForm) }) }), _jsx(Button, { variant: "folder", px: "base", pb: "base", pt: "6", onClick: () => onClick(props), children: _jsxs(Stack, { spacing: "1", align: "center", children: [_jsx(Image, { src: (report && report.length > 0) ? DocIcon : fileTypes[fileExtension] || DocIcon, w: "46px", h: "49px", alt: fileExtension, transition: "all 0.2s ease-in-out" }), _jsxs(Box, { children: [_jsx(Text, { isTruncated: true, maxWidth: "5rem", fontSize: "sm", children: title }), _jsx(Text, { variant: "date", children: updatedAt })] })] }) })] }));
28
28
  };
@@ -16,7 +16,7 @@ import { DocIcon } from '../../../assets/images';
16
16
  import { fileTypes, getFileExtension } from '../../../helpers';
17
17
  export const ListFile = (_a) => {
18
18
  var { menu = [], onClick, onMove } = _a, props = __rest(_a, ["menu", "onClick", "onMove"]);
19
- const { _id, title, updatedAt, files = [], receipt } = props;
19
+ const { _id, title, updatedAt, files = [], receipt, report } = props;
20
20
  const fileExtension = getFileExtension(files, !!receipt);
21
21
  const itemForm = {
22
22
  _id,
@@ -24,5 +24,5 @@ export const ListFile = (_a) => {
24
24
  updatedAt,
25
25
  icon: fileTypes[fileExtension] || DocIcon,
26
26
  };
27
- return (_jsx(Box, { bg: "neutral.white", w: "100%", transition: "all 0.2s ease-in-out", _hover: { bg: 'lightGreen.1' }, children: _jsxs(Flex, { children: [_jsxs(Flex, { gap: "base", p: "base", as: "button", flex: "1", onClick: () => onClick(props), children: [_jsx(Image, { src: fileTypes[fileExtension] || DocIcon, minW: "32px", h: "auto", alt: fileExtension, transition: "all 0.2s ease-in-out" }), _jsxs(Box, { mt: "-1", children: [_jsx(Text, { variant: "date", textTransform: "uppercase", textAlign: "left", children: fileExtension === '' ? 'Doc' : fileExtension }), _jsx(Text, { textOverflow: "ellipsis", noOfLines: 1, fontSize: "sm", textAlign: "left", children: title })] })] }), _jsxs(Flex, { align: "center", gap: "2", h: "fit-content", p: "1", pr: "base", children: [_jsx(Text, { variant: "date", w: "fit-content", children: updatedAt }), _jsx(IconMenuWithMove, { disabled: menu.length < 1 ? true : false, icon: _jsx(MoreHorizontal, { size: 28 }), itemForm: itemForm, menuItems: menu, onMove: () => onMove(itemForm) })] })] }) }));
27
+ return (_jsx(Box, { bg: "neutral.white", w: "100%", transition: "all 0.2s ease-in-out", _hover: { bg: 'lightGreen.1' }, children: _jsxs(Flex, { children: [_jsxs(Flex, { gap: "base", p: "base", as: "button", flex: "1", onClick: () => onClick(props), children: [_jsx(Image, { src: (report && report.length > 0) ? DocIcon : fileTypes[fileExtension] || DocIcon, minW: "32px", h: "auto", alt: fileExtension, transition: "all 0.2s ease-in-out" }), _jsxs(Box, { mt: "-1", children: [_jsx(Text, { variant: "date", textTransform: "uppercase", textAlign: "left", children: fileExtension === '' ? 'Doc' : fileExtension }), _jsx(Text, { textOverflow: "ellipsis", noOfLines: 1, fontSize: "sm", textAlign: "left", children: title })] })] }), _jsxs(Flex, { align: "center", gap: "2", h: "fit-content", p: "1", pr: "base", children: [_jsx(Text, { variant: "date", w: "fit-content", children: updatedAt }), _jsx(IconMenuWithMove, { disabled: menu.length < 1 ? true : false, icon: _jsx(MoreHorizontal, { size: 28 }), itemForm: itemForm, menuItems: menu, onMove: () => onMove(itemForm) })] })] }) }));
28
28
  };
@@ -1,2 +1,2 @@
1
1
  import { DynamicFormI } from '../../../interfaces';
2
- export declare const DynamicForm: ({ callback, displayImages, form: fields, menuItems, onAISend, onRemoveImage, onUpload, showTitle, title, uploadingFieldId, ...props }: DynamicFormI) => import("react/jsx-runtime").JSX.Element;
2
+ export declare const DynamicForm: ({ callback, displayImages, form: fields, menuItems, onAISend, onRemoveImage, onUpload, searching, showTitle, title, uploadingFieldId, ...props }: DynamicFormI) => import("react/jsx-runtime").JSX.Element;
@@ -14,12 +14,15 @@ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-run
14
14
  import { FormProvider } from 'react-hook-form';
15
15
  import { t } from 'i18next';
16
16
  import { Box, Stack, Text } from '@chakra-ui/react';
17
- import { HiddenFieldSection, GroupField, TextField, TextAreaField, SelectField, RatingField, GridField, FieldWithDelete, FileField, SwitchField, DateField, NumberField, CurrencyField, TileBody, CheckboxGroupField, CheckboxAgreement, AIGridField, } from '../..';
17
+ import { HiddenFieldSection, GroupField, TextField, TextAreaField, SelectField, RatingField, GridField, FieldWithDelete, FileField, SwitchField, DateField, NumberField, CurrencyField, TileBody, CheckboxGroupField, CheckboxAgreement, AIGridField, SearchItemLoader, } from '../..';
18
18
  import { useDynamicForm } from '../../../hooks';
19
19
  import { fieldIcons } from '../../../helpers';
20
20
  export const DynamicForm = (_a) => {
21
- var { callback, displayImages, form: fields, menuItems, onAISend, onRemoveImage, onUpload, showTitle = true, title, uploadingFieldId } = _a, props = __rest(_a, ["callback", "displayImages", "form", "menuItems", "onAISend", "onRemoveImage", "onUpload", "showTitle", "title", "uploadingFieldId"]);
21
+ var { callback, displayImages, form: fields, menuItems, onAISend, onRemoveImage, onUpload, searching = false, showTitle = true, title, uploadingFieldId } = _a, props = __rest(_a, ["callback", "displayImages", "form", "menuItems", "onAISend", "onRemoveImage", "onUpload", "searching", "showTitle", "title", "uploadingFieldId"]);
22
22
  const { form, visibleFields, hiddenFields, handleAddAll, handleAdd, handleFilesUpload, handleRemove, } = useDynamicForm({ fields, onUpload });
23
+ if (searching) {
24
+ return _jsx(SearchItemLoader, {});
25
+ }
23
26
  return (_jsxs(Stack, { bg: "lightBlue.1", spacing: "0", h: "full", overflowX: "hidden", children: [showTitle && (_jsx(Box, { px: "base", pt: "4", pb: "2", borderBottom: "1px dashed", borderColor: "lightBlue.6", children: _jsx(Text, { fontFamily: "secondary", children: title !== null && title !== void 0 ? title : t('forms.itemDetails') }) })), _jsx(FormProvider, Object.assign({}, form, { children: _jsx(_Fragment, { children: visibleFields === null || visibleFields === void 0 ? void 0 : visibleFields.map((field) => {
24
27
  const { canBeHidden, children, description, icon, id, name, options, type, value, } = field;
25
28
  const baseProps = {
@@ -0,0 +1 @@
1
+ export declare const SearchItemLoader: () => import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,8 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { t } from 'i18next';
3
+ import { Box, Text, Stack } from '@chakra-ui/react';
4
+ import { PuffLoader } from 'react-spinners';
5
+ import { colors } from '../../../theme/colors';
6
+ export const SearchItemLoader = () => {
7
+ return (_jsxs(Stack, { spacing: "base", align: "center", mt: "50px", children: [_jsx(PuffLoader, { color: colors.blue[1], size: 50 }), _jsx(Box, { w: "40%", children: _jsx(Text, { fontSize: "sm", textAlign: "center", children: t('dynamicForm.searching') }) })] }));
8
+ };
@@ -4,3 +4,4 @@ export * from './DynamicForm';
4
4
  export * from './SimpleDynamicForm';
5
5
  export * from './HiddenField';
6
6
  export * from './HiddenFieldSection';
7
+ export * from './SearchItemLoader';
@@ -4,3 +4,4 @@ export * from './DynamicForm';
4
4
  export * from './SimpleDynamicForm';
5
5
  export * from './HiddenField';
6
6
  export * from './HiddenFieldSection';
7
+ export * from './SearchItemLoader';
@@ -28,6 +28,7 @@ export interface DynamicFormI extends Partial<PartnerFooterI> {
28
28
  onAISend?: AIGridFieldI['onAISend'];
29
29
  onRemoveImage?: (file: string) => void;
30
30
  onUpload?: (filesByFieldId: Record<string, FolderFileI[]>) => void;
31
+ searching?: boolean;
31
32
  showTitle?: boolean;
32
33
  title?: string;
33
34
  uploadingFieldId?: string;
@@ -23,6 +23,16 @@ export const DisplayFilesMock = [
23
23
  ],
24
24
  updatedAt: '2021-08-01T00:00:00.000Z',
25
25
  receipt: 'receipt',
26
+ // report: [
27
+ // {
28
+ // "name": "Brand/Manufacturer",
29
+ // "description": "",
30
+ // "comments": "",
31
+ // "value": "",
32
+ // "type": "text",
33
+ // "id": "10"
34
+ // }
35
+ // ]
26
36
  },
27
37
  // {
28
38
  // _id: '2',
@@ -28,7 +28,7 @@ export default {
28
28
  },
29
29
  };
30
30
  export const DynamicFormComponent = (args) => {
31
- return (_jsx(Box, { p: "base", bg: "neutral.white", w: ['full', '500px'], children: _jsx(DynamicForm, Object.assign({}, args, { form: formFieldsMock, showTitle: false })) }));
31
+ return (_jsx(Box, { p: "base", bg: "neutral.white", w: ['full', '500px'], minH: "500px", children: _jsx(DynamicForm, Object.assign({}, args, { form: formFieldsMock, showTitle: false })) }));
32
32
  };
33
33
  export const DynamicUIFormComponent = (args) => {
34
34
  return (_jsx(Box, { m: "base", w: ['full', '320px'], children: _jsx(DynamicForm, Object.assign({}, args, { form: tileUIMock, showTitle: false, callback: action('callback') })) }));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@homefile/components-v2",
3
- "version": "2.11.5",
3
+ "version": "2.12.0",
4
4
  "author": "Homefile",
5
5
  "license": "UNLICENSED",
6
6
  "typings": "dist/index.d.ts",
@@ -187,7 +187,8 @@
187
187
  },
188
188
  "dynamicForm": {
189
189
  "item": "Name this item",
190
- "myRating": "My Rating"
190
+ "myRating": "My Rating",
191
+ "searching": "Fetching product details, one moment please."
191
192
  },
192
193
  "feedback": {
193
194
  "alt": "Feedback sent",
@@ -10,7 +10,7 @@ export const GridFile = ({
10
10
  onMove,
11
11
  ...props
12
12
  }: DisplayFileI) => {
13
- const { _id, title, updatedAt, files = [], receipt } = props
13
+ const { _id, title, updatedAt, files = [], receipt, report } = props
14
14
 
15
15
  const fileExtension = getFileExtension(files, !!receipt)
16
16
 
@@ -41,7 +41,7 @@ export const GridFile = ({
41
41
  >
42
42
  <Stack spacing="1" align="center">
43
43
  <Image
44
- src={fileTypes[fileExtension] || DocIcon}
44
+ src={(report && report.length > 0) ? DocIcon : fileTypes[fileExtension] || DocIcon}
45
45
  w="46px"
46
46
  h="49px"
47
47
  alt={fileExtension}
@@ -10,7 +10,7 @@ export const ListFile = ({
10
10
  onMove,
11
11
  ...props
12
12
  }: DisplayFileI) => {
13
- const { _id, title, updatedAt, files = [], receipt } = props
13
+ const { _id, title, updatedAt, files = [], receipt, report } = props
14
14
 
15
15
  const fileExtension = getFileExtension(files, !!receipt)
16
16
 
@@ -37,7 +37,7 @@ export const ListFile = ({
37
37
  onClick={() => onClick(props)}
38
38
  >
39
39
  <Image
40
- src={fileTypes[fileExtension] || DocIcon}
40
+ src={(report && report.length > 0) ? DocIcon : fileTypes[fileExtension] || DocIcon}
41
41
  minW="32px"
42
42
  h="auto"
43
43
  alt={fileExtension}
@@ -20,6 +20,7 @@ import {
20
20
  CheckboxGroupField,
21
21
  CheckboxAgreement,
22
22
  AIGridField,
23
+ SearchItemLoader,
23
24
  } from '@/components'
24
25
  import { useDynamicForm } from '@/hooks'
25
26
  import { fieldIcons } from '@/helpers'
@@ -32,6 +33,7 @@ export const DynamicForm = ({
32
33
  onAISend,
33
34
  onRemoveImage,
34
35
  onUpload,
36
+ searching = false,
35
37
  showTitle = true,
36
38
  title,
37
39
  uploadingFieldId,
@@ -47,6 +49,10 @@ export const DynamicForm = ({
47
49
  handleRemove,
48
50
  } = useDynamicForm({ fields, onUpload })
49
51
 
52
+ if (searching) {
53
+ return <SearchItemLoader />
54
+ }
55
+
50
56
  return (
51
57
  <Stack bg="lightBlue.1" spacing="0" h="full" overflowX="hidden">
52
58
  {showTitle && (
@@ -0,0 +1,17 @@
1
+ import { t } from 'i18next'
2
+ import { Box, Text, Stack } from '@chakra-ui/react'
3
+ import { PuffLoader } from 'react-spinners'
4
+ import { colors } from '@/theme/colors'
5
+
6
+ export const SearchItemLoader = () => {
7
+ return (
8
+ <Stack spacing="base" align="center" mt="50px">
9
+ <PuffLoader color={colors.blue[1]} size={50} />
10
+ <Box w="40%">
11
+ <Text fontSize="sm" textAlign="center">
12
+ {t('dynamicForm.searching')}
13
+ </Text>
14
+ </Box>
15
+ </Stack>
16
+ )
17
+ }
@@ -4,3 +4,4 @@ export * from './DynamicForm'
4
4
  export * from './SimpleDynamicForm'
5
5
  export * from './HiddenField'
6
6
  export * from './HiddenFieldSection'
7
+ export * from './SearchItemLoader'
@@ -136,6 +136,7 @@ export interface DynamicFormI extends Partial<PartnerFooterI> {
136
136
  onAISend?: AIGridFieldI['onAISend']
137
137
  onRemoveImage?: (file: string) => void
138
138
  onUpload?: (filesByFieldId: Record<string, FolderFileI[]>) => void
139
+ searching?: boolean
139
140
  showTitle?: boolean
140
141
  title?: string
141
142
  uploadingFieldId?: string
@@ -25,6 +25,16 @@ export const DisplayFilesMock: FileInfoI[] = [
25
25
  ],
26
26
  updatedAt: '2021-08-01T00:00:00.000Z',
27
27
  receipt: 'receipt',
28
+ // report: [
29
+ // {
30
+ // "name": "Brand/Manufacturer",
31
+ // "description": "",
32
+ // "comments": "",
33
+ // "value": "",
34
+ // "type": "text",
35
+ // "id": "10"
36
+ // }
37
+ // ]
28
38
  },
29
39
  // {
30
40
  // _id: '2',
@@ -32,7 +32,7 @@ export default {
32
32
 
33
33
  export const DynamicFormComponent = (args: DynamicFormI) => {
34
34
  return (
35
- <Box p="base" bg="neutral.white" w={['full', '500px']}>
35
+ <Box p="base" bg="neutral.white" w={['full', '500px']} minH="500px">
36
36
  <DynamicForm {...args} form={formFieldsMock} showTitle={false} />
37
37
  </Box>
38
38
  )