@rjsf/mantine 6.0.0-beta.22 → 6.0.0-beta.23
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.cjs +78 -210
- package/dist/index.cjs.map +4 -4
- package/dist/mantine.esm.js +78 -212
- package/dist/mantine.esm.js.map +4 -4
- package/dist/mantine.umd.js +85 -216
- package/lib/templates/FieldHelpTemplate.js +4 -1
- package/lib/templates/FieldHelpTemplate.js.map +1 -1
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/lib/widgets/DateTime/AltDateTimeWidget.d.ts +1 -7
- package/lib/widgets/DateTime/AltDateTimeWidget.js +1 -6
- package/lib/widgets/DateTime/AltDateTimeWidget.js.map +1 -1
- package/lib/widgets/DateTime/AltDateWidget.d.ts +1 -7
- package/lib/widgets/DateTime/AltDateWidget.js +6 -39
- package/lib/widgets/DateTime/AltDateWidget.js.map +1 -1
- package/lib/widgets/FileWidget.js +9 -87
- package/lib/widgets/FileWidget.js.map +1 -1
- package/package.json +7 -7
- package/src/templates/FieldHelpTemplate.tsx +5 -1
- package/src/widgets/DateTime/AltDateTimeWidget.tsx +1 -8
- package/src/widgets/DateTime/AltDateWidget.tsx +6 -71
- package/src/widgets/FileWidget.tsx +20 -112
package/dist/mantine.esm.js
CHANGED
|
@@ -621,8 +621,11 @@ import { Text as Text2 } from "@mantine/core";
|
|
|
621
621
|
import { jsx as jsx13 } from "react/jsx-runtime";
|
|
622
622
|
function FieldHelpTemplate(props) {
|
|
623
623
|
const { fieldPathId, help } = props;
|
|
624
|
+
if (!help) {
|
|
625
|
+
return null;
|
|
626
|
+
}
|
|
624
627
|
const id = helpId(fieldPathId);
|
|
625
|
-
return
|
|
628
|
+
return /* @__PURE__ */ jsx13(Text2, { id, size: "sm", my: "xs", c: "dimmed", children: help });
|
|
626
629
|
}
|
|
627
630
|
|
|
628
631
|
// src/templates/GridTemplate.tsx
|
|
@@ -883,78 +886,33 @@ var templates_default = generateTemplates();
|
|
|
883
886
|
import dayjs2 from "dayjs";
|
|
884
887
|
import customParseFormat from "dayjs/plugin/customParseFormat";
|
|
885
888
|
|
|
889
|
+
// src/widgets/DateTime/AltDateTimeWidget.tsx
|
|
890
|
+
import { jsx as jsx19 } from "react/jsx-runtime";
|
|
891
|
+
function AltDateTimeWidget(props) {
|
|
892
|
+
const { AltDateWidget: AltDateWidget2 } = props.registry.widgets;
|
|
893
|
+
return /* @__PURE__ */ jsx19(AltDateWidget2, { time: true, ...props });
|
|
894
|
+
}
|
|
895
|
+
|
|
886
896
|
// src/widgets/DateTime/AltDateWidget.tsx
|
|
887
|
-
import { useCallback as useCallback2, useEffect, useState } from "react";
|
|
888
897
|
import {
|
|
889
898
|
ariaDescribedByIds as ariaDescribedByIds2,
|
|
890
899
|
dateRangeOptions,
|
|
891
|
-
parseDateString,
|
|
892
|
-
toDateString,
|
|
893
|
-
getDateElementProps,
|
|
894
900
|
titleId as titleId3,
|
|
895
|
-
TranslatableString as TranslatableString5
|
|
901
|
+
TranslatableString as TranslatableString5,
|
|
902
|
+
useAltDateWidgetProps
|
|
896
903
|
} from "@rjsf/utils";
|
|
897
904
|
import { Flex as Flex3, Box as Box6, Group as Group4, Button as Button2, Select, Input } from "@mantine/core";
|
|
898
|
-
import { Fragment as Fragment2, jsx as
|
|
899
|
-
function readyForChange(state) {
|
|
900
|
-
return Object.values(state).every((value) => value !== -1);
|
|
901
|
-
}
|
|
905
|
+
import { Fragment as Fragment2, jsx as jsx20, jsxs as jsxs10 } from "react/jsx-runtime";
|
|
902
906
|
function AltDateWidget(props) {
|
|
903
|
-
const {
|
|
904
|
-
id,
|
|
905
|
-
value,
|
|
906
|
-
required,
|
|
907
|
-
disabled,
|
|
908
|
-
readonly,
|
|
909
|
-
label,
|
|
910
|
-
hideLabel,
|
|
911
|
-
rawErrors,
|
|
912
|
-
options,
|
|
913
|
-
onChange,
|
|
914
|
-
showTime = false,
|
|
915
|
-
registry
|
|
916
|
-
} = props;
|
|
907
|
+
const { id, required, disabled, readonly, label, hideLabel, rawErrors, options, registry } = props;
|
|
917
908
|
const { translateString } = registry;
|
|
918
|
-
const
|
|
919
|
-
useEffect(() => {
|
|
920
|
-
setState(parseDateString(value, showTime));
|
|
921
|
-
}, [showTime, value]);
|
|
922
|
-
const handleChange = useCallback2(
|
|
923
|
-
(property, nextValue) => {
|
|
924
|
-
const nextState = {
|
|
925
|
-
...state,
|
|
926
|
-
[property]: typeof nextValue === "undefined" ? -1 : nextValue
|
|
927
|
-
};
|
|
928
|
-
if (readyForChange(nextState)) {
|
|
929
|
-
onChange(toDateString(nextState, showTime));
|
|
930
|
-
} else {
|
|
931
|
-
setState(nextState);
|
|
932
|
-
}
|
|
933
|
-
},
|
|
934
|
-
[state, onChange, showTime]
|
|
935
|
-
);
|
|
936
|
-
const handleSetNow = useCallback2(() => {
|
|
937
|
-
if (!disabled && !readonly) {
|
|
938
|
-
const nextState = parseDateString((/* @__PURE__ */ new Date()).toJSON(), showTime);
|
|
939
|
-
onChange(toDateString(nextState, showTime));
|
|
940
|
-
}
|
|
941
|
-
}, [disabled, readonly, showTime, onChange]);
|
|
942
|
-
const handleClear = useCallback2(() => {
|
|
943
|
-
if (!disabled && !readonly) {
|
|
944
|
-
onChange("");
|
|
945
|
-
}
|
|
946
|
-
}, [disabled, readonly, onChange]);
|
|
909
|
+
const { elements, handleChange, handleClear, handleSetNow } = useAltDateWidgetProps(props);
|
|
947
910
|
return /* @__PURE__ */ jsxs10(Fragment2, { children: [
|
|
948
|
-
!hideLabel && !!label && /* @__PURE__ */
|
|
911
|
+
!hideLabel && !!label && /* @__PURE__ */ jsx20(Input.Label, { id: titleId3(id), required, children: label }),
|
|
949
912
|
/* @__PURE__ */ jsxs10(Flex3, { gap: "xs", align: "center", wrap: "nowrap", children: [
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
options.yearsRange,
|
|
954
|
-
options.format
|
|
955
|
-
).map((elemProps, i) => {
|
|
956
|
-
const elemId = id + "_" + elemProps.type;
|
|
957
|
-
return /* @__PURE__ */ jsx19(Box6, { children: /* @__PURE__ */ jsx19(
|
|
913
|
+
elements.map((elemProps, i) => {
|
|
914
|
+
const elemId = `${id}_${elemProps.type}`;
|
|
915
|
+
return /* @__PURE__ */ jsx20(Box6, { children: /* @__PURE__ */ jsx20(
|
|
958
916
|
Select,
|
|
959
917
|
{
|
|
960
918
|
id: elemId,
|
|
@@ -963,7 +921,7 @@ function AltDateWidget(props) {
|
|
|
963
921
|
disabled: disabled || readonly,
|
|
964
922
|
data: dateRangeOptions(elemProps.range[0], elemProps.range[1]).map((item) => item.value.toString()),
|
|
965
923
|
value: !elemProps.value || elemProps.value < 0 ? null : elemProps.value.toString(),
|
|
966
|
-
onChange: (v) => handleChange(elemProps.type, v),
|
|
924
|
+
onChange: (v) => handleChange(elemProps.type, v || void 0),
|
|
967
925
|
searchable: false,
|
|
968
926
|
allowDeselect: false,
|
|
969
927
|
comboboxProps: { withinPortal: false },
|
|
@@ -972,30 +930,16 @@ function AltDateWidget(props) {
|
|
|
972
930
|
) }, i);
|
|
973
931
|
}),
|
|
974
932
|
/* @__PURE__ */ jsxs10(Group4, { wrap: "nowrap", gap: 3, children: [
|
|
975
|
-
(options.hideNowButton !== "undefined" ? !options.hideNowButton : true) && /* @__PURE__ */
|
|
976
|
-
(options.hideClearButton !== "undefined" ? !options.hideClearButton : true) && /* @__PURE__ */
|
|
933
|
+
(options.hideNowButton !== "undefined" ? !options.hideNowButton : true) && /* @__PURE__ */ jsx20(Button2, { variant: "subtle", size: "xs", onClick: handleSetNow, children: translateString(TranslatableString5.NowLabel) }),
|
|
934
|
+
(options.hideClearButton !== "undefined" ? !options.hideClearButton : true) && /* @__PURE__ */ jsx20(Button2, { variant: "subtle", size: "xs", onClick: handleClear, children: translateString(TranslatableString5.ClearLabel) })
|
|
977
935
|
] })
|
|
978
936
|
] }),
|
|
979
|
-
rawErrors && rawErrors?.length > 0 && rawErrors.map((error, index) => /* @__PURE__ */
|
|
937
|
+
rawErrors && rawErrors?.length > 0 && rawErrors.map((error, index) => /* @__PURE__ */ jsx20(Input.Error, { children: error }, `alt-date-widget-input-errors-${index}`))
|
|
980
938
|
] });
|
|
981
939
|
}
|
|
982
|
-
AltDateWidget.defaultProps = {
|
|
983
|
-
showTime: false
|
|
984
|
-
};
|
|
985
|
-
|
|
986
|
-
// src/widgets/DateTime/AltDateTimeWidget.tsx
|
|
987
|
-
import { jsx as jsx20 } from "react/jsx-runtime";
|
|
988
|
-
function AltDateTimeWidget(props) {
|
|
989
|
-
const { AltDateWidget: AltDateWidget2 } = props.registry.widgets;
|
|
990
|
-
return /* @__PURE__ */ jsx20(AltDateWidget2, { showTime: true, ...props });
|
|
991
|
-
}
|
|
992
|
-
AltDateTimeWidget.defaultProps = {
|
|
993
|
-
...AltDateWidget?.defaultProps,
|
|
994
|
-
showTime: true
|
|
995
|
-
};
|
|
996
940
|
|
|
997
941
|
// src/widgets/DateTime/DateTimeInput.tsx
|
|
998
|
-
import { useCallback as
|
|
942
|
+
import { useCallback as useCallback2 } from "react";
|
|
999
943
|
import {
|
|
1000
944
|
ariaDescribedByIds as ariaDescribedByIds3,
|
|
1001
945
|
labelValue as labelValue2
|
|
@@ -1036,18 +980,18 @@ function DateTimeInput(props) {
|
|
|
1036
980
|
valueFormat,
|
|
1037
981
|
displayFormat
|
|
1038
982
|
} = props;
|
|
1039
|
-
const handleChange =
|
|
983
|
+
const handleChange = useCallback2(
|
|
1040
984
|
(nextValue) => {
|
|
1041
985
|
onChange(dateFormat(nextValue, valueFormat));
|
|
1042
986
|
},
|
|
1043
987
|
[onChange, valueFormat]
|
|
1044
988
|
);
|
|
1045
|
-
const handleBlur =
|
|
989
|
+
const handleBlur = useCallback2(() => {
|
|
1046
990
|
if (onBlur) {
|
|
1047
991
|
onBlur(id, value);
|
|
1048
992
|
}
|
|
1049
993
|
}, [onBlur, id, value]);
|
|
1050
|
-
const handleFocus =
|
|
994
|
+
const handleFocus = useCallback2(() => {
|
|
1051
995
|
if (onFocus) {
|
|
1052
996
|
onFocus(id, value);
|
|
1053
997
|
}
|
|
@@ -1108,7 +1052,7 @@ function DateTimeWidget(props) {
|
|
|
1108
1052
|
}
|
|
1109
1053
|
|
|
1110
1054
|
// src/widgets/DateTime/TimeWidget.tsx
|
|
1111
|
-
import { useCallback as
|
|
1055
|
+
import { useCallback as useCallback3 } from "react";
|
|
1112
1056
|
import {
|
|
1113
1057
|
labelValue as labelValue3,
|
|
1114
1058
|
ariaDescribedByIds as ariaDescribedByIds4
|
|
@@ -1134,13 +1078,13 @@ function TimeWidget(props) {
|
|
|
1134
1078
|
onFocus
|
|
1135
1079
|
} = props;
|
|
1136
1080
|
const emptyValue = options.emptyValue || "";
|
|
1137
|
-
const handleChange =
|
|
1081
|
+
const handleChange = useCallback3(
|
|
1138
1082
|
(e) => {
|
|
1139
1083
|
onChange(e.target.value === "" ? emptyValue : e.target.value);
|
|
1140
1084
|
},
|
|
1141
1085
|
[onChange, emptyValue]
|
|
1142
1086
|
);
|
|
1143
|
-
const handleBlur =
|
|
1087
|
+
const handleBlur = useCallback3(
|
|
1144
1088
|
({ target }) => {
|
|
1145
1089
|
if (onBlur) {
|
|
1146
1090
|
onBlur(id, target && target.value);
|
|
@@ -1148,7 +1092,7 @@ function TimeWidget(props) {
|
|
|
1148
1092
|
},
|
|
1149
1093
|
[onBlur, id]
|
|
1150
1094
|
);
|
|
1151
|
-
const handleFocus =
|
|
1095
|
+
const handleFocus = useCallback3(
|
|
1152
1096
|
({ target }) => {
|
|
1153
1097
|
if (onFocus) {
|
|
1154
1098
|
onFocus(id, target && target.value);
|
|
@@ -1179,7 +1123,7 @@ function TimeWidget(props) {
|
|
|
1179
1123
|
}
|
|
1180
1124
|
|
|
1181
1125
|
// src/widgets/CheckboxesWidget.tsx
|
|
1182
|
-
import { useCallback as
|
|
1126
|
+
import { useCallback as useCallback4 } from "react";
|
|
1183
1127
|
import {
|
|
1184
1128
|
ariaDescribedByIds as ariaDescribedByIds5,
|
|
1185
1129
|
enumOptionsValueForIndex,
|
|
@@ -1208,7 +1152,7 @@ function CheckboxesWidget(props) {
|
|
|
1208
1152
|
} = props;
|
|
1209
1153
|
const { enumOptions, enumDisabled, inline, emptyValue } = options;
|
|
1210
1154
|
const themeProps = cleanupOptions(options);
|
|
1211
|
-
const handleChange =
|
|
1155
|
+
const handleChange = useCallback4(
|
|
1212
1156
|
(nextValue) => {
|
|
1213
1157
|
if (!disabled && !readonly && onChange) {
|
|
1214
1158
|
onChange(enumOptionsValueForIndex(nextValue, enumOptions, emptyValue));
|
|
@@ -1216,7 +1160,7 @@ function CheckboxesWidget(props) {
|
|
|
1216
1160
|
},
|
|
1217
1161
|
[onChange, disabled, readonly, enumOptions, emptyValue]
|
|
1218
1162
|
);
|
|
1219
|
-
const handleBlur =
|
|
1163
|
+
const handleBlur = useCallback4(
|
|
1220
1164
|
({ target }) => {
|
|
1221
1165
|
if (onBlur) {
|
|
1222
1166
|
onBlur(id, enumOptionsValueForIndex(target.value, enumOptions, emptyValue));
|
|
@@ -1224,7 +1168,7 @@ function CheckboxesWidget(props) {
|
|
|
1224
1168
|
},
|
|
1225
1169
|
[onBlur, id, enumOptions, emptyValue]
|
|
1226
1170
|
);
|
|
1227
|
-
const handleFocus =
|
|
1171
|
+
const handleFocus = useCallback4(
|
|
1228
1172
|
({ target }) => {
|
|
1229
1173
|
if (onFocus) {
|
|
1230
1174
|
onFocus(id, enumOptionsValueForIndex(target.value, enumOptions, emptyValue));
|
|
@@ -1266,7 +1210,7 @@ function CheckboxesWidget(props) {
|
|
|
1266
1210
|
}
|
|
1267
1211
|
|
|
1268
1212
|
// src/widgets/CheckboxWidget.tsx
|
|
1269
|
-
import { useCallback as
|
|
1213
|
+
import { useCallback as useCallback5 } from "react";
|
|
1270
1214
|
import {
|
|
1271
1215
|
descriptionId as descriptionId2,
|
|
1272
1216
|
getTemplate as getTemplate5,
|
|
@@ -1302,7 +1246,7 @@ function CheckboxWidget(props) {
|
|
|
1302
1246
|
registry,
|
|
1303
1247
|
options
|
|
1304
1248
|
);
|
|
1305
|
-
const handleCheckboxChange =
|
|
1249
|
+
const handleCheckboxChange = useCallback5(
|
|
1306
1250
|
(e) => {
|
|
1307
1251
|
if (!disabled && !readonly && onChange) {
|
|
1308
1252
|
onChange(e.currentTarget.checked);
|
|
@@ -1310,7 +1254,7 @@ function CheckboxWidget(props) {
|
|
|
1310
1254
|
},
|
|
1311
1255
|
[onChange, disabled, readonly]
|
|
1312
1256
|
);
|
|
1313
|
-
const handleBlur =
|
|
1257
|
+
const handleBlur = useCallback5(
|
|
1314
1258
|
({ target }) => {
|
|
1315
1259
|
if (onBlur) {
|
|
1316
1260
|
onBlur(id, target.checked);
|
|
@@ -1318,7 +1262,7 @@ function CheckboxWidget(props) {
|
|
|
1318
1262
|
},
|
|
1319
1263
|
[onBlur, id]
|
|
1320
1264
|
);
|
|
1321
|
-
const handleFocus =
|
|
1265
|
+
const handleFocus = useCallback5(
|
|
1322
1266
|
({ target }) => {
|
|
1323
1267
|
if (onFocus) {
|
|
1324
1268
|
onFocus(id, target.checked);
|
|
@@ -1360,7 +1304,7 @@ function CheckboxWidget(props) {
|
|
|
1360
1304
|
}
|
|
1361
1305
|
|
|
1362
1306
|
// src/widgets/ColorWidget.tsx
|
|
1363
|
-
import { useCallback as
|
|
1307
|
+
import { useCallback as useCallback6 } from "react";
|
|
1364
1308
|
import {
|
|
1365
1309
|
labelValue as labelValue5,
|
|
1366
1310
|
ariaDescribedByIds as ariaDescribedByIds7
|
|
@@ -1386,13 +1330,13 @@ function ColorWidget(props) {
|
|
|
1386
1330
|
onFocus
|
|
1387
1331
|
} = props;
|
|
1388
1332
|
const themeProps = cleanupOptions(options);
|
|
1389
|
-
const handleChange =
|
|
1333
|
+
const handleChange = useCallback6(
|
|
1390
1334
|
(nextValue) => {
|
|
1391
1335
|
onChange(nextValue);
|
|
1392
1336
|
},
|
|
1393
1337
|
[onChange]
|
|
1394
1338
|
);
|
|
1395
|
-
const handleBlur =
|
|
1339
|
+
const handleBlur = useCallback6(
|
|
1396
1340
|
({ target }) => {
|
|
1397
1341
|
if (onBlur) {
|
|
1398
1342
|
onBlur(id, target && target.value);
|
|
@@ -1400,7 +1344,7 @@ function ColorWidget(props) {
|
|
|
1400
1344
|
},
|
|
1401
1345
|
[onBlur, id]
|
|
1402
1346
|
);
|
|
1403
|
-
const handleFocus =
|
|
1347
|
+
const handleFocus = useCallback6(
|
|
1404
1348
|
({ target }) => {
|
|
1405
1349
|
if (onFocus) {
|
|
1406
1350
|
onFocus(id, target && target.value);
|
|
@@ -1431,70 +1375,14 @@ function ColorWidget(props) {
|
|
|
1431
1375
|
}
|
|
1432
1376
|
|
|
1433
1377
|
// src/widgets/FileWidget.tsx
|
|
1434
|
-
import { useCallback as
|
|
1378
|
+
import { useCallback as useCallback7 } from "react";
|
|
1435
1379
|
import {
|
|
1436
|
-
dataURItoBlob,
|
|
1437
1380
|
ariaDescribedByIds as ariaDescribedByIds8,
|
|
1438
|
-
labelValue as labelValue6
|
|
1381
|
+
labelValue as labelValue6,
|
|
1382
|
+
useFileWidgetProps
|
|
1439
1383
|
} from "@rjsf/utils";
|
|
1440
1384
|
import { FileInput, Pill } from "@mantine/core";
|
|
1441
1385
|
import { jsx as jsx28 } from "react/jsx-runtime";
|
|
1442
|
-
function addNameToDataURL(dataURL, name) {
|
|
1443
|
-
if (dataURL === null) {
|
|
1444
|
-
return null;
|
|
1445
|
-
}
|
|
1446
|
-
return dataURL.replace(";base64", `;name=${encodeURIComponent(name)};base64`);
|
|
1447
|
-
}
|
|
1448
|
-
function processFile(file) {
|
|
1449
|
-
const { name, size, type } = file;
|
|
1450
|
-
return new Promise((resolve, reject) => {
|
|
1451
|
-
const reader = new window.FileReader();
|
|
1452
|
-
reader.onerror = reject;
|
|
1453
|
-
reader.onload = (event) => {
|
|
1454
|
-
if (typeof event.target?.result === "string") {
|
|
1455
|
-
resolve({
|
|
1456
|
-
dataURL: addNameToDataURL(event.target.result, name),
|
|
1457
|
-
name,
|
|
1458
|
-
size,
|
|
1459
|
-
type
|
|
1460
|
-
});
|
|
1461
|
-
} else {
|
|
1462
|
-
resolve({
|
|
1463
|
-
dataURL: null,
|
|
1464
|
-
name,
|
|
1465
|
-
size,
|
|
1466
|
-
type
|
|
1467
|
-
});
|
|
1468
|
-
}
|
|
1469
|
-
};
|
|
1470
|
-
reader.readAsDataURL(file);
|
|
1471
|
-
});
|
|
1472
|
-
}
|
|
1473
|
-
function processFiles(files) {
|
|
1474
|
-
return Promise.all(Array.from(files).map(processFile));
|
|
1475
|
-
}
|
|
1476
|
-
function extractFileInfo(dataURLs) {
|
|
1477
|
-
return dataURLs.reduce((acc, dataURL) => {
|
|
1478
|
-
if (!dataURL) {
|
|
1479
|
-
return acc;
|
|
1480
|
-
}
|
|
1481
|
-
try {
|
|
1482
|
-
const { blob, name } = dataURItoBlob(dataURL);
|
|
1483
|
-
return [
|
|
1484
|
-
...acc,
|
|
1485
|
-
{
|
|
1486
|
-
dataURL,
|
|
1487
|
-
name,
|
|
1488
|
-
size: blob.size,
|
|
1489
|
-
type: blob.type
|
|
1490
|
-
}
|
|
1491
|
-
];
|
|
1492
|
-
} catch (e) {
|
|
1493
|
-
console.log(e);
|
|
1494
|
-
return acc;
|
|
1495
|
-
}
|
|
1496
|
-
}, []);
|
|
1497
|
-
}
|
|
1498
1386
|
function FileWidget(props) {
|
|
1499
1387
|
const {
|
|
1500
1388
|
id,
|
|
@@ -1512,44 +1400,22 @@ function FileWidget(props) {
|
|
|
1512
1400
|
multiple,
|
|
1513
1401
|
onChange
|
|
1514
1402
|
} = props;
|
|
1403
|
+
const { filesInfo, handleChange, handleRemove } = useFileWidgetProps(value, onChange, multiple);
|
|
1515
1404
|
const themeProps = cleanupOptions(options);
|
|
1516
|
-
const
|
|
1405
|
+
const handleOnChange = useCallback7(
|
|
1517
1406
|
(files) => {
|
|
1518
1407
|
if (typeof files === "object") {
|
|
1519
|
-
|
|
1520
|
-
const newValue = filesInfoEvent.map((fileInfo) => fileInfo.dataURL);
|
|
1521
|
-
if (multiple) {
|
|
1522
|
-
onChange(value.concat(newValue));
|
|
1523
|
-
} else {
|
|
1524
|
-
onChange(newValue[0]);
|
|
1525
|
-
}
|
|
1526
|
-
});
|
|
1527
|
-
}
|
|
1528
|
-
return;
|
|
1529
|
-
},
|
|
1530
|
-
[multiple, value, onChange]
|
|
1531
|
-
);
|
|
1532
|
-
const handleRemoveFile = useCallback8(
|
|
1533
|
-
(index) => {
|
|
1534
|
-
if (multiple) {
|
|
1535
|
-
const newValue = value.filter((_, i) => i !== index);
|
|
1536
|
-
onChange(newValue);
|
|
1537
|
-
} else {
|
|
1538
|
-
onChange(void 0);
|
|
1408
|
+
handleChange(files);
|
|
1539
1409
|
}
|
|
1540
1410
|
},
|
|
1541
|
-
[
|
|
1542
|
-
);
|
|
1543
|
-
const ValueComponent = useCallback8(
|
|
1544
|
-
(props2) => {
|
|
1545
|
-
const filesInfo = props2.value ? extractFileInfo(Array.isArray(props2.value) ? props2.value : [props2.value]) : null;
|
|
1546
|
-
if (Array.isArray(filesInfo) && filesInfo.length > 0) {
|
|
1547
|
-
return /* @__PURE__ */ jsx28(Pill.Group, { children: filesInfo.map((file, index) => /* @__PURE__ */ jsx28(Pill, { withRemoveButton: true, onRemove: () => handleRemoveFile(index), children: file.name }, index)) });
|
|
1548
|
-
}
|
|
1549
|
-
return null;
|
|
1550
|
-
},
|
|
1551
|
-
[handleRemoveFile]
|
|
1411
|
+
[handleChange]
|
|
1552
1412
|
);
|
|
1413
|
+
const ValueComponent = useCallback7(() => {
|
|
1414
|
+
if (Array.isArray(filesInfo) && filesInfo.length > 0) {
|
|
1415
|
+
return /* @__PURE__ */ jsx28(Pill.Group, { children: filesInfo.map((file, index) => /* @__PURE__ */ jsx28(Pill, { withRemoveButton: true, onRemove: () => handleRemove(index), children: file.name }, index)) });
|
|
1416
|
+
}
|
|
1417
|
+
return null;
|
|
1418
|
+
}, [handleRemove, filesInfo]);
|
|
1553
1419
|
return /* @__PURE__ */ jsx28(
|
|
1554
1420
|
FileInput,
|
|
1555
1421
|
{
|
|
@@ -1563,7 +1429,7 @@ function FileWidget(props) {
|
|
|
1563
1429
|
label: labelValue6(label || void 0, hideLabel, false),
|
|
1564
1430
|
multiple: !!multiple,
|
|
1565
1431
|
valueComponent: ValueComponent,
|
|
1566
|
-
onChange:
|
|
1432
|
+
onChange: handleOnChange,
|
|
1567
1433
|
error: rawErrors && rawErrors.length > 0 ? rawErrors.join("\n") : void 0,
|
|
1568
1434
|
...themeProps,
|
|
1569
1435
|
"aria-describedby": ariaDescribedByIds8(id)
|
|
@@ -1572,7 +1438,7 @@ function FileWidget(props) {
|
|
|
1572
1438
|
}
|
|
1573
1439
|
|
|
1574
1440
|
// src/widgets/PasswordWidget.tsx
|
|
1575
|
-
import { useCallback as
|
|
1441
|
+
import { useCallback as useCallback8 } from "react";
|
|
1576
1442
|
import {
|
|
1577
1443
|
ariaDescribedByIds as ariaDescribedByIds9,
|
|
1578
1444
|
labelValue as labelValue7
|
|
@@ -1599,13 +1465,13 @@ function PasswordWidget(props) {
|
|
|
1599
1465
|
} = props;
|
|
1600
1466
|
const emptyValue = options.emptyValue || "";
|
|
1601
1467
|
const themeProps = cleanupOptions(options);
|
|
1602
|
-
const handleChange =
|
|
1468
|
+
const handleChange = useCallback8(
|
|
1603
1469
|
(e) => {
|
|
1604
1470
|
onChange(e.target.value === "" ? emptyValue : e.target.value);
|
|
1605
1471
|
},
|
|
1606
1472
|
[onChange, emptyValue]
|
|
1607
1473
|
);
|
|
1608
|
-
const handleBlur =
|
|
1474
|
+
const handleBlur = useCallback8(
|
|
1609
1475
|
({ target }) => {
|
|
1610
1476
|
if (onBlur) {
|
|
1611
1477
|
onBlur(id, target && target.value);
|
|
@@ -1613,7 +1479,7 @@ function PasswordWidget(props) {
|
|
|
1613
1479
|
},
|
|
1614
1480
|
[onBlur, id]
|
|
1615
1481
|
);
|
|
1616
|
-
const handleFocus =
|
|
1482
|
+
const handleFocus = useCallback8(
|
|
1617
1483
|
({ target }) => {
|
|
1618
1484
|
if (onFocus) {
|
|
1619
1485
|
onFocus(id, target && target.value);
|
|
@@ -1643,7 +1509,7 @@ function PasswordWidget(props) {
|
|
|
1643
1509
|
}
|
|
1644
1510
|
|
|
1645
1511
|
// src/widgets/RadioWidget.tsx
|
|
1646
|
-
import { useCallback as
|
|
1512
|
+
import { useCallback as useCallback9 } from "react";
|
|
1647
1513
|
import {
|
|
1648
1514
|
ariaDescribedByIds as ariaDescribedByIds10,
|
|
1649
1515
|
enumOptionsIndexForValue as enumOptionsIndexForValue2,
|
|
@@ -1671,7 +1537,7 @@ function RadioWidget(props) {
|
|
|
1671
1537
|
} = props;
|
|
1672
1538
|
const { enumOptions, enumDisabled, inline, emptyValue } = options;
|
|
1673
1539
|
const themeProps = cleanupOptions(options);
|
|
1674
|
-
const handleChange =
|
|
1540
|
+
const handleChange = useCallback9(
|
|
1675
1541
|
(nextValue) => {
|
|
1676
1542
|
if (!disabled && !readonly && onChange) {
|
|
1677
1543
|
onChange(enumOptionsValueForIndex2(nextValue, enumOptions, emptyValue));
|
|
@@ -1679,7 +1545,7 @@ function RadioWidget(props) {
|
|
|
1679
1545
|
},
|
|
1680
1546
|
[onChange, disabled, readonly, enumOptions, emptyValue]
|
|
1681
1547
|
);
|
|
1682
|
-
const handleBlur =
|
|
1548
|
+
const handleBlur = useCallback9(
|
|
1683
1549
|
({ target }) => {
|
|
1684
1550
|
if (onBlur) {
|
|
1685
1551
|
onBlur(id, enumOptionsValueForIndex2(target && target.value, enumOptions, emptyValue));
|
|
@@ -1687,7 +1553,7 @@ function RadioWidget(props) {
|
|
|
1687
1553
|
},
|
|
1688
1554
|
[onBlur, id, enumOptions, emptyValue]
|
|
1689
1555
|
);
|
|
1690
|
-
const handleFocus =
|
|
1556
|
+
const handleFocus = useCallback9(
|
|
1691
1557
|
({ target }) => {
|
|
1692
1558
|
if (onFocus) {
|
|
1693
1559
|
onFocus(id, enumOptionsValueForIndex2(target && target.value, enumOptions, emptyValue));
|
|
@@ -1727,7 +1593,7 @@ function RadioWidget(props) {
|
|
|
1727
1593
|
}
|
|
1728
1594
|
|
|
1729
1595
|
// src/widgets/RangeWidget.tsx
|
|
1730
|
-
import { useCallback as
|
|
1596
|
+
import { useCallback as useCallback10 } from "react";
|
|
1731
1597
|
import {
|
|
1732
1598
|
ariaDescribedByIds as ariaDescribedByIds11,
|
|
1733
1599
|
rangeSpec,
|
|
@@ -1755,7 +1621,7 @@ function RangeWidget(props) {
|
|
|
1755
1621
|
} = props;
|
|
1756
1622
|
const themeProps = cleanupOptions(options);
|
|
1757
1623
|
const { min, max, step } = rangeSpec(schema);
|
|
1758
|
-
const handleChange =
|
|
1624
|
+
const handleChange = useCallback10(
|
|
1759
1625
|
(nextValue) => {
|
|
1760
1626
|
if (!disabled && !readonly && onChange) {
|
|
1761
1627
|
onChange(nextValue);
|
|
@@ -1763,12 +1629,12 @@ function RangeWidget(props) {
|
|
|
1763
1629
|
},
|
|
1764
1630
|
[onChange, disabled, readonly]
|
|
1765
1631
|
);
|
|
1766
|
-
const handleBlur =
|
|
1632
|
+
const handleBlur = useCallback10(() => {
|
|
1767
1633
|
if (onBlur) {
|
|
1768
1634
|
onBlur(id, value);
|
|
1769
1635
|
}
|
|
1770
1636
|
}, [onBlur, id, value]);
|
|
1771
|
-
const handleFocus =
|
|
1637
|
+
const handleFocus = useCallback10(() => {
|
|
1772
1638
|
if (onFocus) {
|
|
1773
1639
|
onFocus(id, value);
|
|
1774
1640
|
}
|
|
@@ -1799,7 +1665,7 @@ function RangeWidget(props) {
|
|
|
1799
1665
|
}
|
|
1800
1666
|
|
|
1801
1667
|
// src/widgets/SelectWidget.tsx
|
|
1802
|
-
import { useCallback as
|
|
1668
|
+
import { useCallback as useCallback11, useMemo } from "react";
|
|
1803
1669
|
import {
|
|
1804
1670
|
ariaDescribedByIds as ariaDescribedByIds12,
|
|
1805
1671
|
enumOptionsIndexForValue as enumOptionsIndexForValue3,
|
|
@@ -1829,7 +1695,7 @@ function SelectWidget(props) {
|
|
|
1829
1695
|
} = props;
|
|
1830
1696
|
const { enumOptions, enumDisabled, emptyValue } = options;
|
|
1831
1697
|
const themeProps = cleanupOptions(options);
|
|
1832
|
-
const handleChange =
|
|
1698
|
+
const handleChange = useCallback11(
|
|
1833
1699
|
(nextValue) => {
|
|
1834
1700
|
if (!disabled && !readonly && onChange) {
|
|
1835
1701
|
onChange(enumOptionsValueForIndex3(nextValue, enumOptions, emptyValue));
|
|
@@ -1837,7 +1703,7 @@ function SelectWidget(props) {
|
|
|
1837
1703
|
},
|
|
1838
1704
|
[onChange, disabled, readonly, enumOptions, emptyValue]
|
|
1839
1705
|
);
|
|
1840
|
-
const handleBlur =
|
|
1706
|
+
const handleBlur = useCallback11(
|
|
1841
1707
|
({ target }) => {
|
|
1842
1708
|
if (onBlur) {
|
|
1843
1709
|
onBlur(id, enumOptionsValueForIndex3(target && target.value, enumOptions, emptyValue));
|
|
@@ -1845,7 +1711,7 @@ function SelectWidget(props) {
|
|
|
1845
1711
|
},
|
|
1846
1712
|
[onBlur, id, enumOptions, emptyValue]
|
|
1847
1713
|
);
|
|
1848
|
-
const handleFocus =
|
|
1714
|
+
const handleFocus = useCallback11(
|
|
1849
1715
|
({ target }) => {
|
|
1850
1716
|
if (onFocus) {
|
|
1851
1717
|
onFocus(id, enumOptionsValueForIndex3(target && target.value, enumOptions, emptyValue));
|
|
@@ -1891,7 +1757,7 @@ function SelectWidget(props) {
|
|
|
1891
1757
|
}
|
|
1892
1758
|
|
|
1893
1759
|
// src/widgets/TextareaWidget.tsx
|
|
1894
|
-
import { useCallback as
|
|
1760
|
+
import { useCallback as useCallback12 } from "react";
|
|
1895
1761
|
import {
|
|
1896
1762
|
labelValue as labelValue9,
|
|
1897
1763
|
ariaDescribedByIds as ariaDescribedByIds13
|
|
@@ -1919,13 +1785,13 @@ function TextareaWidget(props) {
|
|
|
1919
1785
|
} = props;
|
|
1920
1786
|
const themeProps = cleanupOptions(options);
|
|
1921
1787
|
const emptyValue = options?.emptyValue ?? "";
|
|
1922
|
-
const handleChange =
|
|
1788
|
+
const handleChange = useCallback12(
|
|
1923
1789
|
(e) => {
|
|
1924
1790
|
onChange(e.target.value === "" ? emptyValue : e.target.value);
|
|
1925
1791
|
},
|
|
1926
1792
|
[onChange, emptyValue]
|
|
1927
1793
|
);
|
|
1928
|
-
const handleBlur =
|
|
1794
|
+
const handleBlur = useCallback12(
|
|
1929
1795
|
({ target }) => {
|
|
1930
1796
|
if (onBlur) {
|
|
1931
1797
|
onBlur(id, target && target.value);
|
|
@@ -1933,7 +1799,7 @@ function TextareaWidget(props) {
|
|
|
1933
1799
|
},
|
|
1934
1800
|
[onBlur, id]
|
|
1935
1801
|
);
|
|
1936
|
-
const handleFocus =
|
|
1802
|
+
const handleFocus = useCallback12(
|
|
1937
1803
|
({ target }) => {
|
|
1938
1804
|
if (onFocus) {
|
|
1939
1805
|
onFocus(id, target && target.value);
|