@elementor/editor-variables 0.14.0 → 0.16.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 (32) hide show
  1. package/CHANGELOG.md +76 -0
  2. package/dist/index.js +743 -500
  3. package/dist/index.js.map +1 -1
  4. package/dist/index.mjs +720 -528
  5. package/dist/index.mjs.map +1 -1
  6. package/package.json +10 -10
  7. package/src/components/color-variable-creation.tsx +18 -57
  8. package/src/components/color-variable-edit.tsx +100 -79
  9. package/src/components/color-variables-selection.tsx +33 -20
  10. package/src/components/fields/color-field.tsx +54 -0
  11. package/src/components/fields/font-field.tsx +85 -0
  12. package/src/components/fields/label-field.tsx +54 -0
  13. package/src/components/font-variable-creation.tsx +19 -76
  14. package/src/components/font-variable-edit.tsx +98 -106
  15. package/src/components/font-variables-selection.tsx +33 -20
  16. package/src/components/ui/color-indicator.tsx +1 -0
  17. package/src/components/ui/delete-confirmation-dialog.tsx +55 -0
  18. package/src/components/ui/menu-item-content.tsx +29 -23
  19. package/src/components/ui/no-search-results.tsx +6 -8
  20. package/src/components/ui/no-variables.tsx +3 -2
  21. package/src/components/ui/tags/assigned-tag.tsx +43 -0
  22. package/src/components/ui/tags/deleted-tag.tsx +26 -0
  23. package/src/components/ui/variable/assigned-variable.tsx +70 -0
  24. package/src/components/ui/variable/deleted-variable.tsx +20 -0
  25. package/src/components/variable-selection-popover.context.ts +7 -0
  26. package/src/components/variable-selection-popover.tsx +17 -8
  27. package/src/controls/color-variable-control.tsx +15 -72
  28. package/src/controls/font-variable-control.tsx +14 -71
  29. package/src/hooks/use-prop-variables.ts +12 -18
  30. package/src/init-color-variables.ts +3 -48
  31. package/src/repeater-injections.ts +35 -0
  32. package/src/utils/validations.ts +42 -0
package/dist/index.js CHANGED
@@ -39,12 +39,51 @@ 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_controls7 = require("@elementor/editor-controls");
43
- var import_editor_editing_panel4 = require("@elementor/editor-editing-panel");
44
- var import_editor_props4 = require("@elementor/editor-props");
42
+ var import_editor_editing_panel9 = require("@elementor/editor-editing-panel");
45
43
 
46
- // src/components/variables-repeater-item-slot.tsx
47
- var React = __toESM(require("react"));
44
+ // src/controls/color-variable-control.tsx
45
+ var React19 = __toESM(require("react"));
46
+ var import_editor_controls9 = require("@elementor/editor-controls");
47
+ var import_editor_props3 = require("@elementor/editor-props");
48
+
49
+ // src/components/ui/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
+ marginRight: theme.spacing(0.25)
54
+ }));
55
+
56
+ // src/components/ui/variable/assigned-variable.tsx
57
+ var import_react13 = require("react");
58
+ var React16 = __toESM(require("react"));
59
+ var import_editor_controls8 = require("@elementor/editor-controls");
60
+ var import_icons11 = require("@elementor/icons");
61
+ var import_ui18 = require("@elementor/ui");
62
+
63
+ // src/components/variable-selection-popover.tsx
64
+ var React14 = __toESM(require("react"));
65
+ var import_react12 = require("react");
66
+ var import_ui16 = require("@elementor/ui");
67
+
68
+ // src/prop-types/color-variable-prop-type.ts
69
+ var import_editor_props = require("@elementor/editor-props");
70
+ var import_schema = require("@elementor/schema");
71
+ var colorVariablePropTypeUtil = (0, import_editor_props.createPropUtils)("global-color-variable", import_schema.z.string());
72
+
73
+ // src/prop-types/font-variable-prop-type.ts
74
+ var import_editor_props2 = require("@elementor/editor-props");
75
+ var import_schema2 = require("@elementor/schema");
76
+ var fontVariablePropTypeUtil = (0, import_editor_props2.createPropUtils)("global-font-variable", import_schema2.z.string());
77
+
78
+ // src/components/color-variable-creation.tsx
79
+ var React3 = __toESM(require("react"));
80
+ var import_react5 = require("react");
81
+ var import_editor_controls = require("@elementor/editor-controls");
82
+ var import_editor_editing_panel = require("@elementor/editor-editing-panel");
83
+ var import_editor_ui = require("@elementor/editor-ui");
84
+ var import_icons = require("@elementor/icons");
85
+ var import_ui4 = require("@elementor/ui");
86
+ var import_i18n4 = require("@wordpress/i18n");
48
87
 
49
88
  // src/hooks/use-prop-variables.ts
50
89
  var import_react = require("react");
