@torq-north/react-tools 1.1.1 → 1.2.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/dist/index.cjs +35 -35
- package/dist/index.es.js +35 -35
- package/dist/src/Form/Components/CheckboxFormField.d.ts +1 -0
- package/dist/src/Form/Components/ComboboxFormField.d.ts +4 -1
- package/dist/src/Form/Components/FileEditorField/FileEditorField.d.ts +2 -1
- package/dist/src/Form/Components/RadioFormField.d.ts +1 -0
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -560,9 +560,9 @@ var isRequired = function (value) {
|
|
|
560
560
|
function TextFormField(_a) {
|
|
561
561
|
var _b;
|
|
562
562
|
var name = _a.name, label = _a.label, required = _a.required, multiline = _a.multiline, disabled = _a.disabled, placeholder = _a.placeholder, slotProps = _a.slotProps, helperText = _a.helperText, icon = _a.icon, showSpace = _a.showSpace, format = _a.format, _c = _a.validators, validators = _c === void 0 ? [] : _c;
|
|
563
|
-
var _d = reactFinalForm.useField(name, __assign(
|
|
564
|
-
? composeValidators.apply(void 0, __spreadArray(__spreadArray([], validators, false), [isRequired], false)) : composeValidators.apply(void 0, validators) })), input = _d.input, meta = _d.meta;
|
|
565
|
-
var textFieldProps = deepmerge(
|
|
563
|
+
var _d = reactFinalForm.useField(name, __assign({ format: format, validate: required
|
|
564
|
+
? 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;
|
|
565
|
+
var textFieldProps = deepmerge({
|
|
566
566
|
fullWidth: true,
|
|
567
567
|
label: label,
|
|
568
568
|
required: required,
|
|
@@ -572,7 +572,7 @@ function TextFormField(_a) {
|
|
|
572
572
|
error: meta.touched && meta.error,
|
|
573
573
|
helperText: (meta.touched && meta.error) || helperText,
|
|
574
574
|
slotProps: { input: input },
|
|
575
|
-
});
|
|
575
|
+
}, (_b = slotProps === null || slotProps === void 0 ? void 0 : slotProps.textField) !== null && _b !== void 0 ? _b : {});
|
|
576
576
|
return (jsxRuntime.jsx(FieldWrapper, { icon: icon, showSpace: showSpace, children: jsxRuntime.jsx(material.TextField, __assign({}, textFieldProps)) }));
|
|
577
577
|
}
|
|
578
578
|
|
|
@@ -618,9 +618,9 @@ function render(option, showCheckbox, isSelected) {
|
|
|
618
618
|
function SelectFormField(_a) {
|
|
619
619
|
var _b, _c;
|
|
620
620
|
var name = _a.name, label = _a.label, required = _a.required, disabled = _a.disabled, helperText = _a.helperText, slotProps = _a.slotProps, isClearable = _a.isClearable, options = _a.options, icon = _a.icon, showSpace = _a.showSpace, format = _a.format, _d = _a.validators, validators = _d === void 0 ? [] : _d;
|
|
621
|
-
var _e = reactFinalForm.useField(name, __assign(
|
|
622
|
-
? composeValidators.apply(void 0, __spreadArray(__spreadArray([], validators, false), [isRequired], false)) : composeValidators.apply(void 0, validators) })), _f = _e.input, value = _f.value, onChange = _f.onChange, otherInputProps = __rest(_f, ["value", "onChange"]), meta = _e.meta;
|
|
623
|
-
var textFieldProps = deepmerge(
|
|
621
|
+
var _e = reactFinalForm.useField(name, __assign({ format: format, validate: required
|
|
622
|
+
? composeValidators.apply(void 0, __spreadArray(__spreadArray([], validators, false), [isRequired], false)) : composeValidators.apply(void 0, validators) }, slotProps === null || slotProps === void 0 ? void 0 : slotProps.field)), _f = _e.input, value = _f.value, onChange = _f.onChange, otherInputProps = __rest(_f, ["value", "onChange"]), meta = _e.meta;
|
|
623
|
+
var textFieldProps = deepmerge({
|
|
624
624
|
fullWidth: true,
|
|
625
625
|
select: true,
|
|
626
626
|
label: label,
|
|
@@ -633,10 +633,10 @@ function SelectFormField(_a) {
|
|
|
633
633
|
slotProps: {
|
|
634
634
|
input: otherInputProps,
|
|
635
635
|
select: {
|
|
636
|
-
endAdornment: isClearable ? (jsxRuntime.jsx(material.Box, { pr: 2, children: jsxRuntime.jsx(material.IconButton, { size: (
|
|
636
|
+
endAdornment: isClearable ? (jsxRuntime.jsx(material.Box, { pr: 2, children: jsxRuntime.jsx(material.IconButton, { size: (_b = slotProps === null || slotProps === void 0 ? void 0 : slotProps.textField) === null || _b === void 0 ? void 0 : _b.size, onClick: function () { return onChange(undefined); }, children: jsxRuntime.jsx(CloseIcon, { fontSize: "inherit" }) }) })) : undefined,
|
|
637
637
|
},
|
|
638
638
|
},
|
|
639
|
-
});
|
|
639
|
+
}, (_c = slotProps === null || slotProps === void 0 ? void 0 : slotProps.textField) !== null && _c !== void 0 ? _c : {});
|
|
640
640
|
var renderedOptions = React.useMemo(function () { return renderSelectOptions(options); }, [options]);
|
|
641
641
|
return (jsxRuntime.jsx(FieldWrapper, { icon: icon, showSpace: showSpace, children: jsxRuntime.jsxs(material.TextField, __assign({}, textFieldProps, { children: [renderedOptions, !options && jsxRuntime.jsx(material.MenuItem, {})] })) }));
|
|
642
642
|
}
|
|
@@ -663,9 +663,9 @@ function findTextFor(value, options) {
|
|
|
663
663
|
function MultiSelectFormField(_a) {
|
|
664
664
|
var _b, _c;
|
|
665
665
|
var name = _a.name, label = _a.label, required = _a.required, disabled = _a.disabled, helperText = _a.helperText, slotProps = _a.slotProps, isClearable = _a.isClearable, options = _a.options, icon = _a.icon, showSpace = _a.showSpace, format = _a.format, _d = _a.validators, validators = _d === void 0 ? [] : _d;
|
|
666
|
-
var _e = reactFinalForm.useField(name, __assign(
|
|
667
|
-
? composeValidators.apply(void 0, __spreadArray(__spreadArray([], validators, false), [isRequired], false)) : composeValidators.apply(void 0, validators) })), _f = _e.input, value = _f.value, onChange = _f.onChange, otherInputProps = __rest(_f, ["value", "onChange"]), meta = _e.meta;
|
|
668
|
-
var textFieldProps = deepmerge(
|
|
666
|
+
var _e = reactFinalForm.useField(name, __assign({ format: format, validate: required
|
|
667
|
+
? composeValidators.apply(void 0, __spreadArray(__spreadArray([], validators, false), [isRequired], false)) : composeValidators.apply(void 0, validators) }, slotProps === null || slotProps === void 0 ? void 0 : slotProps.field)), _f = _e.input, value = _f.value, onChange = _f.onChange, otherInputProps = __rest(_f, ["value", "onChange"]), meta = _e.meta;
|
|
668
|
+
var textFieldProps = deepmerge({
|
|
669
669
|
fullWidth: true,
|
|
670
670
|
select: true,
|
|
671
671
|
label: label,
|
|
@@ -678,12 +678,12 @@ function MultiSelectFormField(_a) {
|
|
|
678
678
|
slotProps: {
|
|
679
679
|
input: otherInputProps,
|
|
680
680
|
select: {
|
|
681
|
-
endAdornment: isClearable ? (jsxRuntime.jsx(material.Box, { pr: 2, children: jsxRuntime.jsx(material.IconButton, { size: (
|
|
681
|
+
endAdornment: isClearable ? (jsxRuntime.jsx(material.Box, { pr: 2, children: jsxRuntime.jsx(material.IconButton, { size: (_b = slotProps === null || slotProps === void 0 ? void 0 : slotProps.textField) === null || _b === void 0 ? void 0 : _b.size, onClick: function () { return onChange([]); }, children: jsxRuntime.jsx(CloseIcon, { fontSize: "inherit" }) }) })) : undefined,
|
|
682
682
|
multiple: true,
|
|
683
683
|
renderValue: function (selected) { return (jsxRuntime.jsx(material.Box, { whiteSpace: "normal", children: selected.map(function (s) { return findTextFor(s, options); }).join(", ") })); },
|
|
684
684
|
},
|
|
685
685
|
},
|
|
686
|
-
});
|
|
686
|
+
}, (_c = slotProps === null || slotProps === void 0 ? void 0 : slotProps.textField) !== null && _c !== void 0 ? _c : {});
|
|
687
687
|
var renderedOptions = React.useMemo(function () { return renderCheckboxSelectOptions(options, value); }, [options, value]);
|
|
688
688
|
return (jsxRuntime.jsx(FieldWrapper, { icon: icon, showSpace: showSpace, children: jsxRuntime.jsxs(material.TextField, __assign({}, textFieldProps, { children: [renderedOptions, !options && jsxRuntime.jsx(material.MenuItem, {})] })) }));
|
|
689
689
|
}
|
|
@@ -694,19 +694,19 @@ var mustBeChecked = function (v) {
|
|
|
694
694
|
|
|
695
695
|
var CheckboxFormField = function (_a) {
|
|
696
696
|
var _b;
|
|
697
|
-
var name = _a.name, label = _a.label, mustBeTrue = _a.mustBeTrue, disabled = _a.disabled, helperText = _a.helperText, slotProps = _a.slotProps, icon = _a.icon, showSpace = _a.showSpace, _c = _a.validators, validators = _c === void 0 ? [] : _c;
|
|
697
|
+
var name = _a.name, label = _a.label, mustBeTrue = _a.mustBeTrue, disabled = _a.disabled, helperText = _a.helperText, slotProps = _a.slotProps, icon = _a.icon, showSpace = _a.showSpace, _c = _a.validators, validators = _c === void 0 ? [] : _c, forceError = _a.forceError;
|
|
698
698
|
var _d = reactFinalForm.useField(name, __assign({ type: "checkbox", validate: mustBeTrue
|
|
699
699
|
? 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 = _d.input, meta = _d.meta;
|
|
700
|
-
var checkboxProps = deepmerge((_b = slotProps === null || slotProps === void 0 ? void 0 : slotProps.checkbox) !== null && _b !== void 0 ? _b : {}
|
|
701
|
-
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, sx: { marginTop: 0, marginLeft: 2 }, children: meta.error || helperText }))] }));
|
|
700
|
+
var checkboxProps = deepmerge(__assign(__assign({}, input), { disabled: disabled }), (_b = slotProps === null || slotProps === void 0 ? void 0 : slotProps.checkbox) !== null && _b !== void 0 ? _b : {});
|
|
701
|
+
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 }))] }));
|
|
702
702
|
};
|
|
703
703
|
|
|
704
704
|
var DateFormField = function (_a) {
|
|
705
705
|
var _b;
|
|
706
706
|
var name = _a.name, label = _a.label, required = _a.required, icon = _a.icon, showSpace = _a.showSpace, slotProps = _a.slotProps, disabled = _a.disabled, helperText = _a.helperText, format = _a.format, _c = _a.validators, validators = _c === void 0 ? [] : _c;
|
|
707
|
-
var _d = reactFinalForm.useField(name, __assign(
|
|
708
|
-
? composeValidators.apply(void 0, __spreadArray(__spreadArray([], validators, false), [isRequired], false)) : composeValidators.apply(void 0, validators) })), input = _d.input, meta = _d.meta;
|
|
709
|
-
var datePickerProps = deepmerge(
|
|
707
|
+
var _d = reactFinalForm.useField(name, __assign({ format: format, validate: required
|
|
708
|
+
? 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;
|
|
709
|
+
var datePickerProps = deepmerge({
|
|
710
710
|
label: label,
|
|
711
711
|
disabled: disabled,
|
|
712
712
|
views: ["year", "month", "day"],
|
|
@@ -721,16 +721,16 @@ var DateFormField = function (_a) {
|
|
|
721
721
|
onBlur: input.onBlur,
|
|
722
722
|
},
|
|
723
723
|
},
|
|
724
|
-
});
|
|
724
|
+
}, (_b = slotProps === null || slotProps === void 0 ? void 0 : slotProps.datePicker) !== null && _b !== void 0 ? _b : {});
|
|
725
725
|
return (jsxRuntime.jsx(FieldWrapper, { icon: icon, showSpace: showSpace, children: jsxRuntime.jsx(xDatePickers.DatePicker, __assign({ value: input.value ? dayjs(input.value) : null, onChange: function (value) { return input.onChange(value === null || value === void 0 ? void 0 : value.toJSON()); } }, datePickerProps)) }));
|
|
726
726
|
};
|
|
727
727
|
|
|
728
728
|
var DateTimeFormField = function (_a) {
|
|
729
729
|
var _b;
|
|
730
730
|
var name = _a.name, label = _a.label, required = _a.required, icon = _a.icon, showSpace = _a.showSpace, slotProps = _a.slotProps, disabled = _a.disabled, helperText = _a.helperText, format = _a.format, _c = _a.validators, validators = _c === void 0 ? [] : _c;
|
|
731
|
-
var _d = reactFinalForm.useField(name, __assign(
|
|
732
|
-
? composeValidators.apply(void 0, __spreadArray(__spreadArray([], validators, false), [isRequired], false)) : composeValidators.apply(void 0, validators) })), input = _d.input, meta = _d.meta;
|
|
733
|
-
var dateTimeProps = deepmerge(
|
|
731
|
+
var _d = reactFinalForm.useField(name, __assign({ format: format, validate: required
|
|
732
|
+
? 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;
|
|
733
|
+
var dateTimeProps = deepmerge({
|
|
734
734
|
label: label,
|
|
735
735
|
disabled: disabled,
|
|
736
736
|
views: ["year", "month", "day"],
|
|
@@ -745,7 +745,7 @@ var DateTimeFormField = function (_a) {
|
|
|
745
745
|
onBlur: input.onBlur,
|
|
746
746
|
},
|
|
747
747
|
},
|
|
748
|
-
});
|
|
748
|
+
}, (_b = slotProps === null || slotProps === void 0 ? void 0 : slotProps.dateTimePicker) !== null && _b !== void 0 ? _b : {});
|
|
749
749
|
return (jsxRuntime.jsx(FieldWrapper, { icon: icon, showSpace: showSpace, children: jsxRuntime.jsx(xDatePickers.DateTimePicker, __assign({ value: input.value ? dayjs(input.value) : null, onChange: function (value) { return input.onChange(value === null || value === void 0 ? void 0 : value.toJSON()); } }, dateTimeProps)) }));
|
|
750
750
|
};
|
|
751
751
|
|
|
@@ -756,16 +756,16 @@ var RadioOption = function (props) {
|
|
|
756
756
|
};
|
|
757
757
|
|
|
758
758
|
var RadioFormField = function (_a) {
|
|
759
|
-
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, _b = _a.validators, validators = _b === void 0 ? [] : _b;
|
|
760
|
-
var _c = reactFinalForm.useField(name, __assign(
|
|
761
|
-
? composeValidators.apply(void 0, __spreadArray(__spreadArray([], validators, false), [isRequired], false)) : composeValidators.apply(void 0, validators) })).meta, error = _c.error, visited = _c.visited;
|
|
759
|
+
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;
|
|
760
|
+
var _c = reactFinalForm.useField(name, __assign({ validate: required
|
|
761
|
+
? 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;
|
|
762
762
|
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) {
|
|
763
763
|
var _a, _b;
|
|
764
|
-
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"
|
|
764
|
+
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) {
|
|
765
765
|
var input = _a.input, meta = _a.meta;
|
|
766
766
|
return (jsxRuntime.jsx(RadioOption, { input: input, meta: meta, disabled: disabled, required: required, radioProps: slotProps === null || slotProps === void 0 ? void 0 : slotProps.radio }));
|
|
767
|
-
} })) }, typeof o === "string" ? o : ((_b = o.text) !== null && _b !== void 0 ? _b : o.value)));
|
|
768
|
-
}) }), (((visited || disabled) && error) || helperText) && (jsxRuntime.jsx(material.FormHelperText, { error: error != null, sx: { marginTop: 0 }, children: error || helperText }))] }) }));
|
|
767
|
+
} }, slotProps === null || slotProps === void 0 ? void 0 : slotProps.radioField)) }, typeof o === "string" ? o : ((_b = o.text) !== null && _b !== void 0 ? _b : o.value)));
|
|
768
|
+
}) }), (((visited || disabled) && error) || helperText) && (jsxRuntime.jsx(material.FormHelperText, { error: error != null || forceError, sx: { marginTop: 0 }, children: error || helperText }))] }) }));
|
|
769
769
|
};
|
|
770
770
|
|
|
771
771
|
var ErrorMessage = function (_a) {
|
|
@@ -4798,9 +4798,9 @@ function arrayify(value) {
|
|
|
4798
4798
|
return Array.isArray(value) ? value : [value];
|
|
4799
4799
|
}
|
|
4800
4800
|
function useFileEditorField(name, options) {
|
|
4801
|
-
var _a = reactFinalForm.useField(name, __assign(
|
|
4801
|
+
var _a = reactFinalForm.useField(name, __assign({ validate: function (v) {
|
|
4802
4802
|
return options.required && v == null ? "This field is required" : undefined;
|
|
4803
|
-
} })), input = _a.input, meta = _a.meta;
|
|
4803
|
+
} }, options.fieldProps)), input = _a.input, meta = _a.meta;
|
|
4804
4804
|
var values = React.useMemo(function () { return arrayify(input.value); }, [input.value]);
|
|
4805
4805
|
var _b = React.useState(false), showError = _b[0], setShowError = _b[1];
|
|
4806
4806
|
var _c = React.useState(""), errorMessage = _c[0], setErrorMessage = _c[1];
|
|
@@ -4915,7 +4915,7 @@ function FileDisplay(_a) {
|
|
|
4915
4915
|
}
|
|
4916
4916
|
|
|
4917
4917
|
function FileEditorField(_a) {
|
|
4918
|
-
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;
|
|
4918
|
+
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, forceError = _a.forceError;
|
|
4919
4919
|
var _b = useFileEditorField(name, {
|
|
4920
4920
|
multiple: multiple,
|
|
4921
4921
|
accept: accept,
|
|
@@ -4923,7 +4923,7 @@ function FileEditorField(_a) {
|
|
|
4923
4923
|
required: required,
|
|
4924
4924
|
fieldProps: slotProps === null || slotProps === void 0 ? void 0 : slotProps.field,
|
|
4925
4925
|
}), getInputProps = _b.getInputProps, getRootProps = _b.getRootProps, dragOverDropzone = _b.dragOverDropzone, values = _b.values, removeFile = _b.removeFile, open = _b.open, showError = _b.showError, setShowError = _b.setShowError, errorMessage = _b.errorMessage, meta = _b.meta;
|
|
4926
|
-
return (jsxRuntime.jsxs(FieldWrapper, { icon: icon, showSpace: showSpace, children: [jsxRuntime.jsxs(material.FormControl, { fullWidth: true, sx: { position: "relative" }, children: [label && (jsxRuntime.jsx(material.FormLabel, { disabled: disabled, error: meta.touched && meta.error, children: label })), jsxRuntime.jsx("input", __assign({}, getInputProps())), jsxRuntime.jsx(DropIndicator, __assign({ multiple: multiple, dragOver: dragOverDropzone, disabled: disabled }, getRootProps(), { children: jsxRuntime.jsxs(material.Stack, { gap: 1, children: [values.length > 0 && (jsxRuntime.jsx(material.Box, { sx: { opacity: disabled ? 0.4 : 1 }, children: jsxRuntime.jsx(FileDisplay, { files: values !== null && values !== void 0 ? values : [], disableLink: true, allowDelete: !disabled, onDelete: removeFile }) })), (multiple || (values === null || values === void 0 ? void 0 : values.length) == 0) && (jsxRuntime.jsx(material.Button, { onClick: open, startIcon: jsxRuntime.jsx(AddIcon, {}), fullWidth: true, disabled: disabled, children: placeholder !== null && placeholder !== void 0 ? placeholder : "Add File".concat(multiple ? "s" : "") }))] }) })), dragOverDropzone && (jsxRuntime.jsx(material.Stack, { position: "absolute", top: 0, bottom: 0, left: 0, right: 0, justifyContent: "center", alignItems: "center", sx: { pointerEvents: "none" }, children: jsxRuntime.jsx(NoteAddIcon, { sx: { fontSize: 50 } }) })), jsxRuntime.jsx(material.FormHelperText, { error: meta.touched && meta.error, children: (meta.touched && meta.error) || helperText })] }), jsxRuntime.jsx(ErrorNotification, { open: showError, onClose: function () { return setShowError(false); }, message: errorMessage })] }));
|
|
4926
|
+
return (jsxRuntime.jsxs(FieldWrapper, { icon: icon, showSpace: showSpace, children: [jsxRuntime.jsxs(material.FormControl, { fullWidth: true, sx: { position: "relative" }, children: [label && (jsxRuntime.jsx(material.FormLabel, { disabled: disabled, error: meta.touched && meta.error, children: label })), jsxRuntime.jsx("input", __assign({}, getInputProps())), jsxRuntime.jsx(DropIndicator, __assign({ multiple: multiple, dragOver: dragOverDropzone, disabled: disabled }, getRootProps(), { children: jsxRuntime.jsxs(material.Stack, { gap: 1, children: [values.length > 0 && (jsxRuntime.jsx(material.Box, { sx: { opacity: disabled ? 0.4 : 1 }, children: jsxRuntime.jsx(FileDisplay, { files: values !== null && values !== void 0 ? values : [], disableLink: true, allowDelete: !disabled, onDelete: removeFile }) })), (multiple || (values === null || values === void 0 ? void 0 : values.length) == 0) && (jsxRuntime.jsx(material.Button, { onClick: open, startIcon: jsxRuntime.jsx(AddIcon, {}), fullWidth: true, disabled: disabled, children: placeholder !== null && placeholder !== void 0 ? placeholder : "Add File".concat(multiple ? "s" : "") }))] }) })), dragOverDropzone && (jsxRuntime.jsx(material.Stack, { position: "absolute", top: 0, bottom: 0, left: 0, right: 0, justifyContent: "center", alignItems: "center", sx: { pointerEvents: "none" }, children: jsxRuntime.jsx(NoteAddIcon, { sx: { fontSize: 50 } }) })), jsxRuntime.jsx(material.FormHelperText, { error: (meta.touched && meta.error) || forceError, children: (meta.touched && meta.error) || helperText })] }), jsxRuntime.jsx(ErrorNotification, { open: showError, onClose: function () { return setShowError(false); }, message: errorMessage })] }));
|
|
4927
4927
|
}
|
|
4928
4928
|
|
|
4929
4929
|
function asInteger(value) {
|
package/dist/index.es.js
CHANGED
|
@@ -558,9 +558,9 @@ var isRequired = function (value) {
|
|
|
558
558
|
function TextFormField(_a) {
|
|
559
559
|
var _b;
|
|
560
560
|
var name = _a.name, label = _a.label, required = _a.required, multiline = _a.multiline, disabled = _a.disabled, placeholder = _a.placeholder, slotProps = _a.slotProps, helperText = _a.helperText, icon = _a.icon, showSpace = _a.showSpace, format = _a.format, _c = _a.validators, validators = _c === void 0 ? [] : _c;
|
|
561
|
-
var _d = useField(name, __assign(
|
|
562
|
-
? composeValidators.apply(void 0, __spreadArray(__spreadArray([], validators, false), [isRequired], false)) : composeValidators.apply(void 0, validators) })), input = _d.input, meta = _d.meta;
|
|
563
|
-
var textFieldProps = deepmerge(
|
|
561
|
+
var _d = useField(name, __assign({ format: format, validate: required
|
|
562
|
+
? 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;
|
|
563
|
+
var textFieldProps = deepmerge({
|
|
564
564
|
fullWidth: true,
|
|
565
565
|
label: label,
|
|
566
566
|
required: required,
|
|
@@ -570,7 +570,7 @@ function TextFormField(_a) {
|
|
|
570
570
|
error: meta.touched && meta.error,
|
|
571
571
|
helperText: (meta.touched && meta.error) || helperText,
|
|
572
572
|
slotProps: { input: input },
|
|
573
|
-
});
|
|
573
|
+
}, (_b = slotProps === null || slotProps === void 0 ? void 0 : slotProps.textField) !== null && _b !== void 0 ? _b : {});
|
|
574
574
|
return (jsx(FieldWrapper, { icon: icon, showSpace: showSpace, children: jsx(TextField, __assign({}, textFieldProps)) }));
|
|
575
575
|
}
|
|
576
576
|
|
|
@@ -616,9 +616,9 @@ function render(option, showCheckbox, isSelected) {
|
|
|
616
616
|
function SelectFormField(_a) {
|
|
617
617
|
var _b, _c;
|
|
618
618
|
var name = _a.name, label = _a.label, required = _a.required, disabled = _a.disabled, helperText = _a.helperText, slotProps = _a.slotProps, isClearable = _a.isClearable, options = _a.options, icon = _a.icon, showSpace = _a.showSpace, format = _a.format, _d = _a.validators, validators = _d === void 0 ? [] : _d;
|
|
619
|
-
var _e = useField(name, __assign(
|
|
620
|
-
? composeValidators.apply(void 0, __spreadArray(__spreadArray([], validators, false), [isRequired], false)) : composeValidators.apply(void 0, validators) })), _f = _e.input, value = _f.value, onChange = _f.onChange, otherInputProps = __rest(_f, ["value", "onChange"]), meta = _e.meta;
|
|
621
|
-
var textFieldProps = deepmerge(
|
|
619
|
+
var _e = useField(name, __assign({ format: format, validate: required
|
|
620
|
+
? composeValidators.apply(void 0, __spreadArray(__spreadArray([], validators, false), [isRequired], false)) : composeValidators.apply(void 0, validators) }, slotProps === null || slotProps === void 0 ? void 0 : slotProps.field)), _f = _e.input, value = _f.value, onChange = _f.onChange, otherInputProps = __rest(_f, ["value", "onChange"]), meta = _e.meta;
|
|
621
|
+
var textFieldProps = deepmerge({
|
|
622
622
|
fullWidth: true,
|
|
623
623
|
select: true,
|
|
624
624
|
label: label,
|
|
@@ -631,10 +631,10 @@ function SelectFormField(_a) {
|
|
|
631
631
|
slotProps: {
|
|
632
632
|
input: otherInputProps,
|
|
633
633
|
select: {
|
|
634
|
-
endAdornment: isClearable ? (jsx(Box, { pr: 2, children: jsx(IconButton, { size: (
|
|
634
|
+
endAdornment: isClearable ? (jsx(Box, { pr: 2, children: jsx(IconButton, { size: (_b = slotProps === null || slotProps === void 0 ? void 0 : slotProps.textField) === null || _b === void 0 ? void 0 : _b.size, onClick: function () { return onChange(undefined); }, children: jsx(CloseIcon, { fontSize: "inherit" }) }) })) : undefined,
|
|
635
635
|
},
|
|
636
636
|
},
|
|
637
|
-
});
|
|
637
|
+
}, (_c = slotProps === null || slotProps === void 0 ? void 0 : slotProps.textField) !== null && _c !== void 0 ? _c : {});
|
|
638
638
|
var renderedOptions = useMemo(function () { return renderSelectOptions(options); }, [options]);
|
|
639
639
|
return (jsx(FieldWrapper, { icon: icon, showSpace: showSpace, children: jsxs(TextField, __assign({}, textFieldProps, { children: [renderedOptions, !options && jsx(MenuItem, {})] })) }));
|
|
640
640
|
}
|
|
@@ -661,9 +661,9 @@ function findTextFor(value, options) {
|
|
|
661
661
|
function MultiSelectFormField(_a) {
|
|
662
662
|
var _b, _c;
|
|
663
663
|
var name = _a.name, label = _a.label, required = _a.required, disabled = _a.disabled, helperText = _a.helperText, slotProps = _a.slotProps, isClearable = _a.isClearable, options = _a.options, icon = _a.icon, showSpace = _a.showSpace, format = _a.format, _d = _a.validators, validators = _d === void 0 ? [] : _d;
|
|
664
|
-
var _e = useField(name, __assign(
|
|
665
|
-
? composeValidators.apply(void 0, __spreadArray(__spreadArray([], validators, false), [isRequired], false)) : composeValidators.apply(void 0, validators) })), _f = _e.input, value = _f.value, onChange = _f.onChange, otherInputProps = __rest(_f, ["value", "onChange"]), meta = _e.meta;
|
|
666
|
-
var textFieldProps = deepmerge(
|
|
664
|
+
var _e = useField(name, __assign({ format: format, validate: required
|
|
665
|
+
? composeValidators.apply(void 0, __spreadArray(__spreadArray([], validators, false), [isRequired], false)) : composeValidators.apply(void 0, validators) }, slotProps === null || slotProps === void 0 ? void 0 : slotProps.field)), _f = _e.input, value = _f.value, onChange = _f.onChange, otherInputProps = __rest(_f, ["value", "onChange"]), meta = _e.meta;
|
|
666
|
+
var textFieldProps = deepmerge({
|
|
667
667
|
fullWidth: true,
|
|
668
668
|
select: true,
|
|
669
669
|
label: label,
|
|
@@ -676,12 +676,12 @@ function MultiSelectFormField(_a) {
|
|
|
676
676
|
slotProps: {
|
|
677
677
|
input: otherInputProps,
|
|
678
678
|
select: {
|
|
679
|
-
endAdornment: isClearable ? (jsx(Box, { pr: 2, children: jsx(IconButton, { size: (
|
|
679
|
+
endAdornment: isClearable ? (jsx(Box, { pr: 2, children: jsx(IconButton, { size: (_b = slotProps === null || slotProps === void 0 ? void 0 : slotProps.textField) === null || _b === void 0 ? void 0 : _b.size, onClick: function () { return onChange([]); }, children: jsx(CloseIcon, { fontSize: "inherit" }) }) })) : undefined,
|
|
680
680
|
multiple: true,
|
|
681
681
|
renderValue: function (selected) { return (jsx(Box, { whiteSpace: "normal", children: selected.map(function (s) { return findTextFor(s, options); }).join(", ") })); },
|
|
682
682
|
},
|
|
683
683
|
},
|
|
684
|
-
});
|
|
684
|
+
}, (_c = slotProps === null || slotProps === void 0 ? void 0 : slotProps.textField) !== null && _c !== void 0 ? _c : {});
|
|
685
685
|
var renderedOptions = useMemo(function () { return renderCheckboxSelectOptions(options, value); }, [options, value]);
|
|
686
686
|
return (jsx(FieldWrapper, { icon: icon, showSpace: showSpace, children: jsxs(TextField, __assign({}, textFieldProps, { children: [renderedOptions, !options && jsx(MenuItem, {})] })) }));
|
|
687
687
|
}
|
|
@@ -692,19 +692,19 @@ var mustBeChecked = function (v) {
|
|
|
692
692
|
|
|
693
693
|
var CheckboxFormField = function (_a) {
|
|
694
694
|
var _b;
|
|
695
|
-
var name = _a.name, label = _a.label, mustBeTrue = _a.mustBeTrue, disabled = _a.disabled, helperText = _a.helperText, slotProps = _a.slotProps, icon = _a.icon, showSpace = _a.showSpace, _c = _a.validators, validators = _c === void 0 ? [] : _c;
|
|
695
|
+
var name = _a.name, label = _a.label, mustBeTrue = _a.mustBeTrue, disabled = _a.disabled, helperText = _a.helperText, slotProps = _a.slotProps, icon = _a.icon, showSpace = _a.showSpace, _c = _a.validators, validators = _c === void 0 ? [] : _c, forceError = _a.forceError;
|
|
696
696
|
var _d = useField(name, __assign({ type: "checkbox", validate: mustBeTrue
|
|
697
697
|
? 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 = _d.input, meta = _d.meta;
|
|
698
|
-
var checkboxProps = deepmerge((_b = slotProps === null || slotProps === void 0 ? void 0 : slotProps.checkbox) !== null && _b !== void 0 ? _b : {}
|
|
699
|
-
return (jsxs(FieldWrapper, { icon: icon, showSpace: showSpace, children: [jsx(FormControlLabel, { control: jsx(FormGroup, { children: jsx(Checkbox, __assign({}, checkboxProps)) }), label: label, disabled: disabled }), ((meta.touched && meta.error) || helperText) && (jsx(FormHelperText, { disabled: disabled, error: meta.touched && meta.error, sx: { marginTop: 0, marginLeft: 2 }, children: meta.error || helperText }))] }));
|
|
698
|
+
var checkboxProps = deepmerge(__assign(__assign({}, input), { disabled: disabled }), (_b = slotProps === null || slotProps === void 0 ? void 0 : slotProps.checkbox) !== null && _b !== void 0 ? _b : {});
|
|
699
|
+
return (jsxs(FieldWrapper, { icon: icon, showSpace: showSpace, children: [jsx(FormControlLabel, { control: jsx(FormGroup, { children: jsx(Checkbox, __assign({}, checkboxProps)) }), label: label, disabled: disabled }), ((meta.touched && meta.error) || helperText) && (jsx(FormHelperText, { disabled: disabled, error: (meta.touched && meta.error) || forceError, sx: { marginTop: 0, marginLeft: 2 }, children: meta.error || helperText }))] }));
|
|
700
700
|
};
|
|
701
701
|
|
|
702
702
|
var DateFormField = function (_a) {
|
|
703
703
|
var _b;
|
|
704
704
|
var name = _a.name, label = _a.label, required = _a.required, icon = _a.icon, showSpace = _a.showSpace, slotProps = _a.slotProps, disabled = _a.disabled, helperText = _a.helperText, format = _a.format, _c = _a.validators, validators = _c === void 0 ? [] : _c;
|
|
705
|
-
var _d = useField(name, __assign(
|
|
706
|
-
? composeValidators.apply(void 0, __spreadArray(__spreadArray([], validators, false), [isRequired], false)) : composeValidators.apply(void 0, validators) })), input = _d.input, meta = _d.meta;
|
|
707
|
-
var datePickerProps = deepmerge(
|
|
705
|
+
var _d = useField(name, __assign({ format: format, validate: required
|
|
706
|
+
? 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;
|
|
707
|
+
var datePickerProps = deepmerge({
|
|
708
708
|
label: label,
|
|
709
709
|
disabled: disabled,
|
|
710
710
|
views: ["year", "month", "day"],
|
|
@@ -719,16 +719,16 @@ var DateFormField = function (_a) {
|
|
|
719
719
|
onBlur: input.onBlur,
|
|
720
720
|
},
|
|
721
721
|
},
|
|
722
|
-
});
|
|
722
|
+
}, (_b = slotProps === null || slotProps === void 0 ? void 0 : slotProps.datePicker) !== null && _b !== void 0 ? _b : {});
|
|
723
723
|
return (jsx(FieldWrapper, { icon: icon, showSpace: showSpace, children: jsx(DatePicker, __assign({ value: input.value ? dayjs(input.value) : null, onChange: function (value) { return input.onChange(value === null || value === void 0 ? void 0 : value.toJSON()); } }, datePickerProps)) }));
|
|
724
724
|
};
|
|
725
725
|
|
|
726
726
|
var DateTimeFormField = function (_a) {
|
|
727
727
|
var _b;
|
|
728
728
|
var name = _a.name, label = _a.label, required = _a.required, icon = _a.icon, showSpace = _a.showSpace, slotProps = _a.slotProps, disabled = _a.disabled, helperText = _a.helperText, format = _a.format, _c = _a.validators, validators = _c === void 0 ? [] : _c;
|
|
729
|
-
var _d = useField(name, __assign(
|
|
730
|
-
? composeValidators.apply(void 0, __spreadArray(__spreadArray([], validators, false), [isRequired], false)) : composeValidators.apply(void 0, validators) })), input = _d.input, meta = _d.meta;
|
|
731
|
-
var dateTimeProps = deepmerge(
|
|
729
|
+
var _d = useField(name, __assign({ format: format, validate: required
|
|
730
|
+
? 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;
|
|
731
|
+
var dateTimeProps = deepmerge({
|
|
732
732
|
label: label,
|
|
733
733
|
disabled: disabled,
|
|
734
734
|
views: ["year", "month", "day"],
|
|
@@ -743,7 +743,7 @@ var DateTimeFormField = function (_a) {
|
|
|
743
743
|
onBlur: input.onBlur,
|
|
744
744
|
},
|
|
745
745
|
},
|
|
746
|
-
});
|
|
746
|
+
}, (_b = slotProps === null || slotProps === void 0 ? void 0 : slotProps.dateTimePicker) !== null && _b !== void 0 ? _b : {});
|
|
747
747
|
return (jsx(FieldWrapper, { icon: icon, showSpace: showSpace, children: jsx(DateTimePicker, __assign({ value: input.value ? dayjs(input.value) : null, onChange: function (value) { return input.onChange(value === null || value === void 0 ? void 0 : value.toJSON()); } }, dateTimeProps)) }));
|
|
748
748
|
};
|
|
749
749
|
|
|
@@ -754,16 +754,16 @@ var RadioOption = function (props) {
|
|
|
754
754
|
};
|
|
755
755
|
|
|
756
756
|
var RadioFormField = function (_a) {
|
|
757
|
-
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, _b = _a.validators, validators = _b === void 0 ? [] : _b;
|
|
758
|
-
var _c = useField(name, __assign(
|
|
759
|
-
? composeValidators.apply(void 0, __spreadArray(__spreadArray([], validators, false), [isRequired], false)) : composeValidators.apply(void 0, validators) })).meta, error = _c.error, visited = _c.visited;
|
|
757
|
+
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;
|
|
758
|
+
var _c = useField(name, __assign({ validate: required
|
|
759
|
+
? 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;
|
|
760
760
|
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) {
|
|
761
761
|
var _a, _b;
|
|
762
|
-
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"
|
|
762
|
+
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) {
|
|
763
763
|
var input = _a.input, meta = _a.meta;
|
|
764
764
|
return (jsx(RadioOption, { input: input, meta: meta, disabled: disabled, required: required, radioProps: slotProps === null || slotProps === void 0 ? void 0 : slotProps.radio }));
|
|
765
|
-
} })) }, typeof o === "string" ? o : ((_b = o.text) !== null && _b !== void 0 ? _b : o.value)));
|
|
766
|
-
}) }), (((visited || disabled) && error) || helperText) && (jsx(FormHelperText, { error: error != null, sx: { marginTop: 0 }, children: error || helperText }))] }) }));
|
|
765
|
+
} }, slotProps === null || slotProps === void 0 ? void 0 : slotProps.radioField)) }, typeof o === "string" ? o : ((_b = o.text) !== null && _b !== void 0 ? _b : o.value)));
|
|
766
|
+
}) }), (((visited || disabled) && error) || helperText) && (jsx(FormHelperText, { error: error != null || forceError, sx: { marginTop: 0 }, children: error || helperText }))] }) }));
|
|
767
767
|
};
|
|
768
768
|
|
|
769
769
|
var ErrorMessage = function (_a) {
|
|
@@ -4796,9 +4796,9 @@ function arrayify(value) {
|
|
|
4796
4796
|
return Array.isArray(value) ? value : [value];
|
|
4797
4797
|
}
|
|
4798
4798
|
function useFileEditorField(name, options) {
|
|
4799
|
-
var _a = useField(name, __assign(
|
|
4799
|
+
var _a = useField(name, __assign({ validate: function (v) {
|
|
4800
4800
|
return options.required && v == null ? "This field is required" : undefined;
|
|
4801
|
-
} })), input = _a.input, meta = _a.meta;
|
|
4801
|
+
} }, options.fieldProps)), input = _a.input, meta = _a.meta;
|
|
4802
4802
|
var values = useMemo(function () { return arrayify(input.value); }, [input.value]);
|
|
4803
4803
|
var _b = useState(false), showError = _b[0], setShowError = _b[1];
|
|
4804
4804
|
var _c = useState(""), errorMessage = _c[0], setErrorMessage = _c[1];
|
|
@@ -4913,7 +4913,7 @@ function FileDisplay(_a) {
|
|
|
4913
4913
|
}
|
|
4914
4914
|
|
|
4915
4915
|
function FileEditorField(_a) {
|
|
4916
|
-
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;
|
|
4916
|
+
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, forceError = _a.forceError;
|
|
4917
4917
|
var _b = useFileEditorField(name, {
|
|
4918
4918
|
multiple: multiple,
|
|
4919
4919
|
accept: accept,
|
|
@@ -4921,7 +4921,7 @@ function FileEditorField(_a) {
|
|
|
4921
4921
|
required: required,
|
|
4922
4922
|
fieldProps: slotProps === null || slotProps === void 0 ? void 0 : slotProps.field,
|
|
4923
4923
|
}), getInputProps = _b.getInputProps, getRootProps = _b.getRootProps, dragOverDropzone = _b.dragOverDropzone, values = _b.values, removeFile = _b.removeFile, open = _b.open, showError = _b.showError, setShowError = _b.setShowError, errorMessage = _b.errorMessage, meta = _b.meta;
|
|
4924
|
-
return (jsxs(FieldWrapper, { icon: icon, showSpace: showSpace, children: [jsxs(FormControl, { fullWidth: true, sx: { position: "relative" }, children: [label && (jsx(FormLabel, { disabled: disabled, error: meta.touched && meta.error, children: label })), jsx("input", __assign({}, getInputProps())), jsx(DropIndicator, __assign({ multiple: multiple, dragOver: dragOverDropzone, disabled: disabled }, getRootProps(), { children: jsxs(Stack, { gap: 1, children: [values.length > 0 && (jsx(Box, { sx: { opacity: disabled ? 0.4 : 1 }, children: jsx(FileDisplay, { files: values !== null && values !== void 0 ? values : [], disableLink: true, allowDelete: !disabled, onDelete: removeFile }) })), (multiple || (values === null || values === void 0 ? void 0 : values.length) == 0) && (jsx(Button, { onClick: open, startIcon: jsx(AddIcon, {}), fullWidth: true, disabled: disabled, children: placeholder !== null && placeholder !== void 0 ? placeholder : "Add File".concat(multiple ? "s" : "") }))] }) })), dragOverDropzone && (jsx(Stack, { position: "absolute", top: 0, bottom: 0, left: 0, right: 0, justifyContent: "center", alignItems: "center", sx: { pointerEvents: "none" }, children: jsx(NoteAddIcon, { sx: { fontSize: 50 } }) })), jsx(FormHelperText, { error: meta.touched && meta.error, children: (meta.touched && meta.error) || helperText })] }), jsx(ErrorNotification, { open: showError, onClose: function () { return setShowError(false); }, message: errorMessage })] }));
|
|
4924
|
+
return (jsxs(FieldWrapper, { icon: icon, showSpace: showSpace, children: [jsxs(FormControl, { fullWidth: true, sx: { position: "relative" }, children: [label && (jsx(FormLabel, { disabled: disabled, error: meta.touched && meta.error, children: label })), jsx("input", __assign({}, getInputProps())), jsx(DropIndicator, __assign({ multiple: multiple, dragOver: dragOverDropzone, disabled: disabled }, getRootProps(), { children: jsxs(Stack, { gap: 1, children: [values.length > 0 && (jsx(Box, { sx: { opacity: disabled ? 0.4 : 1 }, children: jsx(FileDisplay, { files: values !== null && values !== void 0 ? values : [], disableLink: true, allowDelete: !disabled, onDelete: removeFile }) })), (multiple || (values === null || values === void 0 ? void 0 : values.length) == 0) && (jsx(Button, { onClick: open, startIcon: jsx(AddIcon, {}), fullWidth: true, disabled: disabled, children: placeholder !== null && placeholder !== void 0 ? placeholder : "Add File".concat(multiple ? "s" : "") }))] }) })), dragOverDropzone && (jsx(Stack, { position: "absolute", top: 0, bottom: 0, left: 0, right: 0, justifyContent: "center", alignItems: "center", sx: { pointerEvents: "none" }, children: jsx(NoteAddIcon, { sx: { fontSize: 50 } }) })), jsx(FormHelperText, { error: (meta.touched && meta.error) || forceError, children: (meta.touched && meta.error) || helperText })] }), jsx(ErrorNotification, { open: showError, onClose: function () { return setShowError(false); }, message: errorMessage })] }));
|
|
4925
4925
|
}
|
|
4926
4926
|
|
|
4927
4927
|
function asInteger(value) {
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import type { CommonFieldProps } from "../Types";
|
|
2
|
+
import { TextFieldProps } from "@mui/material/TextField";
|
|
2
3
|
type T = boolean | undefined;
|
|
3
|
-
export interface ComboboxFormFieldProps<M extends T> extends CommonFieldProps
|
|
4
|
+
export interface ComboboxFormFieldProps<M extends T> extends CommonFieldProps<{
|
|
5
|
+
textField: TextFieldProps;
|
|
6
|
+
}> {
|
|
4
7
|
options: string[];
|
|
5
8
|
disableClearable?: boolean;
|
|
6
9
|
multiple?: M;
|
|
@@ -9,5 +9,6 @@ export interface FileEditorFieldProps extends CommonFieldProps<{}> {
|
|
|
9
9
|
placeholder?: boolean;
|
|
10
10
|
accept?: Accept;
|
|
11
11
|
maxFiles?: number;
|
|
12
|
+
forceError?: boolean;
|
|
12
13
|
}
|
|
13
|
-
export declare function FileEditorField({ name, label, icon, showSpace, multiple, disabled, helperText, placeholder, required, slotProps, accept, }: FileEditorFieldProps): import("react/jsx-runtime").JSX.Element;
|
|
14
|
+
export declare function FileEditorField({ name, label, icon, showSpace, multiple, disabled, helperText, placeholder, required, slotProps, accept, forceError, }: FileEditorFieldProps): import("react/jsx-runtime").JSX.Element;
|