@homefile/components-v2 2.27.4 → 2.27.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.
@@ -2,28 +2,30 @@ import { jsx as _jsx } from "react/jsx-runtime";
2
2
  import { Stack } from '@chakra-ui/react';
3
3
  import { TextField, SelectField, SwitchField, NumberField, FieldDivider, } from '../..';
4
4
  import { fieldIcons } from '../../../helpers';
5
+ import { FormProvider, useForm } from 'react-hook-form';
5
6
  export const SimpleDynamicForm = ({ dividerStyle, fields, showIcon = false, height = 'full', boxShadow = 'md', }) => {
6
- return (_jsx(Stack, { bg: "neutral.white", spacing: "0", h: height, boxShadow: boxShadow, children: fields === null || fields === void 0 ? void 0 : fields.map((field) => {
7
- const { description, icon, id, name, options, type, value } = field;
8
- const baseProps = {
9
- description,
10
- id,
11
- value,
12
- icon: icon ? fieldIcons[icon] : undefined,
13
- placeholder: name !== null && name !== void 0 ? name : description,
14
- };
15
- switch (type) {
16
- case 'number':
17
- return (_jsx(FieldDivider, { style: dividerStyle, children: _jsx(NumberField, Object.assign({}, baseProps)) }, id));
18
- case 'text':
19
- case 'string':
20
- return (_jsx(FieldDivider, { style: dividerStyle, children: _jsx(TextField, Object.assign({}, baseProps, { showIcon: showIcon })) }, id));
21
- case 'select':
22
- return (_jsx(FieldDivider, { style: dividerStyle, children: _jsx(SelectField, Object.assign({}, baseProps, { options: options })) }, id));
23
- case 'switch':
24
- return (_jsx(FieldDivider, { style: dividerStyle, children: _jsx(SwitchField, Object.assign({}, baseProps)) }, id));
25
- default:
26
- return null;
27
- }
28
- }) }));
7
+ const form = useForm();
8
+ return (_jsx(Stack, { bg: "neutral.white", spacing: "0", h: height, boxShadow: boxShadow, children: _jsx(FormProvider, Object.assign({}, form, { children: fields === null || fields === void 0 ? void 0 : fields.map((field) => {
9
+ const { description, icon, id, name, options, type, value } = field;
10
+ const baseProps = {
11
+ description,
12
+ id,
13
+ value,
14
+ icon: icon ? fieldIcons[icon] : undefined,
15
+ placeholder: name !== null && name !== void 0 ? name : description,
16
+ };
17
+ switch (type) {
18
+ case 'number':
19
+ return (_jsx(FieldDivider, { style: dividerStyle, children: _jsx(NumberField, Object.assign({}, baseProps)) }, id));
20
+ case 'text':
21
+ case 'string':
22
+ return (_jsx(FieldDivider, { style: dividerStyle, children: _jsx(TextField, Object.assign({}, baseProps, { showIcon: showIcon })) }, id));
23
+ case 'select':
24
+ return (_jsx(FieldDivider, { style: dividerStyle, children: _jsx(SelectField, Object.assign({}, baseProps, { options: options })) }, id));
25
+ case 'switch':
26
+ return (_jsx(FieldDivider, { style: dividerStyle, children: _jsx(SwitchField, Object.assign({}, baseProps)) }, id));
27
+ default:
28
+ return null;
29
+ }
30
+ }) })) }));
29
31
  };
@@ -14,7 +14,7 @@ export const HomeItemList = ({ items, onChange }) => {
14
14
  ...items,
15
15
  {
16
16
  id: 'none',
17
- name: hasItems ? t('homeItems.noneAbove') : t('homeItems.addDetail'),
17
+ title: hasItems ? t('homeItems.noneAbove') : t('homeItems.addDetail'),
18
18
  },
19
19
  ];
