@torq-north/react-tools 1.4.6 → 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 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*/, 3];
233
- exception = void 0;
234
- message = void 0;
235
- if (!isJson(response)) return [3 /*break*/, 2];
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 (isJson(response)) {
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 ? undefined : "This field is required";
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.touched && meta.error, helperText: (meta.touched && meta.error) || helperText, slotProps: mergedSlotProps }, remainingTextFieldProps)) }));
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) {
@@ -482,14 +541,25 @@ function SelectFormField(_a) {
482
541
  var _a;
483
542
  setIsFocused(false);
484
543
  (_a = inputSlotProps === null || inputSlotProps === void 0 ? void 0 : inputSlotProps.onBlur) === null || _a === void 0 ? void 0 : _a.call(inputSlotProps, event);
485
- } }), select: __assign(__assign({}, textFieldSlotProps === null || textFieldSlotProps === void 0 ? void 0 : textFieldSlotProps.select), (hasEndAdornment && {
544
+ } }), select: __assign(__assign(__assign({}, textFieldSlotProps === null || textFieldSlotProps === void 0 ? void 0 : textFieldSlotProps.select), { onClose: function (e) {
545
+ var _a, _b;
546
+ typeof (textFieldSlotProps === null || textFieldSlotProps === void 0 ? void 0 : textFieldSlotProps.select) === "function"
547
+ ? undefined
548
+ : (_b = (_a = textFieldSlotProps === null || textFieldSlotProps === void 0 ? void 0 : textFieldSlotProps.select) === null || _a === void 0 ? void 0 : _a.onClose) === null || _b === void 0 ? void 0 : _b.call(_a, e);
549
+ //When opening a select and then moving the mouse away, the input does not register as
550
+ // being unhovered. We can fudge this by setting the hover state to false when the options
551
+ // menu is closed. If the mouse is still over the input when the menu is closed, the hover state
552
+ // will be set to true automatically by the onMouseEnter event handler (and the focus state is
553
+ // always true the whole time so the clear button won't flicker)
554
+ setIsMousedOver(false);
555
+ } }), (hasEndAdornment && {
486
556
  endAdornment: (jsxRuntime.jsxs(material.Stack, { direction: "row", spacing: 1, pr: 2, children: [isClearable &&
487
557
  (isMousedOver || isFocused) &&
488
558
  value != null &&
489
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] })),
490
560
  })) });
491
561
  var renderedOptions = React.useMemo(function () { return renderSelectOptions(options); }, [options]);
492
- 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.touched && meta.error, helperText: (meta.touched && meta.error) || helperText, value: value ? value : [], onChange: onChange, slotProps: mergedSlotProps }, remainingTextFieldProps, { children: [renderedOptions, !options && jsxRuntime.jsx(material.MenuItem, {})] })) }));
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, {})] })) }));
493
563
  }
494
564
 
