@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.cjs
CHANGED
|
@@ -792,7 +792,11 @@ var ErrorNotification = function (_a) {
|
|
|
792
792
|
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" }) }));
|
|
793
793
|
};
|
|
794
794
|
|
|
795
|
-
var DropIndicator = material.styled(material.Box
|
|
795
|
+
var DropIndicator = material.styled(material.Box, {
|
|
796
|
+
shouldForwardProp: function (propName) {
|
|
797
|
+
return propName != "dragOver" && propName != "multiple" && propName != "disabled";
|
|
798
|
+
},
|
|
799
|
+
})(function (_a) {
|
|
796
800
|
var theme = _a.theme, dragOver = _a.dragOver, multiple = _a.multiple, disabled = _a.disabled;
|
|
797
801
|
return ({
|
|
798
802
|
padding: dragOver ? "1px" : "4px",
|
|
@@ -801,7 +805,7 @@ var DropIndicator = material.styled(material.Box)(function (_a) {
|
|
|
801
805
|
borderRadius: 1,
|
|
802
806
|
cursor: multiple ? undefined : "pointer",
|
|
803
807
|
transition: "0.2s opacity",
|
|
804
|
-
"&:hover": disabled
|
|
808
|
+
"&:hover": disabled || multiple
|
|
805
809
|
? undefined
|
|
806
810
|
: {
|
|
807
811
|
opacity: 0.8,
|
|
@@ -4802,7 +4806,7 @@ function useFileEditorField(name, options) {
|
|
|
4802
4806
|
var _c = React.useState(""), errorMessage = _c[0], setErrorMessage = _c[1];
|
|
4803
4807
|
var _d = React.useState(false), dragOverDropzone = _d[0], setDragOverDropzone = _d[1];
|
|
4804
4808
|
var multiple = options.multiple, disabled = options.disabled, otherOptions = __rest(options, ["multiple", "disabled"]);
|
|
4805
|
-
var _e = useDropzone(__assign({ multiple: multiple, noClick: multiple, noKeyboard: multiple, disabled: disabled, onDragEnter: function () { return setDragOverDropzone(true); }, onDragOver: function (e) {
|
|
4809
|
+
var _e = useDropzone(__assign({ multiple: multiple, noClick: multiple || values.length == 0, noKeyboard: multiple, disabled: disabled, onDragEnter: function () { return setDragOverDropzone(true); }, onDragOver: function (e) {
|
|
4806
4810
|
e.preventDefault();
|
|
4807
4811
|
e.stopPropagation();
|
|
4808
4812
|
}, onDragLeave: function () { return setDragOverDropzone(false); }, onDrop: function () { return setDragOverDropzone(false); }, onDropAccepted: function (acceptedFiles) {
|
|
@@ -4905,9 +4909,9 @@ function IndividualFile(_a) {
|
|
|
4905
4909
|
function FileDisplay(_a) {
|
|
4906
4910
|
var files = _a.files, individualFileProps = __rest(_a, ["files"]);
|
|
4907
4911
|
if (!Array.isArray(files)) {
|
|
4908
|
-
return (jsxRuntime.jsx(material.Box, {
|
|
4912
|
+
return (jsxRuntime.jsx(material.Box, { children: jsxRuntime.jsx(IndividualFile, __assign({ file: files }, individualFileProps)) }));
|
|
4909
4913
|
}
|
|
4910
|
-
return (jsxRuntime.jsx(material.Stack, {
|
|
4914
|
+
return (jsxRuntime.jsx(material.Stack, { children: files.map(function (f) { return (jsxRuntime.jsx(IndividualFile, __assign({ file: f }, individualFileProps), isAsset(f) ? f.id : f.name)); }) }));
|
|
4911
4915
|
}
|
|
4912
4916
|
|
|
4913
4917
|
function FileEditorField(_a) {
|
|
@@ -4919,7 +4923,7 @@ function FileEditorField(_a) {
|
|
|
4919
4923
|
required: required,
|
|
4920
4924
|
fieldProps: slotProps === null || slotProps === void 0 ? void 0 : slotProps.field,
|
|
4921
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;
|
|
4922
|
-
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.
|
|
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 })] }));
|
|
4923
4927
|
}
|
|
4924
4928
|
|
|
4925
4929
|
function asInteger(value) {
|