@elementor/editor-editing-panel 0.18.0 → 1.0.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 +64 -0
- package/dist/index.d.mts +8 -24
- package/dist/index.d.ts +8 -24
- package/dist/index.js +1452 -1122
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1436 -1099
- package/dist/index.mjs.map +1 -1
- package/package.json +15 -14
- package/src/components/accordion-section.tsx +3 -2
- package/src/components/add-or-remove-content.tsx +42 -0
- package/src/components/collapsible-field.tsx +34 -0
- package/src/components/editing-panel-error-fallback.tsx +12 -0
- package/src/components/editing-panel.tsx +27 -19
- package/src/components/settings-tab.tsx +12 -11
- package/src/components/style-sections/background-section/background-color-field.tsx +21 -0
- package/src/components/style-sections/background-section/background-section.tsx +15 -0
- package/src/components/style-sections/border-section/border-color-field.tsx +21 -0
- package/src/components/style-sections/border-section/border-field.tsx +47 -0
- package/src/components/style-sections/border-section/border-radius-field.tsx +48 -0
- package/src/components/style-sections/border-section/border-section.tsx +16 -0
- package/src/components/style-sections/border-section/border-style-field.tsx +32 -0
- package/src/components/style-sections/border-section/border-width-field.tsx +42 -0
- package/src/components/style-sections/effects-section/effects-section.tsx +5 -5
- package/src/components/style-sections/position-section/dimensions-field.tsx +46 -0
- package/src/components/style-sections/position-section/position-field.tsx +28 -0
- package/src/components/style-sections/position-section/position-section.tsx +15 -2
- package/src/components/style-sections/position-section/z-index-field.tsx +21 -0
- package/src/components/style-sections/size-section/overflow-field.tsx +45 -0
- package/src/components/style-sections/size-section/size-section.tsx +55 -0
- package/src/components/style-sections/spacing-section/spacing-section.tsx +6 -6
- package/src/components/style-sections/typography-section/font-size-field.tsx +21 -0
- package/src/components/style-sections/typography-section/{font-weight-control.tsx → font-weight-field.tsx} +7 -6
- package/src/components/style-sections/typography-section/letter-spacing-field.tsx +21 -0
- package/src/components/style-sections/typography-section/{text-alignment-control.tsx → text-alignment-field.tsx} +8 -8
- package/src/components/style-sections/typography-section/text-color-field.tsx +21 -0
- package/src/components/style-sections/typography-section/{text-direction-control.tsx → text-direction-field.tsx} +8 -8
- package/src/components/style-sections/typography-section/text-stroke-field.tsx +16 -0
- package/src/components/style-sections/typography-section/{text-style-control.tsx → text-style-field.tsx} +5 -5
- package/src/components/style-sections/typography-section/{transform-control.tsx → transform-field.tsx} +8 -7
- package/src/components/style-sections/typography-section/typography-section.tsx +20 -18
- package/src/components/style-sections/typography-section/word-spacing-field.tsx +21 -0
- package/src/components/style-tab.tsx +44 -25
- package/src/contexts/classes-prop-context.tsx +24 -0
- package/src/contexts/element-context.tsx +6 -10
- package/src/contexts/style-context.tsx +8 -22
- package/src/control-replacement.tsx +3 -0
- package/src/controls/bound-prop-context.tsx +30 -0
- package/src/controls/components/control-toggle-button-group.tsx +15 -6
- package/src/controls/components/repeater.tsx +1 -1
- package/src/controls/components/text-field-inner-selection.tsx +20 -24
- package/src/controls/control-actions/control-actions-context.tsx +27 -0
- package/src/controls/control-actions/control-actions-menu.ts +6 -7
- package/src/controls/control-actions/control-actions.tsx +14 -26
- package/src/{components/style-sections/effects-section/box-shadow-repeater.tsx → controls/controls/box-shadow-repeater-control.tsx} +51 -65
- package/src/controls/controls/color-control.tsx +25 -0
- package/src/controls/controls/equal-unequal-sizes-control.tsx +196 -0
- package/src/controls/{control-types → controls}/image-control.tsx +15 -23
- package/src/controls/{control-types → controls}/image-media-control.tsx +5 -14
- package/src/{components/style-sections/spacing-section → controls/controls}/linked-dimensions-control.tsx +10 -26
- package/src/controls/{control-types → controls}/number-control.tsx +2 -2
- package/src/controls/{control-types → controls}/select-control.tsx +4 -4
- package/src/controls/{control-types → controls}/size-control.tsx +8 -8
- package/src/controls/controls/stroke-control.tsx +105 -0
- package/src/controls/{control-types → controls}/text-area-control.tsx +3 -3
- package/src/controls/{control-types → controls}/text-control.tsx +3 -3
- package/src/controls/{control-types → controls}/toggle-control.tsx +4 -4
- package/src/controls/create-control-replacement.tsx +53 -0
- package/src/controls/create-control.tsx +12 -3
- package/src/controls/index.ts +24 -0
- package/src/controls-actions.ts +8 -0
- package/src/{controls/components → controls-registry}/control-type-container.tsx +1 -1
- package/src/{controls → controls-registry}/controls-registry.tsx +1 -6
- package/src/controls-registry/settings-field.tsx +35 -0
- package/src/controls-registry/styles-field.tsx +19 -0
- package/src/dynamics/components/dynamic-selection-control.tsx +11 -11
- package/src/dynamics/components/dynamic-selection.tsx +6 -6
- package/src/dynamics/dynamic-control.tsx +6 -5
- package/src/dynamics/hooks/use-dynamic-tag.ts +2 -2
- package/src/dynamics/hooks/use-prop-dynamic-action.tsx +7 -7
- package/src/dynamics/hooks/use-prop-dynamic-tags.ts +3 -3
- package/src/dynamics/hooks/use-prop-value-history.ts +3 -3
- package/src/dynamics/init.ts +2 -4
- package/src/dynamics/types.ts +2 -1
- package/src/dynamics/utils.ts +1 -2
- package/src/hooks/use-styles-field.ts +30 -0
- package/src/index.ts +3 -4
- package/src/sync/should-use-v2-panel.ts +1 -2
- package/src/sync/types.ts +3 -2
- package/src/components/style-sections/position-section/z-index-control.tsx +0 -20
- package/src/components/style-sections/size-section.tsx +0 -49
- package/src/components/style-sections/typography-section/font-size-control.tsx +0 -20
- package/src/components/style-sections/typography-section/letter-spacing-control.tsx +0 -20
- package/src/components/style-sections/typography-section/text-color-control.tsx +0 -20
- package/src/components/style-sections/typography-section/word-spacing-control.tsx +0 -20
- package/src/controls/control-context.tsx +0 -22
- package/src/controls/control-replacement.ts +0 -34
- package/src/controls/control-types/color-control.tsx +0 -27
- package/src/controls/hooks/use-style-control.ts +0 -29
- package/src/controls/settings-control.tsx +0 -37
- package/src/controls/style-control.tsx +0 -20
- package/src/hooks/use-element-style-prop.ts +0 -45
- package/src/hooks/use-element-styles.ts +0 -13
- package/src/hooks/use-element-type.ts +0 -33
- package/src/hooks/use-selected-elements.ts +0 -9
- package/src/hooks/use-widget-settings.ts +0 -16
- package/src/props/is-transformable.ts +0 -14
- package/src/sync/get-container.ts +0 -8
- package/src/sync/get-element-styles.ts +0 -9
- package/src/sync/get-selected-elements.ts +0 -21
- package/src/sync/get-widgets-cache.ts +0 -7
- package/src/sync/update-settings.ts +0 -14
- package/src/sync/update-style.ts +0 -24
- package/src/types.ts +0 -89
- package/src/{controls → controls-registry}/control.tsx +0 -0
- package/src/{controls/control-actions/actions/popover-action.tsx → popover-action.tsx} +1 -1
|
@@ -1,35 +1,21 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import { createContext,
|
|
3
|
-
import {
|
|
4
|
-
import { StyleDefinition, StyleVariant } from '@elementor/editor-style';
|
|
2
|
+
import { createContext, PropsWithChildren, useContext } from 'react';
|
|
3
|
+
import { StyleDefinition, StyleVariant } from '@elementor/editor-styles';
|
|
5
4
|
|
|
6
5
|
type ContextValue = {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
selectedClassesProp: string;
|
|
6
|
+
id: StyleDefinition[ 'id' ];
|
|
7
|
+
meta: StyleVariant[ 'meta' ];
|
|
10
8
|
};
|
|
11
9
|
|
|
12
10
|
const Context = createContext< ContextValue | null >( null );
|
|
13
11
|
|
|
14
|
-
type Props =
|
|
15
|
-
children: ReactNode;
|
|
16
|
-
selectedStyleDef: StyleDefinition | null;
|
|
17
|
-
selectedClassesProp: string;
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
export function StyleContext( { children, selectedStyleDef, selectedClassesProp }: Props ) {
|
|
21
|
-
const breakpoint = useActiveBreakpoint();
|
|
22
|
-
// TODO: Handle state when we support it.
|
|
23
|
-
const selectedMeta = { breakpoint, state: null } as const;
|
|
12
|
+
type Props = PropsWithChildren< ContextValue >;
|
|
24
13
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
{ children }
|
|
28
|
-
</Context.Provider>
|
|
29
|
-
);
|
|
14
|
+
export function StyleProvider( { children, id, meta }: Props ) {
|
|
15
|
+
return <Context.Provider value={ { id, meta } }>{ children }</Context.Provider>;
|
|
30
16
|
}
|
|
31
17
|
|
|
32
|
-
export function
|
|
18
|
+
export function useStyle() {
|
|
33
19
|
const context = useContext( Context );
|
|
34
20
|
|
|
35
21
|
if ( ! context ) {
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { PropKey, PropValue } from '@elementor/editor-props';
|
|
3
|
+
import { createContext, useContext } from 'react';
|
|
4
|
+
|
|
5
|
+
export type BoundPropContext< T extends PropValue > = {
|
|
6
|
+
bind: PropKey;
|
|
7
|
+
setValue: ( value: T | undefined ) => void;
|
|
8
|
+
value: T | undefined;
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
export type BoundPropProviderProps< T extends PropValue > = BoundPropContext< T > & {
|
|
12
|
+
children: React.ReactNode;
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
const BoundPropContext = createContext< BoundPropContext< PropValue > | null >( null );
|
|
16
|
+
export const BoundPropProvider = ( { children, value, setValue, bind }: BoundPropProviderProps< PropValue > ) => {
|
|
17
|
+
return <BoundPropContext.Provider value={ { value, setValue, bind } }>{ children }</BoundPropContext.Provider>;
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
export function useBoundProp< T extends PropValue >(): BoundPropContext< T | undefined >;
|
|
21
|
+
export function useBoundProp< T extends PropValue >( defaultValue: T ): BoundPropContext< T >;
|
|
22
|
+
export function useBoundProp< T extends PropValue >( defaultValue?: T ) {
|
|
23
|
+
const boundPropContext = useContext< BoundPropContext< T > >( BoundPropContext as never );
|
|
24
|
+
|
|
25
|
+
if ( ! boundPropContext ) {
|
|
26
|
+
throw new Error( 'useBoundProp must be used within a BoundPropContext' );
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
return { ...boundPropContext, value: boundPropContext.value ?? defaultValue };
|
|
30
|
+
}
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { JSX } from 'react';
|
|
3
|
-
import { StackProps, styled, ToggleButton, ToggleButtonGroup } from '@elementor/ui';
|
|
3
|
+
import { StackProps, styled, ToggleButton, ToggleButtonGroup, Tooltip } from '@elementor/ui';
|
|
4
4
|
|
|
5
5
|
export type ToggleButtonGroupItem< TValue > = {
|
|
6
6
|
value: TValue;
|
|
7
7
|
label: string;
|
|
8
8
|
icon: JSX.ElementType;
|
|
9
|
+
showTooltip?: boolean;
|
|
9
10
|
};
|
|
10
11
|
|
|
11
12
|
const StyledToggleButtonGroup = styled( ToggleButtonGroup )`
|
|
@@ -49,11 +50,19 @@ export const ControlToggleButtonGroup = < TValue, >( {
|
|
|
49
50
|
|
|
50
51
|
return (
|
|
51
52
|
<StyledToggleButtonGroup justify={ justify } value={ value } onChange={ handleChange } exclusive={ exclusive }>
|
|
52
|
-
{ items.map( ( { label, value: buttonValue, icon: Icon } ) =>
|
|
53
|
-
|
|
54
|
-
<
|
|
55
|
-
|
|
56
|
-
|
|
53
|
+
{ items.map( ( { label: label, value: buttonValue, icon: Icon, showTooltip: showTooltip } ) =>
|
|
54
|
+
showTooltip ? (
|
|
55
|
+
<Tooltip title={ label } disableFocusListener={ true } placement="top" key={ buttonValue }>
|
|
56
|
+
<ToggleButton value={ buttonValue } aria-label={ label } size={ size }>
|
|
57
|
+
<Icon fontSize={ size } />
|
|
58
|
+
</ToggleButton>
|
|
59
|
+
</Tooltip>
|
|
60
|
+
) : (
|
|
61
|
+
<ToggleButton key={ buttonValue } value={ buttonValue } aria-label={ label } size={ size }>
|
|
62
|
+
<Icon fontSize={ size } />
|
|
63
|
+
</ToggleButton>
|
|
64
|
+
)
|
|
65
|
+
) }
|
|
57
66
|
</StyledToggleButtonGroup>
|
|
58
67
|
);
|
|
59
68
|
};
|
|
@@ -80,7 +80,7 @@ export const Repeater = < T, >( {
|
|
|
80
80
|
|
|
81
81
|
return (
|
|
82
82
|
<Stack>
|
|
83
|
-
<Stack direction="row" justifyContent="space-between" sx={ {
|
|
83
|
+
<Stack direction="row" justifyContent="space-between" alignItems="center" sx={ { pb: 1 } }>
|
|
84
84
|
<Typography component="label" variant="caption" color="text.secondary">
|
|
85
85
|
{ label }
|
|
86
86
|
</Typography>
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { PropValue } from '../../types';
|
|
2
1
|
import * as React from 'react';
|
|
2
|
+
import { forwardRef, useId } from 'react';
|
|
3
|
+
import { PropValue } from '@elementor/editor-props';
|
|
3
4
|
import { bindMenu, bindTrigger, Button, InputAdornment, Menu, MenuItem, TextField, usePopupState } from '@elementor/ui';
|
|
4
|
-
import { useId } from 'react';
|
|
5
5
|
|
|
6
6
|
export type TextFieldInnerSelectionProps = {
|
|
7
7
|
placeholder?: string;
|
|
@@ -12,28 +12,24 @@ export type TextFieldInnerSelectionProps = {
|
|
|
12
12
|
startAdornment?: React.ReactNode;
|
|
13
13
|
};
|
|
14
14
|
|
|
15
|
-
export const TextFieldInnerSelection = (
|
|
16
|
-
placeholder,
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
} }
|
|
34
|
-
/>
|
|
35
|
-
);
|
|
36
|
-
};
|
|
15
|
+
export const TextFieldInnerSelection = forwardRef(
|
|
16
|
+
( { placeholder, type, value, onChange, endAdornment, startAdornment }: TextFieldInnerSelectionProps, ref ) => {
|
|
17
|
+
return (
|
|
18
|
+
<TextField
|
|
19
|
+
size="tiny"
|
|
20
|
+
type={ type }
|
|
21
|
+
value={ value }
|
|
22
|
+
onChange={ onChange }
|
|
23
|
+
placeholder={ placeholder }
|
|
24
|
+
InputProps={ {
|
|
25
|
+
endAdornment,
|
|
26
|
+
startAdornment,
|
|
27
|
+
} }
|
|
28
|
+
ref={ ref }
|
|
29
|
+
/>
|
|
30
|
+
);
|
|
31
|
+
}
|
|
32
|
+
);
|
|
37
33
|
|
|
38
34
|
export type SelectionEndAdornmentProps< T extends string > = {
|
|
39
35
|
options: T[];
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { createContext, PropsWithChildren, useContext } from 'react';
|
|
3
|
+
|
|
4
|
+
type ControlActionsContext = {
|
|
5
|
+
items: Array< {
|
|
6
|
+
id: string;
|
|
7
|
+
MenuItem: React.ComponentType;
|
|
8
|
+
} >;
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
const Context = createContext< ControlActionsContext | null >( null );
|
|
12
|
+
|
|
13
|
+
export type ControlActionsProviderProps = PropsWithChildren< ControlActionsContext >;
|
|
14
|
+
|
|
15
|
+
export const ControlActionsProvider = ( { children, items }: ControlActionsProviderProps ) => (
|
|
16
|
+
<Context.Provider value={ { items } }>{ children }</Context.Provider>
|
|
17
|
+
);
|
|
18
|
+
|
|
19
|
+
export const useControlActions = () => {
|
|
20
|
+
const context = useContext( Context );
|
|
21
|
+
|
|
22
|
+
if ( ! context ) {
|
|
23
|
+
throw new Error( 'useControlActions must be used within a ControlActionsProvider' );
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
return context;
|
|
27
|
+
};
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { createMenu } from '@elementor/menus';
|
|
1
|
+
import { Components, createMenu } from '@elementor/menus';
|
|
3
2
|
|
|
4
|
-
export const
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
}
|
|
8
|
-
}
|
|
3
|
+
export const createControlActionsMenu = ( { components }: { components: Components } ) => {
|
|
4
|
+
return createMenu( {
|
|
5
|
+
components,
|
|
6
|
+
} );
|
|
7
|
+
};
|
|
@@ -1,43 +1,31 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import { styled, UnstableFloatingActionBar } from '@elementor/ui';
|
|
3
2
|
import { PropsWithChildren } from 'react';
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
const { useMenuItems } = controlActionsMenu;
|
|
3
|
+
import { styled, UnstableFloatingActionBar } from '@elementor/ui';
|
|
4
|
+
import { useControlActions } from './control-actions-context';
|
|
7
5
|
|
|
8
6
|
// CSS hack to hide empty floating bars.
|
|
9
|
-
const
|
|
10
|
-
|
|
11
|
-
display: none;
|
|
12
|
-
}
|
|
7
|
+
const FloatingBarContainer = styled( 'span' )`
|
|
8
|
+
display: contents;
|
|
13
9
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
& > :first-of-type {
|
|
17
|
-
width: 100%;
|
|
10
|
+
.MuiFloatingActionBar-popper:has( .MuiFloatingActionBar-actions:empty ) {
|
|
11
|
+
display: none;
|
|
18
12
|
}
|
|
19
13
|
`;
|
|
20
14
|
|
|
21
|
-
export type ControlActionsProps = PropsWithChildren<
|
|
22
|
-
fullWidth?: boolean;
|
|
23
|
-
} >;
|
|
15
|
+
export type ControlActionsProps = PropsWithChildren< object >;
|
|
24
16
|
|
|
25
|
-
export default function ControlActions( {
|
|
26
|
-
const items =
|
|
17
|
+
export default function ControlActions( { children }: ControlActionsProps ) {
|
|
18
|
+
const { items } = useControlActions();
|
|
27
19
|
|
|
28
20
|
if ( items.length === 0 ) {
|
|
29
21
|
return children;
|
|
30
22
|
}
|
|
31
23
|
|
|
24
|
+
const menuItems = items.map( ( { MenuItem, id } ) => <MenuItem key={ id } /> );
|
|
25
|
+
|
|
32
26
|
return (
|
|
33
|
-
<
|
|
34
|
-
actions={
|
|
35
|
-
|
|
36
|
-
) ) }
|
|
37
|
-
// TODO - work on a general layouting solution instead
|
|
38
|
-
sx={ fullWidth ? { width: '100%' } : undefined }
|
|
39
|
-
>
|
|
40
|
-
{ children }
|
|
41
|
-
</FloatingBar>
|
|
27
|
+
<FloatingBarContainer>
|
|
28
|
+
<UnstableFloatingActionBar actions={ menuItems }>{ children }</UnstableFloatingActionBar>
|
|
29
|
+
</FloatingBarContainer>
|
|
42
30
|
);
|
|
43
31
|
}
|
|
@@ -1,36 +1,22 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { __ } from '@wordpress/i18n';
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
3
|
+
import { PropValue, ShadowPropValue, BoxShadowPropValue } from '@elementor/editor-props';
|
|
4
|
+
import { Grid, Stack, Typography, UnstableColorIndicator } from '@elementor/ui';
|
|
5
|
+
import { Repeater } from '../components/repeater';
|
|
6
|
+
import { SizeControl } from './size-control';
|
|
7
|
+
import { ColorControl } from './color-control';
|
|
8
|
+
import { BoundPropProvider, useBoundProp } from '../bound-prop-context';
|
|
9
|
+
import { SelectControl } from './select-control';
|
|
10
|
+
import { createControl } from '../create-control';
|
|
11
11
|
|
|
12
12
|
type SetContextValue = ( v: PropValue ) => void;
|
|
13
13
|
|
|
14
|
-
export
|
|
15
|
-
|
|
16
|
-
export type Shadow = TransformablePropValue<
|
|
17
|
-
'shadow',
|
|
18
|
-
{
|
|
19
|
-
position: string;
|
|
20
|
-
hOffset: SizeControlValue;
|
|
21
|
-
vOffset: SizeControlValue;
|
|
22
|
-
blur: SizeControlValue;
|
|
23
|
-
spread: SizeControlValue;
|
|
24
|
-
color: ColorPropValue;
|
|
25
|
-
}
|
|
26
|
-
>;
|
|
27
|
-
|
|
28
|
-
export const BoxShadowRepeater = () => {
|
|
29
|
-
const { value, setValue } = useControl< BoxShadow >();
|
|
14
|
+
export const BoxShadowRepeaterControl = createControl( () => {
|
|
15
|
+
const { value, setValue } = useBoundProp< BoxShadowPropValue >();
|
|
30
16
|
|
|
31
17
|
const boxShadowValues = value?.value;
|
|
32
18
|
|
|
33
|
-
const setBoxShadow = ( newValue:
|
|
19
|
+
const setBoxShadow = ( newValue: BoxShadowPropValue[ 'value' ] ) => {
|
|
34
20
|
setValue( {
|
|
35
21
|
$$type: 'box-shadow',
|
|
36
22
|
value: newValue,
|
|
@@ -50,22 +36,20 @@ export const BoxShadowRepeater = () => {
|
|
|
50
36
|
} }
|
|
51
37
|
/>
|
|
52
38
|
);
|
|
53
|
-
};
|
|
39
|
+
} );
|
|
54
40
|
|
|
55
|
-
const ItemIcon = ( { value }: { value:
|
|
41
|
+
const ItemIcon = ( { value }: { value: ShadowPropValue } ) => (
|
|
56
42
|
<UnstableColorIndicator size="inherit" component="span" value={ value.value.color.value } />
|
|
57
43
|
);
|
|
58
44
|
|
|
59
45
|
const ItemContent = ( {
|
|
60
|
-
anchorEl,
|
|
61
46
|
value,
|
|
62
47
|
setValue,
|
|
63
48
|
}: {
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
setValue: ( newValue: Shadow ) => void;
|
|
49
|
+
value: ShadowPropValue;
|
|
50
|
+
setValue: ( newValue: ShadowPropValue ) => void;
|
|
67
51
|
} ) => {
|
|
68
|
-
const setShadow = ( newValue:
|
|
52
|
+
const setShadow = ( newValue: ShadowPropValue[ 'value' ] ) => {
|
|
69
53
|
setValue( {
|
|
70
54
|
$$type: 'shadow',
|
|
71
55
|
value: newValue,
|
|
@@ -79,30 +63,24 @@ const ItemContent = ( {
|
|
|
79
63
|
bind="color"
|
|
80
64
|
value={ value.value.color }
|
|
81
65
|
label={ __( 'Color', 'elementor' ) }
|
|
82
|
-
setValue={ ( v:
|
|
66
|
+
setValue={ ( v: ShadowPropValue[ 'value' ][ 'color' ] ) =>
|
|
67
|
+
setShadow( { ...value.value, color: v } )
|
|
68
|
+
}
|
|
83
69
|
>
|
|
84
|
-
<ColorControl
|
|
85
|
-
anchorEl={ anchorEl }
|
|
86
|
-
anchorOrigin={ {
|
|
87
|
-
vertical: 'top',
|
|
88
|
-
horizontal: 'right',
|
|
89
|
-
} }
|
|
90
|
-
transformOrigin={ {
|
|
91
|
-
vertical: 'top',
|
|
92
|
-
horizontal: -10,
|
|
93
|
-
} }
|
|
94
|
-
/>
|
|
70
|
+
<ColorControl />
|
|
95
71
|
</Control>
|
|
96
72
|
<Control
|
|
97
73
|
bind="position"
|
|
98
74
|
value={ value.value.position }
|
|
99
75
|
label={ __( 'Position', 'elementor' ) }
|
|
100
|
-
setValue={ ( v:
|
|
76
|
+
setValue={ ( v: ShadowPropValue[ 'value' ][ 'position' ] ) =>
|
|
77
|
+
setShadow( { ...value.value, position: v || null } )
|
|
78
|
+
}
|
|
101
79
|
>
|
|
102
80
|
<SelectControl
|
|
103
81
|
options={ [
|
|
104
|
-
{ label: 'Inset', value: 'inset' },
|
|
105
|
-
{ label: 'Outset', value: '
|
|
82
|
+
{ label: __( 'Inset', 'elementor' ), value: 'inset' },
|
|
83
|
+
{ label: __( 'Outset', 'elementor' ), value: '' },
|
|
106
84
|
] }
|
|
107
85
|
/>
|
|
108
86
|
</Control>
|
|
@@ -112,15 +90,19 @@ const ItemContent = ( {
|
|
|
112
90
|
bind="hOffset"
|
|
113
91
|
label={ __( 'Horizontal', 'elementor' ) }
|
|
114
92
|
value={ value.value.hOffset }
|
|
115
|
-
setValue={ ( v:
|
|
93
|
+
setValue={ ( v: ShadowPropValue[ 'value' ][ 'hOffset' ] ) =>
|
|
94
|
+
setShadow( { ...value.value, hOffset: v } )
|
|
95
|
+
}
|
|
116
96
|
>
|
|
117
97
|
<SizeControl />
|
|
118
98
|
</Control>
|
|
119
99
|
<Control
|
|
120
|
-
label={ __( 'Vertical', 'elementor' ) }
|
|
121
100
|
bind="vOffset"
|
|
101
|
+
label={ __( 'Vertical', 'elementor' ) }
|
|
122
102
|
value={ value.value.vOffset }
|
|
123
|
-
setValue={ ( v:
|
|
103
|
+
setValue={ ( v: ShadowPropValue[ 'value' ][ 'vOffset' ] ) =>
|
|
104
|
+
setShadow( { ...value.value, vOffset: v } )
|
|
105
|
+
}
|
|
124
106
|
>
|
|
125
107
|
<SizeControl />
|
|
126
108
|
</Control>
|
|
@@ -130,7 +112,7 @@ const ItemContent = ( {
|
|
|
130
112
|
bind="blur"
|
|
131
113
|
value={ value.value.blur }
|
|
132
114
|
label={ __( 'Blur', 'elementor' ) }
|
|
133
|
-
setValue={ ( v:
|
|
115
|
+
setValue={ ( v: ShadowPropValue[ 'value' ][ 'blur' ] ) => setShadow( { ...value.value, blur: v } ) }
|
|
134
116
|
>
|
|
135
117
|
<SizeControl />
|
|
136
118
|
</Control>
|
|
@@ -138,7 +120,9 @@ const ItemContent = ( {
|
|
|
138
120
|
bind="spread"
|
|
139
121
|
label={ __( 'Spread', 'elementor' ) }
|
|
140
122
|
value={ value.value.spread }
|
|
141
|
-
setValue={ ( v:
|
|
123
|
+
setValue={ ( v: ShadowPropValue[ 'value' ][ 'spread' ] ) =>
|
|
124
|
+
setShadow( { ...value.value, spread: v } )
|
|
125
|
+
}
|
|
142
126
|
>
|
|
143
127
|
<SizeControl />
|
|
144
128
|
</Control>
|
|
@@ -160,27 +144,29 @@ const Control = < T extends PropValue >( {
|
|
|
160
144
|
children: React.ReactNode;
|
|
161
145
|
setValue: ( v: T ) => void;
|
|
162
146
|
} ) => (
|
|
163
|
-
<
|
|
147
|
+
<BoundPropProvider value={ value } setValue={ setValue as SetContextValue } bind={ bind }>
|
|
164
148
|
<Grid item xs={ 6 }>
|
|
165
149
|
<Grid container spacing={ 1 } alignItems="center">
|
|
166
150
|
<Grid item xs={ 12 }>
|
|
167
|
-
<
|
|
151
|
+
<Typography component="label" variant="caption" color="text.secondary">
|
|
152
|
+
{ label }
|
|
153
|
+
</Typography>
|
|
168
154
|
</Grid>
|
|
169
155
|
<Grid item xs={ 12 }>
|
|
170
156
|
{ children }
|
|
171
157
|
</Grid>
|
|
172
158
|
</Grid>
|
|
173
159
|
</Grid>
|
|
174
|
-
</
|
|
160
|
+
</BoundPropProvider>
|
|
175
161
|
);
|
|
176
162
|
|
|
177
|
-
const ItemLabel = ( { value }: { value:
|
|
163
|
+
const ItemLabel = ( { value }: { value: ShadowPropValue } ) => {
|
|
178
164
|
const { position, hOffset, vOffset, blur, spread } = value.value;
|
|
179
165
|
|
|
180
|
-
const { size:
|
|
181
|
-
const { size:
|
|
182
|
-
const { size:
|
|
183
|
-
const { size:
|
|
166
|
+
const { size: blurSize = '', unit: blurUnit = '' } = blur?.value || {};
|
|
167
|
+
const { size: spreadSize = '', unit: spreadUnit = '' } = spread?.value || {};
|
|
168
|
+
const { size: hOffsetSize = 'unset', unit: hOffsetUnit = '' } = hOffset?.value || {};
|
|
169
|
+
const { size: vOffsetSize = 'unset', unit: vOffsetUnit = '' } = vOffset?.value || {};
|
|
184
170
|
|
|
185
171
|
const sizes = [
|
|
186
172
|
hOffsetSize + hOffsetUnit,
|
|
@@ -191,12 +177,12 @@ const ItemLabel = ( { value }: { value: Shadow } ) => {
|
|
|
191
177
|
|
|
192
178
|
return (
|
|
193
179
|
<span style={ { textTransform: 'capitalize' } }>
|
|
194
|
-
{ position }: { sizes }
|
|
180
|
+
{ position ?? 'outset' }: { sizes }
|
|
195
181
|
</span>
|
|
196
182
|
);
|
|
197
183
|
};
|
|
198
184
|
|
|
199
|
-
const initialShadow:
|
|
185
|
+
const initialShadow: ShadowPropValue = {
|
|
200
186
|
$$type: 'shadow',
|
|
201
187
|
value: {
|
|
202
188
|
hOffset: {
|
|
@@ -209,7 +195,7 @@ const initialShadow: Shadow = {
|
|
|
209
195
|
},
|
|
210
196
|
blur: {
|
|
211
197
|
$$type: 'size',
|
|
212
|
-
value: { unit: 'px', size:
|
|
198
|
+
value: { unit: 'px', size: 10 },
|
|
213
199
|
},
|
|
214
200
|
spread: {
|
|
215
201
|
$$type: 'size',
|
|
@@ -217,8 +203,8 @@ const initialShadow: Shadow = {
|
|
|
217
203
|
},
|
|
218
204
|
color: {
|
|
219
205
|
$$type: 'color',
|
|
220
|
-
value: 'rgba(0, 0, 0,
|
|
206
|
+
value: 'rgba(0, 0, 0, 1)',
|
|
221
207
|
},
|
|
222
|
-
position:
|
|
208
|
+
position: null,
|
|
223
209
|
},
|
|
224
210
|
};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { UnstableColorField, UnstableColorFieldProps } from '@elementor/ui';
|
|
3
|
+
import { useBoundProp } from '../bound-prop-context';
|
|
4
|
+
import ControlActions from '../control-actions/control-actions';
|
|
5
|
+
import { createControl } from '../create-control';
|
|
6
|
+
import { ColorPropValue } from '@elementor/editor-props';
|
|
7
|
+
|
|
8
|
+
export const ColorControl = createControl(
|
|
9
|
+
( props: Partial< Omit< UnstableColorFieldProps, 'value' | 'onChange' > > ) => {
|
|
10
|
+
const { value, setValue } = useBoundProp< ColorPropValue >();
|
|
11
|
+
|
|
12
|
+
const handleChange = ( selectedColor: string ) => {
|
|
13
|
+
setValue( {
|
|
14
|
+
$$type: 'color',
|
|
15
|
+
value: selectedColor,
|
|
16
|
+
} );
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
return (
|
|
20
|
+
<ControlActions>
|
|
21
|
+
<UnstableColorField size="tiny" { ...props } value={ value?.value } onChange={ handleChange } />
|
|
22
|
+
</ControlActions>
|
|
23
|
+
);
|
|
24
|
+
}
|
|
25
|
+
);
|