@elementor/editor-controls 3.35.0-336 → 3.35.0-338
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.js +44 -35
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +44 -35
- package/dist/index.mjs.map +1 -1
- package/package.json +15 -15
- package/src/controls/select-control.tsx +58 -47
package/dist/index.mjs
CHANGED
|
@@ -399,43 +399,52 @@ import * as React10 from "react";
|
|
|
399
399
|
import { stringPropTypeUtil } from "@elementor/editor-props";
|
|
400
400
|
import { MenuListItem } from "@elementor/editor-ui";
|
|
401
401
|
import { Select, Typography } from "@elementor/ui";
|
|
402
|
-
var
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
{
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
402
|
+
var DEFAULT_MENU_PROPS = {
|
|
403
|
+
MenuListProps: {
|
|
404
|
+
sx: {
|
|
405
|
+
maxHeight: "160px"
|
|
406
|
+
}
|
|
407
|
+
}
|
|
408
|
+
};
|
|
409
|
+
var SelectControl = createControl(
|
|
410
|
+
({ options, onChange, MenuProps = DEFAULT_MENU_PROPS, ariaLabel }) => {
|
|
411
|
+
const { value, setValue, disabled, placeholder } = useBoundProp(stringPropTypeUtil);
|
|
412
|
+
const handleChange = (event) => {
|
|
413
|
+
const newValue = event.target.value || null;
|
|
414
|
+
onChange?.(newValue, value);
|
|
415
|
+
setValue(newValue);
|
|
416
|
+
};
|
|
417
|
+
const isDisabled = disabled || options.length === 0;
|
|
418
|
+
return /* @__PURE__ */ React10.createElement(ControlActions, null, /* @__PURE__ */ React10.createElement(
|
|
419
|
+
Select,
|
|
420
|
+
{
|
|
421
|
+
sx: { overflow: "hidden" },
|
|
422
|
+
displayEmpty: true,
|
|
423
|
+
size: "tiny",
|
|
424
|
+
MenuProps,
|
|
425
|
+
"aria-label": ariaLabel || placeholder,
|
|
426
|
+
renderValue: (selectedValue) => {
|
|
427
|
+
const findOptionByValue = (searchValue) => options.find((opt) => opt.value === searchValue);
|
|
428
|
+
if (!selectedValue || selectedValue === "") {
|
|
429
|
+
if (placeholder) {
|
|
430
|
+
const placeholderOption = findOptionByValue(placeholder);
|
|
431
|
+
const displayText = placeholderOption?.label || placeholder;
|
|
432
|
+
return /* @__PURE__ */ React10.createElement(Typography, { component: "span", variant: "caption", color: "text.tertiary" }, displayText);
|
|
433
|
+
}
|
|
434
|
+
return "";
|
|
425
435
|
}
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
436
|
+
const option = findOptionByValue(selectedValue);
|
|
437
|
+
return option?.label || selectedValue;
|
|
438
|
+
},
|
|
439
|
+
value: value ?? "",
|
|
440
|
+
onChange: handleChange,
|
|
441
|
+
disabled: isDisabled,
|
|
442
|
+
fullWidth: true
|
|
430
443
|
},
|
|
431
|
-
value: value ?? "",
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
},
|
|
436
|
-
options.map(({ label, ...props }) => /* @__PURE__ */ React10.createElement(MenuListItem, { key: props.value, ...props, value: props.value ?? "" }, label))
|
|
437
|
-
));
|
|
438
|
-
});
|
|
444
|
+
options.map(({ label, ...props }) => /* @__PURE__ */ React10.createElement(MenuListItem, { key: props.value, ...props, value: props.value ?? "" }, label))
|
|
445
|
+
));
|
|
446
|
+
}
|
|
447
|
+
);
|
|
439
448
|
|
|
440
449
|
// src/controls/image-control.tsx
|
|
441
450
|
var ImageControl = createControl(({ sizes, showMode = "all" }) => {
|