@elementor/editor-editing-panel 1.45.0 → 1.47.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 +90 -0
- package/dist/index.d.mts +22 -4
- package/dist/index.d.ts +22 -4
- package/dist/index.js +1187 -1051
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1027 -893
- package/dist/index.mjs.map +1 -1
- package/package.json +18 -17
- package/src/components/css-classes/css-class-menu.tsx +6 -8
- package/src/components/css-classes/css-class-selector.tsx +17 -11
- package/src/components/popover-scrollable-content.tsx +12 -0
- package/src/components/section-content.tsx +6 -16
- package/src/components/section.tsx +8 -4
- package/src/components/settings-tab.tsx +30 -4
- package/src/components/style-indicator.tsx +19 -15
- package/src/components/style-sections/background-section/background-section.tsx +4 -1
- package/src/components/style-sections/border-section/border-color-field.tsx +10 -16
- package/src/components/style-sections/border-section/border-field.tsx +4 -6
- package/src/components/style-sections/border-section/border-radius-field.tsx +4 -2
- package/src/components/style-sections/border-section/border-style-field.tsx +11 -16
- package/src/components/style-sections/border-section/border-width-field.tsx +4 -2
- package/src/components/style-sections/effects-section/effects-section.tsx +22 -2
- package/src/components/style-sections/layout-section/align-content-field.tsx +11 -12
- package/src/components/style-sections/layout-section/align-items-field.tsx +8 -11
- package/src/components/style-sections/layout-section/align-self-child-field.tsx +11 -16
- package/src/components/style-sections/layout-section/display-field.tsx +6 -6
- package/src/components/style-sections/layout-section/flex-direction-field.tsx +11 -14
- package/src/components/style-sections/layout-section/flex-order-field.tsx +32 -37
- package/src/components/style-sections/layout-section/flex-size-field.tsx +35 -58
- package/src/components/style-sections/layout-section/gap-control-field.tsx +5 -6
- package/src/components/style-sections/layout-section/justify-content-field.tsx +11 -12
- package/src/components/style-sections/layout-section/layout-section.tsx +2 -2
- package/src/components/style-sections/layout-section/opacity-control-field.tsx +21 -0
- package/src/components/style-sections/layout-section/utils/rotated-icon.tsx +1 -1
- package/src/components/style-sections/layout-section/wrap-field.tsx +10 -14
- package/src/components/style-sections/position-section/dimensions-field.tsx +4 -4
- package/src/components/style-sections/position-section/offset-field.tsx +12 -14
- package/src/components/style-sections/position-section/position-field.tsx +7 -11
- package/src/components/style-sections/position-section/position-section.tsx +6 -6
- package/src/components/style-sections/position-section/z-index-field.tsx +7 -11
- package/src/components/style-sections/size-section/object-fit-field.tsx +7 -11
- package/src/components/style-sections/size-section/object-position-field.tsx +4 -23
- package/src/components/style-sections/size-section/overflow-field.tsx +7 -11
- package/src/components/style-sections/size-section/size-section.tsx +10 -8
- package/src/components/style-sections/spacing-section/spacing-section.tsx +7 -4
- package/src/components/style-sections/typography-section/column-count-field.tsx +7 -11
- package/src/components/style-sections/typography-section/column-gap-field.tsx +9 -13
- package/src/components/style-sections/typography-section/font-family-field.tsx +9 -11
- package/src/components/style-sections/typography-section/font-size-field.tsx +9 -13
- package/src/components/style-sections/typography-section/font-style-field.tsx +13 -13
- package/src/components/style-sections/typography-section/font-weight-field.tsx +7 -11
- package/src/components/style-sections/typography-section/letter-spacing-field.tsx +9 -13
- package/src/components/style-sections/typography-section/line-height-field.tsx +9 -13
- package/src/components/style-sections/typography-section/text-alignment-field.tsx +11 -14
- package/src/components/style-sections/typography-section/text-color-field.tsx +7 -11
- package/src/components/style-sections/typography-section/text-decoration-field.tsx +7 -11
- package/src/components/style-sections/typography-section/text-direction-field.tsx +7 -11
- package/src/components/style-sections/typography-section/text-stroke-field.tsx +8 -8
- package/src/components/style-sections/typography-section/transform-field.tsx +7 -11
- package/src/components/style-sections/typography-section/typography-section.tsx +4 -2
- package/src/components/style-sections/typography-section/word-spacing-field.tsx +9 -13
- package/src/components/styles-field-layout.tsx +50 -0
- package/src/contexts/section-context.tsx +14 -0
- package/src/controls-registry/control-type-container.tsx +6 -2
- package/src/controls-registry/controls-registry.tsx +30 -10
- package/src/controls-registry/settings-field.tsx +65 -6
- package/src/controls-registry/styles-field.tsx +11 -5
- package/src/dynamics/components/dynamic-selection-control.tsx +20 -22
- package/src/dynamics/components/dynamic-selection.tsx +64 -79
- package/src/dynamics/hooks/use-prop-dynamic-action.tsx +1 -1
- package/src/hooks/use-default-panel-settings.ts +4 -0
- package/src/hooks/use-styles-field.ts +9 -3
- package/src/hooks/use-styles-fields.ts +4 -4
- package/src/index.ts +5 -0
- package/src/popover-action.tsx +11 -6
- package/src/provider-colors-registry.ts +20 -0
- package/src/styles-inheritance/components/infotip/label-chip.tsx +4 -5
- package/src/styles-inheritance/components/styles-inheritance-indicator.tsx +36 -41
- package/src/styles-inheritance/components/styles-inheritance-infotip.tsx +10 -24
- package/src/styles-inheritance/components/styles-inheritance-section-indicators.tsx +29 -44
- package/src/styles-inheritance/hooks/use-normalized-inheritance-chain-items.tsx +1 -17
- package/src/styles-inheritance/types.ts +0 -2
- package/src/styles-inheritance/utils.ts +17 -1
- package/src/sync/experiments-flags.ts +1 -0
- package/src/utils/get-styles-provider-color.ts +28 -0
- package/src/components/popover-content.tsx +0 -15
|
@@ -1,21 +1,12 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
1
|
import { Fragment, useState } from 'react';
|
|
2
|
+
import * as React from 'react';
|
|
3
3
|
import { useBoundProp } from '@elementor/editor-controls';
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
|
|
7
|
-
Divider,
|
|
8
|
-
InputAdornment,
|
|
9
|
-
Link,
|
|
10
|
-
MenuItem,
|
|
11
|
-
MenuList,
|
|
12
|
-
MenuSubheader,
|
|
13
|
-
Stack,
|
|
14
|
-
TextField,
|
|
15
|
-
Typography,
|
|
16
|
-
} from '@elementor/ui';
|
|
4
|
+
import { PopoverHeader, PopoverMenuList, PopoverSearch } from '@elementor/editor-ui';
|
|
5
|
+
import { DatabaseIcon } from '@elementor/icons';
|
|
6
|
+
import { Box, Divider, Link, Stack, Typography, useTheme } from '@elementor/ui';
|
|
17
7
|
import { __ } from '@wordpress/i18n';
|
|
18
8
|
|
|
9
|
+
import { PopoverScrollableContent } from '../../components/popover-scrollable-content';
|
|
19
10
|
import { usePersistDynamicValue } from '../../hooks/use-persist-dynamic-value';
|
|
20
11
|
import { usePropDynamicTags } from '../hooks/use-prop-dynamic-tags';
|
|
21
12
|
import { getAtomicDynamicTags } from '../sync/get-atomic-dynamic-tags';
|
|
@@ -31,7 +22,7 @@ type OptionEntry = [ string, Option[] ];
|
|
|
31
22
|
const SIZE = 'tiny';
|
|
32
23
|
|
|
33
24
|
type DynamicSelectionProps = {
|
|
34
|
-
|
|
25
|
+
close: () => void;
|
|
35
26
|
};
|
|
36
27
|
|
|
37
28
|
type NoResultsProps = {
|
|
@@ -39,9 +30,10 @@ type NoResultsProps = {
|
|
|
39
30
|
onClear?: () => void;
|
|
40
31
|
};
|
|
41
32
|
|
|
42
|
-
export const DynamicSelection = ( {
|
|
33
|
+
export const DynamicSelection = ( { close: closePopover }: DynamicSelectionProps ) => {
|
|
43
34
|
const [ searchValue, setSearchValue ] = useState( '' );
|
|
44
35
|
const { groups: dynamicGroups } = getAtomicDynamicTags() || {};
|
|
36
|
+
const theme = useTheme();
|
|
45
37
|
|
|
46
38
|
const { value: anyValue } = useBoundProp();
|
|
47
39
|
const { bind, value: dynamicValue, setValue } = useBoundProp( dynamicPropTypeUtil );
|
|
@@ -54,79 +46,73 @@ export const DynamicSelection = ( { onSelect }: DynamicSelectionProps ) => {
|
|
|
54
46
|
|
|
55
47
|
const hasNoDynamicTags = ! options.length && ! searchValue.trim();
|
|
56
48
|
|
|
57
|
-
const handleSearch = (
|
|
58
|
-
setSearchValue(
|
|
49
|
+
const handleSearch = ( value: string ) => {
|
|
50
|
+
setSearchValue( value );
|
|
59
51
|
};
|
|
60
52
|
|
|
61
|
-
const handleSetDynamicTag = ( value: string
|
|
53
|
+
const handleSetDynamicTag = ( value: string ) => {
|
|
62
54
|
if ( ! isCurrentValueDynamic ) {
|
|
63
55
|
updatePropValueHistory( anyValue );
|
|
64
56
|
}
|
|
65
57
|
|
|
66
|
-
|
|
58
|
+
const selectedOption = options.flatMap( ( [ , items ] ) => items ).find( ( item ) => item.value === value );
|
|
59
|
+
|
|
60
|
+
setValue( { name: value, settings: { label: selectedOption?.label } } );
|
|
67
61
|
|
|
68
|
-
|
|
62
|
+
closePopover();
|
|
69
63
|
};
|
|
70
64
|
|
|
65
|
+
const virtualizedItems = options.flatMap( ( [ category, items ] ) => [
|
|
66
|
+
{
|
|
67
|
+
type: 'category' as const,
|
|
68
|
+
value: category,
|
|
69
|
+
label: dynamicGroups?.[ category ]?.title || category,
|
|
70
|
+
},
|
|
71
|
+
...items.map( ( item ) => ( {
|
|
72
|
+
type: 'item' as const,
|
|
73
|
+
value: item.value,
|
|
74
|
+
label: item.label,
|
|
75
|
+
} ) ),
|
|
76
|
+
] );
|
|
77
|
+
|
|
71
78
|
return (
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
<
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
79
|
+
<>
|
|
80
|
+
<PopoverHeader
|
|
81
|
+
title={ __( 'Dynamic tags', 'elementor' ) }
|
|
82
|
+
onClose={ closePopover }
|
|
83
|
+
icon={ <DatabaseIcon fontSize={ SIZE } /> }
|
|
84
|
+
/>
|
|
85
|
+
<Stack>
|
|
86
|
+
{ hasNoDynamicTags ? (
|
|
87
|
+
<NoDynamicTags />
|
|
88
|
+
) : (
|
|
89
|
+
<Fragment>
|
|
90
|
+
<PopoverSearch
|
|
81
91
|
value={ searchValue }
|
|
82
|
-
|
|
92
|
+
onSearch={ handleSearch }
|
|
83
93
|
placeholder={ __( 'Search dynamic tags…', 'elementor' ) }
|
|
84
|
-
InputProps={ {
|
|
85
|
-
startAdornment: (
|
|
86
|
-
<InputAdornment position="start">
|
|
87
|
-
<SearchIcon fontSize={ SIZE } />
|
|
88
|
-
</InputAdornment>
|
|
89
|
-
),
|
|
90
|
-
} }
|
|
91
94
|
/>
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
<
|
|
97
|
-
{
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
sx={ { px: 3.5, typography: 'caption' } }
|
|
114
|
-
onClick={ () => handleSetDynamicTag( value, tagLabel ) }
|
|
115
|
-
>
|
|
116
|
-
{ tagLabel }
|
|
117
|
-
</MenuItem>
|
|
118
|
-
);
|
|
119
|
-
} ) }
|
|
120
|
-
</Fragment>
|
|
121
|
-
) ) }
|
|
122
|
-
</MenuList>
|
|
123
|
-
) : (
|
|
124
|
-
<NoResults searchValue={ searchValue } onClear={ () => setSearchValue( '' ) } />
|
|
125
|
-
) }
|
|
126
|
-
</Box>
|
|
127
|
-
</Fragment>
|
|
128
|
-
) }
|
|
129
|
-
</Stack>
|
|
95
|
+
|
|
96
|
+
<Divider />
|
|
97
|
+
|
|
98
|
+
<PopoverScrollableContent>
|
|
99
|
+
<PopoverMenuList
|
|
100
|
+
items={ virtualizedItems }
|
|
101
|
+
onSelect={ handleSetDynamicTag }
|
|
102
|
+
onClose={ closePopover }
|
|
103
|
+
selectedValue={ dynamicValue?.name }
|
|
104
|
+
itemStyle={ ( item ) =>
|
|
105
|
+
item.type === 'item' ? { paddingInlineStart: theme.spacing( 3.5 ) } : {}
|
|
106
|
+
}
|
|
107
|
+
noResultsComponent={
|
|
108
|
+
<NoResults searchValue={ searchValue } onClear={ () => setSearchValue( '' ) } />
|
|
109
|
+
}
|
|
110
|
+
/>
|
|
111
|
+
</PopoverScrollableContent>
|
|
112
|
+
</Fragment>
|
|
113
|
+
) }
|
|
114
|
+
</Stack>
|
|
115
|
+
</>
|
|
130
116
|
);
|
|
131
117
|
};
|
|
132
118
|
|
|
@@ -146,9 +132,8 @@ const NoResults = ( { searchValue, onClear }: NoResultsProps ) => (
|
|
|
146
132
|
<br />
|
|
147
133
|
“{ searchValue }”.
|
|
148
134
|
</Typography>
|
|
149
|
-
<Typography align="center" variant="caption">
|
|
135
|
+
<Typography align="center" variant="caption" sx={ { display: 'flex', flexDirection: 'column' } }>
|
|
150
136
|
{ __( 'Try something else.', 'elementor' ) }
|
|
151
|
-
|
|
152
137
|
<Link color="text.secondary" variant="caption" component="button" onClick={ onClear }>
|
|
153
138
|
{ __( 'Clear & try again', 'elementor' ) }
|
|
154
139
|
</Link>
|
|
@@ -173,7 +158,7 @@ const NoDynamicTags = () => (
|
|
|
173
158
|
{ __( 'Streamline your workflow with dynamic tags', 'elementor' ) }
|
|
174
159
|
</Typography>
|
|
175
160
|
<Typography align="center" variant="caption">
|
|
176
|
-
{ __( '
|
|
161
|
+
{ __( "You'll need Elementor Pro to use this feature.", 'elementor' ) }
|
|
177
162
|
</Typography>
|
|
178
163
|
</Stack>
|
|
179
164
|
</Box>
|
|
@@ -16,6 +16,6 @@ export const usePropDynamicAction = (): PopoverActionProps => {
|
|
|
16
16
|
visible,
|
|
17
17
|
icon: DatabaseIcon,
|
|
18
18
|
title: __( 'Dynamic tags', 'elementor' ),
|
|
19
|
-
|
|
19
|
+
content: ( { close } ) => <DynamicSelection close={ close } />,
|
|
20
20
|
};
|
|
21
21
|
};
|
|
@@ -24,6 +24,10 @@ const defaultPanelSettingsContext = createContext< Record< string, Defaults | un
|
|
|
24
24
|
defaultSectionsExpanded: fallbackEditorSettings.defaultSectionsExpanded,
|
|
25
25
|
defaultTab: 'style',
|
|
26
26
|
},
|
|
27
|
+
'e-divider': {
|
|
28
|
+
defaultSectionsExpanded: fallbackEditorSettings.defaultSectionsExpanded,
|
|
29
|
+
defaultTab: 'style',
|
|
30
|
+
},
|
|
27
31
|
} );
|
|
28
32
|
|
|
29
33
|
export const useDefaultPanelSettings = () => {
|
|
@@ -2,8 +2,14 @@ import type { PropKey, PropValue } from '@elementor/editor-props';
|
|
|
2
2
|
|
|
3
3
|
import { useStylesFields } from './use-styles-fields';
|
|
4
4
|
|
|
5
|
-
export function useStylesField< T extends PropValue >(
|
|
6
|
-
|
|
5
|
+
export function useStylesField< T extends PropValue >(
|
|
6
|
+
propName: PropKey
|
|
7
|
+
): {
|
|
8
|
+
value: T;
|
|
9
|
+
setValue: ( newValue: T ) => void;
|
|
10
|
+
canEdit?: boolean;
|
|
11
|
+
} {
|
|
12
|
+
const { values, setValues, canEdit } = useStylesFields< { [ k: typeof propName ]: T } >( [ propName ] );
|
|
7
13
|
|
|
8
14
|
const value = values?.[ propName ] ?? null;
|
|
9
15
|
|
|
@@ -13,5 +19,5 @@ export function useStylesField< T extends PropValue >( propName: PropKey ): [ T
|
|
|
13
19
|
} );
|
|
14
20
|
};
|
|
15
21
|
|
|
16
|
-
return
|
|
22
|
+
return { value: value as T, setValue, canEdit };
|
|
17
23
|
}
|
|
@@ -21,7 +21,7 @@ import { useStylesRerender } from './use-styles-rerender';
|
|
|
21
21
|
|
|
22
22
|
export function useStylesFields< T extends Props >( propNames: ( keyof T & string )[] ) {
|
|
23
23
|
const { element } = useElement();
|
|
24
|
-
const { id, meta, provider } = useStyle();
|
|
24
|
+
const { id, meta, provider, canEdit } = useStyle();
|
|
25
25
|
const classesProp = useClassesProp();
|
|
26
26
|
|
|
27
27
|
const undoableUpdateStyle = useUndoableUpdateStyle();
|
|
@@ -29,7 +29,7 @@ export function useStylesFields< T extends Props >( propNames: ( keyof T & strin
|
|
|
29
29
|
|
|
30
30
|
useStylesRerender();
|
|
31
31
|
|
|
32
|
-
const
|
|
32
|
+
const values = getProps< T >( {
|
|
33
33
|
elementId: element.id,
|
|
34
34
|
styleId: id,
|
|
35
35
|
provider,
|
|
@@ -37,7 +37,7 @@ export function useStylesFields< T extends Props >( propNames: ( keyof T & strin
|
|
|
37
37
|
propNames,
|
|
38
38
|
} );
|
|
39
39
|
|
|
40
|
-
const
|
|
40
|
+
const setValues = ( props: T ) => {
|
|
41
41
|
if ( id === null ) {
|
|
42
42
|
undoableCreateElementStyle( {
|
|
43
43
|
elementId: element.id,
|
|
@@ -58,7 +58,7 @@ export function useStylesFields< T extends Props >( propNames: ( keyof T & strin
|
|
|
58
58
|
} );
|
|
59
59
|
};
|
|
60
60
|
|
|
61
|
-
return
|
|
61
|
+
return { values, setValues, canEdit };
|
|
62
62
|
}
|
|
63
63
|
|
|
64
64
|
type GetPropsArgs = {
|
package/src/index.ts
CHANGED
|
@@ -1,10 +1,15 @@
|
|
|
1
|
+
export { EXPERIMENTAL_FEATURES } from './sync/experiments-flags';
|
|
2
|
+
|
|
1
3
|
export { useBoundProp } from '@elementor/editor-controls';
|
|
2
4
|
export type { PopoverActionProps } from './popover-action';
|
|
3
5
|
export { registerControlReplacement } from './control-replacement';
|
|
6
|
+
export { registerStyleProviderToColors } from './provider-colors-registry';
|
|
4
7
|
export { injectIntoClassSelectorActions } from './components/css-classes/css-class-selector';
|
|
5
8
|
export { usePanelActions, usePanelStatus } from './panel';
|
|
6
9
|
export { type ValidationResult, type ValidationEvent } from './components/creatable-autocomplete';
|
|
7
10
|
export { controlActionsMenu } from './controls-actions';
|
|
8
11
|
export { useFontFamilies } from './components/style-sections/typography-section/hooks/use-font-families';
|
|
12
|
+
export { PopoverScrollableContent } from './components/popover-scrollable-content';
|
|
13
|
+
export { useSectionWidth } from './contexts/section-context';
|
|
9
14
|
|
|
10
15
|
export { init } from './init';
|
package/src/popover-action.tsx
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { type ComponentType, type ElementType as ReactElementType, useId } from 'react';
|
|
3
|
-
import { PopoverHeader } from '@elementor/editor-ui';
|
|
4
3
|
import { bindPopover, bindToggle, IconButton, Popover, Tooltip, usePopupState } from '@elementor/ui';
|
|
5
4
|
|
|
6
5
|
const SIZE = 'tiny';
|
|
@@ -9,14 +8,14 @@ export type PopoverActionProps = {
|
|
|
9
8
|
title: string;
|
|
10
9
|
visible?: boolean;
|
|
11
10
|
icon: ReactElementType;
|
|
12
|
-
|
|
11
|
+
content: ComponentType< { close: () => void } >;
|
|
13
12
|
};
|
|
14
13
|
|
|
15
14
|
export default function PopoverAction( {
|
|
16
15
|
title,
|
|
17
16
|
visible = true,
|
|
18
17
|
icon: Icon,
|
|
19
|
-
|
|
18
|
+
content: PopoverContent,
|
|
20
19
|
}: PopoverActionProps ) {
|
|
21
20
|
const id = useId();
|
|
22
21
|
const popupState = usePopupState( {
|
|
@@ -40,12 +39,18 @@ export default function PopoverAction( {
|
|
|
40
39
|
disableScrollLock
|
|
41
40
|
anchorOrigin={ {
|
|
42
41
|
vertical: 'bottom',
|
|
43
|
-
horizontal: '
|
|
42
|
+
horizontal: 'right',
|
|
43
|
+
} }
|
|
44
|
+
transformOrigin={ {
|
|
45
|
+
vertical: 'top',
|
|
46
|
+
horizontal: 'right',
|
|
47
|
+
} }
|
|
48
|
+
PaperProps={ {
|
|
49
|
+
sx: { my: 2.5 },
|
|
44
50
|
} }
|
|
45
51
|
{ ...bindPopover( popupState ) }
|
|
46
52
|
>
|
|
47
|
-
<
|
|
48
|
-
<PopoverContent closePopover={ popupState.close } />
|
|
53
|
+
<PopoverContent close={ popupState.close } />
|
|
49
54
|
</Popover>
|
|
50
55
|
</>
|
|
51
56
|
);
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { type ChipProps, type Theme } from '@elementor/ui';
|
|
2
|
+
|
|
3
|
+
type Colors = {
|
|
4
|
+
name: ChipProps[ 'color' ];
|
|
5
|
+
getThemeColor: ( ( theme: Theme ) => string ) | null;
|
|
6
|
+
};
|
|
7
|
+
|
|
8
|
+
const DEFAULT_COLORS: Colors = {
|
|
9
|
+
name: 'default',
|
|
10
|
+
getThemeColor: null,
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
const providerColorsRegistry = new Map< string, Colors >();
|
|
14
|
+
|
|
15
|
+
export const registerStyleProviderToColors = ( provider: string, colors: Colors ) => {
|
|
16
|
+
providerColorsRegistry.set( provider, colors );
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
export const getStyleProviderColors = ( provider: string ): Colors =>
|
|
20
|
+
providerColorsRegistry.get( provider ) ?? DEFAULT_COLORS;
|
|
@@ -4,17 +4,16 @@ import { InfoCircleIcon } from '@elementor/icons';
|
|
|
4
4
|
import { Chip, type Theme, Tooltip } from '@elementor/ui';
|
|
5
5
|
import { __ } from '@wordpress/i18n';
|
|
6
6
|
|
|
7
|
-
import {
|
|
7
|
+
import { getStylesProviderColorName } from '../../../utils/get-styles-provider-color';
|
|
8
8
|
|
|
9
9
|
type Props = {
|
|
10
10
|
displayLabel: string;
|
|
11
|
-
provider
|
|
12
|
-
chipColor: ChipColors;
|
|
11
|
+
provider: string;
|
|
13
12
|
};
|
|
14
13
|
|
|
15
14
|
const SIZE = 'tiny';
|
|
16
15
|
|
|
17
|
-
export const LabelChip = ( { displayLabel, provider
|
|
16
|
+
export const LabelChip = ( { displayLabel, provider }: Props ) => {
|
|
18
17
|
const isBaseStyle = provider === ELEMENTS_BASE_STYLES_PROVIDER_KEY;
|
|
19
18
|
|
|
20
19
|
const chipIcon = isBaseStyle ? (
|
|
@@ -27,7 +26,7 @@ export const LabelChip = ( { displayLabel, provider, chipColor }: Props ) => {
|
|
|
27
26
|
<Chip
|
|
28
27
|
label={ displayLabel }
|
|
29
28
|
size={ SIZE }
|
|
30
|
-
color={
|
|
29
|
+
color={ getStylesProviderColorName( provider ) }
|
|
31
30
|
variant="standard"
|
|
32
31
|
state="enabled"
|
|
33
32
|
icon={ chipIcon }
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
+
import { type ComponentProps } from 'react';
|
|
2
3
|
import { useBoundProp } from '@elementor/editor-controls';
|
|
3
|
-
import { isEmpty } from '@elementor/editor-props';
|
|
4
|
-
import { ELEMENTS_BASE_STYLES_PROVIDER_KEY
|
|
4
|
+
import { isEmpty, type PropType } from '@elementor/editor-props';
|
|
5
|
+
import { ELEMENTS_BASE_STYLES_PROVIDER_KEY } from '@elementor/editor-styles-repository';
|
|
5
6
|
import { isExperimentActive } from '@elementor/editor-v1-adapters';
|
|
6
7
|
import { Tooltip } from '@elementor/ui';
|
|
7
8
|
import { __ } from '@wordpress/i18n';
|
|
@@ -10,12 +11,14 @@ import { StyleIndicator } from '../../components/style-indicator';
|
|
|
10
11
|
import { useStyle } from '../../contexts/style-context';
|
|
11
12
|
import { useStylesInheritanceChain } from '../../contexts/styles-inheritance-context';
|
|
12
13
|
import { EXPERIMENTAL_FEATURES } from '../../sync/experiments-flags';
|
|
14
|
+
import { getStylesProviderThemeColor } from '../../utils/get-styles-provider-color';
|
|
13
15
|
import { isUsingIndicatorPopover } from '../consts';
|
|
16
|
+
import { type SnapshotPropValue } from '../types';
|
|
17
|
+
import { getValueFromInheritanceChain } from '../utils';
|
|
14
18
|
import { StylesInheritanceInfotip } from './styles-inheritance-infotip';
|
|
15
19
|
|
|
16
20
|
export const StylesInheritanceIndicator = () => {
|
|
17
21
|
const { path, propType } = useBoundProp();
|
|
18
|
-
const { id: currentStyleId, provider: currentStyleProvider, meta: currentStyleMeta } = useStyle();
|
|
19
22
|
|
|
20
23
|
const isUsingNestedProps = isExperimentActive( EXPERIMENTAL_FEATURES.V_3_30 );
|
|
21
24
|
|
|
@@ -27,35 +30,49 @@ export const StylesInheritanceIndicator = () => {
|
|
|
27
30
|
return null;
|
|
28
31
|
}
|
|
29
32
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
);
|
|
33
|
+
return <Indicator inheritanceChain={ inheritanceChain } path={ finalPath } propType={ propType } />;
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
type IndicatorProps = {
|
|
37
|
+
inheritanceChain: SnapshotPropValue[];
|
|
38
|
+
path: string[];
|
|
39
|
+
propType: PropType;
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
const Indicator = ( { inheritanceChain, path, propType }: IndicatorProps ) => {
|
|
43
|
+
const { id: currentStyleId, provider: currentStyleProvider, meta: currentStyleMeta } = useStyle();
|
|
44
|
+
|
|
45
|
+
const currentItem = currentStyleId
|
|
46
|
+
? getValueFromInheritanceChain( inheritanceChain, currentStyleId, currentStyleMeta )
|
|
47
|
+
: null;
|
|
41
48
|
|
|
42
49
|
const hasValue = ! isEmpty( currentItem?.value );
|
|
43
50
|
|
|
44
51
|
const [ actualStyle ] = inheritanceChain;
|
|
45
52
|
|
|
46
|
-
if (
|
|
53
|
+
if (
|
|
54
|
+
! isExperimentActive( EXPERIMENTAL_FEATURES.V_3_31 ) &&
|
|
55
|
+
actualStyle.provider === ELEMENTS_BASE_STYLES_PROVIDER_KEY
|
|
56
|
+
) {
|
|
47
57
|
return null;
|
|
48
58
|
}
|
|
49
59
|
|
|
50
60
|
const isFinalValue = currentItem === actualStyle;
|
|
51
61
|
|
|
52
62
|
const label = getLabel( { isFinalValue, hasValue } );
|
|
53
|
-
|
|
63
|
+
|
|
64
|
+
const styleIndicatorProps: ComponentProps< typeof StyleIndicator > = {
|
|
65
|
+
getColor:
|
|
66
|
+
isFinalValue && currentStyleProvider
|
|
67
|
+
? getStylesProviderThemeColor( currentStyleProvider.getKey() )
|
|
68
|
+
: undefined,
|
|
69
|
+
isOverridden: hasValue && ! isFinalValue ? true : undefined,
|
|
70
|
+
};
|
|
54
71
|
|
|
55
72
|
if ( ! isUsingIndicatorPopover() ) {
|
|
56
73
|
return (
|
|
57
74
|
<Tooltip title={ __( 'Style origin', 'elementor' ) } placement="top">
|
|
58
|
-
<StyleIndicator
|
|
75
|
+
<StyleIndicator { ...styleIndicatorProps } aria-label={ label } />
|
|
59
76
|
</Tooltip>
|
|
60
77
|
);
|
|
61
78
|
}
|
|
@@ -63,11 +80,11 @@ export const StylesInheritanceIndicator = () => {
|
|
|
63
80
|
return (
|
|
64
81
|
<StylesInheritanceInfotip
|
|
65
82
|
inheritanceChain={ inheritanceChain }
|
|
66
|
-
path={
|
|
83
|
+
path={ path }
|
|
67
84
|
propType={ propType }
|
|
68
85
|
label={ label }
|
|
69
86
|
>
|
|
70
|
-
<StyleIndicator
|
|
87
|
+
<StyleIndicator { ...styleIndicatorProps } />
|
|
71
88
|
</StylesInheritanceInfotip>
|
|
72
89
|
);
|
|
73
90
|
};
|
|
@@ -83,25 +100,3 @@ const getLabel = ( { isFinalValue, hasValue }: { isFinalValue: boolean; hasValue
|
|
|
83
100
|
|
|
84
101
|
return __( 'This has value from another style', 'elementor' );
|
|
85
102
|
};
|
|
86
|
-
|
|
87
|
-
const getVariant = ( {
|
|
88
|
-
isFinalValue,
|
|
89
|
-
hasValue,
|
|
90
|
-
currentStyleProvider,
|
|
91
|
-
}: {
|
|
92
|
-
isFinalValue: boolean;
|
|
93
|
-
hasValue: boolean;
|
|
94
|
-
currentStyleProvider: object | null;
|
|
95
|
-
} ): 'local' | 'global' | 'overridden' | undefined => {
|
|
96
|
-
if ( isFinalValue ) {
|
|
97
|
-
return isElementsStylesProvider( ( currentStyleProvider as { getKey: () => string } )?.getKey?.() )
|
|
98
|
-
? 'local'
|
|
99
|
-
: 'global';
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
if ( hasValue ) {
|
|
103
|
-
return 'overridden';
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
return undefined;
|
|
107
|
-
};
|
|
@@ -2,29 +2,30 @@ import * as React from 'react';
|
|
|
2
2
|
import { useMemo, useState } from 'react';
|
|
3
3
|
import { createPropsResolver, type PropsResolver } from '@elementor/editor-canvas';
|
|
4
4
|
import { type PropKey, type PropType } from '@elementor/editor-props';
|
|
5
|
+
import { PopoverHeader } from '@elementor/editor-ui';
|
|
5
6
|
import {
|
|
6
7
|
Backdrop,
|
|
7
8
|
Box,
|
|
8
9
|
Card,
|
|
9
10
|
CardContent,
|
|
10
11
|
ClickAwayListener,
|
|
11
|
-
CloseButton,
|
|
12
12
|
IconButton,
|
|
13
13
|
Infotip,
|
|
14
14
|
Stack,
|
|
15
15
|
type Theme,
|
|
16
16
|
Tooltip,
|
|
17
|
-
Typography,
|
|
18
17
|
} from '@elementor/ui';
|
|
19
18
|
import { __ } from '@wordpress/i18n';
|
|
20
19
|
|
|
21
|
-
import {
|
|
20
|
+
import { useSectionWidth } from '../../contexts/section-context';
|
|
22
21
|
import { useDirection } from '../../hooks/use-direction';
|
|
23
22
|
import { useNormalizedInheritanceChainItems } from '../hooks/use-normalized-inheritance-chain-items';
|
|
24
23
|
import { stylesInheritanceTransformersRegistry } from '../styles-inheritance-transformers-registry';
|
|
25
24
|
import { type SnapshotPropValue } from '../types';
|
|
26
25
|
import { ActionIcons, BreakpointIcon, LabelChip, ValueComponent } from './infotip';
|
|
27
26
|
|
|
27
|
+
const SECTION_PADDING_INLINE = 32;
|
|
28
|
+
|
|
28
29
|
type Props = {
|
|
29
30
|
inheritanceChain: SnapshotPropValue[];
|
|
30
31
|
propType: PropType;
|
|
@@ -33,8 +34,6 @@ type Props = {
|
|
|
33
34
|
children: React.ReactNode;
|
|
34
35
|
};
|
|
35
36
|
|
|
36
|
-
const SIZE = 'tiny';
|
|
37
|
-
|
|
38
37
|
export const StylesInheritanceInfotip = ( { inheritanceChain, propType, path, label, children }: Props ) => {
|
|
39
38
|
const [ showInfotip, setShowInfotip ] = useState< boolean >( false );
|
|
40
39
|
const toggleInfotip = () => setShowInfotip( ( prev ) => ! prev );
|
|
@@ -42,8 +41,7 @@ export const StylesInheritanceInfotip = ( { inheritanceChain, propType, path, la
|
|
|
42
41
|
|
|
43
42
|
const key = path.join( '.' );
|
|
44
43
|
|
|
45
|
-
const
|
|
46
|
-
const sectionContentWidth = sectionContentRef?.current?.offsetWidth ?? 320;
|
|
44
|
+
const sectionWidth = useSectionWidth() + SECTION_PADDING_INLINE;
|
|
47
45
|
|
|
48
46
|
const resolve = useMemo< PropsResolver >( () => {
|
|
49
47
|
return createPropsResolver( {
|
|
@@ -59,8 +57,8 @@ export const StylesInheritanceInfotip = ( { inheritanceChain, propType, path, la
|
|
|
59
57
|
<Card
|
|
60
58
|
elevation={ 0 }
|
|
61
59
|
sx={ {
|
|
62
|
-
width: `${
|
|
63
|
-
maxWidth:
|
|
60
|
+
width: `${ sectionWidth - SECTION_PADDING_INLINE }px`,
|
|
61
|
+
maxWidth: 496,
|
|
64
62
|
overflowX: 'hidden',
|
|
65
63
|
} }
|
|
66
64
|
>
|
|
@@ -75,16 +73,8 @@ export const StylesInheritanceInfotip = ( { inheritanceChain, propType, path, la
|
|
|
75
73
|
},
|
|
76
74
|
} }
|
|
77
75
|
>
|
|
78
|
-
<
|
|
79
|
-
|
|
80
|
-
{ __( 'Style origin', 'elementor' ) }
|
|
81
|
-
</Typography>
|
|
82
|
-
<CloseButton
|
|
83
|
-
slotProps={ { icon: { fontSize: SIZE } } }
|
|
84
|
-
sx={ { ml: 'auto' } }
|
|
85
|
-
onClick={ closeInfotip }
|
|
86
|
-
/>
|
|
87
|
-
</Stack>
|
|
76
|
+
<PopoverHeader title={ __( 'Style origin', 'elementor' ) } onClose={ closeInfotip } />
|
|
77
|
+
|
|
88
78
|
<Stack
|
|
89
79
|
gap={ 1.5 }
|
|
90
80
|
sx={ { pl: 2, pr: 1, pb: 2, overflowX: 'hidden', overflowY: 'auto' } }
|
|
@@ -105,11 +95,7 @@ export const StylesInheritanceInfotip = ( { inheritanceChain, propType, path, la
|
|
|
105
95
|
>
|
|
106
96
|
<Box display="flex" gap={ 0.5 } sx={ { flexWrap: 'wrap', width: '100%' } }>
|
|
107
97
|
<BreakpointIcon breakpoint={ item.breakpoint } />
|
|
108
|
-
<LabelChip
|
|
109
|
-
displayLabel={ item.displayLabel }
|
|
110
|
-
provider={ item.provider }
|
|
111
|
-
chipColor={ item.chipColor }
|
|
112
|
-
/>
|
|
98
|
+
<LabelChip displayLabel={ item.displayLabel } provider={ item.provider } />
|
|
113
99
|
<ValueComponent index={ index } value={ item.value } />
|
|
114
100
|
</Box>
|
|
115
101
|
<ActionIcons />
|