@elementor/editor-variables 3.33.0-99 → 3.35.0-324

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.
Files changed (60) hide show
  1. package/dist/index.d.mts +17 -4
  2. package/dist/index.d.ts +17 -4
  3. package/dist/index.js +1903 -809
  4. package/dist/index.js.map +1 -1
  5. package/dist/index.mjs +1850 -747
  6. package/dist/index.mjs.map +1 -1
  7. package/package.json +16 -14
  8. package/src/api.ts +24 -0
  9. package/src/batch-operations.ts +86 -0
  10. package/src/components/fields/color-field.tsx +1 -0
  11. package/src/components/fields/font-field.tsx +2 -1
  12. package/src/components/fields/label-field.tsx +42 -6
  13. package/src/components/ui/deleted-variable-alert.tsx +14 -10
  14. package/src/components/ui/{no-variables.tsx → empty-state.tsx} +8 -13
  15. package/src/components/ui/menu-item-content.tsx +14 -11
  16. package/src/components/ui/mismatch-variable-alert.tsx +5 -9
  17. package/src/components/ui/missing-variable-alert.tsx +8 -9
  18. package/src/components/ui/no-search-results.tsx +1 -2
  19. package/src/components/ui/tags/assigned-tag.tsx +6 -3
  20. package/src/components/ui/tags/warning-variable-tag.tsx +44 -0
  21. package/src/components/ui/variable/deleted-variable.tsx +13 -6
  22. package/src/components/ui/variable/mismatch-variable.tsx +11 -4
  23. package/src/components/ui/variable/missing-variable.tsx +2 -2
  24. package/src/components/variable-creation.tsx +13 -4
  25. package/src/components/variable-edit.tsx +12 -12
  26. package/src/components/variable-restore.tsx +3 -2
  27. package/src/components/variables-manager/hooks/use-auto-edit.ts +21 -0
  28. package/src/components/variables-manager/hooks/use-error-navigation.ts +49 -0
  29. package/src/components/variables-manager/hooks/use-variables-manager-state.ts +89 -0
  30. package/src/components/variables-manager/variable-editable-cell.tsx +131 -67
  31. package/src/components/variables-manager/variables-manager-create-menu.tsx +118 -0
  32. package/src/components/variables-manager/variables-manager-panel.tsx +290 -59
  33. package/src/components/variables-manager/variables-manager-table.tsx +124 -14
  34. package/src/components/variables-selection.tsx +61 -15
  35. package/src/controls/variable-control.tsx +1 -1
  36. package/src/hooks/use-prop-variables.ts +28 -9
  37. package/src/hooks/use-variable-bound-prop.ts +42 -0
  38. package/src/index.ts +1 -0
  39. package/src/init.ts +9 -6
  40. package/src/mcp/create-variable-tool.ts +70 -0
  41. package/src/mcp/delete-variable-tool.ts +50 -0
  42. package/src/mcp/index.ts +17 -0
  43. package/src/mcp/list-variables-tool.ts +58 -0
  44. package/src/mcp/update-variable-tool.ts +81 -0
  45. package/src/mcp/variables-resource.ts +28 -0
  46. package/src/register-variable-types.tsx +4 -0
  47. package/src/service.ts +60 -1
  48. package/src/storage.ts +8 -0
  49. package/src/types.ts +1 -0
  50. package/src/utils/filter-by-search.ts +5 -0
  51. package/src/utils/tracking.ts +37 -22
  52. package/src/utils/unlink-variable.ts +1 -1
  53. package/src/utils/validations.ts +72 -3
  54. package/src/variables-registry/create-variable-type-registry.ts +20 -8
  55. package/src/variables-registry/variable-type-registry.ts +2 -1
  56. package/src/components/ui/tags/deleted-tag.tsx +0 -37
  57. package/src/components/ui/tags/mismatch-tag.tsx +0 -37
  58. package/src/components/ui/tags/missing-tag.tsx +0 -25
  59. /package/src/components/variables-manager/{variable-edit-menu.tsx → ui/variable-edit-menu.tsx} +0 -0
  60. /package/src/components/variables-manager/{variable-table-cell.tsx → ui/variable-table-cell.tsx} +0 -0
package/dist/index.d.mts CHANGED
@@ -1,6 +1,7 @@
1
1
  import * as _elementor_editor_props from '@elementor/editor-props';
2
2
  import { PropType } from '@elementor/editor-props';
3
3
  import * as react from 'react';
4
+ import { RefObject } from 'react';
4
5
  import * as _mui_material from '@mui/material';
5
6
 
6
7
  declare function init(): void;
@@ -17,27 +18,39 @@ type NormalizedVariable = {
17
18
  key: string;
18
19
  label: string;
19
20
  value: string;
21
+ order?: number;
20
22
  };
21
23
 
