@elementor/editor-controls 4.3.0-994 → 4.3.0-996

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
@@ -2625,27 +2625,16 @@ function ChipsList({ getLabel, getTagProps, values }) {
2625
2625
  // src/controls/chips-control.tsx
2626
2626
  var SIZE6 = "tiny";
2627
2627
  var toChipsOption = (val, options) => options.find((opt) => opt.value === val) ?? { label: val, value: val };
2628
- var optionValue = (option) => {
2629
- if ("string" === typeof option) {
2630
- return option;
2631
- }
2632
- return "string" === typeof option?.value ? option.value : "";
2633
- };
2634
- var optionLabel = (option) => {
2635
- if ("string" === typeof option) {
2636
- return option;
2637
- }
2638
- if ("string" === typeof option?.label) {
2639
- return option.label;
2640
- }
2641
- return optionValue(option);
2642
- };
2643
2628
  var ChipsControl = createControl(({ options, freeChips }) => {
2644
2629
  const { value, setValue, disabled } = useBoundProp(import_editor_props17.stringArrayPropTypeUtil);
2645
- const selectedValues = (value || []).map((item) => import_editor_props17.stringPropTypeUtil.extract(item)).filter((val) => "string" === typeof val);
2630
+ const selectedValues = (value || []).map((item) => import_editor_props17.stringPropTypeUtil.extract(item)).filter((val) => val !== null);
2646
2631
  const selectedOptions = selectedValues.map((val) => toChipsOption(val, options));
2647
2632
  const handleChange = (_, newValue) => {
2648
- setValue(newValue.map((option) => import_editor_props17.stringPropTypeUtil.create(optionValue(option))));
2633
+ setValue(
2634
+ newValue.map(
2635
+ (option) => import_editor_props17.stringPropTypeUtil.create(typeof option === "string" ? option : option.value)
2636
+ )
2637
+ );
2649
2638
  };
2650
2639
  return /* @__PURE__ */ React52.createElement(ControlActions, null, /* @__PURE__ */ React52.createElement(
2651
2640
  import_ui39.Autocomplete,
@@ -2659,10 +2648,17 @@ var ChipsControl = createControl(({ options, freeChips }) => {
2659
2648
  filterSelectedOptions: true,
2660
2649
  onChange: handleChange,
2661
2650
  options,
2662
- getOptionLabel: optionLabel,
2663
- isOptionEqualToValue: (option, val) => optionValue(option) === optionValue(val),
2651
+ getOptionLabel: (option) => typeof option === "string" ? option : option.label,
2652
+ isOptionEqualToValue: (option, val) => option.value === val.value,
2664
2653
  renderInput: (params) => /* @__PURE__ */ React52.createElement(import_ui39.TextField, { ...params }),
2665
- renderTags: (tagValues, getTagProps) => /* @__PURE__ */ React52.createElement(ChipsList, { getLabel: optionLabel, getTagProps, values: tagValues })
2654
+ renderTags: (tagValues, getTagProps) => /* @__PURE__ */ React52.createElement(
2655
+ ChipsList,
2656
+ {
2657
+ getLabel: (option) => typeof option === "string" ? option : option.label,
2658
+ getTagProps,
2659
+ values: tagValues
2660
+ }
2661
+ )
2666
2662
  }
2667
2663
  ));
2668
2664
  });
@@ -5322,7 +5318,7 @@ var AspectRatioControl = createControl(({ label }) => {
5322
5318
  fullWidth: true
5323
5319
  },
5324
5320
  [...RATIO_OPTIONS, { label: (0, import_i18n30.__)("Custom", "elementor"), value: CUSTOM_RATIO }].map(
5325
- ({ label: optionLabel2, ...props }) => /* @__PURE__ */ React79.createElement(import_editor_ui10.MenuListItem, { key: props.value, ...props, value: props.value ?? "" }, optionLabel2)
5321
+ ({ label: optionLabel, ...props }) => /* @__PURE__ */ React79.createElement(import_editor_ui10.MenuListItem, { key: props.value, ...props, value: props.value ?? "" }, optionLabel)
5326
5322
  )
5327
5323
  ))), isCustom && /* @__PURE__ */ React79.createElement(import_ui62.Grid, { container: true, gap: 2, alignItems: "center", flexWrap: "nowrap" }, /* @__PURE__ */ React79.createElement(import_ui62.Grid, { item: true, xs: 6 }, /* @__PURE__ */ React79.createElement(
5328
5324
  import_ui62.TextField,