@elementor/editor-editing-panel 1.2.0 → 1.3.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 +29 -0
- package/dist/index.js +657 -486
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +613 -433
- package/dist/index.mjs.map +1 -1
- package/package.json +12 -11
- package/src/components/style-sections/border-section/border-radius-field.tsx +4 -4
- package/src/components/style-sections/border-section/border-width-field.tsx +4 -4
- package/src/components/style-sections/layout-section/align-items-field.tsx +40 -60
- package/src/components/style-sections/layout-section/align-self-child-field.tsx +72 -0
- package/src/components/style-sections/layout-section/flex-direction-field.tsx +2 -2
- package/src/components/style-sections/layout-section/flex-order-field.tsx +14 -8
- package/src/components/style-sections/layout-section/flex-size-field.tsx +164 -0
- package/src/components/style-sections/layout-section/justify-content-field.tsx +51 -78
- package/src/components/style-sections/layout-section/layout-section.tsx +7 -2
- package/src/components/style-sections/layout-section/utils/rotated-icon.tsx +52 -0
- package/src/components/style-sections/layout-section/wrap-field.tsx +1 -1
- package/src/components/style-sections/position-section/position-section.tsx +3 -3
- package/src/components/style-sections/typography-section/line-height-field.tsx +21 -0
- package/src/components/style-sections/typography-section/text-style-field.tsx +31 -8
- package/src/components/style-sections/typography-section/typography-section.tsx +3 -1
- package/src/controls-registry/controls-registry.tsx +4 -0
- package/src/dynamics/components/dynamic-selection-control.tsx +8 -5
- package/src/dynamics/components/dynamic-selection.tsx +10 -8
- package/src/dynamics/dynamic-control.tsx +9 -11
- package/src/dynamics/utils.ts +20 -3
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@elementor/editor-editing-panel",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.3.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"author": "Elementor Team",
|
|
6
6
|
"homepage": "https://elementor.com/",
|
|
@@ -39,18 +39,19 @@
|
|
|
39
39
|
"dev": "tsup --config=../../tsup.dev.ts"
|
|
40
40
|
},
|
|
41
41
|
"dependencies": {
|
|
42
|
-
"@elementor/editor": "
|
|
43
|
-
"@elementor/editor-controls": "
|
|
44
|
-
"@elementor/editor-elements": "
|
|
45
|
-
"@elementor/menus": "
|
|
46
|
-
"@elementor/editor-props": "
|
|
47
|
-
"@elementor/editor-panels": "
|
|
48
|
-
"@elementor/editor-responsive": "
|
|
49
|
-
"@elementor/editor-styles": "
|
|
50
|
-
"@elementor/editor-v1-adapters": "
|
|
42
|
+
"@elementor/editor": "0.17.2",
|
|
43
|
+
"@elementor/editor-controls": "0.2.0",
|
|
44
|
+
"@elementor/editor-elements": "0.3.2",
|
|
45
|
+
"@elementor/menus": "0.1.2",
|
|
46
|
+
"@elementor/editor-props": "0.4.0",
|
|
47
|
+
"@elementor/editor-panels": "0.10.2",
|
|
48
|
+
"@elementor/editor-responsive": "0.12.4",
|
|
49
|
+
"@elementor/editor-styles": "0.3.1",
|
|
50
|
+
"@elementor/editor-v1-adapters": "0.8.5",
|
|
51
51
|
"@elementor/icons": "^1.20.0",
|
|
52
|
+
"@elementor/schema": "0.1.2",
|
|
52
53
|
"@elementor/ui": "^1.22.0",
|
|
53
|
-
"@elementor/utils": "
|
|
54
|
+
"@elementor/utils": "0.3.0",
|
|
54
55
|
"@wordpress/i18n": "^5.13.0"
|
|
55
56
|
},
|
|
56
57
|
"peerDependencies": {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { type EqualUnequalItems, EqualUnequalSizesControl } from '@elementor/editor-controls';
|
|
3
|
-
import
|
|
3
|
+
import { borderRadiusPropTypeUtil } from '@elementor/editor-props';
|
|
4
4
|
import {
|
|
5
5
|
BorderCornersIcon,
|
|
6
6
|
RadiusBottomLeftIcon,
|
|
@@ -12,7 +12,7 @@ import { __ } from '@wordpress/i18n';
|
|
|
12
12
|
|
|
13
13
|
import { StylesField } from '../../../controls-registry/styles-field';
|
|
14
14
|
|
|
15
|
-
const corners: EqualUnequalItems
|
|
15
|
+
const corners: EqualUnequalItems = [
|
|
16
16
|
{
|
|
17
17
|
label: __( 'Top Left', 'elementor' ),
|
|
18
18
|
icon: <RadiusTopLeftIcon fontSize={ 'tiny' } />,
|
|
@@ -39,10 +39,10 @@ export const BorderRadiusField = () => {
|
|
|
39
39
|
return (
|
|
40
40
|
<StylesField bind={ 'border-radius' }>
|
|
41
41
|
<EqualUnequalSizesControl
|
|
42
|
+
items={ corners }
|
|
42
43
|
label={ __( 'Border Radius', 'elementor' ) }
|
|
43
44
|
icon={ <BorderCornersIcon fontSize={ 'tiny' } /> }
|
|
44
|
-
|
|
45
|
-
multiSizeType={ 'border-radius' }
|
|
45
|
+
multiSizePropTypeUtil={ borderRadiusPropTypeUtil }
|
|
46
46
|
/>
|
|
47
47
|
</StylesField>
|
|
48
48
|
);
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { type EqualUnequalItems, EqualUnequalSizesControl } from '@elementor/editor-controls';
|
|
3
|
-
import {
|
|
3
|
+
import { borderWidthPropTypeUtil } from '@elementor/editor-props';
|
|
4
4
|
import { SideAllIcon, SideBottomIcon, SideLeftIcon, SideRightIcon, SideTopIcon } from '@elementor/icons';
|
|
5
5
|
import { __ } from '@wordpress/i18n';
|
|
6
6
|
|
|
7
7
|
import { StylesField } from '../../../controls-registry/styles-field';
|
|
8
8
|
|
|
9
|
-
const edges: EqualUnequalItems
|
|
9
|
+
const edges: EqualUnequalItems = [
|
|
10
10
|
{
|
|
11
11
|
label: __( 'Top', 'elementor' ),
|
|
12
12
|
icon: <SideTopIcon fontSize={ 'tiny' } />,
|
|
@@ -33,10 +33,10 @@ export const BorderWidthField = () => {
|
|
|
33
33
|
return (
|
|
34
34
|
<StylesField bind={ 'border-width' }>
|
|
35
35
|
<EqualUnequalSizesControl
|
|
36
|
+
items={ edges }
|
|
36
37
|
label={ __( 'Border Width', 'elementor' ) }
|
|
37
38
|
icon={ <SideAllIcon fontSize={ 'tiny' } /> }
|
|
38
|
-
|
|
39
|
-
multiSizeType={ 'border-width' }
|
|
39
|
+
multiSizePropTypeUtil={ borderWidthPropTypeUtil }
|
|
40
40
|
/>
|
|
41
41
|
</StylesField>
|
|
42
42
|
);
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import type { JSX } from 'react';
|
|
3
2
|
import { ControlLabel, type ToggleButtonGroupItem, ToggleControl } from '@elementor/editor-controls';
|
|
4
3
|
import {
|
|
5
4
|
LayoutAlignCenterIcon as CenterIcon,
|
|
@@ -7,19 +6,52 @@ import {
|
|
|
7
6
|
LayoutAlignRightIcon,
|
|
8
7
|
LayoutDistributeVerticalIcon as JustifyIcon,
|
|
9
8
|
} from '@elementor/icons';
|
|
10
|
-
import { DirectionProvider, Grid, ThemeProvider,
|
|
9
|
+
import { DirectionProvider, Grid, ThemeProvider, withDirection } from '@elementor/ui';
|
|
11
10
|
import { __ } from '@wordpress/i18n';
|
|
12
11
|
|
|
13
12
|
import { StylesField } from '../../../controls-registry/styles-field';
|
|
14
13
|
import { useDirection } from '../../../hooks/use-direction';
|
|
15
|
-
import {
|
|
16
|
-
import { type FlexDirection } from './flex-direction-field';
|
|
14
|
+
import { RotatedIcon } from './utils/rotated-icon';
|
|
17
15
|
|
|
18
|
-
type AlignItems = 'start' | 'center' | 'end' | '
|
|
16
|
+
type AlignItems = 'start' | 'center' | 'end' | 'stretch';
|
|
17
|
+
|
|
18
|
+
const StartIcon = withDirection( LayoutAlignLeftIcon );
|
|
19
|
+
const EndIcon = withDirection( LayoutAlignRightIcon );
|
|
20
|
+
|
|
21
|
+
const iconProps = {
|
|
22
|
+
isClockwise: false,
|
|
23
|
+
offset: 90,
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
const options: ToggleButtonGroupItem< AlignItems >[] = [
|
|
27
|
+
{
|
|
28
|
+
value: 'start',
|
|
29
|
+
label: __( 'Start', 'elementor' ),
|
|
30
|
+
renderContent: ( { size } ) => <RotatedIcon icon={ StartIcon } size={ size } { ...iconProps } />,
|
|
31
|
+
showTooltip: true,
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
value: 'center',
|
|
35
|
+
label: __( 'Center', 'elementor' ),
|
|
36
|
+
renderContent: ( { size } ) => <RotatedIcon icon={ CenterIcon } size={ size } { ...iconProps } />,
|
|
37
|
+
showTooltip: true,
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
value: 'end',
|
|
41
|
+
label: __( 'End', 'elementor' ),
|
|
42
|
+
renderContent: ( { size } ) => <RotatedIcon icon={ EndIcon } size={ size } { ...iconProps } />,
|
|
43
|
+
showTooltip: true,
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
value: 'stretch',
|
|
47
|
+
label: __( 'Stretch', 'elementor' ),
|
|
48
|
+
renderContent: ( { size } ) => <RotatedIcon icon={ JustifyIcon } size={ size } { ...iconProps } />,
|
|
49
|
+
showTooltip: true,
|
|
50
|
+
},
|
|
51
|
+
];
|
|
19
52
|
|
|
20
53
|
export const AlignItemsField = () => {
|
|
21
|
-
const
|
|
22
|
-
{ isSiteRtl } = useDirection();
|
|
54
|
+
const { isSiteRtl } = useDirection();
|
|
23
55
|
|
|
24
56
|
return (
|
|
25
57
|
<DirectionProvider rtl={ isSiteRtl }>
|
|
@@ -27,7 +59,7 @@ export const AlignItemsField = () => {
|
|
|
27
59
|
<StylesField bind="align-items">
|
|
28
60
|
<Grid container gap={ 2 } alignItems="center" flexWrap="nowrap">
|
|
29
61
|
<Grid item xs={ 6 }>
|
|
30
|
-
<ControlLabel>{ __( 'Align
|
|
62
|
+
<ControlLabel>{ __( 'Align items', 'elementor' ) }</ControlLabel>
|
|
31
63
|
</Grid>
|
|
32
64
|
<Grid item xs={ 6 } sx={ { display: 'flex', justifyContent: 'end' } }>
|
|
33
65
|
<ToggleControl options={ options } />
|
|
@@ -38,55 +70,3 @@ export const AlignItemsField = () => {
|
|
|
38
70
|
</DirectionProvider>
|
|
39
71
|
);
|
|
40
72
|
};
|
|
41
|
-
|
|
42
|
-
const useOptions = (): ToggleButtonGroupItem< AlignItems >[] => {
|
|
43
|
-
const StartIcon = withDirection( LayoutAlignLeftIcon ),
|
|
44
|
-
EndIcon = withDirection( LayoutAlignRightIcon );
|
|
45
|
-
|
|
46
|
-
return [
|
|
47
|
-
{
|
|
48
|
-
value: 'start',
|
|
49
|
-
label: __( 'Start', 'elementor' ),
|
|
50
|
-
renderContent: ( { size } ) => <RotatedIcon icon={ StartIcon } size={ size } />,
|
|
51
|
-
showTooltip: true,
|
|
52
|
-
},
|
|
53
|
-
{
|
|
54
|
-
value: 'center',
|
|
55
|
-
label: __( 'Center', 'elementor' ),
|
|
56
|
-
renderContent: ( { size } ) => <RotatedIcon icon={ CenterIcon } size={ size } />,
|
|
57
|
-
showTooltip: true,
|
|
58
|
-
},
|
|
59
|
-
{
|
|
60
|
-
value: 'end',
|
|
61
|
-
label: __( 'End', 'elementor' ),
|
|
62
|
-
renderContent: ( { size } ) => <RotatedIcon icon={ EndIcon } size={ size } />,
|
|
63
|
-
showTooltip: true,
|
|
64
|
-
},
|
|
65
|
-
{
|
|
66
|
-
value: 'justify',
|
|
67
|
-
label: __( 'Justify', 'elementor' ),
|
|
68
|
-
renderContent: ( { size } ) => <RotatedIcon icon={ JustifyIcon } size={ size } />,
|
|
69
|
-
showTooltip: true,
|
|
70
|
-
},
|
|
71
|
-
];
|
|
72
|
-
};
|
|
73
|
-
|
|
74
|
-
const RotatedIcon = ( { icon: Icon, size }: { icon: JSX.ElementType; size: ToggleButtonProps[ 'size' ] } ) => {
|
|
75
|
-
const [ direction ] = useStylesField< FlexDirection >( 'flex-direction' ),
|
|
76
|
-
isRtl = 'rtl' === useTheme().direction,
|
|
77
|
-
rotationMultiplier = isRtl ? -1 : 1;
|
|
78
|
-
|
|
79
|
-
const rotationAngelMap: Record< FlexDirection, number > = {
|
|
80
|
-
row: 90,
|
|
81
|
-
column: 0,
|
|
82
|
-
'row-reverse': -90,
|
|
83
|
-
'column-reverse': -180,
|
|
84
|
-
};
|
|
85
|
-
|
|
86
|
-
return (
|
|
87
|
-
<Icon
|
|
88
|
-
fontSize={ size }
|
|
89
|
-
sx={ { transition: '.3s', rotate: `${ rotationAngelMap[ direction || 'row' ] * rotationMultiplier }deg` } }
|
|
90
|
-
/>
|
|
91
|
-
);
|
|
92
|
-
};
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { ControlLabel, type ToggleButtonGroupItem, ToggleControl } from '@elementor/editor-controls';
|
|
3
|
+
import {
|
|
4
|
+
LayoutAlignCenterIcon as CenterIcon,
|
|
5
|
+
LayoutAlignLeftIcon,
|
|
6
|
+
LayoutAlignRightIcon,
|
|
7
|
+
LayoutDistributeVerticalIcon as JustifyIcon,
|
|
8
|
+
} from '@elementor/icons';
|
|
9
|
+
import { DirectionProvider, Grid, ThemeProvider, withDirection } from '@elementor/ui';
|
|
10
|
+
import { __ } from '@wordpress/i18n';
|
|
11
|
+
|
|
12
|
+
import { StylesField } from '../../../controls-registry/styles-field';
|
|
13
|
+
import { useDirection } from '../../../hooks/use-direction';
|
|
14
|
+
import { RotatedIcon } from './utils/rotated-icon';
|
|
15
|
+
|
|
16
|
+
type AlignItems = 'start' | 'center' | 'end' | 'stretch';
|
|
17
|
+
|
|
18
|
+
const StartIcon = withDirection( LayoutAlignLeftIcon );
|
|
19
|
+
const EndIcon = withDirection( LayoutAlignRightIcon );
|
|
20
|
+
|
|
21
|
+
const iconProps = {
|
|
22
|
+
isClockwise: false,
|
|
23
|
+
offset: 90,
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
const options: ToggleButtonGroupItem< AlignItems >[] = [
|
|
27
|
+
{
|
|
28
|
+
value: 'start',
|
|
29
|
+
label: __( 'Start', 'elementor' ),
|
|
30
|
+
renderContent: ( { size } ) => <RotatedIcon icon={ StartIcon } size={ size } { ...iconProps } />,
|
|
31
|
+
showTooltip: true,
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
value: 'center',
|
|
35
|
+
label: __( 'Center', 'elementor' ),
|
|
36
|
+
renderContent: ( { size } ) => <RotatedIcon icon={ CenterIcon } size={ size } { ...iconProps } />,
|
|
37
|
+
showTooltip: true,
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
value: 'end',
|
|
41
|
+
label: __( 'End', 'elementor' ),
|
|
42
|
+
renderContent: ( { size } ) => <RotatedIcon icon={ EndIcon } size={ size } { ...iconProps } />,
|
|
43
|
+
showTooltip: true,
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
value: 'stretch',
|
|
47
|
+
label: __( 'Stretch', 'elementor' ),
|
|
48
|
+
renderContent: ( { size } ) => <RotatedIcon icon={ JustifyIcon } size={ size } { ...iconProps } />,
|
|
49
|
+
showTooltip: true,
|
|
50
|
+
},
|
|
51
|
+
];
|
|
52
|
+
|
|
53
|
+
export const AlignSelfChild = () => {
|
|
54
|
+
const { isSiteRtl } = useDirection();
|
|
55
|
+
|
|
56
|
+
return (
|
|
57
|
+
<DirectionProvider rtl={ isSiteRtl }>
|
|
58
|
+
<ThemeProvider>
|
|
59
|
+
<StylesField bind={ 'align-self' }>
|
|
60
|
+
<Grid container gap={ 2 } alignItems="center" flexWrap="nowrap">
|
|
61
|
+
<Grid item xs={ 6 }>
|
|
62
|
+
<ControlLabel>{ __( 'Align self', 'elementor' ) }</ControlLabel>
|
|
63
|
+
</Grid>
|
|
64
|
+
<Grid item xs={ 6 } sx={ { display: 'flex', justifyContent: 'flex-end' } }>
|
|
65
|
+
<ToggleControl options={ options } />
|
|
66
|
+
</Grid>
|
|
67
|
+
</Grid>
|
|
68
|
+
</StylesField>
|
|
69
|
+
</ThemeProvider>
|
|
70
|
+
</DirectionProvider>
|
|
71
|
+
);
|
|
72
|
+
};
|
|
@@ -27,7 +27,7 @@ const options: ToggleButtonGroupItem< FlexDirection >[] = [
|
|
|
27
27
|
},
|
|
28
28
|
{
|
|
29
29
|
value: 'row-reverse',
|
|
30
|
-
label: __( '
|
|
30
|
+
label: __( 'Reversed row', 'elementor' ),
|
|
31
31
|
renderContent: ( { size } ) => {
|
|
32
32
|
const EndIcon = withDirection( ArrowLeftIcon );
|
|
33
33
|
return <EndIcon fontSize={ size } />;
|
|
@@ -36,7 +36,7 @@ const options: ToggleButtonGroupItem< FlexDirection >[] = [
|
|
|
36
36
|
},
|
|
37
37
|
{
|
|
38
38
|
value: 'column-reverse',
|
|
39
|
-
label: __( '
|
|
39
|
+
label: __( 'Reversed column', 'elementor' ),
|
|
40
40
|
renderContent: ( { size } ) => <ArrowUpSmallIcon fontSize={ size } />,
|
|
41
41
|
showTooltip: true,
|
|
42
42
|
},
|
|
@@ -6,6 +6,7 @@ import {
|
|
|
6
6
|
NumberControl,
|
|
7
7
|
type ToggleButtonGroupItem,
|
|
8
8
|
} from '@elementor/editor-controls';
|
|
9
|
+
import { type NumberPropValue } from '@elementor/editor-props';
|
|
9
10
|
import { ArrowDownSmallIcon, ArrowUpSmallIcon, PencilIcon } from '@elementor/icons';
|
|
10
11
|
import { DirectionProvider, Grid, Stack, ThemeProvider } from '@elementor/ui';
|
|
11
12
|
import { __ } from '@wordpress/i18n';
|
|
@@ -22,6 +23,11 @@ export const FIRST_DEFAULT_VALUE = -99999,
|
|
|
22
23
|
LAST = 'last',
|
|
23
24
|
CUSTOM = 'custom';
|
|
24
25
|
|
|
26
|
+
const orderValueMap = {
|
|
27
|
+
[ FIRST ]: FIRST_DEFAULT_VALUE,
|
|
28
|
+
[ LAST ]: LAST_DEFAULT_VALUE,
|
|
29
|
+
};
|
|
30
|
+
|
|
25
31
|
const items: ToggleButtonGroupItem< GroupControlItemOption >[] = [
|
|
26
32
|
{
|
|
27
33
|
value: FIRST,
|
|
@@ -45,20 +51,20 @@ const items: ToggleButtonGroupItem< GroupControlItemOption >[] = [
|
|
|
45
51
|
|
|
46
52
|
export const FlexOrderField = () => {
|
|
47
53
|
const { isSiteRtl } = useDirection(),
|
|
48
|
-
[ order, setOrder ] = useStylesField<
|
|
54
|
+
[ order, setOrder ] = useStylesField< NumberPropValue | null >( 'order' );
|
|
49
55
|
|
|
50
|
-
const [ groupControlValue, setGroupControlValue ] = useState( getGroupControlValue( order ) );
|
|
56
|
+
const [ groupControlValue, setGroupControlValue ] = useState( getGroupControlValue( order?.value || null ) );
|
|
51
57
|
|
|
52
58
|
const handleToggleButtonChange = ( group: GroupControlItemOption | null ) => {
|
|
53
59
|
setGroupControlValue( group );
|
|
54
60
|
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
}
|
|
61
|
+
if ( ! group || group === CUSTOM ) {
|
|
62
|
+
setOrder( null );
|
|
63
|
+
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
60
66
|
|
|
61
|
-
setOrder(
|
|
67
|
+
setOrder( { $$type: 'number', value: orderValueMap[ group ] } );
|
|
62
68
|
};
|
|
63
69
|
|
|
64
70
|
return (
|
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import {
|
|
3
|
+
ControlLabel,
|
|
4
|
+
ControlToggleButtonGroup,
|
|
5
|
+
NumberControl,
|
|
6
|
+
SizeControl,
|
|
7
|
+
type ToggleButtonGroupItem,
|
|
8
|
+
} from '@elementor/editor-controls';
|
|
9
|
+
import type { NumberPropValue, SizePropValue } from '@elementor/editor-props';
|
|
10
|
+
import { ExpandIcon, PencilIcon, ShrinkIcon } from '@elementor/icons';
|
|
11
|
+
import { DirectionProvider, Grid, Stack, ThemeProvider } from '@elementor/ui';
|
|
12
|
+
import { __ } from '@wordpress/i18n';
|
|
13
|
+
|
|
14
|
+
import { StylesField } from '../../../controls-registry/styles-field';
|
|
15
|
+
import { useDirection } from '../../../hooks/use-direction';
|
|
16
|
+
import { useStylesField } from '../../../hooks/use-styles-field';
|
|
17
|
+
|
|
18
|
+
type GroupItem = 'flex-grow' | 'flex-shrink' | 'custom';
|
|
19
|
+
|
|
20
|
+
export const DEFAULT = 1;
|
|
21
|
+
|
|
22
|
+
const items: ToggleButtonGroupItem< GroupItem >[] = [
|
|
23
|
+
{
|
|
24
|
+
value: 'flex-grow',
|
|
25
|
+
label: __( 'Grow', 'elementor' ),
|
|
26
|
+
renderContent: ( { size } ) => <ExpandIcon fontSize={ size } />,
|
|
27
|
+
showTooltip: true,
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
value: 'flex-shrink',
|
|
31
|
+
label: __( 'Shrink', 'elementor' ),
|
|
32
|
+
renderContent: ( { size } ) => <ShrinkIcon fontSize={ size } />,
|
|
33
|
+
showTooltip: true,
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
value: 'custom',
|
|
37
|
+
label: __( 'Custom', 'elementor' ),
|
|
38
|
+
renderContent: ( { size } ) => <PencilIcon fontSize={ size } />,
|
|
39
|
+
showTooltip: true,
|
|
40
|
+
},
|
|
41
|
+
];
|
|
42
|
+
|
|
43
|
+
export const FlexSizeField = () => {
|
|
44
|
+
const { isSiteRtl } = useDirection(),
|
|
45
|
+
[ growField, setGrowField ] = useStylesField< NumberPropValue | null >( 'flex-grow' ),
|
|
46
|
+
[ shrinkField, setShrinkField ] = useStylesField< NumberPropValue | null >( 'flex-shrink' ),
|
|
47
|
+
[ basisField, setBasisField ] = useStylesField< SizePropValue | null >( 'flex-basis' );
|
|
48
|
+
|
|
49
|
+
const grow = growField?.value || null,
|
|
50
|
+
shrink = shrinkField?.value || null,
|
|
51
|
+
basis = basisField?.value || null;
|
|
52
|
+
|
|
53
|
+
const currentGroup = React.useMemo( () => getActiveGroup( { grow, shrink, basis } ), [ grow, shrink, basis ] ),
|
|
54
|
+
[ activeGroup, setActiveGroup ] = React.useState( currentGroup );
|
|
55
|
+
|
|
56
|
+
const onChangeGroup = ( group: GroupItem | null = null ) => {
|
|
57
|
+
setActiveGroup( group );
|
|
58
|
+
setBasisField( null );
|
|
59
|
+
|
|
60
|
+
if ( ! group || group === 'custom' ) {
|
|
61
|
+
setGrowField( null );
|
|
62
|
+
setShrinkField( null );
|
|
63
|
+
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
if ( group === 'flex-grow' ) {
|
|
68
|
+
setGrowField( { $$type: 'number', value: DEFAULT } );
|
|
69
|
+
setShrinkField( null );
|
|
70
|
+
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
setGrowField( null );
|
|
75
|
+
setShrinkField( { $$type: 'number', value: DEFAULT } );
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
return (
|
|
79
|
+
<DirectionProvider rtl={ isSiteRtl }>
|
|
80
|
+
<ThemeProvider>
|
|
81
|
+
<Stack gap={ 2 }>
|
|
82
|
+
<Grid container gap={ 2 } alignItems="center" flexWrap="nowrap">
|
|
83
|
+
<Grid item xs={ 6 }>
|
|
84
|
+
<ControlLabel>{ __( 'Size', 'elementor' ) }</ControlLabel>
|
|
85
|
+
</Grid>
|
|
86
|
+
<Grid item xs={ 6 } sx={ { display: 'flex', justifyContent: 'end' } }>
|
|
87
|
+
<ControlToggleButtonGroup
|
|
88
|
+
value={ activeGroup }
|
|
89
|
+
onChange={ onChangeGroup }
|
|
90
|
+
items={ items }
|
|
91
|
+
exclusive={ true }
|
|
92
|
+
/>
|
|
93
|
+
</Grid>
|
|
94
|
+
</Grid>
|
|
95
|
+
|
|
96
|
+
{ 'custom' === activeGroup && <FlexCustomField /> }
|
|
97
|
+
</Stack>
|
|
98
|
+
</ThemeProvider>
|
|
99
|
+
</DirectionProvider>
|
|
100
|
+
);
|
|
101
|
+
};
|
|
102
|
+
|
|
103
|
+
const FlexCustomField = () => (
|
|
104
|
+
<>
|
|
105
|
+
<StylesField bind={ 'flex-grow' }>
|
|
106
|
+
<Grid container gap={ 2 } alignItems="center" flexWrap="nowrap">
|
|
107
|
+
<Grid item xs={ 6 }>
|
|
108
|
+
<ControlLabel>{ __( 'Grow', 'elementor' ) }</ControlLabel>
|
|
109
|
+
</Grid>
|
|
110
|
+
<Grid item xs={ 6 } sx={ { display: 'flex', justifyContent: 'end' } }>
|
|
111
|
+
<NumberControl min={ 0 } shouldForceInt={ true } />
|
|
112
|
+
</Grid>
|
|
113
|
+
</Grid>
|
|
114
|
+
</StylesField>
|
|
115
|
+
<StylesField bind={ 'flex-shrink' }>
|
|
116
|
+
<Grid container gap={ 2 } alignItems="center" flexWrap="nowrap">
|
|
117
|
+
<Grid item xs={ 6 }>
|
|
118
|
+
<ControlLabel>{ __( 'Shrink', 'elementor' ) }</ControlLabel>
|
|
119
|
+
</Grid>
|
|
120
|
+
<Grid item xs={ 6 } sx={ { display: 'flex', justifyContent: 'end' } }>
|
|
121
|
+
<NumberControl min={ 0 } shouldForceInt={ true } />
|
|
122
|
+
</Grid>
|
|
123
|
+
</Grid>
|
|
124
|
+
</StylesField>
|
|
125
|
+
<StylesField bind={ 'flex-basis' }>
|
|
126
|
+
<Grid container gap={ 2 } alignItems="center" flexWrap="nowrap">
|
|
127
|
+
<Grid item xs={ 6 }>
|
|
128
|
+
<ControlLabel>{ __( 'Basis', 'elementor' ) }</ControlLabel>
|
|
129
|
+
</Grid>
|
|
130
|
+
<Grid item xs={ 6 } sx={ { display: 'flex', justifyContent: 'end' } }>
|
|
131
|
+
<SizeControl />
|
|
132
|
+
</Grid>
|
|
133
|
+
</Grid>
|
|
134
|
+
</StylesField>
|
|
135
|
+
</>
|
|
136
|
+
);
|
|
137
|
+
|
|
138
|
+
const getActiveGroup = ( {
|
|
139
|
+
grow,
|
|
140
|
+
shrink,
|
|
141
|
+
basis,
|
|
142
|
+
}: {
|
|
143
|
+
grow: NumberPropValue[ 'value' ] | null;
|
|
144
|
+
shrink: NumberPropValue[ 'value' ] | null;
|
|
145
|
+
basis: SizePropValue[ 'value' ] | null;
|
|
146
|
+
} ): GroupItem | null => {
|
|
147
|
+
if ( null === grow && null === shrink && ! basis ) {
|
|
148
|
+
return null;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
if ( ( shrink && grow ) || basis ) {
|
|
152
|
+
return 'custom';
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
if ( grow === DEFAULT ) {
|
|
156
|
+
return 'flex-grow';
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
if ( shrink === DEFAULT ) {
|
|
160
|
+
return 'flex-shrink';
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
return 'custom';
|
|
164
|
+
};
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import { type JSX } from 'react';
|
|
3
2
|
import { ControlLabel, type ToggleButtonGroupItem, ToggleControl } from '@elementor/editor-controls';
|
|
4
3
|
import {
|
|
5
4
|
JustifyBottomIcon,
|
|
@@ -9,33 +8,71 @@ import {
|
|
|
9
8
|
JustifySpaceBetweenVerticalIcon as BetweenIcon,
|
|
10
9
|
JustifyTopIcon,
|
|
11
10
|
} from '@elementor/icons';
|
|
12
|
-
import {
|
|
13
|
-
DirectionProvider,
|
|
14
|
-
Stack,
|
|
15
|
-
ThemeProvider,
|
|
16
|
-
type ToggleButtonProps,
|
|
17
|
-
useTheme,
|
|
18
|
-
withDirection,
|
|
19
|
-
} from '@elementor/ui';
|
|
11
|
+
import { DirectionProvider, Stack, ThemeProvider, withDirection } from '@elementor/ui';
|
|
20
12
|
import { __ } from '@wordpress/i18n';
|
|
21
13
|
|
|
22
14
|
import { StylesField } from '../../../controls-registry/styles-field';
|
|
23
15
|
import { useDirection } from '../../../hooks/use-direction';
|
|
24
|
-
import {
|
|
25
|
-
import { type FlexDirection } from './flex-direction-field';
|
|
16
|
+
import { RotatedIcon } from './utils/rotated-icon';
|
|
26
17
|
|
|
27
18
|
type JustifyContent = 'start' | 'center' | 'end' | 'space-between' | 'space-around' | 'space-evenly';
|
|
28
19
|
|
|
20
|
+
const StartIcon = withDirection( JustifyTopIcon );
|
|
21
|
+
const EndIcon = withDirection( JustifyBottomIcon );
|
|
22
|
+
|
|
23
|
+
const iconProps = {
|
|
24
|
+
isClockwise: true,
|
|
25
|
+
offset: -90,
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
const options: ToggleButtonGroupItem< JustifyContent >[] = [
|
|
29
|
+
{
|
|
30
|
+
value: 'start',
|
|
31
|
+
label: __( 'Start', 'elementor' ),
|
|
32
|
+
renderContent: ( { size } ) => <RotatedIcon icon={ StartIcon } size={ size } { ...iconProps } />,
|
|
33
|
+
showTooltip: true,
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
value: 'center',
|
|
37
|
+
label: __( 'Center', 'elementor' ),
|
|
38
|
+
renderContent: ( { size } ) => <RotatedIcon icon={ CenterIcon } size={ size } { ...iconProps } />,
|
|
39
|
+
showTooltip: true,
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
value: 'end',
|
|
43
|
+
label: __( 'End', 'elementor' ),
|
|
44
|
+
renderContent: ( { size } ) => <RotatedIcon icon={ EndIcon } size={ size } { ...iconProps } />,
|
|
45
|
+
showTooltip: true,
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
value: 'space-between',
|
|
49
|
+
label: __( 'Space between', 'elementor' ),
|
|
50
|
+
renderContent: ( { size } ) => <RotatedIcon icon={ BetweenIcon } size={ size } { ...iconProps } />,
|
|
51
|
+
showTooltip: true,
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
value: 'space-around',
|
|
55
|
+
label: __( 'Space around', 'elementor' ),
|
|
56
|
+
renderContent: ( { size } ) => <RotatedIcon icon={ AroundIcon } size={ size } { ...iconProps } />,
|
|
57
|
+
showTooltip: true,
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
value: 'space-evenly',
|
|
61
|
+
label: __( 'Space evenly', 'elementor' ),
|
|
62
|
+
renderContent: ( { size } ) => <RotatedIcon icon={ EvenlyIcon } size={ size } { ...iconProps } />,
|
|
63
|
+
showTooltip: true,
|
|
64
|
+
},
|
|
65
|
+
];
|
|
66
|
+
|
|
29
67
|
export const JustifyContentField = () => {
|
|
30
|
-
const
|
|
31
|
-
{ isSiteRtl } = useDirection();
|
|
68
|
+
const { isSiteRtl } = useDirection();
|
|
32
69
|
|
|
33
70
|
return (
|
|
34
71
|
<DirectionProvider rtl={ isSiteRtl }>
|
|
35
72
|
<ThemeProvider>
|
|
36
73
|
<StylesField bind="justify-content">
|
|
37
74
|
<Stack gap={ 1 }>
|
|
38
|
-
<ControlLabel>{ __( 'Justify
|
|
75
|
+
<ControlLabel>{ __( 'Justify content', 'elementor' ) }</ControlLabel>
|
|
39
76
|
<ToggleControl options={ options } fullWidth={ true } />
|
|
40
77
|
</Stack>
|
|
41
78
|
</StylesField>
|
|
@@ -43,67 +80,3 @@ export const JustifyContentField = () => {
|
|
|
43
80
|
</DirectionProvider>
|
|
44
81
|
);
|
|
45
82
|
};
|
|
46
|
-
|
|
47
|
-
const useOptions = (): ToggleButtonGroupItem< JustifyContent >[] => {
|
|
48
|
-
const StartIcon = withDirection( JustifyTopIcon ),
|
|
49
|
-
EndIcon = withDirection( JustifyBottomIcon );
|
|
50
|
-
|
|
51
|
-
return [
|
|
52
|
-
{
|
|
53
|
-
value: 'start',
|
|
54
|
-
label: __( 'Start', 'elementor' ),
|
|
55
|
-
renderContent: ( { size } ) => <RotatedIcon icon={ StartIcon } size={ size } />,
|
|
56
|
-
showTooltip: true,
|
|
57
|
-
},
|
|
58
|
-
{
|
|
59
|
-
value: 'center',
|
|
60
|
-
label: __( 'Center', 'elementor' ),
|
|
61
|
-
renderContent: ( { size } ) => <RotatedIcon icon={ CenterIcon } size={ size } />,
|
|
62
|
-
showTooltip: true,
|
|
63
|
-
},
|
|
64
|
-
{
|
|
65
|
-
value: 'end',
|
|
66
|
-
label: __( 'End', 'elementor' ),
|
|
67
|
-
renderContent: ( { size } ) => <RotatedIcon icon={ EndIcon } size={ size } />,
|
|
68
|
-
showTooltip: true,
|
|
69
|
-
},
|
|
70
|
-
{
|
|
71
|
-
value: 'space-between',
|
|
72
|
-
label: __( 'Space between', 'elementor' ),
|
|
73
|
-
renderContent: ( { size } ) => <RotatedIcon icon={ BetweenIcon } size={ size } />,
|
|
74
|
-
showTooltip: true,
|
|
75
|
-
},
|
|
76
|
-
{
|
|
77
|
-
value: 'space-around',
|
|
78
|
-
label: __( 'Space around', 'elementor' ),
|
|
79
|
-
renderContent: ( { size } ) => <RotatedIcon icon={ AroundIcon } size={ size } />,
|
|
80
|
-
showTooltip: true,
|
|
81
|
-
},
|
|
82
|
-
{
|
|
83
|
-
value: 'space-evenly',
|
|
84
|
-
label: __( 'Space evenly', 'elementor' ),
|
|
85
|
-
renderContent: ( { size } ) => <RotatedIcon icon={ EvenlyIcon } size={ size } />,
|
|
86
|
-
showTooltip: true,
|
|
87
|
-
},
|
|
88
|
-
];
|
|
89
|
-
};
|
|
90
|
-
|
|
91
|
-
const RotatedIcon = ( { icon: Icon, size }: { icon: JSX.ElementType; size: ToggleButtonProps[ 'size' ] } ) => {
|
|
92
|
-
const [ direction ] = useStylesField< FlexDirection >( 'flex-direction' ),
|
|
93
|
-
isRtl = 'rtl' === useTheme().direction,
|
|
94
|
-
rotationMultiplier = isRtl ? -1 : 1;
|
|
95
|
-
|
|
96
|
-
const rotationAngelMap: Record< FlexDirection, number > = {
|
|
97
|
-
row: -90,
|
|
98
|
-
column: 0,
|
|
99
|
-
'row-reverse': 90,
|
|
100
|
-
'column-reverse': 180,
|
|
101
|
-
};
|
|
102
|
-
|
|
103
|
-
return (
|
|
104
|
-
<Icon
|
|
105
|
-
fontSize={ size }
|
|
106
|
-
sx={ { transition: '.3s', rotate: `${ rotationAngelMap[ direction || 'row' ] * rotationMultiplier }deg` } }
|
|
107
|
-
/>
|
|
108
|
-
);
|
|
109
|
-
};
|