@elementor/editor-variables 4.1.0-772 → 4.1.0-773
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.js +59 -15
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +63 -13
- package/dist/index.mjs.map +1 -1
- package/package.json +15 -15
- package/src/components/variables-repeater-item-slot.tsx +32 -4
- package/src/prop-types/custom-size-variable-prop-type.ts +4 -0
- package/src/prop-types/index.ts +4 -0
- package/src/repeater-injections.ts +54 -14
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@elementor/editor-variables",
|
|
3
|
-
"version": "4.1.0-
|
|
3
|
+
"version": "4.1.0-773",
|
|
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-
|
|
43
|
-
"@elementor/editor-canvas": "4.1.0-
|
|
44
|
-
"@elementor/editor-controls": "4.1.0-
|
|
45
|
-
"@elementor/editor-current-user": "4.1.0-
|
|
46
|
-
"@elementor/editor-mcp": "4.1.0-
|
|
47
|
-
"@elementor/editor-panels": "4.1.0-
|
|
48
|
-
"@elementor/editor-props": "4.1.0-
|
|
49
|
-
"@elementor/editor-ui": "4.1.0-
|
|
50
|
-
"@elementor/editor-v1-adapters": "4.1.0-
|
|
51
|
-
"@elementor/menus": "4.1.0-
|
|
52
|
-
"@elementor/http-client": "4.1.0-
|
|
42
|
+
"@elementor/editor": "4.1.0-773",
|
|
43
|
+
"@elementor/editor-canvas": "4.1.0-773",
|
|
44
|
+
"@elementor/editor-controls": "4.1.0-773",
|
|
45
|
+
"@elementor/editor-current-user": "4.1.0-773",
|
|
46
|
+
"@elementor/editor-mcp": "4.1.0-773",
|
|
47
|
+
"@elementor/editor-panels": "4.1.0-773",
|
|
48
|
+
"@elementor/editor-props": "4.1.0-773",
|
|
49
|
+
"@elementor/editor-ui": "4.1.0-773",
|
|
50
|
+
"@elementor/editor-v1-adapters": "4.1.0-773",
|
|
51
|
+
"@elementor/menus": "4.1.0-773",
|
|
52
|
+
"@elementor/http-client": "4.1.0-773",
|
|
53
53
|
"@elementor/icons": "^1.72.0",
|
|
54
|
-
"@elementor/events": "4.1.0-
|
|
55
|
-
"@elementor/schema": "4.1.0-
|
|
54
|
+
"@elementor/events": "4.1.0-773",
|
|
55
|
+
"@elementor/schema": "4.1.0-773",
|
|
56
56
|
"@elementor/ui": "1.37.5",
|
|
57
|
-
"@elementor/utils": "4.1.0-
|
|
57
|
+
"@elementor/utils": "4.1.0-773",
|
|
58
58
|
"@wordpress/i18n": "^5.13.0"
|
|
59
59
|
},
|
|
60
60
|
"peerDependencies": {
|
|
@@ -1,29 +1,57 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
type BackgroundColorOverlayPropValue,
|
|
4
|
+
type BoxShadowPropValue,
|
|
5
|
+
type KeyValuePropValue,
|
|
6
|
+
type PropValue,
|
|
7
|
+
selectionSizePropTypeUtil,
|
|
8
|
+
type SelectionSizePropValue,
|
|
9
|
+
} from '@elementor/editor-props';
|
|
3
10
|
|
|
4
11
|
import { useVariable } from '../hooks/use-prop-variables';
|
|
5
12
|
import { ColorIndicator } from './ui/color-indicator';
|
|
6
13
|
|
|
14
|
+
type Props = {
|
|
15
|
+
value: PropValue;
|
|
16
|
+
};
|
|
17
|
+
|
|
7
18
|
const useColorVariable = ( value: BackgroundColorOverlayPropValue | BoxShadowPropValue ) => {
|
|
8
19
|
const variableId = value?.value?.color?.value;
|
|
9
20
|
|
|
10
21
|
return useVariable( variableId || '' );
|
|
11
22
|
};
|
|
12
23
|
|
|
13
|
-
export const BackgroundRepeaterColorIndicator = ( { value }:
|
|
24
|
+
export const BackgroundRepeaterColorIndicator = ( { value }: Props ) => {
|
|
14
25
|
const colorVariable = useColorVariable( value as BackgroundColorOverlayPropValue );
|
|
15
26
|
|
|
16
27
|
return <ColorIndicator component="span" size="inherit" value={ colorVariable?.value } />;
|
|
17
28
|
};
|
|
18
29
|
|
|
19
|
-
export const BackgroundRepeaterLabel = ( { value }:
|
|
30
|
+
export const BackgroundRepeaterLabel = ( { value }: Props ) => {
|
|
20
31
|
const colorVariable = useColorVariable( value as BackgroundColorOverlayPropValue );
|
|
21
32
|
|
|
22
33
|
return <span>{ colorVariable?.label }</span>;
|
|
23
34
|
};
|
|
24
35
|
|
|
25
|
-
export const BoxShadowRepeaterColorIndicator = ( { value }:
|
|
36
|
+
export const BoxShadowRepeaterColorIndicator = ( { value }: Props ) => {
|
|
26
37
|
const colorVariable = useColorVariable( value as BoxShadowPropValue );
|
|
27
38
|
|
|
28
39
|
return <ColorIndicator component="span" size="inherit" value={ colorVariable?.value } />;
|
|
29
40
|
};
|
|
41
|
+
|
|
42
|
+
export const TransitionsSizeVariableLabel = ( { value: prop }: Props ) => {
|
|
43
|
+
let label = '';
|
|
44
|
+
|
|
45
|
+
const variableId = ( prop as SelectionSizePropValue )?.value?.size?.value || '';
|
|
46
|
+
const variable = useVariable( variableId );
|
|
47
|
+
|
|
48
|
+
if ( variable && selectionSizePropTypeUtil.isValid( prop ) ) {
|
|
49
|
+
const selection = ( prop.value?.selection as KeyValuePropValue )?.value?.key?.value;
|
|
50
|
+
if ( selection ) {
|
|
51
|
+
label += `${ selection }: `;
|
|
52
|
+
}
|
|
53
|
+
label += variable?.value;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
return <span>{ label }</span>;
|
|
57
|
+
};
|
|
@@ -1,39 +1,79 @@
|
|
|
1
1
|
import { injectIntoRepeaterItemIcon, injectIntoRepeaterItemLabel } from '@elementor/editor-controls';
|
|
2
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
backgroundColorOverlayPropTypeUtil,
|
|
4
|
+
type PropValue,
|
|
5
|
+
selectionSizePropTypeUtil,
|
|
6
|
+
shadowPropTypeUtil,
|
|
7
|
+
} from '@elementor/editor-props';
|
|
3
8
|
|
|
4
9
|
import {
|
|
5
10
|
BackgroundRepeaterColorIndicator,
|
|
6
11
|
BackgroundRepeaterLabel,
|
|
7
12
|
BoxShadowRepeaterColorIndicator,
|
|
13
|
+
TransitionsSizeVariableLabel,
|
|
8
14
|
} from './components/variables-repeater-item-slot';
|
|
9
|
-
import { colorVariablePropTypeUtil } from './prop-types
|
|
15
|
+
import { colorVariablePropTypeUtil, customSizeVariablePropTypeUtil, sizeVariablePropTypeUtil } from './prop-types';
|
|
16
|
+
|
|
17
|
+
type Args = {
|
|
18
|
+
value: PropValue;
|
|
19
|
+
};
|
|
10
20
|
|
|
11
21
|
export function registerRepeaterInjections() {
|
|
22
|
+
backgroundOverlayRepeaterInjections();
|
|
23
|
+
boxShadowRepeaterInjections();
|
|
24
|
+
transitionsRepeaterInjections();
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
const backgroundOverlayRepeaterInjections = () => {
|
|
12
28
|
injectIntoRepeaterItemIcon( {
|
|
13
29
|
id: 'color-variables-background-icon',
|
|
14
30
|
component: BackgroundRepeaterColorIndicator,
|
|
15
|
-
condition: ( { value
|
|
16
|
-
return hasAssignedColorVariable( backgroundColorOverlayPropTypeUtil.extract(
|
|
31
|
+
condition: ( { value }: Args ) => {
|
|
32
|
+
return hasAssignedColorVariable( backgroundColorOverlayPropTypeUtil.extract( value )?.color );
|
|
17
33
|
},
|
|
18
34
|
} );
|
|
19
35
|
|
|
36
|
+
injectIntoRepeaterItemLabel( {
|
|
37
|
+
id: 'color-variables-label',
|
|
38
|
+
component: BackgroundRepeaterLabel,
|
|
39
|
+
condition: ( { value }: Args ) => {
|
|
40
|
+
return hasAssignedColorVariable( backgroundColorOverlayPropTypeUtil.extract( value )?.color );
|
|
41
|
+
},
|
|
42
|
+
} );
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
const boxShadowRepeaterInjections = () => {
|
|
20
46
|
injectIntoRepeaterItemIcon( {
|
|
21
|
-
id: 'color-variables-icon',
|
|
47
|
+
id: 'color-variables-box-shadow-icon',
|
|
22
48
|
component: BoxShadowRepeaterColorIndicator,
|
|
23
|
-
condition: ( { value
|
|
24
|
-
return hasAssignedColorVariable( shadowPropTypeUtil.extract(
|
|
49
|
+
condition: ( { value }: Args ) => {
|
|
50
|
+
return hasAssignedColorVariable( shadowPropTypeUtil.extract( value )?.color );
|
|
25
51
|
},
|
|
26
52
|
} );
|
|
53
|
+
};
|
|
27
54
|
|
|
55
|
+
const transitionsRepeaterInjections = () => {
|
|
28
56
|
injectIntoRepeaterItemLabel( {
|
|
29
|
-
id: '
|
|
30
|
-
component:
|
|
31
|
-
condition: ( { value
|
|
32
|
-
return
|
|
57
|
+
id: 'transition-size-variables-label',
|
|
58
|
+
component: TransitionsSizeVariableLabel,
|
|
59
|
+
condition: ( { value }: Args ) => {
|
|
60
|
+
return hasAssignedSizeVariable( selectionSizePropTypeUtil.extract( value )?.size );
|
|
33
61
|
},
|
|
34
62
|
} );
|
|
35
|
-
}
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
const hasAssignedSizeVariable = ( value: PropValue ): boolean => {
|
|
66
|
+
if ( sizeVariablePropTypeUtil.isValid( value ) ) {
|
|
67
|
+
return true;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
if ( customSizeVariablePropTypeUtil.isValid( value ) ) {
|
|
71
|
+
return true;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
return false;
|
|
75
|
+
};
|
|
36
76
|
|
|
37
|
-
const hasAssignedColorVariable = (
|
|
38
|
-
return !! colorVariablePropTypeUtil.isValid(
|
|
77
|
+
const hasAssignedColorVariable = ( value: PropValue ): boolean => {
|
|
78
|
+
return !! colorVariablePropTypeUtil.isValid( value );
|
|
39
79
|
};
|