@elementor/editor-controls 0.30.0 → 0.31.0
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/CHANGELOG.md +24 -0
- package/dist/index.d.mts +2 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js +104 -71
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +75 -42
- package/dist/index.mjs.map +1 -1
- package/package.json +6 -5
- package/src/components/text-field-inner-selection.tsx +3 -0
- package/src/controls/background-control/background-control.tsx +10 -1
- package/src/controls/background-control/background-overlay/background-overlay-repeater-control.tsx +6 -6
- package/src/controls/box-shadow-repeater-control.tsx +1 -15
- package/src/controls/color-control.tsx +34 -11
- package/src/controls/size-control.tsx +31 -1
package/dist/index.mjs
CHANGED
|
@@ -433,6 +433,7 @@ var TextAreaControl = createControl(({ placeholder }) => {
|
|
|
433
433
|
|
|
434
434
|
// src/controls/size-control.tsx
|
|
435
435
|
import * as React14 from "react";
|
|
436
|
+
import { useRef } from "react";
|
|
436
437
|
import { sizePropTypeUtil, stringPropTypeUtil as stringPropTypeUtil4 } from "@elementor/editor-props";
|
|
437
438
|
import { InputAdornment as InputAdornment2 } from "@elementor/ui";
|
|
438
439
|
|
|
@@ -449,6 +450,7 @@ var TextFieldInnerSelection = forwardRef(
|
|
|
449
450
|
onChange,
|
|
450
451
|
onBlur,
|
|
451
452
|
onKeyDown,
|
|
453
|
+
onKeyUp,
|
|
452
454
|
endAdornment,
|
|
453
455
|
startAdornment
|
|
454
456
|
}, ref) => {
|
|
@@ -462,6 +464,7 @@ var TextFieldInnerSelection = forwardRef(
|
|
|
462
464
|
value,
|
|
463
465
|
onChange,
|
|
464
466
|
onKeyDown,
|
|
467
|
+
onKeyUp,
|
|
465
468
|
onBlur,
|
|
466
469
|
placeholder,
|
|
467
470
|
InputProps: {
|
|
@@ -605,6 +608,21 @@ var SizeInput = ({
|
|
|
605
608
|
size,
|
|
606
609
|
unit
|
|
607
610
|
}) => {
|
|
611
|
+
const unitInputBufferRef = useRef("");
|
|
612
|
+
const handleKeyUp = (event) => {
|
|
613
|
+
const { key } = event;
|
|
614
|
+
if (!/^[a-zA-Z%]$/.test(key)) {
|
|
615
|
+
return;
|
|
616
|
+
}
|
|
617
|
+
event.preventDefault();
|
|
618
|
+
const newChar = key.toLowerCase();
|
|
619
|
+
const updatedBuffer = (unitInputBufferRef.current + newChar).slice(-3);
|
|
620
|
+
unitInputBufferRef.current = updatedBuffer;
|
|
621
|
+
const matchedUnit = units2.find((u) => u.includes(updatedBuffer)) || units2.find((u) => u.startsWith(newChar)) || units2.find((u) => u.includes(newChar));
|
|
622
|
+
if (matchedUnit) {
|
|
623
|
+
handleUnitChange(matchedUnit);
|
|
624
|
+
}
|
|
625
|
+
};
|
|
608
626
|
return /* @__PURE__ */ React14.createElement(ControlActions, null, /* @__PURE__ */ React14.createElement(
|
|
609
627
|
TextFieldInnerSelection,
|
|
610
628
|
{
|
|
@@ -621,12 +639,16 @@ var SizeInput = ({
|
|
|
621
639
|
type: "number",
|
|
622
640
|
value: Number.isNaN(size) ? "" : size,
|
|
623
641
|
onChange: handleSizeChange,
|
|
624
|
-
onBlur
|
|
642
|
+
onBlur: (event) => {
|
|
643
|
+
unitInputBufferRef.current = "";
|
|
644
|
+
onBlur?.(event);
|
|
645
|
+
},
|
|
625
646
|
onKeyDown: (event) => {
|
|
626
647
|
if (RESTRICTED_INPUT_KEYS.includes(event.key)) {
|
|
627
648
|
event.preventDefault();
|
|
628
649
|
}
|
|
629
|
-
}
|
|
650
|
+
},
|
|
651
|
+
onKeyUp: handleKeyUp
|
|
630
652
|
}
|
|
631
653
|
));
|
|
632
654
|
};
|
|
@@ -646,13 +668,38 @@ var SectionContent = ({ gap = 2, sx, children }) => /* @__PURE__ */ React15.crea
|
|
|
646
668
|
import * as React16 from "react";
|
|
647
669
|
import { colorPropTypeUtil } from "@elementor/editor-props";
|
|
648
670
|
import { UnstableColorField } from "@elementor/ui";
|
|
649
|
-
var ColorControl = createControl(
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
671
|
+
var ColorControl = createControl(
|
|
672
|
+
({ propTypeUtil = colorPropTypeUtil, anchorEl, slotProps = {}, ...props }) => {
|
|
673
|
+
const { value, setValue } = useBoundProp(propTypeUtil);
|
|
674
|
+
const handleChange = (selectedColor) => {
|
|
675
|
+
setValue(selectedColor || null);
|
|
676
|
+
};
|
|
677
|
+
return /* @__PURE__ */ React16.createElement(ControlActions, null, /* @__PURE__ */ React16.createElement(
|
|
678
|
+
UnstableColorField,
|
|
679
|
+
{
|
|
680
|
+
size: "tiny",
|
|
681
|
+
fullWidth: true,
|
|
682
|
+
value: value ?? "",
|
|
683
|
+
onChange: handleChange,
|
|
684
|
+
...props,
|
|
685
|
+
slotProps: {
|
|
686
|
+
...slotProps,
|
|
687
|
+
colorPicker: {
|
|
688
|
+
anchorEl,
|
|
689
|
+
anchorOrigin: {
|
|
690
|
+
vertical: "top",
|
|
691
|
+
horizontal: "right"
|
|
692
|
+
},
|
|
693
|
+
transformOrigin: {
|
|
694
|
+
vertical: "top",
|
|
695
|
+
horizontal: -10
|
|
696
|
+
}
|
|
697
|
+
}
|
|
698
|
+
}
|
|
699
|
+
}
|
|
700
|
+
));
|
|
701
|
+
}
|
|
702
|
+
);
|
|
656
703
|
|
|
657
704
|
// src/controls/stroke-control.tsx
|
|
658
705
|
var units = ["px", "em", "rem"];
|
|
@@ -1013,24 +1060,7 @@ var ItemContent = ({ anchorEl, bind }) => {
|
|
|
1013
1060
|
};
|
|
1014
1061
|
var Content = ({ anchorEl }) => {
|
|
1015
1062
|
const { propType, value, setValue } = useBoundProp(shadowPropTypeUtil);
|
|
1016
|
-
return /* @__PURE__ */ React24.createElement(PropProvider, { propType, value, setValue }, /* @__PURE__ */ React24.createElement(PopoverContent, { p: 1.5 }, /* @__PURE__ */ React24.createElement(PopoverGridContainer, null, /* @__PURE__ */ React24.createElement(Control2, { bind: "color", label: __5("Color", "elementor") }, /* @__PURE__ */ React24.createElement(
|
|
1017
|
-
ColorControl,
|
|
1018
|
-
{
|
|
1019
|
-
slotProps: {
|
|
1020
|
-
colorPicker: {
|
|
1021
|
-
anchorEl,
|
|
1022
|
-
anchorOrigin: {
|
|
1023
|
-
vertical: "top",
|
|
1024
|
-
horizontal: "right"
|
|
1025
|
-
},
|
|
1026
|
-
transformOrigin: {
|
|
1027
|
-
vertical: "top",
|
|
1028
|
-
horizontal: -10
|
|
1029
|
-
}
|
|
1030
|
-
}
|
|
1031
|
-
}
|
|
1032
|
-
}
|
|
1033
|
-
)), /* @__PURE__ */ React24.createElement(Control2, { bind: "position", label: __5("Position", "elementor"), sx: { overflow: "hidden" } }, /* @__PURE__ */ React24.createElement(
|
|
1063
|
+
return /* @__PURE__ */ React24.createElement(PropProvider, { propType, value, setValue }, /* @__PURE__ */ React24.createElement(PopoverContent, { p: 1.5 }, /* @__PURE__ */ React24.createElement(PopoverGridContainer, null, /* @__PURE__ */ React24.createElement(Control2, { bind: "color", label: __5("Color", "elementor") }, /* @__PURE__ */ React24.createElement(ColorControl, { anchorEl })), /* @__PURE__ */ React24.createElement(Control2, { bind: "position", label: __5("Position", "elementor"), sx: { overflow: "hidden" } }, /* @__PURE__ */ React24.createElement(
|
|
1034
1064
|
SelectControl,
|
|
1035
1065
|
{
|
|
1036
1066
|
options: [
|
|
@@ -1094,7 +1124,7 @@ import { stringPropTypeUtil as stringPropTypeUtil5 } from "@elementor/editor-pro
|
|
|
1094
1124
|
|
|
1095
1125
|
// src/components/control-toggle-button-group.tsx
|
|
1096
1126
|
import * as React26 from "react";
|
|
1097
|
-
import { useEffect as useEffect3, useMemo, useRef, useState as useState4 } from "react";
|
|
1127
|
+
import { useEffect as useEffect3, useMemo, useRef as useRef2, useState as useState4 } from "react";
|
|
1098
1128
|
import { ChevronDownIcon } from "@elementor/icons";
|
|
1099
1129
|
import {
|
|
1100
1130
|
ListItemText,
|
|
@@ -1201,7 +1231,7 @@ var SplitButtonGroup = ({
|
|
|
1201
1231
|
}) => {
|
|
1202
1232
|
const previewButton = usePreviewButton(items, value);
|
|
1203
1233
|
const [isMenuOpen, setIsMenuOpen] = useState4(false);
|
|
1204
|
-
const menuButtonRef =
|
|
1234
|
+
const menuButtonRef = useRef2(null);
|
|
1205
1235
|
const onMenuToggle = (ev) => {
|
|
1206
1236
|
setIsMenuOpen((prev) => !prev);
|
|
1207
1237
|
ev.preventDefault();
|
|
@@ -1371,7 +1401,7 @@ var NumberControl = createControl(
|
|
|
1371
1401
|
|
|
1372
1402
|
// src/controls/equal-unequal-sizes-control.tsx
|
|
1373
1403
|
import * as React30 from "react";
|
|
1374
|
-
import { useId as useId2, useRef as
|
|
1404
|
+
import { useId as useId2, useRef as useRef3 } from "react";
|
|
1375
1405
|
import { sizePropTypeUtil as sizePropTypeUtil2 } from "@elementor/editor-props";
|
|
1376
1406
|
import { bindPopover as bindPopover2, bindToggle, Grid as Grid5, Popover as Popover2, Stack as Stack7, ToggleButton as ToggleButton2, Tooltip as Tooltip3, usePopupState as usePopupState3 } from "@elementor/ui";
|
|
1377
1407
|
import { __ as __6 } from "@wordpress/i18n";
|
|
@@ -1402,7 +1432,7 @@ function EqualUnequalSizesControl({
|
|
|
1402
1432
|
multiSizePropTypeUtil
|
|
1403
1433
|
}) {
|
|
1404
1434
|
const popupId = useId2();
|
|
1405
|
-
const controlRef =
|
|
1435
|
+
const controlRef = useRef3(null);
|
|
1406
1436
|
const popupState = usePopupState3({ variant: "popover", popupId });
|
|
1407
1437
|
const {
|
|
1408
1438
|
propType: multiSizePropType,
|
|
@@ -1567,7 +1597,7 @@ var Control3 = ({
|
|
|
1567
1597
|
|
|
1568
1598
|
// src/controls/font-family-control/font-family-control.tsx
|
|
1569
1599
|
import * as React32 from "react";
|
|
1570
|
-
import { useEffect as useEffect4, useRef as
|
|
1600
|
+
import { useEffect as useEffect4, useRef as useRef4, useState as useState5 } from "react";
|
|
1571
1601
|
import { stringPropTypeUtil as stringPropTypeUtil6 } from "@elementor/editor-props";
|
|
1572
1602
|
import { ChevronDownIcon as ChevronDownIcon2, SearchIcon, TextIcon, XIcon as XIcon2 } from "@elementor/icons";
|
|
1573
1603
|
import {
|
|
@@ -1702,7 +1732,7 @@ var FontFamilyControl = createControl(({ fontFamilies }) => {
|
|
|
1702
1732
|
var LIST_ITEM_HEIGHT = 36;
|
|
1703
1733
|
var LIST_ITEMS_BUFFER = 6;
|
|
1704
1734
|
var FontList = ({ fontListItems, setFontFamily, handleClose, fontFamily }) => {
|
|
1705
|
-
const containerRef =
|
|
1735
|
+
const containerRef = useRef4(null);
|
|
1706
1736
|
const selectedItem = fontListItems.find((item) => item.value === fontFamily);
|
|
1707
1737
|
const debouncedVirtualizeChange = useDebounce(({ getVirtualIndexes }) => {
|
|
1708
1738
|
getVirtualIndexes().forEach((index) => {
|
|
@@ -2397,6 +2427,7 @@ var SvgMediaControl = createControl(() => {
|
|
|
2397
2427
|
// src/controls/background-control/background-control.tsx
|
|
2398
2428
|
import * as React45 from "react";
|
|
2399
2429
|
import { backgroundPropTypeUtil } from "@elementor/editor-props";
|
|
2430
|
+
import { isExperimentActive } from "@elementor/editor-v1-adapters";
|
|
2400
2431
|
import { Grid as Grid14 } from "@elementor/ui";
|
|
2401
2432
|
import { __ as __18 } from "@wordpress/i18n";
|
|
2402
2433
|
|
|
@@ -2663,7 +2694,7 @@ var BackgroundImageOverlaySize = () => {
|
|
|
2663
2694
|
};
|
|
2664
2695
|
|
|
2665
2696
|
// src/controls/background-control/background-overlay/use-background-tabs-history.ts
|
|
2666
|
-
import { useRef as
|
|
2697
|
+
import { useRef as useRef5 } from "react";
|
|
2667
2698
|
import {
|
|
2668
2699
|
backgroundColorOverlayPropTypeUtil,
|
|
2669
2700
|
backgroundGradientOverlayPropTypeUtil as backgroundGradientOverlayPropTypeUtil2,
|
|
@@ -2688,7 +2719,7 @@ var useBackgroundTabsHistory = ({
|
|
|
2688
2719
|
return "image";
|
|
2689
2720
|
};
|
|
2690
2721
|
const { getTabsProps, getTabProps, getTabPanelProps } = useTabs(getCurrentOverlayType());
|
|
2691
|
-
const valuesHistory =
|
|
2722
|
+
const valuesHistory = useRef5({
|
|
2692
2723
|
image: initialBackgroundImageOverlay,
|
|
2693
2724
|
color: initialBackgroundColorOverlay2,
|
|
2694
2725
|
gradient: initialBackgroundGradientOverlay2
|
|
@@ -2779,10 +2810,10 @@ var BackgroundOverlayRepeaterControl = createControl(() => {
|
|
|
2779
2810
|
}
|
|
2780
2811
|
));
|
|
2781
2812
|
});
|
|
2782
|
-
var ItemContent2 = ({ bind }) => {
|
|
2783
|
-
return /* @__PURE__ */ React44.createElement(PropKeyProvider, { bind }, /* @__PURE__ */ React44.createElement(Content2,
|
|
2813
|
+
var ItemContent2 = ({ anchorEl = null, bind }) => {
|
|
2814
|
+
return /* @__PURE__ */ React44.createElement(PropKeyProvider, { bind }, /* @__PURE__ */ React44.createElement(Content2, { anchorEl }));
|
|
2784
2815
|
};
|
|
2785
|
-
var Content2 = () => {
|
|
2816
|
+
var Content2 = ({ anchorEl }) => {
|
|
2786
2817
|
const { getTabsProps, getTabProps, getTabPanelProps } = useBackgroundTabsHistory({
|
|
2787
2818
|
image: getInitialBackgroundOverlay().value,
|
|
2788
2819
|
color: initialBackgroundColorOverlay.value,
|
|
@@ -2799,7 +2830,7 @@ var Content2 = () => {
|
|
|
2799
2830
|
/* @__PURE__ */ React44.createElement(Tab, { label: __17("Image", "elementor"), ...getTabProps("image") }),
|
|
2800
2831
|
/* @__PURE__ */ React44.createElement(Tab, { label: __17("Gradient", "elementor"), ...getTabProps("gradient") }),
|
|
2801
2832
|
/* @__PURE__ */ React44.createElement(Tab, { label: __17("Color", "elementor"), ...getTabProps("color") })
|
|
2802
|
-
)), /* @__PURE__ */ React44.createElement(TabPanel, { sx: { p: 1.5 }, ...getTabPanelProps("image") }, /* @__PURE__ */ React44.createElement(PopoverContent, null, /* @__PURE__ */ React44.createElement(ImageOverlayContent, null))), /* @__PURE__ */ React44.createElement(TabPanel, { sx: { p: 1.5 }, ...getTabPanelProps("gradient") }, /* @__PURE__ */ React44.createElement(BackgroundGradientColorControl, null)), /* @__PURE__ */ React44.createElement(TabPanel, { sx: { p: 1.5 }, ...getTabPanelProps("color") }, /* @__PURE__ */ React44.createElement(PopoverContent, null, /* @__PURE__ */ React44.createElement(ColorOverlayContent,
|
|
2833
|
+
)), /* @__PURE__ */ React44.createElement(TabPanel, { sx: { p: 1.5 }, ...getTabPanelProps("image") }, /* @__PURE__ */ React44.createElement(PopoverContent, null, /* @__PURE__ */ React44.createElement(ImageOverlayContent, null))), /* @__PURE__ */ React44.createElement(TabPanel, { sx: { p: 1.5 }, ...getTabPanelProps("gradient") }, /* @__PURE__ */ React44.createElement(BackgroundGradientColorControl, null)), /* @__PURE__ */ React44.createElement(TabPanel, { sx: { p: 1.5 }, ...getTabPanelProps("color") }, /* @__PURE__ */ React44.createElement(PopoverContent, null, /* @__PURE__ */ React44.createElement(ColorOverlayContent, { anchorEl }))));
|
|
2803
2834
|
};
|
|
2804
2835
|
var ItemIcon2 = ({ value }) => {
|
|
2805
2836
|
switch (value.$$type) {
|
|
@@ -2868,9 +2899,9 @@ var ItemLabelGradient = ({ value }) => {
|
|
|
2868
2899
|
}
|
|
2869
2900
|
return /* @__PURE__ */ React44.createElement("span", null, __17("Radial Gradient", "elementor"));
|
|
2870
2901
|
};
|
|
2871
|
-
var ColorOverlayContent = () => {
|
|
2902
|
+
var ColorOverlayContent = ({ anchorEl }) => {
|
|
2872
2903
|
const propContext = useBoundProp(backgroundColorOverlayPropTypeUtil2);
|
|
2873
|
-
return /* @__PURE__ */ React44.createElement(PropProvider, { ...propContext }, /* @__PURE__ */ React44.createElement(PropKeyProvider, { bind: "color" }, /* @__PURE__ */ React44.createElement(ColorControl,
|
|
2904
|
+
return /* @__PURE__ */ React44.createElement(PropProvider, { ...propContext }, /* @__PURE__ */ React44.createElement(PropKeyProvider, { bind: "color" }, /* @__PURE__ */ React44.createElement(ColorControl, { anchorEl })));
|
|
2874
2905
|
};
|
|
2875
2906
|
var ImageOverlayContent = () => {
|
|
2876
2907
|
const propContext = useBoundProp(backgroundImageOverlayPropTypeUtil2);
|
|
@@ -2918,7 +2949,9 @@ var getGradientValue = (value) => {
|
|
|
2918
2949
|
// src/controls/background-control/background-control.tsx
|
|
2919
2950
|
var BackgroundControl = createControl(() => {
|
|
2920
2951
|
const propContext = useBoundProp(backgroundPropTypeUtil);
|
|
2921
|
-
|
|
2952
|
+
const isUsingNestedProps = isExperimentActive("e_v_3_30");
|
|
2953
|
+
const colorLabel = __18("Color", "elementor");
|
|
2954
|
+
return /* @__PURE__ */ React45.createElement(PropProvider, { ...propContext }, /* @__PURE__ */ React45.createElement(SectionContent, null, /* @__PURE__ */ React45.createElement(PropKeyProvider, { bind: "background-overlay" }, /* @__PURE__ */ React45.createElement(BackgroundOverlayRepeaterControl, null)), /* @__PURE__ */ React45.createElement(PropKeyProvider, { bind: "color" }, /* @__PURE__ */ React45.createElement(Grid14, { container: true, gap: 2, alignItems: "center", flexWrap: "nowrap" }, /* @__PURE__ */ React45.createElement(Grid14, { item: true, xs: 6 }, isUsingNestedProps ? /* @__PURE__ */ React45.createElement(ControlLabel, null, colorLabel) : /* @__PURE__ */ React45.createElement(ControlFormLabel, null, colorLabel)), /* @__PURE__ */ React45.createElement(Grid14, { item: true, xs: 6 }, /* @__PURE__ */ React45.createElement(ColorControl, null))))));
|
|
2922
2955
|
});
|
|
2923
2956
|
export {
|
|
2924
2957
|
BackgroundControl,
|