@elementor/editor-variables 0.14.0 → 0.16.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +76 -0
- package/dist/index.js +743 -500
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +720 -528
- package/dist/index.mjs.map +1 -1
- package/package.json +10 -10
- package/src/components/color-variable-creation.tsx +18 -57
- package/src/components/color-variable-edit.tsx +100 -79
- package/src/components/color-variables-selection.tsx +33 -20
- 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 +19 -76
- package/src/components/font-variable-edit.tsx +98 -106
- package/src/components/font-variables-selection.tsx +33 -20
- package/src/components/ui/color-indicator.tsx +1 -0
- package/src/components/ui/delete-confirmation-dialog.tsx +55 -0
- package/src/components/ui/menu-item-content.tsx +29 -23
- package/src/components/ui/no-search-results.tsx +6 -8
- package/src/components/ui/no-variables.tsx +3 -2
- package/src/components/ui/tags/assigned-tag.tsx +43 -0
- 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/components/variable-selection-popover.context.ts +7 -0
- package/src/components/variable-selection-popover.tsx +17 -8
- package/src/controls/color-variable-control.tsx +15 -72
- package/src/controls/font-variable-control.tsx +14 -71
- package/src/hooks/use-prop-variables.ts +12 -18
- 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";
|
|
@@ -278,113 +317,147 @@ var useFilteredVariables = (searchValue, propTypeKey) => {
|
|
|
278
317
|
var usePropVariables = (propKey) => {
|
|
279
318
|
return useMemo(() => normalizeVariables(propKey), [propKey]);
|
|
280
319
|
};
|
|
320
|
+
var isNotDeleted = ({ deleted }) => !deleted;
|
|
281
321
|
var normalizeVariables = (propKey) => {
|
|
282
322
|
const variables = service.variables();
|
|
283
|
-
|
|
284
|
-
return Object.entries(variables).filter(([, { type }]) => type === propKey).map(([key, { label, value }]) => ({
|
|
323
|
+
return Object.entries(variables).filter(([, variable]) => variable.type === propKey && isNotDeleted(variable)).map(([key, { label, value }]) => ({
|
|
285
324
|
key,
|
|
286
325
|
label,
|
|
287
326
|
value
|
|
288
327
|
}));
|
|
289
328
|
};
|
|
290
329
|
var createVariable = (newVariable) => {
|
|
291
|
-
return service.create(newVariable).then(({ id
|
|
292
|
-
styleVariablesRepository.update({
|
|
293
|
-
[id]: variable
|
|
294
|
-
});
|
|
330
|
+
return service.create(newVariable).then(({ id }) => {
|
|
295
331
|
return id;
|
|
296
332
|
});
|
|
297
333
|
};
|
|
298
334
|
var updateVariable = (updateId, { value, label }) => {
|
|
299
|
-
return service.update(updateId, { value, label }).then(({ id
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
335
|
+
return service.update(updateId, { value, label }).then(({ id }) => {
|
|
336
|
+
return id;
|
|
337
|
+
});
|
|
338
|
+
};
|
|
339
|
+
var deleteVariable = (deleteId) => {
|
|
340
|
+
return service.delete(deleteId).then(({ id }) => {
|
|
303
341
|
return id;
|
|
304
342
|
});
|
|
305
343
|
};
|
|
306
344
|
|
|
307
|
-
// src/components/
|
|
308
|
-
import
|
|
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
|
-
|
|
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 "";
|
|
321
370
|
};
|
|
322
|
-
var
|
|
323
|
-
const
|
|
324
|
-
|
|
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 "";
|
|
325
377
|
};
|
|
326
|
-
var
|
|
327
|
-
|
|
328
|
-
|
|
378
|
+
var validateValue = (value) => {
|
|
379
|
+
if (!value.trim()) {
|
|
380
|
+
return __("Missing variable value.", "elementor");
|
|
381
|
+
}
|
|
382
|
+
return "";
|
|
329
383
|
};
|
|
330
384
|
|
|
331
|
-
// src/
|
|
332
|
-
import
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
import {
|
|
338
|
-
bindPopover as bindPopover3,
|
|
339
|
-
bindTrigger as bindTrigger3,
|
|
340
|
-
Box,
|
|
341
|
-
IconButton as IconButton8,
|
|
342
|
-
Popover as Popover3,
|
|
343
|
-
Stack as Stack7,
|
|
344
|
-
Typography as Typography3,
|
|
345
|
-
UnstableTag as Tag,
|
|
346
|
-
usePopupState as usePopupState3
|
|
347
|
-
} from "@elementor/ui";
|
|
348
|
-
import { __ as __10 } from "@wordpress/i18n";
|
|
349
|
-
|
|
350
|
-
// src/components/variable-selection-popover.tsx
|
|
351
|
-
import * as React11 from "react";
|
|
352
|
-
import { useRef as useRef5, useState as useState7 } from "react";
|
|
385
|
+
// src/components/variable-selection-popover.context.ts
|
|
386
|
+
import { createContext, useContext } from "react";
|
|
387
|
+
var PopoverContentRefContext = createContext(null);
|
|
388
|
+
var usePopoverContentRef = () => {
|
|
389
|
+
return useContext(PopoverContentRefContext);
|
|
390
|
+
};
|
|
353
391
|
|
|
354
|
-
// src/
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
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
|
+
};
|
|
358
422
|
|
|
359
|
-
// src/
|
|
360
|
-
import
|
|
361
|
-
import {
|
|
362
|
-
|
|
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
|
+
};
|
|
363
454
|
|
|
364
455
|
// src/components/color-variable-creation.tsx
|
|
365
|
-
import * as React2 from "react";
|
|
366
|
-
import { useRef, useState } from "react";
|
|
367
|
-
import { useBoundProp } from "@elementor/editor-controls";
|
|
368
|
-
import { PopoverHeader } from "@elementor/editor-ui";
|
|
369
|
-
import { ArrowLeftIcon, BrushIcon } from "@elementor/icons";
|
|
370
|
-
import {
|
|
371
|
-
Button,
|
|
372
|
-
CardActions,
|
|
373
|
-
Divider,
|
|
374
|
-
FormLabel,
|
|
375
|
-
Grid,
|
|
376
|
-
IconButton,
|
|
377
|
-
Stack,
|
|
378
|
-
TextField,
|
|
379
|
-
UnstableColorField
|
|
380
|
-
} from "@elementor/ui";
|
|
381
|
-
import { __ } from "@wordpress/i18n";
|
|
382
456
|
var SIZE = "tiny";
|
|
383
457
|
var ColorVariableCreation = ({ onGoBack, onClose }) => {
|
|
384
458
|
const { setValue: setVariable } = useBoundProp(colorVariablePropTypeUtil);
|
|
385
|
-
const [color, setColor] =
|
|
386
|
-
const [label, setLabel] =
|
|
387
|
-
const anchorRef = useRef(null);
|
|
459
|
+
const [color, setColor] = useState3("");
|
|
460
|
+
const [label, setLabel] = useState3("");
|
|
388
461
|
const resetFields = () => {
|
|
389
462
|
setColor("");
|
|
390
463
|
setLabel("");
|
|
@@ -403,154 +476,193 @@ var ColorVariableCreation = ({ onGoBack, onClose }) => {
|
|
|
403
476
|
closePopover();
|
|
404
477
|
});
|
|
405
478
|
};
|
|
406
|
-
const
|
|
407
|
-
return
|
|
479
|
+
const hasEmptyValue = () => {
|
|
480
|
+
return "" === color.trim() || "" === label.trim();
|
|
408
481
|
};
|
|
409
|
-
|
|
482
|
+
const isSubmitDisabled = hasEmptyValue();
|
|
483
|
+
return /* @__PURE__ */ React3.createElement(PopoverScrollableContent, { height: "auto" }, /* @__PURE__ */ React3.createElement(
|
|
410
484
|
PopoverHeader,
|
|
411
485
|
{
|
|
412
|
-
icon: /* @__PURE__ */
|
|
413
|
-
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"),
|
|
414
488
|
onClose: closePopover
|
|
415
489
|
}
|
|
416
|
-
), /* @__PURE__ */
|
|
417
|
-
TextField,
|
|
418
|
-
{
|
|
419
|
-
size: "tiny",
|
|
420
|
-
fullWidth: true,
|
|
421
|
-
value: label,
|
|
422
|
-
onChange: (e) => setLabel(e.target.value)
|
|
423
|
-
}
|
|
424
|
-
))), /* @__PURE__ */ React2.createElement(Grid, { container: true, gap: 0.75, alignItems: "center" }, /* @__PURE__ */ React2.createElement(Grid, { item: true, xs: 12 }, /* @__PURE__ */ React2.createElement(FormLabel, { size: "small" }, __("Value", "elementor"))), /* @__PURE__ */ React2.createElement(Grid, { item: true, xs: 12 }, /* @__PURE__ */ React2.createElement(
|
|
425
|
-
UnstableColorField,
|
|
426
|
-
{
|
|
427
|
-
size: "tiny",
|
|
428
|
-
fullWidth: true,
|
|
429
|
-
value: color,
|
|
430
|
-
onChange: setColor,
|
|
431
|
-
slotProps: {
|
|
432
|
-
colorPicker: {
|
|
433
|
-
anchorEl: anchorRef.current,
|
|
434
|
-
anchorOrigin: { vertical: "top", horizontal: "right" },
|
|
435
|
-
transformOrigin: { vertical: "top", horizontal: -10 }
|
|
436
|
-
}
|
|
437
|
-
}
|
|
438
|
-
}
|
|
439
|
-
)))), /* @__PURE__ */ React2.createElement(CardActions, null, /* @__PURE__ */ React2.createElement(Button, { size: "small", variant: "contained", disabled: isFormInvalid(), onClick: handleCreate }, __("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"))));
|
|
440
491
|
};
|
|
441
492
|
|
|
442
493
|
// src/components/color-variable-edit.tsx
|
|
443
|
-
import * as
|
|
444
|
-
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";
|
|
445
498
|
import { PopoverHeader as PopoverHeader2 } from "@elementor/editor-ui";
|
|
446
|
-
import { ArrowLeftIcon as ArrowLeftIcon2, BrushIcon as BrushIcon2 } from "@elementor/icons";
|
|
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";
|
|
447
506
|
import {
|
|
448
507
|
Button as Button2,
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
TextField as TextField2,
|
|
456
|
-
UnstableColorField as UnstableColorField2
|
|
508
|
+
Dialog,
|
|
509
|
+
DialogActions,
|
|
510
|
+
DialogContent,
|
|
511
|
+
DialogContentText,
|
|
512
|
+
DialogTitle,
|
|
513
|
+
Typography
|
|
457
514
|
} from "@elementor/ui";
|
|
458
|
-
import { __ as
|
|
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
|
|
459
530
|
var SIZE2 = "tiny";
|
|
460
531
|
var ColorVariableEdit = ({ onClose, onGoBack, onSubmit, editId }) => {
|
|
532
|
+
const { setValue: notifyBoundPropChange, value: assignedValue } = useBoundProp2(colorVariablePropTypeUtil);
|
|
533
|
+
const [deleteConfirmation, setDeleteConfirmation] = useState4(false);
|
|
461
534
|
const variable = useVariable(editId);
|
|
462
535
|
if (!variable) {
|
|
463
536
|
throw new Error(`Global color variable not found`);
|
|
464
537
|
}
|
|
465
|
-
const
|
|
466
|
-
const [
|
|
467
|
-
const [label, setLabel] = useState2(variable.label);
|
|
538
|
+
const [color, setColor] = useState4(variable.value);
|
|
539
|
+
const [label, setLabel] = useState4(variable.label);
|
|
468
540
|
const handleUpdate = () => {
|
|
469
541
|
updateVariable(editId, {
|
|
470
542
|
value: color,
|
|
471
543
|
label
|
|
472
544
|
}).then(() => {
|
|
545
|
+
maybeTriggerBoundPropChange();
|
|
473
546
|
onSubmit?.();
|
|
474
547
|
});
|
|
475
548
|
};
|
|
476
|
-
const
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
549
|
+
const handleDelete = () => {
|
|
550
|
+
deleteVariable(editId).then(() => {
|
|
551
|
+
maybeTriggerBoundPropChange();
|
|
552
|
+
onSubmit?.();
|
|
553
|
+
});
|
|
554
|
+
};
|
|
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
|
+
};
|
|
566
|
+
const actions = [];
|
|
567
|
+
actions.push(
|
|
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
|
+
)
|
|
578
|
+
);
|
|
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(
|
|
480
587
|
PopoverHeader2,
|
|
481
588
|
{
|
|
482
|
-
title:
|
|
589
|
+
title: __6("Edit variable", "elementor"),
|
|
483
590
|
onClose,
|
|
484
|
-
icon: /* @__PURE__ */
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
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 })),
|
|
600
|
+
actions
|
|
493
601
|
}
|
|
494
|
-
))
|
|
495
|
-
|
|
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,
|
|
496
604
|
{
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
slotProps: {
|
|
502
|
-
colorPicker: {
|
|
503
|
-
anchorEl: anchorRef.current,
|
|
504
|
-
anchorOrigin: { vertical: "top", horizontal: "right" },
|
|
505
|
-
transformOrigin: { vertical: "top", horizontal: -10 }
|
|
506
|
-
}
|
|
507
|
-
}
|
|
605
|
+
open: true,
|
|
606
|
+
label,
|
|
607
|
+
onConfirm: handleDelete,
|
|
608
|
+
closeDialog: closeDeleteDialog()
|
|
508
609
|
}
|
|
509
|
-
))
|
|
610
|
+
));
|
|
510
611
|
};
|
|
511
612
|
|
|
512
613
|
// src/components/color-variables-selection.tsx
|
|
513
|
-
import * as
|
|
514
|
-
import { useState as
|
|
515
|
-
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";
|
|
617
|
+
import { PopoverScrollableContent as PopoverScrollableContent3 } from "@elementor/editor-editing-panel";
|
|
516
618
|
import { PopoverHeader as PopoverHeader3, PopoverMenuList, PopoverSearch } from "@elementor/editor-ui";
|
|
517
|
-
import {
|
|
619
|
+
import { BrushIcon as BrushIcon3, ColorFilterIcon, PlusIcon, SettingsIcon } from "@elementor/icons";
|
|
518
620
|
import { Divider as Divider3, IconButton as IconButton4 } from "@elementor/ui";
|
|
519
|
-
import { __ as
|
|
621
|
+
import { __ as __10 } from "@wordpress/i18n";
|
|
520
622
|
|
|
521
623
|
// src/components/ui/menu-item-content.tsx
|
|
522
|
-
import * as
|
|
624
|
+
import * as React6 from "react";
|
|
625
|
+
import { EllipsisWithTooltip } from "@elementor/editor-ui";
|
|
523
626
|
import { EditIcon } from "@elementor/icons";
|
|
524
|
-
import { IconButton as IconButton3, ListItemIcon,
|
|
525
|
-
import { __ as
|
|
627
|
+
import { Box, IconButton as IconButton3, ListItemIcon, Typography as Typography2 } from "@elementor/ui";
|
|
628
|
+
import { __ as __7 } from "@wordpress/i18n";
|
|
526
629
|
var SIZE3 = "tiny";
|
|
527
630
|
var MenuItemContent = ({ item }) => {
|
|
528
631
|
const onEdit = item.onEdit;
|
|
529
|
-
return /* @__PURE__ */
|
|
530
|
-
|
|
632
|
+
return /* @__PURE__ */ React6.createElement(React6.Fragment, null, /* @__PURE__ */ React6.createElement(ListItemIcon, null, item.icon), /* @__PURE__ */ React6.createElement(
|
|
633
|
+
Box,
|
|
531
634
|
{
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
635
|
+
sx: {
|
|
636
|
+
flex: 1,
|
|
637
|
+
minWidth: 0,
|
|
638
|
+
display: "flex",
|
|
639
|
+
alignItems: "center",
|
|
640
|
+
gap: 1
|
|
641
|
+
}
|
|
642
|
+
},
|
|
643
|
+
/* @__PURE__ */ React6.createElement(
|
|
644
|
+
EllipsisWithTooltip,
|
|
645
|
+
{
|
|
646
|
+
title: item.label || item.value,
|
|
647
|
+
as: Typography2,
|
|
648
|
+
variant: "caption",
|
|
649
|
+
color: "text.primary",
|
|
650
|
+
sx: { marginTop: "1px", lineHeight: "2" },
|
|
651
|
+
maxWidth: "50%"
|
|
652
|
+
}
|
|
653
|
+
),
|
|
654
|
+
item.secondaryText && /* @__PURE__ */ React6.createElement(
|
|
655
|
+
EllipsisWithTooltip,
|
|
656
|
+
{
|
|
657
|
+
title: item.secondaryText,
|
|
658
|
+
as: Typography2,
|
|
547
659
|
variant: "caption",
|
|
548
660
|
color: "text.tertiary",
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
), !!onEdit && /* @__PURE__ */
|
|
661
|
+
sx: { marginTop: "1px", lineHeight: "1" },
|
|
662
|
+
maxWidth: "50%"
|
|
663
|
+
}
|
|
664
|
+
)
|
|
665
|
+
), !!onEdit && /* @__PURE__ */ React6.createElement(
|
|
554
666
|
IconButton3,
|
|
555
667
|
{
|
|
556
668
|
sx: { mx: 1, opacity: "0" },
|
|
@@ -558,40 +670,40 @@ var MenuItemContent = ({ item }) => {
|
|
|
558
670
|
e.stopPropagation();
|
|
559
671
|
onEdit(item.value);
|
|
560
672
|
},
|
|
561
|
-
"aria-label":
|
|
673
|
+
"aria-label": __7("Edit", "elementor")
|
|
562
674
|
},
|
|
563
|
-
/* @__PURE__ */
|
|
675
|
+
/* @__PURE__ */ React6.createElement(EditIcon, { color: "action", fontSize: SIZE3 })
|
|
564
676
|
));
|
|
565
677
|
};
|
|
566
678
|
|
|
567
679
|
// src/components/ui/no-search-results.tsx
|
|
568
|
-
import * as
|
|
569
|
-
import {
|
|
570
|
-
import {
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
Stack3,
|
|
680
|
+
import * as React7 from "react";
|
|
681
|
+
import { Link, Stack, Typography as Typography3 } from "@elementor/ui";
|
|
682
|
+
import { __ as __8 } from "@wordpress/i18n";
|
|
683
|
+
var NoSearchResults = ({ searchValue, onClear, icon }) => {
|
|
684
|
+
return /* @__PURE__ */ React7.createElement(
|
|
685
|
+
Stack,
|
|
575
686
|
{
|
|
576
687
|
gap: 1,
|
|
577
688
|
alignItems: "center",
|
|
578
689
|
justifyContent: "center",
|
|
579
690
|
height: "100%",
|
|
691
|
+
p: 2.5,
|
|
580
692
|
color: "text.secondary",
|
|
581
|
-
sx: {
|
|
693
|
+
sx: { pb: 3.5 }
|
|
582
694
|
},
|
|
583
|
-
|
|
584
|
-
/* @__PURE__ */
|
|
585
|
-
/* @__PURE__ */
|
|
695
|
+
icon,
|
|
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")))
|
|
586
698
|
);
|
|
587
699
|
};
|
|
588
700
|
|
|
589
701
|
// src/components/ui/no-variables.tsx
|
|
590
|
-
import * as
|
|
591
|
-
import { Button as
|
|
592
|
-
import { __ as
|
|
593
|
-
var NoVariables = ({ icon, onAdd }) => /* @__PURE__ */
|
|
594
|
-
|
|
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,
|
|
595
707
|
{
|
|
596
708
|
gap: 1,
|
|
597
709
|
alignItems: "center",
|
|
@@ -601,9 +713,9 @@ var NoVariables = ({ icon, onAdd }) => /* @__PURE__ */ React6.createElement(
|
|
|
601
713
|
sx: { p: 2.5, pb: 5.5 }
|
|
602
714
|
},
|
|
603
715
|
icon,
|
|
604
|
-
/* @__PURE__ */
|
|
605
|
-
/* @__PURE__ */
|
|
606
|
-
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"))
|
|
607
719
|
);
|
|
608
720
|
|
|
609
721
|
// src/components/ui/styled-menu-list.tsx
|
|
@@ -641,8 +753,8 @@ var VariablesStyledMenuList = styled2(MenuList)(({ theme }) => ({
|
|
|
641
753
|
// src/components/color-variables-selection.tsx
|
|
642
754
|
var SIZE4 = "tiny";
|
|
643
755
|
var ColorVariablesSelection = ({ closePopover, onAdd, onEdit, onSettings }) => {
|
|
644
|
-
const { value: variable, setValue: setVariable } =
|
|
645
|
-
const [searchValue, setSearchValue] =
|
|
756
|
+
const { value: variable, setValue: setVariable } = useBoundProp3(colorVariablePropTypeUtil);
|
|
757
|
+
const [searchValue, setSearchValue] = useState5("");
|
|
646
758
|
const {
|
|
647
759
|
list: variables,
|
|
648
760
|
hasMatches: hasSearchResults,
|
|
@@ -655,19 +767,19 @@ var ColorVariablesSelection = ({ closePopover, onAdd, onEdit, onSettings }) => {
|
|
|
655
767
|
const actions = [];
|
|
656
768
|
if (onAdd) {
|
|
657
769
|
actions.push(
|
|
658
|
-
/* @__PURE__ */
|
|
770
|
+
/* @__PURE__ */ React9.createElement(IconButton4, { key: "add", size: SIZE4, onClick: onAdd }, /* @__PURE__ */ React9.createElement(PlusIcon, { fontSize: SIZE4 }))
|
|
659
771
|
);
|
|
660
772
|
}
|
|
661
773
|
if (onSettings) {
|
|
662
774
|
actions.push(
|
|
663
|
-
/* @__PURE__ */
|
|
775
|
+
/* @__PURE__ */ React9.createElement(IconButton4, { key: "settings", size: SIZE4, onClick: onSettings }, /* @__PURE__ */ React9.createElement(SettingsIcon, { fontSize: SIZE4 }))
|
|
664
776
|
);
|
|
665
777
|
}
|
|
666
778
|
const items = variables.map(({ value, label, key }) => ({
|
|
667
779
|
type: "item",
|
|
668
780
|
value: key,
|
|
669
781
|
label,
|
|
670
|
-
icon: /* @__PURE__ */
|
|
782
|
+
icon: /* @__PURE__ */ React9.createElement(ColorIndicator, { size: "inherit", component: "span", value }),
|
|
671
783
|
secondaryText: value,
|
|
672
784
|
onEdit: () => onEdit?.(key)
|
|
673
785
|
}));
|
|
@@ -677,22 +789,22 @@ var ColorVariablesSelection = ({ closePopover, onAdd, onEdit, onSettings }) => {
|
|
|
677
789
|
const handleClearSearch = () => {
|
|
678
790
|
setSearchValue("");
|
|
679
791
|
};
|
|
680
|
-
return /* @__PURE__ */
|
|
792
|
+
return /* @__PURE__ */ React9.createElement(React9.Fragment, null, /* @__PURE__ */ React9.createElement(
|
|
681
793
|
PopoverHeader3,
|
|
682
794
|
{
|
|
683
|
-
title:
|
|
684
|
-
icon: /* @__PURE__ */
|
|
795
|
+
title: __10("Variables", "elementor"),
|
|
796
|
+
icon: /* @__PURE__ */ React9.createElement(ColorFilterIcon, { fontSize: SIZE4 }),
|
|
685
797
|
onClose: closePopover,
|
|
686
798
|
actions
|
|
687
799
|
}
|
|
688
|
-
), hasVariables && /* @__PURE__ */
|
|
800
|
+
), hasVariables && /* @__PURE__ */ React9.createElement(
|
|
689
801
|
PopoverSearch,
|
|
690
802
|
{
|
|
691
803
|
value: searchValue,
|
|
692
804
|
onSearch: handleSearch,
|
|
693
|
-
placeholder:
|
|
805
|
+
placeholder: __10("Search", "elementor")
|
|
694
806
|
}
|
|
695
|
-
), /* @__PURE__ */
|
|
807
|
+
), /* @__PURE__ */ React9.createElement(Divider3, null), /* @__PURE__ */ React9.createElement(PopoverScrollableContent3, null, hasVariables && hasSearchResults && /* @__PURE__ */ React9.createElement(
|
|
696
808
|
PopoverMenuList,
|
|
697
809
|
{
|
|
698
810
|
items,
|
|
@@ -702,88 +814,80 @@ var ColorVariablesSelection = ({ closePopover, onAdd, onEdit, onSettings }) => {
|
|
|
702
814
|
selectedValue: variable,
|
|
703
815
|
"data-testid": "color-variables-list",
|
|
704
816
|
menuListTemplate: VariablesStyledMenuList,
|
|
705
|
-
menuItemContentTemplate: (item) => /* @__PURE__ */
|
|
817
|
+
menuItemContentTemplate: (item) => /* @__PURE__ */ React9.createElement(MenuItemContent, { item })
|
|
706
818
|
}
|
|
707
|
-
), !hasSearchResults && hasVariables && /* @__PURE__ */
|
|
819
|
+
), !hasSearchResults && hasVariables && /* @__PURE__ */ React9.createElement(
|
|
820
|
+
NoSearchResults,
|
|
821
|
+
{
|
|
822
|
+
searchValue,
|
|
823
|
+
onClear: handleClearSearch,
|
|
824
|
+
icon: /* @__PURE__ */ React9.createElement(BrushIcon3, { fontSize: "large" })
|
|
825
|
+
}
|
|
826
|
+
), !hasVariables && /* @__PURE__ */ React9.createElement(
|
|
827
|
+
NoVariables,
|
|
828
|
+
{
|
|
829
|
+
title: __10("Create your first color variable", "elementor"),
|
|
830
|
+
icon: /* @__PURE__ */ React9.createElement(BrushIcon3, { fontSize: "large" }),
|
|
831
|
+
onAdd
|
|
832
|
+
}
|
|
833
|
+
)));
|
|
708
834
|
};
|
|
709
835
|
|
|
710
836
|
// src/components/font-variable-creation.tsx
|
|
711
|
-
import * as
|
|
712
|
-
import {
|
|
713
|
-
import {
|
|
714
|
-
import {
|
|
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";
|
|
715
841
|
import { PopoverHeader as PopoverHeader4 } from "@elementor/editor-ui";
|
|
716
|
-
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";
|
|
717
852
|
import {
|
|
718
853
|
bindPopover,
|
|
719
854
|
bindTrigger,
|
|
720
|
-
|
|
721
|
-
CardActions as CardActions3,
|
|
722
|
-
Divider as Divider4,
|
|
855
|
+
FormHelperText as FormHelperText3,
|
|
723
856
|
FormLabel as FormLabel3,
|
|
724
857
|
Grid as Grid3,
|
|
725
|
-
IconButton as IconButton5,
|
|
726
858
|
Popover,
|
|
727
|
-
Stack as Stack5,
|
|
728
|
-
TextField as TextField3,
|
|
729
859
|
UnstableTag,
|
|
730
860
|
usePopupState
|
|
731
861
|
} from "@elementor/ui";
|
|
732
|
-
import { __ as
|
|
733
|
-
var
|
|
734
|
-
|
|
735
|
-
const
|
|
736
|
-
const
|
|
737
|
-
const
|
|
738
|
-
const [label, setLabel] = useState4("");
|
|
739
|
-
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;
|
|
740
868
|
const fontPopoverState = usePopupState({ variant: "popover" });
|
|
741
|
-
const
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
};
|
|
749
|
-
const handleCreate = () => {
|
|
750
|
-
createVariable({
|
|
751
|
-
value: fontFamily,
|
|
752
|
-
label,
|
|
753
|
-
type: fontVariablePropTypeUtil.key
|
|
754
|
-
}).then((key) => {
|
|
755
|
-
setVariable(key);
|
|
756
|
-
closePopover();
|
|
757
|
-
});
|
|
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);
|
|
758
876
|
};
|
|
759
|
-
const
|
|
760
|
-
|
|
877
|
+
const handleFontFamilyChange = (newFontFamily) => {
|
|
878
|
+
handleChange(newFontFamily);
|
|
879
|
+
fontPopoverState.close();
|
|
761
880
|
};
|
|
762
|
-
return /* @__PURE__ */
|
|
763
|
-
PopoverHeader4,
|
|
764
|
-
{
|
|
765
|
-
icon: /* @__PURE__ */ React8.createElement(React8.Fragment, null, onGoBack && /* @__PURE__ */ React8.createElement(IconButton5, { size: SIZE5, "aria-label": __7("Go Back", "elementor"), onClick: onGoBack }, /* @__PURE__ */ React8.createElement(ArrowLeftIcon3, { fontSize: SIZE5 })), /* @__PURE__ */ React8.createElement(TextIcon, { fontSize: SIZE5 })),
|
|
766
|
-
title: __7("Create variable", "elementor"),
|
|
767
|
-
onClose: closePopover
|
|
768
|
-
}
|
|
769
|
-
), /* @__PURE__ */ React8.createElement(Divider4, null), /* @__PURE__ */ React8.createElement(Stack5, { p: 1.5, gap: 1.5 }, /* @__PURE__ */ React8.createElement(Grid3, { container: true, gap: 0.75, alignItems: "center" }, /* @__PURE__ */ React8.createElement(Grid3, { item: true, xs: 12 }, /* @__PURE__ */ React8.createElement(FormLabel3, { size: "small" }, __7("Name", "elementor"))), /* @__PURE__ */ React8.createElement(Grid3, { item: true, xs: 12 }, /* @__PURE__ */ React8.createElement(
|
|
770
|
-
TextField3,
|
|
771
|
-
{
|
|
772
|
-
size: "tiny",
|
|
773
|
-
fullWidth: true,
|
|
774
|
-
value: label,
|
|
775
|
-
onChange: (e) => setLabel(e.target.value)
|
|
776
|
-
}
|
|
777
|
-
))), /* @__PURE__ */ React8.createElement(Grid3, { container: true, gap: 0.75, alignItems: "center" }, /* @__PURE__ */ React8.createElement(Grid3, { item: true, xs: 12 }, /* @__PURE__ */ React8.createElement(FormLabel3, { size: "small" }, __7("Value", "elementor"))), /* @__PURE__ */ React8.createElement(Grid3, { item: true, xs: 12 }, /* @__PURE__ */ React8.createElement(React8.Fragment, null, /* @__PURE__ */ React8.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(
|
|
778
882
|
UnstableTag,
|
|
779
883
|
{
|
|
780
884
|
variant: "outlined",
|
|
781
885
|
label: fontFamily,
|
|
782
|
-
endIcon: /* @__PURE__ */
|
|
886
|
+
endIcon: /* @__PURE__ */ React10.createElement(ChevronDownIcon, { fontSize: "tiny" }),
|
|
783
887
|
...bindTrigger(fontPopoverState),
|
|
784
888
|
fullWidth: true
|
|
785
889
|
}
|
|
786
|
-
), /* @__PURE__ */
|
|
890
|
+
), /* @__PURE__ */ React10.createElement(
|
|
787
891
|
Popover,
|
|
788
892
|
{
|
|
789
893
|
disablePortal: true,
|
|
@@ -793,125 +897,162 @@ var FontVariableCreation = ({ onClose, onGoBack }) => {
|
|
|
793
897
|
transformOrigin: { vertical: "top", horizontal: -20 },
|
|
794
898
|
...bindPopover(fontPopoverState)
|
|
795
899
|
},
|
|
796
|
-
/* @__PURE__ */
|
|
900
|
+
/* @__PURE__ */ React10.createElement(
|
|
797
901
|
FontFamilySelector,
|
|
798
902
|
{
|
|
799
903
|
fontFamilies,
|
|
800
904
|
fontFamily,
|
|
801
|
-
onFontFamilyChange:
|
|
802
|
-
onClose: fontPopoverState.close
|
|
905
|
+
onFontFamilyChange: handleFontFamilyChange,
|
|
906
|
+
onClose: fontPopoverState.close,
|
|
907
|
+
sectionWidth
|
|
803
908
|
}
|
|
804
909
|
)
|
|
805
|
-
)
|
|
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"))));
|
|
806
949
|
};
|
|
807
950
|
|
|
808
951
|
// src/components/font-variable-edit.tsx
|
|
809
|
-
import * as
|
|
810
|
-
import {
|
|
811
|
-
import {
|
|
812
|
-
import {
|
|
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";
|
|
813
956
|
import { PopoverHeader as PopoverHeader5 } from "@elementor/editor-ui";
|
|
814
|
-
import { ArrowLeftIcon as ArrowLeftIcon4,
|
|
815
|
-
import {
|
|
816
|
-
|
|
817
|
-
bindTrigger as bindTrigger2,
|
|
818
|
-
Button as Button5,
|
|
819
|
-
CardActions as CardActions4,
|
|
820
|
-
Divider as Divider5,
|
|
821
|
-
FormLabel as FormLabel4,
|
|
822
|
-
Grid as Grid4,
|
|
823
|
-
IconButton as IconButton6,
|
|
824
|
-
Popover as Popover2,
|
|
825
|
-
Stack as Stack6,
|
|
826
|
-
TextField as TextField4,
|
|
827
|
-
UnstableTag as UnstableTag2,
|
|
828
|
-
usePopupState as usePopupState2
|
|
829
|
-
} from "@elementor/ui";
|
|
830
|
-
import { __ as __8 } from "@wordpress/i18n";
|
|
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";
|
|
831
960
|
var SIZE6 = "tiny";
|
|
832
961
|
var FontVariableEdit = ({ onClose, onGoBack, onSubmit, editId }) => {
|
|
962
|
+
const { setValue: notifyBoundPropChange, value: assignedValue } = useBoundProp5(fontVariablePropTypeUtil);
|
|
963
|
+
const [deleteConfirmation, setDeleteConfirmation] = useState8(false);
|
|
833
964
|
const variable = useVariable(editId);
|
|
834
965
|
if (!variable) {
|
|
835
966
|
throw new Error(`Global font variable "${editId}" not found`);
|
|
836
967
|
}
|
|
837
|
-
const [fontFamily, setFontFamily] =
|
|
838
|
-
const [label, setLabel] =
|
|
839
|
-
const variableNameId = useId();
|
|
840
|
-
const variableValueId = useId();
|
|
841
|
-
const anchorRef = useRef4(null);
|
|
842
|
-
const fontPopoverState = usePopupState2({ variant: "popover" });
|
|
843
|
-
const fontFamilies = useFontFamilies2();
|
|
968
|
+
const [fontFamily, setFontFamily] = useState8(variable.value);
|
|
969
|
+
const [label, setLabel] = useState8(variable.label);
|
|
844
970
|
const handleUpdate = () => {
|
|
845
971
|
updateVariable(editId, {
|
|
846
972
|
value: fontFamily,
|
|
847
973
|
label
|
|
848
974
|
}).then(() => {
|
|
975
|
+
maybeTriggerBoundPropChange();
|
|
849
976
|
onSubmit?.();
|
|
850
977
|
});
|
|
851
978
|
};
|
|
852
|
-
const
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
979
|
+
const handleDelete = () => {
|
|
980
|
+
deleteVariable(editId).then(() => {
|
|
981
|
+
maybeTriggerBoundPropChange();
|
|
982
|
+
onSubmit?.();
|
|
983
|
+
});
|
|
984
|
+
};
|
|
985
|
+
const maybeTriggerBoundPropChange = () => {
|
|
986
|
+
if (editId === assignedValue) {
|
|
987
|
+
notifyBoundPropChange(editId);
|
|
861
988
|
}
|
|
862
|
-
|
|
863
|
-
|
|
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();
|
|
1003
|
+
const actions = [];
|
|
1004
|
+
actions.push(
|
|
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
|
+
)
|
|
1015
|
+
);
|
|
1016
|
+
return /* @__PURE__ */ React12.createElement(React12.Fragment, null, /* @__PURE__ */ React12.createElement(PopoverScrollableContent5, { height: "auto" }, /* @__PURE__ */ React12.createElement(
|
|
1017
|
+
PopoverHeader5,
|
|
864
1018
|
{
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
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"),
|
|
1029
|
+
onClose,
|
|
1030
|
+
actions
|
|
870
1031
|
}
|
|
871
|
-
)
|
|
872
|
-
|
|
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,
|
|
873
1034
|
{
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
...bindTrigger2(fontPopoverState),
|
|
879
|
-
fullWidth: true
|
|
1035
|
+
open: true,
|
|
1036
|
+
label,
|
|
1037
|
+
onConfirm: handleDelete,
|
|
1038
|
+
closeDialog: closeDeleteDialog()
|
|
880
1039
|
}
|
|
881
|
-
)
|
|
882
|
-
Popover2,
|
|
883
|
-
{
|
|
884
|
-
disablePortal: true,
|
|
885
|
-
disableScrollLock: true,
|
|
886
|
-
anchorEl: anchorRef.current,
|
|
887
|
-
anchorOrigin: { vertical: "top", horizontal: "right" },
|
|
888
|
-
transformOrigin: { vertical: "top", horizontal: -20 },
|
|
889
|
-
...bindPopover2(fontPopoverState)
|
|
890
|
-
},
|
|
891
|
-
/* @__PURE__ */ React9.createElement(
|
|
892
|
-
FontFamilySelector2,
|
|
893
|
-
{
|
|
894
|
-
fontFamilies,
|
|
895
|
-
fontFamily,
|
|
896
|
-
onFontFamilyChange: setFontFamily,
|
|
897
|
-
onClose: fontPopoverState.close
|
|
898
|
-
}
|
|
899
|
-
)
|
|
900
|
-
))))), /* @__PURE__ */ React9.createElement(CardActions4, null, /* @__PURE__ */ React9.createElement(Button5, { size: "small", variant: "contained", disabled: isSaveDisabled(), onClick: handleUpdate }, __8("Save", "elementor"))));
|
|
1040
|
+
));
|
|
901
1041
|
};
|
|
902
1042
|
|
|
903
1043
|
// src/components/font-variables-selection.tsx
|
|
904
|
-
import * as
|
|
905
|
-
import { useState as
|
|
906
|
-
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";
|
|
1047
|
+
import { PopoverScrollableContent as PopoverScrollableContent6 } from "@elementor/editor-editing-panel";
|
|
907
1048
|
import { PopoverHeader as PopoverHeader6, PopoverMenuList as PopoverMenuList2, PopoverSearch as PopoverSearch2 } from "@elementor/editor-ui";
|
|
908
|
-
import { ColorFilterIcon as
|
|
1049
|
+
import { ColorFilterIcon as ColorFilterIcon2, PlusIcon as PlusIcon2, SettingsIcon as SettingsIcon2, TextIcon as TextIcon3 } from "@elementor/icons";
|
|
909
1050
|
import { Divider as Divider6, IconButton as IconButton7 } from "@elementor/ui";
|
|
910
|
-
import { __ as
|
|
1051
|
+
import { __ as __14 } from "@wordpress/i18n";
|
|
911
1052
|
var SIZE7 = "tiny";
|
|
912
1053
|
var FontVariablesSelection = ({ closePopover, onAdd, onEdit, onSettings }) => {
|
|
913
|
-
const { value: variable, setValue: setVariable } =
|
|
914
|
-
const [searchValue, setSearchValue] =
|
|
1054
|
+
const { value: variable, setValue: setVariable } = useBoundProp6(fontVariablePropTypeUtil);
|
|
1055
|
+
const [searchValue, setSearchValue] = useState9("");
|
|
915
1056
|
const {
|
|
916
1057
|
list: variables,
|
|
917
1058
|
hasMatches: hasSearchResults,
|
|
@@ -924,19 +1065,19 @@ var FontVariablesSelection = ({ closePopover, onAdd, onEdit, onSettings }) => {
|
|
|
924
1065
|
const actions = [];
|
|
925
1066
|
if (onAdd) {
|
|
926
1067
|
actions.push(
|
|
927
|
-
/* @__PURE__ */
|
|
1068
|
+
/* @__PURE__ */ React13.createElement(IconButton7, { key: "add", size: SIZE7, onClick: onAdd }, /* @__PURE__ */ React13.createElement(PlusIcon2, { fontSize: SIZE7 }))
|
|
928
1069
|
);
|
|
929
1070
|
}
|
|
930
1071
|
if (onSettings) {
|
|
931
1072
|
actions.push(
|
|
932
|
-
/* @__PURE__ */
|
|
1073
|
+
/* @__PURE__ */ React13.createElement(IconButton7, { key: "settings", size: SIZE7, onClick: onSettings }, /* @__PURE__ */ React13.createElement(SettingsIcon2, { fontSize: SIZE7 }))
|
|
933
1074
|
);
|
|
934
1075
|
}
|
|
935
1076
|
const items = variables.map(({ value, label, key }) => ({
|
|
936
1077
|
type: "item",
|
|
937
1078
|
value: key,
|
|
938
1079
|
label,
|
|
939
|
-
icon: /* @__PURE__ */
|
|
1080
|
+
icon: /* @__PURE__ */ React13.createElement(TextIcon3, { fontSize: SIZE7 }),
|
|
940
1081
|
secondaryText: value,
|
|
941
1082
|
onEdit: () => onEdit?.(key)
|
|
942
1083
|
}));
|
|
@@ -946,22 +1087,22 @@ var FontVariablesSelection = ({ closePopover, onAdd, onEdit, onSettings }) => {
|
|
|
946
1087
|
const handleClearSearch = () => {
|
|
947
1088
|
setSearchValue("");
|
|
948
1089
|
};
|
|
949
|
-
return /* @__PURE__ */
|
|
1090
|
+
return /* @__PURE__ */ React13.createElement(React13.Fragment, null, /* @__PURE__ */ React13.createElement(
|
|
950
1091
|
PopoverHeader6,
|
|
951
1092
|
{
|
|
952
|
-
title:
|
|
1093
|
+
title: __14("Variables", "elementor"),
|
|
953
1094
|
onClose: closePopover,
|
|
954
|
-
icon: /* @__PURE__ */
|
|
1095
|
+
icon: /* @__PURE__ */ React13.createElement(ColorFilterIcon2, { fontSize: SIZE7 }),
|
|
955
1096
|
actions
|
|
956
1097
|
}
|
|
957
|
-
), hasVariables && /* @__PURE__ */
|
|
1098
|
+
), hasVariables && /* @__PURE__ */ React13.createElement(
|
|
958
1099
|
PopoverSearch2,
|
|
959
1100
|
{
|
|
960
1101
|
value: searchValue,
|
|
961
1102
|
onSearch: handleSearch,
|
|
962
|
-
placeholder:
|
|
1103
|
+
placeholder: __14("Search", "elementor")
|
|
963
1104
|
}
|
|
964
|
-
), /* @__PURE__ */
|
|
1105
|
+
), /* @__PURE__ */ React13.createElement(Divider6, null), /* @__PURE__ */ React13.createElement(PopoverScrollableContent6, null, hasVariables && hasSearchResults && /* @__PURE__ */ React13.createElement(
|
|
965
1106
|
PopoverMenuList2,
|
|
966
1107
|
{
|
|
967
1108
|
items,
|
|
@@ -971,9 +1112,23 @@ var FontVariablesSelection = ({ closePopover, onAdd, onEdit, onSettings }) => {
|
|
|
971
1112
|
selectedValue: variable,
|
|
972
1113
|
"data-testid": "font-variables-list",
|
|
973
1114
|
menuListTemplate: VariablesStyledMenuList,
|
|
974
|
-
menuItemContentTemplate: (item) => /* @__PURE__ */
|
|
1115
|
+
menuItemContentTemplate: (item) => /* @__PURE__ */ React13.createElement(MenuItemContent, { item })
|
|
1116
|
+
}
|
|
1117
|
+
), !hasSearchResults && hasVariables && /* @__PURE__ */ React13.createElement(
|
|
1118
|
+
NoSearchResults,
|
|
1119
|
+
{
|
|
1120
|
+
searchValue,
|
|
1121
|
+
onClear: handleClearSearch,
|
|
1122
|
+
icon: /* @__PURE__ */ React13.createElement(TextIcon3, { fontSize: "large" })
|
|
1123
|
+
}
|
|
1124
|
+
), !hasVariables && /* @__PURE__ */ React13.createElement(
|
|
1125
|
+
NoVariables,
|
|
1126
|
+
{
|
|
1127
|
+
title: __14("Create your first font variable", "elementor"),
|
|
1128
|
+
icon: /* @__PURE__ */ React13.createElement(TextIcon3, { fontSize: "large" }),
|
|
1129
|
+
onAdd
|
|
975
1130
|
}
|
|
976
|
-
)
|
|
1131
|
+
)));
|
|
977
1132
|
};
|
|
978
1133
|
|
|
979
1134
|
// src/components/variable-selection-popover.tsx
|
|
@@ -981,16 +1136,17 @@ var VIEW_LIST = "list";
|
|
|
981
1136
|
var VIEW_ADD = "add";
|
|
982
1137
|
var VIEW_EDIT = "edit";
|
|
983
1138
|
var VariableSelectionPopover = ({ closePopover, propTypeKey, selectedVariable }) => {
|
|
984
|
-
const [currentView, setCurrentView] =
|
|
985
|
-
const editIdRef =
|
|
986
|
-
|
|
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({
|
|
987
1143
|
propTypeKey,
|
|
988
1144
|
currentView,
|
|
989
1145
|
selectedVariable,
|
|
990
1146
|
editIdRef,
|
|
991
1147
|
setCurrentView,
|
|
992
1148
|
closePopover
|
|
993
|
-
});
|
|
1149
|
+
})));
|
|
994
1150
|
};
|
|
995
1151
|
function renderStage(props) {
|
|
996
1152
|
const handleSubmitOnEdit = () => {
|
|
@@ -1002,7 +1158,7 @@ function renderStage(props) {
|
|
|
1002
1158
|
};
|
|
1003
1159
|
if (fontVariablePropTypeUtil.key === props.propTypeKey) {
|
|
1004
1160
|
if (VIEW_LIST === props.currentView) {
|
|
1005
|
-
return /* @__PURE__ */
|
|
1161
|
+
return /* @__PURE__ */ React14.createElement(
|
|
1006
1162
|
FontVariablesSelection,
|
|
1007
1163
|
{
|
|
1008
1164
|
closePopover: props.closePopover,
|
|
@@ -1017,7 +1173,7 @@ function renderStage(props) {
|
|
|
1017
1173
|
);
|
|
1018
1174
|
}
|
|
1019
1175
|
if (VIEW_ADD === props.currentView) {
|
|
1020
|
-
return /* @__PURE__ */
|
|
1176
|
+
return /* @__PURE__ */ React14.createElement(
|
|
1021
1177
|
FontVariableCreation,
|
|
1022
1178
|
{
|
|
1023
1179
|
onGoBack: () => props.setCurrentView(VIEW_LIST),
|
|
@@ -1026,7 +1182,7 @@ function renderStage(props) {
|
|
|
1026
1182
|
);
|
|
1027
1183
|
}
|
|
1028
1184
|
if (VIEW_EDIT === props.currentView) {
|
|
1029
|
-
return /* @__PURE__ */
|
|
1185
|
+
return /* @__PURE__ */ React14.createElement(
|
|
1030
1186
|
FontVariableEdit,
|
|
1031
1187
|
{
|
|
1032
1188
|
editId: props.editIdRef.current ?? "",
|
|
@@ -1039,7 +1195,7 @@ function renderStage(props) {
|
|
|
1039
1195
|
}
|
|
1040
1196
|
if (colorVariablePropTypeUtil.key === props.propTypeKey) {
|
|
1041
1197
|
if (VIEW_LIST === props.currentView) {
|
|
1042
|
-
return /* @__PURE__ */
|
|
1198
|
+
return /* @__PURE__ */ React14.createElement(
|
|
1043
1199
|
ColorVariablesSelection,
|
|
1044
1200
|
{
|
|
1045
1201
|
closePopover: props.closePopover,
|
|
@@ -1054,7 +1210,7 @@ function renderStage(props) {
|
|
|
1054
1210
|
);
|
|
1055
1211
|
}
|
|
1056
1212
|
if (VIEW_ADD === props.currentView) {
|
|
1057
|
-
return /* @__PURE__ */
|
|
1213
|
+
return /* @__PURE__ */ React14.createElement(
|
|
1058
1214
|
ColorVariableCreation,
|
|
1059
1215
|
{
|
|
1060
1216
|
onGoBack: () => props.setCurrentView(VIEW_LIST),
|
|
@@ -1063,7 +1219,7 @@ function renderStage(props) {
|
|
|
1063
1219
|
);
|
|
1064
1220
|
}
|
|
1065
1221
|
if (VIEW_EDIT === props.currentView) {
|
|
1066
|
-
return /* @__PURE__ */
|
|
1222
|
+
return /* @__PURE__ */ React14.createElement(
|
|
1067
1223
|
ColorVariableEdit,
|
|
1068
1224
|
{
|
|
1069
1225
|
editId: props.editIdRef.current ?? "",
|
|
@@ -1077,66 +1233,136 @@ function renderStage(props) {
|
|
|
1077
1233
|
return null;
|
|
1078
1234
|
}
|
|
1079
1235
|
|
|
1080
|
-
// src/
|
|
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";
|
|
1081
1241
|
var SIZE8 = "tiny";
|
|
1082
|
-
var
|
|
1083
|
-
const
|
|
1084
|
-
|
|
1085
|
-
|
|
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);
|
|
1086
1271
|
const popupId = useId2();
|
|
1087
|
-
const popupState =
|
|
1272
|
+
const popupState = usePopupState2({
|
|
1088
1273
|
variant: "popover",
|
|
1089
1274
|
popupId: `elementor-variables-list-${popupId}`
|
|
1090
1275
|
});
|
|
1091
|
-
const selectedVariable = useVariable(variableValue);
|
|
1092
|
-
if (!selectedVariable) {
|
|
1093
|
-
throw new Error(`Global color variable ${variableValue} not found`);
|
|
1094
|
-
}
|
|
1095
1276
|
const unlinkVariable = () => {
|
|
1096
|
-
|
|
1277
|
+
setValue(fallbackPropTypeUtil.create(variable.value));
|
|
1097
1278
|
};
|
|
1098
|
-
return /* @__PURE__ */
|
|
1099
|
-
|
|
1279
|
+
return /* @__PURE__ */ React16.createElement(Box4, { ref: anchorRef }, /* @__PURE__ */ React16.createElement(
|
|
1280
|
+
AssignedTag,
|
|
1100
1281
|
{
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
Typography3,
|
|
1106
|
-
{
|
|
1107
|
-
sx: { textOverflow: "ellipsis", overflowX: "hidden", lineHeight: 1 },
|
|
1108
|
-
variant: "caption"
|
|
1109
|
-
},
|
|
1110
|
-
selectedVariable.label
|
|
1111
|
-
)),
|
|
1112
|
-
actions: /* @__PURE__ */ React12.createElement(IconButton8, { size: SIZE8, onClick: unlinkVariable, "aria-label": __10("Unlink", "elementor") }, /* @__PURE__ */ React12.createElement(DetachIcon, { fontSize: SIZE8 })),
|
|
1113
|
-
...bindTrigger3(popupState)
|
|
1282
|
+
label: variable.label,
|
|
1283
|
+
startIcon: /* @__PURE__ */ React16.createElement(React16.Fragment, null, /* @__PURE__ */ React16.createElement(ColorFilterIcon3, { fontSize: SIZE8 }), additionalStartIcon),
|
|
1284
|
+
onUnlink: unlinkVariable,
|
|
1285
|
+
...bindTrigger2(popupState)
|
|
1114
1286
|
}
|
|
1115
|
-
), /* @__PURE__ */
|
|
1116
|
-
|
|
1287
|
+
), /* @__PURE__ */ React16.createElement(
|
|
1288
|
+
Popover2,
|
|
1117
1289
|
{
|
|
1118
1290
|
disableScrollLock: true,
|
|
1119
1291
|
anchorEl: anchorRef.current,
|
|
1120
1292
|
anchorOrigin: { vertical: "bottom", horizontal: "right" },
|
|
1121
1293
|
transformOrigin: { vertical: "top", horizontal: "right" },
|
|
1122
|
-
|
|
1294
|
+
PaperProps: {
|
|
1295
|
+
sx: { my: 1 }
|
|
1296
|
+
},
|
|
1297
|
+
...bindPopover2(popupState)
|
|
1123
1298
|
},
|
|
1124
|
-
/* @__PURE__ */
|
|
1299
|
+
/* @__PURE__ */ React16.createElement(
|
|
1125
1300
|
VariableSelectionPopover,
|
|
1126
1301
|
{
|
|
1127
|
-
selectedVariable,
|
|
1302
|
+
selectedVariable: variable,
|
|
1128
1303
|
closePopover: popupState.close,
|
|
1129
|
-
propTypeKey:
|
|
1304
|
+
propTypeKey: variablePropTypeUtil.key
|
|
1130
1305
|
}
|
|
1131
1306
|
)
|
|
1132
1307
|
));
|
|
1133
1308
|
};
|
|
1134
1309
|
|
|
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";
|
|
1317
|
+
import { ColorFilterIcon as ColorFilterIcon4 } from "@elementor/icons";
|
|
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
|
+
|
|
1135
1361
|
// src/hooks/use-prop-color-variable-action.tsx
|
|
1136
|
-
import * as
|
|
1137
|
-
import { useBoundProp as
|
|
1362
|
+
import * as React20 from "react";
|
|
1363
|
+
import { useBoundProp as useBoundProp9 } from "@elementor/editor-editing-panel";
|
|
1138
1364
|
import { ColorFilterIcon as ColorFilterIcon5 } from "@elementor/icons";
|
|
1139
|
-
import { __ as
|
|
1365
|
+
import { __ as __17 } from "@wordpress/i18n";
|
|
1140
1366
|
|
|
1141
1367
|
// src/utils.ts
|
|
1142
1368
|
var hasAssignedColorVariable = (propValue) => {
|
|
@@ -1154,18 +1380,66 @@ var supportsFontVariables = (propType) => {
|
|
|
1154
1380
|
|
|
1155
1381
|
// src/hooks/use-prop-color-variable-action.tsx
|
|
1156
1382
|
var usePropColorVariableAction = () => {
|
|
1157
|
-
const { propType } =
|
|
1383
|
+
const { propType } = useBoundProp9();
|
|
1158
1384
|
const visible = !!propType && supportsColorVariables(propType);
|
|
1159
1385
|
return {
|
|
1160
1386
|
visible,
|
|
1161
1387
|
icon: ColorFilterIcon5,
|
|
1162
|
-
title:
|
|
1388
|
+
title: __17("Variables", "elementor"),
|
|
1163
1389
|
content: ({ close: closePopover }) => {
|
|
1164
|
-
return /* @__PURE__ */
|
|
1390
|
+
return /* @__PURE__ */ React20.createElement(VariableSelectionPopover, { closePopover, propTypeKey: colorVariablePropTypeUtil.key });
|
|
1165
1391
|
}
|
|
1166
1392
|
};
|
|
1167
1393
|
};
|
|
1168
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
|
+
|
|
1169
1443
|
// src/transformers/variable-transformer.ts
|
|
1170
1444
|
import { createTransformer } from "@elementor/editor-canvas";
|
|
1171
1445
|
var variableTransformer = createTransformer((value) => {
|
|
@@ -1177,15 +1451,7 @@ var variableTransformer = createTransformer((value) => {
|
|
|
1177
1451
|
|
|
1178
1452
|
// src/init-color-variables.ts
|
|
1179
1453
|
var { registerPopoverAction } = controlActionsMenu;
|
|
1180
|
-
|
|
1181
|
-
backgroundOverlay: ({ value: prop }) => {
|
|
1182
|
-
return hasAssignedColorVariable(backgroundColorOverlayPropTypeUtil.extract(prop)?.color);
|
|
1183
|
-
},
|
|
1184
|
-
boxShadow: ({ value: prop }) => {
|
|
1185
|
-
return hasAssignedColorVariable(shadowPropTypeUtil.extract(prop)?.color);
|
|
1186
|
-
}
|
|
1187
|
-
};
|
|
1188
|
-
function registerControlsAndActions() {
|
|
1454
|
+
function initColorVariables() {
|
|
1189
1455
|
registerControlReplacement({
|
|
1190
1456
|
component: ColorVariableControl,
|
|
1191
1457
|
condition: ({ value }) => hasAssignedColorVariable(value)
|
|
@@ -1194,34 +1460,8 @@ function registerControlsAndActions() {
|
|
|
1194
1460
|
id: "color-variables",
|
|
1195
1461
|
useProps: usePropColorVariableAction
|
|
1196
1462
|
});
|
|
1197
|
-
}
|
|
1198
|
-
function registerRepeaterItemIcons() {
|
|
1199
|
-
injectIntoRepeaterItemIcon({
|
|
1200
|
-
id: "color-variables-background-icon",
|
|
1201
|
-
component: BackgroundRepeaterColorIndicator,
|
|
1202
|
-
condition: conditions.backgroundOverlay
|
|
1203
|
-
});
|
|
1204
|
-
injectIntoRepeaterItemIcon({
|
|
1205
|
-
id: "color-variables-icon",
|
|
1206
|
-
component: BoxShadowRepeaterColorIndicator,
|
|
1207
|
-
condition: conditions.boxShadow
|
|
1208
|
-
});
|
|
1209
|
-
}
|
|
1210
|
-
function registerRepeaterItemLabels() {
|
|
1211
|
-
injectIntoRepeaterItemLabel({
|
|
1212
|
-
id: "color-variables-label",
|
|
1213
|
-
component: BackgroundRepeaterLabel,
|
|
1214
|
-
condition: conditions.backgroundOverlay
|
|
1215
|
-
});
|
|
1216
|
-
}
|
|
1217
|
-
function registerStyleTransformers() {
|
|
1218
1463
|
styleTransformersRegistry.register(colorVariablePropTypeUtil.key, variableTransformer);
|
|
1219
|
-
|
|
1220
|
-
function initColorVariables() {
|
|
1221
|
-
registerControlsAndActions();
|
|
1222
|
-
registerRepeaterItemIcons();
|
|
1223
|
-
registerRepeaterItemLabels();
|
|
1224
|
-
registerStyleTransformers();
|
|
1464
|
+
registerRepeaterInjections();
|
|
1225
1465
|
}
|
|
1226
1466
|
|
|
1227
1467
|
// src/init-font-variables.ts
|
|
@@ -1229,91 +1469,43 @@ import { styleTransformersRegistry as styleTransformersRegistry2 } from "@elemen
|
|
|
1229
1469
|
import { controlActionsMenu as controlActionsMenu2, registerControlReplacement as registerControlReplacement2 } from "@elementor/editor-editing-panel";
|
|
1230
1470
|
|
|
1231
1471
|
// src/controls/font-variable-control.tsx
|
|
1232
|
-
import * as
|
|
1233
|
-
import {
|
|
1234
|
-
import { useBoundProp as useBoundProp7 } from "@elementor/editor-controls";
|
|
1472
|
+
import * as React22 from "react";
|
|
1473
|
+
import { useBoundProp as useBoundProp10 } from "@elementor/editor-controls";
|
|
1235
1474
|
import { stringPropTypeUtil } from "@elementor/editor-props";
|
|
1236
|
-
import { ColorFilterIcon as ColorFilterIcon6, DetachIcon as DetachIcon2 } from "@elementor/icons";
|
|
1237
|
-
import {
|
|
1238
|
-
bindPopover as bindPopover4,
|
|
1239
|
-
bindTrigger as bindTrigger4,
|
|
1240
|
-
Box as Box2,
|
|
1241
|
-
IconButton as IconButton9,
|
|
1242
|
-
Popover as Popover4,
|
|
1243
|
-
Stack as Stack8,
|
|
1244
|
-
Typography as Typography4,
|
|
1245
|
-
UnstableTag as Tag2,
|
|
1246
|
-
usePopupState as usePopupState4
|
|
1247
|
-
} from "@elementor/ui";
|
|
1248
|
-
import { __ as __12 } from "@wordpress/i18n";
|
|
1249
|
-
var SIZE9 = "tiny";
|
|
1250
1475
|
var FontVariableControl = () => {
|
|
1251
|
-
const {
|
|
1252
|
-
const
|
|
1253
|
-
|
|
1254
|
-
const popupId = useId3();
|
|
1255
|
-
const popupState = usePopupState4({
|
|
1256
|
-
variant: "popover",
|
|
1257
|
-
popupId: `elementor-variables-list-${popupId}`
|
|
1258
|
-
});
|
|
1259
|
-
const selectedVariable = useVariable(variableValue);
|
|
1260
|
-
if (!selectedVariable) {
|
|
1476
|
+
const { value: variableValue } = useBoundProp10(fontVariablePropTypeUtil);
|
|
1477
|
+
const assignedVariable = useVariable(variableValue);
|
|
1478
|
+
if (!assignedVariable) {
|
|
1261
1479
|
throw new Error(`Global font variable ${variableValue} not found`);
|
|
1262
1480
|
}
|
|
1263
|
-
const
|
|
1264
|
-
|
|
1265
|
-
|
|
1266
|
-
|
|
1267
|
-
|
|
1481
|
+
const isVariableDeleted = assignedVariable?.deleted;
|
|
1482
|
+
if (isVariableDeleted) {
|
|
1483
|
+
return /* @__PURE__ */ React22.createElement(DeletedVariable, { variable: assignedVariable });
|
|
1484
|
+
}
|
|
1485
|
+
return /* @__PURE__ */ React22.createElement(
|
|
1486
|
+
AssignedVariable,
|
|
1268
1487
|
{
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
-
|
|
1272
|
-
label: /* @__PURE__ */ React14.createElement(Box2, { sx: { display: "inline-grid", minWidth: 0 } }, /* @__PURE__ */ React14.createElement(
|
|
1273
|
-
Typography4,
|
|
1274
|
-
{
|
|
1275
|
-
sx: { textOverflow: "ellipsis", overflowX: "hidden", lineHeight: 1 },
|
|
1276
|
-
variant: "caption"
|
|
1277
|
-
},
|
|
1278
|
-
selectedVariable.label
|
|
1279
|
-
)),
|
|
1280
|
-
actions: /* @__PURE__ */ React14.createElement(IconButton9, { size: SIZE9, onClick: unlinkVariable, "aria-label": __12("Unlink", "elementor") }, /* @__PURE__ */ React14.createElement(DetachIcon2, { fontSize: SIZE9 })),
|
|
1281
|
-
...bindTrigger4(popupState)
|
|
1488
|
+
variable: assignedVariable,
|
|
1489
|
+
variablePropTypeUtil: fontVariablePropTypeUtil,
|
|
1490
|
+
fallbackPropTypeUtil: stringPropTypeUtil
|
|
1282
1491
|
}
|
|
1283
|
-
)
|
|
1284
|
-
Popover4,
|
|
1285
|
-
{
|
|
1286
|
-
disableScrollLock: true,
|
|
1287
|
-
anchorEl: anchorRef.current,
|
|
1288
|
-
anchorOrigin: { vertical: "bottom", horizontal: "right" },
|
|
1289
|
-
transformOrigin: { vertical: "top", horizontal: "right" },
|
|
1290
|
-
...bindPopover4(popupState)
|
|
1291
|
-
},
|
|
1292
|
-
/* @__PURE__ */ React14.createElement(
|
|
1293
|
-
VariableSelectionPopover,
|
|
1294
|
-
{
|
|
1295
|
-
selectedVariable,
|
|
1296
|
-
closePopover: popupState.close,
|
|
1297
|
-
propTypeKey: fontVariablePropTypeUtil.key
|
|
1298
|
-
}
|
|
1299
|
-
)
|
|
1300
|
-
));
|
|
1492
|
+
);
|
|
1301
1493
|
};
|
|
1302
1494
|
|
|
1303
1495
|
// src/hooks/use-prop-font-variable-action.tsx
|
|
1304
|
-
import * as
|
|
1305
|
-
import { useBoundProp as
|
|
1306
|
-
import { ColorFilterIcon as
|
|
1307
|
-
import { __ as
|
|
1496
|
+
import * as React23 from "react";
|
|
1497
|
+
import { useBoundProp as useBoundProp11 } from "@elementor/editor-editing-panel";
|
|
1498
|
+
import { ColorFilterIcon as ColorFilterIcon6 } from "@elementor/icons";
|
|
1499
|
+
import { __ as __18 } from "@wordpress/i18n";
|
|
1308
1500
|
var usePropFontVariableAction = () => {
|
|
1309
|
-
const { propType } =
|
|
1501
|
+
const { propType } = useBoundProp11();
|
|
1310
1502
|
const visible = !!propType && supportsFontVariables(propType);
|
|
1311
1503
|
return {
|
|
1312
1504
|
visible,
|
|
1313
|
-
icon:
|
|
1314
|
-
title:
|
|
1505
|
+
icon: ColorFilterIcon6,
|
|
1506
|
+
title: __18("Variables", "elementor"),
|
|
1315
1507
|
content: ({ close: closePopover }) => {
|
|
1316
|
-
return /* @__PURE__ */
|
|
1508
|
+
return /* @__PURE__ */ React23.createElement(VariableSelectionPopover, { closePopover, propTypeKey: fontVariablePropTypeUtil.key });
|
|
1317
1509
|
}
|
|
1318
1510
|
};
|
|
1319
1511
|
};
|
|
@@ -1333,8 +1525,8 @@ function initFontVariables() {
|
|
|
1333
1525
|
}
|
|
1334
1526
|
|
|
1335
1527
|
// src/renderers/style-variables-renderer.tsx
|
|
1336
|
-
import * as
|
|
1337
|
-
import { useEffect, useState as
|
|
1528
|
+
import * as React24 from "react";
|
|
1529
|
+
import { useEffect, useState as useState11 } from "react";
|
|
1338
1530
|
import { __privateUseListenTo as useListenTo, commandEndEvent } from "@elementor/editor-v1-adapters";
|
|
1339
1531
|
import { Portal } from "@elementor/ui";
|
|
1340
1532
|
|
|
@@ -1355,13 +1547,13 @@ function StyleVariablesRenderer() {
|
|
|
1355
1547
|
}
|
|
1356
1548
|
const cssVariables = convertToCssVariables(styleVariables);
|
|
1357
1549
|
const wrappedCss = `${VARIABLES_WRAPPER}{${cssVariables}}`;
|
|
1358
|
-
return /* @__PURE__ */
|
|
1550
|
+
return /* @__PURE__ */ React24.createElement(Portal, { container }, /* @__PURE__ */ React24.createElement("style", { "data-e-style-id": "e-variables", key: wrappedCss }, wrappedCss));
|
|
1359
1551
|
}
|
|
1360
1552
|
function usePortalContainer() {
|
|
1361
1553
|
return useListenTo(commandEndEvent("editor/documents/attach-preview"), () => getCanvasIframeDocument()?.head);
|
|
1362
1554
|
}
|
|
1363
1555
|
function useStyleVariables() {
|
|
1364
|
-
const [variables, setVariables] =
|
|
1556
|
+
const [variables, setVariables] = useState11({});
|
|
1365
1557
|
useEffect(() => {
|
|
1366
1558
|
const unsubscribe = styleVariablesRepository.subscribe(setVariables);
|
|
1367
1559
|
return () => {
|