@elementor/editor-controls 0.1.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.
Files changed (36) hide show
  1. package/CHANGELOG.md +22 -0
  2. package/README.md +4 -0
  3. package/dist/index.d.mts +148 -0
  4. package/dist/index.d.ts +148 -0
  5. package/dist/index.js +1346 -0
  6. package/dist/index.js.map +1 -0
  7. package/dist/index.mjs +1320 -0
  8. package/dist/index.mjs.map +1 -0
  9. package/package.json +52 -0
  10. package/src/bound-prop-context.tsx +30 -0
  11. package/src/components/control-label.tsx +10 -0
  12. package/src/components/control-toggle-button-group.tsx +84 -0
  13. package/src/components/repeater.tsx +200 -0
  14. package/src/components/text-field-inner-selection.tsx +76 -0
  15. package/src/control-actions/control-actions-context.tsx +27 -0
  16. package/src/control-actions/control-actions.tsx +32 -0
  17. package/src/controls/background-overlay-repeater-control.tsx +119 -0
  18. package/src/controls/box-shadow-repeater-control.tsx +227 -0
  19. package/src/controls/color-control.tsx +32 -0
  20. package/src/controls/equal-unequal-sizes-control.tsx +231 -0
  21. package/src/controls/font-family-control.tsx +154 -0
  22. package/src/controls/image-control.tsx +64 -0
  23. package/src/controls/image-media-control.tsx +71 -0
  24. package/src/controls/linked-dimensions-control.tsx +140 -0
  25. package/src/controls/number-control.tsx +31 -0
  26. package/src/controls/select-control.tsx +31 -0
  27. package/src/controls/size-control.tsx +77 -0
  28. package/src/controls/stroke-control.tsx +106 -0
  29. package/src/controls/text-area-control.tsx +32 -0
  30. package/src/controls/text-control.tsx +18 -0
  31. package/src/controls/toggle-control.tsx +34 -0
  32. package/src/create-control-replacement.tsx +54 -0
  33. package/src/create-control.tsx +41 -0
  34. package/src/hooks/use-filtered-font-families.ts +38 -0
  35. package/src/hooks/use-sync-external-state.tsx +51 -0
  36. package/src/index.ts +31 -0