495
565
  function findTextFor(value, options) {
@@ -533,12 +603,23 @@ function MultiSelectFormField(_a) {
533
603
  var _a;
534
604
  setIsFocused(false);
535
605
  (_a = inputSlotProps === null || inputSlotProps === void 0 ? void 0 : inputSlotProps.onBlur) === null || _a === void 0 ? void 0 : _a.call(inputSlotProps, event);
536
- } }), select: __assign(__assign({}, textFieldSlotProps === null || textFieldSlotProps === void 0 ? void 0 : textFieldSlotProps.select), { endAdornment: (jsxRuntime.jsxs(material.Stack, { direction: "row", spacing: 1, pr: 2, children: [isClearable && (isMousedOver || isFocused) && (value === null || value === void 0 ? void 0 : value.length) > 0 && (jsxRuntime.jsx(material.IconButton, { size: "small", onClick: function () { return onChange([]); }, tabIndex: -1, children: jsxRuntime.jsx(CloseIcon, { fontSize: "small" }) })), inputSlotProps === null || inputSlotProps === void 0 ? void 0 : inputSlotProps.endAdornment] })), multiple: true, renderValue: function (selected) { return (jsxRuntime.jsx(material.Stack, { direction: "row", spacing: 1, flexWrap: "wrap", children: selected.map(function (s, index) {
606
+ } }), select: __assign(__assign({}, textFieldSlotProps === null || textFieldSlotProps === void 0 ? void 0 : textFieldSlotProps.select), { onClose: function (e) {
607
+ var _a, _b;
608
+ typeof (textFieldSlotProps === null || textFieldSlotProps === void 0 ? void 0 : textFieldSlotProps.select) === "function"
609
+ ? undefined
610
+ : (_b = (_a = textFieldSlotProps === null || textFieldSlotProps === void 0 ? void 0 : textFieldSlotProps.select) === null || _a === void 0 ? void 0 : _a.onClose) === null || _b === void 0 ? void 0 : _b.call(_a, e);
611
+ //When opening a select and then moving the mouse away, the input does not register as
612
+ // being unhovered. We can fudge this by setting the hover state to false when the options
613
+ // menu is closed. If the mouse is still over the input when the menu is closed, the hover state
614
+ // will be set to true automatically by the onMouseEnter event handler (and the focus state is
615
+ // always true the whole time so the clear button won't flicker)
616
+ setIsMousedOver(false);
617
+ }, endAdornment: (jsxRuntime.jsxs(material.Stack, { direction: "row", spacing: 1, pr: 2, children: [isClearable && (isMousedOver || isFocused) && (value === null || value === void 0 ? void 0 : value.length) > 0 && (jsxRuntime.jsx(material.IconButton, { size: "small", onClick: function () { return onChange([]); }, tabIndex: -1, children: jsxRuntime.jsx(CloseIcon, { fontSize: "small" }) })), inputSlotProps === null || inputSlotProps === void 0 ? void 0 : inputSlotProps.endAdornment] })), multiple: true, renderValue: function (selected) { return (jsxRuntime.jsx(material.Stack, { direction: "row", spacing: 1, flexWrap: "wrap", children: selected.map(function (s, index) {
537
618
  var _a;
538
619
  return (jsxRuntime.jsxs(React.Fragment, { children: [index > 0 && ", ", (_a = findTextFor(s, options)) !== null && _a !== void 0 ? _a : "Unknown"] }, s));
539
620
  }) })); } }) });
540
621
  var renderedOptions = React.useMemo(function () { return renderCheckboxSelectOptions(options, value); }, [options, value]);
541
- 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.touched && meta.error, helperText: (meta.touched && meta.error) || helperText, value: value ? value : [], onChange: onChange, slotProps: mergedSlotProps }, remainingTextFieldProps, { children: [renderedOptions, !options && jsxRuntime.jsx(material.MenuItem, {})] })) }));
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, {})] })) }));
542
623
  }
543
624
 
544
625
  var mustBeChecked = function (v) {
@@ -550,7 +631,7 @@ var CheckboxFormField = function (_a) {
550
631
  var _c = reactFinalForm.useField(name, __assign({ type: "checkbox", validate: mustBeTrue
551
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;
552
633
  var checkboxProps = __assign(__assign(__assign({}, input), { disabled: disabled }), slotProps === null || slotProps === void 0 ? void 0 : slotProps.checkbox);
553
- 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.touched && meta.error) || helperText) && (jsxRuntime.jsx(material.FormHelperText, { disabled: disabled, error: (meta.touched && meta.error) || forceError, sx: { marginTop: 0, marginLeft: 2 }, children: meta.error || helperText }))] }));
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 }))] }));
554
635
  };
555
636
 
556
637
  var DateFormField = function (_a) {
@@ -559,7 +640,7 @@ var DateFormField = function (_a) {
559
640
  var _e = reactFinalForm.useField(name, __assign({ format: format, validate: required
560
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;
561
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"]);
562
- var mergedSlotProps = __assign(__assign({}, datePickerSlotProps), { textField: __assign({ fullWidth: true, required: required, color: meta.touched && meta.error ? "error" : undefined, error: meta.touched && meta.error, helperText: (meta.touched && meta.error) || helperText, onFocus: input.onFocus, onBlur: input.onBlur }, datePickerSlotProps === null || datePickerSlotProps === void 0 ? void 0 : datePickerSlotProps.textField) });
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) });
563
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) {
564
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());
565
646
  }, slotProps: mergedSlotProps }, remainingDatePickerProps)) }));
