@elementor/editor-controls 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 +26 -0
- package/dist/index.d.mts +7 -3
- package/dist/index.d.ts +7 -3
- package/dist/index.js +645 -415
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +570 -341
- package/dist/index.mjs.map +1 -1
- package/package.json +7 -7
- package/src/bound-prop-context/prop-context.tsx +3 -3
- package/src/bound-prop-context/prop-key-context.tsx +1 -0
- package/src/bound-prop-context/use-bound-prop.ts +5 -1
- package/src/components/text-field-popover.tsx +19 -18
- package/src/controls/background-control/background-overlay/background-overlay-repeater-control.tsx +3 -15
- package/src/controls/box-shadow-repeater-control.tsx +1 -1
- package/src/controls/equal-unequal-sizes-control.tsx +1 -1
- package/src/controls/font-family-control/font-family-control.tsx +14 -2
- package/src/controls/image-control.tsx +45 -16
- package/src/controls/link-control.tsx +25 -20
- package/src/controls/linked-dimensions-control.tsx +1 -1
- package/src/controls/repeatable-control.tsx +77 -17
- package/src/controls/select-control.tsx +22 -2
- package/src/controls/switch-control.tsx +9 -1
- package/src/controls/transform-control/functions/axis-row.tsx +32 -0
- package/src/controls/transform-control/functions/move.tsx +44 -0
- package/src/controls/transform-control/transform-content.tsx +36 -0
- package/src/controls/transform-control/transform-icon.tsx +12 -0
- package/src/controls/transform-control/transform-label.tsx +27 -0
- package/src/controls/transform-control/transform-repeater-control.tsx +42 -0
- package/src/hooks/use-repeatable-control-context.ts +6 -1
- package/src/index.ts +1 -0
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { useRef } from 'react';
|
|
3
|
+
import { moveTransformPropTypeUtil } 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 { AxisRow } from './axis-row';
|
|
10
|
+
|
|
11
|
+
const moveAxisControls: { label: string; bindValue: 'x' | 'y' | 'z'; startIcon: React.ReactNode }[] = [
|
|
12
|
+
{
|
|
13
|
+
label: __( 'Move X', 'elementor' ),
|
|
14
|
+
bindValue: 'x',
|
|
15
|
+
startIcon: <ArrowRightIcon fontSize={ 'tiny' } />,
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
label: __( 'Move Y', 'elementor' ),
|
|
19
|
+
bindValue: 'y',
|
|
20
|
+
startIcon: <ArrowDownSmallIcon fontSize={ 'tiny' } />,
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
label: __( 'Move Z', 'elementor' ),
|
|
24
|
+
bindValue: 'z',
|
|
25
|
+
startIcon: <ArrowDownLeftIcon fontSize={ 'tiny' } />,
|
|
26
|
+
},
|
|
27
|
+
];
|
|
28
|
+
|
|
29
|
+
export const Move = () => {
|
|
30
|
+
const context = useBoundProp( moveTransformPropTypeUtil );
|
|
31
|
+
const rowRef = useRef< HTMLDivElement >( null );
|
|
32
|
+
|
|
33
|
+
return (
|
|
34
|
+
<Grid container spacing={ 1.5 }>
|
|
35
|
+
<PropProvider { ...context }>
|
|
36
|
+
<PropKeyProvider bind={ 'transform-move' }>
|
|
37
|
+
{ moveAxisControls.map( ( control ) => (
|
|
38
|
+
<AxisRow key={ control.bindValue } { ...control } anchorRef={ rowRef } />
|
|
39
|
+
) ) }
|
|
40
|
+
</PropKeyProvider>
|
|
41
|
+
</PropProvider>
|
|
42
|
+
</Grid>
|
|
43
|
+
);
|
|
44
|
+
};
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import type { PropKey } from '@elementor/editor-props';
|
|
3
|
+
import { Box, Tab, TabPanel, Tabs, useTabs } from '@elementor/ui';
|
|
4
|
+
import { __ } from '@wordpress/i18n';
|
|
5
|
+
|
|
6
|
+
import { PropKeyProvider } from '../../bound-prop-context';
|
|
7
|
+
import { PopoverContent } from '../../components/popover-content';
|
|
8
|
+
import { Move } from './functions/move';
|
|
9
|
+
|
|
10
|
+
type TransformTabValue = 'transform-move';
|
|
11
|
+
|
|
12
|
+
export const TransformContent = ( { bind }: { anchorEl?: HTMLElement | null; bind: PropKey } ) => {
|
|
13
|
+
const { getTabsProps, getTabProps, getTabPanelProps } = useTabs< TransformTabValue >( 'transform-move' );
|
|
14
|
+
|
|
15
|
+
return (
|
|
16
|
+
<PropKeyProvider bind={ bind }>
|
|
17
|
+
<PopoverContent>
|
|
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>
|
|
34
|
+
</PropKeyProvider>
|
|
35
|
+
);
|
|
36
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { type TransformItemPropValue } from '@elementor/editor-props';
|
|
3
|
+
import { ArrowsMaximizeIcon } from '@elementor/icons';
|
|
4
|
+
|
|
5
|
+
export const TransformIcon = ( { value }: { value: TransformItemPropValue } ) => {
|
|
6
|
+
switch ( value.$$type ) {
|
|
7
|
+
case 'transform-move':
|
|
8
|
+
return <ArrowsMaximizeIcon fontSize="tiny" />;
|
|
9
|
+
default:
|
|
10
|
+
return null;
|
|
11
|
+
}
|
|
12
|
+
};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import type { TransformItemPropValue } from '@elementor/editor-props';
|
|
3
|
+
import { Box } from '@elementor/ui';
|
|
4
|
+
import { __ } from '@wordpress/i18n';
|
|
5
|
+
|
|
6
|
+
const transformMoveValue = ( value: TransformItemPropValue[ 'value' ] ) =>
|
|
7
|
+
Object.values( value )
|
|
8
|
+
.map( ( axis ) => `${ axis?.value.size }${ axis?.value.unit }` )
|
|
9
|
+
.join( ', ' );
|
|
10
|
+
|
|
11
|
+
export const TransformLabel = ( props: { value: TransformItemPropValue } ) => {
|
|
12
|
+
const { $$type, value } = props.value;
|
|
13
|
+
switch ( $$type ) {
|
|
14
|
+
case 'transform-move':
|
|
15
|
+
return <Label label={ __( 'Move', 'elementor' ) } value={ transformMoveValue( value ) } />;
|
|
16
|
+
default:
|
|
17
|
+
return '';
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
const Label = ( { label, value }: { label: string; value: string } ) => {
|
|
22
|
+
return (
|
|
23
|
+
<Box component="span">
|
|
24
|
+
{ label }: { value }
|
|
25
|
+
</Box>
|
|
26
|
+
);
|
|
27
|
+
};
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { type TransformItemPropValue, transformPropTypeUtil } from '@elementor/editor-props';
|
|
3
|
+
import { __ } from '@wordpress/i18n';
|
|
4
|
+
|
|
5
|
+
import { PropProvider, useBoundProp } from '../../bound-prop-context';
|
|
6
|
+
import { Repeater } from '../../components/repeater';
|
|
7
|
+
import { createControl } from '../../create-control';
|
|
8
|
+
import { TransformContent } from './transform-content';
|
|
9
|
+
import { TransformIcon } from './transform-icon';
|
|
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
|
+
};
|
|
20
|
+
|
|
21
|
+
export const TransformRepeaterControl = createControl( () => {
|
|
22
|
+
const { propType, value: transformValues, setValue, disabled } = useBoundProp( transformPropTypeUtil );
|
|
23
|
+
|
|
24
|
+
return (
|
|
25
|
+
<PropProvider propType={ propType } value={ transformValues } setValue={ setValue }>
|
|
26
|
+
<Repeater
|
|
27
|
+
openOnAdd
|
|
28
|
+
disabled={ disabled }
|
|
29
|
+
values={ transformValues ?? [] }
|
|
30
|
+
setValues={ setValue }
|
|
31
|
+
label={ __( 'Transform', 'elementor' ) }
|
|
32
|
+
showDuplicate={ false }
|
|
33
|
+
itemSettings={ {
|
|
34
|
+
Icon: TransformIcon,
|
|
35
|
+
Label: TransformLabel,
|
|
36
|
+
Content: TransformContent,
|
|
37
|
+
initialValues: initialTransformValue,
|
|
38
|
+
} }
|
|
39
|
+
/>
|
|
40
|
+
</PropProvider>
|
|
41
|
+
);
|
|
42
|
+
} );
|
|
@@ -9,7 +9,12 @@ export type ChildControlConfig = {
|
|
|
9
9
|
label?: string;
|
|
10
10
|
};
|
|
11
11
|
|
|
12
|
-
|
|
12
|
+
type RepeatableControlContextType = ChildControlConfig & {
|
|
13
|
+
placeholder: string;
|
|
14
|
+
patternLabel: string;
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
const RepeatableControlContext = createContext< RepeatableControlContextType | undefined >( undefined );
|
|
13
18
|
|
|
14
19
|
const useRepeatableControlContext = () => {
|
|
15
20
|
const context = useContext( RepeatableControlContext );
|
package/src/index.ts
CHANGED
|
@@ -23,6 +23,7 @@ export { SwitchControl } from './controls/switch-control';
|
|
|
23
23
|
export { RepeatableControl } from './controls/repeatable-control';
|
|
24
24
|
export { KeyValueControl } from './controls/key-value-control';
|
|
25
25
|
export { PositionControl } from './controls/position-control';
|
|
26
|
+
export { TransformRepeaterControl } from './controls/transform-control/transform-repeater-control';
|
|
26
27
|
export { PopoverContent } from './components/popover-content';
|
|
27
28
|
|
|
28
29
|
// components
|