@elementor/editor-variables 4.0.0-650 → 4.0.0-660

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
@@ -5,9 +5,13 @@ import { __registerPanel as registerPanel } from "@elementor/editor-panels";
5
5
  import { isTransformable as isTransformable2 } from "@elementor/editor-props";
6
6
  import { controlActionsMenu } from "@elementor/menus";
7
7
 
8
- // src/components/open-panel-from-url.tsx
9
- import { useEffect as useEffect4, useRef as useRef7 } from "react";
10
- import { __privateListenTo as listenTo, routeOpenEvent } from "@elementor/editor-v1-adapters";
8
+ // src/components/open-panel-from-event.tsx
9
+ import { useEffect as useEffect4, useRef as useRef7, useState as useState7 } from "react";
10
+ import {
11
+ __privateListenTo as listenTo,
12
+ __privateOpenRoute as openRoute,
13
+ routeOpenEvent
14
+ } from "@elementor/editor-v1-adapters";
11
15
 
12
16
  // src/components/variables-manager/variables-manager-panel.tsx
13
17
  import * as React14 from "react";
@@ -2174,20 +2178,54 @@ var StopSyncConfirmationDialog = ({ open, onClose, onConfirm }) => {
2174
2178
  ));
2175
2179
  };
2176
2180
 
2181
+ // src/components/open-panel-from-event.tsx
2182
+ var EVENT_NAME = "elementor/open-variables-manager";
2183
+ var DEFAULT_PANEL_ROUTE = "panel/elements/categories";
2184
+ function OpenPanelFromEvent() {
2185
+ const { open } = usePanelActions();
2186
+ const pendingRef = useRef7(false);
2187
+ const [readyToOpen, setReadyToOpen] = useState7(false);
2188
+ useEffect4(() => {
2189
+ if (readyToOpen) {
2190
+ setReadyToOpen(false);
2191
+ open();
2192
+ }
2193
+ }, [readyToOpen, open]);
2194
+ useEffect4(() => {
2195
+ return listenTo(routeOpenEvent(DEFAULT_PANEL_ROUTE), () => {
2196
+ if (pendingRef.current) {
2197
+ pendingRef.current = false;
2198
+ setReadyToOpen(true);
2199
+ }
2200
+ });
2201
+ }, []);
2202
+ useEffect4(() => {
2203
+ const handler = () => {
2204
+ pendingRef.current = true;
2205
+ openRoute(DEFAULT_PANEL_ROUTE);
2206
+ };
2207
+ window.addEventListener(EVENT_NAME, handler);
2208
+ return () => window.removeEventListener(EVENT_NAME, handler);
2209
+ }, []);
2210
+ return null;
2211
+ }
2212
+
2177
2213
  // src/components/open-panel-from-url.tsx
2214
+ import { useEffect as useEffect5, useRef as useRef8 } from "react";
2215
+ import { __privateListenTo as listenTo2, routeOpenEvent as routeOpenEvent2 } from "@elementor/editor-v1-adapters";
2178
2216
  var ACTIVE_PANEL_PARAM = "active-panel";
2179
2217
  var PANEL_ID = "variables-manager";