package/dist/index.js ADDED
@@ -0,0 +1,1346 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+
30
+ // src/index.ts
31
+ var src_exports = {};
32
+ __export(src_exports, {
33
+ BackgroundOverlayRepeaterControl: () => BackgroundOverlayRepeaterControl,
34
+ BoundPropProvider: () => BoundPropProvider,
35
+ BoxShadowRepeaterControl: () => BoxShadowRepeaterControl,
36
+ ColorControl: () => ColorControl,
37
+ ControlActionsProvider: () => ControlActionsProvider,
38
+ ControlLabel: () => ControlLabel,
39
+ ControlReplacementProvider: () => ControlReplacementProvider,
40
+ EqualUnequalSizesControl: () => EqualUnequalSizesControl,
41
+ FontFamilyControl: () => FontFamilyControl,
42
+ ImageControl: () => ImageControl,
43
+ LinkedDimensionsControl: () => LinkedDimensionsControl,
44
+ NumberControl: () => NumberControl,
45
+ SelectControl: () => SelectControl,
46
+ SizeControl: () => SizeControl,
47
+ StrokeControl: () => StrokeControl,
48
+ TextAreaControl: () => TextAreaControl,
49
+ TextControl: () => TextControl,
50
+ ToggleControl: () => ToggleControl,
51
+ createControlReplacement: () => createControlReplacement,
52
+ useBoundProp: () => useBoundProp,
53
+ useControlActions: () => useControlActions,
54
+ useSyncExternalState: () => useSyncExternalState
55
+ });
56
+ module.exports = __toCommonJS(src_exports);
57
+
58
+ // src/controls/image-control.tsx
59
+ var React9 = __toESM(require("react"));
60
+ var import_ui6 = require("@elementor/ui");
61
+ var import_i18n2 = require("@wordpress/i18n");
62
+
63
+ // src/bound-prop-context.tsx
64
+ var React = __toESM(require("react"));
65
+ var import_react = require("react");
66
+ var BoundPropContext = (0, import_react.createContext)(null);
67
+ var BoundPropProvider = ({ children, value, setValue, bind }) => {
68
+ return /* @__PURE__ */ React.createElement(BoundPropContext.Provider, { value: { value, setValue, bind } }, children);
69
+ };
70
+ function useBoundProp(defaultValue) {
71
+ const boundPropContext = (0, import_react.useContext)(BoundPropContext);
72
+ if (!boundPropContext) {
73
+ throw new Error("useBoundProp must be used within a BoundPropContext");
74
+ }
75
+ return { ...boundPropContext, value: boundPropContext.value ?? defaultValue };
76
+ }
77
+
78
+ // src/components/control-label.tsx
79
+ var React2 = __toESM(require("react"));
80
+ var import_ui = require("@elementor/ui");
81
+ var ControlLabel = ({ children }) => {
82
+ return /* @__PURE__ */ React2.createElement(import_ui.Typography, { component: "label", variant: "caption", color: "text.secondary" }, children);
83
+ };
84
+
85
+ // src/create-control.tsx
86
+ var React4 = __toESM(require("react"));
87
+ var import_ui2 = require("@elementor/ui");
88
+
89
+ // src/create-control-replacement.tsx
90
+ var React3 = __toESM(require("react"));
91
+ var import_react2 = require("react");
92
+ var ControlReplacementContext = (0, import_react2.createContext)(void 0);
93
+ var ControlReplacementProvider = ({
94
+ component,
95
+ condition,
96
+ children
97
+ }) => {
98
+ return /* @__PURE__ */ React3.createElement(ControlReplacementContext.Provider, { value: { component, condition } }, children);
99
+ };
100
+ var useControlReplacement = () => {
101
+ const { value } = useBoundProp();
102
+ const controlReplacement = (0, import_react2.useContext)(ControlReplacementContext);
103
+ let shouldReplace = false;
104
+ try {
105
+ shouldReplace = !!controlReplacement?.condition({ value }) && !!controlReplacement.component;
106
+ } catch {
107
+ }
108
+ return shouldReplace ? controlReplacement?.component : void 0;
109
+ };
110
+ var createControlReplacement = () => {
111
+ let controlReplacement;
112
+ function replaceControl({ component, condition }) {
113
+ controlReplacement = { component, condition };
114
+ }
115
+ function getControlReplacement() {
116
+ return controlReplacement;
117
+ }
118
+ return { replaceControl, getControlReplacement };
119
+ };
120
+
121
+ // src/create-control.tsx
122
+ var brandSymbol = Symbol("control");
123
+ function createControl(Component, { supportsReplacements = true } = {}) {
124
+ return (props) => {
125
+ const ControlReplacement = useControlReplacement();
126
+ if (ControlReplacement && supportsReplacements) {
127
+ return /* @__PURE__ */ React4.createElement(import_ui2.ErrorBoundary, { fallback: null }, /* @__PURE__ */ React4.createElement(ControlReplacement, { ...props }));
128
+ }
129
+ return /* @__PURE__ */ React4.createElement(import_ui2.ErrorBoundary, { fallback: null }, /* @__PURE__ */ React4.createElement(Component, { ...props }));
130
+ };
131
+ }
132
+
133
+ // src/controls/image-media-control.tsx
134
+ var React7 = __toESM(require("react"));
135
+ var import_icons = require("@elementor/icons");
136
+ var import_ui4 = require("@elementor/ui");
137
+ var import_wp_media = require("@elementor/wp-media");
138
+ var import_i18n = require("@wordpress/i18n");
139
+
140
+ // src/control-actions/control-actions.tsx
141
+ var React6 = __toESM(require("react"));
142
+ var import_ui3 = require("@elementor/ui");
143
+
144
+ // src/control-actions/control-actions-context.tsx
145
+ var React5 = __toESM(require("react"));
146
+ var import_react3 = require("react");
147
+ var Context = (0, import_react3.createContext)(null);
148
+ var ControlActionsProvider = ({ children, items }) => /* @__PURE__ */ React5.createElement(Context.Provider, { value: { items } }, children);
149
+ var useControlActions = () => {
150
+ const context = (0, import_react3.useContext)(Context);
151
+ if (!context) {
152
+ throw new Error("useControlActions must be used within a ControlActionsProvider");
153
+ }
154
+ return context;
155
+ };
156
+
157
+ // src/control-actions/control-actions.tsx
158
+ var FloatingBarContainer = (0, import_ui3.styled)("span")`
159
+ display: contents;
160
+
161
+ .MuiFloatingActionBar-popper:has( .MuiFloatingActionBar-actions:empty ) {
162
+ display: none;
163
+ }
164
+ `;
165
+ function ControlActions({ children }) {
166
+ const { items } = useControlActions();
167
+ if (items.length === 0) {
168
+ return children;
169
+ }
170
+ const menuItems = items.map(({ MenuItem: MenuItem4, id }) => /* @__PURE__ */ React6.createElement(MenuItem4, { key: id }));
171
+ return /* @__PURE__ */ React6.createElement(FloatingBarContainer, null, /* @__PURE__ */ React6.createElement(import_ui3.UnstableFloatingActionBar, { actions: menuItems }, children));
172
+ }
173
+
174
+ // src/controls/image-media-control.tsx
175
+ var ImageMediaControl = createControl(() => {
176
+ const { value, setValue } = useBoundProp();
177
+ const { id, url } = value?.value ?? {};
178
+ const { data: attachment, isFetching } = (0, import_wp_media.useWpMediaAttachment)(id?.value || null);
179
+ const src = attachment?.url ?? url;
180
+ const { open } = (0, import_wp_media.useWpMediaFrame)({
181
+ types: ["image"],
182
+ multiple: false,
183
+ selected: id?.value || null,
184
+ onSelect: (selectedAttachment) => {
185
+ setValue({
186
+ $$type: "image-src",
187
+ value: {
188
+ id: {
189
+ $$type: "image-attachment-id",
190
+ value: selectedAttachment.id
191
+ },
192
+ url: null
193
+ }
194
+ });
195
+ }
196
+ });
197
+ return /* @__PURE__ */ React7.createElement(import_ui4.Card, { variant: "outlined" }, /* @__PURE__ */ React7.createElement(import_ui4.CardMedia, { image: src, sx: { height: 150 } }, isFetching ? /* @__PURE__ */ React7.createElement(import_ui4.Stack, { justifyContent: "center", alignItems: "center", width: "100%", height: "100%" }, /* @__PURE__ */ React7.createElement(import_ui4.CircularProgress, null)) : null), /* @__PURE__ */ React7.createElement(import_ui4.CardOverlay, null, /* @__PURE__ */ React7.createElement(ControlActions, null, /* @__PURE__ */ React7.createElement(import_ui4.Stack, { gap: 1 }, /* @__PURE__ */ React7.createElement(
198
+ import_ui4.Button,
199
+ {
200
+ size: "tiny",
201
+ color: "inherit",
202
+ variant: "outlined",
203
+ onClick: () => open({ mode: "browse" })
204
+ },
205
+ (0, import_i18n.__)("Select Image", "elementor")
206
+ ), /* @__PURE__ */ React7.createElement(
207
+ import_ui4.Button,
208
+ {
209
+ size: "tiny",
210
+ variant: "text",
211
+ color: "inherit",
212
+ startIcon: /* @__PURE__ */ React7.createElement(import_icons.UploadIcon, null),
213
+ onClick: () => open({ mode: "upload" })
214
+ },
215
+ (0, import_i18n.__)("Upload Image", "elementor")
216
+ )))));
217
+ });
218
+
219
+ // src/controls/select-control.tsx
220
+ var React8 = __toESM(require("react"));
221
+ var import_ui5 = require("@elementor/ui");
222
+ var SelectControl = createControl(({ options }) => {
223
+ const { value, setValue } = useBoundProp();
224
+ const handleChange = (event) => {
225
+ setValue(event.target.value);
226
+ };
227
+ return /* @__PURE__ */ React8.createElement(ControlActions, null, /* @__PURE__ */ React8.createElement(import_ui5.Select, { displayEmpty: true, size: "tiny", value: value ?? "", onChange: handleChange, fullWidth: true }, options.map(({ label, ...props }) => /* @__PURE__ */ React8.createElement(import_ui5.MenuItem, { key: props.value, ...props }, label))));
228
+ });
229
+
230
+ // src/controls/image-control.tsx
231
+ var ImageControl = createControl((props) => {
232
+ const { value, setValue } = useBoundProp();
233
+ const { src, size } = value?.value || {};
234
+ const setImageSrc = (newValue) => {
235
+ setValue({
236
+ $$type: "image",
237
+ value: {
238
+ src: newValue,
239
+ size
240
+ }
241
+ });
242
+ };
243
+ const setImageSize = (newValue) => {
244
+ setValue({
245
+ $$type: "image",
246
+ value: {
247
+ src,
248
+ size: newValue
249
+ }
250
+ });
251
+ };
252
+ return /* @__PURE__ */ React9.createElement(import_ui6.Stack, { gap: 1.5 }, /* @__PURE__ */ React9.createElement(BoundPropProvider, { value: src, setValue: setImageSrc, bind: "src" }, /* @__PURE__ */ React9.createElement(ImageMediaControl, null)), /* @__PURE__ */ React9.createElement(BoundPropProvider, { value: size, setValue: setImageSize, bind: "size" }, /* @__PURE__ */ React9.createElement(import_ui6.Grid, { container: true, gap: 2, alignItems: "center", flexWrap: "nowrap" }, /* @__PURE__ */ React9.createElement(import_ui6.Grid, { item: true, xs: 6 }, /* @__PURE__ */ React9.createElement(ControlLabel, null, " ", (0, import_i18n2.__)("Image Resolution", "elementor"))), /* @__PURE__ */ React9.createElement(import_ui6.Grid, { item: true, xs: 6 }, /* @__PURE__ */ React9.createElement(SelectControl, { options: props.sizes })))));
253
+ });
254
+
255
+ // src/controls/text-control.tsx
256
+ var React10 = __toESM(require("react"));
257
+ var import_ui7 = require("@elementor/ui");
258
+ var TextControl = createControl(({ placeholder }) => {
259
+ const { value, setValue } = useBoundProp("");
260
+ const handleChange = (event) => setValue(event.target.value);
261
+ return /* @__PURE__ */ React10.createElement(ControlActions, null, /* @__PURE__ */ React10.createElement(import_ui7.TextField, { size: "tiny", fullWidth: true, value, onChange: handleChange, placeholder }));
262
+ });
263
+
264
+ // src/controls/text-area-control.tsx
265
+ var React11 = __toESM(require("react"));
266
+ var import_ui8 = require("@elementor/ui");
267
+ var TextAreaControl = createControl(({ placeholder }) => {
268
+ const { value, setValue } = useBoundProp();
269
+ const handleChange = (event) => {
270
+ setValue(event.target.value);
271
+ };
272
+ return /* @__PURE__ */ React11.createElement(ControlActions, null, /* @__PURE__ */ React11.createElement(
273
+ import_ui8.TextField,
274
+ {
275
+ size: "tiny",
276
+ multiline: true,
277
+ fullWidth: true,
278
+ rows: 5,
279
+ value,
280
+ onChange: handleChange,
281
+ placeholder
282
+ }
283
+ ));
284
+ });
285
+
286
+ // src/controls/size-control.tsx
287
+ var React13 = __toESM(require("react"));
288
+ var import_ui10 = require("@elementor/ui");
289
+
290
+ // src/components/text-field-inner-selection.tsx
291
+ var React12 = __toESM(require("react"));
292
+ var import_react4 = require("react");
293
+ var import_ui9 = require("@elementor/ui");
294
+ var TextFieldInnerSelection = (0, import_react4.forwardRef)(
295
+ ({ placeholder, type, value, onChange, endAdornment, startAdornment }, ref) => {
296
+ return /* @__PURE__ */ React12.createElement(
297
+ import_ui9.TextField,
298
+ {
299
+ size: "tiny",
300
+ fullWidth: true,
301
+ type,
302
+ value,
303
+ onChange,
304
+ placeholder,
305
+ InputProps: {
306
+ endAdornment,
307
+ startAdornment
308
+ },
309
+ ref
310
+ }
311
+ );
312
+ }
313
+ );
314
+ var SelectionEndAdornment = ({
315
+ options,
316
+ onClick,
317
+ value
318
+ }) => {
319
+ const popupState = (0, import_ui9.usePopupState)({
320
+ variant: "popover",
321
+ popupId: (0, import_react4.useId)()
322
+ });
323
+ const handleMenuItemClick = (index) => {
324
+ onClick(options[index]);
325
+ popupState.close();
326
+ };
327
+ return /* @__PURE__ */ React12.createElement(import_ui9.InputAdornment, { position: "end" }, /* @__PURE__ */ React12.createElement(
328
+ import_ui9.Button,
329
+ {
330
+ size: "small",
331
+ color: "inherit",
332
+ sx: { font: "inherit", minWidth: "initial" },
333
+ ...(0, import_ui9.bindTrigger)(popupState)
334
+ },
335
+ value.toUpperCase()
336
+ ), /* @__PURE__ */ React12.createElement(import_ui9.Menu, { MenuListProps: { dense: true }, ...(0, import_ui9.bindMenu)(popupState) }, options.map((option, index) => /* @__PURE__ */ React12.createElement(import_ui9.MenuItem, { key: option, onClick: () => handleMenuItemClick(index) }, option.toUpperCase()))));
337
+ };
338
+
339
+ // src/hooks/use-sync-external-state.tsx
340
+ var import_react5 = require("react");
341
+ var useSyncExternalState = ({
342
+ external,
343
+ setExternal,
344
+ persistWhen,
345
+ fallback
346
+ }) => {
347
+ function toExternal(internalValue) {
348
+ if (persistWhen(internalValue)) {
349
+ return internalValue;
350
+ }
351
+ return void 0;
352
+ }
353
+ function toInternal(externalValue, internalValue) {
354
+ if (!externalValue) {
355
+ return fallback(internalValue);
356
+ }
357
+ return externalValue;
358
+ }
359
+ const [internal, setInternal] = (0, import_react5.useState)(toInternal(external, void 0));
360
+ (0, import_react5.useEffect)(() => {
361
+ setInternal((prevInternal) => toInternal(external, prevInternal));
362
+ }, [external]);
363
+ const setInternalValue = (setter) => {
364
+ const setterFn = typeof setter === "function" ? setter : () => setter;
365
+ const updated = setterFn(internal);
366
+ setInternal(updated);
367
+ setExternal(toExternal(updated));
368
+ };
369
+ return [internal, setInternalValue];
370
+ };
371
+
372
+ // src/controls/size-control.tsx
373
+ var defaultUnits = ["px", "%", "em", "rem", "vw", "vh"];
374
+ var defaultUnit = "px";
375
+ var defaultSize = NaN;
376
+ var SizeControl = createControl(({ units: units2 = defaultUnits, placeholder, startIcon }) => {
377
+ const { value, setValue } = useBoundProp();
378
+ const [state, setState] = useSyncExternalState({
379
+ external: value,
380
+ setExternal: setValue,
381
+ persistWhen: (controlValue) => !!controlValue?.value?.size || controlValue?.value?.size === 0,
382
+ fallback: (controlValue) => ({
383
+ $$type: "size",
384
+ value: { unit: controlValue?.value?.unit || defaultUnit, size: defaultSize }
385
+ })
386
+ });
387
+ const handleUnitChange = (unit) => {
388
+ setState((prev) => ({
389
+ ...prev,
390
+ value: {
391
+ ...prev.value,
392
+ unit
393
+ }
394
+ }));
395
+ };
396
+ const handleSizeChange = (event) => {
397
+ const { value: size } = event.target;
398
+ setState((prev) => ({
399
+ ...prev,
400
+ value: {
401
+ ...prev.value,
402
+ size: size || size === "0" ? parseFloat(size) : defaultSize
403
+ }
404
+ }));
405
+ };
406
+ return /* @__PURE__ */ React13.createElement(ControlActions, null, /* @__PURE__ */ React13.createElement(
407
+ TextFieldInnerSelection,
408
+ {
409
+ endAdornment: /* @__PURE__ */ React13.createElement(
410
+ SelectionEndAdornment,
411
+ {
412
+ options: units2,
413
+ onClick: handleUnitChange,
414
+ value: state.value.unit ?? defaultUnit
415
+ }
416
+ ),
417
+ placeholder,
418
+ startAdornment: startIcon ?? /* @__PURE__ */ React13.createElement(import_ui10.InputAdornment, { position: "start" }, startIcon),
419
+ type: "number",
420
+ value: Number.isNaN(state.value.size) ? "" : state.value.size,
421
+ onChange: handleSizeChange
422
+ }
423
+ ));
424
+ });
425
+
426
+ // src/controls/stroke-control.tsx
427
+ var React15 = __toESM(require("react"));
428
+ var import_ui12 = require("@elementor/ui");
429
+ var import_i18n3 = require("@wordpress/i18n");
430
+
431
+ // src/controls/color-control.tsx
432
+ var React14 = __toESM(require("react"));
433
+ var import_ui11 = require("@elementor/ui");
434
+ var ColorControl = createControl(
435
+ (props) => {
436
+ const { value, setValue } = useBoundProp();
437
+ const handleChange = (selectedColor) => {
438
+ setValue({
439
+ $$type: "color",
440
+ value: selectedColor
441
+ });
442
+ };
443
+ return /* @__PURE__ */ React14.createElement(ControlActions, null, /* @__PURE__ */ React14.createElement(
444
+ import_ui11.UnstableColorField,
445
+ {
446
+ size: "tiny",
447
+ ...props,
448
+ value: value?.value,
449
+ onChange: handleChange,
450
+ fullWidth: true
451
+ }
452
+ ));
453
+ }
454
+ );
455
+
456
+ // src/controls/stroke-control.tsx
457
+ var defaultStrokeControlValue = {
458
+ $$type: "stroke",
459
+ value: {
460
+ color: {
461
+ $$type: "color",
462
+ value: "#000000"
463
+ },
464
+ width: {
465
+ $$type: "size",
466
+ value: {
467
+ unit: "px",
468
+ size: NaN
469
+ }
470
+ }
471
+ }
472
+ };
473
+ var units = ["px", "em", "rem"];
474
+ var StrokeControl = createControl(() => {
475
+ const { value, setValue } = useBoundProp(defaultStrokeControlValue);
476
+ const setStrokeWidth = (newValue) => {
477
+ const updatedValue = {
478
+ ...value?.value ?? defaultStrokeControlValue.value,
479
+ width: newValue
480
+ };
481
+ setValue({
482
+ $$type: "stroke",
483
+ value: updatedValue
484
+ });
485
+ };
486
+ const setStrokeColor = (newValue) => {
487
+ const updatedValue = {
488
+ ...value?.value ?? defaultStrokeControlValue.value,
489
+ color: newValue
490
+ };
491
+ setValue({
492
+ $$type: "stroke",
493
+ value: updatedValue
494
+ });
495
+ };
496
+ return /* @__PURE__ */ React15.createElement(import_ui12.Stack, { gap: 1.5 }, /* @__PURE__ */ React15.createElement(
497
+ Control,
498
+ {
499
+ bind: "width",
500
+ label: (0, import_i18n3.__)("Stroke Width", "elementor"),
501
+ value: value?.value.width ?? defaultStrokeControlValue.value.width,
502
+ setValue: setStrokeWidth
503
+ },
504
+ /* @__PURE__ */ React15.createElement(SizeControl, { units })
505
+ ), /* @__PURE__ */ React15.createElement(
506
+ Control,
507
+ {
508
+ bind: "color",
509
+ label: (0, import_i18n3.__)("Stroke Color", "elementor"),
510
+ value: value?.value.color ?? defaultStrokeControlValue.value.color,
511
+ setValue: setStrokeColor
512
+ },
513
+ /* @__PURE__ */ React15.createElement(ColorControl, null)
514
+ ));
515
+ });
516
+ var Control = ({
517
+ bind,
518
+ value,
519
+ setValue,
520
+ label,
521
+ children
522
+ }) => /* @__PURE__ */ React15.createElement(BoundPropProvider, { bind, value, setValue }, /* @__PURE__ */ React15.createElement(import_ui12.Grid, { container: true, gap: 2, alignItems: "center", flexWrap: "nowrap" }, /* @__PURE__ */ React15.createElement(import_ui12.Grid, { item: true, xs: 6 }, /* @__PURE__ */ React15.createElement(ControlLabel, null, label)), /* @__PURE__ */ React15.createElement(import_ui12.Grid, { item: true, xs: 6 }, children)));
523
+
524
+ // src/controls/box-shadow-repeater-control.tsx
525
+ var React17 = __toESM(require("react"));
526
+ var import_ui14 = require("@elementor/ui");
527
+ var import_i18n5 = require("@wordpress/i18n");
528
+
529
+ // src/components/repeater.tsx
530
+ var React16 = __toESM(require("react"));
531
+ var import_react6 = require("react");
532
+ var import_icons2 = require("@elementor/icons");
533
+ var import_ui13 = require("@elementor/ui");
534
+ var import_i18n4 = require("@wordpress/i18n");
535
+ var SIZE = "tiny";
536
+ var Repeater = ({
537
+ label,
538
+ itemSettings,
539
+ values: repeaterValues = [],
540
+ setValues: setRepeaterValues
541
+ }) => {
542
+ const addRepeaterItem = () => {
543
+ const newItem = structuredClone(itemSettings.initialValues);
544
+ setRepeaterValues([...repeaterValues, newItem]);
545
+ };
546
+ const duplicateRepeaterItem = (index) => {
547
+ setRepeaterValues([
548
+ ...repeaterValues.slice(0, index),
549
+ structuredClone(repeaterValues[index]),
550
+ ...repeaterValues.slice(index)
551
+ ]);
552
+ };
553
+ const removeRepeaterItem = (index) => {
554
+ setRepeaterValues(repeaterValues.filter((_, i) => i !== index));
555
+ };
556
+ const toggleDisableRepeaterItem = (index) => {
557
+ setRepeaterValues(
558
+ repeaterValues.map((value, i) => {
559
+ if (i === index) {
560
+ const { disabled, ...rest } = value;
561
+ return { ...rest, ...disabled ? {} : { disabled: true } };
562
+ }
563
+ return value;
564
+ })
565
+ );
566
+ };
567
+ return /* @__PURE__ */ React16.createElement(import_ui13.Stack, null, /* @__PURE__ */ React16.createElement(import_ui13.Stack, { direction: "row", justifyContent: "space-between", alignItems: "center", sx: { pb: 1 } }, /* @__PURE__ */ React16.createElement(import_ui13.Typography, { component: "label", variant: "caption", color: "text.secondary" }, label), /* @__PURE__ */ React16.createElement(import_ui13.IconButton, { size: SIZE, onClick: addRepeaterItem, "aria-label": (0, import_i18n4.__)("Add item", "elementor") }, /* @__PURE__ */ React16.createElement(import_icons2.PlusIcon, { fontSize: SIZE }))), /* @__PURE__ */ React16.createElement(import_ui13.Stack, { gap: 1 }, repeaterValues.map((value, index) => /* @__PURE__ */ React16.createElement(
568
+ RepeaterItem,
569
+ {
570
+ key: index,
571
+ disabled: value.disabled,
572
+ label: /* @__PURE__ */ React16.createElement(itemSettings.Label, { value }),
573
+ startIcon: /* @__PURE__ */ React16.createElement(itemSettings.Icon, { value }),
574
+ removeItem: () => removeRepeaterItem(index),
575
+ duplicateItem: () => duplicateRepeaterItem(index),
576
+ toggleDisableItem: () => toggleDisableRepeaterItem(index)
577
+ },
578
+ (props) => /* @__PURE__ */ React16.createElement(
579
+ itemSettings.Content,
580
+ {
581
+ ...props,
582
+ value,
583
+ setValue: (newValue) => setRepeaterValues(
584
+ repeaterValues.map((item, i) => i === index ? newValue : item)
585
+ )
586
+ }
587
+ )
588
+ ))));
589
+ };
590
+ var RepeaterItem = ({
591
+ label,
592
+ disabled,
593
+ startIcon,
594
+ children,
595
+ removeItem,
596
+ duplicateItem,
597
+ toggleDisableItem
598
+ }) => {
599
+ const popupId = (0, import_react6.useId)();
600
+ const controlRef = (0, import_react6.useRef)(null);
601
+ const [anchorEl, setAnchorEl] = (0, import_react6.useState)(null);
602
+ const popoverState = (0, import_ui13.usePopupState)({ popupId, variant: "popover" });
603
+ const popoverProps = (0, import_ui13.bindPopover)(popoverState);
604
+ return /* @__PURE__ */ React16.createElement(React16.Fragment, null, /* @__PURE__ */ React16.createElement(
605
+ import_ui13.UnstableTag,
606
+ {
607
+ label,
608
+ showActionsOnHover: true,
609
+ ref: controlRef,
610
+ variant: "outlined",
611
+ "aria-label": (0, import_i18n4.__)("Open item", "elementor"),
612
+ ...(0, import_ui13.bindTrigger)(popoverState),
613
+ startIcon,
614
+ actions: /* @__PURE__ */ React16.createElement(React16.Fragment, null, /* @__PURE__ */ React16.createElement(
615
+ import_ui13.IconButton,
616
+ {
617
+ size: SIZE,
618
+ onClick: duplicateItem,
619
+ "aria-label": (0, import_i18n4.__)("Duplicate item", "elementor")
620
+ },
621
+ /* @__PURE__ */ React16.createElement(import_icons2.CopyIcon, { fontSize: SIZE })
622
+ ), /* @__PURE__ */ React16.createElement(
623
+ import_ui13.IconButton,
624
+ {
625
+ size: SIZE,
626
+ onClick: toggleDisableItem,
627
+ "aria-label": disabled ? (0, import_i18n4.__)("Enable item", "elementor") : (0, import_i18n4.__)("Disable item", "elementor")
628
+ },
629
+ disabled ? /* @__PURE__ */ React16.createElement(import_icons2.EyeOffIcon, { fontSize: SIZE }) : /* @__PURE__ */ React16.createElement(import_icons2.EyeIcon, { fontSize: SIZE })
630
+ ), /* @__PURE__ */ React16.createElement(
631
+ import_ui13.IconButton,
632
+ {
633
+ size: SIZE,
634
+ onClick: removeItem,
635
+ "aria-label": (0, import_i18n4.__)("Remove item", "elementor")
636
+ },
637
+ /* @__PURE__ */ React16.createElement(import_icons2.XIcon, { fontSize: SIZE })
638
+ ))
639
+ }
640
+ ), /* @__PURE__ */ React16.createElement(
641
+ import_ui13.Popover,
642
+ {
643
+ disablePortal: true,
644
+ slotProps: {
645
+ paper: {
646
+ ref: setAnchorEl,
647
+ sx: { mt: 0.5, p: 1, pt: 1, width: controlRef.current?.getBoundingClientRect().width }
648
+ }
649
+ },
650
+ anchorOrigin: { vertical: "bottom", horizontal: "left" },
651
+ ...popoverProps
652
+ },
653
+ /* @__PURE__ */ React16.createElement(import_ui13.Box, { p: 0.5 }, children({ anchorEl }))
654
+ ));
655
+ };
656
+
657
+ // src/controls/box-shadow-repeater-control.tsx
658
+ var BoxShadowRepeaterControl = createControl(() => {
659
+ const { value, setValue } = useBoundProp();
660
+ const boxShadowValues = value?.value;
661
+ const setBoxShadow = (newValue) => {
662
+ setValue({
663
+ $$type: "box-shadow",
664
+ value: newValue
665
+ });
666
+ };
667
+ return /* @__PURE__ */ React17.createElement(
668
+ Repeater,
669
+ {
670
+ values: boxShadowValues,
671
+ setValues: setBoxShadow,
672
+ label: (0, import_i18n5.__)("Box shadow", "elementor"),
673
+ itemSettings: {
674
+ Icon: ItemIcon,
675
+ Label: ItemLabel,
676
+ Content: ItemContent,
677
+ initialValues: initialShadow
678
+ }
679
+ }
680
+ );
681
+ });
682
+ var ItemIcon = ({ value }) => /* @__PURE__ */ React17.createElement(import_ui14.UnstableColorIndicator, { size: "inherit", component: "span", value: value.value.color.value });
683
+ var ItemContent = ({
684
+ value,
685
+ setValue,
686
+ anchorEl
687
+ }) => {
688
+ const setShadow = (newValue) => {
689
+ setValue({
690
+ $$type: "shadow",
691
+ value: newValue
692
+ });
693
+ };
694
+ return /* @__PURE__ */ React17.createElement(import_ui14.Stack, { gap: 1.5 }, /* @__PURE__ */ React17.createElement(import_ui14.Grid, { container: true, gap: 2, flexWrap: "nowrap" }, /* @__PURE__ */ React17.createElement(
695
+ Control2,
696
+ {
697
+ bind: "color",
698
+ value: value.value.color,
699
+ label: (0, import_i18n5.__)("Color", "elementor"),
700
+ setValue: (v) => setShadow({ ...value.value, color: v })
701
+ },
702
+ /* @__PURE__ */ React17.createElement(
703
+ ColorControl,
704
+ {
705
+ slotProps: {
706
+ colorPicker: {
707
+ anchorEl,
708
+ anchorOrigin: {
709
+ vertical: "top",
710
+ horizontal: "right"
711
+ },
712
+ transformOrigin: {
713
+ vertical: "top",
714
+ horizontal: -10
715
+ }
716
+ }
717
+ }
718
+ }
719
+ )
720
+ ), /* @__PURE__ */ React17.createElement(
721
+ Control2,
722
+ {
723
+ bind: "position",
724
+ value: value.value.position,
725
+ label: (0, import_i18n5.__)("Position", "elementor"),
726
+ setValue: (v) => setShadow({ ...value.value, position: v || null })
727
+ },
728
+ /* @__PURE__ */ React17.createElement(
729
+ SelectControl,
730
+ {
731
+ options: [
732
+ { label: (0, import_i18n5.__)("Inset", "elementor"), value: "inset" },
733
+ { label: (0, import_i18n5.__)("Outset", "elementor"), value: "" }
734
+ ]
735
+ }
736
+ )
737
+ )), /* @__PURE__ */ React17.createElement(import_ui14.Grid, { container: true, gap: 2, flexWrap: "nowrap" }, /* @__PURE__ */ React17.createElement(
738
+ Control2,
739
+ {
740
+ bind: "hOffset",
741
+ label: (0, import_i18n5.__)("Horizontal", "elementor"),
742
+ value: value.value.hOffset,
743
+ setValue: (v) => setShadow({ ...value.value, hOffset: v })
744
+ },
745
+ /* @__PURE__ */ React17.createElement(SizeControl, null)
746
+ ), /* @__PURE__ */ React17.createElement(
747
+ Control2,
748
+ {
749
+ bind: "vOffset",
750
+ label: (0, import_i18n5.__)("Vertical", "elementor"),
751
+ value: value.value.vOffset,
752
+ setValue: (v) => setShadow({ ...value.value, vOffset: v })
753
+ },
754
+ /* @__PURE__ */ React17.createElement(SizeControl, null)
755
+ )), /* @__PURE__ */ React17.createElement(import_ui14.Grid, { container: true, gap: 2, flexWrap: "nowrap" }, /* @__PURE__ */ React17.createElement(
756
+ Control2,
757
+ {
758
+ bind: "blur",
759
+ value: value.value.blur,
760
+ label: (0, import_i18n5.__)("Blur", "elementor"),
761
+ setValue: (v) => setShadow({ ...value.value, blur: v })
762
+ },
763
+ /* @__PURE__ */ React17.createElement(SizeControl, null)
764
+ ), /* @__PURE__ */ React17.createElement(
765
+ Control2,
766
+ {
767
+ bind: "spread",
768
+ label: (0, import_i18n5.__)("Spread", "elementor"),
769
+ value: value.value.spread,
770
+ setValue: (v) => setShadow({ ...value.value, spread: v })
771
+ },
772
+ /* @__PURE__ */ React17.createElement(SizeControl, null)
773
+ )));
774
+ };
775
+ var Control2 = ({
776
+ value,
777
+ setValue,
778
+ label,
779
+ bind,
780
+ children
781
+ }) => /* @__PURE__ */ React17.createElement(BoundPropProvider, { value, setValue, bind }, /* @__PURE__ */ React17.createElement(import_ui14.Grid, { item: true, xs: 6 }, /* @__PURE__ */ React17.createElement(import_ui14.Grid, { container: true, gap: 1, alignItems: "center" }, /* @__PURE__ */ React17.createElement(import_ui14.Grid, { item: true, xs: 12 }, /* @__PURE__ */ React17.createElement(import_ui14.Typography, { component: "label", variant: "caption", color: "text.secondary" }, label)), /* @__PURE__ */ React17.createElement(import_ui14.Grid, { item: true, xs: 12 }, children))));
782
+ var ItemLabel = ({ value }) => {
783
+ const { position, hOffset, vOffset, blur, spread } = value.value;
784
+ const { size: blurSize = "", unit: blurUnit = "" } = blur?.value || {};
785
+ const { size: spreadSize = "", unit: spreadUnit = "" } = spread?.value || {};
786
+ const { size: hOffsetSize = "unset", unit: hOffsetUnit = "" } = hOffset?.value || {};
787
+ const { size: vOffsetSize = "unset", unit: vOffsetUnit = "" } = vOffset?.value || {};
788
+ const sizes = [
789
+ hOffsetSize + hOffsetUnit,
790
+ vOffsetSize + vOffsetUnit,
791
+ blurSize + blurUnit,
792
+ spreadSize + spreadUnit
793
+ ].join(" ");
794
+ return /* @__PURE__ */ React17.createElement("span", { style: { textTransform: "capitalize" } }, position ?? "outset", ": ", sizes);
795
+ };
796
+ var initialShadow = {
797
+ $$type: "shadow",
798
+ value: {
799
+ hOffset: {
800
+ $$type: "size",
801
+ value: { unit: "px", size: 0 }
802
+ },
803
+ vOffset: {
804
+ $$type: "size",
805
+ value: { unit: "px", size: 0 }
806
+ },
807
+ blur: {
808
+ $$type: "size",
809
+ value: { unit: "px", size: 10 }
810
+ },
811
+ spread: {
812
+ $$type: "size",
813
+ value: { unit: "px", size: 0 }
814
+ },
815
+ color: {
816
+ $$type: "color",
817
+ value: "rgba(0, 0, 0, 1)"
818
+ },
819
+ position: null
820
+ }
821
+ };
822
+
823
+ // src/controls/background-overlay-repeater-control.tsx
824
+ var React18 = __toESM(require("react"));
825
+ var import_ui15 = require("@elementor/ui");
826
+ var import_i18n6 = require("@wordpress/i18n");
827
+ var BackgroundOverlayRepeaterControl = createControl(() => {
828
+ const { value, setValue } = useBoundProp();
829
+ const colorOverlayValues = value?.value;
830
+ const setColorOverlay = (newValue) => {
831
+ setValue({
832
+ $$type: "background-image",
833
+ value: newValue
834
+ });
835
+ };
836
+ return /* @__PURE__ */ React18.createElement(
837
+ Repeater,
838
+ {
839
+ values: colorOverlayValues,
840
+ setValues: setColorOverlay,
841
+ label: (0, import_i18n6.__)("Overlay", "elementor"),
842
+ itemSettings: {
843
+ Icon: ItemIcon2,
844
+ Label: ItemLabel2,
845
+ Content: ItemContent2,
846
+ initialValues: initialGradient
847
+ }
848
+ }
849
+ );
850
+ });
851
+ var ItemIcon2 = ({ value }) => /* @__PURE__ */ React18.createElement(import_ui15.UnstableColorIndicator, { size: "inherit", component: "span", value: value.value.color.value });
852
+ var ItemContent2 = ({
853
+ value,
854
+ setValue
855
+ }) => {
856
+ const setColor = (newValue) => {
857
+ setValue({
858
+ $$type: "background-overlay",
859
+ value: newValue
860
+ });
861
+ };
862
+ return /* @__PURE__ */ React18.createElement(import_ui15.Stack, { gap: 1.5 }, /* @__PURE__ */ React18.createElement(
863
+ Control3,
864
+ {
865
+ bind: "color",
866
+ value: value.value.color,
867
+ label: (0, import_i18n6.__)("Color", "elementor"),
868
+ setValue: (v) => setColor({ ...value.value, color: v })
869
+ },
870
+ /* @__PURE__ */ React18.createElement(ColorControl, null)
871
+ ));
872
+ };
873
+ var Control3 = ({
874
+ value,
875
+ setValue,
876
+ label,
877
+ bind,
878
+ children
879
+ }) => /* @__PURE__ */ React18.createElement(BoundPropProvider, { value, setValue, bind }, /* @__PURE__ */ React18.createElement(import_ui15.Grid, { container: true, spacing: 1, alignItems: "center" }, /* @__PURE__ */ React18.createElement(import_ui15.Grid, { item: true, xs: 12 }, /* @__PURE__ */ React18.createElement(import_ui15.Typography, { component: "label", variant: "caption", color: "text.secondary" }, label)), /* @__PURE__ */ React18.createElement(import_ui15.Grid, { item: true, xs: 12 }, children)));
880
+ var ItemLabel2 = ({ value }) => {
881
+ const color = value.value.color.value;
882
+ return /* @__PURE__ */ React18.createElement("span", null, color);
883
+ };
884
+ var initialGradient = {
885
+ $$type: "background-overlay",
886
+ value: {
887
+ color: {
888
+ $$type: "color",
889
+ value: "rgba(0, 0, 0, 0.2)"
890
+ }
891
+ }
892
+ };
893
+
894
+ // src/controls/toggle-control.tsx
895
+ var React20 = __toESM(require("react"));
896
+
897
+ // src/components/control-toggle-button-group.tsx
898
+ var React19 = __toESM(require("react"));
899
+ var import_ui16 = require("@elementor/ui");
900
+ var StyledToggleButtonGroup = (0, import_ui16.styled)(import_ui16.ToggleButtonGroup)`
901
+ ${({ justify }) => `justify-content: ${justify};`}
902
+ `;
903
+ var ControlToggleButtonGroup = ({
904
+ justify = "end",
905
+ size = "tiny",
906
+ value,
907
+ onChange,
908
+ items,
909
+ exclusive = false,
910
+ fullWidth = false
911
+ }) => {
912
+ const handleChange = (_, newValue) => {
913
+ onChange(newValue);
914
+ };
915
+ return /* @__PURE__ */ React19.createElement(StyledToggleButtonGroup, { justify, value, onChange: handleChange, exclusive }, items.map(
916
+ ({ label, value: buttonValue, renderContent: Content, showTooltip }) => showTooltip ? /* @__PURE__ */ React19.createElement(import_ui16.Tooltip, { key: buttonValue, title: label, disableFocusListener: true, placement: "top" }, /* @__PURE__ */ React19.createElement(import_ui16.ToggleButton, { value: buttonValue, "aria-label": label, size, fullWidth }, /* @__PURE__ */ React19.createElement(Content, { size }))) : /* @__PURE__ */ React19.createElement(
917
+ import_ui16.ToggleButton,
918
+ {
919
+ key: buttonValue,
920
+ value: buttonValue,
921
+ "aria-label": label,
922
+ size,
923
+ fullWidth
924
+ },
925
+ /* @__PURE__ */ React19.createElement(Content, { size })
926
+ )
927
+ ));
928
+ };
929
+
930
+ // src/controls/toggle-control.tsx
931
+ var ToggleControl = createControl(
932
+ ({ options, fullWidth = false, size = "tiny" }) => {
933
+ const { value, setValue } = useBoundProp();
934
+ const handleToggle = (option) => {
935
+ setValue(option);
936
+ };
937
+ return /* @__PURE__ */ React20.createElement(
938
+ ControlToggleButtonGroup,
939
+ {
940
+ items: options,
941
+ value: value || null,
942
+ onChange: handleToggle,
943
+ exclusive: true,
944
+ fullWidth,
945
+ size
946
+ }
947
+ );
948
+ }
949
+ );
950
+
951
+ // src/controls/number-control.tsx
952
+ var React21 = __toESM(require("react"));
953
+ var import_ui17 = require("@elementor/ui");
954
+ var isEmptyOrNaN = (value) => value === void 0 || value === "" || Number.isNaN(Number(value));
955
+ var NumberControl = createControl(({ placeholder }) => {
956
+ const { value, setValue } = useBoundProp();
957
+ const handleChange = (event) => {
958
+ const eventValue = event.target.value;
959
+ setValue(isEmptyOrNaN(eventValue) ? void 0 : Number(eventValue));
960
+ };
961
+ return /* @__PURE__ */ React21.createElement(ControlActions, null, /* @__PURE__ */ React21.createElement(
962
+ import_ui17.TextField,
963
+ {
964
+ size: "tiny",
965
+ type: "number",
966
+ fullWidth: true,
967
+ value: isEmptyOrNaN(value) ? "" : value,
968
+ onChange: handleChange,
969
+ placeholder
970
+ }
971
+ ));
972
+ });
973
+
974
+ // src/controls/equal-unequal-sizes-control.tsx
975
+ var React22 = __toESM(require("react"));
976
+ var import_react7 = require("react");
977
+ var import_ui18 = require("@elementor/ui");
978
+ var import_i18n7 = require("@wordpress/i18n");
979
+ function hasMixedSizes(values) {
980
+ const [firstValue, ...restValues] = values;
981
+ return restValues.some(
982
+ (value) => value?.value?.size !== firstValue?.value?.size || value?.value?.unit !== firstValue?.value?.unit
983
+ );
984
+ }
985
+ function getMultiSizeProps(controlValue, items) {
986
+ return controlValue?.$$type === "size" ? items.reduce((values, item) => {
987
+ const { bind } = item;
988
+ values[bind] = controlValue;
989
+ return values;
990
+ }, {}) : controlValue?.value ?? {};
991
+ }
992
+ function EqualUnequalSizesControl({ label, icon, items, multiSizeType }) {
993
+ const popupId = (0, import_react7.useId)();
994
+ const controlRef = (0, import_react7.useRef)(null);
995
+ const { value: controlValue, setValue: setControlValue } = useBoundProp();
996
+ const setMultiSizeValue = (newValue) => {
997
+ setControlValue({ $$type: multiSizeType, value: newValue });
998
+ };
999
+ const mappedValues = getMultiSizeProps(controlValue, items);
1000
+ const setNestedProp = (item, newValue) => {
1001
+ const { bind } = item;
1002
+ const newMappedValues = {
1003
+ ...mappedValues,
1004
+ [bind]: newValue
1005
+ };
1006
+ const sizes = Object.values(newMappedValues);
1007
+ const isMixed = hasMixedSizes(sizes);
1008
+ if (isMixed) {
1009
+ setMultiSizeValue(newMappedValues);
1010
+ return;
1011
+ }
1012
+ setControlValue(newValue);
1013
+ };
1014
+ const popupState = (0, import_ui18.usePopupState)({
1015
+ variant: "popover",
1016
+ popupId
1017
+ });
1018
+ return /* @__PURE__ */ React22.createElement(React22.Fragment, null, /* @__PURE__ */ React22.createElement(import_ui18.Grid, { container: true, gap: 2, alignItems: "center", flexWrap: "nowrap", ref: controlRef }, /* @__PURE__ */ React22.createElement(import_ui18.Grid, { item: true, xs: 6 }, /* @__PURE__ */ React22.createElement(ControlLabel, null, label)), /* @__PURE__ */ React22.createElement(import_ui18.Grid, { item: true, xs: 6 }, /* @__PURE__ */ React22.createElement(
1019
+ EqualValuesControl,
1020
+ {
1021
+ value: mappedValues,
1022
+ setValue: setControlValue,
1023
+ iconButton: /* @__PURE__ */ React22.createElement(
1024
+ import_ui18.ToggleButton,
1025
+ {
1026
+ size: "tiny",
1027
+ value: "check",
1028
+ sx: { marginLeft: "auto" },
1029
+ ...(0, import_ui18.bindToggle)(popupState),
1030
+ selected: popupState.isOpen
1031
+ },
1032
+ icon
1033
+ )
1034
+ }
1035
+ ))), /* @__PURE__ */ React22.createElement(
1036
+ import_ui18.Popover,
1037
+ {
1038
+ disablePortal: true,
1039
+ disableScrollLock: true,
1040
+ anchorOrigin: {
1041
+ vertical: "bottom",
1042
+ horizontal: "right"
1043
+ },
1044
+ transformOrigin: {
1045
+ vertical: "top",
1046
+ horizontal: "right"
1047
+ },
1048
+ ...(0, import_ui18.bindPopover)(popupState),
1049
+ slotProps: {
1050
+ paper: { sx: { mt: 0.5, p: 2, pt: 1, width: controlRef.current?.getBoundingClientRect().width } }
1051
+ }
1052
+ },
1053
+ /* @__PURE__ */ React22.createElement(import_ui18.Stack, { gap: 1.5 }, /* @__PURE__ */ React22.createElement(import_ui18.Grid, { container: true, gap: 2, alignItems: "center", flexWrap: "nowrap" }, /* @__PURE__ */ React22.createElement(
1054
+ NestedValueControl,
1055
+ {
1056
+ item: items[0],
1057
+ value: mappedValues,
1058
+ setNestedProp
1059
+ }
1060
+ ), /* @__PURE__ */ React22.createElement(
1061
+ NestedValueControl,
1062
+ {
1063
+ item: items[1],
1064
+ value: mappedValues,
1065
+ setNestedProp
1066
+ }
1067
+ )), /* @__PURE__ */ React22.createElement(import_ui18.Grid, { container: true, gap: 2, alignItems: "center", flexWrap: "nowrap" }, /* @__PURE__ */ React22.createElement(
1068
+ NestedValueControl,
1069
+ {
1070
+ item: items[3],
1071
+ value: mappedValues,
1072
+ setNestedProp
1073
+ }
1074
+ ), /* @__PURE__ */ React22.createElement(
1075
+ NestedValueControl,
1076
+ {
1077
+ item: items[2],
1078
+ value: mappedValues,
1079
+ setNestedProp
1080
+ }
1081
+ )))
1082
+ ));
1083
+ }
1084
+ var NestedValueControl = ({
1085
+ item,
1086
+ value,
1087
+ setNestedProp
1088
+ }) => {
1089
+ const { bind } = item;
1090
+ const nestedValue = value?.[bind] ? value[bind] : void 0;
1091
+ return /* @__PURE__ */ React22.createElement(
1092
+ BoundPropProvider,
1093
+ {
1094
+ bind: "",
1095
+ setValue: (val) => setNestedProp(item, val),
1096
+ value: nestedValue
1097
+ },
1098
+ /* @__PURE__ */ React22.createElement(import_ui18.Grid, { item: true, xs: 6 }, /* @__PURE__ */ React22.createElement(import_ui18.Grid, { container: true, gap: 1, alignItems: "center" }, /* @__PURE__ */ React22.createElement(import_ui18.Grid, { item: true, xs: 12 }, /* @__PURE__ */ React22.createElement(ControlLabel, null, item.label)), /* @__PURE__ */ React22.createElement(import_ui18.Grid, { item: true, xs: 12 }, /* @__PURE__ */ React22.createElement(SizeControl, { startIcon: item.icon }))))
1099
+ );
1100
+ };
1101
+ var EqualValuesControl = ({
1102
+ value,
1103
+ setValue,
1104
+ iconButton
1105
+ }) => {
1106
+ const values = Object.values(value ?? {});
1107
+ const isMixed = hasMixedSizes(values);
1108
+ return /* @__PURE__ */ React22.createElement(
1109
+ BoundPropProvider,
1110
+ {
1111
+ bind: "",
1112
+ setValue: (val) => setValue(val),
1113
+ value: isMixed ? void 0 : values[0]
1114
+ },
1115
+ /* @__PURE__ */ React22.createElement(import_ui18.Stack, { direction: "row", alignItems: "center", gap: 1 }, /* @__PURE__ */ React22.createElement(SizeControl, { placeholder: (0, import_i18n7.__)("MIXED", "elementor") }), iconButton)
1116
+ );
1117
+ };
1118
+
1119
+ // src/controls/linked-dimensions-control.tsx
1120
+ var React23 = __toESM(require("react"));
1121
+ var import_icons3 = require("@elementor/icons");
1122
+ var import_ui19 = require("@elementor/ui");
1123
+ var import_i18n8 = require("@wordpress/i18n");
1124
+ var LinkedDimensionsControl = createControl(({ label }) => {
1125
+ const { value, setValue } = useBoundProp();
1126
+ const { top, right, bottom, left, isLinked = true } = value?.value || {};
1127
+ const setLinkedValue = (position, newValue) => {
1128
+ const updatedValue = {
1129
+ isLinked,
1130
+ top: isLinked ? newValue : top,
1131
+ right: isLinked ? newValue : right,
1132
+ bottom: isLinked ? newValue : bottom,
1133
+ left: isLinked ? newValue : left,
1134
+ [position]: newValue
1135
+ };
1136
+ setValue({
1137
+ $$type: "linked-dimensions",
1138
+ value: updatedValue
1139
+ });
1140
+ };
1141
+ const toggleLinked = () => {
1142
+ const updatedValue = {
1143
+ isLinked: !isLinked,
1144
+ top,
1145
+ right: !isLinked ? top : right,
1146
+ bottom: !isLinked ? top : bottom,
1147
+ left: !isLinked ? top : left
1148
+ };
1149
+ setValue({
1150
+ $$type: "linked-dimensions",
1151
+ value: updatedValue
1152
+ });
1153
+ };
1154
+ const LinkedIcon = isLinked ? import_icons3.LinkIcon : import_icons3.DetachIcon;
1155
+ return /* @__PURE__ */ React23.createElement(React23.Fragment, null, /* @__PURE__ */ React23.createElement(import_ui19.Stack, { direction: "row", gap: 2, flexWrap: "nowrap" }, /* @__PURE__ */ React23.createElement(ControlLabel, null, label), /* @__PURE__ */ React23.createElement(
1156
+ import_ui19.ToggleButton,
1157
+ {
1158
+ "aria-label": (0, import_i18n8.__)("Link Inputs", "elementor"),
1159
+ size: "tiny",
1160
+ value: "check",
1161
+ selected: isLinked,
1162
+ sx: { marginLeft: "auto" },
1163
+ onChange: toggleLinked
1164
+ },
1165
+ /* @__PURE__ */ React23.createElement(LinkedIcon, { fontSize: "tiny" })
1166
+ )), /* @__PURE__ */ React23.createElement(import_ui19.Stack, { direction: "row", gap: 2, flexWrap: "nowrap" }, /* @__PURE__ */ React23.createElement(import_ui19.Grid, { container: true, gap: 1, alignItems: "center" }, /* @__PURE__ */ React23.createElement(import_ui19.Grid, { item: true, xs: 12 }, /* @__PURE__ */ React23.createElement(ControlLabel, null, (0, import_i18n8.__)("Top", "elementor"))), /* @__PURE__ */ React23.createElement(import_ui19.Grid, { item: true, xs: 12 }, /* @__PURE__ */ React23.createElement(
1167
+ Control4,
1168
+ {
1169
+ bind: "top",
1170
+ value: top,
1171
+ setValue: setLinkedValue,
1172
+ startIcon: /* @__PURE__ */ React23.createElement(import_icons3.SideTopIcon, { fontSize: "tiny" })
1173
+ }
1174
+ ))), /* @__PURE__ */ React23.createElement(import_ui19.Grid, { container: true, gap: 1, alignItems: "center" }, /* @__PURE__ */ React23.createElement(import_ui19.Grid, { item: true, xs: 12 }, /* @__PURE__ */ React23.createElement(ControlLabel, null, (0, import_i18n8.__)("Right", "elementor"))), /* @__PURE__ */ React23.createElement(import_ui19.Grid, { item: true, xs: 12 }, /* @__PURE__ */ React23.createElement(
1175
+ Control4,
1176
+ {
1177
+ bind: "right",
1178
+ value: right,
1179
+ setValue: setLinkedValue,
1180
+ startIcon: /* @__PURE__ */ React23.createElement(import_icons3.SideRightIcon, { fontSize: "tiny" })
1181
+ }
1182
+ )))), /* @__PURE__ */ React23.createElement(import_ui19.Stack, { direction: "row", gap: 2, flexWrap: "nowrap" }, /* @__PURE__ */ React23.createElement(import_ui19.Grid, { container: true, gap: 1, alignItems: "center" }, /* @__PURE__ */ React23.createElement(import_ui19.Grid, { item: true, xs: 12 }, /* @__PURE__ */ React23.createElement(ControlLabel, null, (0, import_i18n8.__)("Bottom", "elementor"))), /* @__PURE__ */ React23.createElement(import_ui19.Grid, { item: true, xs: 12 }, /* @__PURE__ */ React23.createElement(
1183
+ Control4,
1184
+ {
1185
+ bind: "bottom",
1186
+ value: bottom,
1187
+ setValue: setLinkedValue,
1188
+ startIcon: /* @__PURE__ */ React23.createElement(import_icons3.SideBottomIcon, { fontSize: "tiny" })
1189
+ }
1190
+ ))), /* @__PURE__ */ React23.createElement(import_ui19.Grid, { container: true, gap: 1, alignItems: "center" }, /* @__PURE__ */ React23.createElement(import_ui19.Grid, { item: true, xs: 12 }, /* @__PURE__ */ React23.createElement(ControlLabel, null, (0, import_i18n8.__)("Left", "elementor"))), /* @__PURE__ */ React23.createElement(import_ui19.Grid, { item: true, xs: 12 }, /* @__PURE__ */ React23.createElement(
1191
+ Control4,
1192
+ {
1193
+ bind: "left",
1194
+ value: left,
1195
+ setValue: setLinkedValue,
1196
+ startIcon: /* @__PURE__ */ React23.createElement(import_icons3.SideLeftIcon, { fontSize: "tiny" })
1197
+ }
1198
+ )))));
1199
+ });
1200
+ var Control4 = ({
1201
+ bind,
1202
+ startIcon,
1203
+ value,
1204
+ setValue
1205
+ }) => /* @__PURE__ */ React23.createElement(BoundPropProvider, { setValue: (newValue) => setValue(bind, newValue), value, bind }, /* @__PURE__ */ React23.createElement(SizeControl, { startIcon }));
1206
+
1207
+ // src/controls/font-family-control.tsx
1208
+ var import_react8 = require("react");
1209
+ var React24 = __toESM(require("react"));
1210
+ var import_icons4 = require("@elementor/icons");
1211
+ var import_ui20 = require("@elementor/ui");
1212
+ var import_i18n10 = require("@wordpress/i18n");
1213
+
1214
+ // src/hooks/use-filtered-font-families.ts
1215
+ var import_i18n9 = require("@wordpress/i18n");
1216
+ var supportedCategories = {
1217
+ system: (0, import_i18n9.__)("System", "elementor"),
1218
+ googlefonts: (0, import_i18n9.__)("Google Fonts", "elementor"),
1219
+ customfonts: (0, import_i18n9.__)("Custom Fonts", "elementor")
1220
+ };
1221
+ var useFilteredFontFamilies = (fontFamilies, searchValue) => {
1222
+ const filteredFontFamilies = Object.entries(fontFamilies).reduce(
1223
+ (acc, [font, category]) => {
1224
+ const isMatch = font.toLowerCase().includes(searchValue.trim().toLowerCase());
1225
+ if (!isMatch) {
1226
+ return acc;
1227
+ }
1228
+ const categoryLabel = supportedCategories[category];
1229
+ if (categoryLabel) {
1230
+ const existingCategory = acc.get(categoryLabel);
1231
+ if (existingCategory) {
1232
+ existingCategory.push(font);
1233
+ } else {
1234
+ acc.set(categoryLabel, [font]);
1235
+ }
1236
+ }
1237
+ return acc;
1238
+ },
1239
+ /* @__PURE__ */ new Map()
1240
+ );
1241
+ return [...filteredFontFamilies];
1242
+ };
1243
+
1244
+ // src/controls/font-family-control.tsx
1245
+ var SIZE2 = "tiny";
1246
+ var FontFamilyControl = createControl(({ fontFamilies }) => {
1247
+ const { value: fontFamily, setValue: setFontFamily } = useBoundProp();
1248
+ const [searchValue, setSearchValue] = (0, import_react8.useState)("");
1249
+ const popupId = (0, import_react8.useId)();
1250
+ const popoverState = (0, import_ui20.usePopupState)({ variant: "popover", popupId });
1251
+ const filteredFontFamilies = useFilteredFontFamilies(fontFamilies, searchValue);
1252
+ if (!filteredFontFamilies) {
1253
+ return null;
1254
+ }
1255
+ const handleSearch = (event) => {
1256
+ setSearchValue(event.target.value);
1257
+ };
1258
+ const handleClose = () => {
1259
+ setSearchValue("");
1260
+ popoverState.close();
1261
+ };
1262
+ return /* @__PURE__ */ React24.createElement(React24.Fragment, null, /* @__PURE__ */ React24.createElement(
1263
+ import_ui20.UnstableTag,
1264
+ {
1265
+ variant: "outlined",
1266
+ label: fontFamily,
1267
+ endIcon: /* @__PURE__ */ React24.createElement(import_icons4.ChevronDownIcon, { fontSize: "tiny" }),
1268
+ ...(0, import_ui20.bindTrigger)(popoverState),
1269
+ fullWidth: true
1270
+ }
1271
+ ), /* @__PURE__ */ React24.createElement(
1272
+ import_ui20.Popover,
1273
+ {
1274
+ disablePortal: true,
1275
+ disableScrollLock: true,
1276
+ anchorOrigin: { vertical: "bottom", horizontal: "left" },
1277
+ ...(0, import_ui20.bindPopover)(popoverState),
1278
+ onClose: handleClose
1279
+ },
1280
+ /* @__PURE__ */ React24.createElement(import_ui20.Stack, null, /* @__PURE__ */ React24.createElement(import_ui20.Stack, { direction: "row", alignItems: "center", pl: 1.5, pr: 0.5, py: 1.5 }, /* @__PURE__ */ React24.createElement(import_icons4.EditIcon, { fontSize: SIZE2, sx: { mr: 0.5 } }), /* @__PURE__ */ React24.createElement(import_ui20.Typography, { variant: "subtitle2" }, (0, import_i18n10.__)("Font Family", "elementor")), /* @__PURE__ */ React24.createElement(import_ui20.IconButton, { size: SIZE2, sx: { ml: "auto" }, onClick: handleClose }, /* @__PURE__ */ React24.createElement(import_icons4.XIcon, { fontSize: SIZE2 }))), /* @__PURE__ */ React24.createElement(import_ui20.Box, { px: 1.5, pb: 1 }, /* @__PURE__ */ React24.createElement(
1281
+ import_ui20.TextField,
1282
+ {
1283
+ fullWidth: true,
1284
+ size: SIZE2,
1285
+ value: searchValue,
1286
+ placeholder: (0, import_i18n10.__)("Search", "elementor"),
1287
+ onChange: handleSearch,
1288
+ InputProps: {
1289
+ startAdornment: /* @__PURE__ */ React24.createElement(import_ui20.InputAdornment, { position: "start" }, /* @__PURE__ */ React24.createElement(import_icons4.SearchIcon, { fontSize: SIZE2 }))
1290
+ }
1291
+ }
1292
+ )), /* @__PURE__ */ React24.createElement(import_ui20.Divider, null), /* @__PURE__ */ React24.createElement(import_ui20.Box, { sx: { overflowY: "auto", height: 260, width: 220 } }, filteredFontFamilies.length > 0 ? /* @__PURE__ */ React24.createElement(import_ui20.MenuList, { role: "listbox", tabIndex: 0 }, filteredFontFamilies.map(([category, items], index) => /* @__PURE__ */ React24.createElement(import_react8.Fragment, { key: index }, /* @__PURE__ */ React24.createElement(import_ui20.ListSubheader, { sx: { typography: "caption", color: "text.tertiary" } }, category), items.map((item) => {
1293
+ const isSelected = item === fontFamily;
1294
+ return /* @__PURE__ */ React24.createElement(
1295
+ import_ui20.MenuItem,
1296
+ {
1297
+ key: item,
1298
+ selected: isSelected,
1299
+ autoFocus: isSelected,
1300
+ onClick: () => {
1301
+ setFontFamily(item);
1302
+ handleClose();
1303
+ },
1304
+ sx: { typography: "caption" },
1305
+ style: { fontFamily: item }
1306
+ },
1307
+ item
1308
+ );
1309
+ })))) : /* @__PURE__ */ React24.createElement(import_ui20.Stack, { alignItems: "center", p: 2.5, gap: 1.5 }, /* @__PURE__ */ React24.createElement(import_icons4.PhotoIcon, { fontSize: "large" }), /* @__PURE__ */ React24.createElement(import_ui20.Typography, { align: "center", variant: "caption", color: "text.secondary" }, (0, import_i18n10.__)("Sorry, nothing matched", "elementor"), /* @__PURE__ */ React24.createElement("br", null), "\u201C", searchValue, "\u201D."), /* @__PURE__ */ React24.createElement(import_ui20.Typography, { align: "center", variant: "caption", color: "text.secondary" }, /* @__PURE__ */ React24.createElement(
1310
+ import_ui20.Link,
1311
+ {
1312
+ color: "secondary",
1313
+ variant: "caption",
1314
+ component: "button",
1315
+ onClick: () => setSearchValue("")
1316
+ },
1317
+ (0, import_i18n10.__)("Clear the filters", "elementor")
1318
+ ), "\xA0", (0, import_i18n10.__)("and try again.", "elementor")))))
1319
+ ));
1320
+ });
1321
+ // Annotate the CommonJS export names for ESM import in node:
1322
+ 0 && (module.exports = {
1323
+ BackgroundOverlayRepeaterControl,
1324
+ BoundPropProvider,
1325
+ BoxShadowRepeaterControl,
1326
+ ColorControl,
1327
+ ControlActionsProvider,
1328
+ ControlLabel,
1329
+ ControlReplacementProvider,
1330
+ EqualUnequalSizesControl,
1331
+ FontFamilyControl,
1332
+ ImageControl,
1333
+ LinkedDimensionsControl,
1334
+ NumberControl,
1335
+ SelectControl,
1336
+ SizeControl,
1337
+ StrokeControl,
1338
+ TextAreaControl,
1339
+ TextControl,
1340
+ ToggleControl,
1341
+ createControlReplacement,
1342
+ useBoundProp,
1343
+ useControlActions,
1344
+ useSyncExternalState
1345
+ });
1346
+ //# sourceMappingURL=index.js.map