@elementor/editor-variables 0.3.2 → 0.5.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/dist/index.mjs CHANGED
@@ -1,101 +1,68 @@
1
- // src/init.ts
1
+ // src/init-color-variables.ts
2
2
  import { styleTransformersRegistry } from "@elementor/editor-canvas";
3
3
  import { controlActionsMenu, registerControlReplacement } from "@elementor/editor-editing-panel";
4
4
 
5
- // src/controls/variables-selection-control.tsx
5
+ // src/controls/color-variables-selection-control.tsx
6
6
  import * as React3 from "react";
7
7
  import { useBoundProp as useBoundProp2 } from "@elementor/editor-controls";
8
8
 
9
- // src/components/variables-selection.tsx
9
+ // src/components/color-indicator.tsx
10
+ import { styled, UnstableColorIndicator } from "@elementor/ui";
11
+ var ColorIndicator = styled(UnstableColorIndicator)(({ theme }) => ({
12
+ borderRadius: `${theme.shape.borderRadius / 2}px`
13
+ }));
14
+
15
+ // src/components/color-variables-selection.tsx
10
16
  import * as React from "react";
11
17
  import { Fragment } from "react";
12
18
  import { useBoundProp } from "@elementor/editor-controls";
13
19
  import { EditIcon } from "@elementor/icons";
14
- import { Box, Divider, ListItemIcon, ListItemText, MenuItem, MenuList, styled as styled2 } from "@elementor/ui";
20
+ import { Box, Divider, ListItemIcon, ListItemText, MenuList } from "@elementor/ui";
15
21
 
16
22
  // src/hooks/use-prop-variables.ts
17
23
  import { useMemo } from "react";
