cloudmr-ux 1.0.8 → 1.1.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.d.ts CHANGED
@@ -171,6 +171,33 @@ declare function CmrNameDialog(props: {
171
171
  setOpen: (open: boolean) => void;
172
172
  }): react_jsx_runtime.JSX.Element;
173
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
+
188
+ interface TabInfo {
189
+ id: number;
190
+ text: string;
191
+ disable?: boolean;
192
+ children: JSX.Element;
193
+ }
194
+
195
+ interface CmrTabsProps {
196
+ tabList: TabInfo[];
197
+ onTabSelected?: (tabId: number) => void;
198
+ }
199
+ declare function CmrTabs(props: CmrTabsProps): react_jsx_runtime.JSX.Element;
200
+
174
201
  interface CmrTableProps extends Omit<DataGridProps, 'rows'> {
175
202
  dataSource: any[];
176
203
  idAlias?: string;
@@ -181,4 +208,4 @@ interface CmrTableProps extends Omit<DataGridProps, 'rows'> {
181
208
 
182
209
  declare const CmrTable: FC<CmrTableProps>;
183
210
 
184
- export { CmrUpload as CMRUpload, CmrButton, CmrCheckbox, CmrCollapse, CmrInput, CmrNameDialog, CmrPanel, CmrRadioGroup, CmrSelect, CmrTable, CmrTableProps, LambdaFile };
211
+ export { CmrUpload as CMRUpload, CmrButton, CmrCheckbox, CmrCollapse, CmrConfirmation, CmrInput, CmrNameDialog, CmrPanel, CmrRadioGroup, CmrSelect, CmrTable, CmrTableProps, CmrTabs, LambdaFile };
package/dist/index.js CHANGED
@@ -34,12 +34,14 @@ __export(src_exports, {
34
34
  CmrButton: () => CmrButton,
35
35
  CmrCheckbox: () => CmrCheckbox,
36
36
  CmrCollapse: () => Collapse_default,
37
+ CmrConfirmation: () => CmrConfirmation,
37
38
  CmrInput: () => CmrInput,
38
39
  CmrNameDialog: () => CmrNameDialog,
39
40
  CmrPanel: () => Panel_default,
40
41
  CmrRadioGroup: () => CmrRadioGroup_default,
41
42
  CmrSelect: () => CmrSelect_default,
42
- CmrTable: () => CmrTable2
43
+ CmrTable: () => CmrTable2,
44
+ CmrTabs: () => CmrTabs
43
45
  });
44
46
  module.exports = __toCommonJS(src_exports);
45
47
 
@@ -848,9 +850,128 @@ function CmrNameDialog(props) {
848
850
  ) });
849
851
  }
850
852
 
