@homefile/components-v2 2.14.1 → 2.14.2

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.
Files changed (50) hide show
  1. package/dist/components/forms/dynamicForm/DynamicForm.js +1 -0
  2. package/dist/components/forms/dynamicForm/fields/CurrencyField.d.ts +1 -1
  3. package/dist/components/forms/dynamicForm/fields/CurrencyField.js +2 -2
  4. package/dist/components/forms/dynamicForm/fields/DateField.d.ts +1 -1
  5. package/dist/components/forms/dynamicForm/fields/DateField.js +2 -2
  6. package/dist/components/forms/dynamicForm/fields/GridField.js +2 -1
  7. package/dist/components/forms/dynamicForm/fields/LabeledField.d.ts +1 -1
  8. package/dist/components/forms/dynamicForm/fields/NumberField.d.ts +1 -1
  9. package/dist/components/forms/dynamicForm/fields/NumberField.js +2 -2
  10. package/dist/components/forms/dynamicForm/fields/SelectField.d.ts +1 -1
  11. package/dist/components/forms/dynamicForm/fields/SelectField.js +2 -2
  12. package/dist/components/forms/dynamicForm/fields/SingleFields.js +1 -0
  13. package/dist/components/forms/dynamicForm/fields/TextAreaField.d.ts +1 -1
  14. package/dist/components/forms/dynamicForm/fields/TextAreaField.js +2 -2
  15. package/dist/components/forms/dynamicForm/fields/TextField.d.ts +1 -1
  16. package/dist/components/forms/dynamicForm/fields/TextField.js +2 -2
  17. package/dist/components/inputs/DatePicker.d.ts +1 -1
  18. package/dist/components/inputs/DatePicker.js +2 -2
  19. package/dist/components/inputs/SelectInput.d.ts +1 -1
  20. package/dist/components/inputs/SelectInput.js +2 -2
  21. package/dist/components/inputs/TextInput.d.ts +1 -1
  22. package/dist/components/inputs/TextInput.js +2 -2
  23. package/dist/interfaces/forms/dynamicForm/fields/DateField.interface.d.ts +1 -0
  24. package/dist/interfaces/forms/dynamicForm/fields/SelectField.interface.d.ts +1 -0
  25. package/dist/interfaces/forms/dynamicForm/fields/TextAreaField.interface.d.ts +1 -0
  26. package/dist/interfaces/forms/dynamicForm/fields/TextField.interface.d.ts +1 -0
  27. package/dist/interfaces/inputs/DatePicker.interface.d.ts +1 -0
  28. package/dist/interfaces/inputs/Input.interface.d.ts +1 -0
  29. package/dist/interfaces/inputs/Select.interface.d.ts +1 -0
  30. package/package.json +1 -1
  31. package/src/components/forms/dynamicForm/DynamicForm.tsx +1 -0
  32. package/src/components/forms/dynamicForm/fields/CurrencyField.tsx +9 -3
  33. package/src/components/forms/dynamicForm/fields/DateField.tsx +2 -0
  34. package/src/components/forms/dynamicForm/fields/GridField.tsx +2 -1
  35. package/src/components/forms/dynamicForm/fields/LabeledField.tsx +1 -1
  36. package/src/components/forms/dynamicForm/fields/NumberField.tsx +3 -10
  37. package/src/components/forms/dynamicForm/fields/SelectField.tsx +3 -3
  38. package/src/components/forms/dynamicForm/fields/SingleFields.tsx +1 -0
  39. package/src/components/forms/dynamicForm/fields/TextAreaField.tsx +3 -4
  40. package/src/components/forms/dynamicForm/fields/TextField.tsx +2 -1
  41. package/src/components/inputs/DatePicker.tsx +2 -1
  42. package/src/components/inputs/SelectInput.tsx +2 -3
  43. package/src/components/inputs/TextInput.tsx +2 -1
  44. package/src/interfaces/forms/dynamicForm/fields/DateField.interface.ts +1 -0
  45. package/src/interfaces/forms/dynamicForm/fields/SelectField.interface.ts +1 -0
  46. package/src/interfaces/forms/dynamicForm/fields/TextAreaField.interface.ts +1 -0
  47. package/src/interfaces/forms/dynamicForm/fields/TextField.interface.ts +1 -0
  48. package/src/interfaces/inputs/DatePicker.interface.ts +1 -0
  49. package/src/interfaces/inputs/Input.interface.ts +1 -0
  50. package/src/interfaces/inputs/Select.interface.ts +1 -0
@@ -30,6 +30,7 @@ export const DynamicForm = (_a) => {
30
30
  value,
31
31
  icon: icon ? fieldIcons[icon] : undefined,
32
32
  placeholder: Boolean(name) ? name : description,
33
+ label: name !== null && name !== void 0 ? name : description,
33
34
  };
