cloudmr-ux 1.9.6 → 1.9.8
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 +13 -1
- package/dist/index.js +52 -19
- package/dist/index.mjs +63 -25
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
-
import { ButtonProps, SxProps, Theme } from '@mui/material';
|
|
2
|
+
import { ButtonProps, FormControlProps, SelectProps, SxProps, Theme } from '@mui/material';
|
|
3
3
|
import * as React from 'react';
|
|
4
4
|
import React__default, { ReactNode, ChangeEvent, CSSProperties, FC } from 'react';
|
|
5
5
|
import { SizeType } from 'antd/lib/config-provider/SizeContext';
|
|
@@ -41,11 +41,23 @@ declare const CmrRadioGroup: React__default.FC<CmrRadioProps>;
|
|
|
41
41
|
interface Option {
|
|
42
42
|
label: string;
|
|
43
43
|
value: string;
|
|
44
|
+
disabled?: boolean;
|
|
44
45
|
}
|
|
45
46
|
interface CmrSelectProps {
|
|
46
47
|
options: Option[];
|
|
47
48
|
label: string;
|
|
48
49
|
disabled?: boolean;
|
|
50
|
+
/** Controlled usage (optional) */
|
|
51
|
+
value?: string;
|
|
52
|
+
onChange?: (value: string) => void;
|
|
53
|
+
/** Uncontrolled usage (optional) */
|
|
54
|
+
defaultValue?: string;
|
|
55
|
+
/** Layout/Styling */
|
|
56
|
+
fullWidth?: boolean;
|
|
57
|
+
sx?: FormControlProps['sx'];
|
|
58
|
+
className?: string;
|
|
59
|
+
/** Pass-through to MUI Select */
|
|
60
|
+
SelectProps?: Partial<SelectProps<string>>;
|
|
49
61
|
}
|
|
50
62
|
declare const CmrSelect: React__default.FC<CmrSelectProps>;
|
|
51
63
|
|
package/dist/index.js
CHANGED
|
@@ -134,26 +134,59 @@ var CmrRadioGroup_default = CmrRadioGroup;
|
|
|
134
134
|
var import_react2 = require("react");
|
|
135
135
|
var import_material5 = require("@mui/material");
|
|
136
136
|
var import_jsx_runtime5 = require("react/jsx-runtime");
|
|
137
|
-
var CmrSelect = ({
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
137
|
+
var CmrSelect = ({
|
|
138
|
+
options,
|
|
139
|
+
label,
|
|
140
|
+
disabled,
|
|
141
|
+
value,
|
|
142
|
+
onChange,
|
|
143
|
+
defaultValue = "",
|
|
144
|
+
fullWidth,
|
|
145
|
+
sx,
|
|
146
|
+
className,
|
|
147
|
+
SelectProps: SelectProps2
|
|
148
|
+
}) => {
|
|
149
|
+
const isControlled = value !== void 0;
|
|
150
|
+
const [internal, setInternal] = (0, import_react2.useState)(defaultValue);
|
|
151
|
+
const current = isControlled ? value : internal;
|
|
152
|
+
(0, import_react2.useEffect)(() => {
|
|
153
|
+
if (isControlled)
|
|
154
|
+
setInternal(value);
|
|
155
|
+
}, [isControlled, value]);
|
|
156
|
+
const id = (0, import_react2.useId)();
|
|
157
|
+
const labelId = `${id}-label`;
|
|
158
|
+
const selectId = `${id}-select`;
|
|
159
|
+
const handleChange = (e) => {
|
|
160
|
+
const next = e.target.value;
|
|
161
|
+
if (!isControlled)
|
|
162
|
+
setInternal(next);
|
|
163
|
+
onChange == null ? void 0 : onChange(next);
|
|
142
164
|
};
|
|
143
|
-
return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
165
|
+
return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
|
|
166
|
+
import_material5.FormControl,
|
|
167
|
+
{
|
|
168
|
+
className: className ?? "dropdown-select",
|
|
169
|
+
sx: { minWidth: 200, maxWidth: 400, width: fullWidth ? "100%" : "auto", ...sx },
|
|
170
|
+
disabled,
|
|
171
|
+
fullWidth,
|
|
172
|
+
children: [
|
|
173
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_material5.InputLabel, { id: labelId, className: "dropdown-label", children: label }),
|
|
174
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
175
|
+
import_material5.Select,
|
|
176
|
+
{
|
|
177
|
+
labelId,
|
|
178
|
+
id: selectId,
|
|
179
|
+
value: current,
|
|
180
|
+
label,
|
|
181
|
+
onChange: handleChange,
|
|
182
|
+
MenuProps: { classes: { paper: "custom-dropdown" }, ...SelectProps2 == null ? void 0 : SelectProps2.MenuProps },
|
|
183
|
+
...SelectProps2,
|
|
184
|
+
children: options.map((opt) => /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_material5.MenuItem, { value: opt.value, disabled: !!opt.disabled, children: opt.label }, `${opt.value}-${opt.label}`))
|
|
185
|
+
}
|
|
186
|
+
)
|
|
187
|
+
]
|
|
188
|
+
}
|
|
189
|
+
);
|
|
157
190
|
};
|
|
158
191
|
var CmrSelect_default = CmrSelect;
|
|
159
192
|
|
package/dist/index.mjs
CHANGED
|
@@ -83,29 +83,67 @@ var CmrRadioGroup = ({
|
|
|
83
83
|
var CmrRadioGroup_default = CmrRadioGroup;
|
|
84
84
|
|
|
85
85
|
// src/CmrComponents/CmrSelect/CmrSelect.tsx
|
|
86
|
-
import { useState as useState2 } from "react";
|
|
87
|
-
import {
|
|
86
|
+
import { useEffect, useId, useState as useState2 } from "react";
|
|
87
|
+
import {
|
|
88
|
+
Select,
|
|
89
|
+
MenuItem,
|
|
90
|
+
FormControl as FormControl2,
|
|
91
|
+
InputLabel
|
|
92
|
+
} from "@mui/material";
|
|
88
93
|
import { jsx as jsx5, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
89
|
-
var CmrSelect = ({
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
+
var CmrSelect = ({
|
|
95
|
+
options,
|
|
96
|
+
label,
|
|
97
|
+
disabled,
|
|
98
|
+
value,
|
|
99
|
+
onChange,
|
|
100
|
+
defaultValue = "",
|
|
101
|
+
fullWidth,
|
|
102
|
+
sx,
|
|
103
|
+
className,
|
|
104
|
+
SelectProps: SelectProps2
|
|
105
|
+
}) => {
|
|
106
|
+
const isControlled = value !== void 0;
|
|
107
|
+
const [internal, setInternal] = useState2(defaultValue);
|
|
108
|
+
const current = isControlled ? value : internal;
|
|
109
|
+
useEffect(() => {
|
|
110
|
+
if (isControlled)
|
|
111
|
+
setInternal(value);
|
|
112
|
+
}, [isControlled, value]);
|
|
113
|
+
const id = useId();
|
|
114
|
+
const labelId = `${id}-label`;
|
|
115
|
+
const selectId = `${id}-select`;
|
|
116
|
+
const handleChange = (e) => {
|
|
117
|
+
const next = e.target.value;
|
|
118
|
+
if (!isControlled)
|
|
119
|
+
setInternal(next);
|
|
120
|
+
onChange == null ? void 0 : onChange(next);
|
|
94
121
|
};
|
|
95
|
-
return /* @__PURE__ */ jsxs2(
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
122
|
+
return /* @__PURE__ */ jsxs2(
|
|
123
|
+
FormControl2,
|
|
124
|
+
{
|
|
125
|
+
className: className ?? "dropdown-select",
|
|
126
|
+
sx: { minWidth: 200, maxWidth: 400, width: fullWidth ? "100%" : "auto", ...sx },
|
|
127
|
+
disabled,
|
|
128
|
+
fullWidth,
|
|
129
|
+
children: [
|
|
130
|
+
/* @__PURE__ */ jsx5(InputLabel, { id: labelId, className: "dropdown-label", children: label }),
|
|
131
|
+
/* @__PURE__ */ jsx5(
|
|
132
|
+
Select,
|
|
133
|
+
{
|
|
134
|
+
labelId,
|
|
135
|
+
id: selectId,
|
|
136
|
+
value: current,
|
|
137
|
+
label,
|
|
138
|
+
onChange: handleChange,
|
|
139
|
+
MenuProps: { classes: { paper: "custom-dropdown" }, ...SelectProps2 == null ? void 0 : SelectProps2.MenuProps },
|
|
140
|
+
...SelectProps2,
|
|
141
|
+
children: options.map((opt) => /* @__PURE__ */ jsx5(MenuItem, { value: opt.value, disabled: !!opt.disabled, children: opt.label }, `${opt.value}-${opt.label}`))
|
|
142
|
+
}
|
|
143
|
+
)
|
|
144
|
+
]
|
|
145
|
+
}
|
|
146
|
+
);
|
|
109
147
|
};
|
|
110
148
|
var CmrSelect_default = CmrSelect;
|
|
111
149
|
|
|
@@ -713,7 +751,7 @@ import Dialog2 from "@mui/material/Dialog";
|
|
|
713
751
|
import DialogActions2 from "@mui/material/DialogActions";
|
|
714
752
|
import DialogContent2 from "@mui/material/DialogContent";
|
|
715
753
|
import DialogTitle2 from "@mui/material/DialogTitle";
|
|
716
|
-
import { useEffect } from "react";
|
|
754
|
+
import { useEffect as useEffect2 } from "react";
|
|
717
755
|
import { jsx as jsx11, jsxs as jsxs7 } from "react/jsx-runtime";
|
|
718
756
|
function CmrNameDialog(props) {
|
|
719
757
|
let { originalName, open, setOpen } = props;
|
|
@@ -724,7 +762,7 @@ function CmrNameDialog(props) {
|
|
|
724
762
|
const handleClose = () => {
|
|
725
763
|
setOpen(false);
|
|
726
764
|
};
|
|
727
|
-
|
|
765
|
+
useEffect2(() => {
|
|
728
766
|
checkError(originalName);
|
|
729
767
|
}, [originalName]);
|
|
730
768
|
const handleConfirm = async () => {
|
|
@@ -915,7 +953,7 @@ import DialogContent5 from "@mui/material/DialogContent";
|
|
|
915
953
|
import DialogContentText4 from "@mui/material/DialogContentText";
|
|
916
954
|
import DialogTitle5 from "@mui/material/DialogTitle";
|
|
917
955
|
import { InputAdornment } from "@mui/material";
|
|
918
|
-
import { useEffect as
|
|
956
|
+
import { useEffect as useEffect3 } from "react";
|
|
919
957
|
import { jsx as jsx14, jsxs as jsxs10 } from "react/jsx-runtime";
|
|
920
958
|
function CmrEditConfirmation({
|
|
921
959
|
name,
|
|
@@ -932,7 +970,7 @@ function CmrEditConfirmation({
|
|
|
932
970
|
suffix = ""
|
|
933
971
|
}) {
|
|
934
972
|
const [text, setText] = React8.useState(defaultText);
|
|
935
|
-
|
|
973
|
+
useEffect3(() => {
|
|
936
974
|
if (open)
|
|
937
975
|
setText(defaultText);
|
|
938
976
|
}, [open]);
|