@elementor/editor-editing-panel 1.36.0 → 1.37.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@elementor/editor-editing-panel",
3
- "version": "1.36.0",
3
+ "version": "1.37.0",
4
4
  "private": false,
5
5
  "author": "Elementor Team",
6
6
  "homepage": "https://elementor.com/",
@@ -0,0 +1,34 @@
1
+ import * as React from 'react';
2
+ import { SelectControl } from '@elementor/editor-controls';
3
+ import { Grid } from '@elementor/ui';
4
+ import { __ } from '@wordpress/i18n';
5
+
6
+ import { StylesField } from '../../../controls-registry/styles-field';
7
+ import { ControlLabel } from '../../control-label';
8
+
9
+ const positionOptions = [
10
+ { label: __( 'Fill', 'elementor' ), value: 'fill' },
11
+ { label: __( 'Cover', 'elementor' ), value: 'cover' },
12
+ { label: __( 'Contain', 'elementor' ), value: 'contain' },
13
+ { label: __( 'None', 'elementor' ), value: 'none' },
14
+ { label: __( 'Scale down', 'elementor' ), value: 'scale-down' },
15
+ ];
16
+
17
+ type Props = {
18
+ onChange?: ( newValue: string | null, previousValue: string | null | undefined ) => void;
19
+ };
20
+
21
+ export const ObjectFitField = ( { onChange }: Props ) => {
22
+ return (
23
+ <StylesField bind="object-fit">
24
+ <Grid container pt={ 2 } gap={ 2 } alignItems="center" flexWrap="nowrap">
25
+ <Grid item xs={ 6 }>
26
+ <ControlLabel>{ __( 'Object fit', 'elementor' ) }</ControlLabel>
27
+ </Grid>
28
+ <Grid item xs={ 6 } sx={ { overflow: 'hidden' } }>
29
+ <SelectControl options={ positionOptions } onChange={ onChange } />
30
+ </Grid>
31
+ </Grid>
32
+ </StylesField>
33
+ );
34
+ };
@@ -0,0 +1,38 @@
1
+ import * as React from 'react';
2
+ import { SelectControl } from '@elementor/editor-controls';
3
+ import { Grid } from '@elementor/ui';
4
+ import { __ } from '@wordpress/i18n';
5
+
6
+ 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
+
21
+ type Props = {
22
+ onChange?: ( newValue: string | null, previousValue: string | null | undefined ) => void;
23
+ };
24
+
25
+ export const ObjectPositionField = ( { onChange }: Props ) => {
26
+ return (
27
+ <StylesField bind="object-position">
28
+ <Grid container pt={ 2 } gap={ 2 } alignItems="center" flexWrap="nowrap">
29
+ <Grid item xs={ 6 }>
30
+ <ControlLabel>{ __( 'Object position', 'elementor' ) }</ControlLabel>
31
+ </Grid>
32
+ <Grid item xs={ 6 } sx={ { overflow: 'hidden' } }>
33
+ <SelectControl options={ positionOptions } onChange={ onChange } />
34
+ </Grid>
35
+ </Grid>
36
+ </StylesField>
37
+ );
38
+ };
@@ -1,15 +1,33 @@
1
1
  import * as React from 'react';
2
2
  import { type ExtendedValue, SizeControl } from '@elementor/editor-controls';
3
+ import type { StringPropValue } from '@elementor/editor-props';
4
+ import { isExperimentActive } from '@elementor/editor-v1-adapters';
3
5
  import { Grid, Stack } from '@elementor/ui';
4
6
  import { __ } from '@wordpress/i18n';
5
7
 
6
8
  import { StylesField, type StylesFieldProps } from '../../../controls-registry/styles-field';
9
+ import { useStylesField } from '../../../hooks/use-styles-field';
10
+ import { CollapsibleContent } from '../../collapsible-content';
7
11
  import { ControlLabel } from '../../control-label';
8
12
  import { PanelDivider } from '../../panel-divider';
9
13
  import { SectionContent } from '../../section-content';
14
+ import { ObjectFitField } from './object-fit-field';
15
+ import { ObjectPositionField } from './object-position-field';
10
16
  import { OverflowField } from './overflow-field';
11
17
 
12
18
  export const SizeSection = () => {
19
+ const [ fitValue, setFitValue ] = useStylesField< StringPropValue >( 'object-fit' );
20
+ const isNotFill = fitValue && fitValue?.value !== 'fill';
21
+
22
+ const onFitChange = ( newFit: string | null, previousValue: string | null | undefined ) => {
23
+ if ( newFit && newFit !== previousValue ) {
24
+ setFitValue( {
25
+ value: newFit,
26
+ $$type: 'string',
27
+ } );
28
+ }
29
+ };
30
+ const isVersion330Active = isExperimentActive( 'e_v_3_30' );
13
31
  return (
14
32
  <SectionContent>
15
33
  <Grid container gap={ 2 } flexWrap="nowrap">
@@ -48,6 +66,14 @@ export const SizeSection = () => {
48
66
  <Stack>
49
67
  <OverflowField />
50
68
  </Stack>
69
+ { isVersion330Active && (
70
+ <CollapsibleContent>
71
+ <ObjectFitField onChange={ onFitChange } />
72
+ <Grid item xs={ 6 }>
73
+ { isNotFill && <ObjectPositionField /> }
74
+ </Grid>
75
+ </CollapsibleContent>
76
+ ) }
51
77
  </SectionContent>
52
78
  );
53
79
  };
@@ -1,12 +1,14 @@
1
1
  import { useState } from 'react';
2
+ import { isExperimentActive } from '@elementor/editor-v1-adapters';
2
3
  import { getSessionStorageItem, setSessionStorageItem } from '@elementor/session';
3
4
 
4
5
  import { useElement } from '../contexts/element-context';
5
6
 
6
7
  export const useStateByElement = < T >( key: string, initialValue: T ) => {
7
8
  const { element } = useElement();
9
+ const isFeatureActive = isExperimentActive( 'e_v_3_30' );
8
10
  const lookup = `elementor/editor-state/${ element.id }/${ key }`;
9
- const storedValue = getSessionStorageItem< T >( lookup );
11
+ const storedValue = isFeatureActive ? getSessionStorageItem< T >( lookup ) : initialValue;
10
12
  const [ value, setValue ] = useState( storedValue ?? initialValue );
11
13
 
12
14
  const doUpdate = ( newValue: T ) => {