853
+ // src/CmrComponents/dialogue/Confirmation.tsx
854
+ var React7 = __toESM(require("react"));
855
+ var import_Dialog3 = __toESM(require("@mui/material/Dialog"));
856
+ var import_DialogActions3 = __toESM(require("@mui/material/DialogActions"));
857
+ var import_DialogContent3 = __toESM(require("@mui/material/DialogContent"));
858
+ var import_DialogContentText2 = __toESM(require("@mui/material/DialogContentText"));
859
+ var import_DialogTitle3 = __toESM(require("@mui/material/DialogTitle"));
860
+ var import_jsx_runtime12 = require("react/jsx-runtime");
861
+ function CmrConfirmation({
862
+ name,
863
+ message,
864
+ cancelText = "Cancel",
865
+ color,
866
+ open,
867
+ setOpen,
868
+ confirmCallback = () => {
869
+ },
870
+ confirmText = "Confirm",
871
+ cancellable = false,
872
+ cancelCallback = () => {
873
+ },
874
+ width
875
+ }) {
876
+ const [text, setText] = React7.useState("");
877
+ const handleClose = () => {
878
+ setOpen(false);
879
+ };
880
+ const handleConfirm = () => {
881
+ confirmCallback();
882
+ handleClose();
883
+ };
884
+ const handleCancel = () => {
885
+ cancelCallback();
886
+ handleClose();
887
+ };
888
+ return /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(import_Dialog3.default, { open, onClose: handleClose, children: [
889
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_DialogTitle3.default, { children: name ? name : "Confirmation" }),
890
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(import_DialogContent3.default, { sx: { width }, children: [
891
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_DialogContentText2.default, { alignContent: "center", children: message }),
892
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(import_DialogActions3.default, { className: "mt-4", children: [
893
+ cancellable && /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(CmrButton, { variant: "outlined", color: "inherit", sx: { color: "#333" }, onClick: handleCancel, children: cancelText }),
894
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(CmrButton, { variant: "contained", color, onClick: handleConfirm, children: confirmText })
895
+ ] })
896
+ ] })
897
+ ] });
898
+ }
899
+
900
+ // src/CmrTabs/CmrTabs.tsx
901
+ var React8 = __toESM(require("react"));
902
+ var import_Tabs = __toESM(require("@mui/material/Tabs"));
903
+ var import_Tab = __toESM(require("@mui/material/Tab"));
904
+ var import_Container = __toESM(require("@mui/material/Container"));
905
+ var import_Typography2 = __toESM(require("@mui/material/Typography"));
906
+ var import_Box2 = __toESM(require("@mui/material/Box"));
907
+ var import_react6 = require("react");
908
+ var import_jsx_runtime13 = require("react/jsx-runtime");
909
+ function CustomTabPanel(props) {
910
+ const { children, value, index, ...other } = props;
911
+ return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
912
+ "div",
913
+ {
914
+ role: "tabpanel",
915
+ hidden: value !== index,
916
+ id: `simple-tabpanel-${index}`,
917
+ "aria-labelledby": `simple-tab-${index}`,
918
+ ...other,
919
+ children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_Box2.default, { sx: { p: 0 }, style: { display: value === index ? void 0 : "none" }, children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_Typography2.default, { children }) })
920
+ }
921
+ );
922
+ }
923
+ function a11yProps(index) {
924
+ return {
925
+ id: `simple-tab-${index}`,
926
+ "aria-controls": `simple-tabpanel-${index}`
927
+ };
928
+ }
929
+ function CmrTabs(props) {
930
+ const [value, setValue] = React8.useState(0);
931
+ const handleChange = (event, newValue) => {
932
+ setValue(newValue);
933
+ if (props.onTabSelected)
934
+ props.onTabSelected(newValue);
935
+ };
936
+ return /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(
937
+ import_Container.default,
938
+ {
939
+ maxWidth: "lg",
940
+ sx: {
941
+ flex: 1,
942
+ display: "flex",
943
+ flexDirection: "column",
944
+ mt: 4
945
+ },
946
+ children: [
947
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_Box2.default, { sx: { borderBottom: 1, borderColor: "divider", mb: 4 }, children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
948
+ import_Tabs.default,
949
+ {
950
+ value,
951
+ onChange: handleChange,
952
+ "aria-label": "basic tabs example",
953
+ textColor: "inherit",
954
+ TabIndicatorProps: {
955
+ style: {
956
+ backgroundColor: "#580F8B"
957
+ }
958
+ },
959
+ children: props.tabList.map((tab, index) => /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_Tab.default, { sx: { color: value == index ? "#580F8B" : void 0 }, style: { fontSize: "14px", textTransform: "uppercase", fontWeight: 400 }, label: tab.text, ...a11yProps(index) }))
960
+ }
961
+ ) }),
962
+ props.tabList.map(
963
+ (tab, index) => /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(CustomTabPanel, { value, index, children: (0, import_react6.cloneElement)(tab.children, {
964
+ visible: value == index
965
+ }) })
966
+ )
967
+ ]
968
+ }
969
+ );
970
+ }
971
+
851
972
  // src/CmrTable/CmrTable.tsx
852
973
  var import_x_data_grid = require("@mui/x-data-grid");
