@elementor/editor-variables 3.32.0-49 → 3.32.0-51
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/dist/index.js +664 -457
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +603 -386
- package/dist/index.mjs.map +1 -1
- package/package.json +12 -12
- package/src/components/variable-selection-popover.tsx +2 -2
- package/src/components/variables-manager/variable-edit-menu.tsx +72 -0
- package/src/components/variables-manager/variable-table-cell.tsx +37 -0
- package/src/components/variables-manager/variables-manager-panel.tsx +15 -12
- package/src/components/variables-manager/variables-manager-table.tsx +172 -0
- package/src/hooks/use-prop-variables.ts +14 -6
package/dist/index.js
CHANGED
|
@@ -41,101 +41,44 @@ var import_editor_editing_panel10 = require("@elementor/editor-editing-panel");
|
|
|
41
41
|
var import_editor_panels2 = require("@elementor/editor-panels");
|
|
42
42
|
|
|
43
43
|
// src/components/variables-manager/variables-manager-panel.tsx
|
|
44
|
-
var
|
|
45
|
-
var
|
|
44
|
+
var React6 = __toESM(require("react"));
|
|
45
|
+
var import_react5 = require("react");
|
|
46
46
|
var import_editor_panels = require("@elementor/editor-panels");
|
|
47
|
-
var
|
|
47
|
+
var import_editor_ui2 = require("@elementor/editor-ui");
|
|
48
48
|
var import_editor_v1_adapters = require("@elementor/editor-v1-adapters");
|
|
49
|
-
var
|
|
50
|
-
var
|
|
51
|
-
var
|
|
52
|
-
var id = "variables-manager";
|
|
53
|
-
var { panel, usePanelActions } = (0, import_editor_panels.__createPanel)({
|
|
54
|
-
id,
|
|
55
|
-
component: VariablesManagerPanel,
|
|
56
|
-
allowedEditModes: ["edit", id],
|
|
57
|
-
onOpen: () => {
|
|
58
|
-
(0, import_editor_v1_adapters.changeEditMode)(id);
|
|
59
|
-
},
|
|
60
|
-
onClose: () => {
|
|
61
|
-
(0, import_editor_v1_adapters.changeEditMode)("edit");
|
|
62
|
-
}
|
|
63
|
-
});
|
|
64
|
-
function VariablesManagerPanel() {
|
|
65
|
-
const { close: closePanel } = usePanelActions();
|
|
66
|
-
const isDirty = false;
|
|
67
|
-
usePreventUnload(isDirty);
|
|
68
|
-
return /* @__PURE__ */ React.createElement(import_editor_ui.ThemeProvider, null, /* @__PURE__ */ React.createElement(import_ui.ErrorBoundary, { fallback: /* @__PURE__ */ React.createElement(ErrorBoundaryFallback, null) }, /* @__PURE__ */ React.createElement(import_editor_panels.Panel, null, /* @__PURE__ */ React.createElement(import_editor_panels.PanelHeader, null, /* @__PURE__ */ React.createElement(import_ui.Stack, { p: 1, pl: 2, width: "100%", direction: "row", alignItems: "center" }, /* @__PURE__ */ React.createElement(import_ui.Stack, { width: "100%", direction: "row", gap: 1 }, /* @__PURE__ */ React.createElement(import_editor_panels.PanelHeaderTitle, { sx: { display: "flex", alignItems: "center", gap: 0.5 } }, /* @__PURE__ */ React.createElement(import_icons.FilterIcon, { fontSize: "inherit" }), (0, import_i18n.__)("Variables Manager", "elementor"))), /* @__PURE__ */ React.createElement(
|
|
69
|
-
CloseButton,
|
|
70
|
-
{
|
|
71
|
-
sx: { marginLeft: "auto" },
|
|
72
|
-
onClose: () => {
|
|
73
|
-
closePanel();
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
))), /* @__PURE__ */ React.createElement(
|
|
77
|
-
import_editor_panels.PanelBody,
|
|
78
|
-
{
|
|
79
|
-
sx: {
|
|
80
|
-
display: "flex",
|
|
81
|
-
flexDirection: "column",
|
|
82
|
-
height: "100%"
|
|
83
|
-
}
|
|
84
|
-
},
|
|
85
|
-
/* @__PURE__ */ React.createElement(import_ui.Divider, null),
|
|
86
|
-
/* @__PURE__ */ React.createElement(
|
|
87
|
-
import_ui.Box,
|
|
88
|
-
{
|
|
89
|
-
px: 2,
|
|
90
|
-
sx: {
|
|
91
|
-
flexGrow: 1,
|
|
92
|
-
overflowY: "auto"
|
|
93
|
-
}
|
|
94
|
-
},
|
|
95
|
-
"List"
|
|
96
|
-
)
|
|
97
|
-
), /* @__PURE__ */ React.createElement(import_editor_panels.PanelFooter, null, /* @__PURE__ */ React.createElement(import_ui.Button, { fullWidth: true, size: "small", color: "global", variant: "contained", disabled: !isDirty }, (0, import_i18n.__)("Save changes", "elementor"))))));
|
|
98
|
-
}
|
|
99
|
-
var CloseButton = ({ onClose, ...props }) => /* @__PURE__ */ React.createElement(import_ui.IconButton, { size: "small", color: "secondary", onClick: onClose, "aria-label": "Close", ...props }, /* @__PURE__ */ React.createElement(import_icons.XIcon, { fontSize: "small" }));
|
|
100
|
-
var ErrorBoundaryFallback = () => /* @__PURE__ */ React.createElement(import_ui.Box, { role: "alert", sx: { minHeight: "100%", p: 2 } }, /* @__PURE__ */ React.createElement(import_ui.Alert, { severity: "error", sx: { mb: 2, maxWidth: 400, textAlign: "center" } }, /* @__PURE__ */ React.createElement("strong", null, (0, import_i18n.__)("Something went wrong", "elementor"))));
|
|
101
|
-
var usePreventUnload = (isDirty) => {
|
|
102
|
-
(0, import_react.useEffect)(() => {
|
|
103
|
-
const handleBeforeUnload = (event) => {
|
|
104
|
-
if (isDirty) {
|
|
105
|
-
event.preventDefault();
|
|
106
|
-
}
|
|
107
|
-
};
|
|
108
|
-
window.addEventListener("beforeunload", handleBeforeUnload);
|
|
109
|
-
return () => {
|
|
110
|
-
window.removeEventListener("beforeunload", handleBeforeUnload);
|
|
111
|
-
};
|
|
112
|
-
}, [isDirty]);
|
|
113
|
-
};
|
|
49
|
+
var import_icons3 = require("@elementor/icons");
|
|
50
|
+
var import_ui6 = require("@elementor/ui");
|
|
51
|
+
var import_i18n4 = require("@wordpress/i18n");
|
|
114
52
|
|
|
115
|
-
// src/
|
|
116
|
-
var
|
|
117
|
-
var
|
|
53
|
+
// src/components/variables-manager/variables-manager-table.tsx
|
|
54
|
+
var React5 = __toESM(require("react"));
|
|
55
|
+
var import_react4 = require("react");
|
|
56
|
+
var import_editor_ui = require("@elementor/editor-ui");
|
|
57
|
+
var import_icons2 = require("@elementor/icons");
|
|
58
|
+
var import_ui5 = require("@elementor/ui");
|
|
59
|
+
var import_i18n3 = require("@wordpress/i18n");
|
|
118
60
|
|
|
119
|
-
// src/
|
|
120
|
-
var
|
|
121
|
-
var
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
var
|
|
61
|
+
// src/hooks/use-prop-variables.ts
|
|
62
|
+
var import_react2 = require("react");
|
|
63
|
+
var import_editor_controls = require("@elementor/editor-controls");
|
|
64
|
+
|
|
65
|
+
// src/context/variable-type-context.tsx
|
|
66
|
+
var React2 = __toESM(require("react"));
|
|
67
|
+
var import_react = require("react");
|
|
125
68
|
|
|
126
69
|
// src/variables-registry/create-variable-type-registry.ts
|
|
127
70
|
var import_editor_canvas3 = require("@elementor/editor-canvas");
|
|
128
71
|
var import_editor_editing_panel = require("@elementor/editor-editing-panel");
|
|
129
72
|
|
|
130
73
|
// src/transformers/inheritance-transformer.tsx
|
|
131
|
-
var
|
|
74
|
+
var React = __toESM(require("react"));
|
|
132
75
|
var import_editor_canvas = require("@elementor/editor-canvas");
|
|
133
|
-
var
|
|
134
|
-
var
|
|
76
|
+
var import_ui2 = require("@elementor/ui");
|
|
77
|
+
var import_i18n2 = require("@wordpress/i18n");
|
|
135
78
|
|
|
136
79
|
// src/components/ui/color-indicator.tsx
|
|
137
|
-
var
|
|
138
|
-
var ColorIndicator = (0,
|
|
80
|
+
var import_ui = require("@elementor/ui");
|
|
81
|
+
var ColorIndicator = (0, import_ui.styled)(import_ui.UnstableColorIndicator)(({ theme }) => ({
|
|
139
82
|
borderRadius: `${theme.shape.borderRadius / 2}px`,
|
|
140
83
|
marginRight: theme.spacing(0.25)
|
|
141
84
|
}));
|
|
@@ -146,7 +89,7 @@ var import_schema = require("@elementor/schema");
|
|
|
146
89
|
var colorVariablePropTypeUtil = (0, import_editor_props.createPropUtils)("global-color-variable", import_schema.z.string());
|
|
147
90
|
|
|
148
91
|
// src/service.ts
|
|
149
|
-
var
|
|
92
|
+
var import_i18n = require("@wordpress/i18n");
|
|
150
93
|
|
|
151
94
|
// src/api.ts
|
|
152
95
|
var import_http_client = require("@elementor/http-client");
|
|
@@ -345,7 +288,7 @@ var service = {
|
|
|
345
288
|
return apiClient.create(type, label, value).then((response) => {
|
|
346
289
|
const { success, data: payload } = response.data;
|
|
347
290
|
if (!success) {
|
|
348
|
-
const errorMessage = payload?.message || (0,
|
|
291
|
+
const errorMessage = payload?.message || (0, import_i18n.__)("Unexpected response from server", "elementor");
|
|
349
292
|
throw new Error(errorMessage);
|
|
350
293
|
}
|
|
351
294
|
return payload;
|
|
@@ -367,7 +310,7 @@ var service = {
|
|
|
367
310
|
return apiClient.update(id2, label, value).then((response) => {
|
|
368
311
|
const { success, data: payload } = response.data;
|
|
369
312
|
if (!success) {
|
|
370
|
-
const errorMessage = payload?.message || (0,
|
|
313
|
+
const errorMessage = payload?.message || (0, import_i18n.__)("Unexpected response from server", "elementor");
|
|
371
314
|
throw new Error(errorMessage);
|
|
372
315
|
}
|
|
373
316
|
return payload;
|
|
@@ -459,11 +402,11 @@ var inheritanceTransformer = (0, import_editor_canvas.createTransformer)((id2) =
|
|
|
459
402
|
const variables = service.variables();
|
|
460
403
|
const variable = variables[id2];
|
|
461
404
|
if (!variable) {
|
|
462
|
-
return /* @__PURE__ */
|
|
405
|
+
return /* @__PURE__ */ React.createElement("span", null, (0, import_i18n2.__)("Missing variable", "elementor"));
|
|
463
406
|
}
|
|
464
407
|
const showColorIndicator = variable.type === colorVariablePropTypeUtil.key;
|
|
465
408
|
const css = resolveCssVariable(id2, variable);
|
|
466
|
-
return /* @__PURE__ */
|
|
409
|
+
return /* @__PURE__ */ React.createElement(import_ui2.Stack, { direction: "row", spacing: 0.5, sx: { paddingInline: "1px" }, alignItems: "center" }, showColorIndicator && /* @__PURE__ */ React.createElement(ColorIndicator, { size: "inherit", value: variable.value }), /* @__PURE__ */ React.createElement(import_ui2.Typography, { variant: "caption", overflow: "hidden", whiteSpace: "nowrap", textOverflow: "ellipsis" }, css));
|
|
467
410
|
});
|
|
468
411
|
|
|
469
412
|
// src/transformers/variable-transformer.ts
|
|
@@ -527,88 +470,29 @@ function createVariableTypeRegistry() {
|
|
|
527
470
|
// src/variables-registry/variable-type-registry.ts
|
|
528
471
|
var { registerVariableType, getVariableType, hasVariableType } = createVariableTypeRegistry();
|
|
529
472
|
|
|
530
|
-
// src/utils/unlink-variable.ts
|
|
531
|
-
function transformValueBeforeUnlink(variable, propTypeKey) {
|
|
532
|
-
const { valueTransformer } = getVariableType(propTypeKey);
|
|
533
|
-
if (valueTransformer) {
|
|
534
|
-
return valueTransformer(variable.value);
|
|
535
|
-
}
|
|
536
|
-
return variable.value;
|
|
537
|
-
}
|
|
538
|
-
function createUnlinkHandler(variable, propTypeKey, setValue) {
|
|
539
|
-
return () => {
|
|
540
|
-
const { fallbackPropTypeUtil } = getVariableType(propTypeKey);
|
|
541
|
-
const transformedValue = transformValueBeforeUnlink(variable, propTypeKey);
|
|
542
|
-
setValue(fallbackPropTypeUtil.create(transformedValue));
|
|
543
|
-
};
|
|
544
|
-
}
|
|
545
|
-
|
|
546
|
-
// src/components/variable-selection-popover.tsx
|
|
547
|
-
var React15 = __toESM(require("react"));
|
|
548
|
-
var import_react10 = require("react");
|
|
549
|
-
var import_editor_v1_adapters2 = require("@elementor/editor-v1-adapters");
|
|
550
|
-
|
|
551
|
-
// src/context/variable-selection-popover.context.tsx
|
|
552
|
-
var React3 = __toESM(require("react"));
|
|
553
|
-
var import_react2 = require("react");
|
|
554
|
-
var import_ui4 = require("@elementor/ui");
|
|
555
|
-
var PopoverContentRefContext = (0, import_react2.createContext)(null);
|
|
556
|
-
var PopoverContentRefContextProvider = ({ children }) => {
|
|
557
|
-
const [anchorRef, setAnchorRef] = (0, import_react2.useState)(null);
|
|
558
|
-
return /* @__PURE__ */ React3.createElement(PopoverContentRefContext.Provider, { value: anchorRef }, /* @__PURE__ */ React3.createElement(import_ui4.Box, { ref: setAnchorRef }, children));
|
|
559
|
-
};
|
|
560
|
-
var usePopoverContentRef = () => {
|
|
561
|
-
return (0, import_react2.useContext)(PopoverContentRefContext);
|
|
562
|
-
};
|
|
563
|
-
|
|
564
473
|
// src/context/variable-type-context.tsx
|
|
565
|
-
var
|
|
566
|
-
var import_react3 = require("react");
|
|
567
|
-
var VariableTypeContext = (0, import_react3.createContext)(null);
|
|
474
|
+
var VariableTypeContext = (0, import_react.createContext)(null);
|
|
568
475
|
function VariableTypeProvider({ children, propTypeKey }) {
|
|
569
|
-
return /* @__PURE__ */
|
|
476
|
+
return /* @__PURE__ */ React2.createElement(VariableTypeContext.Provider, { value: propTypeKey }, children);
|
|
570
477
|
}
|
|
571
478
|
function useVariableType() {
|
|
572
|
-
const context = (0,
|
|
479
|
+
const context = (0, import_react.useContext)(VariableTypeContext);
|
|
573
480
|
if (context === null) {
|
|
574
481
|
throw new Error("useVariableType must be used within a VariableTypeProvider");
|
|
575
482
|
}
|
|
576
483
|
return getVariableType(context);
|
|
577
484
|
}
|
|
578
485
|
|
|
579
|
-
// src/hooks/use-permissions.ts
|
|
580
|
-
var import_editor_current_user = require("@elementor/editor-current-user");
|
|
581
|
-
var usePermissions = () => {
|
|
582
|
-
const { canUser } = (0, import_editor_current_user.useCurrentUserCapabilities)();
|
|
583
|
-
return {
|
|
584
|
-
canAssign: () => canUser("edit_posts"),
|
|
585
|
-
canUnlink: () => canUser("edit_posts"),
|
|
586
|
-
canAdd: () => canUser("manage_options"),
|
|
587
|
-
canDelete: () => canUser("manage_options"),
|
|
588
|
-
canEdit: () => canUser("manage_options"),
|
|
589
|
-
canRestore: () => canUser("manage_options"),
|
|
590
|
-
canManageSettings: () => canUser("manage_options")
|
|
591
|
-
};
|
|
592
|
-
};
|
|
593
|
-
|
|
594
|
-
// src/components/variable-creation.tsx
|
|
595
|
-
var React7 = __toESM(require("react"));
|
|
596
|
-
var import_react6 = require("react");
|
|
597
|
-
var import_editor_controls3 = require("@elementor/editor-controls");
|
|
598
|
-
var import_editor_editing_panel2 = require("@elementor/editor-editing-panel");
|
|
599
|
-
var import_editor_ui2 = require("@elementor/editor-ui");
|
|
600
|
-
var import_icons2 = require("@elementor/icons");
|
|
601
|
-
var import_ui7 = require("@elementor/ui");
|
|
602
|
-
var import_i18n6 = require("@wordpress/i18n");
|
|
603
|
-
|
|
604
|
-
// src/hooks/use-initial-value.ts
|
|
605
|
-
var import_editor_controls2 = require("@elementor/editor-controls");
|
|
606
|
-
|
|
607
486
|
// src/hooks/use-prop-variables.ts
|
|
608
|
-
var
|
|
609
|
-
var import_editor_controls = require("@elementor/editor-controls");
|
|
610
|
-
var useVariable = (key) => {
|
|
487
|
+
var getVariables = (includeDeleted = true) => {
|
|
611
488
|
const variables = service.variables();
|
|
489
|
+
if (includeDeleted) {
|
|
490
|
+
return variables;
|
|
491
|
+
}
|
|
492
|
+
return Object.fromEntries(Object.entries(variables).filter(([, variable]) => !variable.deleted));
|
|
493
|
+
};
|
|
494
|
+
var useVariable = (key) => {
|
|
495
|
+
const variables = getVariables();
|
|
612
496
|
if (!variables?.[key]) {
|
|
613
497
|
return null;
|
|
614
498
|
}
|
|
@@ -637,12 +521,11 @@ var filterVariablesBySearchValue = (variables, searchValue) => {
|
|
|
637
521
|
return variables.filter(({ label }) => label.toLowerCase().includes(lowerSearchValue));
|
|
638
522
|
};
|
|
639
523
|
var usePropVariables = (propKey) => {
|
|
640
|
-
return (0,
|
|
524
|
+
return (0, import_react2.useMemo)(() => normalizeVariables(propKey), [propKey]);
|
|
641
525
|
};
|
|
642
|
-
var isNotDeleted = ({ deleted }) => !deleted;
|
|
643
526
|
var normalizeVariables = (propKey) => {
|
|
644
|
-
const variables =
|
|
645
|
-
return Object.entries(variables).filter(([, variable]) => variable.type === propKey
|
|
527
|
+
const variables = getVariables(false);
|
|
528
|
+
return Object.entries(variables).filter(([, variable]) => variable.type === propKey).map(([key, { label, value }]) => ({
|
|
646
529
|
key,
|
|
647
530
|
label,
|
|
648
531
|
value
|
|
@@ -662,7 +545,331 @@ var restoreVariable = (restoreId, label, value) => {
|
|
|
662
545
|
return service.restore(restoreId, label, value).then(extractId);
|
|
663
546
|
};
|
|
664
547
|
|
|
548
|
+
// src/components/variables-manager/variable-edit-menu.tsx
|
|
549
|
+
var React3 = __toESM(require("react"));
|
|
550
|
+
var import_react3 = require("react");
|
|
551
|
+
var import_icons = require("@elementor/icons");
|
|
552
|
+
var import_ui3 = require("@elementor/ui");
|
|
553
|
+
var VariableEditMenu = ({ menuActions, disabled }) => {
|
|
554
|
+
const menuState = (0, import_ui3.usePopupState)({
|
|
555
|
+
variant: "popover"
|
|
556
|
+
});
|
|
557
|
+
return /* @__PURE__ */ React3.createElement(React3.Fragment, null, /* @__PURE__ */ React3.createElement(import_ui3.IconButton, { ...(0, import_ui3.bindTrigger)(menuState), disabled, size: "tiny" }, /* @__PURE__ */ React3.createElement(import_icons.DotsVerticalIcon, { fontSize: "tiny" })), /* @__PURE__ */ React3.createElement(
|
|
558
|
+
import_ui3.Menu,
|
|
559
|
+
{
|
|
560
|
+
disablePortal: true,
|
|
561
|
+
MenuListProps: {
|
|
562
|
+
dense: true
|
|
563
|
+
},
|
|
564
|
+
PaperProps: {
|
|
565
|
+
elevation: 6
|
|
566
|
+
},
|
|
567
|
+
...(0, import_ui3.bindMenu)(menuState),
|
|
568
|
+
anchorEl: menuState.anchorEl,
|
|
569
|
+
anchorOrigin: {
|
|
570
|
+
vertical: "bottom",
|
|
571
|
+
horizontal: "right"
|
|
572
|
+
},
|
|
573
|
+
transformOrigin: {
|
|
574
|
+
vertical: "top",
|
|
575
|
+
horizontal: "right"
|
|
576
|
+
},
|
|
577
|
+
open: menuState.isOpen,
|
|
578
|
+
onClose: menuState.close
|
|
579
|
+
},
|
|
580
|
+
menuActions.map((action) => /* @__PURE__ */ React3.createElement(
|
|
581
|
+
import_ui3.MenuItem,
|
|
582
|
+
{
|
|
583
|
+
key: action.name,
|
|
584
|
+
onClick: () => {
|
|
585
|
+
action.onClick?.();
|
|
586
|
+
menuState.close();
|
|
587
|
+
},
|
|
588
|
+
sx: {
|
|
589
|
+
color: action.color,
|
|
590
|
+
gap: 1
|
|
591
|
+
}
|
|
592
|
+
},
|
|
593
|
+
action.icon && (0, import_react3.createElement)(action.icon, {
|
|
594
|
+
fontSize: "inherit"
|
|
595
|
+
}),
|
|
596
|
+
" ",
|
|
597
|
+
action.name
|
|
598
|
+
))
|
|
599
|
+
));
|
|
600
|
+
};
|
|
601
|
+
|
|
602
|
+
// src/components/variables-manager/variable-table-cell.tsx
|
|
603
|
+
var React4 = __toESM(require("react"));
|
|
604
|
+
var import_ui4 = require("@elementor/ui");
|
|
605
|
+
var VariableTableCell = ({
|
|
606
|
+
children,
|
|
607
|
+
isHeader,
|
|
608
|
+
width,
|
|
609
|
+
maxWidth,
|
|
610
|
+
align,
|
|
611
|
+
noPadding,
|
|
612
|
+
sx
|
|
613
|
+
}) => {
|
|
614
|
+
const baseSx = {
|
|
615
|
+
maxWidth: maxWidth ?? 150,
|
|
616
|
+
cursor: "initial",
|
|
617
|
+
typography: "caption",
|
|
618
|
+
...isHeader && { color: "text.primary", fontWeight: "bold" },
|
|
619
|
+
...width && { width },
|
|
620
|
+
...sx
|
|
621
|
+
};
|
|
622
|
+
return /* @__PURE__ */ React4.createElement(import_ui4.TableCell, { size: "small", padding: noPadding ? "none" : void 0, align, sx: baseSx }, children);
|
|
623
|
+
};
|
|
624
|
+
|
|
625
|
+
// src/components/variables-manager/variables-manager-table.tsx
|
|
626
|
+
var VariablesManagerTable = ({ menuActions }) => {
|
|
627
|
+
const variables = getVariables(false);
|
|
628
|
+
const [ids, setIds] = (0, import_react4.useState)(Object.keys(variables));
|
|
629
|
+
const rows = ids.map((id2) => ({
|
|
630
|
+
id: id2,
|
|
631
|
+
name: variables[id2].label,
|
|
632
|
+
value: variables[id2].value,
|
|
633
|
+
type: variables[id2].type,
|
|
634
|
+
icon: getVariableType(variables[id2].type).icon,
|
|
635
|
+
startIcon: getVariableType(variables[id2].type).startIcon
|
|
636
|
+
}));
|
|
637
|
+
const tableSX = {
|
|
638
|
+
minWidth: 250,
|
|
639
|
+
tableLayout: "fixed"
|
|
640
|
+
};
|
|
641
|
+
return /* @__PURE__ */ React5.createElement(import_ui5.TableContainer, { sx: { overflow: "initial" } }, /* @__PURE__ */ React5.createElement(import_ui5.Table, { sx: tableSX, "aria-label": "Variables manager list with drag and drop reordering" }, /* @__PURE__ */ React5.createElement(import_ui5.TableHead, null, /* @__PURE__ */ React5.createElement(import_ui5.TableRow, null, /* @__PURE__ */ React5.createElement(VariableTableCell, { isHeader: true, noPadding: true, width: 10, maxWidth: 10 }), /* @__PURE__ */ React5.createElement(VariableTableCell, { isHeader: true }, (0, import_i18n3.__)("Name", "elementor")), /* @__PURE__ */ React5.createElement(VariableTableCell, { isHeader: true }, (0, import_i18n3.__)("Value", "elementor")), /* @__PURE__ */ React5.createElement(VariableTableCell, { isHeader: true, noPadding: true, width: 16, maxWidth: 16 }))), /* @__PURE__ */ React5.createElement(import_ui5.TableBody, null, /* @__PURE__ */ React5.createElement(
|
|
642
|
+
import_ui5.UnstableSortableProvider,
|
|
643
|
+
{
|
|
644
|
+
value: ids,
|
|
645
|
+
onChange: setIds,
|
|
646
|
+
variant: "static",
|
|
647
|
+
restrictAxis: true,
|
|
648
|
+
dragOverlay: ({ children: dragOverlayChildren, ...dragOverlayProps }) => /* @__PURE__ */ React5.createElement(import_ui5.Table, { sx: tableSX, ...dragOverlayProps }, /* @__PURE__ */ React5.createElement(import_ui5.TableBody, null, dragOverlayChildren))
|
|
649
|
+
},
|
|
650
|
+
rows.map((row) => /* @__PURE__ */ React5.createElement(
|
|
651
|
+
import_ui5.UnstableSortableItem,
|
|
652
|
+
{
|
|
653
|
+
key: row.id,
|
|
654
|
+
id: row.id,
|
|
655
|
+
render: ({
|
|
656
|
+
itemProps,
|
|
657
|
+
showDropIndication,
|
|
658
|
+
triggerProps,
|
|
659
|
+
itemStyle,
|
|
660
|
+
triggerStyle,
|
|
661
|
+
isDragged,
|
|
662
|
+
dropPosition,
|
|
663
|
+
setTriggerRef,
|
|
664
|
+
isDragOverlay,
|
|
665
|
+
isSorting,
|
|
666
|
+
index
|
|
667
|
+
}) => {
|
|
668
|
+
const showIndicationBefore = showDropIndication && dropPosition === "before";
|
|
669
|
+
const showIndicationAfter = showDropIndication && dropPosition === "after";
|
|
670
|
+
return /* @__PURE__ */ React5.createElement(
|
|
671
|
+
import_ui5.TableRow,
|
|
672
|
+
{
|
|
673
|
+
...itemProps,
|
|
674
|
+
selected: isDragged,
|
|
675
|
+
sx: {
|
|
676
|
+
...showIndicationBefore && {
|
|
677
|
+
"& td, & th": {
|
|
678
|
+
borderTop: "2px solid",
|
|
679
|
+
borderTopColor: "primary.main"
|
|
680
|
+
}
|
|
681
|
+
},
|
|
682
|
+
...showIndicationAfter && {
|
|
683
|
+
"& td, & th": {
|
|
684
|
+
borderBottom: "2px solid",
|
|
685
|
+
borderBottomColor: "primary.main"
|
|
686
|
+
}
|
|
687
|
+
},
|
|
688
|
+
'& [role="toolbar"], & [draggable]': {
|
|
689
|
+
opacity: 0
|
|
690
|
+
},
|
|
691
|
+
"&:hover, &:focus-within": {
|
|
692
|
+
backgroundColor: "action.hover",
|
|
693
|
+
'& [role="toolbar"], & [draggable]': {
|
|
694
|
+
opacity: 1
|
|
695
|
+
}
|
|
696
|
+
}
|
|
697
|
+
},
|
|
698
|
+
style: { ...itemStyle, ...triggerStyle },
|
|
699
|
+
disableDivider: isDragOverlay || index === rows.length - 1
|
|
700
|
+
},
|
|
701
|
+
/* @__PURE__ */ React5.createElement(VariableTableCell, { noPadding: true, width: 10, maxWidth: 10 }, /* @__PURE__ */ React5.createElement(
|
|
702
|
+
import_ui5.IconButton,
|
|
703
|
+
{
|
|
704
|
+
size: "small",
|
|
705
|
+
ref: setTriggerRef,
|
|
706
|
+
...triggerProps,
|
|
707
|
+
disabled: isSorting,
|
|
708
|
+
draggable: true
|
|
709
|
+
},
|
|
710
|
+
/* @__PURE__ */ React5.createElement(import_icons2.GripVerticalIcon, { fontSize: "inherit" })
|
|
711
|
+
)),
|
|
712
|
+
/* @__PURE__ */ React5.createElement(VariableTableCell, null, /* @__PURE__ */ React5.createElement(import_ui5.Stack, { direction: "row", alignItems: "center", gap: 1 }, (0, import_react4.createElement)(row.icon, { fontSize: "inherit" }), /* @__PURE__ */ React5.createElement(import_editor_ui.EllipsisWithTooltip, { title: row.name }, row.name))),
|
|
713
|
+
/* @__PURE__ */ React5.createElement(VariableTableCell, null, /* @__PURE__ */ React5.createElement(import_ui5.Stack, { direction: "row", alignItems: "center", gap: 1 }, row.startIcon && row.startIcon({ value: row.value }), /* @__PURE__ */ React5.createElement(import_editor_ui.EllipsisWithTooltip, { title: row.value }, row.value))),
|
|
714
|
+
/* @__PURE__ */ React5.createElement(
|
|
715
|
+
VariableTableCell,
|
|
716
|
+
{
|
|
717
|
+
align: "right",
|
|
718
|
+
noPadding: true,
|
|
719
|
+
width: 16,
|
|
720
|
+
maxWidth: 16,
|
|
721
|
+
sx: { paddingInlineEnd: 1 }
|
|
722
|
+
},
|
|
723
|
+
/* @__PURE__ */ React5.createElement(import_ui5.Stack, { role: "toolbar", direction: "row", justifyContent: "flex-end" }, /* @__PURE__ */ React5.createElement(
|
|
724
|
+
VariableEditMenu,
|
|
725
|
+
{
|
|
726
|
+
menuActions,
|
|
727
|
+
disabled: isSorting
|
|
728
|
+
}
|
|
729
|
+
))
|
|
730
|
+
)
|
|
731
|
+
);
|
|
732
|
+
}
|
|
733
|
+
}
|
|
734
|
+
))
|
|
735
|
+
))));
|
|
736
|
+
};
|
|
737
|
+
|
|
738
|
+
// src/components/variables-manager/variables-manager-panel.tsx
|
|
739
|
+
var id = "variables-manager";
|
|
740
|
+
var { panel, usePanelActions } = (0, import_editor_panels.__createPanel)({
|
|
741
|
+
id,
|
|
742
|
+
component: VariablesManagerPanel,
|
|
743
|
+
allowedEditModes: ["edit", id],
|
|
744
|
+
onOpen: () => {
|
|
745
|
+
(0, import_editor_v1_adapters.changeEditMode)(id);
|
|
746
|
+
},
|
|
747
|
+
onClose: () => {
|
|
748
|
+
(0, import_editor_v1_adapters.changeEditMode)("edit");
|
|
749
|
+
}
|
|
750
|
+
});
|
|
751
|
+
function VariablesManagerPanel() {
|
|
752
|
+
const { close: closePanel } = usePanelActions();
|
|
753
|
+
const isDirty = false;
|
|
754
|
+
usePreventUnload(isDirty);
|
|
755
|
+
const menuActions = [
|
|
756
|
+
{
|
|
757
|
+
name: (0, import_i18n4.__)("Delete", "elementor"),
|
|
758
|
+
icon: import_icons3.TrashIcon,
|
|
759
|
+
color: "error.main",
|
|
760
|
+
onClick: () => {
|
|
761
|
+
}
|
|
762
|
+
}
|
|
763
|
+
];
|
|
764
|
+
return /* @__PURE__ */ React6.createElement(import_editor_ui2.ThemeProvider, null, /* @__PURE__ */ React6.createElement(import_ui6.ErrorBoundary, { fallback: /* @__PURE__ */ React6.createElement(ErrorBoundaryFallback, null) }, /* @__PURE__ */ React6.createElement(import_editor_panels.Panel, null, /* @__PURE__ */ React6.createElement(import_editor_panels.PanelHeader, null, /* @__PURE__ */ React6.createElement(import_ui6.Stack, { p: 1, pl: 2, width: "100%", direction: "row", alignItems: "center" }, /* @__PURE__ */ React6.createElement(import_ui6.Stack, { width: "100%", direction: "row", gap: 1 }, /* @__PURE__ */ React6.createElement(import_editor_panels.PanelHeaderTitle, { sx: { display: "flex", alignItems: "center", gap: 0.5 } }, /* @__PURE__ */ React6.createElement(import_icons3.ColorFilterIcon, { fontSize: "inherit" }), (0, import_i18n4.__)("Variable Manager", "elementor"))), /* @__PURE__ */ React6.createElement(
|
|
765
|
+
CloseButton,
|
|
766
|
+
{
|
|
767
|
+
sx: { marginLeft: "auto" },
|
|
768
|
+
onClose: () => {
|
|
769
|
+
closePanel();
|
|
770
|
+
}
|
|
771
|
+
}
|
|
772
|
+
))), /* @__PURE__ */ React6.createElement(
|
|
773
|
+
import_editor_panels.PanelBody,
|
|
774
|
+
{
|
|
775
|
+
sx: {
|
|
776
|
+
display: "flex",
|
|
777
|
+
flexDirection: "column",
|
|
778
|
+
height: "100%"
|
|
779
|
+
}
|
|
780
|
+
},
|
|
781
|
+
/* @__PURE__ */ React6.createElement(import_ui6.Divider, null),
|
|
782
|
+
/* @__PURE__ */ React6.createElement(VariablesManagerTable, { menuActions })
|
|
783
|
+
), /* @__PURE__ */ React6.createElement(import_editor_panels.PanelFooter, null, /* @__PURE__ */ React6.createElement(import_ui6.Button, { fullWidth: true, size: "small", color: "global", variant: "contained", disabled: !isDirty }, (0, import_i18n4.__)("Save changes", "elementor"))))));
|
|
784
|
+
}
|
|
785
|
+
var CloseButton = ({ onClose, ...props }) => /* @__PURE__ */ React6.createElement(import_ui6.IconButton, { size: "small", color: "secondary", onClick: onClose, "aria-label": "Close", ...props }, /* @__PURE__ */ React6.createElement(import_icons3.XIcon, { fontSize: "small" }));
|
|
786
|
+
var ErrorBoundaryFallback = () => /* @__PURE__ */ React6.createElement(import_ui6.Box, { role: "alert", sx: { minHeight: "100%", p: 2 } }, /* @__PURE__ */ React6.createElement(import_ui6.Alert, { severity: "error", sx: { mb: 2, maxWidth: 400, textAlign: "center" } }, /* @__PURE__ */ React6.createElement("strong", null, (0, import_i18n4.__)("Something went wrong", "elementor"))));
|
|
787
|
+
var usePreventUnload = (isDirty) => {
|
|
788
|
+
(0, import_react5.useEffect)(() => {
|
|
789
|
+
const handleBeforeUnload = (event) => {
|
|
790
|
+
if (isDirty) {
|
|
791
|
+
event.preventDefault();
|
|
792
|
+
}
|
|
793
|
+
};
|
|
794
|
+
window.addEventListener("beforeunload", handleBeforeUnload);
|
|
795
|
+
return () => {
|
|
796
|
+
window.removeEventListener("beforeunload", handleBeforeUnload);
|
|
797
|
+
};
|
|
798
|
+
}, [isDirty]);
|
|
799
|
+
};
|
|
800
|
+
|
|
801
|
+
// src/controls/variable-control.tsx
|
|
802
|
+
var React28 = __toESM(require("react"));
|
|
803
|
+
var import_editor_controls10 = require("@elementor/editor-controls");
|
|
804
|
+
|
|
805
|
+
// src/components/ui/variable/assigned-variable.tsx
|
|
806
|
+
var import_react13 = require("react");
|
|
807
|
+
var React20 = __toESM(require("react"));
|
|
808
|
+
var import_editor_controls6 = require("@elementor/editor-controls");
|
|
809
|
+
var import_icons11 = require("@elementor/icons");
|
|
810
|
+
var import_ui20 = require("@elementor/ui");
|
|
811
|
+
|
|
812
|
+
// src/utils/unlink-variable.ts
|
|
813
|
+
function transformValueBeforeUnlink(variable, propTypeKey) {
|
|
814
|
+
const { valueTransformer } = getVariableType(propTypeKey);
|
|
815
|
+
if (valueTransformer) {
|
|
816
|
+
return valueTransformer(variable.value);
|
|
817
|
+
}
|
|
818
|
+
return variable.value;
|
|
819
|
+
}
|
|
820
|
+
function createUnlinkHandler(variable, propTypeKey, setValue) {
|
|
821
|
+
return () => {
|
|
822
|
+
const { fallbackPropTypeUtil } = getVariableType(propTypeKey);
|
|
823
|
+
const transformedValue = transformValueBeforeUnlink(variable, propTypeKey);
|
|
824
|
+
setValue(fallbackPropTypeUtil.create(transformedValue));
|
|
825
|
+
};
|
|
826
|
+
}
|
|
827
|
+
|
|
828
|
+
// src/components/variable-selection-popover.tsx
|
|
829
|
+
var React18 = __toESM(require("react"));
|
|
830
|
+
var import_react12 = require("react");
|
|
831
|
+
var import_editor_v1_adapters2 = require("@elementor/editor-v1-adapters");
|
|
832
|
+
|
|
833
|
+
// src/context/variable-selection-popover.context.tsx
|
|
834
|
+
var React7 = __toESM(require("react"));
|
|
835
|
+
var import_react6 = require("react");
|
|
836
|
+
var import_ui7 = require("@elementor/ui");
|
|
837
|
+
var PopoverContentRefContext = (0, import_react6.createContext)(null);
|
|
838
|
+
var PopoverContentRefContextProvider = ({ children }) => {
|
|
839
|
+
const [anchorRef, setAnchorRef] = (0, import_react6.useState)(null);
|
|
840
|
+
return /* @__PURE__ */ React7.createElement(PopoverContentRefContext.Provider, { value: anchorRef }, /* @__PURE__ */ React7.createElement(import_ui7.Box, { ref: setAnchorRef }, children));
|
|
841
|
+
};
|
|
842
|
+
var usePopoverContentRef = () => {
|
|
843
|
+
return (0, import_react6.useContext)(PopoverContentRefContext);
|
|
844
|
+
};
|
|
845
|
+
|
|
846
|
+
// src/hooks/use-permissions.ts
|
|
847
|
+
var import_editor_current_user = require("@elementor/editor-current-user");
|
|
848
|
+
var usePermissions = () => {
|
|
849
|
+
const { canUser } = (0, import_editor_current_user.useCurrentUserCapabilities)();
|
|
850
|
+
return {
|
|
851
|
+
canAssign: () => canUser("edit_posts"),
|
|
852
|
+
canUnlink: () => canUser("edit_posts"),
|
|
853
|
+
canAdd: () => canUser("manage_options"),
|
|
854
|
+
canDelete: () => canUser("manage_options"),
|
|
855
|
+
canEdit: () => canUser("manage_options"),
|
|
856
|
+
canRestore: () => canUser("manage_options"),
|
|
857
|
+
canManageSettings: () => canUser("manage_options")
|
|
858
|
+
};
|
|
859
|
+
};
|
|
860
|
+
|
|
861
|
+
// src/components/variable-creation.tsx
|
|
862
|
+
var React10 = __toESM(require("react"));
|
|
863
|
+
var import_react8 = require("react");
|
|
864
|
+
var import_editor_controls3 = require("@elementor/editor-controls");
|
|
865
|
+
var import_editor_editing_panel2 = require("@elementor/editor-editing-panel");
|
|
866
|
+
var import_editor_ui3 = require("@elementor/editor-ui");
|
|
867
|
+
var import_icons4 = require("@elementor/icons");
|
|
868
|
+
var import_ui10 = require("@elementor/ui");
|
|
869
|
+
var import_i18n7 = require("@wordpress/i18n");
|
|
870
|
+
|
|
665
871
|
// src/hooks/use-initial-value.ts
|
|
872
|
+
var import_editor_controls2 = require("@elementor/editor-controls");
|
|
666
873
|
var useInitialValue = () => {
|
|
667
874
|
const { value: initial } = (0, import_editor_controls2.useBoundProp)();
|
|
668
875
|
const hasAssignedVariable2 = hasVariableType(initial?.$$type) && Boolean(initial?.value);
|
|
@@ -692,15 +899,15 @@ var trackVariableEvent = ({ varType, controlPath, action }) => {
|
|
|
692
899
|
};
|
|
693
900
|
|
|
694
901
|
// src/utils/validations.ts
|
|
695
|
-
var
|
|
902
|
+
var import_i18n5 = require("@wordpress/i18n");
|
|
696
903
|
var ERROR_MESSAGES = {
|
|
697
|
-
MISSING_VARIABLE_NAME: (0,
|
|
698
|
-
MISSING_VARIABLE_VALUE: (0,
|
|
699
|
-
INVALID_CHARACTERS: (0,
|
|
700
|
-
NO_NON_SPECIAL_CHARACTER: (0,
|
|
701
|
-
VARIABLE_LABEL_MAX_LENGTH: (0,
|
|
702
|
-
DUPLICATED_LABEL: (0,
|
|
703
|
-
UNEXPECTED_ERROR: (0,
|
|
904
|
+
MISSING_VARIABLE_NAME: (0, import_i18n5.__)("Give your variable a name.", "elementor"),
|
|
905
|
+
MISSING_VARIABLE_VALUE: (0, import_i18n5.__)("Add a value to complete your variable.", "elementor"),
|
|
906
|
+
INVALID_CHARACTERS: (0, import_i18n5.__)("Use letters, numbers, dashes (-), or underscores (_) for the name.", "elementor"),
|
|
907
|
+
NO_NON_SPECIAL_CHARACTER: (0, import_i18n5.__)("Names have to include at least one non-special character.", "elementor"),
|
|
908
|
+
VARIABLE_LABEL_MAX_LENGTH: (0, import_i18n5.__)("Keep names up to 50 characters.", "elementor"),
|
|
909
|
+
DUPLICATED_LABEL: (0, import_i18n5.__)("This variable name already exists. Please choose a unique name.", "elementor"),
|
|
910
|
+
UNEXPECTED_ERROR: (0, import_i18n5.__)("There was a glitch. Try saving your variable again.", "elementor")
|
|
704
911
|
};
|
|
705
912
|
var VARIABLE_LABEL_MAX_LENGTH = 50;
|
|
706
913
|
var mapServerError = (error) => {
|
|
@@ -744,16 +951,16 @@ var validateValue = (value) => {
|
|
|
744
951
|
};
|
|
745
952
|
|
|
746
953
|
// src/components/fields/label-field.tsx
|
|
747
|
-
var
|
|
748
|
-
var
|
|
749
|
-
var
|
|
750
|
-
var
|
|
954
|
+
var React9 = __toESM(require("react"));
|
|
955
|
+
var import_react7 = require("react");
|
|
956
|
+
var import_ui9 = require("@elementor/ui");
|
|
957
|
+
var import_i18n6 = require("@wordpress/i18n");
|
|
751
958
|
|
|
752
959
|
// src/components/ui/form-field.tsx
|
|
753
|
-
var
|
|
754
|
-
var
|
|
960
|
+
var React8 = __toESM(require("react"));
|
|
961
|
+
var import_ui8 = require("@elementor/ui");
|
|
755
962
|
var FormField = ({ id: id2, label, errorMsg, noticeMsg, children }) => {
|
|
756
|
-
return /* @__PURE__ */
|
|
963
|
+
return /* @__PURE__ */ React8.createElement(import_ui8.Grid, { container: true, gap: 0.75, alignItems: "center" }, /* @__PURE__ */ React8.createElement(import_ui8.Grid, { item: true, xs: 12 }, /* @__PURE__ */ React8.createElement(import_ui8.FormLabel, { htmlFor: id2, size: "tiny" }, label)), /* @__PURE__ */ React8.createElement(import_ui8.Grid, { item: true, xs: 12 }, children, errorMsg && /* @__PURE__ */ React8.createElement(import_ui8.FormHelperText, { error: true }, errorMsg), noticeMsg && /* @__PURE__ */ React8.createElement(import_ui8.FormHelperText, null, noticeMsg)));
|
|
757
964
|
};
|
|
758
965
|
|
|
759
966
|
// src/components/fields/label-field.tsx
|
|
@@ -761,16 +968,16 @@ function isLabelEqual(a, b) {
|
|
|
761
968
|
return a.trim().toLowerCase() === b.trim().toLowerCase();
|
|
762
969
|
}
|
|
763
970
|
var useLabelError = (initialError) => {
|
|
764
|
-
const [error, setError] = (0,
|
|
971
|
+
const [error, setError] = (0, import_react7.useState)(initialError ?? { value: "", message: "" });
|
|
765
972
|
return {
|
|
766
973
|
labelFieldError: error,
|
|
767
974
|
setLabelFieldError: setError
|
|
768
975
|
};
|
|
769
976
|
};
|
|
770
977
|
var LabelField = ({ value, error, onChange }) => {
|
|
771
|
-
const [label, setLabel] = (0,
|
|
772
|
-
const [errorMessage, setErrorMessage] = (0,
|
|
773
|
-
const [noticeMessage, setNoticeMessage] = (0,
|
|
978
|
+
const [label, setLabel] = (0, import_react7.useState)(value);
|
|
979
|
+
const [errorMessage, setErrorMessage] = (0, import_react7.useState)("");
|
|
980
|
+
const [noticeMessage, setNoticeMessage] = (0, import_react7.useState)(() => labelHint(value));
|
|
774
981
|
const handleChange = (newValue) => {
|
|
775
982
|
setLabel(newValue);
|
|
776
983
|
const errorMsg2 = validateLabel(newValue);
|
|
@@ -779,14 +986,14 @@ var LabelField = ({ value, error, onChange }) => {
|
|
|
779
986
|
setNoticeMessage(errorMsg2 ? "" : hintMsg);
|
|
780
987
|
onChange(isLabelEqual(newValue, error?.value ?? "") || errorMsg2 ? "" : newValue);
|
|
781
988
|
};
|
|
782
|
-
const id2 = (0,
|
|
989
|
+
const id2 = (0, import_react7.useId)();
|
|
783
990
|
let errorMsg = errorMessage;
|
|
784
991
|
if (isLabelEqual(label, error?.value ?? "") && error?.message) {
|
|
785
992
|
errorMsg = error.message;
|
|
786
993
|
}
|
|
787
994
|
const noticeMsg = errorMsg ? "" : noticeMessage;
|
|
788
|
-
return /* @__PURE__ */
|
|
789
|
-
|
|
995
|
+
return /* @__PURE__ */ React9.createElement(FormField, { id: id2, label: (0, import_i18n6.__)("Name", "elementor"), errorMsg, noticeMsg }, /* @__PURE__ */ React9.createElement(
|
|
996
|
+
import_ui9.TextField,
|
|
790
997
|
{
|
|
791
998
|
id: id2,
|
|
792
999
|
size: "tiny",
|
|
@@ -805,10 +1012,10 @@ var VariableCreation = ({ onGoBack, onClose }) => {
|
|
|
805
1012
|
const { icon: VariableIcon, valueField: ValueField, variableType, propTypeUtil } = useVariableType();
|
|
806
1013
|
const { setValue: setVariable, path } = (0, import_editor_controls3.useBoundProp)(propTypeUtil);
|
|
807
1014
|
const initialValue = useInitialValue();
|
|
808
|
-
const [value, setValue] = (0,
|
|
809
|
-
const [label, setLabel] = (0,
|
|
810
|
-
const [errorMessage, setErrorMessage] = (0,
|
|
811
|
-
const [valueFieldError, setValueFieldError] = (0,
|
|
1015
|
+
const [value, setValue] = (0, import_react8.useState)(initialValue);
|
|
1016
|
+
const [label, setLabel] = (0, import_react8.useState)("");
|
|
1017
|
+
const [errorMessage, setErrorMessage] = (0, import_react8.useState)("");
|
|
1018
|
+
const [valueFieldError, setValueFieldError] = (0, import_react8.useState)("");
|
|
812
1019
|
const { labelFieldError, setLabelFieldError } = useLabelError();
|
|
813
1020
|
const resetFields = () => {
|
|
814
1021
|
setValue("");
|
|
@@ -859,14 +1066,14 @@ var VariableCreation = ({ onGoBack, onClose }) => {
|
|
|
859
1066
|
return !!errorMessage;
|
|
860
1067
|
};
|
|
861
1068
|
const isSubmitDisabled = hasEmptyFields() || hasErrors();
|
|
862
|
-
return /* @__PURE__ */
|
|
863
|
-
|
|
1069
|
+
return /* @__PURE__ */ React10.createElement(import_editor_editing_panel2.PopoverBody, { height: "auto" }, /* @__PURE__ */ React10.createElement(
|
|
1070
|
+
import_editor_ui3.PopoverHeader,
|
|
864
1071
|
{
|
|
865
|
-
icon: /* @__PURE__ */
|
|
866
|
-
title: (0,
|
|
1072
|
+
icon: /* @__PURE__ */ React10.createElement(React10.Fragment, null, onGoBack && /* @__PURE__ */ React10.createElement(import_ui10.IconButton, { size: SIZE, "aria-label": (0, import_i18n7.__)("Go Back", "elementor"), onClick: onGoBack }, /* @__PURE__ */ React10.createElement(import_icons4.ArrowLeftIcon, { fontSize: SIZE })), /* @__PURE__ */ React10.createElement(VariableIcon, { fontSize: SIZE })),
|
|
1073
|
+
title: (0, import_i18n7.__)("Create variable", "elementor"),
|
|
867
1074
|
onClose: closePopover
|
|
868
1075
|
}
|
|
869
|
-
), /* @__PURE__ */
|
|
1076
|
+
), /* @__PURE__ */ React10.createElement(import_ui10.Divider, null), /* @__PURE__ */ React10.createElement(import_editor_controls3.PopoverContent, { p: 2 }, /* @__PURE__ */ React10.createElement(
|
|
870
1077
|
LabelField,
|
|
871
1078
|
{
|
|
872
1079
|
value: label,
|
|
@@ -876,7 +1083,7 @@ var VariableCreation = ({ onGoBack, onClose }) => {
|
|
|
876
1083
|
setErrorMessage("");
|
|
877
1084
|
}
|
|
878
1085
|
}
|
|
879
|
-
), /* @__PURE__ */
|
|
1086
|
+
), /* @__PURE__ */ React10.createElement(FormField, { errorMsg: valueFieldError, label: (0, import_i18n7.__)("Value", "elementor") }, /* @__PURE__ */ React10.createElement(
|
|
880
1087
|
ValueField,
|
|
881
1088
|
{
|
|
882
1089
|
value,
|
|
@@ -887,25 +1094,25 @@ var VariableCreation = ({ onGoBack, onClose }) => {
|
|
|
887
1094
|
},
|
|
888
1095
|
onValidationChange: setValueFieldError
|
|
889
1096
|
}
|
|
890
|
-
)), errorMessage && /* @__PURE__ */
|
|
1097
|
+
)), errorMessage && /* @__PURE__ */ React10.createElement(import_ui10.FormHelperText, { error: true }, errorMessage)), /* @__PURE__ */ React10.createElement(import_ui10.CardActions, { sx: { pt: 0.5, pb: 1 } }, /* @__PURE__ */ React10.createElement(import_ui10.Button, { size: "small", variant: "contained", disabled: isSubmitDisabled, onClick: handleCreateAndTrack }, (0, import_i18n7.__)("Create", "elementor"))));
|
|
891
1098
|
};
|
|
892
1099
|
|
|
893
1100
|
// src/components/variable-edit.tsx
|
|
894
|
-
var
|
|
895
|
-
var
|
|
1101
|
+
var React13 = __toESM(require("react"));
|
|
1102
|
+
var import_react10 = require("react");
|
|
896
1103
|
var import_editor_controls4 = require("@elementor/editor-controls");
|
|
897
1104
|
var import_editor_current_user2 = require("@elementor/editor-current-user");
|
|
898
1105
|
var import_editor_editing_panel3 = require("@elementor/editor-editing-panel");
|
|
899
|
-
var
|
|
900
|
-
var
|
|
901
|
-
var
|
|
902
|
-
var
|
|
1106
|
+
var import_editor_ui4 = require("@elementor/editor-ui");
|
|
1107
|
+
var import_icons7 = require("@elementor/icons");
|
|
1108
|
+
var import_ui13 = require("@elementor/ui");
|
|
1109
|
+
var import_i18n10 = require("@wordpress/i18n");
|
|
903
1110
|
|
|
904
1111
|
// src/components/ui/delete-confirmation-dialog.tsx
|
|
905
|
-
var
|
|
906
|
-
var
|
|
907
|
-
var
|
|
908
|
-
var
|
|
1112
|
+
var React11 = __toESM(require("react"));
|
|
1113
|
+
var import_icons5 = require("@elementor/icons");
|
|
1114
|
+
var import_ui11 = require("@elementor/ui");
|
|
1115
|
+
var import_i18n8 = require("@wordpress/i18n");
|
|
909
1116
|
var TITLE_ID = "delete-variable-dialog";
|
|
910
1117
|
var DeleteConfirmationDialog = ({
|
|
911
1118
|
open,
|
|
@@ -913,45 +1120,45 @@ var DeleteConfirmationDialog = ({
|
|
|
913
1120
|
closeDialog,
|
|
914
1121
|
onConfirm
|
|
915
1122
|
}) => {
|
|
916
|
-
return /* @__PURE__ */
|
|
1123
|
+
return /* @__PURE__ */ React11.createElement(import_ui11.Dialog, { open, onClose: closeDialog, "aria-labelledby": TITLE_ID, maxWidth: "xs" }, /* @__PURE__ */ React11.createElement(import_ui11.DialogTitle, { id: TITLE_ID, display: "flex", alignItems: "center", gap: 1, sx: { lineHeight: 1 } }, /* @__PURE__ */ React11.createElement(import_icons5.AlertOctagonFilledIcon, { color: "error" }), (0, import_i18n8.__)("Delete this variable?", "elementor")), /* @__PURE__ */ React11.createElement(import_ui11.DialogContent, null, /* @__PURE__ */ React11.createElement(import_ui11.DialogContentText, { variant: "body2", color: "textPrimary" }, (0, import_i18n8.__)("All elements using", "elementor"), /* @__PURE__ */ React11.createElement(import_ui11.Typography, { variant: "subtitle2", component: "span" }, "\xA0", label, "\xA0"), (0, import_i18n8.__)("will keep their current values, but the variable itself will be removed.", "elementor"))), /* @__PURE__ */ React11.createElement(import_ui11.DialogActions, null, /* @__PURE__ */ React11.createElement(import_ui11.Button, { color: "secondary", onClick: closeDialog }, (0, import_i18n8.__)("Not now", "elementor")), /* @__PURE__ */ React11.createElement(import_ui11.Button, { variant: "contained", color: "error", onClick: onConfirm }, (0, import_i18n8.__)("Delete", "elementor"))));
|
|
917
1124
|
};
|
|
918
1125
|
|
|
919
1126
|
// src/components/ui/edit-confirmation-dialog.tsx
|
|
920
|
-
var
|
|
921
|
-
var
|
|
922
|
-
var
|
|
923
|
-
var
|
|
924
|
-
var
|
|
1127
|
+
var React12 = __toESM(require("react"));
|
|
1128
|
+
var import_react9 = require("react");
|
|
1129
|
+
var import_icons6 = require("@elementor/icons");
|
|
1130
|
+
var import_ui12 = require("@elementor/ui");
|
|
1131
|
+
var import_i18n9 = require("@wordpress/i18n");
|
|
925
1132
|
var EDIT_CONFIRMATION_DIALOG_ID = "edit-confirmation-dialog";
|
|
926
1133
|
var EditConfirmationDialog = ({
|
|
927
1134
|
closeDialog,
|
|
928
1135
|
onConfirm,
|
|
929
1136
|
onSuppressMessage
|
|
930
1137
|
}) => {
|
|
931
|
-
const [dontShowAgain, setDontShowAgain] = (0,
|
|
1138
|
+
const [dontShowAgain, setDontShowAgain] = (0, import_react9.useState)(false);
|
|
932
1139
|
const handleSave = () => {
|
|
933
1140
|
if (dontShowAgain) {
|
|
934
1141
|
onSuppressMessage?.();
|
|
935
1142
|
}
|
|
936
1143
|
onConfirm?.();
|
|
937
1144
|
};
|
|
938
|
-
return /* @__PURE__ */
|
|
1145
|
+
return /* @__PURE__ */ React12.createElement(import_ui12.Dialog, { open: true, onClose: closeDialog, maxWidth: "xs" }, /* @__PURE__ */ React12.createElement(import_ui12.DialogTitle, { display: "flex", alignItems: "center", gap: 1 }, /* @__PURE__ */ React12.createElement(import_icons6.AlertTriangleFilledIcon, { color: "secondary" }), (0, import_i18n9.__)("Changes to variables go live right away.", "elementor")), /* @__PURE__ */ React12.createElement(import_ui12.DialogContent, null, /* @__PURE__ */ React12.createElement(import_ui12.DialogContentText, { variant: "body2", color: "textPrimary" }, (0, import_i18n9.__)(
|
|
939
1146
|
"Don't worry - all other changes you make will wait until you publish your site.",
|
|
940
1147
|
"elementor"
|
|
941
|
-
))), /* @__PURE__ */
|
|
942
|
-
|
|
1148
|
+
))), /* @__PURE__ */ React12.createElement(import_ui12.DialogActions, { sx: { justifyContent: "space-between", alignItems: "center" } }, /* @__PURE__ */ React12.createElement(
|
|
1149
|
+
import_ui12.FormControlLabel,
|
|
943
1150
|
{
|
|
944
|
-
control: /* @__PURE__ */
|
|
945
|
-
|
|
1151
|
+
control: /* @__PURE__ */ React12.createElement(
|
|
1152
|
+
import_ui12.Checkbox,
|
|
946
1153
|
{
|
|
947
1154
|
checked: dontShowAgain,
|
|
948
1155
|
onChange: (event) => setDontShowAgain(event.target.checked),
|
|
949
1156
|
size: "small"
|
|
950
1157
|
}
|
|
951
1158
|
),
|
|
952
|
-
label: /* @__PURE__ */
|
|
1159
|
+
label: /* @__PURE__ */ React12.createElement(import_ui12.Typography, { variant: "body2" }, (0, import_i18n9.__)("Don't show me again", "elementor"))
|
|
953
1160
|
}
|
|
954
|
-
), /* @__PURE__ */
|
|
1161
|
+
), /* @__PURE__ */ React12.createElement("div", null, /* @__PURE__ */ React12.createElement(import_ui12.Button, { color: "secondary", onClick: closeDialog }, (0, import_i18n9.__)("Keep editing", "elementor")), /* @__PURE__ */ React12.createElement(import_ui12.Button, { variant: "contained", color: "secondary", onClick: handleSave, sx: { ml: 1 } }, (0, import_i18n9.__)("Save", "elementor")))));
|
|
955
1162
|
};
|
|
956
1163
|
|
|
957
1164
|
// src/components/variable-edit.tsx
|
|
@@ -960,19 +1167,19 @@ var VariableEdit = ({ onClose, onGoBack, onSubmit, editId }) => {
|
|
|
960
1167
|
const { icon: VariableIcon, valueField: ValueField, variableType, propTypeUtil } = useVariableType();
|
|
961
1168
|
const { setValue: notifyBoundPropChange, value: assignedValue } = (0, import_editor_controls4.useBoundProp)(propTypeUtil);
|
|
962
1169
|
const [isMessageSuppressed, suppressMessage] = (0, import_editor_current_user2.useSuppressedMessage)(EDIT_CONFIRMATION_DIALOG_ID);
|
|
963
|
-
const [deleteConfirmation, setDeleteConfirmation] = (0,
|
|
964
|
-
const [editConfirmation, setEditConfirmation] = (0,
|
|
965
|
-
const [errorMessage, setErrorMessage] = (0,
|
|
966
|
-
const [valueFieldError, setValueFieldError] = (0,
|
|
1170
|
+
const [deleteConfirmation, setDeleteConfirmation] = (0, import_react10.useState)(false);
|
|
1171
|
+
const [editConfirmation, setEditConfirmation] = (0, import_react10.useState)(false);
|
|
1172
|
+
const [errorMessage, setErrorMessage] = (0, import_react10.useState)("");
|
|
1173
|
+
const [valueFieldError, setValueFieldError] = (0, import_react10.useState)("");
|
|
967
1174
|
const { labelFieldError, setLabelFieldError } = useLabelError();
|
|
968
1175
|
const variable = useVariable(editId);
|
|
969
1176
|
if (!variable) {
|
|
970
1177
|
throw new Error(`Global ${variableType} variable not found`);
|
|
971
1178
|
}
|
|
972
1179
|
const userPermissions = usePermissions();
|
|
973
|
-
const [value, setValue] = (0,
|
|
974
|
-
const [label, setLabel] = (0,
|
|
975
|
-
(0,
|
|
1180
|
+
const [value, setValue] = (0, import_react10.useState)(() => variable.value);
|
|
1181
|
+
const [label, setLabel] = (0, import_react10.useState)(() => variable.label);
|
|
1182
|
+
(0, import_react10.useEffect)(() => {
|
|
976
1183
|
styleVariablesRepository.update({
|
|
977
1184
|
[editId]: {
|
|
978
1185
|
...variable,
|
|
@@ -1035,15 +1242,15 @@ var VariableEdit = ({ onClose, onGoBack, onSubmit, editId }) => {
|
|
|
1035
1242
|
const actions = [];
|
|
1036
1243
|
if (userPermissions.canDelete()) {
|
|
1037
1244
|
actions.push(
|
|
1038
|
-
/* @__PURE__ */
|
|
1039
|
-
|
|
1245
|
+
/* @__PURE__ */ React13.createElement(
|
|
1246
|
+
import_ui13.IconButton,
|
|
1040
1247
|
{
|
|
1041
1248
|
key: "delete",
|
|
1042
1249
|
size: SIZE2,
|
|
1043
|
-
"aria-label": (0,
|
|
1250
|
+
"aria-label": (0, import_i18n10.__)("Delete", "elementor"),
|
|
1044
1251
|
onClick: handleDeleteConfirmation
|
|
1045
1252
|
},
|
|
1046
|
-
/* @__PURE__ */
|
|
1253
|
+
/* @__PURE__ */ React13.createElement(import_icons7.TrashIcon, { fontSize: SIZE2 })
|
|
1047
1254
|
)
|
|
1048
1255
|
);
|
|
1049
1256
|
}
|
|
@@ -1063,23 +1270,23 @@ var VariableEdit = ({ onClose, onGoBack, onSubmit, editId }) => {
|
|
|
1063
1270
|
return !!errorMessage;
|
|
1064
1271
|
};
|
|
1065
1272
|
const isSubmitDisabled = noValueChanged() || hasEmptyFields() || hasErrors();
|
|
1066
|
-
return /* @__PURE__ */
|
|
1067
|
-
|
|
1273
|
+
return /* @__PURE__ */ React13.createElement(React13.Fragment, null, /* @__PURE__ */ React13.createElement(import_editor_editing_panel3.PopoverBody, { height: "auto" }, /* @__PURE__ */ React13.createElement(
|
|
1274
|
+
import_editor_ui4.PopoverHeader,
|
|
1068
1275
|
{
|
|
1069
|
-
title: (0,
|
|
1276
|
+
title: (0, import_i18n10.__)("Edit variable", "elementor"),
|
|
1070
1277
|
onClose,
|
|
1071
|
-
icon: /* @__PURE__ */
|
|
1072
|
-
|
|
1278
|
+
icon: /* @__PURE__ */ React13.createElement(React13.Fragment, null, onGoBack && /* @__PURE__ */ React13.createElement(
|
|
1279
|
+
import_ui13.IconButton,
|
|
1073
1280
|
{
|
|
1074
1281
|
size: SIZE2,
|
|
1075
|
-
"aria-label": (0,
|
|
1282
|
+
"aria-label": (0, import_i18n10.__)("Go Back", "elementor"),
|
|
1076
1283
|
onClick: onGoBack
|
|
1077
1284
|
},
|
|
1078
|
-
/* @__PURE__ */
|
|
1079
|
-
), /* @__PURE__ */
|
|
1285
|
+
/* @__PURE__ */ React13.createElement(import_icons7.ArrowLeftIcon, { fontSize: SIZE2 })
|
|
1286
|
+
), /* @__PURE__ */ React13.createElement(VariableIcon, { fontSize: SIZE2 })),
|
|
1080
1287
|
actions
|
|
1081
1288
|
}
|
|
1082
|
-
), /* @__PURE__ */
|
|
1289
|
+
), /* @__PURE__ */ React13.createElement(import_ui13.Divider, null), /* @__PURE__ */ React13.createElement(import_editor_controls4.PopoverContent, { p: 2 }, /* @__PURE__ */ React13.createElement(
|
|
1083
1290
|
LabelField,
|
|
1084
1291
|
{
|
|
1085
1292
|
value: label,
|
|
@@ -1089,7 +1296,7 @@ var VariableEdit = ({ onClose, onGoBack, onSubmit, editId }) => {
|
|
|
1089
1296
|
setErrorMessage("");
|
|
1090
1297
|
}
|
|
1091
1298
|
}
|
|
1092
|
-
), /* @__PURE__ */
|
|
1299
|
+
), /* @__PURE__ */ React13.createElement(FormField, { errorMsg: valueFieldError, label: (0, import_i18n10.__)("Value", "elementor") }, /* @__PURE__ */ React13.createElement(
|
|
1093
1300
|
ValueField,
|
|
1094
1301
|
{
|
|
1095
1302
|
value,
|
|
@@ -1100,7 +1307,7 @@ var VariableEdit = ({ onClose, onGoBack, onSubmit, editId }) => {
|
|
|
1100
1307
|
},
|
|
1101
1308
|
onValidationChange: setValueFieldError
|
|
1102
1309
|
}
|
|
1103
|
-
)), errorMessage && /* @__PURE__ */
|
|
1310
|
+
)), errorMessage && /* @__PURE__ */ React13.createElement(import_ui13.FormHelperText, { error: true }, errorMessage)), /* @__PURE__ */ React13.createElement(import_ui13.CardActions, { sx: { pt: 0.5, pb: 1 } }, /* @__PURE__ */ React13.createElement(import_ui13.Button, { size: "small", variant: "contained", disabled: isSubmitDisabled, onClick: handleUpdate }, (0, import_i18n10.__)("Save", "elementor")))), deleteConfirmation && /* @__PURE__ */ React13.createElement(
|
|
1104
1311
|
DeleteConfirmationDialog,
|
|
1105
1312
|
{
|
|
1106
1313
|
open: true,
|
|
@@ -1108,7 +1315,7 @@ var VariableEdit = ({ onClose, onGoBack, onSubmit, editId }) => {
|
|
|
1108
1315
|
onConfirm: handleDelete,
|
|
1109
1316
|
closeDialog: closeDeleteDialog()
|
|
1110
1317
|
}
|
|
1111
|
-
), editConfirmation && !isMessageSuppressed && /* @__PURE__ */
|
|
1318
|
+
), editConfirmation && !isMessageSuppressed && /* @__PURE__ */ React13.createElement(
|
|
1112
1319
|
EditConfirmationDialog,
|
|
1113
1320
|
{
|
|
1114
1321
|
closeDialog: closeEditDialog(),
|
|
@@ -1119,26 +1326,26 @@ var VariableEdit = ({ onClose, onGoBack, onSubmit, editId }) => {
|
|
|
1119
1326
|
};
|
|
1120
1327
|
|
|
1121
1328
|
// src/components/variables-selection.tsx
|
|
1122
|
-
var
|
|
1123
|
-
var
|
|
1329
|
+
var React17 = __toESM(require("react"));
|
|
1330
|
+
var import_react11 = require("react");
|
|
1124
1331
|
var import_editor_controls5 = require("@elementor/editor-controls");
|
|
1125
1332
|
var import_editor_editing_panel4 = require("@elementor/editor-editing-panel");
|
|
1126
|
-
var
|
|
1127
|
-
var
|
|
1128
|
-
var
|
|
1129
|
-
var
|
|
1333
|
+
var import_editor_ui6 = require("@elementor/editor-ui");
|
|
1334
|
+
var import_icons9 = require("@elementor/icons");
|
|
1335
|
+
var import_ui18 = require("@elementor/ui");
|
|
1336
|
+
var import_i18n14 = require("@wordpress/i18n");
|
|
1130
1337
|
|
|
1131
1338
|
// src/components/ui/menu-item-content.tsx
|
|
1132
|
-
var
|
|
1133
|
-
var
|
|
1134
|
-
var
|
|
1135
|
-
var
|
|
1136
|
-
var
|
|
1339
|
+
var React14 = __toESM(require("react"));
|
|
1340
|
+
var import_editor_ui5 = require("@elementor/editor-ui");
|
|
1341
|
+
var import_icons8 = require("@elementor/icons");
|
|
1342
|
+
var import_ui14 = require("@elementor/ui");
|
|
1343
|
+
var import_i18n11 = require("@wordpress/i18n");
|
|
1137
1344
|
var SIZE3 = "tiny";
|
|
1138
1345
|
var MenuItemContent = ({ item }) => {
|
|
1139
1346
|
const onEdit = item.onEdit;
|
|
1140
|
-
return /* @__PURE__ */
|
|
1141
|
-
|
|
1347
|
+
return /* @__PURE__ */ React14.createElement(React14.Fragment, null, /* @__PURE__ */ React14.createElement(import_ui14.ListItemIcon, null, item.icon), /* @__PURE__ */ React14.createElement(
|
|
1348
|
+
import_ui14.Box,
|
|
1142
1349
|
{
|
|
1143
1350
|
sx: {
|
|
1144
1351
|
flex: 1,
|
|
@@ -1148,49 +1355,49 @@ var MenuItemContent = ({ item }) => {
|
|
|
1148
1355
|
gap: 1
|
|
1149
1356
|
}
|
|
1150
1357
|
},
|
|
1151
|
-
/* @__PURE__ */
|
|
1152
|
-
|
|
1358
|
+
/* @__PURE__ */ React14.createElement(
|
|
1359
|
+
import_editor_ui5.EllipsisWithTooltip,
|
|
1153
1360
|
{
|
|
1154
1361
|
title: item.label || item.value,
|
|
1155
|
-
as:
|
|
1362
|
+
as: import_ui14.Typography,
|
|
1156
1363
|
variant: "caption",
|
|
1157
1364
|
color: "text.primary",
|
|
1158
1365
|
sx: { marginTop: "1px", lineHeight: "2" },
|
|
1159
1366
|
maxWidth: "50%"
|
|
1160
1367
|
}
|
|
1161
1368
|
),
|
|
1162
|
-
item.secondaryText && /* @__PURE__ */
|
|
1163
|
-
|
|
1369
|
+
item.secondaryText && /* @__PURE__ */ React14.createElement(
|
|
1370
|
+
import_editor_ui5.EllipsisWithTooltip,
|
|
1164
1371
|
{
|
|
1165
1372
|
title: item.secondaryText,
|
|
1166
|
-
as:
|
|
1373
|
+
as: import_ui14.Typography,
|
|
1167
1374
|
variant: "caption",
|
|
1168
1375
|
color: "text.tertiary",
|
|
1169
1376
|
sx: { marginTop: "1px", lineHeight: "1" },
|
|
1170
1377
|
maxWidth: "50%"
|
|
1171
1378
|
}
|
|
1172
1379
|
)
|
|
1173
|
-
), !!onEdit && /* @__PURE__ */
|
|
1174
|
-
|
|
1380
|
+
), !!onEdit && /* @__PURE__ */ React14.createElement(
|
|
1381
|
+
import_ui14.IconButton,
|
|
1175
1382
|
{
|
|
1176
1383
|
sx: { mx: 1, opacity: "0" },
|
|
1177
1384
|
onClick: (e) => {
|
|
1178
1385
|
e.stopPropagation();
|
|
1179
1386
|
onEdit(item.value);
|
|
1180
1387
|
},
|
|
1181
|
-
"aria-label": (0,
|
|
1388
|
+
"aria-label": (0, import_i18n11.__)("Edit", "elementor")
|
|
1182
1389
|
},
|
|
1183
|
-
/* @__PURE__ */
|
|
1390
|
+
/* @__PURE__ */ React14.createElement(import_icons8.EditIcon, { color: "action", fontSize: SIZE3 })
|
|
1184
1391
|
));
|
|
1185
1392
|
};
|
|
1186
1393
|
|
|
1187
1394
|
// src/components/ui/no-search-results.tsx
|
|
1188
|
-
var
|
|
1189
|
-
var
|
|
1190
|
-
var
|
|
1395
|
+
var React15 = __toESM(require("react"));
|
|
1396
|
+
var import_ui15 = require("@elementor/ui");
|
|
1397
|
+
var import_i18n12 = require("@wordpress/i18n");
|
|
1191
1398
|
var NoSearchResults = ({ searchValue, onClear, icon }) => {
|
|
1192
|
-
return /* @__PURE__ */
|
|
1193
|
-
|
|
1399
|
+
return /* @__PURE__ */ React15.createElement(
|
|
1400
|
+
import_ui15.Stack,
|
|
1194
1401
|
{
|
|
1195
1402
|
gap: 1,
|
|
1196
1403
|
alignItems: "center",
|
|
@@ -1201,19 +1408,19 @@ var NoSearchResults = ({ searchValue, onClear, icon }) => {
|
|
|
1201
1408
|
sx: { pb: 3.5 }
|
|
1202
1409
|
},
|
|
1203
1410
|
icon,
|
|
1204
|
-
/* @__PURE__ */
|
|
1205
|
-
/* @__PURE__ */
|
|
1411
|
+
/* @__PURE__ */ React15.createElement(import_ui15.Typography, { align: "center", variant: "subtitle2" }, (0, import_i18n12.__)("Sorry, nothing matched", "elementor"), /* @__PURE__ */ React15.createElement("br", null), "\u201C", searchValue, "\u201D."),
|
|
1412
|
+
/* @__PURE__ */ React15.createElement(import_ui15.Typography, { align: "center", variant: "caption", sx: { display: "flex", flexDirection: "column" } }, (0, import_i18n12.__)("Try something else.", "elementor"), /* @__PURE__ */ React15.createElement(import_ui15.Link, { color: "text.secondary", variant: "caption", component: "button", onClick: onClear }, (0, import_i18n12.__)("Clear & try again", "elementor")))
|
|
1206
1413
|
);
|
|
1207
1414
|
};
|
|
1208
1415
|
|
|
1209
1416
|
// src/components/ui/no-variables.tsx
|
|
1210
|
-
var
|
|
1211
|
-
var
|
|
1212
|
-
var
|
|
1417
|
+
var React16 = __toESM(require("react"));
|
|
1418
|
+
var import_ui16 = require("@elementor/ui");
|
|
1419
|
+
var import_i18n13 = require("@wordpress/i18n");
|
|
1213
1420
|
var NoVariables = ({ icon, title, onAdd }) => {
|
|
1214
1421
|
const canAdd = usePermissions().canAdd();
|
|
1215
|
-
return /* @__PURE__ */
|
|
1216
|
-
|
|
1422
|
+
return /* @__PURE__ */ React16.createElement(
|
|
1423
|
+
import_ui16.Stack,
|
|
1217
1424
|
{
|
|
1218
1425
|
gap: 1,
|
|
1219
1426
|
alignItems: "center",
|
|
@@ -1223,31 +1430,31 @@ var NoVariables = ({ icon, title, onAdd }) => {
|
|
|
1223
1430
|
sx: { p: 2.5, pb: 5.5 }
|
|
1224
1431
|
},
|
|
1225
1432
|
icon,
|
|
1226
|
-
canAdd ? /* @__PURE__ */
|
|
1433
|
+
canAdd ? /* @__PURE__ */ React16.createElement(React16.Fragment, null, /* @__PURE__ */ React16.createElement(
|
|
1227
1434
|
NoVariablesContent,
|
|
1228
1435
|
{
|
|
1229
|
-
title: title || (0,
|
|
1230
|
-
message: (0,
|
|
1436
|
+
title: title || (0, import_i18n13.__)("Create your first variable", "elementor"),
|
|
1437
|
+
message: (0, import_i18n13.__)(
|
|
1231
1438
|
"Variables are saved attributes that you can apply anywhere on your site.",
|
|
1232
1439
|
"elementor"
|
|
1233
1440
|
)
|
|
1234
1441
|
}
|
|
1235
|
-
), onAdd && /* @__PURE__ */
|
|
1442
|
+
), onAdd && /* @__PURE__ */ React16.createElement(import_ui16.Button, { variant: "outlined", color: "secondary", size: "small", onClick: onAdd }, (0, import_i18n13.__)("Create a variable", "elementor"))) : /* @__PURE__ */ React16.createElement(
|
|
1236
1443
|
NoVariablesContent,
|
|
1237
1444
|
{
|
|
1238
|
-
title: (0,
|
|
1239
|
-
message: (0,
|
|
1445
|
+
title: (0, import_i18n13.__)("There are no variables", "elementor"),
|
|
1446
|
+
message: (0, import_i18n13.__)("With your current role, you can only connect and detach variables.", "elementor")
|
|
1240
1447
|
}
|
|
1241
1448
|
)
|
|
1242
1449
|
);
|
|
1243
1450
|
};
|
|
1244
1451
|
function NoVariablesContent({ title, message }) {
|
|
1245
|
-
return /* @__PURE__ */
|
|
1452
|
+
return /* @__PURE__ */ React16.createElement(React16.Fragment, null, /* @__PURE__ */ React16.createElement(import_ui16.Typography, { align: "center", variant: "subtitle2" }, title), /* @__PURE__ */ React16.createElement(import_ui16.Typography, { align: "center", variant: "caption", maxWidth: "180px" }, message));
|
|
1246
1453
|
}
|
|
1247
1454
|
|
|
1248
1455
|
// src/components/ui/styled-menu-list.tsx
|
|
1249
|
-
var
|
|
1250
|
-
var VariablesStyledMenuList = (0,
|
|
1456
|
+
var import_ui17 = require("@elementor/ui");
|
|
1457
|
+
var VariablesStyledMenuList = (0, import_ui17.styled)(import_ui17.MenuList)(({ theme }) => ({
|
|
1251
1458
|
"& > li": {
|
|
1252
1459
|
height: 32,
|
|
1253
1460
|
width: "100%",
|
|
@@ -1282,7 +1489,7 @@ var SIZE4 = "tiny";
|
|
|
1282
1489
|
var VariablesSelection = ({ closePopover, onAdd, onEdit, onSettings }) => {
|
|
1283
1490
|
const { icon: VariableIcon, startIcon, variableType, propTypeUtil } = useVariableType();
|
|
1284
1491
|
const { value: variable, setValue: setVariable, path } = (0, import_editor_controls5.useBoundProp)(propTypeUtil);
|
|
1285
|
-
const [searchValue, setSearchValue] = (0,
|
|
1492
|
+
const [searchValue, setSearchValue] = (0, import_react11.useState)("");
|
|
1286
1493
|
const {
|
|
1287
1494
|
list: variables,
|
|
1288
1495
|
hasMatches: hasSearchResults,
|
|
@@ -1308,20 +1515,20 @@ var VariablesSelection = ({ closePopover, onAdd, onEdit, onSettings }) => {
|
|
|
1308
1515
|
const actions = [];
|
|
1309
1516
|
if (onAdd) {
|
|
1310
1517
|
actions.push(
|
|
1311
|
-
/* @__PURE__ */
|
|
1518
|
+
/* @__PURE__ */ React17.createElement(import_ui18.IconButton, { key: "add", size: SIZE4, onClick: onAddAndTrack }, /* @__PURE__ */ React17.createElement(import_icons9.PlusIcon, { fontSize: SIZE4 }))
|
|
1312
1519
|
);
|
|
1313
1520
|
}
|
|
1314
1521
|
if (onSettings) {
|
|
1315
1522
|
actions.push(
|
|
1316
|
-
/* @__PURE__ */
|
|
1523
|
+
/* @__PURE__ */ React17.createElement(import_ui18.IconButton, { key: "settings", size: SIZE4, onClick: onSettings }, /* @__PURE__ */ React17.createElement(import_icons9.SettingsIcon, { fontSize: SIZE4 }))
|
|
1317
1524
|
);
|
|
1318
1525
|
}
|
|
1319
|
-
const StartIcon = startIcon || (() => /* @__PURE__ */
|
|
1526
|
+
const StartIcon = startIcon || (() => /* @__PURE__ */ React17.createElement(VariableIcon, { fontSize: SIZE4 }));
|
|
1320
1527
|
const items = variables.map(({ value, label, key }) => ({
|
|
1321
1528
|
type: "item",
|
|
1322
1529
|
value: key,
|
|
1323
1530
|
label,
|
|
1324
|
-
icon: /* @__PURE__ */
|
|
1531
|
+
icon: /* @__PURE__ */ React17.createElement(StartIcon, { value }),
|
|
1325
1532
|
secondaryText: value,
|
|
1326
1533
|
onEdit: onEdit ? () => onEdit?.(key) : void 0
|
|
1327
1534
|
}));
|
|
@@ -1331,28 +1538,28 @@ var VariablesSelection = ({ closePopover, onAdd, onEdit, onSettings }) => {
|
|
|
1331
1538
|
const handleClearSearch = () => {
|
|
1332
1539
|
setSearchValue("");
|
|
1333
1540
|
};
|
|
1334
|
-
const noVariableTitle = (0,
|
|
1541
|
+
const noVariableTitle = (0, import_i18n14.sprintf)(
|
|
1335
1542
|
/* translators: %s: Variable Type. */
|
|
1336
|
-
(0,
|
|
1543
|
+
(0, import_i18n14.__)("Create your first %s variable", "elementor"),
|
|
1337
1544
|
variableType
|
|
1338
1545
|
);
|
|
1339
|
-
return /* @__PURE__ */
|
|
1340
|
-
|
|
1546
|
+
return /* @__PURE__ */ React17.createElement(import_editor_editing_panel4.PopoverBody, null, /* @__PURE__ */ React17.createElement(
|
|
1547
|
+
import_editor_ui6.PopoverHeader,
|
|
1341
1548
|
{
|
|
1342
|
-
title: (0,
|
|
1343
|
-
icon: /* @__PURE__ */
|
|
1549
|
+
title: (0, import_i18n14.__)("Variables", "elementor"),
|
|
1550
|
+
icon: /* @__PURE__ */ React17.createElement(import_icons9.ColorFilterIcon, { fontSize: SIZE4 }),
|
|
1344
1551
|
onClose: closePopover,
|
|
1345
1552
|
actions
|
|
1346
1553
|
}
|
|
1347
|
-
), hasVariables && /* @__PURE__ */
|
|
1348
|
-
|
|
1554
|
+
), hasVariables && /* @__PURE__ */ React17.createElement(
|
|
1555
|
+
import_editor_ui6.PopoverSearch,
|
|
1349
1556
|
{
|
|
1350
1557
|
value: searchValue,
|
|
1351
1558
|
onSearch: handleSearch,
|
|
1352
|
-
placeholder: (0,
|
|
1559
|
+
placeholder: (0, import_i18n14.__)("Search", "elementor")
|
|
1353
1560
|
}
|
|
1354
|
-
), /* @__PURE__ */
|
|
1355
|
-
|
|
1561
|
+
), /* @__PURE__ */ React17.createElement(import_ui18.Divider, null), hasVariables && hasSearchResults && /* @__PURE__ */ React17.createElement(
|
|
1562
|
+
import_editor_ui6.PopoverMenuList,
|
|
1356
1563
|
{
|
|
1357
1564
|
items,
|
|
1358
1565
|
onSelect: handleSetVariable,
|
|
@@ -1361,16 +1568,16 @@ var VariablesSelection = ({ closePopover, onAdd, onEdit, onSettings }) => {
|
|
|
1361
1568
|
selectedValue: variable,
|
|
1362
1569
|
"data-testid": `${variableType}-variables-list`,
|
|
1363
1570
|
menuListTemplate: VariablesStyledMenuList,
|
|
1364
|
-
menuItemContentTemplate: (item) => /* @__PURE__ */
|
|
1571
|
+
menuItemContentTemplate: (item) => /* @__PURE__ */ React17.createElement(MenuItemContent, { item })
|
|
1365
1572
|
}
|
|
1366
|
-
), !hasSearchResults && hasVariables && /* @__PURE__ */
|
|
1573
|
+
), !hasSearchResults && hasVariables && /* @__PURE__ */ React17.createElement(
|
|
1367
1574
|
NoSearchResults,
|
|
1368
1575
|
{
|
|
1369
1576
|
searchValue,
|
|
1370
1577
|
onClear: handleClearSearch,
|
|
1371
|
-
icon: /* @__PURE__ */
|
|
1578
|
+
icon: /* @__PURE__ */ React17.createElement(VariableIcon, { fontSize: "large" })
|
|
1372
1579
|
}
|
|
1373
|
-
), !hasVariables && /* @__PURE__ */
|
|
1580
|
+
), !hasVariables && /* @__PURE__ */ React17.createElement(NoVariables, { title: noVariableTitle, icon: /* @__PURE__ */ React17.createElement(VariableIcon, { fontSize: "large" }), onAdd }));
|
|
1374
1581
|
};
|
|
1375
1582
|
|
|
1376
1583
|
// src/components/variable-selection-popover.tsx
|
|
@@ -1378,13 +1585,13 @@ var VIEW_LIST = "list";
|
|
|
1378
1585
|
var VIEW_ADD = "add";
|
|
1379
1586
|
var VIEW_EDIT = "edit";
|
|
1380
1587
|
var VariableSelectionPopover = ({ closePopover, propTypeKey, selectedVariable }) => {
|
|
1381
|
-
const [currentView, setCurrentView] = (0,
|
|
1382
|
-
const [editId, setEditId] = (0,
|
|
1588
|
+
const [currentView, setCurrentView] = (0, import_react12.useState)(VIEW_LIST);
|
|
1589
|
+
const [editId, setEditId] = (0, import_react12.useState)("");
|
|
1383
1590
|
const { open } = usePanelActions();
|
|
1384
|
-
const onSettingsAvailable = (0, import_editor_v1_adapters2.isExperimentActive)("
|
|
1591
|
+
const onSettingsAvailable = (0, import_editor_v1_adapters2.isExperimentActive)("e_variables_manager") ? () => {
|
|
1385
1592
|
open();
|
|
1386
1593
|
} : void 0;
|
|
1387
|
-
return /* @__PURE__ */
|
|
1594
|
+
return /* @__PURE__ */ React18.createElement(VariableTypeProvider, { propTypeKey }, /* @__PURE__ */ React18.createElement(PopoverContentRefContextProvider, null, RenderView({
|
|
1388
1595
|
propTypeKey,
|
|
1389
1596
|
currentView,
|
|
1390
1597
|
selectedVariable,
|
|
@@ -1418,8 +1625,8 @@ function RenderView(props) {
|
|
|
1418
1625
|
}
|
|
1419
1626
|
if (userPermissions.canManageSettings() && props.onSettings) {
|
|
1420
1627
|
handlers.onSettings = () => {
|
|
1421
|
-
props.onSettings?.();
|
|
1422
1628
|
props.closePopover();
|
|
1629
|
+
props.onSettings?.();
|
|
1423
1630
|
};
|
|
1424
1631
|
}
|
|
1425
1632
|
const handleSubmitOnEdit = () => {
|
|
@@ -1430,7 +1637,7 @@ function RenderView(props) {
|
|
|
1430
1637
|
}
|
|
1431
1638
|
};
|
|
1432
1639
|
if (VIEW_LIST === props.currentView) {
|
|
1433
|
-
return /* @__PURE__ */
|
|
1640
|
+
return /* @__PURE__ */ React18.createElement(
|
|
1434
1641
|
VariablesSelection,
|
|
1435
1642
|
{
|
|
1436
1643
|
closePopover: handlers.onClose,
|
|
@@ -1441,10 +1648,10 @@ function RenderView(props) {
|
|
|
1441
1648
|
);
|
|
1442
1649
|
}
|
|
1443
1650
|
if (VIEW_ADD === props.currentView) {
|
|
1444
|
-
return /* @__PURE__ */
|
|
1651
|
+
return /* @__PURE__ */ React18.createElement(VariableCreation, { onGoBack: handlers.onGoBack, onClose: handlers.onClose });
|
|
1445
1652
|
}
|
|
1446
1653
|
if (VIEW_EDIT === props.currentView) {
|
|
1447
|
-
return /* @__PURE__ */
|
|
1654
|
+
return /* @__PURE__ */ React18.createElement(
|
|
1448
1655
|
VariableEdit,
|
|
1449
1656
|
{
|
|
1450
1657
|
editId: props.editId,
|
|
@@ -1458,25 +1665,25 @@ function RenderView(props) {
|
|
|
1458
1665
|
}
|
|
1459
1666
|
|
|
1460
1667
|
// src/components/ui/tags/assigned-tag.tsx
|
|
1461
|
-
var
|
|
1462
|
-
var
|
|
1463
|
-
var
|
|
1464
|
-
var
|
|
1668
|
+
var React19 = __toESM(require("react"));
|
|
1669
|
+
var import_icons10 = require("@elementor/icons");
|
|
1670
|
+
var import_ui19 = require("@elementor/ui");
|
|
1671
|
+
var import_i18n15 = require("@wordpress/i18n");
|
|
1465
1672
|
var SIZE5 = "tiny";
|
|
1466
1673
|
var AssignedTag = ({ startIcon, label, onUnlink, ...props }) => {
|
|
1467
1674
|
const actions = [];
|
|
1468
1675
|
if (onUnlink) {
|
|
1469
1676
|
actions.push(
|
|
1470
|
-
/* @__PURE__ */
|
|
1677
|
+
/* @__PURE__ */ React19.createElement(import_ui19.IconButton, { key: "unlink", size: SIZE5, onClick: onUnlink, "aria-label": (0, import_i18n15.__)("Unlink", "elementor") }, /* @__PURE__ */ React19.createElement(import_icons10.DetachIcon, { fontSize: SIZE5 }))
|
|
1471
1678
|
);
|
|
1472
1679
|
}
|
|
1473
|
-
return /* @__PURE__ */
|
|
1474
|
-
|
|
1680
|
+
return /* @__PURE__ */ React19.createElement(import_ui19.Tooltip, { title: label, placement: "top" }, /* @__PURE__ */ React19.createElement(
|
|
1681
|
+
import_ui19.UnstableTag,
|
|
1475
1682
|
{
|
|
1476
1683
|
fullWidth: true,
|
|
1477
1684
|
showActionsOnHover: true,
|
|
1478
|
-
startIcon: /* @__PURE__ */
|
|
1479
|
-
label: /* @__PURE__ */
|
|
1685
|
+
startIcon: /* @__PURE__ */ React19.createElement(import_ui19.Stack, { gap: 0.5, direction: "row", alignItems: "center" }, startIcon),
|
|
1686
|
+
label: /* @__PURE__ */ React19.createElement(import_ui19.Box, { sx: { display: "inline-grid", minWidth: 0 } }, /* @__PURE__ */ React19.createElement(import_ui19.Typography, { sx: { lineHeight: 1.34 }, variant: "caption", noWrap: true }, label)),
|
|
1480
1687
|
actions,
|
|
1481
1688
|
...props
|
|
1482
1689
|
}
|
|
@@ -1487,24 +1694,24 @@ var AssignedTag = ({ startIcon, label, onUnlink, ...props }) => {
|
|
|
1487
1694
|
var AssignedVariable = ({ variable, propTypeKey }) => {
|
|
1488
1695
|
const { startIcon, propTypeUtil } = getVariableType(propTypeKey);
|
|
1489
1696
|
const { setValue } = (0, import_editor_controls6.useBoundProp)();
|
|
1490
|
-
const anchorRef = (0,
|
|
1491
|
-
const popupId = (0,
|
|
1492
|
-
const popupState = (0,
|
|
1697
|
+
const anchorRef = (0, import_react13.useRef)(null);
|
|
1698
|
+
const popupId = (0, import_react13.useId)();
|
|
1699
|
+
const popupState = (0, import_ui20.usePopupState)({
|
|
1493
1700
|
variant: "popover",
|
|
1494
1701
|
popupId: `elementor-variables-list-${popupId}`
|
|
1495
1702
|
});
|
|
1496
1703
|
const unlinkVariable = createUnlinkHandler(variable, propTypeKey, setValue);
|
|
1497
1704
|
const StartIcon = startIcon || (() => null);
|
|
1498
|
-
return /* @__PURE__ */
|
|
1705
|
+
return /* @__PURE__ */ React20.createElement(import_ui20.Box, { ref: anchorRef }, /* @__PURE__ */ React20.createElement(
|
|
1499
1706
|
AssignedTag,
|
|
1500
1707
|
{
|
|
1501
1708
|
label: variable.label,
|
|
1502
|
-
startIcon: /* @__PURE__ */
|
|
1709
|
+
startIcon: /* @__PURE__ */ React20.createElement(React20.Fragment, null, /* @__PURE__ */ React20.createElement(import_icons11.ColorFilterIcon, { fontSize: SIZE5 }), /* @__PURE__ */ React20.createElement(StartIcon, { value: variable.value })),
|
|
1503
1710
|
onUnlink: unlinkVariable,
|
|
1504
|
-
...(0,
|
|
1711
|
+
...(0, import_ui20.bindTrigger)(popupState)
|
|
1505
1712
|
}
|
|
1506
|
-
), /* @__PURE__ */
|
|
1507
|
-
|
|
1713
|
+
), /* @__PURE__ */ React20.createElement(
|
|
1714
|
+
import_ui20.Popover,
|
|
1508
1715
|
{
|
|
1509
1716
|
disableScrollLock: true,
|
|
1510
1717
|
anchorEl: anchorRef.current,
|
|
@@ -1513,9 +1720,9 @@ var AssignedVariable = ({ variable, propTypeKey }) => {
|
|
|
1513
1720
|
PaperProps: {
|
|
1514
1721
|
sx: { my: 1 }
|
|
1515
1722
|
},
|
|
1516
|
-
...(0,
|
|
1723
|
+
...(0, import_ui20.bindPopover)(popupState)
|
|
1517
1724
|
},
|
|
1518
|
-
/* @__PURE__ */
|
|
1725
|
+
/* @__PURE__ */ React20.createElement(
|
|
1519
1726
|
VariableSelectionPopover,
|
|
1520
1727
|
{
|
|
1521
1728
|
selectedVariable: variable,
|
|
@@ -1527,19 +1734,19 @@ var AssignedVariable = ({ variable, propTypeKey }) => {
|
|
|
1527
1734
|
};
|
|
1528
1735
|
|
|
1529
1736
|
// src/components/ui/variable/deleted-variable.tsx
|
|
1530
|
-
var
|
|
1531
|
-
var
|
|
1737
|
+
var React24 = __toESM(require("react"));
|
|
1738
|
+
var import_react15 = require("react");
|
|
1532
1739
|
var import_editor_controls8 = require("@elementor/editor-controls");
|
|
1533
|
-
var
|
|
1740
|
+
var import_ui24 = require("@elementor/ui");
|
|
1534
1741
|
|
|
1535
1742
|
// src/components/variable-restore.tsx
|
|
1536
|
-
var
|
|
1537
|
-
var
|
|
1743
|
+
var React21 = __toESM(require("react"));
|
|
1744
|
+
var import_react14 = require("react");
|
|
1538
1745
|
var import_editor_controls7 = require("@elementor/editor-controls");
|
|
1539
1746
|
var import_editor_editing_panel5 = require("@elementor/editor-editing-panel");
|
|
1540
|
-
var
|
|
1541
|
-
var
|
|
1542
|
-
var
|
|
1747
|
+
var import_editor_ui7 = require("@elementor/editor-ui");
|
|
1748
|
+
var import_ui21 = require("@elementor/ui");
|
|
1749
|
+
var import_i18n16 = require("@wordpress/i18n");
|
|
1543
1750
|
var SIZE6 = "tiny";
|
|
1544
1751
|
var VariableRestore = ({ variableId, onClose, onSubmit }) => {
|
|
1545
1752
|
const { icon: VariableIcon, valueField: ValueField, variableType, propTypeUtil } = useVariableType();
|
|
@@ -1548,10 +1755,10 @@ var VariableRestore = ({ variableId, onClose, onSubmit }) => {
|
|
|
1548
1755
|
if (!variable) {
|
|
1549
1756
|
throw new Error(`Global ${variableType} variable not found`);
|
|
1550
1757
|
}
|
|
1551
|
-
const [errorMessage, setErrorMessage] = (0,
|
|
1552
|
-
const [valueFieldError, setValueFieldError] = (0,
|
|
1553
|
-
const [label, setLabel] = (0,
|
|
1554
|
-
const [value, setValue] = (0,
|
|
1758
|
+
const [errorMessage, setErrorMessage] = (0, import_react14.useState)("");
|
|
1759
|
+
const [valueFieldError, setValueFieldError] = (0, import_react14.useState)("");
|
|
1760
|
+
const [label, setLabel] = (0, import_react14.useState)(variable.label);
|
|
1761
|
+
const [value, setValue] = (0, import_react14.useState)(variable.value);
|
|
1555
1762
|
const { labelFieldError, setLabelFieldError } = useLabelError({
|
|
1556
1763
|
value: variable.label,
|
|
1557
1764
|
message: ERROR_MESSAGES.DUPLICATED_LABEL
|
|
@@ -1589,14 +1796,14 @@ var VariableRestore = ({ variableId, onClose, onSubmit }) => {
|
|
|
1589
1796
|
return !!errorMessage;
|
|
1590
1797
|
};
|
|
1591
1798
|
const isSubmitDisabled = noValueChanged() || hasEmptyFields() || hasErrors();
|
|
1592
|
-
return /* @__PURE__ */
|
|
1593
|
-
|
|
1799
|
+
return /* @__PURE__ */ React21.createElement(PopoverContentRefContextProvider, null, /* @__PURE__ */ React21.createElement(import_editor_editing_panel5.PopoverBody, { height: "auto" }, /* @__PURE__ */ React21.createElement(
|
|
1800
|
+
import_editor_ui7.PopoverHeader,
|
|
1594
1801
|
{
|
|
1595
|
-
icon: /* @__PURE__ */
|
|
1596
|
-
title: (0,
|
|
1802
|
+
icon: /* @__PURE__ */ React21.createElement(VariableIcon, { fontSize: SIZE6 }),
|
|
1803
|
+
title: (0, import_i18n16.__)("Restore variable", "elementor"),
|
|
1597
1804
|
onClose
|
|
1598
1805
|
}
|
|
1599
|
-
), /* @__PURE__ */
|
|
1806
|
+
), /* @__PURE__ */ React21.createElement(import_ui21.Divider, null), /* @__PURE__ */ React21.createElement(import_editor_controls7.PopoverContent, { p: 2 }, /* @__PURE__ */ React21.createElement(
|
|
1600
1807
|
LabelField,
|
|
1601
1808
|
{
|
|
1602
1809
|
value: label,
|
|
@@ -1606,7 +1813,7 @@ var VariableRestore = ({ variableId, onClose, onSubmit }) => {
|
|
|
1606
1813
|
setErrorMessage("");
|
|
1607
1814
|
}
|
|
1608
1815
|
}
|
|
1609
|
-
), /* @__PURE__ */
|
|
1816
|
+
), /* @__PURE__ */ React21.createElement(FormField, { errorMsg: valueFieldError, label: (0, import_i18n16.__)("Value", "elementor") }, /* @__PURE__ */ React21.createElement(
|
|
1610
1817
|
ValueField,
|
|
1611
1818
|
{
|
|
1612
1819
|
value,
|
|
@@ -1617,32 +1824,32 @@ var VariableRestore = ({ variableId, onClose, onSubmit }) => {
|
|
|
1617
1824
|
},
|
|
1618
1825
|
onValidationChange: setValueFieldError
|
|
1619
1826
|
}
|
|
1620
|
-
)), errorMessage && /* @__PURE__ */
|
|
1827
|
+
)), errorMessage && /* @__PURE__ */ React21.createElement(import_ui21.FormHelperText, { error: true }, errorMessage)), /* @__PURE__ */ React21.createElement(import_ui21.CardActions, { sx: { pt: 0.5, pb: 1 } }, /* @__PURE__ */ React21.createElement(import_ui21.Button, { size: "small", variant: "contained", disabled: isSubmitDisabled, onClick: handleRestore }, (0, import_i18n16.__)("Restore", "elementor")))));
|
|
1621
1828
|
};
|
|
1622
1829
|
|
|
1623
1830
|
// src/components/ui/deleted-variable-alert.tsx
|
|
1624
|
-
var
|
|
1831
|
+
var React22 = __toESM(require("react"));
|
|
1625
1832
|
var import_editor_editing_panel6 = require("@elementor/editor-editing-panel");
|
|
1626
|
-
var
|
|
1627
|
-
var
|
|
1833
|
+
var import_ui22 = require("@elementor/ui");
|
|
1834
|
+
var import_i18n17 = require("@wordpress/i18n");
|
|
1628
1835
|
var DeletedVariableAlert = ({ onClose, onUnlink, onRestore, label }) => {
|
|
1629
1836
|
const sectionWidth = (0, import_editor_editing_panel6.useSectionWidth)();
|
|
1630
|
-
return /* @__PURE__ */
|
|
1631
|
-
|
|
1837
|
+
return /* @__PURE__ */ React22.createElement(import_ui22.ClickAwayListener, { onClickAway: onClose }, /* @__PURE__ */ React22.createElement(
|
|
1838
|
+
import_ui22.Alert,
|
|
1632
1839
|
{
|
|
1633
1840
|
variant: "standard",
|
|
1634
1841
|
severity: "warning",
|
|
1635
1842
|
onClose,
|
|
1636
|
-
action: /* @__PURE__ */
|
|
1843
|
+
action: /* @__PURE__ */ React22.createElement(React22.Fragment, null, onUnlink && /* @__PURE__ */ React22.createElement(import_ui22.AlertAction, { variant: "contained", onClick: onUnlink }, (0, import_i18n17.__)("Unlink", "elementor")), onRestore && /* @__PURE__ */ React22.createElement(import_ui22.AlertAction, { variant: "outlined", onClick: onRestore }, (0, import_i18n17.__)("Restore", "elementor"))),
|
|
1637
1844
|
sx: { width: sectionWidth }
|
|
1638
1845
|
},
|
|
1639
|
-
/* @__PURE__ */
|
|
1640
|
-
(0,
|
|
1846
|
+
/* @__PURE__ */ React22.createElement(import_ui22.AlertTitle, null, (0, import_i18n17.__)("Deleted variable", "elementor")),
|
|
1847
|
+
(0, import_i18n17.__)("The variable", "elementor"),
|
|
1641
1848
|
" '",
|
|
1642
1849
|
label,
|
|
1643
1850
|
"'",
|
|
1644
1851
|
" ",
|
|
1645
|
-
(0,
|
|
1852
|
+
(0, import_i18n17.__)(
|
|
1646
1853
|
"has been deleted, but it is still referenced in this location. You may restore the variable or unlink it to assign a different value.",
|
|
1647
1854
|
"elementor"
|
|
1648
1855
|
)
|
|
@@ -1650,13 +1857,13 @@ var DeletedVariableAlert = ({ onClose, onUnlink, onRestore, label }) => {
|
|
|
1650
1857
|
};
|
|
1651
1858
|
|
|
1652
1859
|
// src/components/ui/tags/deleted-tag.tsx
|
|
1653
|
-
var
|
|
1654
|
-
var
|
|
1655
|
-
var
|
|
1656
|
-
var
|
|
1657
|
-
var DeletedTag =
|
|
1658
|
-
return /* @__PURE__ */
|
|
1659
|
-
|
|
1860
|
+
var React23 = __toESM(require("react"));
|
|
1861
|
+
var import_icons12 = require("@elementor/icons");
|
|
1862
|
+
var import_ui23 = require("@elementor/ui");
|
|
1863
|
+
var import_i18n18 = require("@wordpress/i18n");
|
|
1864
|
+
var DeletedTag = React23.forwardRef(({ label, onClick, ...props }, ref) => {
|
|
1865
|
+
return /* @__PURE__ */ React23.createElement(
|
|
1866
|
+
import_ui23.Chip,
|
|
1660
1867
|
{
|
|
1661
1868
|
ref,
|
|
1662
1869
|
size: "tiny",
|
|
@@ -1664,8 +1871,8 @@ var DeletedTag = React20.forwardRef(({ label, onClick, ...props }, ref) => {
|
|
|
1664
1871
|
shape: "rounded",
|
|
1665
1872
|
variant: "standard",
|
|
1666
1873
|
onClick,
|
|
1667
|
-
icon: /* @__PURE__ */
|
|
1668
|
-
label: /* @__PURE__ */
|
|
1874
|
+
icon: /* @__PURE__ */ React23.createElement(import_icons12.AlertTriangleFilledIcon, null),
|
|
1875
|
+
label: /* @__PURE__ */ React23.createElement(import_ui23.Tooltip, { title: label, placement: "top" }, /* @__PURE__ */ React23.createElement(import_ui23.Box, { sx: { display: "flex", gap: 0.5, alignItems: "center" } }, /* @__PURE__ */ React23.createElement(import_ui23.Typography, { variant: "caption", noWrap: true }, label), /* @__PURE__ */ React23.createElement(import_ui23.Typography, { variant: "caption", noWrap: true, sx: { textOverflow: "initial", overflow: "visible" } }, "(", (0, import_i18n18.__)("deleted", "elementor"), ")"))),
|
|
1669
1876
|
sx: {
|
|
1670
1877
|
height: (theme) => theme.spacing(3.5),
|
|
1671
1878
|
borderRadius: (theme) => theme.spacing(1),
|
|
@@ -1682,12 +1889,12 @@ var DeletedVariable = ({ variable, propTypeKey }) => {
|
|
|
1682
1889
|
const { propTypeUtil } = getVariableType(propTypeKey);
|
|
1683
1890
|
const { setValue } = (0, import_editor_controls8.useBoundProp)();
|
|
1684
1891
|
const userPermissions = usePermissions();
|
|
1685
|
-
const [showInfotip, setShowInfotip] = (0,
|
|
1892
|
+
const [showInfotip, setShowInfotip] = (0, import_react15.useState)(false);
|
|
1686
1893
|
const toggleInfotip = () => setShowInfotip((prev) => !prev);
|
|
1687
1894
|
const closeInfotip = () => setShowInfotip(false);
|
|
1688
|
-
const deletedChipAnchorRef = (0,
|
|
1689
|
-
const popupId = (0,
|
|
1690
|
-
const popupState = (0,
|
|
1895
|
+
const deletedChipAnchorRef = (0, import_react15.useRef)(null);
|
|
1896
|
+
const popupId = (0, import_react15.useId)();
|
|
1897
|
+
const popupState = (0, import_ui24.usePopupState)({
|
|
1691
1898
|
variant: "popover",
|
|
1692
1899
|
popupId: `elementor-variables-restore-${popupId}`
|
|
1693
1900
|
});
|
|
@@ -1713,15 +1920,15 @@ var DeletedVariable = ({ variable, propTypeKey }) => {
|
|
|
1713
1920
|
const handleRestoreWithOverrides = () => {
|
|
1714
1921
|
popupState.close();
|
|
1715
1922
|
};
|
|
1716
|
-
return /* @__PURE__ */
|
|
1717
|
-
|
|
1923
|
+
return /* @__PURE__ */ React24.createElement(React24.Fragment, null, /* @__PURE__ */ React24.createElement(import_ui24.Box, { ref: deletedChipAnchorRef }, showInfotip && /* @__PURE__ */ React24.createElement(import_ui24.Backdrop, { open: true, onClick: closeInfotip, invisible: true }), /* @__PURE__ */ React24.createElement(
|
|
1924
|
+
import_ui24.Infotip,
|
|
1718
1925
|
{
|
|
1719
1926
|
color: "warning",
|
|
1720
1927
|
placement: "right-start",
|
|
1721
1928
|
open: showInfotip,
|
|
1722
1929
|
disableHoverListener: true,
|
|
1723
1930
|
onClose: closeInfotip,
|
|
1724
|
-
content: /* @__PURE__ */
|
|
1931
|
+
content: /* @__PURE__ */ React24.createElement(
|
|
1725
1932
|
DeletedVariableAlert,
|
|
1726
1933
|
{
|
|
1727
1934
|
onClose: closeInfotip,
|
|
@@ -1741,9 +1948,9 @@ var DeletedVariable = ({ variable, propTypeKey }) => {
|
|
|
1741
1948
|
}
|
|
1742
1949
|
}
|
|
1743
1950
|
},
|
|
1744
|
-
/* @__PURE__ */
|
|
1745
|
-
), /* @__PURE__ */
|
|
1746
|
-
|
|
1951
|
+
/* @__PURE__ */ React24.createElement(DeletedTag, { label: variable.label, onClick: toggleInfotip })
|
|
1952
|
+
), /* @__PURE__ */ React24.createElement(
|
|
1953
|
+
import_ui24.Popover,
|
|
1747
1954
|
{
|
|
1748
1955
|
disableScrollLock: true,
|
|
1749
1956
|
anchorOrigin: { vertical: "bottom", horizontal: "right" },
|
|
@@ -1751,9 +1958,9 @@ var DeletedVariable = ({ variable, propTypeKey }) => {
|
|
|
1751
1958
|
PaperProps: {
|
|
1752
1959
|
sx: { my: 1 }
|
|
1753
1960
|
},
|
|
1754
|
-
...(0,
|
|
1961
|
+
...(0, import_ui24.bindPopover)(popupState)
|
|
1755
1962
|
},
|
|
1756
|
-
/* @__PURE__ */
|
|
1963
|
+
/* @__PURE__ */ React24.createElement(VariableTypeProvider, { propTypeKey }, /* @__PURE__ */ React24.createElement(
|
|
1757
1964
|
VariableRestore,
|
|
1758
1965
|
{
|
|
1759
1966
|
variableId: variable.key ?? "",
|
|
@@ -1765,30 +1972,30 @@ var DeletedVariable = ({ variable, propTypeKey }) => {
|
|
|
1765
1972
|
};
|
|
1766
1973
|
|
|
1767
1974
|
// src/components/ui/variable/missing-variable.tsx
|
|
1768
|
-
var
|
|
1769
|
-
var
|
|
1975
|
+
var React27 = __toESM(require("react"));
|
|
1976
|
+
var import_react16 = require("react");
|
|
1770
1977
|
var import_editor_controls9 = require("@elementor/editor-controls");
|
|
1771
|
-
var
|
|
1772
|
-
var
|
|
1978
|
+
var import_ui27 = require("@elementor/ui");
|
|
1979
|
+
var import_i18n20 = require("@wordpress/i18n");
|
|
1773
1980
|
|
|
1774
1981
|
// src/components/ui/missing-variable-alert.tsx
|
|
1775
|
-
var
|
|
1982
|
+
var React25 = __toESM(require("react"));
|
|
1776
1983
|
var import_editor_editing_panel7 = require("@elementor/editor-editing-panel");
|
|
1777
|
-
var
|
|
1778
|
-
var
|
|
1984
|
+
var import_ui25 = require("@elementor/ui");
|
|
1985
|
+
var import_i18n19 = require("@wordpress/i18n");
|
|
1779
1986
|
var MissingVariableAlert = ({ onClose, onClear }) => {
|
|
1780
1987
|
const sectionWidth = (0, import_editor_editing_panel7.useSectionWidth)();
|
|
1781
|
-
return /* @__PURE__ */
|
|
1782
|
-
|
|
1988
|
+
return /* @__PURE__ */ React25.createElement(import_ui25.ClickAwayListener, { onClickAway: onClose }, /* @__PURE__ */ React25.createElement(
|
|
1989
|
+
import_ui25.Alert,
|
|
1783
1990
|
{
|
|
1784
1991
|
variant: "standard",
|
|
1785
1992
|
severity: "warning",
|
|
1786
1993
|
onClose,
|
|
1787
|
-
action: /* @__PURE__ */
|
|
1994
|
+
action: /* @__PURE__ */ React25.createElement(React25.Fragment, null, onClear && /* @__PURE__ */ React25.createElement(import_ui25.AlertAction, { variant: "contained", onClick: onClear }, (0, import_i18n19.__)("Clear", "elementor"))),
|
|
1788
1995
|
sx: { width: sectionWidth }
|
|
1789
1996
|
},
|
|
1790
|
-
/* @__PURE__ */
|
|
1791
|
-
(0,
|
|
1997
|
+
/* @__PURE__ */ React25.createElement(import_ui25.AlertTitle, null, (0, import_i18n19.__)("This variable is missing", "elementor")),
|
|
1998
|
+
(0, import_i18n19.__)(
|
|
1792
1999
|
"It may have been deleted. Try clearing this field and select a different value or variable.",
|
|
1793
2000
|
"elementor"
|
|
1794
2001
|
)
|
|
@@ -1796,12 +2003,12 @@ var MissingVariableAlert = ({ onClose, onClear }) => {
|
|
|
1796
2003
|
};
|
|
1797
2004
|
|
|
1798
2005
|
// src/components/ui/tags/missing-tag.tsx
|
|
1799
|
-
var
|
|
1800
|
-
var
|
|
1801
|
-
var
|
|
1802
|
-
var MissingTag =
|
|
1803
|
-
return /* @__PURE__ */
|
|
1804
|
-
|
|
2006
|
+
var React26 = __toESM(require("react"));
|
|
2007
|
+
var import_icons13 = require("@elementor/icons");
|
|
2008
|
+
var import_ui26 = require("@elementor/ui");
|
|
2009
|
+
var MissingTag = React26.forwardRef(({ label, onClick, ...props }, ref) => {
|
|
2010
|
+
return /* @__PURE__ */ React26.createElement(
|
|
2011
|
+
import_ui26.Chip,
|
|
1805
2012
|
{
|
|
1806
2013
|
ref,
|
|
1807
2014
|
size: "tiny",
|
|
@@ -1809,7 +2016,7 @@ var MissingTag = React23.forwardRef(({ label, onClick, ...props }, ref) => {
|
|
|
1809
2016
|
shape: "rounded",
|
|
1810
2017
|
variant: "standard",
|
|
1811
2018
|
onClick,
|
|
1812
|
-
icon: /* @__PURE__ */
|
|
2019
|
+
icon: /* @__PURE__ */ React26.createElement(import_icons13.AlertTriangleFilledIcon, null),
|
|
1813
2020
|
label,
|
|
1814
2021
|
sx: {
|
|
1815
2022
|
height: (theme) => theme.spacing(3.5),
|
|
@@ -1825,19 +2032,19 @@ var MissingTag = React23.forwardRef(({ label, onClick, ...props }, ref) => {
|
|
|
1825
2032
|
// src/components/ui/variable/missing-variable.tsx
|
|
1826
2033
|
var MissingVariable = () => {
|
|
1827
2034
|
const { setValue } = (0, import_editor_controls9.useBoundProp)();
|
|
1828
|
-
const [infotipVisible, setInfotipVisible] = (0,
|
|
2035
|
+
const [infotipVisible, setInfotipVisible] = (0, import_react16.useState)(false);
|
|
1829
2036
|
const toggleInfotip = () => setInfotipVisible((prev) => !prev);
|
|
1830
2037
|
const closeInfotip = () => setInfotipVisible(false);
|
|
1831
2038
|
const clearValue = () => setValue(null);
|
|
1832
|
-
return /* @__PURE__ */
|
|
1833
|
-
|
|
2039
|
+
return /* @__PURE__ */ React27.createElement(React27.Fragment, null, infotipVisible && /* @__PURE__ */ React27.createElement(import_ui27.Backdrop, { open: true, onClick: closeInfotip, invisible: true }), /* @__PURE__ */ React27.createElement(
|
|
2040
|
+
import_ui27.Infotip,
|
|
1834
2041
|
{
|
|
1835
2042
|
color: "warning",
|
|
1836
2043
|
placement: "right-start",
|
|
1837
2044
|
open: infotipVisible,
|
|
1838
2045
|
disableHoverListener: true,
|
|
1839
2046
|
onClose: closeInfotip,
|
|
1840
|
-
content: /* @__PURE__ */
|
|
2047
|
+
content: /* @__PURE__ */ React27.createElement(MissingVariableAlert, { onClose: closeInfotip, onClear: clearValue }),
|
|
1841
2048
|
slotProps: {
|
|
1842
2049
|
popper: {
|
|
1843
2050
|
modifiers: [
|
|
@@ -1849,7 +2056,7 @@ var MissingVariable = () => {
|
|
|
1849
2056
|
}
|
|
1850
2057
|
}
|
|
1851
2058
|
},
|
|
1852
|
-
/* @__PURE__ */
|
|
2059
|
+
/* @__PURE__ */ React27.createElement(MissingTag, { label: (0, import_i18n20.__)("Missing variable", "elementor"), onClick: toggleInfotip })
|
|
1853
2060
|
));
|
|
1854
2061
|
};
|
|
1855
2062
|
|
|
@@ -1858,33 +2065,33 @@ var VariableControl = () => {
|
|
|
1858
2065
|
const boundProp = (0, import_editor_controls10.useBoundProp)().value;
|
|
1859
2066
|
const assignedVariable = useVariable(boundProp?.value);
|
|
1860
2067
|
if (!assignedVariable) {
|
|
1861
|
-
return /* @__PURE__ */
|
|
2068
|
+
return /* @__PURE__ */ React28.createElement(MissingVariable, null);
|
|
1862
2069
|
}
|
|
1863
2070
|
const { $$type: propTypeKey } = boundProp;
|
|
1864
2071
|
if (assignedVariable?.deleted) {
|
|
1865
|
-
return /* @__PURE__ */
|
|
2072
|
+
return /* @__PURE__ */ React28.createElement(DeletedVariable, { variable: assignedVariable, propTypeKey });
|
|
1866
2073
|
}
|
|
1867
|
-
return /* @__PURE__ */
|
|
2074
|
+
return /* @__PURE__ */ React28.createElement(AssignedVariable, { variable: assignedVariable, propTypeKey });
|
|
1868
2075
|
};
|
|
1869
2076
|
|
|
1870
2077
|
// src/hooks/use-prop-variable-action.tsx
|
|
1871
|
-
var
|
|
2078
|
+
var React29 = __toESM(require("react"));
|
|
1872
2079
|
var import_editor_editing_panel8 = require("@elementor/editor-editing-panel");
|
|
1873
|
-
var
|
|
1874
|
-
var
|
|
2080
|
+
var import_icons14 = require("@elementor/icons");
|
|
2081
|
+
var import_i18n21 = require("@wordpress/i18n");
|
|
1875
2082
|
var usePropVariableAction = () => {
|
|
1876
2083
|
const { propType, path } = (0, import_editor_editing_panel8.useBoundProp)();
|
|
1877
2084
|
const variable = resolveVariableFromPropType(propType);
|
|
1878
2085
|
return {
|
|
1879
2086
|
visible: Boolean(variable),
|
|
1880
|
-
icon:
|
|
1881
|
-
title: (0,
|
|
2087
|
+
icon: import_icons14.ColorFilterIcon,
|
|
2088
|
+
title: (0, import_i18n21.__)("Variables", "elementor"),
|
|
1882
2089
|
content: ({ close: closePopover }) => {
|
|
1883
2090
|
if (!variable) {
|
|
1884
2091
|
return null;
|
|
1885
2092
|
}
|
|
1886
2093
|
trackOpenVariablePopover(path, variable.variableType);
|
|
1887
|
-
return /* @__PURE__ */
|
|
2094
|
+
return /* @__PURE__ */ React29.createElement(VariableSelectionPopover, { closePopover, propTypeKey: variable.propTypeUtil.key });
|
|
1888
2095
|
}
|
|
1889
2096
|
};
|
|
1890
2097
|
};
|
|
@@ -1909,18 +2116,18 @@ var trackOpenVariablePopover = (path, variableType) => {
|
|
|
1909
2116
|
};
|
|
1910
2117
|
|
|
1911
2118
|
// src/register-variable-types.tsx
|
|
1912
|
-
var
|
|
2119
|
+
var React32 = __toESM(require("react"));
|
|
1913
2120
|
var import_editor_props3 = require("@elementor/editor-props");
|
|
1914
|
-
var
|
|
2121
|
+
var import_icons16 = require("@elementor/icons");
|
|
1915
2122
|
|
|
1916
2123
|
// src/components/fields/color-field.tsx
|
|
1917
|
-
var
|
|
1918
|
-
var
|
|
1919
|
-
var
|
|
2124
|
+
var React30 = __toESM(require("react"));
|
|
2125
|
+
var import_react17 = require("react");
|
|
2126
|
+
var import_ui28 = require("@elementor/ui");
|
|
1920
2127
|
var ColorField = ({ value, onChange, onValidationChange }) => {
|
|
1921
|
-
const [color, setColor] = (0,
|
|
1922
|
-
const [errorMessage, setErrorMessage] = (0,
|
|
1923
|
-
const defaultRef = (0,
|
|
2128
|
+
const [color, setColor] = (0, import_react17.useState)(value);
|
|
2129
|
+
const [errorMessage, setErrorMessage] = (0, import_react17.useState)("");
|
|
2130
|
+
const defaultRef = (0, import_react17.useRef)(null);
|
|
1924
2131
|
const anchorRef = usePopoverContentRef() ?? defaultRef.current;
|
|
1925
2132
|
const handleChange = (newValue) => {
|
|
1926
2133
|
setColor(newValue);
|
|
@@ -1929,8 +2136,8 @@ var ColorField = ({ value, onChange, onValidationChange }) => {
|
|
|
1929
2136
|
onValidationChange?.(errorMsg);
|
|
1930
2137
|
onChange(errorMsg ? "" : newValue);
|
|
1931
2138
|
};
|
|
1932
|
-
return /* @__PURE__ */
|
|
1933
|
-
|
|
2139
|
+
return /* @__PURE__ */ React30.createElement(
|
|
2140
|
+
import_ui28.UnstableColorField,
|
|
1934
2141
|
{
|
|
1935
2142
|
size: "tiny",
|
|
1936
2143
|
fullWidth: true,
|
|
@@ -1949,21 +2156,21 @@ var ColorField = ({ value, onChange, onValidationChange }) => {
|
|
|
1949
2156
|
};
|
|
1950
2157
|
|
|
1951
2158
|
// src/components/fields/font-field.tsx
|
|
1952
|
-
var
|
|
1953
|
-
var
|
|
2159
|
+
var React31 = __toESM(require("react"));
|
|
2160
|
+
var import_react18 = require("react");
|
|
1954
2161
|
var import_editor_controls11 = require("@elementor/editor-controls");
|
|
1955
2162
|
var import_editor_editing_panel9 = require("@elementor/editor-editing-panel");
|
|
1956
|
-
var
|
|
1957
|
-
var
|
|
1958
|
-
var
|
|
2163
|
+
var import_icons15 = require("@elementor/icons");
|
|
2164
|
+
var import_ui29 = require("@elementor/ui");
|
|
2165
|
+
var import_i18n22 = require("@wordpress/i18n");
|
|
1959
2166
|
var FontField = ({ value, onChange, onValidationChange }) => {
|
|
1960
|
-
const [fontFamily, setFontFamily] = (0,
|
|
1961
|
-
const defaultRef = (0,
|
|
2167
|
+
const [fontFamily, setFontFamily] = (0, import_react18.useState)(value);
|
|
2168
|
+
const defaultRef = (0, import_react18.useRef)(null);
|
|
1962
2169
|
const anchorRef = usePopoverContentRef() ?? defaultRef.current;
|
|
1963
|
-
const fontPopoverState = (0,
|
|
2170
|
+
const fontPopoverState = (0, import_ui29.usePopupState)({ variant: "popover" });
|
|
1964
2171
|
const fontFamilies = (0, import_editor_editing_panel9.useFontFamilies)();
|
|
1965
2172
|
const sectionWidth = (0, import_editor_editing_panel9.useSectionWidth)();
|
|
1966
|
-
const mapFontSubs =
|
|
2173
|
+
const mapFontSubs = React31.useMemo(() => {
|
|
1967
2174
|
return fontFamilies.map(({ label, fonts }) => ({
|
|
1968
2175
|
label,
|
|
1969
2176
|
items: fonts
|
|
@@ -1979,28 +2186,28 @@ var FontField = ({ value, onChange, onValidationChange }) => {
|
|
|
1979
2186
|
handleChange(newFontFamily);
|
|
1980
2187
|
fontPopoverState.close();
|
|
1981
2188
|
};
|
|
1982
|
-
const id2 = (0,
|
|
1983
|
-
return /* @__PURE__ */
|
|
1984
|
-
|
|
2189
|
+
const id2 = (0, import_react18.useId)();
|
|
2190
|
+
return /* @__PURE__ */ React31.createElement(React31.Fragment, null, /* @__PURE__ */ React31.createElement(
|
|
2191
|
+
import_ui29.UnstableTag,
|
|
1985
2192
|
{
|
|
1986
2193
|
id: id2,
|
|
1987
2194
|
variant: "outlined",
|
|
1988
2195
|
label: fontFamily,
|
|
1989
|
-
endIcon: /* @__PURE__ */
|
|
1990
|
-
...(0,
|
|
2196
|
+
endIcon: /* @__PURE__ */ React31.createElement(import_icons15.ChevronDownIcon, { fontSize: "tiny" }),
|
|
2197
|
+
...(0, import_ui29.bindTrigger)(fontPopoverState),
|
|
1991
2198
|
fullWidth: true
|
|
1992
2199
|
}
|
|
1993
|
-
), /* @__PURE__ */
|
|
1994
|
-
|
|
2200
|
+
), /* @__PURE__ */ React31.createElement(
|
|
2201
|
+
import_ui29.Popover,
|
|
1995
2202
|
{
|
|
1996
2203
|
disablePortal: true,
|
|
1997
2204
|
disableScrollLock: true,
|
|
1998
2205
|
anchorEl: anchorRef,
|
|
1999
2206
|
anchorOrigin: { vertical: "top", horizontal: "right" },
|
|
2000
2207
|
transformOrigin: { vertical: "top", horizontal: -28 },
|
|
2001
|
-
...(0,
|
|
2208
|
+
...(0, import_ui29.bindPopover)(fontPopoverState)
|
|
2002
2209
|
},
|
|
2003
|
-
/* @__PURE__ */
|
|
2210
|
+
/* @__PURE__ */ React31.createElement(
|
|
2004
2211
|
import_editor_controls11.ItemSelector,
|
|
2005
2212
|
{
|
|
2006
2213
|
itemsList: mapFontSubs,
|
|
@@ -2008,10 +2215,10 @@ var FontField = ({ value, onChange, onValidationChange }) => {
|
|
|
2008
2215
|
onItemChange: handleFontFamilyChange,
|
|
2009
2216
|
onClose: fontPopoverState.close,
|
|
2010
2217
|
sectionWidth,
|
|
2011
|
-
title: (0,
|
|
2218
|
+
title: (0, import_i18n22.__)("Font Family", "elementor"),
|
|
2012
2219
|
itemStyle: (item) => ({ fontFamily: item.value }),
|
|
2013
2220
|
onDebounce: import_editor_controls11.enqueueFont,
|
|
2014
|
-
icon:
|
|
2221
|
+
icon: import_icons15.TextIcon
|
|
2015
2222
|
}
|
|
2016
2223
|
)
|
|
2017
2224
|
));
|
|
@@ -2021,15 +2228,15 @@ var FontField = ({ value, onChange, onValidationChange }) => {
|
|
|
2021
2228
|
function registerVariableTypes() {
|
|
2022
2229
|
registerVariableType({
|
|
2023
2230
|
valueField: ColorField,
|
|
2024
|
-
icon:
|
|
2231
|
+
icon: import_icons16.BrushIcon,
|
|
2025
2232
|
propTypeUtil: colorVariablePropTypeUtil,
|
|
2026
2233
|
fallbackPropTypeUtil: import_editor_props3.colorPropTypeUtil,
|
|
2027
2234
|
variableType: "color",
|
|
2028
|
-
startIcon: ({ value }) => /* @__PURE__ */
|
|
2235
|
+
startIcon: ({ value }) => /* @__PURE__ */ React32.createElement(ColorIndicator, { size: "inherit", component: "span", value })
|
|
2029
2236
|
});
|
|
2030
2237
|
registerVariableType({
|
|
2031
2238
|
valueField: FontField,
|
|
2032
|
-
icon:
|
|
2239
|
+
icon: import_icons16.TextIcon,
|
|
2033
2240
|
propTypeUtil: fontVariablePropTypeUtil,
|
|
2034
2241
|
fallbackPropTypeUtil: import_editor_props3.stringPropTypeUtil,
|
|
2035
2242
|
variableType: "font"
|
|
@@ -2037,10 +2244,10 @@ function registerVariableTypes() {
|
|
|
2037
2244
|
}
|
|
2038
2245
|
|
|
2039
2246
|
// src/renderers/style-variables-renderer.tsx
|
|
2040
|
-
var
|
|
2041
|
-
var
|
|
2247
|
+
var React33 = __toESM(require("react"));
|
|
2248
|
+
var import_react19 = require("react");
|
|
2042
2249
|
var import_editor_v1_adapters3 = require("@elementor/editor-v1-adapters");
|
|
2043
|
-
var
|
|
2250
|
+
var import_ui30 = require("@elementor/ui");
|
|
2044
2251
|
|
|
2045
2252
|
// src/sync/get-canvas-iframe-document.ts
|
|
2046
2253
|
function getCanvasIframeDocument() {
|
|
@@ -2059,14 +2266,14 @@ function StyleVariablesRenderer() {
|
|
|
2059
2266
|
}
|
|
2060
2267
|
const cssVariables = convertToCssVariables(styleVariables);
|
|
2061
2268
|
const wrappedCss = `${VARIABLES_WRAPPER}{${cssVariables}}`;
|
|
2062
|
-
return /* @__PURE__ */
|
|
2269
|
+
return /* @__PURE__ */ React33.createElement(import_ui30.Portal, { container }, /* @__PURE__ */ React33.createElement("style", { "data-e-style-id": "e-variables", key: wrappedCss }, wrappedCss));
|
|
2063
2270
|
}
|
|
2064
2271
|
function usePortalContainer() {
|
|
2065
2272
|
return (0, import_editor_v1_adapters3.__privateUseListenTo)((0, import_editor_v1_adapters3.commandEndEvent)("editor/documents/attach-preview"), () => getCanvasIframeDocument()?.head);
|
|
2066
2273
|
}
|
|
2067
2274
|
function useStyleVariables() {
|
|
2068
|
-
const [variables, setVariables] = (0,
|
|
2069
|
-
(0,
|
|
2275
|
+
const [variables, setVariables] = (0, import_react19.useState)({});
|
|
2276
|
+
(0, import_react19.useEffect)(() => {
|
|
2070
2277
|
const unsubscribe = styleVariablesRepository.subscribe(setVariables);
|
|
2071
2278
|
return () => {
|
|
2072
2279
|
unsubscribe();
|
|
@@ -2089,22 +2296,22 @@ var import_editor_controls12 = require("@elementor/editor-controls");
|
|
|
2089
2296
|
var import_editor_props4 = require("@elementor/editor-props");
|
|
2090
2297
|
|
|
2091
2298
|
// src/components/variables-repeater-item-slot.tsx
|
|
2092
|
-
var
|
|
2299
|
+
var React34 = __toESM(require("react"));
|
|
2093
2300
|
var useColorVariable = (value) => {
|
|
2094
2301
|
const variableId = value?.value?.color?.value;
|
|
2095
2302
|
return useVariable(variableId || "");
|
|
2096
2303
|
};
|
|
2097
2304
|
var BackgroundRepeaterColorIndicator = ({ value }) => {
|
|
2098
2305
|
const colorVariable = useColorVariable(value);
|
|
2099
|
-
return /* @__PURE__ */
|
|
2306
|
+
return /* @__PURE__ */ React34.createElement(ColorIndicator, { component: "span", size: "inherit", value: colorVariable?.value });
|
|
2100
2307
|
};
|
|
2101
2308
|
var BackgroundRepeaterLabel = ({ value }) => {
|
|
2102
2309
|
const colorVariable = useColorVariable(value);
|
|
2103
|
-
return /* @__PURE__ */
|
|
2310
|
+
return /* @__PURE__ */ React34.createElement("span", null, colorVariable?.label);
|
|
2104
2311
|
};
|
|
2105
2312
|
var BoxShadowRepeaterColorIndicator = ({ value }) => {
|
|
2106
2313
|
const colorVariable = useColorVariable(value);
|
|
2107
|
-
return /* @__PURE__ */
|
|
2314
|
+
return /* @__PURE__ */ React34.createElement(ColorIndicator, { component: "span", size: "inherit", value: colorVariable?.value });
|
|
2108
2315
|
};
|
|
2109
2316
|
|
|
2110
2317
|
// src/repeater-injections.ts
|