@@ -571,7 +652,7 @@ var DateTimeFormField = function (_a) {
571
652
  var _d = reactFinalForm.useField(name, __assign({ format: format, validate: required
572
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;
573
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"]);
574
- var mergedSlotProps = __assign(__assign({}, dateTimePickerSlotProps), { textField: __assign({ fullWidth: true, required: required, color: meta.touched && meta.error ? "error" : undefined, error: meta.touched && meta.error, helperText: (meta.touched && meta.error) || helperText, onFocus: input.onFocus, onBlur: input.onBlur }, dateTimePickerSlotProps === null || dateTimePickerSlotProps === void 0 ? void 0 : dateTimePickerSlotProps.textField) });
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) });
575
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)) }));
576
657
  };
577
658
 
@@ -583,15 +664,16 @@ var RadioOption = function (props) {
583
664
 
584
665
  var RadioFormField = function (_a) {
585
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;
586
- var _c = reactFinalForm.useField(name, __assign({ validate: required
587
- ? 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, error = _c.error, visited = _c.visited;
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);
588
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) {
589
671
  var _a;
590
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) {
591
673
  var input = _a.input, meta = _a.meta;
592
674
  return (jsxRuntime.jsx(RadioOption, { input: input, meta: meta, disabled: disabled, required: required, radioProps: slotProps === null || slotProps === void 0 ? void 0 : slotProps.radio }));
593
675
  } }, slotProps === null || slotProps === void 0 ? void 0 : slotProps.radioField)) }, typeof o === "string" ? o : o.value));
594
- }) }), (((visited || disabled) && error) || helperText) && (jsxRuntime.jsx(material.FormHelperText, { error: error != null || forceError, sx: { marginTop: 0 }, children: error || helperText }))] }) }));
676
+ }) }), (error || helperText) && (jsxRuntime.jsx(material.FormHelperText, { error: error != null || forceError, sx: { marginTop: 0 }, children: error || helperText }))] }) }));
595
677
  };
596
678
 
597
679
  var ErrorMessage = function (_a) {
@@ -602,20 +684,17 @@ var ErrorMessage = function (_a) {
602
684
  var ErrorOverlay = function (_a) {
603
685
  var _b, _c, _d, _e;
604
686
  var children = _a.children, show = _a.show, offset = _a.offset, message = _a.message;
605
- 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 ({
606
688
  bgcolor: material.alpha(theme.palette.background.paper, 0.6),
607
- transition: "0.2s",
608
- opacity: show ? 1 : 0,
609
689
  backdropFilter: "blur(7px)",
610
- pointerEvents: show ? undefined : "none",
611
690
  }); }, children: jsxRuntime.jsx(material.Box, { borderRadius: 2, p: 1, sx: function (theme) { return ({
612
691
  bgcolor: material.alpha(theme.palette.background.paper, 0.6),
613
- }); }, children: jsxRuntime.jsx(ErrorMessage, { message: message }) }) })] }));
692
+ }); }, children: jsxRuntime.jsx(ErrorMessage, { message: message }) }) }))] }));
614
693
  };
615
694
 
616
695
  var ErrorNotification = function (_a) {
617
696
  var open = _a.open, message = _a.message, onClose = _a.onClose;
618
- 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 ? message : "An error has occured" }) }));
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" }) }));
619
698
  };
620
699
 
621
700
  var DropIndicator = material.styled(material.Box, {
@@ -4763,7 +4842,7 @@ function FileEditorField(_a) {
4763
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;
4764
4843
  var _c = reactFinalForm.useField(name, __assign({ validate: required
4765
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;
4766
- 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.touched && meta.error, 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: (meta.touched && meta.error) || forceError, children: (meta.touched && meta.error) || helperText })] }) }));
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 })] }) }));
4767
4846
  }
4768
4847
 
4769
4848
  function asInteger(value) {
@@ -5061,6 +5140,7 @@ exports.FileDisplay = FileDisplay;
5061
5140
  exports.FileDropper = FileDropper;
5062
5141
  exports.FileEditor = FileEditor;
5063
5142
  exports.FileEditorField = FileEditorField;
5143
+ exports.HTTPError = HTTPError;
5064
5144
  exports.LabeledValue = LabeledValue;
5065
5145
  exports.LoaderButton = LoaderButton;
5066
5146
  exports.MultiSelectFormField = MultiSelectFormField;