@elementor/editor-variables 4.1.0-788 → 4.1.0-789

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@elementor/editor-variables",
3
- "version": "4.1.0-788",
3
+ "version": "4.1.0-789",
4
4
  "private": false,
5
5
  "author": "Elementor Team",
6
6
  "homepage": "https://elementor.com/",
@@ -39,22 +39,22 @@
39
39
  "dev": "tsup --config=../../tsup.dev.ts"
40
40
  },
41
41
  "dependencies": {
42
- "@elementor/editor": "4.1.0-788",
43
- "@elementor/editor-canvas": "4.1.0-788",
44
- "@elementor/editor-controls": "4.1.0-788",
45
- "@elementor/editor-current-user": "4.1.0-788",
46
- "@elementor/editor-mcp": "4.1.0-788",
47
- "@elementor/editor-panels": "4.1.0-788",
48
- "@elementor/editor-props": "4.1.0-788",
49
- "@elementor/editor-ui": "4.1.0-788",
50
- "@elementor/editor-v1-adapters": "4.1.0-788",
51
- "@elementor/menus": "4.1.0-788",
52
- "@elementor/http-client": "4.1.0-788",
42
+ "@elementor/editor": "4.1.0-789",
43
+ "@elementor/editor-canvas": "4.1.0-789",
44
+ "@elementor/editor-controls": "4.1.0-789",
45
+ "@elementor/editor-current-user": "4.1.0-789",
46
+ "@elementor/editor-mcp": "4.1.0-789",
47
+ "@elementor/editor-panels": "4.1.0-789",
48
+ "@elementor/editor-props": "4.1.0-789",
49
+ "@elementor/editor-ui": "4.1.0-789",
50
+ "@elementor/editor-v1-adapters": "4.1.0-789",
51
+ "@elementor/menus": "4.1.0-789",
52
+ "@elementor/http-client": "4.1.0-789",
53
53
  "@elementor/icons": "^1.72.0",
54
- "@elementor/events": "4.1.0-788",
55
- "@elementor/schema": "4.1.0-788",
54
+ "@elementor/events": "4.1.0-789",
55
+ "@elementor/schema": "4.1.0-789",
56
56
  "@elementor/ui": "1.37.5",
57
- "@elementor/utils": "4.1.0-788",
57
+ "@elementor/utils": "4.1.0-789",
58
58
  "@wordpress/i18n": "^5.13.0"
59
59
  },
