cloudmr-ux 1.9.7 → 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 +4 -8
- package/dist/index.js +12 -17
- package/dist/index.mjs +12 -17
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -47,20 +47,16 @@ interface CmrSelectProps {
|
|
|
47
47
|
options: Option[];
|
|
48
48
|
label: string;
|
|
49
49
|
disabled?: boolean;
|
|
50
|
-
/** Controlled
|
|
50
|
+
/** Controlled usage (optional) */
|
|
51
51
|
value?: string;
|
|
52
|
-
/** Fires when selection changes. For controlled usage, update your state here. */
|
|
53
52
|
onChange?: (value: string) => void;
|
|
54
|
-
/**
|
|
53
|
+
/** Uncontrolled usage (optional) */
|
|
55
54
|
defaultValue?: string;
|
|
56
|
-
/**
|
|
57
|
-
placeholder?: string;
|
|
58
|
-
/** Layout helpers */
|
|
55
|
+
/** Layout/Styling */
|
|
59
56
|
fullWidth?: boolean;
|
|
60
|
-
/** Pass-through styling/props */
|
|
61
57
|
sx?: FormControlProps['sx'];
|
|
62
58
|
className?: string;
|
|
63
|
-
/**
|
|
59
|
+
/** Pass-through to MUI Select */
|
|
64
60
|
SelectProps?: Partial<SelectProps<string>>;
|
|
65
61
|
}
|
|
66
62
|
declare const CmrSelect: React__default.FC<CmrSelectProps>;
|
package/dist/index.js
CHANGED
|
@@ -139,35 +139,29 @@ var CmrSelect = ({
|
|
|
139
139
|
label,
|
|
140
140
|
disabled,
|
|
141
141
|
value,
|
|
142
|
-
// controlled value (optional)
|
|
143
142
|
onChange,
|
|
144
|
-
// callback (optional)
|
|
145
143
|
defaultValue = "",
|
|
146
|
-
// for uncontrolled
|
|
147
|
-
placeholder,
|
|
148
|
-
// optional top disabled item
|
|
149
144
|
fullWidth,
|
|
150
145
|
sx,
|
|
151
146
|
className,
|
|
152
147
|
SelectProps: SelectProps2
|
|
153
148
|
}) => {
|
|
154
149
|
const isControlled = value !== void 0;
|
|
155
|
-
const [
|
|
156
|
-
const
|
|
150
|
+
const [internal, setInternal] = (0, import_react2.useState)(defaultValue);
|
|
151
|
+
const current = isControlled ? value : internal;
|
|
157
152
|
(0, import_react2.useEffect)(() => {
|
|
158
|
-
if (isControlled)
|
|
159
|
-
|
|
160
|
-
}
|
|
153
|
+
if (isControlled)
|
|
154
|
+
setInternal(value);
|
|
161
155
|
}, [isControlled, value]);
|
|
162
156
|
const id = (0, import_react2.useId)();
|
|
163
157
|
const labelId = `${id}-label`;
|
|
164
|
-
const
|
|
165
|
-
|
|
158
|
+
const selectId = `${id}-select`;
|
|
159
|
+
const handleChange = (e) => {
|
|
160
|
+
const next = e.target.value;
|
|
166
161
|
if (!isControlled)
|
|
167
|
-
|
|
162
|
+
setInternal(next);
|
|
168
163
|
onChange == null ? void 0 : onChange(next);
|
|
169
164
|
};
|
|
170
|
-
const items = placeholder ? [{ label: placeholder, value: "", disabled: true }, ...options] : options;
|
|
171
165
|
return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
|
|
172
166
|
import_material5.FormControl,
|
|
173
167
|
{
|
|
@@ -181,12 +175,13 @@ var CmrSelect = ({
|
|
|
181
175
|
import_material5.Select,
|
|
182
176
|
{
|
|
183
177
|
labelId,
|
|
184
|
-
|
|
185
|
-
|
|
178
|
+
id: selectId,
|
|
179
|
+
value: current,
|
|
186
180
|
label,
|
|
181
|
+
onChange: handleChange,
|
|
187
182
|
MenuProps: { classes: { paper: "custom-dropdown" }, ...SelectProps2 == null ? void 0 : SelectProps2.MenuProps },
|
|
188
183
|
...SelectProps2,
|
|
189
|
-
children:
|
|
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}`))
|
|
190
185
|
}
|
|
191
186
|
)
|
|
192
187
|
]
|
package/dist/index.mjs
CHANGED
|
@@ -96,35 +96,29 @@ var CmrSelect = ({
|
|
|
96
96
|
label,
|
|
97
97
|
disabled,
|
|
98
98
|
value,
|
|
99
|
-
// controlled value (optional)
|
|
100
99
|
onChange,
|
|
101
|
-
// callback (optional)
|
|
102
100
|
defaultValue = "",
|
|
103
|
-
// for uncontrolled
|
|
104
|
-
placeholder,
|
|
105
|
-
// optional top disabled item
|
|
106
101
|
fullWidth,
|
|
107
102
|
sx,
|
|
108
103
|
className,
|
|
109
104
|
SelectProps: SelectProps2
|
|
110
105
|
}) => {
|
|
111
106
|
const isControlled = value !== void 0;
|
|
112
|
-
const [
|
|
113
|
-
const
|
|
107
|
+
const [internal, setInternal] = useState2(defaultValue);
|
|
108
|
+
const current = isControlled ? value : internal;
|
|
114
109
|
useEffect(() => {
|
|
115
|
-
if (isControlled)
|
|
116
|
-
|
|
117
|
-
}
|
|
110
|
+
if (isControlled)
|
|
111
|
+
setInternal(value);
|
|
118
112
|
}, [isControlled, value]);
|
|
119
113
|
const id = useId();
|
|
120
114
|
const labelId = `${id}-label`;
|
|
121
|
-
const
|
|
122
|
-
|
|
115
|
+
const selectId = `${id}-select`;
|
|
116
|
+
const handleChange = (e) => {
|
|
117
|
+
const next = e.target.value;
|
|
123
118
|
if (!isControlled)
|
|
124
|
-
|
|
119
|
+
setInternal(next);
|
|
125
120
|
onChange == null ? void 0 : onChange(next);
|
|
126
121
|
};
|
|
127
|
-
const items = placeholder ? [{ label: placeholder, value: "", disabled: true }, ...options] : options;
|
|
128
122
|
return /* @__PURE__ */ jsxs2(
|
|
129
123
|
FormControl2,
|
|
130
124
|
{
|
|
@@ -138,12 +132,13 @@ var CmrSelect = ({
|
|
|
138
132
|
Select,
|
|
139
133
|
{
|
|
140
134
|
labelId,
|
|
141
|
-
|
|
142
|
-
|
|
135
|
+
id: selectId,
|
|
136
|
+
value: current,
|
|
143
137
|
label,
|
|
138
|
+
onChange: handleChange,
|
|
144
139
|
MenuProps: { classes: { paper: "custom-dropdown" }, ...SelectProps2 == null ? void 0 : SelectProps2.MenuProps },
|
|
145
140
|
...SelectProps2,
|
|
146
|
-
children:
|
|
141
|
+
children: options.map((opt) => /* @__PURE__ */ jsx5(MenuItem, { value: opt.value, disabled: !!opt.disabled, children: opt.label }, `${opt.value}-${opt.label}`))
|
|
147
142
|
}
|
|
148
143
|
)
|
|
149
144
|
]
|