@elementor/editor-controls 0.24.0 → 0.25.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 +20 -0
- package/dist/index.d.mts +5 -1
- package/dist/index.d.ts +5 -1
- package/dist/index.js +127 -71
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +102 -46
- 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/text-field-inner-selection.tsx +18 -2
- package/src/controls/font-family-control/font-family-control.tsx +2 -0
- 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/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,25 @@
|
|
|
1
1
|
# @elementor/editor-controls
|
|
2
2
|
|
|
3
|
+
## 0.25.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- bba6b02: Ignore restricted characters in number inputs
|
|
8
|
+
- a27cc75: Style tab layout section show correct display value
|
|
9
|
+
- 6a882a0: autofocus on font family popup search input
|
|
10
|
+
- fd5251c: Add prop validation to required fields.
|
|
11
|
+
|
|
12
|
+
### Patch Changes
|
|
13
|
+
|
|
14
|
+
- 03dad77: Rename "defaultValue" to "placeholder" on bound prop context
|
|
15
|
+
- Updated dependencies [5fa575c]
|
|
16
|
+
- Updated dependencies [044815b]
|
|
17
|
+
- Updated dependencies [fe0ab45]
|
|
18
|
+
- Updated dependencies [fd5251c]
|
|
19
|
+
- @elementor/editor-elements@0.8.1
|
|
20
|
+
- @elementor/editor-ui@0.7.1
|
|
21
|
+
- @elementor/editor-props@0.12.0
|
|
22
|
+
|
|
3
23
|
## 0.24.0
|
|
4
24
|
|
|
5
25
|
### Minor Changes
|
package/dist/index.d.mts
CHANGED
|
@@ -184,16 +184,18 @@ type PropContext<T extends PropValue, P extends PropType> = {
|
|
|
184
184
|
setValue: SetValue<T>;
|
|
185
185
|
value: T | null;
|
|
186
186
|
propType: P;
|
|
187
|
+
placeholder?: T;
|
|
187
188
|
};
|
|
188
189
|
declare const PropContext: React.Context<PropContext<PropValue, PropType> | null>;
|
|
189
190
|
type PropProviderProps<T extends PropValue, P extends PropType> = React.PropsWithChildren<PropContext<T, P>>;
|
|
190
|
-
declare const PropProvider: <T extends PropValue, P extends PropType>({ children, value, setValue, propType, }: PropProviderProps<T, P>) => React.JSX.Element;
|
|
191
|
+
declare const PropProvider: <T extends PropValue, P extends PropType>({ children, value, setValue, propType, placeholder, }: PropProviderProps<T, P>) => React.JSX.Element;
|
|
191
192
|
|
|
192
193
|
type PropKeyContextValue<T, P> = {
|
|
193
194
|
bind: PropKey;
|
|
194
195
|
setValue: SetValue<T>;
|
|
195
196
|
value: T;
|
|
196
197
|
propType: P;
|
|
198
|
+
placeholder?: T;
|
|
197
199
|
path: PropKey[];
|
|
198
200
|
};
|
|
199
201
|
type PropKeyProviderProps = React.PropsWithChildren<{
|
|
@@ -206,7 +208,9 @@ type UseBoundProp<TValue extends PropValue> = {
|
|
|
206
208
|
setValue: SetValue<TValue | null>;
|
|
207
209
|
value: TValue;
|
|
208
210
|
propType: PropType;
|
|
211
|
+
placeholder?: TValue;
|
|
209
212
|
path: PropKey[];
|
|
213
|
+
restoreValue: () => void;
|
|
210
214
|
};
|
|
211
215
|
declare function useBoundProp<T extends PropValue = PropValue>(): PropKeyContextValue<T, PropType>;
|
|
212
216
|
declare function useBoundProp<TKey extends string, TValue extends PropValue>(propTypeUtil: PropTypeUtil<TKey, TValue>): UseBoundProp<TValue>;
|
package/dist/index.d.ts
CHANGED
|
@@ -184,16 +184,18 @@ type PropContext<T extends PropValue, P extends PropType> = {
|
|
|
184
184
|
setValue: SetValue<T>;
|
|
185
185
|
value: T | null;
|
|
186
186
|
propType: P;
|
|
187
|
+
placeholder?: T;
|
|
187
188
|
};
|
|
188
189
|
declare const PropContext: React.Context<PropContext<PropValue, PropType> | null>;
|
|
189
190
|
type PropProviderProps<T extends PropValue, P extends PropType> = React.PropsWithChildren<PropContext<T, P>>;
|
|
190
|
-
declare const PropProvider: <T extends PropValue, P extends PropType>({ children, value, setValue, propType, }: PropProviderProps<T, P>) => React.JSX.Element;
|
|
191
|
+
declare const PropProvider: <T extends PropValue, P extends PropType>({ children, value, setValue, propType, placeholder, }: PropProviderProps<T, P>) => React.JSX.Element;
|
|
191
192
|
|
|
192
193
|
type PropKeyContextValue<T, P> = {
|
|
193
194
|
bind: PropKey;
|
|
194
195
|
setValue: SetValue<T>;
|
|
195
196
|
value: T;
|
|
196
197
|
propType: P;
|
|
198
|
+
placeholder?: T;
|
|
197
199
|
path: PropKey[];
|
|
198
200
|
};
|
|
199
201
|
type PropKeyProviderProps = React.PropsWithChildren<{
|
|
@@ -206,7 +208,9 @@ type UseBoundProp<TValue extends PropValue> = {
|
|
|
206
208
|
setValue: SetValue<TValue | null>;
|
|
207
209
|
value: TValue;
|
|
208
210
|
propType: PropType;
|
|
211
|
+
placeholder?: TValue;
|
|
209
212
|
path: PropKey[];
|
|
213
|
+
restoreValue: () => void;
|
|
210
214
|
};
|
|
211
215
|
declare function useBoundProp<T extends PropValue = PropValue>(): PropKeyContextValue<T, PropType>;
|
|
212
216
|
declare function useBoundProp<TKey extends string, TValue extends PropValue>(propTypeUtil: PropTypeUtil<TKey, TValue>): UseBoundProp<TValue>;
|
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
|
};
|
|
@@ -923,7 +972,7 @@ var RepeaterItem = ({
|
|
|
923
972
|
openOnMount,
|
|
924
973
|
onOpen
|
|
925
974
|
}) => {
|
|
926
|
-
const [anchorEl, setAnchorEl] = (0,
|
|
975
|
+
const [anchorEl, setAnchorEl] = (0, import_react9.useState)(null);
|
|
927
976
|
const { popoverState, popoverProps, ref, setRef } = usePopover(openOnMount, onOpen);
|
|
928
977
|
const duplicateLabel = (0, import_i18n4.__)("Duplicate", "elementor");
|
|
929
978
|
const toggleLabel = disabled ? (0, import_i18n4.__)("Show", "elementor") : (0, import_i18n4.__)("Hide", "elementor");
|
|
@@ -959,10 +1008,10 @@ var RepeaterItem = ({
|
|
|
959
1008
|
));
|
|
960
1009
|
};
|
|
961
1010
|
var usePopover = (openOnMount, onOpen) => {
|
|
962
|
-
const [ref, setRef] = (0,
|
|
1011
|
+
const [ref, setRef] = (0, import_react9.useState)(null);
|
|
963
1012
|
const popoverState = (0, import_ui17.usePopupState)({ variant: "popover" });
|
|
964
1013
|
const popoverProps = (0, import_ui17.bindPopover)(popoverState);
|
|
965
|
-
(0,
|
|
1014
|
+
(0, import_react9.useEffect)(() => {
|
|
966
1015
|
if (openOnMount && ref) {
|
|
967
1016
|
popoverState.open(ref);
|
|
968
1017
|
onOpen?.();
|
|
@@ -1137,7 +1186,7 @@ var ToggleControl = createControl(
|
|
|
1137
1186
|
size = "tiny",
|
|
1138
1187
|
exclusive = true
|
|
1139
1188
|
}) => {
|
|
1140
|
-
const { value, setValue } = useBoundProp(import_editor_props10.stringPropTypeUtil);
|
|
1189
|
+
const { value, setValue, placeholder } = useBoundProp(import_editor_props10.stringPropTypeUtil);
|
|
1141
1190
|
const exclusiveValues = options.filter((option) => option.exclusive).map((option) => option.value);
|
|
1142
1191
|
const handleNonExclusiveToggle = (selectedValues) => {
|
|
1143
1192
|
const newSelectedValue = selectedValues[selectedValues.length - 1];
|
|
@@ -1154,7 +1203,7 @@ var ToggleControl = createControl(
|
|
|
1154
1203
|
ControlToggleButtonGroup,
|
|
1155
1204
|
{
|
|
1156
1205
|
...toggleButtonGroupProps,
|
|
1157
|
-
value: value ?? null,
|
|
1206
|
+
value: value ?? placeholder ?? null,
|
|
1158
1207
|
onChange: setValue,
|
|
1159
1208
|
exclusive: true
|
|
1160
1209
|
}
|
|
@@ -1162,7 +1211,7 @@ var ToggleControl = createControl(
|
|
|
1162
1211
|
ControlToggleButtonGroup,
|
|
1163
1212
|
{
|
|
1164
1213
|
...toggleButtonGroupProps,
|
|
1165
|
-
value: value?.split(" ") ?? [],
|
|
1214
|
+
value: (value ?? placeholder)?.split(" ") ?? [],
|
|
1166
1215
|
onChange: handleNonExclusiveToggle,
|
|
1167
1216
|
exclusive: false
|
|
1168
1217
|
}
|
|
@@ -1175,6 +1224,7 @@ var React27 = __toESM(require("react"));
|
|
|
1175
1224
|
var import_editor_props11 = require("@elementor/editor-props");
|
|
1176
1225
|
var import_ui20 = require("@elementor/ui");
|
|
1177
1226
|
var isEmptyOrNaN = (value) => value === null || value === void 0 || value === "" || Number.isNaN(Number(value));
|
|
1227
|
+
var RESTRICTED_INPUT_KEYS2 = ["e", "E", "+", "-"];
|
|
1178
1228
|
var NumberControl = createControl(
|
|
1179
1229
|
({
|
|
1180
1230
|
placeholder,
|
|
@@ -1202,7 +1252,12 @@ var NumberControl = createControl(
|
|
|
1202
1252
|
value: isEmptyOrNaN(value) ? "" : value,
|
|
1203
1253
|
onChange: handleChange,
|
|
1204
1254
|
placeholder,
|
|
1205
|
-
inputProps: { step }
|
|
1255
|
+
inputProps: { step },
|
|
1256
|
+
onKeyDown: (event) => {
|
|
1257
|
+
if (RESTRICTED_INPUT_KEYS2.includes(event.key)) {
|
|
1258
|
+
event.preventDefault();
|
|
1259
|
+
}
|
|
1260
|
+
}
|
|
1206
1261
|
}
|
|
1207
1262
|
));
|
|
1208
1263
|
}
|
|
@@ -1210,7 +1265,7 @@ var NumberControl = createControl(
|
|
|
1210
1265
|
|
|
1211
1266
|
// src/controls/equal-unequal-sizes-control.tsx
|
|
1212
1267
|
var React29 = __toESM(require("react"));
|
|
1213
|
-
var
|
|
1268
|
+
var import_react10 = require("react");
|
|
1214
1269
|
var import_editor_props12 = require("@elementor/editor-props");
|
|
1215
1270
|
var import_ui22 = require("@elementor/ui");
|
|
1216
1271
|
var import_i18n6 = require("@wordpress/i18n");
|
|
@@ -1240,8 +1295,8 @@ function EqualUnequalSizesControl({
|
|
|
1240
1295
|
items,
|
|
1241
1296
|
multiSizePropTypeUtil
|
|
1242
1297
|
}) {
|
|
1243
|
-
const popupId = (0,
|
|
1244
|
-
const controlRef = (0,
|
|
1298
|
+
const popupId = (0, import_react10.useId)();
|
|
1299
|
+
const controlRef = (0, import_react10.useRef)(null);
|
|
1245
1300
|
const popupState = (0, import_ui22.usePopupState)({ variant: "popover", popupId });
|
|
1246
1301
|
const {
|
|
1247
1302
|
propType: multiSizePropType,
|
|
@@ -1407,7 +1462,7 @@ var Control3 = ({
|
|
|
1407
1462
|
|
|
1408
1463
|
// src/controls/font-family-control/font-family-control.tsx
|
|
1409
1464
|
var React31 = __toESM(require("react"));
|
|
1410
|
-
var
|
|
1465
|
+
var import_react11 = require("react");
|
|
1411
1466
|
var import_editor_props14 = require("@elementor/editor-props");
|
|
1412
1467
|
var import_icons5 = require("@elementor/icons");
|
|
1413
1468
|
var import_ui24 = require("@elementor/ui");
|
|
@@ -1440,7 +1495,7 @@ var enqueueFont = (fontFamily, context = "editor") => {
|
|
|
1440
1495
|
// src/controls/font-family-control/font-family-control.tsx
|
|
1441
1496
|
var SIZE2 = "tiny";
|
|
1442
1497
|
var FontFamilyControl = createControl(({ fontFamilies }) => {
|
|
1443
|
-
const [searchValue, setSearchValue] = (0,
|
|
1498
|
+
const [searchValue, setSearchValue] = (0, import_react11.useState)("");
|
|
1444
1499
|
const { value: fontFamily, setValue: setFontFamily } = useBoundProp(import_editor_props14.stringPropTypeUtil);
|
|
1445
1500
|
const popoverState = (0, import_ui24.usePopupState)({ variant: "popover" });
|
|
1446
1501
|
const filteredFontFamilies = useFilteredFontFamilies(fontFamilies, searchValue);
|
|
@@ -1472,6 +1527,7 @@ var FontFamilyControl = createControl(({ fontFamilies }) => {
|
|
|
1472
1527
|
/* @__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
1528
|
import_ui24.TextField,
|
|
1474
1529
|
{
|
|
1530
|
+
autoFocus: true,
|
|
1475
1531
|
fullWidth: true,
|
|
1476
1532
|
size: SIZE2,
|
|
1477
1533
|
value: searchValue,
|
|
@@ -1524,7 +1580,7 @@ var FontFamilyControl = createControl(({ fontFamilies }) => {
|
|
|
1524
1580
|
var LIST_ITEM_HEIGHT = 36;
|
|
1525
1581
|
var LIST_ITEMS_BUFFER = 6;
|
|
1526
1582
|
var FontList = ({ fontListItems, setFontFamily, handleClose, fontFamily }) => {
|
|
1527
|
-
const containerRef = (0,
|
|
1583
|
+
const containerRef = (0, import_react11.useRef)(null);
|
|
1528
1584
|
const selectedItem = fontListItems.find((item) => item.value === fontFamily);
|
|
1529
1585
|
const debouncedVirtualizeChange = useDebounce(({ getVirtualIndexes }) => {
|
|
1530
1586
|
getVirtualIndexes().forEach((index) => {
|
|
@@ -1541,7 +1597,7 @@ var FontList = ({ fontListItems, setFontFamily, handleClose, fontFamily }) => {
|
|
|
1541
1597
|
overscan: LIST_ITEMS_BUFFER,
|
|
1542
1598
|
onChange: debouncedVirtualizeChange
|
|
1543
1599
|
});
|
|
1544
|
-
(0,
|
|
1600
|
+
(0, import_react11.useEffect)(
|
|
1545
1601
|
() => {
|
|
1546
1602
|
virtualizer.scrollToIndex(fontListItems.findIndex((item) => item.value === fontFamily));
|
|
1547
1603
|
},
|
|
@@ -1649,8 +1705,8 @@ var StyledMenuList = (0, import_ui24.styled)(import_ui24.MenuList)(({ theme }) =
|
|
|
1649
1705
|
position: "relative"
|
|
1650
1706
|
}));
|
|
1651
1707
|
var useDebounce = (fn, delay) => {
|
|
1652
|
-
const [debouncedFn] = (0,
|
|
1653
|
-
(0,
|
|
1708
|
+
const [debouncedFn] = (0, import_react11.useState)(() => (0, import_utils2.debounce)(fn, delay));
|
|
1709
|
+
(0, import_react11.useEffect)(() => () => debouncedFn.cancel(), [debouncedFn]);
|
|
1654
1710
|
return debouncedFn;
|
|
1655
1711
|
};
|
|
1656
1712
|
|
|
@@ -1675,7 +1731,7 @@ var UrlControl = createControl(({ placeholder }) => {
|
|
|
1675
1731
|
|
|
1676
1732
|
// src/controls/link-control.tsx
|
|
1677
1733
|
var React34 = __toESM(require("react"));
|
|
1678
|
-
var
|
|
1734
|
+
var import_react13 = require("react");
|
|
1679
1735
|
var import_editor_elements = require("@elementor/editor-elements");
|
|
1680
1736
|
var import_editor_props16 = require("@elementor/editor-props");
|
|
1681
1737
|
var import_editor_ui3 = require("@elementor/editor-ui");
|
|
@@ -1688,10 +1744,10 @@ var import_i18n9 = require("@wordpress/i18n");
|
|
|
1688
1744
|
|
|
1689
1745
|
// src/components/autocomplete.tsx
|
|
1690
1746
|
var React33 = __toESM(require("react"));
|
|
1691
|
-
var
|
|
1747
|
+
var import_react12 = require("react");
|
|
1692
1748
|
var import_icons6 = require("@elementor/icons");
|
|
1693
1749
|
var import_ui26 = require("@elementor/ui");
|
|
1694
|
-
var Autocomplete = (0,
|
|
1750
|
+
var Autocomplete = (0, import_react12.forwardRef)((props, ref) => {
|
|
1695
1751
|
const {
|
|
1696
1752
|
options,
|
|
1697
1753
|
onOptionChange,
|
|
@@ -1801,7 +1857,7 @@ var learnMoreButton = {
|
|
|
1801
1857
|
var LinkControl = createControl((props) => {
|
|
1802
1858
|
const { value, path, setValue, ...propContext } = useBoundProp(import_editor_props16.linkPropTypeUtil);
|
|
1803
1859
|
const [linkSessionValue, setLinkSessionValue] = (0, import_session.useSessionStorage)(path.join("/"));
|
|
1804
|
-
const [isActive, setIsActive] = (0,
|
|
1860
|
+
const [isActive, setIsActive] = (0, import_react13.useState)(!!value);
|
|
1805
1861
|
const {
|
|
1806
1862
|
allowCustomValues,
|
|
1807
1863
|
queryOptions: { endpoint = "", requestParams = {} },
|
|
@@ -1809,8 +1865,8 @@ var LinkControl = createControl((props) => {
|
|
|
1809
1865
|
minInputLength = 2,
|
|
1810
1866
|
context: { elementId }
|
|
1811
1867
|
} = props || {};
|
|
1812
|
-
const [linkInLinkRestriction, setLinkInLinkRestriction] = (0,
|
|
1813
|
-
const [options, setOptions] = (0,
|
|
1868
|
+
const [linkInLinkRestriction, setLinkInLinkRestriction] = (0, import_react13.useState)((0, import_editor_elements.getLinkInLinkRestriction)(elementId));
|
|
1869
|
+
const [options, setOptions] = (0, import_react13.useState)(
|
|
1814
1870
|
generateFirstLoadedOption(value)
|
|
1815
1871
|
);
|
|
1816
1872
|
const shouldDisableAddingLink = !isActive && linkInLinkRestriction.shouldRestrict;
|
|
@@ -1852,7 +1908,7 @@ var LinkControl = createControl((props) => {
|
|
|
1852
1908
|
}
|
|
1853
1909
|
debounceFetch({ ...requestParams, term: newValue });
|
|
1854
1910
|
};
|
|
1855
|
-
const debounceFetch = (0,
|
|
1911
|
+
const debounceFetch = (0, import_react13.useMemo)(
|
|
1856
1912
|
() => (0, import_utils3.debounce)(
|
|
1857
1913
|
(params) => fetchOptions(endpoint, params).then((newOptions) => {
|
|
1858
1914
|
setOptions(formatOptions(newOptions));
|
|
@@ -2019,7 +2075,7 @@ var Control4 = ({ bind, isLinked }) => {
|
|
|
2019
2075
|
|
|
2020
2076
|
// src/controls/svg-media-control.tsx
|
|
2021
2077
|
var React37 = __toESM(require("react"));
|
|
2022
|
-
var
|
|
2078
|
+
var import_react15 = require("react");
|
|
2023
2079
|
var import_editor_props18 = require("@elementor/editor-props");
|
|
2024
2080
|
var import_icons9 = require("@elementor/icons");
|
|
2025
2081
|
var import_ui30 = require("@elementor/ui");
|
|
@@ -2028,7 +2084,7 @@ var import_i18n12 = require("@wordpress/i18n");
|
|
|
2028
2084
|
|
|
2029
2085
|
// src/components/enable-unfiltered-modal.tsx
|
|
2030
2086
|
var React36 = __toESM(require("react"));
|
|
2031
|
-
var
|
|
2087
|
+
var import_react14 = require("react");
|
|
2032
2088
|
var import_editor_current_user = require("@elementor/editor-current-user");
|
|
2033
2089
|
var import_ui29 = require("@elementor/ui");
|
|
2034
2090
|
var import_i18n11 = require("@wordpress/i18n");
|
|
@@ -2051,7 +2107,7 @@ var WAIT_FOR_CLOSE_TIMEOUT_MS = 300;
|
|
|
2051
2107
|
var EnableUnfilteredModal = (props) => {
|
|
2052
2108
|
const { mutateAsync, isPending } = useUpdateUnfilteredFilesUpload();
|
|
2053
2109
|
const { canUser } = (0, import_editor_current_user.useCurrentUserCapabilities)();
|
|
2054
|
-
const [isError, setIsError] = (0,
|
|
2110
|
+
const [isError, setIsError] = (0, import_react14.useState)(false);
|
|
2055
2111
|
const canManageOptions = canUser("manage_options");
|
|
2056
2112
|
const onClose = (enabled) => {
|
|
2057
2113
|
props.onClose(enabled);
|
|
@@ -2116,7 +2172,7 @@ var SvgMediaControl = createControl(() => {
|
|
|
2116
2172
|
const { data: attachment, isFetching } = (0, import_wp_media2.useWpMediaAttachment)(id?.value || null);
|
|
2117
2173
|
const src = attachment?.url ?? url?.value ?? null;
|
|
2118
2174
|
const { data: allowSvgUpload } = useUnfilteredFilesUpload();
|
|
2119
|
-
const [unfilteredModalOpenState, setUnfilteredModalOpenState] = (0,
|
|
2175
|
+
const [unfilteredModalOpenState, setUnfilteredModalOpenState] = (0, import_react15.useState)(false);
|
|
2120
2176
|
const { open } = (0, import_wp_media2.useWpMediaFrame)({
|
|
2121
2177
|
mediaTypes: ["svg"],
|
|
2122
2178
|
multiple: false,
|
|
@@ -2434,7 +2490,7 @@ var BackgroundImageOverlaySize = () => {
|
|
|
2434
2490
|
};
|
|
2435
2491
|
|
|
2436
2492
|
// src/controls/background-control/background-overlay/use-background-tabs-history.ts
|
|
2437
|
-
var
|
|
2493
|
+
var import_react16 = require("react");
|
|
2438
2494
|
var import_editor_props22 = require("@elementor/editor-props");
|
|
2439
2495
|
var import_ui36 = require("@elementor/ui");
|
|
2440
2496
|
var useBackgroundTabsHistory = ({
|
|
@@ -2455,7 +2511,7 @@ var useBackgroundTabsHistory = ({
|
|
|
2455
2511
|
return "image";
|
|
2456
2512
|
};
|
|
2457
2513
|
const { getTabsProps, getTabProps, getTabPanelProps } = (0, import_ui36.useTabs)(getCurrentOverlayType());
|
|
2458
|
-
const valuesHistory = (0,
|
|
2514
|
+
const valuesHistory = (0, import_react16.useRef)({
|
|
2459
2515
|
image: initialBackgroundImageOverlay,
|
|
2460
2516
|
color: initialBackgroundColorOverlay2,
|
|
2461
2517
|
gradient: initialBackgroundGradientOverlay2
|