@codezee/sixtify-brahma 0.2.37 → 0.2.38

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@codezee/sixtify-brahma",
3
- "version": "0.2.37",
3
+ "version": "0.2.38",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/hardikranpariya/sixtify-brahma.git"
@@ -10,7 +10,7 @@ const ChevronLeft_1 = __importDefault(require("@mui/icons-material/ChevronLeft")
10
10
  const ChevronRight_1 = __importDefault(require("@mui/icons-material/ChevronRight"));
11
11
  const material_1 = require("@mui/material");
12
12
  const DatePicker_1 = require("@mui/x-date-pickers/DatePicker");
13
- const lodash_1 = require("lodash");
13
+ const isFunction_1 = __importDefault(require("lodash/isFunction"));
14
14
  const luxon_1 = require("luxon");
15
15
  const react_1 = require("react");
16
16
  const react_hook_form_1 = require("react-hook-form");
@@ -121,8 +121,8 @@ function DatePicker({ setError, control, defaultValue, disabled = false, label,
121
121
  rightArrowIcon: exports.RightArrowIcon,
122
122
  switchViewIcon: EmptyIcon,
123
123
  }, dayOfWeekFormatter: (weekday) => `${weekday.toFormat("ccc")}`, onChange: (value, details) => {
124
- if (details.validationError) {
125
- if ((0, lodash_1.isFunction)(setError)) {
124
+ if (details.validationError && value && value.year >= 1000) {
125
+ if ((0, isFunction_1.default)(setError)) {
126
126
  setError(name, {
127
127
  type: "manual",
128
128
  message: "common.date.invalid",
@@ -1,14 +1,16 @@
1
1
  import type { FieldError, FieldValues, UseControllerProps } from "react-hook-form";
2
+ import { type SupportedFileType } from "../../utils";
2
3
  export type FileUploadProps<P extends FieldValues> = UseControllerProps<P> & {
3
4
  multiple?: boolean;
4
5
  loading?: boolean;
6
+ required?: boolean;
5
7
  isDisabled?: boolean;
6
8
  onChange: (file: File[]) => void;
7
9
  error?: boolean;
8
10
  helperText?: string;
9
11
  label?: string;
10
12
  size?: number;
11
- accept?: string;
13
+ accept?: SupportedFileType[];
12
14
  fileNames: JSX.Element;
13
15
  acceptTitle?: string;
14
16
  setError: (name: keyof P, error: FieldError | {
@@ -17,5 +19,5 @@ export type FileUploadProps<P extends FieldValues> = UseControllerProps<P> & {
17
19
  }) => void;
18
20
  };
19
21
  export declare const error_with_transaltion = "error_with_transaltion";
20
- export declare function FileUpload<P extends FieldValues>({ loading, onChange, isDisabled, multiple, error, helperText, label, fileNames, size, name, setError, accept, acceptTitle, ...restProps }: FileUploadProps<P>): import("react/jsx-runtime").JSX.Element;
22
+ export declare function FileUpload<P extends FieldValues>({ loading, onChange, isDisabled, multiple, required, error, helperText, label, fileNames, size, name, setError, accept, acceptTitle, ...restProps }: FileUploadProps<P>): import("react/jsx-runtime").JSX.Element;
21
23
  //# sourceMappingURL=FileUpload.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"FileUpload.d.ts","sourceRoot":"","sources":["../../../src/FormFields/FileUpload/FileUpload.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EACV,UAAU,EACV,WAAW,EACX,kBAAkB,EACnB,MAAM,iBAAiB,CAAC;AAQzB,MAAM,MAAM,eAAe,CAAC,CAAC,SAAS,WAAW,IAAI,kBAAkB,CAAC,CAAC,CAAC,GAAG;IAC3E,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,QAAQ,EAAE,CAAC,IAAI,EAAE,IAAI,EAAE,KAAK,IAAI,CAAC;IACjC,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,GAAG,CAAC,OAAO,CAAC;IACvB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,QAAQ,EAAE,CACR,IAAI,EAAE,MAAM,CAAC,EACb,KAAK,EAAE,UAAU,GAAG;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,OAAO,CAAC,EAAE,MAAM,CAAA;KAAE,KACnD,IAAI,CAAC;CACX,CAAC;AAEF,eAAO,MAAM,sBAAsB,2BAA2B,CAAC;AAE/D,wBAAgB,UAAU,CAAC,CAAC,SAAS,WAAW,EAAE,EAChD,OAAe,EACf,QAAQ,EACR,UAAU,EACV,QAAgB,EAChB,KAAK,EACL,UAAU,EACV,KAAK,EACL,SAAS,EACT,IAAS,EACT,IAAI,EACJ,QAAQ,EACR,MAA0C,EAC1C,WAAsD,EACtD,GAAG,SAAS,EACb,EAAE,eAAe,CAAC,CAAC,CAAC,2CA6GpB"}
1
+ {"version":3,"file":"FileUpload.d.ts","sourceRoot":"","sources":["../../../src/FormFields/FileUpload/FileUpload.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EACV,UAAU,EACV,WAAW,EACX,kBAAkB,EACnB,MAAM,iBAAiB,CAAC;AAIzB,OAAO,EAIL,KAAK,iBAAiB,EACvB,MAAM,aAAa,CAAC;AAIrB,MAAM,MAAM,eAAe,CAAC,CAAC,SAAS,WAAW,IAAI,kBAAkB,CAAC,CAAC,CAAC,GAAG;IAC3E,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,QAAQ,EAAE,CAAC,IAAI,EAAE,IAAI,EAAE,KAAK,IAAI,CAAC;IACjC,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,MAAM,CAAC,EAAE,iBAAiB,EAAE,CAAC;IAC7B,SAAS,EAAE,GAAG,CAAC,OAAO,CAAC;IACvB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,QAAQ,EAAE,CACR,IAAI,EAAE,MAAM,CAAC,EACb,KAAK,EAAE,UAAU,GAAG;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,OAAO,CAAC,EAAE,MAAM,CAAA;KAAE,KACnD,IAAI,CAAC;CACX,CAAC;AAEF,eAAO,MAAM,sBAAsB,2BAA2B,CAAC;AAE/D,wBAAgB,UAAU,CAAC,CAAC,SAAS,WAAW,EAAE,EAChD,OAAe,EACf,QAAQ,EACR,UAAU,EACV,QAAgB,EAChB,QAAgB,EAChB,KAAK,EACL,UAAU,EACV,KAAK,EACL,SAAS,EACT,IAAS,EACT,IAAI,EACJ,QAAQ,EACR,MAA6B,EAC7B,WAAsD,EACtD,GAAG,SAAS,EACb,EAAE,eAAe,CAAC,CAAC,CAAC,2CA8GpB"}
@@ -13,11 +13,12 @@ const utils_1 = require("../../utils");
13
13
  const FileUpload_styled_1 = require("./FileUpload.styled");
14
14
  const Skeleton_1 = require("./Skeleton");
15
15
  exports.error_with_transaltion = "error_with_transaltion";
16
- function FileUpload({ loading = false, onChange, isDisabled, multiple = false, error, helperText, label, fileNames, size = 10, name, setError, accept = ".png,.jpg,.jpeg,.doc,.docx,.pdf", acceptTitle = "Only JPG, PNG, PDF files are accepted.", ...restProps }) {
16
+ function FileUpload({ loading = false, onChange, isDisabled, multiple = false, required = false, error, helperText, label, fileNames, size = 10, name, setError, accept = utils_1.SUPPORTED_FILE_TYPES, acceptTitle = "Only JPG, PNG, PDF files are accepted.", ...restProps }) {
17
17
  const theme = (0, material_1.useTheme)();
18
18
  const { red } = theme.palette.app.color;
19
19
  const { t } = (0, react_i18next_1.useTranslation)();
20
20
  const inputRef = (0, react_1.useRef)(null);
21
+ // eslint-disable-next-line sonarjs/cognitive-complexity
21
22
  const handleFileChange = (event) => {
22
23
  if (event.target.files) {
23
24
  const files = Array.from(event.target.files);
@@ -32,7 +33,7 @@ function FileUpload({ loading = false, onChange, isDisabled, multiple = false, e
32
33
  fileSize: size,
33
34
  }));
34
35
  }
35
- else if (!(0, utils_1.isFileTypeValid)(element)) {
36
+ else if (accept.length && !(0, utils_1.isFileTypeValid)(element, accept)) {
36
37
  isShowError = true;
37
38
  inValidFiles.push(t("fileUpload.fileType.error.message", {
38
39
  fileName: element.name,
@@ -60,7 +61,7 @@ function FileUpload({ loading = false, onChange, isDisabled, multiple = false, e
60
61
  if (loading) {
61
62
  return (0, jsx_runtime_1.jsx)(Skeleton_1.Skeleton, {});
62
63
  }
63
- return ((0, jsx_runtime_1.jsxs)(material_1.Stack, { gap: "10px", children: [(0, jsx_runtime_1.jsx)(material_1.InputLabel, { required: true, children: label }), (0, jsx_runtime_1.jsx)(FileUpload_styled_1.FileUploadContainer, { onClick: () => inputRef.current?.click(), error: error, ...restProps, children: (0, jsx_runtime_1.jsx)(PadBox_1.PadBox, { padding: { padding: "20px" }, children: (0, jsx_runtime_1.jsxs)(material_1.Stack, { gap: "4px", alignItems: "center", justifyContent: "center", children: [(0, jsx_runtime_1.jsx)(FileUpload_styled_1.FileInput, { disabled: isDisabled, type: "file", accept: accept, ref: inputRef, onChange: handleFileChange, multiple: multiple }), (0, jsx_runtime_1.jsx)(Svgs_1.SvgDrop, {}), (0, jsx_runtime_1.jsx)(material_1.Typography, { children: "Drag & drop files or Browse" }), (0, jsx_runtime_1.jsx)(material_1.Typography, { variant: "caption", children: acceptTitle })] }) }) }), error && ((0, jsx_runtime_1.jsx)(material_1.Typography, { variant: "caption", sx: {
64
+ return ((0, jsx_runtime_1.jsxs)(material_1.Stack, { gap: "10px", children: [(0, jsx_runtime_1.jsx)(material_1.InputLabel, { required: required, children: label }), (0, jsx_runtime_1.jsx)(FileUpload_styled_1.FileUploadContainer, { onClick: () => inputRef.current?.click(), error: error, ...restProps, children: (0, jsx_runtime_1.jsx)(PadBox_1.PadBox, { padding: { padding: "20px" }, children: (0, jsx_runtime_1.jsxs)(material_1.Stack, { gap: "4px", alignItems: "center", justifyContent: "center", children: [(0, jsx_runtime_1.jsx)(FileUpload_styled_1.FileInput, { disabled: isDisabled, type: "file", accept: accept.toString(), ref: inputRef, onChange: handleFileChange, multiple: multiple }), (0, jsx_runtime_1.jsx)(Svgs_1.SvgDrop, {}), (0, jsx_runtime_1.jsx)(material_1.Typography, { children: "Drag & drop files or Browse" }), (0, jsx_runtime_1.jsx)(material_1.Typography, { variant: "caption", children: acceptTitle })] }) }) }), error && ((0, jsx_runtime_1.jsx)(material_1.Typography, { variant: "caption", sx: {
64
65
  color: `${red[900]}`,
65
66
  whiteSpace: "pre",
66
67
  textWrap: "wrap",
@@ -8,6 +8,7 @@ export type ImageUploadProps = Readonly<{
8
8
  defaultValue?: string;
9
9
  isCapture?: boolean;
10
10
  loading?: boolean;
11
+ size?: number;
11
12
  }>;
12
- export declare function ImageUpload({ variant, isUploading, defaultValue, onDelete, onChange, label, isCapture, loading, subTitle, }: ImageUploadProps): import("react/jsx-runtime").JSX.Element;
13
+ export declare function ImageUpload({ variant, isUploading, defaultValue, onDelete, onChange, label, isCapture, loading, size, subTitle, }: ImageUploadProps): import("react/jsx-runtime").JSX.Element;
13
14
  //# sourceMappingURL=ImageUpload.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"ImageUpload.d.ts","sourceRoot":"","sources":["../../../src/FormFields/ImageUpload/ImageUpload.tsx"],"names":[],"mappings":"AAWA,MAAM,MAAM,gBAAgB,GAAG,QAAQ,CAAC;IACtC,QAAQ,EAAE,MAAM,IAAI,CAAC;IACrB,QAAQ,EAAE,CAAC,IAAI,EAAE,IAAI,EAAE,KAAK,IAAI,CAAC;IACjC,OAAO,CAAC,EAAE,QAAQ,GAAG,QAAQ,CAAC;IAC9B,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB,CAAC,CAAC;AAEH,wBAAgB,WAAW,CAAC,EAC1B,OAAkB,EAClB,WAAmB,EACnB,YAAiB,EACjB,QAAQ,EACR,QAAQ,EACR,KAAK,EACL,SAAiB,EACjB,OAAe,EACf,QAAiC,GAClC,EAAE,gBAAgB,2CAmJlB"}
1
+ {"version":3,"file":"ImageUpload.d.ts","sourceRoot":"","sources":["../../../src/FormFields/ImageUpload/ImageUpload.tsx"],"names":[],"mappings":"AAkBA,MAAM,MAAM,gBAAgB,GAAG,QAAQ,CAAC;IACtC,QAAQ,EAAE,MAAM,IAAI,CAAC;IACrB,QAAQ,EAAE,CAAC,IAAI,EAAE,IAAI,EAAE,KAAK,IAAI,CAAC;IACjC,OAAO,CAAC,EAAE,QAAQ,GAAG,QAAQ,CAAC;IAC9B,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,IAAI,CAAC,EAAE,MAAM,CAAC;CACf,CAAC,CAAC;AASH,wBAAgB,WAAW,CAAC,EAC1B,OAAkB,EAClB,WAAmB,EACnB,YAAiB,EACjB,QAAQ,EACR,QAAQ,EACR,KAAK,EACL,SAAiB,EACjB,OAAe,EACf,IAAQ,EACR,QAAiC,GAClC,EAAE,gBAAgB,2CAqKlB"}
@@ -10,12 +10,17 @@ const CameraAltOutlined_1 = __importDefault(require("@mui/icons-material/CameraA
10
10
  const PersonAddAlt_1 = __importDefault(require("@mui/icons-material/PersonAddAlt"));
11
11
  const material_1 = require("@mui/material");
12
12
  const react_1 = require("react");
13
+ const react_i18next_1 = require("react-i18next");
13
14
  const Button_1 = require("../../Button");
14
15
  const PadBox_1 = require("../../PadBox");
16
+ const Toast_1 = require("../../Toast");
17
+ const utils_1 = require("../../utils");
15
18
  const ImageUpload_styled_1 = require("./ImageUpload.styled");
16
19
  const PhotoCaptureDialog_1 = require("./PhotoCaptureDialog");
17
20
  const Skeleton_1 = require("./Skeleton");
18
- function ImageUpload({ variant = "square", isUploading = false, defaultValue = "", onDelete, onChange, label, isCapture = false, loading = false, subTitle = "PNG, JPEG under 5 MB", }) {
21
+ const imageFileType = ["image/png", "image/jpeg", "image/jpg"];
22
+ function ImageUpload({ variant = "square", isUploading = false, defaultValue = "", onDelete, onChange, label, isCapture = false, loading = false, size = 5, subTitle = "PNG, JPEG under 5 MB", }) {
23
+ const { t } = (0, react_i18next_1.useTranslation)();
19
24
  const inputRef = (0, react_1.useRef)(null);
20
25
  const [hover, setHover] = (0, react_1.useState)(false);
21
26
  const [isOpenCaptureModal, setIsOpenCaptureModal] = (0, react_1.useState)(false);
@@ -24,6 +29,22 @@ function ImageUpload({ variant = "square", isUploading = false, defaultValue = "
24
29
  const handleFileChange = (event) => {
25
30
  if (event.target.files) {
26
31
  const files = Array.from(event.target.files);
32
+ for (const element of files) {
33
+ if (!(0, utils_1.isFileSizeValid)(element, size)) {
34
+ Toast_1.toasts.error({
35
+ title: t("imageUpload.fileSize.error.message", {
36
+ fileSize: size,
37
+ }),
38
+ });
39
+ }
40
+ else if (!(0, utils_1.isFileTypeValid)(element, imageFileType)) {
41
+ Toast_1.toasts.error({
42
+ title: t("fileUpload.fileType.error.message", {
43
+ fileName: element.name,
44
+ }),
45
+ });
46
+ }
47
+ }
27
48
  onChange(files);
28
49
  }
29
50
  };
@@ -61,7 +82,7 @@ function ImageUpload({ variant = "square", isUploading = false, defaultValue = "
61
82
  },
62
83
  }
63
84
  : {}),
64
- }, children: [(0, jsx_runtime_1.jsx)("input", { type: "file", ref: inputRef, onChange: handleFileChange, style: { display: "none" }, accept: "image/png, image/jpeg" }), hover && !!defaultValue && ((0, jsx_runtime_1.jsxs)(ImageUpload_styled_1.DarkBackgroundContainer, { children: [(0, jsx_runtime_1.jsx)(material_1.IconButton, { onClick: () => inputRef.current?.click(), children: (0, jsx_runtime_1.jsx)(icons_material_1.Edit, { sx: { color: "white" } }) }), (0, jsx_runtime_1.jsx)(material_1.IconButton, { onClick: handleFileRemove, children: (0, jsx_runtime_1.jsx)(icons_material_1.Delete, { sx: { color: "white" } }) })] })), isUploading && ((0, jsx_runtime_1.jsx)(ImageUpload_styled_1.DarkBackgroundContainer, { children: (0, jsx_runtime_1.jsx)(material_1.Typography, { color: iron[600], children: "Processing..." }) })), defaultValue ? ((0, jsx_runtime_1.jsx)(PadBox_1.PadBox, { padding: { padding: "2px" }, children: (0, jsx_runtime_1.jsx)("img", { alt: "", src: defaultValue, style: {
85
+ }, children: [(0, jsx_runtime_1.jsx)("input", { type: "file", ref: inputRef, accept: imageFileType.join(","), onChange: handleFileChange, style: { display: "none" } }), hover && !!defaultValue && ((0, jsx_runtime_1.jsxs)(ImageUpload_styled_1.DarkBackgroundContainer, { children: [(0, jsx_runtime_1.jsx)(material_1.IconButton, { onClick: () => inputRef.current?.click(), children: (0, jsx_runtime_1.jsx)(icons_material_1.Edit, { sx: { color: "white" } }) }), (0, jsx_runtime_1.jsx)(material_1.IconButton, { onClick: handleFileRemove, children: (0, jsx_runtime_1.jsx)(icons_material_1.Delete, { sx: { color: "white" } }) })] })), isUploading && ((0, jsx_runtime_1.jsx)(ImageUpload_styled_1.DarkBackgroundContainer, { children: (0, jsx_runtime_1.jsx)(material_1.Typography, { color: iron[600], children: "Processing..." }) })), defaultValue ? ((0, jsx_runtime_1.jsx)(PadBox_1.PadBox, { padding: { padding: "2px" }, children: (0, jsx_runtime_1.jsx)("img", { alt: "", src: defaultValue, style: {
65
86
  width: "100%",
66
87
  height: "100%",
67
88
  objectFit: "cover",
@@ -1,7 +1,7 @@
1
1
  import { type StackOwnProps, type SxProps } from "@mui/material";
2
2
  import { type RadioProps as MuiRadioProps } from "@mui/material/Radio";
3
- import { type ControllerRenderProps, type FieldValues, type UseControllerProps } from "react-hook-form";
4
3
  import type { ReactNode } from "react";
4
+ import { type ControllerRenderProps, type FieldValues, type UseControllerProps } from "react-hook-form";
5
5
  type Options = {
6
6
  values: boolean | string;
7
7
  label?: ReactNode;
@@ -12,9 +12,10 @@ export type RadioGroupFieldProps<P extends FieldValues> = UseControllerProps<P>
12
12
  label?: string;
13
13
  options: Options[];
14
14
  loading?: boolean;
15
+ required?: boolean;
15
16
  direction?: StackOwnProps["direction"];
16
17
  sx?: SxProps;
17
18
  };
18
- export declare function RadioGroupField<P extends FieldValues>({ name, rules, label, control, options, defaultValue, size, color, loading, direction, sx, ...restRadioButtonProps }: RadioGroupFieldProps<P>): import("react/jsx-runtime").JSX.Element;
19
+ export declare function RadioGroupField<P extends FieldValues>({ name, rules, label, control, options, defaultValue, size, color, loading, required, direction, sx, ...restRadioButtonProps }: RadioGroupFieldProps<P>): import("react/jsx-runtime").JSX.Element;
19
20
  export {};
20
21
  //# sourceMappingURL=RadioGroupField.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"RadioGroupField.d.ts","sourceRoot":"","sources":["../../../src/FormFields/RadioGroupField/RadioGroupField.tsx"],"names":[],"mappings":"AAAA,OAAO,EAML,KAAK,aAAa,EAClB,KAAK,OAAO,EACb,MAAM,eAAe,CAAC;AACvB,OAAc,EAAE,KAAK,UAAU,IAAI,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAC9E,OAAO,EAEL,KAAK,qBAAqB,EAC1B,KAAK,WAAW,EAChB,KAAK,kBAAkB,EACxB,MAAM,iBAAiB,CAAC;AAEzB,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAEvC,KAAK,OAAO,GAAG;IACb,MAAM,EAAE,OAAO,GAAG,MAAM,CAAC;IACzB,KAAK,CAAC,EAAE,SAAS,CAAC;IAClB,QAAQ,EAAE,OAAO,CAAC;IAClB,SAAS,CAAC,EAAE,aAAa,CAAC,WAAW,CAAC,CAAC;CACxC,CAAC;AAEF,MAAM,MAAM,oBAAoB,CAAC,CAAC,SAAS,WAAW,IACpD,kBAAkB,CAAC,CAAC,CAAC,GACnB,IAAI,CAAC,IAAI,CAAC,aAAa,EAAE,SAAS,CAAC,EAAE,MAAM,qBAAqB,CAAC,CAAC,CAAC,CAAC,GAAG;IACrE,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,OAAO,EAAE,CAAC;IACnB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,SAAS,CAAC,EAAE,aAAa,CAAC,WAAW,CAAC,CAAC;IACvC,EAAE,CAAC,EAAE,OAAO,CAAC;CACd,CAAC;AAEN,wBAAgB,eAAe,CAAC,CAAC,SAAS,WAAW,EAAE,EACrD,IAAI,EACJ,KAAK,EACL,KAAK,EACL,OAAO,EACP,OAAO,EACP,YAAY,EACZ,IAAc,EACd,KAAmB,EACnB,OAAe,EACf,SAAiB,EACjB,EAAO,EACP,GAAG,oBAAoB,EACxB,EAAE,oBAAoB,CAAC,CAAC,CAAC,2CAuDzB"}
1
+ {"version":3,"file":"RadioGroupField.d.ts","sourceRoot":"","sources":["../../../src/FormFields/RadioGroupField/RadioGroupField.tsx"],"names":[],"mappings":"AAAA,OAAO,EAML,KAAK,aAAa,EAClB,KAAK,OAAO,EACb,MAAM,eAAe,CAAC;AACvB,OAAc,EAAE,KAAK,UAAU,IAAI,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAC9E,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AACvC,OAAO,EAEL,KAAK,qBAAqB,EAC1B,KAAK,WAAW,EAChB,KAAK,kBAAkB,EACxB,MAAM,iBAAiB,CAAC;AAGzB,KAAK,OAAO,GAAG;IACb,MAAM,EAAE,OAAO,GAAG,MAAM,CAAC;IACzB,KAAK,CAAC,EAAE,SAAS,CAAC;IAClB,QAAQ,EAAE,OAAO,CAAC;IAClB,SAAS,CAAC,EAAE,aAAa,CAAC,WAAW,CAAC,CAAC;CACxC,CAAC;AAEF,MAAM,MAAM,oBAAoB,CAAC,CAAC,SAAS,WAAW,IACpD,kBAAkB,CAAC,CAAC,CAAC,GACnB,IAAI,CAAC,IAAI,CAAC,aAAa,EAAE,SAAS,CAAC,EAAE,MAAM,qBAAqB,CAAC,CAAC,CAAC,CAAC,GAAG;IACrE,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,OAAO,EAAE,CAAC;IACnB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,SAAS,CAAC,EAAE,aAAa,CAAC,WAAW,CAAC,CAAC;IACvC,EAAE,CAAC,EAAE,OAAO,CAAC;CACd,CAAC;AAEN,wBAAgB,eAAe,CAAC,CAAC,SAAS,WAAW,EAAE,EACrD,IAAI,EACJ,KAAK,EACL,KAAK,EACL,OAAO,EACP,OAAO,EACP,YAAY,EACZ,IAAc,EACd,KAAmB,EACnB,OAAe,EACf,QAAgB,EAChB,SAAiB,EACjB,EAAO,EACP,GAAG,oBAAoB,EACxB,EAAE,oBAAoB,CAAC,CAAC,CAAC,2CAuDzB"}
@@ -9,12 +9,12 @@ const material_1 = require("@mui/material");
9
9
  const Radio_1 = __importDefault(require("@mui/material/Radio"));
10
10
  const react_hook_form_1 = require("react-hook-form");
11
11
  const Skeleton_1 = require("./Skeleton");
12
- function RadioGroupField({ name, rules, label, control, options, defaultValue, size = "small", color = "secondary", loading = false, direction = "row", sx = {}, ...restRadioButtonProps }) {
12
+ function RadioGroupField({ name, rules, label, control, options, defaultValue, size = "small", color = "secondary", loading = false, required = false, direction = "row", sx = {}, ...restRadioButtonProps }) {
13
13
  const { field: { value, onChange, ...restField }, } = (0, react_hook_form_1.useController)({ name, control, defaultValue, rules });
14
14
  if (loading) {
15
15
  return (0, jsx_runtime_1.jsx)(Skeleton_1.Skeleton, {});
16
16
  }
17
- return ((0, jsx_runtime_1.jsxs)(material_1.Stack, { gap: "5px", children: [label && (0, jsx_runtime_1.jsx)(material_1.InputLabel, { children: label }), (0, jsx_runtime_1.jsx)(material_1.RadioGroup, { name: name, value: value, onChange: (_, event) => {
17
+ return ((0, jsx_runtime_1.jsxs)(material_1.Stack, { gap: "5px", children: [label && (0, jsx_runtime_1.jsx)(material_1.InputLabel, { required: required, children: label }), (0, jsx_runtime_1.jsx)(material_1.RadioGroup, { name: name, value: value, onChange: (_, event) => {
18
18
  if (event === "true") {
19
19
  onChange(true);
20
20
  }
@@ -1,3 +1,5 @@
1
+ export type SupportedFileType = "image/png" | "image/jpeg" | "image/jpg" | "application/pdf" | "application/zip" | "application/msword" | "application/x-zip-compressed" | "application/vnd.openxmlformats-officedocument.wordprocessingml.document" | "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" | "application/vnd.ms-excel";
2
+ export declare const SUPPORTED_FILE_TYPES: SupportedFileType[];
1
3
  export declare const isFileSizeValid: (file: File, maxSizeMB: number) => boolean;
2
- export declare const isFileTypeValid: (file: File) => boolean;
4
+ export declare const isFileTypeValid: (file: File, fileTypes: SupportedFileType[]) => boolean;
3
5
  //# sourceMappingURL=file.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"file.d.ts","sourceRoot":"","sources":["../../src/utils/file.ts"],"names":[],"mappings":"AAaA,eAAO,MAAM,eAAe,GAAI,MAAM,IAAI,EAAE,WAAW,MAAM,YAI5D,CAAC;AAEF,eAAO,MAAM,eAAe,GAAI,MAAM,IAAI,YAEzC,CAAC"}
1
+ {"version":3,"file":"file.d.ts","sourceRoot":"","sources":["../../src/utils/file.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,iBAAiB,GACzB,WAAW,GACX,YAAY,GACZ,WAAW,GACX,iBAAiB,GACjB,iBAAiB,GACjB,oBAAoB,GACpB,8BAA8B,GAC9B,yEAAyE,GACzE,mEAAmE,GACnE,0BAA0B,CAAC;AAE/B,eAAO,MAAM,oBAAoB,EAAE,iBAAiB,EAWnD,CAAC;AAEF,eAAO,MAAM,eAAe,GAAI,MAAM,IAAI,EAAE,WAAW,MAAM,YAI5D,CAAC;AAEF,eAAO,MAAM,eAAe,GAAI,MAAM,IAAI,EAAE,WAAW,iBAAiB,EAAE,YAEzE,CAAC"}
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.isFileTypeValid = exports.isFileSizeValid = void 0;
4
- const SUPPORTED_FILE_TYPES = [
3
+ exports.isFileTypeValid = exports.isFileSizeValid = exports.SUPPORTED_FILE_TYPES = void 0;
4
+ exports.SUPPORTED_FILE_TYPES = [
5
5
  "image/png",
6
6
  "image/jpeg",
7
7
  "image/jpg",
@@ -18,7 +18,7 @@ const isFileSizeValid = (file, maxSizeMB) => {
18
18
  return file.size <= maxSizeInBytes;
19
19
  };
20
20
  exports.isFileSizeValid = isFileSizeValid;
21
- const isFileTypeValid = (file) => {
22
- return SUPPORTED_FILE_TYPES.includes(file.type);
21
+ const isFileTypeValid = (file, fileTypes) => {
22
+ return fileTypes.includes(file.type);
23
23
  };
24
24
  exports.isFileTypeValid = isFileTypeValid;