@elementor/editor-controls 4.1.0-758 → 4.1.0-760
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 +112 -79
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +88 -54
- package/dist/index.mjs.map +1 -1
- package/package.json +15 -15
- package/src/components/repeater/repeater.tsx +24 -16
- 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,12 +7607,13 @@ 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,
|
|
7585
7614
|
bindTrigger as bindTrigger7,
|
|
7586
7615
|
Box as Box27,
|
|
7616
|
+
ClickAwayListener,
|
|
7587
7617
|
IconButton as IconButton10,
|
|
7588
7618
|
Infotip as Infotip4,
|
|
7589
7619
|
Tooltip as Tooltip12,
|
|
@@ -7607,7 +7637,7 @@ var Repeater3 = ({
|
|
|
7607
7637
|
openItem: initialOpenItem = EMPTY_OPEN_ITEM2,
|
|
7608
7638
|
isSortable = true
|
|
7609
7639
|
}) => {
|
|
7610
|
-
const [openItem, setOpenItem] =
|
|
7640
|
+
const [openItem, setOpenItem] = useState19(initialOpenItem);
|
|
7611
7641
|
const uniqueKeys = items2.map(
|
|
7612
7642
|
(item, index) => isSortable && "getId" in itemSettings ? itemSettings.getId({ item, index }) : String(index)
|
|
7613
7643
|
);
|
|
@@ -7749,10 +7779,14 @@ var RepeaterItem = ({
|
|
|
7749
7779
|
actions,
|
|
7750
7780
|
value
|
|
7751
7781
|
}) => {
|
|
7752
|
-
const { popoverState, popoverProps, ref, setRef } = usePopover(
|
|
7753
|
-
|
|
7754
|
-
|
|
7755
|
-
|
|
7782
|
+
const { popoverState, popoverProps, ref, setRef } = usePopover(
|
|
7783
|
+
openOnMount,
|
|
7784
|
+
() => {
|
|
7785
|
+
onOpen();
|
|
7786
|
+
onPopoverOpen?.(value);
|
|
7787
|
+
},
|
|
7788
|
+
onPopoverClose
|
|
7789
|
+
);
|
|
7756
7790
|
const triggerProps = bindTrigger7(popoverState);
|
|
7757
7791
|
const duplicateLabel = __55("Duplicate", "elementor");
|
|
7758
7792
|
const toggleLabel = propDisabled ? __55("Show", "elementor") : __55("Hide", "elementor");
|
|
@@ -7774,41 +7808,41 @@ var RepeaterItem = ({
|
|
|
7774
7808
|
startIcon,
|
|
7775
7809
|
actions: /* @__PURE__ */ React113.createElement(React113.Fragment, null, showDuplicate && /* @__PURE__ */ React113.createElement(Tooltip12, { title: duplicateLabel, placement: "top" }, /* @__PURE__ */ React113.createElement(IconButton10, { size: SIZE11, onClick: duplicateItem, "aria-label": duplicateLabel }, /* @__PURE__ */ React113.createElement(CopyIcon2, { fontSize: SIZE11 }))), showToggle && /* @__PURE__ */ React113.createElement(Tooltip12, { title: toggleLabel, placement: "top" }, /* @__PURE__ */ React113.createElement(IconButton10, { size: SIZE11, onClick: toggleDisableItem, "aria-label": toggleLabel }, propDisabled ? /* @__PURE__ */ React113.createElement(EyeOffIcon2, { fontSize: SIZE11 }) : /* @__PURE__ */ React113.createElement(EyeIcon2, { fontSize: SIZE11 }))), actions?.(value), showRemove && /* @__PURE__ */ React113.createElement(Tooltip12, { title: removeLabel, placement: "top" }, /* @__PURE__ */ React113.createElement(IconButton10, { size: SIZE11, onClick: removeItem, "aria-label": removeLabel }, /* @__PURE__ */ React113.createElement(XIcon4, { fontSize: SIZE11 }))))
|
|
7776
7810
|
}
|
|
7777
|
-
), /* @__PURE__ */ React113.createElement(
|
|
7778
|
-
|
|
7811
|
+
), /* @__PURE__ */ React113.createElement(RepeaterPopover, { width: ref?.getBoundingClientRect().width, ...popoverProps, anchorEl: ref }, /* @__PURE__ */ React113.createElement(
|
|
7812
|
+
ClickAwayListener,
|
|
7779
7813
|
{
|
|
7780
|
-
|
|
7781
|
-
|
|
7782
|
-
|
|
7783
|
-
popoverProps.onClose?.();
|
|
7784
|
-
onPopoverClose?.();
|
|
7785
|
-
},
|
|
7786
|
-
anchorEl: ref
|
|
7814
|
+
mouseEvent: "onMouseDown",
|
|
7815
|
+
touchEvent: "onTouchStart",
|
|
7816
|
+
onClickAway: popoverProps.onClose
|
|
7787
7817
|
},
|
|
7788
7818
|
/* @__PURE__ */ React113.createElement(Box27, null, children({ anchorEl: ref }))
|
|
7789
|
-
));
|
|
7819
|
+
)));
|
|
7790
7820
|
};
|
|
7791
|
-
var usePopover = (openOnMount, onOpen) => {
|
|
7792
|
-
const [ref, setRef] =
|
|
7821
|
+
var usePopover = (openOnMount, onOpen, onPopoverClose) => {
|
|
7822
|
+
const [ref, setRef] = useState19(null);
|
|
7793
7823
|
const popoverState = usePopupState10({ variant: "popover" });
|
|
7794
7824
|
const popoverProps = bindPopover8(popoverState);
|
|
7795
|
-
|
|
7825
|
+
useEffect17(() => {
|
|
7796
7826
|
if (openOnMount && ref) {
|
|
7797
7827
|
popoverState.open(ref);
|
|
7798
7828
|
onOpen?.();
|
|
7799
7829
|
}
|
|
7800
7830
|
}, [ref]);
|
|
7831
|
+
const onClose = () => {
|
|
7832
|
+
popoverProps.onClose?.();
|
|
7833
|
+
onPopoverClose?.();
|
|
7834
|
+
};
|
|
7801
7835
|
return {
|
|
7802
7836
|
popoverState,
|
|
7803
7837
|
ref,
|
|
7804
7838
|
setRef,
|
|
7805
|
-
popoverProps
|
|
7839
|
+
popoverProps: { ...popoverProps, onClose }
|
|
7806
7840
|
};
|
|
7807
7841
|
};
|
|
7808
7842
|
|
|
7809
7843
|
// src/components/inline-editor-toolbar.tsx
|
|
7810
7844
|
import * as React115 from "react";
|
|
7811
|
-
import { useEffect as
|
|
7845
|
+
import { useEffect as useEffect19, useMemo as useMemo16, useRef as useRef29, useState as useState20 } from "react";
|
|
7812
7846
|
import { getContainer, getElementSetting } from "@elementor/editor-elements";
|
|
7813
7847
|
import {
|
|
7814
7848
|
BoldIcon,
|
|
@@ -7834,7 +7868,7 @@ import { __ as __57 } from "@wordpress/i18n";
|
|
|
7834
7868
|
|
|
7835
7869
|
// src/components/url-popover.tsx
|
|
7836
7870
|
import * as React114 from "react";
|
|
7837
|
-
import { useEffect as
|
|
7871
|
+
import { useEffect as useEffect18, useRef as useRef28 } from "react";
|
|
7838
7872
|
import { ExternalLinkIcon } from "@elementor/icons";
|
|
7839
7873
|
import { bindPopover as bindPopover9, Popover as Popover8, Stack as Stack20, TextField as TextField10, ToggleButton as ToggleButton2, Tooltip as Tooltip13 } from "@elementor/ui";
|
|
7840
7874
|
import { __ as __56 } from "@wordpress/i18n";
|
|
@@ -7848,7 +7882,7 @@ var UrlPopover = ({
|
|
|
7848
7882
|
onToggleNewTab
|
|
7849
7883
|
}) => {
|
|
7850
7884
|
const inputRef = useRef28(null);
|
|
7851
|
-
|
|
7885
|
+
useEffect18(() => {
|
|
7852
7886
|
if (popupState.isOpen) {
|
|
7853
7887
|
requestAnimationFrame(() => inputRef.current?.focus());
|
|
7854
7888
|
}
|
|
@@ -7898,8 +7932,8 @@ var UrlPopover = ({
|
|
|
7898
7932
|
|
|
7899
7933
|
// src/components/inline-editor-toolbar.tsx
|
|
7900
7934
|
var InlineEditorToolbar = ({ editor, elementId, sx = {} }) => {
|
|
7901
|
-
const [urlValue, setUrlValue] =
|
|
7902
|
-
const [openInNewTab, setOpenInNewTab] =
|
|
7935
|
+
const [urlValue, setUrlValue] = useState20("");
|
|
7936
|
+
const [openInNewTab, setOpenInNewTab] = useState20(false);
|
|
7903
7937
|
const toolbarRef = useRef29(null);
|
|
7904
7938
|
const linkPopupState = usePopupState11({ variant: "popover" });
|
|
7905
7939
|
const isElementClickable = elementId ? checkIfElementIsClickable(elementId) : false;
|
|
@@ -7944,7 +7978,7 @@ var InlineEditorToolbar = ({ editor, elementId, sx = {} }) => {
|
|
|
7944
7978
|
}
|
|
7945
7979
|
linkPopupState.close();
|
|
7946
7980
|
};
|
|
7947
|
-
|
|
7981
|
+
useEffect19(() => {
|
|
7948
7982
|
editor?.commands?.focus();
|
|
7949
7983
|
}, [editor]);
|
|
7950
7984
|
return /* @__PURE__ */ React115.createElement(
|