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 +2 -8
- package/dist/index.js +240 -259
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +240 -259
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
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?:
|
|
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,
|
|
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(
|
|
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
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
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
|
-
|
|
1173
|
-
name,
|
|
1174
|
-
|
|
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
|
-
|
|
11184
|
-
|
|
11185
|
-
|
|
11186
|
-
|
|
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
|
-
|
|
11199
|
-
|
|
11200
|
-
|
|
11201
|
-
|
|
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(
|
|
11210
|
-
|
|
11211
|
-
|
|
11212
|
-
|
|
11213
|
-
|
|
11214
|
-
|
|
11215
|
-
|
|
11216
|
-
|
|
11217
|
-
|
|
11218
|
-
|
|
11219
|
-
|
|
11220
|
-
|
|
11221
|
-
|
|
11222
|
-
|
|
11223
|
-
|
|
11224
|
-
|
|
11225
|
-
|
|
11226
|
-
|
|
11227
|
-
|
|
11228
|
-
|
|
11229
|
-
|
|
11230
|
-
|
|
11231
|
-
|
|
11232
|
-
|
|
11233
|
-
|
|
11234
|
-
|
|
11235
|
-
|
|
11236
|
-
|
|
11237
|
-
|
|
11238
|
-
|
|
11239
|
-
|
|
11240
|
-
|
|
11241
|
-
|
|
11242
|
-
|
|
11243
|
-
|
|
11244
|
-
|
|
11245
|
-
|
|
11246
|
-
|
|
11247
|
-
|
|
11248
|
-
|
|
11249
|
-
|
|
11250
|
-
|
|
11251
|
-
|
|
11252
|
-
|
|
11253
|
-
|
|
11254
|
-
|
|
11255
|
-
|
|
11256
|
-
|
|
11257
|
-
|
|
11258
|
-
|
|
11259
|
-
|
|
11260
|
-
|
|
11261
|
-
|
|
11262
|
-
|
|
11263
|
-
|
|
11264
|
-
|
|
11265
|
-
|
|
11266
|
-
|
|
11267
|
-
|
|
11268
|
-
|
|
11269
|
-
|
|
11270
|
-
|
|
11271
|
-
|
|
11272
|
-
|
|
11273
|
-
|
|
11274
|
-
|
|
11275
|
-
|
|
11276
|
-
|
|
11277
|
-
|
|
11278
|
-
|
|
11279
|
-
|
|
11280
|
-
|
|
11281
|
-
|
|
11282
|
-
|
|
11283
|
-
|
|
11284
|
-
|
|
11285
|
-
|
|
11286
|
-
|
|
11287
|
-
|
|
11288
|
-
|
|
11289
|
-
|
|
11290
|
-
|
|
11291
|
-
|
|
11292
|
-
|
|
11293
|
-
|
|
11294
|
-
|
|
11295
|
-
|
|
11296
|
-
|
|
11297
|
-
|
|
11298
|
-
|
|
11299
|
-
|
|
11300
|
-
|
|
11301
|
-
|
|
11302
|
-
|
|
11303
|
-
|
|
11304
|
-
|
|
11305
|
-
|
|
11306
|
-
|
|
11307
|
-
|
|
11308
|
-
|
|
11309
|
-
|
|
11310
|
-
|
|
11311
|
-
|
|
11312
|
-
|
|
11313
|
-
|
|
11314
|
-
|
|
11315
|
-
|
|
11316
|
-
|
|
11317
|
-
|
|
11318
|
-
|
|
11319
|
-
|
|
11320
|
-
|
|
11321
|
-
|
|
11322
|
-
|
|
11323
|
-
|
|
11324
|
-
|
|
11325
|
-
|
|
11326
|
-
|
|
11327
|
-
|
|
11328
|
-
|
|
11329
|
-
|
|
11330
|
-
|
|
11331
|
-
|
|
11332
|
-
|
|
11333
|
-
|
|
11334
|
-
|
|
11335
|
-
|
|
11336
|
-
|
|
11337
|
-
|
|
11338
|
-
|
|
11339
|
-
|
|
11340
|
-
|
|
11341
|
-
|
|
11342
|
-
|
|
11343
|
-
|
|
11344
|
-
|
|
11345
|
-
|
|
11346
|
-
|
|
11347
|
-
|
|
11348
|
-
|
|
11349
|
-
|
|
11350
|
-
|
|
11351
|
-
|
|
11352
|
-
|
|
11353
|
-
|
|
11354
|
-
|
|
11355
|
-
|
|
11356
|
-
|
|
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({
|
|
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 {
|
|
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(
|
|
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(
|
|
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
|
-
|
|
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
|
|
13864
|
-
|
|
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 :
|
|
13880
|
-
files: rest.multiple ?
|
|
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:
|
|
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(
|
|
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,
|
|
13929
|
+
setFieldValue(name, "", true);
|
|
13928
13930
|
}
|
|
13929
13931
|
},
|
|
13930
|
-
onRemove: (
|
|
13931
|
-
|
|
13932
|
-
|
|
13933
|
-
|
|
13934
|
-
|
|
13935
|
-
|
|
13936
|
-
|
|
13937
|
-
|
|
13938
|
-
|
|
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
|
-
|
|
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
|
-
|
|
13960
|
-
|
|
13961
|
-
|
|
13962
|
-
|
|
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;
|