@elementor/editor-editing-panel 0.19.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.
Files changed (115) hide show
  1. package/CHANGELOG.md +51 -0
  2. package/dist/index.d.mts +5 -22
  3. package/dist/index.d.ts +5 -22
  4. package/dist/index.js +1444 -1165
  5. package/dist/index.js.map +1 -1
  6. package/dist/index.mjs +1434 -1148
  7. package/dist/index.mjs.map +1 -1
  8. package/package.json +15 -14
  9. package/src/components/accordion-section.tsx +3 -2
  10. package/src/components/add-or-remove-content.tsx +42 -0
  11. package/src/components/collapsible-field.tsx +34 -0
  12. package/src/components/editing-panel.tsx +15 -18
  13. package/src/components/settings-tab.tsx +11 -10
  14. package/src/components/style-sections/background-section/background-color-field.tsx +21 -0
  15. package/src/components/style-sections/background-section/background-section.tsx +2 -2
  16. package/src/components/style-sections/border-section/border-color-field.tsx +21 -0
  17. package/src/components/style-sections/border-section/border-field.tsx +47 -0
  18. package/src/components/style-sections/border-section/border-radius-field.tsx +48 -0
  19. package/src/components/style-sections/border-section/border-section.tsx +16 -0
  20. package/src/components/style-sections/border-section/border-style-field.tsx +32 -0
  21. package/src/components/style-sections/border-section/border-width-field.tsx +42 -0
  22. package/src/components/style-sections/effects-section/effects-section.tsx +5 -5
  23. package/src/components/style-sections/position-section/dimensions-field.tsx +46 -0
  24. package/src/components/style-sections/position-section/position-field.tsx +28 -0
  25. package/src/components/style-sections/position-section/position-section.tsx +15 -2
  26. package/src/components/style-sections/position-section/z-index-field.tsx +21 -0
  27. package/src/components/style-sections/size-section/overflow-field.tsx +45 -0
  28. package/src/components/style-sections/size-section/size-section.tsx +55 -0
  29. package/src/components/style-sections/spacing-section/spacing-section.tsx +6 -6
  30. package/src/components/style-sections/typography-section/font-size-field.tsx +21 -0
  31. package/src/components/style-sections/typography-section/{font-weight-control.tsx → font-weight-field.tsx} +7 -6
  32. package/src/components/style-sections/typography-section/letter-spacing-field.tsx +21 -0
  33. package/src/components/style-sections/typography-section/{text-alignment-control.tsx → text-alignment-field.tsx} +7 -7
  34. package/src/components/style-sections/typography-section/text-color-field.tsx +21 -0
  35. package/src/components/style-sections/typography-section/{text-direction-control.tsx → text-direction-field.tsx} +7 -7
  36. package/src/components/style-sections/typography-section/text-stroke-field.tsx +16 -0
  37. package/src/components/style-sections/typography-section/{text-style-control.tsx → text-style-field.tsx} +4 -4
  38. package/src/components/style-sections/typography-section/{transform-control.tsx → transform-field.tsx} +7 -6
  39. package/src/components/style-sections/typography-section/typography-section.tsx +20 -18
  40. package/src/components/style-sections/typography-section/word-spacing-field.tsx +21 -0
  41. package/src/components/style-tab.tsx +42 -25
  42. package/src/contexts/classes-prop-context.tsx +24 -0
  43. package/src/{controls/providers/element-provider.tsx → contexts/element-context.tsx} +3 -7
  44. package/src/contexts/style-context.tsx +8 -22
  45. package/src/control-replacement.tsx +1 -1
  46. package/src/controls/bound-prop-context.tsx +30 -0
  47. package/src/controls/components/control-toggle-button-group.tsx +15 -6
  48. package/src/controls/components/repeater.tsx +1 -1
  49. package/src/controls/components/text-field-inner-selection.tsx +20 -24
  50. package/src/controls/control-actions/control-actions-context.tsx +27 -0
  51. package/src/controls/control-actions/control-actions-menu.ts +6 -7
  52. package/src/controls/control-actions/control-actions.tsx +14 -26
  53. package/src/{components/style-sections/effects-section/box-shadow-repeater.tsx → controls/controls/box-shadow-repeater-control.tsx} +51 -65
  54. package/src/controls/controls/color-control.tsx +25 -0
  55. package/src/controls/controls/equal-unequal-sizes-control.tsx +196 -0
  56. package/src/controls/{control-types → controls}/image-control.tsx +15 -23
  57. package/src/controls/{control-types → controls}/image-media-control.tsx +5 -14
  58. package/src/{components/style-sections/spacing-section → controls/controls}/linked-dimensions-control.tsx +10 -26
  59. package/src/controls/{control-types → controls}/number-control.tsx +2 -2
  60. package/src/controls/{control-types → controls}/select-control.tsx +4 -4
  61. package/src/controls/{control-types → controls}/size-control.tsx +8 -8
  62. package/src/controls/controls/stroke-control.tsx +105 -0
  63. package/src/controls/{control-types → controls}/text-area-control.tsx +3 -3
  64. package/src/controls/{control-types → controls}/text-control.tsx +3 -3
  65. package/src/controls/{control-types → controls}/toggle-control.tsx +4 -4
  66. package/src/controls/create-control-replacement.tsx +3 -3
  67. package/src/controls/index.ts +24 -0
  68. package/src/controls-actions.ts +8 -0
  69. package/src/{controls/components → controls-registry}/control-type-container.tsx +1 -1
  70. package/src/{controls → controls-registry}/controls-registry.tsx +1 -6
  71. package/src/controls-registry/settings-field.tsx +35 -0
  72. package/src/controls-registry/styles-field.tsx +19 -0
  73. package/src/dynamics/components/dynamic-selection-control.tsx +11 -11
  74. package/src/dynamics/components/dynamic-selection.tsx +3 -3
  75. package/src/dynamics/dynamic-control.tsx +6 -5
  76. package/src/dynamics/hooks/use-dynamic-tag.ts +1 -1
  77. package/src/dynamics/hooks/use-prop-dynamic-action.tsx +6 -6
  78. package/src/dynamics/hooks/use-prop-dynamic-tags.ts +2 -2
  79. package/src/dynamics/hooks/use-prop-value-history.ts +2 -2
  80. package/src/dynamics/init.ts +1 -3
  81. package/src/dynamics/types.ts +2 -2
  82. package/src/dynamics/utils.ts +1 -2
  83. package/src/hooks/use-styles-field.ts +30 -0
  84. package/src/index.ts +2 -3
  85. package/src/sync/should-use-v2-panel.ts +1 -2
  86. package/src/sync/types.ts +3 -3
  87. package/src/components/style-sections/background-section/background-color-control.tsx +0 -20
  88. package/src/components/style-sections/position-section/z-index-control.tsx +0 -20
  89. package/src/components/style-sections/size-section.tsx +0 -49
  90. package/src/components/style-sections/typography-section/font-size-control.tsx +0 -20
  91. package/src/components/style-sections/typography-section/letter-spacing-control.tsx +0 -20
  92. package/src/components/style-sections/typography-section/text-color-control.tsx +0 -20
  93. package/src/components/style-sections/typography-section/word-spacing-control.tsx +0 -20
  94. package/src/controls/control-context.tsx +0 -22
  95. package/src/controls/control-replacement.ts +0 -34
  96. package/src/controls/control-types/color-control.tsx +0 -27
  97. package/src/controls/hooks/use-style-control.ts +0 -29
  98. package/src/controls/hooks/use-widget-settings.ts +0 -16
  99. package/src/controls/props/is-transformable.ts +0 -13
  100. package/src/controls/props/types.ts +0 -51
  101. package/src/controls/settings-control.tsx +0 -37
  102. package/src/controls/style-control.tsx +0 -20
  103. package/src/controls/sync/get-container.ts +0 -8
  104. package/src/controls/sync/update-settings.ts +0 -14
  105. package/src/controls/types.ts +0 -39
  106. package/src/hooks/use-element-style-prop.ts +0 -46
  107. package/src/hooks/use-element-styles.ts +0 -13
  108. package/src/hooks/use-element-type.ts +0 -33
  109. package/src/hooks/use-selected-elements.ts +0 -9
  110. package/src/sync/get-element-styles.ts +0 -9
  111. package/src/sync/get-selected-elements.ts +0 -21
  112. package/src/sync/get-widgets-cache.ts +0 -7
  113. package/src/sync/update-style.ts +0 -25
  114. package/src/{controls → controls-registry}/control.tsx +0 -0
  115. package/src/{controls/control-actions/actions/popover-action.tsx → popover-action.tsx} +1 -1
