@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.es.js
CHANGED
|
@@ -120,24 +120,90 @@ typeof SuppressedError === "function" ? SuppressedError : function (error, suppr
|
|
|
120
120
|
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
121
121
|
};
|
|
122
122
|
|
|
123
|
-
var Http;
|
|
124
|
-
(function (Http) {
|
|
125
|
-
Http["GET"] = "get";
|
|
126
|
-
Http["POST"] = "post";
|
|
127
|
-
Http["PUT"] = "put";
|
|
128
|
-
Http["PATCH"] = "patch";
|
|
129
|
-
Http["DELETE"] = "delete";
|
|
130
|
-
})(Http || (Http = {}));
|
|
131
123
|
var HTTPError = /** @class */ (function (_super) {
|
|
132
124
|
__extends(HTTPError, _super);
|
|
133
|
-
function HTTPError(message, status) {
|
|
125
|
+
function HTTPError(message, status, violations) {
|
|
126
|
+
if (violations === void 0) { violations = []; }
|
|
127
|
+
var _newTarget = this.constructor;
|
|
134
128
|
var _this = _super.call(this, message) || this;
|
|
129
|
+
// Preserve Error inheritance when consumers use the ES5 build.
|
|
130
|
+
Object.setPrototypeOf(_this, _newTarget.prototype);
|
|
131
|
+
_this.name = "HTTPError";
|
|
135
132
|
_this.status = status;
|
|
136
133
|
_this.statusText = message;
|
|
134
|
+
_this.violations = violations;
|
|
137
135
|
return _this;
|
|
138
136
|
}
|
|
139
137
|
return HTTPError;
|
|
140
138
|
}(Error));
|
|
139
|
+
function isJsonResponse(response) {
|
|
140
|
+
var _a;
|
|
141
|
+
var mediaType = (_a = response.headers
|
|
142
|
+
.get("content-type")) === null || _a === void 0 ? void 0 : _a.split(";")[0].trim().toLowerCase();
|
|
143
|
+
return (mediaType === "application/json" ||
|
|
144
|
+
/^application\/[^\s;]+\+json$/.test(mediaType !== null && mediaType !== void 0 ? mediaType : ""));
|
|
145
|
+
}
|
|
146
|
+
function nonEmptyString(value) {
|
|
147
|
+
return typeof value === "string" ? value.trim() || undefined : undefined;
|
|
148
|
+
}
|
|
149
|
+
function asRecord(value) {
|
|
150
|
+
return value !== null && typeof value === "object" && !Array.isArray(value)
|
|
151
|
+
? value
|
|
152
|
+
: undefined;
|
|
153
|
+
}
|
|
154
|
+
function readViolations(value) {
|
|
155
|
+
if (!Array.isArray(value))
|
|
156
|
+
return [];
|
|
157
|
+
return value.flatMap(function (item) {
|
|
158
|
+
var _a;
|
|
159
|
+
var violation = asRecord(item);
|
|
160
|
+
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);
|
|
161
|
+
return typeof (violation === null || violation === void 0 ? void 0 : violation.propertyPath) === "string" && title
|
|
162
|
+
? [{ propertyPath: violation.propertyPath, title: title }]
|
|
163
|
+
: [];
|
|
164
|
+
});
|
|
165
|
+
}
|
|
166
|
+
function readHttpError(response) {
|
|
167
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
168
|
+
var payload, _a, violations, message;
|
|
169
|
+
var _c, _d, _e, _f, _g;
|
|
170
|
+
return __generator(this, function (_h) {
|
|
171
|
+
switch (_h.label) {
|
|
172
|
+
case 0:
|
|
173
|
+
if (!isJsonResponse(response)) return [3 /*break*/, 4];
|
|
174
|
+
_h.label = 1;
|
|
175
|
+
case 1:
|
|
176
|
+
_h.trys.push([1, 3, , 4]);
|
|
177
|
+
_a = asRecord;
|
|
178
|
+
return [4 /*yield*/, response.json()];
|
|
179
|
+
case 2:
|
|
180
|
+
payload = _a.apply(void 0, [_h.sent()]);
|
|
181
|
+
return [3 /*break*/, 4];
|
|
182
|
+
case 3:
|
|
183
|
+
_h.sent();
|
|
184
|
+
return [3 /*break*/, 4];
|
|
185
|
+
case 4:
|
|
186
|
+
violations = readViolations(payload === null || payload === void 0 ? void 0 : payload.violations);
|
|
187
|
+
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
|
|
188
|
+
? violations.map(function (_a) {
|
|
189
|
+
var title = _a.title;
|
|
190
|
+
return title;
|
|
191
|
+
}).join("; ")
|
|
192
|
+
: 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, ")");
|
|
193
|
+
return [2 /*return*/, new HTTPError(message, response.status, violations)];
|
|
194
|
+
}
|
|
195
|
+
});
|
|
196
|
+
});
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
var Http;
|
|
200
|
+
(function (Http) {
|
|
201
|
+
Http["GET"] = "get";
|
|
202
|
+
Http["POST"] = "post";
|
|
203
|
+
Http["PUT"] = "put";
|
|
204
|
+
Http["PATCH"] = "patch";
|
|
205
|
+
Http["DELETE"] = "delete";
|
|
206
|
+
})(Http || (Http = {}));
|
|
141
207
|
var sendGet = function (url, params) { return __awaiter(void 0, void 0, void 0, function () {
|
|
142
208
|
var fetchUrl, response;
|
|
143
209
|
return __generator(this, function (_a) {
|
|
@@ -223,33 +289,17 @@ var sendDelete = function (url) { return __awaiter(void 0, void 0, void 0, funct
|
|
|
223
289
|
}); };
|
|
224
290
|
function checkResponse(response) {
|
|
225
291
|
return __awaiter(this, void 0, void 0, function () {
|
|
226
|
-
var exception, message;
|
|
227
292
|
return __generator(this, function (_a) {
|
|
228
293
|
switch (_a.label) {
|
|
229
294
|
case 0:
|
|
230
|
-
if (!!response.ok) return [3 /*break*/,
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
return [4 /*yield*/, response.json()];
|
|
235
|
-
case 1:
|
|
236
|
-
exception = _a.sent();
|
|
237
|
-
_a.label = 2;
|
|
238
|
-
case 2:
|
|
239
|
-
message = (exception && exception.message) || response.statusText;
|
|
240
|
-
throw new HTTPError(message, response.status);
|
|
241
|
-
case 3: return [2 /*return*/];
|
|
295
|
+
if (!!response.ok) return [3 /*break*/, 2];
|
|
296
|
+
return [4 /*yield*/, readHttpError(response)];
|
|
297
|
+
case 1: throw _a.sent();
|
|
298
|
+
case 2: return [2 /*return*/];
|
|
242
299
|
}
|
|
243
300
|
});
|
|
244
301
|
});
|
|
245
302
|
}
|
|
246
|
-
function isJson(response) {
|
|
247
|
-
var contentType = response.headers.get("content-type");
|
|
248
|
-
if (!contentType) {
|
|
249
|
-
return false;
|
|
250
|
-
}
|
|
251
|
-
return contentType.indexOf("application/json") >= 0;
|
|
252
|
-
}
|
|
253
303
|
var authLoginUrl = "/auth/login";
|
|
254
304
|
var authRedirectEnabled = false;
|
|
255
305
|
function enableAuthRedirect(loginUrl) {
|
|
@@ -275,7 +325,7 @@ function process$1(response) {
|
|
|
275
325
|
return [4 /*yield*/, checkResponse(response)];
|
|
276
326
|
case 1:
|
|
277
327
|
_a.sent();
|
|
278
|
-
if (
|
|
328
|
+
if (isJsonResponse(response)) {
|
|
279
329
|
return [2 /*return*/, response.json()];
|
|
280
330
|
}
|
|
281
331
|
return [2 /*return*/, null];
|
|
@@ -381,6 +431,13 @@ function usePartialSetterState(initial) {
|
|
|
381
431
|
return [params, updateParams];
|
|
382
432
|
}
|
|
383
433
|
|
|
434
|
+
/** Hide rejected values' submission errors after the user edits the field. */
|
|
435
|
+
function getFieldError(meta) {
|
|
436
|
+
if (!meta.touched && !meta.submitFailed)
|
|
437
|
+
return undefined;
|
|
438
|
+
return (meta.error || (!meta.dirtySinceLastSubmit ? meta.submitError : undefined));
|
|
439
|
+
}
|
|
440
|
+
|
|
384
441
|
function FieldWrapper(_a) {
|
|
385
442
|
var icon = _a.icon, children = _a.children, showSpace = _a.showSpace;
|
|
386
443
|
return (jsxs(Stack, { direction: "row", alignItems: "center", children: [(icon || showSpace) && (jsx(Box, { minWidth: 32, color: "primary.main", mt: 2, mx: 1, children: icon })), children] }));
|
|
@@ -404,7 +461,9 @@ function composeValidators() {
|
|
|
404
461
|
}
|
|
405
462
|
|
|
406
463
|
var isRequired = function (value) {
|
|
407
|
-
return value ?
|
|
464
|
+
return (Array.isArray(value) ? value.length > 0 : value != null && value !== "")
|
|
465
|
+
? undefined
|
|
466
|
+
: "This field is required";
|
|
408
467
|
};
|
|
409
468
|
|
|
410
469
|
function TextFormField(_a) {
|
|
@@ -417,7 +476,7 @@ function TextFormField(_a) {
|
|
|
417
476
|
var mergedSlotProps = __assign(__assign({}, textFieldSlotProps), { input: typeof inputSlotProp === "function"
|
|
418
477
|
? function (ownerState) { return (__assign(__assign({}, input), inputSlotProp(ownerState))); }
|
|
419
478
|
: __assign(__assign({}, input), inputSlotProp) });
|
|
420
|
-
return (jsx(FieldWrapper, { icon: icon, showSpace: showSpace, children: jsx(TextField, __assign({ fullWidth: true, label: label, required: required, multiline: multiline, disabled: disabled, placeholder: placeholder, error: meta
|
|
479
|
+
return (jsx(FieldWrapper, { icon: icon, showSpace: showSpace, children: jsx(TextField, __assign({ fullWidth: true, label: label, required: required, multiline: multiline, disabled: disabled, placeholder: placeholder, error: getFieldError(meta), helperText: getFieldError(meta) || helperText, slotProps: mergedSlotProps }, remainingTextFieldProps)) }));
|
|
421
480
|
}
|
|
422
481
|
|
|
423
482
|
function isGroup(o) {
|
|
@@ -498,7 +557,7 @@ function SelectFormField(_a) {
|
|
|
498
557
|
value != "" && (jsx(IconButton, { size: "small", onClick: function () { return onChange(undefined); }, tabIndex: -1, children: jsx(CloseIcon, { fontSize: "small" }) })), inputSlotProps === null || inputSlotProps === void 0 ? void 0 : inputSlotProps.endAdornment] })),
|
|
499
558
|
})) });
|
|
500
559
|
var renderedOptions = useMemo(function () { return renderSelectOptions(options); }, [options]);
|
|
501
|
-
return (jsx(FieldWrapper, { icon: icon, showSpace: showSpace, children: jsxs(TextField, __assign({ onMouseEnter: function () { return setIsMousedOver(true); }, onMouseLeave: function () { return setIsMousedOver(false); }, fullWidth: true, select: true, label: label, required: required, disabled: disabled, error: meta
|
|
560
|
+
return (jsx(FieldWrapper, { icon: icon, showSpace: showSpace, children: jsxs(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 && jsx(MenuItem, {})] })) }));
|
|
502
561
|
}
|
|
503
562
|
|
|
504
563
|
function findTextFor(value, options) {
|
|
@@ -558,7 +617,7 @@ function MultiSelectFormField(_a) {
|
|
|
558
617
|
return (jsxs(React.Fragment, { children: [index > 0 && ", ", (_a = findTextFor(s, options)) !== null && _a !== void 0 ? _a : "Unknown"] }, s));
|
|
559
618
|
}) })); } }) });
|
|
560
619
|
var renderedOptions = useMemo(function () { return renderCheckboxSelectOptions(options, value); }, [options, value]);
|
|
561
|
-
return (jsx(FieldWrapper, { icon: icon, showSpace: showSpace, children: jsxs(TextField, __assign({ onMouseEnter: function () { return setIsMousedOver(true); }, onMouseLeave: function () { return setIsMousedOver(false); }, fullWidth: true, select: true, label: label, required: required, disabled: disabled, error: meta
|
|
620
|
+
return (jsx(FieldWrapper, { icon: icon, showSpace: showSpace, children: jsxs(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 && jsx(MenuItem, {})] })) }));
|
|
562
621
|
}
|
|
563
622
|
|
|
564
623
|
var mustBeChecked = function (v) {
|
|
@@ -570,7 +629,7 @@ var CheckboxFormField = function (_a) {
|
|
|
570
629
|
var _c = useField(name, __assign({ type: "checkbox", validate: mustBeTrue
|
|
571
630
|
? 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;
|
|
572
631
|
var checkboxProps = __assign(__assign(__assign({}, input), { disabled: disabled }), slotProps === null || slotProps === void 0 ? void 0 : slotProps.checkbox);
|
|
573
|
-
return (jsxs(FieldWrapper, { icon: icon, showSpace: showSpace, children: [jsx(FormControlLabel, { control: jsx(FormGroup, { children: jsx(Checkbox, __assign({}, checkboxProps)) }), label: label, disabled: disabled }), ((meta
|
|
632
|
+
return (jsxs(FieldWrapper, { icon: icon, showSpace: showSpace, children: [jsx(FormControlLabel, { control: jsx(FormGroup, { children: jsx(Checkbox, __assign({}, checkboxProps)) }), label: label, disabled: disabled }), (getFieldError(meta) || helperText) && (jsx(FormHelperText, { disabled: disabled, error: getFieldError(meta) || forceError, sx: { marginTop: 0, marginLeft: 2 }, children: getFieldError(meta) || helperText }))] }));
|
|
574
633
|
};
|
|
575
634
|
|
|
576
635
|
var DateFormField = function (_a) {
|
|
@@ -579,7 +638,7 @@ var DateFormField = function (_a) {
|
|
|
579
638
|
var _e = useField(name, __assign({ format: format, validate: required
|
|
580
639
|
? 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;
|
|
581
640
|
var _f = ((_b = slotProps === null || slotProps === void 0 ? void 0 : slotProps.datePicker) !== null && _b !== void 0 ? _b : {}), datePickerSlotProps = _f.slotProps, remainingDatePickerProps = __rest(_f, ["slotProps"]);
|
|
582
|
-
var mergedSlotProps = __assign(__assign({}, datePickerSlotProps), { textField: __assign({ fullWidth: true, required: required, color: meta
|
|
641
|
+
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) });
|
|
583
642
|
return (jsx(FieldWrapper, { icon: icon, showSpace: showSpace, children: jsx(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) {
|
|
584
643
|
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());
|
|
585
644
|
}, slotProps: mergedSlotProps }, remainingDatePickerProps)) }));
|
|
@@ -591,7 +650,7 @@ var DateTimeFormField = function (_a) {
|
|
|
591
650
|
var _d = useField(name, __assign({ format: format, validate: required
|
|
592
651
|
? 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;
|
|
593
652
|
var _e = ((_b = slotProps === null || slotProps === void 0 ? void 0 : slotProps.dateTimePicker) !== null && _b !== void 0 ? _b : {}), dateTimePickerSlotProps = _e.slotProps, remainingDateTimePickerProps = __rest(_e, ["slotProps"]);
|
|
594
|
-
var mergedSlotProps = __assign(__assign({}, dateTimePickerSlotProps), { textField: __assign({ fullWidth: true, required: required, color: meta
|
|
653
|
+
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) });
|
|
595
654
|
return (jsx(FieldWrapper, { icon: icon, showSpace: showSpace, children: jsx(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)) }));
|
|
596
655
|
};
|
|
597
656
|
|
|
@@ -603,15 +662,16 @@ var RadioOption = function (props) {
|
|
|
603
662
|
|
|
604
663
|
var RadioFormField = function (_a) {
|
|
605
664
|
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;
|
|
606
|
-
var
|
|
607
|
-
? 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
|
|
665
|
+
var meta = useField(name, __assign({ validate: required
|
|
666
|
+
? 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 error = getFieldError(meta);
|
|
608
668
|
return (jsx(FieldWrapper, { icon: icon, showSpace: showSpace, children: jsxs(FormControl, { required: required, children: [label && (jsx(FormLabel, { id: "".concat(name, "-radio-buttons-group-label"), disabled: disabled, children: label })), jsx(RadioGroup, { "aria-labelledby": "".concat(name, "-radio-buttons-group-label"), row: !vertical, children: options.map(function (o) {
|
|
609
669
|
var _a;
|
|
610
670
|
return (jsx(FormControlLabel, { label: typeof o === "string" ? o : ((_a = o.text) !== null && _a !== void 0 ? _a : o.value), disabled: disabled, control: jsx(Field, __assign({ name: name, value: typeof o === "string" ? o : o.value, type: "radio", render: function (_a) {
|
|
611
671
|
var input = _a.input, meta = _a.meta;
|
|
612
672
|
return (jsx(RadioOption, { input: input, meta: meta, disabled: disabled, required: required, radioProps: slotProps === null || slotProps === void 0 ? void 0 : slotProps.radio }));
|
|
613
673
|
} }, slotProps === null || slotProps === void 0 ? void 0 : slotProps.radioField)) }, typeof o === "string" ? o : o.value));
|
|
614
|
-
}) }), (
|
|
674
|
+
}) }), (error || helperText) && (jsx(FormHelperText, { error: error != null || forceError, sx: { marginTop: 0 }, children: error || helperText }))] }) }));
|
|
615
675
|
};
|
|
616
676
|
|
|
617
677
|
var ErrorMessage = function (_a) {
|
|
@@ -622,20 +682,17 @@ var ErrorMessage = function (_a) {
|
|
|
622
682
|
var ErrorOverlay = function (_a) {
|
|
623
683
|
var _b, _c, _d, _e;
|
|
624
684
|
var children = _a.children, show = _a.show, offset = _a.offset, message = _a.message;
|
|
625
|
-
return (jsxs(Box, { position: "relative", children: [children, jsx(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 ({
|
|
685
|
+
return (jsxs(Box, { position: "relative", children: [children, show && (jsx(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 ({
|
|
626
686
|
bgcolor: alpha(theme.palette.background.paper, 0.6),
|
|
627
|
-
transition: "0.2s",
|
|
628
|
-
opacity: show ? 1 : 0,
|
|
629
687
|
backdropFilter: "blur(7px)",
|
|
630
|
-
pointerEvents: show ? undefined : "none",
|
|
631
688
|
}); }, children: jsx(Box, { borderRadius: 2, p: 1, sx: function (theme) { return ({
|
|
632
689
|
bgcolor: alpha(theme.palette.background.paper, 0.6),
|
|
633
|
-
}); }, children: jsx(ErrorMessage, { message: message }) }) })] }));
|
|
690
|
+
}); }, children: jsx(ErrorMessage, { message: message }) }) }))] }));
|
|
634
691
|
};
|
|
635
692
|
|
|
636
693
|
var ErrorNotification = function (_a) {
|
|
637
694
|
var open = _a.open, message = _a.message, onClose = _a.onClose;
|
|
638
|
-
return (jsx(Snackbar, { open: open, autoHideDuration: 6000, onClose: onClose, children: jsx(Alert, { onClose: onClose, severity: "error", sx: { width: "100%" }, elevation: 6, variant: "filled", children: message
|
|
695
|
+
return (jsx(Snackbar, { open: open, autoHideDuration: 6000, onClose: onClose, children: jsx(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" }) }));
|
|
639
696
|
};
|
|
640
697
|
|
|
641
698
|
var DropIndicator = styled(Box, {
|
|
@@ -4783,7 +4840,7 @@ function FileEditorField(_a) {
|
|
|
4783
4840
|
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;
|
|
4784
4841
|
var _c = useField(name, __assign({ validate: required
|
|
4785
4842
|
? 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;
|
|
4786
|
-
return (jsx(FieldWrapper, { icon: icon, showSpace: showSpace, children: jsxs(FormControl, { fullWidth: true, children: [label && (jsx(FormLabel, { disabled: disabled, error: meta
|
|
4843
|
+
return (jsx(FieldWrapper, { icon: icon, showSpace: showSpace, children: jsxs(FormControl, { fullWidth: true, children: [label && (jsx(FormLabel, { disabled: disabled, error: getFieldError(meta), children: label })), jsx(FileEditor, { value: input.value, onChange: input.onChange, multiple: multiple, disabled: disabled, accept: accept, maxFiles: maxFiles, maxSize: maxSize, minSize: minSize, placeholder: placeholder }), jsx(FormHelperText, { error: getFieldError(meta) || forceError, children: getFieldError(meta) || helperText })] }) }));
|
|
4787
4844
|
}
|
|
4788
4845
|
|
|
4789
4846
|
function asInteger(value) {
|
|
@@ -5064,5 +5121,5 @@ function TabSet(_a) {
|
|
|
5064
5121
|
}) }) }), jsx(Panel, __assign({}, actualTab === null || actualTab === void 0 ? void 0 : actualTab.PanelProps, { children: actualTab === null || actualTab === void 0 ? void 0 : actualTab.content }))] }));
|
|
5065
5122
|
}
|
|
5066
5123
|
|
|
5067
|
-
export { CheckboxFormField, CloseableDialog, ConfirmCancel, DateFormField, DateTimeFormField, EMAIL_REGEX, EditableBlock, ErrorMessage, ErrorNotification, ErrorOverlay, ExtendedPagination, ExtendedTable, FieldWrapper, FileDisplay, FileDropper, FileEditor, FileEditorField, LabeledValue, LoaderButton, MultiSelectFormField, POSTAL_CODE_REGEX, Panel, RadioFormField, SelectFormField, TabSet, TextFormField, asInteger, asPhoneNumber, enableAuthRedirect, isEmail, isPostalCode, sendDelete, sendFormDataPost, sendGet, sendPost, sendPut, useAsyncData, useAsyncDataCallback, useDebounce, useDebounceEffect, useFileEditor, usePartialSetterState };
|
|
5124
|
+
export { CheckboxFormField, CloseableDialog, ConfirmCancel, DateFormField, DateTimeFormField, EMAIL_REGEX, EditableBlock, ErrorMessage, ErrorNotification, ErrorOverlay, ExtendedPagination, ExtendedTable, FieldWrapper, FileDisplay, FileDropper, FileEditor, FileEditorField, HTTPError, LabeledValue, LoaderButton, MultiSelectFormField, POSTAL_CODE_REGEX, Panel, RadioFormField, SelectFormField, TabSet, TextFormField, asInteger, asPhoneNumber, enableAuthRedirect, isEmail, isPostalCode, sendDelete, sendFormDataPost, sendGet, sendPost, sendPut, useAsyncData, useAsyncDataCallback, useDebounce, useDebounceEffect, useFileEditor, usePartialSetterState };
|
|
5068
5125
|
//# sourceMappingURL=index.es.js.map
|