@elementor/editor-variables 0.8.0 → 0.9.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 +16 -0
- package/dist/index.js +122 -26
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +122 -26
- package/dist/index.mjs.map +1 -1
- package/package.json +6 -4
- package/src/components/color-variable-creation.tsx +6 -1
- package/src/components/color-variables-selection.tsx +4 -4
- package/src/components/font-variables-selection.tsx +4 -4
- package/src/controls/color-variables-selection-control.tsx +1 -1
- package/src/controls/font-variables-selection-control.tsx +1 -1
- package/src/create-style-variables-repository.ts +50 -0
- package/src/hooks/use-prop-variables.ts +25 -31
- package/src/init.ts +8 -0
- package/src/renderers/style-variables-renderer.tsx +56 -0
- package/src/style-variables-repository.ts +3 -0
- package/src/sync/get-canvas-iframe-document.ts +7 -0
- package/src/sync/types.ts +5 -0
- package/src/types.ts +12 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,21 @@
|
|
|
1
1
|
# @elementor/editor-variables
|
|
2
2
|
|
|
3
|
+
## 0.9.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 2ea62e2: Reactive rendering variables style on canvas
|
|
8
|
+
|
|
9
|
+
### Patch Changes
|
|
10
|
+
|
|
11
|
+
- Updated dependencies [cd4c3fe]
|
|
12
|
+
- Updated dependencies [b7369f2]
|
|
13
|
+
- Updated dependencies [8f3a61b]
|
|
14
|
+
- Updated dependencies [e732d81]
|
|
15
|
+
- Updated dependencies [8dca168]
|
|
16
|
+
- @elementor/editor-editing-panel@1.42.0
|
|
17
|
+
- @elementor/editor-controls@0.34.1
|
|
18
|
+
|
|
3
19
|
## 0.8.0
|
|
4
20
|
|
|
5
21
|
### Minor Changes
|
package/dist/index.js
CHANGED
|
@@ -34,6 +34,9 @@ __export(index_exports, {
|
|
|
34
34
|
});
|
|
35
35
|
module.exports = __toCommonJS(index_exports);
|
|
36
36
|
|
|
37
|
+
// src/init.ts
|
|
38
|
+
var import_editor = require("@elementor/editor");
|
|
39
|
+
|
|
37
40
|
// src/init-color-variables.ts
|
|
38
41
|
var import_editor_canvas2 = require("@elementor/editor-canvas");
|
|
39
42
|
var import_editor_editing_panel2 = require("@elementor/editor-editing-panel");
|
|
@@ -58,39 +61,82 @@ var import_ui3 = require("@elementor/ui");
|
|
|
58
61
|
|
|
59
62
|
// src/hooks/use-prop-variables.ts
|
|
60
63
|
var import_react = require("react");
|
|
61
|
-
|
|
62
|
-
|
|
64
|
+
|
|
65
|
+
// src/create-style-variables-repository.ts
|
|
66
|
+
var createStyleVariablesRepository = () => {
|
|
67
|
+
const variables2 = {};
|
|
68
|
+
let subscription;
|
|
69
|
+
const subscribe = (cb) => {
|
|
70
|
+
subscription = cb;
|
|
71
|
+
return () => {
|
|
72
|
+
subscription = () => {
|
|
73
|
+
};
|
|
74
|
+
};
|
|
75
|
+
};
|
|
76
|
+
const notify = () => {
|
|
77
|
+
if (typeof subscription === "function") {
|
|
78
|
+
subscription({ ...variables2 });
|
|
79
|
+
}
|
|
80
|
+
};
|
|
81
|
+
const shouldUpdate = (key, newValue) => {
|
|
82
|
+
return !(key in variables2) || variables2[key] !== newValue;
|
|
83
|
+
};
|
|
84
|
+
const applyUpdates = (updatedVars) => {
|
|
85
|
+
let hasChanges = false;
|
|
86
|
+
for (const [key, { value }] of Object.entries(updatedVars)) {
|
|
87
|
+
if (shouldUpdate(key, value)) {
|
|
88
|
+
variables2[key] = value;
|
|
89
|
+
hasChanges = true;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
return hasChanges;
|
|
93
|
+
};
|
|
94
|
+
const update = (updatedVars) => {
|
|
95
|
+
if (applyUpdates(updatedVars)) {
|
|
96
|
+
notify();
|
|
97
|
+
}
|
|
98
|
+
};
|
|
99
|
+
return {
|
|
100
|
+
subscribe,
|
|
101
|
+
update
|
|
102
|
+
};
|
|
63
103
|
};
|
|
64
|
-
|
|
65
|
-
|
|
104
|
+
|
|
105
|
+
// src/style-variables-repository.ts
|
|
106
|
+
var styleVariablesRepository = createStyleVariablesRepository();
|
|
107
|
+
|
|
108
|
+
// src/hooks/use-prop-variables.ts
|
|
109
|
+
var usePropVariables = (propKey) => {
|
|
110
|
+
return (0, import_react.useMemo)(() => normalizeVariables(propKey), [propKey]);
|
|
111
|
+
};
|
|
112
|
+
var useVariable = (key) => {
|
|
113
|
+
if (!variables?.[key]) {
|
|
66
114
|
return null;
|
|
67
115
|
}
|
|
68
116
|
return {
|
|
69
|
-
...variables[
|
|
117
|
+
...variables[key],
|
|
70
118
|
key
|
|
71
119
|
};
|
|
72
120
|
};
|
|
73
|
-
var normalizeVariables = (
|
|
74
|
-
return Object.entries(variables[
|
|
121
|
+
var normalizeVariables = (propKey) => {
|
|
122
|
+
return Object.entries(variables).filter(([, { type }]) => type === propKey).map(([key, { label, value }]) => ({
|
|
75
123
|
key,
|
|
76
124
|
label,
|
|
77
125
|
value
|
|
78
126
|
}));
|
|
79
127
|
};
|
|
80
|
-
var createVariable = (
|
|
81
|
-
const id = generateId(
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
};
|
|
87
|
-
variables[propTypeKey][id] = newVariable || {};
|
|
128
|
+
var createVariable = (variable) => {
|
|
129
|
+
const id = generateId();
|
|
130
|
+
variables[id] = variable;
|
|
131
|
+
styleVariablesRepository.update({
|
|
132
|
+
[id]: variable
|
|
133
|
+
});
|
|
88
134
|
return id;
|
|
89
135
|
};
|
|
90
136
|
var variables = window?.ElementorV4Variables || {};
|
|
91
|
-
var generateId = (prefix
|
|
137
|
+
var generateId = (prefix = "e-gv") => {
|
|
92
138
|
const randomHex = Math.random().toString(16).slice(2, 9);
|
|
93
|
-
return `${prefix}${randomHex}
|
|
139
|
+
return `${prefix}${randomHex}`;
|
|
94
140
|
};
|
|
95
141
|
|
|
96
142
|
// src/prop-types/color-variable-prop-type.ts
|
|
@@ -113,15 +159,15 @@ var StyledMenuItem = (0, import_ui2.styled)(import_ui2.MenuItem)(() => ({
|
|
|
113
159
|
var ColorVariablesSelection = ({ onSelect }) => {
|
|
114
160
|
const { value: variable, setValue: setVariable } = (0, import_editor_controls.useBoundProp)(colorVariablePropTypeUtil);
|
|
115
161
|
const variables2 = usePropVariables(colorVariablePropTypeUtil.key);
|
|
116
|
-
const handleSetColorVariable = (
|
|
117
|
-
setVariable(
|
|
162
|
+
const handleSetColorVariable = (key) => {
|
|
163
|
+
setVariable(key);
|
|
118
164
|
onSelect?.();
|
|
119
165
|
};
|
|
120
166
|
return /* @__PURE__ */ React.createElement(import_react2.Fragment, null, /* @__PURE__ */ React.createElement(import_ui3.Divider, null), /* @__PURE__ */ React.createElement(import_ui3.Box, { sx: { overflowY: "auto", height: 260, width: 220 } }, /* @__PURE__ */ React.createElement(import_ui3.MenuList, { role: "listbox", tabIndex: 0 }, variables2.map(({ value, label, key }) => /* @__PURE__ */ React.createElement(
|
|
121
167
|
StyledMenuItem,
|
|
122
168
|
{
|
|
123
169
|
key,
|
|
124
|
-
onClick: () => handleSetColorVariable(
|
|
170
|
+
onClick: () => handleSetColorVariable(key),
|
|
125
171
|
selected: key === variable
|
|
126
172
|
},
|
|
127
173
|
/* @__PURE__ */ React.createElement(import_ui3.ListItemIcon, null, /* @__PURE__ */ React.createElement(ColorIndicator, { size: "inherit", component: "span", value })),
|
|
@@ -182,7 +228,11 @@ var ColorVariableCreation = ({ popupState }) => {
|
|
|
182
228
|
popupState.close();
|
|
183
229
|
};
|
|
184
230
|
const handleCreate = () => {
|
|
185
|
-
const key = createVariable(
|
|
231
|
+
const key = createVariable({
|
|
232
|
+
value: color,
|
|
233
|
+
label,
|
|
234
|
+
type: colorVariablePropTypeUtil.key
|
|
235
|
+
});
|
|
186
236
|
setVariable(key);
|
|
187
237
|
closePopover();
|
|
188
238
|
};
|
|
@@ -287,7 +337,7 @@ var VariablesSelectionPopover = ({
|
|
|
287
337
|
var ColorVariablesSelectionControl = () => {
|
|
288
338
|
const { setValue } = (0, import_editor_controls3.useBoundProp)();
|
|
289
339
|
const { value: variableValue } = (0, import_editor_controls3.useBoundProp)(colorVariablePropTypeUtil);
|
|
290
|
-
const selectedVariable = useVariable(
|
|
340
|
+
const selectedVariable = useVariable(variableValue);
|
|
291
341
|
if (!selectedVariable) {
|
|
292
342
|
throw new Error(`Global color variable ${variableValue} not found`);
|
|
293
343
|
}
|
|
@@ -383,15 +433,15 @@ var import_ui6 = require("@elementor/ui");
|
|
|
383
433
|
var FontVariablesSelection = ({ onSelect }) => {
|
|
384
434
|
const { value: variable, setValue: setVariable } = (0, import_editor_controls4.useBoundProp)(fontVariablePropTypeUtil);
|
|
385
435
|
const variables2 = usePropVariables(fontVariablePropTypeUtil.key);
|
|
386
|
-
const handleSetVariable = (
|
|
387
|
-
setVariable(
|
|
436
|
+
const handleSetVariable = (key) => {
|
|
437
|
+
setVariable(key);
|
|
388
438
|
onSelect?.();
|
|
389
439
|
};
|
|
390
440
|
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 }, variables2.map(({ value, label, key }) => /* @__PURE__ */ React6.createElement(
|
|
391
441
|
StyledMenuItem,
|
|
392
442
|
{
|
|
393
443
|
key,
|
|
394
|
-
onClick: () => handleSetVariable(
|
|
444
|
+
onClick: () => handleSetVariable(key),
|
|
395
445
|
selected: key === variable
|
|
396
446
|
},
|
|
397
447
|
/* @__PURE__ */ React6.createElement(import_ui6.ListItemIcon, null, /* @__PURE__ */ React6.createElement(import_icons5.TextIcon, null)),
|
|
@@ -428,7 +478,7 @@ var FontVariablesSelection = ({ onSelect }) => {
|
|
|
428
478
|
var FontVariablesSelectionControl = () => {
|
|
429
479
|
const { setValue: setFontFamily } = (0, import_editor_controls5.useBoundProp)();
|
|
430
480
|
const { value: variableValue } = (0, import_editor_controls5.useBoundProp)(fontVariablePropTypeUtil);
|
|
431
|
-
const selectedVariable = useVariable(
|
|
481
|
+
const selectedVariable = useVariable(variableValue);
|
|
432
482
|
if (!selectedVariable) {
|
|
433
483
|
throw new Error(`Global font variable ${variableValue} not found`);
|
|
434
484
|
}
|
|
@@ -468,10 +518,56 @@ function initFontVariables() {
|
|
|
468
518
|
import_editor_canvas3.styleTransformersRegistry.register(fontVariablePropTypeUtil.key, variableTransformer);
|
|
469
519
|
}
|
|
470
520
|
|
|
521
|
+
// src/renderers/style-variables-renderer.tsx
|
|
522
|
+
var React9 = __toESM(require("react"));
|
|
523
|
+
var import_react6 = require("react");
|
|
524
|
+
var import_editor_v1_adapters = require("@elementor/editor-v1-adapters");
|
|
525
|
+
var import_ui7 = require("@elementor/ui");
|
|
526
|
+
|
|
527
|
+
// src/sync/get-canvas-iframe-document.ts
|
|
528
|
+
function getCanvasIframeDocument() {
|
|
529
|
+
const extendedWindow = window;
|
|
530
|
+
return extendedWindow.elementor?.$preview?.[0]?.contentDocument;
|
|
531
|
+
}
|
|
532
|
+
|
|
533
|
+
// src/renderers/style-variables-renderer.tsx
|
|
534
|
+
var VARIABLES_WRAPPER = "body";
|
|
535
|
+
function StyleVariablesRenderer() {
|
|
536
|
+
const container = usePortalContainer();
|
|
537
|
+
const styleVariables = useStyleVariables();
|
|
538
|
+
const hasVariables = Object.keys(styleVariables).length > 0;
|
|
539
|
+
if (!container || !hasVariables) {
|
|
540
|
+
return null;
|
|
541
|
+
}
|
|
542
|
+
const cssVariables = convertToCssVariables(styleVariables);
|
|
543
|
+
const wrappedCss = `${VARIABLES_WRAPPER}{${cssVariables}}`;
|
|
544
|
+
return /* @__PURE__ */ React9.createElement(import_ui7.Portal, { container }, /* @__PURE__ */ React9.createElement("style", { "data-e-style-id": "e-variables", key: wrappedCss }, wrappedCss));
|
|
545
|
+
}
|
|
546
|
+
function usePortalContainer() {
|
|
547
|
+
return (0, import_editor_v1_adapters.__privateUseListenTo)((0, import_editor_v1_adapters.commandEndEvent)("editor/documents/attach-preview"), () => getCanvasIframeDocument()?.head);
|
|
548
|
+
}
|
|
549
|
+
function useStyleVariables() {
|
|
550
|
+
const [variables2, setVariables] = (0, import_react6.useState)({});
|
|
551
|
+
(0, import_react6.useEffect)(() => {
|
|
552
|
+
const unsubscribe = styleVariablesRepository.subscribe(setVariables);
|
|
553
|
+
return () => {
|
|
554
|
+
unsubscribe();
|
|
555
|
+
};
|
|
556
|
+
}, []);
|
|
557
|
+
return variables2;
|
|
558
|
+
}
|
|
559
|
+
function convertToCssVariables(variables2) {
|
|
560
|
+
return Object.entries(variables2).map(([key, value]) => `--${key}:${value};`).join("");
|
|
561
|
+
}
|
|
562
|
+
|
|
471
563
|
// src/init.ts
|
|
472
564
|
function init() {
|
|
473
565
|
initColorVariables();
|
|
474
566
|
initFontVariables();
|
|
567
|
+
(0, import_editor.injectIntoTop)({
|
|
568
|
+
id: "canvas-style-variables-render",
|
|
569
|
+
component: StyleVariablesRenderer
|
|
570
|
+
});
|
|
475
571
|
}
|
|
476
572
|
// Annotate the CommonJS export names for ESM import in node:
|
|
477
573
|
0 && (module.exports = {
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts","../src/init-color-variables.ts","../src/controls/color-variables-selection-control.tsx","../src/components/color-indicator.tsx","../src/components/color-variables-selection.tsx","../src/hooks/use-prop-variables.ts","../src/prop-types/color-variable-prop-type.ts","../src/components/styled-menu-item.tsx","../src/components/variables-selection-popover.tsx","../src/components/color-variable-creation.tsx","../src/hooks/use-prop-color-variable-action.tsx","../src/prop-types/font-variable-prop-type.ts","../src/utils.ts","../src/transformers/variable-transformer.ts","../src/init-font-variables.ts","../src/controls/font-variables-selection-control.tsx","../src/components/font-variables-selection.tsx","../src/hooks/use-prop-font-variable-action.tsx","../src/init.ts"],"sourcesContent":["export { init } from './init';\n","import { styleTransformersRegistry } from '@elementor/editor-canvas';\nimport { controlActionsMenu, registerControlReplacement } from '@elementor/editor-editing-panel';\n\nimport { ColorVariablesSelectionControl } from './controls/color-variables-selection-control';\nimport { usePropColorVariableAction } from './hooks/use-prop-color-variable-action';\nimport { colorVariablePropTypeUtil } from './prop-types/color-variable-prop-type';\nimport { variableTransformer } from './transformers/variable-transformer';\nimport { hasAssignedColorVariable } from './utils';\n\nconst { registerPopoverAction } = controlActionsMenu;\n\nexport function initColorVariables() {\n\tregisterControlReplacement( {\n\t\tcomponent: ColorVariablesSelectionControl,\n\t\tcondition: ( { value } ) => hasAssignedColorVariable( value ),\n\t} );\n\n\tregisterPopoverAction( {\n\t\tid: 'color-variables',\n\t\tuseProps: usePropColorVariableAction,\n\t} );\n\n\tstyleTransformersRegistry.register( colorVariablePropTypeUtil.key, variableTransformer );\n}\n","import * as React from 'react';\nimport { useBoundProp } from '@elementor/editor-controls';\nimport { colorPropTypeUtil } from '@elementor/editor-props';\n\nimport { ColorIndicator } from '../components/color-indicator';\nimport { ColorVariablesSelection } from '../components/color-variables-selection';\nimport { VariablesSelectionPopover } from '../components/variables-selection-popover';\nimport { useVariable } from '../hooks/use-prop-variables';\nimport { colorVariablePropTypeUtil } from '../prop-types/color-variable-prop-type';\n\nexport const ColorVariablesSelectionControl = () => {\n\tconst { setValue } = useBoundProp();\n\tconst { value: variableValue } = useBoundProp( colorVariablePropTypeUtil );\n\n\tconst selectedVariable = useVariable( colorVariablePropTypeUtil.key, variableValue );\n\n\tif ( ! selectedVariable ) {\n\t\tthrow new Error( `Global color variable ${ variableValue } not found` );\n\t}\n\n\tconst unlinkVariable = () => {\n\t\tsetValue( colorPropTypeUtil.create( selectedVariable.value ) );\n\t};\n\n\treturn (\n\t\t<VariablesSelectionPopover\n\t\t\tselectedVariable={ selectedVariable }\n\t\t\tunlinkVariable={ unlinkVariable }\n\t\t\tstartTagAdornment={ <ColorIndicator size=\"inherit\" component=\"span\" value={ selectedVariable.value } /> }\n\t\t>\n\t\t\t{ ( { closePopover } ) => <ColorVariablesSelection onSelect={ closePopover } /> }\n\t\t</VariablesSelectionPopover>\n\t);\n};\n","import { styled, UnstableColorIndicator } from '@elementor/ui';\n\nexport const ColorIndicator = styled( UnstableColorIndicator )( ( { theme } ) => ( {\n\tborderRadius: `${ theme.shape.borderRadius / 2 }px`,\n} ) );\n","import * as React from 'react';\nimport { Fragment } from 'react';\nimport { useBoundProp } from '@elementor/editor-controls';\nimport { EditIcon } from '@elementor/icons';\nimport { Box, Divider, ListItemIcon, ListItemText, MenuList } from '@elementor/ui';\n\nimport { usePropVariables } from '../hooks/use-prop-variables';\nimport { colorVariablePropTypeUtil } from '../prop-types/color-variable-prop-type';\nimport { type Variable } from '../types';\nimport { ColorIndicator } from './color-indicator';\nimport { StyledMenuItem } from './styled-menu-item';\n\ntype Props = {\n\tonSelect?: () => void;\n};\n\nexport const ColorVariablesSelection = ( { onSelect }: Props ) => {\n\tconst { value: variable, setValue: setVariable } = useBoundProp( colorVariablePropTypeUtil );\n\n\tconst variables = usePropVariables( colorVariablePropTypeUtil.key );\n\n\tconst handleSetColorVariable = ( newValue: Variable ) => {\n\t\tsetVariable( newValue.key );\n\n\t\tonSelect?.();\n\t};\n\n\treturn (\n\t\t<Fragment>\n\t\t\t<Divider />\n\t\t\t<Box sx={ { overflowY: 'auto', height: 260, width: 220 } }>\n\t\t\t\t<MenuList role=\"listbox\" tabIndex={ 0 }>\n\t\t\t\t\t{ variables.map( ( { value, label, key } ) => (\n\t\t\t\t\t\t<StyledMenuItem\n\t\t\t\t\t\t\tkey={ key }\n\t\t\t\t\t\t\tonClick={ () => handleSetColorVariable( { value, label, key } ) }\n\t\t\t\t\t\t\tselected={ key === variable }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<ListItemIcon>\n\t\t\t\t\t\t\t\t<ColorIndicator size=\"inherit\" component=\"span\" value={ value } />\n\t\t\t\t\t\t\t</ListItemIcon>\n\t\t\t\t\t\t\t<ListItemText\n\t\t\t\t\t\t\t\tprimary={ label }\n\t\t\t\t\t\t\t\tsecondary={ value }\n\t\t\t\t\t\t\t\tprimaryTypographyProps={ {\n\t\t\t\t\t\t\t\t\tvariant: 'body2',\n\t\t\t\t\t\t\t\t\tcolor: 'text.secondary',\n\t\t\t\t\t\t\t\t\tstyle: {\n\t\t\t\t\t\t\t\t\t\tlineHeight: 2,\n\t\t\t\t\t\t\t\t\t\tdisplay: 'inline-block',\n\t\t\t\t\t\t\t\t\t\toverflow: 'hidden',\n\t\t\t\t\t\t\t\t\t\ttextOverflow: 'ellipsis',\n\t\t\t\t\t\t\t\t\t\twhiteSpace: 'nowrap',\n\t\t\t\t\t\t\t\t\t\tmaxWidth: '81px',\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t\tsecondaryTypographyProps={ {\n\t\t\t\t\t\t\t\t\tvariant: 'caption',\n\t\t\t\t\t\t\t\t\tcolor: 'text.tertiary',\n\t\t\t\t\t\t\t\t\tstyle: { marginTop: '1px', lineHeight: '1' },\n\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t\tsx={ { display: 'flex', alignItems: 'center', gap: 1 } }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t<EditIcon color=\"action\" fontSize=\"inherit\" sx={ { mx: 1, opacity: '0' } } />\n\t\t\t\t\t\t</StyledMenuItem>\n\t\t\t\t\t) ) }\n\t\t\t\t</MenuList>\n\t\t\t</Box>\n\t\t</Fragment>\n\t);\n};\n","import { useMemo } from 'react';\n\nimport { type Variable } from '../types';\n\ntype VariableData = {\n\tvalue: string;\n\tlabel: string;\n};\ntype Variables = Record< string, VariableData >;\n\ntype VariablesGroup = Record< string, Variables >;\n\nexport const usePropVariables = ( propTypeKey: string ) => {\n\treturn useMemo( () => normalizeVariables( propTypeKey ), [ propTypeKey ] );\n};\n\nexport const useVariable = ( propTypeKey: string, key: string ) => {\n\tif ( ! variables[ propTypeKey ]?.[ key ] ) {\n\t\treturn null;\n\t}\n\n\treturn {\n\t\t...variables[ propTypeKey ][ key ],\n\t\tkey,\n\t};\n};\n\nconst normalizeVariables = ( propTypeKey: string ) => {\n\treturn Object.entries( variables[ propTypeKey ] || {} ).map( ( [ key, { label, value } ] ) => ( {\n\t\tkey,\n\t\tlabel,\n\t\tvalue,\n\t} ) );\n};\n\nexport const createVariable = ( propTypeKey: string, variable: VariableData ) => {\n\tconst id = generateId( 'e-gv', Object.keys( variables[ propTypeKey ] ).length );\n\n\tconst newVariable: Variable = {\n\t\tvalue: variable.value,\n\t\tlabel: variable.label,\n\t\tkey: propTypeKey,\n\t};\n\n\tvariables[ propTypeKey ][ id ] = newVariable || {};\n\n\treturn id;\n};\n\n// @ts-expect-error the temporary solution to get the list of variables from the server\nconst variables: VariablesGroup = window?.ElementorV4Variables || {};\n\nconst generateId = ( prefix: string, variablesCount: number ) => {\n\tconst randomHex = Math.random().toString( 16 ).slice( 2, 9 );\n\n\treturn `${ prefix }${ randomHex }${ variablesCount }`;\n};\n","import { createPropUtils } from '@elementor/editor-props';\nimport { z } from '@elementor/schema';\n\nexport const colorVariablePropTypeUtil = createPropUtils( 'global-color-variable', z.string() );\n","import { MenuItem, styled } from '@elementor/ui';\n\nexport const StyledMenuItem = styled( MenuItem )( () => ( {\n\tpl: 2,\n\tpr: 1,\n\tpy: 0.5,\n\t'&:hover .MuiSvgIcon-root': {\n\t\topacity: 1,\n\t},\n} ) );\n","import * as React from 'react';\nimport { useId, useRef } from 'react';\nimport { ColorFilterIcon, DetachIcon, PlusIcon } from '@elementor/icons';\nimport {\n\tbindPopover,\n\tbindTrigger,\n\tBox,\n\tCloseButton,\n\tIconButton,\n\tPopover,\n\tStack,\n\tTypography,\n\tUnstableTag as Tag,\n\tusePopupState,\n} from '@elementor/ui';\nimport { __ } from '@wordpress/i18n';\n\nimport { type Variable } from '../types';\nimport { ColorVariableCreation } from './color-variable-creation';\n\ntype Props = {\n\tselectedVariable: Variable;\n\tunlinkVariable: () => void;\n\tchildren: ( { closePopover }: { closePopover: () => void } ) => React.ReactNode;\n\tstartTagAdornment?: React.ReactNode;\n};\n\nexport const VariablesSelectionPopover = ( {\n\tselectedVariable,\n\tunlinkVariable,\n\tstartTagAdornment,\n\tchildren,\n}: Props ) => {\n\tconst id = useId();\n\tconst popupState = usePopupState( { variant: 'popover', popupId: `elementor-variables-action-${ id }` } );\n\tconst creationPopupState = usePopupState( { variant: 'popover', popupId: `elementor-variables-creation-${ id }` } );\n\n\tconst closePopover = () => popupState.close();\n\n\tconst handleCreateButtonClick = ( event: React.MouseEvent ) => {\n\t\tclosePopover();\n\t\tbindTrigger( creationPopupState ).onClick( event );\n\t};\n\n\tconst anchorRef = useRef< HTMLDivElement >( null );\n\tconst { label } = selectedVariable;\n\n\treturn (\n\t\t<Box ref={ anchorRef }>\n\t\t\t<Tag\n\t\t\t\tfullWidth\n\t\t\t\tshowActionsOnHover\n\t\t\t\t{ ...bindTrigger( popupState ) }\n\t\t\t\tstartIcon={\n\t\t\t\t\t<Stack spacing={ 1 } direction=\"row\" alignItems=\"center\">\n\t\t\t\t\t\t{ startTagAdornment }\n\t\t\t\t\t\t<ColorFilterIcon fontSize={ 'inherit' } sx={ { mr: 1 } } />\n\t\t\t\t\t</Stack>\n\t\t\t\t}\n\t\t\t\tlabel={\n\t\t\t\t\t<Box sx={ { display: 'inline-grid' } }>\n\t\t\t\t\t\t<Typography sx={ { textOverflow: 'ellipsis', overflowX: 'hidden' } } variant=\"subtitle2\">\n\t\t\t\t\t\t\t{ label }\n\t\t\t\t\t\t</Typography>\n\t\t\t\t\t</Box>\n\t\t\t\t}\n\t\t\t\tactions={\n\t\t\t\t\t<IconButton size=\"tiny\" onClick={ unlinkVariable } aria-label={ __( 'Unlink', 'elementor' ) }>\n\t\t\t\t\t\t<DetachIcon fontSize=\"tiny\" />\n\t\t\t\t\t</IconButton>\n\t\t\t\t}\n\t\t\t/>\n\t\t\t<Popover\n\t\t\t\t{ ...bindPopover( popupState ) }\n\t\t\t\tdisableScrollLock\n\t\t\t\tanchorEl={ anchorRef.current }\n\t\t\t\tanchorOrigin={ { vertical: 'bottom', horizontal: 'right' } }\n\t\t\t\ttransformOrigin={ { vertical: 'top', horizontal: 'right' } }\n\t\t\t>\n\t\t\t\t<Stack direction=\"row\" alignItems=\"center\" pl={ 1.5 } pr={ 0.5 } py={ 1.5 }>\n\t\t\t\t\t<ColorFilterIcon fontSize=\"tiny\" sx={ { mr: 0.5 } } />\n\t\t\t\t\t<Typography variant=\"subtitle2\">{ __( 'Variables', 'elementor' ) }</Typography>\n\t\t\t\t\t<Stack direction=\"row\" sx={ { ml: 'auto' } }>\n\t\t\t\t\t\t<IconButton\n\t\t\t\t\t\t\t{ ...bindTrigger( creationPopupState ) }\n\t\t\t\t\t\t\tsize=\"tiny\"\n\t\t\t\t\t\t\tonClick={ handleCreateButtonClick }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<PlusIcon fontSize=\"tiny\" />\n\t\t\t\t\t\t</IconButton>\n\t\t\t\t\t\t<CloseButton slotProps={ { icon: { fontSize: 'tiny' } } } onClick={ closePopover } />\n\t\t\t\t\t</Stack>\n\t\t\t\t</Stack>\n\t\t\t\t{ children?.( { closePopover } ) }\n\t\t\t</Popover>\n\n\t\t\t<ColorVariableCreation popupState={ creationPopupState } />\n\t\t</Box>\n\t);\n};\n","import * as React from 'react';\nimport { useRef, useState } from 'react';\nimport { useBoundProp } from '@elementor/editor-controls';\nimport { BrushIcon } from '@elementor/icons';\nimport {\n\tbindPopover,\n\tBox,\n\tButton,\n\tCardActions,\n\tCloseButton,\n\tDivider,\n\tFormLabel,\n\tGrid,\n\tPopover,\n\ttype PopupState,\n\tStack,\n\tTextField,\n\tTypography,\n\tUnstableColorField,\n} from '@elementor/ui';\nimport { __ } from '@wordpress/i18n';\n\nimport { createVariable } from '../hooks/use-prop-variables';\nimport { colorVariablePropTypeUtil } from '../prop-types/color-variable-prop-type';\n\nexport const ColorVariableCreation = ( { popupState }: { popupState: PopupState } ) => {\n\tconst { setValue: setVariable } = useBoundProp( colorVariablePropTypeUtil );\n\n\tconst [ color, setColor ] = useState( '' );\n\tconst [ label, setLabel ] = useState( '' );\n\n\tconst anchorRef = useRef< HTMLDivElement >( null );\n\n\tconst resetFields = () => {\n\t\tsetColor( '' );\n\t\tsetLabel( '' );\n\t};\n\n\tconst closePopover = () => {\n\t\tresetFields();\n\t\tpopupState.close();\n\t};\n\n\tconst handleCreate = () => {\n\t\tconst key = createVariable( colorVariablePropTypeUtil.key, { label, value: color } );\n\t\tsetVariable( key );\n\t\tclosePopover();\n\t};\n\n\tconst isInValidForm = () => {\n\t\treturn ! color?.trim() || ! label?.trim();\n\t};\n\n\treturn (\n\t\t<Box ref={ anchorRef }>\n\t\t\t<Popover\n\t\t\t\t{ ...bindPopover( popupState ) }\n\t\t\t\tanchorEl={ anchorRef.current }\n\t\t\t\tanchorOrigin={ { vertical: 'bottom', horizontal: 'right' } }\n\t\t\t\ttransformOrigin={ { vertical: 'top', horizontal: 'right' } }\n\t\t\t>\n\t\t\t\t<Stack direction=\"row\" alignItems=\"center\" pl={ 1.5 } pr={ 0.5 } py={ 1.5 }>\n\t\t\t\t\t<BrushIcon fontSize=\"tiny\" sx={ { mr: 0.5 } } />\n\t\t\t\t\t<Typography variant=\"subtitle2\">{ __( 'Create variable', 'elementor' ) }</Typography>\n\t\t\t\t\t<CloseButton\n\t\t\t\t\t\tslotProps={ { icon: { fontSize: 'small' } } }\n\t\t\t\t\t\tsx={ { ml: 'auto' } }\n\t\t\t\t\t\tonClick={ closePopover }\n\t\t\t\t\t/>\n\t\t\t\t</Stack>\n\n\t\t\t\t<Divider />\n\n\t\t\t\t<Stack p={ 1.5 } gap={ 1.5 }>\n\t\t\t\t\t<Grid container gap={ 0.75 } alignItems=\"center\">\n\t\t\t\t\t\t<Grid item xs={ 12 }>\n\t\t\t\t\t\t\t<FormLabel size=\"small\">{ __( 'Name', 'elementor' ) }</FormLabel>\n\t\t\t\t\t\t</Grid>\n\t\t\t\t\t\t<Grid item xs={ 12 }>\n\t\t\t\t\t\t\t<TextField\n\t\t\t\t\t\t\t\tsize=\"tiny\"\n\t\t\t\t\t\t\t\tfullWidth\n\t\t\t\t\t\t\t\tvalue={ label }\n\t\t\t\t\t\t\t\tonChange={ ( e: React.ChangeEvent< HTMLInputElement > ) => setLabel( e.target.value ) }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t</Grid>\n\t\t\t\t\t</Grid>\n\n\t\t\t\t\t<Grid container gap={ 0.75 } alignItems=\"center\">\n\t\t\t\t\t\t<Grid item xs={ 12 }>\n\t\t\t\t\t\t\t<FormLabel size=\"small\">{ __( 'Value', 'elementor' ) }</FormLabel>\n\t\t\t\t\t\t</Grid>\n\t\t\t\t\t\t<Grid item xs={ 12 }>\n\t\t\t\t\t\t\t<UnstableColorField\n\t\t\t\t\t\t\t\tsize=\"tiny\"\n\t\t\t\t\t\t\t\tfullWidth\n\t\t\t\t\t\t\t\tvalue={ color }\n\t\t\t\t\t\t\t\tonChange={ setColor }\n\t\t\t\t\t\t\t\tslotProps={ {\n\t\t\t\t\t\t\t\t\tcolorPicker: {\n\t\t\t\t\t\t\t\t\t\tanchorEl: anchorRef.current,\n\t\t\t\t\t\t\t\t\t\tanchorOrigin: { vertical: 'top', horizontal: 'right' },\n\t\t\t\t\t\t\t\t\t\ttransformOrigin: { vertical: 'top', horizontal: -10 },\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t</Grid>\n\t\t\t\t\t</Grid>\n\t\t\t\t</Stack>\n\n\t\t\t\t<CardActions>\n\t\t\t\t\t<Button size=\"small\" onClick={ closePopover } color=\"secondary\" variant=\"text\">\n\t\t\t\t\t\t{ __( 'Cancel', 'elementor' ) }\n\t\t\t\t\t</Button>\n\t\t\t\t\t<Button size=\"small\" variant=\"contained\" disabled={ isInValidForm() } onClick={ handleCreate }>\n\t\t\t\t\t\t{ __( 'Create', 'elementor' ) }\n\t\t\t\t\t</Button>\n\t\t\t\t</CardActions>\n\t\t\t</Popover>\n\t\t</Box>\n\t);\n};\n","import * as React from 'react';\nimport { type PopoverActionProps, useBoundProp } from '@elementor/editor-editing-panel';\nimport { ColorFilterIcon } from '@elementor/icons';\nimport { __ } from '@wordpress/i18n';\n\nimport { ColorVariablesSelection } from '../components/color-variables-selection';\nimport { supportsColorVariables } from '../utils';\n\nexport const usePropColorVariableAction = (): PopoverActionProps => {\n\tconst { propType } = useBoundProp();\n\n\tconst visible = !! propType && supportsColorVariables( propType );\n\n\treturn {\n\t\tvisible,\n\t\ticon: ColorFilterIcon,\n\t\ttitle: __( 'Variables', 'elementor' ),\n\t\tpopoverContent: ( { closePopover } ) => <ColorVariablesSelection onSelect={ closePopover } />,\n\t};\n};\n","import { createPropUtils } from '@elementor/editor-props';\nimport { z } from '@elementor/schema';\n\nexport const fontVariablePropTypeUtil = createPropUtils( 'global-font-variable', z.string() );\n","import { type PropType, type PropValue } from '@elementor/editor-props';\n\nimport { colorVariablePropTypeUtil } from './prop-types/color-variable-prop-type';\nimport { fontVariablePropTypeUtil } from './prop-types/font-variable-prop-type';\n\nexport const hasAssignedColorVariable = ( propValue: PropValue ): boolean => {\n\treturn !! colorVariablePropTypeUtil.isValid( propValue );\n};\n\nexport const supportsColorVariables = ( propType: PropType ): boolean => {\n\treturn propType.kind === 'union' && colorVariablePropTypeUtil.key in propType.prop_types;\n};\n\nexport const hasAssignedFontVariable = ( propValue: PropValue ): boolean => {\n\treturn !! fontVariablePropTypeUtil.isValid( propValue );\n};\n\nexport const supportsFontVariables = ( propType: PropType ): boolean => {\n\treturn propType.kind === 'union' && fontVariablePropTypeUtil.key in propType.prop_types;\n};\n","import { createTransformer } from '@elementor/editor-canvas';\n\nexport const variableTransformer = createTransformer( ( value: string ) => {\n\tif ( ! value.trim() ) {\n\t\treturn null;\n\t}\n\n\treturn `var(--${ value })`;\n} );\n","import { styleTransformersRegistry } from '@elementor/editor-canvas';\nimport { controlActionsMenu, registerControlReplacement } from '@elementor/editor-editing-panel';\n\nimport { FontVariablesSelectionControl } from './controls/font-variables-selection-control';\nimport { usePropFontVariableAction } from './hooks/use-prop-font-variable-action';\nimport { fontVariablePropTypeUtil } from './prop-types/font-variable-prop-type';\nimport { variableTransformer } from './transformers/variable-transformer';\nimport { hasAssignedFontVariable } from './utils';\n\nconst { registerPopoverAction } = controlActionsMenu;\n\nexport function initFontVariables() {\n\tregisterControlReplacement( {\n\t\tcomponent: FontVariablesSelectionControl,\n\t\tcondition: ( { value } ) => hasAssignedFontVariable( value ),\n\t} );\n\n\tregisterPopoverAction( {\n\t\tid: 'font-variables',\n\t\tuseProps: usePropFontVariableAction,\n\t} );\n\n\tstyleTransformersRegistry.register( fontVariablePropTypeUtil.key, variableTransformer );\n}\n","import * as React from 'react';\nimport { useBoundProp } from '@elementor/editor-controls';\nimport { stringPropTypeUtil } from '@elementor/editor-props';\n\nimport { FontVariablesSelection } from '../components/font-variables-selection';\nimport { VariablesSelectionPopover } from '../components/variables-selection-popover';\nimport { useVariable } from '../hooks/use-prop-variables';\nimport { fontVariablePropTypeUtil } from '../prop-types/font-variable-prop-type';\n\nexport const FontVariablesSelectionControl = () => {\n\tconst { setValue: setFontFamily } = useBoundProp();\n\tconst { value: variableValue } = useBoundProp( fontVariablePropTypeUtil );\n\n\tconst selectedVariable = useVariable( fontVariablePropTypeUtil.key, variableValue );\n\n\tif ( ! selectedVariable ) {\n\t\tthrow new Error( `Global font variable ${ variableValue } not found` );\n\t}\n\n\tconst unlinkVariable = () => {\n\t\tsetFontFamily( stringPropTypeUtil.create( selectedVariable.value ) );\n\t};\n\n\treturn (\n\t\t<VariablesSelectionPopover selectedVariable={ selectedVariable } unlinkVariable={ unlinkVariable }>\n\t\t\t{ ( { closePopover } ) => <FontVariablesSelection onSelect={ closePopover } /> }\n\t\t</VariablesSelectionPopover>\n\t);\n};\n","import * as React from 'react';\nimport { Fragment } from 'react';\nimport { useBoundProp } from '@elementor/editor-controls';\nimport { EditIcon, TextIcon } from '@elementor/icons';\nimport { Box, Divider, ListItemIcon, ListItemText, MenuList } from '@elementor/ui';\n\nimport { usePropVariables } from '../hooks/use-prop-variables';\nimport { fontVariablePropTypeUtil } from '../prop-types/font-variable-prop-type';\nimport { type Variable } from '../types';\nimport { StyledMenuItem } from './styled-menu-item';\n\ntype Props = {\n\tonSelect?: () => void;\n};\n\nexport const FontVariablesSelection = ( { onSelect }: Props ) => {\n\tconst { value: variable, setValue: setVariable } = useBoundProp( fontVariablePropTypeUtil );\n\n\tconst variables = usePropVariables( fontVariablePropTypeUtil.key );\n\n\tconst handleSetVariable = ( newValue: Variable ) => {\n\t\tsetVariable( newValue.key );\n\n\t\tonSelect?.();\n\t};\n\n\treturn (\n\t\t<Fragment>\n\t\t\t<Divider />\n\t\t\t<Box sx={ { overflowY: 'auto', height: 260, width: 220 } }>\n\t\t\t\t<MenuList role=\"listbox\" tabIndex={ 0 }>\n\t\t\t\t\t{ variables.map( ( { value, label, key } ) => (\n\t\t\t\t\t\t<StyledMenuItem\n\t\t\t\t\t\t\tkey={ key }\n\t\t\t\t\t\t\tonClick={ () => handleSetVariable( { value, label, key } ) }\n\t\t\t\t\t\t\tselected={ key === variable }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<ListItemIcon>\n\t\t\t\t\t\t\t\t<TextIcon />\n\t\t\t\t\t\t\t</ListItemIcon>\n\t\t\t\t\t\t\t<ListItemText\n\t\t\t\t\t\t\t\tprimary={ label }\n\t\t\t\t\t\t\t\tsecondary={ value }\n\t\t\t\t\t\t\t\tprimaryTypographyProps={ {\n\t\t\t\t\t\t\t\t\tvariant: 'body2',\n\t\t\t\t\t\t\t\t\tcolor: 'text.secondary',\n\t\t\t\t\t\t\t\t\tstyle: {\n\t\t\t\t\t\t\t\t\t\tlineHeight: 2,\n\t\t\t\t\t\t\t\t\t\tdisplay: 'inline-block',\n\t\t\t\t\t\t\t\t\t\toverflow: 'hidden',\n\t\t\t\t\t\t\t\t\t\ttextOverflow: 'ellipsis',\n\t\t\t\t\t\t\t\t\t\twhiteSpace: 'nowrap',\n\t\t\t\t\t\t\t\t\t\tmaxWidth: '81px',\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t\tsecondaryTypographyProps={ {\n\t\t\t\t\t\t\t\t\tvariant: 'caption',\n\t\t\t\t\t\t\t\t\tcolor: 'text.tertiary',\n\t\t\t\t\t\t\t\t\tstyle: { marginTop: '1px', lineHeight: '1' },\n\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t\tsx={ { display: 'flex', alignItems: 'center', gap: 1 } }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t<EditIcon color=\"action\" fontSize=\"inherit\" sx={ { mx: 1, opacity: '0' } } />\n\t\t\t\t\t\t</StyledMenuItem>\n\t\t\t\t\t) ) }\n\t\t\t\t</MenuList>\n\t\t\t</Box>\n\t\t</Fragment>\n\t);\n};\n","import * as React from 'react';\nimport { type PopoverActionProps, useBoundProp } from '@elementor/editor-editing-panel';\nimport { ColorFilterIcon } from '@elementor/icons';\nimport { __ } from '@wordpress/i18n';\n\nimport { FontVariablesSelection } from '../components/font-variables-selection';\nimport { supportsFontVariables } from '../utils';\n\nexport const usePropFontVariableAction = (): PopoverActionProps => {\n\tconst { propType } = useBoundProp();\n\n\tconst visible = !! propType && supportsFontVariables( propType );\n\n\treturn {\n\t\tvisible,\n\t\ticon: ColorFilterIcon,\n\t\ttitle: __( 'Variables', 'elementor' ),\n\t\tpopoverContent: ( { closePopover } ) => <FontVariablesSelection onSelect={ closePopover } />,\n\t};\n};\n","import { initColorVariables } from './init-color-variables';\nimport { initFontVariables } from './init-font-variables';\n\nexport function init() {\n\tinitColorVariables();\n\n\tinitFontVariables();\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,IAAAA,wBAA0C;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AAa;AAElC,QAAM,UAAU,CAAC,CAAE,YAAY,sBAAuB,QAAS;AAE/D,SAAO;AAAA,IACN;AAAA,IACA,MAAM;AAAA,IACN,WAAO,iBAAI,aAAa,WAAY;AAAA,IACpC,gBAAgB,CAAE,EAAE,aAAa,MAAO,qCAAC,0BAAuB,UAAW,cAAe;AAAA,EAC3F;AACD;;;AHVA,IAAM,EAAE,uBAAAC,uBAAsB,IAAI;AAE3B,SAAS,oBAAoB;AACnC,+DAA4B;AAAA,IAC3B,WAAW;AAAA,IACX,WAAW,CAAE,EAAE,MAAM,MAAO,wBAAyB,KAAM;AAAA,EAC5D,CAAE;AAEF,EAAAA,uBAAuB;AAAA,IACtB,IAAI;AAAA,IACJ,UAAU;AAAA,EACX,CAAE;AAEF,kDAA0B,SAAU,yBAAyB,KAAK,mBAAoB;AACvF;;;AIpBO,SAAS,OAAO;AACtB,qBAAmB;AAEnB,oBAAkB;AACnB;","names":["import_editor_canvas","import_editor_editing_panel","React","import_editor_controls","import_editor_props","import_react","import_ui","import_ui","variables","React","import_react","import_icons","import_ui","import_i18n","React","import_react","import_editor_controls","import_icons","import_ui","Tag","React","import_icons","import_i18n","import_editor_props","import_schema","import_editor_canvas","import_editor_editing_panel","React","import_editor_controls","import_editor_props","React","import_react","import_editor_controls","import_icons","import_ui","variables","React","import_editor_editing_panel","import_icons","import_i18n","registerPopoverAction"]}
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../src/init.ts","../src/init-color-variables.ts","../src/controls/color-variables-selection-control.tsx","../src/components/color-indicator.tsx","../src/components/color-variables-selection.tsx","../src/hooks/use-prop-variables.ts","../src/create-style-variables-repository.ts","../src/style-variables-repository.ts","../src/prop-types/color-variable-prop-type.ts","../src/components/styled-menu-item.tsx","../src/components/variables-selection-popover.tsx","../src/components/color-variable-creation.tsx","../src/hooks/use-prop-color-variable-action.tsx","../src/prop-types/font-variable-prop-type.ts","../src/utils.ts","../src/transformers/variable-transformer.ts","../src/init-font-variables.ts","../src/controls/font-variables-selection-control.tsx","../src/components/font-variables-selection.tsx","../src/hooks/use-prop-font-variable-action.tsx","../src/renderers/style-variables-renderer.tsx","../src/sync/get-canvas-iframe-document.ts"],"sourcesContent":["export { init } from './init';\n","import { injectIntoTop } from '@elementor/editor';\n\nimport { initColorVariables } from './init-color-variables';\nimport { initFontVariables } from './init-font-variables';\nimport { StyleVariablesRenderer } from './renderers/style-variables-renderer';\n\nexport function init() {\n\tinitColorVariables();\n\n\tinitFontVariables();\n\n\tinjectIntoTop( {\n\t\tid: 'canvas-style-variables-render',\n\t\tcomponent: StyleVariablesRenderer,\n\t} );\n}\n","import { styleTransformersRegistry } from '@elementor/editor-canvas';\nimport { controlActionsMenu, registerControlReplacement } from '@elementor/editor-editing-panel';\n\nimport { ColorVariablesSelectionControl } from './controls/color-variables-selection-control';\nimport { usePropColorVariableAction } from './hooks/use-prop-color-variable-action';\nimport { colorVariablePropTypeUtil } from './prop-types/color-variable-prop-type';\nimport { variableTransformer } from './transformers/variable-transformer';\nimport { hasAssignedColorVariable } from './utils';\n\nconst { registerPopoverAction } = controlActionsMenu;\n\nexport function initColorVariables() {\n\tregisterControlReplacement( {\n\t\tcomponent: ColorVariablesSelectionControl,\n\t\tcondition: ( { value } ) => hasAssignedColorVariable( value ),\n\t} );\n\n\tregisterPopoverAction( {\n\t\tid: 'color-variables',\n\t\tuseProps: usePropColorVariableAction,\n\t} );\n\n\tstyleTransformersRegistry.register( colorVariablePropTypeUtil.key, variableTransformer );\n}\n","import * as React from 'react';\nimport { useBoundProp } from '@elementor/editor-controls';\nimport { colorPropTypeUtil } from '@elementor/editor-props';\n\nimport { ColorIndicator } from '../components/color-indicator';\nimport { ColorVariablesSelection } from '../components/color-variables-selection';\nimport { VariablesSelectionPopover } from '../components/variables-selection-popover';\nimport { useVariable } from '../hooks/use-prop-variables';\nimport { colorVariablePropTypeUtil } from '../prop-types/color-variable-prop-type';\n\nexport const ColorVariablesSelectionControl = () => {\n\tconst { setValue } = useBoundProp();\n\tconst { value: variableValue } = useBoundProp( colorVariablePropTypeUtil );\n\n\tconst selectedVariable = useVariable( variableValue );\n\n\tif ( ! selectedVariable ) {\n\t\tthrow new Error( `Global color variable ${ variableValue } not found` );\n\t}\n\n\tconst unlinkVariable = () => {\n\t\tsetValue( colorPropTypeUtil.create( selectedVariable.value ) );\n\t};\n\n\treturn (\n\t\t<VariablesSelectionPopover\n\t\t\tselectedVariable={ selectedVariable }\n\t\t\tunlinkVariable={ unlinkVariable }\n\t\t\tstartTagAdornment={ <ColorIndicator size=\"inherit\" component=\"span\" value={ selectedVariable.value } /> }\n\t\t>\n\t\t\t{ ( { closePopover } ) => <ColorVariablesSelection onSelect={ closePopover } /> }\n\t\t</VariablesSelectionPopover>\n\t);\n};\n","import { styled, UnstableColorIndicator } from '@elementor/ui';\n\nexport const ColorIndicator = styled( UnstableColorIndicator )( ( { theme } ) => ( {\n\tborderRadius: `${ theme.shape.borderRadius / 2 }px`,\n} ) );\n","import * as React from 'react';\nimport { Fragment } from 'react';\nimport { useBoundProp } from '@elementor/editor-controls';\nimport { EditIcon } from '@elementor/icons';\nimport { Box, Divider, ListItemIcon, ListItemText, MenuList } from '@elementor/ui';\n\nimport { usePropVariables } from '../hooks/use-prop-variables';\nimport { colorVariablePropTypeUtil } from '../prop-types/color-variable-prop-type';\nimport { type VariableKey } from '../types';\nimport { ColorIndicator } from './color-indicator';\nimport { StyledMenuItem } from './styled-menu-item';\n\ntype Props = {\n\tonSelect?: () => void;\n};\n\nexport const ColorVariablesSelection = ( { onSelect }: Props ) => {\n\tconst { value: variable, setValue: setVariable } = useBoundProp( colorVariablePropTypeUtil );\n\n\tconst variables = usePropVariables( colorVariablePropTypeUtil.key );\n\n\tconst handleSetColorVariable = ( key: VariableKey ) => {\n\t\tsetVariable( key );\n\n\t\tonSelect?.();\n\t};\n\n\treturn (\n\t\t<Fragment>\n\t\t\t<Divider />\n\t\t\t<Box sx={ { overflowY: 'auto', height: 260, width: 220 } }>\n\t\t\t\t<MenuList role=\"listbox\" tabIndex={ 0 }>\n\t\t\t\t\t{ variables.map( ( { value, label, key } ) => (\n\t\t\t\t\t\t<StyledMenuItem\n\t\t\t\t\t\t\tkey={ key }\n\t\t\t\t\t\t\tonClick={ () => handleSetColorVariable( key ) }\n\t\t\t\t\t\t\tselected={ key === variable }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<ListItemIcon>\n\t\t\t\t\t\t\t\t<ColorIndicator size=\"inherit\" component=\"span\" value={ value } />\n\t\t\t\t\t\t\t</ListItemIcon>\n\t\t\t\t\t\t\t<ListItemText\n\t\t\t\t\t\t\t\tprimary={ label }\n\t\t\t\t\t\t\t\tsecondary={ value }\n\t\t\t\t\t\t\t\tprimaryTypographyProps={ {\n\t\t\t\t\t\t\t\t\tvariant: 'body2',\n\t\t\t\t\t\t\t\t\tcolor: 'text.secondary',\n\t\t\t\t\t\t\t\t\tstyle: {\n\t\t\t\t\t\t\t\t\t\tlineHeight: 2,\n\t\t\t\t\t\t\t\t\t\tdisplay: 'inline-block',\n\t\t\t\t\t\t\t\t\t\toverflow: 'hidden',\n\t\t\t\t\t\t\t\t\t\ttextOverflow: 'ellipsis',\n\t\t\t\t\t\t\t\t\t\twhiteSpace: 'nowrap',\n\t\t\t\t\t\t\t\t\t\tmaxWidth: '81px',\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t\tsecondaryTypographyProps={ {\n\t\t\t\t\t\t\t\t\tvariant: 'caption',\n\t\t\t\t\t\t\t\t\tcolor: 'text.tertiary',\n\t\t\t\t\t\t\t\t\tstyle: { marginTop: '1px', lineHeight: '1' },\n\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t\tsx={ { display: 'flex', alignItems: 'center', gap: 1 } }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t<EditIcon color=\"action\" fontSize=\"inherit\" sx={ { mx: 1, opacity: '0' } } />\n\t\t\t\t\t\t</StyledMenuItem>\n\t\t\t\t\t) ) }\n\t\t\t\t</MenuList>\n\t\t\t</Box>\n\t\t</Fragment>\n\t);\n};\n","import { useMemo } from 'react';\nimport { type PropKey } from '@elementor/editor-props';\n\nimport { styleVariablesRepository } from '../style-variables-repository';\nimport { type Variable, type Variables } from '../types';\n\nexport const usePropVariables = ( propKey: PropKey ) => {\n\treturn useMemo( () => normalizeVariables( propKey ), [ propKey ] );\n};\n\nexport const useVariable = ( key: string ) => {\n\tif ( ! variables?.[ key ] ) {\n\t\treturn null;\n\t}\n\n\treturn {\n\t\t...variables[ key ],\n\t\tkey,\n\t};\n};\n\nconst normalizeVariables = ( propKey: string ) => {\n\treturn Object.entries( variables )\n\t\t.filter( ( [ , { type } ] ) => type === propKey )\n\t\t.map( ( [ key, { label, value } ] ) => ( {\n\t\t\tkey,\n\t\t\tlabel,\n\t\t\tvalue,\n\t\t} ) );\n};\n\nexport const createVariable = ( variable: Variable ) => {\n\tconst id = generateId();\n\n\tvariables[ id ] = variable;\n\n\tstyleVariablesRepository.update( {\n\t\t[ id ]: variable,\n\t} );\n\n\treturn id;\n};\n\n// @ts-expect-error the temporary solution to get the list of variables from the server\nconst variables: Variables = window?.ElementorV4Variables || {};\n\nconst generateId = ( prefix = 'e-gv' ) => {\n\tconst randomHex = Math.random().toString( 16 ).slice( 2, 9 );\n\n\treturn `${ prefix }${ randomHex }`;\n};\n","import { type StyleVariables, type Variables, type VariableValue } from './types';\n\ntype VariablesChangeCallback = ( variables: StyleVariables ) => void;\n\nexport const createStyleVariablesRepository = () => {\n\tconst variables: StyleVariables = {};\n\tlet subscription: VariablesChangeCallback;\n\n\tconst subscribe = ( cb: VariablesChangeCallback ) => {\n\t\tsubscription = cb;\n\n\t\treturn () => {\n\t\t\tsubscription = () => {};\n\t\t};\n\t};\n\n\tconst notify = () => {\n\t\tif ( typeof subscription === 'function' ) {\n\t\t\tsubscription( { ...variables } );\n\t\t}\n\t};\n\n\tconst shouldUpdate = ( key: string, newValue: VariableValue ): boolean => {\n\t\treturn ! ( key in variables ) || variables[ key ] !== newValue;\n\t};\n\n\tconst applyUpdates = ( updatedVars: Variables ): boolean => {\n\t\tlet hasChanges = false;\n\n\t\tfor ( const [ key, { value } ] of Object.entries( updatedVars ) ) {\n\t\t\tif ( shouldUpdate( key, value ) ) {\n\t\t\t\tvariables[ key ] = value;\n\t\t\t\thasChanges = true;\n\t\t\t}\n\t\t}\n\n\t\treturn hasChanges;\n\t};\n\n\tconst update = ( updatedVars: Variables ) => {\n\t\tif ( applyUpdates( updatedVars ) ) {\n\t\t\tnotify();\n\t\t}\n\t};\n\n\treturn {\n\t\tsubscribe,\n\t\tupdate,\n\t};\n};\n","import { createStyleVariablesRepository } from './create-style-variables-repository';\n\nexport const styleVariablesRepository = createStyleVariablesRepository();\n","import { createPropUtils } from '@elementor/editor-props';\nimport { z } from '@elementor/schema';\n\nexport const colorVariablePropTypeUtil = createPropUtils( 'global-color-variable', z.string() );\n","import { MenuItem, styled } from '@elementor/ui';\n\nexport const StyledMenuItem = styled( MenuItem )( () => ( {\n\tpl: 2,\n\tpr: 1,\n\tpy: 0.5,\n\t'&:hover .MuiSvgIcon-root': {\n\t\topacity: 1,\n\t},\n} ) );\n","import * as React from 'react';\nimport { useId, useRef } from 'react';\nimport { ColorFilterIcon, DetachIcon, PlusIcon } from '@elementor/icons';\nimport {\n\tbindPopover,\n\tbindTrigger,\n\tBox,\n\tCloseButton,\n\tIconButton,\n\tPopover,\n\tStack,\n\tTypography,\n\tUnstableTag as Tag,\n\tusePopupState,\n} from '@elementor/ui';\nimport { __ } from '@wordpress/i18n';\n\nimport { type Variable } from '../types';\nimport { ColorVariableCreation } from './color-variable-creation';\n\ntype Props = {\n\tselectedVariable: Variable;\n\tunlinkVariable: () => void;\n\tchildren: ( { closePopover }: { closePopover: () => void } ) => React.ReactNode;\n\tstartTagAdornment?: React.ReactNode;\n};\n\nexport const VariablesSelectionPopover = ( {\n\tselectedVariable,\n\tunlinkVariable,\n\tstartTagAdornment,\n\tchildren,\n}: Props ) => {\n\tconst id = useId();\n\tconst popupState = usePopupState( { variant: 'popover', popupId: `elementor-variables-action-${ id }` } );\n\tconst creationPopupState = usePopupState( { variant: 'popover', popupId: `elementor-variables-creation-${ id }` } );\n\n\tconst closePopover = () => popupState.close();\n\n\tconst handleCreateButtonClick = ( event: React.MouseEvent ) => {\n\t\tclosePopover();\n\t\tbindTrigger( creationPopupState ).onClick( event );\n\t};\n\n\tconst anchorRef = useRef< HTMLDivElement >( null );\n\tconst { label } = selectedVariable;\n\n\treturn (\n\t\t<Box ref={ anchorRef }>\n\t\t\t<Tag\n\t\t\t\tfullWidth\n\t\t\t\tshowActionsOnHover\n\t\t\t\t{ ...bindTrigger( popupState ) }\n\t\t\t\tstartIcon={\n\t\t\t\t\t<Stack spacing={ 1 } direction=\"row\" alignItems=\"center\">\n\t\t\t\t\t\t{ startTagAdornment }\n\t\t\t\t\t\t<ColorFilterIcon fontSize={ 'inherit' } sx={ { mr: 1 } } />\n\t\t\t\t\t</Stack>\n\t\t\t\t}\n\t\t\t\tlabel={\n\t\t\t\t\t<Box sx={ { display: 'inline-grid' } }>\n\t\t\t\t\t\t<Typography sx={ { textOverflow: 'ellipsis', overflowX: 'hidden' } } variant=\"subtitle2\">\n\t\t\t\t\t\t\t{ label }\n\t\t\t\t\t\t</Typography>\n\t\t\t\t\t</Box>\n\t\t\t\t}\n\t\t\t\tactions={\n\t\t\t\t\t<IconButton size=\"tiny\" onClick={ unlinkVariable } aria-label={ __( 'Unlink', 'elementor' ) }>\n\t\t\t\t\t\t<DetachIcon fontSize=\"tiny\" />\n\t\t\t\t\t</IconButton>\n\t\t\t\t}\n\t\t\t/>\n\t\t\t<Popover\n\t\t\t\t{ ...bindPopover( popupState ) }\n\t\t\t\tdisableScrollLock\n\t\t\t\tanchorEl={ anchorRef.current }\n\t\t\t\tanchorOrigin={ { vertical: 'bottom', horizontal: 'right' } }\n\t\t\t\ttransformOrigin={ { vertical: 'top', horizontal: 'right' } }\n\t\t\t>\n\t\t\t\t<Stack direction=\"row\" alignItems=\"center\" pl={ 1.5 } pr={ 0.5 } py={ 1.5 }>\n\t\t\t\t\t<ColorFilterIcon fontSize=\"tiny\" sx={ { mr: 0.5 } } />\n\t\t\t\t\t<Typography variant=\"subtitle2\">{ __( 'Variables', 'elementor' ) }</Typography>\n\t\t\t\t\t<Stack direction=\"row\" sx={ { ml: 'auto' } }>\n\t\t\t\t\t\t<IconButton\n\t\t\t\t\t\t\t{ ...bindTrigger( creationPopupState ) }\n\t\t\t\t\t\t\tsize=\"tiny\"\n\t\t\t\t\t\t\tonClick={ handleCreateButtonClick }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<PlusIcon fontSize=\"tiny\" />\n\t\t\t\t\t\t</IconButton>\n\t\t\t\t\t\t<CloseButton slotProps={ { icon: { fontSize: 'tiny' } } } onClick={ closePopover } />\n\t\t\t\t\t</Stack>\n\t\t\t\t</Stack>\n\t\t\t\t{ children?.( { closePopover } ) }\n\t\t\t</Popover>\n\n\t\t\t<ColorVariableCreation popupState={ creationPopupState } />\n\t\t</Box>\n\t);\n};\n","import * as React from 'react';\nimport { useRef, useState } from 'react';\nimport { useBoundProp } from '@elementor/editor-controls';\nimport { BrushIcon } from '@elementor/icons';\nimport {\n\tbindPopover,\n\tBox,\n\tButton,\n\tCardActions,\n\tCloseButton,\n\tDivider,\n\tFormLabel,\n\tGrid,\n\tPopover,\n\ttype PopupState,\n\tStack,\n\tTextField,\n\tTypography,\n\tUnstableColorField,\n} from '@elementor/ui';\nimport { __ } from '@wordpress/i18n';\n\nimport { createVariable } from '../hooks/use-prop-variables';\nimport { colorVariablePropTypeUtil } from '../prop-types/color-variable-prop-type';\n\nexport const ColorVariableCreation = ( { popupState }: { popupState: PopupState } ) => {\n\tconst { setValue: setVariable } = useBoundProp( colorVariablePropTypeUtil );\n\n\tconst [ color, setColor ] = useState( '' );\n\tconst [ label, setLabel ] = useState( '' );\n\n\tconst anchorRef = useRef< HTMLDivElement >( null );\n\n\tconst resetFields = () => {\n\t\tsetColor( '' );\n\t\tsetLabel( '' );\n\t};\n\n\tconst closePopover = () => {\n\t\tresetFields();\n\t\tpopupState.close();\n\t};\n\n\tconst handleCreate = () => {\n\t\tconst key = createVariable( {\n\t\t\tvalue: color,\n\t\t\tlabel,\n\t\t\ttype: colorVariablePropTypeUtil.key,\n\t\t} );\n\n\t\tsetVariable( key );\n\t\tclosePopover();\n\t};\n\n\tconst isInValidForm = () => {\n\t\treturn ! color?.trim() || ! label?.trim();\n\t};\n\n\treturn (\n\t\t<Box ref={ anchorRef }>\n\t\t\t<Popover\n\t\t\t\t{ ...bindPopover( popupState ) }\n\t\t\t\tanchorEl={ anchorRef.current }\n\t\t\t\tanchorOrigin={ { vertical: 'bottom', horizontal: 'right' } }\n\t\t\t\ttransformOrigin={ { vertical: 'top', horizontal: 'right' } }\n\t\t\t>\n\t\t\t\t<Stack direction=\"row\" alignItems=\"center\" pl={ 1.5 } pr={ 0.5 } py={ 1.5 }>\n\t\t\t\t\t<BrushIcon fontSize=\"tiny\" sx={ { mr: 0.5 } } />\n\t\t\t\t\t<Typography variant=\"subtitle2\">{ __( 'Create variable', 'elementor' ) }</Typography>\n\t\t\t\t\t<CloseButton\n\t\t\t\t\t\tslotProps={ { icon: { fontSize: 'small' } } }\n\t\t\t\t\t\tsx={ { ml: 'auto' } }\n\t\t\t\t\t\tonClick={ closePopover }\n\t\t\t\t\t/>\n\t\t\t\t</Stack>\n\n\t\t\t\t<Divider />\n\n\t\t\t\t<Stack p={ 1.5 } gap={ 1.5 }>\n\t\t\t\t\t<Grid container gap={ 0.75 } alignItems=\"center\">\n\t\t\t\t\t\t<Grid item xs={ 12 }>\n\t\t\t\t\t\t\t<FormLabel size=\"small\">{ __( 'Name', 'elementor' ) }</FormLabel>\n\t\t\t\t\t\t</Grid>\n\t\t\t\t\t\t<Grid item xs={ 12 }>\n\t\t\t\t\t\t\t<TextField\n\t\t\t\t\t\t\t\tsize=\"tiny\"\n\t\t\t\t\t\t\t\tfullWidth\n\t\t\t\t\t\t\t\tvalue={ label }\n\t\t\t\t\t\t\t\tonChange={ ( e: React.ChangeEvent< HTMLInputElement > ) => setLabel( e.target.value ) }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t</Grid>\n\t\t\t\t\t</Grid>\n\n\t\t\t\t\t<Grid container gap={ 0.75 } alignItems=\"center\">\n\t\t\t\t\t\t<Grid item xs={ 12 }>\n\t\t\t\t\t\t\t<FormLabel size=\"small\">{ __( 'Value', 'elementor' ) }</FormLabel>\n\t\t\t\t\t\t</Grid>\n\t\t\t\t\t\t<Grid item xs={ 12 }>\n\t\t\t\t\t\t\t<UnstableColorField\n\t\t\t\t\t\t\t\tsize=\"tiny\"\n\t\t\t\t\t\t\t\tfullWidth\n\t\t\t\t\t\t\t\tvalue={ color }\n\t\t\t\t\t\t\t\tonChange={ setColor }\n\t\t\t\t\t\t\t\tslotProps={ {\n\t\t\t\t\t\t\t\t\tcolorPicker: {\n\t\t\t\t\t\t\t\t\t\tanchorEl: anchorRef.current,\n\t\t\t\t\t\t\t\t\t\tanchorOrigin: { vertical: 'top', horizontal: 'right' },\n\t\t\t\t\t\t\t\t\t\ttransformOrigin: { vertical: 'top', horizontal: -10 },\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t</Grid>\n\t\t\t\t\t</Grid>\n\t\t\t\t</Stack>\n\n\t\t\t\t<CardActions>\n\t\t\t\t\t<Button size=\"small\" onClick={ closePopover } color=\"secondary\" variant=\"text\">\n\t\t\t\t\t\t{ __( 'Cancel', 'elementor' ) }\n\t\t\t\t\t</Button>\n\t\t\t\t\t<Button size=\"small\" variant=\"contained\" disabled={ isInValidForm() } onClick={ handleCreate }>\n\t\t\t\t\t\t{ __( 'Create', 'elementor' ) }\n\t\t\t\t\t</Button>\n\t\t\t\t</CardActions>\n\t\t\t</Popover>\n\t\t</Box>\n\t);\n};\n","import * as React from 'react';\nimport { type PopoverActionProps, useBoundProp } from '@elementor/editor-editing-panel';\nimport { ColorFilterIcon } from '@elementor/icons';\nimport { __ } from '@wordpress/i18n';\n\nimport { ColorVariablesSelection } from '../components/color-variables-selection';\nimport { supportsColorVariables } from '../utils';\n\nexport const usePropColorVariableAction = (): PopoverActionProps => {\n\tconst { propType } = useBoundProp();\n\n\tconst visible = !! propType && supportsColorVariables( propType );\n\n\treturn {\n\t\tvisible,\n\t\ticon: ColorFilterIcon,\n\t\ttitle: __( 'Variables', 'elementor' ),\n\t\tpopoverContent: ( { closePopover } ) => <ColorVariablesSelection onSelect={ closePopover } />,\n\t};\n};\n","import { createPropUtils } from '@elementor/editor-props';\nimport { z } from '@elementor/schema';\n\nexport const fontVariablePropTypeUtil = createPropUtils( 'global-font-variable', z.string() );\n","import { type PropType, type PropValue } from '@elementor/editor-props';\n\nimport { colorVariablePropTypeUtil } from './prop-types/color-variable-prop-type';\nimport { fontVariablePropTypeUtil } from './prop-types/font-variable-prop-type';\n\nexport const hasAssignedColorVariable = ( propValue: PropValue ): boolean => {\n\treturn !! colorVariablePropTypeUtil.isValid( propValue );\n};\n\nexport const supportsColorVariables = ( propType: PropType ): boolean => {\n\treturn propType.kind === 'union' && colorVariablePropTypeUtil.key in propType.prop_types;\n};\n\nexport const hasAssignedFontVariable = ( propValue: PropValue ): boolean => {\n\treturn !! fontVariablePropTypeUtil.isValid( propValue );\n};\n\nexport const supportsFontVariables = ( propType: PropType ): boolean => {\n\treturn propType.kind === 'union' && fontVariablePropTypeUtil.key in propType.prop_types;\n};\n","import { createTransformer } from '@elementor/editor-canvas';\n\nexport const variableTransformer = createTransformer( ( value: string ) => {\n\tif ( ! value.trim() ) {\n\t\treturn null;\n\t}\n\n\treturn `var(--${ value })`;\n} );\n","import { styleTransformersRegistry } from '@elementor/editor-canvas';\nimport { controlActionsMenu, registerControlReplacement } from '@elementor/editor-editing-panel';\n\nimport { FontVariablesSelectionControl } from './controls/font-variables-selection-control';\nimport { usePropFontVariableAction } from './hooks/use-prop-font-variable-action';\nimport { fontVariablePropTypeUtil } from './prop-types/font-variable-prop-type';\nimport { variableTransformer } from './transformers/variable-transformer';\nimport { hasAssignedFontVariable } from './utils';\n\nconst { registerPopoverAction } = controlActionsMenu;\n\nexport function initFontVariables() {\n\tregisterControlReplacement( {\n\t\tcomponent: FontVariablesSelectionControl,\n\t\tcondition: ( { value } ) => hasAssignedFontVariable( value ),\n\t} );\n\n\tregisterPopoverAction( {\n\t\tid: 'font-variables',\n\t\tuseProps: usePropFontVariableAction,\n\t} );\n\n\tstyleTransformersRegistry.register( fontVariablePropTypeUtil.key, variableTransformer );\n}\n","import * as React from 'react';\nimport { useBoundProp } from '@elementor/editor-controls';\nimport { stringPropTypeUtil } from '@elementor/editor-props';\n\nimport { FontVariablesSelection } from '../components/font-variables-selection';\nimport { VariablesSelectionPopover } from '../components/variables-selection-popover';\nimport { useVariable } from '../hooks/use-prop-variables';\nimport { fontVariablePropTypeUtil } from '../prop-types/font-variable-prop-type';\n\nexport const FontVariablesSelectionControl = () => {\n\tconst { setValue: setFontFamily } = useBoundProp();\n\tconst { value: variableValue } = useBoundProp( fontVariablePropTypeUtil );\n\n\tconst selectedVariable = useVariable( variableValue );\n\n\tif ( ! selectedVariable ) {\n\t\tthrow new Error( `Global font variable ${ variableValue } not found` );\n\t}\n\n\tconst unlinkVariable = () => {\n\t\tsetFontFamily( stringPropTypeUtil.create( selectedVariable.value ) );\n\t};\n\n\treturn (\n\t\t<VariablesSelectionPopover selectedVariable={ selectedVariable } unlinkVariable={ unlinkVariable }>\n\t\t\t{ ( { closePopover } ) => <FontVariablesSelection onSelect={ closePopover } /> }\n\t\t</VariablesSelectionPopover>\n\t);\n};\n","import * as React from 'react';\nimport { Fragment } from 'react';\nimport { useBoundProp } from '@elementor/editor-controls';\nimport { EditIcon, TextIcon } from '@elementor/icons';\nimport { Box, Divider, ListItemIcon, ListItemText, MenuList } from '@elementor/ui';\n\nimport { usePropVariables } from '../hooks/use-prop-variables';\nimport { fontVariablePropTypeUtil } from '../prop-types/font-variable-prop-type';\nimport { type VariableKey } from '../types';\nimport { StyledMenuItem } from './styled-menu-item';\n\ntype Props = {\n\tonSelect?: () => void;\n};\n\nexport const FontVariablesSelection = ( { onSelect }: Props ) => {\n\tconst { value: variable, setValue: setVariable } = useBoundProp( fontVariablePropTypeUtil );\n\n\tconst variables = usePropVariables( fontVariablePropTypeUtil.key );\n\n\tconst handleSetVariable = ( key: VariableKey ) => {\n\t\tsetVariable( key );\n\n\t\tonSelect?.();\n\t};\n\n\treturn (\n\t\t<Fragment>\n\t\t\t<Divider />\n\t\t\t<Box sx={ { overflowY: 'auto', height: 260, width: 220 } }>\n\t\t\t\t<MenuList role=\"listbox\" tabIndex={ 0 }>\n\t\t\t\t\t{ variables.map( ( { value, label, key } ) => (\n\t\t\t\t\t\t<StyledMenuItem\n\t\t\t\t\t\t\tkey={ key }\n\t\t\t\t\t\t\tonClick={ () => handleSetVariable( key ) }\n\t\t\t\t\t\t\tselected={ key === variable }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<ListItemIcon>\n\t\t\t\t\t\t\t\t<TextIcon />\n\t\t\t\t\t\t\t</ListItemIcon>\n\t\t\t\t\t\t\t<ListItemText\n\t\t\t\t\t\t\t\tprimary={ label }\n\t\t\t\t\t\t\t\tsecondary={ value }\n\t\t\t\t\t\t\t\tprimaryTypographyProps={ {\n\t\t\t\t\t\t\t\t\tvariant: 'body2',\n\t\t\t\t\t\t\t\t\tcolor: 'text.secondary',\n\t\t\t\t\t\t\t\t\tstyle: {\n\t\t\t\t\t\t\t\t\t\tlineHeight: 2,\n\t\t\t\t\t\t\t\t\t\tdisplay: 'inline-block',\n\t\t\t\t\t\t\t\t\t\toverflow: 'hidden',\n\t\t\t\t\t\t\t\t\t\ttextOverflow: 'ellipsis',\n\t\t\t\t\t\t\t\t\t\twhiteSpace: 'nowrap',\n\t\t\t\t\t\t\t\t\t\tmaxWidth: '81px',\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t\tsecondaryTypographyProps={ {\n\t\t\t\t\t\t\t\t\tvariant: 'caption',\n\t\t\t\t\t\t\t\t\tcolor: 'text.tertiary',\n\t\t\t\t\t\t\t\t\tstyle: { marginTop: '1px', lineHeight: '1' },\n\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t\tsx={ { display: 'flex', alignItems: 'center', gap: 1 } }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t<EditIcon color=\"action\" fontSize=\"inherit\" sx={ { mx: 1, opacity: '0' } } />\n\t\t\t\t\t\t</StyledMenuItem>\n\t\t\t\t\t) ) }\n\t\t\t\t</MenuList>\n\t\t\t</Box>\n\t\t</Fragment>\n\t);\n};\n","import * as React from 'react';\nimport { type PopoverActionProps, useBoundProp } from '@elementor/editor-editing-panel';\nimport { ColorFilterIcon } from '@elementor/icons';\nimport { __ } from '@wordpress/i18n';\n\nimport { FontVariablesSelection } from '../components/font-variables-selection';\nimport { supportsFontVariables } from '../utils';\n\nexport const usePropFontVariableAction = (): PopoverActionProps => {\n\tconst { propType } = useBoundProp();\n\n\tconst visible = !! propType && supportsFontVariables( propType );\n\n\treturn {\n\t\tvisible,\n\t\ticon: ColorFilterIcon,\n\t\ttitle: __( 'Variables', 'elementor' ),\n\t\tpopoverContent: ( { closePopover } ) => <FontVariablesSelection onSelect={ closePopover } />,\n\t};\n};\n","import * as React from 'react';\nimport { useEffect, useState } from 'react';\nimport { __privateUseListenTo as useListenTo, commandEndEvent } from '@elementor/editor-v1-adapters';\nimport { Portal } from '@elementor/ui';\n\nimport { styleVariablesRepository } from '../style-variables-repository';\nimport { getCanvasIframeDocument } from '../sync/get-canvas-iframe-document';\nimport { type StyleVariables } from '../types';\n\nconst VARIABLES_WRAPPER = 'body';\n\nexport function StyleVariablesRenderer() {\n\tconst container = usePortalContainer();\n\tconst styleVariables = useStyleVariables();\n\n\tconst hasVariables = Object.keys( styleVariables ).length > 0;\n\n\tif ( ! container || ! hasVariables ) {\n\t\treturn null;\n\t}\n\n\tconst cssVariables = convertToCssVariables( styleVariables );\n\tconst wrappedCss = `${ VARIABLES_WRAPPER }{${ cssVariables }}`;\n\n\treturn (\n\t\t<Portal container={ container }>\n\t\t\t<style data-e-style-id=\"e-variables\" key={ wrappedCss }>\n\t\t\t\t{ wrappedCss }\n\t\t\t</style>\n\t\t</Portal>\n\t);\n}\n\nfunction usePortalContainer() {\n\treturn useListenTo( commandEndEvent( 'editor/documents/attach-preview' ), () => getCanvasIframeDocument()?.head );\n}\n\nfunction useStyleVariables() {\n\tconst [ variables, setVariables ] = useState< StyleVariables >( {} );\n\n\tuseEffect( () => {\n\t\tconst unsubscribe = styleVariablesRepository.subscribe( setVariables );\n\n\t\treturn () => {\n\t\t\tunsubscribe();\n\t\t};\n\t}, [] );\n\n\treturn variables;\n}\n\nfunction convertToCssVariables( variables: StyleVariables ): string {\n\treturn Object.entries( variables )\n\t\t.map( ( [ key, value ] ) => `--${ key }:${ value };` )\n\t\t.join( '' );\n}\n","import type { CanvasExtendedWindow } from './types';\n\nexport function getCanvasIframeDocument() {\n\tconst extendedWindow = window as unknown as CanvasExtendedWindow;\n\n\treturn extendedWindow.elementor?.$preview?.[ 0 ]?.contentDocument;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,oBAA8B;;;ACA9B,IAAAA,wBAA0C;AAC1C,IAAAC,+BAA+D;;;ACD/D,IAAAC,SAAuB;AACvB,IAAAC,0BAA6B;AAC7B,IAAAC,uBAAkC;;;ACFlC,gBAA+C;AAExC,IAAM,qBAAiB,kBAAQ,gCAAuB,EAAG,CAAE,EAAE,MAAM,OAAS;AAAA,EAClF,cAAc,GAAI,MAAM,MAAM,eAAe,CAAE;AAChD,EAAI;;;ACJJ,YAAuB;AACvB,IAAAC,gBAAyB;AACzB,6BAA6B;AAC7B,mBAAyB;AACzB,IA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AACpC,WAAO;AAAA,EACR;AAEA,QAAM,eAAe,sBAAuB,cAAe;AAC3D,QAAM,aAAa,GAAI,iBAAkB,IAAK,YAAa;AAE3D,SACC,qCAAC,qBAAO,aACP,qCAAC,WAAM,mBAAgB,eAAc,KAAM,cACxC,UACH,CACD;AAEF;AAEA,SAAS,qBAAqB;AAC7B,aAAO,0BAAAC,0BAAa,2CAAiB,iCAAkC,GAAG,MAAM,wBAAwB,GAAG,IAAK;AACjH;AAEA,SAAS,oBAAoB;AAC5B,QAAM,CAAEC,YAAW,YAAa,QAAI,wBAA4B,CAAC,CAAE;AAEnE,+BAAW,MAAM;AAChB,UAAM,cAAc,yBAAyB,UAAW,YAAa;AAErE,WAAO,MAAM;AACZ,kBAAY;AAAA,IACb;AAAA,EACD,GAAG,CAAC,CAAE;AAEN,SAAOA;AACR;AAEA,SAAS,sBAAuBA,YAAoC;AACnE,SAAO,OAAO,QAASA,UAAU,EAC/B,IAAK,CAAE,CAAE,KAAK,KAAM,MAAO,KAAM,GAAI,IAAK,KAAM,GAAI,EACpD,KAAM,EAAG;AACZ;;;ApBjDO,SAAS,OAAO;AACtB,qBAAmB;AAEnB,oBAAkB;AAElB,mCAAe;AAAA,IACd,IAAI;AAAA,IACJ,WAAW;AAAA,EACZ,CAAE;AACH;","names":["import_editor_canvas","import_editor_editing_panel","React","import_editor_controls","import_editor_props","import_react","import_ui","variables","import_ui","variables","React","import_react","import_icons","import_ui","import_i18n","React","import_react","import_editor_controls","import_icons","import_ui","Tag","React","import_icons","import_i18n","import_editor_props","import_schema","import_editor_canvas","import_editor_editing_panel","React","import_editor_controls","import_editor_props","React","import_react","import_editor_controls","import_icons","import_ui","variables","React","import_editor_editing_panel","import_icons","import_i18n","registerPopoverAction","React","import_react","import_ui","useListenTo","variables"]}
|
package/dist/index.mjs
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
// src/init.ts
|
|
2
|
+
import { injectIntoTop } from "@elementor/editor";
|
|
3
|
+
|
|
1
4
|
// src/init-color-variables.ts
|
|
2
5
|
import { styleTransformersRegistry } from "@elementor/editor-canvas";
|
|
3
6
|
import { controlActionsMenu, registerControlReplacement } from "@elementor/editor-editing-panel";
|
|
@@ -22,39 +25,82 @@ import { Box, Divider, ListItemIcon, ListItemText, MenuList } from "@elementor/u
|
|
|
22
25
|
|
|
23
26
|
// src/hooks/use-prop-variables.ts
|
|
24
27
|
import { useMemo } from "react";
|
|
25
|
-
|
|
26
|
-
|
|
28
|
+
|
|
29
|
+
// src/create-style-variables-repository.ts
|
|
30
|
+
var createStyleVariablesRepository = () => {
|
|
31
|
+
const variables2 = {};
|
|
32
|
+
let subscription;
|
|
33
|
+
const subscribe = (cb) => {
|
|
34
|
+
subscription = cb;
|
|
35
|
+
return () => {
|
|
36
|
+
subscription = () => {
|
|
37
|
+
};
|
|
38
|
+
};
|
|
39
|
+
};
|
|
40
|
+
const notify = () => {
|
|
41
|
+
if (typeof subscription === "function") {
|
|
42
|
+
subscription({ ...variables2 });
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
const shouldUpdate = (key, newValue) => {
|
|
46
|
+
return !(key in variables2) || variables2[key] !== newValue;
|
|
47
|
+
};
|
|
48
|
+
const applyUpdates = (updatedVars) => {
|
|
49
|
+
let hasChanges = false;
|
|
50
|
+
for (const [key, { value }] of Object.entries(updatedVars)) {
|
|
51
|
+
if (shouldUpdate(key, value)) {
|
|
52
|
+
variables2[key] = value;
|
|
53
|
+
hasChanges = true;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
return hasChanges;
|
|
57
|
+
};
|
|
58
|
+
const update = (updatedVars) => {
|
|
59
|
+
if (applyUpdates(updatedVars)) {
|
|
60
|
+
notify();
|
|
61
|
+
}
|
|
62
|
+
};
|
|
63
|
+
return {
|
|
64
|
+
subscribe,
|
|
65
|
+
update
|
|
66
|
+
};
|
|
27
67
|
};
|
|
28
|
-
|
|
29
|
-
|
|
68
|
+
|
|
69
|
+
// src/style-variables-repository.ts
|
|
70
|
+
var styleVariablesRepository = createStyleVariablesRepository();
|
|
71
|
+
|
|
72
|
+
// src/hooks/use-prop-variables.ts
|
|
73
|
+
var usePropVariables = (propKey) => {
|
|
74
|
+
return useMemo(() => normalizeVariables(propKey), [propKey]);
|
|
75
|
+
};
|
|
76
|
+
var useVariable = (key) => {
|
|
77
|
+
if (!variables?.[key]) {
|
|
30
78
|
return null;
|
|
31
79
|
}
|
|
32
80
|
return {
|
|
33
|
-
...variables[
|
|
81
|
+
...variables[key],
|
|
34
82
|
key
|
|
35
83
|
};
|
|
36
84
|
};
|
|
37
|
-
var normalizeVariables = (
|
|
38
|
-
return Object.entries(variables[
|
|
85
|
+
var normalizeVariables = (propKey) => {
|
|
86
|
+
return Object.entries(variables).filter(([, { type }]) => type === propKey).map(([key, { label, value }]) => ({
|
|
39
87
|
key,
|
|
40
88
|
label,
|
|
41
89
|
value
|
|
42
90
|
}));
|
|
43
91
|
};
|
|
44
|
-
var createVariable = (
|
|
45
|
-
const id = generateId(
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
};
|
|
51
|
-
variables[propTypeKey][id] = newVariable || {};
|
|
92
|
+
var createVariable = (variable) => {
|
|
93
|
+
const id = generateId();
|
|
94
|
+
variables[id] = variable;
|
|
95
|
+
styleVariablesRepository.update({
|
|
96
|
+
[id]: variable
|
|
97
|
+
});
|
|
52
98
|
return id;
|
|
53
99
|
};
|
|
54
100
|
var variables = window?.ElementorV4Variables || {};
|
|
55
|
-
var generateId = (prefix
|
|
101
|
+
var generateId = (prefix = "e-gv") => {
|
|
56
102
|
const randomHex = Math.random().toString(16).slice(2, 9);
|
|
57
|
-
return `${prefix}${randomHex}
|
|
103
|
+
return `${prefix}${randomHex}`;
|
|
58
104
|
};
|
|
59
105
|
|
|
60
106
|
// src/prop-types/color-variable-prop-type.ts
|
|
@@ -77,15 +123,15 @@ var StyledMenuItem = styled2(MenuItem)(() => ({
|
|
|
77
123
|
var ColorVariablesSelection = ({ onSelect }) => {
|
|
78
124
|
const { value: variable, setValue: setVariable } = useBoundProp(colorVariablePropTypeUtil);
|
|
79
125
|
const variables2 = usePropVariables(colorVariablePropTypeUtil.key);
|
|
80
|
-
const handleSetColorVariable = (
|
|
81
|
-
setVariable(
|
|
126
|
+
const handleSetColorVariable = (key) => {
|
|
127
|
+
setVariable(key);
|
|
82
128
|
onSelect?.();
|
|
83
129
|
};
|
|
84
130
|
return /* @__PURE__ */ React.createElement(Fragment, null, /* @__PURE__ */ React.createElement(Divider, null), /* @__PURE__ */ React.createElement(Box, { sx: { overflowY: "auto", height: 260, width: 220 } }, /* @__PURE__ */ React.createElement(MenuList, { role: "listbox", tabIndex: 0 }, variables2.map(({ value, label, key }) => /* @__PURE__ */ React.createElement(
|
|
85
131
|
StyledMenuItem,
|
|
86
132
|
{
|
|
87
133
|
key,
|
|
88
|
-
onClick: () => handleSetColorVariable(
|
|
134
|
+
onClick: () => handleSetColorVariable(key),
|
|
89
135
|
selected: key === variable
|
|
90
136
|
},
|
|
91
137
|
/* @__PURE__ */ React.createElement(ListItemIcon, null, /* @__PURE__ */ React.createElement(ColorIndicator, { size: "inherit", component: "span", value })),
|
|
@@ -171,7 +217,11 @@ var ColorVariableCreation = ({ popupState }) => {
|
|
|
171
217
|
popupState.close();
|
|
172
218
|
};
|
|
173
219
|
const handleCreate = () => {
|
|
174
|
-
const key = createVariable(
|
|
220
|
+
const key = createVariable({
|
|
221
|
+
value: color,
|
|
222
|
+
label,
|
|
223
|
+
type: colorVariablePropTypeUtil.key
|
|
224
|
+
});
|
|
175
225
|
setVariable(key);
|
|
176
226
|
closePopover();
|
|
177
227
|
};
|
|
@@ -276,7 +326,7 @@ var VariablesSelectionPopover = ({
|
|
|
276
326
|
var ColorVariablesSelectionControl = () => {
|
|
277
327
|
const { setValue } = useBoundProp3();
|
|
278
328
|
const { value: variableValue } = useBoundProp3(colorVariablePropTypeUtil);
|
|
279
|
-
const selectedVariable = useVariable(
|
|
329
|
+
const selectedVariable = useVariable(variableValue);
|
|
280
330
|
if (!selectedVariable) {
|
|
281
331
|
throw new Error(`Global color variable ${variableValue} not found`);
|
|
282
332
|
}
|
|
@@ -372,15 +422,15 @@ import { Box as Box4, Divider as Divider3, ListItemIcon as ListItemIcon2, ListIt
|
|
|
372
422
|
var FontVariablesSelection = ({ onSelect }) => {
|
|
373
423
|
const { value: variable, setValue: setVariable } = useBoundProp5(fontVariablePropTypeUtil);
|
|
374
424
|
const variables2 = usePropVariables(fontVariablePropTypeUtil.key);
|
|
375
|
-
const handleSetVariable = (
|
|
376
|
-
setVariable(
|
|
425
|
+
const handleSetVariable = (key) => {
|
|
426
|
+
setVariable(key);
|
|
377
427
|
onSelect?.();
|
|
378
428
|
};
|
|
379
429
|
return /* @__PURE__ */ React6.createElement(Fragment2, null, /* @__PURE__ */ React6.createElement(Divider3, null), /* @__PURE__ */ React6.createElement(Box4, { sx: { overflowY: "auto", height: 260, width: 220 } }, /* @__PURE__ */ React6.createElement(MenuList2, { role: "listbox", tabIndex: 0 }, variables2.map(({ value, label, key }) => /* @__PURE__ */ React6.createElement(
|
|
380
430
|
StyledMenuItem,
|
|
381
431
|
{
|
|
382
432
|
key,
|
|
383
|
-
onClick: () => handleSetVariable(
|
|
433
|
+
onClick: () => handleSetVariable(key),
|
|
384
434
|
selected: key === variable
|
|
385
435
|
},
|
|
386
436
|
/* @__PURE__ */ React6.createElement(ListItemIcon2, null, /* @__PURE__ */ React6.createElement(TextIcon, null)),
|
|
@@ -417,7 +467,7 @@ var FontVariablesSelection = ({ onSelect }) => {
|
|
|
417
467
|
var FontVariablesSelectionControl = () => {
|
|
418
468
|
const { setValue: setFontFamily } = useBoundProp6();
|
|
419
469
|
const { value: variableValue } = useBoundProp6(fontVariablePropTypeUtil);
|
|
420
|
-
const selectedVariable = useVariable(
|
|
470
|
+
const selectedVariable = useVariable(variableValue);
|
|
421
471
|
if (!selectedVariable) {
|
|
422
472
|
throw new Error(`Global font variable ${variableValue} not found`);
|
|
423
473
|
}
|
|
@@ -457,10 +507,56 @@ function initFontVariables() {
|
|
|
457
507
|
styleTransformersRegistry2.register(fontVariablePropTypeUtil.key, variableTransformer);
|
|
458
508
|
}
|
|
459
509
|
|
|
510
|
+
// src/renderers/style-variables-renderer.tsx
|
|
511
|
+
import * as React9 from "react";
|
|
512
|
+
import { useEffect, useState as useState2 } from "react";
|
|
513
|
+
import { __privateUseListenTo as useListenTo, commandEndEvent } from "@elementor/editor-v1-adapters";
|
|
514
|
+
import { Portal } from "@elementor/ui";
|
|
515
|
+
|
|
516
|
+
// src/sync/get-canvas-iframe-document.ts
|
|
517
|
+
function getCanvasIframeDocument() {
|
|
518
|
+
const extendedWindow = window;
|
|
519
|
+
return extendedWindow.elementor?.$preview?.[0]?.contentDocument;
|
|
520
|
+
}
|
|
521
|
+
|
|
522
|
+
// src/renderers/style-variables-renderer.tsx
|
|
523
|
+
var VARIABLES_WRAPPER = "body";
|
|
524
|
+
function StyleVariablesRenderer() {
|
|
525
|
+
const container = usePortalContainer();
|
|
526
|
+
const styleVariables = useStyleVariables();
|
|
527
|
+
const hasVariables = Object.keys(styleVariables).length > 0;
|
|
528
|
+
if (!container || !hasVariables) {
|
|
529
|
+
return null;
|
|
530
|
+
}
|
|
531
|
+
const cssVariables = convertToCssVariables(styleVariables);
|
|
532
|
+
const wrappedCss = `${VARIABLES_WRAPPER}{${cssVariables}}`;
|
|
533
|
+
return /* @__PURE__ */ React9.createElement(Portal, { container }, /* @__PURE__ */ React9.createElement("style", { "data-e-style-id": "e-variables", key: wrappedCss }, wrappedCss));
|
|
534
|
+
}
|
|
535
|
+
function usePortalContainer() {
|
|
536
|
+
return useListenTo(commandEndEvent("editor/documents/attach-preview"), () => getCanvasIframeDocument()?.head);
|
|
537
|
+
}
|
|
538
|
+
function useStyleVariables() {
|
|
539
|
+
const [variables2, setVariables] = useState2({});
|
|
540
|
+
useEffect(() => {
|
|
541
|
+
const unsubscribe = styleVariablesRepository.subscribe(setVariables);
|
|
542
|
+
return () => {
|
|
543
|
+
unsubscribe();
|
|
544
|
+
};
|
|
545
|
+
}, []);
|
|
546
|
+
return variables2;
|
|
547
|
+
}
|
|
548
|
+
function convertToCssVariables(variables2) {
|
|
549
|
+
return Object.entries(variables2).map(([key, value]) => `--${key}:${value};`).join("");
|
|
550
|
+
}
|
|
551
|
+
|
|
460
552
|
// src/init.ts
|
|
461
553
|
function init() {
|
|
462
554
|
initColorVariables();
|
|
463
555
|
initFontVariables();
|
|
556
|
+
injectIntoTop({
|
|
557
|
+
id: "canvas-style-variables-render",
|
|
558
|
+
component: StyleVariablesRenderer
|
|
559
|
+
});
|
|
464
560
|
}
|
|
465
561
|
export {
|
|
466
562
|
init
|
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/init-color-variables.ts","../src/controls/color-variables-selection-control.tsx","../src/components/color-indicator.tsx","../src/components/color-variables-selection.tsx","../src/hooks/use-prop-variables.ts","../src/prop-types/color-variable-prop-type.ts","../src/components/styled-menu-item.tsx","../src/components/variables-selection-popover.tsx","../src/components/color-variable-creation.tsx","../src/hooks/use-prop-color-variable-action.tsx","../src/prop-types/font-variable-prop-type.ts","../src/utils.ts","../src/transformers/variable-transformer.ts","../src/init-font-variables.ts","../src/controls/font-variables-selection-control.tsx","../src/components/font-variables-selection.tsx","../src/hooks/use-prop-font-variable-action.tsx","../src/init.ts"],"sourcesContent":["import { styleTransformersRegistry } from '@elementor/editor-canvas';\nimport { controlActionsMenu, registerControlReplacement } from '@elementor/editor-editing-panel';\n\nimport { ColorVariablesSelectionControl } from './controls/color-variables-selection-control';\nimport { usePropColorVariableAction } from './hooks/use-prop-color-variable-action';\nimport { colorVariablePropTypeUtil } from './prop-types/color-variable-prop-type';\nimport { variableTransformer } from './transformers/variable-transformer';\nimport { hasAssignedColorVariable } from './utils';\n\nconst { registerPopoverAction } = controlActionsMenu;\n\nexport function initColorVariables() {\n\tregisterControlReplacement( {\n\t\tcomponent: ColorVariablesSelectionControl,\n\t\tcondition: ( { value } ) => hasAssignedColorVariable( value ),\n\t} );\n\n\tregisterPopoverAction( {\n\t\tid: 'color-variables',\n\t\tuseProps: usePropColorVariableAction,\n\t} );\n\n\tstyleTransformersRegistry.register( colorVariablePropTypeUtil.key, variableTransformer );\n}\n","import * as React from 'react';\nimport { useBoundProp } from '@elementor/editor-controls';\nimport { colorPropTypeUtil } from '@elementor/editor-props';\n\nimport { ColorIndicator } from '../components/color-indicator';\nimport { ColorVariablesSelection } from '../components/color-variables-selection';\nimport { VariablesSelectionPopover } from '../components/variables-selection-popover';\nimport { useVariable } from '../hooks/use-prop-variables';\nimport { colorVariablePropTypeUtil } from '../prop-types/color-variable-prop-type';\n\nexport const ColorVariablesSelectionControl = () => {\n\tconst { setValue } = useBoundProp();\n\tconst { value: variableValue } = useBoundProp( colorVariablePropTypeUtil );\n\n\tconst selectedVariable = useVariable( colorVariablePropTypeUtil.key, variableValue );\n\n\tif ( ! selectedVariable ) {\n\t\tthrow new Error( `Global color variable ${ variableValue } not found` );\n\t}\n\n\tconst unlinkVariable = () => {\n\t\tsetValue( colorPropTypeUtil.create( selectedVariable.value ) );\n\t};\n\n\treturn (\n\t\t<VariablesSelectionPopover\n\t\t\tselectedVariable={ selectedVariable }\n\t\t\tunlinkVariable={ unlinkVariable }\n\t\t\tstartTagAdornment={ <ColorIndicator size=\"inherit\" component=\"span\" value={ selectedVariable.value } /> }\n\t\t>\n\t\t\t{ ( { closePopover } ) => <ColorVariablesSelection onSelect={ closePopover } /> }\n\t\t</VariablesSelectionPopover>\n\t);\n};\n","import { styled, UnstableColorIndicator } from '@elementor/ui';\n\nexport const ColorIndicator = styled( UnstableColorIndicator )( ( { theme } ) => ( {\n\tborderRadius: `${ theme.shape.borderRadius / 2 }px`,\n} ) );\n","import * as React from 'react';\nimport { Fragment } from 'react';\nimport { useBoundProp } from '@elementor/editor-controls';\nimport { EditIcon } from '@elementor/icons';\nimport { Box, Divider, ListItemIcon, ListItemText, MenuList } from '@elementor/ui';\n\nimport { usePropVariables } from '../hooks/use-prop-variables';\nimport { colorVariablePropTypeUtil } from '../prop-types/color-variable-prop-type';\nimport { type Variable } from '../types';\nimport { ColorIndicator } from './color-indicator';\nimport { StyledMenuItem } from './styled-menu-item';\n\ntype Props = {\n\tonSelect?: () => void;\n};\n\nexport const ColorVariablesSelection = ( { onSelect }: Props ) => {\n\tconst { value: variable, setValue: setVariable } = useBoundProp( colorVariablePropTypeUtil );\n\n\tconst variables = usePropVariables( colorVariablePropTypeUtil.key );\n\n\tconst handleSetColorVariable = ( newValue: Variable ) => {\n\t\tsetVariable( newValue.key );\n\n\t\tonSelect?.();\n\t};\n\n\treturn (\n\t\t<Fragment>\n\t\t\t<Divider />\n\t\t\t<Box sx={ { overflowY: 'auto', height: 260, width: 220 } }>\n\t\t\t\t<MenuList role=\"listbox\" tabIndex={ 0 }>\n\t\t\t\t\t{ variables.map( ( { value, label, key } ) => (\n\t\t\t\t\t\t<StyledMenuItem\n\t\t\t\t\t\t\tkey={ key }\n\t\t\t\t\t\t\tonClick={ () => handleSetColorVariable( { value, label, key } ) }\n\t\t\t\t\t\t\tselected={ key === variable }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<ListItemIcon>\n\t\t\t\t\t\t\t\t<ColorIndicator size=\"inherit\" component=\"span\" value={ value } />\n\t\t\t\t\t\t\t</ListItemIcon>\n\t\t\t\t\t\t\t<ListItemText\n\t\t\t\t\t\t\t\tprimary={ label }\n\t\t\t\t\t\t\t\tsecondary={ value }\n\t\t\t\t\t\t\t\tprimaryTypographyProps={ {\n\t\t\t\t\t\t\t\t\tvariant: 'body2',\n\t\t\t\t\t\t\t\t\tcolor: 'text.secondary',\n\t\t\t\t\t\t\t\t\tstyle: {\n\t\t\t\t\t\t\t\t\t\tlineHeight: 2,\n\t\t\t\t\t\t\t\t\t\tdisplay: 'inline-block',\n\t\t\t\t\t\t\t\t\t\toverflow: 'hidden',\n\t\t\t\t\t\t\t\t\t\ttextOverflow: 'ellipsis',\n\t\t\t\t\t\t\t\t\t\twhiteSpace: 'nowrap',\n\t\t\t\t\t\t\t\t\t\tmaxWidth: '81px',\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t\tsecondaryTypographyProps={ {\n\t\t\t\t\t\t\t\t\tvariant: 'caption',\n\t\t\t\t\t\t\t\t\tcolor: 'text.tertiary',\n\t\t\t\t\t\t\t\t\tstyle: { marginTop: '1px', lineHeight: '1' },\n\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t\tsx={ { display: 'flex', alignItems: 'center', gap: 1 } }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t<EditIcon color=\"action\" fontSize=\"inherit\" sx={ { mx: 1, opacity: '0' } } />\n\t\t\t\t\t\t</StyledMenuItem>\n\t\t\t\t\t) ) }\n\t\t\t\t</MenuList>\n\t\t\t</Box>\n\t\t</Fragment>\n\t);\n};\n","import { useMemo } from 'react';\n\nimport { type Variable } from '../types';\n\ntype VariableData = {\n\tvalue: string;\n\tlabel: string;\n};\ntype Variables = Record< string, VariableData >;\n\ntype VariablesGroup = Record< string, Variables >;\n\nexport const usePropVariables = ( propTypeKey: string ) => {\n\treturn useMemo( () => normalizeVariables( propTypeKey ), [ propTypeKey ] );\n};\n\nexport const useVariable = ( propTypeKey: string, key: string ) => {\n\tif ( ! variables[ propTypeKey ]?.[ key ] ) {\n\t\treturn null;\n\t}\n\n\treturn {\n\t\t...variables[ propTypeKey ][ key ],\n\t\tkey,\n\t};\n};\n\nconst normalizeVariables = ( propTypeKey: string ) => {\n\treturn Object.entries( variables[ propTypeKey ] || {} ).map( ( [ key, { label, value } ] ) => ( {\n\t\tkey,\n\t\tlabel,\n\t\tvalue,\n\t} ) );\n};\n\nexport const createVariable = ( propTypeKey: string, variable: VariableData ) => {\n\tconst id = generateId( 'e-gv', Object.keys( variables[ propTypeKey ] ).length );\n\n\tconst newVariable: Variable = {\n\t\tvalue: variable.value,\n\t\tlabel: variable.label,\n\t\tkey: propTypeKey,\n\t};\n\n\tvariables[ propTypeKey ][ id ] = newVariable || {};\n\n\treturn id;\n};\n\n// @ts-expect-error the temporary solution to get the list of variables from the server\nconst variables: VariablesGroup = window?.ElementorV4Variables || {};\n\nconst generateId = ( prefix: string, variablesCount: number ) => {\n\tconst randomHex = Math.random().toString( 16 ).slice( 2, 9 );\n\n\treturn `${ prefix }${ randomHex }${ variablesCount }`;\n};\n","import { createPropUtils } from '@elementor/editor-props';\nimport { z } from '@elementor/schema';\n\nexport const colorVariablePropTypeUtil = createPropUtils( 'global-color-variable', z.string() );\n","import { MenuItem, styled } from '@elementor/ui';\n\nexport const StyledMenuItem = styled( MenuItem )( () => ( {\n\tpl: 2,\n\tpr: 1,\n\tpy: 0.5,\n\t'&:hover .MuiSvgIcon-root': {\n\t\topacity: 1,\n\t},\n} ) );\n","import * as React from 'react';\nimport { useId, useRef } from 'react';\nimport { ColorFilterIcon, DetachIcon, PlusIcon } from '@elementor/icons';\nimport {\n\tbindPopover,\n\tbindTrigger,\n\tBox,\n\tCloseButton,\n\tIconButton,\n\tPopover,\n\tStack,\n\tTypography,\n\tUnstableTag as Tag,\n\tusePopupState,\n} from '@elementor/ui';\nimport { __ } from '@wordpress/i18n';\n\nimport { type Variable } from '../types';\nimport { ColorVariableCreation } from './color-variable-creation';\n\ntype Props = {\n\tselectedVariable: Variable;\n\tunlinkVariable: () => void;\n\tchildren: ( { closePopover }: { closePopover: () => void } ) => React.ReactNode;\n\tstartTagAdornment?: React.ReactNode;\n};\n\nexport const VariablesSelectionPopover = ( {\n\tselectedVariable,\n\tunlinkVariable,\n\tstartTagAdornment,\n\tchildren,\n}: Props ) => {\n\tconst id = useId();\n\tconst popupState = usePopupState( { variant: 'popover', popupId: `elementor-variables-action-${ id }` } );\n\tconst creationPopupState = usePopupState( { variant: 'popover', popupId: `elementor-variables-creation-${ id }` } );\n\n\tconst closePopover = () => popupState.close();\n\n\tconst handleCreateButtonClick = ( event: React.MouseEvent ) => {\n\t\tclosePopover();\n\t\tbindTrigger( creationPopupState ).onClick( event );\n\t};\n\n\tconst anchorRef = useRef< HTMLDivElement >( null );\n\tconst { label } = selectedVariable;\n\n\treturn (\n\t\t<Box ref={ anchorRef }>\n\t\t\t<Tag\n\t\t\t\tfullWidth\n\t\t\t\tshowActionsOnHover\n\t\t\t\t{ ...bindTrigger( popupState ) }\n\t\t\t\tstartIcon={\n\t\t\t\t\t<Stack spacing={ 1 } direction=\"row\" alignItems=\"center\">\n\t\t\t\t\t\t{ startTagAdornment }\n\t\t\t\t\t\t<ColorFilterIcon fontSize={ 'inherit' } sx={ { mr: 1 } } />\n\t\t\t\t\t</Stack>\n\t\t\t\t}\n\t\t\t\tlabel={\n\t\t\t\t\t<Box sx={ { display: 'inline-grid' } }>\n\t\t\t\t\t\t<Typography sx={ { textOverflow: 'ellipsis', overflowX: 'hidden' } } variant=\"subtitle2\">\n\t\t\t\t\t\t\t{ label }\n\t\t\t\t\t\t</Typography>\n\t\t\t\t\t</Box>\n\t\t\t\t}\n\t\t\t\tactions={\n\t\t\t\t\t<IconButton size=\"tiny\" onClick={ unlinkVariable } aria-label={ __( 'Unlink', 'elementor' ) }>\n\t\t\t\t\t\t<DetachIcon fontSize=\"tiny\" />\n\t\t\t\t\t</IconButton>\n\t\t\t\t}\n\t\t\t/>\n\t\t\t<Popover\n\t\t\t\t{ ...bindPopover( popupState ) }\n\t\t\t\tdisableScrollLock\n\t\t\t\tanchorEl={ anchorRef.current }\n\t\t\t\tanchorOrigin={ { vertical: 'bottom', horizontal: 'right' } }\n\t\t\t\ttransformOrigin={ { vertical: 'top', horizontal: 'right' } }\n\t\t\t>\n\t\t\t\t<Stack direction=\"row\" alignItems=\"center\" pl={ 1.5 } pr={ 0.5 } py={ 1.5 }>\n\t\t\t\t\t<ColorFilterIcon fontSize=\"tiny\" sx={ { mr: 0.5 } } />\n\t\t\t\t\t<Typography variant=\"subtitle2\">{ __( 'Variables', 'elementor' ) }</Typography>\n\t\t\t\t\t<Stack direction=\"row\" sx={ { ml: 'auto' } }>\n\t\t\t\t\t\t<IconButton\n\t\t\t\t\t\t\t{ ...bindTrigger( creationPopupState ) }\n\t\t\t\t\t\t\tsize=\"tiny\"\n\t\t\t\t\t\t\tonClick={ handleCreateButtonClick }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<PlusIcon fontSize=\"tiny\" />\n\t\t\t\t\t\t</IconButton>\n\t\t\t\t\t\t<CloseButton slotProps={ { icon: { fontSize: 'tiny' } } } onClick={ closePopover } />\n\t\t\t\t\t</Stack>\n\t\t\t\t</Stack>\n\t\t\t\t{ children?.( { closePopover } ) }\n\t\t\t</Popover>\n\n\t\t\t<ColorVariableCreation popupState={ creationPopupState } />\n\t\t</Box>\n\t);\n};\n","import * as React from 'react';\nimport { useRef, useState } from 'react';\nimport { useBoundProp } from '@elementor/editor-controls';\nimport { BrushIcon } from '@elementor/icons';\nimport {\n\tbindPopover,\n\tBox,\n\tButton,\n\tCardActions,\n\tCloseButton,\n\tDivider,\n\tFormLabel,\n\tGrid,\n\tPopover,\n\ttype PopupState,\n\tStack,\n\tTextField,\n\tTypography,\n\tUnstableColorField,\n} from '@elementor/ui';\nimport { __ } from '@wordpress/i18n';\n\nimport { createVariable } from '../hooks/use-prop-variables';\nimport { colorVariablePropTypeUtil } from '../prop-types/color-variable-prop-type';\n\nexport const ColorVariableCreation = ( { popupState }: { popupState: PopupState } ) => {\n\tconst { setValue: setVariable } = useBoundProp( colorVariablePropTypeUtil );\n\n\tconst [ color, setColor ] = useState( '' );\n\tconst [ label, setLabel ] = useState( '' );\n\n\tconst anchorRef = useRef< HTMLDivElement >( null );\n\n\tconst resetFields = () => {\n\t\tsetColor( '' );\n\t\tsetLabel( '' );\n\t};\n\n\tconst closePopover = () => {\n\t\tresetFields();\n\t\tpopupState.close();\n\t};\n\n\tconst handleCreate = () => {\n\t\tconst key = createVariable( colorVariablePropTypeUtil.key, { label, value: color } );\n\t\tsetVariable( key );\n\t\tclosePopover();\n\t};\n\n\tconst isInValidForm = () => {\n\t\treturn ! color?.trim() || ! label?.trim();\n\t};\n\n\treturn (\n\t\t<Box ref={ anchorRef }>\n\t\t\t<Popover\n\t\t\t\t{ ...bindPopover( popupState ) }\n\t\t\t\tanchorEl={ anchorRef.current }\n\t\t\t\tanchorOrigin={ { vertical: 'bottom', horizontal: 'right' } }\n\t\t\t\ttransformOrigin={ { vertical: 'top', horizontal: 'right' } }\n\t\t\t>\n\t\t\t\t<Stack direction=\"row\" alignItems=\"center\" pl={ 1.5 } pr={ 0.5 } py={ 1.5 }>\n\t\t\t\t\t<BrushIcon fontSize=\"tiny\" sx={ { mr: 0.5 } } />\n\t\t\t\t\t<Typography variant=\"subtitle2\">{ __( 'Create variable', 'elementor' ) }</Typography>\n\t\t\t\t\t<CloseButton\n\t\t\t\t\t\tslotProps={ { icon: { fontSize: 'small' } } }\n\t\t\t\t\t\tsx={ { ml: 'auto' } }\n\t\t\t\t\t\tonClick={ closePopover }\n\t\t\t\t\t/>\n\t\t\t\t</Stack>\n\n\t\t\t\t<Divider />\n\n\t\t\t\t<Stack p={ 1.5 } gap={ 1.5 }>\n\t\t\t\t\t<Grid container gap={ 0.75 } alignItems=\"center\">\n\t\t\t\t\t\t<Grid item xs={ 12 }>\n\t\t\t\t\t\t\t<FormLabel size=\"small\">{ __( 'Name', 'elementor' ) }</FormLabel>\n\t\t\t\t\t\t</Grid>\n\t\t\t\t\t\t<Grid item xs={ 12 }>\n\t\t\t\t\t\t\t<TextField\n\t\t\t\t\t\t\t\tsize=\"tiny\"\n\t\t\t\t\t\t\t\tfullWidth\n\t\t\t\t\t\t\t\tvalue={ label }\n\t\t\t\t\t\t\t\tonChange={ ( e: React.ChangeEvent< HTMLInputElement > ) => setLabel( e.target.value ) }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t</Grid>\n\t\t\t\t\t</Grid>\n\n\t\t\t\t\t<Grid container gap={ 0.75 } alignItems=\"center\">\n\t\t\t\t\t\t<Grid item xs={ 12 }>\n\t\t\t\t\t\t\t<FormLabel size=\"small\">{ __( 'Value', 'elementor' ) }</FormLabel>\n\t\t\t\t\t\t</Grid>\n\t\t\t\t\t\t<Grid item xs={ 12 }>\n\t\t\t\t\t\t\t<UnstableColorField\n\t\t\t\t\t\t\t\tsize=\"tiny\"\n\t\t\t\t\t\t\t\tfullWidth\n\t\t\t\t\t\t\t\tvalue={ color }\n\t\t\t\t\t\t\t\tonChange={ setColor }\n\t\t\t\t\t\t\t\tslotProps={ {\n\t\t\t\t\t\t\t\t\tcolorPicker: {\n\t\t\t\t\t\t\t\t\t\tanchorEl: anchorRef.current,\n\t\t\t\t\t\t\t\t\t\tanchorOrigin: { vertical: 'top', horizontal: 'right' },\n\t\t\t\t\t\t\t\t\t\ttransformOrigin: { vertical: 'top', horizontal: -10 },\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t</Grid>\n\t\t\t\t\t</Grid>\n\t\t\t\t</Stack>\n\n\t\t\t\t<CardActions>\n\t\t\t\t\t<Button size=\"small\" onClick={ closePopover } color=\"secondary\" variant=\"text\">\n\t\t\t\t\t\t{ __( 'Cancel', 'elementor' ) }\n\t\t\t\t\t</Button>\n\t\t\t\t\t<Button size=\"small\" variant=\"contained\" disabled={ isInValidForm() } onClick={ handleCreate }>\n\t\t\t\t\t\t{ __( 'Create', 'elementor' ) }\n\t\t\t\t\t</Button>\n\t\t\t\t</CardActions>\n\t\t\t</Popover>\n\t\t</Box>\n\t);\n};\n","import * as React from 'react';\nimport { type PopoverActionProps, useBoundProp } from '@elementor/editor-editing-panel';\nimport { ColorFilterIcon } from '@elementor/icons';\nimport { __ } from '@wordpress/i18n';\n\nimport { ColorVariablesSelection } from '../components/color-variables-selection';\nimport { supportsColorVariables } from '../utils';\n\nexport const usePropColorVariableAction = (): PopoverActionProps => {\n\tconst { propType } = useBoundProp();\n\n\tconst visible = !! propType && supportsColorVariables( propType );\n\n\treturn {\n\t\tvisible,\n\t\ticon: ColorFilterIcon,\n\t\ttitle: __( 'Variables', 'elementor' ),\n\t\tpopoverContent: ( { closePopover } ) => <ColorVariablesSelection onSelect={ closePopover } />,\n\t};\n};\n","import { createPropUtils } from '@elementor/editor-props';\nimport { z } from '@elementor/schema';\n\nexport const fontVariablePropTypeUtil = createPropUtils( 'global-font-variable', z.string() );\n","import { type PropType, type PropValue } from '@elementor/editor-props';\n\nimport { colorVariablePropTypeUtil } from './prop-types/color-variable-prop-type';\nimport { fontVariablePropTypeUtil } from './prop-types/font-variable-prop-type';\n\nexport const hasAssignedColorVariable = ( propValue: PropValue ): boolean => {\n\treturn !! colorVariablePropTypeUtil.isValid( propValue );\n};\n\nexport const supportsColorVariables = ( propType: PropType ): boolean => {\n\treturn propType.kind === 'union' && colorVariablePropTypeUtil.key in propType.prop_types;\n};\n\nexport const hasAssignedFontVariable = ( propValue: PropValue ): boolean => {\n\treturn !! fontVariablePropTypeUtil.isValid( propValue );\n};\n\nexport const supportsFontVariables = ( propType: PropType ): boolean => {\n\treturn propType.kind === 'union' && fontVariablePropTypeUtil.key in propType.prop_types;\n};\n","import { createTransformer } from '@elementor/editor-canvas';\n\nexport const variableTransformer = createTransformer( ( value: string ) => {\n\tif ( ! value.trim() ) {\n\t\treturn null;\n\t}\n\n\treturn `var(--${ value })`;\n} );\n","import { styleTransformersRegistry } from '@elementor/editor-canvas';\nimport { controlActionsMenu, registerControlReplacement } from '@elementor/editor-editing-panel';\n\nimport { FontVariablesSelectionControl } from './controls/font-variables-selection-control';\nimport { usePropFontVariableAction } from './hooks/use-prop-font-variable-action';\nimport { fontVariablePropTypeUtil } from './prop-types/font-variable-prop-type';\nimport { variableTransformer } from './transformers/variable-transformer';\nimport { hasAssignedFontVariable } from './utils';\n\nconst { registerPopoverAction } = controlActionsMenu;\n\nexport function initFontVariables() {\n\tregisterControlReplacement( {\n\t\tcomponent: FontVariablesSelectionControl,\n\t\tcondition: ( { value } ) => hasAssignedFontVariable( value ),\n\t} );\n\n\tregisterPopoverAction( {\n\t\tid: 'font-variables',\n\t\tuseProps: usePropFontVariableAction,\n\t} );\n\n\tstyleTransformersRegistry.register( fontVariablePropTypeUtil.key, variableTransformer );\n}\n","import * as React from 'react';\nimport { useBoundProp } from '@elementor/editor-controls';\nimport { stringPropTypeUtil } from '@elementor/editor-props';\n\nimport { FontVariablesSelection } from '../components/font-variables-selection';\nimport { VariablesSelectionPopover } from '../components/variables-selection-popover';\nimport { useVariable } from '../hooks/use-prop-variables';\nimport { fontVariablePropTypeUtil } from '../prop-types/font-variable-prop-type';\n\nexport const FontVariablesSelectionControl = () => {\n\tconst { setValue: setFontFamily } = useBoundProp();\n\tconst { value: variableValue } = useBoundProp( fontVariablePropTypeUtil );\n\n\tconst selectedVariable = useVariable( fontVariablePropTypeUtil.key, variableValue );\n\n\tif ( ! selectedVariable ) {\n\t\tthrow new Error( `Global font variable ${ variableValue } not found` );\n\t}\n\n\tconst unlinkVariable = () => {\n\t\tsetFontFamily( stringPropTypeUtil.create( selectedVariable.value ) );\n\t};\n\n\treturn (\n\t\t<VariablesSelectionPopover selectedVariable={ selectedVariable } unlinkVariable={ unlinkVariable }>\n\t\t\t{ ( { closePopover } ) => <FontVariablesSelection onSelect={ closePopover } /> }\n\t\t</VariablesSelectionPopover>\n\t);\n};\n","import * as React from 'react';\nimport { Fragment } from 'react';\nimport { useBoundProp } from '@elementor/editor-controls';\nimport { EditIcon, TextIcon } from '@elementor/icons';\nimport { Box, Divider, ListItemIcon, ListItemText, MenuList } from '@elementor/ui';\n\nimport { usePropVariables } from '../hooks/use-prop-variables';\nimport { fontVariablePropTypeUtil } from '../prop-types/font-variable-prop-type';\nimport { type Variable } from '../types';\nimport { StyledMenuItem } from './styled-menu-item';\n\ntype Props = {\n\tonSelect?: () => void;\n};\n\nexport const FontVariablesSelection = ( { onSelect }: Props ) => {\n\tconst { value: variable, setValue: setVariable } = useBoundProp( fontVariablePropTypeUtil );\n\n\tconst variables = usePropVariables( fontVariablePropTypeUtil.key );\n\n\tconst handleSetVariable = ( newValue: Variable ) => {\n\t\tsetVariable( newValue.key );\n\n\t\tonSelect?.();\n\t};\n\n\treturn (\n\t\t<Fragment>\n\t\t\t<Divider />\n\t\t\t<Box sx={ { overflowY: 'auto', height: 260, width: 220 } }>\n\t\t\t\t<MenuList role=\"listbox\" tabIndex={ 0 }>\n\t\t\t\t\t{ variables.map( ( { value, label, key } ) => (\n\t\t\t\t\t\t<StyledMenuItem\n\t\t\t\t\t\t\tkey={ key }\n\t\t\t\t\t\t\tonClick={ () => handleSetVariable( { value, label, key } ) }\n\t\t\t\t\t\t\tselected={ key === variable }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<ListItemIcon>\n\t\t\t\t\t\t\t\t<TextIcon />\n\t\t\t\t\t\t\t</ListItemIcon>\n\t\t\t\t\t\t\t<ListItemText\n\t\t\t\t\t\t\t\tprimary={ label }\n\t\t\t\t\t\t\t\tsecondary={ value }\n\t\t\t\t\t\t\t\tprimaryTypographyProps={ {\n\t\t\t\t\t\t\t\t\tvariant: 'body2',\n\t\t\t\t\t\t\t\t\tcolor: 'text.secondary',\n\t\t\t\t\t\t\t\t\tstyle: {\n\t\t\t\t\t\t\t\t\t\tlineHeight: 2,\n\t\t\t\t\t\t\t\t\t\tdisplay: 'inline-block',\n\t\t\t\t\t\t\t\t\t\toverflow: 'hidden',\n\t\t\t\t\t\t\t\t\t\ttextOverflow: 'ellipsis',\n\t\t\t\t\t\t\t\t\t\twhiteSpace: 'nowrap',\n\t\t\t\t\t\t\t\t\t\tmaxWidth: '81px',\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t\tsecondaryTypographyProps={ {\n\t\t\t\t\t\t\t\t\tvariant: 'caption',\n\t\t\t\t\t\t\t\t\tcolor: 'text.tertiary',\n\t\t\t\t\t\t\t\t\tstyle: { marginTop: '1px', lineHeight: '1' },\n\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t\tsx={ { display: 'flex', alignItems: 'center', gap: 1 } }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t<EditIcon color=\"action\" fontSize=\"inherit\" sx={ { mx: 1, opacity: '0' } } />\n\t\t\t\t\t\t</StyledMenuItem>\n\t\t\t\t\t) ) }\n\t\t\t\t</MenuList>\n\t\t\t</Box>\n\t\t</Fragment>\n\t);\n};\n","import * as React from 'react';\nimport { type PopoverActionProps, useBoundProp } from '@elementor/editor-editing-panel';\nimport { ColorFilterIcon } from '@elementor/icons';\nimport { __ } from '@wordpress/i18n';\n\nimport { FontVariablesSelection } from '../components/font-variables-selection';\nimport { supportsFontVariables } from '../utils';\n\nexport const usePropFontVariableAction = (): PopoverActionProps => {\n\tconst { propType } = useBoundProp();\n\n\tconst visible = !! propType && supportsFontVariables( propType );\n\n\treturn {\n\t\tvisible,\n\t\ticon: ColorFilterIcon,\n\t\ttitle: __( 'Variables', 'elementor' ),\n\t\tpopoverContent: ( { closePopover } ) => <FontVariablesSelection onSelect={ closePopover } />,\n\t};\n};\n","import { initColorVariables } from './init-color-variables';\nimport { initFontVariables } from './init-font-variables';\n\nexport function init() {\n\tinitColorVariables();\n\n\tinitFontVariables();\n}\n"],"mappings":";AAAA,SAAS,iCAAiC;AAC1C,SAAS,oBAAoB,kCAAkC;;;ACD/D,YAAYA,YAAW;AACvB,SAAS,gBAAAC,qBAAoB;AAC7B,SAAS,yBAAyB;;;ACFlC,SAAS,QAAQ,8BAA8B;AAExC,IAAM,iBAAiB,OAAQ,sBAAuB,EAAG,CAAE,EAAE,MAAM,OAAS;AAAA,EAClF,cAAc,GAAI,MAAM,MAAM,eAAe,CAAE;AAChD,EAAI;;;ACJJ,YAAY,WAAW;AACvB,SAAS,gBAAgB;AACzB,SAAS,oBAAoB;AAC7B,SAAS,gBAAgB;AACzB,SAAS,KAAK,SAAS,cAAc,cAAc,gBAAgB;;;ACJnE,SAAS,e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kBAC9D,CAAE,EAAE,aAAa,MAAO,qCAAC,0BAAuB,UAAW,cAAe,CAC7E;AAEF;;;AE5BA,YAAYC,YAAW;AACvB,SAAkC,gBAAAC,qBAAoB;AACtD,SAAS,mBAAAC,wBAAuB;AAChC,SAAS,MAAAC,WAAU;AAKZ,IAAM,4BAA4B,MAA0B;AAClE,QAAM,EAAE,SAAS,IAAIC,cAAa;AAElC,QAAM,UAAU,CAAC,CAAE,YAAY,sBAAuB,QAAS;AAE/D,SAAO;AAAA,IACN;AAAA,IACA,MAAMC;AAAA,IACN,OAAOC,IAAI,aAAa,WAAY;AAAA,IACpC,gBAAgB,CAAE,EAAE,aAAa,MAAO,qCAAC,0BAAuB,UAAW,cAAe;AAAA,EAC3F;AACD;;;AHVA,IAAM,EAAE,uBAAAC,uBAAsB,IAAIC;AAE3B,SAAS,oBAAoB;AACnC,EAAAC,4BAA4B;AAAA,IAC3B,WAAW;AAAA,IACX,WAAW,CAAE,EAAE,MAAM,MAAO,wBAAyB,KAAM;AAAA,EAC5D,CAAE;AAEF,EAAAF,uBAAuB;AAAA,IACtB,IAAI;AAAA,IACJ,UAAU;AAAA,EACX,CAAE;AAEF,EAAAG,2BAA0B,SAAU,yBAAyB,KAAK,mBAAoB;AACvF;;;AIpBO,SAAS,OAAO;AACtB,qBAAmB;AAEnB,oBAAkB;AACnB;","names":["React","useBoundProp","styled","variables","React","useRef","bindPopover","Box","CloseButton","Popover","Stack","Typography","__","React","useBoundProp","Box","Divider","useBoundProp","Box","Divider","useRef","Box","Stack","Typography","__","Popover","bindPopover","CloseButton","useBoundProp","React","useBoundProp","ColorFilterIcon","__","createPropUtils","z","useBoundProp","ColorFilterIcon","__","styleTransformersRegistry","controlActionsMenu","registerControlReplacement","React","useBoundProp","React","Fragment","useBoundProp","EditIcon","Box","Divider","ListItemIcon","ListItemText","MenuList","useBoundProp","variables","Fragment","Divider","Box","MenuList","ListItemIcon","ListItemText","EditIcon","useBoundProp","React","useBoundProp","ColorFilterIcon","__","useBoundProp","ColorFilterIcon","__","registerPopoverAction","controlActionsMenu","registerControlReplacement","styleTransformersRegistry"]}
|
|
1
|
+
{"version":3,"sources":["../src/init.ts","../src/init-color-variables.ts","../src/controls/color-variables-selection-control.tsx","../src/components/color-indicator.tsx","../src/components/color-variables-selection.tsx","../src/hooks/use-prop-variables.ts","../src/create-style-variables-repository.ts","../src/style-variables-repository.ts","../src/prop-types/color-variable-prop-type.ts","../src/components/styled-menu-item.tsx","../src/components/variables-selection-popover.tsx","../src/components/color-variable-creation.tsx","../src/hooks/use-prop-color-variable-action.tsx","../src/prop-types/font-variable-prop-type.ts","../src/utils.ts","../src/transformers/variable-transformer.ts","../src/init-font-variables.ts","../src/controls/font-variables-selection-control.tsx","../src/components/font-variables-selection.tsx","../src/hooks/use-prop-font-variable-action.tsx","../src/renderers/style-variables-renderer.tsx","../src/sync/get-canvas-iframe-document.ts"],"sourcesContent":["import { injectIntoTop } from '@elementor/editor';\n\nimport { initColorVariables } from './init-color-variables';\nimport { initFontVariables } from './init-font-variables';\nimport { StyleVariablesRenderer } from './renderers/style-variables-renderer';\n\nexport function init() {\n\tinitColorVariables();\n\n\tinitFontVariables();\n\n\tinjectIntoTop( {\n\t\tid: 'canvas-style-variables-render',\n\t\tcomponent: StyleVariablesRenderer,\n\t} );\n}\n","import { styleTransformersRegistry } from '@elementor/editor-canvas';\nimport { controlActionsMenu, registerControlReplacement } from '@elementor/editor-editing-panel';\n\nimport { ColorVariablesSelectionControl } from './controls/color-variables-selection-control';\nimport { usePropColorVariableAction } from './hooks/use-prop-color-variable-action';\nimport { colorVariablePropTypeUtil } from './prop-types/color-variable-prop-type';\nimport { variableTransformer } from './transformers/variable-transformer';\nimport { hasAssignedColorVariable } from './utils';\n\nconst { registerPopoverAction } = controlActionsMenu;\n\nexport function initColorVariables() {\n\tregisterControlReplacement( {\n\t\tcomponent: ColorVariablesSelectionControl,\n\t\tcondition: ( { value } ) => hasAssignedColorVariable( value ),\n\t} );\n\n\tregisterPopoverAction( {\n\t\tid: 'color-variables',\n\t\tuseProps: usePropColorVariableAction,\n\t} );\n\n\tstyleTransformersRegistry.register( colorVariablePropTypeUtil.key, variableTransformer );\n}\n","import * as React from 'react';\nimport { useBoundProp } from '@elementor/editor-controls';\nimport { colorPropTypeUtil } from '@elementor/editor-props';\n\nimport { ColorIndicator } from '../components/color-indicator';\nimport { ColorVariablesSelection } from '../components/color-variables-selection';\nimport { VariablesSelectionPopover } from '../components/variables-selection-popover';\nimport { useVariable } from '../hooks/use-prop-variables';\nimport { colorVariablePropTypeUtil } from '../prop-types/color-variable-prop-type';\n\nexport const ColorVariablesSelectionControl = () => {\n\tconst { setValue } = useBoundProp();\n\tconst { value: variableValue } = useBoundProp( colorVariablePropTypeUtil );\n\n\tconst selectedVariable = useVariable( variableValue );\n\n\tif ( ! selectedVariable ) {\n\t\tthrow new Error( `Global color variable ${ variableValue } not found` );\n\t}\n\n\tconst unlinkVariable = () => {\n\t\tsetValue( colorPropTypeUtil.create( selectedVariable.value ) );\n\t};\n\n\treturn (\n\t\t<VariablesSelectionPopover\n\t\t\tselectedVariable={ selectedVariable }\n\t\t\tunlinkVariable={ unlinkVariable }\n\t\t\tstartTagAdornment={ <ColorIndicator size=\"inherit\" component=\"span\" value={ selectedVariable.value } /> }\n\t\t>\n\t\t\t{ ( { closePopover } ) => <ColorVariablesSelection onSelect={ closePopover } /> }\n\t\t</VariablesSelectionPopover>\n\t);\n};\n","import { styled, UnstableColorIndicator } from '@elementor/ui';\n\nexport const ColorIndicator = styled( UnstableColorIndicator )( ( { theme } ) => ( {\n\tborderRadius: `${ theme.shape.borderRadius / 2 }px`,\n} ) );\n","import * as React from 'react';\nimport { Fragment } from 'react';\nimport { useBoundProp } from '@elementor/editor-controls';\nimport { EditIcon } from '@elementor/icons';\nimport { Box, Divider, ListItemIcon, ListItemText, MenuList } from '@elementor/ui';\n\nimport { usePropVariables } from '../hooks/use-prop-variables';\nimport { colorVariablePropTypeUtil } from '../prop-types/color-variable-prop-type';\nimport { type VariableKey } from '../types';\nimport { ColorIndicator } from './color-indicator';\nimport { StyledMenuItem } from './styled-menu-item';\n\ntype Props = {\n\tonSelect?: () => void;\n};\n\nexport const ColorVariablesSelection = ( { onSelect }: Props ) => {\n\tconst { value: variable, setValue: setVariable } = useBoundProp( colorVariablePropTypeUtil );\n\n\tconst variables = usePropVariables( colorVariablePropTypeUtil.key );\n\n\tconst handleSetColorVariable = ( key: VariableKey ) => {\n\t\tsetVariable( key );\n\n\t\tonSelect?.();\n\t};\n\n\treturn (\n\t\t<Fragment>\n\t\t\t<Divider />\n\t\t\t<Box sx={ { overflowY: 'auto', height: 260, width: 220 } }>\n\t\t\t\t<MenuList role=\"listbox\" tabIndex={ 0 }>\n\t\t\t\t\t{ variables.map( ( { value, label, key } ) => (\n\t\t\t\t\t\t<StyledMenuItem\n\t\t\t\t\t\t\tkey={ key }\n\t\t\t\t\t\t\tonClick={ () => handleSetColorVariable( key ) }\n\t\t\t\t\t\t\tselected={ key === variable }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<ListItemIcon>\n\t\t\t\t\t\t\t\t<ColorIndicator size=\"inherit\" component=\"span\" value={ value } />\n\t\t\t\t\t\t\t</ListItemIcon>\n\t\t\t\t\t\t\t<ListItemText\n\t\t\t\t\t\t\t\tprimary={ label }\n\t\t\t\t\t\t\t\tsecondary={ value }\n\t\t\t\t\t\t\t\tprimaryTypographyProps={ {\n\t\t\t\t\t\t\t\t\tvariant: 'body2',\n\t\t\t\t\t\t\t\t\tcolor: 'text.secondary',\n\t\t\t\t\t\t\t\t\tstyle: {\n\t\t\t\t\t\t\t\t\t\tlineHeight: 2,\n\t\t\t\t\t\t\t\t\t\tdisplay: 'inline-block',\n\t\t\t\t\t\t\t\t\t\toverflow: 'hidden',\n\t\t\t\t\t\t\t\t\t\ttextOverflow: 'ellipsis',\n\t\t\t\t\t\t\t\t\t\twhiteSpace: 'nowrap',\n\t\t\t\t\t\t\t\t\t\tmaxWidth: '81px',\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t\tsecondaryTypographyProps={ {\n\t\t\t\t\t\t\t\t\tvariant: 'caption',\n\t\t\t\t\t\t\t\t\tcolor: 'text.tertiary',\n\t\t\t\t\t\t\t\t\tstyle: { marginTop: '1px', lineHeight: '1' },\n\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t\tsx={ { display: 'flex', alignItems: 'center', gap: 1 } }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t<EditIcon color=\"action\" fontSize=\"inherit\" sx={ { mx: 1, opacity: '0' } } />\n\t\t\t\t\t\t</StyledMenuItem>\n\t\t\t\t\t) ) }\n\t\t\t\t</MenuList>\n\t\t\t</Box>\n\t\t</Fragment>\n\t);\n};\n","import { useMemo } from 'react';\nimport { type PropKey } from '@elementor/editor-props';\n\nimport { styleVariablesRepository } from '../style-variables-repository';\nimport { type Variable, type Variables } from '../types';\n\nexport const usePropVariables = ( propKey: PropKey ) => {\n\treturn useMemo( () => normalizeVariables( propKey ), [ propKey ] );\n};\n\nexport const useVariable = ( key: string ) => {\n\tif ( ! variables?.[ key ] ) {\n\t\treturn null;\n\t}\n\n\treturn {\n\t\t...variables[ key ],\n\t\tkey,\n\t};\n};\n\nconst normalizeVariables = ( propKey: string ) => {\n\treturn Object.entries( variables )\n\t\t.filter( ( [ , { type } ] ) => type === propKey )\n\t\t.map( ( [ key, { label, value } ] ) => ( {\n\t\t\tkey,\n\t\t\tlabel,\n\t\t\tvalue,\n\t\t} ) );\n};\n\nexport const createVariable = ( variable: Variable ) => {\n\tconst id = generateId();\n\n\tvariables[ id ] = variable;\n\n\tstyleVariablesRepository.update( {\n\t\t[ id ]: variable,\n\t} );\n\n\treturn id;\n};\n\n// @ts-expect-error the temporary solution to get the list of variables from the server\nconst variables: Variables = window?.ElementorV4Variables || {};\n\nconst generateId = ( prefix = 'e-gv' ) => {\n\tconst randomHex = Math.random().toString( 16 ).slice( 2, 9 );\n\n\treturn `${ prefix }${ randomHex }`;\n};\n","import { type StyleVariables, type Variables, type VariableValue } from './types';\n\ntype VariablesChangeCallback = ( variables: StyleVariables ) => void;\n\nexport const createStyleVariablesRepository = () => {\n\tconst variables: StyleVariables = {};\n\tlet subscription: VariablesChangeCallback;\n\n\tconst subscribe = ( cb: VariablesChangeCallback ) => {\n\t\tsubscription = cb;\n\n\t\treturn () => {\n\t\t\tsubscription = () => {};\n\t\t};\n\t};\n\n\tconst notify = () => {\n\t\tif ( typeof subscription === 'function' ) {\n\t\t\tsubscription( { ...variables } );\n\t\t}\n\t};\n\n\tconst shouldUpdate = ( key: string, newValue: VariableValue ): boolean => {\n\t\treturn ! ( key in variables ) || variables[ key ] !== newValue;\n\t};\n\n\tconst applyUpdates = ( updatedVars: Variables ): boolean => {\n\t\tlet hasChanges = false;\n\n\t\tfor ( const [ key, { value } ] of Object.entries( updatedVars ) ) {\n\t\t\tif ( shouldUpdate( key, value ) ) {\n\t\t\t\tvariables[ key ] = value;\n\t\t\t\thasChanges = true;\n\t\t\t}\n\t\t}\n\n\t\treturn hasChanges;\n\t};\n\n\tconst update = ( updatedVars: Variables ) => {\n\t\tif ( applyUpdates( updatedVars ) ) {\n\t\t\tnotify();\n\t\t}\n\t};\n\n\treturn {\n\t\tsubscribe,\n\t\tupdate,\n\t};\n};\n","import { createStyleVariablesRepository } from './create-style-variables-repository';\n\nexport const styleVariablesRepository = createStyleVariablesRepository();\n","import { createPropUtils } from '@elementor/editor-props';\nimport { z } from '@elementor/schema';\n\nexport const colorVariablePropTypeUtil = createPropUtils( 'global-color-variable', z.string() );\n","import { MenuItem, styled } from '@elementor/ui';\n\nexport const StyledMenuItem = styled( MenuItem )( () => ( {\n\tpl: 2,\n\tpr: 1,\n\tpy: 0.5,\n\t'&:hover .MuiSvgIcon-root': {\n\t\topacity: 1,\n\t},\n} ) );\n","import * as React from 'react';\nimport { useId, useRef } from 'react';\nimport { ColorFilterIcon, DetachIcon, PlusIcon } from '@elementor/icons';\nimport {\n\tbindPopover,\n\tbindTrigger,\n\tBox,\n\tCloseButton,\n\tIconButton,\n\tPopover,\n\tStack,\n\tTypography,\n\tUnstableTag as Tag,\n\tusePopupState,\n} from '@elementor/ui';\nimport { __ } from '@wordpress/i18n';\n\nimport { type Variable } from '../types';\nimport { ColorVariableCreation } from './color-variable-creation';\n\ntype Props = {\n\tselectedVariable: Variable;\n\tunlinkVariable: () => void;\n\tchildren: ( { closePopover }: { closePopover: () => void } ) => React.ReactNode;\n\tstartTagAdornment?: React.ReactNode;\n};\n\nexport const VariablesSelectionPopover = ( {\n\tselectedVariable,\n\tunlinkVariable,\n\tstartTagAdornment,\n\tchildren,\n}: Props ) => {\n\tconst id = useId();\n\tconst popupState = usePopupState( { variant: 'popover', popupId: `elementor-variables-action-${ id }` } );\n\tconst creationPopupState = usePopupState( { variant: 'popover', popupId: `elementor-variables-creation-${ id }` } );\n\n\tconst closePopover = () => popupState.close();\n\n\tconst handleCreateButtonClick = ( event: React.MouseEvent ) => {\n\t\tclosePopover();\n\t\tbindTrigger( creationPopupState ).onClick( event );\n\t};\n\n\tconst anchorRef = useRef< HTMLDivElement >( null );\n\tconst { label } = selectedVariable;\n\n\treturn (\n\t\t<Box ref={ anchorRef }>\n\t\t\t<Tag\n\t\t\t\tfullWidth\n\t\t\t\tshowActionsOnHover\n\t\t\t\t{ ...bindTrigger( popupState ) }\n\t\t\t\tstartIcon={\n\t\t\t\t\t<Stack spacing={ 1 } direction=\"row\" alignItems=\"center\">\n\t\t\t\t\t\t{ startTagAdornment }\n\t\t\t\t\t\t<ColorFilterIcon fontSize={ 'inherit' } sx={ { mr: 1 } } />\n\t\t\t\t\t</Stack>\n\t\t\t\t}\n\t\t\t\tlabel={\n\t\t\t\t\t<Box sx={ { display: 'inline-grid' } }>\n\t\t\t\t\t\t<Typography sx={ { textOverflow: 'ellipsis', overflowX: 'hidden' } } variant=\"subtitle2\">\n\t\t\t\t\t\t\t{ label }\n\t\t\t\t\t\t</Typography>\n\t\t\t\t\t</Box>\n\t\t\t\t}\n\t\t\t\tactions={\n\t\t\t\t\t<IconButton size=\"tiny\" onClick={ unlinkVariable } aria-label={ __( 'Unlink', 'elementor' ) }>\n\t\t\t\t\t\t<DetachIcon fontSize=\"tiny\" />\n\t\t\t\t\t</IconButton>\n\t\t\t\t}\n\t\t\t/>\n\t\t\t<Popover\n\t\t\t\t{ ...bindPopover( popupState ) }\n\t\t\t\tdisableScrollLock\n\t\t\t\tanchorEl={ anchorRef.current }\n\t\t\t\tanchorOrigin={ { vertical: 'bottom', horizontal: 'right' } }\n\t\t\t\ttransformOrigin={ { vertical: 'top', horizontal: 'right' } }\n\t\t\t>\n\t\t\t\t<Stack direction=\"row\" alignItems=\"center\" pl={ 1.5 } pr={ 0.5 } py={ 1.5 }>\n\t\t\t\t\t<ColorFilterIcon fontSize=\"tiny\" sx={ { mr: 0.5 } } />\n\t\t\t\t\t<Typography variant=\"subtitle2\">{ __( 'Variables', 'elementor' ) }</Typography>\n\t\t\t\t\t<Stack direction=\"row\" sx={ { ml: 'auto' } }>\n\t\t\t\t\t\t<IconButton\n\t\t\t\t\t\t\t{ ...bindTrigger( creationPopupState ) }\n\t\t\t\t\t\t\tsize=\"tiny\"\n\t\t\t\t\t\t\tonClick={ handleCreateButtonClick }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<PlusIcon fontSize=\"tiny\" />\n\t\t\t\t\t\t</IconButton>\n\t\t\t\t\t\t<CloseButton slotProps={ { icon: { fontSize: 'tiny' } } } onClick={ closePopover } />\n\t\t\t\t\t</Stack>\n\t\t\t\t</Stack>\n\t\t\t\t{ children?.( { closePopover } ) }\n\t\t\t</Popover>\n\n\t\t\t<ColorVariableCreation popupState={ creationPopupState } />\n\t\t</Box>\n\t);\n};\n","import * as React from 'react';\nimport { useRef, useState } from 'react';\nimport { useBoundProp } from '@elementor/editor-controls';\nimport { BrushIcon } from '@elementor/icons';\nimport {\n\tbindPopover,\n\tBox,\n\tButton,\n\tCardActions,\n\tCloseButton,\n\tDivider,\n\tFormLabel,\n\tGrid,\n\tPopover,\n\ttype PopupState,\n\tStack,\n\tTextField,\n\tTypography,\n\tUnstableColorField,\n} from '@elementor/ui';\nimport { __ } from '@wordpress/i18n';\n\nimport { createVariable } from '../hooks/use-prop-variables';\nimport { colorVariablePropTypeUtil } from '../prop-types/color-variable-prop-type';\n\nexport const ColorVariableCreation = ( { popupState }: { popupState: PopupState } ) => {\n\tconst { setValue: setVariable } = useBoundProp( colorVariablePropTypeUtil );\n\n\tconst [ color, setColor ] = useState( '' );\n\tconst [ label, setLabel ] = useState( '' );\n\n\tconst anchorRef = useRef< HTMLDivElement >( null );\n\n\tconst resetFields = () => {\n\t\tsetColor( '' );\n\t\tsetLabel( '' );\n\t};\n\n\tconst closePopover = () => {\n\t\tresetFields();\n\t\tpopupState.close();\n\t};\n\n\tconst handleCreate = () => {\n\t\tconst key = createVariable( {\n\t\t\tvalue: color,\n\t\t\tlabel,\n\t\t\ttype: colorVariablePropTypeUtil.key,\n\t\t} );\n\n\t\tsetVariable( key );\n\t\tclosePopover();\n\t};\n\n\tconst isInValidForm = () => {\n\t\treturn ! color?.trim() || ! label?.trim();\n\t};\n\n\treturn (\n\t\t<Box ref={ anchorRef }>\n\t\t\t<Popover\n\t\t\t\t{ ...bindPopover( popupState ) }\n\t\t\t\tanchorEl={ anchorRef.current }\n\t\t\t\tanchorOrigin={ { vertical: 'bottom', horizontal: 'right' } }\n\t\t\t\ttransformOrigin={ { vertical: 'top', horizontal: 'right' } }\n\t\t\t>\n\t\t\t\t<Stack direction=\"row\" alignItems=\"center\" pl={ 1.5 } pr={ 0.5 } py={ 1.5 }>\n\t\t\t\t\t<BrushIcon fontSize=\"tiny\" sx={ { mr: 0.5 } } />\n\t\t\t\t\t<Typography variant=\"subtitle2\">{ __( 'Create variable', 'elementor' ) }</Typography>\n\t\t\t\t\t<CloseButton\n\t\t\t\t\t\tslotProps={ { icon: { fontSize: 'small' } } }\n\t\t\t\t\t\tsx={ { ml: 'auto' } }\n\t\t\t\t\t\tonClick={ closePopover }\n\t\t\t\t\t/>\n\t\t\t\t</Stack>\n\n\t\t\t\t<Divider />\n\n\t\t\t\t<Stack p={ 1.5 } gap={ 1.5 }>\n\t\t\t\t\t<Grid container gap={ 0.75 } alignItems=\"center\">\n\t\t\t\t\t\t<Grid item xs={ 12 }>\n\t\t\t\t\t\t\t<FormLabel size=\"small\">{ __( 'Name', 'elementor' ) }</FormLabel>\n\t\t\t\t\t\t</Grid>\n\t\t\t\t\t\t<Grid item xs={ 12 }>\n\t\t\t\t\t\t\t<TextField\n\t\t\t\t\t\t\t\tsize=\"tiny\"\n\t\t\t\t\t\t\t\tfullWidth\n\t\t\t\t\t\t\t\tvalue={ label }\n\t\t\t\t\t\t\t\tonChange={ ( e: React.ChangeEvent< HTMLInputElement > ) => setLabel( e.target.value ) }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t</Grid>\n\t\t\t\t\t</Grid>\n\n\t\t\t\t\t<Grid container gap={ 0.75 } alignItems=\"center\">\n\t\t\t\t\t\t<Grid item xs={ 12 }>\n\t\t\t\t\t\t\t<FormLabel size=\"small\">{ __( 'Value', 'elementor' ) }</FormLabel>\n\t\t\t\t\t\t</Grid>\n\t\t\t\t\t\t<Grid item xs={ 12 }>\n\t\t\t\t\t\t\t<UnstableColorField\n\t\t\t\t\t\t\t\tsize=\"tiny\"\n\t\t\t\t\t\t\t\tfullWidth\n\t\t\t\t\t\t\t\tvalue={ color }\n\t\t\t\t\t\t\t\tonChange={ setColor }\n\t\t\t\t\t\t\t\tslotProps={ {\n\t\t\t\t\t\t\t\t\tcolorPicker: {\n\t\t\t\t\t\t\t\t\t\tanchorEl: anchorRef.current,\n\t\t\t\t\t\t\t\t\t\tanchorOrigin: { vertical: 'top', horizontal: 'right' },\n\t\t\t\t\t\t\t\t\t\ttransformOrigin: { vertical: 'top', horizontal: -10 },\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t</Grid>\n\t\t\t\t\t</Grid>\n\t\t\t\t</Stack>\n\n\t\t\t\t<CardActions>\n\t\t\t\t\t<Button size=\"small\" onClick={ closePopover } color=\"secondary\" variant=\"text\">\n\t\t\t\t\t\t{ __( 'Cancel', 'elementor' ) }\n\t\t\t\t\t</Button>\n\t\t\t\t\t<Button size=\"small\" variant=\"contained\" disabled={ isInValidForm() } onClick={ handleCreate }>\n\t\t\t\t\t\t{ __( 'Create', 'elementor' ) }\n\t\t\t\t\t</Button>\n\t\t\t\t</CardActions>\n\t\t\t</Popover>\n\t\t</Box>\n\t);\n};\n","import * as React from 'react';\nimport { type PopoverActionProps, useBoundProp } from '@elementor/editor-editing-panel';\nimport { ColorFilterIcon } from '@elementor/icons';\nimport { __ } from '@wordpress/i18n';\n\nimport { ColorVariablesSelection } from '../components/color-variables-selection';\nimport { supportsColorVariables } from '../utils';\n\nexport const usePropColorVariableAction = (): PopoverActionProps => {\n\tconst { propType } = useBoundProp();\n\n\tconst visible = !! propType && supportsColorVariables( propType );\n\n\treturn {\n\t\tvisible,\n\t\ticon: ColorFilterIcon,\n\t\ttitle: __( 'Variables', 'elementor' ),\n\t\tpopoverContent: ( { closePopover } ) => <ColorVariablesSelection onSelect={ closePopover } />,\n\t};\n};\n","import { createPropUtils } from '@elementor/editor-props';\nimport { z } from '@elementor/schema';\n\nexport const fontVariablePropTypeUtil = createPropUtils( 'global-font-variable', z.string() );\n","import { type PropType, type PropValue } from '@elementor/editor-props';\n\nimport { colorVariablePropTypeUtil } from './prop-types/color-variable-prop-type';\nimport { fontVariablePropTypeUtil } from './prop-types/font-variable-prop-type';\n\nexport const hasAssignedColorVariable = ( propValue: PropValue ): boolean => {\n\treturn !! colorVariablePropTypeUtil.isValid( propValue );\n};\n\nexport const supportsColorVariables = ( propType: PropType ): boolean => {\n\treturn propType.kind === 'union' && colorVariablePropTypeUtil.key in propType.prop_types;\n};\n\nexport const hasAssignedFontVariable = ( propValue: PropValue ): boolean => {\n\treturn !! fontVariablePropTypeUtil.isValid( propValue );\n};\n\nexport const supportsFontVariables = ( propType: PropType ): boolean => {\n\treturn propType.kind === 'union' && fontVariablePropTypeUtil.key in propType.prop_types;\n};\n","import { createTransformer } from '@elementor/editor-canvas';\n\nexport const variableTransformer = createTransformer( ( value: string ) => {\n\tif ( ! value.trim() ) {\n\t\treturn null;\n\t}\n\n\treturn `var(--${ value })`;\n} );\n","import { styleTransformersRegistry } from '@elementor/editor-canvas';\nimport { controlActionsMenu, registerControlReplacement } from '@elementor/editor-editing-panel';\n\nimport { FontVariablesSelectionControl } from './controls/font-variables-selection-control';\nimport { usePropFontVariableAction } from './hooks/use-prop-font-variable-action';\nimport { fontVariablePropTypeUtil } from './prop-types/font-variable-prop-type';\nimport { variableTransformer } from './transformers/variable-transformer';\nimport { hasAssignedFontVariable } from './utils';\n\nconst { registerPopoverAction } = controlActionsMenu;\n\nexport function initFontVariables() {\n\tregisterControlReplacement( {\n\t\tcomponent: FontVariablesSelectionControl,\n\t\tcondition: ( { value } ) => hasAssignedFontVariable( value ),\n\t} );\n\n\tregisterPopoverAction( {\n\t\tid: 'font-variables',\n\t\tuseProps: usePropFontVariableAction,\n\t} );\n\n\tstyleTransformersRegistry.register( fontVariablePropTypeUtil.key, variableTransformer );\n}\n","import * as React from 'react';\nimport { useBoundProp } from '@elementor/editor-controls';\nimport { stringPropTypeUtil } from '@elementor/editor-props';\n\nimport { FontVariablesSelection } from '../components/font-variables-selection';\nimport { VariablesSelectionPopover } from '../components/variables-selection-popover';\nimport { useVariable } from '../hooks/use-prop-variables';\nimport { fontVariablePropTypeUtil } from '../prop-types/font-variable-prop-type';\n\nexport const FontVariablesSelectionControl = () => {\n\tconst { setValue: setFontFamily } = useBoundProp();\n\tconst { value: variableValue } = useBoundProp( fontVariablePropTypeUtil );\n\n\tconst selectedVariable = useVariable( variableValue );\n\n\tif ( ! selectedVariable ) {\n\t\tthrow new Error( `Global font variable ${ variableValue } not found` );\n\t}\n\n\tconst unlinkVariable = () => {\n\t\tsetFontFamily( stringPropTypeUtil.create( selectedVariable.value ) );\n\t};\n\n\treturn (\n\t\t<VariablesSelectionPopover selectedVariable={ selectedVariable } unlinkVariable={ unlinkVariable }>\n\t\t\t{ ( { closePopover } ) => <FontVariablesSelection onSelect={ closePopover } /> }\n\t\t</VariablesSelectionPopover>\n\t);\n};\n","import * as React from 'react';\nimport { Fragment } from 'react';\nimport { useBoundProp } from '@elementor/editor-controls';\nimport { EditIcon, TextIcon } from '@elementor/icons';\nimport { Box, Divider, ListItemIcon, ListItemText, MenuList } from '@elementor/ui';\n\nimport { usePropVariables } from '../hooks/use-prop-variables';\nimport { fontVariablePropTypeUtil } from '../prop-types/font-variable-prop-type';\nimport { type VariableKey } from '../types';\nimport { StyledMenuItem } from './styled-menu-item';\n\ntype Props = {\n\tonSelect?: () => void;\n};\n\nexport const FontVariablesSelection = ( { onSelect }: Props ) => {\n\tconst { value: variable, setValue: setVariable } = useBoundProp( fontVariablePropTypeUtil );\n\n\tconst variables = usePropVariables( fontVariablePropTypeUtil.key );\n\n\tconst handleSetVariable = ( key: VariableKey ) => {\n\t\tsetVariable( key );\n\n\t\tonSelect?.();\n\t};\n\n\treturn (\n\t\t<Fragment>\n\t\t\t<Divider />\n\t\t\t<Box sx={ { overflowY: 'auto', height: 260, width: 220 } }>\n\t\t\t\t<MenuList role=\"listbox\" tabIndex={ 0 }>\n\t\t\t\t\t{ variables.map( ( { value, label, key } ) => (\n\t\t\t\t\t\t<StyledMenuItem\n\t\t\t\t\t\t\tkey={ key }\n\t\t\t\t\t\t\tonClick={ () => handleSetVariable( key ) }\n\t\t\t\t\t\t\tselected={ key === variable }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<ListItemIcon>\n\t\t\t\t\t\t\t\t<TextIcon />\n\t\t\t\t\t\t\t</ListItemIcon>\n\t\t\t\t\t\t\t<ListItemText\n\t\t\t\t\t\t\t\tprimary={ label }\n\t\t\t\t\t\t\t\tsecondary={ value }\n\t\t\t\t\t\t\t\tprimaryTypographyProps={ {\n\t\t\t\t\t\t\t\t\tvariant: 'body2',\n\t\t\t\t\t\t\t\t\tcolor: 'text.secondary',\n\t\t\t\t\t\t\t\t\tstyle: {\n\t\t\t\t\t\t\t\t\t\tlineHeight: 2,\n\t\t\t\t\t\t\t\t\t\tdisplay: 'inline-block',\n\t\t\t\t\t\t\t\t\t\toverflow: 'hidden',\n\t\t\t\t\t\t\t\t\t\ttextOverflow: 'ellipsis',\n\t\t\t\t\t\t\t\t\t\twhiteSpace: 'nowrap',\n\t\t\t\t\t\t\t\t\t\tmaxWidth: '81px',\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t\tsecondaryTypographyProps={ {\n\t\t\t\t\t\t\t\t\tvariant: 'caption',\n\t\t\t\t\t\t\t\t\tcolor: 'text.tertiary',\n\t\t\t\t\t\t\t\t\tstyle: { marginTop: '1px', lineHeight: '1' },\n\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t\tsx={ { display: 'flex', alignItems: 'center', gap: 1 } }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t<EditIcon color=\"action\" fontSize=\"inherit\" sx={ { mx: 1, opacity: '0' } } />\n\t\t\t\t\t\t</StyledMenuItem>\n\t\t\t\t\t) ) }\n\t\t\t\t</MenuList>\n\t\t\t</Box>\n\t\t</Fragment>\n\t);\n};\n","import * as React from 'react';\nimport { type PopoverActionProps, useBoundProp } from '@elementor/editor-editing-panel';\nimport { ColorFilterIcon } from '@elementor/icons';\nimport { __ } from '@wordpress/i18n';\n\nimport { FontVariablesSelection } from '../components/font-variables-selection';\nimport { supportsFontVariables } from '../utils';\n\nexport const usePropFontVariableAction = (): PopoverActionProps => {\n\tconst { propType } = useBoundProp();\n\n\tconst visible = !! propType && supportsFontVariables( propType );\n\n\treturn {\n\t\tvisible,\n\t\ticon: ColorFilterIcon,\n\t\ttitle: __( 'Variables', 'elementor' ),\n\t\tpopoverContent: ( { closePopover } ) => <FontVariablesSelection onSelect={ closePopover } />,\n\t};\n};\n","import * as React from 'react';\nimport { useEffect, useState } from 'react';\nimport { __privateUseListenTo as useListenTo, commandEndEvent } from '@elementor/editor-v1-adapters';\nimport { Portal } from '@elementor/ui';\n\nimport { styleVariablesRepository } from '../style-variables-repository';\nimport { getCanvasIframeDocument } from '../sync/get-canvas-iframe-document';\nimport { type StyleVariables } from '../types';\n\nconst VARIABLES_WRAPPER = 'body';\n\nexport function StyleVariablesRenderer() {\n\tconst container = usePortalContainer();\n\tconst styleVariables = useStyleVariables();\n\n\tconst hasVariables = Object.keys( styleVariables ).length > 0;\n\n\tif ( ! container || ! hasVariables ) {\n\t\treturn null;\n\t}\n\n\tconst cssVariables = convertToCssVariables( styleVariables );\n\tconst wrappedCss = `${ VARIABLES_WRAPPER }{${ cssVariables }}`;\n\n\treturn (\n\t\t<Portal container={ container }>\n\t\t\t<style data-e-style-id=\"e-variables\" key={ wrappedCss }>\n\t\t\t\t{ wrappedCss }\n\t\t\t</style>\n\t\t</Portal>\n\t);\n}\n\nfunction usePortalContainer() {\n\treturn useListenTo( commandEndEvent( 'editor/documents/attach-preview' ), () => getCanvasIframeDocument()?.head );\n}\n\nfunction useStyleVariables() {\n\tconst [ variables, setVariables ] = useState< StyleVariables >( {} );\n\n\tuseEffect( () => {\n\t\tconst unsubscribe = styleVariablesRepository.subscribe( setVariables );\n\n\t\treturn () => {\n\t\t\tunsubscribe();\n\t\t};\n\t}, [] );\n\n\treturn variables;\n}\n\nfunction convertToCssVariables( variables: StyleVariables ): string {\n\treturn Object.entries( variables )\n\t\t.map( ( [ key, value ] ) => `--${ key }:${ value };` )\n\t\t.join( '' );\n}\n","import type { CanvasExtendedWindow } from './types';\n\nexport function getCanvasIframeDocument() {\n\tconst extendedWindow = window as unknown as CanvasExtendedWindow;\n\n\treturn extendedWindow.elementor?.$preview?.[ 0 ]?.contentDocument;\n}\n"],"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H,CACD;AAEF;AAEA,SAAS,qBAAqB;AAC7B,SAAO,YAAa,gBAAiB,iCAAkC,GAAG,MAAM,wBAAwB,GAAG,IAAK;AACjH;AAEA,SAAS,oBAAoB;AAC5B,QAAM,CAAEC,YAAW,YAAa,IAAIC,UAA4B,CAAC,CAAE;AAEnE,YAAW,MAAM;AAChB,UAAM,cAAc,yBAAyB,UAAW,YAAa;AAErE,WAAO,MAAM;AACZ,kBAAY;AAAA,IACb;AAAA,EACD,GAAG,CAAC,CAAE;AAEN,SAAOD;AACR;AAEA,SAAS,sBAAuBA,YAAoC;AACnE,SAAO,OAAO,QAASA,UAAU,EAC/B,IAAK,CAAE,CAAE,KAAK,KAAM,MAAO,KAAM,GAAI,IAAK,KAAM,GAAI,EACpD,KAAM,EAAG;AACZ;;;ApBjDO,SAAS,OAAO;AACtB,qBAAmB;AAEnB,oBAAkB;AAElB,gBAAe;AAAA,IACd,IAAI;AAAA,IACJ,WAAW;AAAA,EACZ,CAAE;AACH;","names":["React","useBoundProp","variables","styled","variables","React","useRef","bindPopover","Box","CloseButton","Popover","Stack","Typography","__","React","useBoundProp","Box","Divider","useBoundProp","Box","Divider","useRef","Box","Stack","Typography","__","Popover","bindPopover","CloseButton","useBoundProp","React","useBoundProp","ColorFilterIcon","__","createPropUtils","z","useBoundProp","ColorFilterIcon","__","styleTransformersRegistry","controlActionsMenu","registerControlReplacement","React","useBoundProp","React","Fragment","useBoundProp","EditIcon","Box","Divider","ListItemIcon","ListItemText","MenuList","useBoundProp","variables","Fragment","Divider","Box","MenuList","ListItemIcon","ListItemText","EditIcon","useBoundProp","React","useBoundProp","ColorFilterIcon","__","useBoundProp","ColorFilterIcon","__","registerPopoverAction","controlActionsMenu","registerControlReplacement","styleTransformersRegistry","React","useState","variables","useState"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@elementor/editor-variables",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.9.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"author": "Elementor Team",
|
|
6
6
|
"homepage": "https://elementor.com/",
|
|
@@ -39,14 +39,16 @@
|
|
|
39
39
|
"dev": "tsup --config=../../tsup.dev.ts"
|
|
40
40
|
},
|
|
41
41
|
"dependencies": {
|
|
42
|
-
"@elementor/editor-editing-panel": "1.
|
|
42
|
+
"@elementor/editor-editing-panel": "1.42.0",
|
|
43
43
|
"@elementor/editor-canvas": "0.22.2",
|
|
44
44
|
"@elementor/editor-props": "0.12.1",
|
|
45
45
|
"@elementor/schema": "0.1.2",
|
|
46
|
-
"@elementor/editor-controls": "0.34.
|
|
46
|
+
"@elementor/editor-controls": "0.34.1",
|
|
47
47
|
"@elementor/icons": "1.44.0",
|
|
48
48
|
"@wordpress/i18n": "^5.13.0",
|
|
49
|
-
"@elementor/ui": "1.34.5"
|
|
49
|
+
"@elementor/ui": "1.34.5",
|
|
50
|
+
"@elementor/editor-v1-adapters": "0.12.0",
|
|
51
|
+
"@elementor/editor": "0.19.4"
|
|
50
52
|
},
|
|
51
53
|
"peerDependencies": {
|
|
52
54
|
"react": "^18.3.1"
|
|
@@ -42,7 +42,12 @@ export const ColorVariableCreation = ( { popupState }: { popupState: PopupState
|
|
|
42
42
|
};
|
|
43
43
|
|
|
44
44
|
const handleCreate = () => {
|
|
45
|
-
const key = createVariable(
|
|
45
|
+
const key = createVariable( {
|
|
46
|
+
value: color,
|
|
47
|
+
label,
|
|
48
|
+
type: colorVariablePropTypeUtil.key,
|
|
49
|
+
} );
|
|
50
|
+
|
|
46
51
|
setVariable( key );
|
|
47
52
|
closePopover();
|
|
48
53
|
};
|
|
@@ -6,7 +6,7 @@ import { Box, Divider, ListItemIcon, ListItemText, MenuList } from '@elementor/u
|
|
|
6
6
|
|
|
7
7
|
import { usePropVariables } from '../hooks/use-prop-variables';
|
|
8
8
|
import { colorVariablePropTypeUtil } from '../prop-types/color-variable-prop-type';
|
|
9
|
-
import { type
|
|
9
|
+
import { type VariableKey } from '../types';
|
|
10
10
|
import { ColorIndicator } from './color-indicator';
|
|
11
11
|
import { StyledMenuItem } from './styled-menu-item';
|
|
12
12
|
|
|
@@ -19,8 +19,8 @@ export const ColorVariablesSelection = ( { onSelect }: Props ) => {
|
|
|
19
19
|
|
|
20
20
|
const variables = usePropVariables( colorVariablePropTypeUtil.key );
|
|
21
21
|
|
|
22
|
-
const handleSetColorVariable = (
|
|
23
|
-
setVariable(
|
|
22
|
+
const handleSetColorVariable = ( key: VariableKey ) => {
|
|
23
|
+
setVariable( key );
|
|
24
24
|
|
|
25
25
|
onSelect?.();
|
|
26
26
|
};
|
|
@@ -33,7 +33,7 @@ export const ColorVariablesSelection = ( { onSelect }: Props ) => {
|
|
|
33
33
|
{ variables.map( ( { value, label, key } ) => (
|
|
34
34
|
<StyledMenuItem
|
|
35
35
|
key={ key }
|
|
36
|
-
onClick={ () => handleSetColorVariable(
|
|
36
|
+
onClick={ () => handleSetColorVariable( key ) }
|
|
37
37
|
selected={ key === variable }
|
|
38
38
|
>
|
|
39
39
|
<ListItemIcon>
|
|
@@ -6,7 +6,7 @@ import { Box, Divider, ListItemIcon, ListItemText, MenuList } from '@elementor/u
|
|
|
6
6
|
|
|
7
7
|
import { usePropVariables } from '../hooks/use-prop-variables';
|
|
8
8
|
import { fontVariablePropTypeUtil } from '../prop-types/font-variable-prop-type';
|
|
9
|
-
import { type
|
|
9
|
+
import { type VariableKey } from '../types';
|
|
10
10
|
import { StyledMenuItem } from './styled-menu-item';
|
|
11
11
|
|
|
12
12
|
type Props = {
|
|
@@ -18,8 +18,8 @@ export const FontVariablesSelection = ( { onSelect }: Props ) => {
|
|
|
18
18
|
|
|
19
19
|
const variables = usePropVariables( fontVariablePropTypeUtil.key );
|
|
20
20
|
|
|
21
|
-
const handleSetVariable = (
|
|
22
|
-
setVariable(
|
|
21
|
+
const handleSetVariable = ( key: VariableKey ) => {
|
|
22
|
+
setVariable( key );
|
|
23
23
|
|
|
24
24
|
onSelect?.();
|
|
25
25
|
};
|
|
@@ -32,7 +32,7 @@ export const FontVariablesSelection = ( { onSelect }: Props ) => {
|
|
|
32
32
|
{ variables.map( ( { value, label, key } ) => (
|
|
33
33
|
<StyledMenuItem
|
|
34
34
|
key={ key }
|
|
35
|
-
onClick={ () => handleSetVariable(
|
|
35
|
+
onClick={ () => handleSetVariable( key ) }
|
|
36
36
|
selected={ key === variable }
|
|
37
37
|
>
|
|
38
38
|
<ListItemIcon>
|
|
@@ -12,7 +12,7 @@ export const ColorVariablesSelectionControl = () => {
|
|
|
12
12
|
const { setValue } = useBoundProp();
|
|
13
13
|
const { value: variableValue } = useBoundProp( colorVariablePropTypeUtil );
|
|
14
14
|
|
|
15
|
-
const selectedVariable = useVariable(
|
|
15
|
+
const selectedVariable = useVariable( variableValue );
|
|
16
16
|
|
|
17
17
|
if ( ! selectedVariable ) {
|
|
18
18
|
throw new Error( `Global color variable ${ variableValue } not found` );
|
|
@@ -11,7 +11,7 @@ export const FontVariablesSelectionControl = () => {
|
|
|
11
11
|
const { setValue: setFontFamily } = useBoundProp();
|
|
12
12
|
const { value: variableValue } = useBoundProp( fontVariablePropTypeUtil );
|
|
13
13
|
|
|
14
|
-
const selectedVariable = useVariable(
|
|
14
|
+
const selectedVariable = useVariable( variableValue );
|
|
15
15
|
|
|
16
16
|
if ( ! selectedVariable ) {
|
|
17
17
|
throw new Error( `Global font variable ${ variableValue } not found` );
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { type StyleVariables, type Variables, type VariableValue } from './types';
|
|
2
|
+
|
|
3
|
+
type VariablesChangeCallback = ( variables: StyleVariables ) => void;
|
|
4
|
+
|
|
5
|
+
export const createStyleVariablesRepository = () => {
|
|
6
|
+
const variables: StyleVariables = {};
|
|
7
|
+
let subscription: VariablesChangeCallback;
|
|
8
|
+
|
|
9
|
+
const subscribe = ( cb: VariablesChangeCallback ) => {
|
|
10
|
+
subscription = cb;
|
|
11
|
+
|
|
12
|
+
return () => {
|
|
13
|
+
subscription = () => {};
|
|
14
|
+
};
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
const notify = () => {
|
|
18
|
+
if ( typeof subscription === 'function' ) {
|
|
19
|
+
subscription( { ...variables } );
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
const shouldUpdate = ( key: string, newValue: VariableValue ): boolean => {
|
|
24
|
+
return ! ( key in variables ) || variables[ key ] !== newValue;
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
const applyUpdates = ( updatedVars: Variables ): boolean => {
|
|
28
|
+
let hasChanges = false;
|
|
29
|
+
|
|
30
|
+
for ( const [ key, { value } ] of Object.entries( updatedVars ) ) {
|
|
31
|
+
if ( shouldUpdate( key, value ) ) {
|
|
32
|
+
variables[ key ] = value;
|
|
33
|
+
hasChanges = true;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
return hasChanges;
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
const update = ( updatedVars: Variables ) => {
|
|
41
|
+
if ( applyUpdates( updatedVars ) ) {
|
|
42
|
+
notify();
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
return {
|
|
47
|
+
subscribe,
|
|
48
|
+
update,
|
|
49
|
+
};
|
|
50
|
+
};
|
|
@@ -1,57 +1,51 @@
|
|
|
1
1
|
import { useMemo } from 'react';
|
|
2
|
+
import { type PropKey } from '@elementor/editor-props';
|
|
2
3
|
|
|
3
|
-
import {
|
|
4
|
+
import { styleVariablesRepository } from '../style-variables-repository';
|
|
5
|
+
import { type Variable, type Variables } from '../types';
|
|
4
6
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
label: string;
|
|
7
|
+
export const usePropVariables = ( propKey: PropKey ) => {
|
|
8
|
+
return useMemo( () => normalizeVariables( propKey ), [ propKey ] );
|
|
8
9
|
};
|
|
9
|
-
type Variables = Record< string, VariableData >;
|
|
10
10
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
export const usePropVariables = ( propTypeKey: string ) => {
|
|
14
|
-
return useMemo( () => normalizeVariables( propTypeKey ), [ propTypeKey ] );
|
|
15
|
-
};
|
|
16
|
-
|
|
17
|
-
export const useVariable = ( propTypeKey: string, key: string ) => {
|
|
18
|
-
if ( ! variables[ propTypeKey ]?.[ key ] ) {
|
|
11
|
+
export const useVariable = ( key: string ) => {
|
|
12
|
+
if ( ! variables?.[ key ] ) {
|
|
19
13
|
return null;
|
|
20
14
|
}
|
|
21
15
|
|
|
22
16
|
return {
|
|
23
|
-
...variables[
|
|
17
|
+
...variables[ key ],
|
|
24
18
|
key,
|
|
25
19
|
};
|
|
26
20
|
};
|
|
27
21
|
|
|
28
|
-
const normalizeVariables = (
|
|
29
|
-
return Object.entries( variables
|
|
30
|
-
|
|
31
|
-
label,
|
|
32
|
-
|
|
33
|
-
|
|
22
|
+
const normalizeVariables = ( propKey: string ) => {
|
|
23
|
+
return Object.entries( variables )
|
|
24
|
+
.filter( ( [ , { type } ] ) => type === propKey )
|
|
25
|
+
.map( ( [ key, { label, value } ] ) => ( {
|
|
26
|
+
key,
|
|
27
|
+
label,
|
|
28
|
+
value,
|
|
29
|
+
} ) );
|
|
34
30
|
};
|
|
35
31
|
|
|
36
|
-
export const createVariable = (
|
|
37
|
-
const id = generateId(
|
|
32
|
+
export const createVariable = ( variable: Variable ) => {
|
|
33
|
+
const id = generateId();
|
|
38
34
|
|
|
39
|
-
|
|
40
|
-
value: variable.value,
|
|
41
|
-
label: variable.label,
|
|
42
|
-
key: propTypeKey,
|
|
43
|
-
};
|
|
35
|
+
variables[ id ] = variable;
|
|
44
36
|
|
|
45
|
-
|
|
37
|
+
styleVariablesRepository.update( {
|
|
38
|
+
[ id ]: variable,
|
|
39
|
+
} );
|
|
46
40
|
|
|
47
41
|
return id;
|
|
48
42
|
};
|
|
49
43
|
|
|
50
44
|
// @ts-expect-error the temporary solution to get the list of variables from the server
|
|
51
|
-
const variables:
|
|
45
|
+
const variables: Variables = window?.ElementorV4Variables || {};
|
|
52
46
|
|
|
53
|
-
const generateId = ( prefix
|
|
47
|
+
const generateId = ( prefix = 'e-gv' ) => {
|
|
54
48
|
const randomHex = Math.random().toString( 16 ).slice( 2, 9 );
|
|
55
49
|
|
|
56
|
-
return `${ prefix }${ randomHex }
|
|
50
|
+
return `${ prefix }${ randomHex }`;
|
|
57
51
|
};
|
package/src/init.ts
CHANGED
|
@@ -1,8 +1,16 @@
|
|
|
1
|
+
import { injectIntoTop } from '@elementor/editor';
|
|
2
|
+
|
|
1
3
|
import { initColorVariables } from './init-color-variables';
|
|
2
4
|
import { initFontVariables } from './init-font-variables';
|
|
5
|
+
import { StyleVariablesRenderer } from './renderers/style-variables-renderer';
|
|
3
6
|
|
|
4
7
|
export function init() {
|
|
5
8
|
initColorVariables();
|
|
6
9
|
|
|
7
10
|
initFontVariables();
|
|
11
|
+
|
|
12
|
+
injectIntoTop( {
|
|
13
|
+
id: 'canvas-style-variables-render',
|
|
14
|
+
component: StyleVariablesRenderer,
|
|
15
|
+
} );
|
|
8
16
|
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { useEffect, useState } from 'react';
|
|
3
|
+
import { __privateUseListenTo as useListenTo, commandEndEvent } from '@elementor/editor-v1-adapters';
|
|
4
|
+
import { Portal } from '@elementor/ui';
|
|
5
|
+
|
|
6
|
+
import { styleVariablesRepository } from '../style-variables-repository';
|
|
7
|
+
import { getCanvasIframeDocument } from '../sync/get-canvas-iframe-document';
|
|
8
|
+
import { type StyleVariables } from '../types';
|
|
9
|
+
|
|
10
|
+
const VARIABLES_WRAPPER = 'body';
|
|
11
|
+
|
|
12
|
+
export function StyleVariablesRenderer() {
|
|
13
|
+
const container = usePortalContainer();
|
|
14
|
+
const styleVariables = useStyleVariables();
|
|
15
|
+
|
|
16
|
+
const hasVariables = Object.keys( styleVariables ).length > 0;
|
|
17
|
+
|
|
18
|
+
if ( ! container || ! hasVariables ) {
|
|
19
|
+
return null;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
const cssVariables = convertToCssVariables( styleVariables );
|
|
23
|
+
const wrappedCss = `${ VARIABLES_WRAPPER }{${ cssVariables }}`;
|
|
24
|
+
|
|
25
|
+
return (
|
|
26
|
+
<Portal container={ container }>
|
|
27
|
+
<style data-e-style-id="e-variables" key={ wrappedCss }>
|
|
28
|
+
{ wrappedCss }
|
|
29
|
+
</style>
|
|
30
|
+
</Portal>
|
|
31
|
+
);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
function usePortalContainer() {
|
|
35
|
+
return useListenTo( commandEndEvent( 'editor/documents/attach-preview' ), () => getCanvasIframeDocument()?.head );
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
function useStyleVariables() {
|
|
39
|
+
const [ variables, setVariables ] = useState< StyleVariables >( {} );
|
|
40
|
+
|
|
41
|
+
useEffect( () => {
|
|
42
|
+
const unsubscribe = styleVariablesRepository.subscribe( setVariables );
|
|
43
|
+
|
|
44
|
+
return () => {
|
|
45
|
+
unsubscribe();
|
|
46
|
+
};
|
|
47
|
+
}, [] );
|
|
48
|
+
|
|
49
|
+
return variables;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
function convertToCssVariables( variables: StyleVariables ): string {
|
|
53
|
+
return Object.entries( variables )
|
|
54
|
+
.map( ( [ key, value ] ) => `--${ key }:${ value };` )
|
|
55
|
+
.join( '' );
|
|
56
|
+
}
|
package/src/types.ts
CHANGED
|
@@ -1,5 +1,15 @@
|
|
|
1
|
+
export type VariableKey = string;
|
|
2
|
+
|
|
3
|
+
export type VariableValue = string;
|
|
4
|
+
|
|
1
5
|
export type Variable = {
|
|
2
|
-
value:
|
|
6
|
+
value: VariableValue;
|
|
3
7
|
label: string;
|
|
4
|
-
|
|
8
|
+
type: string;
|
|
5
9
|
};
|
|
10
|
+
|
|
11
|
+
export type Variables = {
|
|
12
|
+
[ key: VariableKey ]: Variable;
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
export type StyleVariables = Record< VariableKey, VariableValue >;
|