@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.
- package/CHANGELOG.md +51 -0
- package/dist/index.d.mts +5 -22
- package/dist/index.d.ts +5 -22
- package/dist/index.js +1444 -1165
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1434 -1148
- 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.tsx +15 -18
- package/src/components/settings-tab.tsx +11 -10
- package/src/components/style-sections/background-section/background-color-field.tsx +21 -0
- package/src/components/style-sections/background-section/background-section.tsx +2 -2
- 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} +7 -7
- 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} +7 -7
- 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} +4 -4
- package/src/components/style-sections/typography-section/{transform-control.tsx → transform-field.tsx} +7 -6
- 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 +42 -25
- package/src/contexts/classes-prop-context.tsx +24 -0
- package/src/{controls/providers/element-provider.tsx → contexts/element-context.tsx} +3 -7
- package/src/contexts/style-context.tsx +8 -22
- package/src/control-replacement.tsx +1 -1
- 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 +3 -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 +3 -3
- package/src/dynamics/dynamic-control.tsx +6 -5
- package/src/dynamics/hooks/use-dynamic-tag.ts +1 -1
- package/src/dynamics/hooks/use-prop-dynamic-action.tsx +6 -6
- package/src/dynamics/hooks/use-prop-dynamic-tags.ts +2 -2
- package/src/dynamics/hooks/use-prop-value-history.ts +2 -2
- package/src/dynamics/init.ts +1 -3
- package/src/dynamics/types.ts +2 -2
- package/src/dynamics/utils.ts +1 -2
- package/src/hooks/use-styles-field.ts +30 -0
- package/src/index.ts +2 -3
- package/src/sync/should-use-v2-panel.ts +1 -2
- package/src/sync/types.ts +3 -3
- package/src/components/style-sections/background-section/background-color-control.tsx +0 -20
- 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/hooks/use-widget-settings.ts +0 -16
- package/src/controls/props/is-transformable.ts +0 -13
- package/src/controls/props/types.ts +0 -51
- package/src/controls/settings-control.tsx +0 -37
- package/src/controls/style-control.tsx +0 -20
- package/src/controls/sync/get-container.ts +0 -8
- package/src/controls/sync/update-settings.ts +0 -14
- package/src/controls/types.ts +0 -39
- package/src/hooks/use-element-style-prop.ts +0 -46
- 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/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-style.ts +0 -25
- package/src/{controls → controls-registry}/control.tsx +0 -0
- package/src/{controls/control-actions/actions/popover-action.tsx → popover-action.tsx} +1 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { styled, Box, BoxProps } from '@elementor/ui';
|
|
3
|
-
import { ControlLayout, ControlType, getLayoutByType } from '
|
|
3
|
+
import { ControlLayout, ControlType, getLayoutByType } from './controls-registry';
|
|
4
4
|
|
|
5
5
|
export const ControlTypeContainer = ( {
|
|
6
6
|
controlType,
|
|
@@ -1,9 +1,4 @@
|
|
|
1
|
-
import { ImageControl } from '
|
|
2
|
-
import { TextControl } from './control-types/text-control';
|
|
3
|
-
import { TextAreaControl } from './control-types/text-area-control';
|
|
4
|
-
import { SizeControl } from './control-types/size-control';
|
|
5
|
-
import { SelectControl } from './control-types/select-control';
|
|
6
|
-
import { ControlComponent } from './create-control';
|
|
1
|
+
import { ControlComponent, ImageControl, SelectControl, SizeControl, TextAreaControl, TextControl } from '../controls';
|
|
7
2
|
|
|
8
3
|
export type ControlLayout = 'full' | 'two-columns';
|
|
9
4
|
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { PropKey, PropValue } from '@elementor/editor-props';
|
|
3
|
+
import { useElementSetting, updateSettings } from '@elementor/editor-elements';
|
|
4
|
+
import { useElement } from '../contexts/element-context';
|
|
5
|
+
import { BoundPropProvider } from '../controls';
|
|
6
|
+
|
|
7
|
+
type Props = {
|
|
8
|
+
bind: PropKey;
|
|
9
|
+
children: React.ReactNode;
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
const SettingsField = ( { bind, children }: Props ) => {
|
|
13
|
+
const { element, elementType } = useElement();
|
|
14
|
+
|
|
15
|
+
const defaultValue = elementType.propsSchema[ bind ]?.default;
|
|
16
|
+
const settingsValue = useElementSetting( { id: element.id, bind } );
|
|
17
|
+
const value = settingsValue ?? defaultValue ?? null;
|
|
18
|
+
|
|
19
|
+
const setValue = ( newValue: PropValue ) => {
|
|
20
|
+
updateSettings( {
|
|
21
|
+
id: element.id,
|
|
22
|
+
props: {
|
|
23
|
+
[ bind ]: newValue,
|
|
24
|
+
},
|
|
25
|
+
} );
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
return (
|
|
29
|
+
<BoundPropProvider setValue={ setValue } value={ value } bind={ bind }>
|
|
30
|
+
{ children }
|
|
31
|
+
</BoundPropProvider>
|
|
32
|
+
);
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
export { SettingsField };
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { PropKey } from '@elementor/editor-props';
|
|
3
|
+
import { useStylesField } from '../hooks/use-styles-field';
|
|
4
|
+
import { BoundPropProvider } from '../controls';
|
|
5
|
+
|
|
6
|
+
export type StylesFieldProps = {
|
|
7
|
+
bind: PropKey;
|
|
8
|
+
children: React.ReactNode;
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
export const StylesField = ( { bind, children }: StylesFieldProps ) => {
|
|
12
|
+
const [ value, setValue ] = useStylesField( bind );
|
|
13
|
+
|
|
14
|
+
return (
|
|
15
|
+
<BoundPropProvider setValue={ setValue } value={ value } bind={ bind }>
|
|
16
|
+
{ children }
|
|
17
|
+
</BoundPropProvider>
|
|
18
|
+
);
|
|
19
|
+
};
|
|
@@ -1,15 +1,8 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { useId } from 'react';
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import { DynamicControl } from '../dynamic-control';
|
|
3
|
+
import { __ } from '@wordpress/i18n';
|
|
4
|
+
import type { Control, ControlsSection } from '@elementor/editor-elements';
|
|
6
5
|
import { DatabaseIcon, SettingsIcon, XIcon } from '@elementor/icons';
|
|
7
|
-
import type { Control, ControlsSection } from '../../controls/types';
|
|
8
|
-
import { DynamicSelection } from './dynamic-selection';
|
|
9
|
-
import { ControlType, getControlByType } from '../../controls/controls-registry';
|
|
10
|
-
import { ControlLabel } from '../../components/control-label';
|
|
11
|
-
import { Control as BaseControl } from '../../controls/control';
|
|
12
|
-
import { useDynamicTag } from '../hooks/use-dynamic-tag';
|
|
13
6
|
import {
|
|
14
7
|
bindPopover,
|
|
15
8
|
bindTrigger,
|
|
@@ -27,13 +20,20 @@ import {
|
|
|
27
20
|
Tab,
|
|
28
21
|
TabPanel,
|
|
29
22
|
} from '@elementor/ui';
|
|
30
|
-
import {
|
|
23
|
+
import { useBoundProp } from '../../controls';
|
|
24
|
+
import { DynamicPropValue, DynamicTag } from '../types';
|
|
25
|
+
import { DynamicControl } from '../dynamic-control';
|
|
26
|
+
import { DynamicSelection } from './dynamic-selection';
|
|
27
|
+
import { ControlLabel } from '../../components/control-label';
|
|
28
|
+
import { Control as BaseControl } from '../../controls-registry/control';
|
|
29
|
+
import { useDynamicTag } from '../hooks/use-dynamic-tag';
|
|
31
30
|
import { usePropValueHistory } from '../hooks/use-prop-value-history';
|
|
31
|
+
import { ControlType, getControlByType } from '../../controls-registry/controls-registry';
|
|
32
32
|
|
|
33
33
|
const SIZE = 'tiny';
|
|
34
34
|
|
|
35
35
|
export const DynamicSelectionControl = () => {
|
|
36
|
-
const { bind, value, setValue } =
|
|
36
|
+
const { bind, value, setValue } = useBoundProp< DynamicPropValue | null >();
|
|
37
37
|
const [ propValueFromHistory ] = usePropValueHistory( bind );
|
|
38
38
|
const { name: tagName = '' } = value?.value || {};
|
|
39
39
|
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { useState, Fragment } from 'react';
|
|
3
|
+
import { PropKey, PropValue } from '@elementor/editor-props';
|
|
3
4
|
import { SearchIcon, PhotoIcon } from '@elementor/icons';
|
|
4
5
|
import {
|
|
5
6
|
Box,
|
|
@@ -14,13 +15,12 @@ import {
|
|
|
14
15
|
Typography,
|
|
15
16
|
} from '@elementor/ui';
|
|
16
17
|
import { __ } from '@wordpress/i18n';
|
|
17
|
-
import {
|
|
18
|
+
import { useBoundProp } from '../../controls';
|
|
18
19
|
import { usePropDynamicTags } from '../hooks/use-prop-dynamic-tags';
|
|
19
20
|
import { getAtomicDynamicTags } from '../sync/get-atomic-dynamic-tags';
|
|
20
21
|
import { isDynamicPropValue } from '../utils';
|
|
21
22
|
import { usePropValueHistory } from '../hooks/use-prop-value-history';
|
|
22
23
|
import { DynamicPropValue } from '../types';
|
|
23
|
-
import { PropKey, PropValue } from '../../controls/props/types';
|
|
24
24
|
|
|
25
25
|
type Option = {
|
|
26
26
|
label: string;
|
|
@@ -38,7 +38,7 @@ export type DynamicSelectionProps = {
|
|
|
38
38
|
export const DynamicSelection = ( { onSelect }: DynamicSelectionProps ) => {
|
|
39
39
|
const [ searchValue, setSearchValue ] = useState( '' );
|
|
40
40
|
const { groups: dynamicGroups } = getAtomicDynamicTags() || {};
|
|
41
|
-
const { bind, value: currentValue, setValue } =
|
|
41
|
+
const { bind, value: currentValue, setValue } = useBoundProp< DynamicPropValue | PropValue >();
|
|
42
42
|
const [ , updatePropValueHistory ] = usePropValueHistory( bind );
|
|
43
43
|
|
|
44
44
|
const isCurrentValueDynamic = isDynamicPropValue( currentValue );
|
|
@@ -1,15 +1,16 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import {
|
|
3
|
-
import { PropKey, PropValue } from '
|
|
2
|
+
import { useBoundProp } from '../controls';
|
|
3
|
+
import { PropKey, PropValue } from '@elementor/editor-props';
|
|
4
4
|
import { useDynamicTag } from './hooks/use-dynamic-tag';
|
|
5
5
|
import { DynamicPropValue } from './types';
|
|
6
|
+
import { BoundPropProvider } from '../controls/bound-prop-context';
|
|
6
7
|
|
|
7
8
|
export type DynamicControlProps = React.PropsWithChildren< {
|
|
8
9
|
bind: PropKey;
|
|
9
10
|
} >;
|
|
10
11
|
|
|
11
12
|
export const DynamicControl = ( { bind, children }: DynamicControlProps ) => {
|
|
12
|
-
const { value, setValue, bind: propName } =
|
|
13
|
+
const { value, setValue, bind: propName } = useBoundProp< DynamicPropValue >();
|
|
13
14
|
const { name = '', settings } = value?.value ?? {};
|
|
14
15
|
|
|
15
16
|
const dynamicTag = useDynamicTag( propName, name );
|
|
@@ -35,8 +36,8 @@ export const DynamicControl = ( { bind, children }: DynamicControlProps ) => {
|
|
|
35
36
|
};
|
|
36
37
|
|
|
37
38
|
return (
|
|
38
|
-
<
|
|
39
|
+
<BoundPropProvider setValue={ setDynamicValue } value={ dynamicValue } bind={ bind }>
|
|
39
40
|
{ children }
|
|
40
|
-
</
|
|
41
|
+
</BoundPropProvider>
|
|
41
42
|
);
|
|
42
43
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { useMemo } from 'react';
|
|
2
|
+
import { PropKey } from '@elementor/editor-props';
|
|
2
3
|
import { usePropDynamicTags } from './use-prop-dynamic-tags';
|
|
3
|
-
import { PropKey } from '../../controls/props/types';
|
|
4
4
|
import { DynamicTag } from '../types';
|
|
5
5
|
|
|
6
6
|
export const useDynamicTag = ( propName: PropKey, tagName: string ): DynamicTag | null => {
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import {
|
|
2
|
+
import { __ } from '@wordpress/i18n';
|
|
3
|
+
import { DatabaseIcon } from '@elementor/icons';
|
|
3
4
|
import { supportsDynamic } from '../utils';
|
|
4
5
|
import { DynamicSelection } from '../components/dynamic-selection';
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import { PopoverActionProps } from '../../controls/control-actions/actions/popover-action';
|
|
6
|
+
import { useBoundProp } from '../../controls';
|
|
7
|
+
import { PopoverActionProps } from '../../popover-action';
|
|
8
|
+
import { useElement } from '../../contexts/element-context';
|
|
9
9
|
|
|
10
10
|
export const usePropDynamicAction = (): PopoverActionProps => {
|
|
11
|
-
const { bind } =
|
|
11
|
+
const { bind } = useBoundProp();
|
|
12
12
|
const { elementType } = useElement();
|
|
13
13
|
|
|
14
14
|
const propType = elementType.propsSchema[ bind ];
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { useMemo } from 'react';
|
|
2
|
-
import {
|
|
2
|
+
import { PropKey } from '@elementor/editor-props';
|
|
3
3
|
import { getAtomicDynamicTags } from '../sync/get-atomic-dynamic-tags';
|
|
4
|
-
import {
|
|
4
|
+
import { useElement } from '../../contexts/element-context';
|
|
5
5
|
import { getDynamicPropType } from '../utils';
|
|
6
6
|
|
|
7
7
|
export const usePropDynamicTags = ( propName: PropKey ) => {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { PropValue } from '
|
|
2
|
-
import { useElement } from '../../
|
|
1
|
+
import { PropValue } from '@elementor/editor-props';
|
|
2
|
+
import { useElement } from '../../contexts/element-context';
|
|
3
3
|
|
|
4
4
|
export const PROPS_VALUES_HISTORY_KEY = 'elementor/dynamic/non-dynamic-values-history';
|
|
5
5
|
|
package/src/dynamics/init.ts
CHANGED
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
import { DynamicSelectionControl } from './components/dynamic-selection-control';
|
|
2
2
|
import { isDynamicPropValue } from './utils';
|
|
3
3
|
import { usePropDynamicAction } from './hooks/use-prop-dynamic-action';
|
|
4
|
-
import { controlActionsMenu } from '../controls/control-actions/control-actions-menu';
|
|
5
4
|
import { replaceControl } from '../control-replacement';
|
|
6
|
-
|
|
7
|
-
const { registerPopoverAction } = controlActionsMenu;
|
|
5
|
+
import { registerPopoverAction } from '../controls-actions';
|
|
8
6
|
|
|
9
7
|
export const init = () => {
|
|
10
8
|
replaceControl( {
|
package/src/dynamics/types.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { TransformablePropType, TransformablePropValue } from '@elementor/editor-props';
|
|
2
|
+
import { ControlItem, PropsSchema } from '@elementor/editor-elements';
|
|
3
3
|
|
|
4
4
|
export type ExtendedWindow = Window & {
|
|
5
5
|
elementor?: {
|
package/src/dynamics/utils.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import { PropType, PropValue, TransformablePropType } from '
|
|
1
|
+
import { isTransformable, PropType, PropValue, TransformablePropType } from '@elementor/editor-props';
|
|
2
2
|
import { DynamicPropType, DynamicPropValue } from './types';
|
|
3
|
-
import { isTransformable } from '../controls/props/is-transformable';
|
|
4
3
|
|
|
5
4
|
const DYNAMIC_PROP_TYPE_KEY = 'dynamic';
|
|
6
5
|
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { PropKey, PropValue } from '@elementor/editor-props';
|
|
2
|
+
import { useElementStyleProp, updateStyle } from '@elementor/editor-elements';
|
|
3
|
+
import { useStyle } from '../contexts/style-context';
|
|
4
|
+
import { useClassesProp } from '../contexts/classes-prop-context';
|
|
5
|
+
import { useElement } from '../contexts/element-context';
|
|
6
|
+
|
|
7
|
+
export const useStylesField = < T extends PropValue >( propName: PropKey ) => {
|
|
8
|
+
const { element } = useElement();
|
|
9
|
+
const { id, meta } = useStyle();
|
|
10
|
+
const classesProp = useClassesProp();
|
|
11
|
+
|
|
12
|
+
const value = useElementStyleProp< T >( {
|
|
13
|
+
elementID: element.id,
|
|
14
|
+
styleDefID: id,
|
|
15
|
+
meta,
|
|
16
|
+
propName,
|
|
17
|
+
} );
|
|
18
|
+
|
|
19
|
+
const setValue = ( newValue: T ) => {
|
|
20
|
+
updateStyle( {
|
|
21
|
+
elementID: element.id,
|
|
22
|
+
styleDefID: id,
|
|
23
|
+
props: { [ propName ]: newValue },
|
|
24
|
+
meta,
|
|
25
|
+
bind: classesProp,
|
|
26
|
+
} );
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
return [ value, setValue ] as const;
|
|
30
|
+
};
|
package/src/index.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
export type { PopoverActionProps } from './
|
|
1
|
+
export type { PopoverActionProps } from './popover-action';
|
|
2
2
|
export { replaceControl } from './control-replacement';
|
|
3
|
-
export {
|
|
4
|
-
export { controlActionsMenu } from './controls/control-actions/control-actions-menu';
|
|
3
|
+
export { useBoundProp } from './controls';
|
|
5
4
|
|
|
6
5
|
import init from './init';
|
|
7
6
|
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import getSelectedElements from '
|
|
2
|
-
import getWidgetsCache from './get-widgets-cache';
|
|
1
|
+
import { getSelectedElements, getWidgetsCache } from '@elementor/editor-elements';
|
|
3
2
|
|
|
4
3
|
export const shouldUseV2Panel = () => {
|
|
5
4
|
const selectedElements = getSelectedElements();
|
package/src/sync/types.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import { ControlItem, PropsSchema } from '@elementor/editor-elements';
|
|
2
|
+
import { PropValue } from '@elementor/editor-props';
|
|
3
|
+
import { StyleDefinition, StyleDefinitionID } from '@elementor/editor-styles';
|
|
4
4
|
|
|
5
5
|
export type ExtendedWindow = Window & {
|
|
6
6
|
elementor?: {
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
|
-
import { __ } from '@wordpress/i18n';
|
|
3
|
-
import { StyleControl } from '../../../controls/style-control';
|
|
4
|
-
import { Grid } from '@elementor/ui';
|
|
5
|
-
import { ColorControl } from '../../../controls/control-types/color-control';
|
|
6
|
-
|
|
7
|
-
export const BackgroundColorControl = () => {
|
|
8
|
-
return (
|
|
9
|
-
<StyleControl bind="background-color">
|
|
10
|
-
<Grid container spacing={ 1 } alignItems="center">
|
|
11
|
-
<Grid item xs={ 6 }>
|
|
12
|
-
<StyleControl.Label>{ __( 'Color', 'elementor' ) }</StyleControl.Label>
|
|
13
|
-
</Grid>
|
|
14
|
-
<Grid item xs={ 6 }>
|
|
15
|
-
<ColorControl />
|
|
16
|
-
</Grid>
|
|
17
|
-
</Grid>
|
|
18
|
-
</StyleControl>
|
|
19
|
-
);
|
|
20
|
-
};
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
|
-
import { __ } from '@wordpress/i18n';
|
|
3
|
-
import { Grid } from '@elementor/ui';
|
|
4
|
-
import { StyleControl } from '../../../controls/style-control';
|
|
5
|
-
import { NumberControl } from '../../../controls/control-types/number-control';
|
|
6
|
-
|
|
7
|
-
export const ZIndexControl = () => {
|
|
8
|
-
return (
|
|
9
|
-
<StyleControl bind="z-index">
|
|
10
|
-
<Grid container spacing={ 1 } alignItems="center">
|
|
11
|
-
<Grid item xs={ 6 }>
|
|
12
|
-
<StyleControl.Label>{ __( 'Z-Index', 'elementor' ) }</StyleControl.Label>
|
|
13
|
-
</Grid>
|
|
14
|
-
<Grid item xs={ 6 }>
|
|
15
|
-
<NumberControl />
|
|
16
|
-
</Grid>
|
|
17
|
-
</Grid>
|
|
18
|
-
</StyleControl>
|
|
19
|
-
);
|
|
20
|
-
};
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
|
-
import { AccordionSection } from '../accordion-section';
|
|
3
|
-
import { StyleControl, StyleControlProps } from '../../controls/style-control';
|
|
4
|
-
import { Grid, Stack } from '@elementor/ui';
|
|
5
|
-
import { __ } from '@wordpress/i18n';
|
|
6
|
-
import { Control as BaseControl } from '../../controls/control';
|
|
7
|
-
|
|
8
|
-
export const SizeSection = () => {
|
|
9
|
-
return (
|
|
10
|
-
<AccordionSection title={ __( 'Size', 'elementor' ) }>
|
|
11
|
-
<Stack gap={ 1.5 }>
|
|
12
|
-
<Grid container spacing={ 2 }>
|
|
13
|
-
<Control bind="width" label={ __( 'Width', 'elementor' ) } />
|
|
14
|
-
<Control bind="height" label={ __( 'Height', 'elementor' ) } />
|
|
15
|
-
</Grid>
|
|
16
|
-
<Grid container spacing={ 2 }>
|
|
17
|
-
<Control bind="min-width" label={ __( 'Min. Width', 'elementor' ) } />
|
|
18
|
-
<Control bind="min-height" label={ __( 'Min. Height', 'elementor' ) } />
|
|
19
|
-
</Grid>
|
|
20
|
-
<Grid container spacing={ 2 }>
|
|
21
|
-
<Control bind="max-width" label={ __( 'Max. Width', 'elementor' ) } />
|
|
22
|
-
<Control bind="max-height" label={ __( 'Max. Height', 'elementor' ) } />
|
|
23
|
-
</Grid>
|
|
24
|
-
</Stack>
|
|
25
|
-
</AccordionSection>
|
|
26
|
-
);
|
|
27
|
-
};
|
|
28
|
-
|
|
29
|
-
type ControlProps = {
|
|
30
|
-
bind: StyleControlProps[ 'bind' ];
|
|
31
|
-
label: string;
|
|
32
|
-
};
|
|
33
|
-
|
|
34
|
-
const Control = ( { label, bind }: ControlProps ) => {
|
|
35
|
-
return (
|
|
36
|
-
<Grid item xs={ 6 }>
|
|
37
|
-
<StyleControl bind={ bind }>
|
|
38
|
-
<Grid container spacing={ 1 } alignItems="center">
|
|
39
|
-
<Grid item xs={ 12 }>
|
|
40
|
-
<StyleControl.Label>{ label }</StyleControl.Label>
|
|
41
|
-
</Grid>
|
|
42
|
-
<Grid item xs={ 12 }>
|
|
43
|
-
<BaseControl type={ 'size' } />
|
|
44
|
-
</Grid>
|
|
45
|
-
</Grid>
|
|
46
|
-
</StyleControl>
|
|
47
|
-
</Grid>
|
|
48
|
-
);
|
|
49
|
-
};
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
|
-
import { __ } from '@wordpress/i18n';
|
|
3
|
-
import { Grid } from '@elementor/ui';
|
|
4
|
-
import { StyleControl } from '../../../controls/style-control';
|
|
5
|
-
import { SizeControl } from '../../../controls/control-types/size-control';
|
|
6
|
-
|
|
7
|
-
export const FontSizeControl = () => {
|
|
8
|
-
return (
|
|
9
|
-
<StyleControl bind="font-size">
|
|
10
|
-
<Grid container spacing={ 1 } alignItems="center">
|
|
11
|
-
<Grid item xs={ 6 }>
|
|
12
|
-
<StyleControl.Label>{ __( 'Font Size', 'elementor' ) }</StyleControl.Label>
|
|
13
|
-
</Grid>
|
|
14
|
-
<Grid item xs={ 6 }>
|
|
15
|
-
<SizeControl />
|
|
16
|
-
</Grid>
|
|
17
|
-
</Grid>
|
|
18
|
-
</StyleControl>
|
|
19
|
-
);
|
|
20
|
-
};
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
|
-
import { __ } from '@wordpress/i18n';
|
|
3
|
-
import { Grid } from '@elementor/ui';
|
|
4
|
-
import { StyleControl } from '../../../controls/style-control';
|
|
5
|
-
import { SizeControl } from '../../../controls/control-types/size-control';
|
|
6
|
-
|
|
7
|
-
export const LetterSpacingControl = () => {
|
|
8
|
-
return (
|
|
9
|
-
<StyleControl bind="letter-spacing">
|
|
10
|
-
<Grid container spacing={ 1 } alignItems="center">
|
|
11
|
-
<Grid item xs={ 6 }>
|
|
12
|
-
<StyleControl.Label>{ __( 'Letter Spacing', 'elementor' ) }</StyleControl.Label>
|
|
13
|
-
</Grid>
|
|
14
|
-
<Grid item xs={ 6 }>
|
|
15
|
-
<SizeControl />
|
|
16
|
-
</Grid>
|
|
17
|
-
</Grid>
|
|
18
|
-
</StyleControl>
|
|
19
|
-
);
|
|
20
|
-
};
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
|
-
import { __ } from '@wordpress/i18n';
|
|
3
|
-
import { Grid } from '@elementor/ui';
|
|
4
|
-
import { StyleControl } from '../../../controls/style-control';
|
|
5
|
-
import { ColorControl } from '../../../controls/control-types/color-control';
|
|
6
|
-
|
|
7
|
-
export const TextColorControl = () => {
|
|
8
|
-
return (
|
|
9
|
-
<StyleControl bind="color">
|
|
10
|
-
<Grid container spacing={ 1 } alignItems="center">
|
|
11
|
-
<Grid item xs={ 6 }>
|
|
12
|
-
<StyleControl.Label>{ __( 'Text Color', 'elementor' ) }</StyleControl.Label>
|
|
13
|
-
</Grid>
|
|
14
|
-
<Grid item xs={ 6 }>
|
|
15
|
-
<ColorControl />
|
|
16
|
-
</Grid>
|
|
17
|
-
</Grid>
|
|
18
|
-
</StyleControl>
|
|
19
|
-
);
|
|
20
|
-
};
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
|
-
import { __ } from '@wordpress/i18n';
|
|
3
|
-
import { Grid } from '@elementor/ui';
|
|
4
|
-
import { StyleControl } from '../../../controls/style-control';
|
|
5
|
-
import { SizeControl } from '../../../controls/control-types/size-control';
|
|
6
|
-
|
|
7
|
-
export const WordSpacingControl = () => {
|
|
8
|
-
return (
|
|
9
|
-
<StyleControl bind="word-spacing">
|
|
10
|
-
<Grid container spacing={ 1 } alignItems="center">
|
|
11
|
-
<Grid item xs={ 6 }>
|
|
12
|
-
<StyleControl.Label>{ __( 'Word Spacing', 'elementor' ) }</StyleControl.Label>
|
|
13
|
-
</Grid>
|
|
14
|
-
<Grid item xs={ 6 }>
|
|
15
|
-
<SizeControl />
|
|
16
|
-
</Grid>
|
|
17
|
-
</Grid>
|
|
18
|
-
</StyleControl>
|
|
19
|
-
);
|
|
20
|
-
};
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { createContext, useContext } from 'react';
|
|
2
|
-
import { PropKey, PropValue } from './props/types';
|
|
3
|
-
|
|
4
|
-
export type ControlContext< T extends PropValue > = {
|
|
5
|
-
bind: PropKey;
|
|
6
|
-
setValue: ( value: T | undefined ) => void;
|
|
7
|
-
value: T | undefined;
|
|
8
|
-
};
|
|
9
|
-
|
|
10
|
-
export const ControlContext = createContext< ControlContext< PropValue > | null >( null );
|
|
11
|
-
|
|
12
|
-
export function useControl< T extends PropValue >(): ControlContext< T | undefined >;
|
|
13
|
-
export function useControl< T extends PropValue >( defaultValue: T ): ControlContext< T >;
|
|
14
|
-
export function useControl< T extends PropValue >( defaultValue?: T ) {
|
|
15
|
-
const controlContext = useContext< ControlContext< T > >( ControlContext as never );
|
|
16
|
-
|
|
17
|
-
if ( ! controlContext ) {
|
|
18
|
-
throw new Error( 'useControl must be used within a ControlContext' );
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
return { ...controlContext, value: controlContext.value ?? defaultValue };
|
|
22
|
-
}
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import { ComponentType } from 'react';
|
|
2
|
-
import { PropValue } from './props/types';
|
|
3
|
-
import { useControl } from './control-context';
|
|
4
|
-
|
|
5
|
-
type ReplaceWhenParams = {
|
|
6
|
-
value: PropValue;
|
|
7
|
-
};
|
|
8
|
-
|
|
9
|
-
type ControlReplacement = {
|
|
10
|
-
component: ComponentType;
|
|
11
|
-
condition: ( { value }: ReplaceWhenParams ) => boolean;
|
|
12
|
-
};
|
|
13
|
-
|
|
14
|
-
let controlReplacement: ControlReplacement | undefined;
|
|
15
|
-
|
|
16
|
-
const getControlReplacement = ( { value }: ReplaceWhenParams ) => {
|
|
17
|
-
let shouldReplace = false;
|
|
18
|
-
|
|
19
|
-
try {
|
|
20
|
-
shouldReplace = !! controlReplacement?.condition( { value } ) && !! controlReplacement?.component;
|
|
21
|
-
} catch {}
|
|
22
|
-
|
|
23
|
-
return shouldReplace ? controlReplacement?.component : undefined;
|
|
24
|
-
};
|
|
25
|
-
|
|
26
|
-
export function replaceControl( { component, condition }: ControlReplacement ) {
|
|
27
|
-
controlReplacement = { component, condition };
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
export function useControlReplacement() {
|
|
31
|
-
const { value } = useControl();
|
|
32
|
-
|
|
33
|
-
return getControlReplacement( { value } );
|
|
34
|
-
}
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
|
-
import { UnstableColorPicker, UnstableColorPickerProps } from '@elementor/ui';
|
|
3
|
-
import { useControl } from '../control-context';
|
|
4
|
-
import ControlActions from '../control-actions/control-actions';
|
|
5
|
-
import { createControl } from '../create-control';
|
|
6
|
-
import { TransformablePropValue } from '../props/types';
|
|
7
|
-
|
|
8
|
-
export type ColorPropValue = TransformablePropValue< 'color', string >;
|
|
9
|
-
|
|
10
|
-
export const ColorControl = createControl(
|
|
11
|
-
( props: Partial< Omit< UnstableColorPickerProps, 'value' | 'onChange' > > ) => {
|
|
12
|
-
const { value, setValue } = useControl< ColorPropValue >();
|
|
13
|
-
|
|
14
|
-
const handleChange = ( selectedColor: string ) => {
|
|
15
|
-
setValue( {
|
|
16
|
-
$$type: 'color',
|
|
17
|
-
value: selectedColor,
|
|
18
|
-
} );
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
return (
|
|
22
|
-
<ControlActions>
|
|
23
|
-
<UnstableColorPicker size="tiny" { ...props } value={ value?.value } onChange={ handleChange } />
|
|
24
|
-
</ControlActions>
|
|
25
|
-
);
|
|
26
|
-
}
|
|
27
|
-
);
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import { useElement } from '../providers/element-provider';
|
|
2
|
-
import { useStyleContext } from '../../contexts/style-context';
|
|
3
|
-
import { useElementStyleProp } from '../../hooks/use-element-style-prop';
|
|
4
|
-
import { updateStyle } from '../../sync/update-style';
|
|
5
|
-
import { PropKey, PropValue } from '../props/types';
|
|
6
|
-
|
|
7
|
-
export const useStyleControl = < T extends PropValue >( propName: PropKey ) => {
|
|
8
|
-
const { element } = useElement();
|
|
9
|
-
const { selectedStyleDef, selectedMeta, selectedClassesProp } = useStyleContext();
|
|
10
|
-
|
|
11
|
-
const value = useElementStyleProp< T >( {
|
|
12
|
-
elementID: element.id,
|
|
13
|
-
styleDefID: selectedStyleDef?.id,
|
|
14
|
-
meta: selectedMeta,
|
|
15
|
-
propName,
|
|
16
|
-
} );
|
|
17
|
-
|
|
18
|
-
const setValue = ( newValue: T ) => {
|
|
19
|
-
updateStyle( {
|
|
20
|
-
elementID: element.id,
|
|
21
|
-
styleDefID: selectedStyleDef?.id,
|
|
22
|
-
props: { [ propName ]: newValue },
|
|
23
|
-
meta: selectedMeta,
|
|
24
|
-
bind: selectedClassesProp,
|
|
25
|
-
} );
|
|
26
|
-
};
|
|
27
|
-
|
|
28
|
-
return [ value, setValue ] as const;
|
|
29
|
-
};
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { commandEndEvent, __privateUseListenTo as useListenTo } from '@elementor/editor-v1-adapters';
|
|
2
|
-
import getContainer from '../sync/get-container';
|
|
3
|
-
import { PropValue } from '../props/types';
|
|
4
|
-
|
|
5
|
-
export const useWidgetSettings = ( { id, bind }: { id: string; bind: string } ): PropValue => {
|
|
6
|
-
return useListenTo(
|
|
7
|
-
commandEndEvent( 'document/elements/settings' ),
|
|
8
|
-
() => {
|
|
9
|
-
const container = getContainer( id );
|
|
10
|
-
const value = container?.settings?.get( bind ) ?? null;
|
|
11
|
-
|
|
12
|
-
return value;
|
|
13
|
-
},
|
|
14
|
-
[ id, bind ]
|
|
15
|
-
);
|
|
16
|
-
};
|