@elementor/editor-editing-panel 1.44.0 → 1.46.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 +62 -0
- package/dist/index.d.mts +11 -4
- package/dist/index.d.ts +11 -4
- package/dist/index.js +867 -765
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +740 -636
- package/dist/index.mjs.map +1 -1
- package/package.json +14 -13
- 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/settings-tab.tsx +25 -2
- package/src/components/style-indicator.tsx +19 -15
- package/src/components/style-sections/border-section/border-field.tsx +4 -6
- package/src/components/style-sections/border-section/border-radius-field.tsx +12 -9
- package/src/components/style-sections/effects-section/effects-section.tsx +6 -0
- package/src/components/style-sections/layout-section/align-content-field.tsx +10 -14
- package/src/components/style-sections/layout-section/align-items-field.tsx +13 -17
- package/src/components/style-sections/layout-section/align-self-child-field.tsx +13 -17
- package/src/components/style-sections/layout-section/flex-direction-field.tsx +13 -17
- package/src/components/style-sections/layout-section/flex-order-field.tsx +31 -36
- package/src/components/style-sections/layout-section/flex-size-field.tsx +67 -69
- package/src/components/style-sections/layout-section/justify-content-field.tsx +10 -14
- package/src/components/style-sections/layout-section/layout-section.tsx +2 -2
- package/src/components/style-sections/layout-section/opacity-control-field.tsx +25 -0
- package/src/components/style-sections/layout-section/utils/rotated-icon.tsx +1 -1
- package/src/components/style-sections/layout-section/wrap-field.tsx +13 -17
- package/src/components/style-sections/position-section/dimensions-field.tsx +39 -21
- package/src/components/style-sections/position-section/offset-field.tsx +5 -2
- package/src/components/style-sections/position-section/position-section.tsx +6 -6
- package/src/components/style-sections/size-section/object-position-field.tsx +2 -24
- package/src/components/style-sections/size-section/size-section.tsx +52 -37
- package/src/components/style-sections/spacing-section/spacing-section.tsx +1 -1
- package/src/components/style-sections/typography-section/column-gap-field.tsx +5 -2
- package/src/components/style-sections/typography-section/font-size-field.tsx +5 -2
- package/src/components/style-sections/typography-section/letter-spacing-field.tsx +5 -2
- package/src/components/style-sections/typography-section/line-height-field.tsx +5 -2
- package/src/components/style-sections/typography-section/text-alignment-field.tsx +12 -9
- package/src/components/style-sections/typography-section/text-stroke-field.tsx +4 -6
- package/src/components/style-sections/typography-section/typography-section.tsx +4 -2
- package/src/components/style-sections/typography-section/word-spacing-field.tsx +5 -2
- package/src/controls-registry/controls-registry.tsx +30 -10
- package/src/controls-registry/styles-field.tsx +1 -3
- package/src/dynamics/components/background-control-dynamic-tag.tsx +48 -0
- package/src/dynamics/components/dynamic-selection-control.tsx +10 -18
- package/src/dynamics/components/dynamic-selection.tsx +58 -77
- package/src/dynamics/hooks/use-prop-dynamic-action.tsx +1 -1
- package/src/dynamics/init.ts +21 -0
- package/src/hooks/use-styles-field.ts +9 -3
- package/src/hooks/use-styles-fields.ts +4 -4
- package/src/index.ts +1 -0
- package/src/popover-action.tsx +3 -5
- 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 +32 -40
- package/src/styles-inheritance/components/styles-inheritance-infotip.tsx +1 -5
- package/src/styles-inheritance/components/styles-inheritance-section-indicators.tsx +29 -44
- package/src/styles-inheritance/components/ui-providers.tsx +18 -0
- 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/utils/get-styles-provider-color.ts +28 -0
|
@@ -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,6 +1,7 @@
|
|
|
1
1
|
export { useBoundProp } from '@elementor/editor-controls';
|
|
2
2
|
export type { PopoverActionProps } from './popover-action';
|
|
3
3
|
export { registerControlReplacement } from './control-replacement';
|
|
4
|
+
export { registerStyleProviderToColors } from './provider-colors-registry';
|
|
4
5
|
export { injectIntoClassSelectorActions } from './components/css-classes/css-class-selector';
|
|
5
6
|
export { usePanelActions, usePanelStatus } from './panel';
|
|
6
7
|
export { type ValidationResult, type ValidationEvent } from './components/creatable-autocomplete';
|
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( {
|
|
@@ -44,8 +43,7 @@ export default function PopoverAction( {
|
|
|
44
43
|
} }
|
|
45
44
|
{ ...bindPopover( popupState ) }
|
|
46
45
|
>
|
|
47
|
-
<
|
|
48
|
-
<PopoverContent closePopover={ popupState.close } />
|
|
46
|
+
<PopoverContent close={ popupState.close } />
|
|
49
47
|
</Popover>
|
|
50
48
|
</>
|
|
51
49
|
);
|
|
@@ -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,17 +30,21 @@ 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
|
|
|
@@ -50,12 +57,19 @@ export const StylesInheritanceIndicator = () => {
|
|
|
50
57
|
const isFinalValue = currentItem === actualStyle;
|
|
51
58
|
|
|
52
59
|
const label = getLabel( { isFinalValue, hasValue } );
|
|
53
|
-
|
|
60
|
+
|
|
61
|
+
const styleIndicatorProps: ComponentProps< typeof StyleIndicator > = {
|
|
62
|
+
getColor:
|
|
63
|
+
isFinalValue && currentStyleProvider
|
|
64
|
+
? getStylesProviderThemeColor( currentStyleProvider.getKey() )
|
|
65
|
+
: undefined,
|
|
66
|
+
isOverridden: hasValue && ! isFinalValue ? true : undefined,
|
|
67
|
+
};
|
|
54
68
|
|
|
55
69
|
if ( ! isUsingIndicatorPopover() ) {
|
|
56
70
|
return (
|
|
57
71
|
<Tooltip title={ __( 'Style origin', 'elementor' ) } placement="top">
|
|
58
|
-
<StyleIndicator
|
|
72
|
+
<StyleIndicator { ...styleIndicatorProps } aria-label={ label } />
|
|
59
73
|
</Tooltip>
|
|
60
74
|
);
|
|
61
75
|
}
|
|
@@ -63,11 +77,11 @@ export const StylesInheritanceIndicator = () => {
|
|
|
63
77
|
return (
|
|
64
78
|
<StylesInheritanceInfotip
|
|
65
79
|
inheritanceChain={ inheritanceChain }
|
|
66
|
-
path={
|
|
80
|
+
path={ path }
|
|
67
81
|
propType={ propType }
|
|
68
82
|
label={ label }
|
|
69
83
|
>
|
|
70
|
-
<StyleIndicator
|
|
84
|
+
<StyleIndicator { ...styleIndicatorProps } />
|
|
71
85
|
</StylesInheritanceInfotip>
|
|
72
86
|
);
|
|
73
87
|
};
|
|
@@ -83,25 +97,3 @@ const getLabel = ( { isFinalValue, hasValue }: { isFinalValue: boolean; hasValue
|
|
|
83
97
|
|
|
84
98
|
return __( 'This has value from another style', 'elementor' );
|
|
85
99
|
};
|
|
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
|
-
};
|
|
@@ -105,11 +105,7 @@ export const StylesInheritanceInfotip = ( { inheritanceChain, propType, path, la
|
|
|
105
105
|
>
|
|
106
106
|
<Box display="flex" gap={ 0.5 } sx={ { flexWrap: 'wrap', width: '100%' } }>
|
|
107
107
|
<BreakpointIcon breakpoint={ item.breakpoint } />
|
|
108
|
-
<LabelChip
|
|
109
|
-
displayLabel={ item.displayLabel }
|
|
110
|
-
provider={ item.provider }
|
|
111
|
-
chipColor={ item.chipColor }
|
|
112
|
-
/>
|
|
108
|
+
<LabelChip displayLabel={ item.displayLabel } provider={ item.provider } />
|
|
113
109
|
<ValueComponent index={ index } value={ item.value } />
|
|
114
110
|
</Box>
|
|
115
111
|
<ActionIcons />
|
|
@@ -1,58 +1,54 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { type PropKey } from '@elementor/editor-props';
|
|
3
3
|
import { type StyleDefinitionVariant } from '@elementor/editor-styles';
|
|
4
|
-
import {
|
|
4
|
+
import { isElementsStylesProvider } from '@elementor/editor-styles-repository';
|
|
5
5
|
import { Stack, Tooltip } from '@elementor/ui';
|
|
6
6
|
import { __ } from '@wordpress/i18n';
|
|
7
7
|
|
|
8
8
|
import { StyleIndicator } from '../../components/style-indicator';
|
|
9
9
|
import { useStyle } from '../../contexts/style-context';
|
|
10
10
|
import { useStylesInheritanceSnapshot } from '../../contexts/styles-inheritance-context';
|
|
11
|
+
import { getStylesProviderThemeColor } from '../../utils/get-styles-provider-color';
|
|
11
12
|
import { type SnapshotPropValue } from '../types';
|
|
12
|
-
|
|
13
13
|
type Props = {
|
|
14
14
|
fields: PropKey[];
|
|
15
15
|
};
|
|
16
16
|
|
|
17
|
-
type Indicators = {
|
|
18
|
-
global?: true;
|
|
19
|
-
local?: true;
|
|
20
|
-
overridden?: true;
|
|
21
|
-
};
|
|
22
|
-
|
|
23
|
-
const orderedVariants = [ 'global', 'local', 'overridden' ] as ( keyof Indicators )[];
|
|
24
|
-
|
|
25
17
|
export const StylesInheritanceSectionIndicators = ( { fields }: Props ) => {
|
|
26
|
-
const { id, meta } = useStyle();
|
|
18
|
+
const { id, meta, provider } = useStyle();
|
|
27
19
|
const snapshot = useStylesInheritanceSnapshot();
|
|
28
20
|
|
|
29
21
|
const snapshotFields = Object.fromEntries(
|
|
30
22
|
Object.entries( snapshot ?? {} ).filter( ( [ key ] ) => fields.includes( key as PropKey ) )
|
|
31
23
|
);
|
|
32
24
|
|
|
33
|
-
const
|
|
25
|
+
const { hasValues, hasOverrides } = getIndicators( snapshotFields, id ?? '', meta );
|
|
34
26
|
|
|
35
|
-
if (
|
|
27
|
+
if ( ! hasValues && ! hasOverrides ) {
|
|
36
28
|
return null;
|
|
37
29
|
}
|
|
38
30
|
|
|
39
|
-
const
|
|
40
|
-
const
|
|
31
|
+
const hasValueLabel = __( 'Has effective styles', 'elementor' );
|
|
32
|
+
const hasOverridesLabel = __( 'Has overridden styles', 'elementor' );
|
|
41
33
|
|
|
42
34
|
return (
|
|
43
35
|
<Tooltip title={ __( 'Has styles', 'elementor' ) } placement="top">
|
|
44
36
|
<Stack direction="row" sx={ { '& > *': { marginInlineStart: -0.25 } } } role="list">
|
|
45
|
-
{
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
37
|
+
{ hasValues && provider && (
|
|
38
|
+
<StyleIndicator
|
|
39
|
+
getColor={ getStylesProviderThemeColor( provider.getKey() ) }
|
|
40
|
+
data-variant={ isElementsStylesProvider( provider.getKey() ) ? 'local' : 'global' }
|
|
41
|
+
role="listitem"
|
|
42
|
+
aria-label={ hasValueLabel }
|
|
43
|
+
/>
|
|
44
|
+
) }
|
|
45
|
+
{ hasOverrides && (
|
|
46
|
+
<StyleIndicator
|
|
47
|
+
isOverridden
|
|
48
|
+
data-variant="overridden"
|
|
49
|
+
role="listitem"
|
|
50
|
+
aria-label={ hasOverridesLabel }
|
|
51
|
+
/>
|
|
56
52
|
) }
|
|
57
53
|
</Stack>
|
|
58
54
|
</Tooltip>
|
|
@@ -63,8 +59,9 @@ function getIndicators(
|
|
|
63
59
|
snapshotFields: Record< PropKey, SnapshotPropValue[] >,
|
|
64
60
|
styleId: string,
|
|
65
61
|
meta: StyleDefinitionVariant[ 'meta' ]
|
|
66
|
-
):
|
|
67
|
-
|
|
62
|
+
): { hasValues: boolean; hasOverrides: boolean } {
|
|
63
|
+
let hasValues = false;
|
|
64
|
+
let hasOverrides = false;
|
|
68
65
|
|
|
69
66
|
Object.values( snapshotFields ).forEach( ( inheritanceChain ) => {
|
|
70
67
|
const currentStyle = getCurrentStyleFromChain( inheritanceChain, styleId, meta );
|
|
@@ -76,25 +73,13 @@ function getIndicators(
|
|
|
76
73
|
const [ actualStyle ] = inheritanceChain;
|
|
77
74
|
|
|
78
75
|
if ( currentStyle === actualStyle ) {
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
indicators.local = true;
|
|
83
|
-
|
|
84
|
-
return;
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
if ( providerKey !== ELEMENTS_BASE_STYLES_PROVIDER_KEY ) {
|
|
88
|
-
indicators.global = true;
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
return;
|
|
76
|
+
hasValues = true;
|
|
77
|
+
} else {
|
|
78
|
+
hasOverrides = true;
|
|
92
79
|
}
|
|
93
|
-
|
|
94
|
-
indicators.overridden = true;
|
|
95
80
|
} );
|
|
96
81
|
|
|
97
|
-
return
|
|
82
|
+
return { hasValues, hasOverrides };
|
|
98
83
|
}
|
|
99
84
|
|
|
100
85
|
function getCurrentStyleFromChain(
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { DirectionProvider, ThemeProvider } from '@elementor/ui';
|
|
3
|
+
|
|
4
|
+
import { useDirection } from '../../hooks/use-direction';
|
|
5
|
+
|
|
6
|
+
interface UiProvidersProps {
|
|
7
|
+
children: React.ReactNode;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export const UiProviders: React.FC< UiProvidersProps > = ( { children } ) => {
|
|
11
|
+
const { isSiteRtl } = useDirection();
|
|
12
|
+
|
|
13
|
+
return (
|
|
14
|
+
<DirectionProvider rtl={ isSiteRtl }>
|
|
15
|
+
<ThemeProvider>{ children }</ThemeProvider>
|
|
16
|
+
</DirectionProvider>
|
|
17
|
+
);
|
|
18
|
+
};
|
|
@@ -5,7 +5,7 @@ import { type StyleDefinitionVariant } from '@elementor/editor-styles';
|
|
|
5
5
|
import { ELEMENTS_BASE_STYLES_PROVIDER_KEY } from '@elementor/editor-styles-repository';
|
|
6
6
|
import { __ } from '@wordpress/i18n';
|
|
7
7
|
|
|
8
|
-
import { type
|
|
8
|
+
import { type SnapshotPropValue } from '../types';
|
|
9
9
|
|
|
10
10
|
const MAXIMUM_ITEMS = 2;
|
|
11
11
|
|
|
@@ -15,7 +15,6 @@ type NormalizedItem = {
|
|
|
15
15
|
breakpoint?: StyleDefinitionVariant[ 'meta' ][ 'breakpoint' ];
|
|
16
16
|
displayLabel: string;
|
|
17
17
|
value: ReactNode | string;
|
|
18
|
-
chipColor: ChipColors;
|
|
19
18
|
};
|
|
20
19
|
|
|
21
20
|
export const useNormalizedInheritanceChainItems = (
|
|
@@ -74,7 +73,6 @@ export const normalizeInheritanceItem = async (
|
|
|
74
73
|
breakpoint: breakpoint ?? DEFAULT_BREAKPOINT,
|
|
75
74
|
displayLabel,
|
|
76
75
|
value: await getTransformedValue( item, bind, resolve ),
|
|
77
|
-
chipColor: getChipColor( item ),
|
|
78
76
|
};
|
|
79
77
|
};
|
|
80
78
|
|
|
@@ -105,17 +103,3 @@ const getTransformedValue = async (
|
|
|
105
103
|
return '';
|
|
106
104
|
}
|
|
107
105
|
};
|
|
108
|
-
|
|
109
|
-
const getChipColor = ( item: SnapshotPropValue ) => {
|
|
110
|
-
const { provider = '', style } = item;
|
|
111
|
-
|
|
112
|
-
if ( provider === ELEMENTS_BASE_STYLES_PROVIDER_KEY ) {
|
|
113
|
-
return 'default';
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
if ( style?.label === 'local' ) {
|
|
117
|
-
return 'accent';
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
return 'global';
|
|
121
|
-
};
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { type BreakpointId } from '@elementor/editor-responsive';
|
|
2
|
-
import { type StyleDefinitionState } from '@elementor/editor-styles';
|
|
2
|
+
import { type StyleDefinitionState, type StyleDefinitionVariant } from '@elementor/editor-styles';
|
|
3
|
+
|
|
4
|
+
import { type SnapshotPropValue } from './types';
|
|
3
5
|
|
|
4
6
|
export const DEFAULT_STATE = 'normal';
|
|
5
7
|
|
|
@@ -8,3 +10,17 @@ const DEFAULT_BREAKPOINT = 'desktop';
|
|
|
8
10
|
export const getStateKey = ( state: StyleDefinitionState ) => state ?? DEFAULT_STATE;
|
|
9
11
|
|
|
10
12
|
export const getBreakpointKey = ( breakpoint: BreakpointId | null ): BreakpointId => breakpoint ?? DEFAULT_BREAKPOINT;
|
|
13
|
+
|
|
14
|
+
export const getValueFromInheritanceChain = (
|
|
15
|
+
inheritanceChain: SnapshotPropValue[],
|
|
16
|
+
styleId: string,
|
|
17
|
+
meta: StyleDefinitionVariant[ 'meta' ]
|
|
18
|
+
) =>
|
|
19
|
+
inheritanceChain.find(
|
|
20
|
+
( {
|
|
21
|
+
style,
|
|
22
|
+
variant: {
|
|
23
|
+
meta: { breakpoint, state },
|
|
24
|
+
},
|
|
25
|
+
} ) => style.id === styleId && breakpoint === meta.breakpoint && state === meta.state
|
|
26
|
+
);
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { ELEMENTS_BASE_STYLES_PROVIDER_KEY, isElementsStylesProvider } from '@elementor/editor-styles-repository';
|
|
2
|
+
import { type ChipProps, type Theme } from '@elementor/ui';
|
|
3
|
+
|
|
4
|
+
import { getStyleProviderColors } from '../provider-colors-registry';
|
|
5
|
+
|
|
6
|
+
export const getStylesProviderColorName = ( provider: string ): ChipProps[ 'color' ] => {
|
|
7
|
+
if ( ! provider || provider === ELEMENTS_BASE_STYLES_PROVIDER_KEY ) {
|
|
8
|
+
return 'default';
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
if ( isElementsStylesProvider( provider ) ) {
|
|
12
|
+
return 'accent';
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
return getStyleProviderColors( provider ).name;
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
export const getStylesProviderThemeColor = ( provider: string ): ( ( theme: Theme ) => string ) | null => {
|
|
19
|
+
if ( ! provider || provider === ELEMENTS_BASE_STYLES_PROVIDER_KEY ) {
|
|
20
|
+
return null;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
if ( isElementsStylesProvider( provider ) ) {
|
|
24
|
+
return ( theme: Theme ) => theme.palette.accent.main;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
return getStyleProviderColors( provider ).getThemeColor;
|
|
28
|
+
};
|