@elementor/editor-variables 0.12.0 → 0.14.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 +63 -0
- package/dist/index.js +918 -332
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +961 -329
- package/dist/index.mjs.map +1 -1
- package/package.json +10 -9
- package/src/components/color-variable-creation.tsx +65 -64
- package/src/components/color-variable-edit.tsx +117 -0
- package/src/components/color-variables-selection.tsx +98 -52
- package/src/components/font-variable-creation.tsx +143 -0
- package/src/components/font-variable-edit.tsx +146 -0
- package/src/components/font-variables-selection.tsx +97 -51
- package/src/components/ui/menu-item-content.tsx +51 -0
- package/src/components/ui/no-search-results.tsx +38 -0
- package/src/components/ui/no-variables.tsx +35 -0
- package/src/components/ui/styled-menu-list.tsx +31 -0
- package/src/components/variable-selection-popover.tsx +133 -0
- package/src/components/variables-repeater-item-slot.tsx +29 -0
- package/src/controls/color-variable-control.tsx +90 -0
- package/src/controls/font-variable-control.tsx +88 -0
- package/src/create-style-variables-repository.ts +3 -2
- package/src/hooks/use-prop-color-variable-action.tsx +7 -2
- package/src/hooks/use-prop-font-variable-action.tsx +7 -2
- package/src/hooks/use-prop-variables.ts +31 -4
- package/src/init-color-variables.ts +51 -3
- package/src/init-font-variables.ts +2 -2
- package/src/service.ts +23 -3
- package/src/storage.ts +5 -1
- package/src/types.ts +12 -8
- package/src/components/styled-menu-item.tsx +0 -10
- package/src/components/variables-selection-popover.tsx +0 -106
- package/src/controls/color-variables-selection-control.tsx +0 -34
- package/src/controls/font-variables-selection-control.tsx +0 -29
- /package/src/components/{color-indicator.tsx → ui/color-indicator.tsx} +0 -0
package/dist/index.js
CHANGED
|
@@ -39,25 +39,12 @@ 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
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
var React4 = __toESM(require("react"));
|
|
46
|
-
var import_editor_controls3 = require("@elementor/editor-controls");
|
|
47
|
-
var import_editor_props2 = require("@elementor/editor-props");
|
|
48
|
-
|
|
49
|
-
// src/components/color-indicator.tsx
|
|
50
|
-
var import_ui = require("@elementor/ui");
|
|
51
|
-
var ColorIndicator = (0, import_ui.styled)(import_ui.UnstableColorIndicator)(({ theme }) => ({
|
|
52
|
-
borderRadius: `${theme.shape.borderRadius / 2}px`
|
|
53
|
-
}));
|
|
42
|
+
var import_editor_controls7 = require("@elementor/editor-controls");
|
|
43
|
+
var import_editor_editing_panel4 = require("@elementor/editor-editing-panel");
|
|
44
|
+
var import_editor_props4 = require("@elementor/editor-props");
|
|
54
45
|
|
|
55
|
-
// src/components/
|
|
46
|
+
// src/components/variables-repeater-item-slot.tsx
|
|
56
47
|
var React = __toESM(require("react"));
|
|
57
|
-
var import_react2 = require("react");
|
|
58
|
-
var import_editor_controls = require("@elementor/editor-controls");
|
|
59
|
-
var import_icons = require("@elementor/icons");
|
|
60
|
-
var import_ui3 = require("@elementor/ui");
|
|
61
48
|
|
|
62
49
|
// src/hooks/use-prop-variables.ts
|
|
63
50
|
var import_react = require("react");
|
|
@@ -110,8 +97,11 @@ var Storage = class {
|
|
|
110
97
|
return this.state.variables;
|
|
111
98
|
}
|
|
112
99
|
fill(variables, watermark) {
|
|
100
|
+
this.state.variables = {};
|
|
101
|
+
if (variables && Object.keys(variables).length) {
|
|
102
|
+
this.state.variables = variables;
|
|
103
|
+
}
|
|
113
104
|
this.state.watermark = watermark;
|
|
114
|
-
this.state.variables = variables;
|
|
115
105
|
localStorage.setItem(STORAGE_WATERMARK_KEY, this.state.watermark.toString());
|
|
116
106
|
localStorage.setItem(STORAGE_KEY, JSON.stringify(this.state.variables));
|
|
117
107
|
}
|
|
@@ -141,6 +131,49 @@ var Storage = class {
|
|
|
141
131
|
}
|
|
142
132
|
};
|
|
143
133
|
|
|
134
|
+
// src/create-style-variables-repository.ts
|
|
135
|
+
var createStyleVariablesRepository = () => {
|
|
136
|
+
const variables = {};
|
|
137
|
+
let subscription;
|
|
138
|
+
const subscribe = (cb) => {
|
|
139
|
+
subscription = cb;
|
|
140
|
+
return () => {
|
|
141
|
+
subscription = () => {
|
|
142
|
+
};
|
|
143
|
+
};
|
|
144
|
+
};
|
|
145
|
+
const notify = () => {
|
|
146
|
+
if (typeof subscription === "function") {
|
|
147
|
+
subscription({ ...variables });
|
|
148
|
+
}
|
|
149
|
+
};
|
|
150
|
+
const shouldUpdate = (key, newValue) => {
|
|
151
|
+
return !(key in variables) || variables[key] !== newValue;
|
|
152
|
+
};
|
|
153
|
+
const applyUpdates = (updatedVars) => {
|
|
154
|
+
let hasChanges = false;
|
|
155
|
+
for (const [key, { value }] of Object.entries(updatedVars)) {
|
|
156
|
+
if (shouldUpdate(key, value)) {
|
|
157
|
+
variables[key] = value;
|
|
158
|
+
hasChanges = true;
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
return hasChanges;
|
|
162
|
+
};
|
|
163
|
+
const update = (updatedVars) => {
|
|
164
|
+
if (applyUpdates(updatedVars)) {
|
|
165
|
+
notify();
|
|
166
|
+
}
|
|
167
|
+
};
|
|
168
|
+
return {
|
|
169
|
+
subscribe,
|
|
170
|
+
update
|
|
171
|
+
};
|
|
172
|
+
};
|
|
173
|
+
|
|
174
|
+
// src/style-variables-repository.ts
|
|
175
|
+
var styleVariablesRepository = createStyleVariablesRepository();
|
|
176
|
+
|
|
144
177
|
// src/service.ts
|
|
145
178
|
var storage = new Storage();
|
|
146
179
|
var service = {
|
|
@@ -160,6 +193,7 @@ var service = {
|
|
|
160
193
|
}).then((data) => {
|
|
161
194
|
const { variables, watermark } = data;
|
|
162
195
|
storage.fill(variables, watermark);
|
|
196
|
+
styleVariablesRepository.update(variables);
|
|
163
197
|
return variables;
|
|
164
198
|
});
|
|
165
199
|
},
|
|
@@ -175,6 +209,9 @@ var service = {
|
|
|
175
209
|
handleWatermark(OP_RW, watermark);
|
|
176
210
|
const { id: variableId, ...createdVariable } = variable;
|
|
177
211
|
storage.add(variableId, createdVariable);
|
|
212
|
+
styleVariablesRepository.update({
|
|
213
|
+
[variableId]: createdVariable
|
|
214
|
+
});
|
|
178
215
|
return {
|
|
179
216
|
id: variableId,
|
|
180
217
|
variable: createdVariable
|
|
@@ -193,6 +230,9 @@ var service = {
|
|
|
193
230
|
handleWatermark(OP_RW, watermark);
|
|
194
231
|
const { id: variableId, ...updatedVariable } = variable;
|
|
195
232
|
storage.update(variableId, updatedVariable);
|
|
233
|
+
styleVariablesRepository.update({
|
|
234
|
+
[variableId]: updatedVariable
|
|
235
|
+
});
|
|
196
236
|
return {
|
|
197
237
|
id: variableId,
|
|
198
238
|
variable: updatedVariable
|
|
@@ -211,6 +251,9 @@ var service = {
|
|
|
211
251
|
handleWatermark(OP_RW, watermark);
|
|
212
252
|
const { id: variableId, ...deletedVariable } = variable;
|
|
213
253
|
storage.update(variableId, deletedVariable);
|
|
254
|
+
styleVariablesRepository.update({
|
|
255
|
+
[variableId]: deletedVariable
|
|
256
|
+
});
|
|
214
257
|
return {
|
|
215
258
|
id: variableId,
|
|
216
259
|
variable: deletedVariable
|
|
@@ -229,6 +272,9 @@ var service = {
|
|
|
229
272
|
handleWatermark(OP_RW, watermark);
|
|
230
273
|
const { id: variableId, ...restoredVariable } = variable;
|
|
231
274
|
storage.update(variableId, restoredVariable);
|
|
275
|
+
styleVariablesRepository.update({
|
|
276
|
+
[variableId]: restoredVariable
|
|
277
|
+
});
|
|
232
278
|
return {
|
|
233
279
|
id: variableId,
|
|
234
280
|
variable: restoredVariable
|
|
@@ -243,53 +289,7 @@ var handleWatermark = (operation, newWatermark) => {
|
|
|
243
289
|
storage.watermark(newWatermark);
|
|
244
290
|
};
|
|
245
291
|
|
|
246
|
-
// src/create-style-variables-repository.ts
|
|
247
|
-
var createStyleVariablesRepository = () => {
|
|
248
|
-
const variables = {};
|
|
249
|
-
let subscription;
|
|
250
|
-
const subscribe = (cb) => {
|
|
251
|
-
subscription = cb;
|
|
252
|
-
return () => {
|
|
253
|
-
subscription = () => {
|
|
254
|
-
};
|
|
255
|
-
};
|
|
256
|
-
};
|
|
257
|
-
const notify = () => {
|
|
258
|
-
if (typeof subscription === "function") {
|
|
259
|
-
subscription({ ...variables });
|
|
260
|
-
}
|
|
261
|
-
};
|
|
262
|
-
const shouldUpdate = (key, newValue) => {
|
|
263
|
-
return !(key in variables) || variables[key] !== newValue;
|
|
264
|
-
};
|
|
265
|
-
const applyUpdates = (updatedVars) => {
|
|
266
|
-
let hasChanges = false;
|
|
267
|
-
for (const [key, { value }] of Object.entries(updatedVars)) {
|
|
268
|
-
if (shouldUpdate(key, value)) {
|
|
269
|
-
variables[key] = value;
|
|
270
|
-
hasChanges = true;
|
|
271
|
-
}
|
|
272
|
-
}
|
|
273
|
-
return hasChanges;
|
|
274
|
-
};
|
|
275
|
-
const update = (updatedVars) => {
|
|
276
|
-
if (applyUpdates(updatedVars)) {
|
|
277
|
-
notify();
|
|
278
|
-
}
|
|
279
|
-
};
|
|
280
|
-
return {
|
|
281
|
-
subscribe,
|
|
282
|
-
update
|
|
283
|
-
};
|
|
284
|
-
};
|
|
285
|
-
|
|
286
|
-
// src/style-variables-repository.ts
|
|
287
|
-
var styleVariablesRepository = createStyleVariablesRepository();
|
|
288
|
-
|
|
289
292
|
// src/hooks/use-prop-variables.ts
|
|
290
|
-
var usePropVariables = (propKey) => {
|
|
291
|
-
return (0, import_react.useMemo)(() => normalizeVariables(propKey), [propKey]);
|
|
292
|
-
};
|
|
293
293
|
var useVariable = (key) => {
|
|
294
294
|
const variables = service.variables();
|
|
295
295
|
if (!variables?.[key]) {
|
|
@@ -300,6 +300,20 @@ var useVariable = (key) => {
|
|
|
300
300
|
key
|
|
301
301
|
};
|
|
302
302
|
};
|
|
303
|
+
var useFilteredVariables = (searchValue, propTypeKey) => {
|
|
304
|
+
const variables = usePropVariables(propTypeKey);
|
|
305
|
+
const filteredVariables = variables.filter(({ label }) => {
|
|
306
|
+
return label.toLowerCase().includes(searchValue.toLowerCase());
|
|
307
|
+
});
|
|
308
|
+
return {
|
|
309
|
+
list: filteredVariables,
|
|
310
|
+
hasMatches: filteredVariables.length > 0,
|
|
311
|
+
isSourceNotEmpty: variables.length > 0
|
|
312
|
+
};
|
|
313
|
+
};
|
|
314
|
+
var usePropVariables = (propKey) => {
|
|
315
|
+
return (0, import_react.useMemo)(() => normalizeVariables(propKey), [propKey]);
|
|
316
|
+
};
|
|
303
317
|
var normalizeVariables = (propKey) => {
|
|
304
318
|
const variables = service.variables();
|
|
305
319
|
styleVariablesRepository.update(variables);
|
|
@@ -317,250 +331,790 @@ var createVariable = (newVariable) => {
|
|
|
317
331
|
return id;
|
|
318
332
|
});
|
|
319
333
|
};
|
|
334
|
+
var updateVariable = (updateId, { value, label }) => {
|
|
335
|
+
return service.update(updateId, { value, label }).then(({ id, variable }) => {
|
|
336
|
+
styleVariablesRepository.update({
|
|
337
|
+
[id]: variable
|
|
338
|
+
});
|
|
339
|
+
return id;
|
|
340
|
+
});
|
|
341
|
+
};
|
|
342
|
+
|
|
343
|
+
// src/components/ui/color-indicator.tsx
|
|
344
|
+
var import_ui = require("@elementor/ui");
|
|
345
|
+
var ColorIndicator = (0, import_ui.styled)(import_ui.UnstableColorIndicator)(({ theme }) => ({
|
|
346
|
+
borderRadius: `${theme.shape.borderRadius / 2}px`
|
|
347
|
+
}));
|
|
348
|
+
|
|
349
|
+
// src/components/variables-repeater-item-slot.tsx
|
|
350
|
+
var useColorVariable = (value) => {
|
|
351
|
+
const variableId = value?.value?.color?.value;
|
|
352
|
+
return useVariable(variableId || "");
|
|
353
|
+
};
|
|
354
|
+
var BackgroundRepeaterColorIndicator = ({ value }) => {
|
|
355
|
+
const colorVariable = useColorVariable(value);
|
|
356
|
+
return /* @__PURE__ */ React.createElement(ColorIndicator, { component: "span", size: "inherit", value: colorVariable?.value });
|
|
357
|
+
};
|
|
358
|
+
var BackgroundRepeaterLabel = ({ value }) => {
|
|
359
|
+
const colorVariable = useColorVariable(value);
|
|
360
|
+
return /* @__PURE__ */ React.createElement("span", null, colorVariable?.label);
|
|
361
|
+
};
|
|
362
|
+
var BoxShadowRepeaterColorIndicator = ({ value }) => {
|
|
363
|
+
const colorVariable = useColorVariable(value);
|
|
364
|
+
return /* @__PURE__ */ React.createElement(ColorIndicator, { component: "span", size: "inherit", value: colorVariable?.value });
|
|
365
|
+
};
|
|
366
|
+
|
|
367
|
+
// src/controls/color-variable-control.tsx
|
|
368
|
+
var React12 = __toESM(require("react"));
|
|
369
|
+
var import_react9 = require("react");
|
|
370
|
+
var import_editor_controls6 = require("@elementor/editor-controls");
|
|
371
|
+
var import_editor_props3 = require("@elementor/editor-props");
|
|
372
|
+
var import_icons9 = require("@elementor/icons");
|
|
373
|
+
var import_ui12 = require("@elementor/ui");
|
|
374
|
+
var import_i18n10 = require("@wordpress/i18n");
|
|
375
|
+
|
|
376
|
+
// src/components/variable-selection-popover.tsx
|
|
377
|
+
var React11 = __toESM(require("react"));
|
|
378
|
+
var import_react8 = require("react");
|
|
320
379
|
|
|
321
380
|
// src/prop-types/color-variable-prop-type.ts
|
|
322
381
|
var import_editor_props = require("@elementor/editor-props");
|
|
323
382
|
var import_schema = require("@elementor/schema");
|
|
324
383
|
var colorVariablePropTypeUtil = (0, import_editor_props.createPropUtils)("global-color-variable", import_schema.z.string());
|
|
325
384
|
|
|
326
|
-
// src/
|
|
327
|
-
var
|
|
328
|
-
var
|
|
329
|
-
|
|
330
|
-
pr: 1,
|
|
331
|
-
py: 0.5,
|
|
332
|
-
"&:hover .MuiSvgIcon-root": {
|
|
333
|
-
opacity: 1
|
|
334
|
-
}
|
|
335
|
-
}));
|
|
385
|
+
// src/prop-types/font-variable-prop-type.ts
|
|
386
|
+
var import_editor_props2 = require("@elementor/editor-props");
|
|
387
|
+
var import_schema2 = require("@elementor/schema");
|
|
388
|
+
var fontVariablePropTypeUtil = (0, import_editor_props2.createPropUtils)("global-font-variable", import_schema2.z.string());
|
|
336
389
|
|
|
337
|
-
// src/components/color-
|
|
338
|
-
var
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
390
|
+
// src/components/color-variable-creation.tsx
|
|
391
|
+
var React2 = __toESM(require("react"));
|
|
392
|
+
var import_react2 = require("react");
|
|
393
|
+
var import_editor_controls = require("@elementor/editor-controls");
|
|
394
|
+
var import_editor_ui = require("@elementor/editor-ui");
|
|
395
|
+
var import_icons = require("@elementor/icons");
|
|
396
|
+
var import_ui2 = require("@elementor/ui");
|
|
397
|
+
var import_i18n = require("@wordpress/i18n");
|
|
398
|
+
var SIZE = "tiny";
|
|
399
|
+
var ColorVariableCreation = ({ onGoBack, onClose }) => {
|
|
400
|
+
const { setValue: setVariable } = (0, import_editor_controls.useBoundProp)(colorVariablePropTypeUtil);
|
|
401
|
+
const [color, setColor] = (0, import_react2.useState)("");
|
|
402
|
+
const [label, setLabel] = (0, import_react2.useState)("");
|
|
403
|
+
const anchorRef = (0, import_react2.useRef)(null);
|
|
404
|
+
const resetFields = () => {
|
|
405
|
+
setColor("");
|
|
406
|
+
setLabel("");
|
|
344
407
|
};
|
|
345
|
-
|
|
346
|
-
|
|
408
|
+
const closePopover = () => {
|
|
409
|
+
resetFields();
|
|
410
|
+
onClose();
|
|
411
|
+
};
|
|
412
|
+
const handleCreate = () => {
|
|
413
|
+
createVariable({
|
|
414
|
+
value: color,
|
|
415
|
+
label,
|
|
416
|
+
type: colorVariablePropTypeUtil.key
|
|
417
|
+
}).then((key) => {
|
|
418
|
+
setVariable(key);
|
|
419
|
+
closePopover();
|
|
420
|
+
});
|
|
421
|
+
};
|
|
422
|
+
const isFormInvalid = () => {
|
|
423
|
+
return !color?.trim() || !label?.trim();
|
|
424
|
+
};
|
|
425
|
+
return /* @__PURE__ */ React2.createElement(React2.Fragment, null, /* @__PURE__ */ React2.createElement(
|
|
426
|
+
import_editor_ui.PopoverHeader,
|
|
347
427
|
{
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
}
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
style: { marginTop: "1px", lineHeight: "1" }
|
|
374
|
-
},
|
|
375
|
-
sx: { display: "flex", alignItems: "center", gap: 1 }
|
|
428
|
+
icon: /* @__PURE__ */ React2.createElement(React2.Fragment, null, onGoBack && /* @__PURE__ */ React2.createElement(import_ui2.IconButton, { size: SIZE, "aria-label": (0, import_i18n.__)("Go Back", "elementor"), onClick: onGoBack }, /* @__PURE__ */ React2.createElement(import_icons.ArrowLeftIcon, { fontSize: SIZE })), /* @__PURE__ */ React2.createElement(import_icons.BrushIcon, { fontSize: SIZE })),
|
|
429
|
+
title: (0, import_i18n.__)("Create variable", "elementor"),
|
|
430
|
+
onClose: closePopover
|
|
431
|
+
}
|
|
432
|
+
), /* @__PURE__ */ React2.createElement(import_ui2.Divider, null), /* @__PURE__ */ React2.createElement(import_ui2.Stack, { p: 1.5, gap: 1.5 }, /* @__PURE__ */ React2.createElement(import_ui2.Grid, { container: true, gap: 0.75, alignItems: "center" }, /* @__PURE__ */ React2.createElement(import_ui2.Grid, { item: true, xs: 12 }, /* @__PURE__ */ React2.createElement(import_ui2.FormLabel, { size: "small" }, (0, import_i18n.__)("Name", "elementor"))), /* @__PURE__ */ React2.createElement(import_ui2.Grid, { item: true, xs: 12 }, /* @__PURE__ */ React2.createElement(
|
|
433
|
+
import_ui2.TextField,
|
|
434
|
+
{
|
|
435
|
+
size: "tiny",
|
|
436
|
+
fullWidth: true,
|
|
437
|
+
value: label,
|
|
438
|
+
onChange: (e) => setLabel(e.target.value)
|
|
439
|
+
}
|
|
440
|
+
))), /* @__PURE__ */ React2.createElement(import_ui2.Grid, { container: true, gap: 0.75, alignItems: "center" }, /* @__PURE__ */ React2.createElement(import_ui2.Grid, { item: true, xs: 12 }, /* @__PURE__ */ React2.createElement(import_ui2.FormLabel, { size: "small" }, (0, import_i18n.__)("Value", "elementor"))), /* @__PURE__ */ React2.createElement(import_ui2.Grid, { item: true, xs: 12 }, /* @__PURE__ */ React2.createElement(
|
|
441
|
+
import_ui2.UnstableColorField,
|
|
442
|
+
{
|
|
443
|
+
size: "tiny",
|
|
444
|
+
fullWidth: true,
|
|
445
|
+
value: color,
|
|
446
|
+
onChange: setColor,
|
|
447
|
+
slotProps: {
|
|
448
|
+
colorPicker: {
|
|
449
|
+
anchorEl: anchorRef.current,
|
|
450
|
+
anchorOrigin: { vertical: "top", horizontal: "right" },
|
|
451
|
+
transformOrigin: { vertical: "top", horizontal: -10 }
|
|
452
|
+
}
|
|
376
453
|
}
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
)))));
|
|
454
|
+
}
|
|
455
|
+
)))), /* @__PURE__ */ React2.createElement(import_ui2.CardActions, null, /* @__PURE__ */ React2.createElement(import_ui2.Button, { size: "small", variant: "contained", disabled: isFormInvalid(), onClick: handleCreate }, (0, import_i18n.__)("Create", "elementor"))));
|
|
380
456
|
};
|
|
381
457
|
|
|
382
|
-
// src/components/
|
|
458
|
+
// src/components/color-variable-edit.tsx
|
|
383
459
|
var React3 = __toESM(require("react"));
|
|
384
|
-
var
|
|
460
|
+
var import_react3 = require("react");
|
|
385
461
|
var import_editor_ui2 = require("@elementor/editor-ui");
|
|
386
|
-
var
|
|
387
|
-
var
|
|
462
|
+
var import_icons2 = require("@elementor/icons");
|
|
463
|
+
var import_ui3 = require("@elementor/ui");
|
|
388
464
|
var import_i18n2 = require("@wordpress/i18n");
|
|
465
|
+
var SIZE2 = "tiny";
|
|
466
|
+
var ColorVariableEdit = ({ onClose, onGoBack, onSubmit, editId }) => {
|
|
467
|
+
const variable = useVariable(editId);
|
|
468
|
+
if (!variable) {
|
|
469
|
+
throw new Error(`Global color variable not found`);
|
|
470
|
+
}
|
|
471
|
+
const anchorRef = (0, import_react3.useRef)(null);
|
|
472
|
+
const [color, setColor] = (0, import_react3.useState)(variable.value);
|
|
473
|
+
const [label, setLabel] = (0, import_react3.useState)(variable.label);
|
|
474
|
+
const handleUpdate = () => {
|
|
475
|
+
updateVariable(editId, {
|
|
476
|
+
value: color,
|
|
477
|
+
label
|
|
478
|
+
}).then(() => {
|
|
479
|
+
onSubmit?.();
|
|
480
|
+
});
|
|
481
|
+
};
|
|
482
|
+
const noValueChanged = () => color === variable.value && label === variable.label;
|
|
483
|
+
const hasEmptyValue = () => "" === color.trim() || "" === label.trim();
|
|
484
|
+
const isSaveDisabled = () => noValueChanged() || hasEmptyValue();
|
|
485
|
+
return /* @__PURE__ */ React3.createElement(React3.Fragment, null, /* @__PURE__ */ React3.createElement(
|
|
486
|
+
import_editor_ui2.PopoverHeader,
|
|
487
|
+
{
|
|
488
|
+
title: (0, import_i18n2.__)("Edit variable", "elementor"),
|
|
489
|
+
onClose,
|
|
490
|
+
icon: /* @__PURE__ */ React3.createElement(React3.Fragment, null, onGoBack && /* @__PURE__ */ React3.createElement(import_ui3.IconButton, { size: SIZE2, "aria-label": (0, import_i18n2.__)("Go Back", "elementor"), onClick: onGoBack }, /* @__PURE__ */ React3.createElement(import_icons2.ArrowLeftIcon, { fontSize: SIZE2 })), /* @__PURE__ */ React3.createElement(import_icons2.BrushIcon, { fontSize: SIZE2 }))
|
|
491
|
+
}
|
|
492
|
+
), /* @__PURE__ */ React3.createElement(import_ui3.Divider, null), /* @__PURE__ */ React3.createElement(import_ui3.Stack, { p: 1.5, gap: 1.5 }, /* @__PURE__ */ React3.createElement(import_ui3.Grid, { container: true, gap: 0.75, alignItems: "center" }, /* @__PURE__ */ React3.createElement(import_ui3.Grid, { item: true, xs: 12 }, /* @__PURE__ */ React3.createElement(import_ui3.FormLabel, { size: "small" }, (0, import_i18n2.__)("Name", "elementor"))), /* @__PURE__ */ React3.createElement(import_ui3.Grid, { item: true, xs: 12 }, /* @__PURE__ */ React3.createElement(
|
|
493
|
+
import_ui3.TextField,
|
|
494
|
+
{
|
|
495
|
+
size: "tiny",
|
|
496
|
+
fullWidth: true,
|
|
497
|
+
value: label,
|
|
498
|
+
onChange: (e) => setLabel(e.target.value)
|
|
499
|
+
}
|
|
500
|
+
))), /* @__PURE__ */ React3.createElement(import_ui3.Grid, { container: true, gap: 0.75, alignItems: "center" }, /* @__PURE__ */ React3.createElement(import_ui3.Grid, { item: true, xs: 12 }, /* @__PURE__ */ React3.createElement(import_ui3.FormLabel, { size: "small" }, (0, import_i18n2.__)("Value", "elementor"))), /* @__PURE__ */ React3.createElement(import_ui3.Grid, { item: true, xs: 12 }, /* @__PURE__ */ React3.createElement(
|
|
501
|
+
import_ui3.UnstableColorField,
|
|
502
|
+
{
|
|
503
|
+
size: "tiny",
|
|
504
|
+
fullWidth: true,
|
|
505
|
+
value: color,
|
|
506
|
+
onChange: setColor,
|
|
507
|
+
slotProps: {
|
|
508
|
+
colorPicker: {
|
|
509
|
+
anchorEl: anchorRef.current,
|
|
510
|
+
anchorOrigin: { vertical: "top", horizontal: "right" },
|
|
511
|
+
transformOrigin: { vertical: "top", horizontal: -10 }
|
|
512
|
+
}
|
|
513
|
+
}
|
|
514
|
+
}
|
|
515
|
+
)))), /* @__PURE__ */ React3.createElement(import_ui3.CardActions, null, /* @__PURE__ */ React3.createElement(import_ui3.Button, { size: "small", variant: "contained", disabled: isSaveDisabled(), onClick: handleUpdate }, (0, import_i18n2.__)("Save", "elementor"))));
|
|
516
|
+
};
|
|
389
517
|
|
|
390
|
-
// src/components/color-
|
|
391
|
-
var
|
|
392
|
-
var
|
|
518
|
+
// src/components/color-variables-selection.tsx
|
|
519
|
+
var React7 = __toESM(require("react"));
|
|
520
|
+
var import_react4 = require("react");
|
|
393
521
|
var import_editor_controls2 = require("@elementor/editor-controls");
|
|
394
|
-
var
|
|
395
|
-
var
|
|
522
|
+
var import_editor_ui3 = require("@elementor/editor-ui");
|
|
523
|
+
var import_icons5 = require("@elementor/icons");
|
|
524
|
+
var import_ui8 = require("@elementor/ui");
|
|
525
|
+
var import_i18n6 = require("@wordpress/i18n");
|
|
526
|
+
|
|
527
|
+
// src/components/ui/menu-item-content.tsx
|
|
528
|
+
var React4 = __toESM(require("react"));
|
|
529
|
+
var import_icons3 = require("@elementor/icons");
|
|
396
530
|
var import_ui4 = require("@elementor/ui");
|
|
397
|
-
var
|
|
398
|
-
var
|
|
399
|
-
var
|
|
400
|
-
const
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
531
|
+
var import_i18n3 = require("@wordpress/i18n");
|
|
532
|
+
var SIZE3 = "tiny";
|
|
533
|
+
var MenuItemContent = ({ item }) => {
|
|
534
|
+
const onEdit = item.onEdit;
|
|
535
|
+
return /* @__PURE__ */ React4.createElement(React4.Fragment, null, /* @__PURE__ */ React4.createElement(import_ui4.ListItemIcon, null, item.icon), /* @__PURE__ */ React4.createElement(
|
|
536
|
+
import_ui4.ListItemText,
|
|
537
|
+
{
|
|
538
|
+
primary: item.label || item.value,
|
|
539
|
+
secondary: item.secondaryText,
|
|
540
|
+
primaryTypographyProps: {
|
|
541
|
+
variant: "body2",
|
|
542
|
+
color: "text.secondary",
|
|
543
|
+
style: {
|
|
544
|
+
lineHeight: 2,
|
|
545
|
+
display: "inline-block",
|
|
546
|
+
overflow: "hidden",
|
|
547
|
+
textOverflow: "ellipsis",
|
|
548
|
+
whiteSpace: "nowrap",
|
|
549
|
+
maxWidth: "81px"
|
|
550
|
+
}
|
|
551
|
+
},
|
|
552
|
+
secondaryTypographyProps: {
|
|
553
|
+
variant: "caption",
|
|
554
|
+
color: "text.tertiary",
|
|
555
|
+
style: { marginTop: "1px", lineHeight: "1" }
|
|
556
|
+
},
|
|
557
|
+
sx: { display: "flex", alignItems: "center", gap: 1 }
|
|
558
|
+
}
|
|
559
|
+
), !!onEdit && /* @__PURE__ */ React4.createElement(
|
|
560
|
+
import_ui4.IconButton,
|
|
561
|
+
{
|
|
562
|
+
sx: { mx: 1, opacity: "0" },
|
|
563
|
+
onClick: (e) => {
|
|
564
|
+
e.stopPropagation();
|
|
565
|
+
onEdit(item.value);
|
|
566
|
+
},
|
|
567
|
+
"aria-label": (0, import_i18n3.__)("Edit", "elementor")
|
|
568
|
+
},
|
|
569
|
+
/* @__PURE__ */ React4.createElement(import_icons3.EditIcon, { color: "action", fontSize: SIZE3 })
|
|
570
|
+
));
|
|
571
|
+
};
|
|
572
|
+
|
|
573
|
+
// src/components/ui/no-search-results.tsx
|
|
574
|
+
var React5 = __toESM(require("react"));
|
|
575
|
+
var import_icons4 = require("@elementor/icons");
|
|
576
|
+
var import_ui5 = require("@elementor/ui");
|
|
577
|
+
var import_i18n4 = require("@wordpress/i18n");
|
|
578
|
+
var NoSearchResults = ({ searchValue, onClear }) => {
|
|
579
|
+
return /* @__PURE__ */ React5.createElement(
|
|
580
|
+
import_ui5.Stack,
|
|
581
|
+
{
|
|
582
|
+
gap: 1,
|
|
583
|
+
alignItems: "center",
|
|
584
|
+
justifyContent: "center",
|
|
585
|
+
height: "100%",
|
|
586
|
+
color: "text.secondary",
|
|
587
|
+
sx: { p: 2.5, pb: 5.5 }
|
|
588
|
+
},
|
|
589
|
+
/* @__PURE__ */ React5.createElement(import_icons4.ColorFilterIcon, { fontSize: "large" }),
|
|
590
|
+
/* @__PURE__ */ React5.createElement(import_ui5.Typography, { align: "center", variant: "subtitle2" }, (0, import_i18n4.__)("Sorry, nothing matched", "elementor"), /* @__PURE__ */ React5.createElement("br", null), "\u201C", searchValue, "\u201D."),
|
|
591
|
+
/* @__PURE__ */ React5.createElement(import_ui5.Typography, { align: "center", variant: "caption" }, (0, import_i18n4.__)("Try something else.", "elementor"), /* @__PURE__ */ React5.createElement("br", null), /* @__PURE__ */ React5.createElement(import_ui5.Link, { color: "text.secondary", variant: "caption", component: "button", onClick: onClear }, (0, import_i18n4.__)("Clear & try again", "elementor")))
|
|
592
|
+
);
|
|
593
|
+
};
|
|
594
|
+
|
|
595
|
+
// src/components/ui/no-variables.tsx
|
|
596
|
+
var React6 = __toESM(require("react"));
|
|
597
|
+
var import_ui6 = require("@elementor/ui");
|
|
598
|
+
var import_i18n5 = require("@wordpress/i18n");
|
|
599
|
+
var NoVariables = ({ icon, onAdd }) => /* @__PURE__ */ React6.createElement(
|
|
600
|
+
import_ui6.Stack,
|
|
601
|
+
{
|
|
602
|
+
gap: 1,
|
|
603
|
+
alignItems: "center",
|
|
604
|
+
justifyContent: "center",
|
|
605
|
+
height: "100%",
|
|
606
|
+
color: "text.secondary",
|
|
607
|
+
sx: { p: 2.5, pb: 5.5 }
|
|
608
|
+
},
|
|
609
|
+
icon,
|
|
610
|
+
/* @__PURE__ */ React6.createElement(import_ui6.Typography, { align: "center", variant: "subtitle2" }, (0, import_i18n5.__)("Create your first variable", "elementor")),
|
|
611
|
+
/* @__PURE__ */ React6.createElement(import_ui6.Typography, { align: "center", variant: "caption", maxWidth: "180px" }, (0, import_i18n5.__)("Variables are saved attributes that you can apply anywhere on your site.", "elementor")),
|
|
612
|
+
onAdd && /* @__PURE__ */ React6.createElement(import_ui6.Button, { variant: "outlined", color: "secondary", size: "small", onClick: onAdd }, (0, import_i18n5.__)("Create a variable", "elementor"))
|
|
613
|
+
);
|
|
614
|
+
|
|
615
|
+
// src/components/ui/styled-menu-list.tsx
|
|
616
|
+
var import_ui7 = require("@elementor/ui");
|
|
617
|
+
var VariablesStyledMenuList = (0, import_ui7.styled)(import_ui7.MenuList)(({ theme }) => ({
|
|
618
|
+
"& > li": {
|
|
619
|
+
height: 32,
|
|
620
|
+
width: "100%",
|
|
621
|
+
display: "flex",
|
|
622
|
+
alignItems: "center"
|
|
623
|
+
},
|
|
624
|
+
'& > [role="option"]': {
|
|
625
|
+
...theme.typography.caption,
|
|
626
|
+
lineHeight: "inherit",
|
|
627
|
+
padding: theme.spacing(0.5, 1, 0.5, 2),
|
|
628
|
+
"&:hover, &:focus": {
|
|
629
|
+
backgroundColor: theme.palette.action.hover
|
|
630
|
+
},
|
|
631
|
+
'&[aria-selected="true"]': {
|
|
632
|
+
backgroundColor: theme.palette.action.selected
|
|
633
|
+
},
|
|
634
|
+
cursor: "pointer",
|
|
635
|
+
textOverflow: "ellipsis",
|
|
636
|
+
position: "absolute",
|
|
637
|
+
top: 0,
|
|
638
|
+
left: 0,
|
|
639
|
+
"&:hover .MuiIconButton-root, .MuiIconButton-root:focus": {
|
|
640
|
+
opacity: 1
|
|
641
|
+
}
|
|
642
|
+
},
|
|
643
|
+
width: "100%",
|
|
644
|
+
position: "relative"
|
|
645
|
+
}));
|
|
646
|
+
|
|
647
|
+
// src/components/color-variables-selection.tsx
|
|
648
|
+
var SIZE4 = "tiny";
|
|
649
|
+
var ColorVariablesSelection = ({ closePopover, onAdd, onEdit, onSettings }) => {
|
|
650
|
+
const { value: variable, setValue: setVariable } = (0, import_editor_controls2.useBoundProp)(colorVariablePropTypeUtil);
|
|
651
|
+
const [searchValue, setSearchValue] = (0, import_react4.useState)("");
|
|
652
|
+
const {
|
|
653
|
+
list: variables,
|
|
654
|
+
hasMatches: hasSearchResults,
|
|
655
|
+
isSourceNotEmpty: hasVariables
|
|
656
|
+
} = useFilteredVariables(searchValue, colorVariablePropTypeUtil.key);
|
|
657
|
+
const handleSetColorVariable = (key) => {
|
|
658
|
+
setVariable(key);
|
|
659
|
+
closePopover();
|
|
660
|
+
};
|
|
661
|
+
const actions = [];
|
|
662
|
+
if (onAdd) {
|
|
663
|
+
actions.push(
|
|
664
|
+
/* @__PURE__ */ React7.createElement(import_ui8.IconButton, { key: "add", size: SIZE4, onClick: onAdd }, /* @__PURE__ */ React7.createElement(import_icons5.PlusIcon, { fontSize: SIZE4 }))
|
|
665
|
+
);
|
|
666
|
+
}
|
|
667
|
+
if (onSettings) {
|
|
668
|
+
actions.push(
|
|
669
|
+
/* @__PURE__ */ React7.createElement(import_ui8.IconButton, { key: "settings", size: SIZE4, onClick: onSettings }, /* @__PURE__ */ React7.createElement(import_icons5.SettingsIcon, { fontSize: SIZE4 }))
|
|
670
|
+
);
|
|
671
|
+
}
|
|
672
|
+
const items = variables.map(({ value, label, key }) => ({
|
|
673
|
+
type: "item",
|
|
674
|
+
value: key,
|
|
675
|
+
label,
|
|
676
|
+
icon: /* @__PURE__ */ React7.createElement(ColorIndicator, { size: "inherit", component: "span", value }),
|
|
677
|
+
secondaryText: value,
|
|
678
|
+
onEdit: () => onEdit?.(key)
|
|
679
|
+
}));
|
|
680
|
+
const handleSearch = (search) => {
|
|
681
|
+
setSearchValue(search);
|
|
682
|
+
};
|
|
683
|
+
const handleClearSearch = () => {
|
|
684
|
+
setSearchValue("");
|
|
685
|
+
};
|
|
686
|
+
return /* @__PURE__ */ React7.createElement(React7.Fragment, null, /* @__PURE__ */ React7.createElement(
|
|
687
|
+
import_editor_ui3.PopoverHeader,
|
|
688
|
+
{
|
|
689
|
+
title: (0, import_i18n6.__)("Variables", "elementor"),
|
|
690
|
+
icon: /* @__PURE__ */ React7.createElement(import_icons5.ColorFilterIcon, { fontSize: SIZE4 }),
|
|
691
|
+
onClose: closePopover,
|
|
692
|
+
actions
|
|
693
|
+
}
|
|
694
|
+
), hasVariables && /* @__PURE__ */ React7.createElement(
|
|
695
|
+
import_editor_ui3.PopoverSearch,
|
|
696
|
+
{
|
|
697
|
+
value: searchValue,
|
|
698
|
+
onSearch: handleSearch,
|
|
699
|
+
placeholder: (0, import_i18n6.__)("Search", "elementor")
|
|
700
|
+
}
|
|
701
|
+
), /* @__PURE__ */ React7.createElement(import_ui8.Divider, null), hasVariables && hasSearchResults && /* @__PURE__ */ React7.createElement(
|
|
702
|
+
import_editor_ui3.PopoverMenuList,
|
|
703
|
+
{
|
|
704
|
+
items,
|
|
705
|
+
onSelect: handleSetColorVariable,
|
|
706
|
+
onClose: () => {
|
|
707
|
+
},
|
|
708
|
+
selectedValue: variable,
|
|
709
|
+
"data-testid": "color-variables-list",
|
|
710
|
+
menuListTemplate: VariablesStyledMenuList,
|
|
711
|
+
menuItemContentTemplate: (item) => /* @__PURE__ */ React7.createElement(MenuItemContent, { item })
|
|
712
|
+
}
|
|
713
|
+
), !hasSearchResults && hasVariables && /* @__PURE__ */ React7.createElement(NoSearchResults, { searchValue, onClear: handleClearSearch }), !hasVariables && /* @__PURE__ */ React7.createElement(NoVariables, { icon: /* @__PURE__ */ React7.createElement(import_icons5.ColorFilterIcon, { fontSize: "large" }), onAdd }));
|
|
714
|
+
};
|
|
715
|
+
|
|
716
|
+
// src/components/font-variable-creation.tsx
|
|
717
|
+
var React8 = __toESM(require("react"));
|
|
718
|
+
var import_react5 = require("react");
|
|
719
|
+
var import_editor_controls3 = require("@elementor/editor-controls");
|
|
720
|
+
var import_editor_editing_panel = require("@elementor/editor-editing-panel");
|
|
721
|
+
var import_editor_ui4 = require("@elementor/editor-ui");
|
|
722
|
+
var import_icons6 = require("@elementor/icons");
|
|
723
|
+
var import_ui9 = require("@elementor/ui");
|
|
724
|
+
var import_i18n7 = require("@wordpress/i18n");
|
|
725
|
+
var SIZE5 = "tiny";
|
|
726
|
+
var FontVariableCreation = ({ onClose, onGoBack }) => {
|
|
727
|
+
const fontFamilies = (0, import_editor_editing_panel.useFontFamilies)();
|
|
728
|
+
const { setValue: setVariable } = (0, import_editor_controls3.useBoundProp)(fontVariablePropTypeUtil);
|
|
729
|
+
const [fontFamily, setFontFamily] = (0, import_react5.useState)("");
|
|
730
|
+
const [label, setLabel] = (0, import_react5.useState)("");
|
|
731
|
+
const anchorRef = (0, import_react5.useRef)(null);
|
|
732
|
+
const fontPopoverState = (0, import_ui9.usePopupState)({ variant: "popover" });
|
|
404
733
|
const resetFields = () => {
|
|
405
|
-
|
|
734
|
+
setFontFamily("");
|
|
406
735
|
setLabel("");
|
|
407
736
|
};
|
|
408
737
|
const closePopover = () => {
|
|
409
738
|
resetFields();
|
|
410
|
-
|
|
739
|
+
onClose();
|
|
411
740
|
};
|
|
412
741
|
const handleCreate = () => {
|
|
413
742
|
createVariable({
|
|
414
|
-
value:
|
|
743
|
+
value: fontFamily,
|
|
415
744
|
label,
|
|
416
|
-
type:
|
|
745
|
+
type: fontVariablePropTypeUtil.key
|
|
417
746
|
}).then((key) => {
|
|
418
747
|
setVariable(key);
|
|
419
748
|
closePopover();
|
|
420
749
|
});
|
|
421
750
|
};
|
|
422
|
-
const
|
|
423
|
-
return !
|
|
751
|
+
const isFormInvalid = () => {
|
|
752
|
+
return !fontFamily?.trim() || !label?.trim();
|
|
424
753
|
};
|
|
425
|
-
return /* @__PURE__ */
|
|
426
|
-
|
|
754
|
+
return /* @__PURE__ */ React8.createElement(React8.Fragment, null, /* @__PURE__ */ React8.createElement(
|
|
755
|
+
import_editor_ui4.PopoverHeader,
|
|
756
|
+
{
|
|
757
|
+
icon: /* @__PURE__ */ React8.createElement(React8.Fragment, null, onGoBack && /* @__PURE__ */ React8.createElement(import_ui9.IconButton, { size: SIZE5, "aria-label": (0, import_i18n7.__)("Go Back", "elementor"), onClick: onGoBack }, /* @__PURE__ */ React8.createElement(import_icons6.ArrowLeftIcon, { fontSize: SIZE5 })), /* @__PURE__ */ React8.createElement(import_icons6.TextIcon, { fontSize: SIZE5 })),
|
|
758
|
+
title: (0, import_i18n7.__)("Create variable", "elementor"),
|
|
759
|
+
onClose: closePopover
|
|
760
|
+
}
|
|
761
|
+
), /* @__PURE__ */ React8.createElement(import_ui9.Divider, null), /* @__PURE__ */ React8.createElement(import_ui9.Stack, { p: 1.5, gap: 1.5 }, /* @__PURE__ */ React8.createElement(import_ui9.Grid, { container: true, gap: 0.75, alignItems: "center" }, /* @__PURE__ */ React8.createElement(import_ui9.Grid, { item: true, xs: 12 }, /* @__PURE__ */ React8.createElement(import_ui9.FormLabel, { size: "small" }, (0, import_i18n7.__)("Name", "elementor"))), /* @__PURE__ */ React8.createElement(import_ui9.Grid, { item: true, xs: 12 }, /* @__PURE__ */ React8.createElement(
|
|
762
|
+
import_ui9.TextField,
|
|
763
|
+
{
|
|
764
|
+
size: "tiny",
|
|
765
|
+
fullWidth: true,
|
|
766
|
+
value: label,
|
|
767
|
+
onChange: (e) => setLabel(e.target.value)
|
|
768
|
+
}
|
|
769
|
+
))), /* @__PURE__ */ React8.createElement(import_ui9.Grid, { container: true, gap: 0.75, alignItems: "center" }, /* @__PURE__ */ React8.createElement(import_ui9.Grid, { item: true, xs: 12 }, /* @__PURE__ */ React8.createElement(import_ui9.FormLabel, { size: "small" }, (0, import_i18n7.__)("Value", "elementor"))), /* @__PURE__ */ React8.createElement(import_ui9.Grid, { item: true, xs: 12 }, /* @__PURE__ */ React8.createElement(React8.Fragment, null, /* @__PURE__ */ React8.createElement(
|
|
770
|
+
import_ui9.UnstableTag,
|
|
771
|
+
{
|
|
772
|
+
variant: "outlined",
|
|
773
|
+
label: fontFamily,
|
|
774
|
+
endIcon: /* @__PURE__ */ React8.createElement(import_icons6.ChevronDownIcon, { fontSize: "tiny" }),
|
|
775
|
+
...(0, import_ui9.bindTrigger)(fontPopoverState),
|
|
776
|
+
fullWidth: true
|
|
777
|
+
}
|
|
778
|
+
), /* @__PURE__ */ React8.createElement(
|
|
779
|
+
import_ui9.Popover,
|
|
427
780
|
{
|
|
428
|
-
|
|
781
|
+
disablePortal: true,
|
|
782
|
+
disableScrollLock: true,
|
|
429
783
|
anchorEl: anchorRef.current,
|
|
430
|
-
anchorOrigin: { vertical: "
|
|
431
|
-
transformOrigin: { vertical: "top", horizontal:
|
|
784
|
+
anchorOrigin: { vertical: "top", horizontal: "right" },
|
|
785
|
+
transformOrigin: { vertical: "top", horizontal: -20 },
|
|
786
|
+
...(0, import_ui9.bindPopover)(fontPopoverState)
|
|
432
787
|
},
|
|
433
|
-
/* @__PURE__ */
|
|
434
|
-
|
|
435
|
-
{
|
|
436
|
-
title: (0, import_i18n.__)("Create variable", "elementor"),
|
|
437
|
-
onClose: closePopover,
|
|
438
|
-
icon: /* @__PURE__ */ React2.createElement(import_icons2.BrushIcon, { fontSize: SIZE })
|
|
439
|
-
}
|
|
440
|
-
),
|
|
441
|
-
/* @__PURE__ */ React2.createElement(import_ui4.Divider, null),
|
|
442
|
-
/* @__PURE__ */ React2.createElement(import_ui4.Stack, { p: 1.5, gap: 1.5 }, /* @__PURE__ */ React2.createElement(import_ui4.Grid, { container: true, gap: 0.75, alignItems: "center" }, /* @__PURE__ */ React2.createElement(import_ui4.Grid, { item: true, xs: 12 }, /* @__PURE__ */ React2.createElement(import_ui4.FormLabel, { size: "small" }, (0, import_i18n.__)("Name", "elementor"))), /* @__PURE__ */ React2.createElement(import_ui4.Grid, { item: true, xs: 12 }, /* @__PURE__ */ React2.createElement(
|
|
443
|
-
import_ui4.TextField,
|
|
788
|
+
/* @__PURE__ */ React8.createElement(
|
|
789
|
+
import_editor_controls3.FontFamilySelector,
|
|
444
790
|
{
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
791
|
+
fontFamilies,
|
|
792
|
+
fontFamily,
|
|
793
|
+
onFontFamilyChange: setFontFamily,
|
|
794
|
+
onClose: fontPopoverState.close
|
|
449
795
|
}
|
|
450
|
-
)
|
|
451
|
-
|
|
452
|
-
{
|
|
453
|
-
size: "tiny",
|
|
454
|
-
fullWidth: true,
|
|
455
|
-
value: color,
|
|
456
|
-
onChange: setColor,
|
|
457
|
-
slotProps: {
|
|
458
|
-
colorPicker: {
|
|
459
|
-
anchorEl: anchorRef.current,
|
|
460
|
-
anchorOrigin: { vertical: "top", horizontal: "right" },
|
|
461
|
-
transformOrigin: { vertical: "top", horizontal: -10 }
|
|
462
|
-
}
|
|
463
|
-
}
|
|
464
|
-
}
|
|
465
|
-
)))),
|
|
466
|
-
/* @__PURE__ */ React2.createElement(import_ui4.CardActions, null, /* @__PURE__ */ React2.createElement(import_ui4.Button, { size: "small", onClick: closePopover, color: "secondary", variant: "text" }, (0, import_i18n.__)("Cancel", "elementor")), /* @__PURE__ */ React2.createElement(import_ui4.Button, { size: "small", variant: "contained", disabled: isInValidForm(), onClick: handleCreate }, (0, import_i18n.__)("Create", "elementor")))
|
|
467
|
-
));
|
|
796
|
+
)
|
|
797
|
+
))))), /* @__PURE__ */ React8.createElement(import_ui9.CardActions, null, /* @__PURE__ */ React8.createElement(import_ui9.Button, { size: "small", variant: "contained", disabled: isFormInvalid(), onClick: handleCreate }, (0, import_i18n7.__)("Create", "elementor"))));
|
|
468
798
|
};
|
|
469
799
|
|
|
470
|
-
// src/components/
|
|
471
|
-
var
|
|
472
|
-
var
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
const
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
800
|
+
// src/components/font-variable-edit.tsx
|
|
801
|
+
var React9 = __toESM(require("react"));
|
|
802
|
+
var import_react6 = require("react");
|
|
803
|
+
var import_editor_controls4 = require("@elementor/editor-controls");
|
|
804
|
+
var import_editor_editing_panel2 = require("@elementor/editor-editing-panel");
|
|
805
|
+
var import_editor_ui5 = require("@elementor/editor-ui");
|
|
806
|
+
var import_icons7 = require("@elementor/icons");
|
|
807
|
+
var import_ui10 = require("@elementor/ui");
|
|
808
|
+
var import_i18n8 = require("@wordpress/i18n");
|
|
809
|
+
var SIZE6 = "tiny";
|
|
810
|
+
var FontVariableEdit = ({ onClose, onGoBack, onSubmit, editId }) => {
|
|
811
|
+
const variable = useVariable(editId);
|
|
812
|
+
if (!variable) {
|
|
813
|
+
throw new Error(`Global font variable "${editId}" not found`);
|
|
814
|
+
}
|
|
815
|
+
const [fontFamily, setFontFamily] = (0, import_react6.useState)(variable.value);
|
|
816
|
+
const [label, setLabel] = (0, import_react6.useState)(variable.label);
|
|
817
|
+
const variableNameId = (0, import_react6.useId)();
|
|
818
|
+
const variableValueId = (0, import_react6.useId)();
|
|
819
|
+
const anchorRef = (0, import_react6.useRef)(null);
|
|
820
|
+
const fontPopoverState = (0, import_ui10.usePopupState)({ variant: "popover" });
|
|
821
|
+
const fontFamilies = (0, import_editor_editing_panel2.useFontFamilies)();
|
|
822
|
+
const handleUpdate = () => {
|
|
823
|
+
updateVariable(editId, {
|
|
824
|
+
value: fontFamily,
|
|
825
|
+
label
|
|
826
|
+
}).then(() => {
|
|
827
|
+
onSubmit?.();
|
|
828
|
+
});
|
|
485
829
|
};
|
|
486
|
-
const
|
|
487
|
-
const
|
|
488
|
-
const
|
|
489
|
-
return /* @__PURE__ */
|
|
490
|
-
|
|
830
|
+
const noValueChanged = () => fontFamily === variable.value && label === variable.label;
|
|
831
|
+
const hasEmptyValue = () => "" === fontFamily.trim() || "" === label.trim();
|
|
832
|
+
const isSaveDisabled = () => noValueChanged() || hasEmptyValue();
|
|
833
|
+
return /* @__PURE__ */ React9.createElement(React9.Fragment, null, /* @__PURE__ */ React9.createElement(
|
|
834
|
+
import_editor_ui5.PopoverHeader,
|
|
491
835
|
{
|
|
836
|
+
icon: /* @__PURE__ */ React9.createElement(React9.Fragment, null, onGoBack && /* @__PURE__ */ React9.createElement(import_ui10.IconButton, { size: SIZE6, "aria-label": (0, import_i18n8.__)("Go Back", "elementor"), onClick: onGoBack }, /* @__PURE__ */ React9.createElement(import_icons7.ArrowLeftIcon, { fontSize: SIZE6 })), /* @__PURE__ */ React9.createElement(import_icons7.TextIcon, { fontSize: SIZE6 })),
|
|
837
|
+
title: (0, import_i18n8.__)("Edit variable", "elementor"),
|
|
838
|
+
onClose
|
|
839
|
+
}
|
|
840
|
+
), /* @__PURE__ */ React9.createElement(import_ui10.Divider, null), /* @__PURE__ */ React9.createElement(import_ui10.Stack, { p: 1.5, gap: 1.5 }, /* @__PURE__ */ React9.createElement(import_ui10.Grid, { container: true, gap: 0.75, alignItems: "center" }, /* @__PURE__ */ React9.createElement(import_ui10.Grid, { item: true, xs: 12 }, /* @__PURE__ */ React9.createElement(import_ui10.FormLabel, { htmlFor: variableNameId, size: "small" }, (0, import_i18n8.__)("Name", "elementor"))), /* @__PURE__ */ React9.createElement(import_ui10.Grid, { item: true, xs: 12 }, /* @__PURE__ */ React9.createElement(
|
|
841
|
+
import_ui10.TextField,
|
|
842
|
+
{
|
|
843
|
+
id: variableNameId,
|
|
844
|
+
size: "tiny",
|
|
492
845
|
fullWidth: true,
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
startIcon: /* @__PURE__ */ React3.createElement(import_ui5.Stack, { spacing: 1, direction: "row", alignItems: "center" }, startTagAdornment, /* @__PURE__ */ React3.createElement(import_icons3.ColorFilterIcon, { fontSize: "inherit", sx: { mr: 1 } })),
|
|
496
|
-
label: /* @__PURE__ */ React3.createElement(import_ui5.Box, { sx: { display: "inline-grid" } }, /* @__PURE__ */ React3.createElement(import_ui5.Typography, { sx: { textOverflow: "ellipsis", overflowX: "hidden" }, variant: "subtitle2" }, label)),
|
|
497
|
-
actions: /* @__PURE__ */ React3.createElement(import_ui5.IconButton, { size: SIZE2, onClick: unlinkVariable, "aria-label": (0, import_i18n2.__)("Unlink", "elementor") }, /* @__PURE__ */ React3.createElement(import_icons3.DetachIcon, { fontSize: SIZE2 }))
|
|
846
|
+
value: label,
|
|
847
|
+
onChange: (e) => setLabel(e.target.value)
|
|
498
848
|
}
|
|
499
|
-
), /* @__PURE__ */
|
|
500
|
-
|
|
849
|
+
))), /* @__PURE__ */ React9.createElement(import_ui10.Grid, { container: true, gap: 0.75, alignItems: "center" }, /* @__PURE__ */ React9.createElement(import_ui10.Grid, { item: true, xs: 12 }, /* @__PURE__ */ React9.createElement(import_ui10.FormLabel, { htmlFor: variableValueId, size: "small" }, (0, import_i18n8.__)("Value", "elementor"))), /* @__PURE__ */ React9.createElement(import_ui10.Grid, { item: true, xs: 12 }, /* @__PURE__ */ React9.createElement(React9.Fragment, null, /* @__PURE__ */ React9.createElement(
|
|
850
|
+
import_ui10.UnstableTag,
|
|
501
851
|
{
|
|
502
|
-
|
|
852
|
+
id: variableValueId,
|
|
853
|
+
variant: "outlined",
|
|
854
|
+
label: fontFamily,
|
|
855
|
+
endIcon: /* @__PURE__ */ React9.createElement(import_icons7.ChevronDownIcon, { fontSize: "tiny" }),
|
|
856
|
+
...(0, import_ui10.bindTrigger)(fontPopoverState),
|
|
857
|
+
fullWidth: true
|
|
858
|
+
}
|
|
859
|
+
), /* @__PURE__ */ React9.createElement(
|
|
860
|
+
import_ui10.Popover,
|
|
861
|
+
{
|
|
862
|
+
disablePortal: true,
|
|
503
863
|
disableScrollLock: true,
|
|
504
864
|
anchorEl: anchorRef.current,
|
|
505
|
-
anchorOrigin: { vertical: "
|
|
506
|
-
transformOrigin: { vertical: "top", horizontal:
|
|
865
|
+
anchorOrigin: { vertical: "top", horizontal: "right" },
|
|
866
|
+
transformOrigin: { vertical: "top", horizontal: -20 },
|
|
867
|
+
...(0, import_ui10.bindPopover)(fontPopoverState)
|
|
507
868
|
},
|
|
508
|
-
/* @__PURE__ */
|
|
509
|
-
|
|
869
|
+
/* @__PURE__ */ React9.createElement(
|
|
870
|
+
import_editor_controls4.FontFamilySelector,
|
|
510
871
|
{
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
/* @__PURE__ */ React3.createElement(
|
|
516
|
-
import_ui5.IconButton,
|
|
517
|
-
{
|
|
518
|
-
key: "createVariable",
|
|
519
|
-
...(0, import_ui5.bindTrigger)(creationPopupState),
|
|
520
|
-
size: SIZE2,
|
|
521
|
-
onClick: handleCreateButtonClick
|
|
522
|
-
},
|
|
523
|
-
/* @__PURE__ */ React3.createElement(import_icons3.PlusIcon, { fontSize: SIZE2 })
|
|
524
|
-
)
|
|
525
|
-
]
|
|
872
|
+
fontFamilies,
|
|
873
|
+
fontFamily,
|
|
874
|
+
onFontFamilyChange: setFontFamily,
|
|
875
|
+
onClose: fontPopoverState.close
|
|
526
876
|
}
|
|
527
|
-
)
|
|
528
|
-
|
|
529
|
-
|
|
877
|
+
)
|
|
878
|
+
))))), /* @__PURE__ */ React9.createElement(import_ui10.CardActions, null, /* @__PURE__ */ React9.createElement(import_ui10.Button, { size: "small", variant: "contained", disabled: isSaveDisabled(), onClick: handleUpdate }, (0, import_i18n8.__)("Save", "elementor"))));
|
|
879
|
+
};
|
|
880
|
+
|
|
881
|
+
// src/components/font-variables-selection.tsx
|
|
882
|
+
var React10 = __toESM(require("react"));
|
|
883
|
+
var import_react7 = require("react");
|
|
884
|
+
var import_editor_controls5 = require("@elementor/editor-controls");
|
|
885
|
+
var import_editor_ui6 = require("@elementor/editor-ui");
|
|
886
|
+
var import_icons8 = require("@elementor/icons");
|
|
887
|
+
var import_ui11 = require("@elementor/ui");
|
|
888
|
+
var import_i18n9 = require("@wordpress/i18n");
|
|
889
|
+
var SIZE7 = "tiny";
|
|
890
|
+
var FontVariablesSelection = ({ closePopover, onAdd, onEdit, onSettings }) => {
|
|
891
|
+
const { value: variable, setValue: setVariable } = (0, import_editor_controls5.useBoundProp)(fontVariablePropTypeUtil);
|
|
892
|
+
const [searchValue, setSearchValue] = (0, import_react7.useState)("");
|
|
893
|
+
const {
|
|
894
|
+
list: variables,
|
|
895
|
+
hasMatches: hasSearchResults,
|
|
896
|
+
isSourceNotEmpty: hasVariables
|
|
897
|
+
} = useFilteredVariables(searchValue, fontVariablePropTypeUtil.key);
|
|
898
|
+
const handleSetVariable = (key) => {
|
|
899
|
+
setVariable(key);
|
|
900
|
+
closePopover();
|
|
901
|
+
};
|
|
902
|
+
const actions = [];
|
|
903
|
+
if (onAdd) {
|
|
904
|
+
actions.push(
|
|
905
|
+
/* @__PURE__ */ React10.createElement(import_ui11.IconButton, { key: "add", size: SIZE7, onClick: onAdd }, /* @__PURE__ */ React10.createElement(import_icons8.PlusIcon, { fontSize: SIZE7 }))
|
|
906
|
+
);
|
|
907
|
+
}
|
|
908
|
+
if (onSettings) {
|
|
909
|
+
actions.push(
|
|
910
|
+
/* @__PURE__ */ React10.createElement(import_ui11.IconButton, { key: "settings", size: SIZE7, onClick: onSettings }, /* @__PURE__ */ React10.createElement(import_icons8.SettingsIcon, { fontSize: SIZE7 }))
|
|
911
|
+
);
|
|
912
|
+
}
|
|
913
|
+
const items = variables.map(({ value, label, key }) => ({
|
|
914
|
+
type: "item",
|
|
915
|
+
value: key,
|
|
916
|
+
label,
|
|
917
|
+
icon: /* @__PURE__ */ React10.createElement(import_icons8.TextIcon, null),
|
|
918
|
+
secondaryText: value,
|
|
919
|
+
onEdit: () => onEdit?.(key)
|
|
920
|
+
}));
|
|
921
|
+
const handleSearch = (search) => {
|
|
922
|
+
setSearchValue(search);
|
|
923
|
+
};
|
|
924
|
+
const handleClearSearch = () => {
|
|
925
|
+
setSearchValue("");
|
|
926
|
+
};
|
|
927
|
+
return /* @__PURE__ */ React10.createElement(React10.Fragment, null, /* @__PURE__ */ React10.createElement(
|
|
928
|
+
import_editor_ui6.PopoverHeader,
|
|
929
|
+
{
|
|
930
|
+
title: (0, import_i18n9.__)("Variables", "elementor"),
|
|
931
|
+
onClose: closePopover,
|
|
932
|
+
icon: /* @__PURE__ */ React10.createElement(import_icons8.ColorFilterIcon, { fontSize: SIZE7 }),
|
|
933
|
+
actions
|
|
934
|
+
}
|
|
935
|
+
), hasVariables && /* @__PURE__ */ React10.createElement(
|
|
936
|
+
import_editor_ui6.PopoverSearch,
|
|
937
|
+
{
|
|
938
|
+
value: searchValue,
|
|
939
|
+
onSearch: handleSearch,
|
|
940
|
+
placeholder: (0, import_i18n9.__)("Search", "elementor")
|
|
941
|
+
}
|
|
942
|
+
), /* @__PURE__ */ React10.createElement(import_ui11.Divider, null), hasVariables && hasSearchResults && /* @__PURE__ */ React10.createElement(
|
|
943
|
+
import_editor_ui6.PopoverMenuList,
|
|
944
|
+
{
|
|
945
|
+
items,
|
|
946
|
+
onSelect: handleSetVariable,
|
|
947
|
+
onClose: () => {
|
|
948
|
+
},
|
|
949
|
+
selectedValue: variable,
|
|
950
|
+
"data-testid": "font-variables-list",
|
|
951
|
+
menuListTemplate: VariablesStyledMenuList,
|
|
952
|
+
menuItemContentTemplate: (item) => /* @__PURE__ */ React10.createElement(MenuItemContent, { item })
|
|
953
|
+
}
|
|
954
|
+
), !hasSearchResults && hasVariables && /* @__PURE__ */ React10.createElement(NoSearchResults, { searchValue, onClear: handleClearSearch }), !hasVariables && /* @__PURE__ */ React10.createElement(NoVariables, { icon: /* @__PURE__ */ React10.createElement(import_icons8.TextIcon, { fontSize: "large" }), onAdd }));
|
|
530
955
|
};
|
|
531
956
|
|
|
532
|
-
// src/
|
|
533
|
-
var
|
|
534
|
-
|
|
535
|
-
|
|
957
|
+
// src/components/variable-selection-popover.tsx
|
|
958
|
+
var VIEW_LIST = "list";
|
|
959
|
+
var VIEW_ADD = "add";
|
|
960
|
+
var VIEW_EDIT = "edit";
|
|
961
|
+
var VariableSelectionPopover = ({ closePopover, propTypeKey, selectedVariable }) => {
|
|
962
|
+
const [currentView, setCurrentView] = (0, import_react8.useState)(VIEW_LIST);
|
|
963
|
+
const editIdRef = (0, import_react8.useRef)("");
|
|
964
|
+
return renderStage({
|
|
965
|
+
propTypeKey,
|
|
966
|
+
currentView,
|
|
967
|
+
selectedVariable,
|
|
968
|
+
editIdRef,
|
|
969
|
+
setCurrentView,
|
|
970
|
+
closePopover
|
|
971
|
+
});
|
|
972
|
+
};
|
|
973
|
+
function renderStage(props) {
|
|
974
|
+
const handleSubmitOnEdit = () => {
|
|
975
|
+
if (props?.selectedVariable?.key === props.editIdRef.current) {
|
|
976
|
+
props.closePopover();
|
|
977
|
+
} else {
|
|
978
|
+
props.setCurrentView(VIEW_LIST);
|
|
979
|
+
}
|
|
980
|
+
};
|
|
981
|
+
if (fontVariablePropTypeUtil.key === props.propTypeKey) {
|
|
982
|
+
if (VIEW_LIST === props.currentView) {
|
|
983
|
+
return /* @__PURE__ */ React11.createElement(
|
|
984
|
+
FontVariablesSelection,
|
|
985
|
+
{
|
|
986
|
+
closePopover: props.closePopover,
|
|
987
|
+
onAdd: () => {
|
|
988
|
+
props.setCurrentView(VIEW_ADD);
|
|
989
|
+
},
|
|
990
|
+
onEdit: (key) => {
|
|
991
|
+
props.editIdRef.current = key;
|
|
992
|
+
props.setCurrentView(VIEW_EDIT);
|
|
993
|
+
}
|
|
994
|
+
}
|
|
995
|
+
);
|
|
996
|
+
}
|
|
997
|
+
if (VIEW_ADD === props.currentView) {
|
|
998
|
+
return /* @__PURE__ */ React11.createElement(
|
|
999
|
+
FontVariableCreation,
|
|
1000
|
+
{
|
|
1001
|
+
onGoBack: () => props.setCurrentView(VIEW_LIST),
|
|
1002
|
+
onClose: props.closePopover
|
|
1003
|
+
}
|
|
1004
|
+
);
|
|
1005
|
+
}
|
|
1006
|
+
if (VIEW_EDIT === props.currentView) {
|
|
1007
|
+
return /* @__PURE__ */ React11.createElement(
|
|
1008
|
+
FontVariableEdit,
|
|
1009
|
+
{
|
|
1010
|
+
editId: props.editIdRef.current ?? "",
|
|
1011
|
+
onGoBack: () => props.setCurrentView(VIEW_LIST),
|
|
1012
|
+
onClose: props.closePopover,
|
|
1013
|
+
onSubmit: handleSubmitOnEdit
|
|
1014
|
+
}
|
|
1015
|
+
);
|
|
1016
|
+
}
|
|
1017
|
+
}
|
|
1018
|
+
if (colorVariablePropTypeUtil.key === props.propTypeKey) {
|
|
1019
|
+
if (VIEW_LIST === props.currentView) {
|
|
1020
|
+
return /* @__PURE__ */ React11.createElement(
|
|
1021
|
+
ColorVariablesSelection,
|
|
1022
|
+
{
|
|
1023
|
+
closePopover: props.closePopover,
|
|
1024
|
+
onAdd: () => {
|
|
1025
|
+
props.setCurrentView(VIEW_ADD);
|
|
1026
|
+
},
|
|
1027
|
+
onEdit: (key) => {
|
|
1028
|
+
props.editIdRef.current = key;
|
|
1029
|
+
props.setCurrentView(VIEW_EDIT);
|
|
1030
|
+
}
|
|
1031
|
+
}
|
|
1032
|
+
);
|
|
1033
|
+
}
|
|
1034
|
+
if (VIEW_ADD === props.currentView) {
|
|
1035
|
+
return /* @__PURE__ */ React11.createElement(
|
|
1036
|
+
ColorVariableCreation,
|
|
1037
|
+
{
|
|
1038
|
+
onGoBack: () => props.setCurrentView(VIEW_LIST),
|
|
1039
|
+
onClose: props.closePopover
|
|
1040
|
+
}
|
|
1041
|
+
);
|
|
1042
|
+
}
|
|
1043
|
+
if (VIEW_EDIT === props.currentView) {
|
|
1044
|
+
return /* @__PURE__ */ React11.createElement(
|
|
1045
|
+
ColorVariableEdit,
|
|
1046
|
+
{
|
|
1047
|
+
editId: props.editIdRef.current ?? "",
|
|
1048
|
+
onGoBack: () => props.setCurrentView(VIEW_LIST),
|
|
1049
|
+
onClose: props.closePopover,
|
|
1050
|
+
onSubmit: handleSubmitOnEdit
|
|
1051
|
+
}
|
|
1052
|
+
);
|
|
1053
|
+
}
|
|
1054
|
+
}
|
|
1055
|
+
return null;
|
|
1056
|
+
}
|
|
1057
|
+
|
|
1058
|
+
// src/controls/color-variable-control.tsx
|
|
1059
|
+
var SIZE8 = "tiny";
|
|
1060
|
+
var ColorVariableControl = () => {
|
|
1061
|
+
const { setValue: setColor } = (0, import_editor_controls6.useBoundProp)();
|
|
1062
|
+
const { value: variableValue } = (0, import_editor_controls6.useBoundProp)(colorVariablePropTypeUtil);
|
|
1063
|
+
const anchorRef = (0, import_react9.useRef)(null);
|
|
1064
|
+
const popupId = (0, import_react9.useId)();
|
|
1065
|
+
const popupState = (0, import_ui12.usePopupState)({
|
|
1066
|
+
variant: "popover",
|
|
1067
|
+
popupId: `elementor-variables-list-${popupId}`
|
|
1068
|
+
});
|
|
536
1069
|
const selectedVariable = useVariable(variableValue);
|
|
537
1070
|
if (!selectedVariable) {
|
|
538
1071
|
throw new Error(`Global color variable ${variableValue} not found`);
|
|
539
1072
|
}
|
|
540
1073
|
const unlinkVariable = () => {
|
|
541
|
-
|
|
1074
|
+
setColor(import_editor_props3.colorPropTypeUtil.create(selectedVariable.value));
|
|
542
1075
|
};
|
|
543
|
-
return /* @__PURE__ */
|
|
544
|
-
|
|
1076
|
+
return /* @__PURE__ */ React12.createElement(import_ui12.Box, { ref: anchorRef }, /* @__PURE__ */ React12.createElement(
|
|
1077
|
+
import_ui12.UnstableTag,
|
|
545
1078
|
{
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
1079
|
+
fullWidth: true,
|
|
1080
|
+
showActionsOnHover: true,
|
|
1081
|
+
startIcon: /* @__PURE__ */ React12.createElement(import_ui12.Stack, { spacing: 0.75, direction: "row", alignItems: "center" }, /* @__PURE__ */ React12.createElement(ColorIndicator, { size: "inherit", value: selectedVariable.value, component: "span" }), /* @__PURE__ */ React12.createElement(import_icons9.ColorFilterIcon, { fontSize: "inherit", sx: { mr: 1 } })),
|
|
1082
|
+
label: /* @__PURE__ */ React12.createElement(import_ui12.Box, { sx: { display: "inline-grid", minWidth: 0 } }, /* @__PURE__ */ React12.createElement(
|
|
1083
|
+
import_ui12.Typography,
|
|
1084
|
+
{
|
|
1085
|
+
sx: { textOverflow: "ellipsis", overflowX: "hidden", lineHeight: 1 },
|
|
1086
|
+
variant: "caption"
|
|
1087
|
+
},
|
|
1088
|
+
selectedVariable.label
|
|
1089
|
+
)),
|
|
1090
|
+
actions: /* @__PURE__ */ React12.createElement(import_ui12.IconButton, { size: SIZE8, onClick: unlinkVariable, "aria-label": (0, import_i18n10.__)("Unlink", "elementor") }, /* @__PURE__ */ React12.createElement(import_icons9.DetachIcon, { fontSize: SIZE8 })),
|
|
1091
|
+
...(0, import_ui12.bindTrigger)(popupState)
|
|
1092
|
+
}
|
|
1093
|
+
), /* @__PURE__ */ React12.createElement(
|
|
1094
|
+
import_ui12.Popover,
|
|
1095
|
+
{
|
|
1096
|
+
disableScrollLock: true,
|
|
1097
|
+
anchorEl: anchorRef.current,
|
|
1098
|
+
anchorOrigin: { vertical: "bottom", horizontal: "right" },
|
|
1099
|
+
transformOrigin: { vertical: "top", horizontal: "right" },
|
|
1100
|
+
...(0, import_ui12.bindPopover)(popupState)
|
|
549
1101
|
},
|
|
550
|
-
|
|
551
|
-
|
|
1102
|
+
/* @__PURE__ */ React12.createElement(
|
|
1103
|
+
VariableSelectionPopover,
|
|
1104
|
+
{
|
|
1105
|
+
selectedVariable,
|
|
1106
|
+
closePopover: popupState.close,
|
|
1107
|
+
propTypeKey: colorVariablePropTypeUtil.key
|
|
1108
|
+
}
|
|
1109
|
+
)
|
|
1110
|
+
));
|
|
552
1111
|
};
|
|
553
1112
|
|
|
554
1113
|
// src/hooks/use-prop-color-variable-action.tsx
|
|
555
|
-
var
|
|
556
|
-
var
|
|
557
|
-
var
|
|
558
|
-
var
|
|
559
|
-
|
|
560
|
-
// src/prop-types/font-variable-prop-type.ts
|
|
561
|
-
var import_editor_props3 = require("@elementor/editor-props");
|
|
562
|
-
var import_schema2 = require("@elementor/schema");
|
|
563
|
-
var fontVariablePropTypeUtil = (0, import_editor_props3.createPropUtils)("global-font-variable", import_schema2.z.string());
|
|
1114
|
+
var React13 = __toESM(require("react"));
|
|
1115
|
+
var import_editor_editing_panel3 = require("@elementor/editor-editing-panel");
|
|
1116
|
+
var import_icons10 = require("@elementor/icons");
|
|
1117
|
+
var import_i18n11 = require("@wordpress/i18n");
|
|
564
1118
|
|
|
565
1119
|
// src/utils.ts
|
|
566
1120
|
var hasAssignedColorVariable = (propValue) => {
|
|
@@ -578,13 +1132,15 @@ var supportsFontVariables = (propType) => {
|
|
|
578
1132
|
|
|
579
1133
|
// src/hooks/use-prop-color-variable-action.tsx
|
|
580
1134
|
var usePropColorVariableAction = () => {
|
|
581
|
-
const { propType } = (0,
|
|
1135
|
+
const { propType } = (0, import_editor_editing_panel3.useBoundProp)();
|
|
582
1136
|
const visible = !!propType && supportsColorVariables(propType);
|
|
583
1137
|
return {
|
|
584
1138
|
visible,
|
|
585
|
-
icon:
|
|
586
|
-
title: (0,
|
|
587
|
-
|
|
1139
|
+
icon: import_icons10.ColorFilterIcon,
|
|
1140
|
+
title: (0, import_i18n11.__)("Variables", "elementor"),
|
|
1141
|
+
content: ({ close: closePopover }) => {
|
|
1142
|
+
return /* @__PURE__ */ React13.createElement(VariableSelectionPopover, { closePopover, propTypeKey: colorVariablePropTypeUtil.key });
|
|
1143
|
+
}
|
|
588
1144
|
};
|
|
589
1145
|
};
|
|
590
1146
|
|
|
@@ -598,113 +1154,143 @@ var variableTransformer = (0, import_editor_canvas.createTransformer)((value) =>
|
|
|
598
1154
|
});
|
|
599
1155
|
|
|
600
1156
|
// src/init-color-variables.ts
|
|
601
|
-
var { registerPopoverAction } =
|
|
602
|
-
|
|
603
|
-
(
|
|
604
|
-
|
|
1157
|
+
var { registerPopoverAction } = import_editor_editing_panel4.controlActionsMenu;
|
|
1158
|
+
var conditions = {
|
|
1159
|
+
backgroundOverlay: ({ value: prop }) => {
|
|
1160
|
+
return hasAssignedColorVariable(import_editor_props4.backgroundColorOverlayPropTypeUtil.extract(prop)?.color);
|
|
1161
|
+
},
|
|
1162
|
+
boxShadow: ({ value: prop }) => {
|
|
1163
|
+
return hasAssignedColorVariable(import_editor_props4.shadowPropTypeUtil.extract(prop)?.color);
|
|
1164
|
+
}
|
|
1165
|
+
};
|
|
1166
|
+
function registerControlsAndActions() {
|
|
1167
|
+
(0, import_editor_editing_panel4.registerControlReplacement)({
|
|
1168
|
+
component: ColorVariableControl,
|
|
605
1169
|
condition: ({ value }) => hasAssignedColorVariable(value)
|
|
606
1170
|
});
|
|
607
1171
|
registerPopoverAction({
|
|
608
1172
|
id: "color-variables",
|
|
609
1173
|
useProps: usePropColorVariableAction
|
|
610
1174
|
});
|
|
1175
|
+
}
|
|
1176
|
+
function registerRepeaterItemIcons() {
|
|
1177
|
+
(0, import_editor_controls7.injectIntoRepeaterItemIcon)({
|
|
1178
|
+
id: "color-variables-background-icon",
|
|
1179
|
+
component: BackgroundRepeaterColorIndicator,
|
|
1180
|
+
condition: conditions.backgroundOverlay
|
|
1181
|
+
});
|
|
1182
|
+
(0, import_editor_controls7.injectIntoRepeaterItemIcon)({
|
|
1183
|
+
id: "color-variables-icon",
|
|
1184
|
+
component: BoxShadowRepeaterColorIndicator,
|
|
1185
|
+
condition: conditions.boxShadow
|
|
1186
|
+
});
|
|
1187
|
+
}
|
|
1188
|
+
function registerRepeaterItemLabels() {
|
|
1189
|
+
(0, import_editor_controls7.injectIntoRepeaterItemLabel)({
|
|
1190
|
+
id: "color-variables-label",
|
|
1191
|
+
component: BackgroundRepeaterLabel,
|
|
1192
|
+
condition: conditions.backgroundOverlay
|
|
1193
|
+
});
|
|
1194
|
+
}
|
|
1195
|
+
function registerStyleTransformers() {
|
|
611
1196
|
import_editor_canvas2.styleTransformersRegistry.register(colorVariablePropTypeUtil.key, variableTransformer);
|
|
612
1197
|
}
|
|
1198
|
+
function initColorVariables() {
|
|
1199
|
+
registerControlsAndActions();
|
|
1200
|
+
registerRepeaterItemIcons();
|
|
1201
|
+
registerRepeaterItemLabels();
|
|
1202
|
+
registerStyleTransformers();
|
|
1203
|
+
}
|
|
613
1204
|
|
|
614
1205
|
// src/init-font-variables.ts
|
|
615
1206
|
var import_editor_canvas3 = require("@elementor/editor-canvas");
|
|
616
|
-
var
|
|
617
|
-
|
|
618
|
-
// src/controls/font-variables-selection-control.tsx
|
|
619
|
-
var React7 = __toESM(require("react"));
|
|
620
|
-
var import_editor_controls5 = require("@elementor/editor-controls");
|
|
621
|
-
var import_editor_props4 = require("@elementor/editor-props");
|
|
622
|
-
|
|
623
|
-
// src/components/font-variables-selection.tsx
|
|
624
|
-
var React6 = __toESM(require("react"));
|
|
625
|
-
var import_react5 = require("react");
|
|
626
|
-
var import_editor_controls4 = require("@elementor/editor-controls");
|
|
627
|
-
var import_icons5 = require("@elementor/icons");
|
|
628
|
-
var import_ui6 = require("@elementor/ui");
|
|
629
|
-
var FontVariablesSelection = ({ onSelect }) => {
|
|
630
|
-
const { value: variable, setValue: setVariable } = (0, import_editor_controls4.useBoundProp)(fontVariablePropTypeUtil);
|
|
631
|
-
const variables = usePropVariables(fontVariablePropTypeUtil.key);
|
|
632
|
-
const handleSetVariable = (key) => {
|
|
633
|
-
setVariable(key);
|
|
634
|
-
onSelect?.();
|
|
635
|
-
};
|
|
636
|
-
return /* @__PURE__ */ React6.createElement(import_react5.Fragment, null, /* @__PURE__ */ React6.createElement(import_ui6.Divider, null), /* @__PURE__ */ React6.createElement(import_ui6.Box, { sx: { overflowY: "auto", height: 260, width: 220 } }, /* @__PURE__ */ React6.createElement(import_ui6.MenuList, { role: "listbox", tabIndex: 0 }, variables.map(({ value, label, key }) => /* @__PURE__ */ React6.createElement(
|
|
637
|
-
StyledMenuItem,
|
|
638
|
-
{
|
|
639
|
-
key,
|
|
640
|
-
onClick: () => handleSetVariable(key),
|
|
641
|
-
selected: key === variable
|
|
642
|
-
},
|
|
643
|
-
/* @__PURE__ */ React6.createElement(import_ui6.ListItemIcon, null, /* @__PURE__ */ React6.createElement(import_icons5.TextIcon, null)),
|
|
644
|
-
/* @__PURE__ */ React6.createElement(
|
|
645
|
-
import_ui6.ListItemText,
|
|
646
|
-
{
|
|
647
|
-
primary: label,
|
|
648
|
-
secondary: value,
|
|
649
|
-
primaryTypographyProps: {
|
|
650
|
-
variant: "body2",
|
|
651
|
-
color: "text.secondary",
|
|
652
|
-
style: {
|
|
653
|
-
lineHeight: 2,
|
|
654
|
-
display: "inline-block",
|
|
655
|
-
overflow: "hidden",
|
|
656
|
-
textOverflow: "ellipsis",
|
|
657
|
-
whiteSpace: "nowrap",
|
|
658
|
-
maxWidth: "81px"
|
|
659
|
-
}
|
|
660
|
-
},
|
|
661
|
-
secondaryTypographyProps: {
|
|
662
|
-
variant: "caption",
|
|
663
|
-
color: "text.tertiary",
|
|
664
|
-
style: { marginTop: "1px", lineHeight: "1" }
|
|
665
|
-
},
|
|
666
|
-
sx: { display: "flex", alignItems: "center", gap: 1 }
|
|
667
|
-
}
|
|
668
|
-
),
|
|
669
|
-
/* @__PURE__ */ React6.createElement(import_icons5.EditIcon, { color: "action", fontSize: "inherit", sx: { mx: 1, opacity: "0" } })
|
|
670
|
-
)))));
|
|
671
|
-
};
|
|
1207
|
+
var import_editor_editing_panel6 = require("@elementor/editor-editing-panel");
|
|
672
1208
|
|
|
673
|
-
// src/controls/font-
|
|
674
|
-
var
|
|
675
|
-
|
|
676
|
-
|
|
1209
|
+
// src/controls/font-variable-control.tsx
|
|
1210
|
+
var React14 = __toESM(require("react"));
|
|
1211
|
+
var import_react10 = require("react");
|
|
1212
|
+
var import_editor_controls8 = require("@elementor/editor-controls");
|
|
1213
|
+
var import_editor_props5 = require("@elementor/editor-props");
|
|
1214
|
+
var import_icons11 = require("@elementor/icons");
|
|
1215
|
+
var import_ui13 = require("@elementor/ui");
|
|
1216
|
+
var import_i18n12 = require("@wordpress/i18n");
|
|
1217
|
+
var SIZE9 = "tiny";
|
|
1218
|
+
var FontVariableControl = () => {
|
|
1219
|
+
const { setValue: setFontFamily } = (0, import_editor_controls8.useBoundProp)();
|
|
1220
|
+
const { value: variableValue } = (0, import_editor_controls8.useBoundProp)(fontVariablePropTypeUtil);
|
|
1221
|
+
const anchorRef = (0, import_react10.useRef)(null);
|
|
1222
|
+
const popupId = (0, import_react10.useId)();
|
|
1223
|
+
const popupState = (0, import_ui13.usePopupState)({
|
|
1224
|
+
variant: "popover",
|
|
1225
|
+
popupId: `elementor-variables-list-${popupId}`
|
|
1226
|
+
});
|
|
677
1227
|
const selectedVariable = useVariable(variableValue);
|
|
678
1228
|
if (!selectedVariable) {
|
|
679
1229
|
throw new Error(`Global font variable ${variableValue} not found`);
|
|
680
1230
|
}
|
|
681
1231
|
const unlinkVariable = () => {
|
|
682
|
-
setFontFamily(
|
|
1232
|
+
setFontFamily(import_editor_props5.stringPropTypeUtil.create(selectedVariable.value));
|
|
683
1233
|
};
|
|
684
|
-
return /* @__PURE__ */
|
|
1234
|
+
return /* @__PURE__ */ React14.createElement(import_ui13.Box, { ref: anchorRef }, /* @__PURE__ */ React14.createElement(
|
|
1235
|
+
import_ui13.UnstableTag,
|
|
1236
|
+
{
|
|
1237
|
+
fullWidth: true,
|
|
1238
|
+
showActionsOnHover: true,
|
|
1239
|
+
startIcon: /* @__PURE__ */ React14.createElement(import_ui13.Stack, { spacing: 0.75, direction: "row", alignItems: "center" }, /* @__PURE__ */ React14.createElement(import_icons11.ColorFilterIcon, { fontSize: "inherit", sx: { mr: 1 } })),
|
|
1240
|
+
label: /* @__PURE__ */ React14.createElement(import_ui13.Box, { sx: { display: "inline-grid", minWidth: 0 } }, /* @__PURE__ */ React14.createElement(
|
|
1241
|
+
import_ui13.Typography,
|
|
1242
|
+
{
|
|
1243
|
+
sx: { textOverflow: "ellipsis", overflowX: "hidden", lineHeight: 1 },
|
|
1244
|
+
variant: "caption"
|
|
1245
|
+
},
|
|
1246
|
+
selectedVariable.label
|
|
1247
|
+
)),
|
|
1248
|
+
actions: /* @__PURE__ */ React14.createElement(import_ui13.IconButton, { size: SIZE9, onClick: unlinkVariable, "aria-label": (0, import_i18n12.__)("Unlink", "elementor") }, /* @__PURE__ */ React14.createElement(import_icons11.DetachIcon, { fontSize: SIZE9 })),
|
|
1249
|
+
...(0, import_ui13.bindTrigger)(popupState)
|
|
1250
|
+
}
|
|
1251
|
+
), /* @__PURE__ */ React14.createElement(
|
|
1252
|
+
import_ui13.Popover,
|
|
1253
|
+
{
|
|
1254
|
+
disableScrollLock: true,
|
|
1255
|
+
anchorEl: anchorRef.current,
|
|
1256
|
+
anchorOrigin: { vertical: "bottom", horizontal: "right" },
|
|
1257
|
+
transformOrigin: { vertical: "top", horizontal: "right" },
|
|
1258
|
+
...(0, import_ui13.bindPopover)(popupState)
|
|
1259
|
+
},
|
|
1260
|
+
/* @__PURE__ */ React14.createElement(
|
|
1261
|
+
VariableSelectionPopover,
|
|
1262
|
+
{
|
|
1263
|
+
selectedVariable,
|
|
1264
|
+
closePopover: popupState.close,
|
|
1265
|
+
propTypeKey: fontVariablePropTypeUtil.key
|
|
1266
|
+
}
|
|
1267
|
+
)
|
|
1268
|
+
));
|
|
685
1269
|
};
|
|
686
1270
|
|
|
687
1271
|
// src/hooks/use-prop-font-variable-action.tsx
|
|
688
|
-
var
|
|
689
|
-
var
|
|
690
|
-
var
|
|
691
|
-
var
|
|
1272
|
+
var React15 = __toESM(require("react"));
|
|
1273
|
+
var import_editor_editing_panel5 = require("@elementor/editor-editing-panel");
|
|
1274
|
+
var import_icons12 = require("@elementor/icons");
|
|
1275
|
+
var import_i18n13 = require("@wordpress/i18n");
|
|
692
1276
|
var usePropFontVariableAction = () => {
|
|
693
|
-
const { propType } = (0,
|
|
1277
|
+
const { propType } = (0, import_editor_editing_panel5.useBoundProp)();
|
|
694
1278
|
const visible = !!propType && supportsFontVariables(propType);
|
|
695
1279
|
return {
|
|
696
1280
|
visible,
|
|
697
|
-
icon:
|
|
698
|
-
title: (0,
|
|
699
|
-
|
|
1281
|
+
icon: import_icons12.ColorFilterIcon,
|
|
1282
|
+
title: (0, import_i18n13.__)("Variables", "elementor"),
|
|
1283
|
+
content: ({ close: closePopover }) => {
|
|
1284
|
+
return /* @__PURE__ */ React15.createElement(VariableSelectionPopover, { closePopover, propTypeKey: fontVariablePropTypeUtil.key });
|
|
1285
|
+
}
|
|
700
1286
|
};
|
|
701
1287
|
};
|
|
702
1288
|
|
|
703
1289
|
// src/init-font-variables.ts
|
|
704
|
-
var { registerPopoverAction: registerPopoverAction2 } =
|
|
1290
|
+
var { registerPopoverAction: registerPopoverAction2 } = import_editor_editing_panel6.controlActionsMenu;
|
|
705
1291
|
function initFontVariables() {
|
|
706
|
-
(0,
|
|
707
|
-
component:
|
|
1292
|
+
(0, import_editor_editing_panel6.registerControlReplacement)({
|
|
1293
|
+
component: FontVariableControl,
|
|
708
1294
|
condition: ({ value }) => hasAssignedFontVariable(value)
|
|
709
1295
|
});
|
|
710
1296
|
registerPopoverAction2({
|
|
@@ -715,10 +1301,10 @@ function initFontVariables() {
|
|
|
715
1301
|
}
|
|
716
1302
|
|
|
717
1303
|
// src/renderers/style-variables-renderer.tsx
|
|
718
|
-
var
|
|
719
|
-
var
|
|
1304
|
+
var React16 = __toESM(require("react"));
|
|
1305
|
+
var import_react11 = require("react");
|
|
720
1306
|
var import_editor_v1_adapters = require("@elementor/editor-v1-adapters");
|
|
721
|
-
var
|
|
1307
|
+
var import_ui14 = require("@elementor/ui");
|
|
722
1308
|
|
|
723
1309
|
// src/sync/get-canvas-iframe-document.ts
|
|
724
1310
|
function getCanvasIframeDocument() {
|
|
@@ -737,14 +1323,14 @@ function StyleVariablesRenderer() {
|
|
|
737
1323
|
}
|
|
738
1324
|
const cssVariables = convertToCssVariables(styleVariables);
|
|
739
1325
|
const wrappedCss = `${VARIABLES_WRAPPER}{${cssVariables}}`;
|
|
740
|
-
return /* @__PURE__ */
|
|
1326
|
+
return /* @__PURE__ */ React16.createElement(import_ui14.Portal, { container }, /* @__PURE__ */ React16.createElement("style", { "data-e-style-id": "e-variables", key: wrappedCss }, wrappedCss));
|
|
741
1327
|
}
|
|
742
1328
|
function usePortalContainer() {
|
|
743
1329
|
return (0, import_editor_v1_adapters.__privateUseListenTo)((0, import_editor_v1_adapters.commandEndEvent)("editor/documents/attach-preview"), () => getCanvasIframeDocument()?.head);
|
|
744
1330
|
}
|
|
745
1331
|
function useStyleVariables() {
|
|
746
|
-
const [variables, setVariables] = (0,
|
|
747
|
-
(0,
|
|
1332
|
+
const [variables, setVariables] = (0, import_react11.useState)({});
|
|
1333
|
+
(0, import_react11.useEffect)(() => {
|
|
748
1334
|
const unsubscribe = styleVariablesRepository.subscribe(setVariables);
|
|
749
1335
|
return () => {
|
|
750
1336
|
unsubscribe();
|