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.mjs
CHANGED
|
@@ -5,7 +5,6 @@ import { DatePicker } from '@mui/x-date-pickers/DatePicker';
|
|
|
5
5
|
import { LocalizationProvider } from '@mui/x-date-pickers/LocalizationProvider';
|
|
6
6
|
import { AdapterDayjs } from '@mui/x-date-pickers/AdapterDayjs';
|
|
7
7
|
import { Dayjs } from 'dayjs';
|
|
8
|
-
import { DemoContainer } from '@mui/x-date-pickers/internals/demo';
|
|
9
8
|
import _19, { get } from 'lodash';
|
|
10
9
|
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
11
10
|
import { DateTimePicker } from '@mui/x-date-pickers/DateTimePicker';
|
|
@@ -76,7 +75,7 @@ var AppDatePicker = forwardRef(
|
|
|
76
75
|
externalOnBlur(event);
|
|
77
76
|
}
|
|
78
77
|
};
|
|
79
|
-
return /* @__PURE__ */ jsx(LocalizationProvider, { dateAdapter: AdapterDayjs, children: /* @__PURE__ */ jsx(Box, { sx, ref, children: /* @__PURE__ */ jsx(
|
|
78
|
+
return /* @__PURE__ */ jsx(LocalizationProvider, { dateAdapter: AdapterDayjs, children: /* @__PURE__ */ jsx(Box, { sx, ref, children: /* @__PURE__ */ jsx(
|
|
80
79
|
DatePicker,
|
|
81
80
|
{
|
|
82
81
|
label,
|
|
@@ -171,7 +170,7 @@ var AppDatePicker = forwardRef(
|
|
|
171
170
|
},
|
|
172
171
|
...otherProps
|
|
173
172
|
}
|
|
174
|
-
) }) })
|
|
173
|
+
) }) });
|
|
175
174
|
}
|
|
176
175
|
);
|
|
177
176
|
AppDatePicker.displayName = "AppDatePicker";
|
|
@@ -1070,10 +1069,19 @@ var AppCheckBox = ({
|
|
|
1070
1069
|
const isTouched = _19.get(touched, name);
|
|
1071
1070
|
useTheme();
|
|
1072
1071
|
const value = getFieldProps(name).value;
|
|
1073
|
-
const
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1072
|
+
const checkedValues = (() => {
|
|
1073
|
+
if (Array.isArray(value)) {
|
|
1074
|
+
return value.map(String);
|
|
1075
|
+
}
|
|
1076
|
+
return value ? [String(value)] : [];
|
|
1077
|
+
})();
|
|
1078
|
+
const handleChange = (itemValue, isChecked) => {
|
|
1079
|
+
if (option.length === 1) {
|
|
1080
|
+
setFieldValue(name, isChecked ? itemValue : false);
|
|
1081
|
+
} else {
|
|
1082
|
+
const newValue = isChecked ? [...checkedValues, String(itemValue)] : checkedValues.filter((v) => v !== String(itemValue));
|
|
1083
|
+
setFieldValue(name, newValue);
|
|
1084
|
+
}
|
|
1077
1085
|
};
|
|
1078
1086
|
return /* @__PURE__ */ jsxs(
|
|
1079
1087
|
Box,
|
|
@@ -1142,11 +1150,9 @@ var AppCheckBox = ({
|
|
|
1142
1150
|
/* @__PURE__ */ jsx(
|
|
1143
1151
|
Checkbox,
|
|
1144
1152
|
{
|
|
1145
|
-
|
|
1146
|
-
name,
|
|
1147
|
-
|
|
1148
|
-
checked: checkedNames.includes(item.name),
|
|
1149
|
-
onChange: (e) => handleChange(item.name, e.target.checked),
|
|
1153
|
+
name: `${name}.${item.name}`,
|
|
1154
|
+
checked: option.length === 1 ? getFieldProps(name).value === item.value : checkedValues.includes(String(item.value)),
|
|
1155
|
+
onChange: (e) => handleChange(item.value, e.target.checked),
|
|
1150
1156
|
disabled: disabled || item.disabled,
|
|
1151
1157
|
sx: [{
|
|
1152
1158
|
color: "primary.main",
|
|
@@ -11152,12 +11158,14 @@ var AppRichTextEditor = ({
|
|
|
11152
11158
|
Typography,
|
|
11153
11159
|
{
|
|
11154
11160
|
variant: "caption",
|
|
11155
|
-
sx: [
|
|
11156
|
-
|
|
11157
|
-
|
|
11158
|
-
|
|
11159
|
-
|
|
11160
|
-
|
|
11161
|
+
sx: [
|
|
11162
|
+
{
|
|
11163
|
+
color: "error.main",
|
|
11164
|
+
display: "block",
|
|
11165
|
+
mt: 0.5,
|
|
11166
|
+
...errorSx
|
|
11167
|
+
}
|
|
11168
|
+
],
|
|
11161
11169
|
children: msg
|
|
11162
11170
|
}
|
|
11163
11171
|
)
|
|
@@ -11167,167 +11175,173 @@ var AppRichTextEditor = ({
|
|
|
11167
11175
|
Typography,
|
|
11168
11176
|
{
|
|
11169
11177
|
variant: "button",
|
|
11170
|
-
sx: [
|
|
11171
|
-
|
|
11172
|
-
|
|
11173
|
-
|
|
11174
|
-
|
|
11175
|
-
|
|
11178
|
+
sx: [
|
|
11179
|
+
{
|
|
11180
|
+
color: "text.primary",
|
|
11181
|
+
mb: 1,
|
|
11182
|
+
display: "block",
|
|
11183
|
+
...labelSx
|
|
11184
|
+
}
|
|
11185
|
+
],
|
|
11176
11186
|
children: [
|
|
11177
11187
|
label,
|
|
11178
11188
|
required && /* @__PURE__ */ jsx(Typography, { component: "span", sx: { color: "error.main", ml: 0.5 }, children: "*" })
|
|
11179
11189
|
]
|
|
11180
11190
|
}
|
|
11181
11191
|
),
|
|
11182
|
-
/* @__PURE__ */ jsxs(
|
|
11183
|
-
|
|
11184
|
-
|
|
11185
|
-
|
|
11186
|
-
|
|
11187
|
-
|
|
11188
|
-
|
|
11189
|
-
|
|
11190
|
-
|
|
11191
|
-
|
|
11192
|
-
|
|
11193
|
-
|
|
11194
|
-
|
|
11195
|
-
|
|
11196
|
-
|
|
11197
|
-
|
|
11198
|
-
|
|
11199
|
-
|
|
11200
|
-
|
|
11201
|
-
|
|
11202
|
-
|
|
11203
|
-
|
|
11204
|
-
|
|
11205
|
-
|
|
11206
|
-
|
|
11207
|
-
|
|
11208
|
-
|
|
11209
|
-
|
|
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
|
-
|
|
11192
|
+
/* @__PURE__ */ jsxs(
|
|
11193
|
+
Box,
|
|
11194
|
+
{
|
|
11195
|
+
sx: {
|
|
11196
|
+
mb: 1,
|
|
11197
|
+
display: "flex",
|
|
11198
|
+
gap: 1,
|
|
11199
|
+
flexWrap: "wrap",
|
|
11200
|
+
p: 1,
|
|
11201
|
+
bgcolor: "background.paper",
|
|
11202
|
+
borderRadius: 1,
|
|
11203
|
+
border: "1px solid",
|
|
11204
|
+
borderColor: "divider",
|
|
11205
|
+
...toolbarSx
|
|
11206
|
+
},
|
|
11207
|
+
children: [
|
|
11208
|
+
/* @__PURE__ */ jsx(Tooltip, { title: "Bold", children: /* @__PURE__ */ jsx(
|
|
11209
|
+
IconButton,
|
|
11210
|
+
{
|
|
11211
|
+
onClick: () => editor.chain().focus().toggleBold().run(),
|
|
11212
|
+
color: editor.isActive("bold") ? "primary" : "default",
|
|
11213
|
+
sx: {
|
|
11214
|
+
...buttonSx,
|
|
11215
|
+
...editor.isActive("bold") ? activeButtonSx : {}
|
|
11216
|
+
},
|
|
11217
|
+
children: /* @__PURE__ */ jsx(FormatBoldIcon, {})
|
|
11218
|
+
}
|
|
11219
|
+
) }),
|
|
11220
|
+
/* @__PURE__ */ jsx(Tooltip, { title: "Italic", children: /* @__PURE__ */ jsx(
|
|
11221
|
+
IconButton,
|
|
11222
|
+
{
|
|
11223
|
+
onClick: () => editor.chain().focus().toggleItalic().run(),
|
|
11224
|
+
color: editor.isActive("italic") ? "primary" : "default",
|
|
11225
|
+
sx: {
|
|
11226
|
+
...buttonSx,
|
|
11227
|
+
...editor.isActive("italic") ? activeButtonSx : {}
|
|
11228
|
+
},
|
|
11229
|
+
children: /* @__PURE__ */ jsx(FormatItalicIcon, {})
|
|
11230
|
+
}
|
|
11231
|
+
) }),
|
|
11232
|
+
/* @__PURE__ */ jsx(Tooltip, { title: "Underline", children: /* @__PURE__ */ jsx(
|
|
11233
|
+
IconButton,
|
|
11234
|
+
{
|
|
11235
|
+
onClick: () => editor.chain().focus().toggleUnderline().run(),
|
|
11236
|
+
color: editor.isActive("underline") ? "primary" : "default",
|
|
11237
|
+
sx: {
|
|
11238
|
+
...buttonSx,
|
|
11239
|
+
...editor.isActive("underline") ? activeButtonSx : {}
|
|
11240
|
+
},
|
|
11241
|
+
children: /* @__PURE__ */ jsx(FormatUnderlinedIcon, {})
|
|
11242
|
+
}
|
|
11243
|
+
) }),
|
|
11244
|
+
/* @__PURE__ */ jsx(Tooltip, { title: "Strike", children: /* @__PURE__ */ jsx(
|
|
11245
|
+
IconButton,
|
|
11246
|
+
{
|
|
11247
|
+
onClick: () => editor.chain().focus().toggleStrike().run(),
|
|
11248
|
+
color: editor.isActive("strike") ? "primary" : "default",
|
|
11249
|
+
sx: {
|
|
11250
|
+
...buttonSx,
|
|
11251
|
+
...editor.isActive("strike") ? activeButtonSx : {}
|
|
11252
|
+
},
|
|
11253
|
+
children: /* @__PURE__ */ jsx(StrikethroughSIcon, {})
|
|
11254
|
+
}
|
|
11255
|
+
) }),
|
|
11256
|
+
/* @__PURE__ */ jsx(Tooltip, { title: "Bullet List", children: /* @__PURE__ */ jsx(
|
|
11257
|
+
IconButton,
|
|
11258
|
+
{
|
|
11259
|
+
onClick: () => editor.chain().focus().toggleBulletList().run(),
|
|
11260
|
+
color: editor.isActive("bulletList") ? "primary" : "default",
|
|
11261
|
+
sx: {
|
|
11262
|
+
...buttonSx,
|
|
11263
|
+
...editor.isActive("bulletList") ? activeButtonSx : {}
|
|
11264
|
+
},
|
|
11265
|
+
children: /* @__PURE__ */ jsx(FormatListBulletedIcon, {})
|
|
11266
|
+
}
|
|
11267
|
+
) }),
|
|
11268
|
+
/* @__PURE__ */ jsx(Tooltip, { title: "Numbered List", children: /* @__PURE__ */ jsx(
|
|
11269
|
+
IconButton,
|
|
11270
|
+
{
|
|
11271
|
+
onClick: () => editor.chain().focus().toggleOrderedList().run(),
|
|
11272
|
+
color: editor.isActive("orderedList") ? "primary" : "default",
|
|
11273
|
+
sx: {
|
|
11274
|
+
...buttonSx,
|
|
11275
|
+
...editor.isActive("orderedList") ? activeButtonSx : {}
|
|
11276
|
+
},
|
|
11277
|
+
children: /* @__PURE__ */ jsx(FormatListNumberedIcon, {})
|
|
11278
|
+
}
|
|
11279
|
+
) }),
|
|
11280
|
+
/* @__PURE__ */ jsx(Tooltip, { title: "Align Left", children: /* @__PURE__ */ jsx(
|
|
11281
|
+
IconButton,
|
|
11282
|
+
{
|
|
11283
|
+
onClick: () => editor.chain().focus().setTextAlign("left").run(),
|
|
11284
|
+
color: editor.isActive({ textAlign: "left" }) ? "primary" : "default",
|
|
11285
|
+
sx: {
|
|
11286
|
+
...buttonSx,
|
|
11287
|
+
...editor.isActive({ textAlign: "left" }) ? activeButtonSx : {}
|
|
11288
|
+
},
|
|
11289
|
+
children: /* @__PURE__ */ jsx(FormatAlignLeftIcon, {})
|
|
11290
|
+
}
|
|
11291
|
+
) }),
|
|
11292
|
+
/* @__PURE__ */ jsx(Tooltip, { title: "Align Center", children: /* @__PURE__ */ jsx(
|
|
11293
|
+
IconButton,
|
|
11294
|
+
{
|
|
11295
|
+
onClick: () => editor.chain().focus().setTextAlign("center").run(),
|
|
11296
|
+
color: editor.isActive({ textAlign: "center" }) ? "primary" : "default",
|
|
11297
|
+
sx: {
|
|
11298
|
+
...buttonSx,
|
|
11299
|
+
...editor.isActive({ textAlign: "center" }) ? activeButtonSx : {}
|
|
11300
|
+
},
|
|
11301
|
+
children: /* @__PURE__ */ jsx(FormatAlignCenterIcon, {})
|
|
11302
|
+
}
|
|
11303
|
+
) }),
|
|
11304
|
+
/* @__PURE__ */ jsx(Tooltip, { title: "Align Right", children: /* @__PURE__ */ jsx(
|
|
11305
|
+
IconButton,
|
|
11306
|
+
{
|
|
11307
|
+
onClick: () => editor.chain().focus().setTextAlign("right").run(),
|
|
11308
|
+
color: editor.isActive({ textAlign: "right" }) ? "primary" : "default",
|
|
11309
|
+
sx: {
|
|
11310
|
+
...buttonSx,
|
|
11311
|
+
...editor.isActive({ textAlign: "right" }) ? activeButtonSx : {}
|
|
11312
|
+
},
|
|
11313
|
+
children: /* @__PURE__ */ jsx(FormatAlignRightIcon, {})
|
|
11314
|
+
}
|
|
11315
|
+
) }),
|
|
11316
|
+
/* @__PURE__ */ jsx(Tooltip, { title: "Heading 1", children: /* @__PURE__ */ jsx(
|
|
11317
|
+
IconButton,
|
|
11318
|
+
{
|
|
11319
|
+
onClick: () => editor.chain().focus().toggleHeading({ level: 1 }).run(),
|
|
11320
|
+
color: editor.isActive("heading", { level: 1 }) ? "primary" : "default",
|
|
11321
|
+
sx: {
|
|
11322
|
+
...buttonSx,
|
|
11323
|
+
...editor.isActive("heading", { level: 1 }) ? activeButtonSx : {}
|
|
11324
|
+
},
|
|
11325
|
+
children: /* @__PURE__ */ jsx(TitleIcon, { sx: { fontSize: "1rem" } })
|
|
11326
|
+
}
|
|
11327
|
+
) }),
|
|
11328
|
+
/* @__PURE__ */ jsx(Tooltip, { title: "Heading 2", children: /* @__PURE__ */ jsx(
|
|
11329
|
+
IconButton,
|
|
11330
|
+
{
|
|
11331
|
+
onClick: () => editor.chain().focus().toggleHeading({ level: 2 }).run(),
|
|
11332
|
+
color: editor.isActive("heading", { level: 2 }) ? "primary" : "default",
|
|
11333
|
+
sx: {
|
|
11334
|
+
...buttonSx,
|
|
11335
|
+
...editor.isActive("heading", { level: 2 }) ? activeButtonSx : {}
|
|
11336
|
+
},
|
|
11337
|
+
children: /* @__PURE__ */ jsx(TitleIcon, { sx: { fontSize: "0.85rem" } })
|
|
11338
|
+
}
|
|
11339
|
+
) }),
|
|
11340
|
+
/* @__PURE__ */ jsx(Tooltip, { title: "Undo", children: /* @__PURE__ */ jsx(IconButton, { onClick: () => editor.chain().focus().undo().run(), children: /* @__PURE__ */ jsx(UndoIcon, {}) }) }),
|
|
11341
|
+
/* @__PURE__ */ jsx(Tooltip, { title: "Redo", children: /* @__PURE__ */ jsx(IconButton, { onClick: () => editor.chain().focus().redo().run(), children: /* @__PURE__ */ jsx(RedoIcon, {}) }) })
|
|
11342
|
+
]
|
|
11343
|
+
}
|
|
11344
|
+
),
|
|
11331
11345
|
/* @__PURE__ */ jsx(
|
|
11332
11346
|
Box,
|
|
11333
11347
|
{
|
|
@@ -13027,7 +13041,9 @@ function MultiFilePreview({
|
|
|
13027
13041
|
);
|
|
13028
13042
|
}) });
|
|
13029
13043
|
}
|
|
13030
|
-
function SingleFilePreview({
|
|
13044
|
+
function SingleFilePreview({
|
|
13045
|
+
file
|
|
13046
|
+
}) {
|
|
13031
13047
|
if (!file) {
|
|
13032
13048
|
return null;
|
|
13033
13049
|
}
|
|
@@ -13677,7 +13693,13 @@ function Upload({
|
|
|
13677
13693
|
sx,
|
|
13678
13694
|
...other
|
|
13679
13695
|
}) {
|
|
13680
|
-
const {
|
|
13696
|
+
const {
|
|
13697
|
+
getRootProps,
|
|
13698
|
+
getInputProps,
|
|
13699
|
+
isDragActive,
|
|
13700
|
+
isDragReject,
|
|
13701
|
+
fileRejections
|
|
13702
|
+
} = useDropzone({
|
|
13681
13703
|
multiple,
|
|
13682
13704
|
disabled,
|
|
13683
13705
|
...other
|
|
@@ -13746,9 +13768,25 @@ function Upload({
|
|
|
13746
13768
|
}
|
|
13747
13769
|
),
|
|
13748
13770
|
hasFiles === true && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
13749
|
-
/* @__PURE__ */ jsx(Box, { sx: { my: 3 }, children: /* @__PURE__ */ jsx(
|
|
13771
|
+
/* @__PURE__ */ jsx(Box, { sx: { my: 3 }, children: /* @__PURE__ */ jsx(
|
|
13772
|
+
MultiFilePreview,
|
|
13773
|
+
{
|
|
13774
|
+
files,
|
|
13775
|
+
thumbnail,
|
|
13776
|
+
onRemove
|
|
13777
|
+
}
|
|
13778
|
+
) }),
|
|
13750
13779
|
/* @__PURE__ */ jsxs(Stack, { direction: "row", justifyContent: "flex-end", spacing: 1.5, children: [
|
|
13751
|
-
onRemoveAll && /* @__PURE__ */ jsx(
|
|
13780
|
+
onRemoveAll && /* @__PURE__ */ jsx(
|
|
13781
|
+
Button,
|
|
13782
|
+
{
|
|
13783
|
+
color: "inherit",
|
|
13784
|
+
variant: "outlined",
|
|
13785
|
+
size: "small",
|
|
13786
|
+
onClick: onRemoveAll,
|
|
13787
|
+
children: t("Remove all")
|
|
13788
|
+
}
|
|
13789
|
+
),
|
|
13752
13790
|
onUpload && /* @__PURE__ */ jsx(Button, { size: "small", variant: "contained", onClick: onUpload, children: t("Upload files") })
|
|
13753
13791
|
] })
|
|
13754
13792
|
] })
|
|
@@ -13813,17 +13851,8 @@ async function blobToBase64(file) {
|
|
|
13813
13851
|
};
|
|
13814
13852
|
});
|
|
13815
13853
|
}
|
|
13816
|
-
var AppUploadFile = ({
|
|
13817
|
-
|
|
13818
|
-
sx,
|
|
13819
|
-
uploadSx,
|
|
13820
|
-
errorSx,
|
|
13821
|
-
helperTextSx,
|
|
13822
|
-
previewSx,
|
|
13823
|
-
dropZoneSx,
|
|
13824
|
-
...rest
|
|
13825
|
-
}) => {
|
|
13826
|
-
var _a, _b;
|
|
13854
|
+
var AppUploadFile = ({ name, ...rest }) => {
|
|
13855
|
+
var _a, _b, _c, _d, _e;
|
|
13827
13856
|
const { errors, touched, setFieldValue, values } = useFormikContext();
|
|
13828
13857
|
const fieldError = _19.get(errors, name);
|
|
13829
13858
|
const isTouched = _19.get(touched, name);
|
|
@@ -13833,43 +13862,16 @@ var AppUploadFile = ({
|
|
|
13833
13862
|
} else if (!((_b = rest.multiple) != null ? _b : false) && _19.isArray(val)) {
|
|
13834
13863
|
val = val[0];
|
|
13835
13864
|
}
|
|
13836
|
-
const
|
|
13837
|
-
|
|
13838
|
-
return (Array.isArray(val2) ? val2 : []).map((item) => ({
|
|
13839
|
-
...(item == null ? void 0 : item.file) ? item : { file: item, preview: item == null ? void 0 : item.preview }
|
|
13840
|
-
}));
|
|
13841
|
-
}
|
|
13842
|
-
return (val2 == null ? void 0 : val2.file) ? val2 : val2 ? { file: val2, preview: val2.preview } : null;
|
|
13843
|
-
};
|
|
13844
|
-
const formattedValue = formatValue(val);
|
|
13845
|
-
const currentFiles = Array.isArray(val) ? val : [];
|
|
13846
|
-
const isMaxFilesReached = rest.maxFiles !== null && rest.maxFiles !== void 0 && currentFiles.length >= rest.maxFiles;
|
|
13847
|
-
return /* @__PURE__ */ jsxs(Box, { sx, children: [
|
|
13865
|
+
const value = ((_c = rest.multiple) != null ? _c : false) ? (val != null ? val : []).map((__) => (__ == null ? void 0 : __.file) ? __ == null ? void 0 : __.file : __) : val;
|
|
13866
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
13848
13867
|
/* @__PURE__ */ jsx(
|
|
13849
13868
|
Upload,
|
|
13850
13869
|
{
|
|
13851
13870
|
...rest,
|
|
13852
|
-
file: rest.multiple ? void 0 :
|
|
13853
|
-
files: rest.multiple ?
|
|
13871
|
+
file: ((_d = rest.multiple) != null ? _d : false) ? void 0 : value,
|
|
13872
|
+
files: ((_e = rest.multiple) != null ? _e : false) ? value : void 0,
|
|
13854
13873
|
error: Boolean(fieldError) && isTouched,
|
|
13855
|
-
disabled:
|
|
13856
|
-
sx: [{
|
|
13857
|
-
"& .MuiDropzoneArea-root": {
|
|
13858
|
-
minHeight: 200,
|
|
13859
|
-
border: "2px dashed",
|
|
13860
|
-
borderColor: "divider",
|
|
13861
|
-
borderRadius: 1,
|
|
13862
|
-
"&:hover": {
|
|
13863
|
-
borderColor: "primary.main",
|
|
13864
|
-
backgroundColor: "action.hover"
|
|
13865
|
-
},
|
|
13866
|
-
...dropZoneSx
|
|
13867
|
-
},
|
|
13868
|
-
"& .MuiDropzonePreviewList-root": {
|
|
13869
|
-
...previewSx
|
|
13870
|
-
},
|
|
13871
|
-
...uploadSx
|
|
13872
|
-
}],
|
|
13874
|
+
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),
|
|
13873
13875
|
onDrop: (fileVal) => {
|
|
13874
13876
|
(async () => {
|
|
13875
13877
|
var _a2;
|
|
@@ -13882,7 +13884,7 @@ var AppUploadFile = ({
|
|
|
13882
13884
|
};
|
|
13883
13885
|
})
|
|
13884
13886
|
);
|
|
13885
|
-
const currentValue = Array.isArray(
|
|
13887
|
+
const currentValue = Array.isArray(value) ? value : [];
|
|
13886
13888
|
if (rest.multiple === true) {
|
|
13887
13889
|
if (currentValue.length >= ((_a2 = rest.maxFiles) != null ? _a2 : Infinity))
|
|
13888
13890
|
return;
|
|
@@ -13897,57 +13899,36 @@ var AppUploadFile = ({
|
|
|
13897
13899
|
if ((_a2 = rest.multiple) != null ? _a2 : false) {
|
|
13898
13900
|
setFieldValue(name, [], true);
|
|
13899
13901
|
} else {
|
|
13900
|
-
setFieldValue(name,
|
|
13902
|
+
setFieldValue(name, "", true);
|
|
13901
13903
|
}
|
|
13902
13904
|
},
|
|
13903
|
-
onRemove: (
|
|
13904
|
-
|
|
13905
|
-
|
|
13906
|
-
|
|
13907
|
-
|
|
13908
|
-
|
|
13909
|
-
|
|
13910
|
-
|
|
13911
|
-
|
|
13912
|
-
setFieldValue(name, null, true);
|
|
13913
|
-
}
|
|
13905
|
+
onRemove: (e) => {
|
|
13906
|
+
const afterFilter = val.filter((file) => {
|
|
13907
|
+
var _a2;
|
|
13908
|
+
if ((_a2 = file.file) != null ? _a2 : false) {
|
|
13909
|
+
return !_19.isEqual(e, file.file);
|
|
13910
|
+
}
|
|
13911
|
+
return !_19.isEqual(e, file);
|
|
13912
|
+
});
|
|
13913
|
+
setFieldValue(name, afterFilter, true);
|
|
13914
13914
|
}
|
|
13915
13915
|
}
|
|
13916
13916
|
),
|
|
13917
13917
|
Boolean(fieldError) && Boolean(isTouched) && /* @__PURE__ */ jsx(
|
|
13918
13918
|
Typography,
|
|
13919
13919
|
{
|
|
13920
|
+
color: "#FF5630",
|
|
13920
13921
|
variant: "caption",
|
|
13921
|
-
|
|
13922
|
-
color: "error.main",
|
|
13923
|
-
display: "block",
|
|
13924
|
-
mt: 0.5,
|
|
13925
|
-
...errorSx
|
|
13926
|
-
}],
|
|
13922
|
+
display: "block",
|
|
13927
13923
|
gutterBottom: true,
|
|
13928
13924
|
children: fieldError
|
|
13929
13925
|
}
|
|
13930
13926
|
),
|
|
13931
|
-
rest.maxFiles != null && /* @__PURE__ */ jsxs(
|
|
13932
|
-
|
|
13933
|
-
|
|
13934
|
-
|
|
13935
|
-
|
|
13936
|
-
display: "block",
|
|
13937
|
-
color: "text.secondary",
|
|
13938
|
-
mt: 0.5,
|
|
13939
|
-
...helperTextSx
|
|
13940
|
-
}],
|
|
13941
|
-
gutterBottom: true,
|
|
13942
|
-
children: [
|
|
13943
|
-
"Maximum ",
|
|
13944
|
-
rest.maxFiles,
|
|
13945
|
-
" file",
|
|
13946
|
-
rest.maxFiles !== 1 ? "s" : "",
|
|
13947
|
-
" allowed"
|
|
13948
|
-
]
|
|
13949
|
-
}
|
|
13950
|
-
)
|
|
13927
|
+
rest.maxFiles != null && /* @__PURE__ */ jsxs(Typography, { variant: "caption", display: "block", gutterBottom: true, children: [
|
|
13928
|
+
"Maximum ",
|
|
13929
|
+
rest.maxFiles,
|
|
13930
|
+
" file allowed"
|
|
13931
|
+
] })
|
|
13951
13932
|
] });
|
|
13952
13933
|
};
|
|
13953
13934
|
var AppUploadFile_default = AppUploadFile;
|