formik-form-components 0.2.13 → 0.2.15

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/index.d.ts CHANGED
@@ -492,7 +492,7 @@ interface Props$2 {
492
492
  placeholder?: string;
493
493
  required?: boolean;
494
494
  /** Variant of the input field */
495
- variant?: 'outlined' | 'filled' | 'standard';
495
+ variant?: "outlined" | "filled" | "standard";
496
496
  sx?: SxProps<Theme>;
497
497
  editorSx?: SxProps<Theme>;
498
498
  toolbarSx?: SxProps<Theme>;
@@ -825,14 +825,8 @@ interface UploadProps extends DropzoneOptions {
825
825
  interface AppUploadFilePropTypes extends UploadProps {
826
826
  name: string;
827
827
  label?: string;
828
- sx?: SxProps<Theme>;
829
- uploadSx?: SxProps<Theme>;
830
- errorSx?: SxProps<Theme>;
831
- helperTextSx?: SxProps<Theme>;
832
- previewSx?: SxProps<Theme>;
833
- dropZoneSx?: SxProps<Theme>;
834
828
  }
835
- declare const AppUploadFile: ({ name, sx, uploadSx, errorSx, helperTextSx, previewSx, dropZoneSx, ...rest }: AppUploadFilePropTypes) => react_jsx_runtime.JSX.Element;
829
+ declare const AppUploadFile: ({ name, ...rest }: AppUploadFilePropTypes) => react_jsx_runtime.JSX.Element;
836
830
 
837
831
  interface SubmitButtonProps {
838
832
  children: React__default.ReactNode;
package/dist/index.js CHANGED
@@ -7,7 +7,6 @@ var DatePicker = require('@mui/x-date-pickers/DatePicker');
7
7
  var LocalizationProvider = require('@mui/x-date-pickers/LocalizationProvider');
8
8
  var AdapterDayjs = require('@mui/x-date-pickers/AdapterDayjs');
9
9
  var dayjs = require('dayjs');
10
- var demo = require('@mui/x-date-pickers/internals/demo');
11
10
  var _19 = require('lodash');
12
11
  var jsxRuntime = require('react/jsx-runtime');
13
12
  var DateTimePicker = require('@mui/x-date-pickers/DateTimePicker');
@@ -103,7 +102,7 @@ var AppDatePicker = react.forwardRef(
103
102
  externalOnBlur(event);
104
103
  }
105
104
  };
106
- return /* @__PURE__ */ jsxRuntime.jsx(LocalizationProvider.LocalizationProvider, { dateAdapter: AdapterDayjs.AdapterDayjs, children: /* @__PURE__ */ jsxRuntime.jsx(material.Box, { sx, ref, children: /* @__PURE__ */ jsxRuntime.jsx(demo.DemoContainer, { components: ["DatePicker"], children: /* @__PURE__ */ jsxRuntime.jsx(
105
+ return /* @__PURE__ */ jsxRuntime.jsx(LocalizationProvider.LocalizationProvider, { dateAdapter: AdapterDayjs.AdapterDayjs, children: /* @__PURE__ */ jsxRuntime.jsx(material.Box, { sx, ref, children: /* @__PURE__ */ jsxRuntime.jsx(
107
106
  DatePicker.DatePicker,
108
107
  {
109
108
  label,
@@ -198,7 +197,7 @@ var AppDatePicker = react.forwardRef(
198
197
  },
199
198
  ...otherProps
200
199
  }
201
- ) }) }) });
200
+ ) }) });
202
201
  }
203
202
  );
204
203
  AppDatePicker.displayName = "AppDatePicker";