2180
- var DEFAULT_PANEL_ROUTE = "panel/elements";
2218
+ var DEFAULT_PANEL_ROUTE2 = "panel/elements";
2181
2219
  function OpenPanelFromUrl() {
2182
2220
  const { open } = usePanelActions();
2183
- const hasOpened = useRef7(false);
2184
- useEffect4(() => {
2221
+ const hasOpened = useRef8(false);
2222
+ useEffect5(() => {
2185
2223
  const urlParams = new URLSearchParams(window.location.search);
2186
2224
  const activePanel = urlParams.get(ACTIVE_PANEL_PARAM);
2187
2225
  if (activePanel !== PANEL_ID) {
2188
2226
  return;
2189
2227
  }
2190
- const cleanup = listenTo(routeOpenEvent(DEFAULT_PANEL_ROUTE), () => {
2228
+ const cleanup = listenTo2(routeOpenEvent2(DEFAULT_PANEL_ROUTE2), () => {
2191
2229
  if (hasOpened.current) {
2192
2230
  return;
2193
2231
  }
@@ -2206,7 +2244,7 @@ import * as React33 from "react";
2206
2244
  import { useBoundProp as useBoundProp11 } from "@elementor/editor-controls";
2207
2245
 
2208
2246
  // src/components/ui/variable/assigned-variable.tsx
2209
- import { useId, useRef as useRef8 } from "react";
2247
+ import { useId, useRef as useRef9 } from "react";
2210
2248
  import * as React24 from "react";
2211
2249
  import { useBoundProp as useBoundProp6 } from "@elementor/editor-controls";
2212
2250
  import { ColorFilterIcon as ColorFilterIcon3 } from "@elementor/icons";
@@ -2230,16 +2268,16 @@ function createUnlinkHandler(variable, propTypeKey, setValue) {
2230
2268
 
2231
2269
  // src/components/variable-selection-popover.tsx
2232
2270
  import * as React22 from "react";
2233
- import { useState as useState12 } from "react";
2271
+ import { useState as useState13 } from "react";
2234
2272
  import { isExperimentActive } from "@elementor/editor-v1-adapters";
2235
2273
 
2236
2274
  // src/context/variable-selection-popover.context.tsx
2237
2275
  import * as React15 from "react";
2238
- import { createContext as createContext2, useContext as useContext2, useState as useState7 } from "react";
2276
+ import { createContext as createContext2, useContext as useContext2, useState as useState8 } from "react";
2239
2277
  import { Box as Box2 } from "@elementor/ui";
2240
2278
  var PopoverContentRefContext = createContext2(null);
2241
2279
  var PopoverContentRefContextProvider = ({ children }) => {
2242
- const [anchorRef, setAnchorRef] = useState7(null);
2280
+ const [anchorRef, setAnchorRef] = useState8(null);
2243
2281
  return /* @__PURE__ */ React15.createElement(PopoverContentRefContext.Provider, { value: anchorRef }, /* @__PURE__ */ React15.createElement(Box2, { ref: setAnchorRef }, children));
2244
2282
  };
2245
2283
  var usePopoverContentRef = () => {
@@ -2248,7 +2286,7 @@ var usePopoverContentRef = () => {
2248
2286
 
2249
2287
  // src/components/variable-creation.tsx
2250
2288
  import * as React17 from "react";
2251
- import { useState as useState8 } from "react";
2289
+ import { useState as useState9 } from "react";
2252
2290
  import { PopoverContent, useBoundProp as useBoundProp4 } from "@elementor/editor-controls";
2253
2291
  import { PopoverHeader, SectionPopoverBody } from "@elementor/editor-ui";
2254
2292
  import { ArrowLeftIcon } from "@elementor/icons";
@@ -2309,11 +2347,11 @@ var VariableCreation = ({ onGoBack, onClose }) => {
2309
2347
  const { setVariableValue: setVariable, path } = useVariableBoundProp();
2310
2348
  const { propType } = useBoundProp4();
2311
2349
  const initialValue = useInitialValue();
2312
- const [value, setValue] = useState8(initialValue);
2313
- const [label, setLabel] = useState8("");
2314
- const [errorMessage, setErrorMessage] = useState8("");
2315
- const [valueFieldError, setValueFieldError] = useState8("");
2316
- const [propTypeKey, setPropTypeKey] = useState8(propTypeUtil.key);
2350
+ const [value, setValue] = useState9(initialValue);
2351
+ const [label, setLabel] = useState9("");
2352
+ const [errorMessage, setErrorMessage] = useState9("");
2353
+ const [valueFieldError, setValueFieldError] = useState9("");
2354
+ const [propTypeKey, setPropTypeKey] = useState9(propTypeUtil.key);
2317
2355
  const { labelFieldError, setLabelFieldError } = useLabelError();
2318
2356
  const resetFields = () => {
2319
2357
  setValue("");
@@ -2433,7 +2471,7 @@ var VariableCreation = ({ onGoBack, onClose }) => {
2433
2471
 
2434
2472
  // src/components/variable-edit.tsx
2435
2473
  import * as React19 from "react";
2436
- import { useEffect as useEffect5, useState as useState10 } from "react";
2474
+ import { useEffect as useEffect6, useState as useState11 } from "react";
2437
2475
  import { PopoverContent as PopoverContent2, useBoundProp as useBoundProp5 } from "@elementor/editor-controls";
2438
2476
  import { useSuppressedMessage as useSuppressedMessage2 } from "@elementor/editor-current-user";
2439
2477
  import { PopoverHeader as PopoverHeader2, SectionPopoverBody as SectionPopoverBody2 } from "@elementor/editor-ui";
@@ -2443,7 +2481,7 @@ import { __ as __13 } from "@wordpress/i18n";
2443
2481
 
2444
2482
  // src/components/ui/edit-confirmation-dialog.tsx
2445
2483
  import * as React18 from "react";
2446
- import { useState as useState9 } from "react";
2484
+ import { useState as useState10 } from "react";
2447
2485
  import { AlertTriangleFilledIcon as AlertTriangleFilledIcon3 } from "@elementor/icons";
2448
2486
  import {
2449
2487
  Button as Button4,
@@ -2463,7 +2501,7 @@ var EditConfirmationDialog = ({
2463
2501
  onConfirm,
2464
2502
  onSuppressMessage
2465
2503
  }) => {
2466
- const [dontShowAgain, setDontShowAgain] = useState9(false);
2504
+ const [dontShowAgain, setDontShowAgain] = useState10(false);
2467
2505
  const handleSave = () => {
2468
2506
  if (dontShowAgain) {
2469
2507
  onSuppressMessage?.();
@@ -2497,20 +2535,20 @@ var VariableEdit = ({ onClose, onGoBack, onSubmit, editId }) => {
2497
2535
  const { setVariableValue: notifyBoundPropChange, variableId } = useVariableBoundProp();
2498
2536
  const { propType } = useBoundProp5();
2499
2537
  const [isMessageSuppressed, suppressMessage] = useSuppressedMessage2(EDIT_CONFIRMATION_DIALOG_ID);
2500
- const [deleteConfirmation, setDeleteConfirmation] = useState10(false);
2501
- const [editConfirmation, setEditConfirmation] = useState10(false);
2502
- const [errorMessage, setErrorMessage] = useState10("");
2503
- const [valueFieldError, setValueFieldError] = useState10("");
2538
+ const [deleteConfirmation, setDeleteConfirmation] = useState11(false);
2539
+ const [editConfirmation, setEditConfirmation] = useState11(false);
2540
+ const [errorMessage, setErrorMessage] = useState11("");
2541
+ const [valueFieldError, setValueFieldError] = useState11("");
2504
2542
  const { labelFieldError, setLabelFieldError } = useLabelError();
2505
2543
  const variable = useVariable(editId);
2506
- const [propTypeKey, setPropTypeKey] = useState10(variable?.type ?? propTypeUtil.key);
2544
+ const [propTypeKey, setPropTypeKey] = useState11(variable?.type ?? propTypeUtil.key);
2507
2545
  if (!variable) {
2508
2546
  throw new Error(`Global ${variableType} variable not found`);
2509
2547
  }
2510
2548
  const userPermissions = usePermissions();
2511
- const [value, setValue] = useState10(() => variable.value);
2512
- const [label, setLabel] = useState10(() => variable.label);
2513
- useEffect5(() => {
2549
+ const [value, setValue] = useState11(() => variable.value);
2550
+ const [label, setLabel] = useState11(() => variable.label);
2551
+ useEffect6(() => {
2514
2552
  styleVariablesRepository.update({
2515
2553
  [editId]: {
2516
2554
  ...variable,
@@ -2674,7 +2712,7 @@ var VariableEdit = ({ onClose, onGoBack, onSubmit, editId }) => {
2674
2712
  };
2675
2713
 
2676
2714
  // src/components/variables-selection.tsx
2677
- import { useState as useState11 } from "react";
2715
+ import { useState as useState12 } from "react";
2678
2716
  import * as React21 from "react";
2679
2717
  import {
2680
2718
  PopoverHeader as PopoverHeader3,
@@ -2786,7 +2824,7 @@ var getProUpgradeUrl = (variableType) => `https://go.elementor.com/renew-license
2786
2824
  var VariablesSelection = ({ closePopover, onAdd, onEdit, onSettings, disabled = false }) => {
2787
2825
  const { icon: VariableIcon, startIcon, variableType, propTypeUtil, emptyState } = useVariableType();
2788
2826
  const { value: variable, setValue: setVariable, path } = useVariableBoundProp();
2789
- const [searchValue, setSearchValue] = useState11("");
2827
+ const [searchValue, setSearchValue] = useState12("");
2790
2828
  const {
2791
2829
  list: variables,
2792
2830
  hasMatches: hasSearchResults,
@@ -2958,8 +2996,8 @@ var VIEW_LIST = "list";
2958
2996
  var VIEW_ADD = "add";
2959
2997
  var VIEW_EDIT = "edit";
2960
2998
  var VariableSelectionPopover = ({ closePopover, propTypeKey, selectedVariable }) => {
2961
- const [currentView, setCurrentView] = useState12(VIEW_LIST);
2962
- const [editId, setEditId] = useState12("");
2999
+ const [currentView, setCurrentView] = useState13(VIEW_LIST);
3000
+ const [editId, setEditId] = useState13("");
2963
3001
  const { open } = usePanelActions();
2964
3002
  const onSettingsAvailable = isExperimentActive("e_variables_manager") ? () => {
2965
3003
  open();
@@ -3070,7 +3108,7 @@ var AssignedTag = ({ startIcon, label, onUnlink, ...props }) => {
3070
3108
  var AssignedVariable = ({ variable, propTypeKey }) => {
3071
3109
  const { startIcon, propTypeUtil } = getVariableType(propTypeKey);
3072
3110
  const { setValue } = useBoundProp6();
3073
- const anchorRef = useRef8(null);
3111
+ const anchorRef = useRef9(null);
3074
3112
  const popupId = useId();
3075
3113
  const popupState = usePopupState3({
3076
3114
  variant: "popover",
@@ -3111,14 +3149,14 @@ var AssignedVariable = ({ variable, propTypeKey }) => {
3111
3149
 
3112
3150
  // src/components/ui/variable/deleted-variable.tsx
3113
3151
  import * as React28 from "react";
3114
- import { useId as useId2, useRef as useRef9, useState as useState14 } from "react";
3152
+ import { useId as useId2, useRef as useRef10, useState as useState15 } from "react";
3115
3153
  import { useBoundProp as useBoundProp8 } from "@elementor/editor-controls";
3116
3154
  import { Backdrop, bindPopover as bindPopover2, Box as Box7, Infotip as Infotip2, Popover as Popover2, usePopupState as usePopupState4 } from "@elementor/ui";
3117
3155
  import { __ as __19 } from "@wordpress/i18n";
3118
3156
 
3119
3157
  // src/components/variable-restore.tsx
3120
3158
  import * as React25 from "react";
3121
- import { useState as useState13 } from "react";
3159
+ import { useState as useState14 } from "react";
3122
3160
  import { PopoverContent as PopoverContent3, useBoundProp as useBoundProp7 } from "@elementor/editor-controls";
3123
3161
  import { PopoverHeader as PopoverHeader4, SectionPopoverBody as SectionPopoverBody4 } from "@elementor/editor-ui";
3124
3162
  import { Button as Button6, CardActions as CardActions3, Divider as Divider5, FormHelperText as FormHelperText4, Typography as Typography11 } from "@elementor/ui";
@@ -3132,11 +3170,11 @@ var VariableRestore = ({ variableId, onClose, onSubmit }) => {
3132
3170
  if (!variable) {
3133
3171
  throw new Error(`Global ${variableType} variable not found`);
3134
3172
  }
3135
- const [errorMessage, setErrorMessage] = useState13("");
3136
- const [valueFieldError, setValueFieldError] = useState13("");
3137
- const [label, setLabel] = useState13(variable.label);
3138
- const [value, setValue] = useState13(variable.value);
3139
- const [propTypeKey, setPropTypeKey] = useState13(variable?.type ?? propTypeUtil.key);
3173
+ const [errorMessage, setErrorMessage] = useState14("");
3174
+ const [valueFieldError, setValueFieldError] = useState14("");
3175
+ const [label, setLabel] = useState14(variable.label);
3176
+ const [value, setValue] = useState14(variable.value);
3177
+ const [propTypeKey, setPropTypeKey] = useState14(variable?.type ?? propTypeUtil.key);
3140
3178
  const { labelFieldError, setLabelFieldError } = useLabelError({
3141
3179
  value: variable.label,
3142
3180
  message: ERROR_MESSAGES.DUPLICATED_LABEL
@@ -3292,10 +3330,10 @@ var DeletedVariable = ({ variable, propTypeKey }) => {
3292
3330
  const { propTypeUtil } = getVariableType(propTypeKey);
3293
3331
  const boundProp = useBoundProp8();
3294
3332
  const userPermissions = usePermissions();
3295
- const [showInfotip, setShowInfotip] = useState14(false);
3333
+ const [showInfotip, setShowInfotip] = useState15(false);
3296
3334
  const toggleInfotip = () => setShowInfotip((prev) => !prev);
3297
3335
  const closeInfotip = () => setShowInfotip(false);
3298
- const deletedChipAnchorRef = useRef9(null);
3336
+ const deletedChipAnchorRef = useRef10(null);
3299
3337
  const popupId = useId2();
3300
3338
  const popupState = usePopupState4({
3301
3339
  variant: "popover",
@@ -3383,7 +3421,7 @@ var DeletedVariable = ({ variable, propTypeKey }) => {
3383
3421
 
3384
3422
  // src/components/ui/variable/mismatch-variable.tsx
3385
3423
  import * as React30 from "react";
3386
- import { useId as useId3, useRef as useRef10, useState as useState15 } from "react";
3424
+ import { useId as useId3, useRef as useRef11, useState as useState16 } from "react";
3387
3425
  import { useBoundProp as useBoundProp9 } from "@elementor/editor-controls";
3388
3426
  import { Backdrop as Backdrop2, bindPopover as bindPopover3, Box as Box8, Infotip as Infotip3, Popover as Popover3, usePopupState as usePopupState5 } from "@elementor/ui";
3389
3427
  import { __ as __21 } from "@wordpress/i18n";
@@ -3421,13 +3459,13 @@ var MismatchVariableAlert = ({ onClose, onClear, triggerSelect }) => {
3421
3459
  // src/components/ui/variable/mismatch-variable.tsx
3422
3460
  var MismatchVariable = ({ variable }) => {
3423
3461
  const { setValue, value } = useBoundProp9();
3424
- const anchorRef = useRef10(null);
3462
+ const anchorRef = useRef11(null);
3425
3463
  const popupId = useId3();
3426
3464
  const popupState = usePopupState5({
3427
3465
  variant: "popover",
3428
3466
  popupId: `elementor-variables-list-${popupId}`
3429
3467
  });
3430
- const [infotipVisible, setInfotipVisible] = useState15(false);
3468
+ const [infotipVisible, setInfotipVisible] = useState16(false);
3431
3469
  const toggleInfotip = () => setInfotipVisible((prev) => !prev);
3432
3470
  const closeInfotip = () => setInfotipVisible(false);
3433
3471
  const triggerSelect = () => {
@@ -3500,7 +3538,7 @@ var MismatchVariable = ({ variable }) => {
3500
3538
 
3501
3539
  // src/components/ui/variable/missing-variable.tsx
3502
3540
  import * as React32 from "react";
3503
- import { useState as useState16 } from "react";
3541
+ import { useState as useState17 } from "react";
3504
3542
  import { useBoundProp as useBoundProp10 } from "@elementor/editor-controls";
3505
3543
  import { Backdrop as Backdrop3, Infotip as Infotip4 } from "@elementor/ui";
3506
3544
  import { __ as __23 } from "@wordpress/i18n";
@@ -3530,7 +3568,7 @@ var MissingVariableAlert = ({ onClose, onClear }) => {
3530
3568
  // src/components/ui/variable/missing-variable.tsx
3531
3569
  var MissingVariable = () => {
3532
3570
  const { setValue } = useBoundProp10();
3533
- const [infotipVisible, setInfotipVisible] = useState16(false);
3571
+ const [infotipVisible, setInfotipVisible] = useState17(false);
3534
3572
  const toggleInfotip = () => setInfotipVisible((prev) => !prev);
3535
3573
  const closeInfotip = () => setInfotipVisible(false);
3536
3574
  const clearValue = () => setValue(null);
@@ -3749,12 +3787,12 @@ import { __ as __26 } from "@wordpress/i18n";
3749
3787
 
3750
3788
  // src/components/fields/color-field.tsx
3751
3789
  import * as React35 from "react";
3752
- import { useRef as useRef11, useState as useState17 } from "react";
3790
+ import { useRef as useRef12, useState as useState18 } from "react";
3753
3791
  import { UnstableColorField } from "@elementor/ui";
3754
3792
  var ColorField = ({ value, onChange, onValidationChange }) => {
3755
- const [color, setColor] = useState17(value);
3756
- const [errorMessage, setErrorMessage] = useState17("");
3757
- const defaultRef = useRef11(null);
3793
+ const [color, setColor] = useState18(value);
3794
+ const [errorMessage, setErrorMessage] = useState18("");
3795
+ const defaultRef = useRef12(null);
3758
3796
  const anchorRef = usePopoverContentRef() ?? defaultRef.current;
3759
3797
  const handleChange = (newValue) => {
3760
3798
  setColor(newValue);
@@ -3793,15 +3831,15 @@ var ColorField = ({ value, onChange, onValidationChange }) => {
3793
3831
 
3794
3832
  // src/components/fields/font-field.tsx
3795
3833
  import * as React36 from "react";
3796
- import { useId as useId4, useRef as useRef12, useState as useState18 } from "react";
3834
+ import { useId as useId4, useRef as useRef13, useState as useState19 } from "react";
3797
3835
  import { enqueueFont as enqueueFont2, ItemSelector, useFontFamilies } from "@elementor/editor-controls";
3798
3836
  import { useSectionWidth } from "@elementor/editor-ui";
3799
3837
  import { ChevronDownIcon, TextIcon } from "@elementor/icons";
3800
3838
  import { bindPopover as bindPopover4, bindTrigger as bindTrigger4, Popover as Popover4, UnstableTag, usePopupState as usePopupState6 } from "@elementor/ui";
3801
3839
  import { __ as __25 } from "@wordpress/i18n";
3802
3840
  var FontField = ({ value, onChange, onValidationChange }) => {
3803
- const [fontFamily, setFontFamily] = useState18(value);
3804
- const defaultRef = useRef12(null);
3841
+ const [fontFamily, setFontFamily] = useState19(value);
3842
+ const defaultRef = useRef13(null);
3805
3843
  const anchorRef = usePopoverContentRef() ?? defaultRef.current;
3806
3844
  const fontPopoverState = usePopupState6({ variant: "popover" });
3807
3845
  const fontFamilies = useFontFamilies();
@@ -3938,7 +3976,7 @@ function registerVariableTypes() {
3938
3976
 
3939
3977
  // src/renderers/style-variables-renderer.tsx
3940
3978
  import * as React38 from "react";
3941
- import { useEffect as useEffect6, useState as useState19 } from "react";
3979
+ import { useEffect as useEffect7, useState as useState20 } from "react";
3942
3980
  import {
3943
3981
  __privateUseListenTo as useListenTo,
3944
3982
  commandEndEvent,
@@ -3961,8 +3999,8 @@ function usePortalContainer() {
3961
3999
  return useListenTo(commandEndEvent("editor/documents/attach-preview"), () => getCanvasIframeDocument()?.head);
3962
4000
  }
3963
4001
  function useStyleVariables() {
3964
- const [variables, setVariables] = useState19({});
3965
- useEffect6(() => {
4002
+ const [variables, setVariables] = useState20({});
4003
+ useEffect7(() => {
3966
4004
  const unsubscribe = styleVariablesRepository.subscribe(setVariables);
3967
4005
  return () => {
3968
4006
  unsubscribe();
@@ -4064,6 +4102,10 @@ function init() {
4064
4102
  id: "variables-open-panel-from-url",
4065
4103
  component: OpenPanelFromUrl
4066
4104
  });
4105
+ injectIntoLogic({
4106
+ id: "variables-open-panel-from-event",
4107
+ component: OpenPanelFromEvent
4108
+ });
4067
4109
  registerPanel(panel);
4068
4110
  }
4069
4111
  function hasVariableAssigned(value) {