@elementor/editor-controls 3.32.0-74 → 3.32.0-75
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.d.mts +3 -2
- package/dist/index.d.ts +3 -2
- package/dist/index.js +411 -423
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +343 -355
- package/dist/index.mjs.map +1 -1
- package/package.json +14 -14
- package/src/components/unstable-repeater/actions/tooltip-add-item-action.tsx +1 -1
- package/src/components/unstable-repeater/header/header.tsx +12 -19
- package/src/controls/transform-control/transform-base-control.tsx +38 -34
- package/src/controls/transform-control/transform-base-controls/children-perspective-control.tsx +58 -48
- package/src/controls/transform-control/transform-base-controls/transform-origin-control.tsx +26 -34
- package/src/controls/transform-control/transform-repeater-control.tsx +38 -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": "3.32.0-
|
|
4
|
+
"version": "3.32.0-75",
|
|
5
5
|
"private": false,
|
|
6
6
|
"author": "Elementor Team",
|
|
7
7
|
"homepage": "https://elementor.com/",
|
|
@@ -40,21 +40,21 @@
|
|
|
40
40
|
"dev": "tsup --config=../../tsup.dev.ts"
|
|
41
41
|
},
|
|
42
42
|
"dependencies": {
|
|
43
|
-
"@elementor/editor-current-user": "3.32.0-
|
|
44
|
-
"@elementor/editor-elements": "3.32.0-
|
|
45
|
-
"@elementor/editor-props": "3.32.0-
|
|
46
|
-
"@elementor/editor-responsive": "3.32.0-
|
|
47
|
-
"@elementor/editor-ui": "3.32.0-
|
|
48
|
-
"@elementor/editor-v1-adapters": "3.32.0-
|
|
49
|
-
"@elementor/env": "3.32.0-
|
|
50
|
-
"@elementor/http-client": "3.32.0-
|
|
43
|
+
"@elementor/editor-current-user": "3.32.0-75",
|
|
44
|
+
"@elementor/editor-elements": "3.32.0-75",
|
|
45
|
+
"@elementor/editor-props": "3.32.0-75",
|
|
46
|
+
"@elementor/editor-responsive": "3.32.0-75",
|
|
47
|
+
"@elementor/editor-ui": "3.32.0-75",
|
|
48
|
+
"@elementor/editor-v1-adapters": "3.32.0-75",
|
|
49
|
+
"@elementor/env": "3.32.0-75",
|
|
50
|
+
"@elementor/http-client": "3.32.0-75",
|
|
51
51
|
"@elementor/icons": "^1.51.1",
|
|
52
|
-
"@elementor/locations": "3.32.0-
|
|
53
|
-
"@elementor/query": "3.32.0-
|
|
54
|
-
"@elementor/session": "3.32.0-
|
|
52
|
+
"@elementor/locations": "3.32.0-75",
|
|
53
|
+
"@elementor/query": "3.32.0-75",
|
|
54
|
+
"@elementor/session": "3.32.0-75",
|
|
55
55
|
"@elementor/ui": "1.36.8",
|
|
56
|
-
"@elementor/utils": "3.32.0-
|
|
57
|
-
"@elementor/wp-media": "3.32.0-
|
|
56
|
+
"@elementor/utils": "3.32.0-75",
|
|
57
|
+
"@elementor/wp-media": "3.32.0-75",
|
|
58
58
|
"@wordpress/i18n": "^5.13.0",
|
|
59
59
|
"@monaco-editor/react": "^4.7.0"
|
|
60
60
|
},
|
|
@@ -26,7 +26,7 @@ export const TooltipAddItemAction = ( {
|
|
|
26
26
|
|
|
27
27
|
return (
|
|
28
28
|
<ConditionalToolTip content={ tooltipContent } enable={ enableTooltip }>
|
|
29
|
-
<Box sx={ {
|
|
29
|
+
<Box component="span" sx={ { cursor: disabled ? 'not-allowed' : 'pointer' } }>
|
|
30
30
|
<IconButton
|
|
31
31
|
size={ SIZE }
|
|
32
32
|
disabled={ disabled }
|
|
@@ -4,31 +4,24 @@ import { Box, Stack, Typography } from '@elementor/ui';
|
|
|
4
4
|
import { useBoundProp } from '../../../bound-prop-context/use-bound-prop';
|
|
5
5
|
import { ControlAdornments } from '../../../control-adornments/control-adornments';
|
|
6
6
|
import { SlotChildren } from '../../../control-replacements';
|
|
7
|
-
import { TransformBaseControl } from '../../../controls/transform-control/transform-base-control';
|
|
8
7
|
import { TooltipAddItemAction } from '../actions/tooltip-add-item-action';
|
|
9
8
|
import { RepeaterHeaderActionsSlot } from '../locations';
|
|
10
9
|
|
|
11
|
-
export const Header = ( { label, children }: React.PropsWithChildren< { label: string }
|
|
10
|
+
export const Header = React.forwardRef( ( { label, children }: React.PropsWithChildren< { label: string } >, ref ) => {
|
|
12
11
|
const { value } = useBoundProp();
|
|
13
12
|
|
|
14
13
|
return (
|
|
15
|
-
<Stack
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
>
|
|
22
|
-
<Typography component="label" variant="caption" color="text.secondary" sx={ { lineHeight: 1 } }>
|
|
23
|
-
{ label }
|
|
24
|
-
</Typography>
|
|
25
|
-
<ControlAdornments />
|
|
26
|
-
<RepeaterHeaderActionsSlot value={ value } />
|
|
27
|
-
<Box sx={ { ml: 'auto' } }>
|
|
28
|
-
<SlotChildren whitelist={ [ TransformBaseControl, TooltipAddItemAction ] as React.FC[] } sorted>
|
|
29
|
-
{ children }
|
|
30
|
-
</SlotChildren>
|
|
14
|
+
<Stack direction="row" alignItems="center" gap={ 1 } sx={ { marginInlineEnd: -0.75, py: 0.25 } } ref={ ref }>
|
|
15
|
+
<Box display="flex" alignItems="center" gap={ 1 } sx={ { flexGrow: 1 } }>
|
|
16
|
+
<Typography component="label" variant="caption" color="text.secondary" sx={ { lineHeight: 1 } }>
|
|
17
|
+
{ label }
|
|
18
|
+
</Typography>
|
|
19
|
+
<ControlAdornments />
|
|
31
20
|
</Box>
|
|
21
|
+
<RepeaterHeaderActionsSlot value={ value } />
|
|
22
|
+
<SlotChildren whitelist={ [ TooltipAddItemAction ] as React.FC[] } sorted>
|
|
23
|
+
{ children }
|
|
24
|
+
</SlotChildren>
|
|
32
25
|
</Stack>
|
|
33
26
|
);
|
|
34
|
-
};
|
|
27
|
+
} );
|
|
@@ -1,53 +1,57 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import { useRef } from 'react';
|
|
3
2
|
import { PopoverHeader } from '@elementor/editor-ui';
|
|
4
3
|
import { AdjustmentsIcon } from '@elementor/icons';
|
|
5
|
-
import { bindPopover,
|
|
4
|
+
import { bindPopover, Box, Divider, Popover, type PopupState } from '@elementor/ui';
|
|
6
5
|
import { __ } from '@wordpress/i18n';
|
|
7
6
|
|
|
7
|
+
import { PropKeyProvider } from '../../bound-prop-context';
|
|
8
|
+
import { PopoverContent } from '../../components/popover-content';
|
|
8
9
|
import { ChildrenPerspectiveControl } from './transform-base-controls/children-perspective-control';
|
|
9
10
|
import { TransformOriginControl } from './transform-base-controls/transform-origin-control';
|
|
10
11
|
|
|
11
12
|
const SIZE = 'tiny';
|
|
12
13
|
|
|
13
|
-
export const TransformBaseControl = ( {
|
|
14
|
-
|
|
15
|
-
|
|
14
|
+
export const TransformBaseControl = ( {
|
|
15
|
+
popupState,
|
|
16
|
+
anchorRef,
|
|
17
|
+
}: {
|
|
18
|
+
popupState: PopupState;
|
|
19
|
+
anchorRef: React.RefObject< HTMLDivElement | null >;
|
|
20
|
+
} ) => {
|
|
16
21
|
const popupProps = bindPopover( {
|
|
17
22
|
...popupState,
|
|
18
23
|
anchorEl: anchorRef.current ?? undefined,
|
|
19
24
|
} );
|
|
20
25
|
|
|
21
26
|
return (
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
{
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
<Popover
|
|
31
|
-
disablePortal
|
|
32
|
-
slotProps={ {
|
|
33
|
-
paper: {
|
|
34
|
-
sx: {
|
|
35
|
-
width: anchorRef.current?.offsetWidth + 'px',
|
|
36
|
-
},
|
|
27
|
+
<Popover
|
|
28
|
+
disablePortal
|
|
29
|
+
anchorOrigin={ { vertical: 'bottom', horizontal: 'left' } }
|
|
30
|
+
slotProps={ {
|
|
31
|
+
paper: {
|
|
32
|
+
sx: {
|
|
33
|
+
width: ( anchorRef.current?.offsetWidth || 0 ) - 6 + 'px',
|
|
34
|
+
mt: 0.5,
|
|
37
35
|
},
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
/>
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
<
|
|
50
|
-
|
|
51
|
-
|
|
36
|
+
},
|
|
37
|
+
} }
|
|
38
|
+
{ ...popupProps }
|
|
39
|
+
>
|
|
40
|
+
<PopoverHeader
|
|
41
|
+
title={ __( 'Base Transform', 'elementor' ) }
|
|
42
|
+
onClose={ popupState.close }
|
|
43
|
+
icon={ <AdjustmentsIcon fontSize={ SIZE } /> }
|
|
44
|
+
/>
|
|
45
|
+
<Divider />
|
|
46
|
+
<PopoverContent sx={ { px: 2, py: 1.5 } }>
|
|
47
|
+
<PropKeyProvider bind={ 'transform-origin' }>
|
|
48
|
+
<TransformOriginControl />
|
|
49
|
+
</PropKeyProvider>
|
|
50
|
+
<Box sx={ { my: 0.5 } }>
|
|
51
|
+
<Divider />
|
|
52
|
+
</Box>
|
|
53
|
+
<ChildrenPerspectiveControl />
|
|
54
|
+
</PopoverContent>
|
|
55
|
+
</Popover>
|
|
52
56
|
);
|
|
53
57
|
};
|
package/src/controls/transform-control/transform-base-controls/children-perspective-control.tsx
CHANGED
|
@@ -1,78 +1,88 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
2
|
+
import { perspectiveOriginPropTypeUtil } from '@elementor/editor-props';
|
|
3
|
+
import { Grid, Stack } from '@elementor/ui';
|
|
4
4
|
import { __ } from '@wordpress/i18n';
|
|
5
5
|
|
|
6
6
|
import { PropKeyProvider, PropProvider, useBoundProp } from '../../../bound-prop-context';
|
|
7
7
|
import { ControlFormLabel } from '../../../components/control-form-label';
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
8
|
+
import { PopoverGridContainer } from '../../../components/popover-grid-container';
|
|
9
|
+
import { type LengthUnit } from '../../../utils/size-control';
|
|
10
10
|
import { SizeControl } from '../../size-control';
|
|
11
11
|
|
|
12
|
-
|
|
12
|
+
type FieldProps = {
|
|
13
|
+
label: string;
|
|
14
|
+
bind: string;
|
|
15
|
+
units: LengthUnit[];
|
|
16
|
+
};
|
|
13
17
|
|
|
14
|
-
const
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
18
|
+
const ORIGIN_UNITS: LengthUnit[] = [ 'px', '%', 'em', 'rem' ];
|
|
19
|
+
|
|
20
|
+
const PERSPECTIVE_CONTROL_FIELD: FieldProps = {
|
|
21
|
+
label: __( 'Perspective', 'elementor' ),
|
|
22
|
+
bind: 'perspective',
|
|
23
|
+
units: [ 'px', 'em', 'rem', 'vw', 'vh' ],
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
const CHILDREN_PERSPECTIVE_FIELDS: FieldProps[] = [
|
|
20
27
|
{
|
|
21
28
|
label: __( 'Origin X', 'elementor' ),
|
|
22
|
-
|
|
29
|
+
bind: 'x',
|
|
23
30
|
units: ORIGIN_UNITS,
|
|
24
31
|
},
|
|
25
32
|
{
|
|
26
33
|
label: __( 'Origin Y', 'elementor' ),
|
|
27
|
-
|
|
34
|
+
bind: 'y',
|
|
28
35
|
units: ORIGIN_UNITS,
|
|
29
36
|
},
|
|
30
37
|
] as const;
|
|
31
38
|
|
|
32
|
-
export const ChildrenPerspectiveControl = (
|
|
39
|
+
export const ChildrenPerspectiveControl = () => {
|
|
33
40
|
return (
|
|
34
41
|
<Stack direction="column" spacing={ 1.5 }>
|
|
35
|
-
<ControlFormLabel
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
<Grid container spacing={ 1.5 } ref={ rowRef }>
|
|
39
|
-
{ CHILDREN_PERSPECTIVE_FIELDS.map( ( control ) => (
|
|
40
|
-
<ControlFields control={ control } rowRef={ rowRef } key={ control.bindValue } />
|
|
41
|
-
) ) }
|
|
42
|
-
<Divider sx={ { py: 3 } } />
|
|
43
|
-
</Grid>
|
|
42
|
+
<ControlFormLabel>{ __( 'Children perspective', 'elementor' ) }</ControlFormLabel>
|
|
43
|
+
<PerspectiveControl />
|
|
44
|
+
<PerspectiveOriginControl />
|
|
44
45
|
</Stack>
|
|
45
46
|
);
|
|
46
47
|
};
|
|
47
48
|
|
|
48
|
-
const
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
49
|
+
const PerspectiveControl = () => (
|
|
50
|
+
<PropKeyProvider bind={ 'perspective' }>
|
|
51
|
+
<ControlFields control={ PERSPECTIVE_CONTROL_FIELD } key={ PERSPECTIVE_CONTROL_FIELD.bind } />
|
|
52
|
+
</PropKeyProvider>
|
|
53
|
+
);
|
|
54
|
+
|
|
55
|
+
const PerspectiveOriginControl = () => (
|
|
56
|
+
<PropKeyProvider bind={ 'perspective-origin' }>
|
|
57
|
+
<PerspectiveOriginControlProvider />
|
|
58
|
+
</PropKeyProvider>
|
|
59
|
+
);
|
|
60
|
+
|
|
61
|
+
const PerspectiveOriginControlProvider = () => {
|
|
62
|
+
const context = useBoundProp( perspectiveOriginPropTypeUtil );
|
|
56
63
|
|
|
57
64
|
return (
|
|
58
65
|
<PropProvider { ...context }>
|
|
59
|
-
|
|
60
|
-
<
|
|
61
|
-
<
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
</Grid>
|
|
65
|
-
<Grid item xs={ 6 } sx={ { pr: 3 } }>
|
|
66
|
-
<SizeControl
|
|
67
|
-
variant="length"
|
|
68
|
-
units={ [ ...control.units ] }
|
|
69
|
-
anchorRef={ rowRef }
|
|
70
|
-
disableCustom
|
|
71
|
-
/>
|
|
72
|
-
</Grid>
|
|
73
|
-
</Grid>
|
|
74
|
-
</Grid>
|
|
75
|
-
</PropKeyProvider>
|
|
66
|
+
{ CHILDREN_PERSPECTIVE_FIELDS.map( ( control ) => (
|
|
67
|
+
<PropKeyProvider bind={ control.bind } key={ control.bind }>
|
|
68
|
+
<ControlFields control={ control } />
|
|
69
|
+
</PropKeyProvider>
|
|
70
|
+
) ) }
|
|
76
71
|
</PropProvider>
|
|
77
72
|
);
|
|
78
73
|
};
|
|
74
|
+
|
|
75
|
+
const ControlFields = ( { control }: { control: FieldProps } ) => {
|
|
76
|
+
const rowRef = React.useRef< HTMLDivElement >( null );
|
|
77
|
+
|
|
78
|
+
return (
|
|
79
|
+
<PopoverGridContainer ref={ rowRef }>
|
|
80
|
+
<Grid item xs={ 6 }>
|
|
81
|
+
<ControlFormLabel>{ control.label }</ControlFormLabel>
|
|
82
|
+
</Grid>
|
|
83
|
+
<Grid item xs={ 6 }>
|
|
84
|
+
<SizeControl variant="length" units={ control.units } anchorRef={ rowRef } disableCustom />
|
|
85
|
+
</Grid>
|
|
86
|
+
</PopoverGridContainer>
|
|
87
|
+
);
|
|
88
|
+
};
|
|
@@ -1,69 +1,61 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
2
|
+
import { transformOriginPropTypeUtil } from '@elementor/editor-props';
|
|
3
|
+
import { Grid, Stack } from '@elementor/ui';
|
|
4
4
|
import { __ } from '@wordpress/i18n';
|
|
5
5
|
|
|
6
6
|
import { PropKeyProvider, PropProvider, useBoundProp } from '../../../bound-prop-context';
|
|
7
7
|
import { ControlFormLabel } from '../../../components/control-form-label';
|
|
8
|
-
import {
|
|
8
|
+
import { PopoverGridContainer } from '../../../components/popover-grid-container';
|
|
9
|
+
import { type LengthUnit } from '../../../utils/size-control';
|
|
9
10
|
import { SizeControl } from '../../size-control';
|
|
10
11
|
|
|
11
|
-
const TRANSFORM_ORIGIN_UNITS = [ 'px', '%', 'em', 'rem' ]
|
|
12
|
+
const TRANSFORM_ORIGIN_UNITS: LengthUnit[] = [ 'px', '%', 'em', 'rem' ];
|
|
13
|
+
const TRANSFORM_ORIGIN_UNITS_Z_AXIS = TRANSFORM_ORIGIN_UNITS.filter( ( unit ) => unit !== '%' );
|
|
12
14
|
|
|
13
15
|
const TRANSFORM_ORIGIN_FIELDS = [
|
|
14
16
|
{
|
|
15
17
|
label: __( 'Origin X', 'elementor' ),
|
|
16
|
-
|
|
18
|
+
bind: 'x',
|
|
17
19
|
units: TRANSFORM_ORIGIN_UNITS,
|
|
18
20
|
},
|
|
19
21
|
{
|
|
20
22
|
label: __( 'Origin Y', 'elementor' ),
|
|
21
|
-
|
|
23
|
+
bind: 'y',
|
|
22
24
|
units: TRANSFORM_ORIGIN_UNITS,
|
|
23
25
|
},
|
|
24
26
|
{
|
|
25
27
|
label: __( 'Origin Z', 'elementor' ),
|
|
26
|
-
|
|
27
|
-
units:
|
|
28
|
+
bind: 'z',
|
|
29
|
+
units: TRANSFORM_ORIGIN_UNITS_Z_AXIS,
|
|
28
30
|
},
|
|
29
31
|
];
|
|
30
32
|
|
|
31
|
-
export const TransformOriginControl = (
|
|
33
|
+
export const TransformOriginControl = () => {
|
|
32
34
|
return (
|
|
33
35
|
<Stack direction="column" spacing={ 1.5 }>
|
|
34
|
-
<ControlFormLabel
|
|
35
|
-
|
|
36
|
-
{
|
|
37
|
-
|
|
38
|
-
) ) }
|
|
39
|
-
<Divider sx={ { py: 3 } } />
|
|
40
|
-
</Grid>
|
|
36
|
+
<ControlFormLabel>{ __( 'Transform', 'elementor' ) }</ControlFormLabel>
|
|
37
|
+
{ TRANSFORM_ORIGIN_FIELDS.map( ( control ) => (
|
|
38
|
+
<ControlFields control={ control } key={ control.bind } />
|
|
39
|
+
) ) }
|
|
41
40
|
</Stack>
|
|
42
41
|
);
|
|
43
42
|
};
|
|
44
43
|
|
|
45
|
-
const ControlFields = ( {
|
|
46
|
-
|
|
47
|
-
rowRef
|
|
48
|
-
}: {
|
|
49
|
-
control: ( typeof TRANSFORM_ORIGIN_FIELDS )[ number ];
|
|
50
|
-
rowRef: React.RefObject< HTMLDivElement >;
|
|
51
|
-
} ) => {
|
|
52
|
-
const context = useBoundProp( sizePropTypeUtil );
|
|
44
|
+
const ControlFields = ( { control }: { control: ( typeof TRANSFORM_ORIGIN_FIELDS )[ number ] } ) => {
|
|
45
|
+
const context = useBoundProp( transformOriginPropTypeUtil );
|
|
46
|
+
const rowRef = React.useRef< HTMLDivElement >( null );
|
|
53
47
|
|
|
54
48
|
return (
|
|
55
49
|
<PropProvider { ...context }>
|
|
56
|
-
<PropKeyProvider bind={ control.
|
|
57
|
-
<
|
|
58
|
-
<Grid
|
|
59
|
-
<
|
|
60
|
-
<ControlLabel>{ control.label }</ControlLabel>
|
|
61
|
-
</Grid>
|
|
62
|
-
<Grid item xs={ 6 } sx={ { pr: 3 } }>
|
|
63
|
-
<SizeControl variant="length" units={ control.units } anchorRef={ rowRef } disableCustom />
|
|
64
|
-
</Grid>
|
|
50
|
+
<PropKeyProvider bind={ control.bind }>
|
|
51
|
+
<PopoverGridContainer ref={ rowRef }>
|
|
52
|
+
<Grid item xs={ 6 }>
|
|
53
|
+
<ControlFormLabel>{ control.label }</ControlFormLabel>
|
|
65
54
|
</Grid>
|
|
66
|
-
|
|
55
|
+
<Grid item xs={ 6 }>
|
|
56
|
+
<SizeControl variant="length" units={ control.units } anchorRef={ rowRef } disableCustom />
|
|
57
|
+
</Grid>
|
|
58
|
+
</PopoverGridContainer>
|
|
67
59
|
</PropKeyProvider>
|
|
68
60
|
</PropProvider>
|
|
69
61
|
);
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
+
import { useRef } from 'react';
|
|
2
3
|
import { transformFunctionsPropTypeUtil, transformPropTypeUtil } from '@elementor/editor-props';
|
|
3
|
-
import { InfoCircleFilledIcon } from '@elementor/icons';
|
|
4
|
-
import { Box, Typography } from '@elementor/ui';
|
|
4
|
+
import { AdjustmentsIcon, InfoCircleFilledIcon } from '@elementor/icons';
|
|
5
|
+
import { bindTrigger, Box, IconButton, type PopupState, Typography, usePopupState } from '@elementor/ui';
|
|
5
6
|
import { __ } from '@wordpress/i18n';
|
|
6
7
|
|
|
7
8
|
import { PropKeyProvider, PropProvider, useBoundProp } from '../../bound-prop-context';
|
|
@@ -15,19 +16,34 @@ import {
|
|
|
15
16
|
import { DisableItemAction } from '../../components/unstable-repeater/actions/disable-item-action';
|
|
16
17
|
import { RemoveItemAction } from '../../components/unstable-repeater/actions/remove-item-action';
|
|
17
18
|
import { EditItemPopover } from '../../components/unstable-repeater/items/edit-item-popover';
|
|
19
|
+
import { injectIntoRepeaterHeaderActions } from '../../components/unstable-repeater/locations';
|
|
18
20
|
import { createControl } from '../../create-control';
|
|
19
21
|
import { initialRotateValue, initialScaleValue, initialSkewValue, initialTransformValue } from './initial-values';
|
|
22
|
+
import { TransformBaseControl } from './transform-base-control';
|
|
20
23
|
import { TransformContent } from './transform-content';
|
|
21
24
|
import { TransformIcon } from './transform-icon';
|
|
22
25
|
import { TransformLabel } from './transform-label';
|
|
23
26
|
|
|
27
|
+
const SIZE = 'tiny';
|
|
28
|
+
|
|
24
29
|
export const TransformRepeaterControl = createControl( () => {
|
|
25
30
|
const context = useBoundProp( transformPropTypeUtil );
|
|
31
|
+
const headerRef = useRef< HTMLDivElement >( null );
|
|
32
|
+
const popupState = usePopupState( { variant: 'popover' } );
|
|
33
|
+
|
|
34
|
+
const repeaterBindKey = 'transform-functions';
|
|
35
|
+
|
|
36
|
+
injectIntoRepeaterHeaderActions( {
|
|
37
|
+
id: 'transform-base-control',
|
|
38
|
+
component: () => <TransformBasePopoverTrigger popupState={ popupState } repeaterBindKey={ repeaterBindKey } />,
|
|
39
|
+
options: { overwrite: true },
|
|
40
|
+
} );
|
|
26
41
|
|
|
27
42
|
return (
|
|
28
43
|
<PropProvider { ...context }>
|
|
29
|
-
<
|
|
30
|
-
|
|
44
|
+
<TransformBaseControl popupState={ popupState } anchorRef={ headerRef } />
|
|
45
|
+
<PropKeyProvider bind={ repeaterBindKey }>
|
|
46
|
+
<Repeater headerRef={ headerRef } />
|
|
31
47
|
</PropKeyProvider>
|
|
32
48
|
</PropProvider>
|
|
33
49
|
);
|
|
@@ -46,7 +62,7 @@ const ToolTip = (
|
|
|
46
62
|
</Box>
|
|
47
63
|
);
|
|
48
64
|
|
|
49
|
-
const Repeater = () => {
|
|
65
|
+
const Repeater = ( { headerRef }: { headerRef: React.RefObject< HTMLDivElement > } ) => {
|
|
50
66
|
const transformFunctionsContext = useBoundProp( transformFunctionsPropTypeUtil );
|
|
51
67
|
const availableValues = [ initialTransformValue, initialScaleValue, initialRotateValue, initialSkewValue ];
|
|
52
68
|
const { value: transformValues } = transformFunctionsContext;
|
|
@@ -63,7 +79,7 @@ const Repeater = () => {
|
|
|
63
79
|
initial={ getInitialValue() ?? initialTransformValue }
|
|
64
80
|
propTypeUtil={ transformFunctionsPropTypeUtil }
|
|
65
81
|
>
|
|
66
|
-
<Header label={ __( 'Transform', 'elementor' ) }>
|
|
82
|
+
<Header label={ __( 'Transform', 'elementor' ) } ref={ headerRef }>
|
|
67
83
|
<TooltipAddItemAction
|
|
68
84
|
disabled={ shouldDisableAddItem }
|
|
69
85
|
tooltipContent={ ToolTip }
|
|
@@ -81,3 +97,19 @@ const Repeater = () => {
|
|
|
81
97
|
</PropProvider>
|
|
82
98
|
);
|
|
83
99
|
};
|
|
100
|
+
|
|
101
|
+
const TransformBasePopoverTrigger = ( {
|
|
102
|
+
popupState,
|
|
103
|
+
repeaterBindKey,
|
|
104
|
+
}: {
|
|
105
|
+
popupState: PopupState;
|
|
106
|
+
repeaterBindKey: string;
|
|
107
|
+
} ) => {
|
|
108
|
+
const { bind } = useBoundProp();
|
|
109
|
+
|
|
110
|
+
return bind !== repeaterBindKey ? null : (
|
|
111
|
+
<IconButton size={ SIZE } aria-label={ __( 'Base Transform', 'elementor' ) } { ...bindTrigger( popupState ) }>
|
|
112
|
+
<AdjustmentsIcon fontSize={ SIZE } />
|
|
113
|
+
</IconButton>
|
|
114
|
+
);
|
|
115
|
+
};
|