@@ -314,93 +353,147 @@ var useFilteredVariables = (searchValue, propTypeKey) => {
314
353
  var usePropVariables = (propKey) => {
315
354
  return (0, import_react.useMemo)(() => normalizeVariables(propKey), [propKey]);
316
355
  };
356
+ var isNotDeleted = ({ deleted }) => !deleted;
317
357
  var normalizeVariables = (propKey) => {
318
358
  const variables = service.variables();
319
- styleVariablesRepository.update(variables);
320
- return Object.entries(variables).filter(([, { type }]) => type === propKey).map(([key, { label, value }]) => ({
359
+ return Object.entries(variables).filter(([, variable]) => variable.type === propKey && isNotDeleted(variable)).map(([key, { label, value }]) => ({
321
360
  key,
322
361
  label,
323
362
  value
324
363
  }));
325
364
  };
326
365
  var createVariable = (newVariable) => {
327
- return service.create(newVariable).then(({ id, variable }) => {
328
- styleVariablesRepository.update({
329
- [id]: variable
330
- });
366
+ return service.create(newVariable).then(({ id }) => {
331
367
  return id;
332
368
  });
333
369
  };
334
370
  var updateVariable = (updateId, { value, label }) => {
335
- return service.update(updateId, { value, label }).then(({ id, variable }) => {
336
- styleVariablesRepository.update({
337
- [id]: variable
338
- });
371
+ return service.update(updateId, { value, label }).then(({ id }) => {
372
+ return id;
373
+ });
374
+ };
375
+ var deleteVariable = (deleteId) => {
376
+ return service.delete(deleteId).then(({ id }) => {
339
377
  return id;
340
378
  });
341
379
  };
342
380
 
343
- // src/components/ui/color-indicator.tsx
344
- var import_ui = require("@elementor/ui");
345
- var ColorIndicator = (0, import_ui.styled)(import_ui.UnstableColorIndicator)(({ theme }) => ({
346
- borderRadius: `${theme.shape.borderRadius / 2}px`
347
- }));
381
+ // src/components/fields/color-field.tsx
382
+ var React = __toESM(require("react"));
383
+ var import_react3 = require("react");
384
+ var import_ui2 = require("@elementor/ui");
385
+ var import_i18n2 = require("@wordpress/i18n");
348
386
 
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 });
387
+ // src/utils/validations.ts
388
+ var import_i18n = require("@wordpress/i18n");
389
+ var VARIABLE_LABEL_MAX_LENGTH = 50;
390
+ var validateLabel = (name) => {
391
+ if (!name.trim()) {
392
+ return (0, import_i18n.__)("Missing variable name.", "elementor");
393
+ }
394
+ const allowedChars = /^[a-zA-Z0-9_-]+$/;
395
+ if (!allowedChars.test(name)) {
396
+ return (0, import_i18n.__)("Names can only use letters, numbers, dashes (-) and underscores (_).", "elementor");
397
+ }
398
+ const hasAlphanumeric = /[a-zA-Z0-9]/;
399
+ if (!hasAlphanumeric.test(name)) {
400
+ return (0, import_i18n.__)("Names have to include at least one non-special character.", "elementor");
401
+ }
402
+ if (VARIABLE_LABEL_MAX_LENGTH < name.length) {
403
+ return (0, import_i18n.__)("Variable names can contain up to 50 characters.", "elementor");
404
+ }
405
+ return "";
357
406
  };
358
- var BackgroundRepeaterLabel = ({ value }) => {
359
- const colorVariable = useColorVariable(value);
360
- return /* @__PURE__ */ React.createElement("span", null, colorVariable?.label);
407
+ var labelHint = (name) => {
408
+ const hintThreshold = VARIABLE_LABEL_MAX_LENGTH * 0.8 - 1;
409
+ if (hintThreshold < name.length) {
410
+ return (0, import_i18n.__)("Variable names can contain up to 50 characters.", "elementor");
411
+ }
412
+ return "";
361
413
  };
362
- var BoxShadowRepeaterColorIndicator = ({ value }) => {
363
- const colorVariable = useColorVariable(value);
364
- return /* @__PURE__ */ React.createElement(ColorIndicator, { component: "span", size: "inherit", value: colorVariable?.value });
414
+ var validateValue = (value) => {
415
+ if (!value.trim()) {
416
+ return (0, import_i18n.__)("Missing variable value.", "elementor");
417
+ }
418
+ return "";
365
419
  };
366
420
 
367
- // src/controls/color-variable-control.tsx
368
- var React12 = __toESM(require("react"));
369
- var import_react9 = require("react");
370
- var import_editor_controls6 = require("@elementor/editor-controls");
371
- var import_editor_props3 = require("@elementor/editor-props");
372
- var import_icons9 = require("@elementor/icons");
373
- var import_ui12 = require("@elementor/ui");
374
- var import_i18n10 = require("@wordpress/i18n");
375
-
376
- // src/components/variable-selection-popover.tsx
377
- var React11 = __toESM(require("react"));
378
- var import_react8 = require("react");
421
+ // src/components/variable-selection-popover.context.ts
422
+ var import_react2 = require("react");
423
+ var PopoverContentRefContext = (0, import_react2.createContext)(null);
424
+ var usePopoverContentRef = () => {
425
+ return (0, import_react2.useContext)(PopoverContentRefContext);
426
+ };
379
427
 
380
- // src/prop-types/color-variable-prop-type.ts
381
- var import_editor_props = require("@elementor/editor-props");
382
- var import_schema = require("@elementor/schema");
383
- var colorVariablePropTypeUtil = (0, import_editor_props.createPropUtils)("global-color-variable", import_schema.z.string());
428
+ // src/components/fields/color-field.tsx
429
+ var ColorField = ({ value, onChange }) => {
430
+ const [color, setColor] = (0, import_react3.useState)(value);
431
+ const [errorMessage, setErrorMessage] = (0, import_react3.useState)("");
432
+ const defaultRef = (0, import_react3.useRef)(null);
433
+ const anchorRef = usePopoverContentRef() ?? defaultRef;
434
+ const handleChange = (newValue) => {
435
+ setColor(newValue);
436
+ const errorMsg = validateValue(newValue);
437
+ setErrorMessage(errorMsg);
438
+ onChange(errorMsg ? "" : newValue);
439
+ };
440
+ return /* @__PURE__ */ React.createElement(import_ui2.Grid, { container: true, gap: 0.75, alignItems: "center" }, /* @__PURE__ */ React.createElement(import_ui2.Grid, { item: true, xs: 12 }, /* @__PURE__ */ React.createElement(import_ui2.FormLabel, { size: "tiny" }, (0, import_i18n2.__)("Value", "elementor"))), /* @__PURE__ */ React.createElement(import_ui2.Grid, { item: true, xs: 12 }, /* @__PURE__ */ React.createElement(
441
+ import_ui2.UnstableColorField,
442
+ {
443
+ size: "tiny",
444
+ fullWidth: true,
445
+ value: color,
446
+ onChange: handleChange,
447
+ error: errorMessage ?? void 0,
448
+ slotProps: {
449
+ colorPicker: {
450
+ anchorEl: anchorRef.current,
451
+ anchorOrigin: { vertical: "top", horizontal: "right" },
452
+ transformOrigin: { vertical: "top", horizontal: -10 }
453
+ }
454
+ }
455
+ }
456
+ ), errorMessage && /* @__PURE__ */ React.createElement(import_ui2.FormHelperText, { error: true }, errorMessage)));
457
+ };
384
458
 
385
- // src/prop-types/font-variable-prop-type.ts
386
- var import_editor_props2 = require("@elementor/editor-props");
387
- var import_schema2 = require("@elementor/schema");
388
- var fontVariablePropTypeUtil = (0, import_editor_props2.createPropUtils)("global-font-variable", import_schema2.z.string());
459
+ // src/components/fields/label-field.tsx
460
+ var React2 = __toESM(require("react"));
461
+ var import_react4 = require("react");
462
+ var import_ui3 = require("@elementor/ui");
463
+ var import_i18n3 = require("@wordpress/i18n");
464
+ var LabelField = ({ value, onChange }) => {
465
+ const [label, setLabel] = (0, import_react4.useState)(value);
466
+ const [errorMessage, setErrorMessage] = (0, import_react4.useState)("");
467
+ const [noticeMessage, setNoticeMessage] = (0, import_react4.useState)(() => labelHint(value));
468
+ const handleChange = (newValue) => {
469
+ setLabel(newValue);
470
+ const errorMsg = validateLabel(newValue);
471
+ const hintMsg = labelHint(newValue);
472
+ setErrorMessage(errorMsg);
473
+ setNoticeMessage(errorMsg ? "" : hintMsg);
474
+ onChange(errorMsg ? "" : newValue);
475
+ };
476
+ const id = (0, import_react4.useId)();
477
+ return /* @__PURE__ */ React2.createElement(import_ui3.Grid, { container: true, gap: 0.75, alignItems: "center" }, /* @__PURE__ */ React2.createElement(import_ui3.Grid, { item: true, xs: 12 }, /* @__PURE__ */ React2.createElement(import_ui3.FormLabel, { htmlFor: id, size: "tiny" }, (0, import_i18n3.__)("Name", "elementor"))), /* @__PURE__ */ React2.createElement(import_ui3.Grid, { item: true, xs: 12 }, /* @__PURE__ */ React2.createElement(
478
+ import_ui3.TextField,
479
+ {
480
+ id,
481
+ size: "tiny",
482
+ fullWidth: true,
483
+ value: label,
484
+ error: !!errorMessage,
485
+ onChange: (e) => handleChange(e.target.value),
486
+ inputProps: { maxLength: VARIABLE_LABEL_MAX_LENGTH }
487
+ }
488
+ ), errorMessage && /* @__PURE__ */ React2.createElement(import_ui3.FormHelperText, { error: true }, errorMessage), noticeMessage && /* @__PURE__ */ React2.createElement(import_ui3.FormHelperText, null, noticeMessage)));
489
+ };
389
490
 
390
491
  // src/components/color-variable-creation.tsx
391
- var React2 = __toESM(require("react"));
392
- var import_react2 = require("react");
393
- var import_editor_controls = require("@elementor/editor-controls");
394
- var import_editor_ui = require("@elementor/editor-ui");
395
- var import_icons = require("@elementor/icons");
396
- var import_ui2 = require("@elementor/ui");
397
- var import_i18n = require("@wordpress/i18n");
398
492
  var SIZE = "tiny";
399
493
  var ColorVariableCreation = ({ onGoBack, onClose }) => {
400
494
  const { setValue: setVariable } = (0, import_editor_controls.useBoundProp)(colorVariablePropTypeUtil);
401
- const [color, setColor] = (0, import_react2.useState)("");
402
- const [label, setLabel] = (0, import_react2.useState)("");
403
- const anchorRef = (0, import_react2.useRef)(null);
495
+ const [color, setColor] = (0, import_react5.useState)("");
496
+ const [label, setLabel] = (0, import_react5.useState)("");
404
497
  const resetFields = () => {
405
498
  setColor("");
406
499
  setLabel("");
@@ -419,185 +512,226 @@ var ColorVariableCreation = ({ onGoBack, onClose }) => {
419
512
  closePopover();
420
513
  });
421
514
  };
422
- const isFormInvalid = () => {
423
- return !color?.trim() || !label?.trim();
515
+ const hasEmptyValue = () => {
516
+ return "" === color.trim() || "" === label.trim();
424
517
  };
425
- return /* @__PURE__ */ React2.createElement(React2.Fragment, null, /* @__PURE__ */ React2.createElement(
518
+ const isSubmitDisabled = hasEmptyValue();
519
+ return /* @__PURE__ */ React3.createElement(import_editor_editing_panel.PopoverScrollableContent, { height: "auto" }, /* @__PURE__ */ React3.createElement(
426
520
  import_editor_ui.PopoverHeader,
427
521
  {
428
- icon: /* @__PURE__ */ React2.createElement(React2.Fragment, null, onGoBack && /* @__PURE__ */ React2.createElement(import_ui2.IconButton, { size: SIZE, "aria-label": (0, import_i18n.__)("Go Back", "elementor"), onClick: onGoBack }, /* @__PURE__ */ React2.createElement(import_icons.ArrowLeftIcon, { fontSize: SIZE })), /* @__PURE__ */ React2.createElement(import_icons.BrushIcon, { fontSize: SIZE })),
429
- title: (0, import_i18n.__)("Create variable", "elementor"),
522
+ icon: /* @__PURE__ */ React3.createElement(React3.Fragment, null, onGoBack && /* @__PURE__ */ React3.createElement(import_ui4.IconButton, { size: SIZE, "aria-label": (0, import_i18n4.__)("Go Back", "elementor"), onClick: onGoBack }, /* @__PURE__ */ React3.createElement(import_icons.ArrowLeftIcon, { fontSize: SIZE })), /* @__PURE__ */ React3.createElement(import_icons.BrushIcon, { fontSize: SIZE })),
523
+ title: (0, import_i18n4.__)("Create variable", "elementor"),
430
524
  onClose: closePopover
431
525
  }
432
- ), /* @__PURE__ */ React2.createElement(import_ui2.Divider, null), /* @__PURE__ */ React2.createElement(import_ui2.Stack, { p: 1.5, gap: 1.5 }, /* @__PURE__ */ React2.createElement(import_ui2.Grid, { container: true, gap: 0.75, alignItems: "center" }, /* @__PURE__ */ React2.createElement(import_ui2.Grid, { item: true, xs: 12 }, /* @__PURE__ */ React2.createElement(import_ui2.FormLabel, { size: "small" }, (0, import_i18n.__)("Name", "elementor"))), /* @__PURE__ */ React2.createElement(import_ui2.Grid, { item: true, xs: 12 }, /* @__PURE__ */ React2.createElement(
433
- import_ui2.TextField,
434
- {
435
- size: "tiny",
436
- fullWidth: true,
437
- value: label,
438
- onChange: (e) => setLabel(e.target.value)
439
- }
440
- ))), /* @__PURE__ */ React2.createElement(import_ui2.Grid, { container: true, gap: 0.75, alignItems: "center" }, /* @__PURE__ */ React2.createElement(import_ui2.Grid, { item: true, xs: 12 }, /* @__PURE__ */ React2.createElement(import_ui2.FormLabel, { size: "small" }, (0, import_i18n.__)("Value", "elementor"))), /* @__PURE__ */ React2.createElement(import_ui2.Grid, { item: true, xs: 12 }, /* @__PURE__ */ React2.createElement(
441
- import_ui2.UnstableColorField,
442
- {
443
- size: "tiny",
444
- fullWidth: true,
445
- value: color,
446
- onChange: setColor,
447
- slotProps: {
448
- colorPicker: {
449
- anchorEl: anchorRef.current,
450
- anchorOrigin: { vertical: "top", horizontal: "right" },
451
- transformOrigin: { vertical: "top", horizontal: -10 }
452
- }
453
- }
454
- }
455
- )))), /* @__PURE__ */ React2.createElement(import_ui2.CardActions, null, /* @__PURE__ */ React2.createElement(import_ui2.Button, { size: "small", variant: "contained", disabled: isFormInvalid(), onClick: handleCreate }, (0, import_i18n.__)("Create", "elementor"))));
526
+ ), /* @__PURE__ */ React3.createElement(import_ui4.Divider, null), /* @__PURE__ */ React3.createElement(import_editor_controls.PopoverContent, { p: 2 }, /* @__PURE__ */ React3.createElement(LabelField, { value: label, onChange: setLabel }), /* @__PURE__ */ React3.createElement(ColorField, { value: color, onChange: setColor })), /* @__PURE__ */ React3.createElement(import_ui4.CardActions, { sx: { pt: 0.5, pb: 1 } }, /* @__PURE__ */ React3.createElement(import_ui4.Button, { size: "small", variant: "contained", disabled: isSubmitDisabled, onClick: handleCreate }, (0, import_i18n4.__)("Create", "elementor"))));
456
527
  };
457
528
 
458
529
  // src/components/color-variable-edit.tsx
459
- var React3 = __toESM(require("react"));
460
- var import_react3 = require("react");
530
+ var React5 = __toESM(require("react"));
531
+ var import_react6 = require("react");
532
+ var import_editor_controls2 = require("@elementor/editor-controls");
533
+ var import_editor_editing_panel2 = require("@elementor/editor-editing-panel");
461
534
  var import_editor_ui2 = require("@elementor/editor-ui");
535
+ var import_icons3 = require("@elementor/icons");
536
+ var import_ui6 = require("@elementor/ui");
537
+ var import_i18n6 = require("@wordpress/i18n");
538
+
539
+ // src/components/ui/delete-confirmation-dialog.tsx
540
+ var React4 = __toESM(require("react"));
462
541
  var import_icons2 = require("@elementor/icons");
463
- var import_ui3 = require("@elementor/ui");
464
- var import_i18n2 = require("@wordpress/i18n");
542
+ var import_ui5 = require("@elementor/ui");
543
+ var import_i18n5 = require("@wordpress/i18n");
544
+ var TITLE_ID = "delete-variable-dialog";
545
+ var DeleteConfirmationDialog = ({
546
+ open,
547
+ label,
548
+ closeDialog,
549
+ onConfirm
550
+ }) => {
551
+ return /* @__PURE__ */ React4.createElement(import_ui5.Dialog, { open, onClose: closeDialog, "aria-labelledby": TITLE_ID, maxWidth: "xs" }, /* @__PURE__ */ React4.createElement(import_ui5.DialogTitle, { id: TITLE_ID, display: "flex", alignItems: "center", gap: 1, sx: { lineHeight: 1 } }, /* @__PURE__ */ React4.createElement(import_icons2.AlertOctagonFilledIcon, { color: "error" }), (0, import_i18n5.__)("Delete Variable", "elementor")), /* @__PURE__ */ React4.createElement(import_ui5.DialogContent, null, /* @__PURE__ */ React4.createElement(import_ui5.DialogContentText, { variant: "body2", color: "textPrimary" }, (0, import_i18n5.__)("You are about to delete", "elementor"), /* @__PURE__ */ React4.createElement(import_ui5.Typography, { variant: "subtitle2", component: "span" }, "\xA0", label, "\xA0"), (0, import_i18n5.__)(
552
+ "Variable. Note that its value is still being used anywhere on your site where it was connected to the variable.",
553
+ "elementor"
554
+ ))), /* @__PURE__ */ React4.createElement(import_ui5.DialogActions, null, /* @__PURE__ */ React4.createElement(import_ui5.Button, { color: "secondary", onClick: closeDialog }, (0, import_i18n5.__)("Cancel", "elementor")), /* @__PURE__ */ React4.createElement(import_ui5.Button, { variant: "contained", color: "error", onClick: onConfirm }, (0, import_i18n5.__)("Delete", "elementor"))));
555
+ };
556
+
557
+ // src/components/color-variable-edit.tsx
465
558
  var SIZE2 = "tiny";
466
559
  var ColorVariableEdit = ({ onClose, onGoBack, onSubmit, editId }) => {
560
+ const { setValue: notifyBoundPropChange, value: assignedValue } = (0, import_editor_controls2.useBoundProp)(colorVariablePropTypeUtil);
561
+ const [deleteConfirmation, setDeleteConfirmation] = (0, import_react6.useState)(false);
467
562
  const variable = useVariable(editId);
468
563
  if (!variable) {
469
564
  throw new Error(`Global color variable not found`);
470
565
  }
471
- const anchorRef = (0, import_react3.useRef)(null);
472
- const [color, setColor] = (0, import_react3.useState)(variable.value);
473
- const [label, setLabel] = (0, import_react3.useState)(variable.label);
566
+ const [color, setColor] = (0, import_react6.useState)(variable.value);
567
+ const [label, setLabel] = (0, import_react6.useState)(variable.label);
474
568
  const handleUpdate = () => {
475
569
  updateVariable(editId, {
476
570
  value: color,
477
571
  label
478
572
  }).then(() => {
573
+ maybeTriggerBoundPropChange();
574
+ onSubmit?.();
575
+ });
576
+ };
577
+ const handleDelete = () => {
578
+ deleteVariable(editId).then(() => {
579
+ maybeTriggerBoundPropChange();
479
580
  onSubmit?.();
480
581
  });
481
582
  };
482
- const noValueChanged = () => color === variable.value && label === variable.label;
483
- const hasEmptyValue = () => "" === color.trim() || "" === label.trim();
484
- const isSaveDisabled = () => noValueChanged() || hasEmptyValue();
485
- return /* @__PURE__ */ React3.createElement(React3.Fragment, null, /* @__PURE__ */ React3.createElement(
583
+ const maybeTriggerBoundPropChange = () => {
584
+ if (editId === assignedValue) {
585
+ notifyBoundPropChange(editId);
586
+ }
587
+ };
588
+ const handleDeleteConfirmation = () => {
589
+ setDeleteConfirmation(true);
590
+ };
591
+ const closeDeleteDialog = () => () => {
592
+ setDeleteConfirmation(false);
593
+ };
594
+ const actions = [];
595
+ actions.push(
596
+ /* @__PURE__ */ React5.createElement(
597
+ import_ui6.IconButton,
598
+ {
599
+ key: "delete",
600
+ size: SIZE2,
601
+ "aria-label": (0, import_i18n6.__)("Delete", "elementor"),
602
+ onClick: handleDeleteConfirmation
603
+ },
604
+ /* @__PURE__ */ React5.createElement(import_icons3.TrashIcon, { fontSize: SIZE2 })
605
+ )
606
+ );
607
+ const hasEmptyValues = () => {
608
+ return !color.trim() || !label.trim();
609
+ };
610
+ const noValueChanged = () => {
611
+ return color === variable.value && label === variable.label;
612
+ };
613
+ const isSubmitDisabled = noValueChanged() || hasEmptyValues();
614
+ return /* @__PURE__ */ React5.createElement(React5.Fragment, null, /* @__PURE__ */ React5.createElement(import_editor_editing_panel2.PopoverScrollableContent, { height: "auto" }, /* @__PURE__ */ React5.createElement(
486
615
  import_editor_ui2.PopoverHeader,
487
616
  {
488
- title: (0, import_i18n2.__)("Edit variable", "elementor"),
617
+ title: (0, import_i18n6.__)("Edit variable", "elementor"),
489
618
  onClose,
490
- 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 }))
491
- }
492
- ), /* @__PURE__ */ React3.createElement(import_ui3.Divider, null), /* @__PURE__ */ React3.createElement(import_ui3.Stack, { p: 1.5, gap: 1.5 }, /* @__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: "small" }, (0, import_i18n2.__)("Name", "elementor"))), /* @__PURE__ */ React3.createElement(import_ui3.Grid, { item: true, xs: 12 }, /* @__PURE__ */ React3.createElement(
493
- import_ui3.TextField,
494
- {
495
- size: "tiny",
496
- fullWidth: true,
497
- value: label,
498
- onChange: (e) => setLabel(e.target.value)
619
+ icon: /* @__PURE__ */ React5.createElement(React5.Fragment, null, onGoBack && /* @__PURE__ */ React5.createElement(
620
+ import_ui6.IconButton,
621
+ {
622
+ size: SIZE2,
623
+ "aria-label": (0, import_i18n6.__)("Go Back", "elementor"),
624
+ onClick: onGoBack
625
+ },
626
+ /* @__PURE__ */ React5.createElement(import_icons3.ArrowLeftIcon, { fontSize: SIZE2 })
627
+ ), /* @__PURE__ */ React5.createElement(import_icons3.BrushIcon, { fontSize: SIZE2 })),
628
+ actions
499
629
  }
500
- ))), /* @__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: "small" }, (0, import_i18n2.__)("Value", "elementor"))), /* @__PURE__ */ React3.createElement(import_ui3.Grid, { item: true, xs: 12 }, /* @__PURE__ */ React3.createElement(
501
- import_ui3.UnstableColorField,
630
+ ), /* @__PURE__ */ React5.createElement(import_ui6.Divider, null), /* @__PURE__ */ React5.createElement(import_editor_controls2.PopoverContent, { p: 2 }, /* @__PURE__ */ React5.createElement(LabelField, { value: label, onChange: setLabel }), /* @__PURE__ */ React5.createElement(ColorField, { value: color, onChange: setColor })), /* @__PURE__ */ React5.createElement(import_ui6.CardActions, { sx: { pt: 0.5, pb: 1 } }, /* @__PURE__ */ React5.createElement(import_ui6.Button, { size: "small", variant: "contained", disabled: isSubmitDisabled, onClick: handleUpdate }, (0, import_i18n6.__)("Save", "elementor")))), deleteConfirmation && /* @__PURE__ */ React5.createElement(
631
+ DeleteConfirmationDialog,
502
632
  {
503
- size: "tiny",
504
- fullWidth: true,
505
- value: color,
506
- onChange: setColor,
507
- slotProps: {
508
- colorPicker: {
509
- anchorEl: anchorRef.current,
510
- anchorOrigin: { vertical: "top", horizontal: "right" },
511
- transformOrigin: { vertical: "top", horizontal: -10 }
512
- }
513
- }
633
+ open: true,
634
+ label,
635
+ onConfirm: handleDelete,
636
+ closeDialog: closeDeleteDialog()
514
637
  }
515
- )))), /* @__PURE__ */ React3.createElement(import_ui3.CardActions, null, /* @__PURE__ */ React3.createElement(import_ui3.Button, { size: "small", variant: "contained", disabled: isSaveDisabled(), onClick: handleUpdate }, (0, import_i18n2.__)("Save", "elementor"))));
638
+ ));
516
639
  };
517
640
 
518
641
  // src/components/color-variables-selection.tsx
519
- var React7 = __toESM(require("react"));
520
- var import_react4 = require("react");
521
- var import_editor_controls2 = require("@elementor/editor-controls");
522
- var import_editor_ui3 = require("@elementor/editor-ui");
642
+ var React9 = __toESM(require("react"));
643
+ var import_react7 = require("react");
644
+ var import_editor_controls3 = require("@elementor/editor-controls");
645
+ var import_editor_editing_panel3 = require("@elementor/editor-editing-panel");
646
+ var import_editor_ui4 = require("@elementor/editor-ui");
523
647
  var import_icons5 = require("@elementor/icons");
524
- var import_ui8 = require("@elementor/ui");
525
- var import_i18n6 = require("@wordpress/i18n");
648
+ var import_ui11 = require("@elementor/ui");
649
+ var import_i18n10 = require("@wordpress/i18n");
526
650
 
527
651
  // src/components/ui/menu-item-content.tsx
528
- var React4 = __toESM(require("react"));
529
- var import_icons3 = require("@elementor/icons");
530
- var import_ui4 = require("@elementor/ui");
531
- var import_i18n3 = require("@wordpress/i18n");
652
+ var React6 = __toESM(require("react"));
653
+ var import_editor_ui3 = require("@elementor/editor-ui");
654
+ var import_icons4 = require("@elementor/icons");
655
+ var import_ui7 = require("@elementor/ui");
656
+ var import_i18n7 = require("@wordpress/i18n");
532
657
  var SIZE3 = "tiny";
533
658
  var MenuItemContent = ({ item }) => {
534
659
  const onEdit = item.onEdit;
535
- return /* @__PURE__ */ React4.createElement(React4.Fragment, null, /* @__PURE__ */ React4.createElement(import_ui4.ListItemIcon, null, item.icon), /* @__PURE__ */ React4.createElement(
536
- import_ui4.ListItemText,
660
+ return /* @__PURE__ */ React6.createElement(React6.Fragment, null, /* @__PURE__ */ React6.createElement(import_ui7.ListItemIcon, null, item.icon), /* @__PURE__ */ React6.createElement(
661
+ import_ui7.Box,
537
662
  {
538
- primary: item.label || item.value,
539
- secondary: item.secondaryText,
540
- primaryTypographyProps: {
541
- variant: "body2",
542
- color: "text.secondary",
543
- style: {
544
- lineHeight: 2,
545
- display: "inline-block",
546
- overflow: "hidden",
547
- textOverflow: "ellipsis",
548
- whiteSpace: "nowrap",
549
- maxWidth: "81px"
550
- }
551
- },
552
- secondaryTypographyProps: {
663
+ sx: {
664
+ flex: 1,
665
+ minWidth: 0,
666
+ display: "flex",
667
+ alignItems: "center",
668
+ gap: 1
669
+ }
670
+ },
671
+ /* @__PURE__ */ React6.createElement(
672
+ import_editor_ui3.EllipsisWithTooltip,
673
+ {
674
+ title: item.label || item.value,
675
+ as: import_ui7.Typography,
676
+ variant: "caption",
677
+ color: "text.primary",
678
+ sx: { marginTop: "1px", lineHeight: "2" },
679
+ maxWidth: "50%"
680
+ }
681
+ ),
682
+ item.secondaryText && /* @__PURE__ */ React6.createElement(
683
+ import_editor_ui3.EllipsisWithTooltip,
684
+ {
685
+ title: item.secondaryText,
686
+ as: import_ui7.Typography,
553
687
  variant: "caption",
554
688
  color: "text.tertiary",
555
- style: { marginTop: "1px", lineHeight: "1" }
556
- },
557
- sx: { display: "flex", alignItems: "center", gap: 1 }
558
- }
559
- ), !!onEdit && /* @__PURE__ */ React4.createElement(
560
- import_ui4.IconButton,
689
+ sx: { marginTop: "1px", lineHeight: "1" },
690
+ maxWidth: "50%"
691
+ }
692
+ )
693
+ ), !!onEdit && /* @__PURE__ */ React6.createElement(
694
+ import_ui7.IconButton,
561
695
  {
562
696
  sx: { mx: 1, opacity: "0" },
563
697
  onClick: (e) => {
564
698
  e.stopPropagation();
565
699
  onEdit(item.value);
566
700
  },
567
- "aria-label": (0, import_i18n3.__)("Edit", "elementor")
701
+ "aria-label": (0, import_i18n7.__)("Edit", "elementor")
568
702
  },
569
- /* @__PURE__ */ React4.createElement(import_icons3.EditIcon, { color: "action", fontSize: SIZE3 })
703
+ /* @__PURE__ */ React6.createElement(import_icons4.EditIcon, { color: "action", fontSize: SIZE3 })
570
704
  ));
571
705
  };
572
706
 
573
707
  // src/components/ui/no-search-results.tsx
574
- var React5 = __toESM(require("react"));
575
- var import_icons4 = require("@elementor/icons");
576
- var import_ui5 = require("@elementor/ui");
577
- var import_i18n4 = require("@wordpress/i18n");
578
- var NoSearchResults = ({ searchValue, onClear }) => {
579
- return /* @__PURE__ */ React5.createElement(
580
- import_ui5.Stack,
708
+ var React7 = __toESM(require("react"));
709
+ var import_ui8 = require("@elementor/ui");
710
+ var import_i18n8 = require("@wordpress/i18n");
711
+ var NoSearchResults = ({ searchValue, onClear, icon }) => {
712
+ return /* @__PURE__ */ React7.createElement(
713
+ import_ui8.Stack,
581
714
  {
582
715
  gap: 1,
583
716
  alignItems: "center",
584
717
  justifyContent: "center",
585
718
  height: "100%",
719
+ p: 2.5,
586
720
  color: "text.secondary",
587
- sx: { p: 2.5, pb: 5.5 }
721
+ sx: { pb: 3.5 }
588
722
  },
589
- /* @__PURE__ */ React5.createElement(import_icons4.ColorFilterIcon, { fontSize: "large" }),
590
- /* @__PURE__ */ React5.createElement(import_ui5.Typography, { align: "center", variant: "subtitle2" }, (0, import_i18n4.__)("Sorry, nothing matched", "elementor"), /* @__PURE__ */ React5.createElement("br", null), "\u201C", searchValue, "\u201D."),
591
- /* @__PURE__ */ React5.createElement(import_ui5.Typography, { align: "center", variant: "caption" }, (0, import_i18n4.__)("Try something else.", "elementor"), /* @__PURE__ */ React5.createElement("br", null), /* @__PURE__ */ React5.createElement(import_ui5.Link, { color: "text.secondary", variant: "caption", component: "button", onClick: onClear }, (0, import_i18n4.__)("Clear & try again", "elementor")))
723
+ icon,
724
+ /* @__PURE__ */ React7.createElement(import_ui8.Typography, { align: "center", variant: "subtitle2" }, (0, import_i18n8.__)("Sorry, nothing matched", "elementor"), /* @__PURE__ */ React7.createElement("br", null), "\u201C", searchValue, "\u201D."),
725
+ /* @__PURE__ */ React7.createElement(import_ui8.Typography, { align: "center", variant: "caption", sx: { display: "flex", flexDirection: "column" } }, (0, import_i18n8.__)("Try something else.", "elementor"), /* @__PURE__ */ React7.createElement(import_ui8.Link, { color: "text.secondary", variant: "caption", component: "button", onClick: onClear }, (0, import_i18n8.__)("Clear & try again", "elementor")))
592
726
  );
593
727
  };
594
728
 
595
729
  // src/components/ui/no-variables.tsx
596
- var React6 = __toESM(require("react"));
597
- var import_ui6 = require("@elementor/ui");
598
- var import_i18n5 = require("@wordpress/i18n");
599
- var NoVariables = ({ icon, onAdd }) => /* @__PURE__ */ React6.createElement(
600
- import_ui6.Stack,
730
+ var React8 = __toESM(require("react"));
731
+ var import_ui9 = require("@elementor/ui");
732
+ var import_i18n9 = require("@wordpress/i18n");
733
+ var NoVariables = ({ icon, title, onAdd }) => /* @__PURE__ */ React8.createElement(
734
+ import_ui9.Stack,
601
735
  {
602
736
  gap: 1,
603
737
  alignItems: "center",
@@ -607,14 +741,14 @@ var NoVariables = ({ icon, onAdd }) => /* @__PURE__ */ React6.createElement(
607
741
  sx: { p: 2.5, pb: 5.5 }
608
742
  },
609
743
  icon,
610
- /* @__PURE__ */ React6.createElement(import_ui6.Typography, { align: "center", variant: "subtitle2" }, (0, import_i18n5.__)("Create your first variable", "elementor")),
611
- /* @__PURE__ */ React6.createElement(import_ui6.Typography, { align: "center", variant: "caption", maxWidth: "180px" }, (0, import_i18n5.__)("Variables are saved attributes that you can apply anywhere on your site.", "elementor")),
612
- onAdd && /* @__PURE__ */ React6.createElement(import_ui6.Button, { variant: "outlined", color: "secondary", size: "small", onClick: onAdd }, (0, import_i18n5.__)("Create a variable", "elementor"))
744
+ /* @__PURE__ */ React8.createElement(import_ui9.Typography, { align: "center", variant: "subtitle2" }, title),
745
+ /* @__PURE__ */ React8.createElement(import_ui9.Typography, { align: "center", variant: "caption", maxWidth: "180px" }, (0, import_i18n9.__)("Variables are saved attributes that you can apply anywhere on your site.", "elementor")),
746
+ onAdd && /* @__PURE__ */ React8.createElement(import_ui9.Button, { variant: "outlined", color: "secondary", size: "small", onClick: onAdd }, (0, import_i18n9.__)("Create a variable", "elementor"))
613
747
  );
614
748
 
615
749
  // src/components/ui/styled-menu-list.tsx
616
- var import_ui7 = require("@elementor/ui");
617
- var VariablesStyledMenuList = (0, import_ui7.styled)(import_ui7.MenuList)(({ theme }) => ({
750
+ var import_ui10 = require("@elementor/ui");
751
+ var VariablesStyledMenuList = (0, import_ui10.styled)(import_ui10.MenuList)(({ theme }) => ({
618
752
  "& > li": {
619
753
  height: 32,
620
754
  width: "100%",
@@ -647,8 +781,8 @@ var VariablesStyledMenuList = (0, import_ui7.styled)(import_ui7.MenuList)(({ the
647
781
  // src/components/color-variables-selection.tsx
648
782
  var SIZE4 = "tiny";
649
783
  var ColorVariablesSelection = ({ closePopover, onAdd, onEdit, onSettings }) => {
650
- const { value: variable, setValue: setVariable } = (0, import_editor_controls2.useBoundProp)(colorVariablePropTypeUtil);
651
- const [searchValue, setSearchValue] = (0, import_react4.useState)("");
784
+ const { value: variable, setValue: setVariable } = (0, import_editor_controls3.useBoundProp)(colorVariablePropTypeUtil);
785
+ const [searchValue, setSearchValue] = (0, import_react7.useState)("");
652
786
  const {
653
787
  list: variables,
654
788
  hasMatches: hasSearchResults,
@@ -661,19 +795,19 @@ var ColorVariablesSelection = ({ closePopover, onAdd, onEdit, onSettings }) => {
661
795
  const actions = [];
662
796
  if (onAdd) {
663
797
  actions.push(
664
- /* @__PURE__ */ React7.createElement(import_ui8.IconButton, { key: "add", size: SIZE4, onClick: onAdd }, /* @__PURE__ */ React7.createElement(import_icons5.PlusIcon, { fontSize: SIZE4 }))
798
+ /* @__PURE__ */ React9.createElement(import_ui11.IconButton, { key: "add", size: SIZE4, onClick: onAdd }, /* @__PURE__ */ React9.createElement(import_icons5.PlusIcon, { fontSize: SIZE4 }))
665
799
  );
666
800
  }
667
801
  if (onSettings) {
668
802
  actions.push(
669
- /* @__PURE__ */ React7.createElement(import_ui8.IconButton, { key: "settings", size: SIZE4, onClick: onSettings }, /* @__PURE__ */ React7.createElement(import_icons5.SettingsIcon, { fontSize: SIZE4 }))
803
+ /* @__PURE__ */ React9.createElement(import_ui11.IconButton, { key: "settings", size: SIZE4, onClick: onSettings }, /* @__PURE__ */ React9.createElement(import_icons5.SettingsIcon, { fontSize: SIZE4 }))
670
804
  );
671
805
  }
672
806
  const items = variables.map(({ value, label, key }) => ({
673
807
  type: "item",
674
808
  value: key,
675
809
  label,
676
- icon: /* @__PURE__ */ React7.createElement(ColorIndicator, { size: "inherit", component: "span", value }),
810
+ icon: /* @__PURE__ */ React9.createElement(ColorIndicator, { size: "inherit", component: "span", value }),
677
811
  secondaryText: value,
678
812
  onEdit: () => onEdit?.(key)
679
813
  }));
@@ -683,23 +817,23 @@ var ColorVariablesSelection = ({ closePopover, onAdd, onEdit, onSettings }) => {
683
817
  const handleClearSearch = () => {
684
818
  setSearchValue("");
685
819
  };
686
- return /* @__PURE__ */ React7.createElement(React7.Fragment, null, /* @__PURE__ */ React7.createElement(
687
- import_editor_ui3.PopoverHeader,
820
+ return /* @__PURE__ */ React9.createElement(React9.Fragment, null, /* @__PURE__ */ React9.createElement(
821
+ import_editor_ui4.PopoverHeader,
688
822
  {
689
- title: (0, import_i18n6.__)("Variables", "elementor"),
690
- icon: /* @__PURE__ */ React7.createElement(import_icons5.ColorFilterIcon, { fontSize: SIZE4 }),
823
+ title: (0, import_i18n10.__)("Variables", "elementor"),
824
+ icon: /* @__PURE__ */ React9.createElement(import_icons5.ColorFilterIcon, { fontSize: SIZE4 }),
691
825
  onClose: closePopover,
692
826
  actions
693
827
  }
694
- ), hasVariables && /* @__PURE__ */ React7.createElement(
695
- import_editor_ui3.PopoverSearch,
828
+ ), hasVariables && /* @__PURE__ */ React9.createElement(
829
+ import_editor_ui4.PopoverSearch,
696
830
  {
697
831
  value: searchValue,
698
832
  onSearch: handleSearch,
699
- placeholder: (0, import_i18n6.__)("Search", "elementor")
833
+ placeholder: (0, import_i18n10.__)("Search", "elementor")
700
834
  }
701
- ), /* @__PURE__ */ React7.createElement(import_ui8.Divider, null), hasVariables && hasSearchResults && /* @__PURE__ */ React7.createElement(
702
- import_editor_ui3.PopoverMenuList,
835
+ ), /* @__PURE__ */ React9.createElement(import_ui11.Divider, null), /* @__PURE__ */ React9.createElement(import_editor_editing_panel3.PopoverScrollableContent, null, hasVariables && hasSearchResults && /* @__PURE__ */ React9.createElement(
836
+ import_editor_ui4.PopoverMenuList,
703
837
  {
704
838
  items,
705
839
  onSelect: handleSetColorVariable,
@@ -708,28 +842,99 @@ var ColorVariablesSelection = ({ closePopover, onAdd, onEdit, onSettings }) => {
708
842
  selectedValue: variable,
709
843
  "data-testid": "color-variables-list",
710
844
  menuListTemplate: VariablesStyledMenuList,
711
- menuItemContentTemplate: (item) => /* @__PURE__ */ React7.createElement(MenuItemContent, { item })
845
+ menuItemContentTemplate: (item) => /* @__PURE__ */ React9.createElement(MenuItemContent, { item })
712
846
  }
713
- ), !hasSearchResults && hasVariables && /* @__PURE__ */ React7.createElement(NoSearchResults, { searchValue, onClear: handleClearSearch }), !hasVariables && /* @__PURE__ */ React7.createElement(NoVariables, { icon: /* @__PURE__ */ React7.createElement(import_icons5.ColorFilterIcon, { fontSize: "large" }), onAdd }));
714
- };
715
-
716
- // src/components/font-variable-creation.tsx
717
- var React8 = __toESM(require("react"));
718
- var import_react5 = require("react");
719
- var import_editor_controls3 = require("@elementor/editor-controls");
720
- var import_editor_editing_panel = require("@elementor/editor-editing-panel");
721
- var import_editor_ui4 = require("@elementor/editor-ui");
847
+ ), !hasSearchResults && hasVariables && /* @__PURE__ */ React9.createElement(
848
+ NoSearchResults,
849
+ {
850
+ searchValue,
851
+ onClear: handleClearSearch,
852
+ icon: /* @__PURE__ */ React9.createElement(import_icons5.BrushIcon, { fontSize: "large" })
853
+ }
854
+ ), !hasVariables && /* @__PURE__ */ React9.createElement(
855
+ NoVariables,
856
+ {
857
+ title: (0, import_i18n10.__)("Create your first color variable", "elementor"),
858
+ icon: /* @__PURE__ */ React9.createElement(import_icons5.BrushIcon, { fontSize: "large" }),
859
+ onAdd
860
+ }
861
+ )));
862
+ };
863
+
864
+ // src/components/font-variable-creation.tsx
865
+ var React11 = __toESM(require("react"));
866
+ var import_react9 = require("react");
867
+ var import_editor_controls5 = require("@elementor/editor-controls");
868
+ var import_editor_editing_panel5 = require("@elementor/editor-editing-panel");
869
+ var import_editor_ui5 = require("@elementor/editor-ui");
870
+ var import_icons7 = require("@elementor/icons");
871
+ var import_ui13 = require("@elementor/ui");
872
+ var import_i18n12 = require("@wordpress/i18n");
873
+
874
+ // src/components/fields/font-field.tsx
875
+ var React10 = __toESM(require("react"));
876
+ var import_react8 = require("react");
877
+ var import_editor_controls4 = require("@elementor/editor-controls");
878
+ var import_editor_editing_panel4 = require("@elementor/editor-editing-panel");
722
879
  var import_icons6 = require("@elementor/icons");
723
- var import_ui9 = require("@elementor/ui");
724
- var import_i18n7 = require("@wordpress/i18n");
880
+ var import_ui12 = require("@elementor/ui");
881
+ var import_i18n11 = require("@wordpress/i18n");
882
+ var FontField = ({ value, onChange }) => {
883
+ const [fontFamily, setFontFamily] = (0, import_react8.useState)(value);
884
+ const [errorMessage, setErrorMessage] = (0, import_react8.useState)("");
885
+ const defaultRef = (0, import_react8.useRef)(null);
886
+ const anchorRef = usePopoverContentRef() ?? defaultRef;
887
+ const fontPopoverState = (0, import_ui12.usePopupState)({ variant: "popover" });
888
+ const fontFamilies = (0, import_editor_editing_panel4.useFontFamilies)();
889
+ const sectionWidth = (0, import_editor_editing_panel4.useSectionWidth)();
890
+ const handleChange = (newValue) => {
891
+ setFontFamily(newValue);
892
+ const errorMsg = validateValue(newValue);
893
+ setErrorMessage(errorMsg);
894
+ onChange(errorMsg ? "" : newValue);
895
+ };
896
+ const handleFontFamilyChange = (newFontFamily) => {
897
+ handleChange(newFontFamily);
898
+ fontPopoverState.close();
899
+ };
900
+ return /* @__PURE__ */ React10.createElement(import_ui12.Grid, { container: true, gap: 0.75, alignItems: "center" }, /* @__PURE__ */ React10.createElement(import_ui12.Grid, { item: true, xs: 12 }, /* @__PURE__ */ React10.createElement(import_ui12.FormLabel, { size: "tiny" }, (0, import_i18n11.__)("Value", "elementor"))), /* @__PURE__ */ React10.createElement(import_ui12.Grid, { item: true, xs: 12 }, /* @__PURE__ */ React10.createElement(
901
+ import_ui12.UnstableTag,
902
+ {
903
+ variant: "outlined",
904
+ label: fontFamily,
905
+ endIcon: /* @__PURE__ */ React10.createElement(import_icons6.ChevronDownIcon, { fontSize: "tiny" }),
906
+ ...(0, import_ui12.bindTrigger)(fontPopoverState),
907
+ fullWidth: true
908
+ }
909
+ ), /* @__PURE__ */ React10.createElement(
910
+ import_ui12.Popover,
911
+ {
912
+ disablePortal: true,
913
+ disableScrollLock: true,
914
+ anchorEl: anchorRef.current,
915
+ anchorOrigin: { vertical: "top", horizontal: "right" },
916
+ transformOrigin: { vertical: "top", horizontal: -20 },
917
+ ...(0, import_ui12.bindPopover)(fontPopoverState)
918
+ },
919
+ /* @__PURE__ */ React10.createElement(
920
+ import_editor_controls4.FontFamilySelector,
921
+ {
922
+ fontFamilies,
923
+ fontFamily,
924
+ onFontFamilyChange: handleFontFamilyChange,
925
+ onClose: fontPopoverState.close,
926
+ sectionWidth
927
+ }
928
+ )
929
+ ), errorMessage && /* @__PURE__ */ React10.createElement(import_ui12.FormHelperText, { error: true }, errorMessage)));
930
+ };
931
+
932
+ // src/components/font-variable-creation.tsx
725
933
  var SIZE5 = "tiny";
726
934
  var FontVariableCreation = ({ onClose, onGoBack }) => {
727
- const fontFamilies = (0, import_editor_editing_panel.useFontFamilies)();
728
- const { setValue: setVariable } = (0, import_editor_controls3.useBoundProp)(fontVariablePropTypeUtil);
729
- const [fontFamily, setFontFamily] = (0, import_react5.useState)("");
730
- const [label, setLabel] = (0, import_react5.useState)("");
731
- const anchorRef = (0, import_react5.useRef)(null);
732
- const fontPopoverState = (0, import_ui9.usePopupState)({ variant: "popover" });
935
+ const { setValue: setVariable } = (0, import_editor_controls5.useBoundProp)(fontVariablePropTypeUtil);
936
+ const [fontFamily, setFontFamily] = (0, import_react9.useState)("");
937
+ const [label, setLabel] = (0, import_react9.useState)("");
733
938
  const resetFields = () => {
734
939
  setFontFamily("");
735
940
  setLabel("");
@@ -748,148 +953,125 @@ var FontVariableCreation = ({ onClose, onGoBack }) => {
748
953
  closePopover();
749
954
  });
750
955
  };
751
- const isFormInvalid = () => {
752
- return !fontFamily?.trim() || !label?.trim();
956
+ const hasEmptyValue = () => {
957
+ return "" === fontFamily.trim() || "" === label.trim();
753
958
  };
754
- return /* @__PURE__ */ React8.createElement(React8.Fragment, null, /* @__PURE__ */ React8.createElement(
755
- import_editor_ui4.PopoverHeader,
959
+ const isSubmitDisabled = hasEmptyValue();
960
+ return /* @__PURE__ */ React11.createElement(import_editor_editing_panel5.PopoverScrollableContent, { height: "auto" }, /* @__PURE__ */ React11.createElement(
961
+ import_editor_ui5.PopoverHeader,
756
962
  {
757
- icon: /* @__PURE__ */ React8.createElement(React8.Fragment, null, onGoBack && /* @__PURE__ */ React8.createElement(import_ui9.IconButton, { size: SIZE5, "aria-label": (0, import_i18n7.__)("Go Back", "elementor"), onClick: onGoBack }, /* @__PURE__ */ React8.createElement(import_icons6.ArrowLeftIcon, { fontSize: SIZE5 })), /* @__PURE__ */ React8.createElement(import_icons6.TextIcon, { fontSize: SIZE5 })),
758
- title: (0, import_i18n7.__)("Create variable", "elementor"),
963
+ icon: /* @__PURE__ */ React11.createElement(React11.Fragment, null, onGoBack && /* @__PURE__ */ React11.createElement(import_ui13.IconButton, { size: SIZE5, "aria-label": (0, import_i18n12.__)("Go Back", "elementor"), onClick: onGoBack }, /* @__PURE__ */ React11.createElement(import_icons7.ArrowLeftIcon, { fontSize: SIZE5 })), /* @__PURE__ */ React11.createElement(import_icons7.TextIcon, { fontSize: SIZE5 })),
964
+ title: (0, import_i18n12.__)("Create variable", "elementor"),
759
965
  onClose: closePopover
760
966
  }
761
- ), /* @__PURE__ */ React8.createElement(import_ui9.Divider, null), /* @__PURE__ */ React8.createElement(import_ui9.Stack, { p: 1.5, gap: 1.5 }, /* @__PURE__ */ React8.createElement(import_ui9.Grid, { container: true, gap: 0.75, alignItems: "center" }, /* @__PURE__ */ React8.createElement(import_ui9.Grid, { item: true, xs: 12 }, /* @__PURE__ */ React8.createElement(import_ui9.FormLabel, { size: "small" }, (0, import_i18n7.__)("Name", "elementor"))), /* @__PURE__ */ React8.createElement(import_ui9.Grid, { item: true, xs: 12 }, /* @__PURE__ */ React8.createElement(
762
- import_ui9.TextField,
763
- {
764
- size: "tiny",
765
- fullWidth: true,
766
- value: label,
767
- onChange: (e) => setLabel(e.target.value)
768
- }
769
- ))), /* @__PURE__ */ React8.createElement(import_ui9.Grid, { container: true, gap: 0.75, alignItems: "center" }, /* @__PURE__ */ React8.createElement(import_ui9.Grid, { item: true, xs: 12 }, /* @__PURE__ */ React8.createElement(import_ui9.FormLabel, { size: "small" }, (0, import_i18n7.__)("Value", "elementor"))), /* @__PURE__ */ React8.createElement(import_ui9.Grid, { item: true, xs: 12 }, /* @__PURE__ */ React8.createElement(React8.Fragment, null, /* @__PURE__ */ React8.createElement(
770
- import_ui9.UnstableTag,
771
- {
772
- variant: "outlined",
773
- label: fontFamily,
774
- endIcon: /* @__PURE__ */ React8.createElement(import_icons6.ChevronDownIcon, { fontSize: "tiny" }),
775
- ...(0, import_ui9.bindTrigger)(fontPopoverState),
776
- fullWidth: true
777
- }
778
- ), /* @__PURE__ */ React8.createElement(
779
- import_ui9.Popover,
780
- {
781
- disablePortal: true,
782
- disableScrollLock: true,
783
- anchorEl: anchorRef.current,
784
- anchorOrigin: { vertical: "top", horizontal: "right" },
785
- transformOrigin: { vertical: "top", horizontal: -20 },
786
- ...(0, import_ui9.bindPopover)(fontPopoverState)
787
- },
788
- /* @__PURE__ */ React8.createElement(
789
- import_editor_controls3.FontFamilySelector,
790
- {
791
- fontFamilies,
792
- fontFamily,
793
- onFontFamilyChange: setFontFamily,
794
- onClose: fontPopoverState.close
795
- }
796
- )
797
- ))))), /* @__PURE__ */ React8.createElement(import_ui9.CardActions, null, /* @__PURE__ */ React8.createElement(import_ui9.Button, { size: "small", variant: "contained", disabled: isFormInvalid(), onClick: handleCreate }, (0, import_i18n7.__)("Create", "elementor"))));
967
+ ), /* @__PURE__ */ React11.createElement(import_ui13.Divider, null), /* @__PURE__ */ React11.createElement(import_editor_controls5.PopoverContent, { p: 2 }, /* @__PURE__ */ React11.createElement(LabelField, { value: label, onChange: setLabel }), /* @__PURE__ */ React11.createElement(FontField, { value: fontFamily, onChange: setFontFamily })), /* @__PURE__ */ React11.createElement(import_ui13.CardActions, { sx: { pt: 0.5, pb: 1 } }, /* @__PURE__ */ React11.createElement(import_ui13.Button, { size: "small", variant: "contained", disabled: isSubmitDisabled, onClick: handleCreate }, (0, import_i18n12.__)("Create", "elementor"))));
798
968
  };
799
969
 
800
970
  // src/components/font-variable-edit.tsx
801
- var React9 = __toESM(require("react"));
802
- var import_react6 = require("react");
803
- var import_editor_controls4 = require("@elementor/editor-controls");
804
- var import_editor_editing_panel2 = require("@elementor/editor-editing-panel");
805
- var import_editor_ui5 = require("@elementor/editor-ui");
806
- var import_icons7 = require("@elementor/icons");
807
- var import_ui10 = require("@elementor/ui");
808
- var import_i18n8 = require("@wordpress/i18n");
971
+ var React12 = __toESM(require("react"));
972
+ var import_react10 = require("react");
973
+ var import_editor_controls6 = require("@elementor/editor-controls");
974
+ var import_editor_editing_panel6 = require("@elementor/editor-editing-panel");
975
+ var import_editor_ui6 = require("@elementor/editor-ui");
976
+ var import_icons8 = require("@elementor/icons");
977
+ var import_ui14 = require("@elementor/ui");
978
+ var import_i18n13 = require("@wordpress/i18n");
809
979
  var SIZE6 = "tiny";
810
980
  var FontVariableEdit = ({ onClose, onGoBack, onSubmit, editId }) => {
981
+ const { setValue: notifyBoundPropChange, value: assignedValue } = (0, import_editor_controls6.useBoundProp)(fontVariablePropTypeUtil);
982
+ const [deleteConfirmation, setDeleteConfirmation] = (0, import_react10.useState)(false);
811
983
  const variable = useVariable(editId);
812
984
  if (!variable) {
813
985
  throw new Error(`Global font variable "${editId}" not found`);
814
986
  }
815
- const [fontFamily, setFontFamily] = (0, import_react6.useState)(variable.value);
816
- const [label, setLabel] = (0, import_react6.useState)(variable.label);
817
- const variableNameId = (0, import_react6.useId)();
818
- const variableValueId = (0, import_react6.useId)();
819
- const anchorRef = (0, import_react6.useRef)(null);
820
- const fontPopoverState = (0, import_ui10.usePopupState)({ variant: "popover" });
821
- const fontFamilies = (0, import_editor_editing_panel2.useFontFamilies)();
987
+ const [fontFamily, setFontFamily] = (0, import_react10.useState)(variable.value);
988
+ const [label, setLabel] = (0, import_react10.useState)(variable.label);
822
989
  const handleUpdate = () => {
823
990
  updateVariable(editId, {
824
991
  value: fontFamily,
825
992
  label
826
993
  }).then(() => {
994
+ maybeTriggerBoundPropChange();
827
995
  onSubmit?.();
828
996
  });
829
997
  };
830
- const noValueChanged = () => fontFamily === variable.value && label === variable.label;
831
- const hasEmptyValue = () => "" === fontFamily.trim() || "" === label.trim();
832
- const isSaveDisabled = () => noValueChanged() || hasEmptyValue();
833
- return /* @__PURE__ */ React9.createElement(React9.Fragment, null, /* @__PURE__ */ React9.createElement(
834
- import_editor_ui5.PopoverHeader,
835
- {
836
- 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_icons7.ArrowLeftIcon, { fontSize: SIZE6 })), /* @__PURE__ */ React9.createElement(import_icons7.TextIcon, { fontSize: SIZE6 })),
837
- title: (0, import_i18n8.__)("Edit variable", "elementor"),
838
- onClose
998
+ const handleDelete = () => {
999
+ deleteVariable(editId).then(() => {
1000
+ maybeTriggerBoundPropChange();
1001
+ onSubmit?.();
1002
+ });
1003
+ };
1004
+ const maybeTriggerBoundPropChange = () => {
1005
+ if (editId === assignedValue) {
1006
+ notifyBoundPropChange(editId);
839
1007
  }
840
- ), /* @__PURE__ */ React9.createElement(import_ui10.Divider, null), /* @__PURE__ */ React9.createElement(import_ui10.Stack, { p: 1.5, gap: 1.5 }, /* @__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, { htmlFor: variableNameId, size: "small" }, (0, import_i18n8.__)("Name", "elementor"))), /* @__PURE__ */ React9.createElement(import_ui10.Grid, { item: true, xs: 12 }, /* @__PURE__ */ React9.createElement(
841
- import_ui10.TextField,
1008
+ };
1009
+ const handleDeleteConfirmation = () => {
1010
+ setDeleteConfirmation(true);
1011
+ };
1012
+ const closeDeleteDialog = () => () => {
1013
+ setDeleteConfirmation(false);
1014
+ };
1015
+ const hasEmptyValue = () => {
1016
+ return !fontFamily.trim() || !label.trim();
1017
+ };
1018
+ const noValueChanged = () => {
1019
+ return fontFamily === variable.value && label === variable.label;
1020
+ };
1021
+ const isSubmitDisabled = noValueChanged() || hasEmptyValue();
1022
+ const actions = [];
1023
+ actions.push(
1024
+ /* @__PURE__ */ React12.createElement(
1025
+ import_ui14.IconButton,
1026
+ {
1027
+ key: "delete",
1028
+ size: SIZE6,
1029
+ "aria-label": (0, import_i18n13.__)("Delete", "elementor"),
1030
+ onClick: handleDeleteConfirmation
1031
+ },
1032
+ /* @__PURE__ */ React12.createElement(import_icons8.TrashIcon, { fontSize: SIZE6 })
1033
+ )
1034
+ );
1035
+ return /* @__PURE__ */ React12.createElement(React12.Fragment, null, /* @__PURE__ */ React12.createElement(import_editor_editing_panel6.PopoverScrollableContent, { height: "auto" }, /* @__PURE__ */ React12.createElement(
1036
+ import_editor_ui6.PopoverHeader,
842
1037
  {
843
- id: variableNameId,
844
- size: "tiny",
845
- fullWidth: true,
846
- value: label,
847
- onChange: (e) => setLabel(e.target.value)
1038
+ icon: /* @__PURE__ */ React12.createElement(React12.Fragment, null, onGoBack && /* @__PURE__ */ React12.createElement(
1039
+ import_ui14.IconButton,
1040
+ {
1041
+ size: SIZE6,
1042
+ "aria-label": (0, import_i18n13.__)("Go Back", "elementor"),
1043
+ onClick: onGoBack
1044
+ },
1045
+ /* @__PURE__ */ React12.createElement(import_icons8.ArrowLeftIcon, { fontSize: SIZE6 })
1046
+ ), /* @__PURE__ */ React12.createElement(import_icons8.TextIcon, { fontSize: SIZE6 })),
1047
+ title: (0, import_i18n13.__)("Edit variable", "elementor"),
1048
+ onClose,
1049
+ actions
848
1050
  }
849
- ))), /* @__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, { htmlFor: variableValueId, size: "small" }, (0, import_i18n8.__)("Value", "elementor"))), /* @__PURE__ */ React9.createElement(import_ui10.Grid, { item: true, xs: 12 }, /* @__PURE__ */ React9.createElement(React9.Fragment, null, /* @__PURE__ */ React9.createElement(
850
- import_ui10.UnstableTag,
1051
+ ), /* @__PURE__ */ React12.createElement(import_ui14.Divider, null), /* @__PURE__ */ React12.createElement(import_editor_controls6.PopoverContent, { p: 2 }, /* @__PURE__ */ React12.createElement(LabelField, { value: label, onChange: setLabel }), /* @__PURE__ */ React12.createElement(FontField, { value: fontFamily, onChange: setFontFamily })), /* @__PURE__ */ React12.createElement(import_ui14.CardActions, { sx: { pt: 0.5, pb: 1 } }, /* @__PURE__ */ React12.createElement(import_ui14.Button, { size: "small", variant: "contained", disabled: isSubmitDisabled, onClick: handleUpdate }, (0, import_i18n13.__)("Save", "elementor")))), deleteConfirmation && /* @__PURE__ */ React12.createElement(
1052
+ DeleteConfirmationDialog,
851
1053
  {
852
- id: variableValueId,
853
- variant: "outlined",
854
- label: fontFamily,
855
- endIcon: /* @__PURE__ */ React9.createElement(import_icons7.ChevronDownIcon, { fontSize: "tiny" }),
856
- ...(0, import_ui10.bindTrigger)(fontPopoverState),
857
- fullWidth: true
1054
+ open: true,
1055
+ label,
1056
+ onConfirm: handleDelete,
1057
+ closeDialog: closeDeleteDialog()
858
1058
  }
859
- ), /* @__PURE__ */ React9.createElement(
860
- import_ui10.Popover,
861
- {
862
- disablePortal: true,
863
- disableScrollLock: true,
864
- anchorEl: anchorRef.current,
865
- anchorOrigin: { vertical: "top", horizontal: "right" },
866
- transformOrigin: { vertical: "top", horizontal: -20 },
867
- ...(0, import_ui10.bindPopover)(fontPopoverState)
868
- },
869
- /* @__PURE__ */ React9.createElement(
870
- import_editor_controls4.FontFamilySelector,
871
- {
872
- fontFamilies,
873
- fontFamily,
874
- onFontFamilyChange: setFontFamily,
875
- onClose: fontPopoverState.close
876
- }
877
- )
878
- ))))), /* @__PURE__ */ React9.createElement(import_ui10.CardActions, null, /* @__PURE__ */ React9.createElement(import_ui10.Button, { size: "small", variant: "contained", disabled: isSaveDisabled(), onClick: handleUpdate }, (0, import_i18n8.__)("Save", "elementor"))));
1059
+ ));
879
1060
  };
880
1061
 
881
1062
  // src/components/font-variables-selection.tsx
882
- var React10 = __toESM(require("react"));
883
- var import_react7 = require("react");
884
- var import_editor_controls5 = require("@elementor/editor-controls");
885
- var import_editor_ui6 = require("@elementor/editor-ui");
886
- var import_icons8 = require("@elementor/icons");
887
- var import_ui11 = require("@elementor/ui");
888
- var import_i18n9 = require("@wordpress/i18n");
1063
+ var React13 = __toESM(require("react"));
1064
+ var import_react11 = require("react");
1065
+ var import_editor_controls7 = require("@elementor/editor-controls");
1066
+ var import_editor_editing_panel7 = require("@elementor/editor-editing-panel");
1067
+ var import_editor_ui7 = require("@elementor/editor-ui");
1068
+ var import_icons9 = require("@elementor/icons");
1069
+ var import_ui15 = require("@elementor/ui");
1070
+ var import_i18n14 = require("@wordpress/i18n");
889
1071
  var SIZE7 = "tiny";
890
1072
  var FontVariablesSelection = ({ closePopover, onAdd, onEdit, onSettings }) => {
891
- const { value: variable, setValue: setVariable } = (0, import_editor_controls5.useBoundProp)(fontVariablePropTypeUtil);
892
- const [searchValue, setSearchValue] = (0, import_react7.useState)("");
1073
+ const { value: variable, setValue: setVariable } = (0, import_editor_controls7.useBoundProp)(fontVariablePropTypeUtil);
1074
+ const [searchValue, setSearchValue] = (0, import_react11.useState)("");
893
1075
  const {
894
1076
  list: variables,
895
1077
  hasMatches: hasSearchResults,
@@ -902,19 +1084,19 @@ var FontVariablesSelection = ({ closePopover, onAdd, onEdit, onSettings }) => {
902
1084
  const actions = [];
903
1085
  if (onAdd) {
904
1086
  actions.push(
905
- /* @__PURE__ */ React10.createElement(import_ui11.IconButton, { key: "add", size: SIZE7, onClick: onAdd }, /* @__PURE__ */ React10.createElement(import_icons8.PlusIcon, { fontSize: SIZE7 }))
1087
+ /* @__PURE__ */ React13.createElement(import_ui15.IconButton, { key: "add", size: SIZE7, onClick: onAdd }, /* @__PURE__ */ React13.createElement(import_icons9.PlusIcon, { fontSize: SIZE7 }))
906
1088
  );
907
1089
  }
908
1090
  if (onSettings) {
909
1091
  actions.push(
910
- /* @__PURE__ */ React10.createElement(import_ui11.IconButton, { key: "settings", size: SIZE7, onClick: onSettings }, /* @__PURE__ */ React10.createElement(import_icons8.SettingsIcon, { fontSize: SIZE7 }))
1092
+ /* @__PURE__ */ React13.createElement(import_ui15.IconButton, { key: "settings", size: SIZE7, onClick: onSettings }, /* @__PURE__ */ React13.createElement(import_icons9.SettingsIcon, { fontSize: SIZE7 }))
911
1093
  );
912
1094
  }
913
1095
  const items = variables.map(({ value, label, key }) => ({
914
1096
  type: "item",
915
1097
  value: key,
916
1098
  label,
917
- icon: /* @__PURE__ */ React10.createElement(import_icons8.TextIcon, null),
1099
+ icon: /* @__PURE__ */ React13.createElement(import_icons9.TextIcon, { fontSize: SIZE7 }),
918
1100
  secondaryText: value,
919
1101
  onEdit: () => onEdit?.(key)
920
1102
  }));
@@ -924,23 +1106,23 @@ var FontVariablesSelection = ({ closePopover, onAdd, onEdit, onSettings }) => {
924
1106
  const handleClearSearch = () => {
925
1107
  setSearchValue("");
926
1108
  };
927
- return /* @__PURE__ */ React10.createElement(React10.Fragment, null, /* @__PURE__ */ React10.createElement(
928
- import_editor_ui6.PopoverHeader,
1109
+ return /* @__PURE__ */ React13.createElement(React13.Fragment, null, /* @__PURE__ */ React13.createElement(
1110
+ import_editor_ui7.PopoverHeader,
929
1111
  {
930
- title: (0, import_i18n9.__)("Variables", "elementor"),
1112
+ title: (0, import_i18n14.__)("Variables", "elementor"),
931
1113
  onClose: closePopover,
932
- icon: /* @__PURE__ */ React10.createElement(import_icons8.ColorFilterIcon, { fontSize: SIZE7 }),
1114
+ icon: /* @__PURE__ */ React13.createElement(import_icons9.ColorFilterIcon, { fontSize: SIZE7 }),
933
1115
  actions
934
1116
  }
935
- ), hasVariables && /* @__PURE__ */ React10.createElement(
936
- import_editor_ui6.PopoverSearch,
1117
+ ), hasVariables && /* @__PURE__ */ React13.createElement(
1118
+ import_editor_ui7.PopoverSearch,
937
1119
  {
938
1120
  value: searchValue,
939
1121
  onSearch: handleSearch,
940
- placeholder: (0, import_i18n9.__)("Search", "elementor")
1122
+ placeholder: (0, import_i18n14.__)("Search", "elementor")
941
1123
  }
942
- ), /* @__PURE__ */ React10.createElement(import_ui11.Divider, null), hasVariables && hasSearchResults && /* @__PURE__ */ React10.createElement(
943
- import_editor_ui6.PopoverMenuList,
1124
+ ), /* @__PURE__ */ React13.createElement(import_ui15.Divider, null), /* @__PURE__ */ React13.createElement(import_editor_editing_panel7.PopoverScrollableContent, null, hasVariables && hasSearchResults && /* @__PURE__ */ React13.createElement(
1125
+ import_editor_ui7.PopoverMenuList,
944
1126
  {
945
1127
  items,
946
1128
  onSelect: handleSetVariable,
@@ -949,9 +1131,23 @@ var FontVariablesSelection = ({ closePopover, onAdd, onEdit, onSettings }) => {
949
1131
  selectedValue: variable,
950
1132
  "data-testid": "font-variables-list",
951
1133
  menuListTemplate: VariablesStyledMenuList,
952
- menuItemContentTemplate: (item) => /* @__PURE__ */ React10.createElement(MenuItemContent, { item })
1134
+ menuItemContentTemplate: (item) => /* @__PURE__ */ React13.createElement(MenuItemContent, { item })
953
1135
  }
954
- ), !hasSearchResults && hasVariables && /* @__PURE__ */ React10.createElement(NoSearchResults, { searchValue, onClear: handleClearSearch }), !hasVariables && /* @__PURE__ */ React10.createElement(NoVariables, { icon: /* @__PURE__ */ React10.createElement(import_icons8.TextIcon, { fontSize: "large" }), onAdd }));
1136
+ ), !hasSearchResults && hasVariables && /* @__PURE__ */ React13.createElement(
1137
+ NoSearchResults,
1138
+ {
1139
+ searchValue,
1140
+ onClear: handleClearSearch,
1141
+ icon: /* @__PURE__ */ React13.createElement(import_icons9.TextIcon, { fontSize: "large" })
1142
+ }
1143
+ ), !hasVariables && /* @__PURE__ */ React13.createElement(
1144
+ NoVariables,
1145
+ {
1146
+ title: (0, import_i18n14.__)("Create your first font variable", "elementor"),
1147
+ icon: /* @__PURE__ */ React13.createElement(import_icons9.TextIcon, { fontSize: "large" }),
1148
+ onAdd
1149
+ }
1150
+ )));
955
1151
  };
956
1152
 
957
1153
  // src/components/variable-selection-popover.tsx
@@ -959,16 +1155,17 @@ var VIEW_LIST = "list";
959
1155
  var VIEW_ADD = "add";
960
1156
  var VIEW_EDIT = "edit";
961
1157
  var VariableSelectionPopover = ({ closePopover, propTypeKey, selectedVariable }) => {
962
- const [currentView, setCurrentView] = (0, import_react8.useState)(VIEW_LIST);
963
- const editIdRef = (0, import_react8.useRef)("");
964
- return renderStage({
1158
+ const [currentView, setCurrentView] = (0, import_react12.useState)(VIEW_LIST);
1159
+ const editIdRef = (0, import_react12.useRef)("");
1160
+ const anchorRef = (0, import_react12.useRef)(null);
1161
+ return /* @__PURE__ */ React14.createElement(PopoverContentRefContext.Provider, { value: anchorRef }, /* @__PURE__ */ React14.createElement(import_ui16.Box, { ref: anchorRef }, renderStage({
965
1162
  propTypeKey,
966
1163
  currentView,
967
1164
  selectedVariable,
968
1165
  editIdRef,
969
1166
  setCurrentView,
970
1167
  closePopover
971
- });
1168
+ })));
972
1169
  };
973
1170
  function renderStage(props) {
974
1171
  const handleSubmitOnEdit = () => {
@@ -980,7 +1177,7 @@ function renderStage(props) {
980
1177
  };
981
1178
  if (fontVariablePropTypeUtil.key === props.propTypeKey) {
982
1179
  if (VIEW_LIST === props.currentView) {
983
- return /* @__PURE__ */ React11.createElement(
1180
+ return /* @__PURE__ */ React14.createElement(
984
1181
  FontVariablesSelection,
985
1182
  {
986
1183
  closePopover: props.closePopover,
@@ -995,7 +1192,7 @@ function renderStage(props) {
995
1192
  );
996
1193
  }
997
1194
  if (VIEW_ADD === props.currentView) {
998
- return /* @__PURE__ */ React11.createElement(
1195
+ return /* @__PURE__ */ React14.createElement(
999
1196
  FontVariableCreation,
1000
1197
  {
1001
1198
  onGoBack: () => props.setCurrentView(VIEW_LIST),
@@ -1004,7 +1201,7 @@ function renderStage(props) {
1004
1201
  );
1005
1202
  }
1006
1203
  if (VIEW_EDIT === props.currentView) {
1007
- return /* @__PURE__ */ React11.createElement(
1204
+ return /* @__PURE__ */ React14.createElement(
1008
1205
  FontVariableEdit,
1009
1206
  {
1010
1207
  editId: props.editIdRef.current ?? "",
@@ -1017,7 +1214,7 @@ function renderStage(props) {
1017
1214
  }
1018
1215
  if (colorVariablePropTypeUtil.key === props.propTypeKey) {
1019
1216
  if (VIEW_LIST === props.currentView) {
1020
- return /* @__PURE__ */ React11.createElement(
1217
+ return /* @__PURE__ */ React14.createElement(
1021
1218
  ColorVariablesSelection,
1022
1219
  {
1023
1220
  closePopover: props.closePopover,
@@ -1032,7 +1229,7 @@ function renderStage(props) {
1032
1229
  );
1033
1230
  }
1034
1231
  if (VIEW_ADD === props.currentView) {
1035
- return /* @__PURE__ */ React11.createElement(
1232
+ return /* @__PURE__ */ React14.createElement(
1036
1233
  ColorVariableCreation,
1037
1234
  {
1038
1235
  onGoBack: () => props.setCurrentView(VIEW_LIST),
@@ -1041,7 +1238,7 @@ function renderStage(props) {
1041
1238
  );
1042
1239
  }
1043
1240
  if (VIEW_EDIT === props.currentView) {
1044
- return /* @__PURE__ */ React11.createElement(
1241
+ return /* @__PURE__ */ React14.createElement(
1045
1242
  ColorVariableEdit,
1046
1243
  {
1047
1244
  editId: props.editIdRef.current ?? "",
@@ -1055,66 +1252,136 @@ function renderStage(props) {
1055
1252
  return null;
1056
1253
  }
1057
1254
 
1058
- // src/controls/color-variable-control.tsx
1255
+ // src/components/ui/tags/assigned-tag.tsx
1256
+ var React15 = __toESM(require("react"));
1257
+ var import_icons10 = require("@elementor/icons");
1258
+ var import_ui17 = require("@elementor/ui");
1259
+ var import_i18n15 = require("@wordpress/i18n");
1059
1260
  var SIZE8 = "tiny";
1060
- var ColorVariableControl = () => {
1061
- const { setValue: setColor } = (0, import_editor_controls6.useBoundProp)();
1062
- const { value: variableValue } = (0, import_editor_controls6.useBoundProp)(colorVariablePropTypeUtil);
1063
- const anchorRef = (0, import_react9.useRef)(null);
1064
- const popupId = (0, import_react9.useId)();
1065
- const popupState = (0, import_ui12.usePopupState)({
1261
+ var AssignedTag = ({ startIcon, label, onUnlink, ...props }) => {
1262
+ const actions = [];
1263
+ if (onUnlink) {
1264
+ actions.push(
1265
+ /* @__PURE__ */ React15.createElement(import_ui17.IconButton, { key: "unlink", size: SIZE8, onClick: onUnlink, "aria-label": (0, import_i18n15.__)("Unlink", "elementor") }, /* @__PURE__ */ React15.createElement(import_icons10.DetachIcon, { fontSize: SIZE8 }))
1266
+ );
1267
+ }
1268
+ return /* @__PURE__ */ React15.createElement(
1269
+ import_ui17.UnstableTag,
1270
+ {
1271
+ fullWidth: true,
1272
+ showActionsOnHover: true,
1273
+ startIcon: /* @__PURE__ */ React15.createElement(import_ui17.Stack, { gap: 0.5, direction: "row", alignItems: "center" }, startIcon),
1274
+ label: /* @__PURE__ */ React15.createElement(import_ui17.Box, { sx: { display: "inline-grid", minWidth: 0 } }, /* @__PURE__ */ React15.createElement(import_ui17.Typography, { sx: { lineHeight: 1.34 }, variant: "caption", noWrap: true }, label)),
1275
+ actions,
1276
+ ...props
1277
+ }
1278
+ );
1279
+ };
1280
+
1281
+ // src/components/ui/variable/assigned-variable.tsx
1282
+ var AssignedVariable = ({
1283
+ variable,
1284
+ variablePropTypeUtil,
1285
+ fallbackPropTypeUtil,
1286
+ additionalStartIcon
1287
+ }) => {
1288
+ const { setValue } = (0, import_editor_controls8.useBoundProp)();
1289
+ const anchorRef = (0, import_react13.useRef)(null);
1290
+ const popupId = (0, import_react13.useId)();
1291
+ const popupState = (0, import_ui18.usePopupState)({
1066
1292
  variant: "popover",
1067
1293
  popupId: `elementor-variables-list-${popupId}`
1068
1294
  });
1069
- const selectedVariable = useVariable(variableValue);
1070
- if (!selectedVariable) {
1071
- throw new Error(`Global color variable ${variableValue} not found`);
1072
- }
1073
1295
  const unlinkVariable = () => {
1074
- setColor(import_editor_props3.colorPropTypeUtil.create(selectedVariable.value));
1296
+ setValue(fallbackPropTypeUtil.create(variable.value));
1075
1297
  };
1076
- return /* @__PURE__ */ React12.createElement(import_ui12.Box, { ref: anchorRef }, /* @__PURE__ */ React12.createElement(
1077
- import_ui12.UnstableTag,
1298
+ return /* @__PURE__ */ React16.createElement(import_ui18.Box, { ref: anchorRef }, /* @__PURE__ */ React16.createElement(
1299
+ AssignedTag,
1078
1300
  {
1079
- fullWidth: true,
1080
- showActionsOnHover: true,
1081
- startIcon: /* @__PURE__ */ React12.createElement(import_ui12.Stack, { spacing: 0.75, direction: "row", alignItems: "center" }, /* @__PURE__ */ React12.createElement(ColorIndicator, { size: "inherit", value: selectedVariable.value, component: "span" }), /* @__PURE__ */ React12.createElement(import_icons9.ColorFilterIcon, { fontSize: "inherit", sx: { mr: 1 } })),
1082
- label: /* @__PURE__ */ React12.createElement(import_ui12.Box, { sx: { display: "inline-grid", minWidth: 0 } }, /* @__PURE__ */ React12.createElement(
1083
- import_ui12.Typography,
1084
- {
1085
- sx: { textOverflow: "ellipsis", overflowX: "hidden", lineHeight: 1 },
1086
- variant: "caption"
1087
- },
1088
- selectedVariable.label
1089
- )),
1090
- actions: /* @__PURE__ */ React12.createElement(import_ui12.IconButton, { size: SIZE8, onClick: unlinkVariable, "aria-label": (0, import_i18n10.__)("Unlink", "elementor") }, /* @__PURE__ */ React12.createElement(import_icons9.DetachIcon, { fontSize: SIZE8 })),
1091
- ...(0, import_ui12.bindTrigger)(popupState)
1301
+ label: variable.label,
1302
+ startIcon: /* @__PURE__ */ React16.createElement(React16.Fragment, null, /* @__PURE__ */ React16.createElement(import_icons11.ColorFilterIcon, { fontSize: SIZE8 }), additionalStartIcon),
1303
+ onUnlink: unlinkVariable,
1304
+ ...(0, import_ui18.bindTrigger)(popupState)
1092
1305
  }
1093
- ), /* @__PURE__ */ React12.createElement(
1094
- import_ui12.Popover,
1306
+ ), /* @__PURE__ */ React16.createElement(
1307
+ import_ui18.Popover,
1095
1308
  {
1096
1309
  disableScrollLock: true,
1097
1310
  anchorEl: anchorRef.current,
1098
1311
  anchorOrigin: { vertical: "bottom", horizontal: "right" },
1099
1312
  transformOrigin: { vertical: "top", horizontal: "right" },
1100
- ...(0, import_ui12.bindPopover)(popupState)
1313
+ PaperProps: {
1314
+ sx: { my: 1 }
1315
+ },
1316
+ ...(0, import_ui18.bindPopover)(popupState)
1101
1317
  },
1102
- /* @__PURE__ */ React12.createElement(
1318
+ /* @__PURE__ */ React16.createElement(
1103
1319
  VariableSelectionPopover,
1104
1320
  {
1105
- selectedVariable,
1321
+ selectedVariable: variable,
1106
1322
  closePopover: popupState.close,
1107
- propTypeKey: colorVariablePropTypeUtil.key
1323
+ propTypeKey: variablePropTypeUtil.key
1108
1324
  }
1109
1325
  )
1110
1326
  ));
1111
1327
  };
1112
1328
 
1329
+ // src/components/ui/variable/deleted-variable.tsx
1330
+ var React18 = __toESM(require("react"));
1331
+ var import_react14 = require("react");
1332
+ var import_ui20 = require("@elementor/ui");
1333
+
1334
+ // src/components/ui/tags/deleted-tag.tsx
1335
+ var React17 = __toESM(require("react"));
1336
+ var import_icons12 = require("@elementor/icons");
1337
+ var import_ui19 = require("@elementor/ui");
1338
+ var import_i18n16 = require("@wordpress/i18n");
1339
+ var DeletedTag = ({ label }) => {
1340
+ return /* @__PURE__ */ React17.createElement(
1341
+ import_ui19.UnstableTag,
1342
+ {
1343
+ showActionsOnHover: true,
1344
+ fullWidth: true,
1345
+ label: /* @__PURE__ */ React17.createElement(import_ui19.Box, { sx: { display: "inline-grid", minWidth: 0 } }, /* @__PURE__ */ React17.createElement(import_ui19.Typography, { sx: { lineHeight: 1.34 }, variant: "caption", noWrap: true }, label)),
1346
+ startIcon: /* @__PURE__ */ React17.createElement(import_icons12.ColorFilterIcon, { fontSize: "tiny" }),
1347
+ endAdornment: /* @__PURE__ */ React17.createElement(import_ui19.Typography, { sx: { lineHeight: 1.34 }, variant: "caption", noWrap: true }, "(", (0, import_i18n16.__)("deleted", "elementor"), ")")
1348
+ }
1349
+ );
1350
+ };
1351
+
1352
+ // src/components/ui/variable/deleted-variable.tsx
1353
+ var DeletedVariable = ({ variable }) => {
1354
+ const anchorRef = (0, import_react14.useRef)(null);
1355
+ return /* @__PURE__ */ React18.createElement(import_ui20.Box, { ref: anchorRef }, /* @__PURE__ */ React18.createElement(DeletedTag, { label: variable.label }));
1356
+ };
1357
+
1358
+ // src/controls/color-variable-control.tsx
1359
+ var ColorVariableControl = () => {
1360
+ const { value: variableValue } = (0, import_editor_controls9.useBoundProp)(colorVariablePropTypeUtil);
1361
+ const assignedVariable = useVariable(variableValue);
1362
+ if (!assignedVariable) {
1363
+ throw new Error(`Global color variable ${variableValue} not found`);
1364
+ }
1365
+ const isVariableDeleted = assignedVariable?.deleted;
1366
+ if (isVariableDeleted) {
1367
+ return /* @__PURE__ */ React19.createElement(DeletedVariable, { variable: assignedVariable });
1368
+ }
1369
+ return /* @__PURE__ */ React19.createElement(
1370
+ AssignedVariable,
1371
+ {
1372
+ variable: assignedVariable,
1373
+ variablePropTypeUtil: colorVariablePropTypeUtil,
1374
+ fallbackPropTypeUtil: import_editor_props3.colorPropTypeUtil,
1375
+ additionalStartIcon: /* @__PURE__ */ React19.createElement(ColorIndicator, { size: "inherit", value: assignedVariable.value, component: "span" })
1376
+ }
1377
+ );
1378
+ };
1379
+
1113
1380
  // src/hooks/use-prop-color-variable-action.tsx
1114
- var React13 = __toESM(require("react"));
1115
- var import_editor_editing_panel3 = require("@elementor/editor-editing-panel");
1116
- var import_icons10 = require("@elementor/icons");
1117
- var import_i18n11 = require("@wordpress/i18n");
1381
+ var React20 = __toESM(require("react"));
1382
+ var import_editor_editing_panel8 = require("@elementor/editor-editing-panel");
1383
+ var import_icons13 = require("@elementor/icons");
1384
+ var import_i18n17 = require("@wordpress/i18n");
1118
1385
 
1119
1386
  // src/utils.ts
1120
1387
  var hasAssignedColorVariable = (propValue) => {
@@ -1132,18 +1399,66 @@ var supportsFontVariables = (propType) => {
1132
1399
 
1133
1400
  // src/hooks/use-prop-color-variable-action.tsx
1134
1401
  var usePropColorVariableAction = () => {
1135
- const { propType } = (0, import_editor_editing_panel3.useBoundProp)();
1402
+ const { propType } = (0, import_editor_editing_panel8.useBoundProp)();
1136
1403
  const visible = !!propType && supportsColorVariables(propType);
1137
1404
  return {
1138
1405
  visible,
1139
- icon: import_icons10.ColorFilterIcon,
1140
- title: (0, import_i18n11.__)("Variables", "elementor"),
1406
+ icon: import_icons13.ColorFilterIcon,
1407
+ title: (0, import_i18n17.__)("Variables", "elementor"),
1141
1408
  content: ({ close: closePopover }) => {
1142
- return /* @__PURE__ */ React13.createElement(VariableSelectionPopover, { closePopover, propTypeKey: colorVariablePropTypeUtil.key });
1409
+ return /* @__PURE__ */ React20.createElement(VariableSelectionPopover, { closePopover, propTypeKey: colorVariablePropTypeUtil.key });
1143
1410
  }
1144
1411
  };
1145
1412
  };
1146
1413
 
1414
+ // src/repeater-injections.ts
1415
+ var import_editor_controls10 = require("@elementor/editor-controls");
1416
+ var import_editor_props4 = require("@elementor/editor-props");
1417
+
1418
+ // src/components/variables-repeater-item-slot.tsx
1419
+ var React21 = __toESM(require("react"));
1420
+ var useColorVariable = (value) => {
1421
+ const variableId = value?.value?.color?.value;
1422
+ return useVariable(variableId || "");
1423
+ };
1424
+ var BackgroundRepeaterColorIndicator = ({ value }) => {
1425
+ const colorVariable = useColorVariable(value);
1426
+ return /* @__PURE__ */ React21.createElement(ColorIndicator, { component: "span", size: "inherit", value: colorVariable?.value });
1427
+ };
1428
+ var BackgroundRepeaterLabel = ({ value }) => {
1429
+ const colorVariable = useColorVariable(value);
1430
+ return /* @__PURE__ */ React21.createElement("span", null, colorVariable?.label);
1431
+ };
1432
+ var BoxShadowRepeaterColorIndicator = ({ value }) => {
1433
+ const colorVariable = useColorVariable(value);
1434
+ return /* @__PURE__ */ React21.createElement(ColorIndicator, { component: "span", size: "inherit", value: colorVariable?.value });
1435
+ };
1436
+
1437
+ // src/repeater-injections.ts
1438
+ function registerRepeaterInjections() {
1439
+ (0, import_editor_controls10.injectIntoRepeaterItemIcon)({
1440
+ id: "color-variables-background-icon",
1441
+ component: BackgroundRepeaterColorIndicator,
1442
+ condition: ({ value: prop }) => {
1443
+ return hasAssignedColorVariable(import_editor_props4.backgroundColorOverlayPropTypeUtil.extract(prop)?.color);
1444
+ }
1445
+ });
1446
+ (0, import_editor_controls10.injectIntoRepeaterItemIcon)({
1447
+ id: "color-variables-icon",
1448
+ component: BoxShadowRepeaterColorIndicator,
1449
+ condition: ({ value: prop }) => {
1450
+ return hasAssignedColorVariable(import_editor_props4.shadowPropTypeUtil.extract(prop)?.color);
1451
+ }
1452
+ });
1453
+ (0, import_editor_controls10.injectIntoRepeaterItemLabel)({
1454
+ id: "color-variables-label",
1455
+ component: BackgroundRepeaterLabel,
1456
+ condition: ({ value: prop }) => {
1457
+ return hasAssignedColorVariable(import_editor_props4.backgroundColorOverlayPropTypeUtil.extract(prop)?.color);
1458
+ }
1459
+ });
1460
+ }
1461
+
1147
1462
  // src/transformers/variable-transformer.ts
1148
1463
  var import_editor_canvas = require("@elementor/editor-canvas");
1149
1464
  var variableTransformer = (0, import_editor_canvas.createTransformer)((value) => {
@@ -1154,17 +1469,9 @@ var variableTransformer = (0, import_editor_canvas.createTransformer)((value) =>
1154
1469
  });
1155
1470
 
1156
1471
  // src/init-color-variables.ts
1157
- var { registerPopoverAction } = import_editor_editing_panel4.controlActionsMenu;
1158
- var conditions = {
1159
- backgroundOverlay: ({ value: prop }) => {
1160
- return hasAssignedColorVariable(import_editor_props4.backgroundColorOverlayPropTypeUtil.extract(prop)?.color);
1161
- },
1162
- boxShadow: ({ value: prop }) => {
1163
- return hasAssignedColorVariable(import_editor_props4.shadowPropTypeUtil.extract(prop)?.color);
1164
- }
1165
- };
1166
- function registerControlsAndActions() {
1167
- (0, import_editor_editing_panel4.registerControlReplacement)({
1472
+ var { registerPopoverAction } = import_editor_editing_panel9.controlActionsMenu;
1473
+ function initColorVariables() {
1474
+ (0, import_editor_editing_panel9.registerControlReplacement)({
1168
1475
  component: ColorVariableControl,
1169
1476
  condition: ({ value }) => hasAssignedColorVariable(value)
1170
1477
  });
@@ -1172,124 +1479,60 @@ function registerControlsAndActions() {
1172
1479
  id: "color-variables",
1173
1480
  useProps: usePropColorVariableAction
1174
1481
  });
1175
- }
1176
- function registerRepeaterItemIcons() {
1177
- (0, import_editor_controls7.injectIntoRepeaterItemIcon)({
1178
- id: "color-variables-background-icon",
1179
- component: BackgroundRepeaterColorIndicator,
1180
- condition: conditions.backgroundOverlay
1181
- });
1182
- (0, import_editor_controls7.injectIntoRepeaterItemIcon)({
1183
- id: "color-variables-icon",
1184
- component: BoxShadowRepeaterColorIndicator,
1185
- condition: conditions.boxShadow
1186
- });
1187
- }
1188
- function registerRepeaterItemLabels() {
1189
- (0, import_editor_controls7.injectIntoRepeaterItemLabel)({
1190
- id: "color-variables-label",
1191
- component: BackgroundRepeaterLabel,
1192
- condition: conditions.backgroundOverlay
1193
- });
1194
- }
1195
- function registerStyleTransformers() {
1196
1482
  import_editor_canvas2.styleTransformersRegistry.register(colorVariablePropTypeUtil.key, variableTransformer);
1197
- }
1198
- function initColorVariables() {
1199
- registerControlsAndActions();
1200
- registerRepeaterItemIcons();
1201
- registerRepeaterItemLabels();
1202
- registerStyleTransformers();
1483
+ registerRepeaterInjections();
1203
1484
  }
1204
1485
 
1205
1486
  // src/init-font-variables.ts
1206
1487
  var import_editor_canvas3 = require("@elementor/editor-canvas");
1207
- var import_editor_editing_panel6 = require("@elementor/editor-editing-panel");
1488
+ var import_editor_editing_panel11 = require("@elementor/editor-editing-panel");
1208
1489
 
1209
1490
  // src/controls/font-variable-control.tsx
1210
- var React14 = __toESM(require("react"));
1211
- var import_react10 = require("react");
1212
- var import_editor_controls8 = require("@elementor/editor-controls");
1491
+ var React22 = __toESM(require("react"));
1492
+ var import_editor_controls11 = require("@elementor/editor-controls");
1213
1493
  var import_editor_props5 = require("@elementor/editor-props");
1214
- var import_icons11 = require("@elementor/icons");
1215
- var import_ui13 = require("@elementor/ui");
1216
- var import_i18n12 = require("@wordpress/i18n");
1217
- var SIZE9 = "tiny";
1218
1494
  var FontVariableControl = () => {
1219
- const { setValue: setFontFamily } = (0, import_editor_controls8.useBoundProp)();
1220
- const { value: variableValue } = (0, import_editor_controls8.useBoundProp)(fontVariablePropTypeUtil);
1221
- const anchorRef = (0, import_react10.useRef)(null);
1222
- const popupId = (0, import_react10.useId)();
1223
- const popupState = (0, import_ui13.usePopupState)({
1224
- variant: "popover",
1225
- popupId: `elementor-variables-list-${popupId}`
1226
- });
1227
- const selectedVariable = useVariable(variableValue);
1228
- if (!selectedVariable) {
1495
+ const { value: variableValue } = (0, import_editor_controls11.useBoundProp)(fontVariablePropTypeUtil);
1496
+ const assignedVariable = useVariable(variableValue);
1497
+ if (!assignedVariable) {
1229
1498
  throw new Error(`Global font variable ${variableValue} not found`);
1230
1499
  }
1231
- const unlinkVariable = () => {
1232
- setFontFamily(import_editor_props5.stringPropTypeUtil.create(selectedVariable.value));
1233
- };
1234
- return /* @__PURE__ */ React14.createElement(import_ui13.Box, { ref: anchorRef }, /* @__PURE__ */ React14.createElement(
1235
- import_ui13.UnstableTag,
1500
+ const isVariableDeleted = assignedVariable?.deleted;
1501
+ if (isVariableDeleted) {
1502
+ return /* @__PURE__ */ React22.createElement(DeletedVariable, { variable: assignedVariable });
1503
+ }
1504
+ return /* @__PURE__ */ React22.createElement(
1505
+ AssignedVariable,
1236
1506
  {
1237
- fullWidth: true,
1238
- showActionsOnHover: true,
1239
- startIcon: /* @__PURE__ */ React14.createElement(import_ui13.Stack, { spacing: 0.75, direction: "row", alignItems: "center" }, /* @__PURE__ */ React14.createElement(import_icons11.ColorFilterIcon, { fontSize: "inherit", sx: { mr: 1 } })),
1240
- label: /* @__PURE__ */ React14.createElement(import_ui13.Box, { sx: { display: "inline-grid", minWidth: 0 } }, /* @__PURE__ */ React14.createElement(
1241
- import_ui13.Typography,
1242
- {
1243
- sx: { textOverflow: "ellipsis", overflowX: "hidden", lineHeight: 1 },
1244
- variant: "caption"
1245
- },
1246
- selectedVariable.label
1247
- )),
1248
- actions: /* @__PURE__ */ React14.createElement(import_ui13.IconButton, { size: SIZE9, onClick: unlinkVariable, "aria-label": (0, import_i18n12.__)("Unlink", "elementor") }, /* @__PURE__ */ React14.createElement(import_icons11.DetachIcon, { fontSize: SIZE9 })),
1249
- ...(0, import_ui13.bindTrigger)(popupState)
1507
+ variable: assignedVariable,
1508
+ variablePropTypeUtil: fontVariablePropTypeUtil,
1509
+ fallbackPropTypeUtil: import_editor_props5.stringPropTypeUtil
1250
1510
  }
1251
- ), /* @__PURE__ */ React14.createElement(
1252
- import_ui13.Popover,
1253
- {
1254
- disableScrollLock: true,
1255
- anchorEl: anchorRef.current,
1256
- anchorOrigin: { vertical: "bottom", horizontal: "right" },
1257
- transformOrigin: { vertical: "top", horizontal: "right" },
1258
- ...(0, import_ui13.bindPopover)(popupState)
1259
- },
1260
- /* @__PURE__ */ React14.createElement(
1261
- VariableSelectionPopover,
1262
- {
1263
- selectedVariable,
1264
- closePopover: popupState.close,
1265
- propTypeKey: fontVariablePropTypeUtil.key
1266
- }
1267
- )
1268
- ));
1511
+ );
1269
1512
  };
1270
1513
 
1271
1514
  // src/hooks/use-prop-font-variable-action.tsx
1272
- var React15 = __toESM(require("react"));
1273
- var import_editor_editing_panel5 = require("@elementor/editor-editing-panel");
1274
- var import_icons12 = require("@elementor/icons");
1275
- var import_i18n13 = require("@wordpress/i18n");
1515
+ var React23 = __toESM(require("react"));
1516
+ var import_editor_editing_panel10 = require("@elementor/editor-editing-panel");
1517
+ var import_icons14 = require("@elementor/icons");
1518
+ var import_i18n18 = require("@wordpress/i18n");
1276
1519
  var usePropFontVariableAction = () => {
1277
- const { propType } = (0, import_editor_editing_panel5.useBoundProp)();
1520
+ const { propType } = (0, import_editor_editing_panel10.useBoundProp)();
1278
1521
  const visible = !!propType && supportsFontVariables(propType);
1279
1522
  return {
1280
1523
  visible,
1281
- icon: import_icons12.ColorFilterIcon,
1282
- title: (0, import_i18n13.__)("Variables", "elementor"),
1524
+ icon: import_icons14.ColorFilterIcon,
1525
+ title: (0, import_i18n18.__)("Variables", "elementor"),
1283
1526
  content: ({ close: closePopover }) => {
1284
- return /* @__PURE__ */ React15.createElement(VariableSelectionPopover, { closePopover, propTypeKey: fontVariablePropTypeUtil.key });
1527
+ return /* @__PURE__ */ React23.createElement(VariableSelectionPopover, { closePopover, propTypeKey: fontVariablePropTypeUtil.key });
1285
1528
  }
1286
1529
  };
1287
1530
  };
1288
1531
 
1289
1532
  // src/init-font-variables.ts
1290
- var { registerPopoverAction: registerPopoverAction2 } = import_editor_editing_panel6.controlActionsMenu;
1533
+ var { registerPopoverAction: registerPopoverAction2 } = import_editor_editing_panel11.controlActionsMenu;
1291
1534
  function initFontVariables() {
1292
- (0, import_editor_editing_panel6.registerControlReplacement)({
1535
+ (0, import_editor_editing_panel11.registerControlReplacement)({
1293
1536
  component: FontVariableControl,
1294
1537
  condition: ({ value }) => hasAssignedFontVariable(value)
1295
1538
  });
@@ -1301,10 +1544,10 @@ function initFontVariables() {
1301
1544
  }
1302
1545
 
1303
1546
  // src/renderers/style-variables-renderer.tsx
1304
- var React16 = __toESM(require("react"));
1305
- var import_react11 = require("react");
1547
+ var React24 = __toESM(require("react"));
1548
+ var import_react15 = require("react");
1306
1549
  var import_editor_v1_adapters = require("@elementor/editor-v1-adapters");
1307
- var import_ui14 = require("@elementor/ui");
1550
+ var import_ui21 = require("@elementor/ui");
1308
1551
 
1309
1552
  // src/sync/get-canvas-iframe-document.ts
1310
1553
  function getCanvasIframeDocument() {
@@ -1323,14 +1566,14 @@ function StyleVariablesRenderer() {
1323
1566
  }
1324
1567
  const cssVariables = convertToCssVariables(styleVariables);
1325
1568
  const wrappedCss = `${VARIABLES_WRAPPER}{${cssVariables}}`;
1326
- return /* @__PURE__ */ React16.createElement(import_ui14.Portal, { container }, /* @__PURE__ */ React16.createElement("style", { "data-e-style-id": "e-variables", key: wrappedCss }, wrappedCss));
1569
+ return /* @__PURE__ */ React24.createElement(import_ui21.Portal, { container }, /* @__PURE__ */ React24.createElement("style", { "data-e-style-id": "e-variables", key: wrappedCss }, wrappedCss));
1327
1570
  }
1328
1571
  function usePortalContainer() {
1329
1572
  return (0, import_editor_v1_adapters.__privateUseListenTo)((0, import_editor_v1_adapters.commandEndEvent)("editor/documents/attach-preview"), () => getCanvasIframeDocument()?.head);
1330
1573
  }
1331
1574
  function useStyleVariables() {
1332
- const [variables, setVariables] = (0, import_react11.useState)({});
1333
- (0, import_react11.useEffect)(() => {
1575
+ const [variables, setVariables] = (0, import_react15.useState)({});
1576
+ (0, import_react15.useEffect)(() => {
1334
1577
  const unsubscribe = styleVariablesRepository.subscribe(setVariables);
1335
1578
  return () => {
1336
1579
  unsubscribe();