22
24
  type ValueFieldProps = {
23
25
  value: string;
24
26
  onChange: (value: string) => void;
27
+ onPropTypeKeyChange?: (key: string) => void;
28
+ propTypeKey?: string;
25
29
  onValidationChange?: (value: string) => void;
26
30
  propType?: PropType;
31
+ error?: {
32
+ value: string;
33
+ message: string;
34
+ };
35
+ ref?: RefObject<HTMLElement | null>;
27
36
  };
28
37
 
29
- declare const registerVariableType: ({ icon, startIcon, valueField, propTypeUtil, variableType, selectionFilter, valueTransformer, fallbackPropTypeUtil, isCompatible, }: {
38
+ declare const registerVariableType: ({ key, icon, startIcon, valueField, propTypeUtil, variableType, defaultValue, selectionFilter, valueTransformer, fallbackPropTypeUtil, isCompatible, }: {
30
39
  icon: react.ForwardRefExoticComponent<Omit<_mui_material.SvgIconProps, "ref"> & react.RefAttributes<SVGSVGElement>>;
31
40
  startIcon?: ({ value }: {
32
41
  value: string;
33
42
  }) => react.JSX.Element;
34
- valueField: ({ value, onChange, onValidationChange, propType }: ValueFieldProps) => react.JSX.Element;
43
+ valueField: (props: ValueFieldProps) => react.JSX.Element;
35
44
  variableType: string;
45
+ key?: string;
46
+ defaultValue?: string;
36
47
  fallbackPropTypeUtil: any;
37
48
  propTypeUtil: _elementor_editor_props.PropTypeUtil<string, string>;
38
49
  selectionFilter?: (variables: NormalizedVariable[], propType: _elementor_editor_props.PropType) => NormalizedVariable[];
39
- valueTransformer?: (value: string) => _elementor_editor_props.PropValue;
50
+ valueTransformer?: (variable: Variable) => _elementor_editor_props.PropValue;
40
51
  isCompatible?: (propType: _elementor_editor_props.PropType, variable: Variable) => boolean;
41
52
  }) => void;
42
53
 
43
- export { init, registerVariableType };
54
+ declare function registerVariableTypes(): void;
55
+
56
+ export { init, registerVariableType, registerVariableTypes };
package/dist/index.d.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  import * as _elementor_editor_props from '@elementor/editor-props';
2
2
  import { PropType } from '@elementor/editor-props';
3
3
  import * as react from 'react';
4
+ import { RefObject } from 'react';
4
5
  import * as _mui_material from '@mui/material';
5
6
 
6
7
  declare function init(): void;
@@ -17,27 +18,39 @@ type NormalizedVariable = {
17
18
  key: string;
18
19
  label: string;
19
20
  value: string;
21
+ order?: number;
20
22
  };
21
23
 
22
24
  type ValueFieldProps = {
23
25
  value: string;
24
26
  onChange: (value: string) => void;
27
+ onPropTypeKeyChange?: (key: string) => void;
28
+ propTypeKey?: string;
25
29
  onValidationChange?: (value: string) => void;
26
30
  propType?: PropType;
31
+ error?: {
32
+ value: string;
33
+ message: string;
34
+ };
35
+ ref?: RefObject<HTMLElement | null>;
27
36
  };
28
37
 
29
- declare const registerVariableType: ({ icon, startIcon, valueField, propTypeUtil, variableType, selectionFilter, valueTransformer, fallbackPropTypeUtil, isCompatible, }: {
38
+ declare const registerVariableType: ({ key, icon, startIcon, valueField, propTypeUtil, variableType, defaultValue, selectionFilter, valueTransformer, fallbackPropTypeUtil, isCompatible, }: {
30
39
  icon: react.ForwardRefExoticComponent<Omit<_mui_material.SvgIconProps, "ref"> & react.RefAttributes<SVGSVGElement>>;
31
40
  startIcon?: ({ value }: {
32
41
  value: string;
33
42
  }) => react.JSX.Element;
34
- valueField: ({ value, onChange, onValidationChange, propType }: ValueFieldProps) => react.JSX.Element;
43
+ valueField: (props: ValueFieldProps) => react.JSX.Element;
35
44
  variableType: string;
45
+ key?: string;
46
+ defaultValue?: string;
36
47
  fallbackPropTypeUtil: any;
37
48
  propTypeUtil: _elementor_editor_props.PropTypeUtil<string, string>;
38
49
  selectionFilter?: (variables: NormalizedVariable[], propType: _elementor_editor_props.PropType) => NormalizedVariable[];
39
- valueTransformer?: (value: string) => _elementor_editor_props.PropValue;
50
+ valueTransformer?: (variable: Variable) => _elementor_editor_props.PropValue;
40
51
  isCompatible?: (propType: _elementor_editor_props.PropType, variable: Variable) => boolean;
41
52
  }) => void;
42
53
 
43
- export { init, registerVariableType };
54
+ declare function registerVariableTypes(): void;
55
+
56
+ export { init, registerVariableType, registerVariableTypes };