@elementor/editor-controls 3.35.0-364 → 3.35.0-366
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 +48 -16
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +75 -43
- package/dist/index.mjs.map +1 -1
- package/package.json +15 -15
- package/src/controls/gap-control.tsx +60 -15
- package/src/controls/linked-dimensions-control.tsx +4 -4
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@elementor/editor-controls",
|
|
3
3
|
"description": "This package contains the controls model and utils for the Elementor editor",
|
|
4
|
-
"version": "3.35.0-
|
|
4
|
+
"version": "3.35.0-366",
|
|
5
5
|
"private": false,
|
|
6
6
|
"author": "Elementor Team",
|
|
7
7
|
"homepage": "https://elementor.com/",
|
|
@@ -40,22 +40,22 @@
|
|
|
40
40
|
"dev": "tsup --config=../../tsup.dev.ts"
|
|
41
41
|
},
|
|
42
42
|
"dependencies": {
|
|
43
|
-
"@elementor/editor-current-user": "3.35.0-
|
|
44
|
-
"@elementor/editor-elements": "3.35.0-
|
|
45
|
-
"@elementor/editor-props": "3.35.0-
|
|
46
|
-
"@elementor/editor-responsive": "3.35.0-
|
|
47
|
-
"@elementor/editor-ui": "3.35.0-
|
|
48
|
-
"@elementor/editor-v1-adapters": "3.35.0-
|
|
49
|
-
"@elementor/env": "3.35.0-
|
|
50
|
-
"@elementor/http-client": "3.35.0-
|
|
43
|
+
"@elementor/editor-current-user": "3.35.0-366",
|
|
44
|
+
"@elementor/editor-elements": "3.35.0-366",
|
|
45
|
+
"@elementor/editor-props": "3.35.0-366",
|
|
46
|
+
"@elementor/editor-responsive": "3.35.0-366",
|
|
47
|
+
"@elementor/editor-ui": "3.35.0-366",
|
|
48
|
+
"@elementor/editor-v1-adapters": "3.35.0-366",
|
|
49
|
+
"@elementor/env": "3.35.0-366",
|
|
50
|
+
"@elementor/http-client": "3.35.0-366",
|
|
51
51
|
"@elementor/icons": "^1.62.0",
|
|
52
|
-
"@elementor/locations": "3.35.0-
|
|
53
|
-
"@elementor/mixpanel": "3.35.0-
|
|
54
|
-
"@elementor/query": "3.35.0-
|
|
55
|
-
"@elementor/session": "3.35.0-
|
|
52
|
+
"@elementor/locations": "3.35.0-366",
|
|
53
|
+
"@elementor/mixpanel": "3.35.0-366",
|
|
54
|
+
"@elementor/query": "3.35.0-366",
|
|
55
|
+
"@elementor/session": "3.35.0-366",
|
|
56
56
|
"@elementor/ui": "1.36.17",
|
|
57
|
-
"@elementor/utils": "3.35.0-
|
|
58
|
-
"@elementor/wp-media": "3.35.0-
|
|
57
|
+
"@elementor/utils": "3.35.0-366",
|
|
58
|
+
"@elementor/wp-media": "3.35.0-366",
|
|
59
59
|
"@wordpress/i18n": "^5.13.0",
|
|
60
60
|
"@monaco-editor/react": "^4.7.0",
|
|
61
61
|
"dayjs": "^1.11.18",
|
|
@@ -1,41 +1,76 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import { type RefObject, useRef } from 'react';
|
|
2
|
+
import { type RefObject, useLayoutEffect, useRef, useState } from 'react';
|
|
3
3
|
import { layoutDirectionPropTypeUtil, type PropKey, sizePropTypeUtil } from '@elementor/editor-props';
|
|
4
|
+
import { useActiveBreakpoint } from '@elementor/editor-responsive';
|
|
4
5
|
import { DetachIcon, LinkIcon } from '@elementor/icons';
|
|
5
|
-
import { Grid, Stack,
|
|
6
|
+
import { Grid, Stack, Tooltip } from '@elementor/ui';
|
|
6
7
|
import { __ } from '@wordpress/i18n';
|
|
7
8
|
|
|
8
9
|
import { PropKeyProvider, PropProvider, useBoundProp } from '../bound-prop-context';
|
|
9
10
|
import { ControlFormLabel } from '../components/control-form-label';
|
|
10
11
|
import { ControlLabel } from '../components/control-label';
|
|
12
|
+
import { StyledToggleButton } from '../components/control-toggle-button-group';
|
|
11
13
|
import { SizeControl } from './size-control';
|
|
12
14
|
|
|
13
15
|
export const GapControl = ( { label }: { label: string } ) => {
|
|
16
|
+
const stackRef = useRef< HTMLDivElement >( null );
|
|
17
|
+
|
|
18
|
+
const { disabled: sizeDisabled } = useBoundProp( sizePropTypeUtil );
|
|
19
|
+
|
|
14
20
|
const {
|
|
15
21
|
value: directionValue,
|
|
16
22
|
setValue: setDirectionValue,
|
|
17
23
|
propType,
|
|
24
|
+
placeholder: directionPlaceholder,
|
|
18
25
|
disabled: directionDisabled,
|
|
19
26
|
} = useBoundProp( layoutDirectionPropTypeUtil );
|
|
20
27
|
|
|
21
|
-
const
|
|
28
|
+
const { value: masterValue, setValue: setMasterValue, placeholder: masterPlaceholder } = useBoundProp();
|
|
29
|
+
|
|
30
|
+
const inferIsLinked = () => {
|
|
31
|
+
if ( layoutDirectionPropTypeUtil.isValid( masterValue ) ) {
|
|
32
|
+
return false;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
if ( ! masterValue && layoutDirectionPropTypeUtil.isValid( masterPlaceholder ) ) {
|
|
36
|
+
return false;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
return true;
|
|
40
|
+
};
|
|
22
41
|
|
|
23
|
-
const
|
|
42
|
+
const [ isLinked, setIsLinked ] = useState( () => inferIsLinked() );
|
|
24
43
|
|
|
25
|
-
const
|
|
44
|
+
const activeBreakpoint = useActiveBreakpoint();
|
|
45
|
+
useLayoutEffect( () => {
|
|
46
|
+
setIsLinked( inferIsLinked() );
|
|
47
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
48
|
+
}, [ activeBreakpoint ] );
|
|
26
49
|
|
|
27
50
|
const onLinkToggle = () => {
|
|
28
|
-
|
|
29
|
-
|
|
51
|
+
setIsLinked( ( prev ) => ! prev );
|
|
52
|
+
|
|
53
|
+
if ( ! layoutDirectionPropTypeUtil.isValid( masterValue ) ) {
|
|
54
|
+
const currentValue = masterValue ? masterValue : null;
|
|
55
|
+
|
|
56
|
+
if ( ! currentValue ) {
|
|
57
|
+
setMasterValue( null );
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
setMasterValue(
|
|
62
|
+
layoutDirectionPropTypeUtil.create( {
|
|
63
|
+
row: currentValue,
|
|
64
|
+
column: currentValue,
|
|
65
|
+
} )
|
|
66
|
+
);
|
|
67
|
+
|
|
30
68
|
return;
|
|
31
69
|
}
|
|
32
70
|
|
|
33
|
-
const
|
|
71
|
+
const currentValue = directionValue?.column ?? directionValue?.row ?? null;
|
|
34
72
|
|
|
35
|
-
|
|
36
|
-
row: value,
|
|
37
|
-
column: value,
|
|
38
|
-
} );
|
|
73
|
+
setMasterValue( currentValue );
|
|
39
74
|
};
|
|
40
75
|
|
|
41
76
|
const tooltipLabel = label.toLowerCase();
|
|
@@ -48,12 +83,21 @@ export const GapControl = ( { label }: { label: string } ) => {
|
|
|
48
83
|
|
|
49
84
|
const disabled = sizeDisabled || directionDisabled;
|
|
50
85
|
|
|
86
|
+
const propProviderProps = {
|
|
87
|
+
propType,
|
|
88
|
+
value: directionValue,
|
|
89
|
+
setValue: setDirectionValue,
|
|
90
|
+
placeholder: directionPlaceholder,
|
|
91
|
+
};
|
|
92
|
+
|
|
93
|
+
const hasPlaceholders = ! masterValue && ( directionPlaceholder || masterPlaceholder );
|
|
94
|
+
|
|
51
95
|
return (
|
|
52
|
-
<PropProvider
|
|
96
|
+
<PropProvider { ...propProviderProps }>
|
|
53
97
|
<Stack direction="row" gap={ 2 } flexWrap="nowrap">
|
|
54
98
|
<ControlLabel>{ label }</ControlLabel>
|
|
55
99
|
<Tooltip title={ isLinked ? unlinkedLabel : linkedLabel } placement="top">
|
|
56
|
-
<
|
|
100
|
+
<StyledToggleButton
|
|
57
101
|
aria-label={ isLinked ? unlinkedLabel : linkedLabel }
|
|
58
102
|
size={ 'tiny' }
|
|
59
103
|
value={ 'check' }
|
|
@@ -61,9 +105,10 @@ export const GapControl = ( { label }: { label: string } ) => {
|
|
|
61
105
|
sx={ { marginLeft: 'auto' } }
|
|
62
106
|
onChange={ onLinkToggle }
|
|
63
107
|
disabled={ disabled }
|
|
108
|
+
isPlaceholder={ hasPlaceholders }
|
|
64
109
|
>
|
|
65
110
|
<LinkedIcon fontSize={ 'tiny' } />
|
|
66
|
-
</
|
|
111
|
+
</StyledToggleButton>
|
|
67
112
|
</Tooltip>
|
|
68
113
|
</Stack>
|
|
69
114
|
<Stack direction="row" gap={ 2 } flexWrap="nowrap" ref={ stackRef }>
|
|
@@ -23,7 +23,7 @@ type Props = {
|
|
|
23
23
|
export const LinkedDimensionsControl = ( { label, isSiteRtl = false, extendedOptions, min }: Props ) => {
|
|
24
24
|
const gridRowRefs: RefObject< HTMLDivElement >[] = [ useRef( null ), useRef( null ) ];
|
|
25
25
|
|
|
26
|
-
const { disabled: sizeDisabled
|
|
26
|
+
const { disabled: sizeDisabled } = useBoundProp( sizePropTypeUtil );
|
|
27
27
|
|
|
28
28
|
const {
|
|
29
29
|
value: dimensionsValue,
|
|
@@ -35,14 +35,12 @@ export const LinkedDimensionsControl = ( { label, isSiteRtl = false, extendedOpt
|
|
|
35
35
|
|
|
36
36
|
const { value: masterValue, placeholder: masterPlaceholder, setValue: setMasterValue } = useBoundProp();
|
|
37
37
|
|
|
38
|
-
const hasPlaceholders = !! ( sizePlaceholder || dimensionsPlaceholder );
|
|
39
|
-
|
|
40
38
|
const inferIsLinked = () => {
|
|
41
39
|
if ( dimensionsPropTypeUtil.isValid( masterValue ) ) {
|
|
42
40
|
return false;
|
|
43
41
|
}
|
|
44
42
|
|
|
45
|
-
if ( dimensionsPropTypeUtil.isValid( masterPlaceholder ) ) {
|
|
43
|
+
if ( ! masterValue && dimensionsPropTypeUtil.isValid( masterPlaceholder ) ) {
|
|
46
44
|
return false;
|
|
47
45
|
}
|
|
48
46
|
|
|
@@ -114,6 +112,8 @@ export const LinkedDimensionsControl = ( { label, isSiteRtl = false, extendedOpt
|
|
|
114
112
|
isDisabled: () => dimensionsDisabled,
|
|
115
113
|
};
|
|
116
114
|
|
|
115
|
+
const hasPlaceholders = ! masterValue && ( dimensionsPlaceholder || masterPlaceholder );
|
|
116
|
+
|
|
117
117
|
return (
|
|
118
118
|
<PropProvider { ...propProviderProps }>
|
|
119
119
|
<Stack direction="row" gap={ 2 } flexWrap="nowrap">
|