@torq-north/react-tools 1.4.7 → 1.4.8
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 +105 -47
- package/dist/index.cjs.map +1 -1
- package/dist/index.es.js +105 -48
- package/dist/index.es.js.map +1 -1
- package/dist/src/Core/Api/httpError.d.ts +12 -0
- package/dist/src/Core/Api/index.d.ts +1 -0
- package/dist/src/Form/Utilities/getFieldError.d.ts +3 -0
- package/dist/src/MUI/Components/Error/ErrorOverlay.d.ts +1 -1
- package/package.json +10 -5
package/dist/index.cjs
CHANGED
|
@@ -122,24 +122,90 @@ typeof SuppressedError === "function" ? SuppressedError : function (error, suppr
|
|
|
122
122
|
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
123
123
|
};
|
|
124
124
|
|
|
125
|
-
var Http;
|
|
126
|
-
(function (Http) {
|
|
127
|
-
Http["GET"] = "get";
|
|
128
|
-
Http["POST"] = "post";
|
|
129
|
-
Http["PUT"] = "put";
|
|
130
|
-
Http["PATCH"] = "patch";
|
|
131
|
-
Http["DELETE"] = "delete";
|
|
132
|
-
})(Http || (Http = {}));
|
|
133
125
|
var HTTPError = /** @class */ (function (_super) {
|
|
134
126
|
__extends(HTTPError, _super);
|
|
135
|
-
function HTTPError(message, status) {
|
|
127
|
+
function HTTPError(message, status, violations) {
|
|
128
|
+
if (violations === void 0) { violations = []; }
|
|
129
|
+
var _newTarget = this.constructor;
|
|
136
130
|
var _this = _super.call(this, message) || this;
|
|
131
|
+
// Preserve Error inheritance when consumers use the ES5 build.
|
|
132
|
+
Object.setPrototypeOf(_this, _newTarget.prototype);
|
|
133
|
+
_this.name = "HTTPError";
|
|
137
134
|
_this.status = status;
|
|
138
135
|
_this.statusText = message;
|
|
136
|
+
_this.violations = violations;
|
|
139
137
|
return _this;
|
|
140
138
|
}
|
|
141
139
|
return HTTPError;
|
|
142
140
|
}(Error));
|
|
141
|
+
function isJsonResponse(response) {
|
|
142
|
+
var _a;
|
|
143
|
+
var mediaType = (_a = response.headers
|
|
144
|
+
.get("content-type")) === null || _a === void 0 ? void 0 : _a.split(";")[0].trim().toLowerCase();
|
|
145
|
+
return (mediaType === "application/json" ||
|
|
146
|
+
/^application\/[^\s;]+\+json$/.test(mediaType !== null && mediaType !== void 0 ? mediaType : ""));
|
|
147
|
+
}
|
|
148
|
+
function nonEmptyString(value) {
|
|
149
|
+
return typeof value === "string" ? value.trim() || undefined : undefined;
|
|
150
|
+
}
|
|
151
|
+
function asRecord(value) {
|
|
152
|
+
return value !== null && typeof value === "object" && !Array.isArray(value)
|
|
153
|
+
? value
|
|
154
|
+
: undefined;
|
|
155
|
+
}
|
|
156
|
+
function readViolations(value) {
|
|
157
|
+
if (!Array.isArray(value))
|
|
158
|
+
return [];
|
|
159
|
+
return value.flatMap(function (item) {
|
|
160
|
+
var _a;
|
|
161
|
+
var violation = asRecord(item);
|
|
162
|
+
var title = (_a = nonEmptyString(violation === null || violation === void 0 ? void 0 : violation.title)) !== null && _a !== void 0 ? _a : nonEmptyString(violation === null || violation === void 0 ? void 0 : violation.message);
|
|
163
|
+
return typeof (violation === null || violation === void 0 ? void 0 : violation.propertyPath) === "string" && title
|
|
164
|
+
? [{ propertyPath: violation.propertyPath, title: title }]
|
|
165
|
+
: [];
|
|
166
|
+
});
|
|
167
|
+
}
|
|
168
|
+
function readHttpError(response) {
|
|
169
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
170
|
+
var payload, _a, violations, message;
|
|
171
|
+
var _c, _d, _e, _f, _g;
|
|
172
|
+
return __generator(this, function (_h) {
|
|
173
|
+
switch (_h.label) {
|
|
174
|
+
case 0:
|
|
175
|
+
if (!isJsonResponse(response)) return [3 /*break*/, 4];
|
|
176
|
+
_h.label = 1;
|
|
177
|
+
case 1:
|
|
178
|
+
_h.trys.push([1, 3, , 4]);
|
|
179
|
+
_a = asRecord;
|
|
180
|
+
return [4 /*yield*/, response.json()];
|
|
181
|
+
case 2:
|
|
182
|
+
payload = _a.apply(void 0, [_h.sent()]);
|
|
183
|
+
return [3 /*break*/, 4];
|
|
184
|
+
case 3:
|
|
185
|
+
_h.sent();
|
|
186
|
+
return [3 /*break*/, 4];
|
|
187
|
+
case 4:
|
|
188
|
+
violations = readViolations(payload === null || payload === void 0 ? void 0 : payload.violations);
|
|
189
|
+
message = (_g = (_f = (_e = (_d = (_c = nonEmptyString(payload === null || payload === void 0 ? void 0 : payload.message)) !== null && _c !== void 0 ? _c : nonEmptyString(payload === null || payload === void 0 ? void 0 : payload.detail)) !== null && _d !== void 0 ? _d : (violations.length
|
|
190
|
+
? violations.map(function (_a) {
|
|
191
|
+
var title = _a.title;
|
|
192
|
+
return title;
|
|
193
|
+
}).join("; ")
|
|
194
|
+
: undefined)) !== null && _e !== void 0 ? _e : nonEmptyString(payload === null || payload === void 0 ? void 0 : payload.title)) !== null && _f !== void 0 ? _f : nonEmptyString(response.statusText)) !== null && _g !== void 0 ? _g : "Request failed (HTTP ".concat(response.status, ")");
|
|
195
|
+
return [2 /*return*/, new HTTPError(message, response.status, violations)];
|
|
196
|
+
}
|
|
197
|
+
});
|
|
198
|
+
});
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
var Http;
|
|
202
|
+
(function (Http) {
|
|
203
|
+
Http["GET"] = "get";
|
|
204
|
+
Http["POST"] = "post";
|
|
205
|
+
Http["PUT"] = "put";
|
|
206
|
+
Http["PATCH"] = "patch";
|
|
207
|
+
Http["DELETE"] = "delete";
|
|
208
|
+
})(Http || (Http = {}));
|
|
143
209
|
var sendGet = function (url, params) { return __awaiter(void 0, void 0, void 0, function () {
|
|
144
210
|
var fetchUrl, response;
|
|
145
211
|
return __generator(this, function (_a) {
|
|
@@ -225,33 +291,17 @@ var sendDelete = function (url) { return __awaiter(void 0, void 0, void 0, funct
|
|
|
225
291
|
}); };
|
|
226
292
|
function checkResponse(response) {
|
|
227
293
|
return __awaiter(this, void 0, void 0, function () {
|
|
228
|
-
var exception, message;
|
|
229
294
|
return __generator(this, function (_a) {
|
|
230
295
|
switch (_a.label) {
|
|
231
296
|
case 0:
|
|
232
|
-
if (!!response.ok) return [3 /*break*/,
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
return [4 /*yield*/, response.json()];
|
|
237
|
-
case 1:
|
|
238
|
-
exception = _a.sent();
|
|
239
|
-
_a.label = 2;
|
|
240
|
-
case 2:
|
|
241
|
-
message = (exception && exception.message) || response.statusText;
|
|
242
|
-
throw new HTTPError(message, response.status);
|
|
243
|
-
case 3: return [2 /*return*/];
|
|
297
|
+
if (!!response.ok) return [3 /*break*/, 2];
|
|
298
|
+
return [4 /*yield*/, readHttpError(response)];
|
|
299
|
+
case 1: throw _a.sent();
|
|
300
|
+
case 2: return [2 /*return*/];
|
|
244
301
|
}
|
|
245
302
|
});
|
|
246
303
|
});
|
|
247
304
|
}
|
|
248
|
-
function isJson(response) {
|
|
249
|
-
var contentType = response.headers.get("content-type");
|
|
250
|
-
if (!contentType) {
|
|
251
|
-
return false;
|
|
252
|
-
}
|
|
253
|
-
return contentType.indexOf("application/json") >= 0;
|
|
254
|
-
}
|
|
255
305
|
var authLoginUrl = "/auth/login";
|
|
256
306
|
var authRedirectEnabled = false;
|
|
257
307
|
function enableAuthRedirect(loginUrl) {
|
|
@@ -277,7 +327,7 @@ function process$1(response) {
|
|
|
277
327
|
return [4 /*yield*/, checkResponse(response)];
|
|
278
328
|
case 1:
|
|
279
329
|
_a.sent();
|
|
280
|
-
if (
|
|
330
|
+
if (isJsonResponse(response)) {
|
|
281
331
|
return [2 /*return*/, response.json()];
|
|
282
332
|
}
|
|
283
333
|
return [2 /*return*/, null];
|
|
@@ -383,6 +433,13 @@ function usePartialSetterState(initial) {
|
|
|
383
433
|
return [params, updateParams];
|
|
384
434
|
}
|
|
385
435
|
|
|
436
|
+
/** Hide rejected values' submission errors after the user edits the field. */
|
|
437
|
+
function getFieldError(meta) {
|
|
438
|
+
if (!meta.touched && !meta.submitFailed)
|
|
439
|
+
return undefined;
|
|
440
|
+
return (meta.error || (!meta.dirtySinceLastSubmit ? meta.submitError : undefined));
|
|
441
|
+
}
|
|
442
|
+
|
|
386
443
|
function FieldWrapper(_a) {
|
|
387
444
|
var icon = _a.icon, children = _a.children, showSpace = _a.showSpace;
|
|
388
445
|
return (jsxRuntime.jsxs(material.Stack, { direction: "row", alignItems: "center", children: [(icon || showSpace) && (jsxRuntime.jsx(material.Box, { minWidth: 32, color: "primary.main", mt: 2, mx: 1, children: icon })), children] }));
|
|
@@ -406,7 +463,9 @@ function composeValidators() {
|
|
|
406
463
|
}
|
|
407
464
|
|
|
408
465
|
var isRequired = function (value) {
|
|
409
|
-
return value ?
|
|
466
|
+
return (Array.isArray(value) ? value.length > 0 : value != null && value !== "")
|
|
467
|
+
? undefined
|
|
468
|
+
: "This field is required";
|
|
410
469
|
};
|
|
411
470
|
|
|
412
471
|
function TextFormField(_a) {
|
|
@@ -419,7 +478,7 @@ function TextFormField(_a) {
|
|
|
419
478
|
var mergedSlotProps = __assign(__assign({}, textFieldSlotProps), { input: typeof inputSlotProp === "function"
|
|
420
479
|
? function (ownerState) { return (__assign(__assign({}, input), inputSlotProp(ownerState))); }
|
|
421
480
|
: __assign(__assign({}, input), inputSlotProp) });
|
|
422
|
-
return (jsxRuntime.jsx(FieldWrapper, { icon: icon, showSpace: showSpace, children: jsxRuntime.jsx(material.TextField, __assign({ fullWidth: true, label: label, required: required, multiline: multiline, disabled: disabled, placeholder: placeholder, error: meta
|
|
481
|
+
return (jsxRuntime.jsx(FieldWrapper, { icon: icon, showSpace: showSpace, children: jsxRuntime.jsx(material.TextField, __assign({ fullWidth: true, label: label, required: required, multiline: multiline, disabled: disabled, placeholder: placeholder, error: getFieldError(meta), helperText: getFieldError(meta) || helperText, slotProps: mergedSlotProps }, remainingTextFieldProps)) }));
|
|
423
482
|
}
|
|
424
483
|
|
|
425
484
|
function isGroup(o) {
|
|
@@ -500,7 +559,7 @@ function SelectFormField(_a) {
|
|
|
500
559
|
value != "" && (jsxRuntime.jsx(material.IconButton, { size: "small", onClick: function () { return onChange(undefined); }, tabIndex: -1, children: jsxRuntime.jsx(CloseIcon, { fontSize: "small" }) })), inputSlotProps === null || inputSlotProps === void 0 ? void 0 : inputSlotProps.endAdornment] })),
|
|
501
560
|
})) });
|
|
502
561
|
var renderedOptions = React.useMemo(function () { return renderSelectOptions(options); }, [options]);
|
|
503
|
-
return (jsxRuntime.jsx(FieldWrapper, { icon: icon, showSpace: showSpace, children: jsxRuntime.jsxs(material.TextField, __assign({ onMouseEnter: function () { return setIsMousedOver(true); }, onMouseLeave: function () { return setIsMousedOver(false); }, fullWidth: true, select: true, label: label, required: required, disabled: disabled, error: meta
|
|
562
|
+
return (jsxRuntime.jsx(FieldWrapper, { icon: icon, showSpace: showSpace, children: jsxRuntime.jsxs(material.TextField, __assign({ onMouseEnter: function () { return setIsMousedOver(true); }, onMouseLeave: function () { return setIsMousedOver(false); }, fullWidth: true, select: true, label: label, required: required, disabled: disabled, error: getFieldError(meta), helperText: getFieldError(meta) || helperText, value: value ? value : [], onChange: onChange, slotProps: mergedSlotProps }, remainingTextFieldProps, { children: [renderedOptions, !options && jsxRuntime.jsx(material.MenuItem, {})] })) }));
|
|
504
563
|
}
|
|
505
564
|
|
|
506
565
|
function findTextFor(value, options) {
|
|
@@ -560,7 +619,7 @@ function MultiSelectFormField(_a) {
|
|
|
560
619
|
return (jsxRuntime.jsxs(React.Fragment, { children: [index > 0 && ", ", (_a = findTextFor(s, options)) !== null && _a !== void 0 ? _a : "Unknown"] }, s));
|
|
561
620
|
}) })); } }) });
|
|
562
621
|
var renderedOptions = React.useMemo(function () { return renderCheckboxSelectOptions(options, value); }, [options, value]);
|
|
563
|
-
return (jsxRuntime.jsx(FieldWrapper, { icon: icon, showSpace: showSpace, children: jsxRuntime.jsxs(material.TextField, __assign({ onMouseEnter: function () { return setIsMousedOver(true); }, onMouseLeave: function () { return setIsMousedOver(false); }, fullWidth: true, select: true, label: label, required: required, disabled: disabled, error: meta
|
|
622
|
+
return (jsxRuntime.jsx(FieldWrapper, { icon: icon, showSpace: showSpace, children: jsxRuntime.jsxs(material.TextField, __assign({ onMouseEnter: function () { return setIsMousedOver(true); }, onMouseLeave: function () { return setIsMousedOver(false); }, fullWidth: true, select: true, label: label, required: required, disabled: disabled, error: getFieldError(meta), helperText: getFieldError(meta) || helperText, value: value ? value : [], onChange: onChange, slotProps: mergedSlotProps }, remainingTextFieldProps, { children: [renderedOptions, !options && jsxRuntime.jsx(material.MenuItem, {})] })) }));
|
|
564
623
|
}
|
|
565
624
|
|
|
566
625
|
var mustBeChecked = function (v) {
|
|
@@ -572,7 +631,7 @@ var CheckboxFormField = function (_a) {
|
|
|
572
631
|
var _c = reactFinalForm.useField(name, __assign({ type: "checkbox", validate: mustBeTrue
|
|
573
632
|
? composeValidators.apply(void 0, __spreadArray(__spreadArray([], validators, false), [mustBeChecked], false)) : composeValidators.apply(void 0, validators) }, slotProps === null || slotProps === void 0 ? void 0 : slotProps.field)), input = _c.input, meta = _c.meta;
|
|
574
633
|
var checkboxProps = __assign(__assign(__assign({}, input), { disabled: disabled }), slotProps === null || slotProps === void 0 ? void 0 : slotProps.checkbox);
|
|
575
|
-
return (jsxRuntime.jsxs(FieldWrapper, { icon: icon, showSpace: showSpace, children: [jsxRuntime.jsx(material.FormControlLabel, { control: jsxRuntime.jsx(material.FormGroup, { children: jsxRuntime.jsx(material.Checkbox, __assign({}, checkboxProps)) }), label: label, disabled: disabled }), ((meta
|
|
634
|
+
return (jsxRuntime.jsxs(FieldWrapper, { icon: icon, showSpace: showSpace, children: [jsxRuntime.jsx(material.FormControlLabel, { control: jsxRuntime.jsx(material.FormGroup, { children: jsxRuntime.jsx(material.Checkbox, __assign({}, checkboxProps)) }), label: label, disabled: disabled }), (getFieldError(meta) || helperText) && (jsxRuntime.jsx(material.FormHelperText, { disabled: disabled, error: getFieldError(meta) || forceError, sx: { marginTop: 0, marginLeft: 2 }, children: getFieldError(meta) || helperText }))] }));
|
|
576
635
|
};
|
|
577
636
|
|
|
578
637
|
var DateFormField = function (_a) {
|
|
@@ -581,7 +640,7 @@ var DateFormField = function (_a) {
|
|
|
581
640
|
var _e = reactFinalForm.useField(name, __assign({ format: format, validate: required
|
|
582
641
|
? composeValidators.apply(void 0, __spreadArray(__spreadArray([], validators, false), [isRequired], false)) : composeValidators.apply(void 0, validators) }, slotProps === null || slotProps === void 0 ? void 0 : slotProps.field)), input = _e.input, meta = _e.meta;
|
|
583
642
|
var _f = ((_b = slotProps === null || slotProps === void 0 ? void 0 : slotProps.datePicker) !== null && _b !== void 0 ? _b : {}), datePickerSlotProps = _f.slotProps, remainingDatePickerProps = __rest(_f, ["slotProps"]);
|
|
584
|
-
var mergedSlotProps = __assign(__assign({}, datePickerSlotProps), { textField: __assign({ fullWidth: true, required: required, color: meta
|
|
643
|
+
var mergedSlotProps = __assign(__assign({}, datePickerSlotProps), { textField: __assign({ fullWidth: true, required: required, color: getFieldError(meta) ? "error" : undefined, error: getFieldError(meta), helperText: getFieldError(meta) || helperText, onFocus: input.onFocus, onBlur: input.onBlur }, datePickerSlotProps === null || datePickerSlotProps === void 0 ? void 0 : datePickerSlotProps.textField) });
|
|
585
644
|
return (jsxRuntime.jsx(FieldWrapper, { icon: icon, showSpace: showSpace, children: jsxRuntime.jsx(xDatePickers.DatePicker, __assign({ label: label, disabled: disabled, views: ["year", "month", "day"], value: input.value ? dayjs(input.value) : null, onOpen: input.onFocus, onClose: input.onBlur, onChange: function (value) {
|
|
586
645
|
return input.onChange(formatAsDate ? value === null || value === void 0 ? void 0 : value.format("YYYY-MM-DD") : value === null || value === void 0 ? void 0 : value.toJSON());
|
|
587
646
|
}, slotProps: mergedSlotProps }, remainingDatePickerProps)) }));
|
|
@@ -593,7 +652,7 @@ var DateTimeFormField = function (_a) {
|
|
|
593
652
|
var _d = reactFinalForm.useField(name, __assign({ format: format, validate: required
|
|
594
653
|
? composeValidators.apply(void 0, __spreadArray(__spreadArray([], validators, false), [isRequired], false)) : composeValidators.apply(void 0, validators) }, slotProps === null || slotProps === void 0 ? void 0 : slotProps.field)), input = _d.input, meta = _d.meta;
|
|
595
654
|
var _e = ((_b = slotProps === null || slotProps === void 0 ? void 0 : slotProps.dateTimePicker) !== null && _b !== void 0 ? _b : {}), dateTimePickerSlotProps = _e.slotProps, remainingDateTimePickerProps = __rest(_e, ["slotProps"]);
|
|
596
|
-
var mergedSlotProps = __assign(__assign({}, dateTimePickerSlotProps), { textField: __assign({ fullWidth: true, required: required, color: meta
|
|
655
|
+
var mergedSlotProps = __assign(__assign({}, dateTimePickerSlotProps), { textField: __assign({ fullWidth: true, required: required, color: getFieldError(meta) ? "error" : undefined, error: getFieldError(meta), helperText: getFieldError(meta) || helperText, onFocus: input.onFocus, onBlur: input.onBlur }, dateTimePickerSlotProps === null || dateTimePickerSlotProps === void 0 ? void 0 : dateTimePickerSlotProps.textField) });
|
|
597
656
|
return (jsxRuntime.jsx(FieldWrapper, { icon: icon, showSpace: showSpace, children: jsxRuntime.jsx(xDatePickers.DateTimePicker, __assign({ label: label, disabled: disabled, value: input.value ? dayjs(input.value) : null, onOpen: input.onFocus, onClose: input.onBlur, onChange: function (value) { return input.onChange(value === null || value === void 0 ? void 0 : value.toJSON()); }, slotProps: mergedSlotProps }, remainingDateTimePickerProps)) }));
|
|
598
657
|
};
|
|
599
658
|
|
|
@@ -605,15 +664,16 @@ var RadioOption = function (props) {
|
|
|
605
664
|
|
|
606
665
|
var RadioFormField = function (_a) {
|
|
607
666
|
var name = _a.name, label = _a.label, options = _a.options, required = _a.required, disabled = _a.disabled, vertical = _a.vertical, icon = _a.icon, showSpace = _a.showSpace, slotProps = _a.slotProps, helperText = _a.helperText, forceError = _a.forceError, _b = _a.validators, validators = _b === void 0 ? [] : _b;
|
|
608
|
-
var
|
|
609
|
-
? composeValidators.apply(void 0, __spreadArray(__spreadArray([], validators, false), [isRequired], false)) : composeValidators.apply(void 0, validators) }, slotProps === null || slotProps === void 0 ? void 0 : slotProps.field)).meta
|
|
667
|
+
var meta = reactFinalForm.useField(name, __assign({ validate: required
|
|
668
|
+
? composeValidators.apply(void 0, __spreadArray(__spreadArray([], validators, false), [isRequired], false)) : composeValidators.apply(void 0, validators) }, slotProps === null || slotProps === void 0 ? void 0 : slotProps.field)).meta;
|
|
669
|
+
var error = getFieldError(meta);
|
|
610
670
|
return (jsxRuntime.jsx(FieldWrapper, { icon: icon, showSpace: showSpace, children: jsxRuntime.jsxs(material.FormControl, { required: required, children: [label && (jsxRuntime.jsx(material.FormLabel, { id: "".concat(name, "-radio-buttons-group-label"), disabled: disabled, children: label })), jsxRuntime.jsx(material.RadioGroup, { "aria-labelledby": "".concat(name, "-radio-buttons-group-label"), row: !vertical, children: options.map(function (o) {
|
|
611
671
|
var _a;
|
|
612
672
|
return (jsxRuntime.jsx(material.FormControlLabel, { label: typeof o === "string" ? o : ((_a = o.text) !== null && _a !== void 0 ? _a : o.value), disabled: disabled, control: jsxRuntime.jsx(reactFinalForm.Field, __assign({ name: name, value: typeof o === "string" ? o : o.value, type: "radio", render: function (_a) {
|
|
613
673
|
var input = _a.input, meta = _a.meta;
|
|
614
674
|
return (jsxRuntime.jsx(RadioOption, { input: input, meta: meta, disabled: disabled, required: required, radioProps: slotProps === null || slotProps === void 0 ? void 0 : slotProps.radio }));
|
|
615
675
|
} }, slotProps === null || slotProps === void 0 ? void 0 : slotProps.radioField)) }, typeof o === "string" ? o : o.value));
|
|
616
|
-
}) }), (
|
|
676
|
+
}) }), (error || helperText) && (jsxRuntime.jsx(material.FormHelperText, { error: error != null || forceError, sx: { marginTop: 0 }, children: error || helperText }))] }) }));
|
|
617
677
|
};
|
|
618
678
|
|
|
619
679
|
var ErrorMessage = function (_a) {
|
|
@@ -624,20 +684,17 @@ var ErrorMessage = function (_a) {
|
|
|
624
684
|
var ErrorOverlay = function (_a) {
|
|
625
685
|
var _b, _c, _d, _e;
|
|
626
686
|
var children = _a.children, show = _a.show, offset = _a.offset, message = _a.message;
|
|
627
|
-
return (jsxRuntime.jsxs(material.Box, { position: "relative", children: [children, jsxRuntime.jsx(material.Stack, { position: "absolute", top: -7 + ((_b = offset === null || offset === void 0 ? void 0 : offset.top) !== null && _b !== void 0 ? _b : 0), left: -7 + ((_c = offset === null || offset === void 0 ? void 0 : offset.left) !== null && _c !== void 0 ? _c : 0), right: -7 + ((_d = offset === null || offset === void 0 ? void 0 : offset.right) !== null && _d !== void 0 ? _d : 0), bottom: -7 + ((_e = offset === null || offset === void 0 ? void 0 : offset.bottom) !== null && _e !== void 0 ? _e : 0), zIndex: 1, borderRadius: 2, justifyContent: "center", alignItems: "center", sx: function (theme) { return ({
|
|
687
|
+
return (jsxRuntime.jsxs(material.Box, { position: "relative", children: [children, show && (jsxRuntime.jsx(material.Stack, { position: "absolute", top: -7 + ((_b = offset === null || offset === void 0 ? void 0 : offset.top) !== null && _b !== void 0 ? _b : 0), left: -7 + ((_c = offset === null || offset === void 0 ? void 0 : offset.left) !== null && _c !== void 0 ? _c : 0), right: -7 + ((_d = offset === null || offset === void 0 ? void 0 : offset.right) !== null && _d !== void 0 ? _d : 0), bottom: -7 + ((_e = offset === null || offset === void 0 ? void 0 : offset.bottom) !== null && _e !== void 0 ? _e : 0), zIndex: 1, borderRadius: 2, justifyContent: "center", alignItems: "center", sx: function (theme) { return ({
|
|
628
688
|
bgcolor: material.alpha(theme.palette.background.paper, 0.6),
|
|
629
|
-
transition: "0.2s",
|
|
630
|
-
opacity: show ? 1 : 0,
|
|
631
689
|
backdropFilter: "blur(7px)",
|
|
632
|
-
pointerEvents: show ? undefined : "none",
|
|
633
690
|
}); }, children: jsxRuntime.jsx(material.Box, { borderRadius: 2, p: 1, sx: function (theme) { return ({
|
|
634
691
|
bgcolor: material.alpha(theme.palette.background.paper, 0.6),
|
|
635
|
-
}); }, children: jsxRuntime.jsx(ErrorMessage, { message: message }) }) })] }));
|
|
692
|
+
}); }, children: jsxRuntime.jsx(ErrorMessage, { message: message }) }) }))] }));
|
|
636
693
|
};
|
|
637
694
|
|
|
638
695
|
var ErrorNotification = function (_a) {
|
|
639
696
|
var open = _a.open, message = _a.message, onClose = _a.onClose;
|
|
640
|
-
return (jsxRuntime.jsx(material.Snackbar, { open: open, autoHideDuration: 6000, onClose: onClose, children: jsxRuntime.jsx(material.Alert, { onClose: onClose, severity: "error", sx: { width: "100%" }, elevation: 6, variant: "filled", children: message
|
|
697
|
+
return (jsxRuntime.jsx(material.Snackbar, { open: open, autoHideDuration: 6000, onClose: onClose, children: jsxRuntime.jsx(material.Alert, { onClose: onClose, severity: "error", sx: { width: "100%" }, elevation: 6, variant: "filled", children: (message === null || message === void 0 ? void 0 : message.trim()) || "An error has occurred" }) }));
|
|
641
698
|
};
|
|
642
699
|
|
|
643
700
|
var DropIndicator = material.styled(material.Box, {
|
|
@@ -4785,7 +4842,7 @@ function FileEditorField(_a) {
|
|
|
4785
4842
|
var name = _a.name, label = _a.label, icon = _a.icon, showSpace = _a.showSpace, multiple = _a.multiple, disabled = _a.disabled, helperText = _a.helperText, placeholder = _a.placeholder, required = _a.required, slotProps = _a.slotProps, accept = _a.accept, maxFiles = _a.maxFiles, maxSize = _a.maxSize, minSize = _a.minSize, forceError = _a.forceError, _b = _a.validators, validators = _b === void 0 ? [] : _b;
|
|
4786
4843
|
var _c = reactFinalForm.useField(name, __assign({ validate: required
|
|
4787
4844
|
? composeValidators.apply(void 0, __spreadArray(__spreadArray([], validators, false), [isFileRequired], false)) : composeValidators.apply(void 0, validators) }, slotProps === null || slotProps === void 0 ? void 0 : slotProps.field)), input = _c.input, meta = _c.meta;
|
|
4788
|
-
return (jsxRuntime.jsx(FieldWrapper, { icon: icon, showSpace: showSpace, children: jsxRuntime.jsxs(material.FormControl, { fullWidth: true, children: [label && (jsxRuntime.jsx(material.FormLabel, { disabled: disabled, error: meta
|
|
4845
|
+
return (jsxRuntime.jsx(FieldWrapper, { icon: icon, showSpace: showSpace, children: jsxRuntime.jsxs(material.FormControl, { fullWidth: true, children: [label && (jsxRuntime.jsx(material.FormLabel, { disabled: disabled, error: getFieldError(meta), children: label })), jsxRuntime.jsx(FileEditor, { value: input.value, onChange: input.onChange, multiple: multiple, disabled: disabled, accept: accept, maxFiles: maxFiles, maxSize: maxSize, minSize: minSize, placeholder: placeholder }), jsxRuntime.jsx(material.FormHelperText, { error: getFieldError(meta) || forceError, children: getFieldError(meta) || helperText })] }) }));
|
|
4789
4846
|
}
|
|
4790
4847
|
|
|
4791
4848
|
function asInteger(value) {
|
|
@@ -5083,6 +5140,7 @@ exports.FileDisplay = FileDisplay;
|
|
|
5083
5140
|
exports.FileDropper = FileDropper;
|
|
5084
5141
|
exports.FileEditor = FileEditor;
|
|
5085
5142
|
exports.FileEditorField = FileEditorField;
|
|
5143
|
+
exports.HTTPError = HTTPError;
|
|
5086
5144
|
exports.LabeledValue = LabeledValue;
|
|
5087
5145
|
exports.LoaderButton = LoaderButton;
|
|
5088
5146
|
exports.MultiSelectFormField = MultiSelectFormField;
|