@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.
- package/dist/components/forms/dynamicForm/SimpleDynamicForm.js +25 -23
- package/dist/components/homeItems/HomeItemList.js +1 -1
- package/dist/components/homeItems/ProductRadioCardContent.d.ts +1 -1
- package/dist/components/homeItems/ProductRadioCardContent.js +2 -2
- package/dist/interfaces/homeItems/ProductRadioCardContent.interface.d.ts +1 -1
- package/dist/stories/homeItems/HomeItemList.stories.js +2 -2
- package/package.json +1 -1
- package/src/components/forms/dynamicForm/SimpleDynamicForm.tsx +43 -39
- package/src/components/homeItems/HomeItemList.tsx +1 -1
- package/src/components/homeItems/ProductRadioCardContent.tsx +2 -2
- package/src/interfaces/homeItems/ProductRadioCardContent.interface.ts +1 -1
- package/src/stories/homeItems/HomeItemList.stories.tsx +2 -2
|
@@ -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
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
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
|
-
|
|
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,
|
|
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,
|
|
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:
|
|
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
|
};
|
package/package.json
CHANGED
|
@@ -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
|
-
|
|
22
|
-
|
|
23
|
+
<FormProvider {...form}>
|
|
24
|
+
{fields?.map((field) => {
|
|
25
|
+
const { description, icon, id, name, options, type, value } = field
|
|
23
26
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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'}>{
|
|
18
|
+
<Text fontSize={isNone ? 'md' : 'lg'}>{title}</Text>
|
|
19
19
|
<DetailsColumn
|
|
20
20
|
color="gray.2"
|
|
21
21
|
details={details}
|