34
35
  const fieldWithDeleteBaseProps = {
35
36
  id,
@@ -1,2 +1,2 @@
1
1
  import { TextFieldI } from '../../../../interfaces';
2
- export declare const CurrencyField: ({ id, icon, placeholder, value }: TextFieldI) => import("react/jsx-runtime").JSX.Element;
2
+ export declare const CurrencyField: ({ label, id, icon, placeholder, value, }: TextFieldI) => import("react/jsx-runtime").JSX.Element;
@@ -3,7 +3,7 @@ import { Controller, useFormContext } from 'react-hook-form';
3
3
  import { Flex, Input } from '@chakra-ui/react';
4
4
  import { FormIcon, LabeledField } from '../../..';
5
5
  import { formatCurrency } from '../../../../utils';
6
- export const CurrencyField = ({ id, icon, placeholder, value }) => {
6
+ export const CurrencyField = ({ label, id, icon, placeholder, value, }) => {
7
7
  const { control } = useFormContext();
8
8
  return (_jsxs(Flex, { align: "center", gap: "base", flex: "auto", children: [_jsx(FormIcon, { icon: icon }), _jsx(Controller, { control: control, name: id, defaultValue: value, render: ({ field: { value, onChange } }) => {
9
9
  const handleChange = (e) => {
@@ -12,6 +12,6 @@ export const CurrencyField = ({ id, icon, placeholder, value }) => {
12
12
  const currency = formatCurrency({ value: number });
13
13
  onChange(currency);
14
14
  };
15
- return (_jsx(LabeledField, { label: String(placeholder), children: _jsx(Input, { onChange: handleChange, placeholder: placeholder, textAlign: "right", value: value, _placeholder: { color: 'gray.2' } }) }));
15
+ return (_jsx(LabeledField, { label: label, children: _jsx(Input, { onChange: handleChange, placeholder: placeholder, textAlign: "right", value: value, _placeholder: { color: 'gray.2' } }) }));
16
16
  } })] }));
17
17
  };
@@ -1,2 +1,2 @@
1
1
  import { DateFieldI } from '../../../../interfaces';
2
- export declare const DateField: ({ id, icon, name, placeholder, showCalendarIcon, value, width, }: DateFieldI) => import("react/jsx-runtime").JSX.Element;
2
+ export declare const DateField: ({ id, icon, name, placeholder, label, showCalendarIcon, value, width, }: DateFieldI) => import("react/jsx-runtime").JSX.Element;
@@ -2,9 +2,9 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { Controller, useFormContext } from 'react-hook-form';
3
3
  import { Flex, Text } from '@chakra-ui/react';
4
4
  import { DatePicker, FormIcon } from '../../..';
5
- export const DateField = ({ id, icon, name, placeholder, showCalendarIcon = true, value, width, }) => {
5
+ export const DateField = ({ id, icon, name, placeholder, label, showCalendarIcon = true, value, width, }) => {
6
6
  const { control } = useFormContext();
7
7
  return (_jsxs(Flex, { align: "center", gap: "base", w: "full", children: [name && (_jsxs(Flex, { align: "center", gap: "base", flexShrink: 0, children: [_jsx(FormIcon, { icon: icon }), _jsx(Text, { fontFamily: "secondary", noOfLines: 1, overflow: "hidden", children: name })] })), _jsx(Controller, { control: control, name: id, defaultValue: value, render: ({ field: { value, onChange } }) => {
8
- return (_jsx(DatePicker, { onChange: onChange, showCalendarIcon: showCalendarIcon, placeholder: name ? '' : placeholder, value: value, width: width }));
8
+ return (_jsx(DatePicker, { onChange: onChange, showCalendarIcon: showCalendarIcon, placeholder: name ? '' : placeholder, value: value, width: width, label: label }));
9
9
  } })] }));
10
10
  };
@@ -8,7 +8,8 @@ export const GridField = ({ children, onRemove, onUpload }) => {
8
8
  const baseProps = {
9
9
  id,
10
10
  value,
11
- placeholder: name && name !== '' ? name : description,
11
+ placeholder: name !== null && name !== void 0 ? name : description,
12
+ label: name !== null && name !== void 0 ? name : description,
12
13
  icon: icon ? fieldIcons[icon] : undefined,
13
14
  };
14
15
  switch (type) {
@@ -1,6 +1,6 @@
1
1
  interface LabeledFieldProps {
2
2
  children: React.ReactNode;
3
- label: string;
3
+ label?: string;
4
4
  }
5
5
  export declare const LabeledField: ({ label, children }: LabeledFieldProps) => import("react/jsx-runtime").JSX.Element;
6
6
  export {};
@@ -1,2 +1,2 @@
1
1
  import { TextFieldI } from '../../../../interfaces';
2
- export declare const NumberField: ({ description, id, icon, placeholder, value, }: TextFieldI) => import("react/jsx-runtime").JSX.Element;
2
+ export declare const NumberField: ({ id, label, placeholder, value }: TextFieldI) => import("react/jsx-runtime").JSX.Element;
@@ -2,10 +2,10 @@ import { jsx as _jsx } from "react/jsx-runtime";
2
2
  import { Controller, useFormContext } from 'react-hook-form';
3
3
  import { Flex, Input } from '@chakra-ui/react';
4
4
  import { LabeledField } from '../../..';
5
- export const NumberField = ({ description, id, icon, placeholder, value, }) => {
5
+ export const NumberField = ({ id, label, placeholder, value }) => {
6
6
  const { control } = useFormContext();
7
7
  return (_jsx(Flex, { align: "center", gap: "base", flex: "auto", children: _jsx(Controller, { control: control, name: id, defaultValue: value, render: ({ field: { value, onChange } }) => {
8
- return (_jsx(LabeledField, { label: String(!description && placeholder), children: _jsx(Input, { onChange: (e) => {
8
+ return (_jsx(LabeledField, { label: label, children: _jsx(Input, { onChange: (e) => {
9
9
  const value = e.target.valueAsNumber;
10
10
  const isNumber = !isNaN(value);
11
11
  if (!isNumber) {
@@ -1,2 +1,2 @@
1
1
  import { SelectFieldI } from '../../../../interfaces';
2
- export declare const SelectField: ({ description, id, icon, options, placeholder, value, }: SelectFieldI) => import("react/jsx-runtime").JSX.Element;
2
+ export declare const SelectField: ({ description, id, label, options, placeholder, value, }: SelectFieldI) => import("react/jsx-runtime").JSX.Element;
@@ -2,11 +2,11 @@ import { jsx as _jsx } from "react/jsx-runtime";
2
2
  import { Controller, useFormContext } from 'react-hook-form';
3
3
  import { Box, Flex } from '@chakra-ui/react';
4
4
  import { SelectInput } from '../../..';
5
- export const SelectField = ({ description, id, icon, options, placeholder, value, }) => {
5
+ export const SelectField = ({ description, id, label, options, placeholder, value, }) => {
6
6
  var _a;
7
7
  const { control } = useFormContext();
8
8
  const stringOptions = (_a = options === null || options === void 0 ? void 0 : options.map((option) => String(option))) !== null && _a !== void 0 ? _a : [];
9
9
  return (_jsx(Flex, { align: "start", gap: "base", flex: "auto", w: description ? '100%' : '40%', children: _jsx(Box, { w: description ? '102px' : '100%', children: _jsx(Controller, { control: control, name: id, defaultValue: value, render: ({ field: { value, onChange } }) => {
10
- return (_jsx(SelectInput, { handleClick: onChange, height: "md", initialValue: value !== null && value !== void 0 ? value : stringOptions[0], items: stringOptions, placeholder: !description ? placeholder : '', width: "100%" }));
10
+ return (_jsx(SelectInput, { handleClick: onChange, height: "md", initialValue: value !== null && value !== void 0 ? value : stringOptions[0], items: stringOptions, placeholder: !description ? placeholder : '', label: label, width: "100%" }));
11
11
  } }) }) }));
12
12
  };
@@ -8,6 +8,7 @@ export const SingleFields = ({ callback, fields, menuItems }) => {
8
8
  id,
9
9
  icon: icon ? fieldIcons[icon] : undefined,
10
10
  placeholder: name,
11
+ label: name,
11
12
  value,
12
13
  };
13
14
  switch (type) {
@@ -1,4 +1,4 @@
1
1
  import { TextAreaFieldI } from '../../../../interfaces';
2
2
  import 'react-quill-new/dist/quill.snow.css';
3
3
  import '../../../../styles/quill.css';
4
- export declare const TextAreaField: ({ id, icon, placeholder, value, }: TextAreaFieldI) => import("react/jsx-runtime").JSX.Element;
4
+ export declare const TextAreaField: ({ id, label, placeholder, value, }: TextAreaFieldI) => import("react/jsx-runtime").JSX.Element;
@@ -5,10 +5,10 @@ import QuillEditor from 'react-quill-new';
5
5
  import 'react-quill-new/dist/quill.snow.css';
6
6
  import '../../../../styles/quill.css';
7
7
  import { LabeledField } from './LabeledField';
8
- export const TextAreaField = ({ id, icon, placeholder = '', value, }) => {
8
+ export const TextAreaField = ({ id, label, placeholder = '', value, }) => {
9
9
  const { control } = useFormContext();
10
10
  return (_jsx(Flex, { gap: "base", align: "start", flex: "auto", children: _jsx(Controller, { control: control, name: id, defaultValue: value, render: ({ field: { value, onChange } }) => {
11
- return (_jsx(LabeledField, { label: placeholder, children: _jsx(QuillEditor, { theme: "snow", value: value, formats: formats, modules: { toolbar }, onChange: onChange, placeholder: placeholder }) }));
11
+ return (_jsx(LabeledField, { label: label, children: _jsx(QuillEditor, { theme: "snow", value: value, formats: formats, modules: { toolbar }, onChange: onChange, placeholder: placeholder }) }));
12
12
  } }) }));
13
13
  };
14
14
  const formats = [
@@ -1,2 +1,2 @@
1
1
  import { TextFieldI } from '../../../../interfaces';
2
- export declare const TextField: ({ id, icon, placeholder, type, value, }: TextFieldI) => import("react/jsx-runtime").JSX.Element;
2
+ export declare const TextField: ({ id, placeholder, label, type, value, }: TextFieldI) => import("react/jsx-runtime").JSX.Element;
@@ -2,9 +2,9 @@ import { jsx as _jsx } from "react/jsx-runtime";
2
2
  import { Controller, useFormContext } from 'react-hook-form';
3
3
  import { Flex } from '@chakra-ui/react';
4
4
  import { TextInput } from '../../..';
5
- export const TextField = ({ id, icon, placeholder = '', type = 'text', value, }) => {
5
+ export const TextField = ({ id, placeholder = '', label, type = 'text', value, }) => {
6
6
  const { control } = useFormContext();
7
7
  return (_jsx(Flex, { align: "center", gap: "base", flex: "auto", children: _jsx(Controller, { control: control, name: id, defaultValue: value, render: ({ field: { value, onChange } }) => {
8
- return (_jsx(TextInput, { handleChange: onChange, placeholder: placeholder, type: type, value: value }));
8
+ return (_jsx(TextInput, { handleChange: onChange, placeholder: placeholder, type: type, value: value, label: label }));
9
9
  } }) }));
10
10
  };
@@ -1,4 +1,4 @@
1
1
  import 'react-datepicker/dist/react-datepicker.css';
2
2
  import '../../styles/calendar.css';
3
3
  import { DatePickerI } from '../../interfaces';
4
- export declare const DatePicker: ({ onChange, placeholder, showCalendarIcon, value, width, }: DatePickerI) => import("react/jsx-runtime").JSX.Element;
4
+ export declare const DatePicker: ({ onChange, placeholder, label, showCalendarIcon, value, width, }: DatePickerI) => import("react/jsx-runtime").JSX.Element;
@@ -7,7 +7,7 @@ import { Flex, IconButton, Input } from '@chakra-ui/react';
7
7
  import { Calendar as CalendarIcon, LabeledField } from '..';
8
8
  import { colors } from '../../theme/colors';
9
9
  import { extractDayMonthYear, joinDayMonthYear } from '../../utils';
10
- export const DatePicker = ({ onChange, placeholder, showCalendarIcon, value, width = '290px', }) => {
10
+ export const DatePicker = ({ onChange, placeholder, label, showCalendarIcon, value, width = '290px', }) => {
11
11
  const formatedValue = extractDayMonthYear(value);
12
12
  const [day, setDay] = useState(formatedValue
13
13
  ? new Date(formatedValue.year, formatedValue.month - 1, formatedValue.day)
@@ -38,7 +38,7 @@ export const DatePicker = ({ onChange, placeholder, showCalendarIcon, value, wid
38
38
  }
39
39
  }, [value]);
40
40
  const renderCustomInput = () => {
41
- return (_jsxs(Flex, { gap: "base", w: width, children: [_jsx(LabeledField, { label: String(placeholder), children: _jsx(Input, { placeholder: placeholder || 'MM/DD/YYYY', onChange: handleInputChange, _placeholder: { color: 'gray.2' }, value: value }) }), showCalendarIcon && (_jsx(IconButton, { "aria-label": "Calendar icon", variant: "iconOutlined", icon: _jsx(CalendarIcon, { size: 28, stroke: colors.blue[3] }), maxH: "input.md", flexShrink: 0 }))] }));
41
+ return (_jsxs(Flex, { gap: "base", w: width, children: [_jsx(LabeledField, { label: label, children: _jsx(Input, { placeholder: placeholder || 'MM/DD/YYYY', onChange: handleInputChange, _placeholder: { color: 'gray.2' }, value: value }) }), showCalendarIcon && (_jsx(IconButton, { "aria-label": "Calendar icon", variant: "iconOutlined", icon: _jsx(CalendarIcon, { size: 28, stroke: colors.blue[3] }), maxH: "input.md", flexShrink: 0 }))] }));
42
42
  };
43
43
  return (_jsx(DatePickerComponent, { selected: day, onChange: handleOnChange, customInput: renderCustomInput(), calendarClassName: "custom-calendar" }));
44
44
  };
@@ -1,2 +1,2 @@
1
1
  import { SelectI } from '../../interfaces';
2
- export declare const SelectInput: ({ filterValue, handleClick, handleFilter, hasFilter, height, initialValue, isDisabled, items, placeholder, variant, width, }: SelectI) => import("react/jsx-runtime").JSX.Element;
2
+ export declare const SelectInput: ({ filterValue, handleClick, handleFilter, hasFilter, height, initialValue, isDisabled, items, label, variant, width, }: SelectI) => import("react/jsx-runtime").JSX.Element;
@@ -5,12 +5,12 @@ import { Menu, Text, Input, InputGroup, InputRightElement, Box, } from '@chakra-
5
5
  import { textOptionVariants } from '../../helpers';
6
6
  import { LabeledField, SearchIcon, SelectButton, SelectItem, SelectList, } from '..';
7
7
  import { colors } from '../../theme/colors';
8
- export const SelectInput = ({ filterValue = '', handleClick, handleFilter = () => null, hasFilter, height = 'sm', initialValue = 'All', isDisabled, items, placeholder, variant = 'primary', width = '10rem', }) => {
8
+ export const SelectInput = ({ filterValue = '', handleClick, handleFilter = () => null, hasFilter, height = 'sm', initialValue = 'All', isDisabled, items, label, variant = 'primary', width = '10rem', }) => {
9
9
  const [selectedValue, setSelectedValue] = useState(initialValue);
10
10
  useEffect(() => {
11
11
  setSelectedValue(initialValue);
12
12
  }, [initialValue]);
13
- return (_jsxs(Menu, { children: [_jsx(LabeledField, { label: String(placeholder), children: _jsx(Box, { w: "100%", children: _jsx(SelectButton, { selectedValue: selectedValue, height: height, isDisabled: isDisabled, variant: variant, width: width }) }) }), _jsxs(SelectList, { children: [hasFilter && (_jsxs(InputGroup, { size: "md", w: "100%", px: "2", pb: "2", children: [_jsx(Input, { variant: "filled", bg: "lightBlue.2", pr: "4.5rem", placeholder: t('forms.search'), value: String(filterValue), onChange: handleFilter }), _jsx(InputRightElement, { mr: "base", children: _jsx(SearchIcon, { size: 26, stroke: colors.gray[3] }) })] })), items === null || items === void 0 ? void 0 : items.map((item) => {
13
+ return (_jsxs(Menu, { children: [_jsx(LabeledField, { label: label, children: _jsx(Box, { w: "100%", children: _jsx(SelectButton, { selectedValue: selectedValue, height: height, isDisabled: isDisabled, variant: variant, width: width }) }) }), _jsxs(SelectList, { children: [hasFilter && (_jsxs(InputGroup, { size: "md", w: "100%", px: "2", pb: "2", children: [_jsx(Input, { variant: "filled", bg: "lightBlue.2", pr: "4.5rem", placeholder: t('forms.search'), value: String(filterValue), onChange: handleFilter }), _jsx(InputRightElement, { mr: "base", children: _jsx(SearchIcon, { size: 26, stroke: colors.gray[3] }) })] })), items === null || items === void 0 ? void 0 : items.map((item) => {
14
14
  const isSelectItem = typeof item === 'object';
15
15
  const id = isSelectItem ? item._id : item;
16
16
  const name = isSelectItem ? item.name : item;
@@ -1,2 +1,2 @@
1
1
  import { InputI } from '../../interfaces';
2
- export declare const TextInput: ({ autoCapitalize, autoCorrect, errorMessage, handleChange, hasError, id, isDisabled, placeholder, value, type, ...props }: InputI) => import("react/jsx-runtime").JSX.Element;
2
+ export declare const TextInput: ({ autoCapitalize, autoCorrect, errorMessage, handleChange, hasError, id, isDisabled, label, placeholder, value, type, ...props }: InputI) => import("react/jsx-runtime").JSX.Element;
@@ -13,7 +13,7 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
13
13
  import { FormControl, Text, Input } from '@chakra-ui/react';
14
14
  import { LabeledField } from '..';
15
15
  export const TextInput = (_a) => {
16
- var { autoCapitalize = 'on', autoCorrect = 'on', errorMessage, handleChange, hasError, id, isDisabled, placeholder, value = '', type = 'text' } = _a, props = __rest(_a, ["autoCapitalize", "autoCorrect", "errorMessage", "handleChange", "hasError", "id", "isDisabled", "placeholder", "value", "type"]);
16
+ var { autoCapitalize = 'on', autoCorrect = 'on', errorMessage, handleChange, hasError, id, isDisabled, label, placeholder, value = '', type = 'text' } = _a, props = __rest(_a, ["autoCapitalize", "autoCorrect", "errorMessage", "handleChange", "hasError", "id", "isDisabled", "label", "placeholder", "value", "type"]);
17
17
  const error = hasError && !isDisabled;
18
- return (_jsxs(FormControl, { isInvalid: error, children: [_jsx(LabeledField, { label: placeholder, children: _jsx(Input, Object.assign({}, props, { autoCapitalize: autoCapitalize, autoCorrect: autoCorrect, id: id, placeholder: placeholder, value: value, type: type, onChange: handleChange, isInvalid: error, isDisabled: isDisabled, _placeholder: { color: 'gray.2' } })) }), error && _jsx(Text, { variant: "error", children: errorMessage })] }));
18
+ return (_jsxs(FormControl, { isInvalid: error, children: [_jsx(LabeledField, { label: label, children: _jsx(Input, Object.assign({}, props, { autoCapitalize: autoCapitalize, autoCorrect: autoCorrect, id: id, placeholder: placeholder, value: value, type: type, onChange: handleChange, isInvalid: error, isDisabled: isDisabled, _placeholder: { color: 'gray.2' } })) }), error && _jsx(Text, { variant: "error", children: errorMessage })] }));
19
19
  };
@@ -4,6 +4,7 @@ export interface DateFieldI {
4
4
  icon?: string;
5
5
  name?: string;
6
6
  placeholder?: string;
7
+ label?: string;
7
8
  showCalendarIcon?: boolean;
8
9
  type?: 'text' | 'email' | 'password' | 'number' | 'tel';
9
10
  value: ReportI['value'];
@@ -3,5 +3,6 @@ export interface SelectFieldI extends FieldDescriptionI {
3
3
  id: string;
4
4
  options: ReportI['options'];
5
5
  placeholder?: string;
6
+ label?: string;
6
7
  value: ReportI['value'];
7
8
  }
@@ -2,6 +2,7 @@ import { ReportI } from '../../..';
2
2
  export interface TextAreaFieldI {
3
3
  id: string;
4
4
  icon?: string;
5
+ label?: string;
5
6
  placeholder?: string;
6
7
  value: ReportI['value'];
7
8
  }
@@ -2,6 +2,7 @@ import { FieldDescriptionI, ReportI } from '../../..';
2
2
  export interface TextFieldI extends FieldDescriptionI {
3
3
  id: string;
4
4
  placeholder?: string;
5
+ label?: string;
5
6
  type?: 'text' | 'email' | 'password' | 'number' | 'tel';
6
7
  value: ReportI['value'];
7
8
  }
@@ -1,6 +1,7 @@
1
1
  export interface DatePickerI {
2
2
  onChange: (date: string) => void;
3
3
  placeholder?: string;
4
+ label?: string;
4
5
  showCalendarIcon?: boolean;
5
6
  value: string;
6
7
  width?: string;
@@ -6,6 +6,7 @@ export interface InputI extends InputProps {
6
6
  handleChange: (event: React.ChangeEvent<HTMLInputElement>) => void;
7
7
  hasError?: boolean;
8
8
  id?: string;
9
+ label?: string;
9
10
  isDisabled?: boolean;
10
11
  placeholder: string;
11
12
  value: string;
@@ -11,6 +11,7 @@ export interface SelectI {
11
11
  initialValue?: string;
12
12
  isDisabled?: boolean;
13
13
  items: SelectItemI[] | string[];
14
+ label?: string;
14
15
  placeholder?: string;
15
16
  width?: string;
16
17
  variant?: 'primary' | 'secondary' | 'tertiary' | 'accountType';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@homefile/components-v2",
3
- "version": "2.14.1",
3
+ "version": "2.14.2",
4
4
  "author": "Homefile",
5
5
  "license": "UNLICENSED",
6
6
  "typings": "dist/index.d.ts",
@@ -86,6 +86,7 @@ export const DynamicForm = ({
86
86
  value,
87
87
  icon: icon ? (fieldIcons[icon] as IconTypes) : undefined,
88
88
  placeholder: Boolean(name) ? name : description,
89
+ label: name ?? description,
89
90
  }
90
91
  const fieldWithDeleteBaseProps = {
91
92
  id,
@@ -1,10 +1,16 @@
1
1
  import { Controller, useFormContext } from 'react-hook-form'
2
- import { Flex, Input, Tooltip } from '@chakra-ui/react'
2
+ import { Flex, Input } from '@chakra-ui/react'
3
3
  import { TextFieldI } from '@/interfaces'
4
4
  import { FormIcon, LabeledField } from '@/components'
5
5
  import { formatCurrency } from '@/utils'
6
6
 
7
- export const CurrencyField = ({ id, icon, placeholder, value }: TextFieldI) => {
7
+ export const CurrencyField = ({
8
+ label,
9
+ id,
10
+ icon,
11
+ placeholder,
12
+ value,
13
+ }: TextFieldI) => {
8
14
  const { control } = useFormContext()
9
15
 
10
16
  return (
@@ -22,7 +28,7 @@ export const CurrencyField = ({ id, icon, placeholder, value }: TextFieldI) => {
22
28
  onChange(currency)
23
29
  }
24
30
  return (
25
- <LabeledField label={String(placeholder)}>
31
+ <LabeledField label={label}>
26
32
  <Input
27
33
  onChange={handleChange}
28
34
  placeholder={placeholder}
@@ -8,6 +8,7 @@ export const DateField = ({
8
8
  icon,
9
9
  name,
10
10
  placeholder,
11
+ label,
11
12
  showCalendarIcon = true,
12
13
  value,
13
14
  width,
@@ -37,6 +38,7 @@ export const DateField = ({
37
38
  placeholder={name ? '' : placeholder}
38
39
  value={value}
39
40
  width={width}
41
+ label={label}
40
42
  />
41
43
  )
42
44
  }}
@@ -18,7 +18,8 @@ export const GridField = ({ children, onRemove, onUpload }: GridFieldI) => {
18
18
  const baseProps = {
19
19
  id,
20
20
  value,
21
- placeholder: name && name !== '' ? name : description,
21
+ placeholder: name ?? description,
22
+ label: name ?? description,
22
23
  icon: icon ? (fieldIcons[icon] as IconTypes) : undefined,
23
24
  }
24
25
 
@@ -2,7 +2,7 @@ import { Box, Text, Flex, Image } from '@chakra-ui/react'
2
2
 
3
3
  interface LabeledFieldProps {
4
4
  children: React.ReactNode
5
- label: string
5
+ label?: string
6
6
  }
7
7
 
8
8
  export const LabeledField = ({ label, children }: LabeledFieldProps) => {
@@ -1,26 +1,19 @@
1
1
  import { Controller, useFormContext } from 'react-hook-form'
2
2
  import { Flex, Input } from '@chakra-ui/react'
3
3
  import { TextFieldI } from '@/interfaces'
4
- import { FieldDescription, LabeledField } from '@/components'
4
+ import { LabeledField } from '@/components'
5
5
 
6
- export const NumberField = ({
7
- description,
8
- id,
9
- icon,
10
- placeholder,
11
- value,
12
- }: TextFieldI) => {
6
+ export const NumberField = ({ id, label, placeholder, value }: TextFieldI) => {
13
7
  const { control } = useFormContext()
14
8
  return (
15
9
  <Flex align="center" gap="base" flex="auto">
16
- {/* <FieldDescription description={description} icon={icon} /> */}
17
10
  <Controller
18
11
  control={control}
19
12
  name={id}
20
13
  defaultValue={value}
21
14
  render={({ field: { value, onChange } }) => {
22
15
  return (
23
- <LabeledField label={String(!description && placeholder)}>
16
+ <LabeledField label={label}>
24
17
  <Input
25
18
  onChange={(e) => {
26
19
  const value = e.target.valueAsNumber
@@ -1,12 +1,12 @@
1
1
  import { Controller, useFormContext } from 'react-hook-form'
2
2
  import { Box, Flex } from '@chakra-ui/react'
3
- import { FieldDescription, SelectInput } from '@/components'
3
+ import { SelectInput } from '@/components'
4
4
  import { SelectFieldI } from '@/interfaces'
5
5
 
6
6
  export const SelectField = ({
7
7
  description,
8
8
  id,
9
- icon,
9
+ label,
10
10
  options,
11
11
  placeholder,
12
12
  value,
@@ -15,7 +15,6 @@ export const SelectField = ({
15
15
  const stringOptions = options?.map((option) => String(option)) ?? []
16
16
  return (
17
17
  <Flex align="start" gap="base" flex="auto" w={description ? '100%' : '40%'}>
18
- {/* <FieldDescription description={description} icon={icon} /> */}
19
18
  <Box w={description ? '102px' : '100%'}>
20
19
  <Controller
21
20
  control={control}
@@ -29,6 +28,7 @@ export const SelectField = ({
29
28
  initialValue={value ?? stringOptions[0]}
30
29
  items={stringOptions}
31
30
  placeholder={!description ? placeholder : ''}
31
+ label={label}
32
32
  width="100%"
33
33
  />
34
34
  )
@@ -37,6 +37,7 @@ export const SingleFields = ({ callback, fields, menuItems }: FieldTypesI) => {
37
37
  id,
38
38
  icon: icon ? fieldIcons[icon] : undefined,
39
39
  placeholder: name,
40
+ label: name,
40
41
  value,
41
42
  }
42
43
  switch (type) {
@@ -1,5 +1,5 @@
1
1
  import { useFormContext, Controller } from 'react-hook-form'
2
- import { Flex, Image } from '@chakra-ui/react'
2
+ import { Flex } from '@chakra-ui/react'
3
3
  import QuillEditor from 'react-quill-new'
4
4
  import { TextAreaFieldI } from '@/interfaces'
5
5
  import 'react-quill-new/dist/quill.snow.css'
@@ -8,21 +8,20 @@ import { LabeledField } from './LabeledField'
8
8
 
9
9
  export const TextAreaField = ({
10
10
  id,
11
- icon,
11
+ label,
12
12
  placeholder = '',
13
13
  value,
14
14
  }: TextAreaFieldI) => {
15
15
  const { control } = useFormContext()
16
16
  return (
17
17
  <Flex gap="base" align="start" flex="auto">
18
- {/* {icon && <Image h="auto" w="icon.md" src={icon} marginTop="2" />} */}
19
18
  <Controller
20
19
  control={control}
21
20
  name={id}
22
21
  defaultValue={value}
23
22
  render={({ field: { value, onChange } }) => {
24
23
  return (
25
- <LabeledField label={placeholder}>
24
+ <LabeledField label={label}>
26
25
  <QuillEditor
27
26
  theme="snow"
28
27
  value={value}
@@ -5,8 +5,8 @@ import { TextFieldI } from '@/interfaces'
5
5
 
6
6
  export const TextField = ({
7
7
  id,
8
- icon,
9
8
  placeholder = '',
9
+ label,
10
10
  type = 'text',
11
11
  value,
12
12
  }: TextFieldI) => {
@@ -24,6 +24,7 @@ export const TextField = ({
24
24
  placeholder={placeholder}
25
25
  type={type}
26
26
  value={value}
27
+ label={label}
27
28
  />
28
29
  )
29
30
  }}
@@ -11,6 +11,7 @@ import { extractDayMonthYear, joinDayMonthYear } from '@/utils'
11
11
  export const DatePicker = ({
12
12
  onChange,
13
13
  placeholder,
14
+ label,
14
15
  showCalendarIcon,
15
16
  value,
16
17
  width = '290px',
@@ -56,7 +57,7 @@ export const DatePicker = ({
56
57
  const renderCustomInput = () => {
57
58
  return (
58
59
  <Flex gap="base" w={width}>
59
- <LabeledField label={String(placeholder)}>
60
+ <LabeledField label={label}>
60
61
  <Input
61
62
  placeholder={placeholder || 'MM/DD/YYYY'}
62
63
  onChange={handleInputChange}
@@ -6,7 +6,6 @@ import {
6
6
  Input,
7
7
  InputGroup,
8
8
  InputRightElement,
9
- Tooltip,
10
9
  Box,
11
10
  } from '@chakra-ui/react'
12
11
  import { SelectI } from '@/interfaces'
@@ -29,7 +28,7 @@ export const SelectInput = ({
29
28
  initialValue = 'All',
30
29
  isDisabled,
31
30
  items,
32
- placeholder,
31
+ label,
33
32
  variant = 'primary',
34
33
  width = '10rem',
35
34
  }: SelectI) => {
@@ -41,7 +40,7 @@ export const SelectInput = ({
41
40
 
42
41
  return (
43
42
  <Menu>
44
- <LabeledField label={String(placeholder)}>
43
+ <LabeledField label={label}>
45
44
  <Box w="100%">
46
45
  <SelectButton
47
46
  selectedValue={selectedValue}
@@ -10,6 +10,7 @@ export const TextInput = ({
10
10
  hasError,
11
11
  id,
12
12
  isDisabled,
13
+ label,
13
14
  placeholder,
14
15
  value = '',
15
16
  type = 'text',
@@ -18,7 +19,7 @@ export const TextInput = ({
18
19
  const error = hasError && !isDisabled
19
20
  return (
20
21
  <FormControl isInvalid={error}>
21
- <LabeledField label={placeholder}>
22
+ <LabeledField label={label}>
22
23
  <Input
23
24
  {...props}
24
25
  autoCapitalize={autoCapitalize}
@@ -5,6 +5,7 @@ export interface DateFieldI {
5
5
  icon?: string
6
6
  name?: string
7
7
  placeholder?: string
8
+ label?: string
8
9
  showCalendarIcon?: boolean
9
10
  type?: 'text' | 'email' | 'password' | 'number' | 'tel'
10
11
  value: ReportI['value']
@@ -4,5 +4,6 @@ export interface SelectFieldI extends FieldDescriptionI {
4
4
  id: string
5
5
  options: ReportI['options']
6
6
  placeholder?: string
7
+ label?: string
7
8
  value: ReportI['value']
8
9
  }
@@ -3,6 +3,7 @@ import { ReportI } from '@/interfaces'
3
3
  export interface TextAreaFieldI {
4
4
  id: string
5
5
  icon?: string
6
+ label?: string
6
7
  placeholder?: string
7
8
  value: ReportI['value']
8
9
  }
@@ -3,6 +3,7 @@ import { FieldDescriptionI, ReportI } from '@/interfaces'
3
3
  export interface TextFieldI extends FieldDescriptionI {
4
4
  id: string
5
5
  placeholder?: string
6
+ label?: string
6
7
  type?: 'text' | 'email' | 'password' | 'number' | 'tel'
7
8
  value: ReportI['value']
8
9
  }
@@ -1,6 +1,7 @@
1
1
  export interface DatePickerI {
2
2
  onChange: (date: string) => void
3
3
  placeholder?: string
4
+ label?: string
4
5
  showCalendarIcon?: boolean
5
6
  value: string
6
7
  width?: string
@@ -7,6 +7,7 @@ export interface InputI extends InputProps {
7
7
  handleChange: (event: React.ChangeEvent<HTMLInputElement>) => void
8
8
  hasError?: boolean
9
9
  id?: string
10
+ label?: string
10
11
  isDisabled?: boolean
11
12
  placeholder: string
12
13
  value: string
@@ -12,6 +12,7 @@ export interface SelectI {
12
12
  initialValue?: string
13
13
  isDisabled?: boolean
14
14
  items: SelectItemI[] | string[]
15
+ label?: string
15
16
  placeholder?: string
16
17
  width?: string
17
18
  variant?: 'primary' | 'secondary' | 'tertiary' | 'accountType'