@elementor/editor-controls 1.5.0 → 3.32.0-21
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 +0 -22
- package/dist/index.d.mts +95 -25
- package/dist/index.d.ts +95 -25
- package/dist/index.js +2045 -1041
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1962 -964
- package/dist/index.mjs.map +1 -1
- package/package.json +18 -18
- package/src/components/control-toggle-button-group.tsx +78 -14
- package/src/components/floating-bar.tsx +45 -0
- package/src/components/{font-family-selector.tsx → item-selector.tsx} +62 -50
- package/src/components/repeater.tsx +1 -1
- package/src/components/restricted-link-infotip.tsx +76 -0
- package/src/components/size-control/size-input.tsx +8 -7
- package/src/components/size-control/text-field-inner-selection.tsx +60 -14
- package/src/components/text-field-popover.tsx +30 -7
- package/src/components/unstable-repeater/actions/add-item-action.tsx +50 -0
- package/src/components/unstable-repeater/actions/disable-item-action.tsx +39 -0
- package/src/components/unstable-repeater/actions/duplicate-item-action.tsx +32 -0
- package/src/components/unstable-repeater/actions/remove-item-action.tsx +27 -0
- package/src/components/unstable-repeater/context/repeater-context.tsx +137 -0
- package/src/components/unstable-repeater/header/header.tsx +23 -0
- package/src/components/unstable-repeater/index.ts +5 -0
- package/src/components/unstable-repeater/items/edit-item-popover.tsx +28 -0
- package/src/components/unstable-repeater/items/item.tsx +71 -0
- package/src/components/unstable-repeater/items/items-container.tsx +49 -0
- package/src/components/unstable-repeater/items/use-popover.tsx +26 -0
- package/src/{locations.ts → components/unstable-repeater/locations.ts} +9 -1
- package/src/components/unstable-repeater/types.ts +26 -0
- package/src/components/unstable-repeater/unstable-repeater.tsx +24 -0
- package/src/control-actions/control-actions.tsx +3 -20
- package/src/control-replacements.tsx +41 -0
- package/src/controls/background-control/background-control.tsx +1 -8
- package/src/controls/background-control/background-overlay/background-overlay-repeater-control.tsx +17 -16
- package/src/controls/equal-unequal-sizes-control.tsx +2 -9
- package/src/controls/filter-control/drop-shadow-item-content.tsx +4 -6
- package/src/controls/filter-control/drop-shadow-item-label.tsx +2 -2
- package/src/controls/filter-repeater-control.tsx +149 -110
- package/src/controls/font-family-control/font-family-control.tsx +22 -10
- package/src/controls/key-value-control.tsx +9 -6
- package/src/controls/link-control.tsx +8 -91
- package/src/controls/linked-dimensions-control.tsx +3 -16
- package/src/controls/number-control.tsx +10 -1
- package/src/controls/position-control.tsx +4 -16
- package/src/controls/repeatable-control.tsx +8 -5
- package/src/controls/select-control.tsx +7 -2
- package/src/controls/selection-size-control.tsx +74 -0
- package/src/controls/size-control.tsx +181 -126
- package/src/controls/stroke-control.tsx +2 -2
- package/src/controls/toggle-control.tsx +3 -2
- package/src/controls/transform-control/functions/axis-row.tsx +4 -2
- package/src/controls/transform-control/functions/move.tsx +2 -1
- package/src/controls/transform-control/functions/rotate.tsx +48 -0
- package/src/controls/transform-control/functions/scale-axis-row.tsx +32 -0
- package/src/controls/transform-control/functions/scale.tsx +45 -0
- package/src/controls/transform-control/functions/skew.tsx +43 -0
- package/src/controls/transform-control/transform-content.tsx +60 -23
- package/src/controls/transform-control/transform-icon.tsx +10 -2
- package/src/controls/transform-control/transform-label.tsx +39 -2
- package/src/controls/transform-control/transform-repeater-control.tsx +2 -10
- package/src/controls/transform-control/types.ts +58 -0
- package/src/controls/transform-control/use-transform-tabs-history.tsx +107 -0
- package/src/controls/transition-control/data.ts +34 -0
- package/src/controls/transition-control/transition-repeater-control.tsx +63 -0
- package/src/controls/transition-control/transition-selector.tsx +88 -0
- package/src/controls/unstable-transform-control/unstable-transform-repeater-control.tsx +35 -0
- package/src/hooks/use-filtered-items-list.ts +24 -0
- package/src/hooks/use-size-extended-options.ts +1 -6
- package/src/index.ts +13 -3
- package/src/utils/size-control.ts +12 -6
- package/src/hooks/use-filtered-font-families.ts +0 -24
|
@@ -42,12 +42,13 @@ export const ToggleControl = createControl(
|
|
|
42
42
|
maxItems,
|
|
43
43
|
fullWidth,
|
|
44
44
|
size,
|
|
45
|
+
placeholder,
|
|
45
46
|
};
|
|
46
47
|
|
|
47
48
|
return exclusive ? (
|
|
48
49
|
<ControlToggleButtonGroup
|
|
49
50
|
{ ...toggleButtonGroupProps }
|
|
50
|
-
value={ value ??
|
|
51
|
+
value={ value ?? null }
|
|
51
52
|
onChange={ setValue }
|
|
52
53
|
disabled={ disabled }
|
|
53
54
|
exclusive={ true }
|
|
@@ -55,7 +56,7 @@ export const ToggleControl = createControl(
|
|
|
55
56
|
) : (
|
|
56
57
|
<ControlToggleButtonGroup
|
|
57
58
|
{ ...toggleButtonGroupProps }
|
|
58
|
-
value={
|
|
59
|
+
value={ value?.split( ' ' ) ?? [] }
|
|
59
60
|
onChange={ handleNonExclusiveToggle }
|
|
60
61
|
disabled={ disabled }
|
|
61
62
|
exclusive={ false }
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { type RefObject } from 'react';
|
|
2
2
|
import * as React from 'react';
|
|
3
|
+
import { type AngleUnit } from '@elementor/editor-controls';
|
|
3
4
|
import { Grid } from '@elementor/ui';
|
|
4
5
|
|
|
5
6
|
import { PropKeyProvider } from '../../../bound-prop-context';
|
|
@@ -12,9 +13,10 @@ type TransformAxisRowProps = {
|
|
|
12
13
|
bindValue: 'x' | 'y' | 'z';
|
|
13
14
|
startIcon: React.ReactNode;
|
|
14
15
|
anchorRef?: RefObject< HTMLDivElement | null >;
|
|
16
|
+
units?: AngleUnit[];
|
|
15
17
|
};
|
|
16
18
|
|
|
17
|
-
export const AxisRow = ( { label, bindValue, startIcon, anchorRef }: TransformAxisRowProps ) => {
|
|
19
|
+
export const AxisRow = ( { label, bindValue, startIcon, anchorRef, units }: TransformAxisRowProps ) => {
|
|
18
20
|
return (
|
|
19
21
|
<Grid item xs={ 12 }>
|
|
20
22
|
<PopoverGridContainer ref={ anchorRef }>
|
|
@@ -23,7 +25,7 @@ export const AxisRow = ( { label, bindValue, startIcon, anchorRef }: TransformAx
|
|
|
23
25
|
</Grid>
|
|
24
26
|
<Grid item xs={ 6 }>
|
|
25
27
|
<PropKeyProvider bind={ bindValue }>
|
|
26
|
-
<SizeControl anchorRef={ anchorRef } startIcon={ startIcon } />
|
|
28
|
+
<SizeControl anchorRef={ anchorRef } startIcon={ startIcon } units={ units } variant="angle" />
|
|
27
29
|
</PropKeyProvider>
|
|
28
30
|
</Grid>
|
|
29
31
|
</PopoverGridContainer>
|
|
@@ -6,6 +6,7 @@ import { Grid } from '@elementor/ui';
|
|
|
6
6
|
import { __ } from '@wordpress/i18n';
|
|
7
7
|
|
|
8
8
|
import { PropKeyProvider, PropProvider, useBoundProp } from '../../../bound-prop-context';
|
|
9
|
+
import { TransformFunctionKeys } from '../types';
|
|
9
10
|
import { AxisRow } from './axis-row';
|
|
10
11
|
|
|
11
12
|
const moveAxisControls: { label: string; bindValue: 'x' | 'y' | 'z'; startIcon: React.ReactNode }[] = [
|
|
@@ -33,7 +34,7 @@ export const Move = () => {
|
|
|
33
34
|
return (
|
|
34
35
|
<Grid container spacing={ 1.5 }>
|
|
35
36
|
<PropProvider { ...context }>
|
|
36
|
-
<PropKeyProvider bind={
|
|
37
|
+
<PropKeyProvider bind={ TransformFunctionKeys.move }>
|
|
37
38
|
{ moveAxisControls.map( ( control ) => (
|
|
38
39
|
<AxisRow key={ control.bindValue } { ...control } anchorRef={ rowRef } />
|
|
39
40
|
) ) }
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { useRef } from 'react';
|
|
3
|
+
import { rotateTransformPropTypeUtil } from '@elementor/editor-props';
|
|
4
|
+
import { Arrow360Icon, RotateClockwiseIcon } from '@elementor/icons';
|
|
5
|
+
import { Grid } from '@elementor/ui';
|
|
6
|
+
import { __ } from '@wordpress/i18n';
|
|
7
|
+
|
|
8
|
+
import { PropKeyProvider, PropProvider, useBoundProp } from '../../../bound-prop-context';
|
|
9
|
+
import { type AngleUnit } from '../../../utils/size-control';
|
|
10
|
+
import { TransformFunctionKeys } from '../types';
|
|
11
|
+
import { AxisRow } from './axis-row';
|
|
12
|
+
|
|
13
|
+
const rotateAxisControls: { label: string; bindValue: 'x' | 'y' | 'z'; startIcon: React.ReactNode }[] = [
|
|
14
|
+
{
|
|
15
|
+
label: __( 'Rotate X', 'elementor' ),
|
|
16
|
+
bindValue: 'x',
|
|
17
|
+
startIcon: <Arrow360Icon fontSize={ 'tiny' } />,
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
label: __( 'Rotate Y', 'elementor' ),
|
|
21
|
+
bindValue: 'y',
|
|
22
|
+
startIcon: <Arrow360Icon fontSize="tiny" style={ { transform: 'scaleX(-1) rotate(-90deg)' } } />,
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
label: __( 'Rotate Z', 'elementor' ),
|
|
26
|
+
bindValue: 'z',
|
|
27
|
+
startIcon: <RotateClockwiseIcon fontSize={ 'tiny' } />,
|
|
28
|
+
},
|
|
29
|
+
];
|
|
30
|
+
|
|
31
|
+
const rotateUnits: AngleUnit[] = [ 'deg', 'rad', 'grad', 'turn' ];
|
|
32
|
+
|
|
33
|
+
export const Rotate = () => {
|
|
34
|
+
const context = useBoundProp( rotateTransformPropTypeUtil );
|
|
35
|
+
const rowRef = useRef< HTMLDivElement >( null );
|
|
36
|
+
|
|
37
|
+
return (
|
|
38
|
+
<Grid container spacing={ 1.5 }>
|
|
39
|
+
<PropProvider { ...context }>
|
|
40
|
+
<PropKeyProvider bind={ TransformFunctionKeys.rotate }>
|
|
41
|
+
{ rotateAxisControls.map( ( control ) => (
|
|
42
|
+
<AxisRow key={ control.bindValue } { ...control } anchorRef={ rowRef } units={ rotateUnits } />
|
|
43
|
+
) ) }
|
|
44
|
+
</PropKeyProvider>
|
|
45
|
+
</PropProvider>
|
|
46
|
+
</Grid>
|
|
47
|
+
);
|
|
48
|
+
};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { type RefObject } from 'react';
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
import { Grid } from '@elementor/ui';
|
|
4
|
+
|
|
5
|
+
import { PropKeyProvider } from '../../../bound-prop-context';
|
|
6
|
+
import { ControlLabel } from '../../../components/control-label';
|
|
7
|
+
import { PopoverGridContainer } from '../../../components/popover-grid-container';
|
|
8
|
+
import { NumberControl } from '../../number-control';
|
|
9
|
+
|
|
10
|
+
type ScaleAxisRowProps = {
|
|
11
|
+
label: string;
|
|
12
|
+
bindValue: 'x' | 'y' | 'z';
|
|
13
|
+
startIcon: React.ReactNode;
|
|
14
|
+
anchorRef?: RefObject< HTMLDivElement | null >;
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
export const ScaleAxisRow = ( { label, bindValue, startIcon, anchorRef }: ScaleAxisRowProps ) => {
|
|
18
|
+
return (
|
|
19
|
+
<Grid item xs={ 12 }>
|
|
20
|
+
<PopoverGridContainer ref={ anchorRef }>
|
|
21
|
+
<Grid item xs={ 6 }>
|
|
22
|
+
<ControlLabel>{ label }</ControlLabel>
|
|
23
|
+
</Grid>
|
|
24
|
+
<Grid item xs={ 6 }>
|
|
25
|
+
<PropKeyProvider bind={ bindValue }>
|
|
26
|
+
<NumberControl step={ 0.1 } placeholder="1" startIcon={ startIcon } />
|
|
27
|
+
</PropKeyProvider>
|
|
28
|
+
</Grid>
|
|
29
|
+
</PopoverGridContainer>
|
|
30
|
+
</Grid>
|
|
31
|
+
);
|
|
32
|
+
};
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { useRef } from 'react';
|
|
3
|
+
import { scaleTransformPropTypeUtil } from '@elementor/editor-props';
|
|
4
|
+
import { ArrowDownLeftIcon, ArrowDownSmallIcon, ArrowRightIcon } from '@elementor/icons';
|
|
5
|
+
import { Grid } from '@elementor/ui';
|
|
6
|
+
import { __ } from '@wordpress/i18n';
|
|
7
|
+
|
|
8
|
+
import { PropKeyProvider, PropProvider, useBoundProp } from '../../../bound-prop-context';
|
|
9
|
+
import { TransformFunctionKeys } from '../types';
|
|
10
|
+
import { ScaleAxisRow } from './scale-axis-row';
|
|
11
|
+
|
|
12
|
+
const scaleAxisControls: { label: string; bindValue: 'x' | 'y' | 'z'; startIcon: React.ReactNode }[] = [
|
|
13
|
+
{
|
|
14
|
+
label: __( 'Scale X', 'elementor' ),
|
|
15
|
+
bindValue: 'x',
|
|
16
|
+
startIcon: <ArrowRightIcon fontSize={ 'tiny' } />,
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
label: __( 'Scale Y', 'elementor' ),
|
|
20
|
+
bindValue: 'y',
|
|
21
|
+
startIcon: <ArrowDownSmallIcon fontSize={ 'tiny' } />,
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
label: __( 'Scale Z', 'elementor' ),
|
|
25
|
+
bindValue: 'z',
|
|
26
|
+
startIcon: <ArrowDownLeftIcon fontSize={ 'tiny' } />,
|
|
27
|
+
},
|
|
28
|
+
];
|
|
29
|
+
|
|
30
|
+
export const Scale = () => {
|
|
31
|
+
const context = useBoundProp( scaleTransformPropTypeUtil );
|
|
32
|
+
const rowRef = useRef< HTMLDivElement >( null );
|
|
33
|
+
|
|
34
|
+
return (
|
|
35
|
+
<Grid container spacing={ 1.5 }>
|
|
36
|
+
<PropProvider { ...context }>
|
|
37
|
+
<PropKeyProvider bind={ TransformFunctionKeys.scale }>
|
|
38
|
+
{ scaleAxisControls.map( ( control ) => (
|
|
39
|
+
<ScaleAxisRow key={ control.bindValue } { ...control } anchorRef={ rowRef } />
|
|
40
|
+
) ) }
|
|
41
|
+
</PropKeyProvider>
|
|
42
|
+
</PropProvider>
|
|
43
|
+
</Grid>
|
|
44
|
+
);
|
|
45
|
+
};
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { useRef } from 'react';
|
|
3
|
+
import { skewTransformPropTypeUtil } from '@elementor/editor-props';
|
|
4
|
+
import { ArrowLeftIcon, ArrowRightIcon } from '@elementor/icons';
|
|
5
|
+
import { Grid } from '@elementor/ui';
|
|
6
|
+
import { __ } from '@wordpress/i18n';
|
|
7
|
+
|
|
8
|
+
import { PropKeyProvider, PropProvider, useBoundProp } from '../../../bound-prop-context';
|
|
9
|
+
import { type AngleUnit } from '../../../utils/size-control';
|
|
10
|
+
import { TransformFunctionKeys } from '../types';
|
|
11
|
+
import { AxisRow } from './axis-row';
|
|
12
|
+
|
|
13
|
+
const skewAxisControls: { label: string; bindValue: 'x' | 'y'; startIcon: React.ReactNode }[] = [
|
|
14
|
+
{
|
|
15
|
+
label: __( 'Skew X', 'elementor' ),
|
|
16
|
+
bindValue: 'x',
|
|
17
|
+
startIcon: <ArrowRightIcon fontSize={ 'tiny' } />,
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
label: __( 'Skew Y', 'elementor' ),
|
|
21
|
+
bindValue: 'y',
|
|
22
|
+
startIcon: <ArrowLeftIcon fontSize="tiny" style={ { transform: 'scaleX(-1) rotate(-90deg)' } } />,
|
|
23
|
+
},
|
|
24
|
+
];
|
|
25
|
+
|
|
26
|
+
const skewUnits: AngleUnit[] = [ 'deg', 'rad', 'grad', 'turn' ];
|
|
27
|
+
|
|
28
|
+
export const Skew = () => {
|
|
29
|
+
const context = useBoundProp( skewTransformPropTypeUtil );
|
|
30
|
+
const rowRef = useRef< HTMLDivElement >( null );
|
|
31
|
+
|
|
32
|
+
return (
|
|
33
|
+
<Grid container spacing={ 1.5 }>
|
|
34
|
+
<PropProvider { ...context }>
|
|
35
|
+
<PropKeyProvider bind={ TransformFunctionKeys.skew }>
|
|
36
|
+
{ skewAxisControls.map( ( control ) => (
|
|
37
|
+
<AxisRow key={ control.bindValue } { ...control } anchorRef={ rowRef } units={ skewUnits } />
|
|
38
|
+
) ) }
|
|
39
|
+
</PropKeyProvider>
|
|
40
|
+
</PropProvider>
|
|
41
|
+
</Grid>
|
|
42
|
+
);
|
|
43
|
+
};
|
|
@@ -1,36 +1,73 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import type
|
|
3
|
-
import { Box, Tab, TabPanel, Tabs
|
|
2
|
+
import { type PropKey } from '@elementor/editor-props';
|
|
3
|
+
import { Box, Tab, TabPanel, Tabs } from '@elementor/ui';
|
|
4
4
|
import { __ } from '@wordpress/i18n';
|
|
5
5
|
|
|
6
6
|
import { PropKeyProvider } from '../../bound-prop-context';
|
|
7
7
|
import { PopoverContent } from '../../components/popover-content';
|
|
8
8
|
import { Move } from './functions/move';
|
|
9
|
-
|
|
10
|
-
|
|
9
|
+
import { Rotate } from './functions/rotate';
|
|
10
|
+
import { Scale } from './functions/scale';
|
|
11
|
+
import { Skew } from './functions/skew';
|
|
12
|
+
import {
|
|
13
|
+
initialRotateValue,
|
|
14
|
+
initialScaleValue,
|
|
15
|
+
initialSkewValue,
|
|
16
|
+
initialTransformValue,
|
|
17
|
+
TransformFunctionKeys,
|
|
18
|
+
} from './types';
|
|
19
|
+
import { useTransformTabsHistory } from './use-transform-tabs-history';
|
|
11
20
|
|
|
12
21
|
export const TransformContent = ( { bind }: { anchorEl?: HTMLElement | null; bind: PropKey } ) => {
|
|
13
|
-
const { getTabsProps, getTabProps, getTabPanelProps } = useTabs< TransformTabValue >( 'transform-move' );
|
|
14
|
-
|
|
15
22
|
return (
|
|
16
23
|
<PropKeyProvider bind={ bind }>
|
|
17
|
-
<
|
|
18
|
-
<Box sx={ { width: '100%' } }>
|
|
19
|
-
<Box sx={ { borderBottom: 1, borderColor: 'divider' } }>
|
|
20
|
-
<Tabs
|
|
21
|
-
size="small"
|
|
22
|
-
variant="fullWidth"
|
|
23
|
-
{ ...getTabsProps() }
|
|
24
|
-
aria-label={ __( 'Transform', 'elementor' ) }
|
|
25
|
-
>
|
|
26
|
-
<Tab label={ __( 'Move', 'elementor' ) } { ...getTabProps( 'transform-move' ) } />
|
|
27
|
-
</Tabs>
|
|
28
|
-
</Box>
|
|
29
|
-
<TabPanel sx={ { p: 1.5 } } { ...getTabPanelProps( 'transform-move' ) }>
|
|
30
|
-
<Move />
|
|
31
|
-
</TabPanel>
|
|
32
|
-
</Box>
|
|
33
|
-
</PopoverContent>
|
|
24
|
+
<Content />
|
|
34
25
|
</PropKeyProvider>
|
|
35
26
|
);
|
|
36
27
|
};
|
|
28
|
+
|
|
29
|
+
const Content = () => {
|
|
30
|
+
const { getTabsProps, getTabProps, getTabPanelProps } = useTransformTabsHistory( {
|
|
31
|
+
move: initialTransformValue.value,
|
|
32
|
+
scale: initialScaleValue.value,
|
|
33
|
+
rotate: initialRotateValue.value,
|
|
34
|
+
skew: initialSkewValue.value,
|
|
35
|
+
} );
|
|
36
|
+
|
|
37
|
+
return (
|
|
38
|
+
<PopoverContent>
|
|
39
|
+
<Box sx={ { width: '100%' } }>
|
|
40
|
+
<Box sx={ { borderBottom: 1, borderColor: 'divider' } }>
|
|
41
|
+
<Tabs
|
|
42
|
+
size="small"
|
|
43
|
+
variant="fullWidth"
|
|
44
|
+
sx={ {
|
|
45
|
+
'& .MuiTab-root': {
|
|
46
|
+
minWidth: '62px',
|
|
47
|
+
},
|
|
48
|
+
} }
|
|
49
|
+
{ ...getTabsProps() }
|
|
50
|
+
aria-label={ __( 'Transform', 'elementor' ) }
|
|
51
|
+
>
|
|
52
|
+
<Tab label={ __( 'Move', 'elementor' ) } { ...getTabProps( TransformFunctionKeys.move ) } />
|
|
53
|
+
<Tab label={ __( 'Scale', 'elementor' ) } { ...getTabProps( TransformFunctionKeys.scale ) } />
|
|
54
|
+
<Tab label={ __( 'Rotate', 'elementor' ) } { ...getTabProps( TransformFunctionKeys.rotate ) } />
|
|
55
|
+
<Tab label={ __( 'Skew', 'elementor' ) } { ...getTabProps( TransformFunctionKeys.skew ) } />
|
|
56
|
+
</Tabs>
|
|
57
|
+
</Box>
|
|
58
|
+
<TabPanel sx={ { p: 1.5 } } { ...getTabPanelProps( TransformFunctionKeys.move ) }>
|
|
59
|
+
<Move />
|
|
60
|
+
</TabPanel>
|
|
61
|
+
<TabPanel sx={ { p: 1.5 } } { ...getTabPanelProps( TransformFunctionKeys.scale ) }>
|
|
62
|
+
<Scale />
|
|
63
|
+
</TabPanel>
|
|
64
|
+
<TabPanel sx={ { p: 1.5 } } { ...getTabPanelProps( TransformFunctionKeys.rotate ) }>
|
|
65
|
+
<Rotate />
|
|
66
|
+
</TabPanel>
|
|
67
|
+
<TabPanel sx={ { p: 1.5 } } { ...getTabPanelProps( TransformFunctionKeys.skew ) }>
|
|
68
|
+
<Skew />
|
|
69
|
+
</TabPanel>
|
|
70
|
+
</Box>
|
|
71
|
+
</PopoverContent>
|
|
72
|
+
);
|
|
73
|
+
};
|
|
@@ -1,11 +1,19 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { type TransformItemPropValue } from '@elementor/editor-props';
|
|
3
|
-
import { ArrowsMaximizeIcon } from '@elementor/icons';
|
|
3
|
+
import { ArrowsMaximizeIcon, ExpandIcon, RotateClockwise2Icon, SkewXIcon } from '@elementor/icons';
|
|
4
|
+
|
|
5
|
+
import { TransformFunctionKeys } from './types';
|
|
4
6
|
|
|
5
7
|
export const TransformIcon = ( { value }: { value: TransformItemPropValue } ) => {
|
|
6
8
|
switch ( value.$$type ) {
|
|
7
|
-
case
|
|
9
|
+
case TransformFunctionKeys.move:
|
|
8
10
|
return <ArrowsMaximizeIcon fontSize="tiny" />;
|
|
11
|
+
case TransformFunctionKeys.scale:
|
|
12
|
+
return <ExpandIcon fontSize="tiny" />;
|
|
13
|
+
case TransformFunctionKeys.rotate:
|
|
14
|
+
return <RotateClockwise2Icon fontSize="tiny" />;
|
|
15
|
+
case TransformFunctionKeys.skew:
|
|
16
|
+
return <SkewXIcon fontSize="tiny" />;
|
|
9
17
|
default:
|
|
10
18
|
return null;
|
|
11
19
|
}
|
|
@@ -3,16 +3,53 @@ import type { TransformItemPropValue } from '@elementor/editor-props';
|
|
|
3
3
|
import { Box } from '@elementor/ui';
|
|
4
4
|
import { __ } from '@wordpress/i18n';
|
|
5
5
|
|
|
6
|
+
import { defaultValues, TransformFunctionKeys } from './types';
|
|
7
|
+
|
|
6
8
|
const transformMoveValue = ( value: TransformItemPropValue[ 'value' ] ) =>
|
|
7
9
|
Object.values( value )
|
|
8
|
-
.map( ( axis ) =>
|
|
10
|
+
.map( ( axis ) => {
|
|
11
|
+
const size = axis?.value?.size ?? defaultValues.move.size;
|
|
12
|
+
const unit = axis?.value?.unit ?? defaultValues.move.unit;
|
|
13
|
+
|
|
14
|
+
return `${ size }${ unit }`;
|
|
15
|
+
} )
|
|
16
|
+
.join( ', ' );
|
|
17
|
+
|
|
18
|
+
const transformScaleValue = ( value: TransformItemPropValue[ 'value' ] ) =>
|
|
19
|
+
Object.values( value )
|
|
20
|
+
.map( ( axis ) => axis?.value || defaultValues.scale )
|
|
21
|
+
.join( ', ' );
|
|
22
|
+
|
|
23
|
+
const transformRotateValue = ( value: TransformItemPropValue[ 'value' ] ) =>
|
|
24
|
+
Object.values( value )
|
|
25
|
+
.map( ( axis ) => {
|
|
26
|
+
const size = axis?.value?.size ?? defaultValues.rotate.size;
|
|
27
|
+
const unit = axis?.value?.unit ?? defaultValues.rotate.unit;
|
|
28
|
+
|
|
29
|
+
return `${ size }${ unit }`;
|
|
30
|
+
} )
|
|
31
|
+
.join( ', ' );
|
|
32
|
+
const transformSkewValue = ( value: TransformItemPropValue[ 'value' ] ) =>
|
|
33
|
+
Object.values( value )
|
|
34
|
+
.map( ( axis ) => {
|
|
35
|
+
const size = axis?.value?.size ?? defaultValues.skew.size;
|
|
36
|
+
const unit = axis?.value?.unit ?? defaultValues.skew.unit;
|
|
37
|
+
|
|
38
|
+
return `${ size }${ unit }`;
|
|
39
|
+
} )
|
|
9
40
|
.join( ', ' );
|
|
10
41
|
|
|
11
42
|
export const TransformLabel = ( props: { value: TransformItemPropValue } ) => {
|
|
12
43
|
const { $$type, value } = props.value;
|
|
13
44
|
switch ( $$type ) {
|
|
14
|
-
case
|
|
45
|
+
case TransformFunctionKeys.move:
|
|
15
46
|
return <Label label={ __( 'Move', 'elementor' ) } value={ transformMoveValue( value ) } />;
|
|
47
|
+
case TransformFunctionKeys.scale:
|
|
48
|
+
return <Label label={ __( 'Scale', 'elementor' ) } value={ transformScaleValue( value ) } />;
|
|
49
|
+
case TransformFunctionKeys.rotate:
|
|
50
|
+
return <Label label={ __( 'Rotate', 'elementor' ) } value={ transformRotateValue( value ) } />;
|
|
51
|
+
case TransformFunctionKeys.skew:
|
|
52
|
+
return <Label label={ __( 'Skew', 'elementor' ) } value={ transformSkewValue( value ) } />;
|
|
16
53
|
default:
|
|
17
54
|
return '';
|
|
18
55
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import {
|
|
2
|
+
import { transformPropTypeUtil } from '@elementor/editor-props';
|
|
3
3
|
import { __ } from '@wordpress/i18n';
|
|
4
4
|
|
|
5
5
|
import { PropProvider, useBoundProp } from '../../bound-prop-context';
|
|
@@ -8,15 +8,7 @@ import { createControl } from '../../create-control';
|
|
|
8
8
|
import { TransformContent } from './transform-content';
|
|
9
9
|
import { TransformIcon } from './transform-icon';
|
|
10
10
|
import { TransformLabel } from './transform-label';
|
|
11
|
-
|
|
12
|
-
const initialTransformValue: TransformItemPropValue = {
|
|
13
|
-
$$type: 'transform-move',
|
|
14
|
-
value: {
|
|
15
|
-
x: { $$type: 'size', value: { size: 0, unit: 'px' } },
|
|
16
|
-
y: { $$type: 'size', value: { size: 0, unit: 'px' } },
|
|
17
|
-
z: { $$type: 'size', value: { size: 0, unit: 'px' } },
|
|
18
|
-
},
|
|
19
|
-
};
|
|
11
|
+
import { initialTransformValue } from './types';
|
|
20
12
|
|
|
21
13
|
export const TransformRepeaterControl = createControl( () => {
|
|
22
14
|
const { propType, value: transformValues, setValue, disabled } = useBoundProp( transformPropTypeUtil );
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import {
|
|
2
|
+
numberPropTypeUtil,
|
|
3
|
+
rotateTransformPropTypeUtil,
|
|
4
|
+
scaleTransformPropTypeUtil,
|
|
5
|
+
skewTransformPropTypeUtil,
|
|
6
|
+
type TransformItemPropValue,
|
|
7
|
+
} from '@elementor/editor-props';
|
|
8
|
+
|
|
9
|
+
export type TransformFunction = 'transform-move' | 'transform-scale' | 'transform-rotate' | 'transform-skew';
|
|
10
|
+
|
|
11
|
+
export const TransformFunctionKeys: Record< string, TransformFunction > = {
|
|
12
|
+
move: 'transform-move',
|
|
13
|
+
scale: 'transform-scale',
|
|
14
|
+
rotate: 'transform-rotate',
|
|
15
|
+
skew: 'transform-skew',
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
export const defaultValues = {
|
|
19
|
+
move: {
|
|
20
|
+
size: 0,
|
|
21
|
+
unit: 'px',
|
|
22
|
+
},
|
|
23
|
+
scale: 1,
|
|
24
|
+
rotate: {
|
|
25
|
+
size: 0,
|
|
26
|
+
unit: 'deg',
|
|
27
|
+
},
|
|
28
|
+
skew: {
|
|
29
|
+
size: 0,
|
|
30
|
+
unit: 'deg',
|
|
31
|
+
},
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
export const initialTransformValue: TransformItemPropValue = {
|
|
35
|
+
$$type: TransformFunctionKeys.move,
|
|
36
|
+
value: {
|
|
37
|
+
x: { $$type: 'size', value: { size: defaultValues.move.size, unit: defaultValues.move.unit as 'px' } },
|
|
38
|
+
y: { $$type: 'size', value: { size: defaultValues.move.size, unit: defaultValues.move.unit as 'px' } },
|
|
39
|
+
z: { $$type: 'size', value: { size: defaultValues.move.size, unit: defaultValues.move.unit as 'px' } },
|
|
40
|
+
},
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
export const initialScaleValue = scaleTransformPropTypeUtil.create( {
|
|
44
|
+
x: numberPropTypeUtil.create( defaultValues.scale ),
|
|
45
|
+
y: numberPropTypeUtil.create( defaultValues.scale ),
|
|
46
|
+
z: numberPropTypeUtil.create( defaultValues.scale ),
|
|
47
|
+
} );
|
|
48
|
+
|
|
49
|
+
export const initialRotateValue = rotateTransformPropTypeUtil.create( {
|
|
50
|
+
x: { $$type: 'size', value: { size: defaultValues.rotate.size, unit: defaultValues.rotate.unit as 'deg' } },
|
|
51
|
+
y: { $$type: 'size', value: { size: defaultValues.rotate.size, unit: defaultValues.rotate.unit as 'deg' } },
|
|
52
|
+
z: { $$type: 'size', value: { size: defaultValues.rotate.size, unit: defaultValues.rotate.unit as 'deg' } },
|
|
53
|
+
} );
|
|
54
|
+
|
|
55
|
+
export const initialSkewValue = skewTransformPropTypeUtil.create( {
|
|
56
|
+
x: { $$type: 'size', value: { size: defaultValues.skew.size, unit: defaultValues.skew.unit as 'deg' } },
|
|
57
|
+
y: { $$type: 'size', value: { size: defaultValues.skew.size, unit: defaultValues.skew.unit as 'deg' } },
|
|
58
|
+
} );
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import { useRef } from 'react';
|
|
2
|
+
import {
|
|
3
|
+
moveTransformPropTypeUtil,
|
|
4
|
+
type MoveTransformPropValue,
|
|
5
|
+
rotateTransformPropTypeUtil,
|
|
6
|
+
type RotateTransformPropValue,
|
|
7
|
+
scaleTransformPropTypeUtil,
|
|
8
|
+
type ScaleTransformPropValue,
|
|
9
|
+
skewTransformPropTypeUtil,
|
|
10
|
+
type SkewTransformPropValue,
|
|
11
|
+
type TransformItemPropValue,
|
|
12
|
+
} from '@elementor/editor-props';
|
|
13
|
+
import { useTabs } from '@elementor/ui';
|
|
14
|
+
|
|
15
|
+
import { useBoundProp } from '../../bound-prop-context';
|
|
16
|
+
import { type TransformFunction, TransformFunctionKeys } from './types';
|
|
17
|
+
|
|
18
|
+
type InitialTransformValues = {
|
|
19
|
+
move: TransformItemPropValue[ 'value' ];
|
|
20
|
+
scale: TransformItemPropValue[ 'value' ];
|
|
21
|
+
rotate: TransformItemPropValue[ 'value' ];
|
|
22
|
+
skew: TransformItemPropValue[ 'value' ];
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
export const useTransformTabsHistory = ( {
|
|
26
|
+
move: initialMove,
|
|
27
|
+
scale: initialScale,
|
|
28
|
+
rotate: initialRotate,
|
|
29
|
+
skew: initialSkew,
|
|
30
|
+
}: InitialTransformValues ) => {
|
|
31
|
+
const { value: moveValue, setValue: setMoveValue } = useBoundProp( moveTransformPropTypeUtil );
|
|
32
|
+
const { value: scaleValue, setValue: setScaleValue } = useBoundProp( scaleTransformPropTypeUtil );
|
|
33
|
+
const { value: rotateValue, setValue: setRotateValue } = useBoundProp( rotateTransformPropTypeUtil );
|
|
34
|
+
const { value: skewValue, setValue: setSkewValue } = useBoundProp( skewTransformPropTypeUtil );
|
|
35
|
+
|
|
36
|
+
const getCurrentTransformType = (): TransformFunction => {
|
|
37
|
+
switch ( true ) {
|
|
38
|
+
case !! scaleValue:
|
|
39
|
+
return TransformFunctionKeys.scale;
|
|
40
|
+
case !! rotateValue:
|
|
41
|
+
return TransformFunctionKeys.rotate;
|
|
42
|
+
case !! skewValue:
|
|
43
|
+
return TransformFunctionKeys.skew;
|
|
44
|
+
default:
|
|
45
|
+
return TransformFunctionKeys.move;
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
const { getTabsProps, getTabProps, getTabPanelProps } = useTabs< TransformFunction >( getCurrentTransformType() );
|
|
50
|
+
|
|
51
|
+
const valuesHistory = useRef< InitialTransformValues >( {
|
|
52
|
+
move: initialMove,
|
|
53
|
+
scale: initialScale,
|
|
54
|
+
rotate: initialRotate,
|
|
55
|
+
skew: initialSkew,
|
|
56
|
+
} );
|
|
57
|
+
|
|
58
|
+
const saveToHistory = ( key: keyof InitialTransformValues, value: TransformItemPropValue[ 'value' ] ) => {
|
|
59
|
+
if ( value ) {
|
|
60
|
+
valuesHistory.current[ key ] = value;
|
|
61
|
+
}
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
const onTabChange = ( e: React.SyntheticEvent, tabName: TransformFunction ) => {
|
|
65
|
+
switch ( tabName ) {
|
|
66
|
+
case TransformFunctionKeys.move:
|
|
67
|
+
setMoveValue( valuesHistory.current.move as MoveTransformPropValue[ 'value' ] );
|
|
68
|
+
saveToHistory( 'scale', scaleValue );
|
|
69
|
+
saveToHistory( 'rotate', rotateValue );
|
|
70
|
+
saveToHistory( 'skew', skewValue );
|
|
71
|
+
|
|
72
|
+
break;
|
|
73
|
+
|
|
74
|
+
case TransformFunctionKeys.scale:
|
|
75
|
+
setScaleValue( valuesHistory.current.scale as ScaleTransformPropValue[ 'value' ] );
|
|
76
|
+
saveToHistory( 'move', moveValue );
|
|
77
|
+
saveToHistory( 'rotate', rotateValue );
|
|
78
|
+
saveToHistory( 'skew', skewValue );
|
|
79
|
+
|
|
80
|
+
break;
|
|
81
|
+
|
|
82
|
+
case TransformFunctionKeys.rotate:
|
|
83
|
+
setRotateValue( valuesHistory.current.rotate as RotateTransformPropValue[ 'value' ] );
|
|
84
|
+
saveToHistory( 'move', moveValue );
|
|
85
|
+
saveToHistory( 'scale', scaleValue );
|
|
86
|
+
saveToHistory( 'skew', skewValue );
|
|
87
|
+
|
|
88
|
+
break;
|
|
89
|
+
|
|
90
|
+
case TransformFunctionKeys.skew:
|
|
91
|
+
setSkewValue( valuesHistory.current.skew as SkewTransformPropValue[ 'value' ] );
|
|
92
|
+
saveToHistory( 'move', moveValue );
|
|
93
|
+
saveToHistory( 'scale', scaleValue );
|
|
94
|
+
saveToHistory( 'rotate', rotateValue );
|
|
95
|
+
|
|
96
|
+
break;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
return getTabsProps().onChange( e, tabName );
|
|
100
|
+
};
|
|
101
|
+
|
|
102
|
+
return {
|
|
103
|
+
getTabProps,
|
|
104
|
+
getTabPanelProps,
|
|
105
|
+
getTabsProps: () => ( { ...getTabsProps(), onChange: onTabChange } ),
|
|
106
|
+
};
|
|
107
|
+
};
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
export type TransitionProperty = {
|
|
2
|
+
label: string;
|
|
3
|
+
value: string;
|
|
4
|
+
};
|
|
5
|
+
|
|
6
|
+
export type TransitionCategory = {
|
|
7
|
+
label: string;
|
|
8
|
+
type: 'category';
|
|
9
|
+
properties: TransitionProperty[];
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
export const initialTransitionValue = {
|
|
13
|
+
selection: {
|
|
14
|
+
$$type: 'key-value',
|
|
15
|
+
value: {
|
|
16
|
+
key: { value: 'All properties', $$type: 'string' },
|
|
17
|
+
value: { value: 'all', $$type: 'string' },
|
|
18
|
+
},
|
|
19
|
+
},
|
|
20
|
+
size: { $$type: 'size', value: { size: 200, unit: 'ms' } },
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
export const transitionProperties: TransitionCategory[] = [
|
|
24
|
+
{
|
|
25
|
+
label: 'Common',
|
|
26
|
+
type: 'category',
|
|
27
|
+
properties: [ { label: 'All properties', value: 'all' } ],
|
|
28
|
+
},
|
|
29
|
+
];
|
|
30
|
+
|
|
31
|
+
export const transitionsItemsList = transitionProperties.map( ( category ) => ( {
|
|
32
|
+
label: category.label,
|
|
33
|
+
items: category.properties.map( ( property ) => property.label ),
|
|
34
|
+
} ) );
|