@@ -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
- <ToggleButton key={ buttonValue } value={ buttonValue } aria-label={ label } size={ size }>
54
- <Icon fontSize={ size } />
55
- </ToggleButton>
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={ { py: 0.5 } }>
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
1
  import * as React from 'react';
2
- import { useId } 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 { PropValue } from '../props/types';
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
- type,
18
- value,
19
- onChange,
20
- endAdornment,
21
- startAdornment,
22
- }: TextFieldInnerSelectionProps ) => {
23
- return (
24
- <TextField
25
- size="tiny"
26
- type={ type }
27
- value={ value }
28
- onChange={ onChange }
29
- placeholder={ placeholder }
30
- InputProps={ {
31
- endAdornment,
32
- startAdornment,
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 PopoverAction from './actions/popover-action';
2
- import { createMenu } from '@elementor/menus';
1
+ import { Components, createMenu } from '@elementor/menus';
3
2
 
4
- export const controlActionsMenu = createMenu( {
5
- components: {
6
- PopoverAction,
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 { controlActionsMenu } from './control-actions-menu';
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 FloatingBar = styled( UnstableFloatingActionBar )`
10
- & .MuiPaper-root:empty {
11
- display: none;
12
- }
7
+ const FloatingBarContainer = styled( 'span' )`
8
+ display: contents;
13
9
 
14
- // this is for a fix which would be added later on - to force the width externally
15
- width: 100%;
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( { fullWidth = false, children }: ControlActionsProps ) {
26
- const items = useMenuItems().default;
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
- <FloatingBar
34
- actions={ items.map( ( { MenuItem, id } ) => (
35
- <MenuItem key={ id } />
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 { Grid, Stack, UnstableColorIndicator } from '@elementor/ui';
4
- import { Repeater } from '../../../controls/components/repeater';
5
- import { ControlContext, useControl } from '../../../controls/control-context';
6
- import { PropValue, TransformablePropValue } from '../../../controls/props/types';
7
- import { SizeControl, SizeControlValue } from '../../../controls/control-types/size-control';
8
- import { ColorControl, ColorPropValue } from '../../../controls/control-types/color-control';
9
- import { ControlLabel } from '../../control-label';
10
- import { SelectControl } from '../../../controls/control-types/select-control';
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 type BoxShadow = TransformablePropValue< 'box-shadow', Shadow[] >;
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: BoxShadow[ 'value' ] ) => {
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: Shadow } ) => (
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
- anchorEl: HTMLElement | null;
65
- value: Shadow;
66
- setValue: ( newValue: Shadow ) => void;
49
+ value: ShadowPropValue;
50
+ setValue: ( newValue: ShadowPropValue ) => void;
67
51
  } ) => {
68
- const setShadow = ( newValue: Shadow[ 'value' ] ) => {
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: ColorPropValue ) => setShadow( { ...value.value, color: 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: string ) => setShadow( { ...value.value, position: 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: 'outset' },
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: SizeControlValue ) => setShadow( { ...value.value, hOffset: 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: SizeControlValue ) => setShadow( { ...value.value, vOffset: 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: SizeControlValue ) => setShadow( { ...value.value, blur: 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: SizeControlValue ) => setShadow( { ...value.value, spread: 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
- <ControlContext.Provider value={ { value, setValue: setValue as SetContextValue, bind } }>
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
- <ControlLabel>{ label }</ControlLabel>
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
- </ControlContext.Provider>
160
+ </BoundPropProvider>
175
161
  );
176
162
 
177
- const ItemLabel = ( { value }: { value: Shadow } ) => {
163
+ const ItemLabel = ( { value }: { value: ShadowPropValue } ) => {
178
164
  const { position, hOffset, vOffset, blur, spread } = value.value;
179
165
 
180
- const { size: hOffsetSize, unit: hOffsetUnit } = hOffset.value;
181
- const { size: vOffsetSize, unit: vOffsetUnit } = vOffset.value;
182
- const { size: blurSize, unit: blurUnit } = blur.value;
183
- const { size: spreadSize, unit: spreadUnit } = spread.value;
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: Shadow = {
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: 0 },
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, 0)',
206
+ value: 'rgba(0, 0, 0, 1)',
221
207
  },
222
- position: 'inset',
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
+ );