@elementor/editor-controls 4.1.0-757 → 4.1.0-759
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.d.mts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +92 -63
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +67 -38
- package/dist/index.mjs.map +1 -1
- package/package.json +15 -15
- package/src/controls/size-control/hooks/use-size-value.ts +18 -8
- package/src/controls/size-control/hooks/use-unit-sync.ts +28 -0
- package/src/controls/size-control/unstable-size-control.tsx +1 -1
- package/src/controls/size-control/utils/resolve-bound-prop-value.ts +31 -27
package/dist/index.mjs
CHANGED
|
@@ -6830,7 +6830,7 @@ import { sizePropTypeUtil as sizePropTypeUtil6 } from "@elementor/editor-props";
|
|
|
6830
6830
|
|
|
6831
6831
|
// src/controls/size-control/size-component.tsx
|
|
6832
6832
|
import * as React107 from "react";
|
|
6833
|
-
import { useEffect as
|
|
6833
|
+
import { useEffect as useEffect16 } from "react";
|
|
6834
6834
|
import { useActiveBreakpoint as useActiveBreakpoint4 } from "@elementor/editor-responsive";
|
|
6835
6835
|
import { Box as Box25, usePopupState as usePopupState9 } from "@elementor/ui";
|
|
6836
6836
|
|
|
@@ -6952,6 +6952,24 @@ var sanitizeSize = (size) => {
|
|
|
6952
6952
|
return size;
|
|
6953
6953
|
};
|
|
6954
6954
|
|
|
6955
|
+
// src/controls/size-control/hooks/use-unit-sync.ts
|
|
6956
|
+
import { useEffect as useEffect14, useState as useState17 } from "react";
|
|
6957
|
+
var useUnitSync = ({ unit, setUnit, persistWhen }) => {
|
|
6958
|
+
const [state, setState] = useState17(unit);
|
|
6959
|
+
useEffect14(() => {
|
|
6960
|
+
if (unit !== state) {
|
|
6961
|
+
setState(unit);
|
|
6962
|
+
}
|
|
6963
|
+
}, [unit]);
|
|
6964
|
+
const setInternalValue = (newUnit) => {
|
|
6965
|
+
setState(newUnit);
|
|
6966
|
+
if (persistWhen()) {
|
|
6967
|
+
setUnit(newUnit);
|
|
6968
|
+
}
|
|
6969
|
+
};
|
|
6970
|
+
return [state, setInternalValue];
|
|
6971
|
+
};
|
|
6972
|
+
|
|
6955
6973
|
// src/controls/size-control/hooks/use-size-value.ts
|
|
6956
6974
|
var useSizeValue = ({
|
|
6957
6975
|
value,
|
|
@@ -6974,25 +6992,34 @@ var useSizeValue = ({
|
|
|
6974
6992
|
persistWhen: (next) => hasChanged(next, resolvedValue),
|
|
6975
6993
|
fallback: () => createDefaultSizeValue(units2, defaultUnit)
|
|
6976
6994
|
});
|
|
6995
|
+
const [unit, setUnit] = useUnitSync({
|
|
6996
|
+
unit: sizeValue?.unit,
|
|
6997
|
+
setUnit: (newUnit) => {
|
|
6998
|
+
setSizeValue({
|
|
6999
|
+
unit: newUnit,
|
|
7000
|
+
size: resolveSizeOnUnitChange(sizeValue.size, newUnit)
|
|
7001
|
+
});
|
|
7002
|
+
},
|
|
7003
|
+
persistWhen: () => {
|
|
7004
|
+
return Boolean(sizeValue.size) || sizeValue.size !== "";
|
|
7005
|
+
}
|
|
7006
|
+
});
|
|
6977
7007
|
const setSize = (newSize, isInputValid = true) => {
|
|
6978
|
-
if (isExtendedUnit(
|
|
7008
|
+
if (isExtendedUnit(unit)) {
|
|
6979
7009
|
return;
|
|
6980
7010
|
}
|
|
6981
7011
|
const trimmed = newSize.trim();
|
|
6982
7012
|
const parsed = Number(trimmed);
|
|
6983
7013
|
const newState = {
|
|
6984
|
-
|
|
7014
|
+
unit,
|
|
6985
7015
|
size: trimmed && !isNaN(parsed) ? parsed : ""
|
|
6986
7016
|
};
|
|
6987
7017
|
setSizeValue(newState, void 0, { validation: () => isInputValid });
|
|
6988
7018
|
};
|
|
6989
|
-
const setUnit = (unit) => {
|
|
6990
|
-
setSizeValue({ unit, size: resolveSizeOnUnitChange(sizeValue.size, unit) });
|
|
6991
|
-
};
|
|
6992
7019
|
return {
|
|
6993
7020
|
size: sizeValue.size,
|
|
6994
|
-
unit: sizeValue.unit,
|
|
6995
7021
|
setSize,
|
|
7022
|
+
unit,
|
|
6996
7023
|
setUnit
|
|
6997
7024
|
};
|
|
6998
7025
|
};
|
|
@@ -7191,7 +7218,7 @@ var shouldHighlightUnit = (value) => {
|
|
|
7191
7218
|
|
|
7192
7219
|
// src/controls/size-control/ui/text-field-popover.tsx
|
|
7193
7220
|
import * as React106 from "react";
|
|
7194
|
-
import { useEffect as
|
|
7221
|
+
import { useEffect as useEffect15, useRef as useRef25 } from "react";
|
|
7195
7222
|
import { PopoverHeader as PopoverHeader4 } from "@elementor/editor-ui";
|
|
7196
7223
|
import { MathFunctionIcon as MathFunctionIcon4 } from "@elementor/icons";
|
|
7197
7224
|
import { bindPopover as bindPopover7, Popover as Popover7, TextField as TextField9 } from "@elementor/ui";
|
|
@@ -7199,7 +7226,7 @@ import { __ as __52 } from "@wordpress/i18n";
|
|
|
7199
7226
|
var SIZE10 = "tiny";
|
|
7200
7227
|
var TextFieldPopover2 = ({ popupState, anchorRef, value, onChange, onClose }) => {
|
|
7201
7228
|
const inputRef = useRef25(null);
|
|
7202
|
-
|
|
7229
|
+
useEffect15(() => {
|
|
7203
7230
|
if (popupState.isOpen) {
|
|
7204
7231
|
requestAnimationFrame(() => {
|
|
7205
7232
|
if (inputRef.current) {
|
|
@@ -7266,7 +7293,7 @@ var SizeComponent = ({ anchorRef, SizeFieldWrapper = React107.Fragment, ...sizeF
|
|
|
7266
7293
|
const activeBreakpoint = useActiveBreakpoint4();
|
|
7267
7294
|
const isCustomUnit = sizeFieldProps?.value?.unit === EXTENDED_UNITS.custom;
|
|
7268
7295
|
const hasCustomUnitOption = sizeFieldProps.units.includes(EXTENDED_UNITS.custom);
|
|
7269
|
-
|
|
7296
|
+
useEffect16(() => {
|
|
7270
7297
|
if (popupState && popupState.isOpen) {
|
|
7271
7298
|
popupState.close();
|
|
7272
7299
|
}
|
|
@@ -7321,36 +7348,38 @@ var SizeComponent = ({ anchorRef, SizeFieldWrapper = React107.Fragment, ...sizeF
|
|
|
7321
7348
|
// src/controls/size-control/utils/resolve-bound-prop-value.ts
|
|
7322
7349
|
import { sizePropTypeUtil as sizePropTypeUtil5 } from "@elementor/editor-props";
|
|
7323
7350
|
var resolveBoundPropValue = (value, boundPropPlaceholder, propPlaceholder) => {
|
|
7324
|
-
|
|
7325
|
-
|
|
7326
|
-
|
|
7327
|
-
|
|
7328
|
-
|
|
7329
|
-
|
|
7351
|
+
const sizeValue = pickFirstValid([
|
|
7352
|
+
{ candidate: value, resolve: (v) => v },
|
|
7353
|
+
{ candidate: propPlaceholder, resolve: toUnitPlaceholder },
|
|
7354
|
+
{ candidate: boundPropPlaceholder, resolve: toUnitPlaceholder }
|
|
7355
|
+
]);
|
|
7356
|
+
const placeholderSource = propPlaceholder ?? boundPropPlaceholder;
|
|
7330
7357
|
return {
|
|
7331
7358
|
sizeValue,
|
|
7332
|
-
placeholder: resolvePlaceholder(
|
|
7359
|
+
placeholder: resolvePlaceholder(placeholderSource)
|
|
7333
7360
|
};
|
|
7334
7361
|
};
|
|
7362
|
+
var toUnitPlaceholder = (v) => ({ ...v, size: "" });
|
|
7363
|
+
var pickFirstValid = (candidates) => {
|
|
7364
|
+
const found = candidates.find(({ candidate }) => validateSizeValue(candidate));
|
|
7365
|
+
return found ? found.resolve(found.candidate) : null;
|
|
7366
|
+
};
|
|
7335
7367
|
var validateSizeValue = (value) => {
|
|
7336
|
-
if (!value) {
|
|
7368
|
+
if (!value || typeof value !== "object") {
|
|
7337
7369
|
return false;
|
|
7338
7370
|
}
|
|
7339
7371
|
const sizePropValue = sizePropTypeUtil5.create(value);
|
|
7340
7372
|
return sizePropTypeUtil5.isValid(sizePropValue);
|
|
7341
7373
|
};
|
|
7342
|
-
var resolvePlaceholder = (
|
|
7343
|
-
if (
|
|
7344
|
-
return
|
|
7374
|
+
var resolvePlaceholder = (placeholder) => {
|
|
7375
|
+
if (typeof placeholder === "string") {
|
|
7376
|
+
return placeholder;
|
|
7345
7377
|
}
|
|
7346
|
-
const size =
|
|
7378
|
+
const size = placeholder?.size;
|
|
7347
7379
|
if (size === void 0) {
|
|
7348
7380
|
return void 0;
|
|
7349
7381
|
}
|
|
7350
|
-
|
|
7351
|
-
return size.toString();
|
|
7352
|
-
}
|
|
7353
|
-
return size;
|
|
7382
|
+
return typeof size === "number" ? size.toString() : size;
|
|
7354
7383
|
};
|
|
7355
7384
|
|
|
7356
7385
|
// src/controls/size-control/utils/settings/get-prop-type-settings.ts
|
|
@@ -7450,7 +7479,7 @@ import { __ as __53 } from "@wordpress/i18n";
|
|
|
7450
7479
|
|
|
7451
7480
|
// src/components/promotions/promotion-trigger.tsx
|
|
7452
7481
|
import * as React109 from "react";
|
|
7453
|
-
import { forwardRef as forwardRef12, useCallback as useCallback4, useImperativeHandle, useState as
|
|
7482
|
+
import { forwardRef as forwardRef12, useCallback as useCallback4, useImperativeHandle, useState as useState18 } from "react";
|
|
7454
7483
|
import { PromotionChip as PromotionChip2, PromotionInfotip } from "@elementor/editor-ui";
|
|
7455
7484
|
import { Box as Box26 } from "@elementor/ui";
|
|
7456
7485
|
function getV4Promotion(key) {
|
|
@@ -7458,7 +7487,7 @@ function getV4Promotion(key) {
|
|
|
7458
7487
|
}
|
|
7459
7488
|
var PromotionTrigger = forwardRef12(
|
|
7460
7489
|
({ promotionKey, children, trackingData }, ref) => {
|
|
7461
|
-
const [isOpen, setIsOpen] =
|
|
7490
|
+
const [isOpen, setIsOpen] = useState18(false);
|
|
7462
7491
|
const promotion = getV4Promotion(promotionKey);
|
|
7463
7492
|
const toggle = useCallback4(() => {
|
|
7464
7493
|
setIsOpen((prev) => {
|
|
@@ -7578,7 +7607,7 @@ var ClearIconButton = ({ tooltipText, onClick, disabled, size = "tiny" }) => /*
|
|
|
7578
7607
|
|
|
7579
7608
|
// src/components/repeater/repeater.tsx
|
|
7580
7609
|
import * as React113 from "react";
|
|
7581
|
-
import { useEffect as
|
|
7610
|
+
import { useEffect as useEffect17, useState as useState19 } from "react";
|
|
7582
7611
|
import { CopyIcon as CopyIcon2, EyeIcon as EyeIcon2, EyeOffIcon as EyeOffIcon2, PlusIcon as PlusIcon4, XIcon as XIcon4 } from "@elementor/icons";
|
|
7583
7612
|
import {
|
|
7584
7613
|
bindPopover as bindPopover8,
|
|
@@ -7607,7 +7636,7 @@ var Repeater3 = ({
|
|
|
7607
7636
|
openItem: initialOpenItem = EMPTY_OPEN_ITEM2,
|
|
7608
7637
|
isSortable = true
|
|
7609
7638
|
}) => {
|
|
7610
|
-
const [openItem, setOpenItem] =
|
|
7639
|
+
const [openItem, setOpenItem] = useState19(initialOpenItem);
|
|
7611
7640
|
const uniqueKeys = items2.map(
|
|
7612
7641
|
(item, index) => isSortable && "getId" in itemSettings ? itemSettings.getId({ item, index }) : String(index)
|
|
7613
7642
|
);
|
|
@@ -7789,10 +7818,10 @@ var RepeaterItem = ({
|
|
|
7789
7818
|
));
|
|
7790
7819
|
};
|
|
7791
7820
|
var usePopover = (openOnMount, onOpen) => {
|
|
7792
|
-
const [ref, setRef] =
|
|
7821
|
+
const [ref, setRef] = useState19(null);
|
|
7793
7822
|
const popoverState = usePopupState10({ variant: "popover" });
|
|
7794
7823
|
const popoverProps = bindPopover8(popoverState);
|
|
7795
|
-
|
|
7824
|
+
useEffect17(() => {
|
|
7796
7825
|
if (openOnMount && ref) {
|
|
7797
7826
|
popoverState.open(ref);
|
|
7798
7827
|
onOpen?.();
|
|
@@ -7808,7 +7837,7 @@ var usePopover = (openOnMount, onOpen) => {
|
|
|
7808
7837
|
|
|
7809
7838
|
// src/components/inline-editor-toolbar.tsx
|
|
7810
7839
|
import * as React115 from "react";
|
|
7811
|
-
import { useEffect as
|
|
7840
|
+
import { useEffect as useEffect19, useMemo as useMemo16, useRef as useRef29, useState as useState20 } from "react";
|
|
7812
7841
|
import { getContainer, getElementSetting } from "@elementor/editor-elements";
|
|
7813
7842
|
import {
|
|
7814
7843
|
BoldIcon,
|
|
@@ -7834,7 +7863,7 @@ import { __ as __57 } from "@wordpress/i18n";
|
|
|
7834
7863
|
|
|
7835
7864
|
// src/components/url-popover.tsx
|
|
7836
7865
|
import * as React114 from "react";
|
|
7837
|
-
import { useEffect as
|
|
7866
|
+
import { useEffect as useEffect18, useRef as useRef28 } from "react";
|
|
7838
7867
|
import { ExternalLinkIcon } from "@elementor/icons";
|
|
7839
7868
|
import { bindPopover as bindPopover9, Popover as Popover8, Stack as Stack20, TextField as TextField10, ToggleButton as ToggleButton2, Tooltip as Tooltip13 } from "@elementor/ui";
|
|
7840
7869
|
import { __ as __56 } from "@wordpress/i18n";
|
|
@@ -7848,7 +7877,7 @@ var UrlPopover = ({
|
|
|
7848
7877
|
onToggleNewTab
|
|
7849
7878
|
}) => {
|
|
7850
7879
|
const inputRef = useRef28(null);
|
|
7851
|
-
|
|
7880
|
+
useEffect18(() => {
|
|
7852
7881
|
if (popupState.isOpen) {
|
|
7853
7882
|
requestAnimationFrame(() => inputRef.current?.focus());
|
|
7854
7883
|
}
|
|
@@ -7898,8 +7927,8 @@ var UrlPopover = ({
|
|
|
7898
7927
|
|
|
7899
7928
|
// src/components/inline-editor-toolbar.tsx
|
|
7900
7929
|
var InlineEditorToolbar = ({ editor, elementId, sx = {} }) => {
|
|
7901
|
-
const [urlValue, setUrlValue] =
|
|
7902
|
-
const [openInNewTab, setOpenInNewTab] =
|
|
7930
|
+
const [urlValue, setUrlValue] = useState20("");
|
|
7931
|
+
const [openInNewTab, setOpenInNewTab] = useState20(false);
|
|
7903
7932
|
const toolbarRef = useRef29(null);
|
|
7904
7933
|
const linkPopupState = usePopupState11({ variant: "popover" });
|
|
7905
7934
|
const isElementClickable = elementId ? checkIfElementIsClickable(elementId) : false;
|
|
@@ -7944,7 +7973,7 @@ var InlineEditorToolbar = ({ editor, elementId, sx = {} }) => {
|
|
|
7944
7973
|
}
|
|
7945
7974
|
linkPopupState.close();
|
|
7946
7975
|
};
|
|
7947
|
-
|
|
7976
|
+
useEffect19(() => {
|
|
7948
7977
|
editor?.commands?.focus();
|
|
7949
7978
|
}, [editor]);
|
|
7950
7979
|
return /* @__PURE__ */ React115.createElement(
|