20
20
  return (_jsxs(Container, { h: "full", children: [_jsx(HomeItemListHeader, { title: hasItems
@@ -1,2 +1,2 @@
1
1
  import { ProductRadioCardContentI } from '../../interfaces';
2
- export declare const ProductRadioCardContent: ({ id, name, brand, model, }: ProductRadioCardContentI) => import("react/jsx-runtime").JSX.Element;
2
+ export declare const ProductRadioCardContent: ({ id, title, brand, model, }: ProductRadioCardContentI) => import("react/jsx-runtime").JSX.Element;
@@ -1,11 +1,11 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { Stack, Text } from '@chakra-ui/react';
3
3
  import { DetailsColumn } from '..';
4
- export const ProductRadioCardContent = ({ id, name, brand, model, }) => {
4
+ export const ProductRadioCardContent = ({ id, title, brand, model, }) => {
5
5
  const isNone = id === 'none';
6
6
  const details = [
7
7
  brand && { label: 'Brand:', value: brand },
8
8
  model && { label: 'Model#:', value: model },
9
9
  ].filter(Boolean);
10
- return (_jsxs(Stack, { spacing: "base", w: "full", children: [_jsx(Text, { fontSize: isNone ? 'md' : 'lg', children: name }), _jsx(DetailsColumn, { color: "gray.2", details: details, fontSize: "md", leftFlexPercent: 20 })] }));
10
+ return (_jsxs(Stack, { spacing: "base", w: "full", children: [_jsx(Text, { fontSize: isNone ? 'md' : 'lg', children: title }), _jsx(DetailsColumn, { color: "gray.2", details: details, fontSize: "md", leftFlexPercent: 20 })] }));
11
11
  };
@@ -1,6 +1,6 @@
1
1
  export interface ProductRadioCardContentI {
2
2
  id: string;
3
- name?: string;
3
+ title?: string;
4
4
  brand?: string;
5
5
  model?: string;
6
6
  }
@@ -10,13 +10,13 @@ export default {
10
10
  items: [
11
11
  {
12
12
  id: '1',
13
- name: 'Item 1',
13
+ title: 'Item 1',
14
14
  brand: 'Brand A',
15
15
  model: 'Model X',
16
16
  },
17
17
  {
18
18
  id: '2',
19
- name: 'Item 2',
19
+ title: 'Item 2',
20
20
  brand: 'Brand B',
21
21
  model: 'Model Y',
22
22
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@homefile/components-v2",
3
- "version": "2.27.4",
3
+ "version": "2.27.6",
4
4
  "author": "Homefile",
5
5
  "license": "UNLICENSED",
6
6
  "typings": "dist/index.d.ts",
@@ -8,6 +8,7 @@ import {
8
8
  FieldDivider,
9
9
  } from '@/components'
10
10
  import { fieldIcons } from '@/helpers'
11
+ import { FormProvider, useForm } from 'react-hook-form'
11
12
 
12
13
  export const SimpleDynamicForm = ({
13
14
  dividerStyle,
@@ -16,48 +17,51 @@ export const SimpleDynamicForm = ({
16
17
  height = 'full',
17
18
  boxShadow = 'md',
18
19
  }: SimpleDynamicFormI) => {
20
+ const form = useForm()
19
21
  return (
20
22
  <Stack bg="neutral.white" spacing="0" h={height} boxShadow={boxShadow}>
21
- {fields?.map((field) => {
22
- const { description, icon, id, name, options, type, value } = field
23
+ <FormProvider {...form}>
24
+ {fields?.map((field) => {
25
+ const { description, icon, id, name, options, type, value } = field
23
26
 
24
- const baseProps = {
25
- description,
26
- id,
27
- value,
28
- icon: icon ? (fieldIcons[icon] as IconTypes) : undefined,
29
- placeholder: name ?? description,
30
- }
31
- switch (type) {
32
- case 'number':
33
- return (
34
- <FieldDivider key={id} style={dividerStyle}>
35
- <NumberField {...baseProps} />
36
- </FieldDivider>
37
- )
38
- case 'text':
39
- case 'string':
40
- return (
41
- <FieldDivider key={id} style={dividerStyle}>
42
- <TextField {...baseProps} showIcon={showIcon} />
43
- </FieldDivider>
44
- )
45
- case 'select':
46
- return (
47
- <FieldDivider key={id} style={dividerStyle}>
48
- <SelectField {...baseProps} options={options} />
49
- </FieldDivider>
50
- )
51
- case 'switch':
52
- return (
53
- <FieldDivider key={id} style={dividerStyle}>
54
- <SwitchField {...baseProps} />
55
- </FieldDivider>
56
- )
57
- default:
58
- return null
59
- }
60
- })}
27
+ const baseProps = {
28
+ description,
29
+ id,
30
+ value,
31
+ icon: icon ? (fieldIcons[icon] as IconTypes) : undefined,
32
+ placeholder: name ?? description,
33
+ }
34
+ switch (type) {
35
+ case 'number':
36
+ return (
37
+ <FieldDivider key={id} style={dividerStyle}>
38
+ <NumberField {...baseProps} />
39
+ </FieldDivider>
40
+ )
41
+ case 'text':
42
+ case 'string':
43
+ return (
44
+ <FieldDivider key={id} style={dividerStyle}>
45
+ <TextField {...baseProps} showIcon={showIcon} />
46
+ </FieldDivider>
47
+ )
48
+ case 'select':
49
+ return (
50
+ <FieldDivider key={id} style={dividerStyle}>
51
+ <SelectField {...baseProps} options={options} />
52
+ </FieldDivider>
53
+ )
54
+ case 'switch':
55
+ return (
56
+ <FieldDivider key={id} style={dividerStyle}>
57
+ <SwitchField {...baseProps} />
58
+ </FieldDivider>
59
+ )
60
+ default:
61
+ return null
62
+ }
63
+ })}
64
+ </FormProvider>
61
65
  </Stack>
62
66
  )
63
67
  }
@@ -21,7 +21,7 @@ export const HomeItemList = ({ items, onChange }: HomeItemListI) => {
21
21
  ...items,
22
22
  {
23
23
  id: 'none',
24
- name: hasItems ? t('homeItems.noneAbove') : t('homeItems.addDetail'),
24
+ title: hasItems ? t('homeItems.noneAbove') : t('homeItems.addDetail'),
25
25
  },
26
26
  ]
27
27
 
@@ -4,7 +4,7 @@ import { DetailsColumn } from '@/components'
4
4
 
5
5
  export const ProductRadioCardContent = ({
6
6
  id,
7
- name,
7
+ title,
8
8
  brand,
9
9
  model,
10
10
  }: ProductRadioCardContentI) => {
@@ -15,7 +15,7 @@ export const ProductRadioCardContent = ({
15
15
  ].filter(Boolean) as DetailRowI[]
16
16
  return (
17
17
  <Stack spacing="base" w="full">
18
- <Text fontSize={isNone ? 'md' : 'lg'}>{name}</Text>
18
+ <Text fontSize={isNone ? 'md' : 'lg'}>{title}</Text>
19
19
  <DetailsColumn
20
20
  color="gray.2"
21
21
  details={details}
@@ -1,6 +1,6 @@
1
1
  export interface ProductRadioCardContentI {
2
2
  id: string
3
- name?: string
3
+ title?: string
4
4
  brand?: string
5
5
  model?: string
6
6
  }
@@ -12,13 +12,13 @@ export default {
12
12
  items: [
13
13
  {
14
14
  id: '1',
15
- name: 'Item 1',
15
+ title: 'Item 1',
16
16
  brand: 'Brand A',
17
17
  model: 'Model X',
18
18
  },
19
19
  {
20
20
  id: '2',
21
- name: 'Item 2',
21
+ title: 'Item 2',
22
22
  brand: 'Brand B',
23
23
  model: 'Model Y',
24
24
  },