@elementor/editor-variables 0.13.0 → 0.15.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 +84 -0
  2. package/dist/index.js +938 -344
  3. package/dist/index.js.map +1 -1
  4. package/dist/index.mjs +950 -335
  5. package/dist/index.mjs.map +1 -1
  6. package/package.json +11 -10
  7. package/src/components/color-variable-creation.tsx +39 -16
  8. package/src/components/color-variable-edit.tsx +133 -0
  9. package/src/components/color-variables-selection.tsx +111 -52
  10. package/src/components/font-variable-creation.tsx +30 -16
  11. package/src/components/font-variable-edit.tsx +163 -0
  12. package/src/components/font-variables-selection.tsx +110 -51
  13. package/src/components/{color-indicator.tsx → ui/color-indicator.tsx} +1 -0
  14. package/src/components/ui/menu-item-content.tsx +60 -0
  15. package/src/components/ui/no-search-results.tsx +36 -0
  16. package/src/components/ui/no-variables.tsx +36 -0
  17. package/src/components/ui/styled-menu-list.tsx +31 -0
  18. package/src/components/ui/variable-tag.tsx +43 -0
  19. package/src/components/variable-selection-popover.context.ts +7 -0
  20. package/src/components/variable-selection-popover.tsx +142 -0
  21. package/src/components/variables-repeater-item-slot.tsx +29 -0
  22. package/src/controls/color-variable-control.tsx +66 -0
  23. package/src/controls/font-variable-control.tsx +60 -0
  24. package/src/create-style-variables-repository.ts +3 -2
  25. package/src/hooks/use-prop-color-variable-action.tsx +7 -2
  26. package/src/hooks/use-prop-font-variable-action.tsx +7 -2
  27. package/src/hooks/use-prop-variables.ts +34 -13
  28. package/src/init-color-variables.ts +51 -3
  29. package/src/init-font-variables.ts +2 -2
  30. package/src/service.ts +23 -3
  31. package/src/storage.ts +5 -1
  32. package/src/types.ts +12 -8
  33. package/src/components/styled-menu-item.tsx +0 -10
  34. package/src/components/variables-selection-popover.tsx +0 -119
  35. package/src/controls/color-variables-selection-control.tsx +0 -34
  36. package/src/controls/font-variables-selection-control.tsx +0 -29
package/dist/index.js CHANGED
@@ -39,25 +39,12 @@ var import_editor = require("@elementor/editor");
39
39
 
40
40
  // src/init-color-variables.ts
41
41
  var import_editor_canvas2 = require("@elementor/editor-canvas");
42
- var import_editor_editing_panel3 = require("@elementor/editor-editing-panel");
43
-
44
- // src/controls/color-variables-selection-control.tsx
45
- var React5 = __toESM(require("react"));
46
- var import_editor_controls4 = require("@elementor/editor-controls");
47
- var import_editor_props3 = require("@elementor/editor-props");
48
-
49
- // src/components/color-indicator.tsx
50
- var import_ui = require("@elementor/ui");
51
- var ColorIndicator = (0, import_ui.styled)(import_ui.UnstableColorIndicator)(({ theme }) => ({
52
- borderRadius: `${theme.shape.borderRadius / 2}px`
53
- }));
42
+ var import_editor_controls8 = require("@elementor/editor-controls");
43
+ var import_editor_editing_panel7 = require("@elementor/editor-editing-panel");
44
+ var import_editor_props4 = require("@elementor/editor-props");
54
45
 
55
- // src/components/color-variables-selection.tsx
46
+ // src/components/variables-repeater-item-slot.tsx
56
47
  var React = __toESM(require("react"));
57
- var import_react2 = require("react");
58
- var import_editor_controls = require("@elementor/editor-controls");
59
- var import_icons = require("@elementor/icons");
60
- var import_ui3 = require("@elementor/ui");
61
48
 
62
49
  // src/hooks/use-prop-variables.ts
63
50
  var import_react = require("react");
@@ -110,8 +97,11 @@ var Storage = class {
110
97
  return this.state.variables;
111
98
  }
112
99
  fill(variables, watermark) {
100
+ this.state.variables = {};
101
+ if (variables && Object.keys(variables).length) {
102
+ this.state.variables = variables;
103
+ }
113
104
  this.state.watermark = watermark;
114
- this.state.variables = variables;
115
105
  localStorage.setItem(STORAGE_WATERMARK_KEY, this.state.watermark.toString());
116
106
  localStorage.setItem(STORAGE_KEY, JSON.stringify(this.state.variables));
117
107
  }
@@ -141,6 +131,49 @@ var Storage = class {
141
131
  }
142
132
  };
143
133
 
134
+ // src/create-style-variables-repository.ts
135
+ var createStyleVariablesRepository = () => {
136
+ const variables = {};
137
+ let subscription;
138
+ const subscribe = (cb) => {
139
+ subscription = cb;
140
+ return () => {
141
+ subscription = () => {
142
+ };
143
+ };
144
+ };
145
+ const notify = () => {
146
+ if (typeof subscription === "function") {
147
+ subscription({ ...variables });
148
+ }
149
+ };
150
+ const shouldUpdate = (key, newValue) => {
151
+ return !(key in variables) || variables[key] !== newValue;
152
+ };
153
+ const applyUpdates = (updatedVars) => {
154
+ let hasChanges = false;
155
+ for (const [key, { value }] of Object.entries(updatedVars)) {
156
+ if (shouldUpdate(key, value)) {
157
+ variables[key] = value;
158
+ hasChanges = true;
159
+ }
160
+ }
161
+ return hasChanges;
162
+ };
163
+ const update = (updatedVars) => {
164
+ if (applyUpdates(updatedVars)) {
165
+ notify();
166
+ }
167
+ };
168
+ return {
169
+ subscribe,
170
+ update
171
+ };
172
+ };
173
+
174
+ // src/style-variables-repository.ts
175
+ var styleVariablesRepository = createStyleVariablesRepository();
176
+
144
177
  // src/service.ts
145
178
  var storage = new Storage();
146
179
  var service = {
@@ -160,6 +193,7 @@ var service = {
160
193
  }).then((data) => {
161
194
  const { variables, watermark } = data;
162
195
  storage.fill(variables, watermark);
196
+ styleVariablesRepository.update(variables);
163
197
  return variables;
164
198
  });
165
199
  },
