@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.mjs
CHANGED
|
@@ -3,12 +3,51 @@ import { injectIntoTop } from "@elementor/editor";
|
|
|
3
3
|
|
|
4
4
|
// src/init-color-variables.ts
|
|
5
5
|
import { styleTransformersRegistry } from "@elementor/editor-canvas";
|
|
6
|
-
import { injectIntoRepeaterItemIcon, injectIntoRepeaterItemLabel } from "@elementor/editor-controls";
|
|
7
6
|
import { controlActionsMenu, registerControlReplacement } from "@elementor/editor-editing-panel";
|
|
8
|
-
import { backgroundColorOverlayPropTypeUtil, shadowPropTypeUtil } from "@elementor/editor-props";
|
|
9
7
|
|
|
10
|
-
// src/
|
|
11
|
-
import * as
|
|
8
|
+
// src/controls/color-variable-control.tsx
|
|
9
|
+
import * as React19 from "react";
|
|
10
|
+
import { useBoundProp as useBoundProp8 } from "@elementor/editor-controls";
|
|
11
|
+
import { colorPropTypeUtil } from "@elementor/editor-props";
|
|
12
|
+
|
|
13
|
+
// src/components/ui/color-indicator.tsx
|
|
14
|
+
import { styled, UnstableColorIndicator } from "@elementor/ui";
|
|
15
|
+
var ColorIndicator = styled(UnstableColorIndicator)(({ theme }) => ({
|
|
16
|
+
borderRadius: `${theme.shape.borderRadius / 2}px`,
|
|
17
|
+
marginRight: theme.spacing(0.25)
|
|
18
|
+
}));
|
|
19
|
+
|
|
20
|
+
// src/components/ui/variable/assigned-variable.tsx
|
|
21
|
+
import { useId as useId2, useRef as useRef4 } from "react";
|
|
22
|
+
import * as React16 from "react";
|
|
23
|
+
import { useBoundProp as useBoundProp7 } from "@elementor/editor-controls";
|
|
24
|
+
import { ColorFilterIcon as ColorFilterIcon3 } from "@elementor/icons";
|
|
25
|
+
import { bindPopover as bindPopover2, bindTrigger as bindTrigger2, Box as Box4, Popover as Popover2, usePopupState as usePopupState2 } from "@elementor/ui";
|
|
26
|
+
|
|
27
|
+
// src/components/variable-selection-popover.tsx
|
|
28
|
+
import * as React14 from "react";
|
|
29
|
+
import { useRef as useRef3, useState as useState10 } from "react";
|
|
30
|
+
import { Box as Box2 } from "@elementor/ui";
|
|
31
|
+
|
|
32
|
+
// src/prop-types/color-variable-prop-type.ts
|
|
33
|
+
import { createPropUtils } from "@elementor/editor-props";
|
|
34
|
+
import { z } from "@elementor/schema";
|
|
35
|
+
var colorVariablePropTypeUtil = createPropUtils("global-color-variable", z.string());
|
|
36
|
+
|
|
37
|
+
// src/prop-types/font-variable-prop-type.ts
|
|
38
|
+
import { createPropUtils as createPropUtils2 } from "@elementor/editor-props";
|
|
39
|
+
import { z as z2 } from "@elementor/schema";
|
|
40
|
+
var fontVariablePropTypeUtil = createPropUtils2("global-font-variable", z2.string());
|
|
41
|
+
|
|
42
|
+
// src/components/color-variable-creation.tsx
|
|
43
|
+
import * as React3 from "react";
|
|
44
|
+
import { useState as useState3 } from "react";
|
|
45
|
+
import { PopoverContent, useBoundProp } from "@elementor/editor-controls";
|
|
46
|
+
import { PopoverScrollableContent } from "@elementor/editor-editing-panel";
|
|
47
|
+
import { PopoverHeader } from "@elementor/editor-ui";
|
|
48
|
+
import { ArrowLeftIcon, BrushIcon } from "@elementor/icons";
|
|
49
|
+
import { Button, CardActions, Divider, IconButton } from "@elementor/ui";
|
|
50
|
+
import { __ as __4 } from "@wordpress/i18n";
|
|
12
51
|
|
|
13
52
|
// src/hooks/use-prop-variables.ts
|
|
14
53
|
import { useMemo } from "react";
|
|
@@ -303,99 +342,46 @@ var deleteVariable = (deleteId) => {
|
|
|
303
342
|
});
|
|
304
343
|
};
|
|
305
344
|
|
|
306
|
-
// src/components/
|
|
307
|
-
import
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
}));
|
|
345
|
+
// src/components/fields/color-field.tsx
|
|
346
|
+
import * as React from "react";
|
|
347
|
+
import { useRef, useState } from "react";
|
|
348
|
+
import { FormHelperText, FormLabel, Grid, UnstableColorField } from "@elementor/ui";
|
|
349
|
+
import { __ as __2 } from "@wordpress/i18n";
|
|
312
350
|
|
|
313
|
-
// src/
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
351
|
+
// src/utils/validations.ts
|
|
352
|
+
import { __ } from "@wordpress/i18n";
|
|
353
|
+
var VARIABLE_LABEL_MAX_LENGTH = 50;
|
|
354
|
+
var validateLabel = (name) => {
|
|
355
|
+
if (!name.trim()) {
|
|
356
|
+
return __("Missing variable name.", "elementor");
|
|
357
|
+
}
|
|
358
|
+
const allowedChars = /^[a-zA-Z0-9_-]+$/;
|
|
359
|
+
if (!allowedChars.test(name)) {
|
|
360
|
+
return __("Names can only use letters, numbers, dashes (-) and underscores (_).", "elementor");
|
|
361
|
+
}
|
|
362
|
+
const hasAlphanumeric = /[a-zA-Z0-9]/;
|
|
363
|
+
if (!hasAlphanumeric.test(name)) {
|
|
364
|
+
return __("Names have to include at least one non-special character.", "elementor");
|
|
365
|
+
}
|
|
366
|
+
if (VARIABLE_LABEL_MAX_LENGTH < name.length) {
|
|
367
|
+
return __("Variable names can contain up to 50 characters.", "elementor");
|
|
368
|
+
}
|
|
369
|
+
return "";
|
|
325
370
|
};
|
|
326
|
-
var
|
|
327
|
-
const
|
|
328
|
-
|
|
371
|
+
var labelHint = (name) => {
|
|
372
|
+
const hintThreshold = VARIABLE_LABEL_MAX_LENGTH * 0.8 - 1;
|
|
373
|
+
if (hintThreshold < name.length) {
|
|
374
|
+
return __("Variable names can contain up to 50 characters.", "elementor");
|
|
375
|
+
}
|
|
376
|
+
return "";
|
|
329
377
|
};
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
import { useId as useId2, useRef as useRef6 } from "react";
|
|
334
|
-
import { useBoundProp as useBoundProp5 } from "@elementor/editor-controls";
|
|
335
|
-
import { colorPropTypeUtil } from "@elementor/editor-props";
|
|
336
|
-
import { ColorFilterIcon as ColorFilterIcon3 } from "@elementor/icons";
|
|
337
|
-
import { bindPopover as bindPopover3, bindTrigger as bindTrigger3, Box as Box4, Popover as Popover3, usePopupState as usePopupState3 } from "@elementor/ui";
|
|
338
|
-
|
|
339
|
-
// src/components/ui/variable-tag.tsx
|
|
340
|
-
import * as React2 from "react";
|
|
341
|
-
import { DetachIcon } from "@elementor/icons";
|
|
342
|
-
import { Box, IconButton, Stack, Typography, UnstableTag as Tag } from "@elementor/ui";
|
|
343
|
-
import { __ } from "@wordpress/i18n";
|
|
344
|
-
var SIZE = "tiny";
|
|
345
|
-
var VariableTag = ({ startIcon, label, onUnlink, ...props }) => {
|
|
346
|
-
const actions = [];
|
|
347
|
-
if (onUnlink) {
|
|
348
|
-
actions.push(
|
|
349
|
-
/* @__PURE__ */ React2.createElement(IconButton, { key: "unlink", size: SIZE, onClick: onUnlink, "aria-label": __("Unlink", "elementor") }, /* @__PURE__ */ React2.createElement(DetachIcon, { fontSize: SIZE }))
|
|
350
|
-
);
|
|
378
|
+
var validateValue = (value) => {
|
|
379
|
+
if (!value.trim()) {
|
|
380
|
+
return __("Missing variable value.", "elementor");
|
|
351
381
|
}
|
|
352
|
-
return
|
|
353
|
-
Tag,
|
|
354
|
-
{
|
|
355
|
-
fullWidth: true,
|
|
356
|
-
showActionsOnHover: true,
|
|
357
|
-
startIcon: /* @__PURE__ */ React2.createElement(Stack, { gap: 0.5, direction: "row", alignItems: "center" }, startIcon),
|
|
358
|
-
label: /* @__PURE__ */ React2.createElement(Box, { sx: { display: "inline-grid", minWidth: 0 } }, /* @__PURE__ */ React2.createElement(Typography, { sx: { lineHeight: 1.34 }, variant: "caption", noWrap: true }, label)),
|
|
359
|
-
actions,
|
|
360
|
-
...props
|
|
361
|
-
}
|
|
362
|
-
);
|
|
382
|
+
return "";
|
|
363
383
|
};
|
|
364
384
|
|
|
365
|
-
// src/components/variable-selection-popover.tsx
|
|
366
|
-
import * as React12 from "react";
|
|
367
|
-
import { useRef as useRef5, useState as useState7 } from "react";
|
|
368
|
-
import { Box as Box3 } from "@elementor/ui";
|
|
369
|
-
|
|
370
|
-
// src/prop-types/color-variable-prop-type.ts
|
|
371
|
-
import { createPropUtils } from "@elementor/editor-props";
|
|
372
|
-
import { z } from "@elementor/schema";
|
|
373
|
-
var colorVariablePropTypeUtil = createPropUtils("global-color-variable", z.string());
|
|
374
|
-
|
|
375
|
-
// src/prop-types/font-variable-prop-type.ts
|
|
376
|
-
import { createPropUtils as createPropUtils2 } from "@elementor/editor-props";
|
|
377
|
-
import { z as z2 } from "@elementor/schema";
|
|
378
|
-
var fontVariablePropTypeUtil = createPropUtils2("global-font-variable", z2.string());
|
|
379
|
-
|
|
380
|
-
// src/components/color-variable-creation.tsx
|
|
381
|
-
import * as React3 from "react";
|
|
382
|
-
import { useRef, useState } from "react";
|
|
383
|
-
import { PopoverContent, useBoundProp } from "@elementor/editor-controls";
|
|
384
|
-
import { PopoverScrollableContent } from "@elementor/editor-editing-panel";
|
|
385
|
-
import { PopoverHeader } from "@elementor/editor-ui";
|
|
386
|
-
import { ArrowLeftIcon, BrushIcon } from "@elementor/icons";
|
|
387
|
-
import {
|
|
388
|
-
Button,
|
|
389
|
-
CardActions,
|
|
390
|
-
Divider,
|
|
391
|
-
FormLabel,
|
|
392
|
-
Grid,
|
|
393
|
-
IconButton as IconButton2,
|
|
394
|
-
TextField,
|
|
395
|
-
UnstableColorField
|
|
396
|
-
} from "@elementor/ui";
|
|
397
|
-
import { __ as __2 } from "@wordpress/i18n";
|
|
398
|
-
|
|
399
385
|
// src/components/variable-selection-popover.context.ts
|
|
400
386
|
import { createContext, useContext } from "react";
|
|
401
387
|
var PopoverContentRefContext = createContext(null);
|
|
@@ -403,14 +389,75 @@ var usePopoverContentRef = () => {
|
|
|
403
389
|
return useContext(PopoverContentRefContext);
|
|
404
390
|
};
|
|
405
391
|
|
|
392
|
+
// src/components/fields/color-field.tsx
|
|
393
|
+
var ColorField = ({ value, onChange }) => {
|
|
394
|
+
const [color, setColor] = useState(value);
|
|
395
|
+
const [errorMessage, setErrorMessage] = useState("");
|
|
396
|
+
const defaultRef = useRef(null);
|
|
397
|
+
const anchorRef = usePopoverContentRef() ?? defaultRef;
|
|
398
|
+
const handleChange = (newValue) => {
|
|
399
|
+
setColor(newValue);
|
|
400
|
+
const errorMsg = validateValue(newValue);
|
|
401
|
+
setErrorMessage(errorMsg);
|
|
402
|
+
onChange(errorMsg ? "" : newValue);
|
|
403
|
+
};
|
|
404
|
+
return /* @__PURE__ */ React.createElement(Grid, { container: true, gap: 0.75, alignItems: "center" }, /* @__PURE__ */ React.createElement(Grid, { item: true, xs: 12 }, /* @__PURE__ */ React.createElement(FormLabel, { size: "tiny" }, __2("Value", "elementor"))), /* @__PURE__ */ React.createElement(Grid, { item: true, xs: 12 }, /* @__PURE__ */ React.createElement(
|
|
405
|
+
UnstableColorField,
|
|
406
|
+
{
|
|
407
|
+
size: "tiny",
|
|
408
|
+
fullWidth: true,
|
|
409
|
+
value: color,
|
|
410
|
+
onChange: handleChange,
|
|
411
|
+
error: errorMessage ?? void 0,
|
|
412
|
+
slotProps: {
|
|
413
|
+
colorPicker: {
|
|
414
|
+
anchorEl: anchorRef.current,
|
|
415
|
+
anchorOrigin: { vertical: "top", horizontal: "right" },
|
|
416
|
+
transformOrigin: { vertical: "top", horizontal: -10 }
|
|
417
|
+
}
|
|
418
|
+
}
|
|
419
|
+
}
|
|
420
|
+
), errorMessage && /* @__PURE__ */ React.createElement(FormHelperText, { error: true }, errorMessage)));
|
|
421
|
+
};
|
|
422
|
+
|
|
423
|
+
// src/components/fields/label-field.tsx
|
|
424
|
+
import * as React2 from "react";
|
|
425
|
+
import { useId, useState as useState2 } from "react";
|
|
426
|
+
import { FormHelperText as FormHelperText2, FormLabel as FormLabel2, Grid as Grid2, TextField } from "@elementor/ui";
|
|
427
|
+
import { __ as __3 } from "@wordpress/i18n";
|
|
428
|
+
var LabelField = ({ value, onChange }) => {
|
|
429
|
+
const [label, setLabel] = useState2(value);
|
|
430
|
+
const [errorMessage, setErrorMessage] = useState2("");
|
|
431
|
+
const [noticeMessage, setNoticeMessage] = useState2(() => labelHint(value));
|
|
432
|
+
const handleChange = (newValue) => {
|
|
433
|
+
setLabel(newValue);
|
|
434
|
+
const errorMsg = validateLabel(newValue);
|
|
435
|
+
const hintMsg = labelHint(newValue);
|
|
436
|
+
setErrorMessage(errorMsg);
|
|
437
|
+
setNoticeMessage(errorMsg ? "" : hintMsg);
|
|
438
|
+
onChange(errorMsg ? "" : newValue);
|
|
439
|
+
};
|
|
440
|
+
const id = useId();
|
|
441
|
+
return /* @__PURE__ */ React2.createElement(Grid2, { container: true, gap: 0.75, alignItems: "center" }, /* @__PURE__ */ React2.createElement(Grid2, { item: true, xs: 12 }, /* @__PURE__ */ React2.createElement(FormLabel2, { htmlFor: id, size: "tiny" }, __3("Name", "elementor"))), /* @__PURE__ */ React2.createElement(Grid2, { item: true, xs: 12 }, /* @__PURE__ */ React2.createElement(
|
|
442
|
+
TextField,
|
|
443
|
+
{
|
|
444
|
+
id,
|
|
445
|
+
size: "tiny",
|
|
446
|
+
fullWidth: true,
|
|
447
|
+
value: label,
|
|
448
|
+
error: !!errorMessage,
|
|
449
|
+
onChange: (e) => handleChange(e.target.value),
|
|
450
|
+
inputProps: { maxLength: VARIABLE_LABEL_MAX_LENGTH }
|
|
451
|
+
}
|
|
452
|
+
), errorMessage && /* @__PURE__ */ React2.createElement(FormHelperText2, { error: true }, errorMessage), noticeMessage && /* @__PURE__ */ React2.createElement(FormHelperText2, null, noticeMessage)));
|
|
453
|
+
};
|
|
454
|
+
|
|
406
455
|
// src/components/color-variable-creation.tsx
|
|
407
|
-
var
|
|
456
|
+
var SIZE = "tiny";
|
|
408
457
|
var ColorVariableCreation = ({ onGoBack, onClose }) => {
|
|
409
458
|
const { setValue: setVariable } = useBoundProp(colorVariablePropTypeUtil);
|
|
410
|
-
const [color, setColor] =
|
|
411
|
-
const [label, setLabel] =
|
|
412
|
-
const defaultRef = useRef(null);
|
|
413
|
-
const anchorRef = usePopoverContentRef() ?? defaultRef;
|
|
459
|
+
const [color, setColor] = useState3("");
|
|
460
|
+
const [label, setLabel] = useState3("");
|
|
414
461
|
const resetFields = () => {
|
|
415
462
|
setColor("");
|
|
416
463
|
setLabel("");
|
|
@@ -429,146 +476,161 @@ var ColorVariableCreation = ({ onGoBack, onClose }) => {
|
|
|
429
476
|
closePopover();
|
|
430
477
|
});
|
|
431
478
|
};
|
|
432
|
-
const
|
|
433
|
-
return
|
|
479
|
+
const hasEmptyValue = () => {
|
|
480
|
+
return "" === color.trim() || "" === label.trim();
|
|
434
481
|
};
|
|
482
|
+
const isSubmitDisabled = hasEmptyValue();
|
|
435
483
|
return /* @__PURE__ */ React3.createElement(PopoverScrollableContent, { height: "auto" }, /* @__PURE__ */ React3.createElement(
|
|
436
484
|
PopoverHeader,
|
|
437
485
|
{
|
|
438
|
-
icon: /* @__PURE__ */ React3.createElement(React3.Fragment, null, onGoBack && /* @__PURE__ */ React3.createElement(
|
|
439
|
-
title:
|
|
486
|
+
icon: /* @__PURE__ */ React3.createElement(React3.Fragment, null, onGoBack && /* @__PURE__ */ React3.createElement(IconButton, { size: SIZE, "aria-label": __4("Go Back", "elementor"), onClick: onGoBack }, /* @__PURE__ */ React3.createElement(ArrowLeftIcon, { fontSize: SIZE })), /* @__PURE__ */ React3.createElement(BrushIcon, { fontSize: SIZE })),
|
|
487
|
+
title: __4("Create variable", "elementor"),
|
|
440
488
|
onClose: closePopover
|
|
441
489
|
}
|
|
442
|
-
), /* @__PURE__ */ React3.createElement(Divider, null), /* @__PURE__ */ React3.createElement(PopoverContent, { p: 2 }, /* @__PURE__ */ React3.createElement(
|
|
443
|
-
TextField,
|
|
444
|
-
{
|
|
445
|
-
size: "tiny",
|
|
446
|
-
fullWidth: true,
|
|
447
|
-
value: label,
|
|
448
|
-
onChange: (e) => setLabel(e.target.value)
|
|
449
|
-
}
|
|
450
|
-
))), /* @__PURE__ */ React3.createElement(Grid, { container: true, gap: 0.75, alignItems: "center" }, /* @__PURE__ */ React3.createElement(Grid, { item: true, xs: 12 }, /* @__PURE__ */ React3.createElement(FormLabel, { size: "tiny" }, __2("Value", "elementor"))), /* @__PURE__ */ React3.createElement(Grid, { item: true, xs: 12 }, /* @__PURE__ */ React3.createElement(
|
|
451
|
-
UnstableColorField,
|
|
452
|
-
{
|
|
453
|
-
size: "tiny",
|
|
454
|
-
fullWidth: true,
|
|
455
|
-
value: color,
|
|
456
|
-
onChange: setColor,
|
|
457
|
-
slotProps: {
|
|
458
|
-
colorPicker: {
|
|
459
|
-
anchorEl: anchorRef.current,
|
|
460
|
-
anchorOrigin: { vertical: "top", horizontal: "right" },
|
|
461
|
-
transformOrigin: { vertical: "top", horizontal: -10 }
|
|
462
|
-
}
|
|
463
|
-
}
|
|
464
|
-
}
|
|
465
|
-
)))), /* @__PURE__ */ React3.createElement(CardActions, { sx: { pt: 0.5, pb: 1 } }, /* @__PURE__ */ React3.createElement(Button, { size: "small", variant: "contained", disabled: isFormInvalid(), onClick: handleCreate }, __2("Create", "elementor"))));
|
|
490
|
+
), /* @__PURE__ */ React3.createElement(Divider, null), /* @__PURE__ */ React3.createElement(PopoverContent, { p: 2 }, /* @__PURE__ */ React3.createElement(LabelField, { value: label, onChange: setLabel }), /* @__PURE__ */ React3.createElement(ColorField, { value: color, onChange: setColor })), /* @__PURE__ */ React3.createElement(CardActions, { sx: { pt: 0.5, pb: 1 } }, /* @__PURE__ */ React3.createElement(Button, { size: "small", variant: "contained", disabled: isSubmitDisabled, onClick: handleCreate }, __4("Create", "elementor"))));
|
|
466
491
|
};
|
|
467
492
|
|
|
468
493
|
// src/components/color-variable-edit.tsx
|
|
469
|
-
import * as
|
|
470
|
-
import {
|
|
471
|
-
import { PopoverContent as PopoverContent2 } from "@elementor/editor-controls";
|
|
472
|
-
import {
|
|
494
|
+
import * as React5 from "react";
|
|
495
|
+
import { useState as useState4 } from "react";
|
|
496
|
+
import { PopoverContent as PopoverContent2, useBoundProp as useBoundProp2 } from "@elementor/editor-controls";
|
|
497
|
+
import { PopoverScrollableContent as PopoverScrollableContent2 } from "@elementor/editor-editing-panel";
|
|
498
|
+
import { PopoverHeader as PopoverHeader2 } from "@elementor/editor-ui";
|
|
473
499
|
import { ArrowLeftIcon as ArrowLeftIcon2, BrushIcon as BrushIcon2, TrashIcon } from "@elementor/icons";
|
|
500
|
+
import { Button as Button3, CardActions as CardActions2, Divider as Divider2, IconButton as IconButton2 } from "@elementor/ui";
|
|
501
|
+
import { __ as __6 } from "@wordpress/i18n";
|
|
502
|
+
|
|
503
|
+
// src/components/ui/delete-confirmation-dialog.tsx
|
|
504
|
+
import * as React4 from "react";
|
|
505
|
+
import { AlertOctagonFilledIcon } from "@elementor/icons";
|
|
474
506
|
import {
|
|
475
507
|
Button as Button2,
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
UnstableColorField as UnstableColorField2
|
|
508
|
+
Dialog,
|
|
509
|
+
DialogActions,
|
|
510
|
+
DialogContent,
|
|
511
|
+
DialogContentText,
|
|
512
|
+
DialogTitle,
|
|
513
|
+
Typography
|
|
483
514
|
} from "@elementor/ui";
|
|
484
|
-
import { __ as
|
|
485
|
-
var
|
|
515
|
+
import { __ as __5 } from "@wordpress/i18n";
|
|
516
|
+
var TITLE_ID = "delete-variable-dialog";
|
|
517
|
+
var DeleteConfirmationDialog = ({
|
|
518
|
+
open,
|
|
519
|
+
label,
|
|
520
|
+
closeDialog,
|
|
521
|
+
onConfirm
|
|
522
|
+
}) => {
|
|
523
|
+
return /* @__PURE__ */ React4.createElement(Dialog, { open, onClose: closeDialog, "aria-labelledby": TITLE_ID, maxWidth: "xs" }, /* @__PURE__ */ React4.createElement(DialogTitle, { id: TITLE_ID, display: "flex", alignItems: "center", gap: 1, sx: { lineHeight: 1 } }, /* @__PURE__ */ React4.createElement(AlertOctagonFilledIcon, { color: "error" }), __5("Delete Variable", "elementor")), /* @__PURE__ */ React4.createElement(DialogContent, null, /* @__PURE__ */ React4.createElement(DialogContentText, { variant: "body2", color: "textPrimary" }, __5("You are about to delete", "elementor"), /* @__PURE__ */ React4.createElement(Typography, { variant: "subtitle2", component: "span" }, "\xA0", label, "\xA0"), __5(
|
|
524
|
+
"Variable. Note that its value is still being used anywhere on your site where it was connected to the variable.",
|
|
525
|
+
"elementor"
|
|
526
|
+
))), /* @__PURE__ */ React4.createElement(DialogActions, null, /* @__PURE__ */ React4.createElement(Button2, { color: "secondary", onClick: closeDialog }, __5("Cancel", "elementor")), /* @__PURE__ */ React4.createElement(Button2, { variant: "contained", color: "error", onClick: onConfirm }, __5("Delete", "elementor"))));
|
|
527
|
+
};
|
|
528
|
+
|
|
529
|
+
// src/components/color-variable-edit.tsx
|
|
530
|
+
var SIZE2 = "tiny";
|
|
486
531
|
var ColorVariableEdit = ({ onClose, onGoBack, onSubmit, editId }) => {
|
|
532
|
+
const { setValue: notifyBoundPropChange, value: assignedValue } = useBoundProp2(colorVariablePropTypeUtil);
|
|
533
|
+
const [deleteConfirmation, setDeleteConfirmation] = useState4(false);
|
|
487
534
|
const variable = useVariable(editId);
|
|
488
535
|
if (!variable) {
|
|
489
536
|
throw new Error(`Global color variable not found`);
|
|
490
537
|
}
|
|
491
|
-
const
|
|
492
|
-
const
|
|
493
|
-
const [color, setColor] = useState2(variable.value);
|
|
494
|
-
const [label, setLabel] = useState2(variable.label);
|
|
538
|
+
const [color, setColor] = useState4(variable.value);
|
|
539
|
+
const [label, setLabel] = useState4(variable.label);
|
|
495
540
|
const handleUpdate = () => {
|
|
496
541
|
updateVariable(editId, {
|
|
497
542
|
value: color,
|
|
498
543
|
label
|
|
499
544
|
}).then(() => {
|
|
545
|
+
maybeTriggerBoundPropChange();
|
|
500
546
|
onSubmit?.();
|
|
501
547
|
});
|
|
502
548
|
};
|
|
503
549
|
const handleDelete = () => {
|
|
504
550
|
deleteVariable(editId).then(() => {
|
|
551
|
+
maybeTriggerBoundPropChange();
|
|
505
552
|
onSubmit?.();
|
|
506
553
|
});
|
|
507
554
|
};
|
|
508
|
-
const
|
|
509
|
-
|
|
510
|
-
|
|
555
|
+
const maybeTriggerBoundPropChange = () => {
|
|
556
|
+
if (editId === assignedValue) {
|
|
557
|
+
notifyBoundPropChange(editId);
|
|
558
|
+
}
|
|
559
|
+
};
|
|
560
|
+
const handleDeleteConfirmation = () => {
|
|
561
|
+
setDeleteConfirmation(true);
|
|
562
|
+
};
|
|
563
|
+
const closeDeleteDialog = () => () => {
|
|
564
|
+
setDeleteConfirmation(false);
|
|
565
|
+
};
|
|
511
566
|
const actions = [];
|
|
512
567
|
actions.push(
|
|
513
|
-
/* @__PURE__ */
|
|
568
|
+
/* @__PURE__ */ React5.createElement(
|
|
569
|
+
IconButton2,
|
|
570
|
+
{
|
|
571
|
+
key: "delete",
|
|
572
|
+
size: SIZE2,
|
|
573
|
+
"aria-label": __6("Delete", "elementor"),
|
|
574
|
+
onClick: handleDeleteConfirmation
|
|
575
|
+
},
|
|
576
|
+
/* @__PURE__ */ React5.createElement(TrashIcon, { fontSize: SIZE2 })
|
|
577
|
+
)
|
|
514
578
|
);
|
|
515
|
-
|
|
579
|
+
const hasEmptyValues = () => {
|
|
580
|
+
return !color.trim() || !label.trim();
|
|
581
|
+
};
|
|
582
|
+
const noValueChanged = () => {
|
|
583
|
+
return color === variable.value && label === variable.label;
|
|
584
|
+
};
|
|
585
|
+
const isSubmitDisabled = noValueChanged() || hasEmptyValues();
|
|
586
|
+
return /* @__PURE__ */ React5.createElement(React5.Fragment, null, /* @__PURE__ */ React5.createElement(PopoverScrollableContent2, { height: "auto" }, /* @__PURE__ */ React5.createElement(
|
|
516
587
|
PopoverHeader2,
|
|
517
588
|
{
|
|
518
|
-
title:
|
|
589
|
+
title: __6("Edit variable", "elementor"),
|
|
519
590
|
onClose,
|
|
520
|
-
icon: /* @__PURE__ */
|
|
591
|
+
icon: /* @__PURE__ */ React5.createElement(React5.Fragment, null, onGoBack && /* @__PURE__ */ React5.createElement(
|
|
592
|
+
IconButton2,
|
|
593
|
+
{
|
|
594
|
+
size: SIZE2,
|
|
595
|
+
"aria-label": __6("Go Back", "elementor"),
|
|
596
|
+
onClick: onGoBack
|
|
597
|
+
},
|
|
598
|
+
/* @__PURE__ */ React5.createElement(ArrowLeftIcon2, { fontSize: SIZE2 })
|
|
599
|
+
), /* @__PURE__ */ React5.createElement(BrushIcon2, { fontSize: SIZE2 })),
|
|
521
600
|
actions
|
|
522
601
|
}
|
|
523
|
-
), /* @__PURE__ */
|
|
524
|
-
|
|
525
|
-
{
|
|
526
|
-
size: "tiny",
|
|
527
|
-
fullWidth: true,
|
|
528
|
-
value: label,
|
|
529
|
-
onChange: (e) => setLabel(e.target.value)
|
|
530
|
-
}
|
|
531
|
-
))), /* @__PURE__ */ React4.createElement(Grid2, { container: true, gap: 0.75, alignItems: "center" }, /* @__PURE__ */ React4.createElement(Grid2, { item: true, xs: 12 }, /* @__PURE__ */ React4.createElement(FormLabel2, { size: "tiny" }, __3("Value", "elementor"))), /* @__PURE__ */ React4.createElement(Grid2, { item: true, xs: 12 }, /* @__PURE__ */ React4.createElement(
|
|
532
|
-
UnstableColorField2,
|
|
602
|
+
), /* @__PURE__ */ React5.createElement(Divider2, null), /* @__PURE__ */ React5.createElement(PopoverContent2, { p: 2 }, /* @__PURE__ */ React5.createElement(LabelField, { value: label, onChange: setLabel }), /* @__PURE__ */ React5.createElement(ColorField, { value: color, onChange: setColor })), /* @__PURE__ */ React5.createElement(CardActions2, { sx: { pt: 0.5, pb: 1 } }, /* @__PURE__ */ React5.createElement(Button3, { size: "small", variant: "contained", disabled: isSubmitDisabled, onClick: handleUpdate }, __6("Save", "elementor")))), deleteConfirmation && /* @__PURE__ */ React5.createElement(
|
|
603
|
+
DeleteConfirmationDialog,
|
|
533
604
|
{
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
slotProps: {
|
|
539
|
-
colorPicker: {
|
|
540
|
-
anchorEl: anchorRef.current,
|
|
541
|
-
anchorOrigin: { vertical: "top", horizontal: "right" },
|
|
542
|
-
transformOrigin: { vertical: "top", horizontal: -10 }
|
|
543
|
-
}
|
|
544
|
-
}
|
|
605
|
+
open: true,
|
|
606
|
+
label,
|
|
607
|
+
onConfirm: handleDelete,
|
|
608
|
+
closeDialog: closeDeleteDialog()
|
|
545
609
|
}
|
|
546
|
-
))
|
|
610
|
+
));
|
|
547
611
|
};
|
|
548
612
|
|
|
549
613
|
// src/components/color-variables-selection.tsx
|
|
550
|
-
import * as
|
|
551
|
-
import { useState as
|
|
552
|
-
import { useBoundProp as
|
|
614
|
+
import * as React9 from "react";
|
|
615
|
+
import { useState as useState5 } from "react";
|
|
616
|
+
import { useBoundProp as useBoundProp3 } from "@elementor/editor-controls";
|
|
553
617
|
import { PopoverScrollableContent as PopoverScrollableContent3 } from "@elementor/editor-editing-panel";
|
|
554
618
|
import { PopoverHeader as PopoverHeader3, PopoverMenuList, PopoverSearch } from "@elementor/editor-ui";
|
|
555
619
|
import { BrushIcon as BrushIcon3, ColorFilterIcon, PlusIcon, SettingsIcon } from "@elementor/icons";
|
|
556
|
-
import { Divider as Divider3, IconButton as
|
|
557
|
-
import { __ as
|
|
620
|
+
import { Divider as Divider3, IconButton as IconButton4 } from "@elementor/ui";
|
|
621
|
+
import { __ as __10 } from "@wordpress/i18n";
|
|
558
622
|
|
|
559
623
|
// src/components/ui/menu-item-content.tsx
|
|
560
|
-
import * as
|
|
624
|
+
import * as React6 from "react";
|
|
561
625
|
import { EllipsisWithTooltip } from "@elementor/editor-ui";
|
|
562
|
-
import { isExperimentActive } from "@elementor/editor-v1-adapters";
|
|
563
626
|
import { EditIcon } from "@elementor/icons";
|
|
564
|
-
import { Box
|
|
565
|
-
import { __ as
|
|
566
|
-
var
|
|
567
|
-
var isVersion330Active = isExperimentActive("e_v_3_30");
|
|
627
|
+
import { Box, IconButton as IconButton3, ListItemIcon, Typography as Typography2 } from "@elementor/ui";
|
|
628
|
+
import { __ as __7 } from "@wordpress/i18n";
|
|
629
|
+
var SIZE3 = "tiny";
|
|
568
630
|
var MenuItemContent = ({ item }) => {
|
|
569
631
|
const onEdit = item.onEdit;
|
|
570
|
-
return /* @__PURE__ */
|
|
571
|
-
|
|
632
|
+
return /* @__PURE__ */ React6.createElement(React6.Fragment, null, /* @__PURE__ */ React6.createElement(ListItemIcon, null, item.icon), /* @__PURE__ */ React6.createElement(
|
|
633
|
+
Box,
|
|
572
634
|
{
|
|
573
635
|
sx: {
|
|
574
636
|
flex: 1,
|
|
@@ -578,18 +640,18 @@ var MenuItemContent = ({ item }) => {
|
|
|
578
640
|
gap: 1
|
|
579
641
|
}
|
|
580
642
|
},
|
|
581
|
-
/* @__PURE__ */
|
|
643
|
+
/* @__PURE__ */ React6.createElement(
|
|
582
644
|
EllipsisWithTooltip,
|
|
583
645
|
{
|
|
584
646
|
title: item.label || item.value,
|
|
585
647
|
as: Typography2,
|
|
586
|
-
variant:
|
|
587
|
-
color:
|
|
648
|
+
variant: "caption",
|
|
649
|
+
color: "text.primary",
|
|
588
650
|
sx: { marginTop: "1px", lineHeight: "2" },
|
|
589
651
|
maxWidth: "50%"
|
|
590
652
|
}
|
|
591
653
|
),
|
|
592
|
-
item.secondaryText && /* @__PURE__ */
|
|
654
|
+
item.secondaryText && /* @__PURE__ */ React6.createElement(
|
|
593
655
|
EllipsisWithTooltip,
|
|
594
656
|
{
|
|
595
657
|
title: item.secondaryText,
|
|
@@ -600,27 +662,27 @@ var MenuItemContent = ({ item }) => {
|
|
|
600
662
|
maxWidth: "50%"
|
|
601
663
|
}
|
|
602
664
|
)
|
|
603
|
-
), !!onEdit && /* @__PURE__ */
|
|
604
|
-
|
|
665
|
+
), !!onEdit && /* @__PURE__ */ React6.createElement(
|
|
666
|
+
IconButton3,
|
|
605
667
|
{
|
|
606
668
|
sx: { mx: 1, opacity: "0" },
|
|
607
669
|
onClick: (e) => {
|
|
608
670
|
e.stopPropagation();
|
|
609
671
|
onEdit(item.value);
|
|
610
672
|
},
|
|
611
|
-
"aria-label":
|
|
673
|
+
"aria-label": __7("Edit", "elementor")
|
|
612
674
|
},
|
|
613
|
-
/* @__PURE__ */
|
|
675
|
+
/* @__PURE__ */ React6.createElement(EditIcon, { color: "action", fontSize: SIZE3 })
|
|
614
676
|
));
|
|
615
677
|
};
|
|
616
678
|
|
|
617
679
|
// src/components/ui/no-search-results.tsx
|
|
618
|
-
import * as
|
|
619
|
-
import { Link, Stack
|
|
620
|
-
import { __ as
|
|
680
|
+
import * as React7 from "react";
|
|
681
|
+
import { Link, Stack, Typography as Typography3 } from "@elementor/ui";
|
|
682
|
+
import { __ as __8 } from "@wordpress/i18n";
|
|
621
683
|
var NoSearchResults = ({ searchValue, onClear, icon }) => {
|
|
622
|
-
return /* @__PURE__ */
|
|
623
|
-
|
|
684
|
+
return /* @__PURE__ */ React7.createElement(
|
|
685
|
+
Stack,
|
|
624
686
|
{
|
|
625
687
|
gap: 1,
|
|
626
688
|
alignItems: "center",
|
|
@@ -631,17 +693,17 @@ var NoSearchResults = ({ searchValue, onClear, icon }) => {
|
|
|
631
693
|
sx: { pb: 3.5 }
|
|
632
694
|
},
|
|
633
695
|
icon,
|
|
634
|
-
/* @__PURE__ */
|
|
635
|
-
/* @__PURE__ */
|
|
696
|
+
/* @__PURE__ */ React7.createElement(Typography3, { align: "center", variant: "subtitle2" }, __8("Sorry, nothing matched", "elementor"), /* @__PURE__ */ React7.createElement("br", null), "\u201C", searchValue, "\u201D."),
|
|
697
|
+
/* @__PURE__ */ React7.createElement(Typography3, { align: "center", variant: "caption", sx: { display: "flex", flexDirection: "column" } }, __8("Try something else.", "elementor"), /* @__PURE__ */ React7.createElement(Link, { color: "text.secondary", variant: "caption", component: "button", onClick: onClear }, __8("Clear & try again", "elementor")))
|
|
636
698
|
);
|
|
637
699
|
};
|
|
638
700
|
|
|
639
701
|
// src/components/ui/no-variables.tsx
|
|
640
|
-
import * as
|
|
641
|
-
import { Button as
|
|
642
|
-
import { __ as
|
|
643
|
-
var NoVariables = ({ icon, title, onAdd }) => /* @__PURE__ */
|
|
644
|
-
|
|
702
|
+
import * as React8 from "react";
|
|
703
|
+
import { Button as Button4, Stack as Stack2, Typography as Typography4 } from "@elementor/ui";
|
|
704
|
+
import { __ as __9 } from "@wordpress/i18n";
|
|
705
|
+
var NoVariables = ({ icon, title, onAdd }) => /* @__PURE__ */ React8.createElement(
|
|
706
|
+
Stack2,
|
|
645
707
|
{
|
|
646
708
|
gap: 1,
|
|
647
709
|
alignItems: "center",
|
|
@@ -651,9 +713,9 @@ var NoVariables = ({ icon, title, onAdd }) => /* @__PURE__ */ React7.createEleme
|
|
|
651
713
|
sx: { p: 2.5, pb: 5.5 }
|
|
652
714
|
},
|
|
653
715
|
icon,
|
|
654
|
-
/* @__PURE__ */
|
|
655
|
-
/* @__PURE__ */
|
|
656
|
-
onAdd && /* @__PURE__ */
|
|
716
|
+
/* @__PURE__ */ React8.createElement(Typography4, { align: "center", variant: "subtitle2" }, title),
|
|
717
|
+
/* @__PURE__ */ React8.createElement(Typography4, { align: "center", variant: "caption", maxWidth: "180px" }, __9("Variables are saved attributes that you can apply anywhere on your site.", "elementor")),
|
|
718
|
+
onAdd && /* @__PURE__ */ React8.createElement(Button4, { variant: "outlined", color: "secondary", size: "small", onClick: onAdd }, __9("Create a variable", "elementor"))
|
|
657
719
|
);
|
|
658
720
|
|
|
659
721
|
// src/components/ui/styled-menu-list.tsx
|
|
@@ -689,10 +751,10 @@ var VariablesStyledMenuList = styled2(MenuList)(({ theme }) => ({
|
|
|
689
751
|
}));
|
|
690
752
|
|
|
691
753
|
// src/components/color-variables-selection.tsx
|
|
692
|
-
var
|
|
754
|
+
var SIZE4 = "tiny";
|
|
693
755
|
var ColorVariablesSelection = ({ closePopover, onAdd, onEdit, onSettings }) => {
|
|
694
|
-
const { value: variable, setValue: setVariable } =
|
|
695
|
-
const [searchValue, setSearchValue] =
|
|
756
|
+
const { value: variable, setValue: setVariable } = useBoundProp3(colorVariablePropTypeUtil);
|
|
757
|
+
const [searchValue, setSearchValue] = useState5("");
|
|
696
758
|
const {
|
|
697
759
|
list: variables,
|
|
698
760
|
hasMatches: hasSearchResults,
|
|
@@ -705,19 +767,19 @@ var ColorVariablesSelection = ({ closePopover, onAdd, onEdit, onSettings }) => {
|
|
|
705
767
|
const actions = [];
|
|
706
768
|
if (onAdd) {
|
|
707
769
|
actions.push(
|
|
708
|
-
/* @__PURE__ */
|
|
770
|
+
/* @__PURE__ */ React9.createElement(IconButton4, { key: "add", size: SIZE4, onClick: onAdd }, /* @__PURE__ */ React9.createElement(PlusIcon, { fontSize: SIZE4 }))
|
|
709
771
|
);
|
|
710
772
|
}
|
|
711
773
|
if (onSettings) {
|
|
712
774
|
actions.push(
|
|
713
|
-
/* @__PURE__ */
|
|
775
|
+
/* @__PURE__ */ React9.createElement(IconButton4, { key: "settings", size: SIZE4, onClick: onSettings }, /* @__PURE__ */ React9.createElement(SettingsIcon, { fontSize: SIZE4 }))
|
|
714
776
|
);
|
|
715
777
|
}
|
|
716
778
|
const items = variables.map(({ value, label, key }) => ({
|
|
717
779
|
type: "item",
|
|
718
780
|
value: key,
|
|
719
781
|
label,
|
|
720
|
-
icon: /* @__PURE__ */
|
|
782
|
+
icon: /* @__PURE__ */ React9.createElement(ColorIndicator, { size: "inherit", component: "span", value }),
|
|
721
783
|
secondaryText: value,
|
|
722
784
|
onEdit: () => onEdit?.(key)
|
|
723
785
|
}));
|
|
@@ -727,22 +789,22 @@ var ColorVariablesSelection = ({ closePopover, onAdd, onEdit, onSettings }) => {
|
|
|
727
789
|
const handleClearSearch = () => {
|
|
728
790
|
setSearchValue("");
|
|
729
791
|
};
|
|
730
|
-
return /* @__PURE__ */
|
|
792
|
+
return /* @__PURE__ */ React9.createElement(React9.Fragment, null, /* @__PURE__ */ React9.createElement(
|
|
731
793
|
PopoverHeader3,
|
|
732
794
|
{
|
|
733
|
-
title:
|
|
734
|
-
icon: /* @__PURE__ */
|
|
795
|
+
title: __10("Variables", "elementor"),
|
|
796
|
+
icon: /* @__PURE__ */ React9.createElement(ColorFilterIcon, { fontSize: SIZE4 }),
|
|
735
797
|
onClose: closePopover,
|
|
736
798
|
actions
|
|
737
799
|
}
|
|
738
|
-
), hasVariables && /* @__PURE__ */
|
|
800
|
+
), hasVariables && /* @__PURE__ */ React9.createElement(
|
|
739
801
|
PopoverSearch,
|
|
740
802
|
{
|
|
741
803
|
value: searchValue,
|
|
742
804
|
onSearch: handleSearch,
|
|
743
|
-
placeholder:
|
|
805
|
+
placeholder: __10("Search", "elementor")
|
|
744
806
|
}
|
|
745
|
-
), /* @__PURE__ */
|
|
807
|
+
), /* @__PURE__ */ React9.createElement(Divider3, null), /* @__PURE__ */ React9.createElement(PopoverScrollableContent3, null, hasVariables && hasSearchResults && /* @__PURE__ */ React9.createElement(
|
|
746
808
|
PopoverMenuList,
|
|
747
809
|
{
|
|
748
810
|
items,
|
|
@@ -752,102 +814,80 @@ var ColorVariablesSelection = ({ closePopover, onAdd, onEdit, onSettings }) => {
|
|
|
752
814
|
selectedValue: variable,
|
|
753
815
|
"data-testid": "color-variables-list",
|
|
754
816
|
menuListTemplate: VariablesStyledMenuList,
|
|
755
|
-
menuItemContentTemplate: (item) => /* @__PURE__ */
|
|
817
|
+
menuItemContentTemplate: (item) => /* @__PURE__ */ React9.createElement(MenuItemContent, { item })
|
|
756
818
|
}
|
|
757
|
-
), !hasSearchResults && hasVariables && /* @__PURE__ */
|
|
819
|
+
), !hasSearchResults && hasVariables && /* @__PURE__ */ React9.createElement(
|
|
758
820
|
NoSearchResults,
|
|
759
821
|
{
|
|
760
822
|
searchValue,
|
|
761
823
|
onClear: handleClearSearch,
|
|
762
|
-
icon: /* @__PURE__ */
|
|
824
|
+
icon: /* @__PURE__ */ React9.createElement(BrushIcon3, { fontSize: "large" })
|
|
763
825
|
}
|
|
764
|
-
), !hasVariables && /* @__PURE__ */
|
|
826
|
+
), !hasVariables && /* @__PURE__ */ React9.createElement(
|
|
765
827
|
NoVariables,
|
|
766
828
|
{
|
|
767
|
-
title:
|
|
768
|
-
icon: /* @__PURE__ */
|
|
829
|
+
title: __10("Create your first color variable", "elementor"),
|
|
830
|
+
icon: /* @__PURE__ */ React9.createElement(BrushIcon3, { fontSize: "large" }),
|
|
769
831
|
onAdd
|
|
770
832
|
}
|
|
771
833
|
)));
|
|
772
834
|
};
|
|
773
835
|
|
|
774
836
|
// src/components/font-variable-creation.tsx
|
|
775
|
-
import * as
|
|
776
|
-
import {
|
|
777
|
-
import {
|
|
778
|
-
import { PopoverScrollableContent as PopoverScrollableContent4
|
|
837
|
+
import * as React11 from "react";
|
|
838
|
+
import { useState as useState7 } from "react";
|
|
839
|
+
import { PopoverContent as PopoverContent3, useBoundProp as useBoundProp4 } from "@elementor/editor-controls";
|
|
840
|
+
import { PopoverScrollableContent as PopoverScrollableContent4 } from "@elementor/editor-editing-panel";
|
|
779
841
|
import { PopoverHeader as PopoverHeader4 } from "@elementor/editor-ui";
|
|
780
|
-
import { ArrowLeftIcon as ArrowLeftIcon3,
|
|
842
|
+
import { ArrowLeftIcon as ArrowLeftIcon3, TextIcon } from "@elementor/icons";
|
|
843
|
+
import { Button as Button5, CardActions as CardActions3, Divider as Divider4, IconButton as IconButton5 } from "@elementor/ui";
|
|
844
|
+
import { __ as __12 } from "@wordpress/i18n";
|
|
845
|
+
|
|
846
|
+
// src/components/fields/font-field.tsx
|
|
847
|
+
import * as React10 from "react";
|
|
848
|
+
import { useRef as useRef2, useState as useState6 } from "react";
|
|
849
|
+
import { FontFamilySelector } from "@elementor/editor-controls";
|
|
850
|
+
import { useFontFamilies, useSectionWidth } from "@elementor/editor-editing-panel";
|
|
851
|
+
import { ChevronDownIcon } from "@elementor/icons";
|
|
781
852
|
import {
|
|
782
853
|
bindPopover,
|
|
783
854
|
bindTrigger,
|
|
784
|
-
|
|
785
|
-
CardActions as CardActions3,
|
|
786
|
-
Divider as Divider4,
|
|
855
|
+
FormHelperText as FormHelperText3,
|
|
787
856
|
FormLabel as FormLabel3,
|
|
788
857
|
Grid as Grid3,
|
|
789
|
-
IconButton as IconButton6,
|
|
790
858
|
Popover,
|
|
791
|
-
TextField as TextField3,
|
|
792
859
|
UnstableTag,
|
|
793
860
|
usePopupState
|
|
794
861
|
} from "@elementor/ui";
|
|
795
|
-
import { __ as
|
|
796
|
-
var
|
|
797
|
-
|
|
798
|
-
const
|
|
799
|
-
const
|
|
800
|
-
const
|
|
801
|
-
const [label, setLabel] = useState4("");
|
|
802
|
-
const anchorRef = useRef3(null);
|
|
862
|
+
import { __ as __11 } from "@wordpress/i18n";
|
|
863
|
+
var FontField = ({ value, onChange }) => {
|
|
864
|
+
const [fontFamily, setFontFamily] = useState6(value);
|
|
865
|
+
const [errorMessage, setErrorMessage] = useState6("");
|
|
866
|
+
const defaultRef = useRef2(null);
|
|
867
|
+
const anchorRef = usePopoverContentRef() ?? defaultRef;
|
|
803
868
|
const fontPopoverState = usePopupState({ variant: "popover" });
|
|
804
|
-
const
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
};
|
|
812
|
-
const handleCreate = () => {
|
|
813
|
-
createVariable({
|
|
814
|
-
value: fontFamily,
|
|
815
|
-
label,
|
|
816
|
-
type: fontVariablePropTypeUtil.key
|
|
817
|
-
}).then((key) => {
|
|
818
|
-
setVariable(key);
|
|
819
|
-
closePopover();
|
|
820
|
-
});
|
|
869
|
+
const fontFamilies = useFontFamilies();
|
|
870
|
+
const sectionWidth = useSectionWidth();
|
|
871
|
+
const handleChange = (newValue) => {
|
|
872
|
+
setFontFamily(newValue);
|
|
873
|
+
const errorMsg = validateValue(newValue);
|
|
874
|
+
setErrorMessage(errorMsg);
|
|
875
|
+
onChange(errorMsg ? "" : newValue);
|
|
821
876
|
};
|
|
822
|
-
const
|
|
823
|
-
|
|
877
|
+
const handleFontFamilyChange = (newFontFamily) => {
|
|
878
|
+
handleChange(newFontFamily);
|
|
879
|
+
fontPopoverState.close();
|
|
824
880
|
};
|
|
825
|
-
|
|
826
|
-
return /* @__PURE__ */ React9.createElement(PopoverScrollableContent4, { height: "auto" }, /* @__PURE__ */ React9.createElement(
|
|
827
|
-
PopoverHeader4,
|
|
828
|
-
{
|
|
829
|
-
icon: /* @__PURE__ */ React9.createElement(React9.Fragment, null, onGoBack && /* @__PURE__ */ React9.createElement(IconButton6, { size: SIZE6, "aria-label": __8("Go Back", "elementor"), onClick: onGoBack }, /* @__PURE__ */ React9.createElement(ArrowLeftIcon3, { fontSize: SIZE6 })), /* @__PURE__ */ React9.createElement(TextIcon, { fontSize: SIZE6 })),
|
|
830
|
-
title: __8("Create variable", "elementor"),
|
|
831
|
-
onClose: closePopover
|
|
832
|
-
}
|
|
833
|
-
), /* @__PURE__ */ React9.createElement(Divider4, null), /* @__PURE__ */ React9.createElement(PopoverContent3, { p: 2 }, /* @__PURE__ */ React9.createElement(Grid3, { container: true, gap: 0.75, alignItems: "center" }, /* @__PURE__ */ React9.createElement(Grid3, { item: true, xs: 12 }, /* @__PURE__ */ React9.createElement(FormLabel3, { size: "tiny" }, __8("Name", "elementor"))), /* @__PURE__ */ React9.createElement(Grid3, { item: true, xs: 12 }, /* @__PURE__ */ React9.createElement(
|
|
834
|
-
TextField3,
|
|
835
|
-
{
|
|
836
|
-
size: "tiny",
|
|
837
|
-
fullWidth: true,
|
|
838
|
-
value: label,
|
|
839
|
-
onChange: (e) => setLabel(e.target.value)
|
|
840
|
-
}
|
|
841
|
-
))), /* @__PURE__ */ React9.createElement(Grid3, { container: true, gap: 0.75, alignItems: "center" }, /* @__PURE__ */ React9.createElement(Grid3, { item: true, xs: 12 }, /* @__PURE__ */ React9.createElement(FormLabel3, { size: "tiny" }, __8("Value", "elementor"))), /* @__PURE__ */ React9.createElement(Grid3, { item: true, xs: 12 }, /* @__PURE__ */ React9.createElement(React9.Fragment, null, /* @__PURE__ */ React9.createElement(
|
|
881
|
+
return /* @__PURE__ */ React10.createElement(Grid3, { container: true, gap: 0.75, alignItems: "center" }, /* @__PURE__ */ React10.createElement(Grid3, { item: true, xs: 12 }, /* @__PURE__ */ React10.createElement(FormLabel3, { size: "tiny" }, __11("Value", "elementor"))), /* @__PURE__ */ React10.createElement(Grid3, { item: true, xs: 12 }, /* @__PURE__ */ React10.createElement(
|
|
842
882
|
UnstableTag,
|
|
843
883
|
{
|
|
844
884
|
variant: "outlined",
|
|
845
885
|
label: fontFamily,
|
|
846
|
-
endIcon: /* @__PURE__ */
|
|
886
|
+
endIcon: /* @__PURE__ */ React10.createElement(ChevronDownIcon, { fontSize: "tiny" }),
|
|
847
887
|
...bindTrigger(fontPopoverState),
|
|
848
888
|
fullWidth: true
|
|
849
889
|
}
|
|
850
|
-
), /* @__PURE__ */
|
|
890
|
+
), /* @__PURE__ */ React10.createElement(
|
|
851
891
|
Popover,
|
|
852
892
|
{
|
|
853
893
|
disablePortal: true,
|
|
@@ -857,138 +897,162 @@ var FontVariableCreation = ({ onClose, onGoBack }) => {
|
|
|
857
897
|
transformOrigin: { vertical: "top", horizontal: -20 },
|
|
858
898
|
...bindPopover(fontPopoverState)
|
|
859
899
|
},
|
|
860
|
-
/* @__PURE__ */
|
|
900
|
+
/* @__PURE__ */ React10.createElement(
|
|
861
901
|
FontFamilySelector,
|
|
862
902
|
{
|
|
863
903
|
fontFamilies,
|
|
864
904
|
fontFamily,
|
|
865
|
-
onFontFamilyChange:
|
|
905
|
+
onFontFamilyChange: handleFontFamilyChange,
|
|
866
906
|
onClose: fontPopoverState.close,
|
|
867
907
|
sectionWidth
|
|
868
908
|
}
|
|
869
909
|
)
|
|
870
|
-
)
|
|
910
|
+
), errorMessage && /* @__PURE__ */ React10.createElement(FormHelperText3, { error: true }, errorMessage)));
|
|
911
|
+
};
|
|
912
|
+
|
|
913
|
+
// src/components/font-variable-creation.tsx
|
|
914
|
+
var SIZE5 = "tiny";
|
|
915
|
+
var FontVariableCreation = ({ onClose, onGoBack }) => {
|
|
916
|
+
const { setValue: setVariable } = useBoundProp4(fontVariablePropTypeUtil);
|
|
917
|
+
const [fontFamily, setFontFamily] = useState7("");
|
|
918
|
+
const [label, setLabel] = useState7("");
|
|
919
|
+
const resetFields = () => {
|
|
920
|
+
setFontFamily("");
|
|
921
|
+
setLabel("");
|
|
922
|
+
};
|
|
923
|
+
const closePopover = () => {
|
|
924
|
+
resetFields();
|
|
925
|
+
onClose();
|
|
926
|
+
};
|
|
927
|
+
const handleCreate = () => {
|
|
928
|
+
createVariable({
|
|
929
|
+
value: fontFamily,
|
|
930
|
+
label,
|
|
931
|
+
type: fontVariablePropTypeUtil.key
|
|
932
|
+
}).then((key) => {
|
|
933
|
+
setVariable(key);
|
|
934
|
+
closePopover();
|
|
935
|
+
});
|
|
936
|
+
};
|
|
937
|
+
const hasEmptyValue = () => {
|
|
938
|
+
return "" === fontFamily.trim() || "" === label.trim();
|
|
939
|
+
};
|
|
940
|
+
const isSubmitDisabled = hasEmptyValue();
|
|
941
|
+
return /* @__PURE__ */ React11.createElement(PopoverScrollableContent4, { height: "auto" }, /* @__PURE__ */ React11.createElement(
|
|
942
|
+
PopoverHeader4,
|
|
943
|
+
{
|
|
944
|
+
icon: /* @__PURE__ */ React11.createElement(React11.Fragment, null, onGoBack && /* @__PURE__ */ React11.createElement(IconButton5, { size: SIZE5, "aria-label": __12("Go Back", "elementor"), onClick: onGoBack }, /* @__PURE__ */ React11.createElement(ArrowLeftIcon3, { fontSize: SIZE5 })), /* @__PURE__ */ React11.createElement(TextIcon, { fontSize: SIZE5 })),
|
|
945
|
+
title: __12("Create variable", "elementor"),
|
|
946
|
+
onClose: closePopover
|
|
947
|
+
}
|
|
948
|
+
), /* @__PURE__ */ React11.createElement(Divider4, null), /* @__PURE__ */ React11.createElement(PopoverContent3, { p: 2 }, /* @__PURE__ */ React11.createElement(LabelField, { value: label, onChange: setLabel }), /* @__PURE__ */ React11.createElement(FontField, { value: fontFamily, onChange: setFontFamily })), /* @__PURE__ */ React11.createElement(CardActions3, { sx: { pt: 0.5, pb: 1 } }, /* @__PURE__ */ React11.createElement(Button5, { size: "small", variant: "contained", disabled: isSubmitDisabled, onClick: handleCreate }, __12("Create", "elementor"))));
|
|
871
949
|
};
|
|
872
950
|
|
|
873
951
|
// src/components/font-variable-edit.tsx
|
|
874
|
-
import * as
|
|
875
|
-
import {
|
|
876
|
-
import {
|
|
877
|
-
import {
|
|
878
|
-
import { PopoverHeader as PopoverHeader5
|
|
879
|
-
import { ArrowLeftIcon as ArrowLeftIcon4,
|
|
880
|
-
import {
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
Button as Button5,
|
|
884
|
-
CardActions as CardActions4,
|
|
885
|
-
Divider as Divider5,
|
|
886
|
-
FormLabel as FormLabel4,
|
|
887
|
-
Grid as Grid4,
|
|
888
|
-
IconButton as IconButton7,
|
|
889
|
-
Popover as Popover2,
|
|
890
|
-
TextField as TextField4,
|
|
891
|
-
UnstableTag as UnstableTag2,
|
|
892
|
-
usePopupState as usePopupState2
|
|
893
|
-
} from "@elementor/ui";
|
|
894
|
-
import { __ as __9 } from "@wordpress/i18n";
|
|
895
|
-
var SIZE7 = "tiny";
|
|
952
|
+
import * as React12 from "react";
|
|
953
|
+
import { useState as useState8 } from "react";
|
|
954
|
+
import { PopoverContent as PopoverContent4, useBoundProp as useBoundProp5 } from "@elementor/editor-controls";
|
|
955
|
+
import { PopoverScrollableContent as PopoverScrollableContent5 } from "@elementor/editor-editing-panel";
|
|
956
|
+
import { PopoverHeader as PopoverHeader5 } from "@elementor/editor-ui";
|
|
957
|
+
import { ArrowLeftIcon as ArrowLeftIcon4, TextIcon as TextIcon2, TrashIcon as TrashIcon2 } from "@elementor/icons";
|
|
958
|
+
import { Button as Button6, CardActions as CardActions4, Divider as Divider5, IconButton as IconButton6 } from "@elementor/ui";
|
|
959
|
+
import { __ as __13 } from "@wordpress/i18n";
|
|
960
|
+
var SIZE6 = "tiny";
|
|
896
961
|
var FontVariableEdit = ({ onClose, onGoBack, onSubmit, editId }) => {
|
|
962
|
+
const { setValue: notifyBoundPropChange, value: assignedValue } = useBoundProp5(fontVariablePropTypeUtil);
|
|
963
|
+
const [deleteConfirmation, setDeleteConfirmation] = useState8(false);
|
|
897
964
|
const variable = useVariable(editId);
|
|
898
965
|
if (!variable) {
|
|
899
966
|
throw new Error(`Global font variable "${editId}" not found`);
|
|
900
967
|
}
|
|
901
|
-
const [fontFamily, setFontFamily] =
|
|
902
|
-
const [label, setLabel] =
|
|
903
|
-
const variableNameId = useId();
|
|
904
|
-
const variableValueId = useId();
|
|
905
|
-
const anchorRef = useRef4(null);
|
|
906
|
-
const fontPopoverState = usePopupState2({ variant: "popover" });
|
|
907
|
-
const fontFamilies = useFontFamilies2();
|
|
968
|
+
const [fontFamily, setFontFamily] = useState8(variable.value);
|
|
969
|
+
const [label, setLabel] = useState8(variable.label);
|
|
908
970
|
const handleUpdate = () => {
|
|
909
971
|
updateVariable(editId, {
|
|
910
972
|
value: fontFamily,
|
|
911
973
|
label
|
|
912
974
|
}).then(() => {
|
|
975
|
+
maybeTriggerBoundPropChange();
|
|
913
976
|
onSubmit?.();
|
|
914
977
|
});
|
|
915
978
|
};
|
|
916
979
|
const handleDelete = () => {
|
|
917
980
|
deleteVariable(editId).then(() => {
|
|
981
|
+
maybeTriggerBoundPropChange();
|
|
918
982
|
onSubmit?.();
|
|
919
983
|
});
|
|
920
984
|
};
|
|
921
|
-
const
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
985
|
+
const maybeTriggerBoundPropChange = () => {
|
|
986
|
+
if (editId === assignedValue) {
|
|
987
|
+
notifyBoundPropChange(editId);
|
|
988
|
+
}
|
|
989
|
+
};
|
|
990
|
+
const handleDeleteConfirmation = () => {
|
|
991
|
+
setDeleteConfirmation(true);
|
|
992
|
+
};
|
|
993
|
+
const closeDeleteDialog = () => () => {
|
|
994
|
+
setDeleteConfirmation(false);
|
|
995
|
+
};
|
|
996
|
+
const hasEmptyValue = () => {
|
|
997
|
+
return !fontFamily.trim() || !label.trim();
|
|
998
|
+
};
|
|
999
|
+
const noValueChanged = () => {
|
|
1000
|
+
return fontFamily === variable.value && label === variable.label;
|
|
1001
|
+
};
|
|
1002
|
+
const isSubmitDisabled = noValueChanged() || hasEmptyValue();
|
|
925
1003
|
const actions = [];
|
|
926
1004
|
actions.push(
|
|
927
|
-
/* @__PURE__ */
|
|
1005
|
+
/* @__PURE__ */ React12.createElement(
|
|
1006
|
+
IconButton6,
|
|
1007
|
+
{
|
|
1008
|
+
key: "delete",
|
|
1009
|
+
size: SIZE6,
|
|
1010
|
+
"aria-label": __13("Delete", "elementor"),
|
|
1011
|
+
onClick: handleDeleteConfirmation
|
|
1012
|
+
},
|
|
1013
|
+
/* @__PURE__ */ React12.createElement(TrashIcon2, { fontSize: SIZE6 })
|
|
1014
|
+
)
|
|
928
1015
|
);
|
|
929
|
-
return /* @__PURE__ */
|
|
1016
|
+
return /* @__PURE__ */ React12.createElement(React12.Fragment, null, /* @__PURE__ */ React12.createElement(PopoverScrollableContent5, { height: "auto" }, /* @__PURE__ */ React12.createElement(
|
|
930
1017
|
PopoverHeader5,
|
|
931
1018
|
{
|
|
932
|
-
icon: /* @__PURE__ */
|
|
933
|
-
|
|
1019
|
+
icon: /* @__PURE__ */ React12.createElement(React12.Fragment, null, onGoBack && /* @__PURE__ */ React12.createElement(
|
|
1020
|
+
IconButton6,
|
|
1021
|
+
{
|
|
1022
|
+
size: SIZE6,
|
|
1023
|
+
"aria-label": __13("Go Back", "elementor"),
|
|
1024
|
+
onClick: onGoBack
|
|
1025
|
+
},
|
|
1026
|
+
/* @__PURE__ */ React12.createElement(ArrowLeftIcon4, { fontSize: SIZE6 })
|
|
1027
|
+
), /* @__PURE__ */ React12.createElement(TextIcon2, { fontSize: SIZE6 })),
|
|
1028
|
+
title: __13("Edit variable", "elementor"),
|
|
934
1029
|
onClose,
|
|
935
1030
|
actions
|
|
936
1031
|
}
|
|
937
|
-
), /* @__PURE__ */
|
|
938
|
-
|
|
1032
|
+
), /* @__PURE__ */ React12.createElement(Divider5, null), /* @__PURE__ */ React12.createElement(PopoverContent4, { p: 2 }, /* @__PURE__ */ React12.createElement(LabelField, { value: label, onChange: setLabel }), /* @__PURE__ */ React12.createElement(FontField, { value: fontFamily, onChange: setFontFamily })), /* @__PURE__ */ React12.createElement(CardActions4, { sx: { pt: 0.5, pb: 1 } }, /* @__PURE__ */ React12.createElement(Button6, { size: "small", variant: "contained", disabled: isSubmitDisabled, onClick: handleUpdate }, __13("Save", "elementor")))), deleteConfirmation && /* @__PURE__ */ React12.createElement(
|
|
1033
|
+
DeleteConfirmationDialog,
|
|
939
1034
|
{
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
onChange: (e) => setLabel(e.target.value)
|
|
945
|
-
}
|
|
946
|
-
))), /* @__PURE__ */ React10.createElement(Grid4, { container: true, gap: 0.75, alignItems: "center" }, /* @__PURE__ */ React10.createElement(Grid4, { item: true, xs: 12 }, /* @__PURE__ */ React10.createElement(FormLabel4, { htmlFor: variableValueId, size: "tiny" }, __9("Value", "elementor"))), /* @__PURE__ */ React10.createElement(Grid4, { item: true, xs: 12 }, /* @__PURE__ */ React10.createElement(React10.Fragment, null, /* @__PURE__ */ React10.createElement(
|
|
947
|
-
UnstableTag2,
|
|
948
|
-
{
|
|
949
|
-
id: variableValueId,
|
|
950
|
-
variant: "outlined",
|
|
951
|
-
label: fontFamily,
|
|
952
|
-
endIcon: /* @__PURE__ */ React10.createElement(ChevronDownIcon2, { fontSize: "tiny" }),
|
|
953
|
-
...bindTrigger2(fontPopoverState),
|
|
954
|
-
fullWidth: true
|
|
1035
|
+
open: true,
|
|
1036
|
+
label,
|
|
1037
|
+
onConfirm: handleDelete,
|
|
1038
|
+
closeDialog: closeDeleteDialog()
|
|
955
1039
|
}
|
|
956
|
-
)
|
|
957
|
-
Popover2,
|
|
958
|
-
{
|
|
959
|
-
disablePortal: true,
|
|
960
|
-
disableScrollLock: true,
|
|
961
|
-
anchorEl: anchorRef.current,
|
|
962
|
-
anchorOrigin: { vertical: "top", horizontal: "right" },
|
|
963
|
-
transformOrigin: { vertical: "top", horizontal: -20 },
|
|
964
|
-
...bindPopover2(fontPopoverState)
|
|
965
|
-
},
|
|
966
|
-
/* @__PURE__ */ React10.createElement(
|
|
967
|
-
FontFamilySelector2,
|
|
968
|
-
{
|
|
969
|
-
fontFamilies,
|
|
970
|
-
fontFamily,
|
|
971
|
-
onFontFamilyChange: setFontFamily,
|
|
972
|
-
onClose: fontPopoverState.close,
|
|
973
|
-
sectionWidth
|
|
974
|
-
}
|
|
975
|
-
)
|
|
976
|
-
))))), /* @__PURE__ */ React10.createElement(CardActions4, { sx: { pt: 0.5, pb: 1 } }, /* @__PURE__ */ React10.createElement(Button5, { size: "small", variant: "contained", disabled: isSaveDisabled(), onClick: handleUpdate }, __9("Save", "elementor"))));
|
|
1040
|
+
));
|
|
977
1041
|
};
|
|
978
1042
|
|
|
979
1043
|
// src/components/font-variables-selection.tsx
|
|
980
|
-
import * as
|
|
981
|
-
import { useState as
|
|
982
|
-
import { useBoundProp as
|
|
1044
|
+
import * as React13 from "react";
|
|
1045
|
+
import { useState as useState9 } from "react";
|
|
1046
|
+
import { useBoundProp as useBoundProp6 } from "@elementor/editor-controls";
|
|
983
1047
|
import { PopoverScrollableContent as PopoverScrollableContent6 } from "@elementor/editor-editing-panel";
|
|
984
1048
|
import { PopoverHeader as PopoverHeader6, PopoverMenuList as PopoverMenuList2, PopoverSearch as PopoverSearch2 } from "@elementor/editor-ui";
|
|
985
1049
|
import { ColorFilterIcon as ColorFilterIcon2, PlusIcon as PlusIcon2, SettingsIcon as SettingsIcon2, TextIcon as TextIcon3 } from "@elementor/icons";
|
|
986
|
-
import { Divider as Divider6, IconButton as
|
|
987
|
-
import { __ as
|
|
988
|
-
var
|
|
1050
|
+
import { Divider as Divider6, IconButton as IconButton7 } from "@elementor/ui";
|
|
1051
|
+
import { __ as __14 } from "@wordpress/i18n";
|
|
1052
|
+
var SIZE7 = "tiny";
|
|
989
1053
|
var FontVariablesSelection = ({ closePopover, onAdd, onEdit, onSettings }) => {
|
|
990
|
-
const { value: variable, setValue: setVariable } =
|
|
991
|
-
const [searchValue, setSearchValue] =
|
|
1054
|
+
const { value: variable, setValue: setVariable } = useBoundProp6(fontVariablePropTypeUtil);
|
|
1055
|
+
const [searchValue, setSearchValue] = useState9("");
|
|
992
1056
|
const {
|
|
993
1057
|
list: variables,
|
|
994
1058
|
hasMatches: hasSearchResults,
|
|
@@ -1001,19 +1065,19 @@ var FontVariablesSelection = ({ closePopover, onAdd, onEdit, onSettings }) => {
|
|
|
1001
1065
|
const actions = [];
|
|
1002
1066
|
if (onAdd) {
|
|
1003
1067
|
actions.push(
|
|
1004
|
-
/* @__PURE__ */
|
|
1068
|
+
/* @__PURE__ */ React13.createElement(IconButton7, { key: "add", size: SIZE7, onClick: onAdd }, /* @__PURE__ */ React13.createElement(PlusIcon2, { fontSize: SIZE7 }))
|
|
1005
1069
|
);
|
|
1006
1070
|
}
|
|
1007
1071
|
if (onSettings) {
|
|
1008
1072
|
actions.push(
|
|
1009
|
-
/* @__PURE__ */
|
|
1073
|
+
/* @__PURE__ */ React13.createElement(IconButton7, { key: "settings", size: SIZE7, onClick: onSettings }, /* @__PURE__ */ React13.createElement(SettingsIcon2, { fontSize: SIZE7 }))
|
|
1010
1074
|
);
|
|
1011
1075
|
}
|
|
1012
1076
|
const items = variables.map(({ value, label, key }) => ({
|
|
1013
1077
|
type: "item",
|
|
1014
1078
|
value: key,
|
|
1015
1079
|
label,
|
|
1016
|
-
icon: /* @__PURE__ */
|
|
1080
|
+
icon: /* @__PURE__ */ React13.createElement(TextIcon3, { fontSize: SIZE7 }),
|
|
1017
1081
|
secondaryText: value,
|
|
1018
1082
|
onEdit: () => onEdit?.(key)
|
|
1019
1083
|
}));
|
|
@@ -1023,22 +1087,22 @@ var FontVariablesSelection = ({ closePopover, onAdd, onEdit, onSettings }) => {
|
|
|
1023
1087
|
const handleClearSearch = () => {
|
|
1024
1088
|
setSearchValue("");
|
|
1025
1089
|
};
|
|
1026
|
-
return /* @__PURE__ */
|
|
1090
|
+
return /* @__PURE__ */ React13.createElement(React13.Fragment, null, /* @__PURE__ */ React13.createElement(
|
|
1027
1091
|
PopoverHeader6,
|
|
1028
1092
|
{
|
|
1029
|
-
title:
|
|
1093
|
+
title: __14("Variables", "elementor"),
|
|
1030
1094
|
onClose: closePopover,
|
|
1031
|
-
icon: /* @__PURE__ */
|
|
1095
|
+
icon: /* @__PURE__ */ React13.createElement(ColorFilterIcon2, { fontSize: SIZE7 }),
|
|
1032
1096
|
actions
|
|
1033
1097
|
}
|
|
1034
|
-
), hasVariables && /* @__PURE__ */
|
|
1098
|
+
), hasVariables && /* @__PURE__ */ React13.createElement(
|
|
1035
1099
|
PopoverSearch2,
|
|
1036
1100
|
{
|
|
1037
1101
|
value: searchValue,
|
|
1038
1102
|
onSearch: handleSearch,
|
|
1039
|
-
placeholder:
|
|
1103
|
+
placeholder: __14("Search", "elementor")
|
|
1040
1104
|
}
|
|
1041
|
-
), /* @__PURE__ */
|
|
1105
|
+
), /* @__PURE__ */ React13.createElement(Divider6, null), /* @__PURE__ */ React13.createElement(PopoverScrollableContent6, null, hasVariables && hasSearchResults && /* @__PURE__ */ React13.createElement(
|
|
1042
1106
|
PopoverMenuList2,
|
|
1043
1107
|
{
|
|
1044
1108
|
items,
|
|
@@ -1048,20 +1112,20 @@ var FontVariablesSelection = ({ closePopover, onAdd, onEdit, onSettings }) => {
|
|
|
1048
1112
|
selectedValue: variable,
|
|
1049
1113
|
"data-testid": "font-variables-list",
|
|
1050
1114
|
menuListTemplate: VariablesStyledMenuList,
|
|
1051
|
-
menuItemContentTemplate: (item) => /* @__PURE__ */
|
|
1115
|
+
menuItemContentTemplate: (item) => /* @__PURE__ */ React13.createElement(MenuItemContent, { item })
|
|
1052
1116
|
}
|
|
1053
|
-
), !hasSearchResults && hasVariables && /* @__PURE__ */
|
|
1117
|
+
), !hasSearchResults && hasVariables && /* @__PURE__ */ React13.createElement(
|
|
1054
1118
|
NoSearchResults,
|
|
1055
1119
|
{
|
|
1056
1120
|
searchValue,
|
|
1057
1121
|
onClear: handleClearSearch,
|
|
1058
|
-
icon: /* @__PURE__ */
|
|
1122
|
+
icon: /* @__PURE__ */ React13.createElement(TextIcon3, { fontSize: "large" })
|
|
1059
1123
|
}
|
|
1060
|
-
), !hasVariables && /* @__PURE__ */
|
|
1124
|
+
), !hasVariables && /* @__PURE__ */ React13.createElement(
|
|
1061
1125
|
NoVariables,
|
|
1062
1126
|
{
|
|
1063
|
-
title:
|
|
1064
|
-
icon: /* @__PURE__ */
|
|
1127
|
+
title: __14("Create your first font variable", "elementor"),
|
|
1128
|
+
icon: /* @__PURE__ */ React13.createElement(TextIcon3, { fontSize: "large" }),
|
|
1065
1129
|
onAdd
|
|
1066
1130
|
}
|
|
1067
1131
|
)));
|
|
@@ -1072,10 +1136,10 @@ var VIEW_LIST = "list";
|
|
|
1072
1136
|
var VIEW_ADD = "add";
|
|
1073
1137
|
var VIEW_EDIT = "edit";
|
|
1074
1138
|
var VariableSelectionPopover = ({ closePopover, propTypeKey, selectedVariable }) => {
|
|
1075
|
-
const [currentView, setCurrentView] =
|
|
1076
|
-
const editIdRef =
|
|
1077
|
-
const anchorRef =
|
|
1078
|
-
return /* @__PURE__ */
|
|
1139
|
+
const [currentView, setCurrentView] = useState10(VIEW_LIST);
|
|
1140
|
+
const editIdRef = useRef3("");
|
|
1141
|
+
const anchorRef = useRef3(null);
|
|
1142
|
+
return /* @__PURE__ */ React14.createElement(PopoverContentRefContext.Provider, { value: anchorRef }, /* @__PURE__ */ React14.createElement(Box2, { ref: anchorRef }, renderStage({
|
|
1079
1143
|
propTypeKey,
|
|
1080
1144
|
currentView,
|
|
1081
1145
|
selectedVariable,
|
|
@@ -1094,7 +1158,7 @@ function renderStage(props) {
|
|
|
1094
1158
|
};
|
|
1095
1159
|
if (fontVariablePropTypeUtil.key === props.propTypeKey) {
|
|
1096
1160
|
if (VIEW_LIST === props.currentView) {
|
|
1097
|
-
return /* @__PURE__ */
|
|
1161
|
+
return /* @__PURE__ */ React14.createElement(
|
|
1098
1162
|
FontVariablesSelection,
|
|
1099
1163
|
{
|
|
1100
1164
|
closePopover: props.closePopover,
|
|
@@ -1109,7 +1173,7 @@ function renderStage(props) {
|
|
|
1109
1173
|
);
|
|
1110
1174
|
}
|
|
1111
1175
|
if (VIEW_ADD === props.currentView) {
|
|
1112
|
-
return /* @__PURE__ */
|
|
1176
|
+
return /* @__PURE__ */ React14.createElement(
|
|
1113
1177
|
FontVariableCreation,
|
|
1114
1178
|
{
|
|
1115
1179
|
onGoBack: () => props.setCurrentView(VIEW_LIST),
|
|
@@ -1118,7 +1182,7 @@ function renderStage(props) {
|
|
|
1118
1182
|
);
|
|
1119
1183
|
}
|
|
1120
1184
|
if (VIEW_EDIT === props.currentView) {
|
|
1121
|
-
return /* @__PURE__ */
|
|
1185
|
+
return /* @__PURE__ */ React14.createElement(
|
|
1122
1186
|
FontVariableEdit,
|
|
1123
1187
|
{
|
|
1124
1188
|
editId: props.editIdRef.current ?? "",
|
|
@@ -1131,7 +1195,7 @@ function renderStage(props) {
|
|
|
1131
1195
|
}
|
|
1132
1196
|
if (colorVariablePropTypeUtil.key === props.propTypeKey) {
|
|
1133
1197
|
if (VIEW_LIST === props.currentView) {
|
|
1134
|
-
return /* @__PURE__ */
|
|
1198
|
+
return /* @__PURE__ */ React14.createElement(
|
|
1135
1199
|
ColorVariablesSelection,
|
|
1136
1200
|
{
|
|
1137
1201
|
closePopover: props.closePopover,
|
|
@@ -1146,7 +1210,7 @@ function renderStage(props) {
|
|
|
1146
1210
|
);
|
|
1147
1211
|
}
|
|
1148
1212
|
if (VIEW_ADD === props.currentView) {
|
|
1149
|
-
return /* @__PURE__ */
|
|
1213
|
+
return /* @__PURE__ */ React14.createElement(
|
|
1150
1214
|
ColorVariableCreation,
|
|
1151
1215
|
{
|
|
1152
1216
|
onGoBack: () => props.setCurrentView(VIEW_LIST),
|
|
@@ -1155,7 +1219,7 @@ function renderStage(props) {
|
|
|
1155
1219
|
);
|
|
1156
1220
|
}
|
|
1157
1221
|
if (VIEW_EDIT === props.currentView) {
|
|
1158
|
-
return /* @__PURE__ */
|
|
1222
|
+
return /* @__PURE__ */ React14.createElement(
|
|
1159
1223
|
ColorVariableEdit,
|
|
1160
1224
|
{
|
|
1161
1225
|
editId: props.editIdRef.current ?? "",
|
|
@@ -1169,33 +1233,59 @@ function renderStage(props) {
|
|
|
1169
1233
|
return null;
|
|
1170
1234
|
}
|
|
1171
1235
|
|
|
1172
|
-
// src/
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1236
|
+
// src/components/ui/tags/assigned-tag.tsx
|
|
1237
|
+
import * as React15 from "react";
|
|
1238
|
+
import { DetachIcon } from "@elementor/icons";
|
|
1239
|
+
import { Box as Box3, IconButton as IconButton8, Stack as Stack3, Typography as Typography5, UnstableTag as Tag } from "@elementor/ui";
|
|
1240
|
+
import { __ as __15 } from "@wordpress/i18n";
|
|
1241
|
+
var SIZE8 = "tiny";
|
|
1242
|
+
var AssignedTag = ({ startIcon, label, onUnlink, ...props }) => {
|
|
1243
|
+
const actions = [];
|
|
1244
|
+
if (onUnlink) {
|
|
1245
|
+
actions.push(
|
|
1246
|
+
/* @__PURE__ */ React15.createElement(IconButton8, { key: "unlink", size: SIZE8, onClick: onUnlink, "aria-label": __15("Unlink", "elementor") }, /* @__PURE__ */ React15.createElement(DetachIcon, { fontSize: SIZE8 }))
|
|
1247
|
+
);
|
|
1248
|
+
}
|
|
1249
|
+
return /* @__PURE__ */ React15.createElement(
|
|
1250
|
+
Tag,
|
|
1251
|
+
{
|
|
1252
|
+
fullWidth: true,
|
|
1253
|
+
showActionsOnHover: true,
|
|
1254
|
+
startIcon: /* @__PURE__ */ React15.createElement(Stack3, { gap: 0.5, direction: "row", alignItems: "center" }, startIcon),
|
|
1255
|
+
label: /* @__PURE__ */ React15.createElement(Box3, { sx: { display: "inline-grid", minWidth: 0 } }, /* @__PURE__ */ React15.createElement(Typography5, { sx: { lineHeight: 1.34 }, variant: "caption", noWrap: true }, label)),
|
|
1256
|
+
actions,
|
|
1257
|
+
...props
|
|
1258
|
+
}
|
|
1259
|
+
);
|
|
1260
|
+
};
|
|
1261
|
+
|
|
1262
|
+
// src/components/ui/variable/assigned-variable.tsx
|
|
1263
|
+
var AssignedVariable = ({
|
|
1264
|
+
variable,
|
|
1265
|
+
variablePropTypeUtil,
|
|
1266
|
+
fallbackPropTypeUtil,
|
|
1267
|
+
additionalStartIcon
|
|
1268
|
+
}) => {
|
|
1269
|
+
const { setValue } = useBoundProp7();
|
|
1270
|
+
const anchorRef = useRef4(null);
|
|
1177
1271
|
const popupId = useId2();
|
|
1178
|
-
const popupState =
|
|
1272
|
+
const popupState = usePopupState2({
|
|
1179
1273
|
variant: "popover",
|
|
1180
1274
|
popupId: `elementor-variables-list-${popupId}`
|
|
1181
1275
|
});
|
|
1182
|
-
const selectedVariable = useVariable(variableValue);
|
|
1183
|
-
if (!selectedVariable) {
|
|
1184
|
-
throw new Error(`Global color variable ${variableValue} not found`);
|
|
1185
|
-
}
|
|
1186
1276
|
const unlinkVariable = () => {
|
|
1187
|
-
|
|
1277
|
+
setValue(fallbackPropTypeUtil.create(variable.value));
|
|
1188
1278
|
};
|
|
1189
|
-
return /* @__PURE__ */
|
|
1190
|
-
|
|
1279
|
+
return /* @__PURE__ */ React16.createElement(Box4, { ref: anchorRef }, /* @__PURE__ */ React16.createElement(
|
|
1280
|
+
AssignedTag,
|
|
1191
1281
|
{
|
|
1192
|
-
label:
|
|
1193
|
-
startIcon: /* @__PURE__ */
|
|
1282
|
+
label: variable.label,
|
|
1283
|
+
startIcon: /* @__PURE__ */ React16.createElement(React16.Fragment, null, /* @__PURE__ */ React16.createElement(ColorFilterIcon3, { fontSize: SIZE8 }), additionalStartIcon),
|
|
1194
1284
|
onUnlink: unlinkVariable,
|
|
1195
|
-
...
|
|
1285
|
+
...bindTrigger2(popupState)
|
|
1196
1286
|
}
|
|
1197
|
-
), /* @__PURE__ */
|
|
1198
|
-
|
|
1287
|
+
), /* @__PURE__ */ React16.createElement(
|
|
1288
|
+
Popover2,
|
|
1199
1289
|
{
|
|
1200
1290
|
disableScrollLock: true,
|
|
1201
1291
|
anchorEl: anchorRef.current,
|
|
@@ -1204,24 +1294,75 @@ var ColorVariableControl = () => {
|
|
|
1204
1294
|
PaperProps: {
|
|
1205
1295
|
sx: { my: 1 }
|
|
1206
1296
|
},
|
|
1207
|
-
...
|
|
1297
|
+
...bindPopover2(popupState)
|
|
1208
1298
|
},
|
|
1209
|
-
/* @__PURE__ */
|
|
1299
|
+
/* @__PURE__ */ React16.createElement(
|
|
1210
1300
|
VariableSelectionPopover,
|
|
1211
1301
|
{
|
|
1212
|
-
selectedVariable,
|
|
1302
|
+
selectedVariable: variable,
|
|
1213
1303
|
closePopover: popupState.close,
|
|
1214
|
-
propTypeKey:
|
|
1304
|
+
propTypeKey: variablePropTypeUtil.key
|
|
1215
1305
|
}
|
|
1216
1306
|
)
|
|
1217
1307
|
));
|
|
1218
1308
|
};
|
|
1219
1309
|
|
|
1220
|
-
// src/
|
|
1221
|
-
import * as
|
|
1222
|
-
import {
|
|
1310
|
+
// src/components/ui/variable/deleted-variable.tsx
|
|
1311
|
+
import * as React18 from "react";
|
|
1312
|
+
import { useRef as useRef5 } from "react";
|
|
1313
|
+
import { Box as Box6 } from "@elementor/ui";
|
|
1314
|
+
|
|
1315
|
+
// src/components/ui/tags/deleted-tag.tsx
|
|
1316
|
+
import * as React17 from "react";
|
|
1223
1317
|
import { ColorFilterIcon as ColorFilterIcon4 } from "@elementor/icons";
|
|
1224
|
-
import {
|
|
1318
|
+
import { Box as Box5, Typography as Typography6, UnstableTag as Tag2 } from "@elementor/ui";
|
|
1319
|
+
import { __ as __16 } from "@wordpress/i18n";
|
|
1320
|
+
var DeletedTag = ({ label }) => {
|
|
1321
|
+
return /* @__PURE__ */ React17.createElement(
|
|
1322
|
+
Tag2,
|
|
1323
|
+
{
|
|
1324
|
+
showActionsOnHover: true,
|
|
1325
|
+
fullWidth: true,
|
|
1326
|
+
label: /* @__PURE__ */ React17.createElement(Box5, { sx: { display: "inline-grid", minWidth: 0 } }, /* @__PURE__ */ React17.createElement(Typography6, { sx: { lineHeight: 1.34 }, variant: "caption", noWrap: true }, label)),
|
|
1327
|
+
startIcon: /* @__PURE__ */ React17.createElement(ColorFilterIcon4, { fontSize: "tiny" }),
|
|
1328
|
+
endAdornment: /* @__PURE__ */ React17.createElement(Typography6, { sx: { lineHeight: 1.34 }, variant: "caption", noWrap: true }, "(", __16("deleted", "elementor"), ")")
|
|
1329
|
+
}
|
|
1330
|
+
);
|
|
1331
|
+
};
|
|
1332
|
+
|
|
1333
|
+
// src/components/ui/variable/deleted-variable.tsx
|
|
1334
|
+
var DeletedVariable = ({ variable }) => {
|
|
1335
|
+
const anchorRef = useRef5(null);
|
|
1336
|
+
return /* @__PURE__ */ React18.createElement(Box6, { ref: anchorRef }, /* @__PURE__ */ React18.createElement(DeletedTag, { label: variable.label }));
|
|
1337
|
+
};
|
|
1338
|
+
|
|
1339
|
+
// src/controls/color-variable-control.tsx
|
|
1340
|
+
var ColorVariableControl = () => {
|
|
1341
|
+
const { value: variableValue } = useBoundProp8(colorVariablePropTypeUtil);
|
|
1342
|
+
const assignedVariable = useVariable(variableValue);
|
|
1343
|
+
if (!assignedVariable) {
|
|
1344
|
+
throw new Error(`Global color variable ${variableValue} not found`);
|
|
1345
|
+
}
|
|
1346
|
+
const isVariableDeleted = assignedVariable?.deleted;
|
|
1347
|
+
if (isVariableDeleted) {
|
|
1348
|
+
return /* @__PURE__ */ React19.createElement(DeletedVariable, { variable: assignedVariable });
|
|
1349
|
+
}
|
|
1350
|
+
return /* @__PURE__ */ React19.createElement(
|
|
1351
|
+
AssignedVariable,
|
|
1352
|
+
{
|
|
1353
|
+
variable: assignedVariable,
|
|
1354
|
+
variablePropTypeUtil: colorVariablePropTypeUtil,
|
|
1355
|
+
fallbackPropTypeUtil: colorPropTypeUtil,
|
|
1356
|
+
additionalStartIcon: /* @__PURE__ */ React19.createElement(ColorIndicator, { size: "inherit", value: assignedVariable.value, component: "span" })
|
|
1357
|
+
}
|
|
1358
|
+
);
|
|
1359
|
+
};
|
|
1360
|
+
|
|
1361
|
+
// src/hooks/use-prop-color-variable-action.tsx
|
|
1362
|
+
import * as React20 from "react";
|
|
1363
|
+
import { useBoundProp as useBoundProp9 } from "@elementor/editor-editing-panel";
|
|
1364
|
+
import { ColorFilterIcon as ColorFilterIcon5 } from "@elementor/icons";
|
|
1365
|
+
import { __ as __17 } from "@wordpress/i18n";
|
|
1225
1366
|
|
|
1226
1367
|
// src/utils.ts
|
|
1227
1368
|
var hasAssignedColorVariable = (propValue) => {
|
|
@@ -1239,18 +1380,66 @@ var supportsFontVariables = (propType) => {
|
|
|
1239
1380
|
|
|
1240
1381
|
// src/hooks/use-prop-color-variable-action.tsx
|
|
1241
1382
|
var usePropColorVariableAction = () => {
|
|
1242
|
-
const { propType } =
|
|
1383
|
+
const { propType } = useBoundProp9();
|
|
1243
1384
|
const visible = !!propType && supportsColorVariables(propType);
|
|
1244
1385
|
return {
|
|
1245
1386
|
visible,
|
|
1246
|
-
icon:
|
|
1247
|
-
title:
|
|
1387
|
+
icon: ColorFilterIcon5,
|
|
1388
|
+
title: __17("Variables", "elementor"),
|
|
1248
1389
|
content: ({ close: closePopover }) => {
|
|
1249
|
-
return /* @__PURE__ */
|
|
1390
|
+
return /* @__PURE__ */ React20.createElement(VariableSelectionPopover, { closePopover, propTypeKey: colorVariablePropTypeUtil.key });
|
|
1250
1391
|
}
|
|
1251
1392
|
};
|
|
1252
1393
|
};
|
|
1253
1394
|
|
|
1395
|
+
// src/repeater-injections.ts
|
|
1396
|
+
import { injectIntoRepeaterItemIcon, injectIntoRepeaterItemLabel } from "@elementor/editor-controls";
|
|
1397
|
+
import { backgroundColorOverlayPropTypeUtil, shadowPropTypeUtil } from "@elementor/editor-props";
|
|
1398
|
+
|
|
1399
|
+
// src/components/variables-repeater-item-slot.tsx
|
|
1400
|
+
import * as React21 from "react";
|
|
1401
|
+
var useColorVariable = (value) => {
|
|
1402
|
+
const variableId = value?.value?.color?.value;
|
|
1403
|
+
return useVariable(variableId || "");
|
|
1404
|
+
};
|
|
1405
|
+
var BackgroundRepeaterColorIndicator = ({ value }) => {
|
|
1406
|
+
const colorVariable = useColorVariable(value);
|
|
1407
|
+
return /* @__PURE__ */ React21.createElement(ColorIndicator, { component: "span", size: "inherit", value: colorVariable?.value });
|
|
1408
|
+
};
|
|
1409
|
+
var BackgroundRepeaterLabel = ({ value }) => {
|
|
1410
|
+
const colorVariable = useColorVariable(value);
|
|
1411
|
+
return /* @__PURE__ */ React21.createElement("span", null, colorVariable?.label);
|
|
1412
|
+
};
|
|
1413
|
+
var BoxShadowRepeaterColorIndicator = ({ value }) => {
|
|
1414
|
+
const colorVariable = useColorVariable(value);
|
|
1415
|
+
return /* @__PURE__ */ React21.createElement(ColorIndicator, { component: "span", size: "inherit", value: colorVariable?.value });
|
|
1416
|
+
};
|
|
1417
|
+
|
|
1418
|
+
// src/repeater-injections.ts
|
|
1419
|
+
function registerRepeaterInjections() {
|
|
1420
|
+
injectIntoRepeaterItemIcon({
|
|
1421
|
+
id: "color-variables-background-icon",
|
|
1422
|
+
component: BackgroundRepeaterColorIndicator,
|
|
1423
|
+
condition: ({ value: prop }) => {
|
|
1424
|
+
return hasAssignedColorVariable(backgroundColorOverlayPropTypeUtil.extract(prop)?.color);
|
|
1425
|
+
}
|
|
1426
|
+
});
|
|
1427
|
+
injectIntoRepeaterItemIcon({
|
|
1428
|
+
id: "color-variables-icon",
|
|
1429
|
+
component: BoxShadowRepeaterColorIndicator,
|
|
1430
|
+
condition: ({ value: prop }) => {
|
|
1431
|
+
return hasAssignedColorVariable(shadowPropTypeUtil.extract(prop)?.color);
|
|
1432
|
+
}
|
|
1433
|
+
});
|
|
1434
|
+
injectIntoRepeaterItemLabel({
|
|
1435
|
+
id: "color-variables-label",
|
|
1436
|
+
component: BackgroundRepeaterLabel,
|
|
1437
|
+
condition: ({ value: prop }) => {
|
|
1438
|
+
return hasAssignedColorVariable(backgroundColorOverlayPropTypeUtil.extract(prop)?.color);
|
|
1439
|
+
}
|
|
1440
|
+
});
|
|
1441
|
+
}
|
|
1442
|
+
|
|
1254
1443
|
// src/transformers/variable-transformer.ts
|
|
1255
1444
|
import { createTransformer } from "@elementor/editor-canvas";
|
|
1256
1445
|
var variableTransformer = createTransformer((value) => {
|
|
@@ -1262,15 +1451,7 @@ var variableTransformer = createTransformer((value) => {
|
|
|
1262
1451
|
|
|
1263
1452
|
// src/init-color-variables.ts
|
|
1264
1453
|
var { registerPopoverAction } = controlActionsMenu;
|
|
1265
|
-
|
|
1266
|
-
backgroundOverlay: ({ value: prop }) => {
|
|
1267
|
-
return hasAssignedColorVariable(backgroundColorOverlayPropTypeUtil.extract(prop)?.color);
|
|
1268
|
-
},
|
|
1269
|
-
boxShadow: ({ value: prop }) => {
|
|
1270
|
-
return hasAssignedColorVariable(shadowPropTypeUtil.extract(prop)?.color);
|
|
1271
|
-
}
|
|
1272
|
-
};
|
|
1273
|
-
function registerControlsAndActions() {
|
|
1454
|
+
function initColorVariables() {
|
|
1274
1455
|
registerControlReplacement({
|
|
1275
1456
|
component: ColorVariableControl,
|
|
1276
1457
|
condition: ({ value }) => hasAssignedColorVariable(value)
|
|
@@ -1279,34 +1460,8 @@ function registerControlsAndActions() {
|
|
|
1279
1460
|
id: "color-variables",
|
|
1280
1461
|
useProps: usePropColorVariableAction
|
|
1281
1462
|
});
|
|
1282
|
-
}
|
|
1283
|
-
function registerRepeaterItemIcons() {
|
|
1284
|
-
injectIntoRepeaterItemIcon({
|
|
1285
|
-
id: "color-variables-background-icon",
|
|
1286
|
-
component: BackgroundRepeaterColorIndicator,
|
|
1287
|
-
condition: conditions.backgroundOverlay
|
|
1288
|
-
});
|
|
1289
|
-
injectIntoRepeaterItemIcon({
|
|
1290
|
-
id: "color-variables-icon",
|
|
1291
|
-
component: BoxShadowRepeaterColorIndicator,
|
|
1292
|
-
condition: conditions.boxShadow
|
|
1293
|
-
});
|
|
1294
|
-
}
|
|
1295
|
-
function registerRepeaterItemLabels() {
|
|
1296
|
-
injectIntoRepeaterItemLabel({
|
|
1297
|
-
id: "color-variables-label",
|
|
1298
|
-
component: BackgroundRepeaterLabel,
|
|
1299
|
-
condition: conditions.backgroundOverlay
|
|
1300
|
-
});
|
|
1301
|
-
}
|
|
1302
|
-
function registerStyleTransformers() {
|
|
1303
1463
|
styleTransformersRegistry.register(colorVariablePropTypeUtil.key, variableTransformer);
|
|
1304
|
-
|
|
1305
|
-
function initColorVariables() {
|
|
1306
|
-
registerControlsAndActions();
|
|
1307
|
-
registerRepeaterItemIcons();
|
|
1308
|
-
registerRepeaterItemLabels();
|
|
1309
|
-
registerStyleTransformers();
|
|
1464
|
+
registerRepeaterInjections();
|
|
1310
1465
|
}
|
|
1311
1466
|
|
|
1312
1467
|
// src/init-font-variables.ts
|
|
@@ -1314,73 +1469,43 @@ import { styleTransformersRegistry as styleTransformersRegistry2 } from "@elemen
|
|
|
1314
1469
|
import { controlActionsMenu as controlActionsMenu2, registerControlReplacement as registerControlReplacement2 } from "@elementor/editor-editing-panel";
|
|
1315
1470
|
|
|
1316
1471
|
// src/controls/font-variable-control.tsx
|
|
1317
|
-
import * as
|
|
1318
|
-
import {
|
|
1319
|
-
import { useBoundProp as useBoundProp7 } from "@elementor/editor-controls";
|
|
1472
|
+
import * as React22 from "react";
|
|
1473
|
+
import { useBoundProp as useBoundProp10 } from "@elementor/editor-controls";
|
|
1320
1474
|
import { stringPropTypeUtil } from "@elementor/editor-props";
|
|
1321
|
-
import { ColorFilterIcon as ColorFilterIcon5 } from "@elementor/icons";
|
|
1322
|
-
import { bindPopover as bindPopover4, bindTrigger as bindTrigger4, Box as Box5, Popover as Popover4, usePopupState as usePopupState4 } from "@elementor/ui";
|
|
1323
1475
|
var FontVariableControl = () => {
|
|
1324
|
-
const {
|
|
1325
|
-
const
|
|
1326
|
-
|
|
1327
|
-
const popupId = useId3();
|
|
1328
|
-
const popupState = usePopupState4({
|
|
1329
|
-
variant: "popover",
|
|
1330
|
-
popupId: `elementor-variables-list-${popupId}`
|
|
1331
|
-
});
|
|
1332
|
-
const selectedVariable = useVariable(variableValue);
|
|
1333
|
-
if (!selectedVariable) {
|
|
1476
|
+
const { value: variableValue } = useBoundProp10(fontVariablePropTypeUtil);
|
|
1477
|
+
const assignedVariable = useVariable(variableValue);
|
|
1478
|
+
if (!assignedVariable) {
|
|
1334
1479
|
throw new Error(`Global font variable ${variableValue} not found`);
|
|
1335
1480
|
}
|
|
1336
|
-
const
|
|
1337
|
-
|
|
1338
|
-
|
|
1339
|
-
|
|
1340
|
-
|
|
1481
|
+
const isVariableDeleted = assignedVariable?.deleted;
|
|
1482
|
+
if (isVariableDeleted) {
|
|
1483
|
+
return /* @__PURE__ */ React22.createElement(DeletedVariable, { variable: assignedVariable });
|
|
1484
|
+
}
|
|
1485
|
+
return /* @__PURE__ */ React22.createElement(
|
|
1486
|
+
AssignedVariable,
|
|
1341
1487
|
{
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
...bindTrigger4(popupState)
|
|
1488
|
+
variable: assignedVariable,
|
|
1489
|
+
variablePropTypeUtil: fontVariablePropTypeUtil,
|
|
1490
|
+
fallbackPropTypeUtil: stringPropTypeUtil
|
|
1346
1491
|
}
|
|
1347
|
-
)
|
|
1348
|
-
Popover4,
|
|
1349
|
-
{
|
|
1350
|
-
disableScrollLock: true,
|
|
1351
|
-
anchorEl: anchorRef.current,
|
|
1352
|
-
anchorOrigin: { vertical: "bottom", horizontal: "right" },
|
|
1353
|
-
transformOrigin: { vertical: "top", horizontal: "right" },
|
|
1354
|
-
PaperProps: {
|
|
1355
|
-
sx: { my: 1 }
|
|
1356
|
-
},
|
|
1357
|
-
...bindPopover4(popupState)
|
|
1358
|
-
},
|
|
1359
|
-
/* @__PURE__ */ React15.createElement(
|
|
1360
|
-
VariableSelectionPopover,
|
|
1361
|
-
{
|
|
1362
|
-
selectedVariable,
|
|
1363
|
-
closePopover: popupState.close,
|
|
1364
|
-
propTypeKey: fontVariablePropTypeUtil.key
|
|
1365
|
-
}
|
|
1366
|
-
)
|
|
1367
|
-
));
|
|
1492
|
+
);
|
|
1368
1493
|
};
|
|
1369
1494
|
|
|
1370
1495
|
// src/hooks/use-prop-font-variable-action.tsx
|
|
1371
|
-
import * as
|
|
1372
|
-
import { useBoundProp as
|
|
1496
|
+
import * as React23 from "react";
|
|
1497
|
+
import { useBoundProp as useBoundProp11 } from "@elementor/editor-editing-panel";
|
|
1373
1498
|
import { ColorFilterIcon as ColorFilterIcon6 } from "@elementor/icons";
|
|
1374
|
-
import { __ as
|
|
1499
|
+
import { __ as __18 } from "@wordpress/i18n";
|
|
1375
1500
|
var usePropFontVariableAction = () => {
|
|
1376
|
-
const { propType } =
|
|
1501
|
+
const { propType } = useBoundProp11();
|
|
1377
1502
|
const visible = !!propType && supportsFontVariables(propType);
|
|
1378
1503
|
return {
|
|
1379
1504
|
visible,
|
|
1380
1505
|
icon: ColorFilterIcon6,
|
|
1381
|
-
title:
|
|
1506
|
+
title: __18("Variables", "elementor"),
|
|
1382
1507
|
content: ({ close: closePopover }) => {
|
|
1383
|
-
return /* @__PURE__ */
|
|
1508
|
+
return /* @__PURE__ */ React23.createElement(VariableSelectionPopover, { closePopover, propTypeKey: fontVariablePropTypeUtil.key });
|
|
1384
1509
|
}
|
|
1385
1510
|
};
|
|
1386
1511
|
};
|
|
@@ -1400,8 +1525,8 @@ function initFontVariables() {
|
|
|
1400
1525
|
}
|
|
1401
1526
|
|
|
1402
1527
|
// src/renderers/style-variables-renderer.tsx
|
|
1403
|
-
import * as
|
|
1404
|
-
import { useEffect, useState as
|
|
1528
|
+
import * as React24 from "react";
|
|
1529
|
+
import { useEffect, useState as useState11 } from "react";
|
|
1405
1530
|
import { __privateUseListenTo as useListenTo, commandEndEvent } from "@elementor/editor-v1-adapters";
|
|
1406
1531
|
import { Portal } from "@elementor/ui";
|
|
1407
1532
|
|
|
@@ -1422,13 +1547,13 @@ function StyleVariablesRenderer() {
|
|
|
1422
1547
|
}
|
|
1423
1548
|
const cssVariables = convertToCssVariables(styleVariables);
|
|
1424
1549
|
const wrappedCss = `${VARIABLES_WRAPPER}{${cssVariables}}`;
|
|
1425
|
-
return /* @__PURE__ */
|
|
1550
|
+
return /* @__PURE__ */ React24.createElement(Portal, { container }, /* @__PURE__ */ React24.createElement("style", { "data-e-style-id": "e-variables", key: wrappedCss }, wrappedCss));
|
|
1426
1551
|
}
|
|
1427
1552
|
function usePortalContainer() {
|
|
1428
1553
|
return useListenTo(commandEndEvent("editor/documents/attach-preview"), () => getCanvasIframeDocument()?.head);
|
|
1429
1554
|
}
|
|
1430
1555
|
function useStyleVariables() {
|
|
1431
|
-
const [variables, setVariables] =
|
|
1556
|
+
const [variables, setVariables] = useState11({});
|
|
1432
1557
|
useEffect(() => {
|
|
1433
1558
|
const unsubscribe = styleVariablesRepository.subscribe(setVariables);
|
|
1434
1559
|
return () => {
|