@@ -1097,10 +1096,19 @@ var AppCheckBox = ({
1097
1096
  const isTouched = _19__default.default.get(touched, name);
1098
1097
  material.useTheme();
1099
1098
  const value = getFieldProps(name).value;
1100
- const checkedNames = Array.isArray(value) ? value : value ? [value] : [];
1101
- const handleChange = (itemName, isChecked) => {
1102
- const newValue = isChecked ? [...checkedNames, itemName] : checkedNames.filter((n) => n !== itemName);
1103
- setFieldValue(name, option.length === 1 ? isChecked : newValue);
1099
+ const checkedValues = (() => {
1100
+ if (Array.isArray(value)) {
1101
+ return value.map(String);
1102
+ }
1103
+ return value ? [String(value)] : [];
1104
+ })();
1105
+ const handleChange = (itemValue, isChecked) => {
1106
+ if (option.length === 1) {
1107
+ setFieldValue(name, isChecked ? itemValue : false);
1108
+ } else {
1109
+ const newValue = isChecked ? [...checkedValues, String(itemValue)] : checkedValues.filter((v) => v !== String(itemValue));
1110
+ setFieldValue(name, newValue);
1111
+ }
1104
1112
  };
1105
1113
  return /* @__PURE__ */ jsxRuntime.jsxs(
1106
1114
  material.Box,
@@ -1169,11 +1177,9 @@ var AppCheckBox = ({
1169
1177
  /* @__PURE__ */ jsxRuntime.jsx(
1170
1178
  material.Checkbox,
1171
1179
  {
1172
- ...getFieldProps(name),
1173
- name,
1174
- value: item.name,
1175
- checked: checkedNames.includes(item.name),
1176
- onChange: (e) => handleChange(item.name, e.target.checked),
1180
+ name: `${name}.${item.name}`,
1181
+ checked: option.length === 1 ? getFieldProps(name).value === item.value : checkedValues.includes(String(item.value)),
1182
+ onChange: (e) => handleChange(item.value, e.target.checked),
1177
1183
  disabled: disabled || item.disabled,
1178
1184
  sx: [{
1179
1185
  color: "primary.main",
@@ -11179,12 +11185,14 @@ var AppRichTextEditor = ({
11179
11185
  material.Typography,
11180
11186
  {
11181
11187
  variant: "caption",
11182
- sx: [{
11183
- color: "error.main",
11184
- display: "block",
11185
- mt: 0.5,
11186
- ...errorSx
11187
- }],
11188
+ sx: [
11189
+ {
11190
+ color: "error.main",
11191
+ display: "block",
11192
+ mt: 0.5,
11193
+ ...errorSx
11194
+ }
11195
+ ],
11188
11196
  children: msg
11189
11197
  }
11190
11198
  )
@@ -11194,167 +11202,173 @@ var AppRichTextEditor = ({
11194
11202
  material.Typography,
11195
11203
  {
11196
11204
  variant: "button",
11197
- sx: [{
11198
- color: "text.primary",
11199
- mb: 1,
11200
- display: "block",
11201
- ...labelSx
11202
- }],
11205
+ sx: [
11206
+ {
11207
+ color: "text.primary",
11208
+ mb: 1,
11209
+ display: "block",
11210
+ ...labelSx
11211
+ }
11212
+ ],
11203
11213
  children: [
11204
11214
  label,
11205
11215
  required && /* @__PURE__ */ jsxRuntime.jsx(material.Typography, { component: "span", sx: { color: "error.main", ml: 0.5 }, children: "*" })
11206
11216
  ]
11207
11217
  }
11208
11218
  ),
11209
- /* @__PURE__ */ jsxRuntime.jsxs(material.Box, { sx: {
11210
- mb: 1,
11211
- display: "flex",
11212
- gap: 1,
11213
- flexWrap: "wrap",
11214
- p: 1,
11215
- bgcolor: "background.paper",
11216
- borderRadius: 1,
11217
- border: "1px solid",
11218
- borderColor: "divider",
11219
- ...toolbarSx
11220
- }, children: [
11221
- /* @__PURE__ */ jsxRuntime.jsx(material.Tooltip, { title: "Bold", children: /* @__PURE__ */ jsxRuntime.jsx(
11222
- material.IconButton,
11223
- {
11224
- onClick: () => editor.chain().focus().toggleBold().run(),
11225
- color: editor.isActive("bold") ? "primary" : "default",
11226
- sx: {
11227
- ...buttonSx,
11228
- ...editor.isActive("bold") ? activeButtonSx : {}
11229
- },
11230
- children: /* @__PURE__ */ jsxRuntime.jsx(FormatBoldIcon__default.default, {})
11231
- }
11232
- ) }),
11233
- /* @__PURE__ */ jsxRuntime.jsx(material.Tooltip, { title: "Italic", children: /* @__PURE__ */ jsxRuntime.jsx(
11234
- material.IconButton,
11235
- {
11236
- onClick: () => editor.chain().focus().toggleItalic().run(),
11237
- color: editor.isActive("italic") ? "primary" : "default",
11238
- sx: {
11239
- ...buttonSx,
11240
- ...editor.isActive("italic") ? activeButtonSx : {}
11241
- },
11242
- children: /* @__PURE__ */ jsxRuntime.jsx(FormatItalicIcon__default.default, {})
11243
- }
11244
- ) }),
11245
- /* @__PURE__ */ jsxRuntime.jsx(material.Tooltip, { title: "Underline", children: /* @__PURE__ */ jsxRuntime.jsx(
11246
- material.IconButton,
11247
- {
11248
- onClick: () => editor.chain().focus().toggleUnderline().run(),
11249
- color: editor.isActive("underline") ? "primary" : "default",
11250
- sx: {
11251
- ...buttonSx,
11252
- ...editor.isActive("underline") ? activeButtonSx : {}
11253
- },
11254
- children: /* @__PURE__ */ jsxRuntime.jsx(FormatUnderlinedIcon__default.default, {})
11255
- }
11256
- ) }),
11257
- /* @__PURE__ */ jsxRuntime.jsx(material.Tooltip, { title: "Strike", children: /* @__PURE__ */ jsxRuntime.jsx(
11258
- material.IconButton,
11259
- {
11260
- onClick: () => editor.chain().focus().toggleStrike().run(),
11261
- color: editor.isActive("strike") ? "primary" : "default",
11262
- sx: {
11263
- ...buttonSx,
11264
- ...editor.isActive("strike") ? activeButtonSx : {}
11265
- },
11266
- children: /* @__PURE__ */ jsxRuntime.jsx(StrikethroughSIcon__default.default, {})
11267
- }
11268
- ) }),
11269
- /* @__PURE__ */ jsxRuntime.jsx(material.Tooltip, { title: "Bullet List", children: /* @__PURE__ */ jsxRuntime.jsx(
11270
- material.IconButton,
11271
- {
11272
- onClick: () => editor.chain().focus().toggleBulletList().run(),
11273
- color: editor.isActive("bulletList") ? "primary" : "default",
11274
- sx: {
11275
- ...buttonSx,
11276
- ...editor.isActive("bulletList") ? activeButtonSx : {}
11277
- },
11278
- children: /* @__PURE__ */ jsxRuntime.jsx(FormatListBulletedIcon__default.default, {})
11279
- }
11280
- ) }),
11281
- /* @__PURE__ */ jsxRuntime.jsx(material.Tooltip, { title: "Numbered List", children: /* @__PURE__ */ jsxRuntime.jsx(
11282
- material.IconButton,
11283
- {
11284
- onClick: () => editor.chain().focus().toggleOrderedList().run(),
11285
- color: editor.isActive("orderedList") ? "primary" : "default",
11286
- sx: {
11287
- ...buttonSx,
11288
- ...editor.isActive("orderedList") ? activeButtonSx : {}
11289
- },
11290
- children: /* @__PURE__ */ jsxRuntime.jsx(FormatListNumberedIcon__default.default, {})
11291
- }
11292
- ) }),
11293
- /* @__PURE__ */ jsxRuntime.jsx(material.Tooltip, { title: "Align Left", children: /* @__PURE__ */ jsxRuntime.jsx(
11294
- material.IconButton,
11295
- {
11296
- onClick: () => editor.chain().focus().setTextAlign("left").run(),
11297
- color: editor.isActive({ textAlign: "left" }) ? "primary" : "default",
11298
- sx: {
11299
- ...buttonSx,
11300
- ...editor.isActive({ textAlign: "left" }) ? activeButtonSx : {}
11301
- },
11302
- children: /* @__PURE__ */ jsxRuntime.jsx(FormatAlignLeftIcon__default.default, {})
11303
- }
11304
- ) }),
11305
- /* @__PURE__ */ jsxRuntime.jsx(material.Tooltip, { title: "Align Center", children: /* @__PURE__ */ jsxRuntime.jsx(
11306
- material.IconButton,
11307
- {
11308
- onClick: () => editor.chain().focus().setTextAlign("center").run(),
11309
- color: editor.isActive({ textAlign: "center" }) ? "primary" : "default",
11310
- sx: {
11311
- ...buttonSx,
11312
- ...editor.isActive({ textAlign: "center" }) ? activeButtonSx : {}
11313
- },
11314
- children: /* @__PURE__ */ jsxRuntime.jsx(FormatAlignCenterIcon__default.default, {})
11315
- }
11316
- ) }),
11317
- /* @__PURE__ */ jsxRuntime.jsx(material.Tooltip, { title: "Align Right", children: /* @__PURE__ */ jsxRuntime.jsx(
11318
- material.IconButton,
11319
- {
11320
- onClick: () => editor.chain().focus().setTextAlign("right").run(),
11321
- color: editor.isActive({ textAlign: "right" }) ? "primary" : "default",
11322
- sx: {
11323
- ...buttonSx,
11324
- ...editor.isActive({ textAlign: "right" }) ? activeButtonSx : {}
11325
- },
11326
- children: /* @__PURE__ */ jsxRuntime.jsx(FormatAlignRightIcon__default.default, {})
11327
- }
11328
- ) }),
11329
- /* @__PURE__ */ jsxRuntime.jsx(material.Tooltip, { title: "Heading 1", children: /* @__PURE__ */ jsxRuntime.jsx(
11330
- material.IconButton,
11331
- {
11332
- onClick: () => editor.chain().focus().toggleHeading({ level: 1 }).run(),
11333
- color: editor.isActive("heading", { level: 1 }) ? "primary" : "default",
11334
- sx: {
11335
- ...buttonSx,
11336
- ...editor.isActive("heading", { level: 1 }) ? activeButtonSx : {}
11337
- },
11338
- children: /* @__PURE__ */ jsxRuntime.jsx(TitleIcon__default.default, { sx: { fontSize: "1rem" } })
11339
- }
11340
- ) }),
11341
- /* @__PURE__ */ jsxRuntime.jsx(material.Tooltip, { title: "Heading 2", children: /* @__PURE__ */ jsxRuntime.jsxs(
11342
- material.IconButton,
11343
- {
11344
- onClick: () => editor.chain().focus().toggleHeading({ level: 2 }).run(),
11345
- color: editor.isActive("heading", { level: 2 }) ? "primary" : "default",
11346
- sx: {
11347
- ...buttonSx,
11348
- ...editor.isActive("heading", { level: 2 }) ? activeButtonSx : {}
11349
- },
11350
- children: [
11351
- /* @__PURE__ */ jsxRuntime.jsx(TitleIcon__default.default, { sx: { fontSize: "0.85rem" } }),
11352
- /* @__PURE__ */ jsxRuntime.jsx(UndoIcon__default.default, {})
11353
- ]
11354
- }
11355
- ) }),
11356
- /* @__PURE__ */ jsxRuntime.jsx(material.Tooltip, { title: "Redo", children: /* @__PURE__ */ jsxRuntime.jsx(material.IconButton, { onClick: () => editor.chain().focus().redo().run(), children: /* @__PURE__ */ jsxRuntime.jsx(RedoIcon__default.default, {}) }) })
11357
- ] }),
11219
+ /* @__PURE__ */ jsxRuntime.jsxs(
11220
+ material.Box,
11221
+ {
11222
+ sx: {
11223
+ mb: 1,
11224
+ display: "flex",
11225
+ gap: 1,
11226
+ flexWrap: "wrap",
11227
+ p: 1,
11228
+ bgcolor: "background.paper",
11229
+ borderRadius: 1,
11230
+ border: "1px solid",
11231
+ borderColor: "divider",
11232
+ ...toolbarSx
11233
+ },
11234
+ children: [
11235
+ /* @__PURE__ */ jsxRuntime.jsx(material.Tooltip, { title: "Bold", children: /* @__PURE__ */ jsxRuntime.jsx(
11236
+ material.IconButton,
11237
+ {
11238
+ onClick: () => editor.chain().focus().toggleBold().run(),
11239
+ color: editor.isActive("bold") ? "primary" : "default",
11240
+ sx: {
11241
+ ...buttonSx,
11242
+ ...editor.isActive("bold") ? activeButtonSx : {}
11243
+ },
11244
+ children: /* @__PURE__ */ jsxRuntime.jsx(FormatBoldIcon__default.default, {})
11245
+ }
11246
+ ) }),
11247
+ /* @__PURE__ */ jsxRuntime.jsx(material.Tooltip, { title: "Italic", children: /* @__PURE__ */ jsxRuntime.jsx(
11248
+ material.IconButton,
11249
+ {
11250
+ onClick: () => editor.chain().focus().toggleItalic().run(),
11251
+ color: editor.isActive("italic") ? "primary" : "default",
11252
+ sx: {
11253
+ ...buttonSx,
11254
+ ...editor.isActive("italic") ? activeButtonSx : {}
11255
+ },
11256
+ children: /* @__PURE__ */ jsxRuntime.jsx(FormatItalicIcon__default.default, {})
11257
+ }
11258
+ ) }),
11259
+ /* @__PURE__ */ jsxRuntime.jsx(material.Tooltip, { title: "Underline", children: /* @__PURE__ */ jsxRuntime.jsx(
11260
+ material.IconButton,
11261
+ {
11262
+ onClick: () => editor.chain().focus().toggleUnderline().run(),
11263
+ color: editor.isActive("underline") ? "primary" : "default",
11264
+ sx: {
11265
+ ...buttonSx,
11266
+ ...editor.isActive("underline") ? activeButtonSx : {}
11267
+ },
11268
+ children: /* @__PURE__ */ jsxRuntime.jsx(FormatUnderlinedIcon__default.default, {})
11269
+ }
11270
+ ) }),
11271
+ /* @__PURE__ */ jsxRuntime.jsx(material.Tooltip, { title: "Strike", children: /* @__PURE__ */ jsxRuntime.jsx(
11272
+ material.IconButton,
11273
+ {
11274
+ onClick: () => editor.chain().focus().toggleStrike().run(),
11275
+ color: editor.isActive("strike") ? "primary" : "default",
11276
+ sx: {
11277
+ ...buttonSx,
11278
+ ...editor.isActive("strike") ? activeButtonSx : {}
11279
+ },
11280
+ children: /* @__PURE__ */ jsxRuntime.jsx(StrikethroughSIcon__default.default, {})
11281
+ }
11282
+ ) }),
11283
+ /* @__PURE__ */ jsxRuntime.jsx(material.Tooltip, { title: "Bullet List", children: /* @__PURE__ */ jsxRuntime.jsx(
11284
+ material.IconButton,
11285
+ {
11286
+ onClick: () => editor.chain().focus().toggleBulletList().run(),
11287
+ color: editor.isActive("bulletList") ? "primary" : "default",
11288
+ sx: {
11289
+ ...buttonSx,
11290
+ ...editor.isActive("bulletList") ? activeButtonSx : {}
11291
+ },
11292
+ children: /* @__PURE__ */ jsxRuntime.jsx(FormatListBulletedIcon__default.default, {})
11293
+ }
11294
+ ) }),
11295
+ /* @__PURE__ */ jsxRuntime.jsx(material.Tooltip, { title: "Numbered List", children: /* @__PURE__ */ jsxRuntime.jsx(
11296
+ material.IconButton,
11297
+ {
11298
+ onClick: () => editor.chain().focus().toggleOrderedList().run(),
11299
+ color: editor.isActive("orderedList") ? "primary" : "default",
11300
+ sx: {
11301
+ ...buttonSx,
11302
+ ...editor.isActive("orderedList") ? activeButtonSx : {}
11303
+ },
11304
+ children: /* @__PURE__ */ jsxRuntime.jsx(FormatListNumberedIcon__default.default, {})
11305
+ }
11306
+ ) }),
11307
+ /* @__PURE__ */ jsxRuntime.jsx(material.Tooltip, { title: "Align Left", children: /* @__PURE__ */ jsxRuntime.jsx(
11308
+ material.IconButton,
11309
+ {
11310
+ onClick: () => editor.chain().focus().setTextAlign("left").run(),
11311
+ color: editor.isActive({ textAlign: "left" }) ? "primary" : "default",
11312
+ sx: {
11313
+ ...buttonSx,
11314
+ ...editor.isActive({ textAlign: "left" }) ? activeButtonSx : {}
11315
+ },
11316
+ children: /* @__PURE__ */ jsxRuntime.jsx(FormatAlignLeftIcon__default.default, {})
11317
+ }
11318
+ ) }),
11319
+ /* @__PURE__ */ jsxRuntime.jsx(material.Tooltip, { title: "Align Center", children: /* @__PURE__ */ jsxRuntime.jsx(
11320
+ material.IconButton,
11321
+ {
11322
+ onClick: () => editor.chain().focus().setTextAlign("center").run(),
11323
+ color: editor.isActive({ textAlign: "center" }) ? "primary" : "default",
11324
+ sx: {
11325
+ ...buttonSx,
11326
+ ...editor.isActive({ textAlign: "center" }) ? activeButtonSx : {}
11327
+ },
11328
+ children: /* @__PURE__ */ jsxRuntime.jsx(FormatAlignCenterIcon__default.default, {})
11329
+ }
11330
+ ) }),
11331
+ /* @__PURE__ */ jsxRuntime.jsx(material.Tooltip, { title: "Align Right", children: /* @__PURE__ */ jsxRuntime.jsx(
11332
+ material.IconButton,
11333
+ {
11334
+ onClick: () => editor.chain().focus().setTextAlign("right").run(),
11335
+ color: editor.isActive({ textAlign: "right" }) ? "primary" : "default",
11336
+ sx: {
11337
+ ...buttonSx,
11338
+ ...editor.isActive({ textAlign: "right" }) ? activeButtonSx : {}
11339
+ },
11340
+ children: /* @__PURE__ */ jsxRuntime.jsx(FormatAlignRightIcon__default.default, {})
11341
+ }
11342
+ ) }),
11343
+ /* @__PURE__ */ jsxRuntime.jsx(material.Tooltip, { title: "Heading 1", children: /* @__PURE__ */ jsxRuntime.jsx(
11344
+ material.IconButton,
11345
+ {
11346
+ onClick: () => editor.chain().focus().toggleHeading({ level: 1 }).run(),
11347
+ color: editor.isActive("heading", { level: 1 }) ? "primary" : "default",
11348
+ sx: {
11349
+ ...buttonSx,
11350
+ ...editor.isActive("heading", { level: 1 }) ? activeButtonSx : {}
11351
+ },
11352
+ children: /* @__PURE__ */ jsxRuntime.jsx(TitleIcon__default.default, { sx: { fontSize: "1rem" } })
11353
+ }
11354
+ ) }),
11355
+ /* @__PURE__ */ jsxRuntime.jsx(material.Tooltip, { title: "Heading 2", children: /* @__PURE__ */ jsxRuntime.jsx(
11356
+ material.IconButton,
11357
+ {
11358
+ onClick: () => editor.chain().focus().toggleHeading({ level: 2 }).run(),
11359
+ color: editor.isActive("heading", { level: 2 }) ? "primary" : "default",
11360
+ sx: {
11361
+ ...buttonSx,
11362
+ ...editor.isActive("heading", { level: 2 }) ? activeButtonSx : {}
11363
+ },
11364
+ children: /* @__PURE__ */ jsxRuntime.jsx(TitleIcon__default.default, { sx: { fontSize: "0.85rem" } })
11365
+ }
11366
+ ) }),
11367
+ /* @__PURE__ */ jsxRuntime.jsx(material.Tooltip, { title: "Undo", children: /* @__PURE__ */ jsxRuntime.jsx(material.IconButton, { onClick: () => editor.chain().focus().undo().run(), children: /* @__PURE__ */ jsxRuntime.jsx(UndoIcon__default.default, {}) }) }),
11368
+ /* @__PURE__ */ jsxRuntime.jsx(material.Tooltip, { title: "Redo", children: /* @__PURE__ */ jsxRuntime.jsx(material.IconButton, { onClick: () => editor.chain().focus().redo().run(), children: /* @__PURE__ */ jsxRuntime.jsx(RedoIcon__default.default, {}) }) })
11369
+ ]
11370
+ }
11371
+ ),
11358
11372
  /* @__PURE__ */ jsxRuntime.jsx(
11359
11373
  material.Box,
11360
11374
  {
@@ -13054,7 +13068,9 @@ function MultiFilePreview({
13054
13068
  );
13055
13069
  }) });
13056
13070
  }
13057
- function SingleFilePreview({ file }) {
13071
+ function SingleFilePreview({
13072
+ file
13073
+ }) {
13058
13074
  if (!file) {
13059
13075
  return null;
13060
13076
  }
@@ -13704,7 +13720,13 @@ function Upload({
13704
13720
  sx,
13705
13721
  ...other
13706
13722
  }) {
13707
- const { getRootProps, getInputProps, isDragActive, isDragReject, fileRejections } = reactDropzone.useDropzone({
13723
+ const {
13724
+ getRootProps,
13725
+ getInputProps,
13726
+ isDragActive,
13727
+ isDragReject,
13728
+ fileRejections
13729
+ } = reactDropzone.useDropzone({
13708
13730
  multiple,
13709
13731
  disabled,
13710
13732
  ...other
@@ -13773,9 +13795,25 @@ function Upload({
13773
13795
  }
13774
13796
  ),
13775
13797
  hasFiles === true && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
13776
- /* @__PURE__ */ jsxRuntime.jsx(material.Box, { sx: { my: 3 }, children: /* @__PURE__ */ jsxRuntime.jsx(MultiFilePreview, { files, thumbnail, onRemove }) }),
13798
+ /* @__PURE__ */ jsxRuntime.jsx(material.Box, { sx: { my: 3 }, children: /* @__PURE__ */ jsxRuntime.jsx(
13799
+ MultiFilePreview,
13800
+ {
13801
+ files,
13802
+ thumbnail,
13803
+ onRemove
13804
+ }
13805
+ ) }),
13777
13806
  /* @__PURE__ */ jsxRuntime.jsxs(material.Stack, { direction: "row", justifyContent: "flex-end", spacing: 1.5, children: [
13778
- onRemoveAll && /* @__PURE__ */ jsxRuntime.jsx(material.Button, { color: "inherit", variant: "outlined", size: "small", onClick: onRemoveAll, children: t("Remove all") }),
13807
+ onRemoveAll && /* @__PURE__ */ jsxRuntime.jsx(
13808
+ material.Button,
13809
+ {
13810
+ color: "inherit",
13811
+ variant: "outlined",
13812
+ size: "small",
13813
+ onClick: onRemoveAll,
13814
+ children: t("Remove all")
13815
+ }
13816
+ ),
13779
13817
  onUpload && /* @__PURE__ */ jsxRuntime.jsx(material.Button, { size: "small", variant: "contained", onClick: onUpload, children: t("Upload files") })
13780
13818
  ] })
13781
13819
  ] })
@@ -13840,17 +13878,8 @@ async function blobToBase64(file) {
13840
13878
  };
13841
13879
  });
13842
13880
  }
13843
- var AppUploadFile = ({
13844
- name,
13845
- sx,
13846
- uploadSx,
13847
- errorSx,
13848
- helperTextSx,
13849
- previewSx,
13850
- dropZoneSx,
13851
- ...rest
13852
- }) => {
13853
- var _a, _b;
13881
+ var AppUploadFile = ({ name, ...rest }) => {
13882
+ var _a, _b, _c, _d, _e;
13854
13883
  const { errors, touched, setFieldValue, values } = formik.useFormikContext();
13855
13884
  const fieldError = _19__default.default.get(errors, name);
13856
13885
  const isTouched = _19__default.default.get(touched, name);
@@ -13860,43 +13889,16 @@ var AppUploadFile = ({
13860
13889
  } else if (!((_b = rest.multiple) != null ? _b : false) && _19__default.default.isArray(val)) {
13861
13890
  val = val[0];
13862
13891
  }
13863
- const formatValue = (val2) => {
13864
- if (rest.multiple) {
13865
- return (Array.isArray(val2) ? val2 : []).map((item) => ({
13866
- ...(item == null ? void 0 : item.file) ? item : { file: item, preview: item == null ? void 0 : item.preview }
13867
- }));
13868
- }
13869
- return (val2 == null ? void 0 : val2.file) ? val2 : val2 ? { file: val2, preview: val2.preview } : null;
13870
- };
13871
- const formattedValue = formatValue(val);
13872
- const currentFiles = Array.isArray(val) ? val : [];
13873
- const isMaxFilesReached = rest.maxFiles !== null && rest.maxFiles !== void 0 && currentFiles.length >= rest.maxFiles;
13874
- return /* @__PURE__ */ jsxRuntime.jsxs(material.Box, { sx, children: [
13892
+ const value = ((_c = rest.multiple) != null ? _c : false) ? (val != null ? val : []).map((__) => (__ == null ? void 0 : __.file) ? __ == null ? void 0 : __.file : __) : val;
13893
+ return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
13875
13894
  /* @__PURE__ */ jsxRuntime.jsx(
13876
13895
  Upload,
13877
13896
  {
13878
13897
  ...rest,
13879
- file: rest.multiple ? void 0 : formattedValue,
13880
- files: rest.multiple ? formattedValue : void 0,
13898
+ file: ((_d = rest.multiple) != null ? _d : false) ? void 0 : value,
13899
+ files: ((_e = rest.multiple) != null ? _e : false) ? value : void 0,
13881
13900
  error: Boolean(fieldError) && isTouched,
13882
- disabled: isMaxFilesReached,
13883
- sx: [{
13884
- "& .MuiDropzoneArea-root": {
13885
- minHeight: 200,
13886
- border: "2px dashed",
13887
- borderColor: "divider",
13888
- borderRadius: 1,
13889
- "&:hover": {
13890
- borderColor: "primary.main",
13891
- backgroundColor: "action.hover"
13892
- },
13893
- ...dropZoneSx
13894
- },
13895
- "& .MuiDropzonePreviewList-root": {
13896
- ...previewSx
13897
- },
13898
- ...uploadSx
13899
- }],
13901
+ disabled: (rest == null ? void 0 : rest.maxFiles) !== null && (rest == null ? void 0 : rest.maxFiles) !== void 0 && (value == null ? void 0 : value.length) >= (rest == null ? void 0 : rest.maxFiles),
13900
13902
  onDrop: (fileVal) => {
13901
13903
  (async () => {
13902
13904
  var _a2;
@@ -13909,7 +13911,7 @@ var AppUploadFile = ({
13909
13911
  };
13910
13912
  })
13911
13913
  );
13912
- const currentValue = Array.isArray(val) ? [...val] : [];
13914
+ const currentValue = Array.isArray(value) ? value : [];
13913
13915
  if (rest.multiple === true) {
13914
13916
  if (currentValue.length >= ((_a2 = rest.maxFiles) != null ? _a2 : Infinity))
13915
13917
  return;
@@ -13924,57 +13926,36 @@ var AppUploadFile = ({
13924
13926
  if ((_a2 = rest.multiple) != null ? _a2 : false) {
13925
13927
  setFieldValue(name, [], true);
13926
13928
  } else {
13927
- setFieldValue(name, null, true);
13929
+ setFieldValue(name, "", true);
13928
13930
  }
13929
13931
  },
13930
- onRemove: (fileToRemove) => {
13931
- if (rest.multiple) {
13932
- const currentFiles2 = Array.isArray(val) ? [...val] : [];
13933
- const filteredFiles = currentFiles2.filter((file) => {
13934
- const fileObj = (file == null ? void 0 : file.file) ? file.file : file;
13935
- return !_19__default.default.isEqual(fileObj, fileToRemove);
13936
- });
13937
- setFieldValue(name, filteredFiles, true);
13938
- } else {
13939
- setFieldValue(name, null, true);
13940
- }
13932
+ onRemove: (e) => {
13933
+ const afterFilter = val.filter((file) => {
13934
+ var _a2;
13935
+ if ((_a2 = file.file) != null ? _a2 : false) {
13936
+ return !_19__default.default.isEqual(e, file.file);
13937
+ }
13938
+ return !_19__default.default.isEqual(e, file);
13939
+ });
13940
+ setFieldValue(name, afterFilter, true);
13941
13941
  }
13942
13942
  }
13943
13943
  ),
13944
13944
  Boolean(fieldError) && Boolean(isTouched) && /* @__PURE__ */ jsxRuntime.jsx(
13945
13945
  material.Typography,
13946
13946
  {
13947
+ color: "#FF5630",
13947
13948
  variant: "caption",
13948
- sx: [{
13949
- color: "error.main",
13950
- display: "block",
13951
- mt: 0.5,
13952
- ...errorSx
13953
- }],
13949
+ display: "block",
13954
13950
  gutterBottom: true,
13955
13951
  children: fieldError
13956
13952
  }
13957
13953
  ),
13958
- rest.maxFiles != null && /* @__PURE__ */ jsxRuntime.jsxs(
13959
- material.Typography,
13960
- {
13961
- variant: "caption",
13962
- sx: [{
13963
- display: "block",
13964
- color: "text.secondary",
13965
- mt: 0.5,
13966
- ...helperTextSx
13967
- }],
13968
- gutterBottom: true,
13969
- children: [
13970
- "Maximum ",
13971
- rest.maxFiles,
13972
- " file",
13973
- rest.maxFiles !== 1 ? "s" : "",
13974
- " allowed"
13975
- ]
13976
- }
13977
- )
13954
+ rest.maxFiles != null && /* @__PURE__ */ jsxRuntime.jsxs(material.Typography, { variant: "caption", display: "block", gutterBottom: true, children: [
13955
+ "Maximum ",
13956
+ rest.maxFiles,
13957
+ " file allowed"
13958
+ ] })
13978
13959
  ] });
13979
13960
  };
13980
13961
  var AppUploadFile_default = AppUploadFile;