@elementor/editor-variables 3.32.0-64 → 3.32.0-66

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.d.mts CHANGED
@@ -5,6 +5,14 @@ import * as _mui_material from '@mui/material';
5
5
 
6
6
  declare function init(): void;
7
7
 
8
+ type Variable = {
9
+ key?: string;
10
+ label: string;
11
+ value: string;
12
+ type: string;
13
+ deleted?: boolean;
14
+ deleted_at?: string;
15
+ };
8
16
  type NormalizedVariable = {
9
17
  key: string;
10
18
  label: string;
@@ -18,7 +26,7 @@ type ValueFieldProps = {
18
26
  propType?: PropType;
19
27
  };
20
28
 
21
- declare const registerVariableType: ({ icon, startIcon, valueField, propTypeUtil, variableType, selectionFilter, valueTransformer, fallbackPropTypeUtil, }: {
29
+ declare const registerVariableType: ({ icon, startIcon, valueField, propTypeUtil, variableType, selectionFilter, valueTransformer, fallbackPropTypeUtil, isCompatible, }: {
22
30
  icon: react.ForwardRefExoticComponent<Omit<_mui_material.SvgIconProps, "ref"> & react.RefAttributes<SVGSVGElement>>;
23
31
  startIcon?: ({ value }: {
24
32
  value: string;
@@ -29,6 +37,7 @@ declare const registerVariableType: ({ icon, startIcon, valueField, propTypeUtil
29
37
  propTypeUtil: _elementor_editor_props.PropTypeUtil<string, string>;
30
38
  selectionFilter?: (variables: NormalizedVariable[], propType: _elementor_editor_props.PropType) => NormalizedVariable[];
31
39
  valueTransformer?: (value: string) => _elementor_editor_props.PropValue;
40
+ isCompatible?: (propType: _elementor_editor_props.PropType, variable: Variable) => boolean;
32
41
  }) => void;
33
42
 
34
43
  export { init, registerVariableType };
package/dist/index.d.ts CHANGED
@@ -5,6 +5,14 @@ import * as _mui_material from '@mui/material';
5
5
 
6
6
  declare function init(): void;
7
7
 
8
+ type Variable = {
9
+ key?: string;
10
+ label: string;
11
+ value: string;
12
+ type: string;
13
+ deleted?: boolean;
14
+ deleted_at?: string;
15
+ };
8
16
  type NormalizedVariable = {
9
17
  key: string;
10
18
  label: string;
@@ -18,7 +26,7 @@ type ValueFieldProps = {
18
26
  propType?: PropType;
19
27
  };
20
28
 
21
- declare const registerVariableType: ({ icon, startIcon, valueField, propTypeUtil, variableType, selectionFilter, valueTransformer, fallbackPropTypeUtil, }: {
29
+ declare const registerVariableType: ({ icon, startIcon, valueField, propTypeUtil, variableType, selectionFilter, valueTransformer, fallbackPropTypeUtil, isCompatible, }: {
22
30
  icon: react.ForwardRefExoticComponent<Omit<_mui_material.SvgIconProps, "ref"> & react.RefAttributes<SVGSVGElement>>;
23
31
  startIcon?: ({ value }: {
24
32
  value: string;
@@ -29,6 +37,7 @@ declare const registerVariableType: ({ icon, startIcon, valueField, propTypeUtil
29
37
  propTypeUtil: _elementor_editor_props.PropTypeUtil<string, string>;
30
38
  selectionFilter?: (variables: NormalizedVariable[], propType: _elementor_editor_props.PropType) => NormalizedVariable[];
31
39
  valueTransformer?: (value: string) => _elementor_editor_props.PropValue;
40
+ isCompatible?: (propType: _elementor_editor_props.PropType, variable: Variable) => boolean;
32
41
  }) => void;
33
42
 
34
43
  export { init, registerVariableType };
package/dist/index.js CHANGED
@@ -37,7 +37,7 @@ module.exports = __toCommonJS(index_exports);
37
37
 
38
38
  // src/init.ts
39
39
  var import_editor = require("@elementor/editor");
40
- var import_editor_editing_panel10 = require("@elementor/editor-editing-panel");
40
+ var import_editor_editing_panel11 = require("@elementor/editor-editing-panel");
41
41
  var import_editor_panels2 = require("@elementor/editor-panels");
42
42
 
43
43
  // src/components/variables-manager/variables-manager-panel.tsx
@@ -422,11 +422,22 @@ function createVariableTypeRegistry() {
422
422
  variableType,
423
423
  selectionFilter,
424
424
  valueTransformer,
425
- fallbackPropTypeUtil
425
+ fallbackPropTypeUtil,
426
+ isCompatible
426
427
  }) => {
427
428
  if (variableTypes[propTypeUtil.key]) {
428
429
  throw new Error(`Variable with key "${propTypeUtil.key}" is already registered.`);
429
430
  }
431
+ if (!isCompatible) {
432
+ isCompatible = (propType, variable) => {
433
+ if ("union" === propType.kind) {
434
+ if (variable.type in propType.prop_types) {
435
+ return true;
436
+ }
437
+ }
438
+ return false;
439
+ };
440
+ }
430
441
  variableTypes[propTypeUtil.key] = {
431
442
  icon,
432
443
  startIcon,
@@ -435,7 +446,8 @@ function createVariableTypeRegistry() {
435
446
  variableType,
436
447
  selectionFilter,
437
448
  valueTransformer,
438
- fallbackPropTypeUtil
449
+ fallbackPropTypeUtil,
450
+ isCompatible
439
451
  };
440
452
  registerTransformer(propTypeUtil.key);
441
453
  registerInheritanceTransformer(propTypeUtil.key);
@@ -884,8 +896,8 @@ var usePreventUnload = (isDirty) => {
884
896
  };
885
897
 
886
898
  // src/controls/variable-control.tsx
887
- var React29 = __toESM(require("react"));
888
- var import_editor_controls10 = require("@elementor/editor-controls");
899
+ var React32 = __toESM(require("react"));
900
+ var import_editor_controls11 = require("@elementor/editor-controls");
889
901
 
890
902
  // src/components/ui/variable/assigned-variable.tsx
891
903
  var import_react14 = require("react");
@@ -2062,19 +2074,29 @@ var DeletedVariable = ({ variable, propTypeKey }) => {
2062
2074
  )));
2063
2075
  };
2064
2076
 
2065
- // src/components/ui/variable/missing-variable.tsx
2077
+ // src/components/ui/variable/mismatch-variable.tsx
2066
2078
  var React28 = __toESM(require("react"));
2067
2079
  var import_react17 = require("react");
2068
2080
  var import_editor_controls9 = require("@elementor/editor-controls");
2069
2081
  var import_ui28 = require("@elementor/ui");
2070
- var import_i18n20 = require("@wordpress/i18n");
2071
2082
 
2072
- // src/components/ui/missing-variable-alert.tsx
2083
+ // src/components/ui/mismatch-variable-alert.tsx
2073
2084
  var React26 = __toESM(require("react"));
2074
2085
  var import_editor_editing_panel7 = require("@elementor/editor-editing-panel");
2075
2086
  var import_ui26 = require("@elementor/ui");
2076
2087
  var import_i18n19 = require("@wordpress/i18n");
2077
- var MissingVariableAlert = ({ onClose, onClear }) => {
2088
+ var i18n = {
2089
+ title: (0, import_i18n19.__)("Variable has changed", "elementor"),
2090
+ message: (0, import_i18n19.__)(
2091
+ `This variable is no longer compatible with this property. You can clear it or select a different one.`,
2092
+ "elementor"
2093
+ ),
2094
+ buttons: {
2095
+ clear: (0, import_i18n19.__)("Clear", "elementor"),
2096
+ select: (0, import_i18n19.__)("Select variable", "elementor")
2097
+ }
2098
+ };
2099
+ var MismatchVariableAlert = ({ onClose, onClear, triggerSelect }) => {
2078
2100
  const sectionWidth = (0, import_editor_editing_panel7.useSectionWidth)();
2079
2101
  return /* @__PURE__ */ React26.createElement(import_ui26.ClickAwayListener, { onClickAway: onClose }, /* @__PURE__ */ React26.createElement(
2080
2102
  import_ui26.Alert,
@@ -2082,22 +2104,23 @@ var MissingVariableAlert = ({ onClose, onClear }) => {
2082
2104
  variant: "standard",
2083
2105
  severity: "warning",
2084
2106
  onClose,
2085
- action: /* @__PURE__ */ React26.createElement(React26.Fragment, null, onClear && /* @__PURE__ */ React26.createElement(import_ui26.AlertAction, { variant: "contained", onClick: onClear }, (0, import_i18n19.__)("Clear", "elementor"))),
2086
- sx: { width: sectionWidth }
2107
+ action: /* @__PURE__ */ React26.createElement(React26.Fragment, null, onClear && /* @__PURE__ */ React26.createElement(import_ui26.AlertAction, { variant: "contained", onClick: onClear }, i18n.buttons.clear), triggerSelect && /* @__PURE__ */ React26.createElement(import_ui26.AlertAction, { variant: "outlined", onClick: triggerSelect }, i18n.buttons.select)),
2108
+ sx: {
2109
+ width: sectionWidth,
2110
+ minWidth: 300
2111
+ }
2087
2112
  },
2088
- /* @__PURE__ */ React26.createElement(import_ui26.AlertTitle, null, (0, import_i18n19.__)("This variable is missing", "elementor")),
2089
- (0, import_i18n19.__)(
2090
- "It may have been deleted. Try clearing this field and select a different value or variable.",
2091
- "elementor"
2092
- )
2113
+ /* @__PURE__ */ React26.createElement(import_ui26.AlertTitle, null, i18n.title),
2114
+ i18n.message
2093
2115
  ));
2094
2116
  };
2095
2117
 
2096
- // src/components/ui/tags/missing-tag.tsx
2118
+ // src/components/ui/tags/mismatch-tag.tsx
2097
2119
  var React27 = __toESM(require("react"));
2098
2120
  var import_icons13 = require("@elementor/icons");
2099
2121
  var import_ui27 = require("@elementor/ui");
2100
- var MissingTag = React27.forwardRef(({ label, onClick, ...props }, ref) => {
2122
+ var import_i18n20 = require("@wordpress/i18n");
2123
+ var MismatchTag = React27.forwardRef(({ label, onClick, ...props }, ref) => {
2101
2124
  return /* @__PURE__ */ React27.createElement(
2102
2125
  import_ui27.Chip,
2103
2126
  {
@@ -2108,6 +2131,136 @@ var MissingTag = React27.forwardRef(({ label, onClick, ...props }, ref) => {
2108
2131
  variant: "standard",
2109
2132
  onClick,
2110
2133
  icon: /* @__PURE__ */ React27.createElement(import_icons13.AlertTriangleFilledIcon, null),
2134
+ label: /* @__PURE__ */ React27.createElement(import_ui27.Tooltip, { title: label, placement: "top" }, /* @__PURE__ */ React27.createElement(import_ui27.Box, { sx: { display: "flex", gap: 0.5, alignItems: "center" } }, /* @__PURE__ */ React27.createElement(import_ui27.Typography, { variant: "caption", noWrap: true }, label), /* @__PURE__ */ React27.createElement(import_ui27.Typography, { variant: "caption", noWrap: true, sx: { textOverflow: "initial", overflow: "visible" } }, "(", (0, import_i18n20.__)("changed", "elementor"), ")"))),
2135
+ sx: {
2136
+ height: (theme) => theme.spacing(3.5),
2137
+ borderRadius: (theme) => theme.spacing(1),
2138
+ justifyContent: "flex-start",
2139
+ width: "100%"
2140
+ },
2141
+ ...props
2142
+ }
2143
+ );
2144
+ });
2145
+
2146
+ // src/components/ui/variable/mismatch-variable.tsx
2147
+ var MismatchVariable = ({ variable }) => {
2148
+ const { setValue } = (0, import_editor_controls9.useBoundProp)();
2149
+ const anchorRef = (0, import_react17.useRef)(null);
2150
+ const popupId = (0, import_react17.useId)();
2151
+ const popupState = (0, import_ui28.usePopupState)({
2152
+ variant: "popover",
2153
+ popupId: `elementor-variables-list-${popupId}`
2154
+ });
2155
+ const [infotipVisible, setInfotipVisible] = (0, import_react17.useState)(false);
2156
+ const toggleInfotip = () => setInfotipVisible((prev) => !prev);
2157
+ const closeInfotip = () => setInfotipVisible(false);
2158
+ const triggerSelect = () => {
2159
+ closeInfotip();
2160
+ popupState.setAnchorEl(anchorRef.current);
2161
+ popupState.open();
2162
+ };
2163
+ const clearValue = () => {
2164
+ closeInfotip();
2165
+ setValue(null);
2166
+ };
2167
+ return /* @__PURE__ */ React28.createElement(import_ui28.Box, { ref: anchorRef }, infotipVisible && /* @__PURE__ */ React28.createElement(import_ui28.Backdrop, { open: true, onClick: closeInfotip, invisible: true }), /* @__PURE__ */ React28.createElement(
2168
+ import_ui28.Infotip,
2169
+ {
2170
+ color: "warning",
2171
+ placement: "right-start",
2172
+ open: infotipVisible,
2173
+ disableHoverListener: true,
2174
+ onClose: closeInfotip,
2175
+ content: /* @__PURE__ */ React28.createElement(
2176
+ MismatchVariableAlert,
2177
+ {
2178
+ onClose: closeInfotip,
2179
+ onClear: clearValue,
2180
+ triggerSelect
2181
+ }
2182
+ ),
2183
+ slotProps: {
2184
+ popper: {
2185
+ modifiers: [
2186
+ {
2187
+ name: "offset",
2188
+ options: { offset: [0, 24] }
2189
+ }
2190
+ ]
2191
+ }
2192
+ }
2193
+ },
2194
+ /* @__PURE__ */ React28.createElement(MismatchTag, { label: variable.label, onClick: toggleInfotip })
2195
+ ), /* @__PURE__ */ React28.createElement(
2196
+ import_ui28.Popover,
2197
+ {
2198
+ disableScrollLock: true,
2199
+ anchorEl: anchorRef.current,
2200
+ anchorOrigin: { vertical: "bottom", horizontal: "right" },
2201
+ transformOrigin: { vertical: "top", horizontal: "right" },
2202
+ PaperProps: {
2203
+ sx: { my: 1 }
2204
+ },
2205
+ ...(0, import_ui28.bindPopover)(popupState)
2206
+ },
2207
+ /* @__PURE__ */ React28.createElement(
2208
+ VariableSelectionPopover,
2209
+ {
2210
+ selectedVariable: variable,
2211
+ closePopover: popupState.close,
2212
+ propTypeKey: variable.type
2213
+ }
2214
+ )
2215
+ ));
2216
+ };
2217
+
2218
+ // src/components/ui/variable/missing-variable.tsx
2219
+ var React31 = __toESM(require("react"));
2220
+ var import_react18 = require("react");
2221
+ var import_editor_controls10 = require("@elementor/editor-controls");
2222
+ var import_ui31 = require("@elementor/ui");
2223
+ var import_i18n22 = require("@wordpress/i18n");
2224
+
2225
+ // src/components/ui/missing-variable-alert.tsx
2226
+ var React29 = __toESM(require("react"));
2227
+ var import_editor_editing_panel8 = require("@elementor/editor-editing-panel");
2228
+ var import_ui29 = require("@elementor/ui");
2229
+ var import_i18n21 = require("@wordpress/i18n");
2230
+ var MissingVariableAlert = ({ onClose, onClear }) => {
2231
+ const sectionWidth = (0, import_editor_editing_panel8.useSectionWidth)();
2232
+ return /* @__PURE__ */ React29.createElement(import_ui29.ClickAwayListener, { onClickAway: onClose }, /* @__PURE__ */ React29.createElement(
2233
+ import_ui29.Alert,
2234
+ {
2235
+ variant: "standard",
2236
+ severity: "warning",
2237
+ onClose,
2238
+ action: /* @__PURE__ */ React29.createElement(React29.Fragment, null, onClear && /* @__PURE__ */ React29.createElement(import_ui29.AlertAction, { variant: "contained", onClick: onClear }, (0, import_i18n21.__)("Clear", "elementor"))),
2239
+ sx: { width: sectionWidth }
2240
+ },
2241
+ /* @__PURE__ */ React29.createElement(import_ui29.AlertTitle, null, (0, import_i18n21.__)("This variable is missing", "elementor")),
2242
+ (0, import_i18n21.__)(
2243
+ "It may have been deleted. Try clearing this field and select a different value or variable.",
2244
+ "elementor"
2245
+ )
2246
+ ));
2247
+ };
2248
+
2249
+ // src/components/ui/tags/missing-tag.tsx
2250
+ var React30 = __toESM(require("react"));
2251
+ var import_icons14 = require("@elementor/icons");
2252
+ var import_ui30 = require("@elementor/ui");
2253
+ var MissingTag = React30.forwardRef(({ label, onClick, ...props }, ref) => {
2254
+ return /* @__PURE__ */ React30.createElement(
2255
+ import_ui30.Chip,
2256
+ {
2257
+ ref,
2258
+ size: "tiny",
2259
+ color: "warning",
2260
+ shape: "rounded",
2261
+ variant: "standard",
2262
+ onClick,
2263
+ icon: /* @__PURE__ */ React30.createElement(import_icons14.AlertTriangleFilledIcon, null),
2111
2264
  label,
2112
2265
  sx: {
2113
2266
  height: (theme) => theme.spacing(3.5),
@@ -2122,20 +2275,20 @@ var MissingTag = React27.forwardRef(({ label, onClick, ...props }, ref) => {
2122
2275
 
2123
2276
  // src/components/ui/variable/missing-variable.tsx
2124
2277
  var MissingVariable = () => {
2125
- const { setValue } = (0, import_editor_controls9.useBoundProp)();
2126
- const [infotipVisible, setInfotipVisible] = (0, import_react17.useState)(false);
2278
+ const { setValue } = (0, import_editor_controls10.useBoundProp)();
2279
+ const [infotipVisible, setInfotipVisible] = (0, import_react18.useState)(false);
2127
2280
  const toggleInfotip = () => setInfotipVisible((prev) => !prev);
2128
2281
  const closeInfotip = () => setInfotipVisible(false);
2129
2282
  const clearValue = () => setValue(null);
2130
- return /* @__PURE__ */ React28.createElement(React28.Fragment, null, infotipVisible && /* @__PURE__ */ React28.createElement(import_ui28.Backdrop, { open: true, onClick: closeInfotip, invisible: true }), /* @__PURE__ */ React28.createElement(
2131
- import_ui28.Infotip,
2283
+ return /* @__PURE__ */ React31.createElement(React31.Fragment, null, infotipVisible && /* @__PURE__ */ React31.createElement(import_ui31.Backdrop, { open: true, onClick: closeInfotip, invisible: true }), /* @__PURE__ */ React31.createElement(
2284
+ import_ui31.Infotip,
2132
2285
  {
2133
2286
  color: "warning",
2134
2287
  placement: "right-start",
2135
2288
  open: infotipVisible,
2136
2289
  disableHoverListener: true,
2137
2290
  onClose: closeInfotip,
2138
- content: /* @__PURE__ */ React28.createElement(MissingVariableAlert, { onClose: closeInfotip, onClear: clearValue }),
2291
+ content: /* @__PURE__ */ React31.createElement(MissingVariableAlert, { onClose: closeInfotip, onClear: clearValue }),
2139
2292
  slotProps: {
2140
2293
  popper: {
2141
2294
  modifiers: [
@@ -2147,42 +2300,47 @@ var MissingVariable = () => {
2147
2300
  }
2148
2301
  }
2149
2302
  },
2150
- /* @__PURE__ */ React28.createElement(MissingTag, { label: (0, import_i18n20.__)("Missing variable", "elementor"), onClick: toggleInfotip })
2303
+ /* @__PURE__ */ React31.createElement(MissingTag, { label: (0, import_i18n22.__)("Missing variable", "elementor"), onClick: toggleInfotip })
2151
2304
  ));
2152
2305
  };
2153
2306
 
2154
2307
  // src/controls/variable-control.tsx
2155
2308
  var VariableControl = () => {
2156
- const boundProp = (0, import_editor_controls10.useBoundProp)().value;
2157
- const assignedVariable = useVariable(boundProp?.value);
2309
+ const boundProp = (0, import_editor_controls11.useBoundProp)();
2310
+ const boundPropValue = boundProp.value;
2311
+ const assignedVariable = useVariable(boundPropValue?.value);
2158
2312
  if (!assignedVariable) {
2159
- return /* @__PURE__ */ React29.createElement(MissingVariable, null);
2313
+ return /* @__PURE__ */ React32.createElement(MissingVariable, null);
2160
2314
  }
2161
- const { $$type: propTypeKey } = boundProp;
2315
+ const { $$type: propTypeKey } = boundPropValue;
2162
2316
  if (assignedVariable?.deleted) {
2163
- return /* @__PURE__ */ React29.createElement(DeletedVariable, { variable: assignedVariable, propTypeKey });
2317
+ return /* @__PURE__ */ React32.createElement(DeletedVariable, { variable: assignedVariable, propTypeKey });
2164
2318
  }
2165
- return /* @__PURE__ */ React29.createElement(AssignedVariable, { variable: assignedVariable, propTypeKey });
2319
+ const { isCompatible } = getVariableType(assignedVariable.type);
2320
+ if (isCompatible && !isCompatible(boundProp?.propType, assignedVariable)) {
2321
+ return /* @__PURE__ */ React32.createElement(MismatchVariable, { variable: assignedVariable });
2322
+ }
2323
+ return /* @__PURE__ */ React32.createElement(AssignedVariable, { variable: assignedVariable, propTypeKey });
2166
2324
  };
2167
2325
 
2168
2326
  // src/hooks/use-prop-variable-action.tsx
2169
- var React30 = __toESM(require("react"));
2170
- var import_editor_editing_panel8 = require("@elementor/editor-editing-panel");
2171
- var import_icons14 = require("@elementor/icons");
2172
- var import_i18n21 = require("@wordpress/i18n");
2327
+ var React33 = __toESM(require("react"));
2328
+ var import_editor_editing_panel9 = require("@elementor/editor-editing-panel");
2329
+ var import_icons15 = require("@elementor/icons");
2330
+ var import_i18n23 = require("@wordpress/i18n");
2173
2331
  var usePropVariableAction = () => {
2174
- const { propType, path } = (0, import_editor_editing_panel8.useBoundProp)();
2332
+ const { propType, path } = (0, import_editor_editing_panel9.useBoundProp)();
2175
2333
  const variable = resolveVariableFromPropType(propType);
2176
2334
  return {
2177
2335
  visible: Boolean(variable),
2178
- icon: import_icons14.ColorFilterIcon,
2179
- title: (0, import_i18n21.__)("Variables", "elementor"),
2336
+ icon: import_icons15.ColorFilterIcon,
2337
+ title: (0, import_i18n23.__)("Variables", "elementor"),
2180
2338
  content: ({ close: closePopover }) => {
2181
2339
  if (!variable) {
2182
2340
  return null;
2183
2341
  }
2184
2342
  trackOpenVariablePopover(path, variable.variableType);
2185
- return /* @__PURE__ */ React30.createElement(VariableSelectionPopover, { closePopover, propTypeKey: variable.propTypeUtil.key });
2343
+ return /* @__PURE__ */ React33.createElement(VariableSelectionPopover, { closePopover, propTypeKey: variable.propTypeUtil.key });
2186
2344
  }
2187
2345
  };
2188
2346
  };
@@ -2207,18 +2365,18 @@ var trackOpenVariablePopover = (path, variableType) => {
2207
2365
  };
2208
2366
 
2209
2367
  // src/register-variable-types.tsx
2210
- var React33 = __toESM(require("react"));
2368
+ var React36 = __toESM(require("react"));
2211
2369
  var import_editor_props3 = require("@elementor/editor-props");
2212
- var import_icons16 = require("@elementor/icons");
2370
+ var import_icons17 = require("@elementor/icons");
2213
2371
 
2214
2372
  // src/components/fields/color-field.tsx
2215
- var React31 = __toESM(require("react"));
2216
- var import_react18 = require("react");
2217
- var import_ui29 = require("@elementor/ui");
2373
+ var React34 = __toESM(require("react"));
2374
+ var import_react19 = require("react");
2375
+ var import_ui32 = require("@elementor/ui");
2218
2376
  var ColorField = ({ value, onChange, onValidationChange }) => {
2219
- const [color, setColor] = (0, import_react18.useState)(value);
2220
- const [errorMessage, setErrorMessage] = (0, import_react18.useState)("");
2221
- const defaultRef = (0, import_react18.useRef)(null);
2377
+ const [color, setColor] = (0, import_react19.useState)(value);
2378
+ const [errorMessage, setErrorMessage] = (0, import_react19.useState)("");
2379
+ const defaultRef = (0, import_react19.useRef)(null);
2222
2380
  const anchorRef = usePopoverContentRef() ?? defaultRef.current;
2223
2381
  const handleChange = (newValue) => {
2224
2382
  setColor(newValue);
@@ -2227,8 +2385,8 @@ var ColorField = ({ value, onChange, onValidationChange }) => {
2227
2385
  onValidationChange?.(errorMsg);
2228
2386
  onChange(errorMsg ? "" : newValue);
2229
2387
  };
2230
- return /* @__PURE__ */ React31.createElement(
2231
- import_ui29.UnstableColorField,
2388
+ return /* @__PURE__ */ React34.createElement(
2389
+ import_ui32.UnstableColorField,
2232
2390
  {
2233
2391
  size: "tiny",
2234
2392
  fullWidth: true,
@@ -2247,21 +2405,21 @@ var ColorField = ({ value, onChange, onValidationChange }) => {
2247
2405
  };
2248
2406
 
2249
2407
  // src/components/fields/font-field.tsx
2250
- var React32 = __toESM(require("react"));
2251
- var import_react19 = require("react");
2252
- var import_editor_controls11 = require("@elementor/editor-controls");
2253
- var import_editor_editing_panel9 = require("@elementor/editor-editing-panel");
2254
- var import_icons15 = require("@elementor/icons");
2255
- var import_ui30 = require("@elementor/ui");
2256
- var import_i18n22 = require("@wordpress/i18n");
2408
+ var React35 = __toESM(require("react"));
2409
+ var import_react20 = require("react");
2410
+ var import_editor_controls12 = require("@elementor/editor-controls");
2411
+ var import_editor_editing_panel10 = require("@elementor/editor-editing-panel");
2412
+ var import_icons16 = require("@elementor/icons");
2413
+ var import_ui33 = require("@elementor/ui");
2414
+ var import_i18n24 = require("@wordpress/i18n");
2257
2415
  var FontField = ({ value, onChange, onValidationChange }) => {
2258
- const [fontFamily, setFontFamily] = (0, import_react19.useState)(value);
2259
- const defaultRef = (0, import_react19.useRef)(null);
2416
+ const [fontFamily, setFontFamily] = (0, import_react20.useState)(value);
2417
+ const defaultRef = (0, import_react20.useRef)(null);
2260
2418
  const anchorRef = usePopoverContentRef() ?? defaultRef.current;
2261
- const fontPopoverState = (0, import_ui30.usePopupState)({ variant: "popover" });
2262
- const fontFamilies = (0, import_editor_editing_panel9.useFontFamilies)();
2263
- const sectionWidth = (0, import_editor_editing_panel9.useSectionWidth)();
2264
- const mapFontSubs = React32.useMemo(() => {
2419
+ const fontPopoverState = (0, import_ui33.usePopupState)({ variant: "popover" });
2420
+ const fontFamilies = (0, import_editor_editing_panel10.useFontFamilies)();
2421
+ const sectionWidth = (0, import_editor_editing_panel10.useSectionWidth)();
2422
+ const mapFontSubs = React35.useMemo(() => {
2265
2423
  return fontFamilies.map(({ label, fonts }) => ({
2266
2424
  label,
2267
2425
  items: fonts
@@ -2277,39 +2435,39 @@ var FontField = ({ value, onChange, onValidationChange }) => {
2277
2435
  handleChange(newFontFamily);
2278
2436
  fontPopoverState.close();
2279
2437
  };
2280
- const id2 = (0, import_react19.useId)();
2281
- return /* @__PURE__ */ React32.createElement(React32.Fragment, null, /* @__PURE__ */ React32.createElement(
2282
- import_ui30.UnstableTag,
2438
+ const id2 = (0, import_react20.useId)();
2439
+ return /* @__PURE__ */ React35.createElement(React35.Fragment, null, /* @__PURE__ */ React35.createElement(
2440
+ import_ui33.UnstableTag,
2283
2441
  {
2284
2442
  id: id2,
2285
2443
  variant: "outlined",
2286
2444
  label: fontFamily,
2287
- endIcon: /* @__PURE__ */ React32.createElement(import_icons15.ChevronDownIcon, { fontSize: "tiny" }),
2288
- ...(0, import_ui30.bindTrigger)(fontPopoverState),
2445
+ endIcon: /* @__PURE__ */ React35.createElement(import_icons16.ChevronDownIcon, { fontSize: "tiny" }),
2446
+ ...(0, import_ui33.bindTrigger)(fontPopoverState),
2289
2447
  fullWidth: true
2290
2448
  }
2291
- ), /* @__PURE__ */ React32.createElement(
2292
- import_ui30.Popover,
2449
+ ), /* @__PURE__ */ React35.createElement(
2450
+ import_ui33.Popover,
2293
2451
  {
2294
2452
  disablePortal: true,
2295
2453
  disableScrollLock: true,
2296
2454
  anchorEl: anchorRef,
2297
2455
  anchorOrigin: { vertical: "top", horizontal: "right" },
2298
2456
  transformOrigin: { vertical: "top", horizontal: -28 },
2299
- ...(0, import_ui30.bindPopover)(fontPopoverState)
2457
+ ...(0, import_ui33.bindPopover)(fontPopoverState)
2300
2458
  },
2301
- /* @__PURE__ */ React32.createElement(
2302
- import_editor_controls11.ItemSelector,
2459
+ /* @__PURE__ */ React35.createElement(
2460
+ import_editor_controls12.ItemSelector,
2303
2461
  {
2304
2462
  itemsList: mapFontSubs,
2305
2463
  selectedItem: fontFamily,
2306
2464
  onItemChange: handleFontFamilyChange,
2307
2465
  onClose: fontPopoverState.close,
2308
2466
  sectionWidth,
2309
- title: (0, import_i18n22.__)("Font Family", "elementor"),
2467
+ title: (0, import_i18n24.__)("Font Family", "elementor"),
2310
2468
  itemStyle: (item) => ({ fontFamily: item.value }),
2311
- onDebounce: import_editor_controls11.enqueueFont,
2312
- icon: import_icons15.TextIcon
2469
+ onDebounce: import_editor_controls12.enqueueFont,
2470
+ icon: import_icons16.TextIcon
2313
2471
  }
2314
2472
  )
2315
2473
  ));
@@ -2319,15 +2477,15 @@ var FontField = ({ value, onChange, onValidationChange }) => {
2319
2477
  function registerVariableTypes() {
2320
2478
  registerVariableType({
2321
2479
  valueField: ColorField,
2322
- icon: import_icons16.BrushIcon,
2480
+ icon: import_icons17.BrushIcon,
2323
2481
  propTypeUtil: colorVariablePropTypeUtil,
2324
2482
  fallbackPropTypeUtil: import_editor_props3.colorPropTypeUtil,
2325
2483
  variableType: "color",
2326
- startIcon: ({ value }) => /* @__PURE__ */ React33.createElement(ColorIndicator, { size: "inherit", component: "span", value })
2484
+ startIcon: ({ value }) => /* @__PURE__ */ React36.createElement(ColorIndicator, { size: "inherit", component: "span", value })
2327
2485
  });
2328
2486
  registerVariableType({
2329
2487
  valueField: FontField,
2330
- icon: import_icons16.TextIcon,
2488
+ icon: import_icons17.TextIcon,
2331
2489
  propTypeUtil: fontVariablePropTypeUtil,
2332
2490
  fallbackPropTypeUtil: import_editor_props3.stringPropTypeUtil,
2333
2491
  variableType: "font"
@@ -2335,10 +2493,10 @@ function registerVariableTypes() {
2335
2493
  }
2336
2494
 
2337
2495
  // src/renderers/style-variables-renderer.tsx
2338
- var React34 = __toESM(require("react"));
2339
- var import_react20 = require("react");
2496
+ var React37 = __toESM(require("react"));
2497
+ var import_react21 = require("react");
2340
2498
  var import_editor_v1_adapters3 = require("@elementor/editor-v1-adapters");
2341
- var import_ui31 = require("@elementor/ui");
2499
+ var import_ui34 = require("@elementor/ui");
2342
2500
 
2343
2501
  // src/sync/get-canvas-iframe-document.ts
2344
2502
  function getCanvasIframeDocument() {
@@ -2357,14 +2515,14 @@ function StyleVariablesRenderer() {
2357
2515
  }
2358
2516
  const cssVariables = convertToCssVariables(styleVariables);
2359
2517
  const wrappedCss = `${VARIABLES_WRAPPER}{${cssVariables}}`;
2360
- return /* @__PURE__ */ React34.createElement(import_ui31.Portal, { container }, /* @__PURE__ */ React34.createElement("style", { "data-e-style-id": "e-variables", key: wrappedCss }, wrappedCss));
2518
+ return /* @__PURE__ */ React37.createElement(import_ui34.Portal, { container }, /* @__PURE__ */ React37.createElement("style", { "data-e-style-id": "e-variables", key: wrappedCss }, wrappedCss));
2361
2519
  }
2362
2520
  function usePortalContainer() {
2363
2521
  return (0, import_editor_v1_adapters3.__privateUseListenTo)((0, import_editor_v1_adapters3.commandEndEvent)("editor/documents/attach-preview"), () => getCanvasIframeDocument()?.head);
2364
2522
  }
2365
2523
  function useStyleVariables() {
2366
- const [variables, setVariables] = (0, import_react20.useState)({});
2367
- (0, import_react20.useEffect)(() => {
2524
+ const [variables, setVariables] = (0, import_react21.useState)({});
2525
+ (0, import_react21.useEffect)(() => {
2368
2526
  const unsubscribe = styleVariablesRepository.subscribe(setVariables);
2369
2527
  return () => {
2370
2528
  unsubscribe();
@@ -2383,45 +2541,45 @@ function convertToCssVariables(variables) {
2383
2541
  }
2384
2542
 
2385
2543
  // src/repeater-injections.ts
2386
- var import_editor_controls12 = require("@elementor/editor-controls");
2544
+ var import_editor_controls13 = require("@elementor/editor-controls");
2387
2545
  var import_editor_props4 = require("@elementor/editor-props");
2388
2546
 
2389
2547
  // src/components/variables-repeater-item-slot.tsx
2390
- var React35 = __toESM(require("react"));
2548
+ var React38 = __toESM(require("react"));
2391
2549
  var useColorVariable = (value) => {
2392
2550
  const variableId = value?.value?.color?.value;
2393
2551
  return useVariable(variableId || "");
2394
2552
  };
2395
2553
  var BackgroundRepeaterColorIndicator = ({ value }) => {
2396
2554
  const colorVariable = useColorVariable(value);
2397
- return /* @__PURE__ */ React35.createElement(ColorIndicator, { component: "span", size: "inherit", value: colorVariable?.value });
2555
+ return /* @__PURE__ */ React38.createElement(ColorIndicator, { component: "span", size: "inherit", value: colorVariable?.value });
2398
2556
  };
2399
2557
  var BackgroundRepeaterLabel = ({ value }) => {
2400
2558
  const colorVariable = useColorVariable(value);
2401
- return /* @__PURE__ */ React35.createElement("span", null, colorVariable?.label);
2559
+ return /* @__PURE__ */ React38.createElement("span", null, colorVariable?.label);
2402
2560
  };
2403
2561
  var BoxShadowRepeaterColorIndicator = ({ value }) => {
2404
2562
  const colorVariable = useColorVariable(value);
2405
- return /* @__PURE__ */ React35.createElement(ColorIndicator, { component: "span", size: "inherit", value: colorVariable?.value });
2563
+ return /* @__PURE__ */ React38.createElement(ColorIndicator, { component: "span", size: "inherit", value: colorVariable?.value });
2406
2564
  };
2407
2565
 
2408
2566
  // src/repeater-injections.ts
2409
2567
  function registerRepeaterInjections() {
2410
- (0, import_editor_controls12.injectIntoRepeaterItemIcon)({
2568
+ (0, import_editor_controls13.injectIntoRepeaterItemIcon)({
2411
2569
  id: "color-variables-background-icon",
2412
2570
  component: BackgroundRepeaterColorIndicator,
2413
2571
  condition: ({ value: prop }) => {
2414
2572
  return hasAssignedColorVariable(import_editor_props4.backgroundColorOverlayPropTypeUtil.extract(prop)?.color);
2415
2573
  }
2416
2574
  });
2417
- (0, import_editor_controls12.injectIntoRepeaterItemIcon)({
2575
+ (0, import_editor_controls13.injectIntoRepeaterItemIcon)({
2418
2576
  id: "color-variables-icon",
2419
2577
  component: BoxShadowRepeaterColorIndicator,
2420
2578
  condition: ({ value: prop }) => {
2421
2579
  return hasAssignedColorVariable(import_editor_props4.shadowPropTypeUtil.extract(prop)?.color);
2422
2580
  }
2423
2581
  });
2424
- (0, import_editor_controls12.injectIntoRepeaterItemLabel)({
2582
+ (0, import_editor_controls13.injectIntoRepeaterItemLabel)({
2425
2583
  id: "color-variables-label",
2426
2584
  component: BackgroundRepeaterLabel,
2427
2585
  condition: ({ value: prop }) => {
@@ -2434,11 +2592,11 @@ var hasAssignedColorVariable = (propValue) => {
2434
2592
  };
2435
2593
 
2436
2594
  // src/init.ts
2437
- var { registerPopoverAction } = import_editor_editing_panel10.controlActionsMenu;
2595
+ var { registerPopoverAction } = import_editor_editing_panel11.controlActionsMenu;
2438
2596
  function init() {
2439
2597
  registerVariableTypes();
2440
2598
  registerRepeaterInjections();
2441
- (0, import_editor_editing_panel10.registerControlReplacement)({
2599
+ (0, import_editor_editing_panel11.registerControlReplacement)({
2442
2600
  component: VariableControl,
2443
2601
  condition: ({ value }) => hasAssignedVariable(value)
2444
2602
  });