@@ -175,6 +209,9 @@ var service = {
175
209
  handleWatermark(OP_RW, watermark);
176
210
  const { id: variableId, ...createdVariable } = variable;
177
211
  storage.add(variableId, createdVariable);
212
+ styleVariablesRepository.update({
213
+ [variableId]: createdVariable
214
+ });
178
215
  return {
179
216
  id: variableId,
180
217
  variable: createdVariable
@@ -193,6 +230,9 @@ var service = {
193
230
  handleWatermark(OP_RW, watermark);
194
231
  const { id: variableId, ...updatedVariable } = variable;
195
232
  storage.update(variableId, updatedVariable);
233
+ styleVariablesRepository.update({
234
+ [variableId]: updatedVariable
235
+ });
196
236
  return {
197
237
  id: variableId,
198
238
  variable: updatedVariable
@@ -211,6 +251,9 @@ var service = {
211
251
  handleWatermark(OP_RW, watermark);
212
252
  const { id: variableId, ...deletedVariable } = variable;
213
253
  storage.update(variableId, deletedVariable);
254
+ styleVariablesRepository.update({
255
+ [variableId]: deletedVariable
256
+ });
214
257
  return {
215
258
  id: variableId,
216
259
  variable: deletedVariable
@@ -229,6 +272,9 @@ var service = {
229
272
  handleWatermark(OP_RW, watermark);
230
273
  const { id: variableId, ...restoredVariable } = variable;
231
274
  storage.update(variableId, restoredVariable);
275
+ styleVariablesRepository.update({
276
+ [variableId]: restoredVariable
277
+ });
232
278
  return {
233
279
  id: variableId,
234
280
  variable: restoredVariable
@@ -243,53 +289,7 @@ var handleWatermark = (operation, newWatermark) => {
243
289
  storage.watermark(newWatermark);
244
290
  };
245
291
 
246
- // src/create-style-variables-repository.ts
247
- var createStyleVariablesRepository = () => {
248
- const variables = {};
249
- let subscription;
250
- const subscribe = (cb) => {
251
- subscription = cb;
252
- return () => {
253
- subscription = () => {
254
- };
255
- };
256
- };
257
- const notify = () => {
258
- if (typeof subscription === "function") {
259
- subscription({ ...variables });
260
- }
261
- };
262
- const shouldUpdate = (key, newValue) => {
263
- return !(key in variables) || variables[key] !== newValue;
264
- };
265
- const applyUpdates = (updatedVars) => {
266
- let hasChanges = false;
267
- for (const [key, { value }] of Object.entries(updatedVars)) {
268
- if (shouldUpdate(key, value)) {
269
- variables[key] = value;
270
- hasChanges = true;
271
- }
272
- }
273
- return hasChanges;
274
- };
275
- const update = (updatedVars) => {
276
- if (applyUpdates(updatedVars)) {
277
- notify();
278
- }
279
- };
280
- return {
281
- subscribe,
282
- update
283
- };
284
- };
285
-
286
- // src/style-variables-repository.ts
287
- var styleVariablesRepository = createStyleVariablesRepository();
288
-
289
292
  // src/hooks/use-prop-variables.ts
290
- var usePropVariables = (propKey) => {
291
- return (0, import_react.useMemo)(() => normalizeVariables(propKey), [propKey]);
292
- };
293
293
  var useVariable = (key) => {
294
294
  const variables = service.variables();
295
295
  if (!variables?.[key]) {
@@ -300,92 +300,113 @@ var useVariable = (key) => {
300
300
  key
301
301
  };
302
302
  };
303
+ var useFilteredVariables = (searchValue, propTypeKey) => {
304
+ const variables = usePropVariables(propTypeKey);
305
+ const filteredVariables = variables.filter(({ label }) => {
306
+ return label.toLowerCase().includes(searchValue.toLowerCase());
307
+ });
308
+ return {
309
+ list: filteredVariables,
310
+ hasMatches: filteredVariables.length > 0,
311
+ isSourceNotEmpty: variables.length > 0
312
+ };
313
+ };
314
+ var usePropVariables = (propKey) => {
315
+ return (0, import_react.useMemo)(() => normalizeVariables(propKey), [propKey]);
316
+ };
317
+ var isNotDeleted = ({ deleted }) => !deleted;
303
318
  var normalizeVariables = (propKey) => {
304
319
  const variables = service.variables();
305
- styleVariablesRepository.update(variables);
306
- return Object.entries(variables).filter(([, { type }]) => type === propKey).map(([key, { label, value }]) => ({
320
+ return Object.entries(variables).filter(([, variable]) => variable.type === propKey && isNotDeleted(variable)).map(([key, { label, value }]) => ({
307
321
  key,
308
322
  label,
309
323
  value
310
324
  }));
311
325
  };
312
326
  var createVariable = (newVariable) => {
313
- return service.create(newVariable).then(({ id, variable }) => {
314
- styleVariablesRepository.update({
315
- [id]: variable
316
- });
327
+ return service.create(newVariable).then(({ id }) => {
328
+ return id;
329
+ });
330
+ };
331
+ var updateVariable = (updateId, { value, label }) => {
332
+ return service.update(updateId, { value, label }).then(({ id }) => {
333
+ return id;
334
+ });
335
+ };
336
+ var deleteVariable = (deleteId) => {
337
+ return service.delete(deleteId).then(({ id }) => {
317
338
  return id;
318
339
  });
319
340
  };
320
341
 
321
- // src/prop-types/color-variable-prop-type.ts
322
- var import_editor_props = require("@elementor/editor-props");
323
- var import_schema = require("@elementor/schema");
324
- var colorVariablePropTypeUtil = (0, import_editor_props.createPropUtils)("global-color-variable", import_schema.z.string());
342
+ // src/components/ui/color-indicator.tsx
343
+ var import_ui = require("@elementor/ui");
344
+ var ColorIndicator = (0, import_ui.styled)(import_ui.UnstableColorIndicator)(({ theme }) => ({
345
+ borderRadius: `${theme.shape.borderRadius / 2}px`,
346
+ marginRight: theme.spacing(0.25)
347
+ }));
325
348
 
326
- // src/components/styled-menu-item.tsx
349
+ // src/components/variables-repeater-item-slot.tsx
350
+ var useColorVariable = (value) => {
351
+ const variableId = value?.value?.color?.value;
352
+ return useVariable(variableId || "");
353
+ };
354
+ var BackgroundRepeaterColorIndicator = ({ value }) => {
355
+ const colorVariable = useColorVariable(value);
356
+ return /* @__PURE__ */ React.createElement(ColorIndicator, { component: "span", size: "inherit", value: colorVariable?.value });
357
+ };
358
+ var BackgroundRepeaterLabel = ({ value }) => {
359
+ const colorVariable = useColorVariable(value);
360
+ return /* @__PURE__ */ React.createElement("span", null, colorVariable?.label);
361
+ };
362
+ var BoxShadowRepeaterColorIndicator = ({ value }) => {
363
+ const colorVariable = useColorVariable(value);
364
+ return /* @__PURE__ */ React.createElement(ColorIndicator, { component: "span", size: "inherit", value: colorVariable?.value });
365
+ };
366
+
367
+ // src/controls/color-variable-control.tsx
368
+ var React13 = __toESM(require("react"));
369
+ var import_react10 = require("react");
370
+ var import_editor_controls7 = require("@elementor/editor-controls");
371
+ var import_editor_props3 = require("@elementor/editor-props");
372
+ var import_icons9 = require("@elementor/icons");
373
+ var import_ui14 = require("@elementor/ui");
374
+
375
+ // src/components/ui/variable-tag.tsx
376
+ var React2 = __toESM(require("react"));
377
+ var import_icons = require("@elementor/icons");
327
378
  var import_ui2 = require("@elementor/ui");
328
- var StyledMenuItem = (0, import_ui2.styled)(import_ui2.MenuItem)(() => ({
329
- pl: 2,
330
- pr: 1,
331
- py: 0.5,
332
- "&:hover .MuiSvgIcon-root": {
333
- opacity: 1
379
+ var import_i18n = require("@wordpress/i18n");
380
+ var SIZE = "tiny";
381
+ var VariableTag = ({ startIcon, label, onUnlink, ...props }) => {
382
+ const actions = [];
383
+ if (onUnlink) {
384
+ actions.push(
385
+ /* @__PURE__ */ React2.createElement(import_ui2.IconButton, { key: "unlink", size: SIZE, onClick: onUnlink, "aria-label": (0, import_i18n.__)("Unlink", "elementor") }, /* @__PURE__ */ React2.createElement(import_icons.DetachIcon, { fontSize: SIZE }))
386
+ );
334
387
  }
335
- }));
336
-
337
- // src/components/color-variables-selection.tsx
338
- var ColorVariablesSelection = ({ onSelect }) => {
339
- const { value: variable, setValue: setVariable } = (0, import_editor_controls.useBoundProp)(colorVariablePropTypeUtil);
340
- const variables = usePropVariables(colorVariablePropTypeUtil.key);
341
- const handleSetColorVariable = (key) => {
342
- setVariable(key);
343
- onSelect?.();
344
- };
345
- return /* @__PURE__ */ React.createElement(import_react2.Fragment, null, /* @__PURE__ */ React.createElement(import_ui3.Divider, null), /* @__PURE__ */ React.createElement(import_ui3.Box, { sx: { overflowY: "auto", height: 260, width: 220 } }, /* @__PURE__ */ React.createElement(import_ui3.MenuList, { role: "listbox", tabIndex: 0 }, variables.map(({ value, label, key }) => /* @__PURE__ */ React.createElement(
346
- StyledMenuItem,
388
+ return /* @__PURE__ */ React2.createElement(
389
+ import_ui2.UnstableTag,
347
390
  {
348
- key,
349
- onClick: () => handleSetColorVariable(key),
350
- selected: key === variable
351
- },
352
- /* @__PURE__ */ React.createElement(import_ui3.ListItemIcon, null, /* @__PURE__ */ React.createElement(ColorIndicator, { size: "inherit", component: "span", value })),
353
- /* @__PURE__ */ React.createElement(
354
- import_ui3.ListItemText,
355
- {
356
- primary: label,
357
- secondary: value,
358
- primaryTypographyProps: {
359
- variant: "body2",
360
- color: "text.secondary",
361
- style: {
362
- lineHeight: 2,
363
- display: "inline-block",
364
- overflow: "hidden",
365
- textOverflow: "ellipsis",
366
- whiteSpace: "nowrap",
367
- maxWidth: "81px"
368
- }
369
- },
370
- secondaryTypographyProps: {
371
- variant: "caption",
372
- color: "text.tertiary",
373
- style: { marginTop: "1px", lineHeight: "1" }
374
- },
375
- sx: { display: "flex", alignItems: "center", gap: 1 }
376
- }
377
- ),
378
- /* @__PURE__ */ React.createElement(import_icons.EditIcon, { color: "action", fontSize: "inherit", sx: { mx: 1, opacity: "0" } })
379
- )))));
391
+ fullWidth: true,
392
+ showActionsOnHover: true,
393
+ startIcon: /* @__PURE__ */ React2.createElement(import_ui2.Stack, { gap: 0.5, direction: "row", alignItems: "center" }, startIcon),
394
+ label: /* @__PURE__ */ React2.createElement(import_ui2.Box, { sx: { display: "inline-grid", minWidth: 0 } }, /* @__PURE__ */ React2.createElement(import_ui2.Typography, { sx: { lineHeight: 1.34 }, variant: "caption", noWrap: true }, label)),
395
+ actions,
396
+ ...props
397
+ }
398
+ );
380
399
  };
381
400
 
382
- // src/components/variables-selection-popover.tsx
383
- var React4 = __toESM(require("react"));
384
- var import_react5 = require("react");
385
- var import_editor_ui3 = require("@elementor/editor-ui");
386
- var import_icons4 = require("@elementor/icons");
387
- var import_ui6 = require("@elementor/ui");
388
- var import_i18n3 = require("@wordpress/i18n");
401
+ // src/components/variable-selection-popover.tsx
402
+ var React12 = __toESM(require("react"));
403
+ var import_react9 = require("react");
404
+ var import_ui13 = require("@elementor/ui");
405
+
406
+ // src/prop-types/color-variable-prop-type.ts
407
+ var import_editor_props = require("@elementor/editor-props");
408
+ var import_schema = require("@elementor/schema");
409
+ var colorVariablePropTypeUtil = (0, import_editor_props.createPropUtils)("global-color-variable", import_schema.z.string());
389
410
 
390
411
  // src/prop-types/font-variable-prop-type.ts
391
412
  var import_editor_props2 = require("@elementor/editor-props");
@@ -393,19 +414,30 @@ var import_schema2 = require("@elementor/schema");
393
414
  var fontVariablePropTypeUtil = (0, import_editor_props2.createPropUtils)("global-font-variable", import_schema2.z.string());
394
415
 
395
416
  // src/components/color-variable-creation.tsx
396
- var React2 = __toESM(require("react"));
417
+ var React3 = __toESM(require("react"));
397
418
  var import_react3 = require("react");
398
- var import_editor_controls2 = require("@elementor/editor-controls");
419
+ var import_editor_controls = require("@elementor/editor-controls");
420
+ var import_editor_editing_panel = require("@elementor/editor-editing-panel");
399
421
  var import_editor_ui = require("@elementor/editor-ui");
400
422
  var import_icons2 = require("@elementor/icons");
401
- var import_ui4 = require("@elementor/ui");
402
- var import_i18n = require("@wordpress/i18n");
403
- var SIZE = "tiny";
404
- var ColorVariableCreation = ({ onClose }) => {
405
- const { setValue: setVariable } = (0, import_editor_controls2.useBoundProp)(colorVariablePropTypeUtil);
423
+ var import_ui3 = require("@elementor/ui");
424
+ var import_i18n2 = require("@wordpress/i18n");
425
+
426
+ // src/components/variable-selection-popover.context.ts
427
+ var import_react2 = require("react");
428
+ var PopoverContentRefContext = (0, import_react2.createContext)(null);
429
+ var usePopoverContentRef = () => {
430
+ return (0, import_react2.useContext)(PopoverContentRefContext);
431
+ };
432
+
433
+ // src/components/color-variable-creation.tsx
434
+ var SIZE2 = "tiny";
435
+ var ColorVariableCreation = ({ onGoBack, onClose }) => {
436
+ const { setValue: setVariable } = (0, import_editor_controls.useBoundProp)(colorVariablePropTypeUtil);
406
437
  const [color, setColor] = (0, import_react3.useState)("");
407
438
  const [label, setLabel] = (0, import_react3.useState)("");
408
- const anchorRef = (0, import_react3.useRef)(null);
439
+ const defaultRef = (0, import_react3.useRef)(null);
440
+ const anchorRef = usePopoverContentRef() ?? defaultRef;
409
441
  const resetFields = () => {
410
442
  setColor("");
411
443
  setLabel("");
@@ -427,23 +459,23 @@ var ColorVariableCreation = ({ onClose }) => {
427
459
  const isFormInvalid = () => {
428
460
  return !color?.trim() || !label?.trim();
429
461
  };
430
- return /* @__PURE__ */ React2.createElement(React2.Fragment, null, /* @__PURE__ */ React2.createElement(
462
+ return /* @__PURE__ */ React3.createElement(import_editor_editing_panel.PopoverScrollableContent, { height: "auto" }, /* @__PURE__ */ React3.createElement(
431
463
  import_editor_ui.PopoverHeader,
432
464
  {
433
- title: (0, import_i18n.__)("Create variable", "elementor"),
434
- onClose: closePopover,
435
- icon: /* @__PURE__ */ React2.createElement(import_icons2.BrushIcon, { fontSize: SIZE })
465
+ icon: /* @__PURE__ */ React3.createElement(React3.Fragment, null, onGoBack && /* @__PURE__ */ React3.createElement(import_ui3.IconButton, { size: SIZE2, "aria-label": (0, import_i18n2.__)("Go Back", "elementor"), onClick: onGoBack }, /* @__PURE__ */ React3.createElement(import_icons2.ArrowLeftIcon, { fontSize: SIZE2 })), /* @__PURE__ */ React3.createElement(import_icons2.BrushIcon, { fontSize: SIZE2 })),
466
+ title: (0, import_i18n2.__)("Create variable", "elementor"),
467
+ onClose: closePopover
436
468
  }
437
- ), /* @__PURE__ */ React2.createElement(import_ui4.Divider, null), /* @__PURE__ */ React2.createElement(import_ui4.Stack, { p: 1.5, gap: 1.5 }, /* @__PURE__ */ React2.createElement(import_ui4.Grid, { container: true, gap: 0.75, alignItems: "center" }, /* @__PURE__ */ React2.createElement(import_ui4.Grid, { item: true, xs: 12 }, /* @__PURE__ */ React2.createElement(import_ui4.FormLabel, { size: "small" }, (0, import_i18n.__)("Name", "elementor"))), /* @__PURE__ */ React2.createElement(import_ui4.Grid, { item: true, xs: 12 }, /* @__PURE__ */ React2.createElement(
438
- import_ui4.TextField,
469
+ ), /* @__PURE__ */ React3.createElement(import_ui3.Divider, null), /* @__PURE__ */ React3.createElement(import_editor_controls.PopoverContent, { p: 2 }, /* @__PURE__ */ React3.createElement(import_ui3.Grid, { container: true, gap: 0.75, alignItems: "center" }, /* @__PURE__ */ React3.createElement(import_ui3.Grid, { item: true, xs: 12 }, /* @__PURE__ */ React3.createElement(import_ui3.FormLabel, { size: "tiny" }, (0, import_i18n2.__)("Name", "elementor"))), /* @__PURE__ */ React3.createElement(import_ui3.Grid, { item: true, xs: 12 }, /* @__PURE__ */ React3.createElement(
470
+ import_ui3.TextField,
439
471
  {
440
472
  size: "tiny",
441
473
  fullWidth: true,
442
474
  value: label,
443
475
  onChange: (e) => setLabel(e.target.value)
444
476
  }
445
- ))), /* @__PURE__ */ React2.createElement(import_ui4.Grid, { container: true, gap: 0.75, alignItems: "center" }, /* @__PURE__ */ React2.createElement(import_ui4.Grid, { item: true, xs: 12 }, /* @__PURE__ */ React2.createElement(import_ui4.FormLabel, { size: "small" }, (0, import_i18n.__)("Value", "elementor"))), /* @__PURE__ */ React2.createElement(import_ui4.Grid, { item: true, xs: 12 }, /* @__PURE__ */ React2.createElement(
446
- import_ui4.UnstableColorField,
477
+ ))), /* @__PURE__ */ React3.createElement(import_ui3.Grid, { container: true, gap: 0.75, alignItems: "center" }, /* @__PURE__ */ React3.createElement(import_ui3.Grid, { item: true, xs: 12 }, /* @__PURE__ */ React3.createElement(import_ui3.FormLabel, { size: "tiny" }, (0, import_i18n2.__)("Value", "elementor"))), /* @__PURE__ */ React3.createElement(import_ui3.Grid, { item: true, xs: 12 }, /* @__PURE__ */ React3.createElement(
478
+ import_ui3.UnstableColorField,
447
479
  {
448
480
  size: "tiny",
449
481
  fullWidth: true,
@@ -457,26 +489,323 @@ var ColorVariableCreation = ({ onClose }) => {
457
489
  }
458
490
  }
459
491
  }
460
- )))), /* @__PURE__ */ React2.createElement(import_ui4.CardActions, null, /* @__PURE__ */ React2.createElement(import_ui4.Button, { size: "small", onClick: closePopover, color: "secondary", variant: "text" }, (0, import_i18n.__)("Cancel", "elementor")), /* @__PURE__ */ React2.createElement(import_ui4.Button, { size: "small", variant: "contained", disabled: isFormInvalid(), onClick: handleCreate }, (0, import_i18n.__)("Create", "elementor"))));
492
+ )))), /* @__PURE__ */ React3.createElement(import_ui3.CardActions, { sx: { pt: 0.5, pb: 1 } }, /* @__PURE__ */ React3.createElement(import_ui3.Button, { size: "small", variant: "contained", disabled: isFormInvalid(), onClick: handleCreate }, (0, import_i18n2.__)("Create", "elementor"))));
461
493
  };
462
494
 
463
- // src/components/font-variable-creation.tsx
464
- var React3 = __toESM(require("react"));
495
+ // src/components/color-variable-edit.tsx
496
+ var React4 = __toESM(require("react"));
465
497
  var import_react4 = require("react");
466
- var import_editor_controls3 = require("@elementor/editor-controls");
467
- var import_editor_editing_panel = require("@elementor/editor-editing-panel");
498
+ var import_editor_controls2 = require("@elementor/editor-controls");
468
499
  var import_editor_ui2 = require("@elementor/editor-ui");
469
500
  var import_icons3 = require("@elementor/icons");
501
+ var import_ui4 = require("@elementor/ui");
502
+ var import_i18n3 = require("@wordpress/i18n");
503
+ var SIZE3 = "tiny";
504
+ var ColorVariableEdit = ({ onClose, onGoBack, onSubmit, editId }) => {
505
+ const variable = useVariable(editId);
506
+ if (!variable) {
507
+ throw new Error(`Global color variable not found`);
508
+ }
509
+ const defaultRef = (0, import_react4.useRef)(null);
510
+ const anchorRef = usePopoverContentRef() ?? defaultRef;
511
+ const [color, setColor] = (0, import_react4.useState)(variable.value);
512
+ const [label, setLabel] = (0, import_react4.useState)(variable.label);
513
+ const handleUpdate = () => {
514
+ updateVariable(editId, {
515
+ value: color,
516
+ label
517
+ }).then(() => {
518
+ onSubmit?.();
519
+ });
520
+ };
521
+ const handleDelete = () => {
522
+ deleteVariable(editId).then(() => {
523
+ onSubmit?.();
524
+ });
525
+ };
526
+ const noValueChanged = () => color === variable.value && label === variable.label;
527
+ const hasEmptyValue = () => "" === color.trim() || "" === label.trim();
528
+ const isSaveDisabled = () => noValueChanged() || hasEmptyValue();
529
+ const actions = [];
530
+ actions.push(
531
+ /* @__PURE__ */ React4.createElement(import_ui4.IconButton, { key: "delete", size: SIZE3, "aria-label": (0, import_i18n3.__)("Delete", "elementor"), onClick: handleDelete }, /* @__PURE__ */ React4.createElement(import_icons3.TrashIcon, { fontSize: SIZE3 }))
532
+ );
533
+ return /* @__PURE__ */ React4.createElement(import_editor_ui2.PopoverScrollableContent, { height: "auto" }, /* @__PURE__ */ React4.createElement(
534
+ import_editor_ui2.PopoverHeader,
535
+ {
536
+ title: (0, import_i18n3.__)("Edit variable", "elementor"),
537
+ onClose,
538
+ icon: /* @__PURE__ */ React4.createElement(React4.Fragment, null, onGoBack && /* @__PURE__ */ React4.createElement(import_ui4.IconButton, { size: SIZE3, "aria-label": (0, import_i18n3.__)("Go Back", "elementor"), onClick: onGoBack }, /* @__PURE__ */ React4.createElement(import_icons3.ArrowLeftIcon, { fontSize: SIZE3 })), /* @__PURE__ */ React4.createElement(import_icons3.BrushIcon, { fontSize: SIZE3 })),
539
+ actions
540
+ }
541
+ ), /* @__PURE__ */ React4.createElement(import_ui4.Divider, null), /* @__PURE__ */ React4.createElement(import_editor_controls2.PopoverContent, { p: 2 }, /* @__PURE__ */ React4.createElement(import_ui4.Grid, { container: true, gap: 0.75, alignItems: "center" }, /* @__PURE__ */ React4.createElement(import_ui4.Grid, { item: true, xs: 12 }, /* @__PURE__ */ React4.createElement(import_ui4.FormLabel, { size: "tiny" }, (0, import_i18n3.__)("Name", "elementor"))), /* @__PURE__ */ React4.createElement(import_ui4.Grid, { item: true, xs: 12 }, /* @__PURE__ */ React4.createElement(
542
+ import_ui4.TextField,
543
+ {
544
+ size: "tiny",
545
+ fullWidth: true,
546
+ value: label,
547
+ onChange: (e) => setLabel(e.target.value)
548
+ }
549
+ ))), /* @__PURE__ */ React4.createElement(import_ui4.Grid, { container: true, gap: 0.75, alignItems: "center" }, /* @__PURE__ */ React4.createElement(import_ui4.Grid, { item: true, xs: 12 }, /* @__PURE__ */ React4.createElement(import_ui4.FormLabel, { size: "tiny" }, (0, import_i18n3.__)("Value", "elementor"))), /* @__PURE__ */ React4.createElement(import_ui4.Grid, { item: true, xs: 12 }, /* @__PURE__ */ React4.createElement(
550
+ import_ui4.UnstableColorField,
551
+ {
552
+ size: "tiny",
553
+ fullWidth: true,
554
+ value: color,
555
+ onChange: setColor,
556
+ slotProps: {
557
+ colorPicker: {
558
+ anchorEl: anchorRef.current,
559
+ anchorOrigin: { vertical: "top", horizontal: "right" },
560
+ transformOrigin: { vertical: "top", horizontal: -10 }
561
+ }
562
+ }
563
+ }
564
+ )))), /* @__PURE__ */ React4.createElement(import_ui4.CardActions, { sx: { pt: 0.5, pb: 1 } }, /* @__PURE__ */ React4.createElement(import_ui4.Button, { size: "small", variant: "contained", disabled: isSaveDisabled(), onClick: handleUpdate }, (0, import_i18n3.__)("Save", "elementor"))));
565
+ };
566
+
567
+ // src/components/color-variables-selection.tsx
568
+ var React8 = __toESM(require("react"));
569
+ var import_react5 = require("react");
570
+ var import_editor_controls3 = require("@elementor/editor-controls");
571
+ var import_editor_editing_panel2 = require("@elementor/editor-editing-panel");
572
+ var import_editor_ui4 = require("@elementor/editor-ui");
573
+ var import_icons5 = require("@elementor/icons");
574
+ var import_ui9 = require("@elementor/ui");
575
+ var import_i18n7 = require("@wordpress/i18n");
576
+
577
+ // src/components/ui/menu-item-content.tsx
578
+ var React5 = __toESM(require("react"));
579
+ var import_editor_ui3 = require("@elementor/editor-ui");
580
+ var import_editor_v1_adapters = require("@elementor/editor-v1-adapters");
581
+ var import_icons4 = require("@elementor/icons");
470
582
  var import_ui5 = require("@elementor/ui");
471
- var import_i18n2 = require("@wordpress/i18n");
472
- var SIZE2 = "tiny";
473
- var FontVariableCreation = ({ onClose }) => {
474
- const fontFamilies = (0, import_editor_editing_panel.useFontFamilies)();
475
- const { setValue: setVariable } = (0, import_editor_controls3.useBoundProp)(fontVariablePropTypeUtil);
476
- const [fontFamily, setFontFamily] = (0, import_react4.useState)("");
477
- const [label, setLabel] = (0, import_react4.useState)("");
478
- const anchorRef = (0, import_react4.useRef)(null);
479
- const fontPopoverState = (0, import_ui5.usePopupState)({ variant: "popover" });
583
+ var import_i18n4 = require("@wordpress/i18n");
584
+ var SIZE4 = "tiny";
585
+ var isVersion330Active = (0, import_editor_v1_adapters.isExperimentActive)("e_v_3_30");
586
+ var MenuItemContent = ({ item }) => {
587
+ const onEdit = item.onEdit;
588
+ return /* @__PURE__ */ React5.createElement(React5.Fragment, null, /* @__PURE__ */ React5.createElement(import_ui5.ListItemIcon, null, item.icon), /* @__PURE__ */ React5.createElement(
589
+ import_ui5.Box,
590
+ {
591
+ sx: {
592
+ flex: 1,
593
+ minWidth: 0,
594
+ display: "flex",
595
+ alignItems: "center",
596
+ gap: 1
597
+ }
598
+ },
599
+ /* @__PURE__ */ React5.createElement(
600
+ import_editor_ui3.EllipsisWithTooltip,
601
+ {
602
+ title: item.label || item.value,
603
+ as: import_ui5.Typography,
604
+ variant: isVersion330Active ? "caption" : "body2",
605
+ color: isVersion330Active ? "text.primary" : "text.secondary",
606
+ sx: { marginTop: "1px", lineHeight: "2" },
607
+ maxWidth: "50%"
608
+ }
609
+ ),
610
+ item.secondaryText && /* @__PURE__ */ React5.createElement(
611
+ import_editor_ui3.EllipsisWithTooltip,
612
+ {
613
+ title: item.secondaryText,
614
+ as: import_ui5.Typography,
615
+ variant: "caption",
616
+ color: "text.tertiary",
617
+ sx: { marginTop: "1px", lineHeight: "1" },
618
+ maxWidth: "50%"
619
+ }
620
+ )
621
+ ), !!onEdit && /* @__PURE__ */ React5.createElement(
622
+ import_ui5.IconButton,
623
+ {
624
+ sx: { mx: 1, opacity: "0" },
625
+ onClick: (e) => {
626
+ e.stopPropagation();
627
+ onEdit(item.value);
628
+ },
629
+ "aria-label": (0, import_i18n4.__)("Edit", "elementor")
630
+ },
631
+ /* @__PURE__ */ React5.createElement(import_icons4.EditIcon, { color: "action", fontSize: SIZE4 })
632
+ ));
633
+ };
634
+
635
+ // src/components/ui/no-search-results.tsx
636
+ var React6 = __toESM(require("react"));
637
+ var import_ui6 = require("@elementor/ui");
638
+ var import_i18n5 = require("@wordpress/i18n");
639
+ var NoSearchResults = ({ searchValue, onClear, icon }) => {
640
+ return /* @__PURE__ */ React6.createElement(
641
+ import_ui6.Stack,
642
+ {
643
+ gap: 1,
644
+ alignItems: "center",
645
+ justifyContent: "center",
646
+ height: "100%",
647
+ p: 2.5,
648
+ color: "text.secondary",
649
+ sx: { pb: 3.5 }
650
+ },
651
+ icon,
652
+ /* @__PURE__ */ React6.createElement(import_ui6.Typography, { align: "center", variant: "subtitle2" }, (0, import_i18n5.__)("Sorry, nothing matched", "elementor"), /* @__PURE__ */ React6.createElement("br", null), "\u201C", searchValue, "\u201D."),
653
+ /* @__PURE__ */ React6.createElement(import_ui6.Typography, { align: "center", variant: "caption", sx: { display: "flex", flexDirection: "column" } }, (0, import_i18n5.__)("Try something else.", "elementor"), /* @__PURE__ */ React6.createElement(import_ui6.Link, { color: "text.secondary", variant: "caption", component: "button", onClick: onClear }, (0, import_i18n5.__)("Clear & try again", "elementor")))
654
+ );
655
+ };
656
+
657
+ // src/components/ui/no-variables.tsx
658
+ var React7 = __toESM(require("react"));
659
+ var import_ui7 = require("@elementor/ui");
660
+ var import_i18n6 = require("@wordpress/i18n");
661
+ var NoVariables = ({ icon, title, onAdd }) => /* @__PURE__ */ React7.createElement(
662
+ import_ui7.Stack,
663
+ {
664
+ gap: 1,
665
+ alignItems: "center",
666
+ justifyContent: "center",
667
+ height: "100%",
668
+ color: "text.secondary",
669
+ sx: { p: 2.5, pb: 5.5 }
670
+ },
671
+ icon,
672
+ /* @__PURE__ */ React7.createElement(import_ui7.Typography, { align: "center", variant: "subtitle2" }, title),
673
+ /* @__PURE__ */ React7.createElement(import_ui7.Typography, { align: "center", variant: "caption", maxWidth: "180px" }, (0, import_i18n6.__)("Variables are saved attributes that you can apply anywhere on your site.", "elementor")),
674
+ onAdd && /* @__PURE__ */ React7.createElement(import_ui7.Button, { variant: "outlined", color: "secondary", size: "small", onClick: onAdd }, (0, import_i18n6.__)("Create a variable", "elementor"))
675
+ );
676
+
677
+ // src/components/ui/styled-menu-list.tsx
678
+ var import_ui8 = require("@elementor/ui");
679
+ var VariablesStyledMenuList = (0, import_ui8.styled)(import_ui8.MenuList)(({ theme }) => ({
680
+ "& > li": {
681
+ height: 32,
682
+ width: "100%",
683
+ display: "flex",
684
+ alignItems: "center"
685
+ },
686
+ '& > [role="option"]': {
687
+ ...theme.typography.caption,
688
+ lineHeight: "inherit",
689
+ padding: theme.spacing(0.5, 1, 0.5, 2),
690
+ "&:hover, &:focus": {
691
+ backgroundColor: theme.palette.action.hover
692
+ },
693
+ '&[aria-selected="true"]': {
694
+ backgroundColor: theme.palette.action.selected
695
+ },
696
+ cursor: "pointer",
697
+ textOverflow: "ellipsis",
698
+ position: "absolute",
699
+ top: 0,
700
+ left: 0,
701
+ "&:hover .MuiIconButton-root, .MuiIconButton-root:focus": {
702
+ opacity: 1
703
+ }
704
+ },
705
+ width: "100%",
706
+ position: "relative"
707
+ }));
708
+
709
+ // src/components/color-variables-selection.tsx
710
+ var SIZE5 = "tiny";
711
+ var ColorVariablesSelection = ({ closePopover, onAdd, onEdit, onSettings }) => {
712
+ const { value: variable, setValue: setVariable } = (0, import_editor_controls3.useBoundProp)(colorVariablePropTypeUtil);
713
+ const [searchValue, setSearchValue] = (0, import_react5.useState)("");
714
+ const {
715
+ list: variables,
716
+ hasMatches: hasSearchResults,
717
+ isSourceNotEmpty: hasVariables
718
+ } = useFilteredVariables(searchValue, colorVariablePropTypeUtil.key);
719
+ const handleSetColorVariable = (key) => {
720
+ setVariable(key);
721
+ closePopover();
722
+ };
723
+ const actions = [];
724
+ if (onAdd) {
725
+ actions.push(
726
+ /* @__PURE__ */ React8.createElement(import_ui9.IconButton, { key: "add", size: SIZE5, onClick: onAdd }, /* @__PURE__ */ React8.createElement(import_icons5.PlusIcon, { fontSize: SIZE5 }))
727
+ );
728
+ }
729
+ if (onSettings) {
730
+ actions.push(
731
+ /* @__PURE__ */ React8.createElement(import_ui9.IconButton, { key: "settings", size: SIZE5, onClick: onSettings }, /* @__PURE__ */ React8.createElement(import_icons5.SettingsIcon, { fontSize: SIZE5 }))
732
+ );
733
+ }
734
+ const items = variables.map(({ value, label, key }) => ({
735
+ type: "item",
736
+ value: key,
737
+ label,
738
+ icon: /* @__PURE__ */ React8.createElement(ColorIndicator, { size: "inherit", component: "span", value }),
739
+ secondaryText: value,
740
+ onEdit: () => onEdit?.(key)
741
+ }));
742
+ const handleSearch = (search) => {
743
+ setSearchValue(search);
744
+ };
745
+ const handleClearSearch = () => {
746
+ setSearchValue("");
747
+ };
748
+ return /* @__PURE__ */ React8.createElement(React8.Fragment, null, /* @__PURE__ */ React8.createElement(
749
+ import_editor_ui4.PopoverHeader,
750
+ {
751
+ title: (0, import_i18n7.__)("Variables", "elementor"),
752
+ icon: /* @__PURE__ */ React8.createElement(import_icons5.ColorFilterIcon, { fontSize: SIZE5 }),
753
+ onClose: closePopover,
754
+ actions
755
+ }
756
+ ), hasVariables && /* @__PURE__ */ React8.createElement(
757
+ import_editor_ui4.PopoverSearch,
758
+ {
759
+ value: searchValue,
760
+ onSearch: handleSearch,
761
+ placeholder: (0, import_i18n7.__)("Search", "elementor")
762
+ }
763
+ ), /* @__PURE__ */ React8.createElement(import_ui9.Divider, null), /* @__PURE__ */ React8.createElement(import_editor_editing_panel2.PopoverScrollableContent, null, hasVariables && hasSearchResults && /* @__PURE__ */ React8.createElement(
764
+ import_editor_ui4.PopoverMenuList,
765
+ {
766
+ items,
767
+ onSelect: handleSetColorVariable,
768
+ onClose: () => {
769
+ },
770
+ selectedValue: variable,
771
+ "data-testid": "color-variables-list",
772
+ menuListTemplate: VariablesStyledMenuList,
773
+ menuItemContentTemplate: (item) => /* @__PURE__ */ React8.createElement(MenuItemContent, { item })
774
+ }
775
+ ), !hasSearchResults && hasVariables && /* @__PURE__ */ React8.createElement(
776
+ NoSearchResults,
777
+ {
778
+ searchValue,
779
+ onClear: handleClearSearch,
780
+ icon: /* @__PURE__ */ React8.createElement(import_icons5.BrushIcon, { fontSize: "large" })
781
+ }
782
+ ), !hasVariables && /* @__PURE__ */ React8.createElement(
783
+ NoVariables,
784
+ {
785
+ title: (0, import_i18n7.__)("Create your first color variable", "elementor"),
786
+ icon: /* @__PURE__ */ React8.createElement(import_icons5.BrushIcon, { fontSize: "large" }),
787
+ onAdd
788
+ }
789
+ )));
790
+ };
791
+
792
+ // src/components/font-variable-creation.tsx
793
+ var React9 = __toESM(require("react"));
794
+ var import_react6 = require("react");
795
+ var import_editor_controls4 = require("@elementor/editor-controls");
796
+ var import_editor_editing_panel3 = require("@elementor/editor-editing-panel");
797
+ var import_editor_ui5 = require("@elementor/editor-ui");
798
+ var import_icons6 = require("@elementor/icons");
799
+ var import_ui10 = require("@elementor/ui");
800
+ var import_i18n8 = require("@wordpress/i18n");
801
+ var SIZE6 = "tiny";
802
+ var FontVariableCreation = ({ onClose, onGoBack }) => {
803
+ const fontFamilies = (0, import_editor_editing_panel3.useFontFamilies)();
804
+ const { setValue: setVariable } = (0, import_editor_controls4.useBoundProp)(fontVariablePropTypeUtil);
805
+ const [fontFamily, setFontFamily] = (0, import_react6.useState)("");
806
+ const [label, setLabel] = (0, import_react6.useState)("");
807
+ const anchorRef = (0, import_react6.useRef)(null);
808
+ const fontPopoverState = (0, import_ui10.usePopupState)({ variant: "popover" });
480
809
  const resetFields = () => {
481
810
  setFontFamily("");
482
811
  setLabel("");
@@ -498,152 +827,393 @@ var FontVariableCreation = ({ onClose }) => {
498
827
  const isFormInvalid = () => {
499
828
  return !fontFamily?.trim() || !label?.trim();
500
829
  };
501
- return /* @__PURE__ */ React3.createElement(React3.Fragment, null, /* @__PURE__ */ React3.createElement(
502
- import_editor_ui2.PopoverHeader,
830
+ const sectionWidth = (0, import_editor_editing_panel3.useSectionWidth)();
831
+ return /* @__PURE__ */ React9.createElement(import_editor_editing_panel3.PopoverScrollableContent, { height: "auto" }, /* @__PURE__ */ React9.createElement(
832
+ import_editor_ui5.PopoverHeader,
503
833
  {
504
- title: (0, import_i18n2.__)("Create variable", "elementor"),
505
- onClose: closePopover,
506
- icon: /* @__PURE__ */ React3.createElement(import_icons3.TextIcon, { fontSize: SIZE2 })
834
+ icon: /* @__PURE__ */ React9.createElement(React9.Fragment, null, onGoBack && /* @__PURE__ */ React9.createElement(import_ui10.IconButton, { size: SIZE6, "aria-label": (0, import_i18n8.__)("Go Back", "elementor"), onClick: onGoBack }, /* @__PURE__ */ React9.createElement(import_icons6.ArrowLeftIcon, { fontSize: SIZE6 })), /* @__PURE__ */ React9.createElement(import_icons6.TextIcon, { fontSize: SIZE6 })),
835
+ title: (0, import_i18n8.__)("Create variable", "elementor"),
836
+ onClose: closePopover
507
837
  }
508
- ), /* @__PURE__ */ React3.createElement(import_ui5.Divider, null), /* @__PURE__ */ React3.createElement(import_ui5.Stack, { p: 1.5, gap: 1.5 }, /* @__PURE__ */ React3.createElement(import_ui5.Grid, { container: true, gap: 0.75, alignItems: "center" }, /* @__PURE__ */ React3.createElement(import_ui5.Grid, { item: true, xs: 12 }, /* @__PURE__ */ React3.createElement(import_ui5.FormLabel, { size: "small" }, (0, import_i18n2.__)("Name", "elementor"))), /* @__PURE__ */ React3.createElement(import_ui5.Grid, { item: true, xs: 12 }, /* @__PURE__ */ React3.createElement(
509
- import_ui5.TextField,
838
+ ), /* @__PURE__ */ React9.createElement(import_ui10.Divider, null), /* @__PURE__ */ React9.createElement(import_editor_controls4.PopoverContent, { p: 2 }, /* @__PURE__ */ React9.createElement(import_ui10.Grid, { container: true, gap: 0.75, alignItems: "center" }, /* @__PURE__ */ React9.createElement(import_ui10.Grid, { item: true, xs: 12 }, /* @__PURE__ */ React9.createElement(import_ui10.FormLabel, { size: "tiny" }, (0, import_i18n8.__)("Name", "elementor"))), /* @__PURE__ */ React9.createElement(import_ui10.Grid, { item: true, xs: 12 }, /* @__PURE__ */ React9.createElement(
839
+ import_ui10.TextField,
510
840
  {
511
841
  size: "tiny",
512
842
  fullWidth: true,
513
843
  value: label,
514
844
  onChange: (e) => setLabel(e.target.value)
515
845
  }
516
- ))), /* @__PURE__ */ React3.createElement(import_ui5.Grid, { container: true, gap: 0.75, alignItems: "center" }, /* @__PURE__ */ React3.createElement(import_ui5.Grid, { item: true, xs: 12 }, /* @__PURE__ */ React3.createElement(import_ui5.FormLabel, { size: "small" }, (0, import_i18n2.__)("Value", "elementor"))), /* @__PURE__ */ React3.createElement(import_ui5.Grid, { item: true, xs: 12 }, /* @__PURE__ */ React3.createElement(React3.Fragment, null, /* @__PURE__ */ React3.createElement(
517
- import_ui5.UnstableTag,
846
+ ))), /* @__PURE__ */ React9.createElement(import_ui10.Grid, { container: true, gap: 0.75, alignItems: "center" }, /* @__PURE__ */ React9.createElement(import_ui10.Grid, { item: true, xs: 12 }, /* @__PURE__ */ React9.createElement(import_ui10.FormLabel, { size: "tiny" }, (0, import_i18n8.__)("Value", "elementor"))), /* @__PURE__ */ React9.createElement(import_ui10.Grid, { item: true, xs: 12 }, /* @__PURE__ */ React9.createElement(React9.Fragment, null, /* @__PURE__ */ React9.createElement(
847
+ import_ui10.UnstableTag,
518
848
  {
519
849
  variant: "outlined",
520
850
  label: fontFamily,
521
- endIcon: /* @__PURE__ */ React3.createElement(import_icons3.ChevronDownIcon, { fontSize: "tiny" }),
522
- ...(0, import_ui5.bindTrigger)(fontPopoverState),
851
+ endIcon: /* @__PURE__ */ React9.createElement(import_icons6.ChevronDownIcon, { fontSize: "tiny" }),
852
+ ...(0, import_ui10.bindTrigger)(fontPopoverState),
523
853
  fullWidth: true
524
854
  }
525
- ), /* @__PURE__ */ React3.createElement(
526
- import_ui5.Popover,
855
+ ), /* @__PURE__ */ React9.createElement(
856
+ import_ui10.Popover,
527
857
  {
528
858
  disablePortal: true,
529
859
  disableScrollLock: true,
530
860
  anchorEl: anchorRef.current,
531
861
  anchorOrigin: { vertical: "top", horizontal: "right" },
532
862
  transformOrigin: { vertical: "top", horizontal: -20 },
533
- ...(0, import_ui5.bindPopover)(fontPopoverState)
863
+ ...(0, import_ui10.bindPopover)(fontPopoverState)
534
864
  },
535
- /* @__PURE__ */ React3.createElement(
536
- import_editor_controls3.FontFamilySelector,
865
+ /* @__PURE__ */ React9.createElement(
866
+ import_editor_controls4.FontFamilySelector,
537
867
  {
538
868
  fontFamilies,
539
869
  fontFamily,
540
870
  onFontFamilyChange: setFontFamily,
541
- onClose: fontPopoverState.close
871
+ onClose: fontPopoverState.close,
872
+ sectionWidth
542
873
  }
543
874
  )
544
- ))))), /* @__PURE__ */ React3.createElement(import_ui5.CardActions, null, /* @__PURE__ */ React3.createElement(import_ui5.Button, { size: "small", onClick: closePopover, color: "secondary", variant: "text" }, (0, import_i18n2.__)("Cancel", "elementor")), /* @__PURE__ */ React3.createElement(import_ui5.Button, { size: "small", variant: "contained", disabled: isFormInvalid(), onClick: handleCreate }, (0, import_i18n2.__)("Create", "elementor"))));
875
+ ))))), /* @__PURE__ */ React9.createElement(import_ui10.CardActions, { sx: { pt: 0.5, pb: 1 } }, /* @__PURE__ */ React9.createElement(import_ui10.Button, { size: "small", variant: "contained", disabled: isFormInvalid(), onClick: handleCreate }, (0, import_i18n8.__)("Create", "elementor"))));
545
876
  };
546
877
 
547
- // src/components/variables-selection-popover.tsx
548
- var SIZE3 = "tiny";
549
- var VariablesSelectionPopover = ({
550
- selectedVariable,
551
- unlinkVariable,
552
- startTagAdornment,
553
- children
554
- }) => {
555
- const id = (0, import_react5.useId)();
556
- const popupState = (0, import_ui6.usePopupState)({ variant: "popover", popupId: `elementor-variables-action-${id}` });
557
- const creationPopupState = (0, import_ui6.usePopupState)({ variant: "popover", popupId: `elementor-variables-creation-${id}` });
558
- const closePopover = () => popupState.close();
559
- const handleCreateButtonClick = (event) => {
560
- closePopover();
561
- (0, import_ui6.bindTrigger)(creationPopupState).onClick(event);
878
+ // src/components/font-variable-edit.tsx
879
+ var React10 = __toESM(require("react"));
880
+ var import_react7 = require("react");
881
+ var import_editor_controls5 = require("@elementor/editor-controls");
882
+ var import_editor_editing_panel4 = require("@elementor/editor-editing-panel");
883
+ var import_editor_ui6 = require("@elementor/editor-ui");
884
+ var import_icons7 = require("@elementor/icons");
885
+ var import_ui11 = require("@elementor/ui");
886
+ var import_i18n9 = require("@wordpress/i18n");
887
+ var SIZE7 = "tiny";
888
+ var FontVariableEdit = ({ onClose, onGoBack, onSubmit, editId }) => {
889
+ const variable = useVariable(editId);
890
+ if (!variable) {
891
+ throw new Error(`Global font variable "${editId}" not found`);
892
+ }
893
+ const [fontFamily, setFontFamily] = (0, import_react7.useState)(variable.value);
894
+ const [label, setLabel] = (0, import_react7.useState)(variable.label);
895
+ const variableNameId = (0, import_react7.useId)();
896
+ const variableValueId = (0, import_react7.useId)();
897
+ const anchorRef = (0, import_react7.useRef)(null);
898
+ const fontPopoverState = (0, import_ui11.usePopupState)({ variant: "popover" });
899
+ const fontFamilies = (0, import_editor_editing_panel4.useFontFamilies)();
900
+ const handleUpdate = () => {
901
+ updateVariable(editId, {
902
+ value: fontFamily,
903
+ label
904
+ }).then(() => {
905
+ onSubmit?.();
906
+ });
907
+ };
908
+ const handleDelete = () => {
909
+ deleteVariable(editId).then(() => {
910
+ onSubmit?.();
911
+ });
562
912
  };
563
- const anchorRef = (0, import_react5.useRef)(null);
564
- const { label } = selectedVariable;
565
- const colorCreationEnabled = colorVariablePropTypeUtil.key === selectedVariable.type;
566
- const fontCreationEnabled = fontVariablePropTypeUtil.key === selectedVariable.type;
567
- return /* @__PURE__ */ React4.createElement(import_ui6.Box, { ref: anchorRef }, /* @__PURE__ */ React4.createElement(
568
- import_ui6.UnstableTag,
913
+ const noValueChanged = () => fontFamily === variable.value && label === variable.label;
914
+ const hasEmptyValue = () => "" === fontFamily.trim() || "" === label.trim();
915
+ const isSaveDisabled = () => noValueChanged() || hasEmptyValue();
916
+ const sectionWidth = (0, import_editor_editing_panel4.useSectionWidth)();
917
+ const actions = [];
918
+ actions.push(
919
+ /* @__PURE__ */ React10.createElement(import_ui11.IconButton, { key: "delete", size: SIZE7, "aria-label": (0, import_i18n9.__)("Delete", "elementor"), onClick: handleDelete }, /* @__PURE__ */ React10.createElement(import_icons7.TrashIcon, { fontSize: SIZE7 }))
920
+ );
921
+ return /* @__PURE__ */ React10.createElement(import_editor_ui6.PopoverScrollableContent, { height: "auto" }, /* @__PURE__ */ React10.createElement(
922
+ import_editor_ui6.PopoverHeader,
569
923
  {
924
+ icon: /* @__PURE__ */ React10.createElement(React10.Fragment, null, onGoBack && /* @__PURE__ */ React10.createElement(import_ui11.IconButton, { size: SIZE7, "aria-label": (0, import_i18n9.__)("Go Back", "elementor"), onClick: onGoBack }, /* @__PURE__ */ React10.createElement(import_icons7.ArrowLeftIcon, { fontSize: SIZE7 })), /* @__PURE__ */ React10.createElement(import_icons7.TextIcon, { fontSize: SIZE7 })),
925
+ title: (0, import_i18n9.__)("Edit variable", "elementor"),
926
+ onClose,
927
+ actions
928
+ }
929
+ ), /* @__PURE__ */ React10.createElement(import_ui11.Divider, null), /* @__PURE__ */ React10.createElement(import_editor_controls5.PopoverContent, { p: 2 }, /* @__PURE__ */ React10.createElement(import_ui11.Grid, { container: true, gap: 0.75, alignItems: "center" }, /* @__PURE__ */ React10.createElement(import_ui11.Grid, { item: true, xs: 12 }, /* @__PURE__ */ React10.createElement(import_ui11.FormLabel, { htmlFor: variableNameId, size: "tiny" }, (0, import_i18n9.__)("Name", "elementor"))), /* @__PURE__ */ React10.createElement(import_ui11.Grid, { item: true, xs: 12 }, /* @__PURE__ */ React10.createElement(
930
+ import_ui11.TextField,
931
+ {
932
+ id: variableNameId,
933
+ size: "tiny",
570
934
  fullWidth: true,
571
- showActionsOnHover: true,
572
- ...(0, import_ui6.bindTrigger)(popupState),
573
- startIcon: /* @__PURE__ */ React4.createElement(import_ui6.Stack, { spacing: 1, direction: "row", alignItems: "center" }, startTagAdornment, /* @__PURE__ */ React4.createElement(import_icons4.ColorFilterIcon, { fontSize: "inherit", sx: { mr: 1 } })),
574
- label: /* @__PURE__ */ React4.createElement(import_ui6.Box, { sx: { display: "inline-grid" } }, /* @__PURE__ */ React4.createElement(import_ui6.Typography, { sx: { textOverflow: "ellipsis", overflowX: "hidden" }, variant: "subtitle2" }, label)),
575
- actions: /* @__PURE__ */ React4.createElement(import_ui6.IconButton, { size: SIZE3, onClick: unlinkVariable, "aria-label": (0, import_i18n3.__)("Unlink", "elementor") }, /* @__PURE__ */ React4.createElement(import_icons4.DetachIcon, { fontSize: SIZE3 }))
935
+ value: label,
936
+ onChange: (e) => setLabel(e.target.value)
937
+ }
938
+ ))), /* @__PURE__ */ React10.createElement(import_ui11.Grid, { container: true, gap: 0.75, alignItems: "center" }, /* @__PURE__ */ React10.createElement(import_ui11.Grid, { item: true, xs: 12 }, /* @__PURE__ */ React10.createElement(import_ui11.FormLabel, { htmlFor: variableValueId, size: "tiny" }, (0, import_i18n9.__)("Value", "elementor"))), /* @__PURE__ */ React10.createElement(import_ui11.Grid, { item: true, xs: 12 }, /* @__PURE__ */ React10.createElement(React10.Fragment, null, /* @__PURE__ */ React10.createElement(
939
+ import_ui11.UnstableTag,
940
+ {
941
+ id: variableValueId,
942
+ variant: "outlined",
943
+ label: fontFamily,
944
+ endIcon: /* @__PURE__ */ React10.createElement(import_icons7.ChevronDownIcon, { fontSize: "tiny" }),
945
+ ...(0, import_ui11.bindTrigger)(fontPopoverState),
946
+ fullWidth: true
576
947
  }
577
- ), /* @__PURE__ */ React4.createElement(
578
- import_ui6.Popover,
948
+ ), /* @__PURE__ */ React10.createElement(
949
+ import_ui11.Popover,
579
950
  {
580
- ...(0, import_ui6.bindPopover)(popupState),
951
+ disablePortal: true,
581
952
  disableScrollLock: true,
582
953
  anchorEl: anchorRef.current,
583
- anchorOrigin: { vertical: "bottom", horizontal: "right" },
584
- transformOrigin: { vertical: "top", horizontal: "right" }
954
+ anchorOrigin: { vertical: "top", horizontal: "right" },
955
+ transformOrigin: { vertical: "top", horizontal: -20 },
956
+ ...(0, import_ui11.bindPopover)(fontPopoverState)
585
957
  },
586
- /* @__PURE__ */ React4.createElement(
587
- import_editor_ui3.PopoverHeader,
958
+ /* @__PURE__ */ React10.createElement(
959
+ import_editor_controls5.FontFamilySelector,
588
960
  {
589
- title: (0, import_i18n3.__)("Variables", "elementor"),
590
- onClose: closePopover,
591
- icon: /* @__PURE__ */ React4.createElement(import_icons4.ColorFilterIcon, { fontSize: SIZE3 }),
592
- actions: [
593
- /* @__PURE__ */ React4.createElement(
594
- import_ui6.IconButton,
595
- {
596
- key: "createVariable",
597
- ...(0, import_ui6.bindTrigger)(creationPopupState),
598
- size: SIZE3,
599
- onClick: handleCreateButtonClick
600
- },
601
- /* @__PURE__ */ React4.createElement(import_icons4.PlusIcon, { fontSize: SIZE3 })
602
- )
603
- ]
961
+ fontFamilies,
962
+ fontFamily,
963
+ onFontFamilyChange: setFontFamily,
964
+ onClose: fontPopoverState.close,
965
+ sectionWidth
604
966
  }
605
- ),
606
- children?.({ closePopover })
607
- ), /* @__PURE__ */ React4.createElement(import_ui6.Box, { ref: anchorRef }, /* @__PURE__ */ React4.createElement(
608
- import_ui6.Popover,
967
+ )
968
+ ))))), /* @__PURE__ */ React10.createElement(import_ui11.CardActions, { sx: { pt: 0.5, pb: 1 } }, /* @__PURE__ */ React10.createElement(import_ui11.Button, { size: "small", variant: "contained", disabled: isSaveDisabled(), onClick: handleUpdate }, (0, import_i18n9.__)("Save", "elementor"))));
969
+ };
970
+
971
+ // src/components/font-variables-selection.tsx
972
+ var React11 = __toESM(require("react"));
973
+ var import_react8 = require("react");
974
+ var import_editor_controls6 = require("@elementor/editor-controls");
975
+ var import_editor_editing_panel5 = require("@elementor/editor-editing-panel");
976
+ var import_editor_ui7 = require("@elementor/editor-ui");
977
+ var import_icons8 = require("@elementor/icons");
978
+ var import_ui12 = require("@elementor/ui");
979
+ var import_i18n10 = require("@wordpress/i18n");
980
+ var SIZE8 = "tiny";
981
+ var FontVariablesSelection = ({ closePopover, onAdd, onEdit, onSettings }) => {
982
+ const { value: variable, setValue: setVariable } = (0, import_editor_controls6.useBoundProp)(fontVariablePropTypeUtil);
983
+ const [searchValue, setSearchValue] = (0, import_react8.useState)("");
984
+ const {
985
+ list: variables,
986
+ hasMatches: hasSearchResults,
987
+ isSourceNotEmpty: hasVariables
988
+ } = useFilteredVariables(searchValue, fontVariablePropTypeUtil.key);
989
+ const handleSetVariable = (key) => {
990
+ setVariable(key);
991
+ closePopover();
992
+ };
993
+ const actions = [];
994
+ if (onAdd) {
995
+ actions.push(
996
+ /* @__PURE__ */ React11.createElement(import_ui12.IconButton, { key: "add", size: SIZE8, onClick: onAdd }, /* @__PURE__ */ React11.createElement(import_icons8.PlusIcon, { fontSize: SIZE8 }))
997
+ );
998
+ }
999
+ if (onSettings) {
1000
+ actions.push(
1001
+ /* @__PURE__ */ React11.createElement(import_ui12.IconButton, { key: "settings", size: SIZE8, onClick: onSettings }, /* @__PURE__ */ React11.createElement(import_icons8.SettingsIcon, { fontSize: SIZE8 }))
1002
+ );
1003
+ }
1004
+ const items = variables.map(({ value, label, key }) => ({
1005
+ type: "item",
1006
+ value: key,
1007
+ label,
1008
+ icon: /* @__PURE__ */ React11.createElement(import_icons8.TextIcon, { fontSize: SIZE8 }),
1009
+ secondaryText: value,
1010
+ onEdit: () => onEdit?.(key)
1011
+ }));
1012
+ const handleSearch = (search) => {
1013
+ setSearchValue(search);
1014
+ };
1015
+ const handleClearSearch = () => {
1016
+ setSearchValue("");
1017
+ };
1018
+ return /* @__PURE__ */ React11.createElement(React11.Fragment, null, /* @__PURE__ */ React11.createElement(
1019
+ import_editor_ui7.PopoverHeader,
609
1020
  {
610
- ...(0, import_ui6.bindPopover)(creationPopupState),
611
- anchorEl: anchorRef.current,
612
- anchorOrigin: { vertical: "bottom", horizontal: "right" },
613
- transformOrigin: { vertical: "top", horizontal: "right" }
614
- },
615
- colorCreationEnabled && /* @__PURE__ */ React4.createElement(ColorVariableCreation, { onClose: creationPopupState.close }),
616
- fontCreationEnabled && /* @__PURE__ */ React4.createElement(FontVariableCreation, { onClose: creationPopupState.close })
1021
+ title: (0, import_i18n10.__)("Variables", "elementor"),
1022
+ onClose: closePopover,
1023
+ icon: /* @__PURE__ */ React11.createElement(import_icons8.ColorFilterIcon, { fontSize: SIZE8 }),
1024
+ actions
1025
+ }
1026
+ ), hasVariables && /* @__PURE__ */ React11.createElement(
1027
+ import_editor_ui7.PopoverSearch,
1028
+ {
1029
+ value: searchValue,
1030
+ onSearch: handleSearch,
1031
+ placeholder: (0, import_i18n10.__)("Search", "elementor")
1032
+ }
1033
+ ), /* @__PURE__ */ React11.createElement(import_ui12.Divider, null), /* @__PURE__ */ React11.createElement(import_editor_editing_panel5.PopoverScrollableContent, null, hasVariables && hasSearchResults && /* @__PURE__ */ React11.createElement(
1034
+ import_editor_ui7.PopoverMenuList,
1035
+ {
1036
+ items,
1037
+ onSelect: handleSetVariable,
1038
+ onClose: () => {
1039
+ },
1040
+ selectedValue: variable,
1041
+ "data-testid": "font-variables-list",
1042
+ menuListTemplate: VariablesStyledMenuList,
1043
+ menuItemContentTemplate: (item) => /* @__PURE__ */ React11.createElement(MenuItemContent, { item })
1044
+ }
1045
+ ), !hasSearchResults && hasVariables && /* @__PURE__ */ React11.createElement(
1046
+ NoSearchResults,
1047
+ {
1048
+ searchValue,
1049
+ onClear: handleClearSearch,
1050
+ icon: /* @__PURE__ */ React11.createElement(import_icons8.TextIcon, { fontSize: "large" })
1051
+ }
1052
+ ), !hasVariables && /* @__PURE__ */ React11.createElement(
1053
+ NoVariables,
1054
+ {
1055
+ title: (0, import_i18n10.__)("Create your first font variable", "elementor"),
1056
+ icon: /* @__PURE__ */ React11.createElement(import_icons8.TextIcon, { fontSize: "large" }),
1057
+ onAdd
1058
+ }
617
1059
  )));
618
1060
  };
619
1061
 
620
- // src/controls/color-variables-selection-control.tsx
621
- var ColorVariablesSelectionControl = () => {
622
- const { setValue } = (0, import_editor_controls4.useBoundProp)();
623
- const { value: variableValue } = (0, import_editor_controls4.useBoundProp)(colorVariablePropTypeUtil);
1062
+ // src/components/variable-selection-popover.tsx
1063
+ var VIEW_LIST = "list";
1064
+ var VIEW_ADD = "add";
1065
+ var VIEW_EDIT = "edit";
1066
+ var VariableSelectionPopover = ({ closePopover, propTypeKey, selectedVariable }) => {
1067
+ const [currentView, setCurrentView] = (0, import_react9.useState)(VIEW_LIST);
1068
+ const editIdRef = (0, import_react9.useRef)("");
1069
+ const anchorRef = (0, import_react9.useRef)(null);
1070
+ return /* @__PURE__ */ React12.createElement(PopoverContentRefContext.Provider, { value: anchorRef }, /* @__PURE__ */ React12.createElement(import_ui13.Box, { ref: anchorRef }, renderStage({
1071
+ propTypeKey,
1072
+ currentView,
1073
+ selectedVariable,
1074
+ editIdRef,
1075
+ setCurrentView,
1076
+ closePopover
1077
+ })));
1078
+ };
1079
+ function renderStage(props) {
1080
+ const handleSubmitOnEdit = () => {
1081
+ if (props?.selectedVariable?.key === props.editIdRef.current) {
1082
+ props.closePopover();
1083
+ } else {
1084
+ props.setCurrentView(VIEW_LIST);
1085
+ }
1086
+ };
1087
+ if (fontVariablePropTypeUtil.key === props.propTypeKey) {
1088
+ if (VIEW_LIST === props.currentView) {
1089
+ return /* @__PURE__ */ React12.createElement(
1090
+ FontVariablesSelection,
1091
+ {
1092
+ closePopover: props.closePopover,
1093
+ onAdd: () => {
1094
+ props.setCurrentView(VIEW_ADD);
1095
+ },
1096
+ onEdit: (key) => {
1097
+ props.editIdRef.current = key;
1098
+ props.setCurrentView(VIEW_EDIT);
1099
+ }
1100
+ }
1101
+ );
1102
+ }
1103
+ if (VIEW_ADD === props.currentView) {
1104
+ return /* @__PURE__ */ React12.createElement(
1105
+ FontVariableCreation,
1106
+ {
1107
+ onGoBack: () => props.setCurrentView(VIEW_LIST),
1108
+ onClose: props.closePopover
1109
+ }
1110
+ );
1111
+ }
1112
+ if (VIEW_EDIT === props.currentView) {
1113
+ return /* @__PURE__ */ React12.createElement(
1114
+ FontVariableEdit,
1115
+ {
1116
+ editId: props.editIdRef.current ?? "",
1117
+ onGoBack: () => props.setCurrentView(VIEW_LIST),
1118
+ onClose: props.closePopover,
1119
+ onSubmit: handleSubmitOnEdit
1120
+ }
1121
+ );
1122
+ }
1123
+ }
1124
+ if (colorVariablePropTypeUtil.key === props.propTypeKey) {
1125
+ if (VIEW_LIST === props.currentView) {
1126
+ return /* @__PURE__ */ React12.createElement(
1127
+ ColorVariablesSelection,
1128
+ {
1129
+ closePopover: props.closePopover,
1130
+ onAdd: () => {
1131
+ props.setCurrentView(VIEW_ADD);
1132
+ },
1133
+ onEdit: (key) => {
1134
+ props.editIdRef.current = key;
1135
+ props.setCurrentView(VIEW_EDIT);
1136
+ }
1137
+ }
1138
+ );
1139
+ }
1140
+ if (VIEW_ADD === props.currentView) {
1141
+ return /* @__PURE__ */ React12.createElement(
1142
+ ColorVariableCreation,
1143
+ {
1144
+ onGoBack: () => props.setCurrentView(VIEW_LIST),
1145
+ onClose: props.closePopover
1146
+ }
1147
+ );
1148
+ }
1149
+ if (VIEW_EDIT === props.currentView) {
1150
+ return /* @__PURE__ */ React12.createElement(
1151
+ ColorVariableEdit,
1152
+ {
1153
+ editId: props.editIdRef.current ?? "",
1154
+ onGoBack: () => props.setCurrentView(VIEW_LIST),
1155
+ onClose: props.closePopover,
1156
+ onSubmit: handleSubmitOnEdit
1157
+ }
1158
+ );
1159
+ }
1160
+ }
1161
+ return null;
1162
+ }
1163
+
1164
+ // src/controls/color-variable-control.tsx
1165
+ var ColorVariableControl = () => {
1166
+ const { setValue: setColor } = (0, import_editor_controls7.useBoundProp)();
1167
+ const { value: variableValue } = (0, import_editor_controls7.useBoundProp)(colorVariablePropTypeUtil);
1168
+ const anchorRef = (0, import_react10.useRef)(null);
1169
+ const popupId = (0, import_react10.useId)();
1170
+ const popupState = (0, import_ui14.usePopupState)({
1171
+ variant: "popover",
1172
+ popupId: `elementor-variables-list-${popupId}`
1173
+ });
624
1174
  const selectedVariable = useVariable(variableValue);
625
1175
  if (!selectedVariable) {
626
1176
  throw new Error(`Global color variable ${variableValue} not found`);
627
1177
  }
628
1178
  const unlinkVariable = () => {
629
- setValue(import_editor_props3.colorPropTypeUtil.create(selectedVariable.value));
1179
+ setColor(import_editor_props3.colorPropTypeUtil.create(selectedVariable.value));
630
1180
  };
631
- return /* @__PURE__ */ React5.createElement(
632
- VariablesSelectionPopover,
1181
+ return /* @__PURE__ */ React13.createElement(import_ui14.Box, { ref: anchorRef }, /* @__PURE__ */ React13.createElement(
1182
+ VariableTag,
633
1183
  {
634
- selectedVariable,
635
- unlinkVariable,
636
- startTagAdornment: /* @__PURE__ */ React5.createElement(ColorIndicator, { size: "inherit", component: "span", value: selectedVariable.value })
1184
+ label: selectedVariable.label,
1185
+ startIcon: /* @__PURE__ */ React13.createElement(React13.Fragment, null, /* @__PURE__ */ React13.createElement(import_icons9.ColorFilterIcon, { fontSize: SIZE }), /* @__PURE__ */ React13.createElement(ColorIndicator, { size: "inherit", value: selectedVariable.value, component: "span" })),
1186
+ onUnlink: unlinkVariable,
1187
+ ...(0, import_ui14.bindTrigger)(popupState)
1188
+ }
1189
+ ), /* @__PURE__ */ React13.createElement(
1190
+ import_ui14.Popover,
1191
+ {
1192
+ disableScrollLock: true,
1193
+ anchorEl: anchorRef.current,
1194
+ anchorOrigin: { vertical: "bottom", horizontal: "right" },
1195
+ transformOrigin: { vertical: "top", horizontal: "right" },
1196
+ PaperProps: {
1197
+ sx: { my: 1 }
1198
+ },
1199
+ ...(0, import_ui14.bindPopover)(popupState)
637
1200
  },
638
- ({ closePopover }) => /* @__PURE__ */ React5.createElement(ColorVariablesSelection, { onSelect: closePopover })
639
- );
1201
+ /* @__PURE__ */ React13.createElement(
1202
+ VariableSelectionPopover,
1203
+ {
1204
+ selectedVariable,
1205
+ closePopover: popupState.close,
1206
+ propTypeKey: colorVariablePropTypeUtil.key
1207
+ }
1208
+ )
1209
+ ));
640
1210
  };
641
1211
 
642
1212
  // src/hooks/use-prop-color-variable-action.tsx
643
- var React6 = __toESM(require("react"));
644
- var import_editor_editing_panel2 = require("@elementor/editor-editing-panel");
645
- var import_icons5 = require("@elementor/icons");
646
- var import_i18n4 = require("@wordpress/i18n");
1213
+ var React14 = __toESM(require("react"));
1214
+ var import_editor_editing_panel6 = require("@elementor/editor-editing-panel");
1215
+ var import_icons10 = require("@elementor/icons");
1216
+ var import_i18n11 = require("@wordpress/i18n");
647
1217
 
648
1218
  // src/utils.ts
649
1219
  var hasAssignedColorVariable = (propValue) => {
@@ -661,13 +1231,15 @@ var supportsFontVariables = (propType) => {
661
1231
 
662
1232
  // src/hooks/use-prop-color-variable-action.tsx
663
1233
  var usePropColorVariableAction = () => {
664
- const { propType } = (0, import_editor_editing_panel2.useBoundProp)();
1234
+ const { propType } = (0, import_editor_editing_panel6.useBoundProp)();
665
1235
  const visible = !!propType && supportsColorVariables(propType);
666
1236
  return {
667
1237
  visible,
668
- icon: import_icons5.ColorFilterIcon,
669
- title: (0, import_i18n4.__)("Variables", "elementor"),
670
- popoverContent: ({ closePopover }) => /* @__PURE__ */ React6.createElement(ColorVariablesSelection, { onSelect: closePopover })
1238
+ icon: import_icons10.ColorFilterIcon,
1239
+ title: (0, import_i18n11.__)("Variables", "elementor"),
1240
+ content: ({ close: closePopover }) => {
1241
+ return /* @__PURE__ */ React14.createElement(VariableSelectionPopover, { closePopover, propTypeKey: colorVariablePropTypeUtil.key });
1242
+ }
671
1243
  };
672
1244
  };
673
1245
 
@@ -681,113 +1253,135 @@ var variableTransformer = (0, import_editor_canvas.createTransformer)((value) =>
681
1253
  });
682
1254
 
683
1255
  // src/init-color-variables.ts
684
- var { registerPopoverAction } = import_editor_editing_panel3.controlActionsMenu;
685
- function initColorVariables() {
686
- (0, import_editor_editing_panel3.registerControlReplacement)({
687
- component: ColorVariablesSelectionControl,
1256
+ var { registerPopoverAction } = import_editor_editing_panel7.controlActionsMenu;
1257
+ var conditions = {
1258
+ backgroundOverlay: ({ value: prop }) => {
1259
+ return hasAssignedColorVariable(import_editor_props4.backgroundColorOverlayPropTypeUtil.extract(prop)?.color);
1260
+ },
1261
+ boxShadow: ({ value: prop }) => {
1262
+ return hasAssignedColorVariable(import_editor_props4.shadowPropTypeUtil.extract(prop)?.color);
1263
+ }
1264
+ };
1265
+ function registerControlsAndActions() {
1266
+ (0, import_editor_editing_panel7.registerControlReplacement)({
1267
+ component: ColorVariableControl,
688
1268
  condition: ({ value }) => hasAssignedColorVariable(value)
689
1269
  });
690
1270
  registerPopoverAction({
691
1271
  id: "color-variables",
692
1272
  useProps: usePropColorVariableAction
693
1273
  });
1274
+ }
1275
+ function registerRepeaterItemIcons() {
1276
+ (0, import_editor_controls8.injectIntoRepeaterItemIcon)({
1277
+ id: "color-variables-background-icon",
1278
+ component: BackgroundRepeaterColorIndicator,
1279
+ condition: conditions.backgroundOverlay
1280
+ });
1281
+ (0, import_editor_controls8.injectIntoRepeaterItemIcon)({
1282
+ id: "color-variables-icon",
1283
+ component: BoxShadowRepeaterColorIndicator,
1284
+ condition: conditions.boxShadow
1285
+ });
1286
+ }
1287
+ function registerRepeaterItemLabels() {
1288
+ (0, import_editor_controls8.injectIntoRepeaterItemLabel)({
1289
+ id: "color-variables-label",
1290
+ component: BackgroundRepeaterLabel,
1291
+ condition: conditions.backgroundOverlay
1292
+ });
1293
+ }
1294
+ function registerStyleTransformers() {
694
1295
  import_editor_canvas2.styleTransformersRegistry.register(colorVariablePropTypeUtil.key, variableTransformer);
695
1296
  }
1297
+ function initColorVariables() {
1298
+ registerControlsAndActions();
1299
+ registerRepeaterItemIcons();
1300
+ registerRepeaterItemLabels();
1301
+ registerStyleTransformers();
1302
+ }
696
1303
 
697
1304
  // src/init-font-variables.ts
698
1305
  var import_editor_canvas3 = require("@elementor/editor-canvas");
699
- var import_editor_editing_panel5 = require("@elementor/editor-editing-panel");
1306
+ var import_editor_editing_panel9 = require("@elementor/editor-editing-panel");
700
1307
 
701
- // src/controls/font-variables-selection-control.tsx
702
- var React8 = __toESM(require("react"));
703
- var import_editor_controls6 = require("@elementor/editor-controls");
704
- var import_editor_props4 = require("@elementor/editor-props");
705
-
706
- // src/components/font-variables-selection.tsx
707
- var React7 = __toESM(require("react"));
708
- var import_react6 = require("react");
709
- var import_editor_controls5 = require("@elementor/editor-controls");
710
- var import_icons6 = require("@elementor/icons");
711
- var import_ui7 = require("@elementor/ui");
712
- var FontVariablesSelection = ({ onSelect }) => {
713
- const { value: variable, setValue: setVariable } = (0, import_editor_controls5.useBoundProp)(fontVariablePropTypeUtil);
714
- const variables = usePropVariables(fontVariablePropTypeUtil.key);
715
- const handleSetVariable = (key) => {
716
- setVariable(key);
717
- onSelect?.();
718
- };
719
- return /* @__PURE__ */ React7.createElement(import_react6.Fragment, null, /* @__PURE__ */ React7.createElement(import_ui7.Divider, null), /* @__PURE__ */ React7.createElement(import_ui7.Box, { sx: { overflowY: "auto", height: 260, width: 220 } }, /* @__PURE__ */ React7.createElement(import_ui7.MenuList, { role: "listbox", tabIndex: 0 }, variables.map(({ value, label, key }) => /* @__PURE__ */ React7.createElement(
720
- StyledMenuItem,
721
- {
722
- key,
723
- onClick: () => handleSetVariable(key),
724
- selected: key === variable
725
- },
726
- /* @__PURE__ */ React7.createElement(import_ui7.ListItemIcon, null, /* @__PURE__ */ React7.createElement(import_icons6.TextIcon, null)),
727
- /* @__PURE__ */ React7.createElement(
728
- import_ui7.ListItemText,
729
- {
730
- primary: label,
731
- secondary: value,
732
- primaryTypographyProps: {
733
- variant: "body2",
734
- color: "text.secondary",
735
- style: {
736
- lineHeight: 2,
737
- display: "inline-block",
738
- overflow: "hidden",
739
- textOverflow: "ellipsis",
740
- whiteSpace: "nowrap",
741
- maxWidth: "81px"
742
- }
743
- },
744
- secondaryTypographyProps: {
745
- variant: "caption",
746
- color: "text.tertiary",
747
- style: { marginTop: "1px", lineHeight: "1" }
748
- },
749
- sx: { display: "flex", alignItems: "center", gap: 1 }
750
- }
751
- ),
752
- /* @__PURE__ */ React7.createElement(import_icons6.EditIcon, { color: "action", fontSize: "inherit", sx: { mx: 1, opacity: "0" } })
753
- )))));
754
- };
755
-
756
- // src/controls/font-variables-selection-control.tsx
757
- var FontVariablesSelectionControl = () => {
758
- const { setValue: setFontFamily } = (0, import_editor_controls6.useBoundProp)();
759
- const { value: variableValue } = (0, import_editor_controls6.useBoundProp)(fontVariablePropTypeUtil);
1308
+ // src/controls/font-variable-control.tsx
1309
+ var React15 = __toESM(require("react"));
1310
+ var import_react11 = require("react");
1311
+ var import_editor_controls9 = require("@elementor/editor-controls");
1312
+ var import_editor_props5 = require("@elementor/editor-props");
1313
+ var import_icons11 = require("@elementor/icons");
1314
+ var import_ui15 = require("@elementor/ui");
1315
+ var FontVariableControl = () => {
1316
+ const { setValue: setFontFamily } = (0, import_editor_controls9.useBoundProp)();
1317
+ const { value: variableValue } = (0, import_editor_controls9.useBoundProp)(fontVariablePropTypeUtil);
1318
+ const anchorRef = (0, import_react11.useRef)(null);
1319
+ const popupId = (0, import_react11.useId)();
1320
+ const popupState = (0, import_ui15.usePopupState)({
1321
+ variant: "popover",
1322
+ popupId: `elementor-variables-list-${popupId}`
1323
+ });
760
1324
  const selectedVariable = useVariable(variableValue);
761
1325
  if (!selectedVariable) {
762
1326
  throw new Error(`Global font variable ${variableValue} not found`);
763
1327
  }
764
1328
  const unlinkVariable = () => {
765
- setFontFamily(import_editor_props4.stringPropTypeUtil.create(selectedVariable.value));
1329
+ setFontFamily(import_editor_props5.stringPropTypeUtil.create(selectedVariable.value));
766
1330
  };
767
- return /* @__PURE__ */ React8.createElement(VariablesSelectionPopover, { selectedVariable, unlinkVariable }, ({ closePopover }) => /* @__PURE__ */ React8.createElement(FontVariablesSelection, { onSelect: closePopover }));
1331
+ return /* @__PURE__ */ React15.createElement(import_ui15.Box, { ref: anchorRef }, /* @__PURE__ */ React15.createElement(
1332
+ VariableTag,
1333
+ {
1334
+ label: selectedVariable.label,
1335
+ startIcon: /* @__PURE__ */ React15.createElement(import_icons11.ColorFilterIcon, { fontSize: SIZE }),
1336
+ onUnlink: unlinkVariable,
1337
+ ...(0, import_ui15.bindTrigger)(popupState)
1338
+ }
1339
+ ), /* @__PURE__ */ React15.createElement(
1340
+ import_ui15.Popover,
1341
+ {
1342
+ disableScrollLock: true,
1343
+ anchorEl: anchorRef.current,
1344
+ anchorOrigin: { vertical: "bottom", horizontal: "right" },
1345
+ transformOrigin: { vertical: "top", horizontal: "right" },
1346
+ PaperProps: {
1347
+ sx: { my: 1 }
1348
+ },
1349
+ ...(0, import_ui15.bindPopover)(popupState)
1350
+ },
1351
+ /* @__PURE__ */ React15.createElement(
1352
+ VariableSelectionPopover,
1353
+ {
1354
+ selectedVariable,
1355
+ closePopover: popupState.close,
1356
+ propTypeKey: fontVariablePropTypeUtil.key
1357
+ }
1358
+ )
1359
+ ));
768
1360
  };
769
1361
 
770
1362
  // src/hooks/use-prop-font-variable-action.tsx
771
- var React9 = __toESM(require("react"));
772
- var import_editor_editing_panel4 = require("@elementor/editor-editing-panel");
773
- var import_icons7 = require("@elementor/icons");
774
- var import_i18n5 = require("@wordpress/i18n");
1363
+ var React16 = __toESM(require("react"));
1364
+ var import_editor_editing_panel8 = require("@elementor/editor-editing-panel");
1365
+ var import_icons12 = require("@elementor/icons");
1366
+ var import_i18n12 = require("@wordpress/i18n");
775
1367
  var usePropFontVariableAction = () => {
776
- const { propType } = (0, import_editor_editing_panel4.useBoundProp)();
1368
+ const { propType } = (0, import_editor_editing_panel8.useBoundProp)();
777
1369
  const visible = !!propType && supportsFontVariables(propType);
778
1370
  return {
779
1371
  visible,
780
- icon: import_icons7.ColorFilterIcon,
781
- title: (0, import_i18n5.__)("Variables", "elementor"),
782
- popoverContent: ({ closePopover }) => /* @__PURE__ */ React9.createElement(FontVariablesSelection, { onSelect: closePopover })
1372
+ icon: import_icons12.ColorFilterIcon,
1373
+ title: (0, import_i18n12.__)("Variables", "elementor"),
1374
+ content: ({ close: closePopover }) => {
1375
+ return /* @__PURE__ */ React16.createElement(VariableSelectionPopover, { closePopover, propTypeKey: fontVariablePropTypeUtil.key });
1376
+ }
783
1377
  };
784
1378
  };
785
1379
 
786
1380
  // src/init-font-variables.ts
787
- var { registerPopoverAction: registerPopoverAction2 } = import_editor_editing_panel5.controlActionsMenu;
1381
+ var { registerPopoverAction: registerPopoverAction2 } = import_editor_editing_panel9.controlActionsMenu;
788
1382
  function initFontVariables() {
789
- (0, import_editor_editing_panel5.registerControlReplacement)({
790
- component: FontVariablesSelectionControl,
1383
+ (0, import_editor_editing_panel9.registerControlReplacement)({
1384
+ component: FontVariableControl,
791
1385
  condition: ({ value }) => hasAssignedFontVariable(value)
792
1386
  });
793
1387
  registerPopoverAction2({
@@ -798,10 +1392,10 @@ function initFontVariables() {
798
1392
  }
799
1393
 
800
1394
  // src/renderers/style-variables-renderer.tsx
801
- var React10 = __toESM(require("react"));
802
- var import_react7 = require("react");
803
- var import_editor_v1_adapters = require("@elementor/editor-v1-adapters");
804
- var import_ui8 = require("@elementor/ui");
1395
+ var React17 = __toESM(require("react"));
1396
+ var import_react12 = require("react");
1397
+ var import_editor_v1_adapters2 = require("@elementor/editor-v1-adapters");
1398
+ var import_ui16 = require("@elementor/ui");
805
1399
 
806
1400
  // src/sync/get-canvas-iframe-document.ts
807
1401
  function getCanvasIframeDocument() {
@@ -820,14 +1414,14 @@ function StyleVariablesRenderer() {
820
1414
  }
821
1415
  const cssVariables = convertToCssVariables(styleVariables);
822
1416
  const wrappedCss = `${VARIABLES_WRAPPER}{${cssVariables}}`;
823
- return /* @__PURE__ */ React10.createElement(import_ui8.Portal, { container }, /* @__PURE__ */ React10.createElement("style", { "data-e-style-id": "e-variables", key: wrappedCss }, wrappedCss));
1417
+ return /* @__PURE__ */ React17.createElement(import_ui16.Portal, { container }, /* @__PURE__ */ React17.createElement("style", { "data-e-style-id": "e-variables", key: wrappedCss }, wrappedCss));
824
1418
  }
825
1419
  function usePortalContainer() {
826
- return (0, import_editor_v1_adapters.__privateUseListenTo)((0, import_editor_v1_adapters.commandEndEvent)("editor/documents/attach-preview"), () => getCanvasIframeDocument()?.head);
1420
+ return (0, import_editor_v1_adapters2.__privateUseListenTo)((0, import_editor_v1_adapters2.commandEndEvent)("editor/documents/attach-preview"), () => getCanvasIframeDocument()?.head);
827
1421
  }
828
1422
  function useStyleVariables() {
829
- const [variables, setVariables] = (0, import_react7.useState)({});
830
- (0, import_react7.useEffect)(() => {
1423
+ const [variables, setVariables] = (0, import_react12.useState)({});
1424
+ (0, import_react12.useEffect)(() => {
831
1425
  const unsubscribe = styleVariablesRepository.subscribe(setVariables);
832
1426
  return () => {
833
1427
  unsubscribe();