@elementor/editor-controls 4.1.0-776 → 4.1.0-778
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 +22 -7
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +26 -8
- package/dist/index.mjs.map +1 -1
- package/package.json +15 -15
- package/src/controls/gap-control.tsx +34 -6
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": "4.1.0-
|
|
4
|
+
"version": "4.1.0-778",
|
|
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": "4.1.0-
|
|
44
|
-
"@elementor/editor-elements": "4.1.0-
|
|
45
|
-
"@elementor/editor-props": "4.1.0-
|
|
46
|
-
"@elementor/editor-responsive": "4.1.0-
|
|
47
|
-
"@elementor/editor-ui": "4.1.0-
|
|
48
|
-
"@elementor/editor-v1-adapters": "4.1.0-
|
|
49
|
-
"@elementor/env": "4.1.0-
|
|
50
|
-
"@elementor/events": "4.1.0-
|
|
51
|
-
"@elementor/http-client": "4.1.0-
|
|
43
|
+
"@elementor/editor-current-user": "4.1.0-778",
|
|
44
|
+
"@elementor/editor-elements": "4.1.0-778",
|
|
45
|
+
"@elementor/editor-props": "4.1.0-778",
|
|
46
|
+
"@elementor/editor-responsive": "4.1.0-778",
|
|
47
|
+
"@elementor/editor-ui": "4.1.0-778",
|
|
48
|
+
"@elementor/editor-v1-adapters": "4.1.0-778",
|
|
49
|
+
"@elementor/env": "4.1.0-778",
|
|
50
|
+
"@elementor/events": "4.1.0-778",
|
|
51
|
+
"@elementor/http-client": "4.1.0-778",
|
|
52
52
|
"@elementor/icons": "^1.68.0",
|
|
53
|
-
"@elementor/locations": "4.1.0-
|
|
54
|
-
"@elementor/query": "4.1.0-
|
|
55
|
-
"@elementor/session": "4.1.0-
|
|
53
|
+
"@elementor/locations": "4.1.0-778",
|
|
54
|
+
"@elementor/query": "4.1.0-778",
|
|
55
|
+
"@elementor/session": "4.1.0-778",
|
|
56
56
|
"@elementor/ui": "1.37.5",
|
|
57
|
-
"@elementor/utils": "4.1.0-
|
|
58
|
-
"@elementor/wp-media": "4.1.0-
|
|
57
|
+
"@elementor/utils": "4.1.0-778",
|
|
58
|
+
"@elementor/wp-media": "4.1.0-778",
|
|
59
59
|
"@monaco-editor/react": "^4.7.0",
|
|
60
60
|
"@tiptap/extension-bold": "^3.11.1",
|
|
61
61
|
"@tiptap/extension-document": "^3.11.1",
|
|
@@ -1,6 +1,13 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { type RefObject, useLayoutEffect, useRef, useState } from 'react';
|
|
3
|
-
import {
|
|
3
|
+
import {
|
|
4
|
+
layoutDirectionPropTypeUtil,
|
|
5
|
+
type LayoutDirectionPropValue,
|
|
6
|
+
type PropKey,
|
|
7
|
+
type PropValue,
|
|
8
|
+
sizePropTypeUtil,
|
|
9
|
+
type SizePropValue,
|
|
10
|
+
} from '@elementor/editor-props';
|
|
4
11
|
import { useActiveBreakpoint } from '@elementor/editor-responsive';
|
|
5
12
|
import { DetachIcon, LinkIcon } from '@elementor/icons';
|
|
6
13
|
import { Grid, Stack, Tooltip } from '@elementor/ui';
|
|
@@ -10,7 +17,7 @@ import { PropKeyProvider, PropProvider, useBoundProp } from '../bound-prop-conte
|
|
|
10
17
|
import { ControlFormLabel } from '../components/control-form-label';
|
|
11
18
|
import { ControlLabel } from '../components/control-label';
|
|
12
19
|
import { StyledToggleButton } from '../components/control-toggle-button-group';
|
|
13
|
-
import {
|
|
20
|
+
import { UnstableSizeControl } from './size-control/unstable-size-control';
|
|
14
21
|
|
|
15
22
|
export const GapControl = ( { label }: { label: string } ) => {
|
|
16
23
|
const stackRef = useRef< HTMLDivElement >( null );
|
|
@@ -41,11 +48,13 @@ export const GapControl = ( { label }: { label: string } ) => {
|
|
|
41
48
|
|
|
42
49
|
const [ isLinked, setIsLinked ] = useState( () => inferIsLinked() );
|
|
43
50
|
|
|
51
|
+
const isCurrentlyDirection = layoutDirectionPropTypeUtil.isValid( masterValue ?? masterPlaceholder );
|
|
52
|
+
|
|
44
53
|
const activeBreakpoint = useActiveBreakpoint();
|
|
45
54
|
useLayoutEffect( () => {
|
|
46
55
|
setIsLinked( inferIsLinked() );
|
|
47
56
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
48
|
-
}, [ activeBreakpoint ] );
|
|
57
|
+
}, [ activeBreakpoint, isCurrentlyDirection ] );
|
|
49
58
|
|
|
50
59
|
const onLinkToggle = () => {
|
|
51
60
|
setIsLinked( ( prev ) => ! prev );
|
|
@@ -86,12 +95,27 @@ export const GapControl = ( { label }: { label: string } ) => {
|
|
|
86
95
|
const propProviderProps = {
|
|
87
96
|
propType,
|
|
88
97
|
value: directionValue,
|
|
89
|
-
setValue:
|
|
98
|
+
setValue: ( directions: PropValue ) => {
|
|
99
|
+
const entries = Object.entries( directions as LayoutDirectionPropValue );
|
|
100
|
+
const filtered = entries.filter( ( [ , value ] ) => Boolean( value ) );
|
|
101
|
+
|
|
102
|
+
setDirectionValue( filtered.length === 0 ? null : Object.fromEntries( filtered ) );
|
|
103
|
+
},
|
|
90
104
|
placeholder: directionPlaceholder,
|
|
91
105
|
};
|
|
92
106
|
|
|
93
107
|
const hasPlaceholders = ! masterValue && ( directionPlaceholder || masterPlaceholder );
|
|
94
108
|
|
|
109
|
+
const getEffectivePlaceholder = ( bind: string ) => {
|
|
110
|
+
if ( isLinked ) {
|
|
111
|
+
const linkedPlaceholder = directionPlaceholder?.column ?? directionPlaceholder?.row;
|
|
112
|
+
|
|
113
|
+
return sizePropTypeUtil.extract( linkedPlaceholder );
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
return sizePropTypeUtil.extract( directionPlaceholder?.[ bind as keyof LayoutDirectionPropValue[ 'value' ] ] );
|
|
117
|
+
};
|
|
118
|
+
|
|
95
119
|
return (
|
|
96
120
|
<PropProvider { ...propProviderProps }>
|
|
97
121
|
<Stack direction="row" gap={ 2 } flexWrap="nowrap">
|
|
@@ -122,6 +146,7 @@ export const GapControl = ( { label }: { label: string } ) => {
|
|
|
122
146
|
ariaLabel={ __( 'Column gap', 'elementor' ) }
|
|
123
147
|
isLinked={ isLinked }
|
|
124
148
|
anchorRef={ stackRef }
|
|
149
|
+
placeholder={ getEffectivePlaceholder( 'column' ) ?? undefined }
|
|
125
150
|
/>
|
|
126
151
|
</Grid>
|
|
127
152
|
</Grid>
|
|
@@ -135,6 +160,7 @@ export const GapControl = ( { label }: { label: string } ) => {
|
|
|
135
160
|
ariaLabel={ __( 'Row gap', 'elementor' ) }
|
|
136
161
|
isLinked={ isLinked }
|
|
137
162
|
anchorRef={ stackRef }
|
|
163
|
+
placeholder={ getEffectivePlaceholder( 'row' ) ?? undefined }
|
|
138
164
|
/>
|
|
139
165
|
</Grid>
|
|
140
166
|
</Grid>
|
|
@@ -148,19 +174,21 @@ const Control = ( {
|
|
|
148
174
|
ariaLabel,
|
|
149
175
|
isLinked,
|
|
150
176
|
anchorRef,
|
|
177
|
+
placeholder,
|
|
151
178
|
}: {
|
|
152
179
|
bind: PropKey;
|
|
153
180
|
ariaLabel?: string;
|
|
154
181
|
isLinked: boolean;
|
|
182
|
+
placeholder?: SizePropValue[ 'value' ];
|
|
155
183
|
anchorRef: RefObject< HTMLDivElement >;
|
|
156
184
|
} ) => {
|
|
157
185
|
if ( isLinked ) {
|
|
158
|
-
return <
|
|
186
|
+
return <UnstableSizeControl anchorRef={ anchorRef } placeholder={ placeholder } ariaLabel={ ariaLabel } />;
|
|
159
187
|
}
|
|
160
188
|
|
|
161
189
|
return (
|
|
162
190
|
<PropKeyProvider bind={ bind }>
|
|
163
|
-
<
|
|
191
|
+
<UnstableSizeControl anchorRef={ anchorRef } placeholder={ placeholder } ariaLabel={ ariaLabel } />
|
|
164
192
|
</PropKeyProvider>
|
|
165
193
|
);
|
|
166
194
|
};
|