@elementor/editor-controls 0.24.0 → 0.26.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 +26 -0
- package/dist/index.d.mts +5 -1
- package/dist/index.d.ts +5 -1
- package/dist/index.js +150 -81
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +125 -56
- package/dist/index.mjs.map +1 -1
- package/package.json +4 -4
- package/src/bound-prop-context/prop-context.tsx +3 -0
- package/src/bound-prop-context/prop-key-context.tsx +3 -1
- package/src/bound-prop-context/use-bound-prop.ts +41 -2
- package/src/components/repeater.tsx +7 -1
- package/src/components/text-field-inner-selection.tsx +18 -2
- package/src/controls/font-family-control/font-family-control.tsx +2 -0
- package/src/controls/link-control.tsx +2 -1
- package/src/controls/number-control.tsx +7 -0
- package/src/controls/size-control.tsx +25 -15
- package/src/controls/toggle-control.tsx +3 -3
package/dist/index.js
CHANGED
|
@@ -94,7 +94,8 @@ var PropProvider = ({
|
|
|
94
94
|
children,
|
|
95
95
|
value,
|
|
96
96
|
setValue,
|
|
97
|
-
propType
|
|
97
|
+
propType,
|
|
98
|
+
placeholder
|
|
98
99
|
}) => {
|
|
99
100
|
return /* @__PURE__ */ React.createElement(
|
|
100
101
|
PropContext.Provider,
|
|
@@ -102,7 +103,8 @@ var PropProvider = ({
|
|
|
102
103
|
value: {
|
|
103
104
|
value,
|
|
104
105
|
propType,
|
|
105
|
-
setValue
|
|
106
|
+
setValue,
|
|
107
|
+
placeholder
|
|
106
108
|
}
|
|
107
109
|
},
|
|
108
110
|
children
|
|
@@ -149,11 +151,12 @@ var ObjectPropKeyProvider = ({ children, bind }) => {
|
|
|
149
151
|
return context?.setValue(newValue, options, { ...meta, bind });
|
|
150
152
|
};
|
|
151
153
|
const value = context.value?.[bind];
|
|
154
|
+
const placeholder = context.placeholder?.[bind];
|
|
152
155
|
const propType = context.propType.shape[bind];
|
|
153
156
|
return /* @__PURE__ */ React2.createElement(
|
|
154
157
|
PropKeyContext.Provider,
|
|
155
158
|
{
|
|
156
|
-
value: { ...context, value, setValue, bind, propType, path: [...path ?? [], bind] }
|
|
159
|
+
value: { ...context, value, setValue, placeholder, bind, propType, path: [...path ?? [], bind] }
|
|
157
160
|
},
|
|
158
161
|
children
|
|
159
162
|
);
|
|
@@ -187,12 +190,17 @@ var usePropKeyContext = () => {
|
|
|
187
190
|
};
|
|
188
191
|
|
|
189
192
|
// src/bound-prop-context/use-bound-prop.ts
|
|
193
|
+
var import_react3 = require("react");
|
|
190
194
|
function useBoundProp(propTypeUtil) {
|
|
191
195
|
const propKeyContext = usePropKeyContext();
|
|
196
|
+
const { isValid, validate, restoreValue } = useValidation(propKeyContext.propType);
|
|
192
197
|
if (!propTypeUtil) {
|
|
193
198
|
return propKeyContext;
|
|
194
199
|
}
|
|
195
200
|
function setValue(value2, options, meta) {
|
|
201
|
+
if (!validate(value2)) {
|
|
202
|
+
return;
|
|
203
|
+
}
|
|
196
204
|
if (value2 === null) {
|
|
197
205
|
return propKeyContext?.setValue(null, options, meta);
|
|
198
206
|
}
|
|
@@ -200,13 +208,34 @@ function useBoundProp(propTypeUtil) {
|
|
|
200
208
|
}
|
|
201
209
|
const propType = resolveUnionPropType(propKeyContext.propType, propTypeUtil.key);
|
|
202
210
|
const value = propTypeUtil.extract(propKeyContext.value ?? propType.default ?? null);
|
|
211
|
+
const placeholder = propTypeUtil.extract(propKeyContext.placeholder ?? null);
|
|
203
212
|
return {
|
|
204
213
|
...propKeyContext,
|
|
214
|
+
propType,
|
|
205
215
|
setValue,
|
|
206
|
-
value,
|
|
207
|
-
|
|
216
|
+
value: isValid ? value : null,
|
|
217
|
+
restoreValue,
|
|
218
|
+
placeholder
|
|
208
219
|
};
|
|
209
220
|
}
|
|
221
|
+
var useValidation = (propType) => {
|
|
222
|
+
const [isValid, setIsValid] = (0, import_react3.useState)(true);
|
|
223
|
+
const validate = (value) => {
|
|
224
|
+
let valid = true;
|
|
225
|
+
if (propType.settings.required && value === null) {
|
|
226
|
+
valid = false;
|
|
227
|
+
}
|
|
228
|
+
setIsValid(valid);
|
|
229
|
+
return valid;
|
|
230
|
+
};
|
|
231
|
+
const restoreValue = () => setIsValid(true);
|
|
232
|
+
return {
|
|
233
|
+
isValid,
|
|
234
|
+
setIsValid,
|
|
235
|
+
validate,
|
|
236
|
+
restoreValue
|
|
237
|
+
};
|
|
238
|
+
};
|
|
210
239
|
var resolveUnionPropType = (propType, key) => {
|
|
211
240
|
let resolvedPropType = propType;
|
|
212
241
|
if (propType.kind === "union") {
|
|
@@ -231,8 +260,8 @@ var import_ui2 = require("@elementor/ui");
|
|
|
231
260
|
|
|
232
261
|
// src/create-control-replacement.tsx
|
|
233
262
|
var React4 = __toESM(require("react"));
|
|
234
|
-
var
|
|
235
|
-
var ControlReplacementContext = (0,
|
|
263
|
+
var import_react4 = require("react");
|
|
264
|
+
var ControlReplacementContext = (0, import_react4.createContext)(void 0);
|
|
236
265
|
var ControlReplacementProvider = ({
|
|
237
266
|
component,
|
|
238
267
|
condition,
|
|
@@ -242,7 +271,7 @@ var ControlReplacementProvider = ({
|
|
|
242
271
|
};
|
|
243
272
|
var useControlReplacement = () => {
|
|
244
273
|
const { value } = useBoundProp();
|
|
245
|
-
const controlReplacement = (0,
|
|
274
|
+
const controlReplacement = (0, import_react4.useContext)(ControlReplacementContext);
|
|
246
275
|
let shouldReplace = false;
|
|
247
276
|
try {
|
|
248
277
|
shouldReplace = !!controlReplacement?.condition({ value }) && !!controlReplacement.component;
|
|
@@ -326,11 +355,11 @@ var import_ui3 = require("@elementor/ui");
|
|
|
326
355
|
|
|
327
356
|
// src/control-actions/control-actions-context.tsx
|
|
328
357
|
var React6 = __toESM(require("react"));
|
|
329
|
-
var
|
|
330
|
-
var Context = (0,
|
|
358
|
+
var import_react5 = require("react");
|
|
359
|
+
var Context = (0, import_react5.createContext)(null);
|
|
331
360
|
var ControlActionsProvider = ({ children, items }) => /* @__PURE__ */ React6.createElement(Context.Provider, { value: { items } }, children);
|
|
332
361
|
var useControlActions = () => {
|
|
333
|
-
const context = (0,
|
|
362
|
+
const context = (0, import_react5.useContext)(Context);
|
|
334
363
|
if (!context) {
|
|
335
364
|
throw new Error("useControlActions must be used within a ControlActionsProvider");
|
|
336
365
|
}
|
|
@@ -481,25 +510,36 @@ var import_ui10 = require("@elementor/ui");
|
|
|
481
510
|
|
|
482
511
|
// src/components/text-field-inner-selection.tsx
|
|
483
512
|
var React13 = __toESM(require("react"));
|
|
484
|
-
var
|
|
513
|
+
var import_react6 = require("react");
|
|
485
514
|
var import_editor_ui2 = require("@elementor/editor-ui");
|
|
486
515
|
var import_ui9 = require("@elementor/ui");
|
|
487
|
-
var TextFieldInnerSelection = (0,
|
|
488
|
-
({
|
|
516
|
+
var TextFieldInnerSelection = (0, import_react6.forwardRef)(
|
|
517
|
+
({
|
|
518
|
+
placeholder,
|
|
519
|
+
type,
|
|
520
|
+
value,
|
|
521
|
+
onChange,
|
|
522
|
+
onBlur,
|
|
523
|
+
onKeyDown,
|
|
524
|
+
endAdornment,
|
|
525
|
+
startAdornment
|
|
526
|
+
}, ref) => {
|
|
489
527
|
return /* @__PURE__ */ React13.createElement(
|
|
490
528
|
import_ui9.TextField,
|
|
491
529
|
{
|
|
530
|
+
ref,
|
|
492
531
|
size: "tiny",
|
|
493
532
|
fullWidth: true,
|
|
494
533
|
type,
|
|
495
534
|
value,
|
|
496
535
|
onChange,
|
|
536
|
+
onKeyDown,
|
|
537
|
+
onBlur,
|
|
497
538
|
placeholder,
|
|
498
539
|
InputProps: {
|
|
499
540
|
endAdornment,
|
|
500
541
|
startAdornment
|
|
501
|
-
}
|
|
502
|
-
ref
|
|
542
|
+
}
|
|
503
543
|
}
|
|
504
544
|
);
|
|
505
545
|
}
|
|
@@ -511,7 +551,7 @@ var SelectionEndAdornment = ({
|
|
|
511
551
|
}) => {
|
|
512
552
|
const popupState = (0, import_ui9.usePopupState)({
|
|
513
553
|
variant: "popover",
|
|
514
|
-
popupId: (0,
|
|
554
|
+
popupId: (0, import_react6.useId)()
|
|
515
555
|
});
|
|
516
556
|
const handleMenuItemClick = (index) => {
|
|
517
557
|
onClick(options[index]);
|
|
@@ -530,7 +570,7 @@ var SelectionEndAdornment = ({
|
|
|
530
570
|
};
|
|
531
571
|
|
|
532
572
|
// src/hooks/use-sync-external-state.tsx
|
|
533
|
-
var
|
|
573
|
+
var import_react7 = require("react");
|
|
534
574
|
var useSyncExternalState = ({
|
|
535
575
|
external,
|
|
536
576
|
setExternal,
|
|
@@ -549,8 +589,8 @@ var useSyncExternalState = ({
|
|
|
549
589
|
}
|
|
550
590
|
return externalValue;
|
|
551
591
|
}
|
|
552
|
-
const [internal, setInternal] = (0,
|
|
553
|
-
(0,
|
|
592
|
+
const [internal, setInternal] = (0, import_react7.useState)(toInternal(external, null));
|
|
593
|
+
(0, import_react7.useEffect)(() => {
|
|
554
594
|
setInternal((prevInternal) => toInternal(external, prevInternal));
|
|
555
595
|
}, [external]);
|
|
556
596
|
const setInternalValue = (setter) => {
|
|
@@ -568,7 +608,7 @@ var defaultUnit = "px";
|
|
|
568
608
|
var defaultSize = NaN;
|
|
569
609
|
var SizeControl = createControl(
|
|
570
610
|
({ units: units2 = defaultUnits, extendedValues = [], placeholder, startIcon }) => {
|
|
571
|
-
const { value: sizeValue, setValue: setSizeValue } = useBoundProp(import_editor_props6.sizePropTypeUtil);
|
|
611
|
+
const { value: sizeValue, setValue: setSizeValue, restoreValue } = useBoundProp(import_editor_props6.sizePropTypeUtil);
|
|
572
612
|
const [state, setState] = useSyncExternalState({
|
|
573
613
|
external: sizeValue,
|
|
574
614
|
setExternal: setSizeValue,
|
|
@@ -588,20 +628,21 @@ var SizeControl = createControl(
|
|
|
588
628
|
size: size || size === "0" ? parseFloat(size) : defaultSize
|
|
589
629
|
}));
|
|
590
630
|
};
|
|
591
|
-
const
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
631
|
+
const Input = extendedValues?.length ? ExtendedSizeInput : SizeInput;
|
|
632
|
+
return /* @__PURE__ */ React14.createElement(
|
|
633
|
+
Input,
|
|
634
|
+
{
|
|
635
|
+
size: state.size,
|
|
636
|
+
unit: state.unit,
|
|
637
|
+
placeholder,
|
|
638
|
+
startIcon,
|
|
639
|
+
units: units2,
|
|
640
|
+
extendedValues,
|
|
641
|
+
handleSizeChange,
|
|
642
|
+
handleUnitChange,
|
|
643
|
+
onBlur: restoreValue
|
|
644
|
+
}
|
|
645
|
+
);
|
|
605
646
|
}
|
|
606
647
|
);
|
|
607
648
|
var ExtendedSizeInput = (props) => {
|
|
@@ -625,12 +666,14 @@ var ExtendedSizeInput = (props) => {
|
|
|
625
666
|
}
|
|
626
667
|
);
|
|
627
668
|
};
|
|
669
|
+
var RESTRICTED_INPUT_KEYS = ["e", "E", "+", "-"];
|
|
628
670
|
var SizeInput = ({
|
|
629
671
|
units: units2,
|
|
630
672
|
handleUnitChange,
|
|
631
673
|
handleSizeChange,
|
|
632
674
|
placeholder,
|
|
633
675
|
startIcon,
|
|
676
|
+
onBlur,
|
|
634
677
|
size,
|
|
635
678
|
unit
|
|
636
679
|
}) => {
|
|
@@ -649,7 +692,13 @@ var SizeInput = ({
|
|
|
649
692
|
startAdornment: startIcon ? /* @__PURE__ */ React14.createElement(import_ui10.InputAdornment, { position: "start" }, startIcon) : void 0,
|
|
650
693
|
type: "number",
|
|
651
694
|
value: Number.isNaN(size) ? "" : size,
|
|
652
|
-
onChange: handleSizeChange
|
|
695
|
+
onChange: handleSizeChange,
|
|
696
|
+
onBlur,
|
|
697
|
+
onKeyDown: (event) => {
|
|
698
|
+
if (RESTRICTED_INPUT_KEYS.includes(event.key)) {
|
|
699
|
+
event.preventDefault();
|
|
700
|
+
}
|
|
701
|
+
}
|
|
653
702
|
}
|
|
654
703
|
));
|
|
655
704
|
};
|
|
@@ -708,7 +757,7 @@ var PopoverGridContainer = ({
|
|
|
708
757
|
|
|
709
758
|
// src/components/repeater.tsx
|
|
710
759
|
var React23 = __toESM(require("react"));
|
|
711
|
-
var
|
|
760
|
+
var import_react9 = require("react");
|
|
712
761
|
var import_icons3 = require("@elementor/icons");
|
|
713
762
|
var import_ui17 = require("@elementor/ui");
|
|
714
763
|
var import_i18n4 = require("@wordpress/i18n");
|
|
@@ -718,11 +767,11 @@ var React21 = __toESM(require("react"));
|
|
|
718
767
|
|
|
719
768
|
// src/control-adornments/control-adornments-context.tsx
|
|
720
769
|
var React20 = __toESM(require("react"));
|
|
721
|
-
var
|
|
722
|
-
var Context2 = (0,
|
|
770
|
+
var import_react8 = require("react");
|
|
771
|
+
var Context2 = (0, import_react8.createContext)(null);
|
|
723
772
|
var ControlAdornmentsProvider = ({ children, items }) => /* @__PURE__ */ React20.createElement(Context2.Provider, { value: { items } }, children);
|
|
724
773
|
var useControlAdornments = () => {
|
|
725
|
-
const context = (0,
|
|
774
|
+
const context = (0, import_react8.useContext)(Context2);
|
|
726
775
|
return context?.items ?? [];
|
|
727
776
|
};
|
|
728
777
|
|
|
@@ -818,14 +867,14 @@ var Repeater = ({
|
|
|
818
867
|
values: repeaterValues = [],
|
|
819
868
|
setValues: setRepeaterValues
|
|
820
869
|
}) => {
|
|
821
|
-
const [openItem, setOpenItem] = (0,
|
|
870
|
+
const [openItem, setOpenItem] = (0, import_react9.useState)(EMPTY_OPEN_ITEM);
|
|
822
871
|
const [items, setItems] = useSyncExternalState({
|
|
823
872
|
external: repeaterValues,
|
|
824
873
|
// @ts-expect-error - as long as persistWhen => true, value will never be null
|
|
825
874
|
setExternal: setRepeaterValues,
|
|
826
875
|
persistWhen: () => true
|
|
827
876
|
});
|
|
828
|
-
const [uniqueKeys, setUniqueKeys] = (0,
|
|
877
|
+
const [uniqueKeys, setUniqueKeys] = (0, import_react9.useState)(items.map((_, index) => index));
|
|
829
878
|
const generateNextKey = (source) => {
|
|
830
879
|
return 1 + Math.max(0, ...source);
|
|
831
880
|
};
|
|
@@ -882,16 +931,28 @@ var Repeater = ({
|
|
|
882
931
|
});
|
|
883
932
|
});
|
|
884
933
|
};
|
|
885
|
-
return /* @__PURE__ */ React23.createElement(SectionContent, null, /* @__PURE__ */ React23.createElement(
|
|
886
|
-
import_ui17.
|
|
934
|
+
return /* @__PURE__ */ React23.createElement(SectionContent, null, /* @__PURE__ */ React23.createElement(
|
|
935
|
+
import_ui17.Stack,
|
|
887
936
|
{
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
937
|
+
direction: "row",
|
|
938
|
+
justifyContent: "start",
|
|
939
|
+
alignItems: "center",
|
|
940
|
+
gap: 1,
|
|
941
|
+
sx: { marginInlineEnd: -0.75 }
|
|
892
942
|
},
|
|
893
|
-
/* @__PURE__ */ React23.createElement(
|
|
894
|
-
|
|
943
|
+
/* @__PURE__ */ React23.createElement(import_ui17.Typography, { component: "label", variant: "caption", color: "text.secondary" }, label),
|
|
944
|
+
/* @__PURE__ */ React23.createElement(ControlAdornments, null),
|
|
945
|
+
/* @__PURE__ */ React23.createElement(
|
|
946
|
+
import_ui17.IconButton,
|
|
947
|
+
{
|
|
948
|
+
sx: { ml: "auto" },
|
|
949
|
+
size: SIZE,
|
|
950
|
+
onClick: addRepeaterItem,
|
|
951
|
+
"aria-label": (0, import_i18n4.__)("Add item", "elementor")
|
|
952
|
+
},
|
|
953
|
+
/* @__PURE__ */ React23.createElement(import_icons3.PlusIcon, { fontSize: SIZE })
|
|
954
|
+
)
|
|
955
|
+
), 0 < uniqueKeys.length && /* @__PURE__ */ React23.createElement(SortableProvider, { value: uniqueKeys, onChange: onChangeOrder }, uniqueKeys.map((key, index) => {
|
|
895
956
|
const value = items[index];
|
|
896
957
|
if (!value) {
|
|
897
958
|
return null;
|
|
@@ -923,7 +984,7 @@ var RepeaterItem = ({
|
|
|
923
984
|
openOnMount,
|
|
924
985
|
onOpen
|
|
925
986
|
}) => {
|
|
926
|
-
const [anchorEl, setAnchorEl] = (0,
|
|
987
|
+
const [anchorEl, setAnchorEl] = (0, import_react9.useState)(null);
|
|
927
988
|
const { popoverState, popoverProps, ref, setRef } = usePopover(openOnMount, onOpen);
|
|
928
989
|
const duplicateLabel = (0, import_i18n4.__)("Duplicate", "elementor");
|
|
929
990
|
const toggleLabel = disabled ? (0, import_i18n4.__)("Show", "elementor") : (0, import_i18n4.__)("Hide", "elementor");
|
|
@@ -959,10 +1020,10 @@ var RepeaterItem = ({
|
|
|
959
1020
|
));
|
|
960
1021
|
};
|
|
961
1022
|
var usePopover = (openOnMount, onOpen) => {
|
|
962
|
-
const [ref, setRef] = (0,
|
|
1023
|
+
const [ref, setRef] = (0, import_react9.useState)(null);
|
|
963
1024
|
const popoverState = (0, import_ui17.usePopupState)({ variant: "popover" });
|
|
964
1025
|
const popoverProps = (0, import_ui17.bindPopover)(popoverState);
|
|
965
|
-
(0,
|
|
1026
|
+
(0, import_react9.useEffect)(() => {
|
|
966
1027
|
if (openOnMount && ref) {
|
|
967
1028
|
popoverState.open(ref);
|
|
968
1029
|
onOpen?.();
|
|
@@ -1137,7 +1198,7 @@ var ToggleControl = createControl(
|
|
|
1137
1198
|
size = "tiny",
|
|
1138
1199
|
exclusive = true
|
|
1139
1200
|
}) => {
|
|
1140
|
-
const { value, setValue } = useBoundProp(import_editor_props10.stringPropTypeUtil);
|
|
1201
|
+
const { value, setValue, placeholder } = useBoundProp(import_editor_props10.stringPropTypeUtil);
|
|
1141
1202
|
const exclusiveValues = options.filter((option) => option.exclusive).map((option) => option.value);
|
|
1142
1203
|
const handleNonExclusiveToggle = (selectedValues) => {
|
|
1143
1204
|
const newSelectedValue = selectedValues[selectedValues.length - 1];
|
|
@@ -1154,7 +1215,7 @@ var ToggleControl = createControl(
|
|
|
1154
1215
|
ControlToggleButtonGroup,
|
|
1155
1216
|
{
|
|
1156
1217
|
...toggleButtonGroupProps,
|
|
1157
|
-
value: value ?? null,
|
|
1218
|
+
value: value ?? placeholder ?? null,
|
|
1158
1219
|
onChange: setValue,
|
|
1159
1220
|
exclusive: true
|
|
1160
1221
|
}
|
|
@@ -1162,7 +1223,7 @@ var ToggleControl = createControl(
|
|
|
1162
1223
|
ControlToggleButtonGroup,
|
|
1163
1224
|
{
|
|
1164
1225
|
...toggleButtonGroupProps,
|
|
1165
|
-
value: value?.split(" ") ?? [],
|
|
1226
|
+
value: (value ?? placeholder)?.split(" ") ?? [],
|
|
1166
1227
|
onChange: handleNonExclusiveToggle,
|
|
1167
1228
|
exclusive: false
|
|
1168
1229
|
}
|
|
@@ -1175,6 +1236,7 @@ var React27 = __toESM(require("react"));
|
|
|
1175
1236
|
var import_editor_props11 = require("@elementor/editor-props");
|
|
1176
1237
|
var import_ui20 = require("@elementor/ui");
|
|
1177
1238
|
var isEmptyOrNaN = (value) => value === null || value === void 0 || value === "" || Number.isNaN(Number(value));
|
|
1239
|
+
var RESTRICTED_INPUT_KEYS2 = ["e", "E", "+", "-"];
|
|
1178
1240
|
var NumberControl = createControl(
|
|
1179
1241
|
({
|
|
1180
1242
|
placeholder,
|
|
@@ -1202,7 +1264,12 @@ var NumberControl = createControl(
|
|
|
1202
1264
|
value: isEmptyOrNaN(value) ? "" : value,
|
|
1203
1265
|
onChange: handleChange,
|
|
1204
1266
|
placeholder,
|
|
1205
|
-
inputProps: { step }
|
|
1267
|
+
inputProps: { step },
|
|
1268
|
+
onKeyDown: (event) => {
|
|
1269
|
+
if (RESTRICTED_INPUT_KEYS2.includes(event.key)) {
|
|
1270
|
+
event.preventDefault();
|
|
1271
|
+
}
|
|
1272
|
+
}
|
|
1206
1273
|
}
|
|
1207
1274
|
));
|
|
1208
1275
|
}
|
|
@@ -1210,7 +1277,7 @@ var NumberControl = createControl(
|
|
|
1210
1277
|
|
|
1211
1278
|
// src/controls/equal-unequal-sizes-control.tsx
|
|
1212
1279
|
var React29 = __toESM(require("react"));
|
|
1213
|
-
var
|
|
1280
|
+
var import_react10 = require("react");
|
|
1214
1281
|
var import_editor_props12 = require("@elementor/editor-props");
|
|
1215
1282
|
var import_ui22 = require("@elementor/ui");
|
|
1216
1283
|
var import_i18n6 = require("@wordpress/i18n");
|
|
@@ -1240,8 +1307,8 @@ function EqualUnequalSizesControl({
|
|
|
1240
1307
|
items,
|
|
1241
1308
|
multiSizePropTypeUtil
|
|
1242
1309
|
}) {
|
|
1243
|
-
const popupId = (0,
|
|
1244
|
-
const controlRef = (0,
|
|
1310
|
+
const popupId = (0, import_react10.useId)();
|
|
1311
|
+
const controlRef = (0, import_react10.useRef)(null);
|
|
1245
1312
|
const popupState = (0, import_ui22.usePopupState)({ variant: "popover", popupId });
|
|
1246
1313
|
const {
|
|
1247
1314
|
propType: multiSizePropType,
|
|
@@ -1407,7 +1474,7 @@ var Control3 = ({
|
|
|
1407
1474
|
|
|
1408
1475
|
// src/controls/font-family-control/font-family-control.tsx
|
|
1409
1476
|
var React31 = __toESM(require("react"));
|
|
1410
|
-
var
|
|
1477
|
+
var import_react11 = require("react");
|
|
1411
1478
|
var import_editor_props14 = require("@elementor/editor-props");
|
|
1412
1479
|
var import_icons5 = require("@elementor/icons");
|
|
1413
1480
|
var import_ui24 = require("@elementor/ui");
|
|
@@ -1440,7 +1507,7 @@ var enqueueFont = (fontFamily, context = "editor") => {
|
|
|
1440
1507
|
// src/controls/font-family-control/font-family-control.tsx
|
|
1441
1508
|
var SIZE2 = "tiny";
|
|
1442
1509
|
var FontFamilyControl = createControl(({ fontFamilies }) => {
|
|
1443
|
-
const [searchValue, setSearchValue] = (0,
|
|
1510
|
+
const [searchValue, setSearchValue] = (0, import_react11.useState)("");
|
|
1444
1511
|
const { value: fontFamily, setValue: setFontFamily } = useBoundProp(import_editor_props14.stringPropTypeUtil);
|
|
1445
1512
|
const popoverState = (0, import_ui24.usePopupState)({ variant: "popover" });
|
|
1446
1513
|
const filteredFontFamilies = useFilteredFontFamilies(fontFamilies, searchValue);
|
|
@@ -1472,6 +1539,7 @@ var FontFamilyControl = createControl(({ fontFamilies }) => {
|
|
|
1472
1539
|
/* @__PURE__ */ React31.createElement(import_ui24.Stack, null, /* @__PURE__ */ React31.createElement(import_ui24.Stack, { direction: "row", alignItems: "center", pl: 1.5, pr: 0.5, py: 1.5 }, /* @__PURE__ */ React31.createElement(import_icons5.TextIcon, { fontSize: SIZE2, sx: { mr: 0.5 } }), /* @__PURE__ */ React31.createElement(import_ui24.Typography, { variant: "subtitle2" }, (0, import_i18n8.__)("Font Family", "elementor")), /* @__PURE__ */ React31.createElement(import_ui24.IconButton, { size: SIZE2, sx: { ml: "auto" }, onClick: handleClose }, /* @__PURE__ */ React31.createElement(import_icons5.XIcon, { fontSize: SIZE2 }))), /* @__PURE__ */ React31.createElement(import_ui24.Box, { px: 1.5, pb: 1 }, /* @__PURE__ */ React31.createElement(
|
|
1473
1540
|
import_ui24.TextField,
|
|
1474
1541
|
{
|
|
1542
|
+
autoFocus: true,
|
|
1475
1543
|
fullWidth: true,
|
|
1476
1544
|
size: SIZE2,
|
|
1477
1545
|
value: searchValue,
|
|
@@ -1524,7 +1592,7 @@ var FontFamilyControl = createControl(({ fontFamilies }) => {
|
|
|
1524
1592
|
var LIST_ITEM_HEIGHT = 36;
|
|
1525
1593
|
var LIST_ITEMS_BUFFER = 6;
|
|
1526
1594
|
var FontList = ({ fontListItems, setFontFamily, handleClose, fontFamily }) => {
|
|
1527
|
-
const containerRef = (0,
|
|
1595
|
+
const containerRef = (0, import_react11.useRef)(null);
|
|
1528
1596
|
const selectedItem = fontListItems.find((item) => item.value === fontFamily);
|
|
1529
1597
|
const debouncedVirtualizeChange = useDebounce(({ getVirtualIndexes }) => {
|
|
1530
1598
|
getVirtualIndexes().forEach((index) => {
|
|
@@ -1541,7 +1609,7 @@ var FontList = ({ fontListItems, setFontFamily, handleClose, fontFamily }) => {
|
|
|
1541
1609
|
overscan: LIST_ITEMS_BUFFER,
|
|
1542
1610
|
onChange: debouncedVirtualizeChange
|
|
1543
1611
|
});
|
|
1544
|
-
(0,
|
|
1612
|
+
(0, import_react11.useEffect)(
|
|
1545
1613
|
() => {
|
|
1546
1614
|
virtualizer.scrollToIndex(fontListItems.findIndex((item) => item.value === fontFamily));
|
|
1547
1615
|
},
|
|
@@ -1649,8 +1717,8 @@ var StyledMenuList = (0, import_ui24.styled)(import_ui24.MenuList)(({ theme }) =
|
|
|
1649
1717
|
position: "relative"
|
|
1650
1718
|
}));
|
|
1651
1719
|
var useDebounce = (fn, delay) => {
|
|
1652
|
-
const [debouncedFn] = (0,
|
|
1653
|
-
(0,
|
|
1720
|
+
const [debouncedFn] = (0, import_react11.useState)(() => (0, import_utils2.debounce)(fn, delay));
|
|
1721
|
+
(0, import_react11.useEffect)(() => () => debouncedFn.cancel(), [debouncedFn]);
|
|
1654
1722
|
return debouncedFn;
|
|
1655
1723
|
};
|
|
1656
1724
|
|
|
@@ -1675,7 +1743,7 @@ var UrlControl = createControl(({ placeholder }) => {
|
|
|
1675
1743
|
|
|
1676
1744
|
// src/controls/link-control.tsx
|
|
1677
1745
|
var React34 = __toESM(require("react"));
|
|
1678
|
-
var
|
|
1746
|
+
var import_react13 = require("react");
|
|
1679
1747
|
var import_editor_elements = require("@elementor/editor-elements");
|
|
1680
1748
|
var import_editor_props16 = require("@elementor/editor-props");
|
|
1681
1749
|
var import_editor_ui3 = require("@elementor/editor-ui");
|
|
@@ -1688,10 +1756,10 @@ var import_i18n9 = require("@wordpress/i18n");
|
|
|
1688
1756
|
|
|
1689
1757
|
// src/components/autocomplete.tsx
|
|
1690
1758
|
var React33 = __toESM(require("react"));
|
|
1691
|
-
var
|
|
1759
|
+
var import_react12 = require("react");
|
|
1692
1760
|
var import_icons6 = require("@elementor/icons");
|
|
1693
1761
|
var import_ui26 = require("@elementor/ui");
|
|
1694
|
-
var Autocomplete = (0,
|
|
1762
|
+
var Autocomplete = (0, import_react12.forwardRef)((props, ref) => {
|
|
1695
1763
|
const {
|
|
1696
1764
|
options,
|
|
1697
1765
|
onOptionChange,
|
|
@@ -1801,7 +1869,7 @@ var learnMoreButton = {
|
|
|
1801
1869
|
var LinkControl = createControl((props) => {
|
|
1802
1870
|
const { value, path, setValue, ...propContext } = useBoundProp(import_editor_props16.linkPropTypeUtil);
|
|
1803
1871
|
const [linkSessionValue, setLinkSessionValue] = (0, import_session.useSessionStorage)(path.join("/"));
|
|
1804
|
-
const [isActive, setIsActive] = (0,
|
|
1872
|
+
const [isActive, setIsActive] = (0, import_react13.useState)(!!value);
|
|
1805
1873
|
const {
|
|
1806
1874
|
allowCustomValues,
|
|
1807
1875
|
queryOptions: { endpoint = "", requestParams = {} },
|
|
@@ -1809,8 +1877,8 @@ var LinkControl = createControl((props) => {
|
|
|
1809
1877
|
minInputLength = 2,
|
|
1810
1878
|
context: { elementId }
|
|
1811
1879
|
} = props || {};
|
|
1812
|
-
const [linkInLinkRestriction, setLinkInLinkRestriction] = (0,
|
|
1813
|
-
const [options, setOptions] = (0,
|
|
1880
|
+
const [linkInLinkRestriction, setLinkInLinkRestriction] = (0, import_react13.useState)((0, import_editor_elements.getLinkInLinkRestriction)(elementId));
|
|
1881
|
+
const [options, setOptions] = (0, import_react13.useState)(
|
|
1814
1882
|
generateFirstLoadedOption(value)
|
|
1815
1883
|
);
|
|
1816
1884
|
const shouldDisableAddingLink = !isActive && linkInLinkRestriction.shouldRestrict;
|
|
@@ -1852,7 +1920,7 @@ var LinkControl = createControl((props) => {
|
|
|
1852
1920
|
}
|
|
1853
1921
|
debounceFetch({ ...requestParams, term: newValue });
|
|
1854
1922
|
};
|
|
1855
|
-
const debounceFetch = (0,
|
|
1923
|
+
const debounceFetch = (0, import_react13.useMemo)(
|
|
1856
1924
|
() => (0, import_utils3.debounce)(
|
|
1857
1925
|
(params) => fetchOptions(endpoint, params).then((newOptions) => {
|
|
1858
1926
|
setOptions(formatOptions(newOptions));
|
|
@@ -1867,7 +1935,8 @@ var LinkControl = createControl((props) => {
|
|
|
1867
1935
|
direction: "row",
|
|
1868
1936
|
sx: {
|
|
1869
1937
|
justifyContent: "space-between",
|
|
1870
|
-
alignItems: "center"
|
|
1938
|
+
alignItems: "center",
|
|
1939
|
+
marginInlineEnd: -0.75
|
|
1871
1940
|
}
|
|
1872
1941
|
},
|
|
1873
1942
|
/* @__PURE__ */ React34.createElement(ControlFormLabel, null, (0, import_i18n9.__)("Link", "elementor")),
|
|
@@ -1906,7 +1975,7 @@ var SwitchControl = ({ disabled }) => {
|
|
|
1906
1975
|
opacity: 0
|
|
1907
1976
|
}
|
|
1908
1977
|
} : {};
|
|
1909
|
-
return /* @__PURE__ */ React34.createElement(import_ui27.Grid, { container: true, alignItems: "center", flexWrap: "nowrap", justifyContent: "space-between" }, /* @__PURE__ */ React34.createElement(import_ui27.Grid, { item: true }, /* @__PURE__ */ React34.createElement(ControlFormLabel, null, (0, import_i18n9.__)("Open in a new tab", "elementor"))), /* @__PURE__ */ React34.createElement(import_ui27.Grid, { item: true }, /* @__PURE__ */ React34.createElement(import_ui27.Switch, { checked: value, onClick, disabled, inputProps })));
|
|
1978
|
+
return /* @__PURE__ */ React34.createElement(import_ui27.Grid, { container: true, alignItems: "center", flexWrap: "nowrap", justifyContent: "space-between" }, /* @__PURE__ */ React34.createElement(import_ui27.Grid, { item: true }, /* @__PURE__ */ React34.createElement(ControlFormLabel, null, (0, import_i18n9.__)("Open in a new tab", "elementor"))), /* @__PURE__ */ React34.createElement(import_ui27.Grid, { item: true, sx: { marginInlineEnd: -1 } }, /* @__PURE__ */ React34.createElement(import_ui27.Switch, { checked: value, onClick, disabled, inputProps })));
|
|
1910
1979
|
};
|
|
1911
1980
|
async function fetchOptions(ajaxUrl, params) {
|
|
1912
1981
|
if (!params || !ajaxUrl) {
|
|
@@ -2019,7 +2088,7 @@ var Control4 = ({ bind, isLinked }) => {
|
|
|
2019
2088
|
|
|
2020
2089
|
// src/controls/svg-media-control.tsx
|
|
2021
2090
|
var React37 = __toESM(require("react"));
|
|
2022
|
-
var
|
|
2091
|
+
var import_react15 = require("react");
|
|
2023
2092
|
var import_editor_props18 = require("@elementor/editor-props");
|
|
2024
2093
|
var import_icons9 = require("@elementor/icons");
|
|
2025
2094
|
var import_ui30 = require("@elementor/ui");
|
|
@@ -2028,7 +2097,7 @@ var import_i18n12 = require("@wordpress/i18n");
|
|
|
2028
2097
|
|
|
2029
2098
|
// src/components/enable-unfiltered-modal.tsx
|
|
2030
2099
|
var React36 = __toESM(require("react"));
|
|
2031
|
-
var
|
|
2100
|
+
var import_react14 = require("react");
|
|
2032
2101
|
var import_editor_current_user = require("@elementor/editor-current-user");
|
|
2033
2102
|
var import_ui29 = require("@elementor/ui");
|
|
2034
2103
|
var import_i18n11 = require("@wordpress/i18n");
|
|
@@ -2051,7 +2120,7 @@ var WAIT_FOR_CLOSE_TIMEOUT_MS = 300;
|
|
|
2051
2120
|
var EnableUnfilteredModal = (props) => {
|
|
2052
2121
|
const { mutateAsync, isPending } = useUpdateUnfilteredFilesUpload();
|
|
2053
2122
|
const { canUser } = (0, import_editor_current_user.useCurrentUserCapabilities)();
|
|
2054
|
-
const [isError, setIsError] = (0,
|
|
2123
|
+
const [isError, setIsError] = (0, import_react14.useState)(false);
|
|
2055
2124
|
const canManageOptions = canUser("manage_options");
|
|
2056
2125
|
const onClose = (enabled) => {
|
|
2057
2126
|
props.onClose(enabled);
|
|
@@ -2116,7 +2185,7 @@ var SvgMediaControl = createControl(() => {
|
|
|
2116
2185
|
const { data: attachment, isFetching } = (0, import_wp_media2.useWpMediaAttachment)(id?.value || null);
|
|
2117
2186
|
const src = attachment?.url ?? url?.value ?? null;
|
|
2118
2187
|
const { data: allowSvgUpload } = useUnfilteredFilesUpload();
|
|
2119
|
-
const [unfilteredModalOpenState, setUnfilteredModalOpenState] = (0,
|
|
2188
|
+
const [unfilteredModalOpenState, setUnfilteredModalOpenState] = (0, import_react15.useState)(false);
|
|
2120
2189
|
const { open } = (0, import_wp_media2.useWpMediaFrame)({
|
|
2121
2190
|
mediaTypes: ["svg"],
|
|
2122
2191
|
multiple: false,
|
|
@@ -2434,7 +2503,7 @@ var BackgroundImageOverlaySize = () => {
|
|
|
2434
2503
|
};
|
|
2435
2504
|
|
|
2436
2505
|
// src/controls/background-control/background-overlay/use-background-tabs-history.ts
|
|
2437
|
-
var
|
|
2506
|
+
var import_react16 = require("react");
|
|
2438
2507
|
var import_editor_props22 = require("@elementor/editor-props");
|
|
2439
2508
|
var import_ui36 = require("@elementor/ui");
|
|
2440
2509
|
var useBackgroundTabsHistory = ({
|
|
@@ -2455,7 +2524,7 @@ var useBackgroundTabsHistory = ({
|
|
|
2455
2524
|
return "image";
|
|
2456
2525
|
};
|
|
2457
2526
|
const { getTabsProps, getTabProps, getTabPanelProps } = (0, import_ui36.useTabs)(getCurrentOverlayType());
|
|
2458
|
-
const valuesHistory = (0,
|
|
2527
|
+
const valuesHistory = (0, import_react16.useRef)({
|
|
2459
2528
|
image: initialBackgroundImageOverlay,
|
|
2460
2529
|
color: initialBackgroundColorOverlay2,
|
|
2461
2530
|
gradient: initialBackgroundGradientOverlay2
|