@torq-north/react-tools 1.1.0 → 1.1.1
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 +10 -6
- package/dist/index.cjs.map +1 -1
- package/dist/index.es.js +10 -6
- package/dist/index.es.js.map +1 -1
- package/package.json +1 -1
package/dist/index.es.js
CHANGED
|
@@ -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,
|
|
@@ -4800,7 +4804,7 @@ function useFileEditorField(name, options) {
|
|
|
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,9 +4907,9 @@ 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) {
|
|
@@ -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, 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) {
|