18
- var usePropVariables = () => {
19
- return useMemo(() => getVariables(), []);
24
+ var usePropVariables = (propTypeKey) => {
25
+ return useMemo(() => normalizeVariables(propTypeKey), [propTypeKey]);
20
26
  };
21
- var useVariable = (key) => {
22
- if (!variables[key]) {
27
+ var useVariable = (propTypeKey, key) => {
28
+ if (!variables[propTypeKey][key]) {
23
29
  return null;
24
30
  }
25
31
  return {
26
- ...variables[key],
32
+ ...variables[propTypeKey][key],
27
33
  key
28
34
  };
29
35
  };
30
- var getVariables = () => {
31
- return normalizeVariables();
32
- };
33
- var normalizeVariables = () => {
34
- return Object.entries(variables).map(([key, { label, value }]) => ({
36
+ var normalizeVariables = (propTypeKey) => {
37
+ return Object.entries(variables[propTypeKey]).map(([key, { label, value }]) => ({
35
38
  key,
36
39
  label,
37
40
  value
38
41
  }));
39
42
  };
40
- var variables = window?.ElementorV4Variables ?? {
41
- "e-gc-001": {
42
- value: "#ffffff",
43
- label: "Main: white"
44
- },
45
- "e-gc-002": {
46
- value: "#000000",
47
- label: "Main: black"
48
- },
49
- "e-gc-a01": {
50
- value: "#FF0000",
51
- label: "Danger: red"
52
- },
53
- "e-gc-a02": {
54
- value: "#0000FF",
55
- label: "Informative: blue"
56
- },
57
- "e-gc-a03": {
58
- value: "#FF7BE5",
59
- label: "Elementor: pint"
60
- },
61
- "e-gc-a04": {
62
- value: "#808080",
63
- label: "Gray: background"
64
- },
65
- "e-gc-b01": {
66
- value: "#213555",
67
- label: "Navy: primary"
68
- },
69
- "e-gc-b02": {
70
- value: "#3E5879",
71
- label: "Navy: secondary"
72
- },
73
- "e-gc-b03": {
74
- value: "#D8C4B6",
75
- label: "Navy: light"
76
- },
77
- "e-gc-b04": {
78
- value: "#F5EFE7",
79
- label: "Navy long text variable name: background"
80
- }
81
- };
43
+ var variables = window?.ElementorV4Variables;
82
44
 
83
45
  // src/prop-types/color-variable-prop-type.ts
84
46
  import { createPropUtils } from "@elementor/editor-props";
85
47
  import { z } from "@elementor/schema";
86
48
  var colorVariablePropTypeUtil = createPropUtils("global-color-variable", z.string());
87
49
 
88
- // src/components/color-indicator.tsx
89
- import { styled, UnstableColorIndicator } from "@elementor/ui";
90
- var ColorIndicator = styled(UnstableColorIndicator)(({ theme }) => ({
91
- borderRadius: `${theme.shape.borderRadius / 2}px`
50
+ // src/components/styled-menu-item.tsx
51
+ import { MenuItem, styled as styled2 } from "@elementor/ui";
52
+ var StyledMenuItem = styled2(MenuItem)(() => ({
53
+ pl: 2,
54
+ pr: 1,
55
+ py: 0.5,
56
+ "&:hover .MuiSvgIcon-root": {
57
+ opacity: 1
58
+ }
92
59
  }));
93
60
 
94
- // src/components/variables-selection.tsx
95
- var VariablesSelection = ({ onSelect }) => {
61
+ // src/components/color-variables-selection.tsx
62
+ var ColorVariablesSelection = ({ onSelect }) => {
96
63
  const { value: variable, setValue: setVariable } = useBoundProp(colorVariablePropTypeUtil);
97
- const variables2 = usePropVariables();
98
- const handleSetVariable = (newValue) => {
64
+ const variables2 = usePropVariables(colorVariablePropTypeUtil.key);
65
+ const handleSetColorVariable = (newValue) => {
99
66
  setVariable(newValue.key);
100
67
  onSelect?.();
101
68
  };
@@ -103,7 +70,7 @@ var VariablesSelection = ({ onSelect }) => {
103
70
  StyledMenuItem,
104
71
  {
105
72
  key,
106
- onClick: () => handleSetVariable({ value, label, key }),
73
+ onClick: () => handleSetColorVariable({ value, label, key }),
107
74
  selected: key === variable
108
75
  },
109
76
  /* @__PURE__ */ React.createElement(ListItemIcon, null, /* @__PURE__ */ React.createElement(ColorIndicator, { size: "inherit", component: "span", value })),
@@ -135,14 +102,6 @@ var VariablesSelection = ({ onSelect }) => {
135
102
  /* @__PURE__ */ React.createElement(EditIcon, { color: "action", fontSize: "inherit", sx: { mx: 1, opacity: "0" } })
136
103
  )))));
137
104
  };
138
- var StyledMenuItem = styled2(MenuItem)(() => ({
139
- pl: 2,
140
- pr: 1,
141
- py: 0.5,
142
- "&:hover .MuiSvgIcon-root": {
143
- opacity: 1
144
- }
145
- }));
146
105
 
147
106
  // src/components/variables-selection-popover.tsx
148
107
  import * as React2 from "react";
@@ -161,18 +120,23 @@ import {
161
120
  usePopupState
162
121
  } from "@elementor/ui";
163
122
  import { __ } from "@wordpress/i18n";
164
- var VariablesSelectionPopover = ({ selectedVariable, unlinkVariable, children }) => {
123
+ var VariablesSelectionPopover = ({
124
+ selectedVariable,
125
+ unlinkVariable,
126
+ startTagAdornment,
127
+ children
128
+ }) => {
165
129
  const id = useId();
166
130
  const popupState = usePopupState({ variant: "popover", popupId: `elementor-variables-action-${id}` });
167
131
  const closePopover = () => popupState.close();
168
- const { value, label } = selectedVariable;
132
+ const { label } = selectedVariable;
169
133
  return /* @__PURE__ */ React2.createElement(Box2, null, /* @__PURE__ */ React2.createElement(
170
134
  Tag,
171
135
  {
172
136
  fullWidth: true,
173
137
  showActionsOnHover: true,
174
138
  ...bindTrigger(popupState),
175
- startIcon: /* @__PURE__ */ React2.createElement(Stack, { spacing: 1, direction: "row", alignItems: "center" }, /* @__PURE__ */ React2.createElement(ColorIndicator, { size: "inherit", component: "span", value }), /* @__PURE__ */ React2.createElement(ColorFilterIcon, { fontSize: "inherit", sx: { mr: 1 } })),
139
+ startIcon: /* @__PURE__ */ React2.createElement(Stack, { spacing: 1, direction: "row", alignItems: "center" }, startTagAdornment, /* @__PURE__ */ React2.createElement(ColorFilterIcon, { fontSize: "inherit", sx: { mr: 1 } })),
176
140
  label: /* @__PURE__ */ React2.createElement(Box2, { sx: { display: "inline-grid" } }, /* @__PURE__ */ React2.createElement(Typography, { sx: { textOverflow: "ellipsis", overflowX: "hidden" }, variant: "subtitle2" }, label)),
177
141
  actions: /* @__PURE__ */ React2.createElement(IconButton, { size: "tiny", onClick: unlinkVariable, "aria-label": __("Unlink", "elementor") }, /* @__PURE__ */ React2.createElement(DetachIcon, { fontSize: "tiny" }))
178
142
  }
@@ -196,43 +160,62 @@ var VariablesSelectionPopover = ({ selectedVariable, unlinkVariable, children })
196
160
  ));
197
161
  };
198
162
 
199
- // src/controls/variables-selection-control.tsx
200
- var VariablesSelectionControl = () => {
163
+ // src/controls/color-variables-selection-control.tsx
164
+ var ColorVariablesSelectionControl = () => {
201
165
  const { setValue } = useBoundProp2();
202
166
  const { value: variableValue } = useBoundProp2(colorVariablePropTypeUtil);
203
167
  const unlinkVariable = () => {
204
- setValue("");
168
+ setValue(null);
205
169
  };
206
- const selectedVariable = useVariable(variableValue);
170
+ const selectedVariable = useVariable(colorVariablePropTypeUtil.key, variableValue);
207
171
  if (!selectedVariable) {
208
172
  throw new Error(`Global color variable ${variableValue} not found`);
209
173
  }
210
- return /* @__PURE__ */ React3.createElement(VariablesSelectionPopover, { selectedVariable, unlinkVariable }, ({ closePopover }) => /* @__PURE__ */ React3.createElement(VariablesSelection, { onSelect: closePopover }));
174
+ return /* @__PURE__ */ React3.createElement(
175
+ VariablesSelectionPopover,
176
+ {
177
+ selectedVariable,
178
+ unlinkVariable,
179
+ startTagAdornment: /* @__PURE__ */ React3.createElement(ColorIndicator, { size: "inherit", component: "span", value: selectedVariable.value })
180
+ },
181
+ ({ closePopover }) => /* @__PURE__ */ React3.createElement(ColorVariablesSelection, { onSelect: closePopover })
182
+ );
211
183
  };
212
184
 
213
- // src/hooks/use-prop-variable-action.tsx
185
+ // src/hooks/use-prop-color-variable-action.tsx
214
186
  import * as React4 from "react";
215
187
  import { useBoundProp as useBoundProp3 } from "@elementor/editor-editing-panel";
216
188
  import { ColorFilterIcon as ColorFilterIcon2 } from "@elementor/icons";
217
189
  import { __ as __2 } from "@wordpress/i18n";
218
190
 
191
+ // src/prop-types/font-variable-prop-type.ts
192
+ import { createPropUtils as createPropUtils2 } from "@elementor/editor-props";
193
+ import { z as z2 } from "@elementor/schema";
194
+ var fontVariablePropTypeUtil = createPropUtils2("global-font-variable", z2.string());
195
+
219
196
  // src/utils.ts
220
- var hasAssignedVariable = (propValue) => {
197
+ var hasAssignedColorVariable = (propValue) => {
221
198
  return !!colorVariablePropTypeUtil.isValid(propValue);
222
199
  };
223
- var supportsVariables = (propType) => {
200
+ var supportsColorVariables = (propType) => {
224
201
  return propType.kind === "union" && colorVariablePropTypeUtil.key in propType.prop_types;
225
202
  };
203
+ var hasAssignedFontVariable = (propValue) => {
204
+ return !!fontVariablePropTypeUtil.isValid(propValue);
205
+ };
206
+ var supportsFontVariables = (propType) => {
207
+ return propType.kind === "union" && fontVariablePropTypeUtil.key in propType.prop_types;
208
+ };
226
209
 
227
- // src/hooks/use-prop-variable-action.tsx
228
- var usePropVariableAction = () => {
210
+ // src/hooks/use-prop-color-variable-action.tsx
211
+ var usePropColorVariableAction = () => {
229
212
  const { propType } = useBoundProp3();
230
- const visible = !!propType && supportsVariables(propType);
213
+ const visible = !!propType && supportsColorVariables(propType);
231
214
  return {
232
215
  visible,
233
216
  icon: ColorFilterIcon2,
234
217
  title: __2("Variables", "elementor"),
235
- popoverContent: ({ closePopover }) => /* @__PURE__ */ React4.createElement(VariablesSelection, { onSelect: closePopover })
218
+ popoverContent: ({ closePopover }) => /* @__PURE__ */ React4.createElement(ColorVariablesSelection, { onSelect: closePopover })
236
219
  };
237
220
  };
238
221
 
@@ -245,19 +228,127 @@ var variableTransformer = createTransformer((value) => {
245
228
  return `var(--${value})`;
246
229
  });
247
230
 
248
- // src/init.ts
231
+ // src/init-color-variables.ts
249
232
  var { registerPopoverAction } = controlActionsMenu;
250
- function init() {
233
+ function initColorVariables() {
251
234
  registerControlReplacement({
252
- component: VariablesSelectionControl,
253
- condition: ({ value }) => hasAssignedVariable(value)
235
+ component: ColorVariablesSelectionControl,
236
+ condition: ({ value }) => hasAssignedColorVariable(value)
254
237
  });
255
238
  registerPopoverAction({
256
- id: "variables",
257
- useProps: usePropVariableAction
239
+ id: "color-variables",
240
+ useProps: usePropColorVariableAction
258
241
  });
259
242
  styleTransformersRegistry.register(colorVariablePropTypeUtil.key, variableTransformer);
260
243
  }
244
+
245
+ // src/init-font-variables.ts
246
+ import { styleTransformersRegistry as styleTransformersRegistry2 } from "@elementor/editor-canvas";
247
+ import { controlActionsMenu as controlActionsMenu2, registerControlReplacement as registerControlReplacement2 } from "@elementor/editor-editing-panel";
248
+
249
+ // src/controls/font-variables-selection-control.tsx
250
+ import * as React6 from "react";
251
+ import { useBoundProp as useBoundProp5 } from "@elementor/editor-controls";
252
+
253
+ // src/components/font-variables-selection.tsx
254
+ import * as React5 from "react";
255
+ import { Fragment as Fragment2 } from "react";
256
+ import { useBoundProp as useBoundProp4 } from "@elementor/editor-controls";
257
+ import { EditIcon as EditIcon2, TextIcon } from "@elementor/icons";
258
+ import { Box as Box3, Divider as Divider2, ListItemIcon as ListItemIcon2, ListItemText as ListItemText2, MenuList as MenuList2 } from "@elementor/ui";
259
+ var FontVariablesSelection = ({ onSelect }) => {
260
+ const { value: variable, setValue: setVariable } = useBoundProp4(fontVariablePropTypeUtil);
261
+ const variables2 = usePropVariables(fontVariablePropTypeUtil.key);
262
+ const handleSetVariable = (newValue) => {
263
+ setVariable(newValue.key);
264
+ onSelect?.();
265
+ };
266
+ return /* @__PURE__ */ React5.createElement(Fragment2, null, /* @__PURE__ */ React5.createElement(Divider2, null), /* @__PURE__ */ React5.createElement(Box3, { sx: { overflowY: "auto", height: 260, width: 220 } }, /* @__PURE__ */ React5.createElement(MenuList2, { role: "listbox", tabIndex: 0 }, variables2.map(({ value, label, key }) => /* @__PURE__ */ React5.createElement(
267
+ StyledMenuItem,
268
+ {
269
+ key,
270
+ onClick: () => handleSetVariable({ value, label, key }),
271
+ selected: key === variable
272
+ },
273
+ /* @__PURE__ */ React5.createElement(ListItemIcon2, null, /* @__PURE__ */ React5.createElement(TextIcon, null)),
274
+ /* @__PURE__ */ React5.createElement(
275
+ ListItemText2,
276
+ {
277
+ primary: label,
278
+ secondary: value,
279
+ primaryTypographyProps: {
280
+ variant: "body2",
281
+ color: "text.secondary",
282
+ style: {
283
+ lineHeight: 2,
284
+ display: "inline-block",
285
+ overflow: "hidden",
286
+ textOverflow: "ellipsis",
287
+ whiteSpace: "nowrap",
288
+ maxWidth: "81px"
289
+ }
290
+ },
291
+ secondaryTypographyProps: {
292
+ variant: "caption",
293
+ color: "text.tertiary",
294
+ style: { marginTop: "1px", lineHeight: "1" }
295
+ },
296
+ sx: { display: "flex", alignItems: "center", gap: 1 }
297
+ }
298
+ ),
299
+ /* @__PURE__ */ React5.createElement(EditIcon2, { color: "action", fontSize: "inherit", sx: { mx: 1, opacity: "0" } })
300
+ )))));
301
+ };
302
+
303
+ // src/controls/font-variables-selection-control.tsx
304
+ var FontVariablesSelectionControl = () => {
305
+ const { setValue } = useBoundProp5();
306
+ const { value: variableValue } = useBoundProp5(fontVariablePropTypeUtil);
307
+ const unlinkVariable = () => {
308
+ setValue(null);
309
+ };
310
+ const selectedVariable = useVariable(fontVariablePropTypeUtil.key, variableValue);
311
+ if (!selectedVariable) {
312
+ throw new Error(`Global font variable ${variableValue} not found`);
313
+ }
314
+ return /* @__PURE__ */ React6.createElement(VariablesSelectionPopover, { selectedVariable, unlinkVariable }, ({ closePopover }) => /* @__PURE__ */ React6.createElement(FontVariablesSelection, { onSelect: closePopover }));
315
+ };
316
+
317
+ // src/hooks/use-prop-font-variable-action.tsx
318
+ import * as React7 from "react";
319
+ import { useBoundProp as useBoundProp6 } from "@elementor/editor-editing-panel";
320
+ import { ColorFilterIcon as ColorFilterIcon3 } from "@elementor/icons";
321
+ import { __ as __3 } from "@wordpress/i18n";
322
+ var usePropFontVariableAction = () => {
323
+ const { propType } = useBoundProp6();
324
+ const visible = !!propType && supportsFontVariables(propType);
325
+ return {
326
+ visible,
327
+ icon: ColorFilterIcon3,
328
+ title: __3("Variables", "elementor"),
329
+ popoverContent: ({ closePopover }) => /* @__PURE__ */ React7.createElement(FontVariablesSelection, { onSelect: closePopover })
330
+ };
331
+ };
332
+
333
+ // src/init-font-variables.ts
334
+ var { registerPopoverAction: registerPopoverAction2 } = controlActionsMenu2;
335
+ function initFontVariables() {
336
+ registerControlReplacement2({
337
+ component: FontVariablesSelectionControl,
338
+ condition: ({ value }) => hasAssignedFontVariable(value)
339
+ });
340
+ registerPopoverAction2({
341
+ id: "font-variables",
342
+ useProps: usePropFontVariableAction
343
+ });
344
+ styleTransformersRegistry2.register(fontVariablePropTypeUtil.key, variableTransformer);
345
+ }
346
+
347
+ // src/init.ts
348
+ function init() {
349
+ initColorVariables();
350
+ initFontVariables();
351
+ }
261
352
  export {
262
353
  init
263
354
  };
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/init.ts","../src/controls/variables-selection-control.tsx","../src/components/variables-selection.tsx","../src/hooks/use-prop-variables.ts","../src/prop-types/color-variable-prop-type.ts","../src/components/color-indicator.tsx","../src/components/variables-selection-popover.tsx","../src/hooks/use-prop-variable-action.tsx","../src/utils.ts","../src/transformers/variable-transformer.ts"],"sourcesContent":["import { styleTransformersRegistry } from '@elementor/editor-canvas';\nimport { controlActionsMenu, registerControlReplacement } from '@elementor/editor-editing-panel';\n\nimport { VariablesSelectionControl } from './controls/variables-selection-control';\nimport { usePropVariableAction } from './hooks/use-prop-variable-action';\nimport { colorVariablePropTypeUtil } from './prop-types/color-variable-prop-type';\nimport { variableTransformer } from './transformers/variable-transformer';\nimport { hasAssignedVariable } from './utils';\n\nconst { registerPopoverAction } = controlActionsMenu;\n\nexport function init() {\n\tregisterControlReplacement( {\n\t\tcomponent: VariablesSelectionControl,\n\t\tcondition: ( { value } ) => hasAssignedVariable( value ),\n\t} );\n\n\tregisterPopoverAction( {\n\t\tid: 'variables',\n\t\tuseProps: usePropVariableAction,\n\t} );\n\n\tstyleTransformersRegistry.register( colorVariablePropTypeUtil.key, variableTransformer );\n}\n","import * as React from 'react';\nimport { useBoundProp } from '@elementor/editor-controls';\n\nimport { VariablesSelection } from '../components/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 VariablesSelectionControl = () => {\n\tconst { setValue } = useBoundProp();\n\tconst { value: variableValue } = useBoundProp( colorVariablePropTypeUtil );\n\n\tconst unlinkVariable = () => {\n\t\tsetValue( '' );\n\t};\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\treturn (\n\t\t<VariablesSelectionPopover selectedVariable={ selectedVariable } unlinkVariable={ unlinkVariable }>\n\t\t\t{ ( { closePopover } ) => <VariablesSelection 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 } from '@elementor/icons';\nimport { Box, Divider, ListItemIcon, ListItemText, MenuItem, MenuList, styled } 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';\n\ntype Props = {\n\tonSelect?: () => void;\n};\n\nexport const VariablesSelection = ( { onSelect }: Props ) => {\n\tconst { value: variable, setValue: setVariable } = useBoundProp( colorVariablePropTypeUtil );\n\n\tconst variables = usePropVariables();\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<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\nconst 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 { useMemo } from 'react';\n\nimport { type Variable } from '../types';\n\nexport const usePropVariables = () => {\n\treturn useMemo( () => getVariables(), [] );\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 getVariables = (): Variable[] => {\n\treturn normalizeVariables();\n};\n\nconst normalizeVariables = () => {\n\treturn Object.entries( variables ).map( ( [ key, { label, value } ] ) => ( {\n\t\tkey,\n\t\tlabel,\n\t\tvalue,\n\t} ) );\n};\n\n// @ts-expect-error the temporary solution to get the list of variables from the server\nconst variables: Record< string, { value: string; label: string } > = window?.ElementorV4Variables ?? {\n\t'e-gc-001': {\n\t\tvalue: '#ffffff',\n\t\tlabel: 'Main: white',\n\t},\n\t'e-gc-002': {\n\t\tvalue: '#000000',\n\t\tlabel: 'Main: black',\n\t},\n\t'e-gc-a01': {\n\t\tvalue: '#FF0000',\n\t\tlabel: 'Danger: red',\n\t},\n\t'e-gc-a02': {\n\t\tvalue: '#0000FF',\n\t\tlabel: 'Informative: blue',\n\t},\n\t'e-gc-a03': {\n\t\tvalue: '#FF7BE5',\n\t\tlabel: 'Elementor: pint',\n\t},\n\t'e-gc-a04': {\n\t\tvalue: '#808080',\n\t\tlabel: 'Gray: background',\n\t},\n\n\t'e-gc-b01': {\n\t\tvalue: '#213555',\n\t\tlabel: 'Navy: primary',\n\t},\n\t'e-gc-b02': {\n\t\tvalue: '#3E5879',\n\t\tlabel: 'Navy: secondary',\n\t},\n\t'e-gc-b03': {\n\t\tvalue: '#D8C4B6',\n\t\tlabel: 'Navy: light',\n\t},\n\t'e-gc-b04': {\n\t\tvalue: '#F5EFE7',\n\t\tlabel: 'Navy long text variable name: background',\n\t},\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 { 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 { useId } from 'react';\nimport { ColorFilterIcon, DetachIcon } 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 { ColorIndicator } from './color-indicator';\n\ntype Props = {\n\tselectedVariable: Variable;\n\tunlinkVariable: () => void;\n\tchildren: ( { closePopover }: { closePopover: () => void } ) => React.ReactNode;\n};\n\nexport const VariablesSelectionPopover = ( { selectedVariable, unlinkVariable, children }: Props ) => {\n\tconst id = useId();\n\tconst popupState = usePopupState( { variant: 'popover', popupId: `elementor-variables-action-${ id }` } );\n\n\tconst closePopover = () => popupState.close();\n\n\tconst { value, label } = selectedVariable;\n\n\treturn (\n\t\t<Box>\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<ColorIndicator size=\"inherit\" component=\"span\" value={ value } />\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\tdisableScrollLock\n\t\t\t\tanchorOrigin={ { vertical: 'bottom', horizontal: 'center' } }\n\t\t\t\ttransformOrigin={ { vertical: 'top', horizontal: 'center' } }\n\t\t\t\t{ ...bindPopover( popupState ) }\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<CloseButton\n\t\t\t\t\t\tslotProps={ { icon: { fontSize: 'tiny' } } }\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\t\t\t\t{ children( { closePopover } ) }\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 { VariablesSelection } from '../components/variables-selection';\nimport { supportsVariables } from '../utils';\n\nexport const usePropVariableAction = (): PopoverActionProps => {\n\tconst { propType } = useBoundProp();\n\n\tconst visible = !! propType && supportsVariables( propType );\n\n\treturn {\n\t\tvisible,\n\t\ticon: ColorFilterIcon,\n\t\ttitle: __( 'Variables', 'elementor' ),\n\t\tpopoverContent: ( { closePopover } ) => <VariablesSelection onSelect={ closePopover } />,\n\t};\n};\n","import { type PropType, type PropValue } from '@elementor/editor-props';\n\nimport { colorVariablePropTypeUtil } from './prop-types/color-variable-prop-type';\n\nexport const hasAssignedVariable = ( propValue: PropValue ): boolean => {\n\treturn !! colorVariablePropTypeUtil.isValid( propValue );\n};\n\nexport const supportsVariables = ( propType: PropType ): boolean => {\n\treturn propType.kind === 'union' && colorVariablePropTypeUtil.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"],"mappings":";AAAA,SAAS,iCAAiC;AAC1C,SAAS,oBAAoB,kCAAkC;;;ACD/D,YAAYA,YAAW;AACvB,SAAS,gBAAAC,qBAAoB;;;ACD7B,YAAY,WAAW;AACvB,SAAS,gBAAgB;AACzB,SAA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,SAAkC,gBAAAC,qBAAoB;AACtD,SAAS,mBAAAC,wBAAuB;AAChC,SAAS,MAAAC,WAAU;;;ACCZ,IAAM,sBAAsB,CAAE,cAAmC;AACvE,SAAO,CAAC,CAAE,0BAA0B,QAAS,SAAU;AACxD;AAEO,IAAM,oBAAoB,CAAE,aAAiC;AACnE,SAAO,SAAS,SAAS,WAAW,0BAA0B,OAAO,SAAS;AAC/E;;;ADFO,IAAM,wBAAwB,MAA0B;AAC9D,QAAM,EAAE,SAAS,IAAIC,cAAa;AAElC,QAAM,UAAU,CAAC,CAAE,YAAY,kBAAmB,QAAS;AAE3D,SAAO;AAAA,IACN;AAAA,IACA,MAAMC;AAAA,IACN,OAAOC,IAAI,aAAa,WAAY;AAAA,IACpC,gBAAgB,CAAE,EAAE,aAAa,MAAO,qCAAC,sBAAmB,UAAW,cAAe;AAAA,EACvF;AACD;;;AEnBA,SAAS,yBAAyB;AAE3B,IAAM,sBAAsB,kBAAmB,CAAE,UAAmB;AAC1E,MAAK,CAAE,MAAM,KAAK,GAAI;AACrB,WAAO;AAAA,EACR;AAEA,SAAO,SAAU,KAAM;AACxB,CAAE;;;ATCF,IAAM,EAAE,sBAAsB,IAAI;AAE3B,SAAS,OAAO;AACtB,6BAA4B;AAAA,IAC3B,WAAW;AAAA,IACX,WAAW,CAAE,EAAE,MAAM,MAAO,oBAAqB,KAAM;AAAA,EACxD,CAAE;AAEF,wBAAuB;AAAA,IACtB,IAAI;AAAA,IACJ,UAAU;AAAA,EACX,CAAE;AAEF,4BAA0B,SAAU,0BAA0B,KAAK,mBAAoB;AACxF;","names":["React","useBoundProp","styled","variables","styled","React","Box","Box","useBoundProp","React","useBoundProp","ColorFilterIcon","__","useBoundProp","ColorFilterIcon","__"]}
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/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';\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 unlinkVariable = () => {\n\t\tsetValue( null );\n\t};\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\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\ntype Variables = Record< string, { value: string; label: string } >;\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\n// @ts-expect-error the temporary solution to get the list of variables from the server\nconst variables: VariablesGroup = window?.ElementorV4Variables;\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 } from 'react';\nimport { ColorFilterIcon, DetachIcon } 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';\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\n\tconst closePopover = () => popupState.close();\n\n\tconst { label } = selectedVariable;\n\n\treturn (\n\t\t<Box>\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\tdisableScrollLock\n\t\t\t\tanchorOrigin={ { vertical: 'bottom', horizontal: 'center' } }\n\t\t\t\ttransformOrigin={ { vertical: 'top', horizontal: 'center' } }\n\t\t\t\t{ ...bindPopover( popupState ) }\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<CloseButton\n\t\t\t\t\t\tslotProps={ { icon: { fontSize: 'tiny' } } }\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\t\t\t\t{ children( { closePopover } ) }\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';\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 } = useBoundProp();\n\tconst { value: variableValue } = useBoundProp( fontVariablePropTypeUtil );\n\n\tconst unlinkVariable = () => {\n\t\tsetValue( null );\n\t};\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\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;;;ACD7B,SAAS,QAAQ,8BAA8B;AAExC,IAAM,iBAAiB,OAAQ,sBAAuB,EAAG,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M,iBAAiB,MAAM;AAC5B,aAAU,IAAK;AAAA,EAChB;AAEA,QAAM,mBAAmB,YAAa,yBAAyB,KAAK,aAAc;AAElF,MAAK,CAAE,kBAAmB;AACzB,UAAM,IAAI,MAAO,wBAAyB,aAAc,YAAa;AAAA,EACtE;AAEA,SACC,qCAAC,6BAA0B,kBAAsC,kBAC9D,CAAE,EAAE,aAAa,MAAO,qCAAC,0BAAuB,UAAW,cAAe,CAC7E;AAEF;;;AE3BA,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","Box","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"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@elementor/editor-variables",
3
- "version": "0.3.2",
3
+ "version": "0.5.0",
4
4
  "private": false,
5
5
  "author": "Elementor Team",
6
6
  "homepage": "https://elementor.com/",
@@ -39,11 +39,11 @@
39
39
  "dev": "tsup --config=../../tsup.dev.ts"
40
40
  },
41
41
  "dependencies": {
42
- "@elementor/editor-editing-panel": "1.33.1",
43
- "@elementor/editor-canvas": "0.21.0",
42
+ "@elementor/editor-editing-panel": "1.35.0",
43
+ "@elementor/editor-canvas": "0.21.2",
44
44
  "@elementor/editor-props": "0.12.0",
45
45
  "@elementor/schema": "0.1.2",
46
- "@elementor/editor-controls": "0.28.2",
46
+ "@elementor/editor-controls": "0.30.0",
47
47
  "@elementor/icons": "1.40.1",
48
48
  "@wordpress/i18n": "^5.13.0",
49
49
  "@elementor/ui": "1.34.2"
@@ -2,23 +2,24 @@ import * as React from 'react';
2
2
  import { Fragment } from 'react';
3
3
  import { useBoundProp } from '@elementor/editor-controls';
4
4
  import { EditIcon } from '@elementor/icons';
5
- import { Box, Divider, ListItemIcon, ListItemText, MenuItem, MenuList, styled } from '@elementor/ui';
5
+ import { Box, Divider, ListItemIcon, ListItemText, MenuList } from '@elementor/ui';
6
6
 
7
7
  import { usePropVariables } from '../hooks/use-prop-variables';
8
8
  import { colorVariablePropTypeUtil } from '../prop-types/color-variable-prop-type';
9
9
  import { type Variable } from '../types';
10
10
  import { ColorIndicator } from './color-indicator';
11
+ import { StyledMenuItem } from './styled-menu-item';
11
12
 
12
13
  type Props = {
13
14
  onSelect?: () => void;
14
15
  };
15
16
 
16
- export const VariablesSelection = ( { onSelect }: Props ) => {
17
+ export const ColorVariablesSelection = ( { onSelect }: Props ) => {
17
18
  const { value: variable, setValue: setVariable } = useBoundProp( colorVariablePropTypeUtil );
18
19
 
19
- const variables = usePropVariables();
20
+ const variables = usePropVariables( colorVariablePropTypeUtil.key );
20
21
 
21
- const handleSetVariable = ( newValue: Variable ) => {
22
+ const handleSetColorVariable = ( newValue: Variable ) => {
22
23
  setVariable( newValue.key );
23
24
 
24
25
  onSelect?.();
@@ -32,7 +33,7 @@ export const VariablesSelection = ( { onSelect }: Props ) => {
32
33
  { variables.map( ( { value, label, key } ) => (
33
34
  <StyledMenuItem
34
35
  key={ key }
35
- onClick={ () => handleSetVariable( { value, label, key } ) }
36
+ onClick={ () => handleSetColorVariable( { value, label, key } ) }
36
37
  selected={ key === variable }
37
38
  >
38
39
  <ListItemIcon>
@@ -68,12 +69,3 @@ export const VariablesSelection = ( { onSelect }: Props ) => {
68
69
  </Fragment>
69
70
  );
70
71
  };
71
-
72
- const StyledMenuItem = styled( MenuItem )( () => ( {
73
- pl: 2,
74
- pr: 1,
75
- py: 0.5,
76
- '&:hover .MuiSvgIcon-root': {
77
- opacity: 1,
78
- },
79
- } ) );
@@ -0,0 +1,70 @@
1
+ import * as React from 'react';
2
+ import { Fragment } from 'react';
3
+ import { useBoundProp } from '@elementor/editor-controls';
4
+ import { EditIcon, TextIcon } from '@elementor/icons';
5
+ import { Box, Divider, ListItemIcon, ListItemText, MenuList } from '@elementor/ui';
6
+
7
+ import { usePropVariables } from '../hooks/use-prop-variables';
8
+ import { fontVariablePropTypeUtil } from '../prop-types/font-variable-prop-type';
9
+ import { type Variable } from '../types';
10
+ import { StyledMenuItem } from './styled-menu-item';
11
+
12
+ type Props = {
13
+ onSelect?: () => void;
14
+ };
15
+
16
+ export const FontVariablesSelection = ( { onSelect }: Props ) => {
17
+ const { value: variable, setValue: setVariable } = useBoundProp( fontVariablePropTypeUtil );
18
+
19
+ const variables = usePropVariables( fontVariablePropTypeUtil.key );
20
+
21
+ const handleSetVariable = ( newValue: Variable ) => {
22
+ setVariable( newValue.key );
23
+
24
+ onSelect?.();
25
+ };
26
+
27
+ return (
28
+ <Fragment>
29
+ <Divider />
30
+ <Box sx={ { overflowY: 'auto', height: 260, width: 220 } }>
31
+ <MenuList role="listbox" tabIndex={ 0 }>
32
+ { variables.map( ( { value, label, key } ) => (
33
+ <StyledMenuItem
34
+ key={ key }
35
+ onClick={ () => handleSetVariable( { value, label, key } ) }
36
+ selected={ key === variable }
37
+ >
38
+ <ListItemIcon>
39
+ <TextIcon />
40
+ </ListItemIcon>
41
+ <ListItemText
42
+ primary={ label }
43
+ secondary={ value }
44
+ primaryTypographyProps={ {
45
+ variant: 'body2',
46
+ color: 'text.secondary',
47
+ style: {
48
+ lineHeight: 2,
49
+ display: 'inline-block',
50
+ overflow: 'hidden',
51
+ textOverflow: 'ellipsis',
52
+ whiteSpace: 'nowrap',
53
+ maxWidth: '81px',
54
+ },
55
+ } }
56
+ secondaryTypographyProps={ {
57
+ variant: 'caption',
58
+ color: 'text.tertiary',
59
+ style: { marginTop: '1px', lineHeight: '1' },
60
+ } }
61
+ sx={ { display: 'flex', alignItems: 'center', gap: 1 } }
62
+ />
63
+ <EditIcon color="action" fontSize="inherit" sx={ { mx: 1, opacity: '0' } } />
64
+ </StyledMenuItem>
65
+ ) ) }
66
+ </MenuList>
67
+ </Box>
68
+ </Fragment>
69
+ );
70
+ };
@@ -0,0 +1,10 @@
1
+ import { MenuItem, styled } from '@elementor/ui';
2
+
3
+ export const StyledMenuItem = styled( MenuItem )( () => ( {
4
+ pl: 2,
5
+ pr: 1,
6
+ py: 0.5,
7
+ '&:hover .MuiSvgIcon-root': {
8
+ opacity: 1,
9
+ },
10
+ } ) );