@elementor/editor-editing-panel 1.44.0 → 1.46.0
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/CHANGELOG.md +62 -0
- package/dist/index.d.mts +11 -4
- package/dist/index.d.ts +11 -4
- package/dist/index.js +867 -765
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +740 -636
- package/dist/index.mjs.map +1 -1
- package/package.json +14 -13
- package/src/components/css-classes/css-class-menu.tsx +6 -8
- package/src/components/css-classes/css-class-selector.tsx +17 -11
- package/src/components/settings-tab.tsx +25 -2
- package/src/components/style-indicator.tsx +19 -15
- package/src/components/style-sections/border-section/border-field.tsx +4 -6
- package/src/components/style-sections/border-section/border-radius-field.tsx +12 -9
- package/src/components/style-sections/effects-section/effects-section.tsx +6 -0
- package/src/components/style-sections/layout-section/align-content-field.tsx +10 -14
- package/src/components/style-sections/layout-section/align-items-field.tsx +13 -17
- package/src/components/style-sections/layout-section/align-self-child-field.tsx +13 -17
- package/src/components/style-sections/layout-section/flex-direction-field.tsx +13 -17
- package/src/components/style-sections/layout-section/flex-order-field.tsx +31 -36
- package/src/components/style-sections/layout-section/flex-size-field.tsx +67 -69
- package/src/components/style-sections/layout-section/justify-content-field.tsx +10 -14
- package/src/components/style-sections/layout-section/layout-section.tsx +2 -2
- package/src/components/style-sections/layout-section/opacity-control-field.tsx +25 -0
- package/src/components/style-sections/layout-section/utils/rotated-icon.tsx +1 -1
- package/src/components/style-sections/layout-section/wrap-field.tsx +13 -17
- package/src/components/style-sections/position-section/dimensions-field.tsx +39 -21
- package/src/components/style-sections/position-section/offset-field.tsx +5 -2
- package/src/components/style-sections/position-section/position-section.tsx +6 -6
- package/src/components/style-sections/size-section/object-position-field.tsx +2 -24
- package/src/components/style-sections/size-section/size-section.tsx +52 -37
- package/src/components/style-sections/spacing-section/spacing-section.tsx +1 -1
- package/src/components/style-sections/typography-section/column-gap-field.tsx +5 -2
- package/src/components/style-sections/typography-section/font-size-field.tsx +5 -2
- package/src/components/style-sections/typography-section/letter-spacing-field.tsx +5 -2
- package/src/components/style-sections/typography-section/line-height-field.tsx +5 -2
- package/src/components/style-sections/typography-section/text-alignment-field.tsx +12 -9
- package/src/components/style-sections/typography-section/text-stroke-field.tsx +4 -6
- package/src/components/style-sections/typography-section/typography-section.tsx +4 -2
- package/src/components/style-sections/typography-section/word-spacing-field.tsx +5 -2
- package/src/controls-registry/controls-registry.tsx +30 -10
- package/src/controls-registry/styles-field.tsx +1 -3
- package/src/dynamics/components/background-control-dynamic-tag.tsx +48 -0
- package/src/dynamics/components/dynamic-selection-control.tsx +10 -18
- package/src/dynamics/components/dynamic-selection.tsx +58 -77
- package/src/dynamics/hooks/use-prop-dynamic-action.tsx +1 -1
- package/src/dynamics/init.ts +21 -0
- package/src/hooks/use-styles-field.ts +9 -3
- package/src/hooks/use-styles-fields.ts +4 -4
- package/src/index.ts +1 -0
- package/src/popover-action.tsx +3 -5
- package/src/provider-colors-registry.ts +20 -0
- package/src/styles-inheritance/components/infotip/label-chip.tsx +4 -5
- package/src/styles-inheritance/components/styles-inheritance-indicator.tsx +32 -40
- package/src/styles-inheritance/components/styles-inheritance-infotip.tsx +1 -5
- package/src/styles-inheritance/components/styles-inheritance-section-indicators.tsx +29 -44
- package/src/styles-inheritance/components/ui-providers.tsx +18 -0
- package/src/styles-inheritance/hooks/use-normalized-inheritance-chain-items.tsx +1 -17
- package/src/styles-inheritance/types.ts +0 -2
- package/src/styles-inheritance/utils.ts +17 -1
- package/src/utils/get-styles-provider-color.ts +28 -0
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import { useMemo, useState } from 'react';
|
|
2
|
+
import { type MutableRefObject, useMemo, useRef, useState } from 'react';
|
|
3
3
|
import {
|
|
4
4
|
ControlToggleButtonGroup,
|
|
5
5
|
NumberControl,
|
|
@@ -8,13 +8,12 @@ import {
|
|
|
8
8
|
} from '@elementor/editor-controls';
|
|
9
9
|
import { numberPropTypeUtil, type NumberPropValue, type SizePropValue } from '@elementor/editor-props';
|
|
10
10
|
import { ExpandIcon, PencilIcon, ShrinkIcon } from '@elementor/icons';
|
|
11
|
-
import {
|
|
11
|
+
import { Grid } from '@elementor/ui';
|
|
12
12
|
import { __ } from '@wordpress/i18n';
|
|
13
13
|
|
|
14
|
-
import { useStyle } from '../../../contexts/style-context';
|
|
15
14
|
import { StylesField } from '../../../controls-registry/styles-field';
|
|
16
|
-
import { useDirection } from '../../../hooks/use-direction';
|
|
17
15
|
import { useStylesFields } from '../../../hooks/use-styles-fields';
|
|
16
|
+
import { UiProviders } from '../../../styles-inheritance/components/ui-providers';
|
|
18
17
|
import { ControlLabel } from '../../control-label';
|
|
19
18
|
import { SectionContent } from '../../section-content';
|
|
20
19
|
|
|
@@ -44,18 +43,15 @@ const items: ToggleButtonGroupItem< GroupItem >[] = [
|
|
|
44
43
|
];
|
|
45
44
|
|
|
46
45
|
export const FlexSizeField = () => {
|
|
47
|
-
const {
|
|
48
|
-
const { canEdit } = useStyle();
|
|
49
|
-
|
|
50
|
-
const [ fields, setFields ] = useStylesFields< {
|
|
46
|
+
const { values, setValues, canEdit } = useStylesFields< {
|
|
51
47
|
'flex-grow': NumberPropValue | null;
|
|
52
48
|
'flex-shrink': NumberPropValue | null;
|
|
53
49
|
'flex-basis': SizePropValue | null;
|
|
54
50
|
} >( [ 'flex-grow', 'flex-shrink', 'flex-basis' ] );
|
|
55
51
|
|
|
56
|
-
const grow =
|
|
57
|
-
const shrink =
|
|
58
|
-
const basis =
|
|
52
|
+
const grow = values?.[ 'flex-grow' ]?.value || null;
|
|
53
|
+
const shrink = values?.[ 'flex-shrink' ]?.value || null;
|
|
54
|
+
const basis = values?.[ 'flex-basis' ]?.value || null;
|
|
59
55
|
|
|
60
56
|
const currentGroup = useMemo( () => getActiveGroup( { grow, shrink, basis } ), [ grow, shrink, basis ] ),
|
|
61
57
|
[ activeGroup, setActiveGroup ] = useState( currentGroup );
|
|
@@ -64,7 +60,7 @@ export const FlexSizeField = () => {
|
|
|
64
60
|
setActiveGroup( group );
|
|
65
61
|
|
|
66
62
|
if ( ! group || group === 'custom' ) {
|
|
67
|
-
|
|
63
|
+
setValues( {
|
|
68
64
|
'flex-basis': null,
|
|
69
65
|
'flex-grow': null,
|
|
70
66
|
'flex-shrink': null,
|
|
@@ -74,7 +70,7 @@ export const FlexSizeField = () => {
|
|
|
74
70
|
}
|
|
75
71
|
|
|
76
72
|
if ( group === 'flex-grow' ) {
|
|
77
|
-
|
|
73
|
+
setValues( {
|
|
78
74
|
'flex-basis': null,
|
|
79
75
|
'flex-grow': numberPropTypeUtil.create( DEFAULT ),
|
|
80
76
|
'flex-shrink': null,
|
|
@@ -83,7 +79,7 @@ export const FlexSizeField = () => {
|
|
|
83
79
|
return;
|
|
84
80
|
}
|
|
85
81
|
|
|
86
|
-
|
|
82
|
+
setValues( {
|
|
87
83
|
'flex-basis': null,
|
|
88
84
|
'flex-grow': null,
|
|
89
85
|
'flex-shrink': numberPropTypeUtil.create( DEFAULT ),
|
|
@@ -91,67 +87,69 @@ export const FlexSizeField = () => {
|
|
|
91
87
|
};
|
|
92
88
|
|
|
93
89
|
return (
|
|
94
|
-
<
|
|
95
|
-
<
|
|
96
|
-
<
|
|
97
|
-
<
|
|
98
|
-
<
|
|
99
|
-
<
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
<
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
</ThemeProvider>
|
|
117
|
-
</DirectionProvider>
|
|
90
|
+
<UiProviders>
|
|
91
|
+
<SectionContent>
|
|
92
|
+
<Grid container gap={ 2 } alignItems="center" flexWrap="nowrap">
|
|
93
|
+
<StylesField bind={ activeGroup ?? '' }>
|
|
94
|
+
<Grid item xs={ 6 }>
|
|
95
|
+
<ControlLabel>{ __( 'Size', 'elementor' ) }</ControlLabel>
|
|
96
|
+
</Grid>
|
|
97
|
+
|
|
98
|
+
<Grid item xs={ 6 } sx={ { display: 'flex', justifyContent: 'end' } }>
|
|
99
|
+
<ControlToggleButtonGroup
|
|
100
|
+
value={ activeGroup }
|
|
101
|
+
onChange={ onChangeGroup }
|
|
102
|
+
disabled={ ! canEdit }
|
|
103
|
+
items={ items }
|
|
104
|
+
exclusive={ true }
|
|
105
|
+
/>
|
|
106
|
+
</Grid>
|
|
107
|
+
</StylesField>
|
|
108
|
+
</Grid>
|
|
109
|
+
{ 'custom' === activeGroup && <FlexCustomField /> }
|
|
110
|
+
</SectionContent>
|
|
111
|
+
</UiProviders>
|
|
118
112
|
);
|
|
119
113
|
};
|
|
120
114
|
|
|
121
|
-
const FlexCustomField = () =>
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
<Grid container gap={ 2 } alignItems="center" flexWrap="nowrap">
|
|
135
|
-
<Grid item xs={ 6 }>
|
|
136
|
-
<ControlLabel>{ __( 'Shrink', 'elementor' ) }</ControlLabel>
|
|
137
|
-
</Grid>
|
|
138
|
-
<Grid item xs={ 6 } sx={ { display: 'flex', justifyContent: 'end' } }>
|
|
139
|
-
<NumberControl min={ 0 } shouldForceInt={ true } />
|
|
115
|
+
const FlexCustomField = () => {
|
|
116
|
+
const flexBasisRowRef: MutableRefObject< HTMLElement | undefined > = useRef();
|
|
117
|
+
|
|
118
|
+
return (
|
|
119
|
+
<>
|
|
120
|
+
<StylesField bind={ 'flex-grow' }>
|
|
121
|
+
<Grid container gap={ 2 } alignItems="center" flexWrap="nowrap">
|
|
122
|
+
<Grid item xs={ 6 }>
|
|
123
|
+
<ControlLabel>{ __( 'Grow', 'elementor' ) }</ControlLabel>
|
|
124
|
+
</Grid>
|
|
125
|
+
<Grid item xs={ 6 } sx={ { display: 'flex', justifyContent: 'end' } }>
|
|
126
|
+
<NumberControl min={ 0 } shouldForceInt={ true } />
|
|
127
|
+
</Grid>
|
|
140
128
|
</Grid>
|
|
141
|
-
</
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
129
|
+
</StylesField>
|
|
130
|
+
<StylesField bind={ 'flex-shrink' }>
|
|
131
|
+
<Grid container gap={ 2 } alignItems="center" flexWrap="nowrap">
|
|
132
|
+
<Grid item xs={ 6 }>
|
|
133
|
+
<ControlLabel>{ __( 'Shrink', 'elementor' ) }</ControlLabel>
|
|
134
|
+
</Grid>
|
|
135
|
+
<Grid item xs={ 6 } sx={ { display: 'flex', justifyContent: 'end' } }>
|
|
136
|
+
<NumberControl min={ 0 } shouldForceInt={ true } />
|
|
137
|
+
</Grid>
|
|
147
138
|
</Grid>
|
|
148
|
-
|
|
149
|
-
|
|
139
|
+
</StylesField>
|
|
140
|
+
<StylesField bind={ 'flex-basis' }>
|
|
141
|
+
<Grid container gap={ 2 } alignItems="center" flexWrap="nowrap" ref={ flexBasisRowRef }>
|
|
142
|
+
<Grid item xs={ 6 }>
|
|
143
|
+
<ControlLabel>{ __( 'Basis', 'elementor' ) }</ControlLabel>
|
|
144
|
+
</Grid>
|
|
145
|
+
<Grid item xs={ 6 } sx={ { display: 'flex', justifyContent: 'end' } }>
|
|
146
|
+
<SizeControl extendedOptions={ [ 'auto' ] } anchorRef={ flexBasisRowRef } />
|
|
147
|
+
</Grid>
|
|
150
148
|
</Grid>
|
|
151
|
-
</
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
149
|
+
</StylesField>
|
|
150
|
+
</>
|
|
151
|
+
);
|
|
152
|
+
};
|
|
155
153
|
|
|
156
154
|
const getActiveGroup = ( {
|
|
157
155
|
grow,
|
|
@@ -8,11 +8,11 @@ import {
|
|
|
8
8
|
JustifySpaceBetweenVerticalIcon as BetweenIcon,
|
|
9
9
|
JustifyTopIcon,
|
|
10
10
|
} from '@elementor/icons';
|
|
11
|
-
import {
|
|
11
|
+
import { Stack, withDirection } from '@elementor/ui';
|
|
12
12
|
import { __ } from '@wordpress/i18n';
|
|
13
13
|
|
|
14
14
|
import { StylesField } from '../../../controls-registry/styles-field';
|
|
15
|
-
import {
|
|
15
|
+
import { UiProviders } from '../../../styles-inheritance/components/ui-providers';
|
|
16
16
|
import { ControlLabel } from '../../control-label';
|
|
17
17
|
import { RotatedIcon } from './utils/rotated-icon';
|
|
18
18
|
|
|
@@ -66,18 +66,14 @@ const options: ToggleButtonGroupItem< JustifyContent >[] = [
|
|
|
66
66
|
];
|
|
67
67
|
|
|
68
68
|
export const JustifyContentField = () => {
|
|
69
|
-
const { isSiteRtl } = useDirection();
|
|
70
|
-
|
|
71
69
|
return (
|
|
72
|
-
<
|
|
73
|
-
<
|
|
74
|
-
<
|
|
75
|
-
<
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
</ThemeProvider>
|
|
81
|
-
</DirectionProvider>
|
|
70
|
+
<UiProviders>
|
|
71
|
+
<StylesField bind="justify-content">
|
|
72
|
+
<Stack gap={ 0.75 }>
|
|
73
|
+
<ControlLabel>{ __( 'Justify content', 'elementor' ) }</ControlLabel>
|
|
74
|
+
<ToggleControl options={ options } fullWidth={ true } />
|
|
75
|
+
</Stack>
|
|
76
|
+
</StylesField>
|
|
77
|
+
</UiProviders>
|
|
82
78
|
);
|
|
83
79
|
};
|
|
@@ -21,7 +21,7 @@ import { JustifyContentField } from './justify-content-field';
|
|
|
21
21
|
import { WrapField } from './wrap-field';
|
|
22
22
|
|
|
23
23
|
export const LayoutSection = () => {
|
|
24
|
-
const
|
|
24
|
+
const { value: display } = useStylesField< StringPropValue >( 'display' );
|
|
25
25
|
const displayPlaceholder = useDisplayPlaceholderValue();
|
|
26
26
|
const isDisplayFlex = shouldDisplayFlexFields( display, displayPlaceholder as StringPropValue );
|
|
27
27
|
const { element } = useElement();
|
|
@@ -39,7 +39,7 @@ export const LayoutSection = () => {
|
|
|
39
39
|
};
|
|
40
40
|
|
|
41
41
|
const FlexFields = () => {
|
|
42
|
-
const
|
|
42
|
+
const { value: flexWrap } = useStylesField< StringPropValue >( 'flex-wrap' );
|
|
43
43
|
|
|
44
44
|
return (
|
|
45
45
|
<>
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { type MutableRefObject, useRef } from 'react';
|
|
3
|
+
import { SizeControl } from '@elementor/editor-controls';
|
|
4
|
+
import { Grid } from '@elementor/ui';
|
|
5
|
+
import { __ } from '@wordpress/i18n';
|
|
6
|
+
|
|
7
|
+
import { StylesField } from '../../../controls-registry/styles-field';
|
|
8
|
+
import { ControlLabel } from '../../control-label';
|
|
9
|
+
|
|
10
|
+
export const OpacityControlField = () => {
|
|
11
|
+
const rowRef: MutableRefObject< HTMLElement | undefined > = useRef();
|
|
12
|
+
|
|
13
|
+
return (
|
|
14
|
+
<StylesField bind={ 'opacity' }>
|
|
15
|
+
<Grid container gap={ 2 } alignItems="center" flexWrap="nowrap" ref={ rowRef }>
|
|
16
|
+
<Grid item xs={ 6 }>
|
|
17
|
+
<ControlLabel>{ __( 'Opacity', 'elementor' ) }</ControlLabel>
|
|
18
|
+
</Grid>
|
|
19
|
+
<Grid item xs={ 6 }>
|
|
20
|
+
<SizeControl units={ [ '%' ] } anchorRef={ rowRef } defaultUnit="%" />
|
|
21
|
+
</Grid>
|
|
22
|
+
</Grid>
|
|
23
|
+
</StylesField>
|
|
24
|
+
);
|
|
25
|
+
};
|
|
@@ -48,7 +48,7 @@ const useGetTargetAngle = (
|
|
|
48
48
|
disableRotationForReversed: boolean,
|
|
49
49
|
existingRef?: React.MutableRefObject< number >
|
|
50
50
|
) => {
|
|
51
|
-
const
|
|
51
|
+
const { value: direction } = useStylesField< StringPropValue >( 'flex-direction' );
|
|
52
52
|
const isRtl = 'rtl' === useTheme().direction;
|
|
53
53
|
const rotationMultiplier = isRtl ? -1 : 1;
|
|
54
54
|
const angleMap = isClockwise ? CLOCKWISE_ANGLES : COUNTER_CLOCKWISE_ANGLES;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { type ToggleButtonGroupItem, ToggleControl } from '@elementor/editor-controls';
|
|
3
3
|
import { ArrowBackIcon, ArrowForwardIcon, ArrowRightIcon } from '@elementor/icons';
|
|
4
|
-
import {
|
|
4
|
+
import { Grid } from '@elementor/ui';
|
|
5
5
|
import { __ } from '@wordpress/i18n';
|
|
6
6
|
|
|
7
7
|
import { StylesField } from '../../../controls-registry/styles-field';
|
|
8
|
-
import {
|
|
8
|
+
import { UiProviders } from '../../../styles-inheritance/components/ui-providers';
|
|
9
9
|
import { ControlLabel } from '../../control-label';
|
|
10
10
|
|
|
11
11
|
type FlexWrap = 'nowrap' | 'wrap' | 'wrap-reverse';
|
|
@@ -32,22 +32,18 @@ const options: ToggleButtonGroupItem< FlexWrap >[] = [
|
|
|
32
32
|
];
|
|
33
33
|
|
|
34
34
|
export const WrapField = () => {
|
|
35
|
-
const { isSiteRtl } = useDirection();
|
|
36
|
-
|
|
37
35
|
return (
|
|
38
|
-
<
|
|
39
|
-
<
|
|
40
|
-
<
|
|
41
|
-
<Grid
|
|
42
|
-
<
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
<
|
|
46
|
-
<ToggleControl options={ options } />
|
|
47
|
-
</Grid>
|
|
36
|
+
<UiProviders>
|
|
37
|
+
<StylesField bind={ 'flex-wrap' }>
|
|
38
|
+
<Grid container gap={ 2 } alignItems="center" flexWrap="nowrap">
|
|
39
|
+
<Grid item xs={ 6 }>
|
|
40
|
+
<ControlLabel>{ __( 'Wrap', 'elementor' ) }</ControlLabel>
|
|
41
|
+
</Grid>
|
|
42
|
+
<Grid item xs={ 6 } sx={ { display: 'flex', justifyContent: 'flex-end' } }>
|
|
43
|
+
<ToggleControl options={ options } />
|
|
48
44
|
</Grid>
|
|
49
|
-
</
|
|
50
|
-
</
|
|
51
|
-
</
|
|
45
|
+
</Grid>
|
|
46
|
+
</StylesField>
|
|
47
|
+
</UiProviders>
|
|
52
48
|
);
|
|
53
49
|
};
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
+
import { type MutableRefObject, useRef } from 'react';
|
|
2
3
|
import { SizeControl } from '@elementor/editor-controls';
|
|
3
4
|
import { SideBottomIcon, SideLeftIcon, SideRightIcon, SideTopIcon } from '@elementor/icons';
|
|
4
5
|
import { Grid, Stack, withDirection } from '@elementor/ui';
|
|
@@ -6,6 +7,7 @@ import { __ } from '@wordpress/i18n';
|
|
|
6
7
|
|
|
7
8
|
import { StylesField } from '../../../controls-registry/styles-field';
|
|
8
9
|
import { useDirection } from '../../../hooks/use-direction';
|
|
10
|
+
import { UiProviders } from '../../../styles-inheritance/components/ui-providers';
|
|
9
11
|
import { ControlLabel } from '../../control-label';
|
|
10
12
|
import { RotatedIcon } from '../layout-section/utils/rotated-icon';
|
|
11
13
|
|
|
@@ -29,31 +31,47 @@ const getInlineEndLabel = ( isSiteRtl: boolean ) =>
|
|
|
29
31
|
|
|
30
32
|
export const DimensionsField = () => {
|
|
31
33
|
const { isSiteRtl } = useDirection();
|
|
34
|
+
const rowRefs: MutableRefObject< HTMLElement | undefined >[] = [ useRef(), useRef() ];
|
|
32
35
|
|
|
33
36
|
return (
|
|
34
|
-
|
|
35
|
-
<Stack direction="row" gap={ 2 } flexWrap="nowrap">
|
|
36
|
-
<DimensionField side="inset-block-start" label={ __( 'Top', 'elementor' ) } />
|
|
37
|
-
<DimensionField
|
|
37
|
+
<UiProviders>
|
|
38
|
+
<Stack direction="row" gap={ 2 } flexWrap="nowrap" ref={ rowRefs[ 0 ] }>
|
|
39
|
+
<DimensionField side="inset-block-start" label={ __( 'Top', 'elementor' ) } rowRef={ rowRefs[ 0 ] } />
|
|
40
|
+
<DimensionField
|
|
41
|
+
side="inset-inline-end"
|
|
42
|
+
label={ getInlineEndLabel( isSiteRtl ) }
|
|
43
|
+
rowRef={ rowRefs[ 0 ] }
|
|
44
|
+
/>
|
|
38
45
|
</Stack>
|
|
39
|
-
<Stack direction="row" gap={ 2 } flexWrap="nowrap">
|
|
40
|
-
<DimensionField side="inset-block-end" label={ __( 'Bottom', 'elementor' ) } />
|
|
41
|
-
<DimensionField
|
|
46
|
+
<Stack direction="row" gap={ 2 } flexWrap="nowrap" ref={ rowRefs[ 1 ] }>
|
|
47
|
+
<DimensionField side="inset-block-end" label={ __( 'Bottom', 'elementor' ) } rowRef={ rowRefs[ 1 ] } />
|
|
48
|
+
<DimensionField
|
|
49
|
+
side="inset-inline-start"
|
|
50
|
+
label={ getInlineStartLabel( isSiteRtl ) }
|
|
51
|
+
rowRef={ rowRefs[ 1 ] }
|
|
52
|
+
/>
|
|
42
53
|
</Stack>
|
|
43
|
-
|
|
54
|
+
</UiProviders>
|
|
44
55
|
);
|
|
45
56
|
};
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
57
|
+
|
|
58
|
+
const DimensionField = ( {
|
|
59
|
+
side,
|
|
60
|
+
label,
|
|
61
|
+
rowRef,
|
|
62
|
+
}: {
|
|
63
|
+
side: Side;
|
|
64
|
+
label: string;
|
|
65
|
+
rowRef: MutableRefObject< HTMLElement | undefined >;
|
|
66
|
+
} ) => (
|
|
67
|
+
<StylesField bind={ side }>
|
|
68
|
+
<Grid container gap={ 0.75 } alignItems="center">
|
|
69
|
+
<Grid item xs={ 12 }>
|
|
70
|
+
<ControlLabel>{ label }</ControlLabel>
|
|
56
71
|
</Grid>
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
72
|
+
<Grid item xs={ 12 }>
|
|
73
|
+
<SizeControl startIcon={ sideIcons[ side ] } extendedOptions={ [ 'auto' ] } anchorRef={ rowRef } />
|
|
74
|
+
</Grid>
|
|
75
|
+
</Grid>
|
|
76
|
+
</StylesField>
|
|
77
|
+
);
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
+
import { type MutableRefObject, useRef } from 'react';
|
|
2
3
|
import { SizeControl } from '@elementor/editor-controls';
|
|
3
4
|
import { Grid } from '@elementor/ui';
|
|
4
5
|
import { __ } from '@wordpress/i18n';
|
|
@@ -7,14 +8,16 @@ import { StylesField } from '../../../controls-registry/styles-field';
|
|
|
7
8
|
import { ControlLabel } from '../../control-label';
|
|
8
9
|
|
|
9
10
|
export const OffsetField = () => {
|
|
11
|
+
const rowRef: MutableRefObject< HTMLElement | undefined > = useRef();
|
|
12
|
+
|
|
10
13
|
return (
|
|
11
14
|
<StylesField bind="scroll-margin-top">
|
|
12
|
-
<Grid container gap={ 2 } alignItems="center" flexWrap="nowrap">
|
|
15
|
+
<Grid container gap={ 2 } alignItems="center" flexWrap="nowrap" ref={ rowRef }>
|
|
13
16
|
<Grid item xs={ 6 }>
|
|
14
17
|
<ControlLabel>{ __( 'Anchor offset', 'elementor' ) }</ControlLabel>
|
|
15
18
|
</Grid>
|
|
16
19
|
<Grid item xs={ 6 }>
|
|
17
|
-
<SizeControl units={ [ 'px', 'em', 'rem', 'vw', 'vh' ] } />
|
|
20
|
+
<SizeControl units={ [ 'px', 'em', 'rem', 'vw', 'vh' ] } anchorRef={ rowRef } />
|
|
18
21
|
</Grid>
|
|
19
22
|
</Grid>
|
|
20
23
|
</StylesField>
|
|
@@ -29,8 +29,8 @@ type DimensionsValues = {
|
|
|
29
29
|
};
|
|
30
30
|
|
|
31
31
|
export const PositionSection = () => {
|
|
32
|
-
const
|
|
33
|
-
const
|
|
32
|
+
const { value: positionValue } = useStylesField< StringPropValue >( 'position' );
|
|
33
|
+
const { values: dimensions, setValues: setDimensions } = useStylesFields< DimensionsValues >( [
|
|
34
34
|
'inset-block-start',
|
|
35
35
|
'inset-block-end',
|
|
36
36
|
'inset-inline-start',
|
|
@@ -42,9 +42,9 @@ export const PositionSection = () => {
|
|
|
42
42
|
|
|
43
43
|
const onPositionChange = ( newPosition: string | null, previousPosition: string | null | undefined ) => {
|
|
44
44
|
if ( newPosition === 'static' ) {
|
|
45
|
-
if (
|
|
46
|
-
updateDimensionsHistory(
|
|
47
|
-
|
|
45
|
+
if ( dimensions ) {
|
|
46
|
+
updateDimensionsHistory( dimensions );
|
|
47
|
+
setDimensions( {
|
|
48
48
|
'inset-block-start': undefined,
|
|
49
49
|
'inset-block-end': undefined,
|
|
50
50
|
'inset-inline-start': undefined,
|
|
@@ -53,7 +53,7 @@ export const PositionSection = () => {
|
|
|
53
53
|
}
|
|
54
54
|
} else if ( previousPosition === 'static' ) {
|
|
55
55
|
if ( dimensionsValuesFromHistory ) {
|
|
56
|
-
|
|
56
|
+
setDimensions( dimensionsValuesFromHistory );
|
|
57
57
|
clearDimensionsHistory();
|
|
58
58
|
}
|
|
59
59
|
}
|
|
@@ -1,34 +1,12 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import {
|
|
3
|
-
import { Grid } from '@elementor/ui';
|
|
4
|
-
import { __ } from '@wordpress/i18n';
|
|
2
|
+
import { PositionControl } from '@elementor/editor-controls';
|
|
5
3
|
|
|
6
4
|
import { StylesField } from '../../../controls-registry/styles-field';
|
|
7
|
-
import { ControlLabel } from '../../control-label';
|
|
8
|
-
|
|
9
|
-
const positionOptions = [
|
|
10
|
-
{ label: __( 'Center center', 'elementor' ), value: 'center center' },
|
|
11
|
-
{ label: __( 'Center left', 'elementor' ), value: 'center left' },
|
|
12
|
-
{ label: __( 'Center right', 'elementor' ), value: 'center right' },
|
|
13
|
-
{ label: __( 'Top center', 'elementor' ), value: 'top center' },
|
|
14
|
-
{ label: __( 'Top left', 'elementor' ), value: 'top left' },
|
|
15
|
-
{ label: __( 'Top right', 'elementor' ), value: 'top right' },
|
|
16
|
-
{ label: __( 'Bottom center', 'elementor' ), value: 'bottom center' },
|
|
17
|
-
{ label: __( 'Bottom left', 'elementor' ), value: 'bottom left' },
|
|
18
|
-
{ label: __( 'Bottom right', 'elementor' ), value: 'bottom right' },
|
|
19
|
-
];
|
|
20
5
|
|
|
21
6
|
export const ObjectPositionField = () => {
|
|
22
7
|
return (
|
|
23
8
|
<StylesField bind="object-position">
|
|
24
|
-
<
|
|
25
|
-
<Grid item xs={ 6 }>
|
|
26
|
-
<ControlLabel>{ __( 'Object position', 'elementor' ) }</ControlLabel>
|
|
27
|
-
</Grid>
|
|
28
|
-
<Grid item xs={ 6 } sx={ { overflow: 'hidden' } }>
|
|
29
|
-
<SelectControl options={ positionOptions } />
|
|
30
|
-
</Grid>
|
|
31
|
-
</Grid>
|
|
9
|
+
<PositionControl />
|
|
32
10
|
</StylesField>
|
|
33
11
|
);
|
|
34
12
|
};
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import {
|
|
2
|
+
import { type MutableRefObject, useRef } from 'react';
|
|
3
|
+
import { AspectRatioControl, type ExtendedOption, SizeControl } from '@elementor/editor-controls';
|
|
3
4
|
import type { StringPropValue } from '@elementor/editor-props';
|
|
4
5
|
import { isExperimentActive } from '@elementor/editor-v1-adapters';
|
|
5
6
|
import { Grid, Stack } from '@elementor/ui';
|
|
@@ -15,47 +16,60 @@ import { ObjectFitField } from './object-fit-field';
|
|
|
15
16
|
import { ObjectPositionField } from './object-position-field';
|
|
16
17
|
import { OverflowField } from './overflow-field';
|
|
17
18
|
|
|
19
|
+
const EXPERIMENT_ID = 'e_v_3_30';
|
|
20
|
+
|
|
21
|
+
const CssSizeProps = [
|
|
22
|
+
[
|
|
23
|
+
{
|
|
24
|
+
bind: 'width',
|
|
25
|
+
label: __( 'Width', 'elementor' ),
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
bind: 'height',
|
|
29
|
+
label: __( 'Height', 'elementor' ),
|
|
30
|
+
},
|
|
31
|
+
],
|
|
32
|
+
[
|
|
33
|
+
{
|
|
34
|
+
bind: 'min-width',
|
|
35
|
+
label: __( 'Min width', 'elementor' ),
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
bind: 'min-height',
|
|
39
|
+
label: __( 'Min height', 'elementor' ),
|
|
40
|
+
},
|
|
41
|
+
],
|
|
42
|
+
[
|
|
43
|
+
{
|
|
44
|
+
bind: 'max-width',
|
|
45
|
+
label: __( 'Max width', 'elementor' ),
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
bind: 'max-height',
|
|
49
|
+
label: __( 'Max height', 'elementor' ),
|
|
50
|
+
},
|
|
51
|
+
],
|
|
52
|
+
];
|
|
53
|
+
|
|
18
54
|
export const SizeSection = () => {
|
|
19
|
-
const
|
|
55
|
+
const { value: fitValue } = useStylesField< StringPropValue >( 'object-fit' );
|
|
20
56
|
|
|
21
57
|
const isNotFill = fitValue && fitValue?.value !== 'fill';
|
|
22
58
|
|
|
23
|
-
const
|
|
59
|
+
const gridRowRefs: MutableRefObject< HTMLElement | undefined >[] = [ useRef(), useRef(), useRef() ];
|
|
60
|
+
const isVersion330Active = isExperimentActive( EXPERIMENT_ID );
|
|
24
61
|
|
|
25
62
|
return (
|
|
26
63
|
<SectionContent>
|
|
27
|
-
|
|
28
|
-
<Grid
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
</Grid>
|
|
35
|
-
<Grid container gap={ 2 } flexWrap="nowrap">
|
|
36
|
-
<Grid item xs={ 6 }>
|
|
37
|
-
<SizeField
|
|
38
|
-
bind="min-width"
|
|
39
|
-
label={ __( 'Min width', 'elementor' ) }
|
|
40
|
-
extendedValues={ [ 'auto' ] }
|
|
41
|
-
/>
|
|
64
|
+
{ CssSizeProps.map( ( row, rowIndex ) => (
|
|
65
|
+
<Grid key={ rowIndex } container gap={ 2 } flexWrap="nowrap" ref={ gridRowRefs[ rowIndex ] }>
|
|
66
|
+
{ row.map( ( props ) => (
|
|
67
|
+
<Grid item xs={ 6 } key={ props.bind }>
|
|
68
|
+
<SizeField { ...props } rowRef={ gridRowRefs[ rowIndex ] } extendedOptions={ [ 'auto' ] } />
|
|
69
|
+
</Grid>
|
|
70
|
+
) ) }
|
|
42
71
|
</Grid>
|
|
43
|
-
|
|
44
|
-
<SizeField
|
|
45
|
-
bind="min-height"
|
|
46
|
-
label={ __( 'Min height', 'elementor' ) }
|
|
47
|
-
extendedValues={ [ 'auto' ] }
|
|
48
|
-
/>
|
|
49
|
-
</Grid>
|
|
50
|
-
</Grid>
|
|
51
|
-
<Grid container gap={ 2 } flexWrap="nowrap">
|
|
52
|
-
<Grid item xs={ 6 }>
|
|
53
|
-
<SizeField bind="max-width" label={ __( 'Max width', 'elementor' ) } />
|
|
54
|
-
</Grid>
|
|
55
|
-
<Grid item xs={ 6 }>
|
|
56
|
-
<SizeField bind="max-height" label={ __( 'Max height', 'elementor' ) } />
|
|
57
|
-
</Grid>
|
|
58
|
-
</Grid>
|
|
72
|
+
) ) }
|
|
59
73
|
<PanelDivider />
|
|
60
74
|
<Stack>
|
|
61
75
|
<OverflowField />
|
|
@@ -83,10 +97,11 @@ export const SizeSection = () => {
|
|
|
83
97
|
type ControlProps = {
|
|
84
98
|
bind: StylesFieldProps[ 'bind' ];
|
|
85
99
|
label: string;
|
|
86
|
-
|
|
100
|
+
rowRef: MutableRefObject< HTMLElement | undefined >;
|
|
101
|
+
extendedOptions?: ExtendedOption[];
|
|
87
102
|
};
|
|
88
103
|
|
|
89
|
-
const SizeField = ( { label, bind,
|
|
104
|
+
const SizeField = ( { label, bind, rowRef, extendedOptions }: ControlProps ) => {
|
|
90
105
|
return (
|
|
91
106
|
<StylesField bind={ bind }>
|
|
92
107
|
<Grid container gap={ 0.75 } alignItems="center">
|
|
@@ -94,7 +109,7 @@ const SizeField = ( { label, bind, extendedValues }: ControlProps ) => {
|
|
|
94
109
|
<ControlLabel>{ label }</ControlLabel>
|
|
95
110
|
</Grid>
|
|
96
111
|
<Grid item xs={ 12 }>
|
|
97
|
-
<SizeControl
|
|
112
|
+
<SizeControl extendedOptions={ extendedOptions } anchorRef={ rowRef } />
|
|
98
113
|
</Grid>
|
|
99
114
|
</Grid>
|
|
100
115
|
</StylesField>
|