@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/CHANGELOG.md +14 -0
- package/dist/index.d.mts +11 -5
- package/dist/index.d.ts +11 -5
- package/dist/index.js +123 -88
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +123 -90
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
- package/src/components/control-form-label.tsx +3 -3
- package/src/components/control-label.tsx +1 -1
- package/src/components/font-family-selector.tsx +8 -10
- package/src/components/repeater.tsx +2 -4
- package/src/components/sortable.tsx +4 -2
- package/src/controls/background-control/background-overlay/background-image-overlay/background-image-overlay-position.tsx +3 -2
- package/src/controls/background-control/background-overlay/background-image-overlay/background-image-overlay-size.tsx +2 -1
- package/src/controls/background-control/background-overlay/background-overlay-repeater-control.tsx +1 -1
- package/src/controls/box-shadow-repeater-control.tsx +3 -3
- package/src/controls/equal-unequal-sizes-control.tsx +14 -4
- package/src/controls/font-family-control/font-family-control.tsx +3 -1
- package/src/controls/gap-control.tsx +3 -1
- package/src/controls/image-control.tsx +2 -2
- package/src/controls/link-control.tsx +1 -1
- package/src/controls/linked-dimensions-control.tsx +11 -4
- package/src/index.ts +1 -0
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.
|
|
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.
|
|
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 = (
|
|
5
|
-
return <FormLabel size="tiny"
|
|
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={
|
|
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 {
|
|
4
|
-
import { SearchIcon, TextIcon
|
|
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
|
-
<
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
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
|
-
<
|
|
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
|
-
</
|
|
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
|
-
|
|
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>
|
package/src/controls/background-control/background-overlay/background-overlay-repeater-control.tsx
CHANGED
|
@@ -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
|
|
50
|
+
const context = useBoundProp( shadowPropTypeUtil );
|
|
51
51
|
|
|
52
52
|
return (
|
|
53
|
-
<PropProvider
|
|
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
|
|
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
|
-
|
|
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
|
|
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=
|
|
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={
|
|
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>
|
|
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>
|
|
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
|
|
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={
|
|
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';
|