@elementor/editor-variables 3.33.0-173 → 3.33.0-175
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 +391 -276
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +361 -236
- package/dist/index.mjs.map +1 -1
- package/package.json +14 -14
- package/src/components/variables-manager/hooks/use-error-navigation.ts +49 -0
- package/src/components/variables-manager/hooks/use-variables-manager-state.ts +16 -24
- package/src/components/variables-manager/variables-manager-panel.tsx +169 -102
- package/src/utils/validations.ts +54 -2
package/dist/index.js
CHANGED
|
@@ -44,19 +44,107 @@ var import_editor_props6 = require("@elementor/editor-props");
|
|
|
44
44
|
|
|
45
45
|
// src/components/variables-manager/variables-manager-panel.tsx
|
|
46
46
|
var React12 = __toESM(require("react"));
|
|
47
|
-
var
|
|
47
|
+
var import_react11 = require("react");
|
|
48
48
|
var import_editor_panels = require("@elementor/editor-panels");
|
|
49
49
|
var import_editor_ui3 = require("@elementor/editor-ui");
|
|
50
50
|
var import_editor_v1_adapters = require("@elementor/editor-v1-adapters");
|
|
51
51
|
var import_icons5 = require("@elementor/icons");
|
|
52
52
|
var import_ui12 = require("@elementor/ui");
|
|
53
|
-
var
|
|
53
|
+
var import_i18n9 = require("@wordpress/i18n");
|
|
54
|
+
|
|
55
|
+
// src/utils/validations.ts
|
|
56
|
+
var import_i18n = require("@wordpress/i18n");
|
|
57
|
+
var ERROR_MESSAGES = {
|
|
58
|
+
MISSING_VARIABLE_NAME: (0, import_i18n.__)("Give your variable a name.", "elementor"),
|
|
59
|
+
MISSING_VARIABLE_VALUE: (0, import_i18n.__)("Add a value to complete your variable.", "elementor"),
|
|
60
|
+
INVALID_CHARACTERS: (0, import_i18n.__)("Use letters, numbers, dashes (-), or underscores (_) for the name.", "elementor"),
|
|
61
|
+
NO_NON_SPECIAL_CHARACTER: (0, import_i18n.__)("Names have to include at least one non-special character.", "elementor"),
|
|
62
|
+
VARIABLE_LABEL_MAX_LENGTH: (0, import_i18n.__)("Keep names up to 50 characters.", "elementor"),
|
|
63
|
+
DUPLICATED_LABEL: (0, import_i18n.__)("This variable name already exists. Please choose a unique name.", "elementor"),
|
|
64
|
+
UNEXPECTED_ERROR: (0, import_i18n.__)("There was a glitch. Try saving your variable again.", "elementor"),
|
|
65
|
+
BATCH: {
|
|
66
|
+
DUPLICATED_LABELS: (count, name) => (
|
|
67
|
+
// eslint-disable-next-line @wordpress/i18n-translator-comments
|
|
68
|
+
(0, import_i18n.sprintf)((0, import_i18n.__)("We found %1$d duplicated %2$s.", "elementor"), count, name)
|
|
69
|
+
),
|
|
70
|
+
UNEXPECTED_ERROR: (0, import_i18n.__)("The save didn\u2019t go through.", "elementor"),
|
|
71
|
+
DUPLICATED_LABEL_ACTION: (0, import_i18n.__)("Take me there", "elementor"),
|
|
72
|
+
DUPLICATED_LABEL_ACTION_MESSAGE: (0, import_i18n.__)("Please rename the variables.", "elementor"),
|
|
73
|
+
UNEXPECTED_ERROR_ACTION_MESSAGE: (0, import_i18n.__)("Try saving your variables again.", "elementor")
|
|
74
|
+
}
|
|
75
|
+
};
|
|
76
|
+
var VARIABLE_LABEL_MAX_LENGTH = 50;
|
|
77
|
+
var mapServerError = (error) => {
|
|
78
|
+
if (error?.response?.data?.code === "duplicated_label") {
|
|
79
|
+
return {
|
|
80
|
+
field: "label",
|
|
81
|
+
message: ERROR_MESSAGES.DUPLICATED_LABEL
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
if (error?.response?.data?.code === "batch_duplicated_label") {
|
|
85
|
+
const errorData = error?.response?.data?.data ?? {};
|
|
86
|
+
const count = Object.keys(errorData).length;
|
|
87
|
+
const name = count === 1 ? "name" : "names";
|
|
88
|
+
const duplicatedIds = Object.keys(errorData);
|
|
89
|
+
return {
|
|
90
|
+
field: "label",
|
|
91
|
+
message: ERROR_MESSAGES.BATCH.DUPLICATED_LABELS(count, name),
|
|
92
|
+
action: {
|
|
93
|
+
label: ERROR_MESSAGES.BATCH.DUPLICATED_LABEL_ACTION,
|
|
94
|
+
message: ERROR_MESSAGES.BATCH.DUPLICATED_LABEL_ACTION_MESSAGE,
|
|
95
|
+
data: {
|
|
96
|
+
duplicatedIds
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
if (error?.response?.data?.code === "batch_operation_failed") {
|
|
102
|
+
return {
|
|
103
|
+
field: "label",
|
|
104
|
+
message: ERROR_MESSAGES.BATCH.UNEXPECTED_ERROR
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
return void 0;
|
|
108
|
+
};
|
|
109
|
+
var validateLabel = (name, variables) => {
|
|
110
|
+
if (!name.trim()) {
|
|
111
|
+
return ERROR_MESSAGES.MISSING_VARIABLE_NAME;
|
|
112
|
+
}
|
|
113
|
+
const allowedChars = /^[a-zA-Z0-9_-]+$/;
|
|
114
|
+
if (!allowedChars.test(name)) {
|
|
115
|
+
return ERROR_MESSAGES.INVALID_CHARACTERS;
|
|
116
|
+
}
|
|
117
|
+
const hasAlphanumeric = /[a-zA-Z0-9]/;
|
|
118
|
+
if (!hasAlphanumeric.test(name)) {
|
|
119
|
+
return ERROR_MESSAGES.NO_NON_SPECIAL_CHARACTER;
|
|
120
|
+
}
|
|
121
|
+
if (VARIABLE_LABEL_MAX_LENGTH < name.length) {
|
|
122
|
+
return ERROR_MESSAGES.VARIABLE_LABEL_MAX_LENGTH;
|
|
123
|
+
}
|
|
124
|
+
if (Object.values(variables ?? {}).some((variable) => variable.label === name)) {
|
|
125
|
+
return ERROR_MESSAGES.DUPLICATED_LABEL;
|
|
126
|
+
}
|
|
127
|
+
return "";
|
|
128
|
+
};
|
|
129
|
+
var labelHint = (name) => {
|
|
130
|
+
const hintThreshold = VARIABLE_LABEL_MAX_LENGTH * 0.8 - 1;
|
|
131
|
+
if (hintThreshold < name.length) {
|
|
132
|
+
return ERROR_MESSAGES.VARIABLE_LABEL_MAX_LENGTH;
|
|
133
|
+
}
|
|
134
|
+
return "";
|
|
135
|
+
};
|
|
136
|
+
var validateValue = (value) => {
|
|
137
|
+
if (!value.trim()) {
|
|
138
|
+
return ERROR_MESSAGES.MISSING_VARIABLE_VALUE;
|
|
139
|
+
}
|
|
140
|
+
return "";
|
|
141
|
+
};
|
|
54
142
|
|
|
55
143
|
// src/components/ui/delete-confirmation-dialog.tsx
|
|
56
144
|
var React = __toESM(require("react"));
|
|
57
145
|
var import_icons = require("@elementor/icons");
|
|
58
146
|
var import_ui = require("@elementor/ui");
|
|
59
|
-
var
|
|
147
|
+
var import_i18n2 = require("@wordpress/i18n");
|
|
60
148
|
var TITLE_ID = "delete-variable-dialog";
|
|
61
149
|
var DeleteConfirmationDialog = ({
|
|
62
150
|
open,
|
|
@@ -64,13 +152,13 @@ var DeleteConfirmationDialog = ({
|
|
|
64
152
|
closeDialog,
|
|
65
153
|
onConfirm
|
|
66
154
|
}) => {
|
|
67
|
-
return /* @__PURE__ */ React.createElement(import_ui.Dialog, { open, onClose: closeDialog, "aria-labelledby": TITLE_ID, maxWidth: "xs" }, /* @__PURE__ */ React.createElement(import_ui.DialogTitle, { id: TITLE_ID, display: "flex", alignItems: "center", gap: 1, sx: { lineHeight: 1 } }, /* @__PURE__ */ React.createElement(import_icons.AlertOctagonFilledIcon, { color: "error" }), (0,
|
|
155
|
+
return /* @__PURE__ */ React.createElement(import_ui.Dialog, { open, onClose: closeDialog, "aria-labelledby": TITLE_ID, maxWidth: "xs" }, /* @__PURE__ */ React.createElement(import_ui.DialogTitle, { id: TITLE_ID, display: "flex", alignItems: "center", gap: 1, sx: { lineHeight: 1 } }, /* @__PURE__ */ React.createElement(import_icons.AlertOctagonFilledIcon, { color: "error" }), (0, import_i18n2.__)("Delete this variable?", "elementor")), /* @__PURE__ */ React.createElement(import_ui.DialogContent, null, /* @__PURE__ */ React.createElement(import_ui.DialogContentText, { variant: "body2", color: "textPrimary" }, (0, import_i18n2.__)("All elements using", "elementor"), "\xA0", /* @__PURE__ */ React.createElement(import_ui.Typography, { variant: "subtitle2", component: "span", sx: { lineBreak: "anywhere" } }, label), "\xA0", (0, import_i18n2.__)("will keep their current values, but the variable itself will be removed.", "elementor"))), /* @__PURE__ */ React.createElement(import_ui.DialogActions, null, /* @__PURE__ */ React.createElement(import_ui.Button, { color: "secondary", onClick: closeDialog }, (0, import_i18n2.__)("Not now", "elementor")), /* @__PURE__ */ React.createElement(import_ui.Button, { variant: "contained", color: "error", onClick: onConfirm }, (0, import_i18n2.__)("Delete", "elementor"))));
|
|
68
156
|
};
|
|
69
157
|
|
|
70
158
|
// src/components/ui/empty-state.tsx
|
|
71
159
|
var React2 = __toESM(require("react"));
|
|
72
160
|
var import_ui2 = require("@elementor/ui");
|
|
73
|
-
var
|
|
161
|
+
var import_i18n3 = require("@wordpress/i18n");
|
|
74
162
|
|
|
75
163
|
// src/hooks/use-permissions.ts
|
|
76
164
|
var import_editor_current_user = require("@elementor/editor-current-user");
|
|
@@ -101,11 +189,11 @@ var EmptyState = ({ icon, title, message, onAdd }) => {
|
|
|
101
189
|
sx: { p: 2.5, pt: 8, pb: 5.5 }
|
|
102
190
|
},
|
|
103
191
|
icon,
|
|
104
|
-
canAdd ? /* @__PURE__ */ React2.createElement(React2.Fragment, null, /* @__PURE__ */ React2.createElement(Content, { title, message }), onAdd && /* @__PURE__ */ React2.createElement(import_ui2.Button, { variant: "outlined", color: "secondary", size: "small", onClick: onAdd }, (0,
|
|
192
|
+
canAdd ? /* @__PURE__ */ React2.createElement(React2.Fragment, null, /* @__PURE__ */ React2.createElement(Content, { title, message }), onAdd && /* @__PURE__ */ React2.createElement(import_ui2.Button, { variant: "outlined", color: "secondary", size: "small", onClick: onAdd }, (0, import_i18n3.__)("Create a variable", "elementor"))) : /* @__PURE__ */ React2.createElement(
|
|
105
193
|
Content,
|
|
106
194
|
{
|
|
107
|
-
title: (0,
|
|
108
|
-
message: (0,
|
|
195
|
+
title: (0, import_i18n3.__)("There are no variables", "elementor"),
|
|
196
|
+
message: (0, import_i18n3.__)("With your current role, you can only connect and detach variables.", "elementor")
|
|
109
197
|
}
|
|
110
198
|
)
|
|
111
199
|
);
|
|
@@ -117,7 +205,7 @@ function Content({ title, message }) {
|
|
|
117
205
|
// src/components/ui/no-search-results.tsx
|
|
118
206
|
var React3 = __toESM(require("react"));
|
|
119
207
|
var import_ui3 = require("@elementor/ui");
|
|
120
|
-
var
|
|
208
|
+
var import_i18n4 = require("@wordpress/i18n");
|
|
121
209
|
var NoSearchResults = ({ searchValue, onClear, icon }) => {
|
|
122
210
|
return /* @__PURE__ */ React3.createElement(
|
|
123
211
|
import_ui3.Stack,
|
|
@@ -130,8 +218,8 @@ var NoSearchResults = ({ searchValue, onClear, icon }) => {
|
|
|
130
218
|
sx: { pb: 3.5, pt: 8 }
|
|
131
219
|
},
|
|
132
220
|
icon,
|
|
133
|
-
/* @__PURE__ */ React3.createElement(import_ui3.Typography, { align: "center", variant: "subtitle2" }, (0,
|
|
134
|
-
/* @__PURE__ */ React3.createElement(import_ui3.Typography, { align: "center", variant: "caption", sx: { display: "flex", flexDirection: "column" } }, (0,
|
|
221
|
+
/* @__PURE__ */ React3.createElement(import_ui3.Typography, { align: "center", variant: "subtitle2" }, (0, import_i18n4.__)("Sorry, nothing matched", "elementor"), /* @__PURE__ */ React3.createElement("br", null), "\u201C", searchValue, "\u201D."),
|
|
222
|
+
/* @__PURE__ */ React3.createElement(import_ui3.Typography, { align: "center", variant: "caption", sx: { display: "flex", flexDirection: "column" } }, (0, import_i18n4.__)("Try something else.", "elementor"), /* @__PURE__ */ React3.createElement(import_ui3.Link, { color: "text.secondary", variant: "caption", component: "button", onClick: onClear }, (0, import_i18n4.__)("Clear & try again", "elementor")))
|
|
135
223
|
);
|
|
136
224
|
};
|
|
137
225
|
|
|
@@ -154,9 +242,43 @@ var useAutoEdit = () => {
|
|
|
154
242
|
};
|
|
155
243
|
};
|
|
156
244
|
|
|
245
|
+
// src/components/variables-manager/hooks/use-error-navigation.ts
|
|
246
|
+
var import_react2 = require("react");
|
|
247
|
+
var useErrorNavigation = () => {
|
|
248
|
+
const currentIndexRef = (0, import_react2.useRef)(0);
|
|
249
|
+
const createNavigationCallback = (0, import_react2.useCallback)(
|
|
250
|
+
(ids, onNavigate, onComplete) => {
|
|
251
|
+
return () => {
|
|
252
|
+
if (!ids?.length) {
|
|
253
|
+
return;
|
|
254
|
+
}
|
|
255
|
+
const currentIndex = currentIndexRef.current;
|
|
256
|
+
const currentId = ids[currentIndex];
|
|
257
|
+
if (currentId) {
|
|
258
|
+
onNavigate(currentId);
|
|
259
|
+
const nextIndex = currentIndex + 1;
|
|
260
|
+
if (nextIndex >= ids.length) {
|
|
261
|
+
onComplete();
|
|
262
|
+
currentIndexRef.current = 0;
|
|
263
|
+
} else {
|
|
264
|
+
currentIndexRef.current = nextIndex;
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
};
|
|
268
|
+
},
|
|
269
|
+
[]
|
|
270
|
+
);
|
|
271
|
+
const resetNavigation = (0, import_react2.useCallback)(() => {
|
|
272
|
+
currentIndexRef.current = 0;
|
|
273
|
+
}, []);
|
|
274
|
+
return {
|
|
275
|
+
createNavigationCallback,
|
|
276
|
+
resetNavigation
|
|
277
|
+
};
|
|
278
|
+
};
|
|
279
|
+
|
|
157
280
|
// src/components/variables-manager/hooks/use-variables-manager-state.ts
|
|
158
|
-
var
|
|
159
|
-
var import_i18n7 = require("@wordpress/i18n");
|
|
281
|
+
var import_react5 = require("react");
|
|
160
282
|
|
|
161
283
|
// src/batch-operations.ts
|
|
162
284
|
var generateTempId = () => {
|
|
@@ -219,12 +341,12 @@ var buildOperationsArray = (originalVariables, currentVariables) => {
|
|
|
219
341
|
};
|
|
220
342
|
|
|
221
343
|
// src/hooks/use-prop-variables.ts
|
|
222
|
-
var
|
|
344
|
+
var import_react4 = require("react");
|
|
223
345
|
var import_editor_controls = require("@elementor/editor-controls");
|
|
224
346
|
|
|
225
347
|
// src/context/variable-type-context.tsx
|
|
226
348
|
var React5 = __toESM(require("react"));
|
|
227
|
-
var
|
|
349
|
+
var import_react3 = require("react");
|
|
228
350
|
|
|
229
351
|
// src/variables-registry/create-variable-type-registry.ts
|
|
230
352
|
var import_editor_canvas3 = require("@elementor/editor-canvas");
|
|
@@ -234,7 +356,7 @@ var import_editor_editing_panel = require("@elementor/editor-editing-panel");
|
|
|
234
356
|
var React4 = __toESM(require("react"));
|
|
235
357
|
var import_editor_canvas = require("@elementor/editor-canvas");
|
|
236
358
|
var import_ui5 = require("@elementor/ui");
|
|
237
|
-
var
|
|
359
|
+
var import_i18n6 = require("@wordpress/i18n");
|
|
238
360
|
|
|
239
361
|
// src/components/ui/color-indicator.tsx
|
|
240
362
|
var import_ui4 = require("@elementor/ui");
|
|
@@ -249,7 +371,7 @@ var import_schema = require("@elementor/schema");
|
|
|
249
371
|
var colorVariablePropTypeUtil = (0, import_editor_props.createPropUtils)("global-color-variable", import_schema.z.string());
|
|
250
372
|
|
|
251
373
|
// src/service.ts
|
|
252
|
-
var
|
|
374
|
+
var import_i18n5 = require("@wordpress/i18n");
|
|
253
375
|
|
|
254
376
|
// src/api.ts
|
|
255
377
|
var import_http_client = require("@elementor/http-client");
|
|
@@ -454,7 +576,7 @@ var service = {
|
|
|
454
576
|
return apiClient.create(type, label, value).then((response) => {
|
|
455
577
|
const { success, data: payload } = response.data;
|
|
456
578
|
if (!success) {
|
|
457
|
-
const errorMessage = payload?.message || (0,
|
|
579
|
+
const errorMessage = payload?.message || (0, import_i18n5.__)("Unexpected response from server", "elementor");
|
|
458
580
|
throw new Error(errorMessage);
|
|
459
581
|
}
|
|
460
582
|
return payload;
|
|
@@ -476,7 +598,7 @@ var service = {
|
|
|
476
598
|
return apiClient.update(id2, label, value).then((response) => {
|
|
477
599
|
const { success, data: payload } = response.data;
|
|
478
600
|
if (!success) {
|
|
479
|
-
const errorMessage = payload?.message || (0,
|
|
601
|
+
const errorMessage = payload?.message || (0, import_i18n5.__)("Unexpected response from server", "elementor");
|
|
480
602
|
throw new Error(errorMessage);
|
|
481
603
|
}
|
|
482
604
|
return payload;
|
|
@@ -609,7 +731,7 @@ var inheritanceTransformer = (0, import_editor_canvas.createTransformer)((id2) =
|
|
|
609
731
|
const variables = service.variables();
|
|
610
732
|
const variable = variables[id2];
|
|
611
733
|
if (!variable) {
|
|
612
|
-
return /* @__PURE__ */ React4.createElement("span", null, (0,
|
|
734
|
+
return /* @__PURE__ */ React4.createElement("span", null, (0, import_i18n6.__)("Missing variable", "elementor"));
|
|
613
735
|
}
|
|
614
736
|
const showColorIndicator = variable.type === colorVariablePropTypeUtil.key;
|
|
615
737
|
const css = resolveCssVariable(id2, variable);
|
|
@@ -696,12 +818,12 @@ function createVariableTypeRegistry() {
|
|
|
696
818
|
var { registerVariableType, getVariableType, getVariableTypes, hasVariableType } = createVariableTypeRegistry();
|
|
697
819
|
|
|
698
820
|
// src/context/variable-type-context.tsx
|
|
699
|
-
var VariableTypeContext = (0,
|
|
821
|
+
var VariableTypeContext = (0, import_react3.createContext)(null);
|
|
700
822
|
function VariableTypeProvider({ children, propTypeKey }) {
|
|
701
823
|
return /* @__PURE__ */ React5.createElement(VariableTypeContext.Provider, { value: propTypeKey }, children);
|
|
702
824
|
}
|
|
703
825
|
function useVariableType() {
|
|
704
|
-
const context = (0,
|
|
826
|
+
const context = (0, import_react3.useContext)(VariableTypeContext);
|
|
705
827
|
if (context === null) {
|
|
706
828
|
throw new Error("useVariableType must be used within a VariableTypeProvider");
|
|
707
829
|
}
|
|
@@ -754,7 +876,7 @@ var useVariableSelectionFilter = (variables) => {
|
|
|
754
876
|
return selectionFilter ? selectionFilter(variables, propType) : variables;
|
|
755
877
|
};
|
|
756
878
|
var usePropVariables = (propKey) => {
|
|
757
|
-
return (0,
|
|
879
|
+
return (0, import_react4.useMemo)(() => normalizeVariables(propKey), [propKey]);
|
|
758
880
|
};
|
|
759
881
|
var normalizeVariables = (propKey) => {
|
|
760
882
|
const variables = getVariables(false);
|
|
@@ -779,77 +901,22 @@ var restoreVariable = (restoreId, label, value) => {
|
|
|
779
901
|
return service.restore(restoreId, label, value).then(extractId);
|
|
780
902
|
};
|
|
781
903
|
|
|
782
|
-
// src/utils/validations.ts
|
|
783
|
-
var import_i18n6 = require("@wordpress/i18n");
|
|
784
|
-
var ERROR_MESSAGES = {
|
|
785
|
-
MISSING_VARIABLE_NAME: (0, import_i18n6.__)("Give your variable a name.", "elementor"),
|
|
786
|
-
MISSING_VARIABLE_VALUE: (0, import_i18n6.__)("Add a value to complete your variable.", "elementor"),
|
|
787
|
-
INVALID_CHARACTERS: (0, import_i18n6.__)("Use letters, numbers, dashes (-), or underscores (_) for the name.", "elementor"),
|
|
788
|
-
NO_NON_SPECIAL_CHARACTER: (0, import_i18n6.__)("Names have to include at least one non-special character.", "elementor"),
|
|
789
|
-
VARIABLE_LABEL_MAX_LENGTH: (0, import_i18n6.__)("Keep names up to 50 characters.", "elementor"),
|
|
790
|
-
DUPLICATED_LABEL: (0, import_i18n6.__)("This variable name already exists. Please choose a unique name.", "elementor"),
|
|
791
|
-
UNEXPECTED_ERROR: (0, import_i18n6.__)("There was a glitch. Try saving your variable again.", "elementor")
|
|
792
|
-
};
|
|
793
|
-
var VARIABLE_LABEL_MAX_LENGTH = 50;
|
|
794
|
-
var mapServerError = (error) => {
|
|
795
|
-
if (error?.response?.data?.code === "duplicated_label") {
|
|
796
|
-
return {
|
|
797
|
-
field: "label",
|
|
798
|
-
message: ERROR_MESSAGES.DUPLICATED_LABEL
|
|
799
|
-
};
|
|
800
|
-
}
|
|
801
|
-
return void 0;
|
|
802
|
-
};
|
|
803
|
-
var validateLabel = (name, variables) => {
|
|
804
|
-
if (!name.trim()) {
|
|
805
|
-
return ERROR_MESSAGES.MISSING_VARIABLE_NAME;
|
|
806
|
-
}
|
|
807
|
-
const allowedChars = /^[a-zA-Z0-9_-]+$/;
|
|
808
|
-
if (!allowedChars.test(name)) {
|
|
809
|
-
return ERROR_MESSAGES.INVALID_CHARACTERS;
|
|
810
|
-
}
|
|
811
|
-
const hasAlphanumeric = /[a-zA-Z0-9]/;
|
|
812
|
-
if (!hasAlphanumeric.test(name)) {
|
|
813
|
-
return ERROR_MESSAGES.NO_NON_SPECIAL_CHARACTER;
|
|
814
|
-
}
|
|
815
|
-
if (VARIABLE_LABEL_MAX_LENGTH < name.length) {
|
|
816
|
-
return ERROR_MESSAGES.VARIABLE_LABEL_MAX_LENGTH;
|
|
817
|
-
}
|
|
818
|
-
if (Object.values(variables ?? {}).some((variable) => variable.label === name)) {
|
|
819
|
-
return ERROR_MESSAGES.DUPLICATED_LABEL;
|
|
820
|
-
}
|
|
821
|
-
return "";
|
|
822
|
-
};
|
|
823
|
-
var labelHint = (name) => {
|
|
824
|
-
const hintThreshold = VARIABLE_LABEL_MAX_LENGTH * 0.8 - 1;
|
|
825
|
-
if (hintThreshold < name.length) {
|
|
826
|
-
return ERROR_MESSAGES.VARIABLE_LABEL_MAX_LENGTH;
|
|
827
|
-
}
|
|
828
|
-
return "";
|
|
829
|
-
};
|
|
830
|
-
var validateValue = (value) => {
|
|
831
|
-
if (!value.trim()) {
|
|
832
|
-
return ERROR_MESSAGES.MISSING_VARIABLE_VALUE;
|
|
833
|
-
}
|
|
834
|
-
return "";
|
|
835
|
-
};
|
|
836
|
-
|
|
837
904
|
// src/components/variables-manager/hooks/use-variables-manager-state.ts
|
|
838
905
|
var useVariablesManagerState = () => {
|
|
839
|
-
const [variables, setVariables] = (0,
|
|
840
|
-
const [deletedVariables, setDeletedVariables] = (0,
|
|
841
|
-
const [
|
|
842
|
-
const [
|
|
843
|
-
const [isSaving, setIsSaving] = (0,
|
|
844
|
-
const [searchValue, setSearchValue] = (0,
|
|
845
|
-
const handleOnChange = (0,
|
|
906
|
+
const [variables, setVariables] = (0, import_react5.useState)(() => getVariables(false));
|
|
907
|
+
const [deletedVariables, setDeletedVariables] = (0, import_react5.useState)([]);
|
|
908
|
+
const [isSaveDisabled, setIsSaveDisabled] = (0, import_react5.useState)(false);
|
|
909
|
+
const [isDirty, setIsDirty] = (0, import_react5.useState)(false);
|
|
910
|
+
const [isSaving, setIsSaving] = (0, import_react5.useState)(false);
|
|
911
|
+
const [searchValue, setSearchValue] = (0, import_react5.useState)("");
|
|
912
|
+
const handleOnChange = (0, import_react5.useCallback)(
|
|
846
913
|
(newVariables) => {
|
|
847
914
|
setVariables({ ...variables, ...newVariables });
|
|
848
915
|
setIsDirty(true);
|
|
849
916
|
},
|
|
850
917
|
[variables]
|
|
851
918
|
);
|
|
852
|
-
const createVariable2 = (0,
|
|
919
|
+
const createVariable2 = (0, import_react5.useCallback)((type, defaultName, defaultValue) => {
|
|
853
920
|
const newId = generateTempId();
|
|
854
921
|
const newVariable = {
|
|
855
922
|
id: newId,
|
|
@@ -861,7 +928,7 @@ var useVariablesManagerState = () => {
|
|
|
861
928
|
setIsDirty(true);
|
|
862
929
|
return newId;
|
|
863
930
|
}, []);
|
|
864
|
-
const handleDeleteVariable = (0,
|
|
931
|
+
const handleDeleteVariable = (0, import_react5.useCallback)((itemId) => {
|
|
865
932
|
setDeletedVariables((prev) => [...prev, itemId]);
|
|
866
933
|
setVariables((prev) => ({ ...prev, [itemId]: { ...prev[itemId], deleted: true } }));
|
|
867
934
|
setIsDirty(true);
|
|
@@ -869,26 +936,18 @@ var useVariablesManagerState = () => {
|
|
|
869
936
|
const handleSearch = (searchTerm) => {
|
|
870
937
|
setSearchValue(searchTerm);
|
|
871
938
|
};
|
|
872
|
-
const handleSave = (0,
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
return { success: true };
|
|
885
|
-
}
|
|
886
|
-
throw new Error((0, import_i18n7.__)("Failed to save variables. Please try again.", "elementor"));
|
|
887
|
-
} catch (error) {
|
|
888
|
-
const errorMessage = error instanceof Error ? error.message : ERROR_MESSAGES.UNEXPECTED_ERROR;
|
|
889
|
-
setIsSaving(false);
|
|
890
|
-
return { success: false, error: errorMessage };
|
|
891
|
-
}
|
|
939
|
+
const handleSave = (0, import_react5.useCallback)(async () => {
|
|
940
|
+
const originalVariables = getVariables(false);
|
|
941
|
+
setIsSaving(true);
|
|
942
|
+
const result = await service.batchSave(originalVariables, variables);
|
|
943
|
+
if (result.success) {
|
|
944
|
+
await service.load();
|
|
945
|
+
const updatedVariables = service.variables();
|
|
946
|
+
setVariables(updatedVariables);
|
|
947
|
+
setDeletedVariables([]);
|
|
948
|
+
setIsDirty(false);
|
|
949
|
+
}
|
|
950
|
+
return { success: result.success };
|
|
892
951
|
}, [variables]);
|
|
893
952
|
const filteredVariables = () => {
|
|
894
953
|
const list = Object.entries(variables).map(([id2, value]) => ({ ...value, id: id2 }));
|
|
@@ -899,7 +958,7 @@ var useVariablesManagerState = () => {
|
|
|
899
958
|
variables: filteredVariables(),
|
|
900
959
|
deletedVariables,
|
|
901
960
|
isDirty,
|
|
902
|
-
|
|
961
|
+
isSaveDisabled,
|
|
903
962
|
handleOnChange,
|
|
904
963
|
createVariable: createVariable2,
|
|
905
964
|
handleDeleteVariable,
|
|
@@ -907,16 +966,17 @@ var useVariablesManagerState = () => {
|
|
|
907
966
|
isSaving,
|
|
908
967
|
handleSearch,
|
|
909
968
|
searchValue,
|
|
910
|
-
|
|
969
|
+
setIsSaving,
|
|
970
|
+
setIsSaveDisabled
|
|
911
971
|
};
|
|
912
972
|
};
|
|
913
973
|
|
|
914
974
|
// src/components/variables-manager/variables-manager-create-menu.tsx
|
|
915
975
|
var React6 = __toESM(require("react"));
|
|
916
|
-
var
|
|
976
|
+
var import_react6 = require("react");
|
|
917
977
|
var import_icons2 = require("@elementor/icons");
|
|
918
978
|
var import_ui6 = require("@elementor/ui");
|
|
919
|
-
var
|
|
979
|
+
var import_i18n7 = require("@wordpress/i18n");
|
|
920
980
|
var SIZE = "tiny";
|
|
921
981
|
var VariableManagerCreateMenu = ({
|
|
922
982
|
variables,
|
|
@@ -924,7 +984,7 @@ var VariableManagerCreateMenu = ({
|
|
|
924
984
|
disabled,
|
|
925
985
|
menuState
|
|
926
986
|
}) => {
|
|
927
|
-
const buttonRef = (0,
|
|
987
|
+
const buttonRef = (0, import_react6.useRef)(null);
|
|
928
988
|
const variableTypes = getVariableTypes();
|
|
929
989
|
const menuOptions = Object.entries(variableTypes).map(([key, variable]) => {
|
|
930
990
|
const displayName = variable.variableType.charAt(0).toUpperCase() + variable.variableType.slice(1);
|
|
@@ -945,7 +1005,7 @@ var VariableManagerCreateMenu = ({
|
|
|
945
1005
|
ref: buttonRef,
|
|
946
1006
|
disabled,
|
|
947
1007
|
size: SIZE,
|
|
948
|
-
"aria-label": (0,
|
|
1008
|
+
"aria-label": (0, import_i18n7.__)("Add variable", "elementor")
|
|
949
1009
|
},
|
|
950
1010
|
/* @__PURE__ */ React6.createElement(import_icons2.PlusIcon, { fontSize: SIZE })
|
|
951
1011
|
), /* @__PURE__ */ React6.createElement(
|
|
@@ -982,7 +1042,7 @@ var VariableManagerCreateMenu = ({
|
|
|
982
1042
|
gap: 1.5
|
|
983
1043
|
}
|
|
984
1044
|
},
|
|
985
|
-
(0,
|
|
1045
|
+
(0, import_react6.createElement)(option.icon, {
|
|
986
1046
|
fontSize: SIZE,
|
|
987
1047
|
color: "action"
|
|
988
1048
|
}),
|
|
@@ -1003,22 +1063,22 @@ var getDefaultName = (variables, type, baseName) => {
|
|
|
1003
1063
|
|
|
1004
1064
|
// src/components/variables-manager/variables-manager-table.tsx
|
|
1005
1065
|
var React11 = __toESM(require("react"));
|
|
1006
|
-
var
|
|
1066
|
+
var import_react10 = require("react");
|
|
1007
1067
|
var import_editor_ui2 = require("@elementor/editor-ui");
|
|
1008
1068
|
var import_icons4 = require("@elementor/icons");
|
|
1009
1069
|
var import_ui11 = require("@elementor/ui");
|
|
1010
|
-
var
|
|
1070
|
+
var import_i18n8 = require("@wordpress/i18n");
|
|
1011
1071
|
|
|
1012
1072
|
// src/components/fields/label-field.tsx
|
|
1013
1073
|
var React7 = __toESM(require("react"));
|
|
1014
|
-
var
|
|
1074
|
+
var import_react7 = require("react");
|
|
1015
1075
|
var import_editor_ui = require("@elementor/editor-ui");
|
|
1016
1076
|
var import_ui7 = require("@elementor/ui");
|
|
1017
1077
|
function isLabelEqual(a, b) {
|
|
1018
1078
|
return a.trim().toLowerCase() === b.trim().toLowerCase();
|
|
1019
1079
|
}
|
|
1020
1080
|
var useLabelError = (initialError) => {
|
|
1021
|
-
const [error, setError] = (0,
|
|
1081
|
+
const [error, setError] = (0, import_react7.useState)(initialError ?? { value: "", message: "" });
|
|
1022
1082
|
return {
|
|
1023
1083
|
labelFieldError: error,
|
|
1024
1084
|
setLabelFieldError: setError
|
|
@@ -1036,9 +1096,9 @@ var LabelField = ({
|
|
|
1036
1096
|
showWarningInfotip = false,
|
|
1037
1097
|
variables
|
|
1038
1098
|
}) => {
|
|
1039
|
-
const [label, setLabel] = (0,
|
|
1040
|
-
const [errorMessage, setErrorMessage] = (0,
|
|
1041
|
-
const fieldRef = (0,
|
|
1099
|
+
const [label, setLabel] = (0, import_react7.useState)(value);
|
|
1100
|
+
const [errorMessage, setErrorMessage] = (0, import_react7.useState)("");
|
|
1101
|
+
const fieldRef = (0, import_react7.useRef)(null);
|
|
1042
1102
|
const handleChange = (newValue) => {
|
|
1043
1103
|
setLabel(newValue);
|
|
1044
1104
|
const errorMsg2 = validateLabel(newValue, variables);
|
|
@@ -1089,7 +1149,7 @@ var LabelField = ({
|
|
|
1089
1149
|
|
|
1090
1150
|
// src/components/variables-manager/ui/variable-edit-menu.tsx
|
|
1091
1151
|
var React8 = __toESM(require("react"));
|
|
1092
|
-
var
|
|
1152
|
+
var import_react8 = require("react");
|
|
1093
1153
|
var import_icons3 = require("@elementor/icons");
|
|
1094
1154
|
var import_ui8 = require("@elementor/ui");
|
|
1095
1155
|
var VariableEditMenu = ({ menuActions, disabled, itemId }) => {
|
|
@@ -1132,7 +1192,7 @@ var VariableEditMenu = ({ menuActions, disabled, itemId }) => {
|
|
|
1132
1192
|
gap: 1
|
|
1133
1193
|
}
|
|
1134
1194
|
},
|
|
1135
|
-
action.icon && (0,
|
|
1195
|
+
action.icon && (0, import_react8.createElement)(action.icon, {
|
|
1136
1196
|
fontSize: "inherit"
|
|
1137
1197
|
}),
|
|
1138
1198
|
" ",
|
|
@@ -1167,7 +1227,7 @@ var VariableTableCell = ({
|
|
|
1167
1227
|
|
|
1168
1228
|
// src/components/variables-manager/variable-editable-cell.tsx
|
|
1169
1229
|
var React10 = __toESM(require("react"));
|
|
1170
|
-
var
|
|
1230
|
+
var import_react9 = require("react");
|
|
1171
1231
|
var import_ui10 = require("@elementor/ui");
|
|
1172
1232
|
var VariableEditableCell = React10.memo(
|
|
1173
1233
|
({
|
|
@@ -1182,22 +1242,22 @@ var VariableEditableCell = React10.memo(
|
|
|
1182
1242
|
gap = 1,
|
|
1183
1243
|
fieldType
|
|
1184
1244
|
}) => {
|
|
1185
|
-
const [value, setValue] = (0,
|
|
1186
|
-
const [isEditing, setIsEditing] = (0,
|
|
1245
|
+
const [value, setValue] = (0, import_react9.useState)(initialValue);
|
|
1246
|
+
const [isEditing, setIsEditing] = (0, import_react9.useState)(false);
|
|
1187
1247
|
const { labelFieldError, setLabelFieldError } = useLabelError();
|
|
1188
|
-
const [valueFieldError, setValueFieldError] = (0,
|
|
1189
|
-
const rowRef = (0,
|
|
1190
|
-
const handleSave = (0,
|
|
1248
|
+
const [valueFieldError, setValueFieldError] = (0, import_react9.useState)("");
|
|
1249
|
+
const rowRef = (0, import_react9.useRef)(null);
|
|
1250
|
+
const handleSave = (0, import_react9.useCallback)(() => {
|
|
1191
1251
|
const hasError = fieldType === "label" && labelFieldError?.message || fieldType === "value" && valueFieldError;
|
|
1192
1252
|
if (!hasError) {
|
|
1193
1253
|
onChange(value);
|
|
1194
1254
|
}
|
|
1195
1255
|
setIsEditing(false);
|
|
1196
1256
|
}, [value, onChange, fieldType, labelFieldError, valueFieldError]);
|
|
1197
|
-
(0,
|
|
1257
|
+
(0, import_react9.useEffect)(() => {
|
|
1198
1258
|
onRowRef?.(rowRef?.current);
|
|
1199
1259
|
}, [onRowRef]);
|
|
1200
|
-
(0,
|
|
1260
|
+
(0, import_react9.useEffect)(() => {
|
|
1201
1261
|
if (autoEdit && !isEditing) {
|
|
1202
1262
|
setIsEditing(true);
|
|
1203
1263
|
onAutoEditComplete?.();
|
|
@@ -1217,10 +1277,10 @@ var VariableEditableCell = React10.memo(
|
|
|
1217
1277
|
setIsEditing(true);
|
|
1218
1278
|
}
|
|
1219
1279
|
};
|
|
1220
|
-
const handleChange = (0,
|
|
1280
|
+
const handleChange = (0, import_react9.useCallback)((newValue) => {
|
|
1221
1281
|
setValue(newValue);
|
|
1222
1282
|
}, []);
|
|
1223
|
-
const handleValidationChange = (0,
|
|
1283
|
+
const handleValidationChange = (0, import_react9.useCallback)(
|
|
1224
1284
|
(errorMsg) => {
|
|
1225
1285
|
if (fieldType === "label") {
|
|
1226
1286
|
setLabelFieldError({
|
|
@@ -1291,9 +1351,9 @@ var VariablesManagerTable = ({
|
|
|
1291
1351
|
onAutoEditComplete,
|
|
1292
1352
|
onFieldError
|
|
1293
1353
|
}) => {
|
|
1294
|
-
const tableContainerRef = (0,
|
|
1295
|
-
const variableRowRefs = (0,
|
|
1296
|
-
(0,
|
|
1354
|
+
const tableContainerRef = (0, import_react10.useRef)(null);
|
|
1355
|
+
const variableRowRefs = (0, import_react10.useRef)(/* @__PURE__ */ new Map());
|
|
1356
|
+
(0, import_react10.useEffect)(() => {
|
|
1297
1357
|
if (autoEditVariableId && tableContainerRef.current) {
|
|
1298
1358
|
const rowElement = variableRowRefs.current.get(autoEditVariableId);
|
|
1299
1359
|
if (rowElement) {
|
|
@@ -1341,7 +1401,7 @@ var VariablesManagerTable = ({
|
|
|
1341
1401
|
});
|
|
1342
1402
|
handleOnChange(updatedVariables);
|
|
1343
1403
|
};
|
|
1344
|
-
return /* @__PURE__ */ React11.createElement(import_ui11.TableContainer, { ref: tableContainerRef, sx: { overflow: "initial" } }, /* @__PURE__ */ React11.createElement(import_ui11.Table, { sx: tableSX, "aria-label": "Variables manager list with drag and drop reordering", stickyHeader: true }, /* @__PURE__ */ React11.createElement(import_ui11.TableHead, null, /* @__PURE__ */ React11.createElement(import_ui11.TableRow, null, /* @__PURE__ */ React11.createElement(VariableTableCell, { isHeader: true, noPadding: true, width: 10, maxWidth: 10 }), /* @__PURE__ */ React11.createElement(VariableTableCell, { isHeader: true }, (0,
|
|
1404
|
+
return /* @__PURE__ */ React11.createElement(import_ui11.TableContainer, { ref: tableContainerRef, sx: { overflow: "initial" } }, /* @__PURE__ */ React11.createElement(import_ui11.Table, { sx: tableSX, "aria-label": "Variables manager list with drag and drop reordering", stickyHeader: true }, /* @__PURE__ */ React11.createElement(import_ui11.TableHead, null, /* @__PURE__ */ React11.createElement(import_ui11.TableRow, null, /* @__PURE__ */ React11.createElement(VariableTableCell, { isHeader: true, noPadding: true, width: 10, maxWidth: 10 }), /* @__PURE__ */ React11.createElement(VariableTableCell, { isHeader: true }, (0, import_i18n8.__)("Name", "elementor")), /* @__PURE__ */ React11.createElement(VariableTableCell, { isHeader: true }, (0, import_i18n8.__)("Value", "elementor")), /* @__PURE__ */ React11.createElement(VariableTableCell, { isHeader: true, noPadding: true, width: 16, maxWidth: 16 }))), /* @__PURE__ */ React11.createElement(import_ui11.TableBody, null, /* @__PURE__ */ React11.createElement(
|
|
1345
1405
|
import_ui11.UnstableSortableProvider,
|
|
1346
1406
|
{
|
|
1347
1407
|
value: ids,
|
|
@@ -1421,7 +1481,7 @@ var VariablesManagerTable = ({
|
|
|
1421
1481
|
});
|
|
1422
1482
|
}
|
|
1423
1483
|
},
|
|
1424
|
-
prefixElement: (0,
|
|
1484
|
+
prefixElement: (0, import_react10.createElement)(row.icon, { fontSize: "inherit" }),
|
|
1425
1485
|
editableElement: ({
|
|
1426
1486
|
value,
|
|
1427
1487
|
onChange,
|
|
@@ -1557,18 +1617,21 @@ function VariablesManagerPanel() {
|
|
|
1557
1617
|
const {
|
|
1558
1618
|
variables,
|
|
1559
1619
|
isDirty,
|
|
1560
|
-
hasValidationErrors,
|
|
1561
1620
|
searchValue,
|
|
1621
|
+
isSaveDisabled,
|
|
1562
1622
|
handleOnChange,
|
|
1563
1623
|
createVariable: createVariable2,
|
|
1564
1624
|
handleDeleteVariable,
|
|
1565
1625
|
handleSave,
|
|
1566
1626
|
isSaving,
|
|
1567
1627
|
handleSearch,
|
|
1568
|
-
|
|
1628
|
+
setIsSaving,
|
|
1629
|
+
setIsSaveDisabled
|
|
1569
1630
|
} = useVariablesManagerState();
|
|
1570
1631
|
const { autoEditVariableId, startAutoEdit, handleAutoEditComplete } = useAutoEdit();
|
|
1571
|
-
const
|
|
1632
|
+
const { createNavigationCallback, resetNavigation } = useErrorNavigation();
|
|
1633
|
+
const [deleteConfirmation, setDeleteConfirmation] = (0, import_react11.useState)(null);
|
|
1634
|
+
const [serverError, setServerError] = (0, import_react11.useState)(null);
|
|
1572
1635
|
usePreventUnload(isDirty);
|
|
1573
1636
|
const handleClosePanel = () => {
|
|
1574
1637
|
if (isDirty) {
|
|
@@ -1577,7 +1640,7 @@ function VariablesManagerPanel() {
|
|
|
1577
1640
|
}
|
|
1578
1641
|
closePanel();
|
|
1579
1642
|
};
|
|
1580
|
-
const handleCreateVariable = (0,
|
|
1643
|
+
const handleCreateVariable = (0, import_react11.useCallback)(
|
|
1581
1644
|
(type, defaultName, defaultValue) => {
|
|
1582
1645
|
const newId = createVariable2(type, defaultName, defaultValue);
|
|
1583
1646
|
if (newId) {
|
|
@@ -1586,7 +1649,30 @@ function VariablesManagerPanel() {
|
|
|
1586
1649
|
},
|
|
1587
1650
|
[createVariable2, startAutoEdit]
|
|
1588
1651
|
);
|
|
1589
|
-
const
|
|
1652
|
+
const handleSaveClick = async () => {
|
|
1653
|
+
try {
|
|
1654
|
+
setServerError(null);
|
|
1655
|
+
resetNavigation();
|
|
1656
|
+
return await handleSave();
|
|
1657
|
+
} catch (error) {
|
|
1658
|
+
const mappedError = mapServerError(error);
|
|
1659
|
+
const duplicatedIds = mappedError?.action?.data?.duplicatedIds;
|
|
1660
|
+
if (mappedError && "label" === mappedError.field) {
|
|
1661
|
+
if (duplicatedIds && mappedError.action) {
|
|
1662
|
+
mappedError.action.callback = createNavigationCallback(duplicatedIds, startAutoEdit, () => {
|
|
1663
|
+
setIsSaveDisabled(false);
|
|
1664
|
+
});
|
|
1665
|
+
}
|
|
1666
|
+
setServerError(mappedError);
|
|
1667
|
+
setIsSaveDisabled(true);
|
|
1668
|
+
resetNavigation();
|
|
1669
|
+
}
|
|
1670
|
+
return { success: false, error: mappedError };
|
|
1671
|
+
} finally {
|
|
1672
|
+
setIsSaving(false);
|
|
1673
|
+
}
|
|
1674
|
+
};
|
|
1675
|
+
const handleDeleteVariableWithConfirmation = (0, import_react11.useCallback)(
|
|
1590
1676
|
(itemId) => {
|
|
1591
1677
|
handleDeleteVariable(itemId);
|
|
1592
1678
|
setDeleteConfirmation(null);
|
|
@@ -1595,7 +1681,7 @@ function VariablesManagerPanel() {
|
|
|
1595
1681
|
);
|
|
1596
1682
|
const menuActions = [
|
|
1597
1683
|
{
|
|
1598
|
-
name: (0,
|
|
1684
|
+
name: (0, import_i18n9.__)("Delete", "elementor"),
|
|
1599
1685
|
icon: import_icons5.TrashIcon,
|
|
1600
1686
|
color: "error.main",
|
|
1601
1687
|
onClick: (itemId) => {
|
|
@@ -1606,14 +1692,14 @@ function VariablesManagerPanel() {
|
|
|
1606
1692
|
}
|
|
1607
1693
|
];
|
|
1608
1694
|
const hasVariables = Object.values(variables).some((variable) => !variable.deleted);
|
|
1609
|
-
return /* @__PURE__ */ React12.createElement(import_editor_ui3.ThemeProvider, null, /* @__PURE__ */ React12.createElement(
|
|
1695
|
+
return /* @__PURE__ */ React12.createElement(import_editor_ui3.ThemeProvider, null, /* @__PURE__ */ React12.createElement(import_editor_panels.Panel, null, /* @__PURE__ */ React12.createElement(
|
|
1610
1696
|
import_editor_panels.PanelHeader,
|
|
1611
1697
|
{
|
|
1612
1698
|
sx: {
|
|
1613
1699
|
height: "unset"
|
|
1614
1700
|
}
|
|
1615
1701
|
},
|
|
1616
|
-
/* @__PURE__ */ React12.createElement(import_ui12.Stack, { width: "100%", direction: "column", alignItems: "center" }, /* @__PURE__ */ React12.createElement(import_ui12.Stack, { p: 1, pl: 2, width: "100%", direction: "row", alignItems: "center" }, /* @__PURE__ */ React12.createElement(import_ui12.Stack, { width: "100%", direction: "row", gap: 1 }, /* @__PURE__ */ React12.createElement(import_editor_panels.PanelHeaderTitle, { sx: { display: "flex", alignItems: "center", gap: 0.5 } }, /* @__PURE__ */ React12.createElement(import_icons5.ColorFilterIcon, { fontSize: "inherit" }), (0,
|
|
1702
|
+
/* @__PURE__ */ React12.createElement(import_ui12.Stack, { width: "100%", direction: "column", alignItems: "center" }, /* @__PURE__ */ React12.createElement(import_ui12.Stack, { p: 1, pl: 2, width: "100%", direction: "row", alignItems: "center" }, /* @__PURE__ */ React12.createElement(import_ui12.Stack, { width: "100%", direction: "row", gap: 1 }, /* @__PURE__ */ React12.createElement(import_editor_panels.PanelHeaderTitle, { sx: { display: "flex", alignItems: "center", gap: 0.5 } }, /* @__PURE__ */ React12.createElement(import_icons5.ColorFilterIcon, { fontSize: "inherit" }), (0, import_i18n9.__)("Variable Manager", "elementor"))), /* @__PURE__ */ React12.createElement(import_ui12.Stack, { direction: "row", gap: 0.5, alignItems: "center" }, /* @__PURE__ */ React12.createElement(
|
|
1617
1703
|
VariableManagerCreateMenu,
|
|
1618
1704
|
{
|
|
1619
1705
|
onCreate: handleCreateVariable,
|
|
@@ -1636,7 +1722,7 @@ function VariablesManagerPanel() {
|
|
|
1636
1722
|
display: "flex",
|
|
1637
1723
|
flex: 1
|
|
1638
1724
|
},
|
|
1639
|
-
placeholder: (0,
|
|
1725
|
+
placeholder: (0, import_i18n9.__)("Search", "elementor"),
|
|
1640
1726
|
value: searchValue,
|
|
1641
1727
|
onSearch: handleSearch
|
|
1642
1728
|
}
|
|
@@ -1658,7 +1744,7 @@ function VariablesManagerPanel() {
|
|
|
1658
1744
|
onChange: handleOnChange,
|
|
1659
1745
|
autoEditVariableId,
|
|
1660
1746
|
onAutoEditComplete: handleAutoEditComplete,
|
|
1661
|
-
onFieldError:
|
|
1747
|
+
onFieldError: setIsSaveDisabled
|
|
1662
1748
|
}
|
|
1663
1749
|
),
|
|
1664
1750
|
!hasVariables && searchValue && /* @__PURE__ */ React12.createElement(
|
|
@@ -1672,8 +1758,8 @@ function VariablesManagerPanel() {
|
|
|
1672
1758
|
!hasVariables && !searchValue && /* @__PURE__ */ React12.createElement(
|
|
1673
1759
|
EmptyState,
|
|
1674
1760
|
{
|
|
1675
|
-
title: (0,
|
|
1676
|
-
message: (0,
|
|
1761
|
+
title: (0, import_i18n9.__)("Create your first variable", "elementor"),
|
|
1762
|
+
message: (0, import_i18n9.__)(
|
|
1677
1763
|
"Variables are saved attributes that you can apply anywhere on your site.",
|
|
1678
1764
|
"elementor"
|
|
1679
1765
|
),
|
|
@@ -1682,17 +1768,45 @@ function VariablesManagerPanel() {
|
|
|
1682
1768
|
}
|
|
1683
1769
|
)
|
|
1684
1770
|
), /* @__PURE__ */ React12.createElement(import_editor_panels.PanelFooter, null, /* @__PURE__ */ React12.createElement(
|
|
1685
|
-
import_ui12.
|
|
1771
|
+
import_ui12.Infotip,
|
|
1686
1772
|
{
|
|
1687
|
-
|
|
1688
|
-
|
|
1689
|
-
|
|
1690
|
-
|
|
1691
|
-
|
|
1692
|
-
|
|
1693
|
-
|
|
1773
|
+
placement: "right",
|
|
1774
|
+
open: !!serverError,
|
|
1775
|
+
content: serverError ? /* @__PURE__ */ React12.createElement(
|
|
1776
|
+
import_ui12.Alert,
|
|
1777
|
+
{
|
|
1778
|
+
severity: "error",
|
|
1779
|
+
action: serverError.action ? /* @__PURE__ */ React12.createElement(import_ui12.AlertAction, { onClick: serverError.action.callback }, serverError.action.label) : void 0,
|
|
1780
|
+
icon: /* @__PURE__ */ React12.createElement(import_icons5.AlertTriangleFilledIcon, null)
|
|
1781
|
+
},
|
|
1782
|
+
/* @__PURE__ */ React12.createElement(import_ui12.AlertTitle, null, serverError.message),
|
|
1783
|
+
serverError.action?.message
|
|
1784
|
+
) : null,
|
|
1785
|
+
arrow: false,
|
|
1786
|
+
slotProps: {
|
|
1787
|
+
popper: {
|
|
1788
|
+
modifiers: [
|
|
1789
|
+
{
|
|
1790
|
+
name: "offset",
|
|
1791
|
+
options: { offset: [-10, 10] }
|
|
1792
|
+
}
|
|
1793
|
+
]
|
|
1794
|
+
}
|
|
1795
|
+
}
|
|
1694
1796
|
},
|
|
1695
|
-
|
|
1797
|
+
/* @__PURE__ */ React12.createElement(
|
|
1798
|
+
import_ui12.Button,
|
|
1799
|
+
{
|
|
1800
|
+
fullWidth: true,
|
|
1801
|
+
size: "small",
|
|
1802
|
+
color: "global",
|
|
1803
|
+
variant: "contained",
|
|
1804
|
+
disabled: isSaveDisabled || !isDirty || isSaving,
|
|
1805
|
+
onClick: handleSaveClick,
|
|
1806
|
+
loading: isSaving
|
|
1807
|
+
},
|
|
1808
|
+
(0, import_i18n9.__)("Save changes", "elementor")
|
|
1809
|
+
)
|
|
1696
1810
|
))), deleteConfirmation && /* @__PURE__ */ React12.createElement(
|
|
1697
1811
|
DeleteConfirmationDialog,
|
|
1698
1812
|
{
|
|
@@ -1701,32 +1815,33 @@ function VariablesManagerPanel() {
|
|
|
1701
1815
|
onConfirm: () => handleDeleteVariableWithConfirmation(deleteConfirmation.id),
|
|
1702
1816
|
closeDialog: () => setDeleteConfirmation(null)
|
|
1703
1817
|
}
|
|
1704
|
-
)
|
|
1818
|
+
), isSaveChangesDialogOpen && /* @__PURE__ */ React12.createElement(import_editor_ui3.SaveChangesDialog, null, /* @__PURE__ */ React12.createElement(import_editor_ui3.SaveChangesDialog.Title, { onClose: closeSaveChangesDialog }, (0, import_i18n9.__)("You have unsaved changes", "elementor")), /* @__PURE__ */ React12.createElement(import_editor_ui3.SaveChangesDialog.Content, null, /* @__PURE__ */ React12.createElement(import_editor_ui3.SaveChangesDialog.ContentText, null, (0, import_i18n9.__)("To avoid losing your updates, save your changes before leaving.", "elementor"))), /* @__PURE__ */ React12.createElement(
|
|
1705
1819
|
import_editor_ui3.SaveChangesDialog.Actions,
|
|
1706
1820
|
{
|
|
1707
1821
|
actions: {
|
|
1708
1822
|
discard: {
|
|
1709
|
-
label: (0,
|
|
1823
|
+
label: (0, import_i18n9.__)("Discard", "elementor"),
|
|
1710
1824
|
action: () => {
|
|
1711
1825
|
closeSaveChangesDialog();
|
|
1712
1826
|
closePanel();
|
|
1713
1827
|
}
|
|
1714
1828
|
},
|
|
1715
1829
|
confirm: {
|
|
1716
|
-
label: (0,
|
|
1830
|
+
label: (0, import_i18n9.__)("Save", "elementor"),
|
|
1717
1831
|
action: async () => {
|
|
1718
|
-
await
|
|
1832
|
+
const result = await handleSaveClick();
|
|
1719
1833
|
closeSaveChangesDialog();
|
|
1720
|
-
|
|
1834
|
+
if (result?.success) {
|
|
1835
|
+
closePanel();
|
|
1836
|
+
}
|
|
1721
1837
|
}
|
|
1722
1838
|
}
|
|
1723
1839
|
}
|
|
1724
1840
|
}
|
|
1725
1841
|
)));
|
|
1726
1842
|
}
|
|
1727
|
-
var ErrorBoundaryFallback = () => /* @__PURE__ */ React12.createElement(import_ui12.Box, { role: "alert", sx: { minHeight: "100%", p: 2 } }, /* @__PURE__ */ React12.createElement(import_ui12.Alert, { severity: "error", sx: { mb: 2, maxWidth: 400, textAlign: "center" } }, /* @__PURE__ */ React12.createElement("strong", null, (0, import_i18n10.__)("Something went wrong", "elementor"))));
|
|
1728
1843
|
var usePreventUnload = (isDirty) => {
|
|
1729
|
-
(0,
|
|
1844
|
+
(0, import_react11.useEffect)(() => {
|
|
1730
1845
|
const handleBeforeUnload = (event) => {
|
|
1731
1846
|
if (isDirty) {
|
|
1732
1847
|
event.preventDefault();
|
|
@@ -1744,7 +1859,7 @@ var React31 = __toESM(require("react"));
|
|
|
1744
1859
|
var import_editor_controls11 = require("@elementor/editor-controls");
|
|
1745
1860
|
|
|
1746
1861
|
// src/components/ui/variable/assigned-variable.tsx
|
|
1747
|
-
var
|
|
1862
|
+
var import_react18 = require("react");
|
|
1748
1863
|
var React22 = __toESM(require("react"));
|
|
1749
1864
|
var import_editor_controls6 = require("@elementor/editor-controls");
|
|
1750
1865
|
var import_icons12 = require("@elementor/icons");
|
|
@@ -1768,31 +1883,31 @@ function createUnlinkHandler(variable, propTypeKey, setValue) {
|
|
|
1768
1883
|
|
|
1769
1884
|
// src/components/variable-selection-popover.tsx
|
|
1770
1885
|
var React20 = __toESM(require("react"));
|
|
1771
|
-
var
|
|
1886
|
+
var import_react17 = require("react");
|
|
1772
1887
|
var import_editor_v1_adapters2 = require("@elementor/editor-v1-adapters");
|
|
1773
1888
|
|
|
1774
1889
|
// src/context/variable-selection-popover.context.tsx
|
|
1775
1890
|
var React13 = __toESM(require("react"));
|
|
1776
|
-
var
|
|
1891
|
+
var import_react12 = require("react");
|
|
1777
1892
|
var import_ui13 = require("@elementor/ui");
|
|
1778
|
-
var PopoverContentRefContext = (0,
|
|
1893
|
+
var PopoverContentRefContext = (0, import_react12.createContext)(null);
|
|
1779
1894
|
var PopoverContentRefContextProvider = ({ children }) => {
|
|
1780
|
-
const [anchorRef, setAnchorRef] = (0,
|
|
1895
|
+
const [anchorRef, setAnchorRef] = (0, import_react12.useState)(null);
|
|
1781
1896
|
return /* @__PURE__ */ React13.createElement(PopoverContentRefContext.Provider, { value: anchorRef }, /* @__PURE__ */ React13.createElement(import_ui13.Box, { ref: setAnchorRef }, children));
|
|
1782
1897
|
};
|
|
1783
1898
|
var usePopoverContentRef = () => {
|
|
1784
|
-
return (0,
|
|
1899
|
+
return (0, import_react12.useContext)(PopoverContentRefContext);
|
|
1785
1900
|
};
|
|
1786
1901
|
|
|
1787
1902
|
// src/components/variable-creation.tsx
|
|
1788
1903
|
var React15 = __toESM(require("react"));
|
|
1789
|
-
var
|
|
1904
|
+
var import_react13 = require("react");
|
|
1790
1905
|
var import_editor_controls4 = require("@elementor/editor-controls");
|
|
1791
1906
|
var import_editor_editing_panel2 = require("@elementor/editor-editing-panel");
|
|
1792
1907
|
var import_editor_ui4 = require("@elementor/editor-ui");
|
|
1793
1908
|
var import_icons6 = require("@elementor/icons");
|
|
1794
1909
|
var import_ui15 = require("@elementor/ui");
|
|
1795
|
-
var
|
|
1910
|
+
var import_i18n10 = require("@wordpress/i18n");
|
|
1796
1911
|
|
|
1797
1912
|
// src/hooks/use-initial-value.ts
|
|
1798
1913
|
var import_editor_controls2 = require("@elementor/editor-controls");
|
|
@@ -1866,10 +1981,10 @@ var VariableCreation = ({ onGoBack, onClose }) => {
|
|
|
1866
1981
|
const { setVariableValue: setVariable, path } = useVariableBoundProp();
|
|
1867
1982
|
const { propType } = (0, import_editor_controls4.useBoundProp)();
|
|
1868
1983
|
const initialValue = useInitialValue();
|
|
1869
|
-
const [value, setValue] = (0,
|
|
1870
|
-
const [label, setLabel] = (0,
|
|
1871
|
-
const [errorMessage, setErrorMessage] = (0,
|
|
1872
|
-
const [valueFieldError, setValueFieldError] = (0,
|
|
1984
|
+
const [value, setValue] = (0, import_react13.useState)(initialValue);
|
|
1985
|
+
const [label, setLabel] = (0, import_react13.useState)("");
|
|
1986
|
+
const [errorMessage, setErrorMessage] = (0, import_react13.useState)("");
|
|
1987
|
+
const [valueFieldError, setValueFieldError] = (0, import_react13.useState)("");
|
|
1873
1988
|
const { labelFieldError, setLabelFieldError } = useLabelError();
|
|
1874
1989
|
const resetFields = () => {
|
|
1875
1990
|
setValue("");
|
|
@@ -1923,15 +2038,15 @@ var VariableCreation = ({ onGoBack, onClose }) => {
|
|
|
1923
2038
|
return /* @__PURE__ */ React15.createElement(import_editor_editing_panel2.PopoverBody, { height: "auto" }, /* @__PURE__ */ React15.createElement(
|
|
1924
2039
|
import_editor_ui4.PopoverHeader,
|
|
1925
2040
|
{
|
|
1926
|
-
icon: /* @__PURE__ */ React15.createElement(React15.Fragment, null, onGoBack && /* @__PURE__ */ React15.createElement(import_ui15.IconButton, { size: SIZE2, "aria-label": (0,
|
|
1927
|
-
title: (0,
|
|
2041
|
+
icon: /* @__PURE__ */ React15.createElement(React15.Fragment, null, onGoBack && /* @__PURE__ */ React15.createElement(import_ui15.IconButton, { size: SIZE2, "aria-label": (0, import_i18n10.__)("Go Back", "elementor"), onClick: onGoBack }, /* @__PURE__ */ React15.createElement(import_icons6.ArrowLeftIcon, { fontSize: SIZE2 })), /* @__PURE__ */ React15.createElement(VariableIcon, { fontSize: SIZE2 })),
|
|
2042
|
+
title: (0, import_i18n10.__)("Create variable", "elementor"),
|
|
1928
2043
|
onClose: closePopover
|
|
1929
2044
|
}
|
|
1930
2045
|
), /* @__PURE__ */ React15.createElement(import_ui15.Divider, null), /* @__PURE__ */ React15.createElement(import_editor_controls4.PopoverContent, { p: 2 }, /* @__PURE__ */ React15.createElement(
|
|
1931
2046
|
FormField,
|
|
1932
2047
|
{
|
|
1933
2048
|
id: "variable-label",
|
|
1934
|
-
label: (0,
|
|
2049
|
+
label: (0, import_i18n10.__)("Name", "elementor"),
|
|
1935
2050
|
errorMsg: labelFieldError?.message,
|
|
1936
2051
|
noticeMsg: labelHint(label)
|
|
1937
2052
|
},
|
|
@@ -1953,7 +2068,7 @@ var VariableCreation = ({ onGoBack, onClose }) => {
|
|
|
1953
2068
|
}
|
|
1954
2069
|
}
|
|
1955
2070
|
)
|
|
1956
|
-
), /* @__PURE__ */ React15.createElement(FormField, { errorMsg: valueFieldError, label: (0,
|
|
2071
|
+
), /* @__PURE__ */ React15.createElement(FormField, { errorMsg: valueFieldError, label: (0, import_i18n10.__)("Value", "elementor") }, /* @__PURE__ */ React15.createElement(import_ui15.Typography, { variant: "h5", id: "variable-value-wrapper" }, /* @__PURE__ */ React15.createElement(
|
|
1957
2072
|
ValueField,
|
|
1958
2073
|
{
|
|
1959
2074
|
value,
|
|
@@ -1974,41 +2089,41 @@ var VariableCreation = ({ onGoBack, onClose }) => {
|
|
|
1974
2089
|
disabled: isSubmitDisabled,
|
|
1975
2090
|
onClick: handleCreateAndTrack
|
|
1976
2091
|
},
|
|
1977
|
-
(0,
|
|
2092
|
+
(0, import_i18n10.__)("Create", "elementor")
|
|
1978
2093
|
)));
|
|
1979
2094
|
};
|
|
1980
2095
|
|
|
1981
2096
|
// src/components/variable-edit.tsx
|
|
1982
2097
|
var React17 = __toESM(require("react"));
|
|
1983
|
-
var
|
|
2098
|
+
var import_react15 = require("react");
|
|
1984
2099
|
var import_editor_controls5 = require("@elementor/editor-controls");
|
|
1985
2100
|
var import_editor_current_user2 = require("@elementor/editor-current-user");
|
|
1986
2101
|
var import_editor_editing_panel3 = require("@elementor/editor-editing-panel");
|
|
1987
2102
|
var import_editor_ui5 = require("@elementor/editor-ui");
|
|
1988
2103
|
var import_icons8 = require("@elementor/icons");
|
|
1989
2104
|
var import_ui17 = require("@elementor/ui");
|
|
1990
|
-
var
|
|
2105
|
+
var import_i18n12 = require("@wordpress/i18n");
|
|
1991
2106
|
|
|
1992
2107
|
// src/components/ui/edit-confirmation-dialog.tsx
|
|
1993
2108
|
var React16 = __toESM(require("react"));
|
|
1994
|
-
var
|
|
2109
|
+
var import_react14 = require("react");
|
|
1995
2110
|
var import_icons7 = require("@elementor/icons");
|
|
1996
2111
|
var import_ui16 = require("@elementor/ui");
|
|
1997
|
-
var
|
|
2112
|
+
var import_i18n11 = require("@wordpress/i18n");
|
|
1998
2113
|
var EDIT_CONFIRMATION_DIALOG_ID = "edit-confirmation-dialog";
|
|
1999
2114
|
var EditConfirmationDialog = ({
|
|
2000
2115
|
closeDialog,
|
|
2001
2116
|
onConfirm,
|
|
2002
2117
|
onSuppressMessage
|
|
2003
2118
|
}) => {
|
|
2004
|
-
const [dontShowAgain, setDontShowAgain] = (0,
|
|
2119
|
+
const [dontShowAgain, setDontShowAgain] = (0, import_react14.useState)(false);
|
|
2005
2120
|
const handleSave = () => {
|
|
2006
2121
|
if (dontShowAgain) {
|
|
2007
2122
|
onSuppressMessage?.();
|
|
2008
2123
|
}
|
|
2009
2124
|
onConfirm?.();
|
|
2010
2125
|
};
|
|
2011
|
-
return /* @__PURE__ */ React16.createElement(import_ui16.Dialog, { open: true, onClose: closeDialog, maxWidth: "xs" }, /* @__PURE__ */ React16.createElement(import_ui16.DialogTitle, { display: "flex", alignItems: "center", gap: 1 }, /* @__PURE__ */ React16.createElement(import_icons7.AlertTriangleFilledIcon, { color: "secondary" }), (0,
|
|
2126
|
+
return /* @__PURE__ */ React16.createElement(import_ui16.Dialog, { open: true, onClose: closeDialog, maxWidth: "xs" }, /* @__PURE__ */ React16.createElement(import_ui16.DialogTitle, { display: "flex", alignItems: "center", gap: 1 }, /* @__PURE__ */ React16.createElement(import_icons7.AlertTriangleFilledIcon, { color: "secondary" }), (0, import_i18n11.__)("Changes to variables go live right away.", "elementor")), /* @__PURE__ */ React16.createElement(import_ui16.DialogContent, null, /* @__PURE__ */ React16.createElement(import_ui16.DialogContentText, { variant: "body2", color: "textPrimary" }, (0, import_i18n11.__)(
|
|
2012
2127
|
"Don't worry - all other changes you make will wait until you publish your site.",
|
|
2013
2128
|
"elementor"
|
|
2014
2129
|
))), /* @__PURE__ */ React16.createElement(import_ui16.DialogActions, { sx: { justifyContent: "space-between", alignItems: "center" } }, /* @__PURE__ */ React16.createElement(
|
|
@@ -2022,9 +2137,9 @@ var EditConfirmationDialog = ({
|
|
|
2022
2137
|
size: "small"
|
|
2023
2138
|
}
|
|
2024
2139
|
),
|
|
2025
|
-
label: /* @__PURE__ */ React16.createElement(import_ui16.Typography, { variant: "body2" }, (0,
|
|
2140
|
+
label: /* @__PURE__ */ React16.createElement(import_ui16.Typography, { variant: "body2" }, (0, import_i18n11.__)("Don't show me again", "elementor"))
|
|
2026
2141
|
}
|
|
2027
|
-
), /* @__PURE__ */ React16.createElement("div", null, /* @__PURE__ */ React16.createElement(import_ui16.Button, { color: "secondary", onClick: closeDialog }, (0,
|
|
2142
|
+
), /* @__PURE__ */ React16.createElement("div", null, /* @__PURE__ */ React16.createElement(import_ui16.Button, { color: "secondary", onClick: closeDialog }, (0, import_i18n11.__)("Keep editing", "elementor")), /* @__PURE__ */ React16.createElement(import_ui16.Button, { variant: "contained", color: "secondary", onClick: handleSave, sx: { ml: 1 } }, (0, import_i18n11.__)("Save", "elementor")))));
|
|
2028
2143
|
};
|
|
2029
2144
|
|
|
2030
2145
|
// src/components/variable-edit.tsx
|
|
@@ -2034,19 +2149,19 @@ var VariableEdit = ({ onClose, onGoBack, onSubmit, editId }) => {
|
|
|
2034
2149
|
const { setVariableValue: notifyBoundPropChange, variableId } = useVariableBoundProp();
|
|
2035
2150
|
const { propType } = (0, import_editor_controls5.useBoundProp)();
|
|
2036
2151
|
const [isMessageSuppressed, suppressMessage] = (0, import_editor_current_user2.useSuppressedMessage)(EDIT_CONFIRMATION_DIALOG_ID);
|
|
2037
|
-
const [deleteConfirmation, setDeleteConfirmation] = (0,
|
|
2038
|
-
const [editConfirmation, setEditConfirmation] = (0,
|
|
2039
|
-
const [errorMessage, setErrorMessage] = (0,
|
|
2040
|
-
const [valueFieldError, setValueFieldError] = (0,
|
|
2152
|
+
const [deleteConfirmation, setDeleteConfirmation] = (0, import_react15.useState)(false);
|
|
2153
|
+
const [editConfirmation, setEditConfirmation] = (0, import_react15.useState)(false);
|
|
2154
|
+
const [errorMessage, setErrorMessage] = (0, import_react15.useState)("");
|
|
2155
|
+
const [valueFieldError, setValueFieldError] = (0, import_react15.useState)("");
|
|
2041
2156
|
const { labelFieldError, setLabelFieldError } = useLabelError();
|
|
2042
2157
|
const variable = useVariable(editId);
|
|
2043
2158
|
if (!variable) {
|
|
2044
2159
|
throw new Error(`Global ${variableType} variable not found`);
|
|
2045
2160
|
}
|
|
2046
2161
|
const userPermissions = usePermissions();
|
|
2047
|
-
const [value, setValue] = (0,
|
|
2048
|
-
const [label, setLabel] = (0,
|
|
2049
|
-
(0,
|
|
2162
|
+
const [value, setValue] = (0, import_react15.useState)(() => variable.value);
|
|
2163
|
+
const [label, setLabel] = (0, import_react15.useState)(() => variable.label);
|
|
2164
|
+
(0, import_react15.useEffect)(() => {
|
|
2050
2165
|
styleVariablesRepository.update({
|
|
2051
2166
|
[editId]: {
|
|
2052
2167
|
...variable,
|
|
@@ -2114,7 +2229,7 @@ var VariableEdit = ({ onClose, onGoBack, onSubmit, editId }) => {
|
|
|
2114
2229
|
{
|
|
2115
2230
|
key: "delete",
|
|
2116
2231
|
size: SIZE3,
|
|
2117
|
-
"aria-label": (0,
|
|
2232
|
+
"aria-label": (0, import_i18n12.__)("Delete", "elementor"),
|
|
2118
2233
|
onClick: handleDeleteConfirmation
|
|
2119
2234
|
},
|
|
2120
2235
|
/* @__PURE__ */ React17.createElement(import_icons8.TrashIcon, { fontSize: SIZE3 })
|
|
@@ -2140,13 +2255,13 @@ var VariableEdit = ({ onClose, onGoBack, onSubmit, editId }) => {
|
|
|
2140
2255
|
return /* @__PURE__ */ React17.createElement(React17.Fragment, null, /* @__PURE__ */ React17.createElement(import_editor_editing_panel3.PopoverBody, { height: "auto" }, /* @__PURE__ */ React17.createElement(
|
|
2141
2256
|
import_editor_ui5.PopoverHeader,
|
|
2142
2257
|
{
|
|
2143
|
-
title: (0,
|
|
2258
|
+
title: (0, import_i18n12.__)("Edit variable", "elementor"),
|
|
2144
2259
|
onClose,
|
|
2145
2260
|
icon: /* @__PURE__ */ React17.createElement(React17.Fragment, null, onGoBack && /* @__PURE__ */ React17.createElement(
|
|
2146
2261
|
import_ui17.IconButton,
|
|
2147
2262
|
{
|
|
2148
2263
|
size: SIZE3,
|
|
2149
|
-
"aria-label": (0,
|
|
2264
|
+
"aria-label": (0, import_i18n12.__)("Go Back", "elementor"),
|
|
2150
2265
|
onClick: onGoBack
|
|
2151
2266
|
},
|
|
2152
2267
|
/* @__PURE__ */ React17.createElement(import_icons8.ArrowLeftIcon, { fontSize: SIZE3 })
|
|
@@ -2157,7 +2272,7 @@ var VariableEdit = ({ onClose, onGoBack, onSubmit, editId }) => {
|
|
|
2157
2272
|
FormField,
|
|
2158
2273
|
{
|
|
2159
2274
|
id: "variable-label",
|
|
2160
|
-
label: (0,
|
|
2275
|
+
label: (0, import_i18n12.__)("Name", "elementor"),
|
|
2161
2276
|
errorMsg: labelFieldError?.message,
|
|
2162
2277
|
noticeMsg: labelHint(label)
|
|
2163
2278
|
},
|
|
@@ -2179,7 +2294,7 @@ var VariableEdit = ({ onClose, onGoBack, onSubmit, editId }) => {
|
|
|
2179
2294
|
}
|
|
2180
2295
|
}
|
|
2181
2296
|
)
|
|
2182
|
-
), /* @__PURE__ */ React17.createElement(FormField, { errorMsg: valueFieldError, label: (0,
|
|
2297
|
+
), /* @__PURE__ */ React17.createElement(FormField, { errorMsg: valueFieldError, label: (0, import_i18n12.__)("Value", "elementor") }, /* @__PURE__ */ React17.createElement(import_ui17.Typography, { variant: "h5" }, /* @__PURE__ */ React17.createElement(
|
|
2183
2298
|
ValueField,
|
|
2184
2299
|
{
|
|
2185
2300
|
value,
|
|
@@ -2191,7 +2306,7 @@ var VariableEdit = ({ onClose, onGoBack, onSubmit, editId }) => {
|
|
|
2191
2306
|
onValidationChange: setValueFieldError,
|
|
2192
2307
|
propType
|
|
2193
2308
|
}
|
|
2194
|
-
))), errorMessage && /* @__PURE__ */ React17.createElement(import_ui17.FormHelperText, { error: true }, errorMessage)), /* @__PURE__ */ React17.createElement(import_ui17.CardActions, { sx: { pt: 0.5, pb: 1 } }, /* @__PURE__ */ React17.createElement(import_ui17.Button, { size: "small", variant: "contained", disabled: isSubmitDisabled, onClick: handleUpdate }, (0,
|
|
2309
|
+
))), errorMessage && /* @__PURE__ */ React17.createElement(import_ui17.FormHelperText, { error: true }, errorMessage)), /* @__PURE__ */ React17.createElement(import_ui17.CardActions, { sx: { pt: 0.5, pb: 1 } }, /* @__PURE__ */ React17.createElement(import_ui17.Button, { size: "small", variant: "contained", disabled: isSubmitDisabled, onClick: handleUpdate }, (0, import_i18n12.__)("Save", "elementor")))), deleteConfirmation && /* @__PURE__ */ React17.createElement(
|
|
2195
2310
|
DeleteConfirmationDialog,
|
|
2196
2311
|
{
|
|
2197
2312
|
open: true,
|
|
@@ -2211,19 +2326,19 @@ var VariableEdit = ({ onClose, onGoBack, onSubmit, editId }) => {
|
|
|
2211
2326
|
|
|
2212
2327
|
// src/components/variables-selection.tsx
|
|
2213
2328
|
var React19 = __toESM(require("react"));
|
|
2214
|
-
var
|
|
2329
|
+
var import_react16 = require("react");
|
|
2215
2330
|
var import_editor_editing_panel4 = require("@elementor/editor-editing-panel");
|
|
2216
2331
|
var import_editor_ui7 = require("@elementor/editor-ui");
|
|
2217
2332
|
var import_icons10 = require("@elementor/icons");
|
|
2218
2333
|
var import_ui20 = require("@elementor/ui");
|
|
2219
|
-
var
|
|
2334
|
+
var import_i18n14 = require("@wordpress/i18n");
|
|
2220
2335
|
|
|
2221
2336
|
// src/components/ui/menu-item-content.tsx
|
|
2222
2337
|
var React18 = __toESM(require("react"));
|
|
2223
2338
|
var import_editor_ui6 = require("@elementor/editor-ui");
|
|
2224
2339
|
var import_icons9 = require("@elementor/icons");
|
|
2225
2340
|
var import_ui18 = require("@elementor/ui");
|
|
2226
|
-
var
|
|
2341
|
+
var import_i18n13 = require("@wordpress/i18n");
|
|
2227
2342
|
var SIZE4 = "tiny";
|
|
2228
2343
|
var MenuItemContent = ({ item }) => {
|
|
2229
2344
|
const onEdit = item.onEdit;
|
|
@@ -2268,7 +2383,7 @@ var MenuItemContent = ({ item }) => {
|
|
|
2268
2383
|
e.stopPropagation();
|
|
2269
2384
|
onEdit(item.value);
|
|
2270
2385
|
},
|
|
2271
|
-
"aria-label": (0,
|
|
2386
|
+
"aria-label": (0, import_i18n13.__)("Edit", "elementor")
|
|
2272
2387
|
},
|
|
2273
2388
|
/* @__PURE__ */ React18.createElement(import_icons9.EditIcon, { color: "action", fontSize: SIZE4 })
|
|
2274
2389
|
));
|
|
@@ -2311,7 +2426,7 @@ var SIZE5 = "tiny";
|
|
|
2311
2426
|
var VariablesSelection = ({ closePopover, onAdd, onEdit, onSettings }) => {
|
|
2312
2427
|
const { icon: VariableIcon, startIcon, variableType, propTypeUtil } = useVariableType();
|
|
2313
2428
|
const { value: variable, setValue: setVariable, path } = useVariableBoundProp();
|
|
2314
|
-
const [searchValue, setSearchValue] = (0,
|
|
2429
|
+
const [searchValue, setSearchValue] = (0, import_react16.useState)("");
|
|
2315
2430
|
const {
|
|
2316
2431
|
list: variables,
|
|
2317
2432
|
hasMatches: hasSearchResults,
|
|
@@ -2361,15 +2476,15 @@ var VariablesSelection = ({ closePopover, onAdd, onEdit, onSettings }) => {
|
|
|
2361
2476
|
const handleClearSearch = () => {
|
|
2362
2477
|
setSearchValue("");
|
|
2363
2478
|
};
|
|
2364
|
-
const noVariableTitle = (0,
|
|
2479
|
+
const noVariableTitle = (0, import_i18n14.sprintf)(
|
|
2365
2480
|
/* translators: %s: Variable Type. */
|
|
2366
|
-
(0,
|
|
2481
|
+
(0, import_i18n14.__)("Create your first %s variable", "elementor"),
|
|
2367
2482
|
variableType
|
|
2368
2483
|
);
|
|
2369
2484
|
return /* @__PURE__ */ React19.createElement(import_editor_editing_panel4.PopoverBody, null, /* @__PURE__ */ React19.createElement(
|
|
2370
2485
|
import_editor_ui7.PopoverHeader,
|
|
2371
2486
|
{
|
|
2372
|
-
title: (0,
|
|
2487
|
+
title: (0, import_i18n14.__)("Variables", "elementor"),
|
|
2373
2488
|
icon: /* @__PURE__ */ React19.createElement(import_icons10.ColorFilterIcon, { fontSize: SIZE5 }),
|
|
2374
2489
|
onClose: closePopover,
|
|
2375
2490
|
actions
|
|
@@ -2379,7 +2494,7 @@ var VariablesSelection = ({ closePopover, onAdd, onEdit, onSettings }) => {
|
|
|
2379
2494
|
{
|
|
2380
2495
|
value: searchValue,
|
|
2381
2496
|
onSearch: handleSearch,
|
|
2382
|
-
placeholder: (0,
|
|
2497
|
+
placeholder: (0, import_i18n14.__)("Search", "elementor")
|
|
2383
2498
|
}
|
|
2384
2499
|
), /* @__PURE__ */ React19.createElement(import_ui20.Divider, null), hasVariables && hasSearchResults && /* @__PURE__ */ React19.createElement(
|
|
2385
2500
|
import_editor_ui7.PopoverMenuList,
|
|
@@ -2404,7 +2519,7 @@ var VariablesSelection = ({ closePopover, onAdd, onEdit, onSettings }) => {
|
|
|
2404
2519
|
EmptyState,
|
|
2405
2520
|
{
|
|
2406
2521
|
title: noVariableTitle,
|
|
2407
|
-
message: (0,
|
|
2522
|
+
message: (0, import_i18n14.__)(
|
|
2408
2523
|
"Variables are saved attributes that you can apply anywhere on your site.",
|
|
2409
2524
|
"elementor"
|
|
2410
2525
|
),
|
|
@@ -2414,8 +2529,8 @@ var VariablesSelection = ({ closePopover, onAdd, onEdit, onSettings }) => {
|
|
|
2414
2529
|
), hasNoCompatibleVariables && /* @__PURE__ */ React19.createElement(
|
|
2415
2530
|
EmptyState,
|
|
2416
2531
|
{
|
|
2417
|
-
title: (0,
|
|
2418
|
-
message: (0,
|
|
2532
|
+
title: (0, import_i18n14.__)("No compatible variables", "elementor"),
|
|
2533
|
+
message: (0, import_i18n14.__)(
|
|
2419
2534
|
"Looks like none of your variables work with this control. Create a new variable to use it here.",
|
|
2420
2535
|
"elementor"
|
|
2421
2536
|
),
|
|
@@ -2430,8 +2545,8 @@ var VIEW_LIST = "list";
|
|
|
2430
2545
|
var VIEW_ADD = "add";
|
|
2431
2546
|
var VIEW_EDIT = "edit";
|
|
2432
2547
|
var VariableSelectionPopover = ({ closePopover, propTypeKey, selectedVariable }) => {
|
|
2433
|
-
const [currentView, setCurrentView] = (0,
|
|
2434
|
-
const [editId, setEditId] = (0,
|
|
2548
|
+
const [currentView, setCurrentView] = (0, import_react17.useState)(VIEW_LIST);
|
|
2549
|
+
const [editId, setEditId] = (0, import_react17.useState)("");
|
|
2435
2550
|
const { open } = usePanelActions();
|
|
2436
2551
|
const onSettingsAvailable = (0, import_editor_v1_adapters2.isExperimentActive)("e_variables_manager") ? () => {
|
|
2437
2552
|
open();
|
|
@@ -2513,13 +2628,13 @@ function RenderView(props) {
|
|
|
2513
2628
|
var React21 = __toESM(require("react"));
|
|
2514
2629
|
var import_icons11 = require("@elementor/icons");
|
|
2515
2630
|
var import_ui21 = require("@elementor/ui");
|
|
2516
|
-
var
|
|
2631
|
+
var import_i18n15 = require("@wordpress/i18n");
|
|
2517
2632
|
var SIZE6 = "tiny";
|
|
2518
2633
|
var AssignedTag = ({ startIcon, label, onUnlink, ...props }) => {
|
|
2519
2634
|
const actions = [];
|
|
2520
2635
|
if (onUnlink) {
|
|
2521
2636
|
actions.push(
|
|
2522
|
-
/* @__PURE__ */ React21.createElement(import_ui21.IconButton, { key: "unlink", size: SIZE6, onClick: onUnlink, "aria-label": (0,
|
|
2637
|
+
/* @__PURE__ */ React21.createElement(import_ui21.IconButton, { key: "unlink", size: SIZE6, onClick: onUnlink, "aria-label": (0, import_i18n15.__)("Unlink", "elementor") }, /* @__PURE__ */ React21.createElement(import_icons11.DetachIcon, { fontSize: SIZE6 }))
|
|
2523
2638
|
);
|
|
2524
2639
|
}
|
|
2525
2640
|
return /* @__PURE__ */ React21.createElement(import_ui21.Tooltip, { title: label, placement: "top" }, /* @__PURE__ */ React21.createElement(
|
|
@@ -2539,8 +2654,8 @@ var AssignedTag = ({ startIcon, label, onUnlink, ...props }) => {
|
|
|
2539
2654
|
var AssignedVariable = ({ variable, propTypeKey }) => {
|
|
2540
2655
|
const { startIcon, propTypeUtil } = getVariableType(propTypeKey);
|
|
2541
2656
|
const { setValue } = (0, import_editor_controls6.useBoundProp)();
|
|
2542
|
-
const anchorRef = (0,
|
|
2543
|
-
const popupId = (0,
|
|
2657
|
+
const anchorRef = (0, import_react18.useRef)(null);
|
|
2658
|
+
const popupId = (0, import_react18.useId)();
|
|
2544
2659
|
const popupState = (0, import_ui22.usePopupState)({
|
|
2545
2660
|
variant: "popover",
|
|
2546
2661
|
popupId: `elementor-variables-list-${popupId}`
|
|
@@ -2580,19 +2695,19 @@ var AssignedVariable = ({ variable, propTypeKey }) => {
|
|
|
2580
2695
|
|
|
2581
2696
|
// src/components/ui/variable/deleted-variable.tsx
|
|
2582
2697
|
var React26 = __toESM(require("react"));
|
|
2583
|
-
var
|
|
2698
|
+
var import_react20 = require("react");
|
|
2584
2699
|
var import_editor_controls8 = require("@elementor/editor-controls");
|
|
2585
2700
|
var import_ui26 = require("@elementor/ui");
|
|
2586
|
-
var
|
|
2701
|
+
var import_i18n18 = require("@wordpress/i18n");
|
|
2587
2702
|
|
|
2588
2703
|
// src/components/variable-restore.tsx
|
|
2589
2704
|
var React23 = __toESM(require("react"));
|
|
2590
|
-
var
|
|
2705
|
+
var import_react19 = require("react");
|
|
2591
2706
|
var import_editor_controls7 = require("@elementor/editor-controls");
|
|
2592
2707
|
var import_editor_editing_panel5 = require("@elementor/editor-editing-panel");
|
|
2593
2708
|
var import_editor_ui8 = require("@elementor/editor-ui");
|
|
2594
2709
|
var import_ui23 = require("@elementor/ui");
|
|
2595
|
-
var
|
|
2710
|
+
var import_i18n16 = require("@wordpress/i18n");
|
|
2596
2711
|
var SIZE7 = "tiny";
|
|
2597
2712
|
var VariableRestore = ({ variableId, onClose, onSubmit }) => {
|
|
2598
2713
|
const { icon: VariableIcon, valueField: ValueField, variableType } = useVariableType();
|
|
@@ -2602,10 +2717,10 @@ var VariableRestore = ({ variableId, onClose, onSubmit }) => {
|
|
|
2602
2717
|
if (!variable) {
|
|
2603
2718
|
throw new Error(`Global ${variableType} variable not found`);
|
|
2604
2719
|
}
|
|
2605
|
-
const [errorMessage, setErrorMessage] = (0,
|
|
2606
|
-
const [valueFieldError, setValueFieldError] = (0,
|
|
2607
|
-
const [label, setLabel] = (0,
|
|
2608
|
-
const [value, setValue] = (0,
|
|
2720
|
+
const [errorMessage, setErrorMessage] = (0, import_react19.useState)("");
|
|
2721
|
+
const [valueFieldError, setValueFieldError] = (0, import_react19.useState)("");
|
|
2722
|
+
const [label, setLabel] = (0, import_react19.useState)(variable.label);
|
|
2723
|
+
const [value, setValue] = (0, import_react19.useState)(variable.value);
|
|
2609
2724
|
const { labelFieldError, setLabelFieldError } = useLabelError({
|
|
2610
2725
|
value: variable.label,
|
|
2611
2726
|
message: ERROR_MESSAGES.DUPLICATED_LABEL
|
|
@@ -2647,14 +2762,14 @@ var VariableRestore = ({ variableId, onClose, onSubmit }) => {
|
|
|
2647
2762
|
import_editor_ui8.PopoverHeader,
|
|
2648
2763
|
{
|
|
2649
2764
|
icon: /* @__PURE__ */ React23.createElement(VariableIcon, { fontSize: SIZE7 }),
|
|
2650
|
-
title: (0,
|
|
2765
|
+
title: (0, import_i18n16.__)("Restore variable", "elementor"),
|
|
2651
2766
|
onClose
|
|
2652
2767
|
}
|
|
2653
2768
|
), /* @__PURE__ */ React23.createElement(import_ui23.Divider, null), /* @__PURE__ */ React23.createElement(import_editor_controls7.PopoverContent, { p: 2 }, /* @__PURE__ */ React23.createElement(
|
|
2654
2769
|
FormField,
|
|
2655
2770
|
{
|
|
2656
2771
|
id: "variable-label",
|
|
2657
|
-
label: (0,
|
|
2772
|
+
label: (0, import_i18n16.__)("Name", "elementor"),
|
|
2658
2773
|
errorMsg: labelFieldError?.message,
|
|
2659
2774
|
noticeMsg: labelHint(label)
|
|
2660
2775
|
},
|
|
@@ -2676,7 +2791,7 @@ var VariableRestore = ({ variableId, onClose, onSubmit }) => {
|
|
|
2676
2791
|
}
|
|
2677
2792
|
}
|
|
2678
2793
|
)
|
|
2679
|
-
), /* @__PURE__ */ React23.createElement(FormField, { errorMsg: valueFieldError, label: (0,
|
|
2794
|
+
), /* @__PURE__ */ React23.createElement(FormField, { errorMsg: valueFieldError, label: (0, import_i18n16.__)("Value", "elementor") }, /* @__PURE__ */ React23.createElement(import_ui23.Typography, { variant: "h5" }, /* @__PURE__ */ React23.createElement(
|
|
2680
2795
|
ValueField,
|
|
2681
2796
|
{
|
|
2682
2797
|
value,
|
|
@@ -2688,13 +2803,13 @@ var VariableRestore = ({ variableId, onClose, onSubmit }) => {
|
|
|
2688
2803
|
onValidationChange: setValueFieldError,
|
|
2689
2804
|
propType
|
|
2690
2805
|
}
|
|
2691
|
-
))), errorMessage && /* @__PURE__ */ React23.createElement(import_ui23.FormHelperText, { error: true }, errorMessage)), /* @__PURE__ */ React23.createElement(import_ui23.CardActions, { sx: { pt: 0.5, pb: 1 } }, /* @__PURE__ */ React23.createElement(import_ui23.Button, { size: "small", variant: "contained", disabled: isSubmitDisabled, onClick: handleRestore }, (0,
|
|
2806
|
+
))), errorMessage && /* @__PURE__ */ React23.createElement(import_ui23.FormHelperText, { error: true }, errorMessage)), /* @__PURE__ */ React23.createElement(import_ui23.CardActions, { sx: { pt: 0.5, pb: 1 } }, /* @__PURE__ */ React23.createElement(import_ui23.Button, { size: "small", variant: "contained", disabled: isSubmitDisabled, onClick: handleRestore }, (0, import_i18n16.__)("Restore", "elementor")))));
|
|
2692
2807
|
};
|
|
2693
2808
|
|
|
2694
2809
|
// src/components/ui/deleted-variable-alert.tsx
|
|
2695
2810
|
var React24 = __toESM(require("react"));
|
|
2696
2811
|
var import_ui24 = require("@elementor/ui");
|
|
2697
|
-
var
|
|
2812
|
+
var import_i18n17 = require("@wordpress/i18n");
|
|
2698
2813
|
var DeletedVariableAlert = ({ onClose, onUnlink, onRestore, label }) => {
|
|
2699
2814
|
return /* @__PURE__ */ React24.createElement(import_ui24.ClickAwayListener, { onClickAway: onClose }, /* @__PURE__ */ React24.createElement(
|
|
2700
2815
|
import_ui24.Alert,
|
|
@@ -2702,11 +2817,11 @@ var DeletedVariableAlert = ({ onClose, onUnlink, onRestore, label }) => {
|
|
|
2702
2817
|
variant: "standard",
|
|
2703
2818
|
severity: "warning",
|
|
2704
2819
|
onClose,
|
|
2705
|
-
action: /* @__PURE__ */ React24.createElement(React24.Fragment, null, onUnlink && /* @__PURE__ */ React24.createElement(import_ui24.AlertAction, { variant: "contained", onClick: onUnlink }, (0,
|
|
2820
|
+
action: /* @__PURE__ */ React24.createElement(React24.Fragment, null, onUnlink && /* @__PURE__ */ React24.createElement(import_ui24.AlertAction, { variant: "contained", onClick: onUnlink }, (0, import_i18n17.__)("Unlink", "elementor")), onRestore && /* @__PURE__ */ React24.createElement(import_ui24.AlertAction, { variant: "outlined", onClick: onRestore }, (0, import_i18n17.__)("Restore", "elementor"))),
|
|
2706
2821
|
sx: { maxWidth: 300 }
|
|
2707
2822
|
},
|
|
2708
|
-
/* @__PURE__ */ React24.createElement(import_ui24.AlertTitle, null, (0,
|
|
2709
|
-
/* @__PURE__ */ React24.createElement(import_ui24.Typography, { variant: "body2", color: "textPrimary" }, (0,
|
|
2823
|
+
/* @__PURE__ */ React24.createElement(import_ui24.AlertTitle, null, (0, import_i18n17.__)("Deleted variable", "elementor")),
|
|
2824
|
+
/* @__PURE__ */ React24.createElement(import_ui24.Typography, { variant: "body2", color: "textPrimary" }, (0, import_i18n17.__)("The variable", "elementor"), "\xA0'", /* @__PURE__ */ React24.createElement(import_ui24.Typography, { variant: "body2", component: "span", sx: { lineBreak: "anywhere" } }, label), "'\xA0", (0, import_i18n17.__)(
|
|
2710
2825
|
"has been deleted, but it is still referenced in this location. You may restore the variable or unlink it to assign a different value.",
|
|
2711
2826
|
"elementor"
|
|
2712
2827
|
))
|
|
@@ -2749,11 +2864,11 @@ var DeletedVariable = ({ variable, propTypeKey }) => {
|
|
|
2749
2864
|
const { propTypeUtil } = getVariableType(propTypeKey);
|
|
2750
2865
|
const boundProp = (0, import_editor_controls8.useBoundProp)();
|
|
2751
2866
|
const userPermissions = usePermissions();
|
|
2752
|
-
const [showInfotip, setShowInfotip] = (0,
|
|
2867
|
+
const [showInfotip, setShowInfotip] = (0, import_react20.useState)(false);
|
|
2753
2868
|
const toggleInfotip = () => setShowInfotip((prev) => !prev);
|
|
2754
2869
|
const closeInfotip = () => setShowInfotip(false);
|
|
2755
|
-
const deletedChipAnchorRef = (0,
|
|
2756
|
-
const popupId = (0,
|
|
2870
|
+
const deletedChipAnchorRef = (0, import_react20.useRef)(null);
|
|
2871
|
+
const popupId = (0, import_react20.useId)();
|
|
2757
2872
|
const popupState = (0, import_ui26.usePopupState)({
|
|
2758
2873
|
variant: "popover",
|
|
2759
2874
|
popupId: `elementor-variables-restore-${popupId}`
|
|
@@ -2813,7 +2928,7 @@ var DeletedVariable = ({ variable, propTypeKey }) => {
|
|
|
2813
2928
|
{
|
|
2814
2929
|
label: variable.label,
|
|
2815
2930
|
onClick: toggleInfotip,
|
|
2816
|
-
suffix: (0,
|
|
2931
|
+
suffix: (0, import_i18n18.__)("deleted", "elementor")
|
|
2817
2932
|
}
|
|
2818
2933
|
)
|
|
2819
2934
|
), /* @__PURE__ */ React26.createElement(
|
|
@@ -2840,24 +2955,24 @@ var DeletedVariable = ({ variable, propTypeKey }) => {
|
|
|
2840
2955
|
|
|
2841
2956
|
// src/components/ui/variable/mismatch-variable.tsx
|
|
2842
2957
|
var React28 = __toESM(require("react"));
|
|
2843
|
-
var
|
|
2958
|
+
var import_react21 = require("react");
|
|
2844
2959
|
var import_editor_controls9 = require("@elementor/editor-controls");
|
|
2845
2960
|
var import_ui28 = require("@elementor/ui");
|
|
2846
|
-
var
|
|
2961
|
+
var import_i18n20 = require("@wordpress/i18n");
|
|
2847
2962
|
|
|
2848
2963
|
// src/components/ui/mismatch-variable-alert.tsx
|
|
2849
2964
|
var React27 = __toESM(require("react"));
|
|
2850
2965
|
var import_ui27 = require("@elementor/ui");
|
|
2851
|
-
var
|
|
2966
|
+
var import_i18n19 = require("@wordpress/i18n");
|
|
2852
2967
|
var i18n = {
|
|
2853
|
-
title: (0,
|
|
2854
|
-
message: (0,
|
|
2968
|
+
title: (0, import_i18n19.__)("Variable has changed", "elementor"),
|
|
2969
|
+
message: (0, import_i18n19.__)(
|
|
2855
2970
|
`This variable is no longer compatible with this property. You can clear it or select a different one.`,
|
|
2856
2971
|
"elementor"
|
|
2857
2972
|
),
|
|
2858
2973
|
buttons: {
|
|
2859
|
-
clear: (0,
|
|
2860
|
-
select: (0,
|
|
2974
|
+
clear: (0, import_i18n19.__)("Clear", "elementor"),
|
|
2975
|
+
select: (0, import_i18n19.__)("Select variable", "elementor")
|
|
2861
2976
|
}
|
|
2862
2977
|
};
|
|
2863
2978
|
var MismatchVariableAlert = ({ onClose, onClear, triggerSelect }) => {
|
|
@@ -2878,13 +2993,13 @@ var MismatchVariableAlert = ({ onClose, onClear, triggerSelect }) => {
|
|
|
2878
2993
|
// src/components/ui/variable/mismatch-variable.tsx
|
|
2879
2994
|
var MismatchVariable = ({ variable }) => {
|
|
2880
2995
|
const { setValue, value } = (0, import_editor_controls9.useBoundProp)();
|
|
2881
|
-
const anchorRef = (0,
|
|
2882
|
-
const popupId = (0,
|
|
2996
|
+
const anchorRef = (0, import_react21.useRef)(null);
|
|
2997
|
+
const popupId = (0, import_react21.useId)();
|
|
2883
2998
|
const popupState = (0, import_ui28.usePopupState)({
|
|
2884
2999
|
variant: "popover",
|
|
2885
3000
|
popupId: `elementor-variables-list-${popupId}`
|
|
2886
3001
|
});
|
|
2887
|
-
const [infotipVisible, setInfotipVisible] = (0,
|
|
3002
|
+
const [infotipVisible, setInfotipVisible] = (0, import_react21.useState)(false);
|
|
2888
3003
|
const toggleInfotip = () => setInfotipVisible((prev) => !prev);
|
|
2889
3004
|
const closeInfotip = () => setInfotipVisible(false);
|
|
2890
3005
|
const triggerSelect = () => {
|
|
@@ -2929,7 +3044,7 @@ var MismatchVariable = ({ variable }) => {
|
|
|
2929
3044
|
{
|
|
2930
3045
|
label: variable.label,
|
|
2931
3046
|
onClick: toggleInfotip,
|
|
2932
|
-
suffix: (0,
|
|
3047
|
+
suffix: (0, import_i18n20.__)("changed", "elementor")
|
|
2933
3048
|
}
|
|
2934
3049
|
)
|
|
2935
3050
|
), /* @__PURE__ */ React28.createElement(
|
|
@@ -2957,15 +3072,15 @@ var MismatchVariable = ({ variable }) => {
|
|
|
2957
3072
|
|
|
2958
3073
|
// src/components/ui/variable/missing-variable.tsx
|
|
2959
3074
|
var React30 = __toESM(require("react"));
|
|
2960
|
-
var
|
|
3075
|
+
var import_react22 = require("react");
|
|
2961
3076
|
var import_editor_controls10 = require("@elementor/editor-controls");
|
|
2962
3077
|
var import_ui30 = require("@elementor/ui");
|
|
2963
|
-
var
|
|
3078
|
+
var import_i18n22 = require("@wordpress/i18n");
|
|
2964
3079
|
|
|
2965
3080
|
// src/components/ui/missing-variable-alert.tsx
|
|
2966
3081
|
var React29 = __toESM(require("react"));
|
|
2967
3082
|
var import_ui29 = require("@elementor/ui");
|
|
2968
|
-
var
|
|
3083
|
+
var import_i18n21 = require("@wordpress/i18n");
|
|
2969
3084
|
var MissingVariableAlert = ({ onClose, onClear }) => {
|
|
2970
3085
|
return /* @__PURE__ */ React29.createElement(import_ui29.ClickAwayListener, { onClickAway: onClose }, /* @__PURE__ */ React29.createElement(
|
|
2971
3086
|
import_ui29.Alert,
|
|
@@ -2973,11 +3088,11 @@ var MissingVariableAlert = ({ onClose, onClear }) => {
|
|
|
2973
3088
|
variant: "standard",
|
|
2974
3089
|
severity: "warning",
|
|
2975
3090
|
onClose,
|
|
2976
|
-
action: /* @__PURE__ */ React29.createElement(React29.Fragment, null, onClear && /* @__PURE__ */ React29.createElement(import_ui29.AlertAction, { variant: "contained", onClick: onClear }, (0,
|
|
3091
|
+
action: /* @__PURE__ */ React29.createElement(React29.Fragment, null, onClear && /* @__PURE__ */ React29.createElement(import_ui29.AlertAction, { variant: "contained", onClick: onClear }, (0, import_i18n21.__)("Clear", "elementor"))),
|
|
2977
3092
|
sx: { maxWidth: 300 }
|
|
2978
3093
|
},
|
|
2979
|
-
/* @__PURE__ */ React29.createElement(import_ui29.AlertTitle, null, (0,
|
|
2980
|
-
/* @__PURE__ */ React29.createElement(import_ui29.Typography, { variant: "body2", color: "textPrimary" }, (0,
|
|
3094
|
+
/* @__PURE__ */ React29.createElement(import_ui29.AlertTitle, null, (0, import_i18n21.__)("This variable is missing", "elementor")),
|
|
3095
|
+
/* @__PURE__ */ React29.createElement(import_ui29.Typography, { variant: "body2", color: "textPrimary" }, (0, import_i18n21.__)(
|
|
2981
3096
|
"It may have been deleted. Try clearing this field and select a different value or variable.",
|
|
2982
3097
|
"elementor"
|
|
2983
3098
|
))
|
|
@@ -2987,7 +3102,7 @@ var MissingVariableAlert = ({ onClose, onClear }) => {
|
|
|
2987
3102
|
// src/components/ui/variable/missing-variable.tsx
|
|
2988
3103
|
var MissingVariable = () => {
|
|
2989
3104
|
const { setValue } = (0, import_editor_controls10.useBoundProp)();
|
|
2990
|
-
const [infotipVisible, setInfotipVisible] = (0,
|
|
3105
|
+
const [infotipVisible, setInfotipVisible] = (0, import_react22.useState)(false);
|
|
2991
3106
|
const toggleInfotip = () => setInfotipVisible((prev) => !prev);
|
|
2992
3107
|
const closeInfotip = () => setInfotipVisible(false);
|
|
2993
3108
|
const clearValue = () => setValue(null);
|
|
@@ -3011,7 +3126,7 @@ var MissingVariable = () => {
|
|
|
3011
3126
|
}
|
|
3012
3127
|
}
|
|
3013
3128
|
},
|
|
3014
|
-
/* @__PURE__ */ React30.createElement(WarningVariableTag, { label: (0,
|
|
3129
|
+
/* @__PURE__ */ React30.createElement(WarningVariableTag, { label: (0, import_i18n22.__)("Missing variable", "elementor"), onClick: toggleInfotip })
|
|
3015
3130
|
));
|
|
3016
3131
|
};
|
|
3017
3132
|
|
|
@@ -3038,14 +3153,14 @@ var VariableControl = () => {
|
|
|
3038
3153
|
var React32 = __toESM(require("react"));
|
|
3039
3154
|
var import_editor_editing_panel6 = require("@elementor/editor-editing-panel");
|
|
3040
3155
|
var import_icons14 = require("@elementor/icons");
|
|
3041
|
-
var
|
|
3156
|
+
var import_i18n23 = require("@wordpress/i18n");
|
|
3042
3157
|
var usePropVariableAction = () => {
|
|
3043
3158
|
const { propType, path } = (0, import_editor_editing_panel6.useBoundProp)();
|
|
3044
3159
|
const variable = resolveVariableFromPropType(propType);
|
|
3045
3160
|
return {
|
|
3046
3161
|
visible: Boolean(variable),
|
|
3047
3162
|
icon: import_icons14.ColorFilterIcon,
|
|
3048
|
-
title: (0,
|
|
3163
|
+
title: (0, import_i18n23.__)("Variables", "elementor"),
|
|
3049
3164
|
content: ({ close: closePopover }) => {
|
|
3050
3165
|
if (!variable) {
|
|
3051
3166
|
return null;
|
|
@@ -3334,12 +3449,12 @@ var import_icons16 = require("@elementor/icons");
|
|
|
3334
3449
|
|
|
3335
3450
|
// src/components/fields/color-field.tsx
|
|
3336
3451
|
var React33 = __toESM(require("react"));
|
|
3337
|
-
var
|
|
3452
|
+
var import_react23 = require("react");
|
|
3338
3453
|
var import_ui31 = require("@elementor/ui");
|
|
3339
3454
|
var ColorField = ({ value, onChange, onValidationChange }) => {
|
|
3340
|
-
const [color, setColor] = (0,
|
|
3341
|
-
const [errorMessage, setErrorMessage] = (0,
|
|
3342
|
-
const defaultRef = (0,
|
|
3455
|
+
const [color, setColor] = (0, import_react23.useState)(value);
|
|
3456
|
+
const [errorMessage, setErrorMessage] = (0, import_react23.useState)("");
|
|
3457
|
+
const defaultRef = (0, import_react23.useRef)(null);
|
|
3343
3458
|
const anchorRef = usePopoverContentRef() ?? defaultRef.current;
|
|
3344
3459
|
const handleChange = (newValue) => {
|
|
3345
3460
|
setColor(newValue);
|
|
@@ -3378,15 +3493,15 @@ var ColorField = ({ value, onChange, onValidationChange }) => {
|
|
|
3378
3493
|
|
|
3379
3494
|
// src/components/fields/font-field.tsx
|
|
3380
3495
|
var React34 = __toESM(require("react"));
|
|
3381
|
-
var
|
|
3496
|
+
var import_react24 = require("react");
|
|
3382
3497
|
var import_editor_controls12 = require("@elementor/editor-controls");
|
|
3383
3498
|
var import_editor_editing_panel7 = require("@elementor/editor-editing-panel");
|
|
3384
3499
|
var import_icons15 = require("@elementor/icons");
|
|
3385
3500
|
var import_ui32 = require("@elementor/ui");
|
|
3386
|
-
var
|
|
3501
|
+
var import_i18n24 = require("@wordpress/i18n");
|
|
3387
3502
|
var FontField = ({ value, onChange, onValidationChange }) => {
|
|
3388
|
-
const [fontFamily, setFontFamily] = (0,
|
|
3389
|
-
const defaultRef = (0,
|
|
3503
|
+
const [fontFamily, setFontFamily] = (0, import_react24.useState)(value);
|
|
3504
|
+
const defaultRef = (0, import_react24.useRef)(null);
|
|
3390
3505
|
const anchorRef = usePopoverContentRef() ?? defaultRef.current;
|
|
3391
3506
|
const fontPopoverState = (0, import_ui32.usePopupState)({ variant: "popover" });
|
|
3392
3507
|
const fontFamilies = (0, import_editor_editing_panel7.useFontFamilies)();
|
|
@@ -3407,7 +3522,7 @@ var FontField = ({ value, onChange, onValidationChange }) => {
|
|
|
3407
3522
|
handleChange(newFontFamily);
|
|
3408
3523
|
fontPopoverState.close();
|
|
3409
3524
|
};
|
|
3410
|
-
const id2 = (0,
|
|
3525
|
+
const id2 = (0, import_react24.useId)();
|
|
3411
3526
|
return /* @__PURE__ */ React34.createElement(React34.Fragment, null, /* @__PURE__ */ React34.createElement(
|
|
3412
3527
|
import_ui32.UnstableTag,
|
|
3413
3528
|
{
|
|
@@ -3437,7 +3552,7 @@ var FontField = ({ value, onChange, onValidationChange }) => {
|
|
|
3437
3552
|
onItemChange: handleFontFamilyChange,
|
|
3438
3553
|
onClose: fontPopoverState.close,
|
|
3439
3554
|
sectionWidth,
|
|
3440
|
-
title: (0,
|
|
3555
|
+
title: (0, import_i18n24.__)("Font Family", "elementor"),
|
|
3441
3556
|
itemStyle: (item) => ({ fontFamily: item.value }),
|
|
3442
3557
|
onDebounce: import_editor_controls12.enqueueFont,
|
|
3443
3558
|
icon: import_icons15.TextIcon
|
|
@@ -3469,7 +3584,7 @@ function registerVariableTypes() {
|
|
|
3469
3584
|
|
|
3470
3585
|
// src/renderers/style-variables-renderer.tsx
|
|
3471
3586
|
var React36 = __toESM(require("react"));
|
|
3472
|
-
var
|
|
3587
|
+
var import_react25 = require("react");
|
|
3473
3588
|
var import_editor_v1_adapters3 = require("@elementor/editor-v1-adapters");
|
|
3474
3589
|
var import_ui33 = require("@elementor/ui");
|
|
3475
3590
|
|
|
@@ -3496,8 +3611,8 @@ function usePortalContainer() {
|
|
|
3496
3611
|
return (0, import_editor_v1_adapters3.__privateUseListenTo)((0, import_editor_v1_adapters3.commandEndEvent)("editor/documents/attach-preview"), () => getCanvasIframeDocument()?.head);
|
|
3497
3612
|
}
|
|
3498
3613
|
function useStyleVariables() {
|
|
3499
|
-
const [variables, setVariables] = (0,
|
|
3500
|
-
(0,
|
|
3614
|
+
const [variables, setVariables] = (0, import_react25.useState)({});
|
|
3615
|
+
(0, import_react25.useEffect)(() => {
|
|
3501
3616
|
const unsubscribe = styleVariablesRepository.subscribe(setVariables);
|
|
3502
3617
|
return () => {
|
|
3503
3618
|
unsubscribe();
|