@rjsf/mantine 6.0.0-beta.22 → 6.0.0
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/README.md +2 -0
- 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 +10 -10
- 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/README.md
CHANGED
|
@@ -50,6 +50,8 @@
|
|
|
50
50
|
|
|
51
51
|
`Mantine` theme, fields and widgets for `react-jsonschema-form`.
|
|
52
52
|
|
|
53
|
+
[<img src="./screenshot.png" alt="product-screenshot" width="800" />](https://rjsf-team.github.io/@rjsf/mantine)
|
|
54
|
+
|
|
53
55
|
### Built With
|
|
54
56
|
|
|
55
57
|
- [react-jsonschema-form](https://github.com/rjsf-team/react-jsonschema-form/)
|
package/dist/index.cjs
CHANGED
|
@@ -647,8 +647,11 @@ var import_core12 = require("@mantine/core");
|
|
|
647
647
|
var import_jsx_runtime13 = require("react/jsx-runtime");
|
|
648
648
|
function FieldHelpTemplate(props) {
|
|
649
649
|
const { fieldPathId, help } = props;
|
|
650
|
+
if (!help) {
|
|
651
|
+
return null;
|
|
652
|
+
}
|
|
650
653
|
const id = (0, import_utils12.helpId)(fieldPathId);
|
|
651
|
-
return
|
|
654
|
+
return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_core12.Text, { id, size: "sm", my: "xs", c: "dimmed", children: help });
|
|
652
655
|
}
|
|
653
656
|
|
|
654
657
|
// src/templates/GridTemplate.tsx
|
|
@@ -897,70 +900,27 @@ var templates_default = generateTemplates();
|
|
|
897
900
|
var import_dayjs2 = __toESM(require("dayjs"), 1);
|
|
898
901
|
var import_customParseFormat = __toESM(require("dayjs/plugin/customParseFormat"), 1);
|
|
899
902
|
|
|
903
|
+
// src/widgets/DateTime/AltDateTimeWidget.tsx
|
|
904
|
+
var import_jsx_runtime20 = require("react/jsx-runtime");
|
|
905
|
+
function AltDateTimeWidget(props) {
|
|
906
|
+
const { AltDateWidget: AltDateWidget2 } = props.registry.widgets;
|
|
907
|
+
return /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(AltDateWidget2, { time: true, ...props });
|
|
908
|
+
}
|
|
909
|
+
|
|
900
910
|
// src/widgets/DateTime/AltDateWidget.tsx
|
|
901
|
-
var import_react2 = require("react");
|
|
902
911
|
var import_utils15 = require("@rjsf/utils");
|
|
903
912
|
var import_core18 = require("@mantine/core");
|
|
904
|
-
var
|
|
905
|
-
function readyForChange(state) {
|
|
906
|
-
return Object.values(state).every((value) => value !== -1);
|
|
907
|
-
}
|
|
913
|
+
var import_jsx_runtime21 = require("react/jsx-runtime");
|
|
908
914
|
function AltDateWidget(props) {
|
|
909
|
-
const {
|
|
910
|
-
id,
|
|
911
|
-
value,
|
|
912
|
-
required,
|
|
913
|
-
disabled,
|
|
914
|
-
readonly,
|
|
915
|
-
label,
|
|
916
|
-
hideLabel,
|
|
917
|
-
rawErrors,
|
|
918
|
-
options,
|
|
919
|
-
onChange,
|
|
920
|
-
showTime = false,
|
|
921
|
-
registry
|
|
922
|
-
} = props;
|
|
915
|
+
const { id, required, disabled, readonly, label, hideLabel, rawErrors, options, registry } = props;
|
|
923
916
|
const { translateString } = registry;
|
|
924
|
-
const
|
|
925
|
-
(0,
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
...state,
|
|
932
|
-
[property]: typeof nextValue === "undefined" ? -1 : nextValue
|
|
933
|
-
};
|
|
934
|
-
if (readyForChange(nextState)) {
|
|
935
|
-
onChange((0, import_utils15.toDateString)(nextState, showTime));
|
|
936
|
-
} else {
|
|
937
|
-
setState(nextState);
|
|
938
|
-
}
|
|
939
|
-
},
|
|
940
|
-
[state, onChange, showTime]
|
|
941
|
-
);
|
|
942
|
-
const handleSetNow = (0, import_react2.useCallback)(() => {
|
|
943
|
-
if (!disabled && !readonly) {
|
|
944
|
-
const nextState = (0, import_utils15.parseDateString)((/* @__PURE__ */ new Date()).toJSON(), showTime);
|
|
945
|
-
onChange((0, import_utils15.toDateString)(nextState, showTime));
|
|
946
|
-
}
|
|
947
|
-
}, [disabled, readonly, showTime, onChange]);
|
|
948
|
-
const handleClear = (0, import_react2.useCallback)(() => {
|
|
949
|
-
if (!disabled && !readonly) {
|
|
950
|
-
onChange("");
|
|
951
|
-
}
|
|
952
|
-
}, [disabled, readonly, onChange]);
|
|
953
|
-
return /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)(import_jsx_runtime20.Fragment, { children: [
|
|
954
|
-
!hideLabel && !!label && /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(import_core18.Input.Label, { id: (0, import_utils15.titleId)(id), required, children: label }),
|
|
955
|
-
/* @__PURE__ */ (0, import_jsx_runtime20.jsxs)(import_core18.Flex, { gap: "xs", align: "center", wrap: "nowrap", children: [
|
|
956
|
-
(0, import_utils15.getDateElementProps)(
|
|
957
|
-
state,
|
|
958
|
-
showTime,
|
|
959
|
-
options.yearsRange,
|
|
960
|
-
options.format
|
|
961
|
-
).map((elemProps, i) => {
|
|
962
|
-
const elemId = id + "_" + elemProps.type;
|
|
963
|
-
return /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(import_core18.Box, { children: /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
|
|
917
|
+
const { elements, handleChange, handleClear, handleSetNow } = (0, import_utils15.useAltDateWidgetProps)(props);
|
|
918
|
+
return /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)(import_jsx_runtime21.Fragment, { children: [
|
|
919
|
+
!hideLabel && !!label && /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(import_core18.Input.Label, { id: (0, import_utils15.titleId)(id), required, children: label }),
|
|
920
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsxs)(import_core18.Flex, { gap: "xs", align: "center", wrap: "nowrap", children: [
|
|
921
|
+
elements.map((elemProps, i) => {
|
|
922
|
+
const elemId = `${id}_${elemProps.type}`;
|
|
923
|
+
return /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(import_core18.Box, { children: /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
|
|
964
924
|
import_core18.Select,
|
|
965
925
|
{
|
|
966
926
|
id: elemId,
|
|
@@ -969,7 +929,7 @@ function AltDateWidget(props) {
|
|
|
969
929
|
disabled: disabled || readonly,
|
|
970
930
|
data: (0, import_utils15.dateRangeOptions)(elemProps.range[0], elemProps.range[1]).map((item) => item.value.toString()),
|
|
971
931
|
value: !elemProps.value || elemProps.value < 0 ? null : elemProps.value.toString(),
|
|
972
|
-
onChange: (v) => handleChange(elemProps.type, v),
|
|
932
|
+
onChange: (v) => handleChange(elemProps.type, v || void 0),
|
|
973
933
|
searchable: false,
|
|
974
934
|
allowDeselect: false,
|
|
975
935
|
comboboxProps: { withinPortal: false },
|
|
@@ -977,31 +937,17 @@ function AltDateWidget(props) {
|
|
|
977
937
|
}
|
|
978
938
|
) }, i);
|
|
979
939
|
}),
|
|
980
|
-
/* @__PURE__ */ (0,
|
|
981
|
-
(options.hideNowButton !== "undefined" ? !options.hideNowButton : true) && /* @__PURE__ */ (0,
|
|
982
|
-
(options.hideClearButton !== "undefined" ? !options.hideClearButton : true) && /* @__PURE__ */ (0,
|
|
940
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsxs)(import_core18.Group, { wrap: "nowrap", gap: 3, children: [
|
|
941
|
+
(options.hideNowButton !== "undefined" ? !options.hideNowButton : true) && /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(import_core18.Button, { variant: "subtle", size: "xs", onClick: handleSetNow, children: translateString(import_utils15.TranslatableString.NowLabel) }),
|
|
942
|
+
(options.hideClearButton !== "undefined" ? !options.hideClearButton : true) && /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(import_core18.Button, { variant: "subtle", size: "xs", onClick: handleClear, children: translateString(import_utils15.TranslatableString.ClearLabel) })
|
|
983
943
|
] })
|
|
984
944
|
] }),
|
|
985
|
-
rawErrors && rawErrors?.length > 0 && rawErrors.map((error, index) => /* @__PURE__ */ (0,
|
|
945
|
+
rawErrors && rawErrors?.length > 0 && rawErrors.map((error, index) => /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(import_core18.Input.Error, { children: error }, `alt-date-widget-input-errors-${index}`))
|
|
986
946
|
] });
|
|
987
947
|
}
|
|
988
|
-
AltDateWidget.defaultProps = {
|
|
989
|
-
showTime: false
|
|
990
|
-
};
|
|
991
|
-
|
|
992
|
-
// src/widgets/DateTime/AltDateTimeWidget.tsx
|
|
993
|
-
var import_jsx_runtime21 = require("react/jsx-runtime");
|
|
994
|
-
function AltDateTimeWidget(props) {
|
|
995
|
-
const { AltDateWidget: AltDateWidget2 } = props.registry.widgets;
|
|
996
|
-
return /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(AltDateWidget2, { showTime: true, ...props });
|
|
997
|
-
}
|
|
998
|
-
AltDateTimeWidget.defaultProps = {
|
|
999
|
-
...AltDateWidget?.defaultProps,
|
|
1000
|
-
showTime: true
|
|
1001
|
-
};
|
|
1002
948
|
|
|
1003
949
|
// src/widgets/DateTime/DateTimeInput.tsx
|
|
1004
|
-
var
|
|
950
|
+
var import_react2 = require("react");
|
|
1005
951
|
var import_utils16 = require("@rjsf/utils");
|
|
1006
952
|
var import_dayjs = __toESM(require("dayjs"), 1);
|
|
1007
953
|
var import_dates = require("@mantine/dates");
|
|
@@ -1039,18 +985,18 @@ function DateTimeInput(props) {
|
|
|
1039
985
|
valueFormat,
|
|
1040
986
|
displayFormat
|
|
1041
987
|
} = props;
|
|
1042
|
-
const handleChange = (0,
|
|
988
|
+
const handleChange = (0, import_react2.useCallback)(
|
|
1043
989
|
(nextValue) => {
|
|
1044
990
|
onChange(dateFormat(nextValue, valueFormat));
|
|
1045
991
|
},
|
|
1046
992
|
[onChange, valueFormat]
|
|
1047
993
|
);
|
|
1048
|
-
const handleBlur = (0,
|
|
994
|
+
const handleBlur = (0, import_react2.useCallback)(() => {
|
|
1049
995
|
if (onBlur) {
|
|
1050
996
|
onBlur(id, value);
|
|
1051
997
|
}
|
|
1052
998
|
}, [onBlur, id, value]);
|
|
1053
|
-
const handleFocus = (0,
|
|
999
|
+
const handleFocus = (0, import_react2.useCallback)(() => {
|
|
1054
1000
|
if (onFocus) {
|
|
1055
1001
|
onFocus(id, value);
|
|
1056
1002
|
}
|
|
@@ -1111,7 +1057,7 @@ function DateTimeWidget(props) {
|
|
|
1111
1057
|
}
|
|
1112
1058
|
|
|
1113
1059
|
// src/widgets/DateTime/TimeWidget.tsx
|
|
1114
|
-
var
|
|
1060
|
+
var import_react3 = require("react");
|
|
1115
1061
|
var import_utils17 = require("@rjsf/utils");
|
|
1116
1062
|
var import_dates2 = require("@mantine/dates");
|
|
1117
1063
|
var import_jsx_runtime25 = require("react/jsx-runtime");
|
|
@@ -1134,13 +1080,13 @@ function TimeWidget(props) {
|
|
|
1134
1080
|
onFocus
|
|
1135
1081
|
} = props;
|
|
1136
1082
|
const emptyValue = options.emptyValue || "";
|
|
1137
|
-
const handleChange = (0,
|
|
1083
|
+
const handleChange = (0, import_react3.useCallback)(
|
|
1138
1084
|
(e) => {
|
|
1139
1085
|
onChange(e.target.value === "" ? emptyValue : e.target.value);
|
|
1140
1086
|
},
|
|
1141
1087
|
[onChange, emptyValue]
|
|
1142
1088
|
);
|
|
1143
|
-
const handleBlur = (0,
|
|
1089
|
+
const handleBlur = (0, import_react3.useCallback)(
|
|
1144
1090
|
({ target }) => {
|
|
1145
1091
|
if (onBlur) {
|
|
1146
1092
|
onBlur(id, target && target.value);
|
|
@@ -1148,7 +1094,7 @@ function TimeWidget(props) {
|
|
|
1148
1094
|
},
|
|
1149
1095
|
[onBlur, id]
|
|
1150
1096
|
);
|
|
1151
|
-
const handleFocus = (0,
|
|
1097
|
+
const handleFocus = (0, import_react3.useCallback)(
|
|
1152
1098
|
({ target }) => {
|
|
1153
1099
|
if (onFocus) {
|
|
1154
1100
|
onFocus(id, target && target.value);
|
|
@@ -1179,7 +1125,7 @@ function TimeWidget(props) {
|
|
|
1179
1125
|
}
|
|
1180
1126
|
|
|
1181
1127
|
// src/widgets/CheckboxesWidget.tsx
|
|
1182
|
-
var
|
|
1128
|
+
var import_react4 = require("react");
|
|
1183
1129
|
var import_utils18 = require("@rjsf/utils");
|
|
1184
1130
|
var import_core19 = require("@mantine/core");
|
|
1185
1131
|
var import_jsx_runtime26 = require("react/jsx-runtime");
|
|
@@ -1202,7 +1148,7 @@ function CheckboxesWidget(props) {
|
|
|
1202
1148
|
} = props;
|
|
1203
1149
|
const { enumOptions, enumDisabled, inline, emptyValue } = options;
|
|
1204
1150
|
const themeProps = cleanupOptions(options);
|
|
1205
|
-
const handleChange = (0,
|
|
1151
|
+
const handleChange = (0, import_react4.useCallback)(
|
|
1206
1152
|
(nextValue) => {
|
|
1207
1153
|
if (!disabled && !readonly && onChange) {
|
|
1208
1154
|
onChange((0, import_utils18.enumOptionsValueForIndex)(nextValue, enumOptions, emptyValue));
|
|
@@ -1210,7 +1156,7 @@ function CheckboxesWidget(props) {
|
|
|
1210
1156
|
},
|
|
1211
1157
|
[onChange, disabled, readonly, enumOptions, emptyValue]
|
|
1212
1158
|
);
|
|
1213
|
-
const handleBlur = (0,
|
|
1159
|
+
const handleBlur = (0, import_react4.useCallback)(
|
|
1214
1160
|
({ target }) => {
|
|
1215
1161
|
if (onBlur) {
|
|
1216
1162
|
onBlur(id, (0, import_utils18.enumOptionsValueForIndex)(target.value, enumOptions, emptyValue));
|
|
@@ -1218,7 +1164,7 @@ function CheckboxesWidget(props) {
|
|
|
1218
1164
|
},
|
|
1219
1165
|
[onBlur, id, enumOptions, emptyValue]
|
|
1220
1166
|
);
|
|
1221
|
-
const handleFocus = (0,
|
|
1167
|
+
const handleFocus = (0, import_react4.useCallback)(
|
|
1222
1168
|
({ target }) => {
|
|
1223
1169
|
if (onFocus) {
|
|
1224
1170
|
onFocus(id, (0, import_utils18.enumOptionsValueForIndex)(target.value, enumOptions, emptyValue));
|
|
@@ -1260,7 +1206,7 @@ function CheckboxesWidget(props) {
|
|
|
1260
1206
|
}
|
|
1261
1207
|
|
|
1262
1208
|
// src/widgets/CheckboxWidget.tsx
|
|
1263
|
-
var
|
|
1209
|
+
var import_react5 = require("react");
|
|
1264
1210
|
var import_utils20 = require("@rjsf/utils");
|
|
1265
1211
|
var import_core20 = require("@mantine/core");
|
|
1266
1212
|
var import_jsx_runtime27 = require("react/jsx-runtime");
|
|
@@ -1291,7 +1237,7 @@ function CheckboxWidget(props) {
|
|
|
1291
1237
|
registry,
|
|
1292
1238
|
options
|
|
1293
1239
|
);
|
|
1294
|
-
const handleCheckboxChange = (0,
|
|
1240
|
+
const handleCheckboxChange = (0, import_react5.useCallback)(
|
|
1295
1241
|
(e) => {
|
|
1296
1242
|
if (!disabled && !readonly && onChange) {
|
|
1297
1243
|
onChange(e.currentTarget.checked);
|
|
@@ -1299,7 +1245,7 @@ function CheckboxWidget(props) {
|
|
|
1299
1245
|
},
|
|
1300
1246
|
[onChange, disabled, readonly]
|
|
1301
1247
|
);
|
|
1302
|
-
const handleBlur = (0,
|
|
1248
|
+
const handleBlur = (0, import_react5.useCallback)(
|
|
1303
1249
|
({ target }) => {
|
|
1304
1250
|
if (onBlur) {
|
|
1305
1251
|
onBlur(id, target.checked);
|
|
@@ -1307,7 +1253,7 @@ function CheckboxWidget(props) {
|
|
|
1307
1253
|
},
|
|
1308
1254
|
[onBlur, id]
|
|
1309
1255
|
);
|
|
1310
|
-
const handleFocus = (0,
|
|
1256
|
+
const handleFocus = (0, import_react5.useCallback)(
|
|
1311
1257
|
({ target }) => {
|
|
1312
1258
|
if (onFocus) {
|
|
1313
1259
|
onFocus(id, target.checked);
|
|
@@ -1349,7 +1295,7 @@ function CheckboxWidget(props) {
|
|
|
1349
1295
|
}
|
|
1350
1296
|
|
|
1351
1297
|
// src/widgets/ColorWidget.tsx
|
|
1352
|
-
var
|
|
1298
|
+
var import_react6 = require("react");
|
|
1353
1299
|
var import_utils22 = require("@rjsf/utils");
|
|
1354
1300
|
var import_core21 = require("@mantine/core");
|
|
1355
1301
|
var import_jsx_runtime28 = require("react/jsx-runtime");
|
|
@@ -1372,13 +1318,13 @@ function ColorWidget(props) {
|
|
|
1372
1318
|
onFocus
|
|
1373
1319
|
} = props;
|
|
1374
1320
|
const themeProps = cleanupOptions(options);
|
|
1375
|
-
const handleChange = (0,
|
|
1321
|
+
const handleChange = (0, import_react6.useCallback)(
|
|
1376
1322
|
(nextValue) => {
|
|
1377
1323
|
onChange(nextValue);
|
|
1378
1324
|
},
|
|
1379
1325
|
[onChange]
|
|
1380
1326
|
);
|
|
1381
|
-
const handleBlur = (0,
|
|
1327
|
+
const handleBlur = (0, import_react6.useCallback)(
|
|
1382
1328
|
({ target }) => {
|
|
1383
1329
|
if (onBlur) {
|
|
1384
1330
|
onBlur(id, target && target.value);
|
|
@@ -1386,7 +1332,7 @@ function ColorWidget(props) {
|
|
|
1386
1332
|
},
|
|
1387
1333
|
[onBlur, id]
|
|
1388
1334
|
);
|
|
1389
|
-
const handleFocus = (0,
|
|
1335
|
+
const handleFocus = (0, import_react6.useCallback)(
|
|
1390
1336
|
({ target }) => {
|
|
1391
1337
|
if (onFocus) {
|
|
1392
1338
|
onFocus(id, target && target.value);
|
|
@@ -1417,66 +1363,10 @@ function ColorWidget(props) {
|
|
|
1417
1363
|
}
|
|
1418
1364
|
|
|
1419
1365
|
// src/widgets/FileWidget.tsx
|
|
1420
|
-
var
|
|
1366
|
+
var import_react7 = require("react");
|
|
1421
1367
|
var import_utils24 = require("@rjsf/utils");
|
|
1422
1368
|
var import_core22 = require("@mantine/core");
|
|
1423
1369
|
var import_jsx_runtime29 = require("react/jsx-runtime");
|
|
1424
|
-
function addNameToDataURL(dataURL, name) {
|
|
1425
|
-
if (dataURL === null) {
|
|
1426
|
-
return null;
|
|
1427
|
-
}
|
|
1428
|
-
return dataURL.replace(";base64", `;name=${encodeURIComponent(name)};base64`);
|
|
1429
|
-
}
|
|
1430
|
-
function processFile(file) {
|
|
1431
|
-
const { name, size, type } = file;
|
|
1432
|
-
return new Promise((resolve, reject) => {
|
|
1433
|
-
const reader = new window.FileReader();
|
|
1434
|
-
reader.onerror = reject;
|
|
1435
|
-
reader.onload = (event) => {
|
|
1436
|
-
if (typeof event.target?.result === "string") {
|
|
1437
|
-
resolve({
|
|
1438
|
-
dataURL: addNameToDataURL(event.target.result, name),
|
|
1439
|
-
name,
|
|
1440
|
-
size,
|
|
1441
|
-
type
|
|
1442
|
-
});
|
|
1443
|
-
} else {
|
|
1444
|
-
resolve({
|
|
1445
|
-
dataURL: null,
|
|
1446
|
-
name,
|
|
1447
|
-
size,
|
|
1448
|
-
type
|
|
1449
|
-
});
|
|
1450
|
-
}
|
|
1451
|
-
};
|
|
1452
|
-
reader.readAsDataURL(file);
|
|
1453
|
-
});
|
|
1454
|
-
}
|
|
1455
|
-
function processFiles(files) {
|
|
1456
|
-
return Promise.all(Array.from(files).map(processFile));
|
|
1457
|
-
}
|
|
1458
|
-
function extractFileInfo(dataURLs) {
|
|
1459
|
-
return dataURLs.reduce((acc, dataURL) => {
|
|
1460
|
-
if (!dataURL) {
|
|
1461
|
-
return acc;
|
|
1462
|
-
}
|
|
1463
|
-
try {
|
|
1464
|
-
const { blob, name } = (0, import_utils24.dataURItoBlob)(dataURL);
|
|
1465
|
-
return [
|
|
1466
|
-
...acc,
|
|
1467
|
-
{
|
|
1468
|
-
dataURL,
|
|
1469
|
-
name,
|
|
1470
|
-
size: blob.size,
|
|
1471
|
-
type: blob.type
|
|
1472
|
-
}
|
|
1473
|
-
];
|
|
1474
|
-
} catch (e) {
|
|
1475
|
-
console.log(e);
|
|
1476
|
-
return acc;
|
|
1477
|
-
}
|
|
1478
|
-
}, []);
|
|
1479
|
-
}
|
|
1480
1370
|
function FileWidget(props) {
|
|
1481
1371
|
const {
|
|
1482
1372
|
id,
|
|
@@ -1494,44 +1384,22 @@ function FileWidget(props) {
|
|
|
1494
1384
|
multiple,
|
|
1495
1385
|
onChange
|
|
1496
1386
|
} = props;
|
|
1387
|
+
const { filesInfo, handleChange, handleRemove } = (0, import_utils24.useFileWidgetProps)(value, onChange, multiple);
|
|
1497
1388
|
const themeProps = cleanupOptions(options);
|
|
1498
|
-
const
|
|
1389
|
+
const handleOnChange = (0, import_react7.useCallback)(
|
|
1499
1390
|
(files) => {
|
|
1500
1391
|
if (typeof files === "object") {
|
|
1501
|
-
|
|
1502
|
-
const newValue = filesInfoEvent.map((fileInfo) => fileInfo.dataURL);
|
|
1503
|
-
if (multiple) {
|
|
1504
|
-
onChange(value.concat(newValue));
|
|
1505
|
-
} else {
|
|
1506
|
-
onChange(newValue[0]);
|
|
1507
|
-
}
|
|
1508
|
-
});
|
|
1509
|
-
}
|
|
1510
|
-
return;
|
|
1511
|
-
},
|
|
1512
|
-
[multiple, value, onChange]
|
|
1513
|
-
);
|
|
1514
|
-
const handleRemoveFile = (0, import_react8.useCallback)(
|
|
1515
|
-
(index) => {
|
|
1516
|
-
if (multiple) {
|
|
1517
|
-
const newValue = value.filter((_, i) => i !== index);
|
|
1518
|
-
onChange(newValue);
|
|
1519
|
-
} else {
|
|
1520
|
-
onChange(void 0);
|
|
1521
|
-
}
|
|
1522
|
-
},
|
|
1523
|
-
[multiple, value, onChange]
|
|
1524
|
-
);
|
|
1525
|
-
const ValueComponent = (0, import_react8.useCallback)(
|
|
1526
|
-
(props2) => {
|
|
1527
|
-
const filesInfo = props2.value ? extractFileInfo(Array.isArray(props2.value) ? props2.value : [props2.value]) : null;
|
|
1528
|
-
if (Array.isArray(filesInfo) && filesInfo.length > 0) {
|
|
1529
|
-
return /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(import_core22.Pill.Group, { children: filesInfo.map((file, index) => /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(import_core22.Pill, { withRemoveButton: true, onRemove: () => handleRemoveFile(index), children: file.name }, index)) });
|
|
1392
|
+
handleChange(files);
|
|
1530
1393
|
}
|
|
1531
|
-
return null;
|
|
1532
1394
|
},
|
|
1533
|
-
[
|
|
1395
|
+
[handleChange]
|
|
1534
1396
|
);
|
|
1397
|
+
const ValueComponent = (0, import_react7.useCallback)(() => {
|
|
1398
|
+
if (Array.isArray(filesInfo) && filesInfo.length > 0) {
|
|
1399
|
+
return /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(import_core22.Pill.Group, { children: filesInfo.map((file, index) => /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(import_core22.Pill, { withRemoveButton: true, onRemove: () => handleRemove(index), children: file.name }, index)) });
|
|
1400
|
+
}
|
|
1401
|
+
return null;
|
|
1402
|
+
}, [handleRemove, filesInfo]);
|
|
1535
1403
|
return /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
|
|
1536
1404
|
import_core22.FileInput,
|
|
1537
1405
|
{
|
|
@@ -1545,7 +1413,7 @@ function FileWidget(props) {
|
|
|
1545
1413
|
label: (0, import_utils24.labelValue)(label || void 0, hideLabel, false),
|
|
1546
1414
|
multiple: !!multiple,
|
|
1547
1415
|
valueComponent: ValueComponent,
|
|
1548
|
-
onChange:
|
|
1416
|
+
onChange: handleOnChange,
|
|
1549
1417
|
error: rawErrors && rawErrors.length > 0 ? rawErrors.join("\n") : void 0,
|
|
1550
1418
|
...themeProps,
|
|
1551
1419
|
"aria-describedby": (0, import_utils24.ariaDescribedByIds)(id)
|
|
@@ -1554,7 +1422,7 @@ function FileWidget(props) {
|
|
|
1554
1422
|
}
|
|
1555
1423
|
|
|
1556
1424
|
// src/widgets/PasswordWidget.tsx
|
|
1557
|
-
var
|
|
1425
|
+
var import_react8 = require("react");
|
|
1558
1426
|
var import_utils26 = require("@rjsf/utils");
|
|
1559
1427
|
var import_core23 = require("@mantine/core");
|
|
1560
1428
|
var import_jsx_runtime30 = require("react/jsx-runtime");
|
|
@@ -1578,13 +1446,13 @@ function PasswordWidget(props) {
|
|
|
1578
1446
|
} = props;
|
|
1579
1447
|
const emptyValue = options.emptyValue || "";
|
|
1580
1448
|
const themeProps = cleanupOptions(options);
|
|
1581
|
-
const handleChange = (0,
|
|
1449
|
+
const handleChange = (0, import_react8.useCallback)(
|
|
1582
1450
|
(e) => {
|
|
1583
1451
|
onChange(e.target.value === "" ? emptyValue : e.target.value);
|
|
1584
1452
|
},
|
|
1585
1453
|
[onChange, emptyValue]
|
|
1586
1454
|
);
|
|
1587
|
-
const handleBlur = (0,
|
|
1455
|
+
const handleBlur = (0, import_react8.useCallback)(
|
|
1588
1456
|
({ target }) => {
|
|
1589
1457
|
if (onBlur) {
|
|
1590
1458
|
onBlur(id, target && target.value);
|
|
@@ -1592,7 +1460,7 @@ function PasswordWidget(props) {
|
|
|
1592
1460
|
},
|
|
1593
1461
|
[onBlur, id]
|
|
1594
1462
|
);
|
|
1595
|
-
const handleFocus = (0,
|
|
1463
|
+
const handleFocus = (0, import_react8.useCallback)(
|
|
1596
1464
|
({ target }) => {
|
|
1597
1465
|
if (onFocus) {
|
|
1598
1466
|
onFocus(id, target && target.value);
|
|
@@ -1622,7 +1490,7 @@ function PasswordWidget(props) {
|
|
|
1622
1490
|
}
|
|
1623
1491
|
|
|
1624
1492
|
// src/widgets/RadioWidget.tsx
|
|
1625
|
-
var
|
|
1493
|
+
var import_react9 = require("react");
|
|
1626
1494
|
var import_utils28 = require("@rjsf/utils");
|
|
1627
1495
|
var import_core24 = require("@mantine/core");
|
|
1628
1496
|
var import_jsx_runtime31 = require("react/jsx-runtime");
|
|
@@ -1645,7 +1513,7 @@ function RadioWidget(props) {
|
|
|
1645
1513
|
} = props;
|
|
1646
1514
|
const { enumOptions, enumDisabled, inline, emptyValue } = options;
|
|
1647
1515
|
const themeProps = cleanupOptions(options);
|
|
1648
|
-
const handleChange = (0,
|
|
1516
|
+
const handleChange = (0, import_react9.useCallback)(
|
|
1649
1517
|
(nextValue) => {
|
|
1650
1518
|
if (!disabled && !readonly && onChange) {
|
|
1651
1519
|
onChange((0, import_utils28.enumOptionsValueForIndex)(nextValue, enumOptions, emptyValue));
|
|
@@ -1653,7 +1521,7 @@ function RadioWidget(props) {
|
|
|
1653
1521
|
},
|
|
1654
1522
|
[onChange, disabled, readonly, enumOptions, emptyValue]
|
|
1655
1523
|
);
|
|
1656
|
-
const handleBlur = (0,
|
|
1524
|
+
const handleBlur = (0, import_react9.useCallback)(
|
|
1657
1525
|
({ target }) => {
|
|
1658
1526
|
if (onBlur) {
|
|
1659
1527
|
onBlur(id, (0, import_utils28.enumOptionsValueForIndex)(target && target.value, enumOptions, emptyValue));
|
|
@@ -1661,7 +1529,7 @@ function RadioWidget(props) {
|
|
|
1661
1529
|
},
|
|
1662
1530
|
[onBlur, id, enumOptions, emptyValue]
|
|
1663
1531
|
);
|
|
1664
|
-
const handleFocus = (0,
|
|
1532
|
+
const handleFocus = (0, import_react9.useCallback)(
|
|
1665
1533
|
({ target }) => {
|
|
1666
1534
|
if (onFocus) {
|
|
1667
1535
|
onFocus(id, (0, import_utils28.enumOptionsValueForIndex)(target && target.value, enumOptions, emptyValue));
|
|
@@ -1701,7 +1569,7 @@ function RadioWidget(props) {
|
|
|
1701
1569
|
}
|
|
1702
1570
|
|
|
1703
1571
|
// src/widgets/RangeWidget.tsx
|
|
1704
|
-
var
|
|
1572
|
+
var import_react10 = require("react");
|
|
1705
1573
|
var import_utils30 = require("@rjsf/utils");
|
|
1706
1574
|
var import_core25 = require("@mantine/core");
|
|
1707
1575
|
var import_jsx_runtime32 = require("react/jsx-runtime");
|
|
@@ -1725,7 +1593,7 @@ function RangeWidget(props) {
|
|
|
1725
1593
|
} = props;
|
|
1726
1594
|
const themeProps = cleanupOptions(options);
|
|
1727
1595
|
const { min, max, step } = (0, import_utils30.rangeSpec)(schema);
|
|
1728
|
-
const handleChange = (0,
|
|
1596
|
+
const handleChange = (0, import_react10.useCallback)(
|
|
1729
1597
|
(nextValue) => {
|
|
1730
1598
|
if (!disabled && !readonly && onChange) {
|
|
1731
1599
|
onChange(nextValue);
|
|
@@ -1733,12 +1601,12 @@ function RangeWidget(props) {
|
|
|
1733
1601
|
},
|
|
1734
1602
|
[onChange, disabled, readonly]
|
|
1735
1603
|
);
|
|
1736
|
-
const handleBlur = (0,
|
|
1604
|
+
const handleBlur = (0, import_react10.useCallback)(() => {
|
|
1737
1605
|
if (onBlur) {
|
|
1738
1606
|
onBlur(id, value);
|
|
1739
1607
|
}
|
|
1740
1608
|
}, [onBlur, id, value]);
|
|
1741
|
-
const handleFocus = (0,
|
|
1609
|
+
const handleFocus = (0, import_react10.useCallback)(() => {
|
|
1742
1610
|
if (onFocus) {
|
|
1743
1611
|
onFocus(id, value);
|
|
1744
1612
|
}
|
|
@@ -1769,7 +1637,7 @@ function RangeWidget(props) {
|
|
|
1769
1637
|
}
|
|
1770
1638
|
|
|
1771
1639
|
// src/widgets/SelectWidget.tsx
|
|
1772
|
-
var
|
|
1640
|
+
var import_react11 = require("react");
|
|
1773
1641
|
var import_utils32 = require("@rjsf/utils");
|
|
1774
1642
|
var import_core26 = require("@mantine/core");
|
|
1775
1643
|
var import_jsx_runtime33 = require("react/jsx-runtime");
|
|
@@ -1794,7 +1662,7 @@ function SelectWidget(props) {
|
|
|
1794
1662
|
} = props;
|
|
1795
1663
|
const { enumOptions, enumDisabled, emptyValue } = options;
|
|
1796
1664
|
const themeProps = cleanupOptions(options);
|
|
1797
|
-
const handleChange = (0,
|
|
1665
|
+
const handleChange = (0, import_react11.useCallback)(
|
|
1798
1666
|
(nextValue) => {
|
|
1799
1667
|
if (!disabled && !readonly && onChange) {
|
|
1800
1668
|
onChange((0, import_utils32.enumOptionsValueForIndex)(nextValue, enumOptions, emptyValue));
|
|
@@ -1802,7 +1670,7 @@ function SelectWidget(props) {
|
|
|
1802
1670
|
},
|
|
1803
1671
|
[onChange, disabled, readonly, enumOptions, emptyValue]
|
|
1804
1672
|
);
|
|
1805
|
-
const handleBlur = (0,
|
|
1673
|
+
const handleBlur = (0, import_react11.useCallback)(
|
|
1806
1674
|
({ target }) => {
|
|
1807
1675
|
if (onBlur) {
|
|
1808
1676
|
onBlur(id, (0, import_utils32.enumOptionsValueForIndex)(target && target.value, enumOptions, emptyValue));
|
|
@@ -1810,7 +1678,7 @@ function SelectWidget(props) {
|
|
|
1810
1678
|
},
|
|
1811
1679
|
[onBlur, id, enumOptions, emptyValue]
|
|
1812
1680
|
);
|
|
1813
|
-
const handleFocus = (0,
|
|
1681
|
+
const handleFocus = (0, import_react11.useCallback)(
|
|
1814
1682
|
({ target }) => {
|
|
1815
1683
|
if (onFocus) {
|
|
1816
1684
|
onFocus(id, (0, import_utils32.enumOptionsValueForIndex)(target && target.value, enumOptions, emptyValue));
|
|
@@ -1819,7 +1687,7 @@ function SelectWidget(props) {
|
|
|
1819
1687
|
[onFocus, id, enumOptions, emptyValue]
|
|
1820
1688
|
);
|
|
1821
1689
|
const selectedIndexes = (0, import_utils32.enumOptionsIndexForValue)(value, enumOptions, multiple);
|
|
1822
|
-
const selectOptions = (0,
|
|
1690
|
+
const selectOptions = (0, import_react11.useMemo)(() => {
|
|
1823
1691
|
if (Array.isArray(enumOptions)) {
|
|
1824
1692
|
return enumOptions.map((option, index) => ({
|
|
1825
1693
|
key: String(index),
|
|
@@ -1856,7 +1724,7 @@ function SelectWidget(props) {
|
|
|
1856
1724
|
}
|
|
1857
1725
|
|
|
1858
1726
|
// src/widgets/TextareaWidget.tsx
|
|
1859
|
-
var
|
|
1727
|
+
var import_react12 = require("react");
|
|
1860
1728
|
var import_utils34 = require("@rjsf/utils");
|
|
1861
1729
|
var import_core27 = require("@mantine/core");
|
|
1862
1730
|
var import_jsx_runtime34 = require("react/jsx-runtime");
|
|
@@ -1881,13 +1749,13 @@ function TextareaWidget(props) {
|
|
|
1881
1749
|
} = props;
|
|
1882
1750
|
const themeProps = cleanupOptions(options);
|
|
1883
1751
|
const emptyValue = options?.emptyValue ?? "";
|
|
1884
|
-
const handleChange = (0,
|
|
1752
|
+
const handleChange = (0, import_react12.useCallback)(
|
|
1885
1753
|
(e) => {
|
|
1886
1754
|
onChange(e.target.value === "" ? emptyValue : e.target.value);
|
|
1887
1755
|
},
|
|
1888
1756
|
[onChange, emptyValue]
|
|
1889
1757
|
);
|
|
1890
|
-
const handleBlur = (0,
|
|
1758
|
+
const handleBlur = (0, import_react12.useCallback)(
|
|
1891
1759
|
({ target }) => {
|
|
1892
1760
|
if (onBlur) {
|
|
1893
1761
|
onBlur(id, target && target.value);
|
|
@@ -1895,7 +1763,7 @@ function TextareaWidget(props) {
|
|
|
1895
1763
|
},
|
|
1896
1764
|
[onBlur, id]
|
|
1897
1765
|
);
|
|
1898
|
-
const handleFocus = (0,
|
|
1766
|
+
const handleFocus = (0, import_react12.useCallback)(
|
|
1899
1767
|
({ target }) => {
|
|
1900
1768
|
if (onFocus) {
|
|
1901
1769
|
onFocus(id, target && target.value);
|