@elementor/editor-variables 3.35.0-343 → 3.35.0-344

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
@@ -657,7 +657,8 @@ function createVariableTypeRegistry() {
657
657
  selectionFilter,
658
658
  valueTransformer,
659
659
  fallbackPropTypeUtil,
660
- isCompatible
660
+ isCompatible,
661
+ emptyState
661
662
  }) => {
662
663
  const variableTypeKey = key ?? propTypeUtil.key;
663
664
  if (!isCompatible) {
@@ -680,7 +681,8 @@ function createVariableTypeRegistry() {
680
681
  selectionFilter,
681
682
  valueTransformer,
682
683
  fallbackPropTypeUtil,
683
- isCompatible
684
+ isCompatible,
685
+ emptyState
684
686
  };
685
687
  registerTransformer(propTypeUtil.key);
686
688
  registerInheritanceTransformer(propTypeUtil.key);
@@ -755,8 +757,13 @@ var usePermissions = () => {
755
757
  };
756
758
 
757
759
  // src/components/ui/empty-state.tsx
758
- var EmptyState = ({ icon, title, message, onAdd }) => {
760
+ var EmptyState = ({ icon, title, message, onAdd, children }) => {
759
761
  const canAdd = usePermissions().canAdd();
762
+ const displayTitle = canAdd ? title : __5("There are no variables", "elementor");
763
+ const displayMessage = canAdd ? message : __5("With your current role, you can only connect and detach variables.", "elementor");
764
+ return /* @__PURE__ */ React3.createElement(Content, { title: displayTitle, message: displayMessage, icon }, children || onAdd && /* @__PURE__ */ React3.createElement(Button2, { variant: "outlined", color: "secondary", size: "small", onClick: onAdd }, __5("Create a variable", "elementor")));
765
+ };
766
+ function Content({ title, message, icon, children }) {
760
767
  return /* @__PURE__ */ React3.createElement(
761
768
  Stack2,
762
769
  {
@@ -768,17 +775,10 @@ var EmptyState = ({ icon, title, message, onAdd }) => {
768
775
  sx: { p: 2.5, pt: 8, pb: 5.5 }
769
776
  },
770
777
  icon,
771
- canAdd ? /* @__PURE__ */ React3.createElement(React3.Fragment, null, /* @__PURE__ */ React3.createElement(Content, { title, message }), onAdd && /* @__PURE__ */ React3.createElement(Button2, { variant: "outlined", color: "secondary", size: "small", onClick: onAdd }, __5("Create a variable", "elementor"))) : /* @__PURE__ */ React3.createElement(
772
- Content,
773
- {
774
- title: __5("There are no variables", "elementor"),
775
- message: __5("With your current role, you can only connect and detach variables.", "elementor")
776
- }
777
- )
778
+ /* @__PURE__ */ React3.createElement(Typography3, { align: "center", variant: "subtitle2" }, title),
779
+ /* @__PURE__ */ React3.createElement(Typography3, { align: "center", variant: "caption", maxWidth: "180px" }, message),
780
+ children
778
781
  );
779
- };
780
- function Content({ title, message }) {
781
- return /* @__PURE__ */ React3.createElement(React3.Fragment, null, /* @__PURE__ */ React3.createElement(Typography3, { align: "center", variant: "subtitle2" }, title), /* @__PURE__ */ React3.createElement(Typography3, { align: "center", variant: "caption", maxWidth: "180px" }, message));
782
782
  }
783
783
 
784
784
  // src/components/ui/no-search-results.tsx
@@ -1611,7 +1611,7 @@ var VariablesManagerTable = ({
1611
1611
  onChange,
1612
1612
  onValidationChange,
1613
1613
  error
1614
- }) => row.valueField({
1614
+ }) => row.valueField?.({
1615
1615
  ref: {
1616
1616
  current: variableRowRefs.current.get(
1617
1617
  "table-ref-" + row.id
@@ -1631,7 +1631,7 @@ var VariablesManagerTable = ({
1631
1631
  onFieldError?.(!!errorMsg);
1632
1632
  },
1633
1633
  error
1634
- }),
1634
+ }) ?? /* @__PURE__ */ React11.createElement(React11.Fragment, null),
1635
1635
  onRowRef: handleRowRef(row.id),
1636
1636
  gap: 0.25,
1637
1637
  fieldType: "value"
@@ -1996,6 +1996,25 @@ var usePopoverContentRef = () => {
1996
1996
  return useContext2(PopoverContentRefContext);
1997
1997
  };
1998
1998
 
1999
+ // src/sync/license-info.ts
2000
+ function getLicenseInfo() {
2001
+ const extendedWindow = window;
2002
+ return {
2003
+ hasPro: !!extendedWindow.elementorPro
2004
+ };
2005
+ }
2006
+
2007
+ // src/hooks/use-quota-permissions.ts
2008
+ var useQuotaPermissions = (variableType) => {
2009
+ const quotaConfig = window.ElementorVariablesQuotaConfig || {};
2010
+ const limit = quotaConfig[variableType] || 0;
2011
+ const hasQuota = limit > 0;
2012
+ return {
2013
+ canAdd: () => hasQuota || getLicenseInfo().hasPro,
2014
+ canEdit: () => hasQuota || getLicenseInfo().hasPro
2015
+ };
2016
+ };
2017
+
1999
2018
  // src/components/variable-creation.tsx
2000
2019
  import * as React15 from "react";
2001
2020
  import { useState as useState7 } from "react";
@@ -2148,7 +2167,7 @@ var VariableCreation = ({ onGoBack, onClose }) => {
2148
2167
  }
2149
2168
  }
2150
2169
  )
2151
- ), /* @__PURE__ */ React15.createElement(FormField, { errorMsg: valueFieldError, label: __10("Value", "elementor") }, /* @__PURE__ */ React15.createElement(Typography6, { variant: "h5", id: "variable-value-wrapper" }, /* @__PURE__ */ React15.createElement(
2170
+ ), ValueField && /* @__PURE__ */ React15.createElement(FormField, { errorMsg: valueFieldError, label: __10("Value", "elementor") }, /* @__PURE__ */ React15.createElement(Typography6, { variant: "h5", id: "variable-value-wrapper" }, /* @__PURE__ */ React15.createElement(
2152
2171
  ValueField,
2153
2172
  {
2154
2173
  value,
@@ -2377,7 +2396,7 @@ var VariableEdit = ({ onClose, onGoBack, onSubmit, editId }) => {
2377
2396
  }
2378
2397
  }
2379
2398
  )
2380
- ), /* @__PURE__ */ React17.createElement(FormField, { errorMsg: valueFieldError, label: __12("Value", "elementor") }, /* @__PURE__ */ React17.createElement(Typography8, { variant: "h5" }, /* @__PURE__ */ React17.createElement(
2399
+ ), ValueField && /* @__PURE__ */ React17.createElement(FormField, { errorMsg: valueFieldError, label: __12("Value", "elementor") }, /* @__PURE__ */ React17.createElement(Typography8, { variant: "h5" }, /* @__PURE__ */ React17.createElement(
2381
2400
  ValueField,
2382
2401
  {
2383
2402
  propTypeKey: variable.type,
@@ -2510,8 +2529,8 @@ var VariablesStyledMenuList = styled2(MenuList)(({ theme }) => ({
2510
2529
  var SIZE5 = "tiny";
2511
2530
  var CREATE_LABEL = __14("Create variable", "elementor");
2512
2531
  var MANAGER_LABEL = __14("Variables Manager", "elementor");
2513
- var VariablesSelection = ({ closePopover, onAdd, onEdit, onSettings }) => {
2514
- const { icon: VariableIcon, startIcon, variableType, propTypeUtil } = useVariableType();
2532
+ var VariablesSelection = ({ closePopover, onAdd, onEdit, onSettings, disabled = false }) => {
2533
+ const { icon: VariableIcon, startIcon, variableType, propTypeUtil, emptyState } = useVariableType();
2515
2534
  const { value: variable, setValue: setVariable, path } = useVariableBoundProp();
2516
2535
  const [searchValue, setSearchValue] = useState10("");
2517
2536
  const {
@@ -2540,16 +2559,17 @@ var VariablesSelection = ({ closePopover, onAdd, onEdit, onSettings }) => {
2540
2559
  const actions = [];
2541
2560
  if (onAdd) {
2542
2561
  actions.push(
2543
- /* @__PURE__ */ React19.createElement(Tooltip3, { key: "add", placement: "top", title: CREATE_LABEL }, /* @__PURE__ */ React19.createElement(
2562
+ /* @__PURE__ */ React19.createElement(Tooltip3, { key: "add", placement: "top", title: CREATE_LABEL }, /* @__PURE__ */ React19.createElement("span", null, /* @__PURE__ */ React19.createElement(
2544
2563
  IconButton7,
2545
2564
  {
2546
2565
  id: "add-variable-button",
2547
2566
  size: SIZE5,
2548
2567
  onClick: onAddAndTrack,
2549
- "aria-label": CREATE_LABEL
2568
+ "aria-label": CREATE_LABEL,
2569
+ disabled
2550
2570
  },
2551
2571
  /* @__PURE__ */ React19.createElement(PlusIcon2, { fontSize: SIZE5 })
2552
- ))
2572
+ )))
2553
2573
  );
2554
2574
  }
2555
2575
  if (onSettings) {
@@ -2589,11 +2609,23 @@ var VariablesSelection = ({ closePopover, onAdd, onEdit, onSettings }) => {
2589
2609
  const handleClearSearch = () => {
2590
2610
  setSearchValue("");
2591
2611
  };
2592
- const noVariableTitle = sprintf2(
2612
+ const noVariableTitle = disabled ? sprintf2(
2613
+ /* translators: %s: Variable Type. */
2614
+ __14("No %s variables yet", "elementor"),
2615
+ variableType
2616
+ ) : sprintf2(
2593
2617
  /* translators: %s: Variable Type. */
2594
2618
  __14("Create your first %s variable", "elementor"),
2595
2619
  variableType
2596
2620
  );
2621
+ const noVariableMessage = disabled ? sprintf2(
2622
+ /* translators: %s: Variable Type. */
2623
+ __14(
2624
+ "Start by creating your first %s variable to apply consistent sizing across elements.",
2625
+ "elementor"
2626
+ ),
2627
+ variableType
2628
+ ) : __14("Variables are saved attributes that you can apply anywhere on your site.", "elementor");
2597
2629
  return /* @__PURE__ */ React19.createElement(PopoverBody3, null, /* @__PURE__ */ React19.createElement(
2598
2630
  PopoverHeader3,
2599
2631
  {
@@ -2632,13 +2664,11 @@ var VariablesSelection = ({ closePopover, onAdd, onEdit, onSettings }) => {
2632
2664
  EmptyState,
2633
2665
  {
2634
2666
  title: noVariableTitle,
2635
- message: __14(
2636
- "Variables are saved attributes that you can apply anywhere on your site.",
2637
- "elementor"
2638
- ),
2667
+ message: noVariableMessage,
2639
2668
  icon: /* @__PURE__ */ React19.createElement(VariableIcon, { fontSize: "large" }),
2640
- onAdd
2641
- }
2669
+ onAdd: disabled ? void 0 : onAdd
2670
+ },
2671
+ emptyState
2642
2672
  ), hasNoCompatibleVariables && /* @__PURE__ */ React19.createElement(
2643
2673
  EmptyState,
2644
2674
  {
@@ -2648,8 +2678,9 @@ var VariablesSelection = ({ closePopover, onAdd, onEdit, onSettings }) => {
2648
2678
  "elementor"
2649
2679
  ),
2650
2680
  icon: /* @__PURE__ */ React19.createElement(VariableIcon, { fontSize: "large" }),
2651
- onAdd
2652
- }
2681
+ onAdd: disabled ? void 0 : onAdd
2682
+ },
2683
+ emptyState
2653
2684
  ));
2654
2685
  };
2655
2686
 
@@ -2677,6 +2708,7 @@ var VariableSelectionPopover = ({ closePopover, propTypeKey, selectedVariable })
2677
2708
  };
2678
2709
  function RenderView(props) {
2679
2710
  const userPermissions = usePermissions();
2711
+ const userQuotaPremissions = useQuotaPermissions(props.propTypeKey);
2680
2712
  const handlers = {
2681
2713
  onClose: () => {
2682
2714
  props.closePopover();
@@ -2716,7 +2748,8 @@ function RenderView(props) {
2716
2748
  closePopover: handlers.onClose,
2717
2749
  onAdd: handlers.onAdd,
2718
2750
  onEdit: handlers.onEdit,
2719
- onSettings: handlers.onSettings
2751
+ onSettings: handlers.onSettings,
2752
+ disabled: !userQuotaPremissions.canAdd()
2720
2753
  }
2721
2754
  );
2722
2755
  }
@@ -2905,7 +2938,7 @@ var VariableRestore = ({ variableId, onClose, onSubmit }) => {
2905
2938
  }
2906
2939
  }
2907
2940
  )
2908
- ), /* @__PURE__ */ React23.createElement(FormField, { errorMsg: valueFieldError, label: __16("Value", "elementor") }, /* @__PURE__ */ React23.createElement(Typography11, { variant: "h5" }, /* @__PURE__ */ React23.createElement(
2941
+ ), ValueField && /* @__PURE__ */ React23.createElement(FormField, { errorMsg: valueFieldError, label: __16("Value", "elementor") }, /* @__PURE__ */ React23.createElement(Typography11, { variant: "h5" }, /* @__PURE__ */ React23.createElement(
2909
2942
  ValueField,
2910
2943
  {
2911
2944
  value,
@@ -3531,8 +3564,9 @@ function initMcp() {
3531
3564
 
3532
3565
  // src/register-variable-types.tsx
3533
3566
  import * as React35 from "react";
3534
- import { colorPropTypeUtil, stringPropTypeUtil } from "@elementor/editor-props";
3535
- import { BrushIcon, TextIcon as TextIcon2 } from "@elementor/icons";
3567
+ import { colorPropTypeUtil, sizePropTypeUtil, stringPropTypeUtil } from "@elementor/editor-props";
3568
+ import { UpgradeButton } from "@elementor/editor-ui";
3569
+ import { BrushIcon, ExpandDiagonalIcon, TextIcon as TextIcon2 } from "@elementor/icons";
3536
3570
 
3537
3571
  // src/components/fields/color-field.tsx
3538
3572
  import * as React33 from "react";
@@ -3648,6 +3682,11 @@ var FontField = ({ value, onChange, onValidationChange }) => {
3648
3682
  ));
3649
3683
  };
3650
3684
 
3685
+ // src/prop-types/size-variable-prop-type.ts
3686
+ import { createPropUtils as createPropUtils3 } from "@elementor/editor-props";
3687
+ import { z as z6 } from "@elementor/schema";
3688
+ var sizeVariablePropTypeUtil = createPropUtils3("global-size-variable", z6.string());
3689
+
3651
3690
  // src/register-variable-types.tsx
3652
3691
  function registerVariableTypes() {
3653
3692
  registerVariableType({
@@ -3669,6 +3708,15 @@ function registerVariableTypes() {
3669
3708
  variableType: "font",
3670
3709
  defaultValue: "Roboto"
3671
3710
  });
3711
+ registerVariableType({
3712
+ key: sizeVariablePropTypeUtil.key,
3713
+ icon: ExpandDiagonalIcon,
3714
+ propTypeUtil: sizeVariablePropTypeUtil,
3715
+ fallbackPropTypeUtil: sizePropTypeUtil,
3716
+ variableType: "size",
3717
+ selectionFilter: () => [],
3718
+ emptyState: /* @__PURE__ */ React35.createElement(UpgradeButton, { size: "small", href: "https://go.elementor.com/go-pro-panel-size-variable/" })
3719
+ });
3672
3720
  }
3673
3721
 
3674
3722
  // src/renderers/style-variables-renderer.tsx
@@ -3834,6 +3882,7 @@ export {
3834
3882
  init,
3835
3883
  registerVariableType,
3836
3884
  registerVariableTypes,
3837
- service
3885
+ service,
3886
+ sizeVariablePropTypeUtil
3838
3887
  };
3839
3888
  //# sourceMappingURL=index.mjs.map