@torq-north/react-tools 1.1.0 → 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 +44 -40
- package/dist/index.cjs.map +1 -1
- package/dist/index.es.js +44 -40
- package/dist/index.es.js.map +1 -1
- 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.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) {
|
|
@@ -790,7 +790,11 @@ var ErrorNotification = function (_a) {
|
|
|
790
790
|
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 ? message : "An error has occured" }) }));
|
|
791
791
|
};
|
|
792
792
|
|
|
793
|
-
var DropIndicator = styled(Box
|
|
793
|
+
var DropIndicator = styled(Box, {
|
|
794
|
+
shouldForwardProp: function (propName) {
|
|
795
|
+
return propName != "dragOver" && propName != "multiple" && propName != "disabled";
|
|
796
|
+
},
|
|
797
|
+
})(function (_a) {
|
|
794
798
|
var theme = _a.theme, dragOver = _a.dragOver, multiple = _a.multiple, disabled = _a.disabled;
|
|
795
799
|
return ({
|
|
796
800
|
padding: dragOver ? "1px" : "4px",
|
|
@@ -799,7 +803,7 @@ var DropIndicator = styled(Box)(function (_a) {
|
|
|
799
803
|
borderRadius: 1,
|
|
800
804
|
cursor: multiple ? undefined : "pointer",
|
|
801
805
|
transition: "0.2s opacity",
|
|
802
|
-
"&:hover": disabled
|
|
806
|
+
"&:hover": disabled || multiple
|
|
803
807
|
? undefined
|
|
804
808
|
: {
|
|
805
809
|
opacity: 0.8,
|
|
@@ -4792,15 +4796,15 @@ function arrayify(value) {
|
|
|
4792
4796
|
return Array.isArray(value) ? value : [value];
|
|
4793
4797
|
}
|
|
4794
4798
|
function useFileEditorField(name, options) {
|
|
4795
|
-
var _a = useField(name, __assign(
|
|
4799
|
+
var _a = useField(name, __assign({ validate: function (v) {
|
|
4796
4800
|
return options.required && v == null ? "This field is required" : undefined;
|
|
4797
|
-
} })), input = _a.input, meta = _a.meta;
|
|
4801
|
+
} }, options.fieldProps)), input = _a.input, meta = _a.meta;
|
|
4798
4802
|
var values = useMemo(function () { return arrayify(input.value); }, [input.value]);
|
|
4799
4803
|
var _b = useState(false), showError = _b[0], setShowError = _b[1];
|
|
4800
4804
|
var _c = useState(""), errorMessage = _c[0], setErrorMessage = _c[1];
|
|
4801
4805
|
var _d = useState(false), dragOverDropzone = _d[0], setDragOverDropzone = _d[1];
|
|
4802
4806
|
var multiple = options.multiple, disabled = options.disabled, otherOptions = __rest(options, ["multiple", "disabled"]);
|
|
4803
|
-
var _e = useDropzone(__assign({ multiple: multiple, noClick: multiple, noKeyboard: multiple, disabled: disabled, onDragEnter: function () { return setDragOverDropzone(true); }, onDragOver: function (e) {
|
|
4807
|
+
var _e = useDropzone(__assign({ multiple: multiple, noClick: multiple || values.length == 0, noKeyboard: multiple, disabled: disabled, onDragEnter: function () { return setDragOverDropzone(true); }, onDragOver: function (e) {
|
|
4804
4808
|
e.preventDefault();
|
|
4805
4809
|
e.stopPropagation();
|
|
4806
4810
|
}, onDragLeave: function () { return setDragOverDropzone(false); }, onDrop: function () { return setDragOverDropzone(false); }, onDropAccepted: function (acceptedFiles) {
|
|
@@ -4903,13 +4907,13 @@ function IndividualFile(_a) {
|
|
|
4903
4907
|
function FileDisplay(_a) {
|
|
4904
4908
|
var files = _a.files, individualFileProps = __rest(_a, ["files"]);
|
|
4905
4909
|
if (!Array.isArray(files)) {
|
|
4906
|
-
return (jsx(Box, {
|
|
4910
|
+
return (jsx(Box, { children: jsx(IndividualFile, __assign({ file: files }, individualFileProps)) }));
|
|
4907
4911
|
}
|
|
4908
|
-
return (jsx(Stack, {
|
|
4912
|
+
return (jsx(Stack, { children: files.map(function (f) { return (jsx(IndividualFile, __assign({ file: f }, individualFileProps), isAsset(f) ? f.id : f.name)); }) }));
|
|
4909
4913
|
}
|
|
4910
4914
|
|
|
4911
4915
|
function FileEditorField(_a) {
|
|
4912
|
-
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;
|
|
4913
4917
|
var _b = useFileEditorField(name, {
|
|
4914
4918
|
multiple: multiple,
|
|
4915
4919
|
accept: accept,
|
|
@@ -4917,7 +4921,7 @@ function FileEditorField(_a) {
|
|
|
4917
4921
|
required: required,
|
|
4918
4922
|
fieldProps: slotProps === null || slotProps === void 0 ? void 0 : slotProps.field,
|
|
4919
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;
|
|
4920
|
-
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())),
|
|
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 })] }));
|
|
4921
4925
|
}
|
|
4922
4926
|
|
|
4923
4927
|
function asInteger(value) {
|