@elementor/editor-controls 3.33.0-269 → 3.33.0-270

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
@@ -1031,13 +1031,16 @@ var SizeControl = createControl(
1031
1031
  propType
1032
1032
  } = useBoundProp(import_editor_props7.sizePropTypeUtil);
1033
1033
  const actualDefaultUnit = defaultUnit ?? externalPlaceholder?.unit ?? defaultSelectedUnit[variant];
1034
- const [internalState, setInternalState] = (0, import_react13.useState)(createStateFromSizeProp(sizeValue, actualDefaultUnit));
1035
1034
  const activeBreakpoint = (0, import_editor_responsive.useActiveBreakpoint)();
1036
1035
  const actualUnits = resolveUnits(propType, enablePropTypeUnits, variant, units2);
1037
1036
  const actualExtendedOptions = useSizeExtendedOptions(extendedOptions || [], disableCustom ?? false);
1038
1037
  const popupState = (0, import_ui13.usePopupState)({ variant: "popover" });
1038
+ const memorizedExternalState = (0, import_react13.useMemo)(
1039
+ () => createStateFromSizeProp(sizeValue, actualDefaultUnit),
1040
+ [sizeValue, actualDefaultUnit]
1041
+ );
1039
1042
  const [state, setState] = useSyncExternalState({
1040
- external: internalState,
1043
+ external: memorizedExternalState,
1041
1044
  setExternal: (newState, options, meta) => setSizeValue(extractValueFromState(newState), options, meta),
1042
1045
  persistWhen: (newState) => !!extractValueFromState(newState),
1043
1046
  fallback: (newState) => ({
@@ -1092,7 +1095,7 @@ var SizeControl = createControl(
1092
1095
  return;
1093
1096
  }
1094
1097
  if (state.unit === newState.unit) {
1095
- setInternalState(mergedStates);
1098
+ setState(mergedStates);
1096
1099
  return;
1097
1100
  }
1098
1101
  setState(newState);
@@ -1171,11 +1174,15 @@ function extractValueFromState(state, allowEmpty = false) {
1171
1174
  if (unit === "auto") {
1172
1175
  return { size: "", unit };
1173
1176
  }
1174
- if (!allowEmpty && (unit === "custom" && !state.custom || unit !== "custom" && !state.numeric && state.numeric !== 0)) {
1177
+ if (unit === "custom") {
1178
+ return { size: state.custom ?? "", unit: "custom" };
1179
+ }
1180
+ const numeric = state.numeric;
1181
+ if (!allowEmpty && (numeric === void 0 || numeric === null || Number.isNaN(numeric))) {
1175
1182
  return null;
1176
1183
  }
1177
1184
  return {
1178
- size: state[unit === "custom" ? "custom" : "numeric"],
1185
+ size: numeric,
1179
1186
  unit
1180
1187
  };
1181
1188
  }