@elementor/editor-variables 0.16.0 → 0.18.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +50 -0
- package/dist/index.js +392 -136
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +400 -144
- package/dist/index.mjs.map +1 -1
- package/package.json +7 -7
- package/src/components/color-variable-creation.tsx +30 -10
- package/src/components/color-variable-edit.tsx +29 -10
- package/src/components/color-variables-selection.tsx +32 -34
- package/src/components/font-variable-creation.tsx +30 -10
- package/src/components/font-variable-edit.tsx +29 -10
- package/src/components/font-variables-selection.tsx +32 -34
- package/src/components/ui/delete-confirmation-dialog.tsx +4 -7
- package/src/components/ui/deleted-variable-alert.tsx +47 -0
- package/src/components/ui/tags/assigned-tag.tsx +21 -19
- package/src/components/ui/tags/deleted-tag.tsx +29 -18
- package/src/components/ui/variable/deleted-variable.tsx +63 -7
- package/src/controls/color-variable-control.tsx +7 -1
- package/src/controls/font-variable-control.tsx +7 -1
- package/src/create-style-variables-repository.ts +44 -5
- package/src/hooks/use-prop-variables.ts +6 -0
- package/src/renderers/style-variables-renderer.tsx +10 -4
- package/src/service.ts +23 -2
- package/src/sync/enqueue-font.ts +7 -0
- package/src/sync/types.ts +5 -0
- package/src/transformers/variable-transformer.ts +21 -3
- package/src/types.ts +1 -1
- package/src/utils/validations.ts +5 -5
package/dist/index.js
CHANGED
|
@@ -39,11 +39,11 @@ var import_editor = require("@elementor/editor");
|
|
|
39
39
|
|
|
40
40
|
// src/init-color-variables.ts
|
|
41
41
|
var import_editor_canvas2 = require("@elementor/editor-canvas");
|
|
42
|
-
var
|
|
42
|
+
var import_editor_editing_panel10 = require("@elementor/editor-editing-panel");
|
|
43
43
|
|
|
44
44
|
// src/controls/color-variable-control.tsx
|
|
45
|
-
var
|
|
46
|
-
var
|
|
45
|
+
var React20 = __toESM(require("react"));
|
|
46
|
+
var import_editor_controls10 = require("@elementor/editor-controls");
|
|
47
47
|
var import_editor_props3 = require("@elementor/editor-props");
|
|
48
48
|
|
|
49
49
|
// src/components/ui/color-indicator.tsx
|
|
@@ -83,11 +83,14 @@ var import_editor_editing_panel = require("@elementor/editor-editing-panel");
|
|
|
83
83
|
var import_editor_ui = require("@elementor/editor-ui");
|
|
84
84
|
var import_icons = require("@elementor/icons");
|
|
85
85
|
var import_ui4 = require("@elementor/ui");
|
|
86
|
-
var
|
|
86
|
+
var import_i18n5 = require("@wordpress/i18n");
|
|
87
87
|
|
|
88
88
|
// src/hooks/use-prop-variables.ts
|
|
89
89
|
var import_react = require("react");
|
|
90
90
|
|
|
91
|
+
// src/service.ts
|
|
92
|
+
var import_i18n = require("@wordpress/i18n");
|
|
93
|
+
|
|
91
94
|
// src/api.ts
|
|
92
95
|
var import_http_client = require("@elementor/http-client");
|
|
93
96
|
var BASE_PATH = "elementor/v1/variables";
|
|
@@ -170,6 +173,12 @@ var Storage = class {
|
|
|
170
173
|
}
|
|
171
174
|
};
|
|
172
175
|
|
|
176
|
+
// src/sync/enqueue-font.ts
|
|
177
|
+
var enqueueFont = (fontFamily, context = "preview") => {
|
|
178
|
+
const extendedWindow = window;
|
|
179
|
+
return extendedWindow.elementor?.helpers?.enqueueFont?.(fontFamily, context) ?? null;
|
|
180
|
+
};
|
|
181
|
+
|
|
173
182
|
// src/create-style-variables-repository.ts
|
|
174
183
|
var createStyleVariablesRepository = () => {
|
|
175
184
|
const variables = {};
|
|
@@ -186,19 +195,46 @@ var createStyleVariablesRepository = () => {
|
|
|
186
195
|
subscription({ ...variables });
|
|
187
196
|
}
|
|
188
197
|
};
|
|
189
|
-
const shouldUpdate = (key,
|
|
190
|
-
|
|
198
|
+
const shouldUpdate = (key, maybeUpdated) => {
|
|
199
|
+
if (!(key in variables)) {
|
|
200
|
+
return true;
|
|
201
|
+
}
|
|
202
|
+
if (variables[key].label !== maybeUpdated.label) {
|
|
203
|
+
return true;
|
|
204
|
+
}
|
|
205
|
+
if (variables[key].value !== maybeUpdated.value) {
|
|
206
|
+
return true;
|
|
207
|
+
}
|
|
208
|
+
if (!variables[key]?.deleted && maybeUpdated?.deleted) {
|
|
209
|
+
return true;
|
|
210
|
+
}
|
|
211
|
+
if (variables[key]?.deleted && !maybeUpdated?.deleted) {
|
|
212
|
+
return true;
|
|
213
|
+
}
|
|
214
|
+
return false;
|
|
191
215
|
};
|
|
192
216
|
const applyUpdates = (updatedVars) => {
|
|
193
217
|
let hasChanges = false;
|
|
194
|
-
for (const [key,
|
|
195
|
-
if (shouldUpdate(key,
|
|
196
|
-
variables[key] =
|
|
218
|
+
for (const [key, variable] of Object.entries(updatedVars)) {
|
|
219
|
+
if (shouldUpdate(key, variable)) {
|
|
220
|
+
variables[key] = variable;
|
|
221
|
+
if (variable.type === fontVariablePropTypeUtil.key) {
|
|
222
|
+
fontEnqueue(variable.value);
|
|
223
|
+
}
|
|
197
224
|
hasChanges = true;
|
|
198
225
|
}
|
|
199
226
|
}
|
|
200
227
|
return hasChanges;
|
|
201
228
|
};
|
|
229
|
+
const fontEnqueue = (value) => {
|
|
230
|
+
if (!value) {
|
|
231
|
+
return;
|
|
232
|
+
}
|
|
233
|
+
try {
|
|
234
|
+
enqueueFont(value);
|
|
235
|
+
} catch {
|
|
236
|
+
}
|
|
237
|
+
};
|
|
202
238
|
const update = (updatedVars) => {
|
|
203
239
|
if (applyUpdates(updatedVars)) {
|
|
204
240
|
notify();
|
|
@@ -240,7 +276,8 @@ var service = {
|
|
|
240
276
|
return apiClient.create(type, label, value).then((response) => {
|
|
241
277
|
const { success, data: payload } = response.data;
|
|
242
278
|
if (!success) {
|
|
243
|
-
|
|
279
|
+
const errorMessage = payload?.message || (0, import_i18n.__)("Unexpected response from server", "elementor");
|
|
280
|
+
throw new Error(errorMessage);
|
|
244
281
|
}
|
|
245
282
|
return payload;
|
|
246
283
|
}).then((data) => {
|
|
@@ -255,13 +292,17 @@ var service = {
|
|
|
255
292
|
id: variableId,
|
|
256
293
|
variable: createdVariable
|
|
257
294
|
};
|
|
295
|
+
}).catch((error) => {
|
|
296
|
+
const message = getErrorMessage(error.response);
|
|
297
|
+
throw message ? new Error(message) : error;
|
|
258
298
|
});
|
|
259
299
|
},
|
|
260
300
|
update: (id, { label, value }) => {
|
|
261
301
|
return apiClient.update(id, label, value).then((response) => {
|
|
262
302
|
const { success, data: payload } = response.data;
|
|
263
303
|
if (!success) {
|
|
264
|
-
|
|
304
|
+
const errorMessage = payload?.message || (0, import_i18n.__)("Unexpected response from server", "elementor");
|
|
305
|
+
throw new Error(errorMessage);
|
|
265
306
|
}
|
|
266
307
|
return payload;
|
|
267
308
|
}).then((data) => {
|
|
@@ -276,6 +317,9 @@ var service = {
|
|
|
276
317
|
id: variableId,
|
|
277
318
|
variable: updatedVariable
|
|
278
319
|
};
|
|
320
|
+
}).catch((error) => {
|
|
321
|
+
const message = getErrorMessage(error.response);
|
|
322
|
+
throw message ? new Error(message) : error;
|
|
279
323
|
});
|
|
280
324
|
},
|
|
281
325
|
delete: (id) => {
|
|
@@ -327,6 +371,12 @@ var handleWatermark = (operation, newWatermark) => {
|
|
|
327
371
|
}
|
|
328
372
|
storage.watermark(newWatermark);
|
|
329
373
|
};
|
|
374
|
+
var getErrorMessage = (response) => {
|
|
375
|
+
if (response?.data?.code === "duplicated_label") {
|
|
376
|
+
return (0, import_i18n.__)("This variable name already exists. Please choose a unique name.", "elementor");
|
|
377
|
+
}
|
|
378
|
+
return (0, import_i18n.__)("There was a glitch. Try saving your variable again.", "elementor");
|
|
379
|
+
};
|
|
330
380
|
|
|
331
381
|
// src/hooks/use-prop-variables.ts
|
|
332
382
|
var useVariable = (key) => {
|
|
@@ -377,43 +427,48 @@ var deleteVariable = (deleteId) => {
|
|
|
377
427
|
return id;
|
|
378
428
|
});
|
|
379
429
|
};
|
|
430
|
+
var restoreVariable = (restoreId) => {
|
|
431
|
+
return service.restore(restoreId).then(({ id }) => {
|
|
432
|
+
return id;
|
|
433
|
+
});
|
|
434
|
+
};
|
|
380
435
|
|
|
381
436
|
// src/components/fields/color-field.tsx
|
|
382
437
|
var React = __toESM(require("react"));
|
|
383
438
|
var import_react3 = require("react");
|
|
384
439
|
var import_ui2 = require("@elementor/ui");
|
|
385
|
-
var
|
|
440
|
+
var import_i18n3 = require("@wordpress/i18n");
|
|
386
441
|
|
|
387
442
|
// src/utils/validations.ts
|
|
388
|
-
var
|
|
443
|
+
var import_i18n2 = require("@wordpress/i18n");
|
|
389
444
|
var VARIABLE_LABEL_MAX_LENGTH = 50;
|
|
390
445
|
var validateLabel = (name) => {
|
|
391
446
|
if (!name.trim()) {
|
|
392
|
-
return (0,
|
|
447
|
+
return (0, import_i18n2.__)("Give your variable a name.", "elementor");
|
|
393
448
|
}
|
|
394
449
|
const allowedChars = /^[a-zA-Z0-9_-]+$/;
|
|
395
450
|
if (!allowedChars.test(name)) {
|
|
396
|
-
return (0,
|
|
451
|
+
return (0, import_i18n2.__)("Use letters, numbers, dashes (-), or underscores (_) for the name.", "elementor");
|
|
397
452
|
}
|
|
398
453
|
const hasAlphanumeric = /[a-zA-Z0-9]/;
|
|
399
454
|
if (!hasAlphanumeric.test(name)) {
|
|
400
|
-
return (0,
|
|
455
|
+
return (0, import_i18n2.__)("Names have to include at least one non-special character.", "elementor");
|
|
401
456
|
}
|
|
402
457
|
if (VARIABLE_LABEL_MAX_LENGTH < name.length) {
|
|
403
|
-
return (0,
|
|
458
|
+
return (0, import_i18n2.__)("Keep names up to 50 characters.", "elementor");
|
|
404
459
|
}
|
|
405
460
|
return "";
|
|
406
461
|
};
|
|
407
462
|
var labelHint = (name) => {
|
|
408
463
|
const hintThreshold = VARIABLE_LABEL_MAX_LENGTH * 0.8 - 1;
|
|
409
464
|
if (hintThreshold < name.length) {
|
|
410
|
-
return (0,
|
|
465
|
+
return (0, import_i18n2.__)("Keep names up to 50 characters.", "elementor");
|
|
411
466
|
}
|
|
412
467
|
return "";
|
|
413
468
|
};
|
|
414
469
|
var validateValue = (value) => {
|
|
415
470
|
if (!value.trim()) {
|
|
416
|
-
return (0,
|
|
471
|
+
return (0, import_i18n2.__)("Add a value to complete your variable.", "elementor");
|
|
417
472
|
}
|
|
418
473
|
return "";
|
|
419
474
|
};
|
|
@@ -437,7 +492,7 @@ var ColorField = ({ value, onChange }) => {
|
|
|
437
492
|
setErrorMessage(errorMsg);
|
|
438
493
|
onChange(errorMsg ? "" : newValue);
|
|
439
494
|
};
|
|
440
|
-
return /* @__PURE__ */ React.createElement(import_ui2.Grid, { container: true, gap: 0.75, alignItems: "center" }, /* @__PURE__ */ React.createElement(import_ui2.Grid, { item: true, xs: 12 }, /* @__PURE__ */ React.createElement(import_ui2.FormLabel, { size: "tiny" }, (0,
|
|
495
|
+
return /* @__PURE__ */ React.createElement(import_ui2.Grid, { container: true, gap: 0.75, alignItems: "center" }, /* @__PURE__ */ React.createElement(import_ui2.Grid, { item: true, xs: 12 }, /* @__PURE__ */ React.createElement(import_ui2.FormLabel, { size: "tiny" }, (0, import_i18n3.__)("Value", "elementor"))), /* @__PURE__ */ React.createElement(import_ui2.Grid, { item: true, xs: 12 }, /* @__PURE__ */ React.createElement(
|
|
441
496
|
import_ui2.UnstableColorField,
|
|
442
497
|
{
|
|
443
498
|
size: "tiny",
|
|
@@ -460,7 +515,7 @@ var ColorField = ({ value, onChange }) => {
|
|
|
460
515
|
var React2 = __toESM(require("react"));
|
|
461
516
|
var import_react4 = require("react");
|
|
462
517
|
var import_ui3 = require("@elementor/ui");
|
|
463
|
-
var
|
|
518
|
+
var import_i18n4 = require("@wordpress/i18n");
|
|
464
519
|
var LabelField = ({ value, onChange }) => {
|
|
465
520
|
const [label, setLabel] = (0, import_react4.useState)(value);
|
|
466
521
|
const [errorMessage, setErrorMessage] = (0, import_react4.useState)("");
|
|
@@ -474,7 +529,7 @@ var LabelField = ({ value, onChange }) => {
|
|
|
474
529
|
onChange(errorMsg ? "" : newValue);
|
|
475
530
|
};
|
|
476
531
|
const id = (0, import_react4.useId)();
|
|
477
|
-
return /* @__PURE__ */ React2.createElement(import_ui3.Grid, { container: true, gap: 0.75, alignItems: "center" }, /* @__PURE__ */ React2.createElement(import_ui3.Grid, { item: true, xs: 12 }, /* @__PURE__ */ React2.createElement(import_ui3.FormLabel, { htmlFor: id, size: "tiny" }, (0,
|
|
532
|
+
return /* @__PURE__ */ React2.createElement(import_ui3.Grid, { container: true, gap: 0.75, alignItems: "center" }, /* @__PURE__ */ React2.createElement(import_ui3.Grid, { item: true, xs: 12 }, /* @__PURE__ */ React2.createElement(import_ui3.FormLabel, { htmlFor: id, size: "tiny" }, (0, import_i18n4.__)("Name", "elementor"))), /* @__PURE__ */ React2.createElement(import_ui3.Grid, { item: true, xs: 12 }, /* @__PURE__ */ React2.createElement(
|
|
478
533
|
import_ui3.TextField,
|
|
479
534
|
{
|
|
480
535
|
id,
|
|
@@ -494,9 +549,11 @@ var ColorVariableCreation = ({ onGoBack, onClose }) => {
|
|
|
494
549
|
const { setValue: setVariable } = (0, import_editor_controls.useBoundProp)(colorVariablePropTypeUtil);
|
|
495
550
|
const [color, setColor] = (0, import_react5.useState)("");
|
|
496
551
|
const [label, setLabel] = (0, import_react5.useState)("");
|
|
552
|
+
const [errorMessage, setErrorMessage] = (0, import_react5.useState)("");
|
|
497
553
|
const resetFields = () => {
|
|
498
554
|
setColor("");
|
|
499
555
|
setLabel("");
|
|
556
|
+
setErrorMessage("");
|
|
500
557
|
};
|
|
501
558
|
const closePopover = () => {
|
|
502
559
|
resetFields();
|
|
@@ -510,20 +567,40 @@ var ColorVariableCreation = ({ onGoBack, onClose }) => {
|
|
|
510
567
|
}).then((key) => {
|
|
511
568
|
setVariable(key);
|
|
512
569
|
closePopover();
|
|
570
|
+
}).catch((error) => {
|
|
571
|
+
setErrorMessage(error.message);
|
|
513
572
|
});
|
|
514
573
|
};
|
|
515
574
|
const hasEmptyValue = () => {
|
|
516
575
|
return "" === color.trim() || "" === label.trim();
|
|
517
576
|
};
|
|
518
577
|
const isSubmitDisabled = hasEmptyValue();
|
|
519
|
-
return /* @__PURE__ */ React3.createElement(import_editor_editing_panel.
|
|
578
|
+
return /* @__PURE__ */ React3.createElement(import_editor_editing_panel.PopoverBody, { height: "auto" }, /* @__PURE__ */ React3.createElement(
|
|
520
579
|
import_editor_ui.PopoverHeader,
|
|
521
580
|
{
|
|
522
|
-
icon: /* @__PURE__ */ React3.createElement(React3.Fragment, null, onGoBack && /* @__PURE__ */ React3.createElement(import_ui4.IconButton, { size: SIZE, "aria-label": (0,
|
|
523
|
-
title: (0,
|
|
581
|
+
icon: /* @__PURE__ */ React3.createElement(React3.Fragment, null, onGoBack && /* @__PURE__ */ React3.createElement(import_ui4.IconButton, { size: SIZE, "aria-label": (0, import_i18n5.__)("Go Back", "elementor"), onClick: onGoBack }, /* @__PURE__ */ React3.createElement(import_icons.ArrowLeftIcon, { fontSize: SIZE })), /* @__PURE__ */ React3.createElement(import_icons.BrushIcon, { fontSize: SIZE })),
|
|
582
|
+
title: (0, import_i18n5.__)("Create variable", "elementor"),
|
|
524
583
|
onClose: closePopover
|
|
525
584
|
}
|
|
526
|
-
), /* @__PURE__ */ React3.createElement(import_ui4.Divider, null), /* @__PURE__ */ React3.createElement(import_editor_controls.PopoverContent, { p: 2 }, /* @__PURE__ */ React3.createElement(
|
|
585
|
+
), /* @__PURE__ */ React3.createElement(import_ui4.Divider, null), /* @__PURE__ */ React3.createElement(import_editor_controls.PopoverContent, { p: 2 }, /* @__PURE__ */ React3.createElement(
|
|
586
|
+
LabelField,
|
|
587
|
+
{
|
|
588
|
+
value: label,
|
|
589
|
+
onChange: (value) => {
|
|
590
|
+
setLabel(value);
|
|
591
|
+
setErrorMessage("");
|
|
592
|
+
}
|
|
593
|
+
}
|
|
594
|
+
), /* @__PURE__ */ React3.createElement(
|
|
595
|
+
ColorField,
|
|
596
|
+
{
|
|
597
|
+
value: color,
|
|
598
|
+
onChange: (value) => {
|
|
599
|
+
setColor(value);
|
|
600
|
+
setErrorMessage("");
|
|
601
|
+
}
|
|
602
|
+
}
|
|
603
|
+
), errorMessage && /* @__PURE__ */ React3.createElement(import_ui4.FormHelperText, { error: true }, errorMessage)), /* @__PURE__ */ React3.createElement(import_ui4.CardActions, { sx: { pt: 0.5, pb: 1 } }, /* @__PURE__ */ React3.createElement(import_ui4.Button, { size: "small", variant: "contained", disabled: isSubmitDisabled, onClick: handleCreate }, (0, import_i18n5.__)("Create", "elementor"))));
|
|
527
604
|
};
|
|
528
605
|
|
|
529
606
|
// src/components/color-variable-edit.tsx
|
|
@@ -534,13 +611,13 @@ var import_editor_editing_panel2 = require("@elementor/editor-editing-panel");
|
|
|
534
611
|
var import_editor_ui2 = require("@elementor/editor-ui");
|
|
535
612
|
var import_icons3 = require("@elementor/icons");
|
|
536
613
|
var import_ui6 = require("@elementor/ui");
|
|
537
|
-
var
|
|
614
|
+
var import_i18n7 = require("@wordpress/i18n");
|
|
538
615
|
|
|
539
616
|
// src/components/ui/delete-confirmation-dialog.tsx
|
|
540
617
|
var React4 = __toESM(require("react"));
|
|
541
618
|
var import_icons2 = require("@elementor/icons");
|
|
542
619
|
var import_ui5 = require("@elementor/ui");
|
|
543
|
-
var
|
|
620
|
+
var import_i18n6 = require("@wordpress/i18n");
|
|
544
621
|
var TITLE_ID = "delete-variable-dialog";
|
|
545
622
|
var DeleteConfirmationDialog = ({
|
|
546
623
|
open,
|
|
@@ -548,10 +625,7 @@ var DeleteConfirmationDialog = ({
|
|
|
548
625
|
closeDialog,
|
|
549
626
|
onConfirm
|
|
550
627
|
}) => {
|
|
551
|
-
return /* @__PURE__ */ React4.createElement(import_ui5.Dialog, { open, onClose: closeDialog, "aria-labelledby": TITLE_ID, maxWidth: "xs" }, /* @__PURE__ */ React4.createElement(import_ui5.DialogTitle, { id: TITLE_ID, display: "flex", alignItems: "center", gap: 1, sx: { lineHeight: 1 } }, /* @__PURE__ */ React4.createElement(import_icons2.AlertOctagonFilledIcon, { color: "error" }), (0,
|
|
552
|
-
"Variable. Note that its value is still being used anywhere on your site where it was connected to the variable.",
|
|
553
|
-
"elementor"
|
|
554
|
-
))), /* @__PURE__ */ React4.createElement(import_ui5.DialogActions, null, /* @__PURE__ */ React4.createElement(import_ui5.Button, { color: "secondary", onClick: closeDialog }, (0, import_i18n5.__)("Cancel", "elementor")), /* @__PURE__ */ React4.createElement(import_ui5.Button, { variant: "contained", color: "error", onClick: onConfirm }, (0, import_i18n5.__)("Delete", "elementor"))));
|
|
628
|
+
return /* @__PURE__ */ React4.createElement(import_ui5.Dialog, { open, onClose: closeDialog, "aria-labelledby": TITLE_ID, maxWidth: "xs" }, /* @__PURE__ */ React4.createElement(import_ui5.DialogTitle, { id: TITLE_ID, display: "flex", alignItems: "center", gap: 1, sx: { lineHeight: 1 } }, /* @__PURE__ */ React4.createElement(import_icons2.AlertOctagonFilledIcon, { color: "error" }), (0, import_i18n6.__)("Delete this variable?", "elementor")), /* @__PURE__ */ React4.createElement(import_ui5.DialogContent, null, /* @__PURE__ */ React4.createElement(import_ui5.DialogContentText, { variant: "body2", color: "textPrimary" }, (0, import_i18n6.__)("All elements using", "elementor"), /* @__PURE__ */ React4.createElement(import_ui5.Typography, { variant: "subtitle2", component: "span" }, "\xA0", label, "\xA0"), (0, import_i18n6.__)("will keep their current values, but the variable itself will be removed.", "elementor"))), /* @__PURE__ */ React4.createElement(import_ui5.DialogActions, null, /* @__PURE__ */ React4.createElement(import_ui5.Button, { color: "secondary", onClick: closeDialog }, (0, import_i18n6.__)("Not now", "elementor")), /* @__PURE__ */ React4.createElement(import_ui5.Button, { variant: "contained", color: "error", onClick: onConfirm }, (0, import_i18n6.__)("Delete", "elementor"))));
|
|
555
629
|
};
|
|
556
630
|
|
|
557
631
|
// src/components/color-variable-edit.tsx
|
|
@@ -559,6 +633,7 @@ var SIZE2 = "tiny";
|
|
|
559
633
|
var ColorVariableEdit = ({ onClose, onGoBack, onSubmit, editId }) => {
|
|
560
634
|
const { setValue: notifyBoundPropChange, value: assignedValue } = (0, import_editor_controls2.useBoundProp)(colorVariablePropTypeUtil);
|
|
561
635
|
const [deleteConfirmation, setDeleteConfirmation] = (0, import_react6.useState)(false);
|
|
636
|
+
const [errorMessage, setErrorMessage] = (0, import_react6.useState)("");
|
|
562
637
|
const variable = useVariable(editId);
|
|
563
638
|
if (!variable) {
|
|
564
639
|
throw new Error(`Global color variable not found`);
|
|
@@ -572,6 +647,8 @@ var ColorVariableEdit = ({ onClose, onGoBack, onSubmit, editId }) => {
|
|
|
572
647
|
}).then(() => {
|
|
573
648
|
maybeTriggerBoundPropChange();
|
|
574
649
|
onSubmit?.();
|
|
650
|
+
}).catch((error) => {
|
|
651
|
+
setErrorMessage(error.message);
|
|
575
652
|
});
|
|
576
653
|
};
|
|
577
654
|
const handleDelete = () => {
|
|
@@ -598,7 +675,7 @@ var ColorVariableEdit = ({ onClose, onGoBack, onSubmit, editId }) => {
|
|
|
598
675
|
{
|
|
599
676
|
key: "delete",
|
|
600
677
|
size: SIZE2,
|
|
601
|
-
"aria-label": (0,
|
|
678
|
+
"aria-label": (0, import_i18n7.__)("Delete", "elementor"),
|
|
602
679
|
onClick: handleDeleteConfirmation
|
|
603
680
|
},
|
|
604
681
|
/* @__PURE__ */ React5.createElement(import_icons3.TrashIcon, { fontSize: SIZE2 })
|
|
@@ -611,23 +688,41 @@ var ColorVariableEdit = ({ onClose, onGoBack, onSubmit, editId }) => {
|
|
|
611
688
|
return color === variable.value && label === variable.label;
|
|
612
689
|
};
|
|
613
690
|
const isSubmitDisabled = noValueChanged() || hasEmptyValues();
|
|
614
|
-
return /* @__PURE__ */ React5.createElement(React5.Fragment, null, /* @__PURE__ */ React5.createElement(import_editor_editing_panel2.
|
|
691
|
+
return /* @__PURE__ */ React5.createElement(React5.Fragment, null, /* @__PURE__ */ React5.createElement(import_editor_editing_panel2.PopoverBody, { height: "auto" }, /* @__PURE__ */ React5.createElement(
|
|
615
692
|
import_editor_ui2.PopoverHeader,
|
|
616
693
|
{
|
|
617
|
-
title: (0,
|
|
694
|
+
title: (0, import_i18n7.__)("Edit variable", "elementor"),
|
|
618
695
|
onClose,
|
|
619
696
|
icon: /* @__PURE__ */ React5.createElement(React5.Fragment, null, onGoBack && /* @__PURE__ */ React5.createElement(
|
|
620
697
|
import_ui6.IconButton,
|
|
621
698
|
{
|
|
622
699
|
size: SIZE2,
|
|
623
|
-
"aria-label": (0,
|
|
700
|
+
"aria-label": (0, import_i18n7.__)("Go Back", "elementor"),
|
|
624
701
|
onClick: onGoBack
|
|
625
702
|
},
|
|
626
703
|
/* @__PURE__ */ React5.createElement(import_icons3.ArrowLeftIcon, { fontSize: SIZE2 })
|
|
627
704
|
), /* @__PURE__ */ React5.createElement(import_icons3.BrushIcon, { fontSize: SIZE2 })),
|
|
628
705
|
actions
|
|
629
706
|
}
|
|
630
|
-
), /* @__PURE__ */ React5.createElement(import_ui6.Divider, null), /* @__PURE__ */ React5.createElement(import_editor_controls2.PopoverContent, { p: 2 }, /* @__PURE__ */ React5.createElement(
|
|
707
|
+
), /* @__PURE__ */ React5.createElement(import_ui6.Divider, null), /* @__PURE__ */ React5.createElement(import_editor_controls2.PopoverContent, { p: 2 }, /* @__PURE__ */ React5.createElement(
|
|
708
|
+
LabelField,
|
|
709
|
+
{
|
|
710
|
+
value: label,
|
|
711
|
+
onChange: (value) => {
|
|
712
|
+
setLabel(value);
|
|
713
|
+
setErrorMessage("");
|
|
714
|
+
}
|
|
715
|
+
}
|
|
716
|
+
), /* @__PURE__ */ React5.createElement(
|
|
717
|
+
ColorField,
|
|
718
|
+
{
|
|
719
|
+
value: color,
|
|
720
|
+
onChange: (value) => {
|
|
721
|
+
setColor(value);
|
|
722
|
+
setErrorMessage("");
|
|
723
|
+
}
|
|
724
|
+
}
|
|
725
|
+
), errorMessage && /* @__PURE__ */ React5.createElement(import_ui6.FormHelperText, { error: true }, errorMessage)), /* @__PURE__ */ React5.createElement(import_ui6.CardActions, { sx: { pt: 0.5, pb: 1 } }, /* @__PURE__ */ React5.createElement(import_ui6.Button, { size: "small", variant: "contained", disabled: isSubmitDisabled, onClick: handleUpdate }, (0, import_i18n7.__)("Save", "elementor")))), deleteConfirmation && /* @__PURE__ */ React5.createElement(
|
|
631
726
|
DeleteConfirmationDialog,
|
|
632
727
|
{
|
|
633
728
|
open: true,
|
|
@@ -646,14 +741,14 @@ var import_editor_editing_panel3 = require("@elementor/editor-editing-panel");
|
|
|
646
741
|
var import_editor_ui4 = require("@elementor/editor-ui");
|
|
647
742
|
var import_icons5 = require("@elementor/icons");
|
|
648
743
|
var import_ui11 = require("@elementor/ui");
|
|
649
|
-
var
|
|
744
|
+
var import_i18n11 = require("@wordpress/i18n");
|
|
650
745
|
|
|
651
746
|
// src/components/ui/menu-item-content.tsx
|
|
652
747
|
var React6 = __toESM(require("react"));
|
|
653
748
|
var import_editor_ui3 = require("@elementor/editor-ui");
|
|
654
749
|
var import_icons4 = require("@elementor/icons");
|
|
655
750
|
var import_ui7 = require("@elementor/ui");
|
|
656
|
-
var
|
|
751
|
+
var import_i18n8 = require("@wordpress/i18n");
|
|
657
752
|
var SIZE3 = "tiny";
|
|
658
753
|
var MenuItemContent = ({ item }) => {
|
|
659
754
|
const onEdit = item.onEdit;
|
|
@@ -698,7 +793,7 @@ var MenuItemContent = ({ item }) => {
|
|
|
698
793
|
e.stopPropagation();
|
|
699
794
|
onEdit(item.value);
|
|
700
795
|
},
|
|
701
|
-
"aria-label": (0,
|
|
796
|
+
"aria-label": (0, import_i18n8.__)("Edit", "elementor")
|
|
702
797
|
},
|
|
703
798
|
/* @__PURE__ */ React6.createElement(import_icons4.EditIcon, { color: "action", fontSize: SIZE3 })
|
|
704
799
|
));
|
|
@@ -707,7 +802,7 @@ var MenuItemContent = ({ item }) => {
|
|
|
707
802
|
// src/components/ui/no-search-results.tsx
|
|
708
803
|
var React7 = __toESM(require("react"));
|
|
709
804
|
var import_ui8 = require("@elementor/ui");
|
|
710
|
-
var
|
|
805
|
+
var import_i18n9 = require("@wordpress/i18n");
|
|
711
806
|
var NoSearchResults = ({ searchValue, onClear, icon }) => {
|
|
712
807
|
return /* @__PURE__ */ React7.createElement(
|
|
713
808
|
import_ui8.Stack,
|
|
@@ -721,15 +816,15 @@ var NoSearchResults = ({ searchValue, onClear, icon }) => {
|
|
|
721
816
|
sx: { pb: 3.5 }
|
|
722
817
|
},
|
|
723
818
|
icon,
|
|
724
|
-
/* @__PURE__ */ React7.createElement(import_ui8.Typography, { align: "center", variant: "subtitle2" }, (0,
|
|
725
|
-
/* @__PURE__ */ React7.createElement(import_ui8.Typography, { align: "center", variant: "caption", sx: { display: "flex", flexDirection: "column" } }, (0,
|
|
819
|
+
/* @__PURE__ */ React7.createElement(import_ui8.Typography, { align: "center", variant: "subtitle2" }, (0, import_i18n9.__)("Sorry, nothing matched", "elementor"), /* @__PURE__ */ React7.createElement("br", null), "\u201C", searchValue, "\u201D."),
|
|
820
|
+
/* @__PURE__ */ React7.createElement(import_ui8.Typography, { align: "center", variant: "caption", sx: { display: "flex", flexDirection: "column" } }, (0, import_i18n9.__)("Try something else.", "elementor"), /* @__PURE__ */ React7.createElement(import_ui8.Link, { color: "text.secondary", variant: "caption", component: "button", onClick: onClear }, (0, import_i18n9.__)("Clear & try again", "elementor")))
|
|
726
821
|
);
|
|
727
822
|
};
|
|
728
823
|
|
|
729
824
|
// src/components/ui/no-variables.tsx
|
|
730
825
|
var React8 = __toESM(require("react"));
|
|
731
826
|
var import_ui9 = require("@elementor/ui");
|
|
732
|
-
var
|
|
827
|
+
var import_i18n10 = require("@wordpress/i18n");
|
|
733
828
|
var NoVariables = ({ icon, title, onAdd }) => /* @__PURE__ */ React8.createElement(
|
|
734
829
|
import_ui9.Stack,
|
|
735
830
|
{
|
|
@@ -742,8 +837,8 @@ var NoVariables = ({ icon, title, onAdd }) => /* @__PURE__ */ React8.createEleme
|
|
|
742
837
|
},
|
|
743
838
|
icon,
|
|
744
839
|
/* @__PURE__ */ React8.createElement(import_ui9.Typography, { align: "center", variant: "subtitle2" }, title),
|
|
745
|
-
/* @__PURE__ */ React8.createElement(import_ui9.Typography, { align: "center", variant: "caption", maxWidth: "180px" }, (0,
|
|
746
|
-
onAdd && /* @__PURE__ */ React8.createElement(import_ui9.Button, { variant: "outlined", color: "secondary", size: "small", onClick: onAdd }, (0,
|
|
840
|
+
/* @__PURE__ */ React8.createElement(import_ui9.Typography, { align: "center", variant: "caption", maxWidth: "180px" }, (0, import_i18n10.__)("Variables are saved attributes that you can apply anywhere on your site.", "elementor")),
|
|
841
|
+
onAdd && /* @__PURE__ */ React8.createElement(import_ui9.Button, { variant: "outlined", color: "secondary", size: "small", onClick: onAdd }, (0, import_i18n10.__)("Create a variable", "elementor"))
|
|
747
842
|
);
|
|
748
843
|
|
|
749
844
|
// src/components/ui/styled-menu-list.tsx
|
|
@@ -817,10 +912,10 @@ var ColorVariablesSelection = ({ closePopover, onAdd, onEdit, onSettings }) => {
|
|
|
817
912
|
const handleClearSearch = () => {
|
|
818
913
|
setSearchValue("");
|
|
819
914
|
};
|
|
820
|
-
return /* @__PURE__ */ React9.createElement(
|
|
915
|
+
return /* @__PURE__ */ React9.createElement(import_editor_editing_panel3.PopoverBody, null, /* @__PURE__ */ React9.createElement(
|
|
821
916
|
import_editor_ui4.PopoverHeader,
|
|
822
917
|
{
|
|
823
|
-
title: (0,
|
|
918
|
+
title: (0, import_i18n11.__)("Variables", "elementor"),
|
|
824
919
|
icon: /* @__PURE__ */ React9.createElement(import_icons5.ColorFilterIcon, { fontSize: SIZE4 }),
|
|
825
920
|
onClose: closePopover,
|
|
826
921
|
actions
|
|
@@ -830,9 +925,9 @@ var ColorVariablesSelection = ({ closePopover, onAdd, onEdit, onSettings }) => {
|
|
|
830
925
|
{
|
|
831
926
|
value: searchValue,
|
|
832
927
|
onSearch: handleSearch,
|
|
833
|
-
placeholder: (0,
|
|
928
|
+
placeholder: (0, import_i18n11.__)("Search", "elementor")
|
|
834
929
|
}
|
|
835
|
-
), /* @__PURE__ */ React9.createElement(import_ui11.Divider, null),
|
|
930
|
+
), /* @__PURE__ */ React9.createElement(import_ui11.Divider, null), hasVariables && hasSearchResults && /* @__PURE__ */ React9.createElement(
|
|
836
931
|
import_editor_ui4.PopoverMenuList,
|
|
837
932
|
{
|
|
838
933
|
items,
|
|
@@ -854,11 +949,11 @@ var ColorVariablesSelection = ({ closePopover, onAdd, onEdit, onSettings }) => {
|
|
|
854
949
|
), !hasVariables && /* @__PURE__ */ React9.createElement(
|
|
855
950
|
NoVariables,
|
|
856
951
|
{
|
|
857
|
-
title: (0,
|
|
952
|
+
title: (0, import_i18n11.__)("Create your first color variable", "elementor"),
|
|
858
953
|
icon: /* @__PURE__ */ React9.createElement(import_icons5.BrushIcon, { fontSize: "large" }),
|
|
859
954
|
onAdd
|
|
860
955
|
}
|
|
861
|
-
))
|
|
956
|
+
));
|
|
862
957
|
};
|
|
863
958
|
|
|
864
959
|
// src/components/font-variable-creation.tsx
|
|
@@ -869,7 +964,7 @@ var import_editor_editing_panel5 = require("@elementor/editor-editing-panel");
|
|
|
869
964
|
var import_editor_ui5 = require("@elementor/editor-ui");
|
|
870
965
|
var import_icons7 = require("@elementor/icons");
|
|
871
966
|
var import_ui13 = require("@elementor/ui");
|
|
872
|
-
var
|
|
967
|
+
var import_i18n13 = require("@wordpress/i18n");
|
|
873
968
|
|
|
874
969
|
// src/components/fields/font-field.tsx
|
|
875
970
|
var React10 = __toESM(require("react"));
|
|
@@ -878,7 +973,7 @@ var import_editor_controls4 = require("@elementor/editor-controls");
|
|
|
878
973
|
var import_editor_editing_panel4 = require("@elementor/editor-editing-panel");
|
|
879
974
|
var import_icons6 = require("@elementor/icons");
|
|
880
975
|
var import_ui12 = require("@elementor/ui");
|
|
881
|
-
var
|
|
976
|
+
var import_i18n12 = require("@wordpress/i18n");
|
|
882
977
|
var FontField = ({ value, onChange }) => {
|
|
883
978
|
const [fontFamily, setFontFamily] = (0, import_react8.useState)(value);
|
|
884
979
|
const [errorMessage, setErrorMessage] = (0, import_react8.useState)("");
|
|
@@ -897,7 +992,7 @@ var FontField = ({ value, onChange }) => {
|
|
|
897
992
|
handleChange(newFontFamily);
|
|
898
993
|
fontPopoverState.close();
|
|
899
994
|
};
|
|
900
|
-
return /* @__PURE__ */ React10.createElement(import_ui12.Grid, { container: true, gap: 0.75, alignItems: "center" }, /* @__PURE__ */ React10.createElement(import_ui12.Grid, { item: true, xs: 12 }, /* @__PURE__ */ React10.createElement(import_ui12.FormLabel, { size: "tiny" }, (0,
|
|
995
|
+
return /* @__PURE__ */ React10.createElement(import_ui12.Grid, { container: true, gap: 0.75, alignItems: "center" }, /* @__PURE__ */ React10.createElement(import_ui12.Grid, { item: true, xs: 12 }, /* @__PURE__ */ React10.createElement(import_ui12.FormLabel, { size: "tiny" }, (0, import_i18n12.__)("Value", "elementor"))), /* @__PURE__ */ React10.createElement(import_ui12.Grid, { item: true, xs: 12 }, /* @__PURE__ */ React10.createElement(
|
|
901
996
|
import_ui12.UnstableTag,
|
|
902
997
|
{
|
|
903
998
|
variant: "outlined",
|
|
@@ -935,9 +1030,11 @@ var FontVariableCreation = ({ onClose, onGoBack }) => {
|
|
|
935
1030
|
const { setValue: setVariable } = (0, import_editor_controls5.useBoundProp)(fontVariablePropTypeUtil);
|
|
936
1031
|
const [fontFamily, setFontFamily] = (0, import_react9.useState)("");
|
|
937
1032
|
const [label, setLabel] = (0, import_react9.useState)("");
|
|
1033
|
+
const [errorMessage, setErrorMessage] = (0, import_react9.useState)("");
|
|
938
1034
|
const resetFields = () => {
|
|
939
1035
|
setFontFamily("");
|
|
940
1036
|
setLabel("");
|
|
1037
|
+
setErrorMessage("");
|
|
941
1038
|
};
|
|
942
1039
|
const closePopover = () => {
|
|
943
1040
|
resetFields();
|
|
@@ -951,20 +1048,40 @@ var FontVariableCreation = ({ onClose, onGoBack }) => {
|
|
|
951
1048
|
}).then((key) => {
|
|
952
1049
|
setVariable(key);
|
|
953
1050
|
closePopover();
|
|
1051
|
+
}).catch((error) => {
|
|
1052
|
+
setErrorMessage(error.message);
|
|
954
1053
|
});
|
|
955
1054
|
};
|
|
956
1055
|
const hasEmptyValue = () => {
|
|
957
1056
|
return "" === fontFamily.trim() || "" === label.trim();
|
|
958
1057
|
};
|
|
959
1058
|
const isSubmitDisabled = hasEmptyValue();
|
|
960
|
-
return /* @__PURE__ */ React11.createElement(import_editor_editing_panel5.
|
|
1059
|
+
return /* @__PURE__ */ React11.createElement(import_editor_editing_panel5.PopoverBody, { height: "auto" }, /* @__PURE__ */ React11.createElement(
|
|
961
1060
|
import_editor_ui5.PopoverHeader,
|
|
962
1061
|
{
|
|
963
|
-
icon: /* @__PURE__ */ React11.createElement(React11.Fragment, null, onGoBack && /* @__PURE__ */ React11.createElement(import_ui13.IconButton, { size: SIZE5, "aria-label": (0,
|
|
964
|
-
title: (0,
|
|
1062
|
+
icon: /* @__PURE__ */ React11.createElement(React11.Fragment, null, onGoBack && /* @__PURE__ */ React11.createElement(import_ui13.IconButton, { size: SIZE5, "aria-label": (0, import_i18n13.__)("Go Back", "elementor"), onClick: onGoBack }, /* @__PURE__ */ React11.createElement(import_icons7.ArrowLeftIcon, { fontSize: SIZE5 })), /* @__PURE__ */ React11.createElement(import_icons7.TextIcon, { fontSize: SIZE5 })),
|
|
1063
|
+
title: (0, import_i18n13.__)("Create variable", "elementor"),
|
|
965
1064
|
onClose: closePopover
|
|
966
1065
|
}
|
|
967
|
-
), /* @__PURE__ */ React11.createElement(import_ui13.Divider, null), /* @__PURE__ */ React11.createElement(import_editor_controls5.PopoverContent, { p: 2 }, /* @__PURE__ */ React11.createElement(
|
|
1066
|
+
), /* @__PURE__ */ React11.createElement(import_ui13.Divider, null), /* @__PURE__ */ React11.createElement(import_editor_controls5.PopoverContent, { p: 2 }, /* @__PURE__ */ React11.createElement(
|
|
1067
|
+
LabelField,
|
|
1068
|
+
{
|
|
1069
|
+
value: label,
|
|
1070
|
+
onChange: (value) => {
|
|
1071
|
+
setLabel(value);
|
|
1072
|
+
setErrorMessage("");
|
|
1073
|
+
}
|
|
1074
|
+
}
|
|
1075
|
+
), /* @__PURE__ */ React11.createElement(
|
|
1076
|
+
FontField,
|
|
1077
|
+
{
|
|
1078
|
+
value: fontFamily,
|
|
1079
|
+
onChange: (value) => {
|
|
1080
|
+
setFontFamily(value);
|
|
1081
|
+
setErrorMessage("");
|
|
1082
|
+
}
|
|
1083
|
+
}
|
|
1084
|
+
), errorMessage && /* @__PURE__ */ React11.createElement(import_ui13.FormHelperText, { error: true }, errorMessage)), /* @__PURE__ */ React11.createElement(import_ui13.CardActions, { sx: { pt: 0.5, pb: 1 } }, /* @__PURE__ */ React11.createElement(import_ui13.Button, { size: "small", variant: "contained", disabled: isSubmitDisabled, onClick: handleCreate }, (0, import_i18n13.__)("Create", "elementor"))));
|
|
968
1085
|
};
|
|
969
1086
|
|
|
970
1087
|
// src/components/font-variable-edit.tsx
|
|
@@ -975,11 +1092,12 @@ var import_editor_editing_panel6 = require("@elementor/editor-editing-panel");
|
|
|
975
1092
|
var import_editor_ui6 = require("@elementor/editor-ui");
|
|
976
1093
|
var import_icons8 = require("@elementor/icons");
|
|
977
1094
|
var import_ui14 = require("@elementor/ui");
|
|
978
|
-
var
|
|
1095
|
+
var import_i18n14 = require("@wordpress/i18n");
|
|
979
1096
|
var SIZE6 = "tiny";
|
|
980
1097
|
var FontVariableEdit = ({ onClose, onGoBack, onSubmit, editId }) => {
|
|
981
1098
|
const { setValue: notifyBoundPropChange, value: assignedValue } = (0, import_editor_controls6.useBoundProp)(fontVariablePropTypeUtil);
|
|
982
1099
|
const [deleteConfirmation, setDeleteConfirmation] = (0, import_react10.useState)(false);
|
|
1100
|
+
const [errorMessage, setErrorMessage] = (0, import_react10.useState)("");
|
|
983
1101
|
const variable = useVariable(editId);
|
|
984
1102
|
if (!variable) {
|
|
985
1103
|
throw new Error(`Global font variable "${editId}" not found`);
|
|
@@ -993,6 +1111,8 @@ var FontVariableEdit = ({ onClose, onGoBack, onSubmit, editId }) => {
|
|
|
993
1111
|
}).then(() => {
|
|
994
1112
|
maybeTriggerBoundPropChange();
|
|
995
1113
|
onSubmit?.();
|
|
1114
|
+
}).catch((error) => {
|
|
1115
|
+
setErrorMessage(error.message);
|
|
996
1116
|
});
|
|
997
1117
|
};
|
|
998
1118
|
const handleDelete = () => {
|
|
@@ -1026,29 +1146,47 @@ var FontVariableEdit = ({ onClose, onGoBack, onSubmit, editId }) => {
|
|
|
1026
1146
|
{
|
|
1027
1147
|
key: "delete",
|
|
1028
1148
|
size: SIZE6,
|
|
1029
|
-
"aria-label": (0,
|
|
1149
|
+
"aria-label": (0, import_i18n14.__)("Delete", "elementor"),
|
|
1030
1150
|
onClick: handleDeleteConfirmation
|
|
1031
1151
|
},
|
|
1032
1152
|
/* @__PURE__ */ React12.createElement(import_icons8.TrashIcon, { fontSize: SIZE6 })
|
|
1033
1153
|
)
|
|
1034
1154
|
);
|
|
1035
|
-
return /* @__PURE__ */ React12.createElement(React12.Fragment, null, /* @__PURE__ */ React12.createElement(import_editor_editing_panel6.
|
|
1155
|
+
return /* @__PURE__ */ React12.createElement(React12.Fragment, null, /* @__PURE__ */ React12.createElement(import_editor_editing_panel6.PopoverBody, { height: "auto" }, /* @__PURE__ */ React12.createElement(
|
|
1036
1156
|
import_editor_ui6.PopoverHeader,
|
|
1037
1157
|
{
|
|
1038
1158
|
icon: /* @__PURE__ */ React12.createElement(React12.Fragment, null, onGoBack && /* @__PURE__ */ React12.createElement(
|
|
1039
1159
|
import_ui14.IconButton,
|
|
1040
1160
|
{
|
|
1041
1161
|
size: SIZE6,
|
|
1042
|
-
"aria-label": (0,
|
|
1162
|
+
"aria-label": (0, import_i18n14.__)("Go Back", "elementor"),
|
|
1043
1163
|
onClick: onGoBack
|
|
1044
1164
|
},
|
|
1045
1165
|
/* @__PURE__ */ React12.createElement(import_icons8.ArrowLeftIcon, { fontSize: SIZE6 })
|
|
1046
1166
|
), /* @__PURE__ */ React12.createElement(import_icons8.TextIcon, { fontSize: SIZE6 })),
|
|
1047
|
-
title: (0,
|
|
1167
|
+
title: (0, import_i18n14.__)("Edit variable", "elementor"),
|
|
1048
1168
|
onClose,
|
|
1049
1169
|
actions
|
|
1050
1170
|
}
|
|
1051
|
-
), /* @__PURE__ */ React12.createElement(import_ui14.Divider, null), /* @__PURE__ */ React12.createElement(import_editor_controls6.PopoverContent, { p: 2 }, /* @__PURE__ */ React12.createElement(
|
|
1171
|
+
), /* @__PURE__ */ React12.createElement(import_ui14.Divider, null), /* @__PURE__ */ React12.createElement(import_editor_controls6.PopoverContent, { p: 2 }, /* @__PURE__ */ React12.createElement(
|
|
1172
|
+
LabelField,
|
|
1173
|
+
{
|
|
1174
|
+
value: label,
|
|
1175
|
+
onChange: (value) => {
|
|
1176
|
+
setLabel(value);
|
|
1177
|
+
setErrorMessage("");
|
|
1178
|
+
}
|
|
1179
|
+
}
|
|
1180
|
+
), /* @__PURE__ */ React12.createElement(
|
|
1181
|
+
FontField,
|
|
1182
|
+
{
|
|
1183
|
+
value: fontFamily,
|
|
1184
|
+
onChange: (value) => {
|
|
1185
|
+
setFontFamily(value);
|
|
1186
|
+
setErrorMessage("");
|
|
1187
|
+
}
|
|
1188
|
+
}
|
|
1189
|
+
), errorMessage && /* @__PURE__ */ React12.createElement(import_ui14.FormHelperText, { error: true }, errorMessage)), /* @__PURE__ */ React12.createElement(import_ui14.CardActions, { sx: { pt: 0.5, pb: 1 } }, /* @__PURE__ */ React12.createElement(import_ui14.Button, { size: "small", variant: "contained", disabled: isSubmitDisabled, onClick: handleUpdate }, (0, import_i18n14.__)("Save", "elementor")))), deleteConfirmation && /* @__PURE__ */ React12.createElement(
|
|
1052
1190
|
DeleteConfirmationDialog,
|
|
1053
1191
|
{
|
|
1054
1192
|
open: true,
|
|
@@ -1067,7 +1205,7 @@ var import_editor_editing_panel7 = require("@elementor/editor-editing-panel");
|
|
|
1067
1205
|
var import_editor_ui7 = require("@elementor/editor-ui");
|
|
1068
1206
|
var import_icons9 = require("@elementor/icons");
|
|
1069
1207
|
var import_ui15 = require("@elementor/ui");
|
|
1070
|
-
var
|
|
1208
|
+
var import_i18n15 = require("@wordpress/i18n");
|
|
1071
1209
|
var SIZE7 = "tiny";
|
|
1072
1210
|
var FontVariablesSelection = ({ closePopover, onAdd, onEdit, onSettings }) => {
|
|
1073
1211
|
const { value: variable, setValue: setVariable } = (0, import_editor_controls7.useBoundProp)(fontVariablePropTypeUtil);
|
|
@@ -1106,10 +1244,10 @@ var FontVariablesSelection = ({ closePopover, onAdd, onEdit, onSettings }) => {
|
|
|
1106
1244
|
const handleClearSearch = () => {
|
|
1107
1245
|
setSearchValue("");
|
|
1108
1246
|
};
|
|
1109
|
-
return /* @__PURE__ */ React13.createElement(
|
|
1247
|
+
return /* @__PURE__ */ React13.createElement(import_editor_editing_panel7.PopoverBody, null, /* @__PURE__ */ React13.createElement(
|
|
1110
1248
|
import_editor_ui7.PopoverHeader,
|
|
1111
1249
|
{
|
|
1112
|
-
title: (0,
|
|
1250
|
+
title: (0, import_i18n15.__)("Variables", "elementor"),
|
|
1113
1251
|
onClose: closePopover,
|
|
1114
1252
|
icon: /* @__PURE__ */ React13.createElement(import_icons9.ColorFilterIcon, { fontSize: SIZE7 }),
|
|
1115
1253
|
actions
|
|
@@ -1119,9 +1257,9 @@ var FontVariablesSelection = ({ closePopover, onAdd, onEdit, onSettings }) => {
|
|
|
1119
1257
|
{
|
|
1120
1258
|
value: searchValue,
|
|
1121
1259
|
onSearch: handleSearch,
|
|
1122
|
-
placeholder: (0,
|
|
1260
|
+
placeholder: (0, import_i18n15.__)("Search", "elementor")
|
|
1123
1261
|
}
|
|
1124
|
-
), /* @__PURE__ */ React13.createElement(import_ui15.Divider, null),
|
|
1262
|
+
), /* @__PURE__ */ React13.createElement(import_ui15.Divider, null), hasVariables && hasSearchResults && /* @__PURE__ */ React13.createElement(
|
|
1125
1263
|
import_editor_ui7.PopoverMenuList,
|
|
1126
1264
|
{
|
|
1127
1265
|
items,
|
|
@@ -1143,11 +1281,11 @@ var FontVariablesSelection = ({ closePopover, onAdd, onEdit, onSettings }) => {
|
|
|
1143
1281
|
), !hasVariables && /* @__PURE__ */ React13.createElement(
|
|
1144
1282
|
NoVariables,
|
|
1145
1283
|
{
|
|
1146
|
-
title: (0,
|
|
1284
|
+
title: (0, import_i18n15.__)("Create your first font variable", "elementor"),
|
|
1147
1285
|
icon: /* @__PURE__ */ React13.createElement(import_icons9.TextIcon, { fontSize: "large" }),
|
|
1148
1286
|
onAdd
|
|
1149
1287
|
}
|
|
1150
|
-
))
|
|
1288
|
+
));
|
|
1151
1289
|
};
|
|
1152
1290
|
|
|
1153
1291
|
// src/components/variable-selection-popover.tsx
|
|
@@ -1256,16 +1394,16 @@ function renderStage(props) {
|
|
|
1256
1394
|
var React15 = __toESM(require("react"));
|
|
1257
1395
|
var import_icons10 = require("@elementor/icons");
|
|
1258
1396
|
var import_ui17 = require("@elementor/ui");
|
|
1259
|
-
var
|
|
1397
|
+
var import_i18n16 = require("@wordpress/i18n");
|
|
1260
1398
|
var SIZE8 = "tiny";
|
|
1261
1399
|
var AssignedTag = ({ startIcon, label, onUnlink, ...props }) => {
|
|
1262
1400
|
const actions = [];
|
|
1263
1401
|
if (onUnlink) {
|
|
1264
1402
|
actions.push(
|
|
1265
|
-
/* @__PURE__ */ React15.createElement(import_ui17.IconButton, { key: "unlink", size: SIZE8, onClick: onUnlink, "aria-label": (0,
|
|
1403
|
+
/* @__PURE__ */ React15.createElement(import_ui17.IconButton, { key: "unlink", size: SIZE8, onClick: onUnlink, "aria-label": (0, import_i18n16.__)("Unlink", "elementor") }, /* @__PURE__ */ React15.createElement(import_icons10.DetachIcon, { fontSize: SIZE8 }))
|
|
1266
1404
|
);
|
|
1267
1405
|
}
|
|
1268
|
-
return /* @__PURE__ */ React15.createElement(
|
|
1406
|
+
return /* @__PURE__ */ React15.createElement(import_ui17.Tooltip, { title: label, placement: "top" }, /* @__PURE__ */ React15.createElement(
|
|
1269
1407
|
import_ui17.UnstableTag,
|
|
1270
1408
|
{
|
|
1271
1409
|
fullWidth: true,
|
|
@@ -1275,7 +1413,7 @@ var AssignedTag = ({ startIcon, label, onUnlink, ...props }) => {
|
|
|
1275
1413
|
actions,
|
|
1276
1414
|
...props
|
|
1277
1415
|
}
|
|
1278
|
-
);
|
|
1416
|
+
));
|
|
1279
1417
|
};
|
|
1280
1418
|
|
|
1281
1419
|
// src/components/ui/variable/assigned-variable.tsx
|
|
@@ -1327,61 +1465,154 @@ var AssignedVariable = ({
|
|
|
1327
1465
|
};
|
|
1328
1466
|
|
|
1329
1467
|
// src/components/ui/variable/deleted-variable.tsx
|
|
1330
|
-
var
|
|
1468
|
+
var React19 = __toESM(require("react"));
|
|
1331
1469
|
var import_react14 = require("react");
|
|
1332
|
-
var
|
|
1470
|
+
var import_editor_controls9 = require("@elementor/editor-controls");
|
|
1471
|
+
var import_editor_v1_adapters = require("@elementor/editor-v1-adapters");
|
|
1472
|
+
var import_ui21 = require("@elementor/ui");
|
|
1333
1473
|
|
|
1334
|
-
// src/components/ui/
|
|
1474
|
+
// src/components/ui/deleted-variable-alert.tsx
|
|
1335
1475
|
var React17 = __toESM(require("react"));
|
|
1336
|
-
var
|
|
1476
|
+
var import_editor_editing_panel8 = require("@elementor/editor-editing-panel");
|
|
1337
1477
|
var import_ui19 = require("@elementor/ui");
|
|
1338
|
-
var
|
|
1339
|
-
var
|
|
1340
|
-
|
|
1341
|
-
|
|
1478
|
+
var import_i18n17 = require("@wordpress/i18n");
|
|
1479
|
+
var DeletedVariableAlert = ({ onClose, onUnlink, onRestore, label }) => {
|
|
1480
|
+
const sectionWidth = (0, import_editor_editing_panel8.useSectionWidth)();
|
|
1481
|
+
return /* @__PURE__ */ React17.createElement(import_ui19.ClickAwayListener, { onClickAway: onClose }, /* @__PURE__ */ React17.createElement(
|
|
1482
|
+
import_ui19.Alert,
|
|
1342
1483
|
{
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
|
|
1347
|
-
|
|
1484
|
+
variant: "standard",
|
|
1485
|
+
severity: "warning",
|
|
1486
|
+
onClose,
|
|
1487
|
+
action: /* @__PURE__ */ React17.createElement(React17.Fragment, null, onUnlink && /* @__PURE__ */ React17.createElement(import_ui19.AlertAction, { variant: "contained", onClick: onUnlink }, (0, import_i18n17.__)("Unlink", "elementor")), onRestore && /* @__PURE__ */ React17.createElement(import_ui19.AlertAction, { variant: "outlined", onClick: onRestore }, (0, import_i18n17.__)("Restore", "elementor"))),
|
|
1488
|
+
sx: { width: sectionWidth }
|
|
1489
|
+
},
|
|
1490
|
+
/* @__PURE__ */ React17.createElement(import_ui19.AlertTitle, null, (0, import_i18n17.__)("Deleted variable", "elementor")),
|
|
1491
|
+
(0, import_i18n17.__)("The variable", "elementor"),
|
|
1492
|
+
" '",
|
|
1493
|
+
label,
|
|
1494
|
+
"'",
|
|
1495
|
+
" ",
|
|
1496
|
+
(0, import_i18n17.__)(
|
|
1497
|
+
"has been deleted, but it is still referenced in this location. You may restore the variable or unlink it to assign a different value.",
|
|
1498
|
+
"elementor"
|
|
1499
|
+
)
|
|
1500
|
+
));
|
|
1501
|
+
};
|
|
1502
|
+
|
|
1503
|
+
// src/components/ui/tags/deleted-tag.tsx
|
|
1504
|
+
var React18 = __toESM(require("react"));
|
|
1505
|
+
var import_icons12 = require("@elementor/icons");
|
|
1506
|
+
var import_ui20 = require("@elementor/ui");
|
|
1507
|
+
var import_i18n18 = require("@wordpress/i18n");
|
|
1508
|
+
var DeletedTag = React18.forwardRef(({ label, onClick, ...props }, ref) => {
|
|
1509
|
+
return /* @__PURE__ */ React18.createElement(
|
|
1510
|
+
import_ui20.Chip,
|
|
1511
|
+
{
|
|
1512
|
+
ref,
|
|
1513
|
+
size: "tiny",
|
|
1514
|
+
color: "warning",
|
|
1515
|
+
shape: "rounded",
|
|
1516
|
+
variant: "standard",
|
|
1517
|
+
onClick,
|
|
1518
|
+
icon: /* @__PURE__ */ React18.createElement(import_icons12.AlertTriangleFilledIcon, null),
|
|
1519
|
+
label: /* @__PURE__ */ React18.createElement(import_ui20.Tooltip, { title: label, placement: "top" }, /* @__PURE__ */ React18.createElement(import_ui20.Box, { sx: { display: "flex", gap: 0.5, alignItems: "center" } }, /* @__PURE__ */ React18.createElement(import_ui20.Typography, { variant: "caption", noWrap: true }, label), /* @__PURE__ */ React18.createElement(import_ui20.Typography, { variant: "caption", noWrap: true, sx: { textOverflow: "initial", overflow: "visible" } }, "(", (0, import_i18n18.__)("deleted", "elementor"), ")"))),
|
|
1520
|
+
sx: {
|
|
1521
|
+
height: (theme) => theme.spacing(3.5),
|
|
1522
|
+
borderRadius: (theme) => theme.spacing(1),
|
|
1523
|
+
justifyContent: "flex-start",
|
|
1524
|
+
width: "100%"
|
|
1525
|
+
},
|
|
1526
|
+
...props
|
|
1348
1527
|
}
|
|
1349
1528
|
);
|
|
1350
|
-
};
|
|
1529
|
+
});
|
|
1351
1530
|
|
|
1352
1531
|
// src/components/ui/variable/deleted-variable.tsx
|
|
1353
|
-
var
|
|
1354
|
-
|
|
1355
|
-
|
|
1532
|
+
var isV331Active = (0, import_editor_v1_adapters.isExperimentActive)("e_v_3_31");
|
|
1533
|
+
var DeletedVariable = ({ variable, variablePropTypeUtil, fallbackPropTypeUtil }) => {
|
|
1534
|
+
const { setValue } = (0, import_editor_controls9.useBoundProp)();
|
|
1535
|
+
const [showInfotip, setShowInfotip] = (0, import_react14.useState)(false);
|
|
1536
|
+
const toggleInfotip = () => setShowInfotip((prev) => !prev);
|
|
1537
|
+
const closeInfotip = () => setShowInfotip(false);
|
|
1538
|
+
const unlinkVariable = () => {
|
|
1539
|
+
setValue(fallbackPropTypeUtil.create(variable.value));
|
|
1540
|
+
};
|
|
1541
|
+
const handleRestore = () => {
|
|
1542
|
+
if (!variable.key) {
|
|
1543
|
+
return;
|
|
1544
|
+
}
|
|
1545
|
+
restoreVariable(variable.key).then((key) => {
|
|
1546
|
+
setValue(variablePropTypeUtil.create(key));
|
|
1547
|
+
closeInfotip();
|
|
1548
|
+
});
|
|
1549
|
+
};
|
|
1550
|
+
return /* @__PURE__ */ React19.createElement(React19.Fragment, null, showInfotip && /* @__PURE__ */ React19.createElement(import_ui21.Backdrop, { open: true, onClick: closeInfotip, invisible: true }), /* @__PURE__ */ React19.createElement(
|
|
1551
|
+
import_ui21.Infotip,
|
|
1552
|
+
{
|
|
1553
|
+
color: "warning",
|
|
1554
|
+
placement: "right-start",
|
|
1555
|
+
open: showInfotip,
|
|
1556
|
+
disableHoverListener: true,
|
|
1557
|
+
onClose: closeInfotip,
|
|
1558
|
+
content: /* @__PURE__ */ React19.createElement(
|
|
1559
|
+
DeletedVariableAlert,
|
|
1560
|
+
{
|
|
1561
|
+
onClose: closeInfotip,
|
|
1562
|
+
onUnlink: unlinkVariable,
|
|
1563
|
+
onRestore: isV331Active ? handleRestore : void 0,
|
|
1564
|
+
label: variable.label
|
|
1565
|
+
}
|
|
1566
|
+
),
|
|
1567
|
+
slotProps: {
|
|
1568
|
+
popper: {
|
|
1569
|
+
modifiers: [
|
|
1570
|
+
{
|
|
1571
|
+
name: "offset",
|
|
1572
|
+
options: { offset: [0, 24] }
|
|
1573
|
+
}
|
|
1574
|
+
]
|
|
1575
|
+
}
|
|
1576
|
+
}
|
|
1577
|
+
},
|
|
1578
|
+
/* @__PURE__ */ React19.createElement(DeletedTag, { label: variable.label, onClick: toggleInfotip })
|
|
1579
|
+
));
|
|
1356
1580
|
};
|
|
1357
1581
|
|
|
1358
1582
|
// src/controls/color-variable-control.tsx
|
|
1359
1583
|
var ColorVariableControl = () => {
|
|
1360
|
-
const { value: variableValue } = (0,
|
|
1584
|
+
const { value: variableValue } = (0, import_editor_controls10.useBoundProp)(colorVariablePropTypeUtil);
|
|
1361
1585
|
const assignedVariable = useVariable(variableValue);
|
|
1362
1586
|
if (!assignedVariable) {
|
|
1363
1587
|
throw new Error(`Global color variable ${variableValue} not found`);
|
|
1364
1588
|
}
|
|
1365
1589
|
const isVariableDeleted = assignedVariable?.deleted;
|
|
1366
1590
|
if (isVariableDeleted) {
|
|
1367
|
-
return /* @__PURE__ */
|
|
1591
|
+
return /* @__PURE__ */ React20.createElement(
|
|
1592
|
+
DeletedVariable,
|
|
1593
|
+
{
|
|
1594
|
+
variable: assignedVariable,
|
|
1595
|
+
variablePropTypeUtil: colorVariablePropTypeUtil,
|
|
1596
|
+
fallbackPropTypeUtil: import_editor_props3.colorPropTypeUtil
|
|
1597
|
+
}
|
|
1598
|
+
);
|
|
1368
1599
|
}
|
|
1369
|
-
return /* @__PURE__ */
|
|
1600
|
+
return /* @__PURE__ */ React20.createElement(
|
|
1370
1601
|
AssignedVariable,
|
|
1371
1602
|
{
|
|
1372
1603
|
variable: assignedVariable,
|
|
1373
1604
|
variablePropTypeUtil: colorVariablePropTypeUtil,
|
|
1374
1605
|
fallbackPropTypeUtil: import_editor_props3.colorPropTypeUtil,
|
|
1375
|
-
additionalStartIcon: /* @__PURE__ */
|
|
1606
|
+
additionalStartIcon: /* @__PURE__ */ React20.createElement(ColorIndicator, { size: "inherit", value: assignedVariable.value, component: "span" })
|
|
1376
1607
|
}
|
|
1377
1608
|
);
|
|
1378
1609
|
};
|
|
1379
1610
|
|
|
1380
1611
|
// src/hooks/use-prop-color-variable-action.tsx
|
|
1381
|
-
var
|
|
1382
|
-
var
|
|
1612
|
+
var React21 = __toESM(require("react"));
|
|
1613
|
+
var import_editor_editing_panel9 = require("@elementor/editor-editing-panel");
|
|
1383
1614
|
var import_icons13 = require("@elementor/icons");
|
|
1384
|
-
var
|
|
1615
|
+
var import_i18n19 = require("@wordpress/i18n");
|
|
1385
1616
|
|
|
1386
1617
|
// src/utils.ts
|
|
1387
1618
|
var hasAssignedColorVariable = (propValue) => {
|
|
@@ -1399,58 +1630,58 @@ var supportsFontVariables = (propType) => {
|
|
|
1399
1630
|
|
|
1400
1631
|
// src/hooks/use-prop-color-variable-action.tsx
|
|
1401
1632
|
var usePropColorVariableAction = () => {
|
|
1402
|
-
const { propType } = (0,
|
|
1633
|
+
const { propType } = (0, import_editor_editing_panel9.useBoundProp)();
|
|
1403
1634
|
const visible = !!propType && supportsColorVariables(propType);
|
|
1404
1635
|
return {
|
|
1405
1636
|
visible,
|
|
1406
1637
|
icon: import_icons13.ColorFilterIcon,
|
|
1407
|
-
title: (0,
|
|
1638
|
+
title: (0, import_i18n19.__)("Variables", "elementor"),
|
|
1408
1639
|
content: ({ close: closePopover }) => {
|
|
1409
|
-
return /* @__PURE__ */
|
|
1640
|
+
return /* @__PURE__ */ React21.createElement(VariableSelectionPopover, { closePopover, propTypeKey: colorVariablePropTypeUtil.key });
|
|
1410
1641
|
}
|
|
1411
1642
|
};
|
|
1412
1643
|
};
|
|
1413
1644
|
|
|
1414
1645
|
// src/repeater-injections.ts
|
|
1415
|
-
var
|
|
1646
|
+
var import_editor_controls11 = require("@elementor/editor-controls");
|
|
1416
1647
|
var import_editor_props4 = require("@elementor/editor-props");
|
|
1417
1648
|
|
|
1418
1649
|
// src/components/variables-repeater-item-slot.tsx
|
|
1419
|
-
var
|
|
1650
|
+
var React22 = __toESM(require("react"));
|
|
1420
1651
|
var useColorVariable = (value) => {
|
|
1421
1652
|
const variableId = value?.value?.color?.value;
|
|
1422
1653
|
return useVariable(variableId || "");
|
|
1423
1654
|
};
|
|
1424
1655
|
var BackgroundRepeaterColorIndicator = ({ value }) => {
|
|
1425
1656
|
const colorVariable = useColorVariable(value);
|
|
1426
|
-
return /* @__PURE__ */
|
|
1657
|
+
return /* @__PURE__ */ React22.createElement(ColorIndicator, { component: "span", size: "inherit", value: colorVariable?.value });
|
|
1427
1658
|
};
|
|
1428
1659
|
var BackgroundRepeaterLabel = ({ value }) => {
|
|
1429
1660
|
const colorVariable = useColorVariable(value);
|
|
1430
|
-
return /* @__PURE__ */
|
|
1661
|
+
return /* @__PURE__ */ React22.createElement("span", null, colorVariable?.label);
|
|
1431
1662
|
};
|
|
1432
1663
|
var BoxShadowRepeaterColorIndicator = ({ value }) => {
|
|
1433
1664
|
const colorVariable = useColorVariable(value);
|
|
1434
|
-
return /* @__PURE__ */
|
|
1665
|
+
return /* @__PURE__ */ React22.createElement(ColorIndicator, { component: "span", size: "inherit", value: colorVariable?.value });
|
|
1435
1666
|
};
|
|
1436
1667
|
|
|
1437
1668
|
// src/repeater-injections.ts
|
|
1438
1669
|
function registerRepeaterInjections() {
|
|
1439
|
-
(0,
|
|
1670
|
+
(0, import_editor_controls11.injectIntoRepeaterItemIcon)({
|
|
1440
1671
|
id: "color-variables-background-icon",
|
|
1441
1672
|
component: BackgroundRepeaterColorIndicator,
|
|
1442
1673
|
condition: ({ value: prop }) => {
|
|
1443
1674
|
return hasAssignedColorVariable(import_editor_props4.backgroundColorOverlayPropTypeUtil.extract(prop)?.color);
|
|
1444
1675
|
}
|
|
1445
1676
|
});
|
|
1446
|
-
(0,
|
|
1677
|
+
(0, import_editor_controls11.injectIntoRepeaterItemIcon)({
|
|
1447
1678
|
id: "color-variables-icon",
|
|
1448
1679
|
component: BoxShadowRepeaterColorIndicator,
|
|
1449
1680
|
condition: ({ value: prop }) => {
|
|
1450
1681
|
return hasAssignedColorVariable(import_editor_props4.shadowPropTypeUtil.extract(prop)?.color);
|
|
1451
1682
|
}
|
|
1452
1683
|
});
|
|
1453
|
-
(0,
|
|
1684
|
+
(0, import_editor_controls11.injectIntoRepeaterItemLabel)({
|
|
1454
1685
|
id: "color-variables-label",
|
|
1455
1686
|
component: BackgroundRepeaterLabel,
|
|
1456
1687
|
condition: ({ value: prop }) => {
|
|
@@ -1461,17 +1692,29 @@ function registerRepeaterInjections() {
|
|
|
1461
1692
|
|
|
1462
1693
|
// src/transformers/variable-transformer.ts
|
|
1463
1694
|
var import_editor_canvas = require("@elementor/editor-canvas");
|
|
1464
|
-
var variableTransformer = (0, import_editor_canvas.createTransformer)((
|
|
1465
|
-
|
|
1695
|
+
var variableTransformer = (0, import_editor_canvas.createTransformer)((id) => {
|
|
1696
|
+
const variables = service.variables();
|
|
1697
|
+
let name = id;
|
|
1698
|
+
let fallbackValue = "";
|
|
1699
|
+
if (variables[id]) {
|
|
1700
|
+
fallbackValue = variables[id].value;
|
|
1701
|
+
if (!variables[id]?.deleted) {
|
|
1702
|
+
name = variables[id].label;
|
|
1703
|
+
}
|
|
1704
|
+
}
|
|
1705
|
+
if (!name.trim()) {
|
|
1466
1706
|
return null;
|
|
1467
1707
|
}
|
|
1468
|
-
|
|
1708
|
+
if (!fallbackValue.trim()) {
|
|
1709
|
+
return `var(--${name})`;
|
|
1710
|
+
}
|
|
1711
|
+
return `var(--${name}, ${fallbackValue})`;
|
|
1469
1712
|
});
|
|
1470
1713
|
|
|
1471
1714
|
// src/init-color-variables.ts
|
|
1472
|
-
var { registerPopoverAction } =
|
|
1715
|
+
var { registerPopoverAction } = import_editor_editing_panel10.controlActionsMenu;
|
|
1473
1716
|
function initColorVariables() {
|
|
1474
|
-
(0,
|
|
1717
|
+
(0, import_editor_editing_panel10.registerControlReplacement)({
|
|
1475
1718
|
component: ColorVariableControl,
|
|
1476
1719
|
condition: ({ value }) => hasAssignedColorVariable(value)
|
|
1477
1720
|
});
|
|
@@ -1485,23 +1728,30 @@ function initColorVariables() {
|
|
|
1485
1728
|
|
|
1486
1729
|
// src/init-font-variables.ts
|
|
1487
1730
|
var import_editor_canvas3 = require("@elementor/editor-canvas");
|
|
1488
|
-
var
|
|
1731
|
+
var import_editor_editing_panel12 = require("@elementor/editor-editing-panel");
|
|
1489
1732
|
|
|
1490
1733
|
// src/controls/font-variable-control.tsx
|
|
1491
|
-
var
|
|
1492
|
-
var
|
|
1734
|
+
var React23 = __toESM(require("react"));
|
|
1735
|
+
var import_editor_controls12 = require("@elementor/editor-controls");
|
|
1493
1736
|
var import_editor_props5 = require("@elementor/editor-props");
|
|
1494
1737
|
var FontVariableControl = () => {
|
|
1495
|
-
const { value: variableValue } = (0,
|
|
1738
|
+
const { value: variableValue } = (0, import_editor_controls12.useBoundProp)(fontVariablePropTypeUtil);
|
|
1496
1739
|
const assignedVariable = useVariable(variableValue);
|
|
1497
1740
|
if (!assignedVariable) {
|
|
1498
1741
|
throw new Error(`Global font variable ${variableValue} not found`);
|
|
1499
1742
|
}
|
|
1500
1743
|
const isVariableDeleted = assignedVariable?.deleted;
|
|
1501
1744
|
if (isVariableDeleted) {
|
|
1502
|
-
return /* @__PURE__ */
|
|
1745
|
+
return /* @__PURE__ */ React23.createElement(
|
|
1746
|
+
DeletedVariable,
|
|
1747
|
+
{
|
|
1748
|
+
variable: assignedVariable,
|
|
1749
|
+
variablePropTypeUtil: fontVariablePropTypeUtil,
|
|
1750
|
+
fallbackPropTypeUtil: import_editor_props5.stringPropTypeUtil
|
|
1751
|
+
}
|
|
1752
|
+
);
|
|
1503
1753
|
}
|
|
1504
|
-
return /* @__PURE__ */
|
|
1754
|
+
return /* @__PURE__ */ React23.createElement(
|
|
1505
1755
|
AssignedVariable,
|
|
1506
1756
|
{
|
|
1507
1757
|
variable: assignedVariable,
|
|
@@ -1512,27 +1762,27 @@ var FontVariableControl = () => {
|
|
|
1512
1762
|
};
|
|
1513
1763
|
|
|
1514
1764
|
// src/hooks/use-prop-font-variable-action.tsx
|
|
1515
|
-
var
|
|
1516
|
-
var
|
|
1765
|
+
var React24 = __toESM(require("react"));
|
|
1766
|
+
var import_editor_editing_panel11 = require("@elementor/editor-editing-panel");
|
|
1517
1767
|
var import_icons14 = require("@elementor/icons");
|
|
1518
|
-
var
|
|
1768
|
+
var import_i18n20 = require("@wordpress/i18n");
|
|
1519
1769
|
var usePropFontVariableAction = () => {
|
|
1520
|
-
const { propType } = (0,
|
|
1770
|
+
const { propType } = (0, import_editor_editing_panel11.useBoundProp)();
|
|
1521
1771
|
const visible = !!propType && supportsFontVariables(propType);
|
|
1522
1772
|
return {
|
|
1523
1773
|
visible,
|
|
1524
1774
|
icon: import_icons14.ColorFilterIcon,
|
|
1525
|
-
title: (0,
|
|
1775
|
+
title: (0, import_i18n20.__)("Variables", "elementor"),
|
|
1526
1776
|
content: ({ close: closePopover }) => {
|
|
1527
|
-
return /* @__PURE__ */
|
|
1777
|
+
return /* @__PURE__ */ React24.createElement(VariableSelectionPopover, { closePopover, propTypeKey: fontVariablePropTypeUtil.key });
|
|
1528
1778
|
}
|
|
1529
1779
|
};
|
|
1530
1780
|
};
|
|
1531
1781
|
|
|
1532
1782
|
// src/init-font-variables.ts
|
|
1533
|
-
var { registerPopoverAction: registerPopoverAction2 } =
|
|
1783
|
+
var { registerPopoverAction: registerPopoverAction2 } = import_editor_editing_panel12.controlActionsMenu;
|
|
1534
1784
|
function initFontVariables() {
|
|
1535
|
-
(0,
|
|
1785
|
+
(0, import_editor_editing_panel12.registerControlReplacement)({
|
|
1536
1786
|
component: FontVariableControl,
|
|
1537
1787
|
condition: ({ value }) => hasAssignedFontVariable(value)
|
|
1538
1788
|
});
|
|
@@ -1544,10 +1794,10 @@ function initFontVariables() {
|
|
|
1544
1794
|
}
|
|
1545
1795
|
|
|
1546
1796
|
// src/renderers/style-variables-renderer.tsx
|
|
1547
|
-
var
|
|
1797
|
+
var React25 = __toESM(require("react"));
|
|
1548
1798
|
var import_react15 = require("react");
|
|
1549
|
-
var
|
|
1550
|
-
var
|
|
1799
|
+
var import_editor_v1_adapters2 = require("@elementor/editor-v1-adapters");
|
|
1800
|
+
var import_ui22 = require("@elementor/ui");
|
|
1551
1801
|
|
|
1552
1802
|
// src/sync/get-canvas-iframe-document.ts
|
|
1553
1803
|
function getCanvasIframeDocument() {
|
|
@@ -1566,10 +1816,10 @@ function StyleVariablesRenderer() {
|
|
|
1566
1816
|
}
|
|
1567
1817
|
const cssVariables = convertToCssVariables(styleVariables);
|
|
1568
1818
|
const wrappedCss = `${VARIABLES_WRAPPER}{${cssVariables}}`;
|
|
1569
|
-
return /* @__PURE__ */
|
|
1819
|
+
return /* @__PURE__ */ React25.createElement(import_ui22.Portal, { container }, /* @__PURE__ */ React25.createElement("style", { "data-e-style-id": "e-variables", key: wrappedCss }, wrappedCss));
|
|
1570
1820
|
}
|
|
1571
1821
|
function usePortalContainer() {
|
|
1572
|
-
return (0,
|
|
1822
|
+
return (0, import_editor_v1_adapters2.__privateUseListenTo)((0, import_editor_v1_adapters2.commandEndEvent)("editor/documents/attach-preview"), () => getCanvasIframeDocument()?.head);
|
|
1573
1823
|
}
|
|
1574
1824
|
function useStyleVariables() {
|
|
1575
1825
|
const [variables, setVariables] = (0, import_react15.useState)({});
|
|
@@ -1581,8 +1831,14 @@ function useStyleVariables() {
|
|
|
1581
1831
|
}, []);
|
|
1582
1832
|
return variables;
|
|
1583
1833
|
}
|
|
1834
|
+
function cssVariableDeclaration(key, variable) {
|
|
1835
|
+
const variableName = variable?.deleted ? key : variable.label;
|
|
1836
|
+
const value = variable.value;
|
|
1837
|
+
return `--${variableName}:${value};`;
|
|
1838
|
+
}
|
|
1584
1839
|
function convertToCssVariables(variables) {
|
|
1585
|
-
|
|
1840
|
+
const listOfVariables = Object.entries(variables);
|
|
1841
|
+
return listOfVariables.map(([key, variable]) => cssVariableDeclaration(key, variable)).join("");
|
|
1586
1842
|
}
|
|
1587
1843
|
|
|
1588
1844
|
// src/init.ts
|