@elementor/editor-variables 0.13.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 +46 -0
- package/dist/index.js +837 -334
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +865 -317
- package/dist/index.mjs.map +1 -1
- package/package.json +10 -9
- package/src/components/color-variable-creation.tsx +28 -7
- 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 +18 -6
- 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 -119
- 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 React5 = __toESM(require("react"));
|
|
46
|
-
var import_editor_controls4 = require("@elementor/editor-controls");
|
|
47
|
-
var import_editor_props3 = 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,75 +331,56 @@ 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
|
+
};
|
|
320
342
|
|
|
321
|
-
// src/
|
|
322
|
-
var
|
|
323
|
-
var
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
// src/components/styled-menu-item.tsx
|
|
327
|
-
var import_ui2 = require("@elementor/ui");
|
|
328
|
-
var StyledMenuItem = (0, import_ui2.styled)(import_ui2.MenuItem)(() => ({
|
|
329
|
-
pl: 2,
|
|
330
|
-
pr: 1,
|
|
331
|
-
py: 0.5,
|
|
332
|
-
"&:hover .MuiSvgIcon-root": {
|
|
333
|
-
opacity: 1
|
|
334
|
-
}
|
|
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`
|
|
335
347
|
}));
|
|
336
348
|
|
|
337
|
-
// src/components/
|
|
338
|
-
var
|
|
339
|
-
const
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
};
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
/* @__PURE__ */ React.createElement(
|
|
354
|
-
import_ui3.ListItemText,
|
|
355
|
-
{
|
|
356
|
-
primary: label,
|
|
357
|
-
secondary: value,
|
|
358
|
-
primaryTypographyProps: {
|
|
359
|
-
variant: "body2",
|
|
360
|
-
color: "text.secondary",
|
|
361
|
-
style: {
|
|
362
|
-
lineHeight: 2,
|
|
363
|
-
display: "inline-block",
|
|
364
|
-
overflow: "hidden",
|
|
365
|
-
textOverflow: "ellipsis",
|
|
366
|
-
whiteSpace: "nowrap",
|
|
367
|
-
maxWidth: "81px"
|
|
368
|
-
}
|
|
369
|
-
},
|
|
370
|
-
secondaryTypographyProps: {
|
|
371
|
-
variant: "caption",
|
|
372
|
-
color: "text.tertiary",
|
|
373
|
-
style: { marginTop: "1px", lineHeight: "1" }
|
|
374
|
-
},
|
|
375
|
-
sx: { display: "flex", alignItems: "center", gap: 1 }
|
|
376
|
-
}
|
|
377
|
-
),
|
|
378
|
-
/* @__PURE__ */ React.createElement(import_icons.EditIcon, { color: "action", fontSize: "inherit", sx: { mx: 1, opacity: "0" } })
|
|
379
|
-
)))));
|
|
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 });
|
|
380
365
|
};
|
|
381
366
|
|
|
382
|
-
// src/
|
|
383
|
-
var
|
|
384
|
-
var
|
|
385
|
-
var
|
|
386
|
-
var
|
|
387
|
-
var
|
|
388
|
-
var
|
|
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");
|
|
379
|
+
|
|
380
|
+
// src/prop-types/color-variable-prop-type.ts
|
|
381
|
+
var import_editor_props = require("@elementor/editor-props");
|
|
382
|
+
var import_schema = require("@elementor/schema");
|
|
383
|
+
var colorVariablePropTypeUtil = (0, import_editor_props.createPropUtils)("global-color-variable", import_schema.z.string());
|
|
389
384
|
|
|
390
385
|
// src/prop-types/font-variable-prop-type.ts
|
|
391
386
|
var import_editor_props2 = require("@elementor/editor-props");
|
|
@@ -394,18 +389,18 @@ var fontVariablePropTypeUtil = (0, import_editor_props2.createPropUtils)("global
|
|
|
394
389
|
|
|
395
390
|
// src/components/color-variable-creation.tsx
|
|
396
391
|
var React2 = __toESM(require("react"));
|
|
397
|
-
var
|
|
398
|
-
var
|
|
392
|
+
var import_react2 = require("react");
|
|
393
|
+
var import_editor_controls = require("@elementor/editor-controls");
|
|
399
394
|
var import_editor_ui = require("@elementor/editor-ui");
|
|
400
|
-
var
|
|
401
|
-
var
|
|
395
|
+
var import_icons = require("@elementor/icons");
|
|
396
|
+
var import_ui2 = require("@elementor/ui");
|
|
402
397
|
var import_i18n = require("@wordpress/i18n");
|
|
403
398
|
var SIZE = "tiny";
|
|
404
|
-
var ColorVariableCreation = ({ onClose }) => {
|
|
405
|
-
const { setValue: setVariable } = (0,
|
|
406
|
-
const [color, setColor] = (0,
|
|
407
|
-
const [label, setLabel] = (0,
|
|
408
|
-
const anchorRef = (0,
|
|
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);
|
|
409
404
|
const resetFields = () => {
|
|
410
405
|
setColor("");
|
|
411
406
|
setLabel("");
|
|
@@ -430,20 +425,20 @@ var ColorVariableCreation = ({ onClose }) => {
|
|
|
430
425
|
return /* @__PURE__ */ React2.createElement(React2.Fragment, null, /* @__PURE__ */ React2.createElement(
|
|
431
426
|
import_editor_ui.PopoverHeader,
|
|
432
427
|
{
|
|
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 })),
|
|
433
429
|
title: (0, import_i18n.__)("Create variable", "elementor"),
|
|
434
|
-
onClose: closePopover
|
|
435
|
-
icon: /* @__PURE__ */ React2.createElement(import_icons2.BrushIcon, { fontSize: SIZE })
|
|
430
|
+
onClose: closePopover
|
|
436
431
|
}
|
|
437
|
-
), /* @__PURE__ */ React2.createElement(
|
|
438
|
-
|
|
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,
|
|
439
434
|
{
|
|
440
435
|
size: "tiny",
|
|
441
436
|
fullWidth: true,
|
|
442
437
|
value: label,
|
|
443
438
|
onChange: (e) => setLabel(e.target.value)
|
|
444
439
|
}
|
|
445
|
-
))), /* @__PURE__ */ React2.createElement(
|
|
446
|
-
|
|
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,
|
|
447
442
|
{
|
|
448
443
|
size: "tiny",
|
|
449
444
|
fullWidth: true,
|
|
@@ -457,26 +452,284 @@ var ColorVariableCreation = ({ onClose }) => {
|
|
|
457
452
|
}
|
|
458
453
|
}
|
|
459
454
|
}
|
|
460
|
-
)))), /* @__PURE__ */ React2.createElement(
|
|
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"))));
|
|
461
456
|
};
|
|
462
457
|
|
|
463
|
-
// src/components/
|
|
458
|
+
// src/components/color-variable-edit.tsx
|
|
464
459
|
var React3 = __toESM(require("react"));
|
|
465
|
-
var
|
|
466
|
-
var import_editor_controls3 = require("@elementor/editor-controls");
|
|
467
|
-
var import_editor_editing_panel = require("@elementor/editor-editing-panel");
|
|
460
|
+
var import_react3 = require("react");
|
|
468
461
|
var import_editor_ui2 = require("@elementor/editor-ui");
|
|
469
|
-
var
|
|
470
|
-
var
|
|
462
|
+
var import_icons2 = require("@elementor/icons");
|
|
463
|
+
var import_ui3 = require("@elementor/ui");
|
|
471
464
|
var import_i18n2 = require("@wordpress/i18n");
|
|
472
465
|
var SIZE2 = "tiny";
|
|
473
|
-
var
|
|
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
|
+
};
|
|
517
|
+
|
|
518
|
+
// src/components/color-variables-selection.tsx
|
|
519
|
+
var React7 = __toESM(require("react"));
|
|
520
|
+
var import_react4 = require("react");
|
|
521
|
+
var import_editor_controls2 = require("@elementor/editor-controls");
|
|
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");
|
|
530
|
+
var import_ui4 = require("@elementor/ui");
|
|
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 }) => {
|
|
474
727
|
const fontFamilies = (0, import_editor_editing_panel.useFontFamilies)();
|
|
475
728
|
const { setValue: setVariable } = (0, import_editor_controls3.useBoundProp)(fontVariablePropTypeUtil);
|
|
476
|
-
const [fontFamily, setFontFamily] = (0,
|
|
477
|
-
const [label, setLabel] = (0,
|
|
478
|
-
const anchorRef = (0,
|
|
479
|
-
const fontPopoverState = (0,
|
|
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" });
|
|
480
733
|
const resetFields = () => {
|
|
481
734
|
setFontFamily("");
|
|
482
735
|
setLabel("");
|
|
@@ -498,41 +751,41 @@ var FontVariableCreation = ({ onClose }) => {
|
|
|
498
751
|
const isFormInvalid = () => {
|
|
499
752
|
return !fontFamily?.trim() || !label?.trim();
|
|
500
753
|
};
|
|
501
|
-
return /* @__PURE__ */
|
|
502
|
-
|
|
754
|
+
return /* @__PURE__ */ React8.createElement(React8.Fragment, null, /* @__PURE__ */ React8.createElement(
|
|
755
|
+
import_editor_ui4.PopoverHeader,
|
|
503
756
|
{
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
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
|
|
507
760
|
}
|
|
508
|
-
), /* @__PURE__ */
|
|
509
|
-
|
|
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,
|
|
510
763
|
{
|
|
511
764
|
size: "tiny",
|
|
512
765
|
fullWidth: true,
|
|
513
766
|
value: label,
|
|
514
767
|
onChange: (e) => setLabel(e.target.value)
|
|
515
768
|
}
|
|
516
|
-
))), /* @__PURE__ */
|
|
517
|
-
|
|
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,
|
|
518
771
|
{
|
|
519
772
|
variant: "outlined",
|
|
520
773
|
label: fontFamily,
|
|
521
|
-
endIcon: /* @__PURE__ */
|
|
522
|
-
...(0,
|
|
774
|
+
endIcon: /* @__PURE__ */ React8.createElement(import_icons6.ChevronDownIcon, { fontSize: "tiny" }),
|
|
775
|
+
...(0, import_ui9.bindTrigger)(fontPopoverState),
|
|
523
776
|
fullWidth: true
|
|
524
777
|
}
|
|
525
|
-
), /* @__PURE__ */
|
|
526
|
-
|
|
778
|
+
), /* @__PURE__ */ React8.createElement(
|
|
779
|
+
import_ui9.Popover,
|
|
527
780
|
{
|
|
528
781
|
disablePortal: true,
|
|
529
782
|
disableScrollLock: true,
|
|
530
783
|
anchorEl: anchorRef.current,
|
|
531
784
|
anchorOrigin: { vertical: "top", horizontal: "right" },
|
|
532
785
|
transformOrigin: { vertical: "top", horizontal: -20 },
|
|
533
|
-
...(0,
|
|
786
|
+
...(0, import_ui9.bindPopover)(fontPopoverState)
|
|
534
787
|
},
|
|
535
|
-
/* @__PURE__ */
|
|
788
|
+
/* @__PURE__ */ React8.createElement(
|
|
536
789
|
import_editor_controls3.FontFamilySelector,
|
|
537
790
|
{
|
|
538
791
|
fontFamilies,
|
|
@@ -541,109 +794,327 @@ var FontVariableCreation = ({ onClose }) => {
|
|
|
541
794
|
onClose: fontPopoverState.close
|
|
542
795
|
}
|
|
543
796
|
)
|
|
544
|
-
))))), /* @__PURE__ */
|
|
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"))));
|
|
545
798
|
};
|
|
546
799
|
|
|
547
|
-
// src/components/
|
|
548
|
-
var
|
|
549
|
-
var
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
const
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
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
|
+
});
|
|
562
829
|
};
|
|
563
|
-
const
|
|
564
|
-
const
|
|
565
|
-
const
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
import_ui6.UnstableTag,
|
|
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,
|
|
569
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",
|
|
570
845
|
fullWidth: true,
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
846
|
+
value: label,
|
|
847
|
+
onChange: (e) => setLabel(e.target.value)
|
|
848
|
+
}
|
|
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,
|
|
851
|
+
{
|
|
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
|
|
576
858
|
}
|
|
577
|
-
), /* @__PURE__ */
|
|
578
|
-
|
|
859
|
+
), /* @__PURE__ */ React9.createElement(
|
|
860
|
+
import_ui10.Popover,
|
|
579
861
|
{
|
|
580
|
-
|
|
862
|
+
disablePortal: true,
|
|
581
863
|
disableScrollLock: true,
|
|
582
864
|
anchorEl: anchorRef.current,
|
|
583
|
-
anchorOrigin: { vertical: "
|
|
584
|
-
transformOrigin: { vertical: "top", horizontal:
|
|
865
|
+
anchorOrigin: { vertical: "top", horizontal: "right" },
|
|
866
|
+
transformOrigin: { vertical: "top", horizontal: -20 },
|
|
867
|
+
...(0, import_ui10.bindPopover)(fontPopoverState)
|
|
585
868
|
},
|
|
586
|
-
/* @__PURE__ */
|
|
587
|
-
|
|
869
|
+
/* @__PURE__ */ React9.createElement(
|
|
870
|
+
import_editor_controls4.FontFamilySelector,
|
|
588
871
|
{
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
/* @__PURE__ */ React4.createElement(
|
|
594
|
-
import_ui6.IconButton,
|
|
595
|
-
{
|
|
596
|
-
key: "createVariable",
|
|
597
|
-
...(0, import_ui6.bindTrigger)(creationPopupState),
|
|
598
|
-
size: SIZE3,
|
|
599
|
-
onClick: handleCreateButtonClick
|
|
600
|
-
},
|
|
601
|
-
/* @__PURE__ */ React4.createElement(import_icons4.PlusIcon, { fontSize: SIZE3 })
|
|
602
|
-
)
|
|
603
|
-
]
|
|
872
|
+
fontFamilies,
|
|
873
|
+
fontFamily,
|
|
874
|
+
onFontFamilyChange: setFontFamily,
|
|
875
|
+
onClose: fontPopoverState.close
|
|
604
876
|
}
|
|
605
|
-
)
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
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,
|
|
609
929
|
{
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
}
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
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 }));
|
|
618
955
|
};
|
|
619
956
|
|
|
620
|
-
// src/
|
|
621
|
-
var
|
|
622
|
-
|
|
623
|
-
|
|
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
|
+
});
|
|
624
1069
|
const selectedVariable = useVariable(variableValue);
|
|
625
1070
|
if (!selectedVariable) {
|
|
626
1071
|
throw new Error(`Global color variable ${variableValue} not found`);
|
|
627
1072
|
}
|
|
628
1073
|
const unlinkVariable = () => {
|
|
629
|
-
|
|
1074
|
+
setColor(import_editor_props3.colorPropTypeUtil.create(selectedVariable.value));
|
|
630
1075
|
};
|
|
631
|
-
return /* @__PURE__ */
|
|
632
|
-
|
|
1076
|
+
return /* @__PURE__ */ React12.createElement(import_ui12.Box, { ref: anchorRef }, /* @__PURE__ */ React12.createElement(
|
|
1077
|
+
import_ui12.UnstableTag,
|
|
1078
|
+
{
|
|
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,
|
|
633
1095
|
{
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
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)
|
|
637
1101
|
},
|
|
638
|
-
|
|
639
|
-
|
|
1102
|
+
/* @__PURE__ */ React12.createElement(
|
|
1103
|
+
VariableSelectionPopover,
|
|
1104
|
+
{
|
|
1105
|
+
selectedVariable,
|
|
1106
|
+
closePopover: popupState.close,
|
|
1107
|
+
propTypeKey: colorVariablePropTypeUtil.key
|
|
1108
|
+
}
|
|
1109
|
+
)
|
|
1110
|
+
));
|
|
640
1111
|
};
|
|
641
1112
|
|
|
642
1113
|
// src/hooks/use-prop-color-variable-action.tsx
|
|
643
|
-
var
|
|
644
|
-
var
|
|
645
|
-
var
|
|
646
|
-
var
|
|
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");
|
|
647
1118
|
|
|
648
1119
|
// src/utils.ts
|
|
649
1120
|
var hasAssignedColorVariable = (propValue) => {
|
|
@@ -661,13 +1132,15 @@ var supportsFontVariables = (propType) => {
|
|
|
661
1132
|
|
|
662
1133
|
// src/hooks/use-prop-color-variable-action.tsx
|
|
663
1134
|
var usePropColorVariableAction = () => {
|
|
664
|
-
const { propType } = (0,
|
|
1135
|
+
const { propType } = (0, import_editor_editing_panel3.useBoundProp)();
|
|
665
1136
|
const visible = !!propType && supportsColorVariables(propType);
|
|
666
1137
|
return {
|
|
667
1138
|
visible,
|
|
668
|
-
icon:
|
|
669
|
-
title: (0,
|
|
670
|
-
|
|
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
|
+
}
|
|
671
1144
|
};
|
|
672
1145
|
};
|
|
673
1146
|
|
|
@@ -681,113 +1154,143 @@ var variableTransformer = (0, import_editor_canvas.createTransformer)((value) =>
|
|
|
681
1154
|
});
|
|
682
1155
|
|
|
683
1156
|
// src/init-color-variables.ts
|
|
684
|
-
var { registerPopoverAction } =
|
|
685
|
-
|
|
686
|
-
(
|
|
687
|
-
|
|
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,
|
|
688
1169
|
condition: ({ value }) => hasAssignedColorVariable(value)
|
|
689
1170
|
});
|
|
690
1171
|
registerPopoverAction({
|
|
691
1172
|
id: "color-variables",
|
|
692
1173
|
useProps: usePropColorVariableAction
|
|
693
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() {
|
|
694
1196
|
import_editor_canvas2.styleTransformersRegistry.register(colorVariablePropTypeUtil.key, variableTransformer);
|
|
695
1197
|
}
|
|
1198
|
+
function initColorVariables() {
|
|
1199
|
+
registerControlsAndActions();
|
|
1200
|
+
registerRepeaterItemIcons();
|
|
1201
|
+
registerRepeaterItemLabels();
|
|
1202
|
+
registerStyleTransformers();
|
|
1203
|
+
}
|
|
696
1204
|
|
|
697
1205
|
// src/init-font-variables.ts
|
|
698
1206
|
var import_editor_canvas3 = require("@elementor/editor-canvas");
|
|
699
|
-
var
|
|
700
|
-
|
|
701
|
-
// src/controls/font-variables-selection-control.tsx
|
|
702
|
-
var React8 = __toESM(require("react"));
|
|
703
|
-
var import_editor_controls6 = require("@elementor/editor-controls");
|
|
704
|
-
var import_editor_props4 = require("@elementor/editor-props");
|
|
705
|
-
|
|
706
|
-
// src/components/font-variables-selection.tsx
|
|
707
|
-
var React7 = __toESM(require("react"));
|
|
708
|
-
var import_react6 = require("react");
|
|
709
|
-
var import_editor_controls5 = require("@elementor/editor-controls");
|
|
710
|
-
var import_icons6 = require("@elementor/icons");
|
|
711
|
-
var import_ui7 = require("@elementor/ui");
|
|
712
|
-
var FontVariablesSelection = ({ onSelect }) => {
|
|
713
|
-
const { value: variable, setValue: setVariable } = (0, import_editor_controls5.useBoundProp)(fontVariablePropTypeUtil);
|
|
714
|
-
const variables = usePropVariables(fontVariablePropTypeUtil.key);
|
|
715
|
-
const handleSetVariable = (key) => {
|
|
716
|
-
setVariable(key);
|
|
717
|
-
onSelect?.();
|
|
718
|
-
};
|
|
719
|
-
return /* @__PURE__ */ React7.createElement(import_react6.Fragment, null, /* @__PURE__ */ React7.createElement(import_ui7.Divider, null), /* @__PURE__ */ React7.createElement(import_ui7.Box, { sx: { overflowY: "auto", height: 260, width: 220 } }, /* @__PURE__ */ React7.createElement(import_ui7.MenuList, { role: "listbox", tabIndex: 0 }, variables.map(({ value, label, key }) => /* @__PURE__ */ React7.createElement(
|
|
720
|
-
StyledMenuItem,
|
|
721
|
-
{
|
|
722
|
-
key,
|
|
723
|
-
onClick: () => handleSetVariable(key),
|
|
724
|
-
selected: key === variable
|
|
725
|
-
},
|
|
726
|
-
/* @__PURE__ */ React7.createElement(import_ui7.ListItemIcon, null, /* @__PURE__ */ React7.createElement(import_icons6.TextIcon, null)),
|
|
727
|
-
/* @__PURE__ */ React7.createElement(
|
|
728
|
-
import_ui7.ListItemText,
|
|
729
|
-
{
|
|
730
|
-
primary: label,
|
|
731
|
-
secondary: value,
|
|
732
|
-
primaryTypographyProps: {
|
|
733
|
-
variant: "body2",
|
|
734
|
-
color: "text.secondary",
|
|
735
|
-
style: {
|
|
736
|
-
lineHeight: 2,
|
|
737
|
-
display: "inline-block",
|
|
738
|
-
overflow: "hidden",
|
|
739
|
-
textOverflow: "ellipsis",
|
|
740
|
-
whiteSpace: "nowrap",
|
|
741
|
-
maxWidth: "81px"
|
|
742
|
-
}
|
|
743
|
-
},
|
|
744
|
-
secondaryTypographyProps: {
|
|
745
|
-
variant: "caption",
|
|
746
|
-
color: "text.tertiary",
|
|
747
|
-
style: { marginTop: "1px", lineHeight: "1" }
|
|
748
|
-
},
|
|
749
|
-
sx: { display: "flex", alignItems: "center", gap: 1 }
|
|
750
|
-
}
|
|
751
|
-
),
|
|
752
|
-
/* @__PURE__ */ React7.createElement(import_icons6.EditIcon, { color: "action", fontSize: "inherit", sx: { mx: 1, opacity: "0" } })
|
|
753
|
-
)))));
|
|
754
|
-
};
|
|
1207
|
+
var import_editor_editing_panel6 = require("@elementor/editor-editing-panel");
|
|
755
1208
|
|
|
756
|
-
// src/controls/font-
|
|
757
|
-
var
|
|
758
|
-
|
|
759
|
-
|
|
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
|
+
});
|
|
760
1227
|
const selectedVariable = useVariable(variableValue);
|
|
761
1228
|
if (!selectedVariable) {
|
|
762
1229
|
throw new Error(`Global font variable ${variableValue} not found`);
|
|
763
1230
|
}
|
|
764
1231
|
const unlinkVariable = () => {
|
|
765
|
-
setFontFamily(
|
|
1232
|
+
setFontFamily(import_editor_props5.stringPropTypeUtil.create(selectedVariable.value));
|
|
766
1233
|
};
|
|
767
|
-
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
|
+
));
|
|
768
1269
|
};
|
|
769
1270
|
|
|
770
1271
|
// src/hooks/use-prop-font-variable-action.tsx
|
|
771
|
-
var
|
|
772
|
-
var
|
|
773
|
-
var
|
|
774
|
-
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");
|
|
775
1276
|
var usePropFontVariableAction = () => {
|
|
776
|
-
const { propType } = (0,
|
|
1277
|
+
const { propType } = (0, import_editor_editing_panel5.useBoundProp)();
|
|
777
1278
|
const visible = !!propType && supportsFontVariables(propType);
|
|
778
1279
|
return {
|
|
779
1280
|
visible,
|
|
780
|
-
icon:
|
|
781
|
-
title: (0,
|
|
782
|
-
|
|
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
|
+
}
|
|
783
1286
|
};
|
|
784
1287
|
};
|
|
785
1288
|
|
|
786
1289
|
// src/init-font-variables.ts
|
|
787
|
-
var { registerPopoverAction: registerPopoverAction2 } =
|
|
1290
|
+
var { registerPopoverAction: registerPopoverAction2 } = import_editor_editing_panel6.controlActionsMenu;
|
|
788
1291
|
function initFontVariables() {
|
|
789
|
-
(0,
|
|
790
|
-
component:
|
|
1292
|
+
(0, import_editor_editing_panel6.registerControlReplacement)({
|
|
1293
|
+
component: FontVariableControl,
|
|
791
1294
|
condition: ({ value }) => hasAssignedFontVariable(value)
|
|
792
1295
|
});
|
|
793
1296
|
registerPopoverAction2({
|
|
@@ -798,10 +1301,10 @@ function initFontVariables() {
|
|
|
798
1301
|
}
|
|
799
1302
|
|
|
800
1303
|
// src/renderers/style-variables-renderer.tsx
|
|
801
|
-
var
|
|
802
|
-
var
|
|
1304
|
+
var React16 = __toESM(require("react"));
|
|
1305
|
+
var import_react11 = require("react");
|
|
803
1306
|
var import_editor_v1_adapters = require("@elementor/editor-v1-adapters");
|
|
804
|
-
var
|
|
1307
|
+
var import_ui14 = require("@elementor/ui");
|
|
805
1308
|
|
|
806
1309
|
// src/sync/get-canvas-iframe-document.ts
|
|
807
1310
|
function getCanvasIframeDocument() {
|
|
@@ -820,14 +1323,14 @@ function StyleVariablesRenderer() {
|
|
|
820
1323
|
}
|
|
821
1324
|
const cssVariables = convertToCssVariables(styleVariables);
|
|
822
1325
|
const wrappedCss = `${VARIABLES_WRAPPER}{${cssVariables}}`;
|
|
823
|
-
return /* @__PURE__ */
|
|
1326
|
+
return /* @__PURE__ */ React16.createElement(import_ui14.Portal, { container }, /* @__PURE__ */ React16.createElement("style", { "data-e-style-id": "e-variables", key: wrappedCss }, wrappedCss));
|
|
824
1327
|
}
|
|
825
1328
|
function usePortalContainer() {
|
|
826
1329
|
return (0, import_editor_v1_adapters.__privateUseListenTo)((0, import_editor_v1_adapters.commandEndEvent)("editor/documents/attach-preview"), () => getCanvasIframeDocument()?.head);
|
|
827
1330
|
}
|
|
828
1331
|
function useStyleVariables() {
|
|
829
|
-
const [variables, setVariables] = (0,
|
|
830
|
-
(0,
|
|
1332
|
+
const [variables, setVariables] = (0, import_react11.useState)({});
|
|
1333
|
+
(0, import_react11.useEffect)(() => {
|
|
831
1334
|
const unsubscribe = styleVariablesRepository.subscribe(setVariables);
|
|
832
1335
|
return () => {
|
|
833
1336
|
unsubscribe();
|