@elementor/editor-controls 4.1.0-756 → 4.1.0-757

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 CHANGED
@@ -571,19 +571,7 @@ var SelectControl = createControl(
571
571
  size: "tiny",
572
572
  MenuProps,
573
573
  "aria-label": ariaLabel || placeholder,
574
- renderValue: (selectedValue) => {
575
- const findOptionByValue = (searchValue) => options.find((opt) => opt.value === searchValue);
576
- if (!selectedValue || selectedValue === "") {
577
- if (placeholder) {
578
- const placeholderOption = findOptionByValue(placeholder);
579
- const displayText = placeholderOption?.label || placeholder;
580
- return /* @__PURE__ */ React12.createElement(import_ui5.Typography, { component: "span", variant: "caption", color: "text.tertiary" }, displayText);
581
- }
582
- return "";
583
- }
584
- const option = findOptionByValue(selectedValue);
585
- return option?.label || selectedValue;
586
- },
574
+ renderValue: (selectedValue) => getSelectRenderValue(options, placeholder, selectedValue),
587
575
  value: value ?? "",
588
576
  onChange: handleChange,
589
577
  disabled: isDisabled,
@@ -593,6 +581,20 @@ var SelectControl = createControl(
593
581
  ));
594
582
  }
595
583
  );
584
+ function getSelectRenderValue(options, placeholder, selectedValue) {
585
+ const optionWithValue = (v) => options.find(({ value }) => value === v);
586
+ if (!isUnsetSelectValue(selectedValue)) {
587
+ return optionWithValue(selectedValue)?.label ?? selectedValue;
588
+ }
589
+ if (placeholder) {
590
+ const text = optionWithValue(placeholder)?.label ?? placeholder;
591
+ return /* @__PURE__ */ React12.createElement(import_ui5.Typography, { component: "span", variant: "inherit", color: "text.tertiary" }, text);
592
+ }
593
+ return options.find(({ value }) => isUnsetSelectValue(value))?.label ?? "";
594
+ }
595
+ function isUnsetSelectValue(value) {
596
+ return value === null || value === void 0 || value === "";
597
+ }
596
598
 
597
599
  // src/controls/image-control.tsx
598
600
  var ImageControl = createControl(({ sizes, label = (0, import_i18n2.__)("Image", "elementor") }) => {