@elementor/editor-controls 0.35.0 → 0.36.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,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": "0.35.0",
4
+ "version": "0.36.0",
5
5
  "private": false,
6
6
  "author": "Elementor Team",
7
7
  "homepage": "https://elementor.com/",
@@ -43,7 +43,7 @@
43
43
  "@elementor/editor-current-user": "0.5.0",
44
44
  "@elementor/editor-elements": "0.8.4",
45
45
  "@elementor/editor-props": "0.12.1",
46
- "@elementor/editor-ui": "0.10.1",
46
+ "@elementor/editor-ui": "0.11.0",
47
47
  "@elementor/editor-v1-adapters": "0.12.0",
48
48
  "@elementor/env": "0.3.5",
49
49
  "@elementor/http-client": "0.3.0",
@@ -1,6 +1,6 @@
1
1
  import * as React from 'react';
2
- import { FormLabel } from '@elementor/ui';
2
+ import { FormLabel, type FormLabelProps } from '@elementor/ui';
3
3
 
4
- export const ControlFormLabel = ( { children }: { children: React.ReactNode } ) => {
5
- return <FormLabel size="tiny">{ children }</FormLabel>;
4
+ export const ControlFormLabel = ( props: FormLabelProps ) => {
5
+ return <FormLabel size="tiny" { ...props } />;
6
6
  };
@@ -7,7 +7,7 @@ import { ControlFormLabel } from './control-form-label';
7
7
 
8
8
  export const ControlLabel = ( { children }: PropsWithChildren< object > ) => {
9
9
  return (
10
- <Stack direction="row" alignItems="center" justifyItems="start" gap={ 1 }>
10
+ <Stack direction="row" alignItems="center" justifyItems="start" gap={ 0.25 }>
11
11
  <ControlFormLabel>{ children }</ControlFormLabel>
12
12
  <ControlAdornments />
13
13
  </Stack>
@@ -1,11 +1,10 @@
1
1
  import { useEffect, useRef, useState } from 'react';
2
2
  import * as React from 'react';
3
- import { type FontCategory } from '@elementor/editor-controls';
4
- import { SearchIcon, TextIcon, XIcon } from '@elementor/icons';
3
+ import { PopoverHeader } from '@elementor/editor-ui';
4
+ import { SearchIcon, TextIcon } from '@elementor/icons';
5
5
  import {
6
6
  Box,
7
7
  Divider,
8
- IconButton,
9
8
  InputAdornment,
10
9
  Link,
11
10
  MenuList,
@@ -20,6 +19,7 @@ import { useVirtualizer } from '@tanstack/react-virtual';
20
19
  import { __ } from '@wordpress/i18n';
21
20
 
22
21
  import { enqueueFont } from '../controls/font-family-control/enqueue-font';
22
+ import { type FontCategory } from '../controls/font-family-control/font-family-control';
23
23
  import { type FontListItem, useFilteredFontFamilies } from '../hooks/use-filtered-font-families';
24
24
 
25
25
  const SIZE = 'tiny';
@@ -52,13 +52,11 @@ export const FontFamilySelector = ( {
52
52
 
53
53
  return (
54
54
  <Stack>
55
- <Stack direction="row" alignItems="center" pl={ 1.5 } pr={ 0.5 } py={ 1.5 }>
56
- <TextIcon fontSize={ SIZE } sx={ { mr: 0.5 } } />
57
- <Typography variant="subtitle2">{ __( 'Font Family', 'elementor' ) }</Typography>
58
- <IconButton size={ SIZE } sx={ { ml: 'auto' } } onClick={ handleClose }>
59
- <XIcon fontSize={ SIZE } />
60
- </IconButton>
61
- </Stack>
55
+ <PopoverHeader
56
+ title={ __( 'Font Family', 'elementor' ) }
57
+ onClose={ handleClose }
58
+ icon={ <TextIcon fontSize={ SIZE } /> }
59
+ />
62
60
 
63
61
  <Box px={ 1.5 } pb={ 1 }>
64
62
  <TextField
@@ -143,8 +143,6 @@ export const Repeater = < T, >( {
143
143
  } );
144
144
  };
145
145
 
146
- const ItemWrapper = disabled ? React.Fragment : SortableItem;
147
-
148
146
  return (
149
147
  <SectionContent>
150
148
  <Stack
@@ -178,7 +176,7 @@ export const Repeater = < T, >( {
178
176
  }
179
177
 
180
178
  return (
181
- <ItemWrapper id={ key } key={ `sortable-${ key }` }>
179
+ <SortableItem id={ key } key={ `sortable-${ key }` } disabled={ disabled }>
182
180
  <RepeaterItem
183
181
  disabled={ disabled }
184
182
  propDisabled={ value?.disabled }
@@ -202,7 +200,7 @@ export const Repeater = < T, >( {
202
200
  <itemSettings.Content { ...props } value={ value } bind={ String( index ) } />
203
201
  ) }
204
202
  </RepeaterItem>
205
- </ItemWrapper>
203
+ </SortableItem>
206
204
  );
207
205
  } ) }
208
206
  </SortableProvider>
@@ -23,12 +23,14 @@ export const SortableProvider = < T extends number >( props: UnstableSortablePro
23
23
  type SortableItemProps = {
24
24
  id: UnstableSortableItemProps[ 'id' ];
25
25
  children: React.ReactNode;
26
+ disabled?: boolean;
26
27
  };
27
28
 
28
- export const SortableItem = ( { id, children }: SortableItemProps ): React.ReactNode => {
29
+ export const SortableItem = ( { id, children, disabled }: SortableItemProps ): React.ReactNode => {
29
30
  return (
30
31
  <UnstableSortableItem
31
32
  id={ id }
33
+ disabled={ disabled }
32
34
  render={ ( {
33
35
  itemProps,
34
36
  triggerProps,
@@ -39,7 +41,7 @@ export const SortableItem = ( { id, children }: SortableItemProps ): React.React
39
41
  }: UnstableSortableItemRenderProps ) => {
40
42
  return (
41
43
  <StyledListItem { ...itemProps } style={ itemStyle }>
42
- <SortableTrigger { ...triggerProps } style={ triggerStyle } />
44
+ { ! disabled && <SortableTrigger { ...triggerProps } style={ triggerStyle } /> }
43
45
  { children }
44
46
  { showDropIndication && <StyledDivider style={ dropIndicationStyle } /> }
45
47
  </StyledListItem>
@@ -60,10 +60,11 @@ export const BackgroundImageOverlayPosition = () => {
60
60
  </Grid>
61
61
  <Grid item xs={ 6 } sx={ { display: 'flex', justifyContent: 'flex-end', overflow: 'hidden' } }>
62
62
  <Select
63
+ fullWidth
63
64
  size="tiny"
64
- value={ ( backgroundImageOffsetContext.value ? 'custom' : stringPropContext.value ) ?? '' }
65
65
  onChange={ handlePositionChange }
66
- fullWidth
66
+ disabled={ stringPropContext.disabled }
67
+ value={ ( backgroundImageOffsetContext.value ? 'custom' : stringPropContext.value ) ?? '' }
67
68
  >
68
69
  { backgroundPositionOptions.map( ( { label, value } ) => (
69
70
  <MenuListItem key={ value } value={ value ?? '' }>
@@ -74,10 +74,11 @@ export const BackgroundImageOverlaySize = () => {
74
74
  <ControlToggleButtonGroup
75
75
  exclusive
76
76
  items={ sizeControlOptions }
77
+ onChange={ handleSizeChange }
78
+ disabled={ stringPropContext.disabled }
77
79
  value={
78
80
  ( backgroundImageScaleContext.value ? 'custom' : stringPropContext.value ) as Sizes
79
81
  }
80
- onChange={ handleSizeChange }
81
82
  />
82
83
  </Grid>
83
84
  </PopoverGridContainer>
@@ -74,7 +74,7 @@ export const BackgroundOverlayRepeaterControl = createControl( () => {
74
74
  const { propType, value: overlayValues, setValue, disabled } = useBoundProp( backgroundOverlayPropTypeUtil );
75
75
 
76
76
  return (
77
- <PropProvider propType={ propType } value={ overlayValues } setValue={ setValue }>
77
+ <PropProvider propType={ propType } value={ overlayValues } setValue={ setValue } disabled={ disabled }>
78
78
  <Repeater
79
79
  openOnAdd
80
80
  disabled={ disabled }
@@ -16,7 +16,7 @@ export const BoxShadowRepeaterControl = createControl( () => {
16
16
  const { propType, value, setValue, disabled } = useBoundProp( boxShadowPropTypeUtil );
17
17
 
18
18
  return (
19
- <PropProvider propType={ propType } value={ value } setValue={ setValue }>
19
+ <PropProvider propType={ propType } value={ value } setValue={ setValue } disabled={ disabled }>
20
20
  <Repeater
21
21
  openOnAdd
22
22
  disabled={ disabled }
@@ -47,10 +47,10 @@ const ItemContent = ( { anchorEl, bind }: { anchorEl: HTMLElement | null; bind:
47
47
  };
48
48
 
49
49
  const Content = ( { anchorEl }: { anchorEl: HTMLElement | null } ) => {
50
- const { propType, value, setValue } = useBoundProp( shadowPropTypeUtil );
50
+ const context = useBoundProp( shadowPropTypeUtil );
51
51
 
52
52
  return (
53
- <PropProvider propType={ propType } value={ value } setValue={ setValue }>
53
+ <PropProvider { ...context }>
54
54
  <PopoverContent p={ 1.5 }>
55
55
  <PopoverGridContainer>
56
56
  <Control bind="color" label={ __( 'Color', 'elementor' ) }>
@@ -62,7 +62,7 @@ export function EqualUnequalSizesControl< TMultiPropType extends string, TPropVa
62
62
  disabled: multiSizeDisabled,
63
63
  } = useBoundProp( multiSizePropTypeUtil );
64
64
 
65
- const { value: sizeValue, setValue: setSizeValue, disabled: sizeDisabled } = useBoundProp( sizePropTypeUtil );
65
+ const { value: sizeValue, setValue: setSizeValue } = useBoundProp( sizePropTypeUtil );
66
66
 
67
67
  const splitEqualValue = () => {
68
68
  if ( ! sizeValue ) {
@@ -98,13 +98,19 @@ export function EqualUnequalSizesControl< TMultiPropType extends string, TPropVa
98
98
  return splitEqualValue() ?? null;
99
99
  };
100
100
 
101
+ const isShowingGeneralIndicator = ! isExperimentActive( 'e_v_3_30' ) || ! popupState.isOpen;
102
+
101
103
  const isMixed = !! multiSizeValue;
102
104
 
103
105
  return (
104
106
  <>
105
107
  <Grid container gap={ 2 } alignItems="center" flexWrap="nowrap" ref={ controlRef }>
106
108
  <Grid item xs={ 6 }>
107
- <ControlLabel>{ label }</ControlLabel>
109
+ { ! isShowingGeneralIndicator ? (
110
+ <ControlFormLabel>{ label }</ControlFormLabel>
111
+ ) : (
112
+ <ControlLabel>{ label }</ControlLabel>
113
+ ) }
108
114
  </Grid>
109
115
  <Grid item xs={ 6 }>
110
116
  <Stack direction="row" alignItems="center" gap={ 1 }>
@@ -117,7 +123,6 @@ export function EqualUnequalSizesControl< TMultiPropType extends string, TPropVa
117
123
  { ...bindToggle( popupState ) }
118
124
  selected={ popupState.isOpen }
119
125
  aria-label={ tooltipLabel }
120
- disabled={ multiSizeDisabled || sizeDisabled }
121
126
  >
122
127
  { icon }
123
128
  </ToggleButton>
@@ -141,7 +146,12 @@ export function EqualUnequalSizesControl< TMultiPropType extends string, TPropVa
141
146
  paper: { sx: { mt: 0.5, width: controlRef.current?.getBoundingClientRect().width } },
142
147
  } }
143
148
  >
144
- <PropProvider propType={ multiSizePropType } value={ getMultiSizeValues() } setValue={ setNestedProp }>
149
+ <PropProvider
150
+ propType={ multiSizePropType }
151
+ value={ getMultiSizeValues() }
152
+ setValue={ setNestedProp }
153
+ disabled={ multiSizeDisabled }
154
+ >
145
155
  <PopoverContent p={ 1.5 } pt={ 2.5 } pb={ 3 }>
146
156
  <PopoverGridContainer>
147
157
  <MultiSizeValueControl item={ items[ 0 ] } />
@@ -17,6 +17,8 @@ type FontFamilyControlProps = {
17
17
  fontFamilies: FontCategory[];
18
18
  };
19
19
 
20
+ const SIZE = 'tiny';
21
+
20
22
  export const FontFamilyControl = createControl( ( { fontFamilies }: FontFamilyControlProps ) => {
21
23
  const { value: fontFamily, setValue: setFontFamily, disabled } = useBoundProp( stringPropTypeUtil );
22
24
 
@@ -28,7 +30,7 @@ export const FontFamilyControl = createControl( ( { fontFamilies }: FontFamilyCo
28
30
  <UnstableTag
29
31
  variant="outlined"
30
32
  label={ fontFamily }
31
- endIcon={ <ChevronDownIcon fontSize="tiny" /> }
33
+ endIcon={ <ChevronDownIcon fontSize={ SIZE } /> }
32
34
  { ...bindTrigger( popoverState ) }
33
35
  fullWidth
34
36
  disabled={ disabled }
@@ -44,6 +44,8 @@ export const GapControl = createControl( ( { label }: { label: string } ) => {
44
44
  // translators: %s: Tooltip title.
45
45
  const unlinkedLabel = __( 'Unlink %s', 'elementor' ).replace( '%s', tooltipLabel );
46
46
 
47
+ const disabled = sizeDisabled || directionDisabled;
48
+
47
49
  return (
48
50
  <PropProvider propType={ propType } value={ directionValue } setValue={ setDirectionValue }>
49
51
  <Stack direction="row" gap={ 2 } flexWrap="nowrap">
@@ -56,7 +58,7 @@ export const GapControl = createControl( ( { label }: { label: string } ) => {
56
58
  selected={ isLinked }
57
59
  sx={ { marginLeft: 'auto' } }
58
60
  onChange={ onLinkToggle }
59
- disabled={ sizeDisabled || directionDisabled }
61
+ disabled={ disabled }
60
62
  >
61
63
  <LinkedIcon fontSize={ 'tiny' } />
62
64
  </ToggleButton>
@@ -29,7 +29,7 @@ export const ImageControl = createControl(
29
29
  <Stack gap={ 1.5 }>
30
30
  { [ 'all', 'media' ].includes( showMode ) ? (
31
31
  <PropKeyProvider bind={ 'src' }>
32
- <ControlFormLabel> { __( 'Image', 'elementor' ) } </ControlFormLabel>
32
+ <ControlFormLabel>{ __( 'Image', 'elementor' ) }</ControlFormLabel>
33
33
  <ImageMediaControl mediaTypes={ mediaTypes } />
34
34
  </PropKeyProvider>
35
35
  ) : null }
@@ -37,7 +37,7 @@ export const ImageControl = createControl(
37
37
  <PropKeyProvider bind={ 'size' }>
38
38
  <Grid container gap={ 1.5 } alignItems="center" flexWrap="nowrap">
39
39
  <Grid item xs={ 6 }>
40
- <ControlFormLabel> { resolutionLabel } </ControlFormLabel>
40
+ <ControlFormLabel>{ resolutionLabel }</ControlFormLabel>
41
41
  </Grid>
42
42
  <Grid item xs={ 6 } sx={ { overflow: 'hidden' } }>
43
43
  <SelectControl options={ sizes } />
@@ -189,7 +189,7 @@ export const LinkControl = createControl( ( props: Props ) => {
189
189
  </ControlActions>
190
190
  </PropKeyProvider>
191
191
  <PropKeyProvider bind={ 'isTargetBlank' }>
192
- <SwitchControl disabled={ ! value } />
192
+ <SwitchControl disabled={ propContext.disabled || ! value } />
193
193
  </PropKeyProvider>
194
194
  </Stack>
195
195
  </Collapse>
@@ -58,8 +58,15 @@ export const LinkedDimensionsControl = createControl(
58
58
  // translators: %s: Tooltip title.
59
59
  const unlinkedLabel = __( 'Unlink %s', 'elementor' ).replace( '%s', tooltipLabel );
60
60
 
61
+ const disabled = sizeDisabled || dimensionsDisabled;
62
+
61
63
  return (
62
- <PropProvider propType={ propType } value={ dimensionsValue } setValue={ setDimensionsValue }>
64
+ <PropProvider
65
+ propType={ propType }
66
+ value={ dimensionsValue }
67
+ setValue={ setDimensionsValue }
68
+ disabled={ disabled }
69
+ >
63
70
  <Stack direction="row" gap={ 2 } flexWrap="nowrap">
64
71
  { isUsingNestedProps ? (
65
72
  <ControlFormLabel>{ label }</ControlFormLabel>
@@ -74,7 +81,7 @@ export const LinkedDimensionsControl = createControl(
74
81
  selected={ isLinked }
75
82
  sx={ { marginLeft: 'auto' } }
76
83
  onChange={ onLinkToggle }
77
- disabled={ sizeDisabled || dimensionsDisabled }
84
+ disabled={ disabled }
78
85
  >
79
86
  <LinkedIcon fontSize={ 'tiny' } />
80
87
  </ToggleButton>
@@ -141,6 +148,8 @@ export const LinkedDimensionsControl = createControl(
141
148
  <Grid item xs={ 12 }>
142
149
  <Control
143
150
  bind={ 'inline-start' }
151
+ isLinked={ isLinked }
152
+ extendedValues={ extendedValues }
144
153
  startIcon={
145
154
  isSiteRtl ? (
146
155
  <SideRightIcon fontSize={ 'tiny' } />
@@ -148,8 +157,6 @@ export const LinkedDimensionsControl = createControl(
148
157
  <SideLeftIcon fontSize={ 'tiny' } />
149
158
  )
150
159
  }
151
- isLinked={ isLinked }
152
- extendedValues={ extendedValues }
153
160
  />
154
161
  </Grid>
155
162
  </Grid>
package/src/index.ts CHANGED
@@ -23,6 +23,7 @@ export { SwitchControl } from './controls/switch-control';
23
23
  // components
24
24
  export { ControlFormLabel } from './components/control-form-label';
25
25
  export { ControlToggleButtonGroup } from './components/control-toggle-button-group';
26
+ export { FontFamilySelector } from './components/font-family-selector';
26
27
 
27
28
  // types
28
29
  export type { ControlComponent } from './create-control';