@codezee/sixtify-brahma 0.2.36 → 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 +1 -1
- package/packages/shared-components/dist/ContentBox/ContentBox.d.ts.map +1 -1
- package/packages/shared-components/dist/ContentBox/ContentBox.js +1 -2
- package/packages/shared-components/dist/FilterList/FilterList.d.ts.map +1 -1
- package/packages/shared-components/dist/FilterList/FilterList.js +3 -1
- package/packages/shared-components/dist/FilterList/FilterListV2.d.ts +2 -2
- package/packages/shared-components/dist/FilterList/FilterListV2.d.ts.map +1 -1
- package/packages/shared-components/dist/FilterList/FilterListV2.js +17 -7
- package/packages/shared-components/dist/FilterList/FilterTypeWrapper.d.ts +4 -0
- package/packages/shared-components/dist/FilterList/FilterTypeWrapper.d.ts.map +1 -1
- package/packages/shared-components/dist/FilterList/GetFilterPopupComponent.d.ts.map +1 -1
- package/packages/shared-components/dist/FilterList/GetFilterPopupComponent.js +19 -3
- package/packages/shared-components/dist/FormFields/DatePicker/DatePicker.js +3 -3
- package/packages/shared-components/dist/FormFields/FileUpload/FileUpload.d.ts +4 -2
- package/packages/shared-components/dist/FormFields/FileUpload/FileUpload.d.ts.map +1 -1
- package/packages/shared-components/dist/FormFields/FileUpload/FileUpload.js +4 -3
- package/packages/shared-components/dist/FormFields/ImageUpload/ImageUpload.d.ts +2 -1
- package/packages/shared-components/dist/FormFields/ImageUpload/ImageUpload.d.ts.map +1 -1
- package/packages/shared-components/dist/FormFields/ImageUpload/ImageUpload.js +23 -2
- package/packages/shared-components/dist/FormFields/RadioGroupField/RadioGroupField.d.ts +3 -2
- package/packages/shared-components/dist/FormFields/RadioGroupField/RadioGroupField.d.ts.map +1 -1
- package/packages/shared-components/dist/FormFields/RadioGroupField/RadioGroupField.js +2 -2
- package/packages/shared-components/dist/utils/file.d.ts +3 -1
- package/packages/shared-components/dist/utils/file.d.ts.map +1 -1
- package/packages/shared-components/dist/utils/file.js +4 -4
package/package.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ContentBox.d.ts","sourceRoot":"","sources":["../../src/ContentBox/ContentBox.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"ContentBox.d.ts","sourceRoot":"","sources":["../../src/ContentBox/ContentBox.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,OAAO,CAAC;AAE/C,eAAO,MAAM,UAAU,GAAI,cAAc,iBAAiB,4CAkBzD,CAAC"}
|
|
@@ -3,7 +3,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.ContentBox = void 0;
|
|
4
4
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
5
|
const material_1 = require("@mui/material");
|
|
6
|
-
const PadBox_1 = require("../PadBox");
|
|
7
6
|
const ContentBox = ({ children }) => {
|
|
8
7
|
const theme = (0, material_1.useTheme)();
|
|
9
8
|
const { iron, butterflyBlue } = theme.palette.app.color;
|
|
@@ -13,6 +12,6 @@ const ContentBox = ({ children }) => {
|
|
|
13
12
|
borderRadius: "6px",
|
|
14
13
|
height: "100%",
|
|
15
14
|
width: "100%",
|
|
16
|
-
}, children:
|
|
15
|
+
}, children: children }));
|
|
17
16
|
};
|
|
18
17
|
exports.ContentBox = ContentBox;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FilterList.d.ts","sourceRoot":"","sources":["../../src/FilterList/FilterList.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"FilterList.d.ts","sourceRoot":"","sources":["../../src/FilterList/FilterList.tsx"],"names":[],"mappings":"AAWA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAI1D,MAAM,MAAM,eAAe,GAAG;IAC5B,eAAe,EAAE,cAAc,EAAE,CAAC;CACnC,CAAC;AACF,eAAO,MAAM,UAAU,GAAI,qBAAqB,eAAe,4CAoK9D,CAAC"}
|
|
@@ -9,6 +9,7 @@ const Button_1 = require("../Button");
|
|
|
9
9
|
const FilterPill_1 = require("../Chips/FilterPill");
|
|
10
10
|
const SvgFilterList_1 = require("../Svgs/SvgFilterList");
|
|
11
11
|
const Tooltip_1 = require("../Tooltip");
|
|
12
|
+
const FilterListV2_1 = require("./FilterListV2");
|
|
12
13
|
const FilterPopup_1 = require("./FilterPopup");
|
|
13
14
|
const FilterPopupWrapper_1 = require("./FilterPopupWrapper");
|
|
14
15
|
const FilterTypeWrapper_1 = require("./FilterTypeWrapper");
|
|
@@ -27,7 +28,8 @@ const FilterList = ({ filterListItems }) => {
|
|
|
27
28
|
setOpenFilterPopup(false);
|
|
28
29
|
setCurrentFilter(null);
|
|
29
30
|
handleClose();
|
|
30
|
-
|
|
31
|
+
const filteredData = (0, FilterListV2_1.formatFilterData)(data, filterListItems);
|
|
32
|
+
setFilterListData(filteredData);
|
|
31
33
|
};
|
|
32
34
|
const handleClick = (event) => {
|
|
33
35
|
setAnchorEl(event.currentTarget);
|
|
@@ -8,7 +8,7 @@ export type FilterListV2Props = {
|
|
|
8
8
|
onChange: (data: FieldValues, isPopup: boolean) => void;
|
|
9
9
|
onClear: () => void;
|
|
10
10
|
resetFormBasedOnFields?: string;
|
|
11
|
-
dateKeys?: string[];
|
|
12
11
|
};
|
|
13
|
-
export declare
|
|
12
|
+
export declare function formatFilterData(data: FieldValues, filterListItems: FilterListType[]): Record<string, FieldValues>;
|
|
13
|
+
export declare const FilterListV2: ({ filterListItems, isDisabled, filterListData, onApply, onClear, onChange, }: FilterListV2Props) => import("react/jsx-runtime").JSX.Element;
|
|
14
14
|
//# sourceMappingURL=FilterListV2.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FilterListV2.d.ts","sourceRoot":"","sources":["../../src/FilterList/FilterListV2.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"FilterListV2.d.ts","sourceRoot":"","sources":["../../src/FilterList/FilterListV2.tsx"],"names":[],"mappings":"AAuBA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAenD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAI1D,MAAM,MAAM,iBAAiB,GAAG;IAC9B,eAAe,EAAE,cAAc,EAAE,CAAC;IAClC,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,cAAc,CAAC,EAAE,WAAW,CAAC;IAC7B,OAAO,EAAE,CAAC,IAAI,EAAE,WAAW,EAAE,OAAO,CAAC,EAAE,OAAO,EAAE,GAAG,CAAC,EAAE,MAAM,KAAK,IAAI,CAAC;IACtE,QAAQ,EAAE,CAAC,IAAI,EAAE,WAAW,EAAE,OAAO,EAAE,OAAO,KAAK,IAAI,CAAC;IACxD,OAAO,EAAE,MAAM,IAAI,CAAC;IACpB,sBAAsB,CAAC,EAAE,MAAM,CAAC;CACjC,CAAC;AAEF,wBAAgB,gBAAgB,CAC9B,IAAI,EAAE,WAAW,EACjB,eAAe,EAAE,cAAc,EAAE,GAChC,MAAM,CAAC,MAAM,EAAE,WAAW,CAAC,CAiB7B;AAED,eAAO,MAAM,YAAY,GAAI,8EAO1B,iBAAiB,4CAskBnB,CAAC"}
|
|
@@ -4,6 +4,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.FilterListV2 = void 0;
|
|
7
|
+
exports.formatFilterData = formatFilterData;
|
|
7
8
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
8
9
|
/* eslint-disable sonarjs/no-nested-functions */
|
|
9
10
|
/* eslint-disable sonarjs/no-nested-conditional */
|
|
@@ -14,6 +15,7 @@ const icons_material_1 = require("@mui/icons-material");
|
|
|
14
15
|
const material_1 = require("@mui/material");
|
|
15
16
|
const icons_1 = require("@mui/x-date-pickers/icons");
|
|
16
17
|
const lodash_1 = require("lodash");
|
|
18
|
+
const isEqual_1 = __importDefault(require("lodash/isEqual"));
|
|
17
19
|
const luxon_1 = require("luxon");
|
|
18
20
|
const react_1 = require("react");
|
|
19
21
|
const react_hook_form_1 = require("react-hook-form");
|
|
@@ -29,8 +31,19 @@ const Tooltip_1 = require("../Tooltip");
|
|
|
29
31
|
const FilterPopupWrapper_1 = require("./FilterPopupWrapper");
|
|
30
32
|
const GetFilterPopupComponent_1 = require("./GetFilterPopupComponent");
|
|
31
33
|
const getFormData_1 = require("./getFormData");
|
|
32
|
-
|
|
33
|
-
|
|
34
|
+
function formatFilterData(data, filterListItems) {
|
|
35
|
+
return Object.fromEntries(Object.entries(data).flatMap(([key, value]) => {
|
|
36
|
+
if (value) {
|
|
37
|
+
const config = filterListItems.find((item) => item.key === key);
|
|
38
|
+
const formattedValue = config?.monthYearFormat && typeof value === "string"
|
|
39
|
+
? luxon_1.DateTime.fromISO(value).toFormat("yyyy-MM")
|
|
40
|
+
: value;
|
|
41
|
+
return [[key, formattedValue]];
|
|
42
|
+
}
|
|
43
|
+
return [];
|
|
44
|
+
}));
|
|
45
|
+
}
|
|
46
|
+
const FilterListV2 = ({ filterListItems, isDisabled = false, filterListData, onApply, onClear, onChange, }) => {
|
|
34
47
|
const theme = (0, material_1.useTheme)();
|
|
35
48
|
const { iron, slate } = theme.palette.app.color;
|
|
36
49
|
const [anchorEl, setAnchorEl] = (0, react_1.useState)(null);
|
|
@@ -117,7 +130,7 @@ const FilterListV2 = ({ filterListItems, isDisabled = false, filterListData, onA
|
|
|
117
130
|
const onSubmit = (data) => {
|
|
118
131
|
setOpenFilterPopup(false);
|
|
119
132
|
setCurrentFilter(null);
|
|
120
|
-
const filteredData =
|
|
133
|
+
const filteredData = formatFilterData(data, filterListItems);
|
|
121
134
|
onApply(filteredData, openFilterPopup, currentFilter?.key);
|
|
122
135
|
handleClose();
|
|
123
136
|
};
|
|
@@ -181,10 +194,7 @@ const FilterListV2 = ({ filterListItems, isDisabled = false, filterListData, onA
|
|
|
181
194
|
return;
|
|
182
195
|
}
|
|
183
196
|
const item = getFilterItem(key);
|
|
184
|
-
const keyValue = item &&
|
|
185
|
-
(0, getFormData_1.getFormValue)(dateKeys?.includes(item?.key)
|
|
186
|
-
? luxon_1.DateTime.fromISO(value).toFormat(FormFields_1.dateFormats.dateWithEuropean)
|
|
187
|
-
: value, item);
|
|
197
|
+
const keyValue = item && (0, getFormData_1.getFormValue)(value, item);
|
|
188
198
|
if (typeof value !== "boolean" && !keyValue) {
|
|
189
199
|
return;
|
|
190
200
|
}
|
|
@@ -5,6 +5,8 @@ type Options = readonly {
|
|
|
5
5
|
value: string;
|
|
6
6
|
disabled?: boolean;
|
|
7
7
|
avatar?: string;
|
|
8
|
+
employee_code?: string;
|
|
9
|
+
punch_code?: string;
|
|
8
10
|
}[];
|
|
9
11
|
export type FilterListType = {
|
|
10
12
|
label: string;
|
|
@@ -16,6 +18,8 @@ export type FilterListType = {
|
|
|
16
18
|
options?: Options;
|
|
17
19
|
multiSelect?: boolean;
|
|
18
20
|
required?: boolean;
|
|
21
|
+
monthYearFormat?: boolean;
|
|
22
|
+
employeeAutocomplete?: boolean;
|
|
19
23
|
};
|
|
20
24
|
type FilterTypeWrapperProps = {
|
|
21
25
|
filter: FilterListType;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FilterTypeWrapper.d.ts","sourceRoot":"","sources":["../../src/FilterList/FilterTypeWrapper.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAG5D,MAAM,MAAM,mBAAmB,GAC3B,cAAc,GACd,MAAM,GACN,MAAM,GACN,WAAW,GACX,UAAU,GACV,OAAO,GACP,QAAQ,CAAC;AAEb,KAAK,OAAO,GAAG,SAAS;IACtB,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,MAAM,CAAC,EAAE,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"FilterTypeWrapper.d.ts","sourceRoot":"","sources":["../../src/FilterList/FilterTypeWrapper.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAG5D,MAAM,MAAM,mBAAmB,GAC3B,cAAc,GACd,MAAM,GACN,MAAM,GACN,WAAW,GACX,UAAU,GACV,OAAO,GACP,QAAQ,CAAC;AAEb,KAAK,OAAO,GAAG,SAAS;IACtB,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB,EAAE,CAAC;AAEJ,MAAM,MAAM,cAAc,GAAG;IAC3B,KAAK,EAAE,MAAM,CAAC;IACd,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,mBAAmB,CAAC;IAC1B,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,oBAAoB,CAAC,EAAE,OAAO,CAAC;CAChC,CAAC;AACF,KAAK,sBAAsB,GAAG;IAC5B,MAAM,EAAE,cAAc,CAAC;IACvB,OAAO,EAAE,OAAO,CAAC,WAAW,CAAC,CAAC;CAC/B,CAAC;AACF,eAAO,MAAM,iBAAiB,GAAI,sBAG/B,sBAAsB,4CAqBxB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GetFilterPopupComponent.d.ts","sourceRoot":"","sources":["../../src/FilterList/GetFilterPopupComponent.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAOzE,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,sBAAsB,CAAC;AACrE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"GetFilterPopupComponent.d.ts","sourceRoot":"","sources":["../../src/FilterList/GetFilterPopupComponent.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAOzE,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,sBAAsB,CAAC;AACrE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAQ1D,eAAO,MAAM,uBAAuB,GAClC,gBAAgB,cAAc,EAC9B,SAAS,OAAO,CAAC,WAAW,CAAC,EAC7B,QAAQ,WAAW,CAAC,WAAW,CAAC,KAC/B,wBAsGF,CAAC"}
|
|
@@ -6,7 +6,7 @@ const material_1 = require("@mui/material");
|
|
|
6
6
|
const FormFields_1 = require("../FormFields");
|
|
7
7
|
const getFilterPopupComponent = (selectedFilter, control, errors) => {
|
|
8
8
|
const theme = (0, material_1.useTheme)();
|
|
9
|
-
const { sapphireBlue, black } = theme.palette.app.color;
|
|
9
|
+
const { iron, sapphireBlue, black } = theme.palette.app.color;
|
|
10
10
|
const errorSelectedKey = errors[selectedFilter.key];
|
|
11
11
|
return {
|
|
12
12
|
autoComplete: selectedFilter.options && ((0, jsx_runtime_1.jsx)(FormFields_1.Autocomplete, { disableClearable: true, multiple: selectedFilter.multiSelect ?? false, placeholder: `Select ${selectedFilter.label}`, name: `${selectedFilter.key}`, disabled: selectedFilter.isDisabled, shouldCloseOnSelect: selectedFilter.multiSelect ?? false, control: control, options: selectedFilter.options ?? [], sx: {
|
|
@@ -17,9 +17,25 @@ const getFilterPopupComponent = (selectedFilter, control, errors) => {
|
|
|
17
17
|
backgroundColor: sapphireBlue[300],
|
|
18
18
|
color: black[900],
|
|
19
19
|
},
|
|
20
|
-
},
|
|
20
|
+
}, ...(selectedFilter.employeeAutocomplete && {
|
|
21
|
+
isShowAvatar: true,
|
|
22
|
+
isShowSelectAll: false,
|
|
23
|
+
renderOption: (props, option) => {
|
|
24
|
+
const { key, ...optionProps } = props;
|
|
25
|
+
return ((0, jsx_runtime_1.jsx)("li", { ...optionProps, children: (0, jsx_runtime_1.jsxs)(material_1.Stack, { direction: "row", gap: "10px", alignItems: "center", children: [option.avatar && ((0, jsx_runtime_1.jsx)(material_1.Avatar, { sx: { width: 30, height: 30 }, src: option.avatar, alt: option.label })), (0, jsx_runtime_1.jsxs)(material_1.Box, { children: [(0, jsx_runtime_1.jsx)(material_1.Typography, { children: `${option.label} (${option.employee_code})` }), (0, jsx_runtime_1.jsx)(material_1.Typography, { variant: "body2", color: iron[800], children: option.punch_code })] })] }) }, key));
|
|
26
|
+
},
|
|
27
|
+
getOptionLabel: (option) => {
|
|
28
|
+
if (typeof option === "string") {
|
|
29
|
+
return option;
|
|
30
|
+
}
|
|
31
|
+
return `${option.label} (${option.employee_code}) - ${option.punch_code}`;
|
|
32
|
+
},
|
|
33
|
+
}), error: !!errorSelectedKey, helperText: errorSelectedKey?.message })),
|
|
21
34
|
text: ((0, jsx_runtime_1.jsx)(FormFields_1.TextField, { name: selectedFilter.key, control: control, disabled: selectedFilter.isDisabled, placeholder: selectedFilter.label, error: !!errorSelectedKey, helperText: errorSelectedKey?.message })),
|
|
22
|
-
date: ((0, jsx_runtime_1.jsx)(FormFields_1.DatePicker, { name: selectedFilter.key, control: control, disabled: selectedFilter.isDisabled, error: !!errorSelectedKey, helperText: errorSelectedKey?.message
|
|
35
|
+
date: ((0, jsx_runtime_1.jsx)(FormFields_1.DatePicker, { name: selectedFilter.key, control: control, disabled: selectedFilter.isDisabled, error: !!errorSelectedKey, helperText: errorSelectedKey?.message, ...(selectedFilter.monthYearFormat && {
|
|
36
|
+
format: "MMM yyyy",
|
|
37
|
+
views: ["year", "month"],
|
|
38
|
+
}) })),
|
|
23
39
|
dateRange: ((0, jsx_runtime_1.jsx)(FormFields_1.DateRangePicker, { name: selectedFilter.key, control: control, disabled: selectedFilter.isDisabled, error: !!errorSelectedKey, helperText: errorSelectedKey?.message })),
|
|
24
40
|
};
|
|
25
41
|
};
|
|
@@ -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
|
|
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,
|
|
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?:
|
|
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;
|
|
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 =
|
|
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:
|
|
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":"
|
|
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
|
-
|
|
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" }
|
|
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;
|
|
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":"
|
|
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
|
-
|
|
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
|
|
21
|
+
const isFileTypeValid = (file, fileTypes) => {
|
|
22
|
+
return fileTypes.includes(file.type);
|
|
23
23
|
};
|
|
24
24
|
exports.isFileTypeValid = isFileTypeValid;
|