60
60
  "peerDependencies": {
@@ -2,12 +2,16 @@ import * as React from 'react';
2
2
  import {
3
3
  type BackgroundColorOverlayPropValue,
4
4
  type BoxShadowPropValue,
5
+ cssFilterFunctionPropUtil,
6
+ dropShadowFilterPropTypeUtil,
5
7
  type KeyValuePropValue,
6
8
  type PropValue,
7
9
  selectionSizePropTypeUtil,
8
10
  type SelectionSizePropValue,
9
11
  shadowPropTypeUtil,
10
12
  } from '@elementor/editor-props';
13
+ import { Box } from '@elementor/ui';
14
+ import { __ } from '@wordpress/i18n';
11
15
 
12
16
  import { getVariable } from '../hooks/use-prop-variables';
13
17
  import { sizeValue } from '../utils/size-value';
@@ -32,7 +36,7 @@ export const BackgroundRepeaterColorIndicator = ( { value }: Props ) => {
32
36
  export const BackgroundRepeaterLabel = ( { value }: Props ) => {
33
37
  const colorVariable = useColorVariable( value as BackgroundColorOverlayPropValue );
34
38
 
35
- return <span>{ colorVariable?.label }</span>;
39
+ return <Box component="span">{ colorVariable?.label }</Box>;
36
40
  };
37
41
 
38
42
  export const BoxShadowRepeaterColorIndicator = ( { value }: Props ) => {
@@ -41,24 +45,73 @@ export const BoxShadowRepeaterColorIndicator = ( { value }: Props ) => {
41
45
  return <ColorIndicator component="span" size="inherit" value={ colorVariable?.value } />;
42
46
  };
43
47
 
48
+ export const FilterDropShadowIconIndicator = ( { value }: Props ) => {
49
+ const { args } = cssFilterFunctionPropUtil.extract( value ) || {};
50
+ const { color } = dropShadowFilterPropTypeUtil.extract( args ) || {};
51
+ const colorVariable = getVariable( color?.value || '' );
52
+
53
+ return <ColorIndicator component="span" size="inherit" value={ colorVariable?.value } />;
54
+ };
55
+
56
+ export const FilterSingleSizeRepeaterLabel = ( { value }: Props ) => {
57
+ const cssFilterFunction = cssFilterFunctionPropUtil.extract( value );
58
+
59
+ if ( dropShadowFilterPropTypeUtil.isValid( cssFilterFunction?.args ) ) {
60
+ return null;
61
+ }
62
+
63
+ const args = cssFilterFunction?.args as { value?: { size?: PropValue } };
64
+ const func = cssFilterFunction?.func?.value ?? '';
65
+ const rendered = sizeValue( args?.value?.size );
66
+
67
+ return (
68
+ <>
69
+ <Box component="span" style={ { textTransform: 'capitalize' } }>
70
+ { `${ func }: ` }
71
+ </Box>
72
+ <Box component="span">{ rendered }</Box>
73
+ </>
74
+ );
75
+ };
76
+
77
+ export const FilterDropShadowRepeaterLabel = ( { value }: Props ) => {
78
+ const { args } = cssFilterFunctionPropUtil.extract( value ) || {};
79
+ const { xAxis, yAxis, blur } = dropShadowFilterPropTypeUtil.extract( args ) || {};
80
+
81
+ const labels = [];
82
+
83
+ for ( const val of [ xAxis, yAxis, blur ] ) {
84
+ const rendered = sizeValue( val );
85
+ if ( rendered ) {
86
+ labels.push( rendered );
87
+ }
88
+ }
89
+
90
+ return (
91
+ <Box component="span">
92
+ { __( 'Drop shadow:', 'elementor' ) } { labels.join( ' ' ) }
93
+ </Box>
94
+ );
95
+ };
96
+
44
97
  export const BoxShadowRepeaterLabel = ( { value }: Props ) => {
45
- const shadowPropValue = shadowPropTypeUtil.extract( value ) || {};
98
+ const { position, hOffset, vOffset, blur, spread } = shadowPropTypeUtil.extract( value ) || {};
46
99
 
47
100
  const labels: string[] = [];
48
101
 
49
- for ( const key of [ 'hOffset', 'vOffset', 'blur', 'spread' ] ) {
50
- const rendered = sizeValue( shadowPropValue[ key as keyof typeof shadowPropValue ] );
102
+ for ( const val of [ hOffset, vOffset, blur, spread ] ) {
103
+ const rendered = sizeValue( val );
51
104
  if ( rendered ) {
52
105
  labels.push( rendered );
53
106
  }
54
107
  }
55
108
 
56
- const positionLabel = shadowPropValue.position?.value || 'outset';
109
+ const positionLabel = position?.value || 'outset';
57
110
 
58
111
  return (
59
- <span style={ { textTransform: 'capitalize' } }>
112
+ <Box component="span" style={ { textTransform: 'capitalize' } }>
60
113
  { positionLabel }: { labels.join( ' ' ) }
61
- </span>
114
+ </Box>
62
115
  );
63
116
  };
64
117
 
@@ -76,5 +129,5 @@ export const TransitionsSizeVariableLabel = ( { value: prop }: Props ) => {
76
129
  label += variable?.value;
77
130
  }
78
131
 
79
- return <span>{ label }</span>;
132
+ return <Box component="span">{ label }</Box>;
80
133
  };
@@ -1,6 +1,8 @@
1
1
  import { injectIntoRepeaterItemIcon, injectIntoRepeaterItemLabel } from '@elementor/editor-controls';
2
2
  import {
3
3
  backgroundColorOverlayPropTypeUtil,
4
+ cssFilterFunctionPropUtil,
5
+ dropShadowFilterPropTypeUtil,
4
6
  type PropValue,
5
7
  selectionSizePropTypeUtil,
6
8
  shadowPropTypeUtil,
@@ -11,6 +13,9 @@ import {
11
13
  BackgroundRepeaterLabel,
12
14
  BoxShadowRepeaterColorIndicator,
13
15
  BoxShadowRepeaterLabel,
16
+ FilterDropShadowIconIndicator,
17
+ FilterDropShadowRepeaterLabel,
18
+ FilterSingleSizeRepeaterLabel,
14
19
  TransitionsSizeVariableLabel,
15
20
  } from './components/variables-repeater-item-slot';
16
21
  import { colorVariablePropTypeUtil, customSizeVariablePropTypeUtil, sizeVariablePropTypeUtil } from './prop-types';
@@ -23,11 +28,12 @@ export function registerRepeaterInjections() {
23
28
  backgroundOverlayRepeaterInjections();
24
29
  boxShadowRepeaterInjections();
25
30
  transitionsRepeaterInjections();
31
+ filterRepeaterInjections();
26
32
  }
27
33
 
28
- const backgroundOverlayRepeaterInjections = () => {
34
+ function backgroundOverlayRepeaterInjections() {
29
35
  injectIntoRepeaterItemIcon( {
30
- id: 'color-variables-background-icon',
36
+ id: 'background-color-variables-icon',
31
37
  component: BackgroundRepeaterColorIndicator,
32
38
  condition: ( { value }: Args ) => {
33
39
  return hasAssignedColorVariable( backgroundColorOverlayPropTypeUtil.extract( value )?.color );
@@ -35,17 +41,17 @@ const backgroundOverlayRepeaterInjections = () => {
35
41
  } );
36
42
 
37
43
  injectIntoRepeaterItemLabel( {
38
- id: 'color-variables-label',
44
+ id: 'background-color-variables-label',
39
45
  component: BackgroundRepeaterLabel,
40
46
  condition: ( { value }: Args ) => {
41
47
  return hasAssignedColorVariable( backgroundColorOverlayPropTypeUtil.extract( value )?.color );
42
48
  },
43
49
  } );
44
- };
50
+ }
45
51
 
46
- const boxShadowRepeaterInjections = () => {
52
+ function boxShadowRepeaterInjections() {
47
53
  injectIntoRepeaterItemIcon( {
48
- id: 'color-variables-box-shadow-icon',
54
+ id: 'box-shadow-color-variables-icon',
49
55
  component: BoxShadowRepeaterColorIndicator,
50
56
  condition: ( { value }: Args ) => {
51
57
  const { color } = shadowPropTypeUtil.extract( value ) || {};
@@ -67,9 +73,9 @@ const boxShadowRepeaterInjections = () => {
67
73
  );
68
74
  },
69
75
  } );
70
- };
76
+ }
71
77
 
72
- const transitionsRepeaterInjections = () => {
78
+ function transitionsRepeaterInjections() {
73
79
  injectIntoRepeaterItemLabel( {
74
80
  id: 'transition-size-variables-label',
75
81
  component: TransitionsSizeVariableLabel,
@@ -77,9 +83,63 @@ const transitionsRepeaterInjections = () => {
77
83
  return hasAssignedSizeVariable( selectionSizePropTypeUtil.extract( value )?.size );
78
84
  },
79
85
  } );
80
- };
86
+ }
87
+
88
+ function filterRepeaterInjections() {
89
+ injectIntoRepeaterItemIcon( {
90
+ id: 'filters-color-variables-icon',
91
+ component: FilterDropShadowIconIndicator,
92
+ condition: ( { value }: Args ) => {
93
+ if ( ! cssFilterFunctionPropUtil.isValid( value ) ) {
94
+ return false;
95
+ }
96
+
97
+ const args = cssFilterFunctionPropUtil.extract( value )?.args;
98
+ if ( dropShadowFilterPropTypeUtil.isValid( args ) ) {
99
+ return hasAssignedColorVariable( dropShadowFilterPropTypeUtil.extract( args )?.color );
100
+ }
101
+
102
+ return false;
103
+ },
104
+ } );
105
+
106
+ injectIntoRepeaterItemLabel( {
107
+ id: 'filters-drop-shadow-size-variables-label',
108
+ component: FilterDropShadowRepeaterLabel,
109
+ condition: ( { value }: Args ) => {
110
+ if ( ! cssFilterFunctionPropUtil.isValid( value ) ) {
111
+ return false;
112
+ }
81
113
 
82
- const hasAssignedSizeVariable = ( value: PropValue ): boolean => {
114
+ const args = cssFilterFunctionPropUtil.extract( value )?.args;
115
+ if ( dropShadowFilterPropTypeUtil.isValid( args ) ) {
116
+ const { xAxis, yAxis, blur } = dropShadowFilterPropTypeUtil.extract( args ) || {};
117
+ return (
118
+ hasAssignedSizeVariable( xAxis ) ||
119
+ hasAssignedSizeVariable( yAxis ) ||
120
+ hasAssignedSizeVariable( blur )
121
+ );
122
+ }
123
+
124
+ return false;
125
+ },
126
+ } );
127
+
128
+ injectIntoRepeaterItemLabel( {
129
+ id: 'filters-size-variables-label',
130
+ component: FilterSingleSizeRepeaterLabel,
131
+ condition: ( { value }: Args ) => {
132
+ if ( ! cssFilterFunctionPropUtil.isValid( value ) ) {
133
+ return false;
134
+ }
135
+
136
+ const args = cssFilterFunctionPropUtil.extract( value )?.args as { value?: { size?: PropValue } };
137
+ return hasAssignedSizeVariable( args?.value?.size );
138
+ },
139
+ } );
140
+ }
141
+
142
+ function hasAssignedSizeVariable( value: PropValue ): boolean {
83
143
  if ( sizeVariablePropTypeUtil.isValid( value ) ) {
84
144
  return true;
85
145
  }
@@ -89,8 +149,8 @@ const hasAssignedSizeVariable = ( value: PropValue ): boolean => {
89
149
  }
90
150
 
91
151
  return false;
92
- };
152
+ }
93
153
 
94
- const hasAssignedColorVariable = ( value: PropValue ): boolean => {
154
+ function hasAssignedColorVariable( value: PropValue ): boolean {
95
155
  return !! colorVariablePropTypeUtil.isValid( value );
96
- };
156
+ }