853
- var import_jsx_runtime12 = require("react/jsx-runtime");
974
+ var import_jsx_runtime14 = require("react/jsx-runtime");
854
975
  var CmrTable = (props) => {
855
976
  const {
856
977
  dataSource,
@@ -862,7 +983,7 @@ var CmrTable = (props) => {
862
983
  showCheckbox = true,
863
984
  ...rest
864
985
  } = props;
865
- return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { style: style ?? { height: "400px", width: "100%" }, className: className ?? "", children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
986
+ return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("div", { style: style ?? { height: "400px", width: "100%" }, className: className ?? "", children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
866
987
  import_x_data_grid.DataGrid,
867
988
  {
868
989
  rows: dataSource ? dataSource.map((row) => ({
@@ -892,10 +1013,12 @@ var CmrTable2 = CmrTable_default;
892
1013
  CmrButton,
893
1014
  CmrCheckbox,
894
1015
  CmrCollapse,
1016
+ CmrConfirmation,
895
1017
  CmrInput,
896
1018
  CmrNameDialog,
897
1019
  CmrPanel,
898
1020
  CmrRadioGroup,
899
1021
  CmrSelect,
900
- CmrTable
1022
+ CmrTable,
1023
+ CmrTabs
901
1024
  });
package/dist/index.mjs CHANGED
@@ -809,9 +809,128 @@ function CmrNameDialog(props) {
809
809
  ) });
810
810
  }
811
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
+
859
+ // src/CmrTabs/CmrTabs.tsx
860
+ import * as React8 from "react";
861
+ import Tabs from "@mui/material/Tabs";
862
+ import Tab from "@mui/material/Tab";
863
+ import Container from "@mui/material/Container";
864
+ import Typography3 from "@mui/material/Typography";
865
+ import Box3 from "@mui/material/Box";
866
+ import { cloneElement as cloneElement2 } from "react";
867
+ import { jsx as jsx13, jsxs as jsxs9 } from "react/jsx-runtime";
868
+ function CustomTabPanel(props) {
869
+ const { children, value, index, ...other } = props;
870
+ return /* @__PURE__ */ jsx13(
871
+ "div",
872
+ {
873
+ role: "tabpanel",
874
+ hidden: value !== index,
875
+ id: `simple-tabpanel-${index}`,
876
+ "aria-labelledby": `simple-tab-${index}`,
877
+ ...other,
878
+ children: /* @__PURE__ */ jsx13(Box3, { sx: { p: 0 }, style: { display: value === index ? void 0 : "none" }, children: /* @__PURE__ */ jsx13(Typography3, { children }) })
879
+ }
880
+ );
881
+ }
882
+ function a11yProps(index) {
883
+ return {
884
+ id: `simple-tab-${index}`,
885
+ "aria-controls": `simple-tabpanel-${index}`
886
+ };
887
+ }
888
+ function CmrTabs(props) {
889
+ const [value, setValue] = React8.useState(0);
890
+ const handleChange = (event, newValue) => {
891
+ setValue(newValue);
892
+ if (props.onTabSelected)
893
+ props.onTabSelected(newValue);
894
+ };
895
+ return /* @__PURE__ */ jsxs9(
896
+ Container,
897
+ {
898
+ maxWidth: "lg",
899
+ sx: {
900
+ flex: 1,
901
+ display: "flex",
902
+ flexDirection: "column",
903
+ mt: 4
904
+ },
905
+ children: [
906
+ /* @__PURE__ */ jsx13(Box3, { sx: { borderBottom: 1, borderColor: "divider", mb: 4 }, children: /* @__PURE__ */ jsx13(
907
+ Tabs,
908
+ {
909
+ value,
910
+ onChange: handleChange,
911
+ "aria-label": "basic tabs example",
912
+ textColor: "inherit",
913
+ TabIndicatorProps: {
914
+ style: {
915
+ backgroundColor: "#580F8B"
916
+ }
917
+ },
918
+ children: props.tabList.map((tab, index) => /* @__PURE__ */ jsx13(Tab, { sx: { color: value == index ? "#580F8B" : void 0 }, style: { fontSize: "14px", textTransform: "uppercase", fontWeight: 400 }, label: tab.text, ...a11yProps(index) }))
919
+ }
920
+ ) }),
921
+ props.tabList.map(
922
+ (tab, index) => /* @__PURE__ */ jsx13(CustomTabPanel, { value, index, children: cloneElement2(tab.children, {
923
+ visible: value == index
924
+ }) })
925
+ )
926
+ ]
927
+ }
928
+ );
929
+ }
930
+
812
931
  // src/CmrTable/CmrTable.tsx
813
932
  import { DataGrid } from "@mui/x-data-grid";
814
- import { jsx as jsx12 } from "react/jsx-runtime";
933
+ import { jsx as jsx14 } from "react/jsx-runtime";
815
934
  var CmrTable = (props) => {
816
935
  const {
817
936
  dataSource,
@@ -823,7 +942,7 @@ var CmrTable = (props) => {
823
942
  showCheckbox = true,
824
943
  ...rest
825
944
  } = props;
826
- return /* @__PURE__ */ jsx12("div", { style: style ?? { height: "400px", width: "100%" }, className: className ?? "", children: /* @__PURE__ */ jsx12(
945
+ return /* @__PURE__ */ jsx14("div", { style: style ?? { height: "400px", width: "100%" }, className: className ?? "", children: /* @__PURE__ */ jsx14(
827
946
  DataGrid,
828
947
  {
829
948
  rows: dataSource ? dataSource.map((row) => ({
@@ -852,10 +971,12 @@ export {
852
971
  CmrButton,
853
972
  CmrCheckbox,
854
973
  Collapse_default as CmrCollapse,
974
+ CmrConfirmation,
855
975
  CmrInput,
856
976
  CmrNameDialog,
857
977
  Panel_default as CmrPanel,
858
978
  CmrRadioGroup_default as CmrRadioGroup,
859
979
  CmrSelect_default as CmrSelect,
860
- CmrTable2 as CmrTable
980
+ CmrTable2 as CmrTable,
981
+ CmrTabs
861
982
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cloudmr-ux",
3
- "version": "1.0.8",
3
+ "version": "1.1.0",
4
4
  "author": "erosmontin@gmail.com",
5
5
  "license": "MIT",
6
6
  "repository": "erosmontin/cloudmr-ux",