cloudmr-ux 1.0.7 → 1.0.9
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.d.ts +22 -1
- package/dist/index.js +142 -2
- package/dist/index.mjs +140 -2
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -164,6 +164,27 @@ declare const CmrUpload: {
|
|
|
164
164
|
};
|
|
165
165
|
};
|
|
166
166
|
|
|
167
|
+
declare function CmrNameDialog(props: {
|
|
168
|
+
originalName: string;
|
|
169
|
+
renamingCallback: (alias: string) => Promise<boolean>;
|
|
170
|
+
open: boolean;
|
|
171
|
+
setOpen: (open: boolean) => void;
|
|
172
|
+
}): react_jsx_runtime.JSX.Element;
|
|
173
|
+
|
|
174
|
+
declare function CmrConfirmation({ name, message, cancelText, color, open, setOpen, confirmCallback, confirmText, cancellable, cancelCallback, width }: {
|
|
175
|
+
name: string | undefined;
|
|
176
|
+
cancelText?: string;
|
|
177
|
+
message: string | undefined;
|
|
178
|
+
color?: "inherit" | "primary" | "secondary" | "success" | "error" | "info" | "warning" | undefined;
|
|
179
|
+
open: boolean;
|
|
180
|
+
setOpen: (open: boolean) => void;
|
|
181
|
+
confirmCallback?: () => void;
|
|
182
|
+
cancellable?: boolean;
|
|
183
|
+
cancelCallback?: () => void;
|
|
184
|
+
width?: number;
|
|
185
|
+
confirmText?: string;
|
|
186
|
+
}): react_jsx_runtime.JSX.Element;
|
|
187
|
+
|
|
167
188
|
interface CmrTableProps extends Omit<DataGridProps, 'rows'> {
|
|
168
189
|
dataSource: any[];
|
|
169
190
|
idAlias?: string;
|
|
@@ -174,4 +195,4 @@ interface CmrTableProps extends Omit<DataGridProps, 'rows'> {
|
|
|
174
195
|
|
|
175
196
|
declare const CmrTable: FC<CmrTableProps>;
|
|
176
197
|
|
|
177
|
-
export { CmrUpload as CMRUpload, CmrButton, CmrCheckbox, CmrCollapse, CmrInput, CmrPanel, CmrRadioGroup, CmrSelect, CmrTable, CmrTableProps, LambdaFile };
|
|
198
|
+
export { CmrUpload as CMRUpload, CmrButton, CmrCheckbox, CmrCollapse, CmrConfirmation, CmrInput, CmrNameDialog, CmrPanel, CmrRadioGroup, CmrSelect, CmrTable, CmrTableProps, LambdaFile };
|
package/dist/index.js
CHANGED
|
@@ -34,7 +34,9 @@ __export(src_exports, {
|
|
|
34
34
|
CmrButton: () => CmrButton,
|
|
35
35
|
CmrCheckbox: () => CmrCheckbox,
|
|
36
36
|
CmrCollapse: () => Collapse_default,
|
|
37
|
+
CmrConfirmation: () => CmrConfirmation,
|
|
37
38
|
CmrInput: () => CmrInput,
|
|
39
|
+
CmrNameDialog: () => CmrNameDialog,
|
|
38
40
|
CmrPanel: () => Panel_default,
|
|
39
41
|
CmrRadioGroup: () => CmrRadioGroup_default,
|
|
40
42
|
CmrSelect: () => CmrSelect_default,
|
|
@@ -758,9 +760,145 @@ CmrUpload.defaultProps = {
|
|
|
758
760
|
};
|
|
759
761
|
var Upload_default = CmrUpload;
|
|
760
762
|
|
|
763
|
+
// src/CmrComponents/rename/edit.tsx
|
|
764
|
+
var React6 = __toESM(require("react"));
|
|
765
|
+
var import_material8 = require("@mui/material");
|
|
766
|
+
var import_TextField2 = __toESM(require("@mui/material/TextField"));
|
|
767
|
+
var import_Dialog2 = __toESM(require("@mui/material/Dialog"));
|
|
768
|
+
var import_DialogActions2 = __toESM(require("@mui/material/DialogActions"));
|
|
769
|
+
var import_DialogContent2 = __toESM(require("@mui/material/DialogContent"));
|
|
770
|
+
var import_DialogTitle2 = __toESM(require("@mui/material/DialogTitle"));
|
|
771
|
+
var import_react5 = require("react");
|
|
772
|
+
var import_jsx_runtime11 = require("react/jsx-runtime");
|
|
773
|
+
function CmrNameDialog(props) {
|
|
774
|
+
let { originalName, open, setOpen } = props;
|
|
775
|
+
const [helperText, setHelperText] = React6.useState("");
|
|
776
|
+
const [text, setText] = React6.useState(originalName);
|
|
777
|
+
const [error, setError] = React6.useState(false);
|
|
778
|
+
const renamingCallback = props.renamingCallback;
|
|
779
|
+
const handleClose = () => {
|
|
780
|
+
setOpen(false);
|
|
781
|
+
};
|
|
782
|
+
(0, import_react5.useEffect)(() => {
|
|
783
|
+
checkError(originalName);
|
|
784
|
+
}, [originalName]);
|
|
785
|
+
const handleConfirm = async () => {
|
|
786
|
+
if (await renamingCallback(text))
|
|
787
|
+
handleClose();
|
|
788
|
+
};
|
|
789
|
+
const handleTextFieldChange = (e) => {
|
|
790
|
+
setText(e.target.value);
|
|
791
|
+
checkError(e.target.value);
|
|
792
|
+
};
|
|
793
|
+
const checkError = (text2) => {
|
|
794
|
+
const fileNameRegex = /^[a-zA-Z0-9_\-]+\.[a-zA-Z]{1,5}$/;
|
|
795
|
+
let newExtension = text2.split(".").pop();
|
|
796
|
+
let orgExtension = originalName.indexOf(".") >= 0 ? originalName.split(".").pop() : "?";
|
|
797
|
+
if (!fileNameRegex.test(text2)) {
|
|
798
|
+
setError(true);
|
|
799
|
+
if (text2.indexOf(".") < 0) {
|
|
800
|
+
setHelperText("Invalid file name, needs a valid extension.");
|
|
801
|
+
} else {
|
|
802
|
+
setHelperText("Invalid file name, please check.");
|
|
803
|
+
}
|
|
804
|
+
} else if (newExtension !== orgExtension) {
|
|
805
|
+
setHelperText(`You are modifying your file extension from .${orgExtension} to .${newExtension}.`);
|
|
806
|
+
setError(false);
|
|
807
|
+
} else {
|
|
808
|
+
setError(false);
|
|
809
|
+
setHelperText("");
|
|
810
|
+
}
|
|
811
|
+
};
|
|
812
|
+
return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("div", { children: /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(
|
|
813
|
+
import_Dialog2.default,
|
|
814
|
+
{
|
|
815
|
+
open,
|
|
816
|
+
onClose: handleClose,
|
|
817
|
+
fullWidth: true,
|
|
818
|
+
maxWidth: "xs",
|
|
819
|
+
children: [
|
|
820
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_DialogTitle2.default, { children: /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(import_material8.Typography, { children: [
|
|
821
|
+
" Rename the File ",
|
|
822
|
+
originalName,
|
|
823
|
+
" as:"
|
|
824
|
+
] }) }),
|
|
825
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_DialogContent2.default, { children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
|
|
826
|
+
import_TextField2.default,
|
|
827
|
+
{
|
|
828
|
+
autoFocus: true,
|
|
829
|
+
margin: "dense",
|
|
830
|
+
id: "name",
|
|
831
|
+
defaultValue: originalName,
|
|
832
|
+
onFocus: (event) => {
|
|
833
|
+
event.target.select();
|
|
834
|
+
},
|
|
835
|
+
fullWidth: true,
|
|
836
|
+
inputProps: { style: { fontSize: "16px" } },
|
|
837
|
+
variant: "standard",
|
|
838
|
+
onChange: handleTextFieldChange,
|
|
839
|
+
error,
|
|
840
|
+
helperText
|
|
841
|
+
}
|
|
842
|
+
) }),
|
|
843
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(import_DialogActions2.default, { children: [
|
|
844
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)(CmrButton, { variant: "outlined", onClick: handleClose, children: "Cancel" }),
|
|
845
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)(CmrButton, { variant: "contained", color: "primary", onClick: handleConfirm, children: "Confirm" })
|
|
846
|
+
] })
|
|
847
|
+
]
|
|
848
|
+
}
|
|
849
|
+
) });
|
|
850
|
+
}
|
|
851
|
+
|
|
852
|
+
// src/CmrComponents/dialogue/Confirmation.tsx
|
|
853
|
+
var React7 = __toESM(require("react"));
|
|
854
|
+
var import_Dialog3 = __toESM(require("@mui/material/Dialog"));
|
|
855
|
+
var import_DialogActions3 = __toESM(require("@mui/material/DialogActions"));
|
|
856
|
+
var import_DialogContent3 = __toESM(require("@mui/material/DialogContent"));
|
|
857
|
+
var import_DialogContentText2 = __toESM(require("@mui/material/DialogContentText"));
|
|
858
|
+
var import_DialogTitle3 = __toESM(require("@mui/material/DialogTitle"));
|
|
859
|
+
var import_jsx_runtime12 = require("react/jsx-runtime");
|
|
860
|
+
function CmrConfirmation({
|
|
861
|
+
name,
|
|
862
|
+
message,
|
|
863
|
+
cancelText = "Cancel",
|
|
864
|
+
color,
|
|
865
|
+
open,
|
|
866
|
+
setOpen,
|
|
867
|
+
confirmCallback = () => {
|
|
868
|
+
},
|
|
869
|
+
confirmText = "Confirm",
|
|
870
|
+
cancellable = false,
|
|
871
|
+
cancelCallback = () => {
|
|
872
|
+
},
|
|
873
|
+
width
|
|
874
|
+
}) {
|
|
875
|
+
const [text, setText] = React7.useState("");
|
|
876
|
+
const handleClose = () => {
|
|
877
|
+
setOpen(false);
|
|
878
|
+
};
|
|
879
|
+
const handleConfirm = () => {
|
|
880
|
+
confirmCallback();
|
|
881
|
+
handleClose();
|
|
882
|
+
};
|
|
883
|
+
const handleCancel = () => {
|
|
884
|
+
cancelCallback();
|
|
885
|
+
handleClose();
|
|
886
|
+
};
|
|
887
|
+
return /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(import_Dialog3.default, { open, onClose: handleClose, children: [
|
|
888
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_DialogTitle3.default, { children: name ? name : "Confirmation" }),
|
|
889
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(import_DialogContent3.default, { sx: { width }, children: [
|
|
890
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_DialogContentText2.default, { alignContent: "center", children: message }),
|
|
891
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(import_DialogActions3.default, { className: "mt-4", children: [
|
|
892
|
+
cancellable && /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(CmrButton, { variant: "outlined", color: "inherit", sx: { color: "#333" }, onClick: handleCancel, children: cancelText }),
|
|
893
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)(CmrButton, { variant: "contained", color, onClick: handleConfirm, children: confirmText })
|
|
894
|
+
] })
|
|
895
|
+
] })
|
|
896
|
+
] });
|
|
897
|
+
}
|
|
898
|
+
|
|
761
899
|
// src/CmrTable/CmrTable.tsx
|
|
762
900
|
var import_x_data_grid = require("@mui/x-data-grid");
|
|
763
|
-
var
|
|
901
|
+
var import_jsx_runtime13 = require("react/jsx-runtime");
|
|
764
902
|
var CmrTable = (props) => {
|
|
765
903
|
const {
|
|
766
904
|
dataSource,
|
|
@@ -772,7 +910,7 @@ var CmrTable = (props) => {
|
|
|
772
910
|
showCheckbox = true,
|
|
773
911
|
...rest
|
|
774
912
|
} = props;
|
|
775
|
-
return /* @__PURE__ */ (0,
|
|
913
|
+
return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("div", { style: style ?? { height: "400px", width: "100%" }, className: className ?? "", children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|
|
776
914
|
import_x_data_grid.DataGrid,
|
|
777
915
|
{
|
|
778
916
|
rows: dataSource ? dataSource.map((row) => ({
|
|
@@ -802,7 +940,9 @@ var CmrTable2 = CmrTable_default;
|
|
|
802
940
|
CmrButton,
|
|
803
941
|
CmrCheckbox,
|
|
804
942
|
CmrCollapse,
|
|
943
|
+
CmrConfirmation,
|
|
805
944
|
CmrInput,
|
|
945
|
+
CmrNameDialog,
|
|
806
946
|
CmrPanel,
|
|
807
947
|
CmrRadioGroup,
|
|
808
948
|
CmrSelect,
|
package/dist/index.mjs
CHANGED
|
@@ -720,9 +720,145 @@ CmrUpload.defaultProps = {
|
|
|
720
720
|
};
|
|
721
721
|
var Upload_default = CmrUpload;
|
|
722
722
|
|
|
723
|
+
// src/CmrComponents/rename/edit.tsx
|
|
724
|
+
import * as React6 from "react";
|
|
725
|
+
import { Typography as Typography2 } from "@mui/material";
|
|
726
|
+
import TextField2 from "@mui/material/TextField";
|
|
727
|
+
import Dialog2 from "@mui/material/Dialog";
|
|
728
|
+
import DialogActions2 from "@mui/material/DialogActions";
|
|
729
|
+
import DialogContent2 from "@mui/material/DialogContent";
|
|
730
|
+
import DialogTitle2 from "@mui/material/DialogTitle";
|
|
731
|
+
import { useEffect } from "react";
|
|
732
|
+
import { jsx as jsx11, jsxs as jsxs7 } from "react/jsx-runtime";
|
|
733
|
+
function CmrNameDialog(props) {
|
|
734
|
+
let { originalName, open, setOpen } = props;
|
|
735
|
+
const [helperText, setHelperText] = React6.useState("");
|
|
736
|
+
const [text, setText] = React6.useState(originalName);
|
|
737
|
+
const [error, setError] = React6.useState(false);
|
|
738
|
+
const renamingCallback = props.renamingCallback;
|
|
739
|
+
const handleClose = () => {
|
|
740
|
+
setOpen(false);
|
|
741
|
+
};
|
|
742
|
+
useEffect(() => {
|
|
743
|
+
checkError(originalName);
|
|
744
|
+
}, [originalName]);
|
|
745
|
+
const handleConfirm = async () => {
|
|
746
|
+
if (await renamingCallback(text))
|
|
747
|
+
handleClose();
|
|
748
|
+
};
|
|
749
|
+
const handleTextFieldChange = (e) => {
|
|
750
|
+
setText(e.target.value);
|
|
751
|
+
checkError(e.target.value);
|
|
752
|
+
};
|
|
753
|
+
const checkError = (text2) => {
|
|
754
|
+
const fileNameRegex = /^[a-zA-Z0-9_\-]+\.[a-zA-Z]{1,5}$/;
|
|
755
|
+
let newExtension = text2.split(".").pop();
|
|
756
|
+
let orgExtension = originalName.indexOf(".") >= 0 ? originalName.split(".").pop() : "?";
|
|
757
|
+
if (!fileNameRegex.test(text2)) {
|
|
758
|
+
setError(true);
|
|
759
|
+
if (text2.indexOf(".") < 0) {
|
|
760
|
+
setHelperText("Invalid file name, needs a valid extension.");
|
|
761
|
+
} else {
|
|
762
|
+
setHelperText("Invalid file name, please check.");
|
|
763
|
+
}
|
|
764
|
+
} else if (newExtension !== orgExtension) {
|
|
765
|
+
setHelperText(`You are modifying your file extension from .${orgExtension} to .${newExtension}.`);
|
|
766
|
+
setError(false);
|
|
767
|
+
} else {
|
|
768
|
+
setError(false);
|
|
769
|
+
setHelperText("");
|
|
770
|
+
}
|
|
771
|
+
};
|
|
772
|
+
return /* @__PURE__ */ jsx11("div", { children: /* @__PURE__ */ jsxs7(
|
|
773
|
+
Dialog2,
|
|
774
|
+
{
|
|
775
|
+
open,
|
|
776
|
+
onClose: handleClose,
|
|
777
|
+
fullWidth: true,
|
|
778
|
+
maxWidth: "xs",
|
|
779
|
+
children: [
|
|
780
|
+
/* @__PURE__ */ jsx11(DialogTitle2, { children: /* @__PURE__ */ jsxs7(Typography2, { children: [
|
|
781
|
+
" Rename the File ",
|
|
782
|
+
originalName,
|
|
783
|
+
" as:"
|
|
784
|
+
] }) }),
|
|
785
|
+
/* @__PURE__ */ jsx11(DialogContent2, { children: /* @__PURE__ */ jsx11(
|
|
786
|
+
TextField2,
|
|
787
|
+
{
|
|
788
|
+
autoFocus: true,
|
|
789
|
+
margin: "dense",
|
|
790
|
+
id: "name",
|
|
791
|
+
defaultValue: originalName,
|
|
792
|
+
onFocus: (event) => {
|
|
793
|
+
event.target.select();
|
|
794
|
+
},
|
|
795
|
+
fullWidth: true,
|
|
796
|
+
inputProps: { style: { fontSize: "16px" } },
|
|
797
|
+
variant: "standard",
|
|
798
|
+
onChange: handleTextFieldChange,
|
|
799
|
+
error,
|
|
800
|
+
helperText
|
|
801
|
+
}
|
|
802
|
+
) }),
|
|
803
|
+
/* @__PURE__ */ jsxs7(DialogActions2, { children: [
|
|
804
|
+
/* @__PURE__ */ jsx11(CmrButton, { variant: "outlined", onClick: handleClose, children: "Cancel" }),
|
|
805
|
+
/* @__PURE__ */ jsx11(CmrButton, { variant: "contained", color: "primary", onClick: handleConfirm, children: "Confirm" })
|
|
806
|
+
] })
|
|
807
|
+
]
|
|
808
|
+
}
|
|
809
|
+
) });
|
|
810
|
+
}
|
|
811
|
+
|
|
812
|
+
// src/CmrComponents/dialogue/Confirmation.tsx
|
|
813
|
+
import * as React7 from "react";
|
|
814
|
+
import Dialog3 from "@mui/material/Dialog";
|
|
815
|
+
import DialogActions3 from "@mui/material/DialogActions";
|
|
816
|
+
import DialogContent3 from "@mui/material/DialogContent";
|
|
817
|
+
import DialogContentText2 from "@mui/material/DialogContentText";
|
|
818
|
+
import DialogTitle3 from "@mui/material/DialogTitle";
|
|
819
|
+
import { jsx as jsx12, jsxs as jsxs8 } from "react/jsx-runtime";
|
|
820
|
+
function CmrConfirmation({
|
|
821
|
+
name,
|
|
822
|
+
message,
|
|
823
|
+
cancelText = "Cancel",
|
|
824
|
+
color,
|
|
825
|
+
open,
|
|
826
|
+
setOpen,
|
|
827
|
+
confirmCallback = () => {
|
|
828
|
+
},
|
|
829
|
+
confirmText = "Confirm",
|
|
830
|
+
cancellable = false,
|
|
831
|
+
cancelCallback = () => {
|
|
832
|
+
},
|
|
833
|
+
width
|
|
834
|
+
}) {
|
|
835
|
+
const [text, setText] = React7.useState("");
|
|
836
|
+
const handleClose = () => {
|
|
837
|
+
setOpen(false);
|
|
838
|
+
};
|
|
839
|
+
const handleConfirm = () => {
|
|
840
|
+
confirmCallback();
|
|
841
|
+
handleClose();
|
|
842
|
+
};
|
|
843
|
+
const handleCancel = () => {
|
|
844
|
+
cancelCallback();
|
|
845
|
+
handleClose();
|
|
846
|
+
};
|
|
847
|
+
return /* @__PURE__ */ jsxs8(Dialog3, { open, onClose: handleClose, children: [
|
|
848
|
+
/* @__PURE__ */ jsx12(DialogTitle3, { children: name ? name : "Confirmation" }),
|
|
849
|
+
/* @__PURE__ */ jsxs8(DialogContent3, { sx: { width }, children: [
|
|
850
|
+
/* @__PURE__ */ jsx12(DialogContentText2, { alignContent: "center", children: message }),
|
|
851
|
+
/* @__PURE__ */ jsxs8(DialogActions3, { className: "mt-4", children: [
|
|
852
|
+
cancellable && /* @__PURE__ */ jsx12(CmrButton, { variant: "outlined", color: "inherit", sx: { color: "#333" }, onClick: handleCancel, children: cancelText }),
|
|
853
|
+
/* @__PURE__ */ jsx12(CmrButton, { variant: "contained", color, onClick: handleConfirm, children: confirmText })
|
|
854
|
+
] })
|
|
855
|
+
] })
|
|
856
|
+
] });
|
|
857
|
+
}
|
|
858
|
+
|
|
723
859
|
// src/CmrTable/CmrTable.tsx
|
|
724
860
|
import { DataGrid } from "@mui/x-data-grid";
|
|
725
|
-
import { jsx as
|
|
861
|
+
import { jsx as jsx13 } from "react/jsx-runtime";
|
|
726
862
|
var CmrTable = (props) => {
|
|
727
863
|
const {
|
|
728
864
|
dataSource,
|
|
@@ -734,7 +870,7 @@ var CmrTable = (props) => {
|
|
|
734
870
|
showCheckbox = true,
|
|
735
871
|
...rest
|
|
736
872
|
} = props;
|
|
737
|
-
return /* @__PURE__ */
|
|
873
|
+
return /* @__PURE__ */ jsx13("div", { style: style ?? { height: "400px", width: "100%" }, className: className ?? "", children: /* @__PURE__ */ jsx13(
|
|
738
874
|
DataGrid,
|
|
739
875
|
{
|
|
740
876
|
rows: dataSource ? dataSource.map((row) => ({
|
|
@@ -763,7 +899,9 @@ export {
|
|
|
763
899
|
CmrButton,
|
|
764
900
|
CmrCheckbox,
|
|
765
901
|
Collapse_default as CmrCollapse,
|
|
902
|
+
CmrConfirmation,
|
|
766
903
|
CmrInput,
|
|
904
|
+
CmrNameDialog,
|
|
767
905
|
Panel_default as CmrPanel,
|
|
768
906
|
CmrRadioGroup_default as CmrRadioGroup,
|
|
769
907
|
CmrSelect_default as CmrSelect,
|