@elementor/editor-controls 4.2.0-946 → 4.2.0-beta2

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.mjs CHANGED
@@ -779,11 +779,11 @@ function useTypingBuffer(options = {}) {
779
779
  var lengthUnits = ["px", "%", "em", "rem", "vw", "vh", "ch"];
780
780
  var angleUnits = ["deg", "rad", "grad", "turn"];
781
781
  var timeUnits = ["s", "ms"];
782
- var defaultExtendedOptions = ["auto", "custom"];
783
782
  var DEFAULT_UNIT = "px";
784
783
  var DEFAULT_SIZE = NaN;
784
+ var extendedOptions = ["auto", "custom"];
785
785
  function isUnitExtendedOption(unit) {
786
- return defaultExtendedOptions.includes(unit);
786
+ return extendedOptions.includes(unit);
787
787
  }
788
788
 
789
789
  // src/components/size-control/text-field-inner-selection.tsx
@@ -1121,13 +1121,13 @@ var TextFieldPopover = (props) => {
1121
1121
  import { useMemo } from "react";
1122
1122
  function useSizeExtendedOptions(options, disableCustom) {
1123
1123
  return useMemo(() => {
1124
- const extendedOptions = [...options];
1125
- if (!disableCustom && !extendedOptions.includes("custom")) {
1126
- extendedOptions.push("custom");
1124
+ const extendedOptions2 = [...options];
1125
+ if (!disableCustom && !extendedOptions2.includes("custom")) {
1126
+ extendedOptions2.push("custom");
1127
1127
  } else if (options.includes("custom")) {
1128
- extendedOptions.splice(extendedOptions.indexOf("custom"), 1);
1128
+ extendedOptions2.splice(extendedOptions2.indexOf("custom"), 1);
1129
1129
  }
1130
- return extendedOptions;
1130
+ return extendedOptions2;
1131
1131
  }, [options, disableCustom]);
1132
1132
  }
1133
1133
 
@@ -1164,6 +1164,11 @@ var useSyncExternalState = ({
1164
1164
  return [internal, setInternalValue];
1165
1165
  };
1166
1166
 
1167
+ // src/controls/size-control/utils/settings/get-prop-type-settings.ts
1168
+ var getPropTypeSettings = (propType) => {
1169
+ return propType.settings;
1170
+ };
1171
+
1167
1172
  // src/controls/size-control.tsx
1168
1173
  var defaultSelectedUnit = {
1169
1174
  length: "px",
@@ -1184,7 +1189,7 @@ var SizeControl = createControl(
1184
1189
  placeholder,
1185
1190
  startIcon,
1186
1191
  anchorRef,
1187
- extendedOptions,
1192
+ extendedOptions: extendedOptions2,
1188
1193
  disableCustom,
1189
1194
  min = 0,
1190
1195
  enablePropTypeUnits = false,
@@ -1201,7 +1206,7 @@ var SizeControl = createControl(
1201
1206
  } = useBoundProp(sizePropTypeUtil2);
1202
1207
  const actualDefaultUnit = defaultUnit ?? externalPlaceholder?.unit ?? defaultSelectedUnit[variant];
1203
1208
  const activeBreakpoint = useActiveBreakpoint();
1204
- const actualExtendedOptions = useSizeExtendedOptions(extendedOptions || [], disableCustom ?? false);
1209
+ const actualExtendedOptions = useSizeExtendedOptions(extendedOptions2 || [], disableCustom ?? false);
1205
1210
  const actualUnits = resolveUnits(propType, enablePropTypeUnits, variant, units2, actualExtendedOptions);
1206
1211
  const popupState = usePopupState2({ variant: "popover" });
1207
1212
  const memorizedExternalState = useMemo2(
@@ -1290,7 +1295,7 @@ function resolveUnits(propType, enablePropTypeUnits, variant, externalUnits, act
1290
1295
  if (!enablePropTypeUnits) {
1291
1296
  return [...externalUnits ?? fallback, ...actualExtendedOptions || []];
1292
1297
  }
1293
- return propType.settings?.available_units ?? fallback;
1298
+ return getPropTypeSettings(propType)?.available_units ?? fallback;
1294
1299
  }
1295
1300
  function formatSize(size, unit) {
1296
1301
  if (isUnitExtendedOption(unit)) {
@@ -3626,11 +3631,6 @@ var resolvePlaceholder = (placeholder) => {
3626
3631
  return typeof size === "number" ? size.toString() : size;
3627
3632
  };
3628
3633
 
3629
- // src/controls/size-control/utils/settings/get-prop-type-settings.ts
3630
- var getPropTypeSettings = (propType) => {
3631
- return propType.settings;
3632
- };
3633
-
3634
3634
  // src/controls/size-control/utils/settings/get-default-unit.ts
3635
3635
  var getDefaultUnit = (propType) => {
3636
3636
  return getPropTypeSettings(propType)?.default_unit;
@@ -4187,7 +4187,7 @@ var UrlControl = createControl(
4187
4187
 
4188
4188
  // src/controls/link-control.tsx
4189
4189
  import * as React73 from "react";
4190
- import { useEffect as useEffect13, useState as useState12 } from "react";
4190
+ import { useEffect as useEffect14, useState as useState12 } from "react";
4191
4191
  import { getLinkInLinkRestriction } from "@elementor/editor-elements";
4192
4192
  import { linkPropTypeUtil } from "@elementor/editor-props";
4193
4193
  import { __privateUseListenTo as useListenTo, commandEndEvent } from "@elementor/editor-v1-adapters";
@@ -4415,7 +4415,7 @@ function factoryFilter(newValue, options, minInputLength) {
4415
4415
  }
4416
4416
 
4417
4417
  // src/hooks/use-query-autocomplete.ts
4418
- import { useMemo as useMemo9, useState as useState11 } from "react";
4418
+ import { useEffect as useEffect13, useMemo as useMemo9, useState as useState11 } from "react";
4419
4419
  import { numberPropTypeUtil as numberPropTypeUtil2, stringPropTypeUtil as stringPropTypeUtil8 } from "@elementor/editor-props";
4420
4420
  import { httpService as httpService2 } from "@elementor/http-client";
4421
4421
  import { debounce as debounce2 } from "@elementor/utils";
@@ -4439,12 +4439,19 @@ function useQueryAutocomplete({
4439
4439
  ),
4440
4440
  [url, excludeIdSet]
4441
4441
  );
4442
+ useEffect13(() => {
4443
+ if (minInputLength === 0 && url) {
4444
+ fetchOptions(url, { ...params, term: "" }).then((newOptions) => {
4445
+ setOptions(formatOptions(filterExcludedOptions(newOptions, excludeIdSet)));
4446
+ });
4447
+ }
4448
+ }, [url, minInputLength, excludeIdSet, params]);
4442
4449
  const updateOptions = (term) => {
4443
- setOptions([]);
4444
- if (!term || !url || term.length < minInputLength) {
4450
+ const termStr = term ?? "";
4451
+ if (!url || termStr.length < minInputLength) {
4445
4452
  return;
4446
4453
  }
4447
- debounceFetch({ ...params, term });
4454
+ debounceFetch({ ...params, term: termStr });
4448
4455
  };
4449
4456
  return { options, updateOptions };
4450
4457
  }
@@ -4609,7 +4616,7 @@ var LinkControl = createControl((props) => {
4609
4616
  },
4610
4617
  [debouncedCheckRestriction]
4611
4618
  );
4612
- useEffect13(() => {
4619
+ useEffect14(() => {
4613
4620
  debouncedCheckRestriction();
4614
4621
  const handleInlineLinkChanged = () => {
4615
4622
  debouncedCheckRestriction();
@@ -5098,7 +5105,7 @@ var GapControl = ({ label }) => {
5098
5105
  const disabled = sizeDisabled || directionDisabled;
5099
5106
  const propProviderProps = {
5100
5107
  propType,
5101
- value: directionValue ?? (!isLinked ? { row: masterPlaceholder, column: masterPlaceholder } : null),
5108
+ value: directionValue ?? (!isLinked ? { row: directionPlaceholder?.row, column: directionPlaceholder?.column } : null),
5102
5109
  setValue: (directions) => {
5103
5110
  const entries = Object.entries(directions);
5104
5111
  const filtered = entries.filter(([, value]) => Boolean(value));
@@ -5162,7 +5169,7 @@ var Control4 = ({
5162
5169
 
5163
5170
  // src/controls/aspect-ratio-control.tsx
5164
5171
  import * as React79 from "react";
5165
- import { useEffect as useEffect14, useState as useState14 } from "react";
5172
+ import { useEffect as useEffect15, useState as useState14 } from "react";
5166
5173
  import { stringPropTypeUtil as stringPropTypeUtil13 } from "@elementor/editor-props";
5167
5174
  import { MenuListItem as MenuListItem5 } from "@elementor/editor-ui";
5168
5175
  import { ArrowsMoveHorizontalIcon, ArrowsMoveVerticalIcon } from "@elementor/icons";
@@ -5195,7 +5202,7 @@ var AspectRatioControl = createControl(({ label }) => {
5195
5202
  const [selectedValue, setSelectedValue] = useState14(
5196
5203
  isCustomSelected ? CUSTOM_RATIO : aspectRatioValue || ""
5197
5204
  );
5198
- useEffect14(() => {
5205
+ useEffect15(() => {
5199
5206
  const isCustomValue = aspectRatioValue && !RATIO_OPTIONS.some((option) => option.value === aspectRatioValue);
5200
5207
  if (isCustomValue) {
5201
5208
  const [width, height] = aspectRatioValue.split("/");
@@ -7046,7 +7053,7 @@ var TransformBasePopoverTrigger = ({
7046
7053
 
7047
7054
  // src/controls/transition-control/transition-repeater-control.tsx
7048
7055
  import * as React108 from "react";
7049
- import { useEffect as useEffect15, useMemo as useMemo16, useState as useState18 } from "react";
7056
+ import { useEffect as useEffect16, useMemo as useMemo16, useState as useState18 } from "react";
7050
7057
  import {
7051
7058
  createArrayPropUtils as createArrayPropUtils3,
7052
7059
  selectionSizePropTypeUtil as selectionSizePropTypeUtil2
@@ -7612,7 +7619,7 @@ var TransitionRepeaterControl = createControl(
7612
7619
  });
7613
7620
  return set;
7614
7621
  }, [proInstalled]);
7615
- useEffect15(() => {
7622
+ useEffect16(() => {
7616
7623
  if (!value || value.length === 0) {
7617
7624
  return;
7618
7625
  }
@@ -7624,7 +7631,7 @@ var TransitionRepeaterControl = createControl(
7624
7631
  setValue(sanitized);
7625
7632
  }
7626
7633
  }, [allowedTransitionSet]);
7627
- useEffect15(() => {
7634
+ useEffect16(() => {
7628
7635
  recentlyUsedListGetter().then(setRecentlyUsedList);
7629
7636
  }, [recentlyUsedListGetter]);
7630
7637
  const allPropertiesUsed = useMemo16(() => areAllPropertiesUsed(value), [value]);
@@ -7910,14 +7917,14 @@ var BoundTimeStringControl = ({ bind, ariaLabel }) => {
7910
7917
 
7911
7918
  // src/controls/inline-editing-control.tsx
7912
7919
  import * as React115 from "react";
7913
- import { useCallback as useCallback4, useEffect as useEffect17, useMemo as useMemo17 } from "react";
7920
+ import { useCallback as useCallback4, useEffect as useEffect18, useMemo as useMemo17 } from "react";
7914
7921
  import { htmlV3PropTypeUtil, parseHtmlChildren, stringPropTypeUtil as stringPropTypeUtil20 } from "@elementor/editor-props";
7915
7922
  import { Box as Box25 } from "@elementor/ui";
7916
7923
  import { debounce as debounce3 } from "@elementor/utils";
7917
7924
 
7918
7925
  // src/components/inline-editor.tsx
7919
7926
  import * as React114 from "react";
7920
- import { useEffect as useEffect16, useRef as useRef28 } from "react";
7927
+ import { useEffect as useEffect17, useRef as useRef28 } from "react";
7921
7928
  import { Box as Box24 } from "@elementor/ui";
7922
7929
  import Bold from "@tiptap/extension-bold";
7923
7930
  import Document from "@tiptap/extension-document";
@@ -8070,7 +8077,7 @@ var InlineEditor = React114.forwardRef((props, ref) => {
8070
8077
  });
8071
8078
  var useOnUpdate = (callback, dependencies) => {
8072
8079
  const hasMounted = useRef28(false);
8073
- useEffect16(() => {
8080
+ useEffect17(() => {
8074
8081
  if (hasMounted.current) {
8075
8082
  callback();
8076
8083
  } else {
@@ -8110,7 +8117,7 @@ var InlineEditingControl = createControl(
8110
8117
  },
8111
8118
  [setValue, value?.children, debouncedParse]
8112
8119
  );
8113
- useEffect17(() => () => debouncedParse.cancel(), [debouncedParse]);
8120
+ useEffect18(() => () => debouncedParse.cancel(), [debouncedParse]);
8114
8121
  return /* @__PURE__ */ React115.createElement(ControlActions, null, /* @__PURE__ */ React115.createElement(
8115
8122
  Box25,
8116
8123
  {
@@ -8627,7 +8634,7 @@ var ClearIconButton = ({ tooltipText, onClick, disabled, size = "tiny" }) => /*
8627
8634
 
8628
8635
  // src/components/repeater/repeater.tsx
8629
8636
  import * as React126 from "react";
8630
- import { useEffect as useEffect18, useState as useState21 } from "react";
8637
+ import { useEffect as useEffect19, useState as useState21 } from "react";
8631
8638
  import { CopyIcon as CopyIcon2, EyeIcon as EyeIcon2, EyeOffIcon as EyeOffIcon2, PlusIcon as PlusIcon5, XIcon as XIcon4 } from "@elementor/icons";
8632
8639
  import {
8633
8640
  bindPopover as bindPopover8,
@@ -8835,7 +8842,7 @@ var usePopover = (openOnMount, onOpen, onPopoverClose) => {
8835
8842
  const [ref, setRef] = useState21(null);
8836
8843
  const popoverState = usePopupState10({ variant: "popover" });
8837
8844
  const popoverProps = bindPopover8(popoverState);
8838
- useEffect18(() => {
8845
+ useEffect19(() => {
8839
8846
  if (openOnMount && ref) {
8840
8847
  popoverState.open(ref);
8841
8848
  onOpen?.();
@@ -8855,7 +8862,7 @@ var usePopover = (openOnMount, onOpen, onPopoverClose) => {
8855
8862
 
8856
8863
  // src/components/inline-editor-toolbar.tsx
8857
8864
  import * as React128 from "react";
8858
- import { useEffect as useEffect20, useMemo as useMemo18, useRef as useRef32, useState as useState22 } from "react";
8865
+ import { useEffect as useEffect21, useMemo as useMemo18, useRef as useRef32, useState as useState22 } from "react";
8859
8866
  import { getContainer as getContainer3, getElementSetting } from "@elementor/editor-elements";
8860
8867
  import {
8861
8868
  BoldIcon,
@@ -8881,7 +8888,7 @@ import { __ as __64 } from "@wordpress/i18n";
8881
8888
 
8882
8889
  // src/components/url-popover.tsx
8883
8890
  import * as React127 from "react";
8884
- import { useEffect as useEffect19, useRef as useRef31 } from "react";
8891
+ import { useEffect as useEffect20, useRef as useRef31 } from "react";
8885
8892
  import { ExternalLinkIcon } from "@elementor/icons";
8886
8893
  import { bindPopover as bindPopover9, Popover as Popover8, Stack as Stack23, TextField as TextField13, ToggleButton as ToggleButton2, Tooltip as Tooltip13 } from "@elementor/ui";
8887
8894
  import { __ as __63 } from "@wordpress/i18n";
@@ -8895,7 +8902,7 @@ var UrlPopover = ({
8895
8902
  onToggleNewTab
8896
8903
  }) => {
8897
8904
  const inputRef = useRef31(null);
8898
- useEffect19(() => {
8905
+ useEffect20(() => {
8899
8906
  if (popupState.isOpen) {
8900
8907
  requestAnimationFrame(() => inputRef.current?.focus());
8901
8908
  }
@@ -8991,7 +8998,7 @@ var InlineEditorToolbar = ({ editor, elementId, sx = {} }) => {
8991
8998
  }
8992
8999
  linkPopupState.close();
8993
9000
  };
8994
- useEffect20(() => {
9001
+ useEffect21(() => {
8995
9002
  editor?.commands?.focus();
8996
9003
  }, [editor]);
8997
9004
  return /* @__PURE__ */ React128.createElement(