@elementor/editor-variables 4.1.0-686 → 4.1.0-688
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 +340 -309
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +246 -215
- package/dist/index.mjs.map +1 -1
- package/package.json +15 -15
- package/src/components/global-styles-import-listener.tsx +33 -0
- package/src/init.ts +6 -0
package/dist/index.js
CHANGED
|
@@ -49,177 +49,11 @@ var import_editor_panels2 = require("@elementor/editor-panels");
|
|
|
49
49
|
var import_editor_props7 = require("@elementor/editor-props");
|
|
50
50
|
var import_menus = require("@elementor/menus");
|
|
51
51
|
|
|
52
|
-
// src/components/
|
|
53
|
-
var
|
|
54
|
-
var import_editor_v1_adapters3 = require("@elementor/editor-v1-adapters");
|
|
55
|
-
|
|
56
|
-
// src/components/variables-manager/variables-manager-panel.tsx
|
|
57
|
-
var React14 = __toESM(require("react"));
|
|
58
|
-
var import_react13 = require("react");
|
|
59
|
-
var import_editor_current_user2 = require("@elementor/editor-current-user");
|
|
60
|
-
var import_editor_panels = require("@elementor/editor-panels");
|
|
61
|
-
var import_editor_ui5 = require("@elementor/editor-ui");
|
|
62
|
-
var import_editor_v1_adapters2 = require("@elementor/editor-v1-adapters");
|
|
63
|
-
var import_icons5 = require("@elementor/icons");
|
|
64
|
-
var import_ui14 = require("@elementor/ui");
|
|
65
|
-
var import_i18n10 = require("@wordpress/i18n");
|
|
66
|
-
|
|
67
|
-
// src/utils/tracking.ts
|
|
68
|
-
var import_events = require("@elementor/events");
|
|
69
|
-
var trackVariableEvent = ({ varType, controlPath, action }) => {
|
|
70
|
-
const { dispatchEvent, config } = (0, import_events.getMixpanel)();
|
|
71
|
-
if (!config?.names?.variables?.[action]) {
|
|
72
|
-
return;
|
|
73
|
-
}
|
|
74
|
-
const name = config.names.variables[action];
|
|
75
|
-
dispatchEvent?.(name, {
|
|
76
|
-
location: config?.locations?.variables || "",
|
|
77
|
-
secondaryLocation: config?.secondaryLocations?.variablesPopover || "",
|
|
78
|
-
trigger: config?.triggers?.click || "",
|
|
79
|
-
var_type: varType,
|
|
80
|
-
control_path: controlPath,
|
|
81
|
-
action_type: name
|
|
82
|
-
});
|
|
83
|
-
};
|
|
84
|
-
var trackVariablesManagerEvent = ({ action, varType, controlPath }) => {
|
|
85
|
-
const { dispatchEvent, config } = (0, import_events.getMixpanel)();
|
|
86
|
-
if (!config?.names?.variables?.[action]) {
|
|
87
|
-
return;
|
|
88
|
-
}
|
|
89
|
-
const name = config.names.variables[action];
|
|
90
|
-
const eventData = {
|
|
91
|
-
location: config?.locations?.variablesManager || "",
|
|
92
|
-
trigger: config?.triggers?.click || "",
|
|
93
|
-
action_type: name
|
|
94
|
-
};
|
|
95
|
-
if (varType) {
|
|
96
|
-
eventData.var_type = varType;
|
|
97
|
-
}
|
|
98
|
-
if (controlPath) {
|
|
99
|
-
eventData.style_control_path = controlPath;
|
|
100
|
-
}
|
|
101
|
-
dispatchEvent?.(name, eventData);
|
|
102
|
-
};
|
|
103
|
-
|
|
104
|
-
// src/utils/validations.ts
|
|
105
|
-
var import_icons = require("@elementor/icons");
|
|
106
|
-
var import_i18n = require("@wordpress/i18n");
|
|
107
|
-
var ERROR_MESSAGES = {
|
|
108
|
-
MISSING_VARIABLE_NAME: (0, import_i18n.__)("Give your variable a name.", "elementor"),
|
|
109
|
-
MISSING_VARIABLE_VALUE: (0, import_i18n.__)("Add a value to complete your variable.", "elementor"),
|
|
110
|
-
INVALID_CHARACTERS: (0, import_i18n.__)("Use letters, numbers, dashes (-), or underscores (_) for the name.", "elementor"),
|
|
111
|
-
NO_NON_SPECIAL_CHARACTER: (0, import_i18n.__)("Names have to include at least one non-special character.", "elementor"),
|
|
112
|
-
VARIABLE_LABEL_MAX_LENGTH: (0, import_i18n.__)("Keep names up to 50 characters.", "elementor"),
|
|
113
|
-
DUPLICATED_LABEL: (0, import_i18n.__)("This variable name already exists. Please choose a unique name.", "elementor"),
|
|
114
|
-
UNEXPECTED_ERROR: (0, import_i18n.__)("There was a glitch. Try saving your variable again.", "elementor"),
|
|
115
|
-
BATCH: {
|
|
116
|
-
DUPLICATED_LABELS: (count, name) => (
|
|
117
|
-
// eslint-disable-next-line @wordpress/i18n-translator-comments
|
|
118
|
-
(0, import_i18n.sprintf)((0, import_i18n.__)("We found %1$d duplicated %2$s.", "elementor"), count, name)
|
|
119
|
-
),
|
|
120
|
-
UNEXPECTED_ERROR: (0, import_i18n.__)("There was a glitch.", "elementor"),
|
|
121
|
-
DUPLICATED_LABEL_ACTION: (0, import_i18n.__)("Take me there", "elementor"),
|
|
122
|
-
DUPLICATED_LABEL_ACTION_MESSAGE: (0, import_i18n.__)("Please rename the variables.", "elementor"),
|
|
123
|
-
UNEXPECTED_ERROR_ACTION_MESSAGE: (0, import_i18n.__)("Try saving your variables again.", "elementor")
|
|
124
|
-
}
|
|
125
|
-
};
|
|
126
|
-
var VARIABLE_LABEL_MAX_LENGTH = 50;
|
|
127
|
-
var mapServerError = (error) => {
|
|
128
|
-
if (error?.response?.data?.code === "duplicated_label") {
|
|
129
|
-
return {
|
|
130
|
-
field: "label",
|
|
131
|
-
message: ERROR_MESSAGES.DUPLICATED_LABEL
|
|
132
|
-
};
|
|
133
|
-
}
|
|
134
|
-
if (error?.response?.data?.code === "batch_duplicated_label") {
|
|
135
|
-
const errorData = error?.response?.data?.data ?? {};
|
|
136
|
-
const count = Object.keys(errorData).length;
|
|
137
|
-
const name = count === 1 ? "name" : "names";
|
|
138
|
-
const duplicatedIds = Object.keys(errorData);
|
|
139
|
-
return {
|
|
140
|
-
field: "label",
|
|
141
|
-
message: ERROR_MESSAGES.BATCH.DUPLICATED_LABELS(count, name),
|
|
142
|
-
severity: "error",
|
|
143
|
-
IconComponent: import_icons.AlertTriangleFilledIcon,
|
|
144
|
-
action: {
|
|
145
|
-
label: ERROR_MESSAGES.BATCH.DUPLICATED_LABEL_ACTION,
|
|
146
|
-
message: ERROR_MESSAGES.BATCH.DUPLICATED_LABEL_ACTION_MESSAGE,
|
|
147
|
-
data: {
|
|
148
|
-
duplicatedIds
|
|
149
|
-
}
|
|
150
|
-
}
|
|
151
|
-
};
|
|
152
|
-
}
|
|
153
|
-
if (error?.response?.data?.code === "batch_operation_failed") {
|
|
154
|
-
return {
|
|
155
|
-
field: "label",
|
|
156
|
-
message: ERROR_MESSAGES.BATCH.UNEXPECTED_ERROR,
|
|
157
|
-
severity: "secondary",
|
|
158
|
-
IconComponent: import_icons.InfoCircleFilledIcon,
|
|
159
|
-
action: {
|
|
160
|
-
message: ERROR_MESSAGES.BATCH.UNEXPECTED_ERROR_ACTION_MESSAGE
|
|
161
|
-
}
|
|
162
|
-
};
|
|
163
|
-
}
|
|
164
|
-
return void 0;
|
|
165
|
-
};
|
|
166
|
-
var validateLabel = (name, variables) => {
|
|
167
|
-
if (!name.trim()) {
|
|
168
|
-
return ERROR_MESSAGES.MISSING_VARIABLE_NAME;
|
|
169
|
-
}
|
|
170
|
-
const allowedChars = /^[a-zA-Z0-9_-]+$/;
|
|
171
|
-
if (!allowedChars.test(name)) {
|
|
172
|
-
return ERROR_MESSAGES.INVALID_CHARACTERS;
|
|
173
|
-
}
|
|
174
|
-
const hasAlphanumeric = /[a-zA-Z0-9]/;
|
|
175
|
-
if (!hasAlphanumeric.test(name)) {
|
|
176
|
-
return ERROR_MESSAGES.NO_NON_SPECIAL_CHARACTER;
|
|
177
|
-
}
|
|
178
|
-
if (VARIABLE_LABEL_MAX_LENGTH < name.length) {
|
|
179
|
-
return ERROR_MESSAGES.VARIABLE_LABEL_MAX_LENGTH;
|
|
180
|
-
}
|
|
181
|
-
if (Object.values(variables ?? {}).some((variable) => variable.label === name)) {
|
|
182
|
-
return ERROR_MESSAGES.DUPLICATED_LABEL;
|
|
183
|
-
}
|
|
184
|
-
return "";
|
|
185
|
-
};
|
|
186
|
-
var labelHint = (name) => {
|
|
187
|
-
const hintThreshold = VARIABLE_LABEL_MAX_LENGTH * 0.8 - 1;
|
|
188
|
-
if (hintThreshold < name.length) {
|
|
189
|
-
return ERROR_MESSAGES.VARIABLE_LABEL_MAX_LENGTH;
|
|
190
|
-
}
|
|
191
|
-
return "";
|
|
192
|
-
};
|
|
193
|
-
var validateValue = (value) => {
|
|
194
|
-
if (!value.trim()) {
|
|
195
|
-
return ERROR_MESSAGES.MISSING_VARIABLE_VALUE;
|
|
196
|
-
}
|
|
197
|
-
return "";
|
|
198
|
-
};
|
|
199
|
-
|
|
200
|
-
// src/variables-registry/create-variable-type-registry.ts
|
|
201
|
-
var import_editor_canvas3 = require("@elementor/editor-canvas");
|
|
202
|
-
|
|
203
|
-
// src/transformers/inheritance-transformer.tsx
|
|
204
|
-
var React = __toESM(require("react"));
|
|
205
|
-
var import_editor_canvas = require("@elementor/editor-canvas");
|
|
206
|
-
var import_ui2 = require("@elementor/ui");
|
|
207
|
-
var import_i18n3 = require("@wordpress/i18n");
|
|
208
|
-
|
|
209
|
-
// src/components/ui/color-indicator.tsx
|
|
210
|
-
var import_ui = require("@elementor/ui");
|
|
211
|
-
var ColorIndicator = (0, import_ui.styled)(import_ui.UnstableColorIndicator)(({ theme }) => ({
|
|
212
|
-
borderRadius: `${theme.shape.borderRadius / 2}px`,
|
|
213
|
-
marginRight: theme.spacing(0.25)
|
|
214
|
-
}));
|
|
215
|
-
|
|
216
|
-
// src/prop-types/color-variable-prop-type.ts
|
|
217
|
-
var import_editor_props = require("@elementor/editor-props");
|
|
218
|
-
var import_schema = require("@elementor/schema");
|
|
219
|
-
var colorVariablePropTypeUtil = (0, import_editor_props.createPropUtils)("global-color-variable", import_schema.z.string());
|
|
52
|
+
// src/components/global-styles-import-listener.tsx
|
|
53
|
+
var import_react = require("react");
|
|
220
54
|
|
|
221
55
|
// src/service.ts
|
|
222
|
-
var
|
|
56
|
+
var import_i18n = require("@wordpress/i18n");
|
|
223
57
|
|
|
224
58
|
// src/api.ts
|
|
225
59
|
var import_http_client = require("@elementor/http-client");
|
|
@@ -384,9 +218,9 @@ var Storage = class {
|
|
|
384
218
|
var import_editor_v1_adapters = require("@elementor/editor-v1-adapters");
|
|
385
219
|
|
|
386
220
|
// src/prop-types/font-variable-prop-type.ts
|
|
387
|
-
var
|
|
388
|
-
var
|
|
389
|
-
var fontVariablePropTypeUtil = (0,
|
|
221
|
+
var import_editor_props = require("@elementor/editor-props");
|
|
222
|
+
var import_schema = require("@elementor/schema");
|
|
223
|
+
var fontVariablePropTypeUtil = (0, import_editor_props.createPropUtils)("global-font-variable", import_schema.z.string());
|
|
390
224
|
|
|
391
225
|
// src/create-style-variables-repository.ts
|
|
392
226
|
var createStyleVariablesRepository = () => {
|
|
@@ -498,7 +332,7 @@ var service = {
|
|
|
498
332
|
return apiClient.create(type, label, value).then((response) => {
|
|
499
333
|
const { success, data: payload } = response.data;
|
|
500
334
|
if (!success) {
|
|
501
|
-
const errorMessage = payload?.message || (0,
|
|
335
|
+
const errorMessage = payload?.message || (0, import_i18n.__)("Unexpected response from server", "elementor");
|
|
502
336
|
throw new Error(errorMessage);
|
|
503
337
|
}
|
|
504
338
|
return payload;
|
|
@@ -520,7 +354,7 @@ var service = {
|
|
|
520
354
|
return apiClient.update(id2, label, value, type).then((response) => {
|
|
521
355
|
const { success, data: payload } = response.data;
|
|
522
356
|
if (!success) {
|
|
523
|
-
const errorMessage = payload?.message || (0,
|
|
357
|
+
const errorMessage = payload?.message || (0, import_i18n.__)("Unexpected response from server", "elementor");
|
|
524
358
|
throw new Error(errorMessage);
|
|
525
359
|
}
|
|
526
360
|
return payload;
|
|
@@ -629,6 +463,199 @@ var handleWatermark = (operation, newWatermark) => {
|
|
|
629
463
|
storage.watermark(newWatermark);
|
|
630
464
|
};
|
|
631
465
|
|
|
466
|
+
// src/components/global-styles-import-listener.tsx
|
|
467
|
+
function GlobalStylesImportListener() {
|
|
468
|
+
(0, import_react.useEffect)(() => {
|
|
469
|
+
const handleGlobalStylesImported = (event) => {
|
|
470
|
+
const importedVars = event.detail?.global_variables;
|
|
471
|
+
if (!importedVars) {
|
|
472
|
+
return;
|
|
473
|
+
}
|
|
474
|
+
if (importedVars.data && typeof importedVars.data === "object") {
|
|
475
|
+
styleVariablesRepository.update(importedVars.data);
|
|
476
|
+
}
|
|
477
|
+
service.load();
|
|
478
|
+
};
|
|
479
|
+
window.addEventListener("elementor/global-styles/imported", handleGlobalStylesImported);
|
|
480
|
+
return () => {
|
|
481
|
+
window.removeEventListener(
|
|
482
|
+
"elementor/global-styles/imported",
|
|
483
|
+
handleGlobalStylesImported
|
|
484
|
+
);
|
|
485
|
+
};
|
|
486
|
+
}, []);
|
|
487
|
+
return null;
|
|
488
|
+
}
|
|
489
|
+
|
|
490
|
+
// src/components/open-panel-from-event.tsx
|
|
491
|
+
var import_react15 = require("react");
|
|
492
|
+
var import_editor_v1_adapters3 = require("@elementor/editor-v1-adapters");
|
|
493
|
+
|
|
494
|
+
// src/components/variables-manager/variables-manager-panel.tsx
|
|
495
|
+
var React14 = __toESM(require("react"));
|
|
496
|
+
var import_react14 = require("react");
|
|
497
|
+
var import_editor_current_user2 = require("@elementor/editor-current-user");
|
|
498
|
+
var import_editor_panels = require("@elementor/editor-panels");
|
|
499
|
+
var import_editor_ui5 = require("@elementor/editor-ui");
|
|
500
|
+
var import_editor_v1_adapters2 = require("@elementor/editor-v1-adapters");
|
|
501
|
+
var import_icons5 = require("@elementor/icons");
|
|
502
|
+
var import_ui14 = require("@elementor/ui");
|
|
503
|
+
var import_i18n10 = require("@wordpress/i18n");
|
|
504
|
+
|
|
505
|
+
// src/utils/tracking.ts
|
|
506
|
+
var import_events = require("@elementor/events");
|
|
507
|
+
var trackVariableEvent = ({ varType, controlPath, action }) => {
|
|
508
|
+
const { dispatchEvent, config } = (0, import_events.getMixpanel)();
|
|
509
|
+
if (!config?.names?.variables?.[action]) {
|
|
510
|
+
return;
|
|
511
|
+
}
|
|
512
|
+
const name = config.names.variables[action];
|
|
513
|
+
dispatchEvent?.(name, {
|
|
514
|
+
location: config?.locations?.variables || "",
|
|
515
|
+
secondaryLocation: config?.secondaryLocations?.variablesPopover || "",
|
|
516
|
+
trigger: config?.triggers?.click || "",
|
|
517
|
+
var_type: varType,
|
|
518
|
+
control_path: controlPath,
|
|
519
|
+
action_type: name
|
|
520
|
+
});
|
|
521
|
+
};
|
|
522
|
+
var trackVariablesManagerEvent = ({ action, varType, controlPath }) => {
|
|
523
|
+
const { dispatchEvent, config } = (0, import_events.getMixpanel)();
|
|
524
|
+
if (!config?.names?.variables?.[action]) {
|
|
525
|
+
return;
|
|
526
|
+
}
|
|
527
|
+
const name = config.names.variables[action];
|
|
528
|
+
const eventData = {
|
|
529
|
+
location: config?.locations?.variablesManager || "",
|
|
530
|
+
trigger: config?.triggers?.click || "",
|
|
531
|
+
action_type: name
|
|
532
|
+
};
|
|
533
|
+
if (varType) {
|
|
534
|
+
eventData.var_type = varType;
|
|
535
|
+
}
|
|
536
|
+
if (controlPath) {
|
|
537
|
+
eventData.style_control_path = controlPath;
|
|
538
|
+
}
|
|
539
|
+
dispatchEvent?.(name, eventData);
|
|
540
|
+
};
|
|
541
|
+
|
|
542
|
+
// src/utils/validations.ts
|
|
543
|
+
var import_icons = require("@elementor/icons");
|
|
544
|
+
var import_i18n2 = require("@wordpress/i18n");
|
|
545
|
+
var ERROR_MESSAGES = {
|
|
546
|
+
MISSING_VARIABLE_NAME: (0, import_i18n2.__)("Give your variable a name.", "elementor"),
|
|
547
|
+
MISSING_VARIABLE_VALUE: (0, import_i18n2.__)("Add a value to complete your variable.", "elementor"),
|
|
548
|
+
INVALID_CHARACTERS: (0, import_i18n2.__)("Use letters, numbers, dashes (-), or underscores (_) for the name.", "elementor"),
|
|
549
|
+
NO_NON_SPECIAL_CHARACTER: (0, import_i18n2.__)("Names have to include at least one non-special character.", "elementor"),
|
|
550
|
+
VARIABLE_LABEL_MAX_LENGTH: (0, import_i18n2.__)("Keep names up to 50 characters.", "elementor"),
|
|
551
|
+
DUPLICATED_LABEL: (0, import_i18n2.__)("This variable name already exists. Please choose a unique name.", "elementor"),
|
|
552
|
+
UNEXPECTED_ERROR: (0, import_i18n2.__)("There was a glitch. Try saving your variable again.", "elementor"),
|
|
553
|
+
BATCH: {
|
|
554
|
+
DUPLICATED_LABELS: (count, name) => (
|
|
555
|
+
// eslint-disable-next-line @wordpress/i18n-translator-comments
|
|
556
|
+
(0, import_i18n2.sprintf)((0, import_i18n2.__)("We found %1$d duplicated %2$s.", "elementor"), count, name)
|
|
557
|
+
),
|
|
558
|
+
UNEXPECTED_ERROR: (0, import_i18n2.__)("There was a glitch.", "elementor"),
|
|
559
|
+
DUPLICATED_LABEL_ACTION: (0, import_i18n2.__)("Take me there", "elementor"),
|
|
560
|
+
DUPLICATED_LABEL_ACTION_MESSAGE: (0, import_i18n2.__)("Please rename the variables.", "elementor"),
|
|
561
|
+
UNEXPECTED_ERROR_ACTION_MESSAGE: (0, import_i18n2.__)("Try saving your variables again.", "elementor")
|
|
562
|
+
}
|
|
563
|
+
};
|
|
564
|
+
var VARIABLE_LABEL_MAX_LENGTH = 50;
|
|
565
|
+
var mapServerError = (error) => {
|
|
566
|
+
if (error?.response?.data?.code === "duplicated_label") {
|
|
567
|
+
return {
|
|
568
|
+
field: "label",
|
|
569
|
+
message: ERROR_MESSAGES.DUPLICATED_LABEL
|
|
570
|
+
};
|
|
571
|
+
}
|
|
572
|
+
if (error?.response?.data?.code === "batch_duplicated_label") {
|
|
573
|
+
const errorData = error?.response?.data?.data ?? {};
|
|
574
|
+
const count = Object.keys(errorData).length;
|
|
575
|
+
const name = count === 1 ? "name" : "names";
|
|
576
|
+
const duplicatedIds = Object.keys(errorData);
|
|
577
|
+
return {
|
|
578
|
+
field: "label",
|
|
579
|
+
message: ERROR_MESSAGES.BATCH.DUPLICATED_LABELS(count, name),
|
|
580
|
+
severity: "error",
|
|
581
|
+
IconComponent: import_icons.AlertTriangleFilledIcon,
|
|
582
|
+
action: {
|
|
583
|
+
label: ERROR_MESSAGES.BATCH.DUPLICATED_LABEL_ACTION,
|
|
584
|
+
message: ERROR_MESSAGES.BATCH.DUPLICATED_LABEL_ACTION_MESSAGE,
|
|
585
|
+
data: {
|
|
586
|
+
duplicatedIds
|
|
587
|
+
}
|
|
588
|
+
}
|
|
589
|
+
};
|
|
590
|
+
}
|
|
591
|
+
if (error?.response?.data?.code === "batch_operation_failed") {
|
|
592
|
+
return {
|
|
593
|
+
field: "label",
|
|
594
|
+
message: ERROR_MESSAGES.BATCH.UNEXPECTED_ERROR,
|
|
595
|
+
severity: "secondary",
|
|
596
|
+
IconComponent: import_icons.InfoCircleFilledIcon,
|
|
597
|
+
action: {
|
|
598
|
+
message: ERROR_MESSAGES.BATCH.UNEXPECTED_ERROR_ACTION_MESSAGE
|
|
599
|
+
}
|
|
600
|
+
};
|
|
601
|
+
}
|
|
602
|
+
return void 0;
|
|
603
|
+
};
|
|
604
|
+
var validateLabel = (name, variables) => {
|
|
605
|
+
if (!name.trim()) {
|
|
606
|
+
return ERROR_MESSAGES.MISSING_VARIABLE_NAME;
|
|
607
|
+
}
|
|
608
|
+
const allowedChars = /^[a-zA-Z0-9_-]+$/;
|
|
609
|
+
if (!allowedChars.test(name)) {
|
|
610
|
+
return ERROR_MESSAGES.INVALID_CHARACTERS;
|
|
611
|
+
}
|
|
612
|
+
const hasAlphanumeric = /[a-zA-Z0-9]/;
|
|
613
|
+
if (!hasAlphanumeric.test(name)) {
|
|
614
|
+
return ERROR_MESSAGES.NO_NON_SPECIAL_CHARACTER;
|
|
615
|
+
}
|
|
616
|
+
if (VARIABLE_LABEL_MAX_LENGTH < name.length) {
|
|
617
|
+
return ERROR_MESSAGES.VARIABLE_LABEL_MAX_LENGTH;
|
|
618
|
+
}
|
|
619
|
+
if (Object.values(variables ?? {}).some((variable) => variable.label === name)) {
|
|
620
|
+
return ERROR_MESSAGES.DUPLICATED_LABEL;
|
|
621
|
+
}
|
|
622
|
+
return "";
|
|
623
|
+
};
|
|
624
|
+
var labelHint = (name) => {
|
|
625
|
+
const hintThreshold = VARIABLE_LABEL_MAX_LENGTH * 0.8 - 1;
|
|
626
|
+
if (hintThreshold < name.length) {
|
|
627
|
+
return ERROR_MESSAGES.VARIABLE_LABEL_MAX_LENGTH;
|
|
628
|
+
}
|
|
629
|
+
return "";
|
|
630
|
+
};
|
|
631
|
+
var validateValue = (value) => {
|
|
632
|
+
if (!value.trim()) {
|
|
633
|
+
return ERROR_MESSAGES.MISSING_VARIABLE_VALUE;
|
|
634
|
+
}
|
|
635
|
+
return "";
|
|
636
|
+
};
|
|
637
|
+
|
|
638
|
+
// src/variables-registry/create-variable-type-registry.ts
|
|
639
|
+
var import_editor_canvas3 = require("@elementor/editor-canvas");
|
|
640
|
+
|
|
641
|
+
// src/transformers/inheritance-transformer.tsx
|
|
642
|
+
var React = __toESM(require("react"));
|
|
643
|
+
var import_editor_canvas = require("@elementor/editor-canvas");
|
|
644
|
+
var import_ui2 = require("@elementor/ui");
|
|
645
|
+
var import_i18n3 = require("@wordpress/i18n");
|
|
646
|
+
|
|
647
|
+
// src/components/ui/color-indicator.tsx
|
|
648
|
+
var import_ui = require("@elementor/ui");
|
|
649
|
+
var ColorIndicator = (0, import_ui.styled)(import_ui.UnstableColorIndicator)(({ theme }) => ({
|
|
650
|
+
borderRadius: `${theme.shape.borderRadius / 2}px`,
|
|
651
|
+
marginRight: theme.spacing(0.25)
|
|
652
|
+
}));
|
|
653
|
+
|
|
654
|
+
// src/prop-types/color-variable-prop-type.ts
|
|
655
|
+
var import_editor_props2 = require("@elementor/editor-props");
|
|
656
|
+
var import_schema2 = require("@elementor/schema");
|
|
657
|
+
var colorVariablePropTypeUtil = (0, import_editor_props2.createPropUtils)("global-color-variable", import_schema2.z.string());
|
|
658
|
+
|
|
632
659
|
// src/transformers/utils/resolve-css-variable.ts
|
|
633
660
|
var resolveCssVariable = (id2, variable) => {
|
|
634
661
|
let name = id2;
|
|
@@ -831,13 +858,13 @@ var NoSearchResults = ({ searchValue, onClear, icon }) => {
|
|
|
831
858
|
};
|
|
832
859
|
|
|
833
860
|
// src/components/variables-manager/hooks/use-auto-edit.ts
|
|
834
|
-
var
|
|
861
|
+
var import_react2 = require("react");
|
|
835
862
|
var useAutoEdit = () => {
|
|
836
|
-
const [autoEditVariableId, setAutoEditVariableId] = (0,
|
|
837
|
-
const startAutoEdit = (0,
|
|
863
|
+
const [autoEditVariableId, setAutoEditVariableId] = (0, import_react2.useState)(void 0);
|
|
864
|
+
const startAutoEdit = (0, import_react2.useCallback)((variableId) => {
|
|
838
865
|
setAutoEditVariableId(variableId);
|
|
839
866
|
}, []);
|
|
840
|
-
const handleAutoEditComplete = (0,
|
|
867
|
+
const handleAutoEditComplete = (0, import_react2.useCallback)(() => {
|
|
841
868
|
setTimeout(() => {
|
|
842
869
|
setAutoEditVariableId(void 0);
|
|
843
870
|
}, 100);
|
|
@@ -850,10 +877,10 @@ var useAutoEdit = () => {
|
|
|
850
877
|
};
|
|
851
878
|
|
|
852
879
|
// src/components/variables-manager/hooks/use-error-navigation.ts
|
|
853
|
-
var
|
|
880
|
+
var import_react3 = require("react");
|
|
854
881
|
var useErrorNavigation = () => {
|
|
855
|
-
const currentIndexRef = (0,
|
|
856
|
-
const createNavigationCallback = (0,
|
|
882
|
+
const currentIndexRef = (0, import_react3.useRef)(0);
|
|
883
|
+
const createNavigationCallback = (0, import_react3.useCallback)(
|
|
857
884
|
(ids, onNavigate, onComplete) => {
|
|
858
885
|
return () => {
|
|
859
886
|
if (!ids?.length) {
|
|
@@ -875,7 +902,7 @@ var useErrorNavigation = () => {
|
|
|
875
902
|
},
|
|
876
903
|
[]
|
|
877
904
|
);
|
|
878
|
-
const resetNavigation = (0,
|
|
905
|
+
const resetNavigation = (0, import_react3.useCallback)(() => {
|
|
879
906
|
currentIndexRef.current = 0;
|
|
880
907
|
}, []);
|
|
881
908
|
return {
|
|
@@ -885,21 +912,21 @@ var useErrorNavigation = () => {
|
|
|
885
912
|
};
|
|
886
913
|
|
|
887
914
|
// src/components/variables-manager/hooks/use-variables-manager-state.ts
|
|
888
|
-
var
|
|
915
|
+
var import_react6 = require("react");
|
|
889
916
|
|
|
890
917
|
// src/hooks/use-prop-variables.ts
|
|
891
|
-
var
|
|
918
|
+
var import_react5 = require("react");
|
|
892
919
|
var import_editor_controls = require("@elementor/editor-controls");
|
|
893
920
|
|
|
894
921
|
// src/context/variable-type-context.tsx
|
|
895
922
|
var React5 = __toESM(require("react"));
|
|
896
|
-
var
|
|
897
|
-
var VariableTypeContext = (0,
|
|
923
|
+
var import_react4 = require("react");
|
|
924
|
+
var VariableTypeContext = (0, import_react4.createContext)(null);
|
|
898
925
|
function VariableTypeProvider({ children, propTypeKey }) {
|
|
899
926
|
return /* @__PURE__ */ React5.createElement(VariableTypeContext.Provider, { value: propTypeKey }, children);
|
|
900
927
|
}
|
|
901
928
|
function useVariableType() {
|
|
902
|
-
const context = (0,
|
|
929
|
+
const context = (0, import_react4.useContext)(VariableTypeContext);
|
|
903
930
|
if (context === null) {
|
|
904
931
|
throw new Error("useVariableType must be used within a VariableTypeProvider");
|
|
905
932
|
}
|
|
@@ -982,7 +1009,7 @@ var useVariableSelectionFilter = (variables) => {
|
|
|
982
1009
|
return selectionFilter ? selectionFilter(variables, propType) : variables;
|
|
983
1010
|
};
|
|
984
1011
|
var usePropVariables = (propKey) => {
|
|
985
|
-
return (0,
|
|
1012
|
+
return (0, import_react5.useMemo)(() => normalizeVariables(propKey), [propKey]);
|
|
986
1013
|
};
|
|
987
1014
|
var getMatchingTypes = (propKey) => {
|
|
988
1015
|
const matchingTypes = [];
|
|
@@ -1016,20 +1043,20 @@ var restoreVariable = (restoreId, label, value, type) => {
|
|
|
1016
1043
|
|
|
1017
1044
|
// src/components/variables-manager/hooks/use-variables-manager-state.ts
|
|
1018
1045
|
var useVariablesManagerState = () => {
|
|
1019
|
-
const [variables, setVariables] = (0,
|
|
1020
|
-
const [deletedVariables, setDeletedVariables] = (0,
|
|
1021
|
-
const [isSaveDisabled, setIsSaveDisabled] = (0,
|
|
1022
|
-
const [isDirty, setIsDirty] = (0,
|
|
1023
|
-
const [isSaving, setIsSaving] = (0,
|
|
1024
|
-
const [searchValue, setSearchValue] = (0,
|
|
1025
|
-
const handleOnChange = (0,
|
|
1046
|
+
const [variables, setVariables] = (0, import_react6.useState)(() => getVariables(false));
|
|
1047
|
+
const [deletedVariables, setDeletedVariables] = (0, import_react6.useState)([]);
|
|
1048
|
+
const [isSaveDisabled, setIsSaveDisabled] = (0, import_react6.useState)(false);
|
|
1049
|
+
const [isDirty, setIsDirty] = (0, import_react6.useState)(false);
|
|
1050
|
+
const [isSaving, setIsSaving] = (0, import_react6.useState)(false);
|
|
1051
|
+
const [searchValue, setSearchValue] = (0, import_react6.useState)("");
|
|
1052
|
+
const handleOnChange = (0, import_react6.useCallback)(
|
|
1026
1053
|
(newVariables) => {
|
|
1027
1054
|
setVariables({ ...variables, ...newVariables });
|
|
1028
1055
|
setIsDirty(true);
|
|
1029
1056
|
},
|
|
1030
1057
|
[variables]
|
|
1031
1058
|
);
|
|
1032
|
-
const createVariable2 = (0,
|
|
1059
|
+
const createVariable2 = (0, import_react6.useCallback)((type, defaultName, defaultValue) => {
|
|
1033
1060
|
const newId = generateTempId();
|
|
1034
1061
|
const newVariable = {
|
|
1035
1062
|
id: newId,
|
|
@@ -1041,19 +1068,19 @@ var useVariablesManagerState = () => {
|
|
|
1041
1068
|
setIsDirty(true);
|
|
1042
1069
|
return newId;
|
|
1043
1070
|
}, []);
|
|
1044
|
-
const handleDeleteVariable = (0,
|
|
1071
|
+
const handleDeleteVariable = (0, import_react6.useCallback)((itemId) => {
|
|
1045
1072
|
setDeletedVariables((prev) => [...prev, itemId]);
|
|
1046
1073
|
setVariables((prev) => ({ ...prev, [itemId]: { ...prev[itemId], deleted: true } }));
|
|
1047
1074
|
setIsDirty(true);
|
|
1048
1075
|
}, []);
|
|
1049
|
-
const handleStartSync = (0,
|
|
1076
|
+
const handleStartSync = (0, import_react6.useCallback)((itemId) => {
|
|
1050
1077
|
setVariables((prev) => ({
|
|
1051
1078
|
...prev,
|
|
1052
1079
|
[itemId]: { ...prev[itemId], sync_to_v3: true }
|
|
1053
1080
|
}));
|
|
1054
1081
|
setIsDirty(true);
|
|
1055
1082
|
}, []);
|
|
1056
|
-
const handleStopSync = (0,
|
|
1083
|
+
const handleStopSync = (0, import_react6.useCallback)((itemId) => {
|
|
1057
1084
|
setVariables((prev) => ({
|
|
1058
1085
|
...prev,
|
|
1059
1086
|
[itemId]: { ...prev[itemId], sync_to_v3: false }
|
|
@@ -1063,7 +1090,7 @@ var useVariablesManagerState = () => {
|
|
|
1063
1090
|
const handleSearch = (searchTerm) => {
|
|
1064
1091
|
setSearchValue(searchTerm);
|
|
1065
1092
|
};
|
|
1066
|
-
const handleSave = (0,
|
|
1093
|
+
const handleSave = (0, import_react6.useCallback)(async () => {
|
|
1067
1094
|
const originalVariables = getVariables(false);
|
|
1068
1095
|
setIsSaving(true);
|
|
1069
1096
|
const result = await service.batchSave(originalVariables, variables, deletedVariables);
|
|
@@ -1076,7 +1103,7 @@ var useVariablesManagerState = () => {
|
|
|
1076
1103
|
}
|
|
1077
1104
|
return { success: result.success };
|
|
1078
1105
|
}, [variables, deletedVariables]);
|
|
1079
|
-
const filteredVariables = (0,
|
|
1106
|
+
const filteredVariables = (0, import_react6.useCallback)(() => {
|
|
1080
1107
|
const list = variablesToList(variables).filter((v) => !v.deleted);
|
|
1081
1108
|
const typeFiltered = applySelectionFilters(list, getVariableTypes());
|
|
1082
1109
|
const searchFiltered = filterBySearch(typeFiltered, searchValue);
|
|
@@ -1103,7 +1130,7 @@ var useVariablesManagerState = () => {
|
|
|
1103
1130
|
|
|
1104
1131
|
// src/components/variables-manager/variables-manager-create-menu.tsx
|
|
1105
1132
|
var React7 = __toESM(require("react"));
|
|
1106
|
-
var
|
|
1133
|
+
var import_react8 = require("react");
|
|
1107
1134
|
var import_icons2 = require("@elementor/icons");
|
|
1108
1135
|
var import_ui7 = require("@elementor/ui");
|
|
1109
1136
|
var import_utils2 = require("@elementor/utils");
|
|
@@ -1126,17 +1153,17 @@ var useQuotaPermissions = (variableType) => {
|
|
|
1126
1153
|
|
|
1127
1154
|
// src/components/ui/variable-promotion-chip.tsx
|
|
1128
1155
|
var React6 = __toESM(require("react"));
|
|
1129
|
-
var
|
|
1156
|
+
var import_react7 = require("react");
|
|
1130
1157
|
var import_editor_controls2 = require("@elementor/editor-controls");
|
|
1131
1158
|
var import_editor_ui2 = require("@elementor/editor-ui");
|
|
1132
1159
|
var import_ui6 = require("@elementor/ui");
|
|
1133
1160
|
var import_utils = require("@elementor/utils");
|
|
1134
1161
|
var import_i18n7 = require("@wordpress/i18n");
|
|
1135
|
-
var VariablePromotionChip = (0,
|
|
1162
|
+
var VariablePromotionChip = (0, import_react7.forwardRef)(
|
|
1136
1163
|
({ variableType, upgradeUrl, trackingData }, ref) => {
|
|
1137
|
-
const [isOpen, setIsOpen] = (0,
|
|
1164
|
+
const [isOpen, setIsOpen] = (0, import_react7.useState)(false);
|
|
1138
1165
|
(0, import_editor_ui2.useCanvasClickHandler)(isOpen, () => setIsOpen(false));
|
|
1139
|
-
const toggle = (0,
|
|
1166
|
+
const toggle = (0, import_react7.useCallback)(() => {
|
|
1140
1167
|
setIsOpen((prev) => {
|
|
1141
1168
|
if (!prev) {
|
|
1142
1169
|
(0, import_editor_controls2.trackViewPromotion)(trackingData);
|
|
@@ -1144,7 +1171,7 @@ var VariablePromotionChip = (0, import_react6.forwardRef)(
|
|
|
1144
1171
|
return !prev;
|
|
1145
1172
|
});
|
|
1146
1173
|
}, [trackingData]);
|
|
1147
|
-
(0,
|
|
1174
|
+
(0, import_react7.useImperativeHandle)(ref, () => ({ toggle }), [toggle]);
|
|
1148
1175
|
const title = (0, import_i18n7.sprintf)(
|
|
1149
1176
|
/* translators: %s: Variable Type. */
|
|
1150
1177
|
(0, import_i18n7.__)("%s variables", "elementor"),
|
|
@@ -1192,9 +1219,9 @@ var TRACKING_DATA = {
|
|
|
1192
1219
|
};
|
|
1193
1220
|
var SIZE = "tiny";
|
|
1194
1221
|
var VariableManagerCreateMenu = ({ variables, onCreate, menuState }) => {
|
|
1195
|
-
const buttonRef = (0,
|
|
1222
|
+
const buttonRef = (0, import_react8.useRef)(null);
|
|
1196
1223
|
const variableTypes = getVariableTypes();
|
|
1197
|
-
const menuOptionConfigs = (0,
|
|
1224
|
+
const menuOptionConfigs = (0, import_react8.useMemo)(
|
|
1198
1225
|
() => Object.entries(variableTypes).filter(([, variable]) => !!variable.defaultValue).map(([key, variable]) => ({
|
|
1199
1226
|
key,
|
|
1200
1227
|
propTypeKey: variable.propTypeUtil.key,
|
|
@@ -1253,7 +1280,7 @@ var MenuOption = ({
|
|
|
1253
1280
|
onCreate,
|
|
1254
1281
|
onClose
|
|
1255
1282
|
}) => {
|
|
1256
|
-
const promotionRef = (0,
|
|
1283
|
+
const promotionRef = (0, import_react8.useRef)(null);
|
|
1257
1284
|
const userQuotaPermissions = useQuotaPermissions(config.propTypeKey);
|
|
1258
1285
|
const displayName = (0, import_utils2.capitalize)(config.variableType);
|
|
1259
1286
|
const isDisabled = !userQuotaPermissions.canAdd();
|
|
@@ -1267,7 +1294,7 @@ var MenuOption = ({
|
|
|
1267
1294
|
trackVariablesManagerEvent({ action: "add", varType: config.variableType });
|
|
1268
1295
|
onClose();
|
|
1269
1296
|
};
|
|
1270
|
-
return /* @__PURE__ */ React7.createElement(import_ui7.MenuItem, { onClick: handleClick, sx: { gap: 1.5, cursor: "pointer" } }, (0,
|
|
1297
|
+
return /* @__PURE__ */ React7.createElement(import_ui7.MenuItem, { onClick: handleClick, sx: { gap: 1.5, cursor: "pointer" } }, (0, import_react8.createElement)(config.icon, { fontSize: SIZE, color: isDisabled ? "disabled" : "action" }), /* @__PURE__ */ React7.createElement(import_ui7.Typography, { variant: "caption", color: isDisabled ? "text.disabled" : "text.primary" }, displayName), isDisabled && /* @__PURE__ */ React7.createElement(
|
|
1271
1298
|
VariablePromotionChip,
|
|
1272
1299
|
{
|
|
1273
1300
|
variableType: config.variableType,
|
|
@@ -1295,7 +1322,7 @@ var getDefaultName = (variables, baseName) => {
|
|
|
1295
1322
|
|
|
1296
1323
|
// src/components/variables-manager/variables-manager-table.tsx
|
|
1297
1324
|
var React13 = __toESM(require("react"));
|
|
1298
|
-
var
|
|
1325
|
+
var import_react13 = require("react");
|
|
1299
1326
|
var import_ui13 = require("@elementor/ui");
|
|
1300
1327
|
var import_i18n9 = require("@wordpress/i18n");
|
|
1301
1328
|
|
|
@@ -1325,21 +1352,21 @@ var VariableTableCell = ({
|
|
|
1325
1352
|
|
|
1326
1353
|
// src/components/variables-manager/ui/variable-table-row.tsx
|
|
1327
1354
|
var React12 = __toESM(require("react"));
|
|
1328
|
-
var
|
|
1355
|
+
var import_react12 = require("react");
|
|
1329
1356
|
var import_editor_ui4 = require("@elementor/editor-ui");
|
|
1330
1357
|
var import_icons4 = require("@elementor/icons");
|
|
1331
1358
|
var import_ui12 = require("@elementor/ui");
|
|
1332
1359
|
|
|
1333
1360
|
// src/components/fields/label-field.tsx
|
|
1334
1361
|
var React9 = __toESM(require("react"));
|
|
1335
|
-
var
|
|
1362
|
+
var import_react9 = require("react");
|
|
1336
1363
|
var import_editor_ui3 = require("@elementor/editor-ui");
|
|
1337
1364
|
var import_ui9 = require("@elementor/ui");
|
|
1338
1365
|
function isLabelEqual(a, b) {
|
|
1339
1366
|
return a.trim().toLowerCase() === b.trim().toLowerCase();
|
|
1340
1367
|
}
|
|
1341
1368
|
var useLabelError = (initialError) => {
|
|
1342
|
-
const [error, setError] = (0,
|
|
1369
|
+
const [error, setError] = (0, import_react9.useState)(initialError ?? { value: "", message: "" });
|
|
1343
1370
|
return {
|
|
1344
1371
|
labelFieldError: error,
|
|
1345
1372
|
setLabelFieldError: setError
|
|
@@ -1358,9 +1385,9 @@ var LabelField = ({
|
|
|
1358
1385
|
variables,
|
|
1359
1386
|
onKeyDown
|
|
1360
1387
|
}) => {
|
|
1361
|
-
const [label, setLabel] = (0,
|
|
1362
|
-
const [errorMessage, setErrorMessage] = (0,
|
|
1363
|
-
const fieldRef = (0,
|
|
1388
|
+
const [label, setLabel] = (0, import_react9.useState)(value);
|
|
1389
|
+
const [errorMessage, setErrorMessage] = (0, import_react9.useState)("");
|
|
1390
|
+
const fieldRef = (0, import_react9.useRef)(null);
|
|
1364
1391
|
const handleChange = (newValue) => {
|
|
1365
1392
|
setLabel(newValue);
|
|
1366
1393
|
const errorMsg2 = validateLabel(newValue, variables);
|
|
@@ -1412,7 +1439,7 @@ var LabelField = ({
|
|
|
1412
1439
|
|
|
1413
1440
|
// src/components/variables-manager/variable-editable-cell.tsx
|
|
1414
1441
|
var React10 = __toESM(require("react"));
|
|
1415
|
-
var
|
|
1442
|
+
var import_react10 = require("react");
|
|
1416
1443
|
var import_ui10 = require("@elementor/ui");
|
|
1417
1444
|
var VariableEditableCell = React10.memo(
|
|
1418
1445
|
({
|
|
@@ -1428,22 +1455,22 @@ var VariableEditableCell = React10.memo(
|
|
|
1428
1455
|
fieldType,
|
|
1429
1456
|
disabled = false
|
|
1430
1457
|
}) => {
|
|
1431
|
-
const [value, setValue] = (0,
|
|
1432
|
-
const [isEditing, setIsEditing] = (0,
|
|
1458
|
+
const [value, setValue] = (0, import_react10.useState)(initialValue);
|
|
1459
|
+
const [isEditing, setIsEditing] = (0, import_react10.useState)(false);
|
|
1433
1460
|
const { labelFieldError, setLabelFieldError } = useLabelError();
|
|
1434
|
-
const [valueFieldError, setValueFieldError] = (0,
|
|
1435
|
-
const rowRef = (0,
|
|
1436
|
-
const handleSave = (0,
|
|
1461
|
+
const [valueFieldError, setValueFieldError] = (0, import_react10.useState)("");
|
|
1462
|
+
const rowRef = (0, import_react10.useRef)(null);
|
|
1463
|
+
const handleSave = (0, import_react10.useCallback)(() => {
|
|
1437
1464
|
const hasError = fieldType === "label" && labelFieldError?.message || fieldType === "value" && valueFieldError;
|
|
1438
1465
|
if (!hasError) {
|
|
1439
1466
|
onChange(value);
|
|
1440
1467
|
}
|
|
1441
1468
|
setIsEditing(false);
|
|
1442
1469
|
}, [value, onChange, fieldType, labelFieldError, valueFieldError]);
|
|
1443
|
-
(0,
|
|
1470
|
+
(0, import_react10.useEffect)(() => {
|
|
1444
1471
|
onRowRef?.(rowRef?.current);
|
|
1445
1472
|
}, [onRowRef]);
|
|
1446
|
-
(0,
|
|
1473
|
+
(0, import_react10.useEffect)(() => {
|
|
1447
1474
|
if (autoEdit && !isEditing && !disabled) {
|
|
1448
1475
|
setIsEditing(true);
|
|
1449
1476
|
onAutoEditComplete?.();
|
|
@@ -1469,10 +1496,10 @@ var VariableEditableCell = React10.memo(
|
|
|
1469
1496
|
setIsEditing(true);
|
|
1470
1497
|
}
|
|
1471
1498
|
};
|
|
1472
|
-
const handleChange = (0,
|
|
1499
|
+
const handleChange = (0, import_react10.useCallback)((newValue) => {
|
|
1473
1500
|
setValue(newValue);
|
|
1474
1501
|
}, []);
|
|
1475
|
-
const handleValidationChange = (0,
|
|
1502
|
+
const handleValidationChange = (0, import_react10.useCallback)(
|
|
1476
1503
|
(errorMsg) => {
|
|
1477
1504
|
if (fieldType === "label") {
|
|
1478
1505
|
setLabelFieldError({
|
|
@@ -1536,7 +1563,7 @@ var VariableEditableCell = React10.memo(
|
|
|
1536
1563
|
|
|
1537
1564
|
// src/components/variables-manager/ui/variable-edit-menu.tsx
|
|
1538
1565
|
var React11 = __toESM(require("react"));
|
|
1539
|
-
var
|
|
1566
|
+
var import_react11 = require("react");
|
|
1540
1567
|
var import_icons3 = require("@elementor/icons");
|
|
1541
1568
|
var import_ui11 = require("@elementor/ui");
|
|
1542
1569
|
var VariableEditMenu = ({ menuActions, disabled, itemId }) => {
|
|
@@ -1593,7 +1620,7 @@ var VariableEditMenu = ({ menuActions, disabled, itemId }) => {
|
|
|
1593
1620
|
gap: 1
|
|
1594
1621
|
}
|
|
1595
1622
|
},
|
|
1596
|
-
action.icon && (0,
|
|
1623
|
+
action.icon && (0, import_react11.createElement)(action.icon, {
|
|
1597
1624
|
fontSize: "inherit"
|
|
1598
1625
|
}),
|
|
1599
1626
|
" ",
|
|
@@ -1624,7 +1651,7 @@ var VariableRow = (props) => {
|
|
|
1624
1651
|
setTriggerRef,
|
|
1625
1652
|
isSorting
|
|
1626
1653
|
} = props;
|
|
1627
|
-
const promotionRef = (0,
|
|
1654
|
+
const promotionRef = (0, import_react12.useRef)(null);
|
|
1628
1655
|
const isDisabled = !useQuotaPermissions(row.type).canEdit();
|
|
1629
1656
|
const showIndicationBefore = showDropIndication && dropPosition === "before";
|
|
1630
1657
|
const showIndicationAfter = showDropIndication && dropPosition === "after";
|
|
@@ -1682,7 +1709,7 @@ var VariableRow = (props) => {
|
|
|
1682
1709
|
});
|
|
1683
1710
|
}
|
|
1684
1711
|
},
|
|
1685
|
-
prefixElement: (0,
|
|
1712
|
+
prefixElement: (0, import_react12.createElement)(row.icon, {
|
|
1686
1713
|
fontSize: "inherit",
|
|
1687
1714
|
color: isDisabled ? "disabled" : "inherit"
|
|
1688
1715
|
}),
|
|
@@ -1782,9 +1809,9 @@ var VariablesManagerTable = ({
|
|
|
1782
1809
|
onAutoEditComplete,
|
|
1783
1810
|
onFieldError
|
|
1784
1811
|
}) => {
|
|
1785
|
-
const tableContainerRef = (0,
|
|
1786
|
-
const variableRowRefs = (0,
|
|
1787
|
-
(0,
|
|
1812
|
+
const tableContainerRef = (0, import_react13.useRef)(null);
|
|
1813
|
+
const variableRowRefs = (0, import_react13.useRef)(/* @__PURE__ */ new Map());
|
|
1814
|
+
(0, import_react13.useEffect)(() => {
|
|
1788
1815
|
if (autoEditVariableId && tableContainerRef.current) {
|
|
1789
1816
|
const rowElement = variableRowRefs.current.get(autoEditVariableId);
|
|
1790
1817
|
if (rowElement) {
|
|
@@ -1915,9 +1942,9 @@ function VariablesManagerPanel() {
|
|
|
1915
1942
|
} = useVariablesManagerState();
|
|
1916
1943
|
const { autoEditVariableId, startAutoEdit, handleAutoEditComplete } = useAutoEdit();
|
|
1917
1944
|
const { createNavigationCallback, resetNavigation } = useErrorNavigation();
|
|
1918
|
-
const [deleteConfirmation, setDeleteConfirmation] = (0,
|
|
1919
|
-
const [stopSyncConfirmation, setStopSyncConfirmation] = (0,
|
|
1920
|
-
const [serverError, setServerError] = (0,
|
|
1945
|
+
const [deleteConfirmation, setDeleteConfirmation] = (0, import_react14.useState)(null);
|
|
1946
|
+
const [stopSyncConfirmation, setStopSyncConfirmation] = (0, import_react14.useState)(null);
|
|
1947
|
+
const [serverError, setServerError] = (0, import_react14.useState)(null);
|
|
1921
1948
|
usePreventUnload(isDirty);
|
|
1922
1949
|
const handleClosePanel = () => {
|
|
1923
1950
|
if (isDirty) {
|
|
@@ -1926,7 +1953,7 @@ function VariablesManagerPanel() {
|
|
|
1926
1953
|
}
|
|
1927
1954
|
closePanel();
|
|
1928
1955
|
};
|
|
1929
|
-
const handleCreateVariable = (0,
|
|
1956
|
+
const handleCreateVariable = (0, import_react14.useCallback)(
|
|
1930
1957
|
(type, defaultName, defaultValue) => {
|
|
1931
1958
|
const newId = createVariable2(type, defaultName, defaultValue);
|
|
1932
1959
|
if (newId) {
|
|
@@ -1960,21 +1987,21 @@ function VariablesManagerPanel() {
|
|
|
1960
1987
|
setIsSaving(false);
|
|
1961
1988
|
}
|
|
1962
1989
|
};
|
|
1963
|
-
const handleDeleteVariableWithConfirmation = (0,
|
|
1990
|
+
const handleDeleteVariableWithConfirmation = (0, import_react14.useCallback)(
|
|
1964
1991
|
(itemId) => {
|
|
1965
1992
|
handleDeleteVariable(itemId);
|
|
1966
1993
|
setDeleteConfirmation(null);
|
|
1967
1994
|
},
|
|
1968
1995
|
[handleDeleteVariable]
|
|
1969
1996
|
);
|
|
1970
|
-
const handleStopSyncWithConfirmation = (0,
|
|
1997
|
+
const handleStopSyncWithConfirmation = (0, import_react14.useCallback)(
|
|
1971
1998
|
(itemId) => {
|
|
1972
1999
|
handleStopSync(itemId);
|
|
1973
2000
|
setStopSyncConfirmation(null);
|
|
1974
2001
|
},
|
|
1975
2002
|
[handleStopSync]
|
|
1976
2003
|
);
|
|
1977
|
-
const handleShowStopSyncDialog = (0,
|
|
2004
|
+
const handleShowStopSyncDialog = (0, import_react14.useCallback)(
|
|
1978
2005
|
(itemId) => {
|
|
1979
2006
|
if (!isStopSyncSuppressed) {
|
|
1980
2007
|
setStopSyncConfirmation(itemId);
|
|
@@ -1984,7 +2011,7 @@ function VariablesManagerPanel() {
|
|
|
1984
2011
|
},
|
|
1985
2012
|
[isStopSyncSuppressed, handleStopSync]
|
|
1986
2013
|
);
|
|
1987
|
-
const buildMenuActions = (0,
|
|
2014
|
+
const buildMenuActions = (0, import_react14.useCallback)(
|
|
1988
2015
|
(variableId) => {
|
|
1989
2016
|
const variable = variables[variableId];
|
|
1990
2017
|
if (!variable) {
|
|
@@ -2176,7 +2203,7 @@ function VariablesManagerPanel() {
|
|
|
2176
2203
|
)));
|
|
2177
2204
|
}
|
|
2178
2205
|
var usePreventUnload = (isDirty) => {
|
|
2179
|
-
(0,
|
|
2206
|
+
(0, import_react14.useEffect)(() => {
|
|
2180
2207
|
const handleBeforeUnload = (event) => {
|
|
2181
2208
|
if (isDirty) {
|
|
2182
2209
|
event.preventDefault();
|
|
@@ -2212,15 +2239,15 @@ var EVENT_NAME = "elementor/open-variables-manager";
|
|
|
2212
2239
|
var DEFAULT_PANEL_ROUTE = "panel/elements/categories";
|
|
2213
2240
|
function OpenPanelFromEvent() {
|
|
2214
2241
|
const { open } = usePanelActions();
|
|
2215
|
-
const pendingRef = (0,
|
|
2216
|
-
const [readyToOpen, setReadyToOpen] = (0,
|
|
2217
|
-
(0,
|
|
2242
|
+
const pendingRef = (0, import_react15.useRef)(false);
|
|
2243
|
+
const [readyToOpen, setReadyToOpen] = (0, import_react15.useState)(false);
|
|
2244
|
+
(0, import_react15.useEffect)(() => {
|
|
2218
2245
|
if (readyToOpen) {
|
|
2219
2246
|
setReadyToOpen(false);
|
|
2220
2247
|
open();
|
|
2221
2248
|
}
|
|
2222
2249
|
}, [readyToOpen, open]);
|
|
2223
|
-
(0,
|
|
2250
|
+
(0, import_react15.useEffect)(() => {
|
|
2224
2251
|
return (0, import_editor_v1_adapters3.__privateListenTo)((0, import_editor_v1_adapters3.routeOpenEvent)(DEFAULT_PANEL_ROUTE), () => {
|
|
2225
2252
|
if (pendingRef.current) {
|
|
2226
2253
|
pendingRef.current = false;
|
|
@@ -2228,7 +2255,7 @@ function OpenPanelFromEvent() {
|
|
|
2228
2255
|
}
|
|
2229
2256
|
});
|
|
2230
2257
|
}, []);
|
|
2231
|
-
(0,
|
|
2258
|
+
(0, import_react15.useEffect)(() => {
|
|
2232
2259
|
const handler = () => {
|
|
2233
2260
|
pendingRef.current = true;
|
|
2234
2261
|
(0, import_editor_v1_adapters3.__privateOpenRoute)(DEFAULT_PANEL_ROUTE);
|
|
@@ -2240,15 +2267,15 @@ function OpenPanelFromEvent() {
|
|
|
2240
2267
|
}
|
|
2241
2268
|
|
|
2242
2269
|
// src/components/open-panel-from-url.tsx
|
|
2243
|
-
var
|
|
2270
|
+
var import_react16 = require("react");
|
|
2244
2271
|
var import_editor_v1_adapters4 = require("@elementor/editor-v1-adapters");
|
|
2245
2272
|
var ACTIVE_PANEL_PARAM = "active-panel";
|
|
2246
2273
|
var PANEL_ID = "variables-manager";
|
|
2247
2274
|
var DEFAULT_PANEL_ROUTE2 = "panel/elements";
|
|
2248
2275
|
function OpenPanelFromUrl() {
|
|
2249
2276
|
const { open } = usePanelActions();
|
|
2250
|
-
const hasOpened = (0,
|
|
2251
|
-
(0,
|
|
2277
|
+
const hasOpened = (0, import_react16.useRef)(false);
|
|
2278
|
+
(0, import_react16.useEffect)(() => {
|
|
2252
2279
|
const urlParams = new URLSearchParams(window.location.search);
|
|
2253
2280
|
const activePanel = urlParams.get(ACTIVE_PANEL_PARAM);
|
|
2254
2281
|
if (activePanel !== PANEL_ID) {
|
|
@@ -2273,7 +2300,7 @@ var React33 = __toESM(require("react"));
|
|
|
2273
2300
|
var import_editor_controls13 = require("@elementor/editor-controls");
|
|
2274
2301
|
|
|
2275
2302
|
// src/components/ui/variable/assigned-variable.tsx
|
|
2276
|
-
var
|
|
2303
|
+
var import_react23 = require("react");
|
|
2277
2304
|
var React24 = __toESM(require("react"));
|
|
2278
2305
|
var import_editor_controls8 = require("@elementor/editor-controls");
|
|
2279
2306
|
var import_icons12 = require("@elementor/icons");
|
|
@@ -2297,25 +2324,25 @@ function createUnlinkHandler(variable, propTypeKey, setValue) {
|
|
|
2297
2324
|
|
|
2298
2325
|
// src/components/variable-selection-popover.tsx
|
|
2299
2326
|
var React22 = __toESM(require("react"));
|
|
2300
|
-
var
|
|
2327
|
+
var import_react22 = require("react");
|
|
2301
2328
|
var import_editor_v1_adapters5 = require("@elementor/editor-v1-adapters");
|
|
2302
2329
|
|
|
2303
2330
|
// src/context/variable-selection-popover.context.tsx
|
|
2304
2331
|
var React15 = __toESM(require("react"));
|
|
2305
|
-
var
|
|
2332
|
+
var import_react17 = require("react");
|
|
2306
2333
|
var import_ui15 = require("@elementor/ui");
|
|
2307
|
-
var PopoverContentRefContext = (0,
|
|
2334
|
+
var PopoverContentRefContext = (0, import_react17.createContext)(null);
|
|
2308
2335
|
var PopoverContentRefContextProvider = ({ children }) => {
|
|
2309
|
-
const [anchorRef, setAnchorRef] = (0,
|
|
2336
|
+
const [anchorRef, setAnchorRef] = (0, import_react17.useState)(null);
|
|
2310
2337
|
return /* @__PURE__ */ React15.createElement(PopoverContentRefContext.Provider, { value: anchorRef }, /* @__PURE__ */ React15.createElement(import_ui15.Box, { ref: setAnchorRef }, children));
|
|
2311
2338
|
};
|
|
2312
2339
|
var usePopoverContentRef = () => {
|
|
2313
|
-
return (0,
|
|
2340
|
+
return (0, import_react17.useContext)(PopoverContentRefContext);
|
|
2314
2341
|
};
|
|
2315
2342
|
|
|
2316
2343
|
// src/components/variable-creation.tsx
|
|
2317
2344
|
var React17 = __toESM(require("react"));
|
|
2318
|
-
var
|
|
2345
|
+
var import_react18 = require("react");
|
|
2319
2346
|
var import_editor_controls5 = require("@elementor/editor-controls");
|
|
2320
2347
|
var import_editor_ui6 = require("@elementor/editor-ui");
|
|
2321
2348
|
var import_icons6 = require("@elementor/icons");
|
|
@@ -2376,11 +2403,11 @@ var VariableCreation = ({ onGoBack, onClose }) => {
|
|
|
2376
2403
|
const { setVariableValue: setVariable, path } = useVariableBoundProp();
|
|
2377
2404
|
const { propType } = (0, import_editor_controls5.useBoundProp)();
|
|
2378
2405
|
const initialValue = useInitialValue();
|
|
2379
|
-
const [value, setValue] = (0,
|
|
2380
|
-
const [label, setLabel] = (0,
|
|
2381
|
-
const [errorMessage, setErrorMessage] = (0,
|
|
2382
|
-
const [valueFieldError, setValueFieldError] = (0,
|
|
2383
|
-
const [propTypeKey, setPropTypeKey] = (0,
|
|
2406
|
+
const [value, setValue] = (0, import_react18.useState)(initialValue);
|
|
2407
|
+
const [label, setLabel] = (0, import_react18.useState)("");
|
|
2408
|
+
const [errorMessage, setErrorMessage] = (0, import_react18.useState)("");
|
|
2409
|
+
const [valueFieldError, setValueFieldError] = (0, import_react18.useState)("");
|
|
2410
|
+
const [propTypeKey, setPropTypeKey] = (0, import_react18.useState)(propTypeUtil.key);
|
|
2384
2411
|
const { labelFieldError, setLabelFieldError } = useLabelError();
|
|
2385
2412
|
const resetFields = () => {
|
|
2386
2413
|
setValue("");
|
|
@@ -2500,7 +2527,7 @@ var VariableCreation = ({ onGoBack, onClose }) => {
|
|
|
2500
2527
|
|
|
2501
2528
|
// src/components/variable-edit.tsx
|
|
2502
2529
|
var React19 = __toESM(require("react"));
|
|
2503
|
-
var
|
|
2530
|
+
var import_react20 = require("react");
|
|
2504
2531
|
var import_editor_controls6 = require("@elementor/editor-controls");
|
|
2505
2532
|
var import_editor_current_user3 = require("@elementor/editor-current-user");
|
|
2506
2533
|
var import_editor_ui7 = require("@elementor/editor-ui");
|
|
@@ -2510,7 +2537,7 @@ var import_i18n13 = require("@wordpress/i18n");
|
|
|
2510
2537
|
|
|
2511
2538
|
// src/components/ui/edit-confirmation-dialog.tsx
|
|
2512
2539
|
var React18 = __toESM(require("react"));
|
|
2513
|
-
var
|
|
2540
|
+
var import_react19 = require("react");
|
|
2514
2541
|
var import_icons7 = require("@elementor/icons");
|
|
2515
2542
|
var import_ui18 = require("@elementor/ui");
|
|
2516
2543
|
var import_i18n12 = require("@wordpress/i18n");
|
|
@@ -2520,7 +2547,7 @@ var EditConfirmationDialog = ({
|
|
|
2520
2547
|
onConfirm,
|
|
2521
2548
|
onSuppressMessage
|
|
2522
2549
|
}) => {
|
|
2523
|
-
const [dontShowAgain, setDontShowAgain] = (0,
|
|
2550
|
+
const [dontShowAgain, setDontShowAgain] = (0, import_react19.useState)(false);
|
|
2524
2551
|
const handleSave = () => {
|
|
2525
2552
|
if (dontShowAgain) {
|
|
2526
2553
|
onSuppressMessage?.();
|
|
@@ -2554,20 +2581,20 @@ var VariableEdit = ({ onClose, onGoBack, onSubmit, editId }) => {
|
|
|
2554
2581
|
const { setVariableValue: notifyBoundPropChange, variableId } = useVariableBoundProp();
|
|
2555
2582
|
const { propType } = (0, import_editor_controls6.useBoundProp)();
|
|
2556
2583
|
const [isMessageSuppressed, suppressMessage] = (0, import_editor_current_user3.useSuppressedMessage)(EDIT_CONFIRMATION_DIALOG_ID);
|
|
2557
|
-
const [deleteConfirmation, setDeleteConfirmation] = (0,
|
|
2558
|
-
const [editConfirmation, setEditConfirmation] = (0,
|
|
2559
|
-
const [errorMessage, setErrorMessage] = (0,
|
|
2560
|
-
const [valueFieldError, setValueFieldError] = (0,
|
|
2584
|
+
const [deleteConfirmation, setDeleteConfirmation] = (0, import_react20.useState)(false);
|
|
2585
|
+
const [editConfirmation, setEditConfirmation] = (0, import_react20.useState)(false);
|
|
2586
|
+
const [errorMessage, setErrorMessage] = (0, import_react20.useState)("");
|
|
2587
|
+
const [valueFieldError, setValueFieldError] = (0, import_react20.useState)("");
|
|
2561
2588
|
const { labelFieldError, setLabelFieldError } = useLabelError();
|
|
2562
2589
|
const variable = useVariable(editId);
|
|
2563
|
-
const [propTypeKey, setPropTypeKey] = (0,
|
|
2590
|
+
const [propTypeKey, setPropTypeKey] = (0, import_react20.useState)(variable?.type ?? propTypeUtil.key);
|
|
2564
2591
|
if (!variable) {
|
|
2565
2592
|
throw new Error(`Global ${variableType} variable not found`);
|
|
2566
2593
|
}
|
|
2567
2594
|
const userPermissions = usePermissions();
|
|
2568
|
-
const [value, setValue] = (0,
|
|
2569
|
-
const [label, setLabel] = (0,
|
|
2570
|
-
(0,
|
|
2595
|
+
const [value, setValue] = (0, import_react20.useState)(() => variable.value);
|
|
2596
|
+
const [label, setLabel] = (0, import_react20.useState)(() => variable.label);
|
|
2597
|
+
(0, import_react20.useEffect)(() => {
|
|
2571
2598
|
styleVariablesRepository.update({
|
|
2572
2599
|
[editId]: {
|
|
2573
2600
|
...variable,
|
|
@@ -2731,7 +2758,7 @@ var VariableEdit = ({ onClose, onGoBack, onSubmit, editId }) => {
|
|
|
2731
2758
|
};
|
|
2732
2759
|
|
|
2733
2760
|
// src/components/variables-selection.tsx
|
|
2734
|
-
var
|
|
2761
|
+
var import_react21 = require("react");
|
|
2735
2762
|
var React21 = __toESM(require("react"));
|
|
2736
2763
|
var import_editor_controls7 = require("@elementor/editor-controls");
|
|
2737
2764
|
var import_editor_ui9 = require("@elementor/editor-ui");
|
|
@@ -2839,7 +2866,7 @@ var getProUpgradeUrl = (variableType) => `https://go.elementor.com/renew-license
|
|
|
2839
2866
|
var VariablesSelection = ({ closePopover, onAdd, onEdit, onSettings, disabled = false }) => {
|
|
2840
2867
|
const { icon: VariableIcon, startIcon, variableType, propTypeUtil, emptyState } = useVariableType();
|
|
2841
2868
|
const { value: variable, setValue: setVariable, path } = useVariableBoundProp();
|
|
2842
|
-
const [searchValue, setSearchValue] = (0,
|
|
2869
|
+
const [searchValue, setSearchValue] = (0, import_react21.useState)("");
|
|
2843
2870
|
const {
|
|
2844
2871
|
list: variables,
|
|
2845
2872
|
hasMatches: hasSearchResults,
|
|
@@ -2916,7 +2943,7 @@ var VariablesSelection = ({ closePopover, onAdd, onEdit, onSettings, disabled =
|
|
|
2916
2943
|
const handleClearSearch = () => {
|
|
2917
2944
|
setSearchValue("");
|
|
2918
2945
|
};
|
|
2919
|
-
(0,
|
|
2946
|
+
(0, import_react21.useEffect)(() => {
|
|
2920
2947
|
if (disabled) {
|
|
2921
2948
|
(0, import_editor_controls7.trackViewPromotion)({
|
|
2922
2949
|
target_name: "variables_popover",
|
|
@@ -3024,8 +3051,8 @@ var VIEW_LIST = "list";
|
|
|
3024
3051
|
var VIEW_ADD = "add";
|
|
3025
3052
|
var VIEW_EDIT = "edit";
|
|
3026
3053
|
var VariableSelectionPopover = ({ closePopover, propTypeKey, selectedVariable }) => {
|
|
3027
|
-
const [currentView, setCurrentView] = (0,
|
|
3028
|
-
const [editId, setEditId] = (0,
|
|
3054
|
+
const [currentView, setCurrentView] = (0, import_react22.useState)(VIEW_LIST);
|
|
3055
|
+
const [editId, setEditId] = (0, import_react22.useState)("");
|
|
3029
3056
|
const { open } = usePanelActions();
|
|
3030
3057
|
const onSettingsAvailable = (0, import_editor_v1_adapters5.isExperimentActive)("e_variables_manager") ? () => {
|
|
3031
3058
|
open();
|
|
@@ -3136,8 +3163,8 @@ var AssignedTag = ({ startIcon, label, onUnlink, ...props }) => {
|
|
|
3136
3163
|
var AssignedVariable = ({ variable, propTypeKey }) => {
|
|
3137
3164
|
const { startIcon, propTypeUtil } = getVariableType(propTypeKey);
|
|
3138
3165
|
const { setValue } = (0, import_editor_controls8.useBoundProp)();
|
|
3139
|
-
const anchorRef = (0,
|
|
3140
|
-
const popupId = (0,
|
|
3166
|
+
const anchorRef = (0, import_react23.useRef)(null);
|
|
3167
|
+
const popupId = (0, import_react23.useId)();
|
|
3141
3168
|
const popupState = (0, import_ui24.usePopupState)({
|
|
3142
3169
|
variant: "popover",
|
|
3143
3170
|
popupId: `elementor-variables-list-${popupId}`
|
|
@@ -3177,14 +3204,14 @@ var AssignedVariable = ({ variable, propTypeKey }) => {
|
|
|
3177
3204
|
|
|
3178
3205
|
// src/components/ui/variable/deleted-variable.tsx
|
|
3179
3206
|
var React28 = __toESM(require("react"));
|
|
3180
|
-
var
|
|
3207
|
+
var import_react25 = require("react");
|
|
3181
3208
|
var import_editor_controls10 = require("@elementor/editor-controls");
|
|
3182
3209
|
var import_ui28 = require("@elementor/ui");
|
|
3183
3210
|
var import_i18n19 = require("@wordpress/i18n");
|
|
3184
3211
|
|
|
3185
3212
|
// src/components/variable-restore.tsx
|
|
3186
3213
|
var React25 = __toESM(require("react"));
|
|
3187
|
-
var
|
|
3214
|
+
var import_react24 = require("react");
|
|
3188
3215
|
var import_editor_controls9 = require("@elementor/editor-controls");
|
|
3189
3216
|
var import_editor_ui11 = require("@elementor/editor-ui");
|
|
3190
3217
|
var import_ui25 = require("@elementor/ui");
|
|
@@ -3198,11 +3225,11 @@ var VariableRestore = ({ variableId, onClose, onSubmit }) => {
|
|
|
3198
3225
|
if (!variable) {
|
|
3199
3226
|
throw new Error(`Global ${variableType} variable not found`);
|
|
3200
3227
|
}
|
|
3201
|
-
const [errorMessage, setErrorMessage] = (0,
|
|
3202
|
-
const [valueFieldError, setValueFieldError] = (0,
|
|
3203
|
-
const [label, setLabel] = (0,
|
|
3204
|
-
const [value, setValue] = (0,
|
|
3205
|
-
const [propTypeKey, setPropTypeKey] = (0,
|
|
3228
|
+
const [errorMessage, setErrorMessage] = (0, import_react24.useState)("");
|
|
3229
|
+
const [valueFieldError, setValueFieldError] = (0, import_react24.useState)("");
|
|
3230
|
+
const [label, setLabel] = (0, import_react24.useState)(variable.label);
|
|
3231
|
+
const [value, setValue] = (0, import_react24.useState)(variable.value);
|
|
3232
|
+
const [propTypeKey, setPropTypeKey] = (0, import_react24.useState)(variable?.type ?? propTypeUtil.key);
|
|
3206
3233
|
const { labelFieldError, setLabelFieldError } = useLabelError({
|
|
3207
3234
|
value: variable.label,
|
|
3208
3235
|
message: ERROR_MESSAGES.DUPLICATED_LABEL
|
|
@@ -3358,11 +3385,11 @@ var DeletedVariable = ({ variable, propTypeKey }) => {
|
|
|
3358
3385
|
const { propTypeUtil } = getVariableType(propTypeKey);
|
|
3359
3386
|
const boundProp = (0, import_editor_controls10.useBoundProp)();
|
|
3360
3387
|
const userPermissions = usePermissions();
|
|
3361
|
-
const [showInfotip, setShowInfotip] = (0,
|
|
3388
|
+
const [showInfotip, setShowInfotip] = (0, import_react25.useState)(false);
|
|
3362
3389
|
const toggleInfotip = () => setShowInfotip((prev) => !prev);
|
|
3363
3390
|
const closeInfotip = () => setShowInfotip(false);
|
|
3364
|
-
const deletedChipAnchorRef = (0,
|
|
3365
|
-
const popupId = (0,
|
|
3391
|
+
const deletedChipAnchorRef = (0, import_react25.useRef)(null);
|
|
3392
|
+
const popupId = (0, import_react25.useId)();
|
|
3366
3393
|
const popupState = (0, import_ui28.usePopupState)({
|
|
3367
3394
|
variant: "popover",
|
|
3368
3395
|
popupId: `elementor-variables-restore-${popupId}`
|
|
@@ -3449,7 +3476,7 @@ var DeletedVariable = ({ variable, propTypeKey }) => {
|
|
|
3449
3476
|
|
|
3450
3477
|
// src/components/ui/variable/mismatch-variable.tsx
|
|
3451
3478
|
var React30 = __toESM(require("react"));
|
|
3452
|
-
var
|
|
3479
|
+
var import_react26 = require("react");
|
|
3453
3480
|
var import_editor_controls11 = require("@elementor/editor-controls");
|
|
3454
3481
|
var import_ui30 = require("@elementor/ui");
|
|
3455
3482
|
var import_i18n21 = require("@wordpress/i18n");
|
|
@@ -3487,13 +3514,13 @@ var MismatchVariableAlert = ({ onClose, onClear, triggerSelect }) => {
|
|
|
3487
3514
|
// src/components/ui/variable/mismatch-variable.tsx
|
|
3488
3515
|
var MismatchVariable = ({ variable }) => {
|
|
3489
3516
|
const { setValue, value } = (0, import_editor_controls11.useBoundProp)();
|
|
3490
|
-
const anchorRef = (0,
|
|
3491
|
-
const popupId = (0,
|
|
3517
|
+
const anchorRef = (0, import_react26.useRef)(null);
|
|
3518
|
+
const popupId = (0, import_react26.useId)();
|
|
3492
3519
|
const popupState = (0, import_ui30.usePopupState)({
|
|
3493
3520
|
variant: "popover",
|
|
3494
3521
|
popupId: `elementor-variables-list-${popupId}`
|
|
3495
3522
|
});
|
|
3496
|
-
const [infotipVisible, setInfotipVisible] = (0,
|
|
3523
|
+
const [infotipVisible, setInfotipVisible] = (0, import_react26.useState)(false);
|
|
3497
3524
|
const toggleInfotip = () => setInfotipVisible((prev) => !prev);
|
|
3498
3525
|
const closeInfotip = () => setInfotipVisible(false);
|
|
3499
3526
|
const triggerSelect = () => {
|
|
@@ -3566,7 +3593,7 @@ var MismatchVariable = ({ variable }) => {
|
|
|
3566
3593
|
|
|
3567
3594
|
// src/components/ui/variable/missing-variable.tsx
|
|
3568
3595
|
var React32 = __toESM(require("react"));
|
|
3569
|
-
var
|
|
3596
|
+
var import_react27 = require("react");
|
|
3570
3597
|
var import_editor_controls12 = require("@elementor/editor-controls");
|
|
3571
3598
|
var import_ui32 = require("@elementor/ui");
|
|
3572
3599
|
var import_i18n23 = require("@wordpress/i18n");
|
|
@@ -3596,7 +3623,7 @@ var MissingVariableAlert = ({ onClose, onClear }) => {
|
|
|
3596
3623
|
// src/components/ui/variable/missing-variable.tsx
|
|
3597
3624
|
var MissingVariable = () => {
|
|
3598
3625
|
const { setValue } = (0, import_editor_controls12.useBoundProp)();
|
|
3599
|
-
const [infotipVisible, setInfotipVisible] = (0,
|
|
3626
|
+
const [infotipVisible, setInfotipVisible] = (0, import_react27.useState)(false);
|
|
3600
3627
|
const toggleInfotip = () => setInfotipVisible((prev) => !prev);
|
|
3601
3628
|
const closeInfotip = () => setInfotipVisible(false);
|
|
3602
3629
|
const clearValue = () => setValue(null);
|
|
@@ -3816,12 +3843,12 @@ var import_i18n26 = require("@wordpress/i18n");
|
|
|
3816
3843
|
|
|
3817
3844
|
// src/components/fields/color-field.tsx
|
|
3818
3845
|
var React35 = __toESM(require("react"));
|
|
3819
|
-
var
|
|
3846
|
+
var import_react28 = require("react");
|
|
3820
3847
|
var import_ui33 = require("@elementor/ui");
|
|
3821
3848
|
var ColorField = ({ value, onChange, onValidationChange }) => {
|
|
3822
|
-
const [color, setColor] = (0,
|
|
3823
|
-
const [errorMessage, setErrorMessage] = (0,
|
|
3824
|
-
const defaultRef = (0,
|
|
3849
|
+
const [color, setColor] = (0, import_react28.useState)(value);
|
|
3850
|
+
const [errorMessage, setErrorMessage] = (0, import_react28.useState)("");
|
|
3851
|
+
const defaultRef = (0, import_react28.useRef)(null);
|
|
3825
3852
|
const anchorRef = usePopoverContentRef() ?? defaultRef.current;
|
|
3826
3853
|
const handleChange = (newValue) => {
|
|
3827
3854
|
setColor(newValue);
|
|
@@ -3860,15 +3887,15 @@ var ColorField = ({ value, onChange, onValidationChange }) => {
|
|
|
3860
3887
|
|
|
3861
3888
|
// src/components/fields/font-field.tsx
|
|
3862
3889
|
var React36 = __toESM(require("react"));
|
|
3863
|
-
var
|
|
3890
|
+
var import_react29 = require("react");
|
|
3864
3891
|
var import_editor_controls15 = require("@elementor/editor-controls");
|
|
3865
3892
|
var import_editor_ui12 = require("@elementor/editor-ui");
|
|
3866
3893
|
var import_icons15 = require("@elementor/icons");
|
|
3867
3894
|
var import_ui34 = require("@elementor/ui");
|
|
3868
3895
|
var import_i18n25 = require("@wordpress/i18n");
|
|
3869
3896
|
var FontField = ({ value, onChange, onValidationChange }) => {
|
|
3870
|
-
const [fontFamily, setFontFamily] = (0,
|
|
3871
|
-
const defaultRef = (0,
|
|
3897
|
+
const [fontFamily, setFontFamily] = (0, import_react29.useState)(value);
|
|
3898
|
+
const defaultRef = (0, import_react29.useRef)(null);
|
|
3872
3899
|
const anchorRef = usePopoverContentRef() ?? defaultRef.current;
|
|
3873
3900
|
const fontPopoverState = (0, import_ui34.usePopupState)({ variant: "popover" });
|
|
3874
3901
|
const fontFamilies = (0, import_editor_controls15.useFontFamilies)();
|
|
@@ -3889,7 +3916,7 @@ var FontField = ({ value, onChange, onValidationChange }) => {
|
|
|
3889
3916
|
handleChange(newFontFamily);
|
|
3890
3917
|
fontPopoverState.close();
|
|
3891
3918
|
};
|
|
3892
|
-
const id2 = (0,
|
|
3919
|
+
const id2 = (0, import_react29.useId)();
|
|
3893
3920
|
return /* @__PURE__ */ React36.createElement(React36.Fragment, null, /* @__PURE__ */ React36.createElement(
|
|
3894
3921
|
import_ui34.UnstableTag,
|
|
3895
3922
|
{
|
|
@@ -4012,7 +4039,7 @@ function registerVariableTypes() {
|
|
|
4012
4039
|
|
|
4013
4040
|
// src/renderers/style-variables-renderer.tsx
|
|
4014
4041
|
var React38 = __toESM(require("react"));
|
|
4015
|
-
var
|
|
4042
|
+
var import_react30 = require("react");
|
|
4016
4043
|
var import_editor_v1_adapters7 = require("@elementor/editor-v1-adapters");
|
|
4017
4044
|
var import_ui35 = require("@elementor/ui");
|
|
4018
4045
|
var VARIABLES_WRAPPER = ":root";
|
|
@@ -4031,8 +4058,8 @@ function usePortalContainer() {
|
|
|
4031
4058
|
return (0, import_editor_v1_adapters7.__privateUseListenTo)((0, import_editor_v1_adapters7.commandEndEvent)("editor/documents/attach-preview"), () => (0, import_editor_v1_adapters7.getCanvasIframeDocument)()?.head);
|
|
4032
4059
|
}
|
|
4033
4060
|
function useStyleVariables() {
|
|
4034
|
-
const [variables, setVariables] = (0,
|
|
4035
|
-
(0,
|
|
4061
|
+
const [variables, setVariables] = (0, import_react30.useState)({});
|
|
4062
|
+
(0, import_react30.useEffect)(() => {
|
|
4036
4063
|
const unsubscribe = styleVariablesRepository.subscribe(setVariables);
|
|
4037
4064
|
return () => {
|
|
4038
4065
|
unsubscribe();
|
|
@@ -4130,6 +4157,10 @@ function init() {
|
|
|
4130
4157
|
id: "canvas-style-variables-render",
|
|
4131
4158
|
component: StyleVariablesRenderer
|
|
4132
4159
|
});
|
|
4160
|
+
(0, import_editor.injectIntoLogic)({
|
|
4161
|
+
id: "variables-import-listener",
|
|
4162
|
+
component: GlobalStylesImportListener
|
|
4163
|
+
});
|
|
4133
4164
|
(0, import_editor.injectIntoLogic)({
|
|
4134
4165
|
id: "variables-open-panel-from-url",
|
|
4135
4166
|
component: OpenPanelFromUrl
|