@elementor/editor-variables 0.15.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.
- package/CHANGELOG.md +38 -0
- package/dist/index.js +647 -495
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +637 -512
- package/dist/index.mjs.map +1 -1
- package/package.json +9 -9
- package/src/components/color-variable-creation.tsx +11 -52
- package/src/components/color-variable-edit.tsx +88 -83
- package/src/components/fields/color-field.tsx +54 -0
- package/src/components/fields/font-field.tsx +85 -0
- package/src/components/fields/label-field.tsx +54 -0
- package/src/components/font-variable-creation.tsx +13 -72
- package/src/components/font-variable-edit.tsx +86 -111
- package/src/components/ui/delete-confirmation-dialog.tsx +55 -0
- package/src/components/ui/menu-item-content.tsx +2 -5
- package/src/components/ui/{variable-tag.tsx → tags/assigned-tag.tsx} +1 -1
- package/src/components/ui/tags/deleted-tag.tsx +26 -0
- package/src/components/ui/variable/assigned-variable.tsx +70 -0
- package/src/components/ui/variable/deleted-variable.tsx +20 -0
- package/src/controls/color-variable-control.tsx +15 -48
- package/src/controls/font-variable-control.tsx +14 -43
- package/src/init-color-variables.ts +3 -48
- package/src/repeater-injections.ts +35 -0
- 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_editing_panel9 = require("@elementor/editor-editing-panel");
|
|
43
|
+
|
|
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"));
|
|
42
59
|
var import_editor_controls8 = require("@elementor/editor-controls");
|
|
43
|
-
var
|
|
44
|
-
var
|
|
60
|
+
var import_icons11 = require("@elementor/icons");
|
|
61
|
+
var import_ui18 = require("@elementor/ui");
|
|
45
62
|
|
|
46
|
-
// src/components/
|
|
47
|
-
var
|
|
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");
|
|
@@ -339,105 +378,122 @@ var deleteVariable = (deleteId) => {
|
|
|
339
378
|
});
|
|
340
379
|
};
|
|
341
380
|
|
|
342
|
-
// src/components/
|
|
343
|
-
var
|
|
344
|
-
var
|
|
345
|
-
|
|
346
|
-
|
|
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/
|
|
350
|
-
var
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
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
|
|
359
|
-
const
|
|
360
|
-
|
|
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
|
|
363
|
-
|
|
364
|
-
|
|
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/
|
|
368
|
-
var
|
|
369
|
-
var
|
|
370
|
-
var
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
var import_ui14 = require("@elementor/ui");
|
|
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
|
+
};
|
|
374
427
|
|
|
375
|
-
// src/components/
|
|
376
|
-
var
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
}
|
|
388
|
-
|
|
389
|
-
import_ui2.UnstableTag,
|
|
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,
|
|
390
442
|
{
|
|
443
|
+
size: "tiny",
|
|
391
444
|
fullWidth: true,
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
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
|
+
}
|
|
397
455
|
}
|
|
398
|
-
);
|
|
456
|
+
), errorMessage && /* @__PURE__ */ React.createElement(import_ui2.FormHelperText, { error: true }, errorMessage)));
|
|
399
457
|
};
|
|
400
458
|
|
|
401
|
-
// src/components/
|
|
402
|
-
var
|
|
403
|
-
var
|
|
404
|
-
var import_ui13 = require("@elementor/ui");
|
|
405
|
-
|
|
406
|
-
// src/prop-types/color-variable-prop-type.ts
|
|
407
|
-
var import_editor_props = require("@elementor/editor-props");
|
|
408
|
-
var import_schema = require("@elementor/schema");
|
|
409
|
-
var colorVariablePropTypeUtil = (0, import_editor_props.createPropUtils)("global-color-variable", import_schema.z.string());
|
|
410
|
-
|
|
411
|
-
// src/prop-types/font-variable-prop-type.ts
|
|
412
|
-
var import_editor_props2 = require("@elementor/editor-props");
|
|
413
|
-
var import_schema2 = require("@elementor/schema");
|
|
414
|
-
var fontVariablePropTypeUtil = (0, import_editor_props2.createPropUtils)("global-font-variable", import_schema2.z.string());
|
|
415
|
-
|
|
416
|
-
// src/components/color-variable-creation.tsx
|
|
417
|
-
var React3 = __toESM(require("react"));
|
|
418
|
-
var import_react3 = require("react");
|
|
419
|
-
var import_editor_controls = require("@elementor/editor-controls");
|
|
420
|
-
var import_editor_editing_panel = require("@elementor/editor-editing-panel");
|
|
421
|
-
var import_editor_ui = require("@elementor/editor-ui");
|
|
422
|
-
var import_icons2 = require("@elementor/icons");
|
|
459
|
+
// src/components/fields/label-field.tsx
|
|
460
|
+
var React2 = __toESM(require("react"));
|
|
461
|
+
var import_react4 = require("react");
|
|
423
462
|
var import_ui3 = require("@elementor/ui");
|
|
424
|
-
var
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
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)));
|
|
431
489
|
};
|
|
432
490
|
|
|
433
491
|
// src/components/color-variable-creation.tsx
|
|
434
|
-
var
|
|
492
|
+
var SIZE = "tiny";
|
|
435
493
|
var ColorVariableCreation = ({ onGoBack, onClose }) => {
|
|
436
494
|
const { setValue: setVariable } = (0, import_editor_controls.useBoundProp)(colorVariablePropTypeUtil);
|
|
437
|
-
const [color, setColor] = (0,
|
|
438
|
-
const [label, setLabel] = (0,
|
|
439
|
-
const defaultRef = (0, import_react3.useRef)(null);
|
|
440
|
-
const anchorRef = usePopoverContentRef() ?? defaultRef;
|
|
495
|
+
const [color, setColor] = (0, import_react5.useState)("");
|
|
496
|
+
const [label, setLabel] = (0, import_react5.useState)("");
|
|
441
497
|
const resetFields = () => {
|
|
442
498
|
setColor("");
|
|
443
499
|
setLabel("");
|
|
@@ -456,137 +512,153 @@ var ColorVariableCreation = ({ onGoBack, onClose }) => {
|
|
|
456
512
|
closePopover();
|
|
457
513
|
});
|
|
458
514
|
};
|
|
459
|
-
const
|
|
460
|
-
return
|
|
515
|
+
const hasEmptyValue = () => {
|
|
516
|
+
return "" === color.trim() || "" === label.trim();
|
|
461
517
|
};
|
|
518
|
+
const isSubmitDisabled = hasEmptyValue();
|
|
462
519
|
return /* @__PURE__ */ React3.createElement(import_editor_editing_panel.PopoverScrollableContent, { height: "auto" }, /* @__PURE__ */ React3.createElement(
|
|
463
520
|
import_editor_ui.PopoverHeader,
|
|
464
521
|
{
|
|
465
|
-
icon: /* @__PURE__ */ React3.createElement(React3.Fragment, null, onGoBack && /* @__PURE__ */ React3.createElement(
|
|
466
|
-
title: (0,
|
|
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"),
|
|
467
524
|
onClose: closePopover
|
|
468
525
|
}
|
|
469
|
-
), /* @__PURE__ */ React3.createElement(
|
|
470
|
-
import_ui3.TextField,
|
|
471
|
-
{
|
|
472
|
-
size: "tiny",
|
|
473
|
-
fullWidth: true,
|
|
474
|
-
value: label,
|
|
475
|
-
onChange: (e) => setLabel(e.target.value)
|
|
476
|
-
}
|
|
477
|
-
))), /* @__PURE__ */ React3.createElement(import_ui3.Grid, { container: true, gap: 0.75, alignItems: "center" }, /* @__PURE__ */ React3.createElement(import_ui3.Grid, { item: true, xs: 12 }, /* @__PURE__ */ React3.createElement(import_ui3.FormLabel, { size: "tiny" }, (0, import_i18n2.__)("Value", "elementor"))), /* @__PURE__ */ React3.createElement(import_ui3.Grid, { item: true, xs: 12 }, /* @__PURE__ */ React3.createElement(
|
|
478
|
-
import_ui3.UnstableColorField,
|
|
479
|
-
{
|
|
480
|
-
size: "tiny",
|
|
481
|
-
fullWidth: true,
|
|
482
|
-
value: color,
|
|
483
|
-
onChange: setColor,
|
|
484
|
-
slotProps: {
|
|
485
|
-
colorPicker: {
|
|
486
|
-
anchorEl: anchorRef.current,
|
|
487
|
-
anchorOrigin: { vertical: "top", horizontal: "right" },
|
|
488
|
-
transformOrigin: { vertical: "top", horizontal: -10 }
|
|
489
|
-
}
|
|
490
|
-
}
|
|
491
|
-
}
|
|
492
|
-
)))), /* @__PURE__ */ React3.createElement(import_ui3.CardActions, { sx: { pt: 0.5, pb: 1 } }, /* @__PURE__ */ React3.createElement(import_ui3.Button, { size: "small", variant: "contained", disabled: isFormInvalid(), onClick: handleCreate }, (0, import_i18n2.__)("Create", "elementor"))));
|
|
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"))));
|
|
493
527
|
};
|
|
494
528
|
|
|
495
529
|
// src/components/color-variable-edit.tsx
|
|
496
|
-
var
|
|
497
|
-
var
|
|
530
|
+
var React5 = __toESM(require("react"));
|
|
531
|
+
var import_react6 = require("react");
|
|
498
532
|
var import_editor_controls2 = require("@elementor/editor-controls");
|
|
533
|
+
var import_editor_editing_panel2 = require("@elementor/editor-editing-panel");
|
|
499
534
|
var import_editor_ui2 = require("@elementor/editor-ui");
|
|
500
535
|
var import_icons3 = require("@elementor/icons");
|
|
501
|
-
var
|
|
502
|
-
var
|
|
503
|
-
|
|
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"));
|
|
541
|
+
var import_icons2 = require("@elementor/icons");
|
|
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
|
|
558
|
+
var SIZE2 = "tiny";
|
|
504
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);
|
|
505
562
|
const variable = useVariable(editId);
|
|
506
563
|
if (!variable) {
|
|
507
564
|
throw new Error(`Global color variable not found`);
|
|
508
565
|
}
|
|
509
|
-
const
|
|
510
|
-
const
|
|
511
|
-
const [color, setColor] = (0, import_react4.useState)(variable.value);
|
|
512
|
-
const [label, setLabel] = (0, import_react4.useState)(variable.label);
|
|
566
|
+
const [color, setColor] = (0, import_react6.useState)(variable.value);
|
|
567
|
+
const [label, setLabel] = (0, import_react6.useState)(variable.label);
|
|
513
568
|
const handleUpdate = () => {
|
|
514
569
|
updateVariable(editId, {
|
|
515
570
|
value: color,
|
|
516
571
|
label
|
|
517
572
|
}).then(() => {
|
|
573
|
+
maybeTriggerBoundPropChange();
|
|
518
574
|
onSubmit?.();
|
|
519
575
|
});
|
|
520
576
|
};
|
|
521
577
|
const handleDelete = () => {
|
|
522
578
|
deleteVariable(editId).then(() => {
|
|
579
|
+
maybeTriggerBoundPropChange();
|
|
523
580
|
onSubmit?.();
|
|
524
581
|
});
|
|
525
582
|
};
|
|
526
|
-
const
|
|
527
|
-
|
|
528
|
-
|
|
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
|
+
};
|
|
529
594
|
const actions = [];
|
|
530
595
|
actions.push(
|
|
531
|
-
/* @__PURE__ */
|
|
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
|
+
)
|
|
532
606
|
);
|
|
533
|
-
|
|
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(
|
|
534
615
|
import_editor_ui2.PopoverHeader,
|
|
535
616
|
{
|
|
536
|
-
title: (0,
|
|
617
|
+
title: (0, import_i18n6.__)("Edit variable", "elementor"),
|
|
537
618
|
onClose,
|
|
538
|
-
icon: /* @__PURE__ */
|
|
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 })),
|
|
539
628
|
actions
|
|
540
629
|
}
|
|
541
|
-
), /* @__PURE__ */
|
|
542
|
-
|
|
543
|
-
{
|
|
544
|
-
size: "tiny",
|
|
545
|
-
fullWidth: true,
|
|
546
|
-
value: label,
|
|
547
|
-
onChange: (e) => setLabel(e.target.value)
|
|
548
|
-
}
|
|
549
|
-
))), /* @__PURE__ */ React4.createElement(import_ui4.Grid, { container: true, gap: 0.75, alignItems: "center" }, /* @__PURE__ */ React4.createElement(import_ui4.Grid, { item: true, xs: 12 }, /* @__PURE__ */ React4.createElement(import_ui4.FormLabel, { size: "tiny" }, (0, import_i18n3.__)("Value", "elementor"))), /* @__PURE__ */ React4.createElement(import_ui4.Grid, { item: true, xs: 12 }, /* @__PURE__ */ React4.createElement(
|
|
550
|
-
import_ui4.UnstableColorField,
|
|
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,
|
|
551
632
|
{
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
slotProps: {
|
|
557
|
-
colorPicker: {
|
|
558
|
-
anchorEl: anchorRef.current,
|
|
559
|
-
anchorOrigin: { vertical: "top", horizontal: "right" },
|
|
560
|
-
transformOrigin: { vertical: "top", horizontal: -10 }
|
|
561
|
-
}
|
|
562
|
-
}
|
|
633
|
+
open: true,
|
|
634
|
+
label,
|
|
635
|
+
onConfirm: handleDelete,
|
|
636
|
+
closeDialog: closeDeleteDialog()
|
|
563
637
|
}
|
|
564
|
-
))
|
|
638
|
+
));
|
|
565
639
|
};
|
|
566
640
|
|
|
567
641
|
// src/components/color-variables-selection.tsx
|
|
568
|
-
var
|
|
569
|
-
var
|
|
642
|
+
var React9 = __toESM(require("react"));
|
|
643
|
+
var import_react7 = require("react");
|
|
570
644
|
var import_editor_controls3 = require("@elementor/editor-controls");
|
|
571
|
-
var
|
|
645
|
+
var import_editor_editing_panel3 = require("@elementor/editor-editing-panel");
|
|
572
646
|
var import_editor_ui4 = require("@elementor/editor-ui");
|
|
573
647
|
var import_icons5 = require("@elementor/icons");
|
|
574
|
-
var
|
|
575
|
-
var
|
|
648
|
+
var import_ui11 = require("@elementor/ui");
|
|
649
|
+
var import_i18n10 = require("@wordpress/i18n");
|
|
576
650
|
|
|
577
651
|
// src/components/ui/menu-item-content.tsx
|
|
578
|
-
var
|
|
652
|
+
var React6 = __toESM(require("react"));
|
|
579
653
|
var import_editor_ui3 = require("@elementor/editor-ui");
|
|
580
|
-
var import_editor_v1_adapters = require("@elementor/editor-v1-adapters");
|
|
581
654
|
var import_icons4 = require("@elementor/icons");
|
|
582
|
-
var
|
|
583
|
-
var
|
|
584
|
-
var
|
|
585
|
-
var isVersion330Active = (0, import_editor_v1_adapters.isExperimentActive)("e_v_3_30");
|
|
655
|
+
var import_ui7 = require("@elementor/ui");
|
|
656
|
+
var import_i18n7 = require("@wordpress/i18n");
|
|
657
|
+
var SIZE3 = "tiny";
|
|
586
658
|
var MenuItemContent = ({ item }) => {
|
|
587
659
|
const onEdit = item.onEdit;
|
|
588
|
-
return /* @__PURE__ */
|
|
589
|
-
|
|
660
|
+
return /* @__PURE__ */ React6.createElement(React6.Fragment, null, /* @__PURE__ */ React6.createElement(import_ui7.ListItemIcon, null, item.icon), /* @__PURE__ */ React6.createElement(
|
|
661
|
+
import_ui7.Box,
|
|
590
662
|
{
|
|
591
663
|
sx: {
|
|
592
664
|
flex: 1,
|
|
@@ -596,49 +668,49 @@ var MenuItemContent = ({ item }) => {
|
|
|
596
668
|
gap: 1
|
|
597
669
|
}
|
|
598
670
|
},
|
|
599
|
-
/* @__PURE__ */
|
|
671
|
+
/* @__PURE__ */ React6.createElement(
|
|
600
672
|
import_editor_ui3.EllipsisWithTooltip,
|
|
601
673
|
{
|
|
602
674
|
title: item.label || item.value,
|
|
603
|
-
as:
|
|
604
|
-
variant:
|
|
605
|
-
color:
|
|
675
|
+
as: import_ui7.Typography,
|
|
676
|
+
variant: "caption",
|
|
677
|
+
color: "text.primary",
|
|
606
678
|
sx: { marginTop: "1px", lineHeight: "2" },
|
|
607
679
|
maxWidth: "50%"
|
|
608
680
|
}
|
|
609
681
|
),
|
|
610
|
-
item.secondaryText && /* @__PURE__ */
|
|
682
|
+
item.secondaryText && /* @__PURE__ */ React6.createElement(
|
|
611
683
|
import_editor_ui3.EllipsisWithTooltip,
|
|
612
684
|
{
|
|
613
685
|
title: item.secondaryText,
|
|
614
|
-
as:
|
|
686
|
+
as: import_ui7.Typography,
|
|
615
687
|
variant: "caption",
|
|
616
688
|
color: "text.tertiary",
|
|
617
689
|
sx: { marginTop: "1px", lineHeight: "1" },
|
|
618
690
|
maxWidth: "50%"
|
|
619
691
|
}
|
|
620
692
|
)
|
|
621
|
-
), !!onEdit && /* @__PURE__ */
|
|
622
|
-
|
|
693
|
+
), !!onEdit && /* @__PURE__ */ React6.createElement(
|
|
694
|
+
import_ui7.IconButton,
|
|
623
695
|
{
|
|
624
696
|
sx: { mx: 1, opacity: "0" },
|
|
625
697
|
onClick: (e) => {
|
|
626
698
|
e.stopPropagation();
|
|
627
699
|
onEdit(item.value);
|
|
628
700
|
},
|
|
629
|
-
"aria-label": (0,
|
|
701
|
+
"aria-label": (0, import_i18n7.__)("Edit", "elementor")
|
|
630
702
|
},
|
|
631
|
-
/* @__PURE__ */
|
|
703
|
+
/* @__PURE__ */ React6.createElement(import_icons4.EditIcon, { color: "action", fontSize: SIZE3 })
|
|
632
704
|
));
|
|
633
705
|
};
|
|
634
706
|
|
|
635
707
|
// src/components/ui/no-search-results.tsx
|
|
636
|
-
var
|
|
637
|
-
var
|
|
638
|
-
var
|
|
708
|
+
var React7 = __toESM(require("react"));
|
|
709
|
+
var import_ui8 = require("@elementor/ui");
|
|
710
|
+
var import_i18n8 = require("@wordpress/i18n");
|
|
639
711
|
var NoSearchResults = ({ searchValue, onClear, icon }) => {
|
|
640
|
-
return /* @__PURE__ */
|
|
641
|
-
|
|
712
|
+
return /* @__PURE__ */ React7.createElement(
|
|
713
|
+
import_ui8.Stack,
|
|
642
714
|
{
|
|
643
715
|
gap: 1,
|
|
644
716
|
alignItems: "center",
|
|
@@ -649,17 +721,17 @@ var NoSearchResults = ({ searchValue, onClear, icon }) => {
|
|
|
649
721
|
sx: { pb: 3.5 }
|
|
650
722
|
},
|
|
651
723
|
icon,
|
|
652
|
-
/* @__PURE__ */
|
|
653
|
-
/* @__PURE__ */
|
|
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")))
|
|
654
726
|
);
|
|
655
727
|
};
|
|
656
728
|
|
|
657
729
|
// src/components/ui/no-variables.tsx
|
|
658
|
-
var
|
|
659
|
-
var
|
|
660
|
-
var
|
|
661
|
-
var NoVariables = ({ icon, title, onAdd }) => /* @__PURE__ */
|
|
662
|
-
|
|
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,
|
|
663
735
|
{
|
|
664
736
|
gap: 1,
|
|
665
737
|
alignItems: "center",
|
|
@@ -669,14 +741,14 @@ var NoVariables = ({ icon, title, onAdd }) => /* @__PURE__ */ React7.createEleme
|
|
|
669
741
|
sx: { p: 2.5, pb: 5.5 }
|
|
670
742
|
},
|
|
671
743
|
icon,
|
|
672
|
-
/* @__PURE__ */
|
|
673
|
-
/* @__PURE__ */
|
|
674
|
-
onAdd && /* @__PURE__ */
|
|
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"))
|
|
675
747
|
);
|
|
676
748
|
|
|
677
749
|
// src/components/ui/styled-menu-list.tsx
|
|
678
|
-
var
|
|
679
|
-
var VariablesStyledMenuList = (0,
|
|
750
|
+
var import_ui10 = require("@elementor/ui");
|
|
751
|
+
var VariablesStyledMenuList = (0, import_ui10.styled)(import_ui10.MenuList)(({ theme }) => ({
|
|
680
752
|
"& > li": {
|
|
681
753
|
height: 32,
|
|
682
754
|
width: "100%",
|
|
@@ -707,10 +779,10 @@ var VariablesStyledMenuList = (0, import_ui8.styled)(import_ui8.MenuList)(({ the
|
|
|
707
779
|
}));
|
|
708
780
|
|
|
709
781
|
// src/components/color-variables-selection.tsx
|
|
710
|
-
var
|
|
782
|
+
var SIZE4 = "tiny";
|
|
711
783
|
var ColorVariablesSelection = ({ closePopover, onAdd, onEdit, onSettings }) => {
|
|
712
784
|
const { value: variable, setValue: setVariable } = (0, import_editor_controls3.useBoundProp)(colorVariablePropTypeUtil);
|
|
713
|
-
const [searchValue, setSearchValue] = (0,
|
|
785
|
+
const [searchValue, setSearchValue] = (0, import_react7.useState)("");
|
|
714
786
|
const {
|
|
715
787
|
list: variables,
|
|
716
788
|
hasMatches: hasSearchResults,
|
|
@@ -723,19 +795,19 @@ var ColorVariablesSelection = ({ closePopover, onAdd, onEdit, onSettings }) => {
|
|
|
723
795
|
const actions = [];
|
|
724
796
|
if (onAdd) {
|
|
725
797
|
actions.push(
|
|
726
|
-
/* @__PURE__ */
|
|
798
|
+
/* @__PURE__ */ React9.createElement(import_ui11.IconButton, { key: "add", size: SIZE4, onClick: onAdd }, /* @__PURE__ */ React9.createElement(import_icons5.PlusIcon, { fontSize: SIZE4 }))
|
|
727
799
|
);
|
|
728
800
|
}
|
|
729
801
|
if (onSettings) {
|
|
730
802
|
actions.push(
|
|
731
|
-
/* @__PURE__ */
|
|
803
|
+
/* @__PURE__ */ React9.createElement(import_ui11.IconButton, { key: "settings", size: SIZE4, onClick: onSettings }, /* @__PURE__ */ React9.createElement(import_icons5.SettingsIcon, { fontSize: SIZE4 }))
|
|
732
804
|
);
|
|
733
805
|
}
|
|
734
806
|
const items = variables.map(({ value, label, key }) => ({
|
|
735
807
|
type: "item",
|
|
736
808
|
value: key,
|
|
737
809
|
label,
|
|
738
|
-
icon: /* @__PURE__ */
|
|
810
|
+
icon: /* @__PURE__ */ React9.createElement(ColorIndicator, { size: "inherit", component: "span", value }),
|
|
739
811
|
secondaryText: value,
|
|
740
812
|
onEdit: () => onEdit?.(key)
|
|
741
813
|
}));
|
|
@@ -745,22 +817,22 @@ var ColorVariablesSelection = ({ closePopover, onAdd, onEdit, onSettings }) => {
|
|
|
745
817
|
const handleClearSearch = () => {
|
|
746
818
|
setSearchValue("");
|
|
747
819
|
};
|
|
748
|
-
return /* @__PURE__ */
|
|
820
|
+
return /* @__PURE__ */ React9.createElement(React9.Fragment, null, /* @__PURE__ */ React9.createElement(
|
|
749
821
|
import_editor_ui4.PopoverHeader,
|
|
750
822
|
{
|
|
751
|
-
title: (0,
|
|
752
|
-
icon: /* @__PURE__ */
|
|
823
|
+
title: (0, import_i18n10.__)("Variables", "elementor"),
|
|
824
|
+
icon: /* @__PURE__ */ React9.createElement(import_icons5.ColorFilterIcon, { fontSize: SIZE4 }),
|
|
753
825
|
onClose: closePopover,
|
|
754
826
|
actions
|
|
755
827
|
}
|
|
756
|
-
), hasVariables && /* @__PURE__ */
|
|
828
|
+
), hasVariables && /* @__PURE__ */ React9.createElement(
|
|
757
829
|
import_editor_ui4.PopoverSearch,
|
|
758
830
|
{
|
|
759
831
|
value: searchValue,
|
|
760
832
|
onSearch: handleSearch,
|
|
761
|
-
placeholder: (0,
|
|
833
|
+
placeholder: (0, import_i18n10.__)("Search", "elementor")
|
|
762
834
|
}
|
|
763
|
-
), /* @__PURE__ */
|
|
835
|
+
), /* @__PURE__ */ React9.createElement(import_ui11.Divider, null), /* @__PURE__ */ React9.createElement(import_editor_editing_panel3.PopoverScrollableContent, null, hasVariables && hasSearchResults && /* @__PURE__ */ React9.createElement(
|
|
764
836
|
import_editor_ui4.PopoverMenuList,
|
|
765
837
|
{
|
|
766
838
|
items,
|
|
@@ -770,42 +842,99 @@ var ColorVariablesSelection = ({ closePopover, onAdd, onEdit, onSettings }) => {
|
|
|
770
842
|
selectedValue: variable,
|
|
771
843
|
"data-testid": "color-variables-list",
|
|
772
844
|
menuListTemplate: VariablesStyledMenuList,
|
|
773
|
-
menuItemContentTemplate: (item) => /* @__PURE__ */
|
|
845
|
+
menuItemContentTemplate: (item) => /* @__PURE__ */ React9.createElement(MenuItemContent, { item })
|
|
774
846
|
}
|
|
775
|
-
), !hasSearchResults && hasVariables && /* @__PURE__ */
|
|
847
|
+
), !hasSearchResults && hasVariables && /* @__PURE__ */ React9.createElement(
|
|
776
848
|
NoSearchResults,
|
|
777
849
|
{
|
|
778
850
|
searchValue,
|
|
779
851
|
onClear: handleClearSearch,
|
|
780
|
-
icon: /* @__PURE__ */
|
|
852
|
+
icon: /* @__PURE__ */ React9.createElement(import_icons5.BrushIcon, { fontSize: "large" })
|
|
781
853
|
}
|
|
782
|
-
), !hasVariables && /* @__PURE__ */
|
|
854
|
+
), !hasVariables && /* @__PURE__ */ React9.createElement(
|
|
783
855
|
NoVariables,
|
|
784
856
|
{
|
|
785
|
-
title: (0,
|
|
786
|
-
icon: /* @__PURE__ */
|
|
857
|
+
title: (0, import_i18n10.__)("Create your first color variable", "elementor"),
|
|
858
|
+
icon: /* @__PURE__ */ React9.createElement(import_icons5.BrushIcon, { fontSize: "large" }),
|
|
787
859
|
onAdd
|
|
788
860
|
}
|
|
789
861
|
)));
|
|
790
862
|
};
|
|
791
863
|
|
|
792
864
|
// src/components/font-variable-creation.tsx
|
|
793
|
-
var
|
|
794
|
-
var
|
|
795
|
-
var
|
|
796
|
-
var
|
|
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");
|
|
797
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");
|
|
798
879
|
var import_icons6 = require("@elementor/icons");
|
|
799
|
-
var
|
|
800
|
-
var
|
|
801
|
-
var
|
|
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
|
|
933
|
+
var SIZE5 = "tiny";
|
|
802
934
|
var FontVariableCreation = ({ onClose, onGoBack }) => {
|
|
803
|
-
const
|
|
804
|
-
const
|
|
805
|
-
const [
|
|
806
|
-
const [label, setLabel] = (0, import_react6.useState)("");
|
|
807
|
-
const anchorRef = (0, import_react6.useRef)(null);
|
|
808
|
-
const fontPopoverState = (0, import_ui10.usePopupState)({ variant: "popover" });
|
|
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)("");
|
|
809
938
|
const resetFields = () => {
|
|
810
939
|
setFontFamily("");
|
|
811
940
|
setLabel("");
|
|
@@ -824,163 +953,125 @@ var FontVariableCreation = ({ onClose, onGoBack }) => {
|
|
|
824
953
|
closePopover();
|
|
825
954
|
});
|
|
826
955
|
};
|
|
827
|
-
const
|
|
828
|
-
return
|
|
956
|
+
const hasEmptyValue = () => {
|
|
957
|
+
return "" === fontFamily.trim() || "" === label.trim();
|
|
829
958
|
};
|
|
830
|
-
const
|
|
831
|
-
return /* @__PURE__ */
|
|
959
|
+
const isSubmitDisabled = hasEmptyValue();
|
|
960
|
+
return /* @__PURE__ */ React11.createElement(import_editor_editing_panel5.PopoverScrollableContent, { height: "auto" }, /* @__PURE__ */ React11.createElement(
|
|
832
961
|
import_editor_ui5.PopoverHeader,
|
|
833
962
|
{
|
|
834
|
-
icon: /* @__PURE__ */
|
|
835
|
-
title: (0,
|
|
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"),
|
|
836
965
|
onClose: closePopover
|
|
837
966
|
}
|
|
838
|
-
), /* @__PURE__ */
|
|
839
|
-
import_ui10.TextField,
|
|
840
|
-
{
|
|
841
|
-
size: "tiny",
|
|
842
|
-
fullWidth: true,
|
|
843
|
-
value: label,
|
|
844
|
-
onChange: (e) => setLabel(e.target.value)
|
|
845
|
-
}
|
|
846
|
-
))), /* @__PURE__ */ React9.createElement(import_ui10.Grid, { container: true, gap: 0.75, alignItems: "center" }, /* @__PURE__ */ React9.createElement(import_ui10.Grid, { item: true, xs: 12 }, /* @__PURE__ */ React9.createElement(import_ui10.FormLabel, { size: "tiny" }, (0, import_i18n8.__)("Value", "elementor"))), /* @__PURE__ */ React9.createElement(import_ui10.Grid, { item: true, xs: 12 }, /* @__PURE__ */ React9.createElement(React9.Fragment, null, /* @__PURE__ */ React9.createElement(
|
|
847
|
-
import_ui10.UnstableTag,
|
|
848
|
-
{
|
|
849
|
-
variant: "outlined",
|
|
850
|
-
label: fontFamily,
|
|
851
|
-
endIcon: /* @__PURE__ */ React9.createElement(import_icons6.ChevronDownIcon, { fontSize: "tiny" }),
|
|
852
|
-
...(0, import_ui10.bindTrigger)(fontPopoverState),
|
|
853
|
-
fullWidth: true
|
|
854
|
-
}
|
|
855
|
-
), /* @__PURE__ */ React9.createElement(
|
|
856
|
-
import_ui10.Popover,
|
|
857
|
-
{
|
|
858
|
-
disablePortal: true,
|
|
859
|
-
disableScrollLock: true,
|
|
860
|
-
anchorEl: anchorRef.current,
|
|
861
|
-
anchorOrigin: { vertical: "top", horizontal: "right" },
|
|
862
|
-
transformOrigin: { vertical: "top", horizontal: -20 },
|
|
863
|
-
...(0, import_ui10.bindPopover)(fontPopoverState)
|
|
864
|
-
},
|
|
865
|
-
/* @__PURE__ */ React9.createElement(
|
|
866
|
-
import_editor_controls4.FontFamilySelector,
|
|
867
|
-
{
|
|
868
|
-
fontFamilies,
|
|
869
|
-
fontFamily,
|
|
870
|
-
onFontFamilyChange: setFontFamily,
|
|
871
|
-
onClose: fontPopoverState.close,
|
|
872
|
-
sectionWidth
|
|
873
|
-
}
|
|
874
|
-
)
|
|
875
|
-
))))), /* @__PURE__ */ React9.createElement(import_ui10.CardActions, { sx: { pt: 0.5, pb: 1 } }, /* @__PURE__ */ React9.createElement(import_ui10.Button, { size: "small", variant: "contained", disabled: isFormInvalid(), onClick: handleCreate }, (0, import_i18n8.__)("Create", "elementor"))));
|
|
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"))));
|
|
876
968
|
};
|
|
877
969
|
|
|
878
970
|
// src/components/font-variable-edit.tsx
|
|
879
|
-
var
|
|
880
|
-
var
|
|
881
|
-
var
|
|
882
|
-
var
|
|
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");
|
|
883
975
|
var import_editor_ui6 = require("@elementor/editor-ui");
|
|
884
|
-
var
|
|
885
|
-
var
|
|
886
|
-
var
|
|
887
|
-
var
|
|
976
|
+
var import_icons8 = require("@elementor/icons");
|
|
977
|
+
var import_ui14 = require("@elementor/ui");
|
|
978
|
+
var import_i18n13 = require("@wordpress/i18n");
|
|
979
|
+
var SIZE6 = "tiny";
|
|
888
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);
|
|
889
983
|
const variable = useVariable(editId);
|
|
890
984
|
if (!variable) {
|
|
891
985
|
throw new Error(`Global font variable "${editId}" not found`);
|
|
892
986
|
}
|
|
893
|
-
const [fontFamily, setFontFamily] = (0,
|
|
894
|
-
const [label, setLabel] = (0,
|
|
895
|
-
const variableNameId = (0, import_react7.useId)();
|
|
896
|
-
const variableValueId = (0, import_react7.useId)();
|
|
897
|
-
const anchorRef = (0, import_react7.useRef)(null);
|
|
898
|
-
const fontPopoverState = (0, import_ui11.usePopupState)({ variant: "popover" });
|
|
899
|
-
const fontFamilies = (0, import_editor_editing_panel4.useFontFamilies)();
|
|
987
|
+
const [fontFamily, setFontFamily] = (0, import_react10.useState)(variable.value);
|
|
988
|
+
const [label, setLabel] = (0, import_react10.useState)(variable.label);
|
|
900
989
|
const handleUpdate = () => {
|
|
901
990
|
updateVariable(editId, {
|
|
902
991
|
value: fontFamily,
|
|
903
992
|
label
|
|
904
993
|
}).then(() => {
|
|
994
|
+
maybeTriggerBoundPropChange();
|
|
905
995
|
onSubmit?.();
|
|
906
996
|
});
|
|
907
997
|
};
|
|
908
998
|
const handleDelete = () => {
|
|
909
999
|
deleteVariable(editId).then(() => {
|
|
1000
|
+
maybeTriggerBoundPropChange();
|
|
910
1001
|
onSubmit?.();
|
|
911
1002
|
});
|
|
912
1003
|
};
|
|
913
|
-
const
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
1004
|
+
const maybeTriggerBoundPropChange = () => {
|
|
1005
|
+
if (editId === assignedValue) {
|
|
1006
|
+
notifyBoundPropChange(editId);
|
|
1007
|
+
}
|
|
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();
|
|
917
1022
|
const actions = [];
|
|
918
1023
|
actions.push(
|
|
919
|
-
/* @__PURE__ */
|
|
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
|
+
)
|
|
920
1034
|
);
|
|
921
|
-
return /* @__PURE__ */
|
|
1035
|
+
return /* @__PURE__ */ React12.createElement(React12.Fragment, null, /* @__PURE__ */ React12.createElement(import_editor_editing_panel6.PopoverScrollableContent, { height: "auto" }, /* @__PURE__ */ React12.createElement(
|
|
922
1036
|
import_editor_ui6.PopoverHeader,
|
|
923
1037
|
{
|
|
924
|
-
icon: /* @__PURE__ */
|
|
925
|
-
|
|
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"),
|
|
926
1048
|
onClose,
|
|
927
1049
|
actions
|
|
928
1050
|
}
|
|
929
|
-
), /* @__PURE__ */
|
|
930
|
-
|
|
931
|
-
{
|
|
932
|
-
id: variableNameId,
|
|
933
|
-
size: "tiny",
|
|
934
|
-
fullWidth: true,
|
|
935
|
-
value: label,
|
|
936
|
-
onChange: (e) => setLabel(e.target.value)
|
|
937
|
-
}
|
|
938
|
-
))), /* @__PURE__ */ React10.createElement(import_ui11.Grid, { container: true, gap: 0.75, alignItems: "center" }, /* @__PURE__ */ React10.createElement(import_ui11.Grid, { item: true, xs: 12 }, /* @__PURE__ */ React10.createElement(import_ui11.FormLabel, { htmlFor: variableValueId, size: "tiny" }, (0, import_i18n9.__)("Value", "elementor"))), /* @__PURE__ */ React10.createElement(import_ui11.Grid, { item: true, xs: 12 }, /* @__PURE__ */ React10.createElement(React10.Fragment, null, /* @__PURE__ */ React10.createElement(
|
|
939
|
-
import_ui11.UnstableTag,
|
|
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,
|
|
940
1053
|
{
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
...(0, import_ui11.bindTrigger)(fontPopoverState),
|
|
946
|
-
fullWidth: true
|
|
1054
|
+
open: true,
|
|
1055
|
+
label,
|
|
1056
|
+
onConfirm: handleDelete,
|
|
1057
|
+
closeDialog: closeDeleteDialog()
|
|
947
1058
|
}
|
|
948
|
-
)
|
|
949
|
-
import_ui11.Popover,
|
|
950
|
-
{
|
|
951
|
-
disablePortal: true,
|
|
952
|
-
disableScrollLock: true,
|
|
953
|
-
anchorEl: anchorRef.current,
|
|
954
|
-
anchorOrigin: { vertical: "top", horizontal: "right" },
|
|
955
|
-
transformOrigin: { vertical: "top", horizontal: -20 },
|
|
956
|
-
...(0, import_ui11.bindPopover)(fontPopoverState)
|
|
957
|
-
},
|
|
958
|
-
/* @__PURE__ */ React10.createElement(
|
|
959
|
-
import_editor_controls5.FontFamilySelector,
|
|
960
|
-
{
|
|
961
|
-
fontFamilies,
|
|
962
|
-
fontFamily,
|
|
963
|
-
onFontFamilyChange: setFontFamily,
|
|
964
|
-
onClose: fontPopoverState.close,
|
|
965
|
-
sectionWidth
|
|
966
|
-
}
|
|
967
|
-
)
|
|
968
|
-
))))), /* @__PURE__ */ React10.createElement(import_ui11.CardActions, { sx: { pt: 0.5, pb: 1 } }, /* @__PURE__ */ React10.createElement(import_ui11.Button, { size: "small", variant: "contained", disabled: isSaveDisabled(), onClick: handleUpdate }, (0, import_i18n9.__)("Save", "elementor"))));
|
|
1059
|
+
));
|
|
969
1060
|
};
|
|
970
1061
|
|
|
971
1062
|
// src/components/font-variables-selection.tsx
|
|
972
|
-
var
|
|
973
|
-
var
|
|
974
|
-
var
|
|
975
|
-
var
|
|
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");
|
|
976
1067
|
var import_editor_ui7 = require("@elementor/editor-ui");
|
|
977
|
-
var
|
|
978
|
-
var
|
|
979
|
-
var
|
|
980
|
-
var
|
|
1068
|
+
var import_icons9 = require("@elementor/icons");
|
|
1069
|
+
var import_ui15 = require("@elementor/ui");
|
|
1070
|
+
var import_i18n14 = require("@wordpress/i18n");
|
|
1071
|
+
var SIZE7 = "tiny";
|
|
981
1072
|
var FontVariablesSelection = ({ closePopover, onAdd, onEdit, onSettings }) => {
|
|
982
|
-
const { value: variable, setValue: setVariable } = (0,
|
|
983
|
-
const [searchValue, setSearchValue] = (0,
|
|
1073
|
+
const { value: variable, setValue: setVariable } = (0, import_editor_controls7.useBoundProp)(fontVariablePropTypeUtil);
|
|
1074
|
+
const [searchValue, setSearchValue] = (0, import_react11.useState)("");
|
|
984
1075
|
const {
|
|
985
1076
|
list: variables,
|
|
986
1077
|
hasMatches: hasSearchResults,
|
|
@@ -993,19 +1084,19 @@ var FontVariablesSelection = ({ closePopover, onAdd, onEdit, onSettings }) => {
|
|
|
993
1084
|
const actions = [];
|
|
994
1085
|
if (onAdd) {
|
|
995
1086
|
actions.push(
|
|
996
|
-
/* @__PURE__ */
|
|
1087
|
+
/* @__PURE__ */ React13.createElement(import_ui15.IconButton, { key: "add", size: SIZE7, onClick: onAdd }, /* @__PURE__ */ React13.createElement(import_icons9.PlusIcon, { fontSize: SIZE7 }))
|
|
997
1088
|
);
|
|
998
1089
|
}
|
|
999
1090
|
if (onSettings) {
|
|
1000
1091
|
actions.push(
|
|
1001
|
-
/* @__PURE__ */
|
|
1092
|
+
/* @__PURE__ */ React13.createElement(import_ui15.IconButton, { key: "settings", size: SIZE7, onClick: onSettings }, /* @__PURE__ */ React13.createElement(import_icons9.SettingsIcon, { fontSize: SIZE7 }))
|
|
1002
1093
|
);
|
|
1003
1094
|
}
|
|
1004
1095
|
const items = variables.map(({ value, label, key }) => ({
|
|
1005
1096
|
type: "item",
|
|
1006
1097
|
value: key,
|
|
1007
1098
|
label,
|
|
1008
|
-
icon: /* @__PURE__ */
|
|
1099
|
+
icon: /* @__PURE__ */ React13.createElement(import_icons9.TextIcon, { fontSize: SIZE7 }),
|
|
1009
1100
|
secondaryText: value,
|
|
1010
1101
|
onEdit: () => onEdit?.(key)
|
|
1011
1102
|
}));
|
|
@@ -1015,22 +1106,22 @@ var FontVariablesSelection = ({ closePopover, onAdd, onEdit, onSettings }) => {
|
|
|
1015
1106
|
const handleClearSearch = () => {
|
|
1016
1107
|
setSearchValue("");
|
|
1017
1108
|
};
|
|
1018
|
-
return /* @__PURE__ */
|
|
1109
|
+
return /* @__PURE__ */ React13.createElement(React13.Fragment, null, /* @__PURE__ */ React13.createElement(
|
|
1019
1110
|
import_editor_ui7.PopoverHeader,
|
|
1020
1111
|
{
|
|
1021
|
-
title: (0,
|
|
1112
|
+
title: (0, import_i18n14.__)("Variables", "elementor"),
|
|
1022
1113
|
onClose: closePopover,
|
|
1023
|
-
icon: /* @__PURE__ */
|
|
1114
|
+
icon: /* @__PURE__ */ React13.createElement(import_icons9.ColorFilterIcon, { fontSize: SIZE7 }),
|
|
1024
1115
|
actions
|
|
1025
1116
|
}
|
|
1026
|
-
), hasVariables && /* @__PURE__ */
|
|
1117
|
+
), hasVariables && /* @__PURE__ */ React13.createElement(
|
|
1027
1118
|
import_editor_ui7.PopoverSearch,
|
|
1028
1119
|
{
|
|
1029
1120
|
value: searchValue,
|
|
1030
1121
|
onSearch: handleSearch,
|
|
1031
|
-
placeholder: (0,
|
|
1122
|
+
placeholder: (0, import_i18n14.__)("Search", "elementor")
|
|
1032
1123
|
}
|
|
1033
|
-
), /* @__PURE__ */
|
|
1124
|
+
), /* @__PURE__ */ React13.createElement(import_ui15.Divider, null), /* @__PURE__ */ React13.createElement(import_editor_editing_panel7.PopoverScrollableContent, null, hasVariables && hasSearchResults && /* @__PURE__ */ React13.createElement(
|
|
1034
1125
|
import_editor_ui7.PopoverMenuList,
|
|
1035
1126
|
{
|
|
1036
1127
|
items,
|
|
@@ -1040,20 +1131,20 @@ var FontVariablesSelection = ({ closePopover, onAdd, onEdit, onSettings }) => {
|
|
|
1040
1131
|
selectedValue: variable,
|
|
1041
1132
|
"data-testid": "font-variables-list",
|
|
1042
1133
|
menuListTemplate: VariablesStyledMenuList,
|
|
1043
|
-
menuItemContentTemplate: (item) => /* @__PURE__ */
|
|
1134
|
+
menuItemContentTemplate: (item) => /* @__PURE__ */ React13.createElement(MenuItemContent, { item })
|
|
1044
1135
|
}
|
|
1045
|
-
), !hasSearchResults && hasVariables && /* @__PURE__ */
|
|
1136
|
+
), !hasSearchResults && hasVariables && /* @__PURE__ */ React13.createElement(
|
|
1046
1137
|
NoSearchResults,
|
|
1047
1138
|
{
|
|
1048
1139
|
searchValue,
|
|
1049
1140
|
onClear: handleClearSearch,
|
|
1050
|
-
icon: /* @__PURE__ */
|
|
1141
|
+
icon: /* @__PURE__ */ React13.createElement(import_icons9.TextIcon, { fontSize: "large" })
|
|
1051
1142
|
}
|
|
1052
|
-
), !hasVariables && /* @__PURE__ */
|
|
1143
|
+
), !hasVariables && /* @__PURE__ */ React13.createElement(
|
|
1053
1144
|
NoVariables,
|
|
1054
1145
|
{
|
|
1055
|
-
title: (0,
|
|
1056
|
-
icon: /* @__PURE__ */
|
|
1146
|
+
title: (0, import_i18n14.__)("Create your first font variable", "elementor"),
|
|
1147
|
+
icon: /* @__PURE__ */ React13.createElement(import_icons9.TextIcon, { fontSize: "large" }),
|
|
1057
1148
|
onAdd
|
|
1058
1149
|
}
|
|
1059
1150
|
)));
|
|
@@ -1064,10 +1155,10 @@ var VIEW_LIST = "list";
|
|
|
1064
1155
|
var VIEW_ADD = "add";
|
|
1065
1156
|
var VIEW_EDIT = "edit";
|
|
1066
1157
|
var VariableSelectionPopover = ({ closePopover, propTypeKey, selectedVariable }) => {
|
|
1067
|
-
const [currentView, setCurrentView] = (0,
|
|
1068
|
-
const editIdRef = (0,
|
|
1069
|
-
const anchorRef = (0,
|
|
1070
|
-
return /* @__PURE__ */
|
|
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({
|
|
1071
1162
|
propTypeKey,
|
|
1072
1163
|
currentView,
|
|
1073
1164
|
selectedVariable,
|
|
@@ -1086,7 +1177,7 @@ function renderStage(props) {
|
|
|
1086
1177
|
};
|
|
1087
1178
|
if (fontVariablePropTypeUtil.key === props.propTypeKey) {
|
|
1088
1179
|
if (VIEW_LIST === props.currentView) {
|
|
1089
|
-
return /* @__PURE__ */
|
|
1180
|
+
return /* @__PURE__ */ React14.createElement(
|
|
1090
1181
|
FontVariablesSelection,
|
|
1091
1182
|
{
|
|
1092
1183
|
closePopover: props.closePopover,
|
|
@@ -1101,7 +1192,7 @@ function renderStage(props) {
|
|
|
1101
1192
|
);
|
|
1102
1193
|
}
|
|
1103
1194
|
if (VIEW_ADD === props.currentView) {
|
|
1104
|
-
return /* @__PURE__ */
|
|
1195
|
+
return /* @__PURE__ */ React14.createElement(
|
|
1105
1196
|
FontVariableCreation,
|
|
1106
1197
|
{
|
|
1107
1198
|
onGoBack: () => props.setCurrentView(VIEW_LIST),
|
|
@@ -1110,7 +1201,7 @@ function renderStage(props) {
|
|
|
1110
1201
|
);
|
|
1111
1202
|
}
|
|
1112
1203
|
if (VIEW_EDIT === props.currentView) {
|
|
1113
|
-
return /* @__PURE__ */
|
|
1204
|
+
return /* @__PURE__ */ React14.createElement(
|
|
1114
1205
|
FontVariableEdit,
|
|
1115
1206
|
{
|
|
1116
1207
|
editId: props.editIdRef.current ?? "",
|
|
@@ -1123,7 +1214,7 @@ function renderStage(props) {
|
|
|
1123
1214
|
}
|
|
1124
1215
|
if (colorVariablePropTypeUtil.key === props.propTypeKey) {
|
|
1125
1216
|
if (VIEW_LIST === props.currentView) {
|
|
1126
|
-
return /* @__PURE__ */
|
|
1217
|
+
return /* @__PURE__ */ React14.createElement(
|
|
1127
1218
|
ColorVariablesSelection,
|
|
1128
1219
|
{
|
|
1129
1220
|
closePopover: props.closePopover,
|
|
@@ -1138,7 +1229,7 @@ function renderStage(props) {
|
|
|
1138
1229
|
);
|
|
1139
1230
|
}
|
|
1140
1231
|
if (VIEW_ADD === props.currentView) {
|
|
1141
|
-
return /* @__PURE__ */
|
|
1232
|
+
return /* @__PURE__ */ React14.createElement(
|
|
1142
1233
|
ColorVariableCreation,
|
|
1143
1234
|
{
|
|
1144
1235
|
onGoBack: () => props.setCurrentView(VIEW_LIST),
|
|
@@ -1147,7 +1238,7 @@ function renderStage(props) {
|
|
|
1147
1238
|
);
|
|
1148
1239
|
}
|
|
1149
1240
|
if (VIEW_EDIT === props.currentView) {
|
|
1150
|
-
return /* @__PURE__ */
|
|
1241
|
+
return /* @__PURE__ */ React14.createElement(
|
|
1151
1242
|
ColorVariableEdit,
|
|
1152
1243
|
{
|
|
1153
1244
|
editId: props.editIdRef.current ?? "",
|
|
@@ -1161,33 +1252,59 @@ function renderStage(props) {
|
|
|
1161
1252
|
return null;
|
|
1162
1253
|
}
|
|
1163
1254
|
|
|
1164
|
-
// src/
|
|
1165
|
-
var
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
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");
|
|
1260
|
+
var SIZE8 = "tiny";
|
|
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)({
|
|
1171
1292
|
variant: "popover",
|
|
1172
1293
|
popupId: `elementor-variables-list-${popupId}`
|
|
1173
1294
|
});
|
|
1174
|
-
const selectedVariable = useVariable(variableValue);
|
|
1175
|
-
if (!selectedVariable) {
|
|
1176
|
-
throw new Error(`Global color variable ${variableValue} not found`);
|
|
1177
|
-
}
|
|
1178
1295
|
const unlinkVariable = () => {
|
|
1179
|
-
|
|
1296
|
+
setValue(fallbackPropTypeUtil.create(variable.value));
|
|
1180
1297
|
};
|
|
1181
|
-
return /* @__PURE__ */
|
|
1182
|
-
|
|
1298
|
+
return /* @__PURE__ */ React16.createElement(import_ui18.Box, { ref: anchorRef }, /* @__PURE__ */ React16.createElement(
|
|
1299
|
+
AssignedTag,
|
|
1183
1300
|
{
|
|
1184
|
-
label:
|
|
1185
|
-
startIcon: /* @__PURE__ */
|
|
1301
|
+
label: variable.label,
|
|
1302
|
+
startIcon: /* @__PURE__ */ React16.createElement(React16.Fragment, null, /* @__PURE__ */ React16.createElement(import_icons11.ColorFilterIcon, { fontSize: SIZE8 }), additionalStartIcon),
|
|
1186
1303
|
onUnlink: unlinkVariable,
|
|
1187
|
-
...(0,
|
|
1304
|
+
...(0, import_ui18.bindTrigger)(popupState)
|
|
1188
1305
|
}
|
|
1189
|
-
), /* @__PURE__ */
|
|
1190
|
-
|
|
1306
|
+
), /* @__PURE__ */ React16.createElement(
|
|
1307
|
+
import_ui18.Popover,
|
|
1191
1308
|
{
|
|
1192
1309
|
disableScrollLock: true,
|
|
1193
1310
|
anchorEl: anchorRef.current,
|
|
@@ -1196,24 +1313,75 @@ var ColorVariableControl = () => {
|
|
|
1196
1313
|
PaperProps: {
|
|
1197
1314
|
sx: { my: 1 }
|
|
1198
1315
|
},
|
|
1199
|
-
...(0,
|
|
1316
|
+
...(0, import_ui18.bindPopover)(popupState)
|
|
1200
1317
|
},
|
|
1201
|
-
/* @__PURE__ */
|
|
1318
|
+
/* @__PURE__ */ React16.createElement(
|
|
1202
1319
|
VariableSelectionPopover,
|
|
1203
1320
|
{
|
|
1204
|
-
selectedVariable,
|
|
1321
|
+
selectedVariable: variable,
|
|
1205
1322
|
closePopover: popupState.close,
|
|
1206
|
-
propTypeKey:
|
|
1323
|
+
propTypeKey: variablePropTypeUtil.key
|
|
1207
1324
|
}
|
|
1208
1325
|
)
|
|
1209
1326
|
));
|
|
1210
1327
|
};
|
|
1211
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
|
+
|
|
1212
1380
|
// src/hooks/use-prop-color-variable-action.tsx
|
|
1213
|
-
var
|
|
1214
|
-
var
|
|
1215
|
-
var
|
|
1216
|
-
var
|
|
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");
|
|
1217
1385
|
|
|
1218
1386
|
// src/utils.ts
|
|
1219
1387
|
var hasAssignedColorVariable = (propValue) => {
|
|
@@ -1231,18 +1399,66 @@ var supportsFontVariables = (propType) => {
|
|
|
1231
1399
|
|
|
1232
1400
|
// src/hooks/use-prop-color-variable-action.tsx
|
|
1233
1401
|
var usePropColorVariableAction = () => {
|
|
1234
|
-
const { propType } = (0,
|
|
1402
|
+
const { propType } = (0, import_editor_editing_panel8.useBoundProp)();
|
|
1235
1403
|
const visible = !!propType && supportsColorVariables(propType);
|
|
1236
1404
|
return {
|
|
1237
1405
|
visible,
|
|
1238
|
-
icon:
|
|
1239
|
-
title: (0,
|
|
1406
|
+
icon: import_icons13.ColorFilterIcon,
|
|
1407
|
+
title: (0, import_i18n17.__)("Variables", "elementor"),
|
|
1240
1408
|
content: ({ close: closePopover }) => {
|
|
1241
|
-
return /* @__PURE__ */
|
|
1409
|
+
return /* @__PURE__ */ React20.createElement(VariableSelectionPopover, { closePopover, propTypeKey: colorVariablePropTypeUtil.key });
|
|
1242
1410
|
}
|
|
1243
1411
|
};
|
|
1244
1412
|
};
|
|
1245
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
|
+
|
|
1246
1462
|
// src/transformers/variable-transformer.ts
|
|
1247
1463
|
var import_editor_canvas = require("@elementor/editor-canvas");
|
|
1248
1464
|
var variableTransformer = (0, import_editor_canvas.createTransformer)((value) => {
|
|
@@ -1253,17 +1469,9 @@ var variableTransformer = (0, import_editor_canvas.createTransformer)((value) =>
|
|
|
1253
1469
|
});
|
|
1254
1470
|
|
|
1255
1471
|
// src/init-color-variables.ts
|
|
1256
|
-
var { registerPopoverAction } =
|
|
1257
|
-
|
|
1258
|
-
|
|
1259
|
-
return hasAssignedColorVariable(import_editor_props4.backgroundColorOverlayPropTypeUtil.extract(prop)?.color);
|
|
1260
|
-
},
|
|
1261
|
-
boxShadow: ({ value: prop }) => {
|
|
1262
|
-
return hasAssignedColorVariable(import_editor_props4.shadowPropTypeUtil.extract(prop)?.color);
|
|
1263
|
-
}
|
|
1264
|
-
};
|
|
1265
|
-
function registerControlsAndActions() {
|
|
1266
|
-
(0, import_editor_editing_panel7.registerControlReplacement)({
|
|
1472
|
+
var { registerPopoverAction } = import_editor_editing_panel9.controlActionsMenu;
|
|
1473
|
+
function initColorVariables() {
|
|
1474
|
+
(0, import_editor_editing_panel9.registerControlReplacement)({
|
|
1267
1475
|
component: ColorVariableControl,
|
|
1268
1476
|
condition: ({ value }) => hasAssignedColorVariable(value)
|
|
1269
1477
|
});
|
|
@@ -1271,116 +1479,60 @@ function registerControlsAndActions() {
|
|
|
1271
1479
|
id: "color-variables",
|
|
1272
1480
|
useProps: usePropColorVariableAction
|
|
1273
1481
|
});
|
|
1274
|
-
}
|
|
1275
|
-
function registerRepeaterItemIcons() {
|
|
1276
|
-
(0, import_editor_controls8.injectIntoRepeaterItemIcon)({
|
|
1277
|
-
id: "color-variables-background-icon",
|
|
1278
|
-
component: BackgroundRepeaterColorIndicator,
|
|
1279
|
-
condition: conditions.backgroundOverlay
|
|
1280
|
-
});
|
|
1281
|
-
(0, import_editor_controls8.injectIntoRepeaterItemIcon)({
|
|
1282
|
-
id: "color-variables-icon",
|
|
1283
|
-
component: BoxShadowRepeaterColorIndicator,
|
|
1284
|
-
condition: conditions.boxShadow
|
|
1285
|
-
});
|
|
1286
|
-
}
|
|
1287
|
-
function registerRepeaterItemLabels() {
|
|
1288
|
-
(0, import_editor_controls8.injectIntoRepeaterItemLabel)({
|
|
1289
|
-
id: "color-variables-label",
|
|
1290
|
-
component: BackgroundRepeaterLabel,
|
|
1291
|
-
condition: conditions.backgroundOverlay
|
|
1292
|
-
});
|
|
1293
|
-
}
|
|
1294
|
-
function registerStyleTransformers() {
|
|
1295
1482
|
import_editor_canvas2.styleTransformersRegistry.register(colorVariablePropTypeUtil.key, variableTransformer);
|
|
1296
|
-
|
|
1297
|
-
function initColorVariables() {
|
|
1298
|
-
registerControlsAndActions();
|
|
1299
|
-
registerRepeaterItemIcons();
|
|
1300
|
-
registerRepeaterItemLabels();
|
|
1301
|
-
registerStyleTransformers();
|
|
1483
|
+
registerRepeaterInjections();
|
|
1302
1484
|
}
|
|
1303
1485
|
|
|
1304
1486
|
// src/init-font-variables.ts
|
|
1305
1487
|
var import_editor_canvas3 = require("@elementor/editor-canvas");
|
|
1306
|
-
var
|
|
1488
|
+
var import_editor_editing_panel11 = require("@elementor/editor-editing-panel");
|
|
1307
1489
|
|
|
1308
1490
|
// src/controls/font-variable-control.tsx
|
|
1309
|
-
var
|
|
1310
|
-
var
|
|
1311
|
-
var import_editor_controls9 = require("@elementor/editor-controls");
|
|
1491
|
+
var React22 = __toESM(require("react"));
|
|
1492
|
+
var import_editor_controls11 = require("@elementor/editor-controls");
|
|
1312
1493
|
var import_editor_props5 = require("@elementor/editor-props");
|
|
1313
|
-
var import_icons11 = require("@elementor/icons");
|
|
1314
|
-
var import_ui15 = require("@elementor/ui");
|
|
1315
1494
|
var FontVariableControl = () => {
|
|
1316
|
-
const {
|
|
1317
|
-
const
|
|
1318
|
-
|
|
1319
|
-
const popupId = (0, import_react11.useId)();
|
|
1320
|
-
const popupState = (0, import_ui15.usePopupState)({
|
|
1321
|
-
variant: "popover",
|
|
1322
|
-
popupId: `elementor-variables-list-${popupId}`
|
|
1323
|
-
});
|
|
1324
|
-
const selectedVariable = useVariable(variableValue);
|
|
1325
|
-
if (!selectedVariable) {
|
|
1495
|
+
const { value: variableValue } = (0, import_editor_controls11.useBoundProp)(fontVariablePropTypeUtil);
|
|
1496
|
+
const assignedVariable = useVariable(variableValue);
|
|
1497
|
+
if (!assignedVariable) {
|
|
1326
1498
|
throw new Error(`Global font variable ${variableValue} not found`);
|
|
1327
1499
|
}
|
|
1328
|
-
const
|
|
1329
|
-
|
|
1330
|
-
|
|
1331
|
-
|
|
1332
|
-
|
|
1500
|
+
const isVariableDeleted = assignedVariable?.deleted;
|
|
1501
|
+
if (isVariableDeleted) {
|
|
1502
|
+
return /* @__PURE__ */ React22.createElement(DeletedVariable, { variable: assignedVariable });
|
|
1503
|
+
}
|
|
1504
|
+
return /* @__PURE__ */ React22.createElement(
|
|
1505
|
+
AssignedVariable,
|
|
1333
1506
|
{
|
|
1334
|
-
|
|
1335
|
-
|
|
1336
|
-
|
|
1337
|
-
...(0, import_ui15.bindTrigger)(popupState)
|
|
1507
|
+
variable: assignedVariable,
|
|
1508
|
+
variablePropTypeUtil: fontVariablePropTypeUtil,
|
|
1509
|
+
fallbackPropTypeUtil: import_editor_props5.stringPropTypeUtil
|
|
1338
1510
|
}
|
|
1339
|
-
)
|
|
1340
|
-
import_ui15.Popover,
|
|
1341
|
-
{
|
|
1342
|
-
disableScrollLock: true,
|
|
1343
|
-
anchorEl: anchorRef.current,
|
|
1344
|
-
anchorOrigin: { vertical: "bottom", horizontal: "right" },
|
|
1345
|
-
transformOrigin: { vertical: "top", horizontal: "right" },
|
|
1346
|
-
PaperProps: {
|
|
1347
|
-
sx: { my: 1 }
|
|
1348
|
-
},
|
|
1349
|
-
...(0, import_ui15.bindPopover)(popupState)
|
|
1350
|
-
},
|
|
1351
|
-
/* @__PURE__ */ React15.createElement(
|
|
1352
|
-
VariableSelectionPopover,
|
|
1353
|
-
{
|
|
1354
|
-
selectedVariable,
|
|
1355
|
-
closePopover: popupState.close,
|
|
1356
|
-
propTypeKey: fontVariablePropTypeUtil.key
|
|
1357
|
-
}
|
|
1358
|
-
)
|
|
1359
|
-
));
|
|
1511
|
+
);
|
|
1360
1512
|
};
|
|
1361
1513
|
|
|
1362
1514
|
// src/hooks/use-prop-font-variable-action.tsx
|
|
1363
|
-
var
|
|
1364
|
-
var
|
|
1365
|
-
var
|
|
1366
|
-
var
|
|
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");
|
|
1367
1519
|
var usePropFontVariableAction = () => {
|
|
1368
|
-
const { propType } = (0,
|
|
1520
|
+
const { propType } = (0, import_editor_editing_panel10.useBoundProp)();
|
|
1369
1521
|
const visible = !!propType && supportsFontVariables(propType);
|
|
1370
1522
|
return {
|
|
1371
1523
|
visible,
|
|
1372
|
-
icon:
|
|
1373
|
-
title: (0,
|
|
1524
|
+
icon: import_icons14.ColorFilterIcon,
|
|
1525
|
+
title: (0, import_i18n18.__)("Variables", "elementor"),
|
|
1374
1526
|
content: ({ close: closePopover }) => {
|
|
1375
|
-
return /* @__PURE__ */
|
|
1527
|
+
return /* @__PURE__ */ React23.createElement(VariableSelectionPopover, { closePopover, propTypeKey: fontVariablePropTypeUtil.key });
|
|
1376
1528
|
}
|
|
1377
1529
|
};
|
|
1378
1530
|
};
|
|
1379
1531
|
|
|
1380
1532
|
// src/init-font-variables.ts
|
|
1381
|
-
var { registerPopoverAction: registerPopoverAction2 } =
|
|
1533
|
+
var { registerPopoverAction: registerPopoverAction2 } = import_editor_editing_panel11.controlActionsMenu;
|
|
1382
1534
|
function initFontVariables() {
|
|
1383
|
-
(0,
|
|
1535
|
+
(0, import_editor_editing_panel11.registerControlReplacement)({
|
|
1384
1536
|
component: FontVariableControl,
|
|
1385
1537
|
condition: ({ value }) => hasAssignedFontVariable(value)
|
|
1386
1538
|
});
|
|
@@ -1392,10 +1544,10 @@ function initFontVariables() {
|
|
|
1392
1544
|
}
|
|
1393
1545
|
|
|
1394
1546
|
// src/renderers/style-variables-renderer.tsx
|
|
1395
|
-
var
|
|
1396
|
-
var
|
|
1397
|
-
var
|
|
1398
|
-
var
|
|
1547
|
+
var React24 = __toESM(require("react"));
|
|
1548
|
+
var import_react15 = require("react");
|
|
1549
|
+
var import_editor_v1_adapters = require("@elementor/editor-v1-adapters");
|
|
1550
|
+
var import_ui21 = require("@elementor/ui");
|
|
1399
1551
|
|
|
1400
1552
|
// src/sync/get-canvas-iframe-document.ts
|
|
1401
1553
|
function getCanvasIframeDocument() {
|
|
@@ -1414,14 +1566,14 @@ function StyleVariablesRenderer() {
|
|
|
1414
1566
|
}
|
|
1415
1567
|
const cssVariables = convertToCssVariables(styleVariables);
|
|
1416
1568
|
const wrappedCss = `${VARIABLES_WRAPPER}{${cssVariables}}`;
|
|
1417
|
-
return /* @__PURE__ */
|
|
1569
|
+
return /* @__PURE__ */ React24.createElement(import_ui21.Portal, { container }, /* @__PURE__ */ React24.createElement("style", { "data-e-style-id": "e-variables", key: wrappedCss }, wrappedCss));
|
|
1418
1570
|
}
|
|
1419
1571
|
function usePortalContainer() {
|
|
1420
|
-
return (0,
|
|
1572
|
+
return (0, import_editor_v1_adapters.__privateUseListenTo)((0, import_editor_v1_adapters.commandEndEvent)("editor/documents/attach-preview"), () => getCanvasIframeDocument()?.head);
|
|
1421
1573
|
}
|
|
1422
1574
|
function useStyleVariables() {
|
|
1423
|
-
const [variables, setVariables] = (0,
|
|
1424
|
-
(0,
|
|
1575
|
+
const [variables, setVariables] = (0, import_react15.useState)({});
|
|
1576
|
+
(0, import_react15.useEffect)(() => {
|
|
1425
1577
|
const unsubscribe = styleVariablesRepository.subscribe(setVariables);
|
|
1426
1578
|
return () => {
|
|
1427
1579
|
unsubscribe();
|