@elementor/editor-editing-panel 0.19.0 → 1.1.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 +97 -0
- package/dist/index.d.mts +10 -36
- package/dist/index.d.ts +10 -36
- package/dist/index.js +1256 -1445
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1311 -1482
- package/dist/index.mjs.map +1 -1
- package/package.json +15 -14
- package/src/components/add-or-remove-content.tsx +42 -0
- package/src/components/collapse-icon.tsx +12 -0
- package/src/components/collapsible-content.tsx +5 -14
- package/src/components/collapsible-field.tsx +36 -0
- package/src/components/css-class-selector-section.tsx +76 -0
- package/src/components/editing-panel-hooks.tsx +2 -0
- package/src/components/editing-panel-tabs.tsx +23 -13
- package/src/components/editing-panel.tsx +21 -21
- package/src/components/multi-combobox/index.ts +3 -0
- package/src/components/multi-combobox/multi-combobox.tsx +120 -0
- package/src/components/multi-combobox/types.ts +26 -0
- package/src/components/multi-combobox/use-combobox-actions.ts +62 -0
- package/src/components/section.tsx +37 -0
- package/src/components/sections-list.tsx +6 -0
- package/src/components/settings-tab.tsx +17 -16
- package/src/components/style-sections/background-section/background-color-field.tsx +21 -0
- package/src/components/style-sections/background-section/background-section.tsx +10 -8
- package/src/components/style-sections/border-section/border-color-field.tsx +21 -0
- package/src/components/style-sections/border-section/border-field.tsx +48 -0
- package/src/components/style-sections/border-section/border-radius-field.tsx +49 -0
- package/src/components/style-sections/border-section/border-section.tsx +13 -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 +43 -0
- package/src/components/style-sections/effects-section/effects-section.tsx +8 -11
- package/src/components/style-sections/layout-section/display-field.tsx +32 -0
- package/src/components/style-sections/layout-section/justify-content-field.tsx +82 -0
- package/src/components/style-sections/layout-section/layout-section.tsx +17 -0
- package/src/components/style-sections/layout-section/utils/rotate-flex-icon.ts +12 -0
- 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 +51 -8
- 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 +62 -0
- package/src/components/style-sections/spacing-section/spacing-section.tsx +12 -14
- package/src/components/style-sections/typography-section/font-family-field.tsx +40 -0
- 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} +9 -8
- package/src/components/style-sections/typography-section/letter-spacing-field.tsx +21 -0
- package/src/components/style-sections/typography-section/text-alignment-field.tsx +47 -0
- 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} +12 -12
- 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} +9 -8
- package/src/components/style-sections/typography-section/transform-field.tsx +40 -0
- package/src/components/style-sections/typography-section/typography-section.tsx +31 -30
- package/src/components/style-sections/typography-section/word-spacing-field.tsx +21 -0
- package/src/components/style-tab.tsx +82 -29
- 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 +10 -23
- package/src/control-replacement.tsx +1 -1
- package/src/{controls/control-actions/control-actions-menu.ts → controls-actions.ts} +2 -1
- package/src/{controls/components → controls-registry}/control-type-container.tsx +3 -2
- package/src/{controls → controls-registry}/control.tsx +2 -1
- package/src/{controls → controls-registry}/controls-registry.tsx +8 -6
- package/src/controls-registry/settings-field.tsx +36 -0
- package/src/controls-registry/styles-field.tsx +20 -0
- package/src/dynamics/components/dynamic-selection-control.tsx +18 -17
- package/src/dynamics/components/dynamic-selection.tsx +10 -9
- package/src/dynamics/dynamic-control.tsx +7 -6
- package/src/dynamics/hooks/use-dynamic-tag.ts +3 -2
- package/src/dynamics/hooks/use-prop-dynamic-action.tsx +7 -6
- package/src/dynamics/hooks/use-prop-dynamic-tags.ts +3 -2
- package/src/dynamics/init.ts +3 -3
- package/src/dynamics/sync/get-elementor-config.ts +1 -1
- package/src/dynamics/types.ts +2 -2
- package/src/dynamics/utils.ts +3 -3
- package/src/hooks/use-close-editor-panel.ts +23 -0
- package/src/hooks/use-direction.ts +13 -0
- package/src/hooks/use-open-editor-panel.ts +4 -3
- package/src/hooks/use-prop-value-history.ts +45 -0
- package/src/hooks/use-style-prop-history.ts +75 -0
- package/src/hooks/use-styles-field.ts +51 -0
- package/src/index.ts +2 -3
- package/src/init.ts +5 -4
- package/src/panel.ts +1 -0
- package/src/{controls/control-actions/actions/popover-action.tsx → popover-action.tsx} +2 -2
- package/src/sync/enqueue-font.ts +7 -0
- package/src/sync/get-elementor-config.ts +7 -0
- package/src/sync/{should-use-v2-panel.ts → is-atomic-widget-selected.ts} +2 -3
- package/src/sync/types.ts +20 -21
- package/src/components/accordion-section.tsx +0 -25
- package/src/components/control-label.tsx +0 -10
- package/src/components/style-sections/background-section/background-color-control.tsx +0 -20
- package/src/components/style-sections/effects-section/box-shadow-repeater.tsx +0 -224
- 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/spacing-section/linked-dimensions-control.tsx +0 -155
- 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-alignment-control.tsx +0 -47
- package/src/components/style-sections/typography-section/text-color-control.tsx +0 -20
- package/src/components/style-sections/typography-section/transform-control.tsx +0 -25
- package/src/components/style-sections/typography-section/word-spacing-control.tsx +0 -20
- package/src/controls/components/control-toggle-button-group.tsx +0 -59
- package/src/controls/components/repeater.tsx +0 -197
- package/src/controls/components/text-field-inner-selection.tsx +0 -79
- package/src/controls/control-actions/control-actions.tsx +0 -43
- 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/control-types/image-control.tsx +0 -66
- package/src/controls/control-types/image-media-control.tsx +0 -73
- package/src/controls/control-types/number-control.tsx +0 -29
- package/src/controls/control-types/select-control.tsx +0 -30
- package/src/controls/control-types/size-control.tsx +0 -71
- package/src/controls/control-types/text-area-control.tsx +0 -31
- package/src/controls/control-types/text-control.tsx +0 -17
- package/src/controls/control-types/toggle-control.tsx +0 -26
- package/src/controls/create-control-replacement.tsx +0 -53
- package/src/controls/create-control.tsx +0 -40
- package/src/controls/hooks/use-style-control.ts +0 -29
- package/src/controls/hooks/use-sync-external-state.tsx +0 -51
- 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/dynamics/hooks/use-prop-value-history.ts +0 -26
- 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
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { useCallback, useMemo } from 'react';
|
|
2
|
+
import { getSessionStorageItem, setSessionStorageItem } from '@elementor/utils';
|
|
3
|
+
|
|
4
|
+
import { useElement } from '../contexts/element-context';
|
|
5
|
+
|
|
6
|
+
export const PROPS_VALUES_HISTORY_PREFIX = 'elementor/editor-editing-panel/prop-value-history';
|
|
7
|
+
|
|
8
|
+
export const usePropValueHistory = () => {
|
|
9
|
+
const { element } = useElement();
|
|
10
|
+
const elementKey = `${ PROPS_VALUES_HISTORY_PREFIX }/${ element.id }`;
|
|
11
|
+
|
|
12
|
+
const getElementPropsHistory = useCallback( () => {
|
|
13
|
+
return getSessionStorageItem< Record< string, unknown > >( elementKey );
|
|
14
|
+
}, [ elementKey ] );
|
|
15
|
+
|
|
16
|
+
const getPropValue = useCallback(
|
|
17
|
+
< T >( propKey: string ) => {
|
|
18
|
+
const elementPropValues = getElementPropsHistory();
|
|
19
|
+
return ( elementPropValues?.[ propKey ] ?? null ) as T | null;
|
|
20
|
+
},
|
|
21
|
+
[ getElementPropsHistory ]
|
|
22
|
+
);
|
|
23
|
+
|
|
24
|
+
const setPropValue = useCallback(
|
|
25
|
+
( propKey: string, propValue: unknown ) => {
|
|
26
|
+
const elementPropValues = getElementPropsHistory();
|
|
27
|
+
const updatedElementPropValues = { ...elementPropValues, [ propKey ]: propValue };
|
|
28
|
+
setSessionStorageItem( elementKey, updatedElementPropValues );
|
|
29
|
+
},
|
|
30
|
+
[ getElementPropsHistory, elementKey ]
|
|
31
|
+
);
|
|
32
|
+
|
|
33
|
+
const removeProp = useCallback(
|
|
34
|
+
( propKey: string ) => {
|
|
35
|
+
const elementPropValues = getElementPropsHistory();
|
|
36
|
+
const updatedElementPropValues = Object.fromEntries(
|
|
37
|
+
Object.entries( elementPropValues || {} ).filter( ( [ key ] ) => key !== propKey )
|
|
38
|
+
);
|
|
39
|
+
setSessionStorageItem( elementKey, updatedElementPropValues );
|
|
40
|
+
},
|
|
41
|
+
[ getElementPropsHistory, elementKey ]
|
|
42
|
+
);
|
|
43
|
+
|
|
44
|
+
return useMemo( () => ( { getPropValue, setPropValue, removeProp } ), [ getPropValue, removeProp, setPropValue ] );
|
|
45
|
+
};
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { useCallback, useMemo } from 'react';
|
|
2
|
+
import { getElementStyles, getVariantByMeta, updateStyle } from '@elementor/editor-elements';
|
|
3
|
+
import { type PropKey } from '@elementor/editor-props';
|
|
4
|
+
|
|
5
|
+
import { useElement } from '../contexts/element-context';
|
|
6
|
+
import { useStyle } from '../contexts/style-context';
|
|
7
|
+
import { usePropValueHistory } from './use-prop-value-history';
|
|
8
|
+
|
|
9
|
+
export const useStylePropsHistory = ( props: PropKey[] ) => {
|
|
10
|
+
const { element } = useElement();
|
|
11
|
+
const { id: styleDefID, meta } = useStyle();
|
|
12
|
+
const { getPropValue, setPropValue, removeProp } = usePropValueHistory();
|
|
13
|
+
|
|
14
|
+
const styleDef = getElementStyles( element.id )?.[ styleDefID ];
|
|
15
|
+
const styleVariant = styleDef ? getVariantByMeta( styleDef, meta ) : null;
|
|
16
|
+
const styleVariantPath = `${ styleDefID }-${ styleVariant?.meta.breakpoint }-${ styleVariant?.meta.state }`;
|
|
17
|
+
|
|
18
|
+
const saveStylePropsHistory = useCallback( () => {
|
|
19
|
+
props.forEach( ( propKey ) => {
|
|
20
|
+
const propValue = styleVariant?.props[ propKey ];
|
|
21
|
+
|
|
22
|
+
if ( propValue ) {
|
|
23
|
+
const propPath = `${ styleVariantPath }-${ propKey }`;
|
|
24
|
+
setPropValue( propPath, propValue );
|
|
25
|
+
}
|
|
26
|
+
} );
|
|
27
|
+
}, [ props, setPropValue, styleVariant?.props, styleVariantPath ] );
|
|
28
|
+
|
|
29
|
+
const updateStylePropsFromHistory = useCallback( () => {
|
|
30
|
+
const propValuesFromHistory = props.reduce( ( allProps, currentPropKey ) => {
|
|
31
|
+
const propPath = `${ styleVariantPath }-${ currentPropKey }`;
|
|
32
|
+
const propHistory = getPropValue( propPath );
|
|
33
|
+
|
|
34
|
+
if ( propHistory ) {
|
|
35
|
+
removeProp( propPath );
|
|
36
|
+
return { ...allProps, [ currentPropKey ]: propHistory };
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
return allProps;
|
|
40
|
+
}, {} );
|
|
41
|
+
|
|
42
|
+
if ( Object.keys( propValuesFromHistory ).length ) {
|
|
43
|
+
updateStyle( {
|
|
44
|
+
elementID: element.id,
|
|
45
|
+
styleDefID,
|
|
46
|
+
meta,
|
|
47
|
+
props: propValuesFromHistory,
|
|
48
|
+
bind: 'classes',
|
|
49
|
+
} );
|
|
50
|
+
}
|
|
51
|
+
}, [ element.id, getPropValue, meta, props, removeProp, styleDefID, styleVariantPath ] );
|
|
52
|
+
|
|
53
|
+
const clearCurrentStyleProps = useCallback( () => {
|
|
54
|
+
const resetValues = props.reduce(
|
|
55
|
+
( allProps, currentPropKey ) => ( {
|
|
56
|
+
...allProps,
|
|
57
|
+
[ currentPropKey ]: undefined,
|
|
58
|
+
} ),
|
|
59
|
+
{}
|
|
60
|
+
);
|
|
61
|
+
|
|
62
|
+
updateStyle( {
|
|
63
|
+
elementID: element.id,
|
|
64
|
+
styleDefID,
|
|
65
|
+
meta,
|
|
66
|
+
props: resetValues,
|
|
67
|
+
bind: 'classes',
|
|
68
|
+
} );
|
|
69
|
+
}, [ element.id, meta, props, styleDefID ] );
|
|
70
|
+
|
|
71
|
+
return useMemo(
|
|
72
|
+
() => ( { saveStylePropsHistory, updateStylePropsFromHistory, clearCurrentStyleProps } ),
|
|
73
|
+
[ saveStylePropsHistory, updateStylePropsFromHistory, clearCurrentStyleProps ]
|
|
74
|
+
);
|
|
75
|
+
};
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { useEffect, useRef } from 'react';
|
|
2
|
+
import { updateStyle, useElementStyleProp } from '@elementor/editor-elements';
|
|
3
|
+
import type { PropKey, PropValue } from '@elementor/editor-props';
|
|
4
|
+
|
|
5
|
+
import { useClassesProp } from '../contexts/classes-prop-context';
|
|
6
|
+
import { useElement } from '../contexts/element-context';
|
|
7
|
+
import { useStyle } from '../contexts/style-context';
|
|
8
|
+
|
|
9
|
+
export const useStylesField = < T extends PropValue >(
|
|
10
|
+
propName: PropKey
|
|
11
|
+
): [
|
|
12
|
+
T | null,
|
|
13
|
+
( newValue: T ) => void,
|
|
14
|
+
( callback: ( newValue: T | null, previousValue: T | null ) => void ) => void,
|
|
15
|
+
] => {
|
|
16
|
+
const { element } = useElement();
|
|
17
|
+
const { id, meta } = useStyle();
|
|
18
|
+
const classesProp = useClassesProp();
|
|
19
|
+
const previousValue = useRef< T | null >( null );
|
|
20
|
+
const onChangeCallbacks = useRef< Set< ( newValue: T | null, previousValue: T | null ) => void > >( new Set() );
|
|
21
|
+
|
|
22
|
+
const value = useElementStyleProp< T >( {
|
|
23
|
+
elementID: element.id,
|
|
24
|
+
styleDefID: id,
|
|
25
|
+
meta,
|
|
26
|
+
propName,
|
|
27
|
+
} );
|
|
28
|
+
|
|
29
|
+
const setValue = ( newValue: T ) => {
|
|
30
|
+
updateStyle( {
|
|
31
|
+
elementID: element.id,
|
|
32
|
+
styleDefID: id,
|
|
33
|
+
props: { [ propName ]: newValue },
|
|
34
|
+
meta,
|
|
35
|
+
bind: classesProp,
|
|
36
|
+
} );
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
const registerChangeListener = ( callback: ( newValue: T | null, previousValue: T | null ) => void ) => {
|
|
40
|
+
onChangeCallbacks.current.add( callback );
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
useEffect( () => {
|
|
44
|
+
onChangeCallbacks.current.forEach( ( cb ) => {
|
|
45
|
+
cb( value, previousValue.current );
|
|
46
|
+
} );
|
|
47
|
+
previousValue.current = value;
|
|
48
|
+
}, [ value ] );
|
|
49
|
+
|
|
50
|
+
return [ value, setValue, registerChangeListener ];
|
|
51
|
+
};
|
package/src/index.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
export
|
|
1
|
+
export { useBoundProp } from '@elementor/editor-controls';
|
|
2
|
+
export type { PopoverActionProps } from './popover-action';
|
|
2
3
|
export { replaceControl } from './control-replacement';
|
|
3
|
-
export { useControl } from './controls/control-context';
|
|
4
|
-
export { controlActionsMenu } from './controls/control-actions/control-actions-menu';
|
|
5
4
|
|
|
6
5
|
import init from './init';
|
|
7
6
|
|
package/src/init.ts
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import { panel } from './panel';
|
|
2
1
|
import { injectIntoLogic } from '@elementor/editor';
|
|
3
|
-
import { shouldUseV2Panel } from './sync/should-use-v2-panel';
|
|
4
|
-
import { EditingPanelHooks } from './components/editing-panel-hooks';
|
|
5
2
|
import { __registerPanel as registerPanel } from '@elementor/editor-panels';
|
|
6
3
|
import { __privateBlockDataCommand as blockDataCommand } from '@elementor/editor-v1-adapters';
|
|
4
|
+
|
|
5
|
+
import { EditingPanelHooks } from './components/editing-panel-hooks';
|
|
7
6
|
import { init as initDynamics } from './dynamics/init';
|
|
7
|
+
import { panel } from './panel';
|
|
8
|
+
import { isAtomicWidgetSelected } from './sync/is-atomic-widget-selected';
|
|
8
9
|
|
|
9
10
|
export default function init() {
|
|
10
11
|
registerPanel( panel );
|
|
@@ -22,6 +23,6 @@ export default function init() {
|
|
|
22
23
|
const blockV1Panel = () => {
|
|
23
24
|
blockDataCommand( {
|
|
24
25
|
command: 'panel/editor/open',
|
|
25
|
-
condition:
|
|
26
|
+
condition: isAtomicWidgetSelected,
|
|
26
27
|
} );
|
|
27
28
|
};
|
package/src/panel.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import {
|
|
3
|
-
import { ComponentType, ElementType as ReactElementType, useId } from 'react';
|
|
2
|
+
import { type ComponentType, type ElementType as ReactElementType, useId } from 'react';
|
|
4
3
|
import { XIcon } from '@elementor/icons';
|
|
4
|
+
import { bindPopover, bindToggle, IconButton, Popover, Stack, Tooltip, Typography, usePopupState } from '@elementor/ui';
|
|
5
5
|
|
|
6
6
|
const SIZE = 'tiny';
|
|
7
7
|
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { type EnqueueFont, type ExtendedWindow } from './types';
|
|
2
|
+
|
|
3
|
+
export const enqueueFont: EnqueueFont = ( fontFamily, context = 'editor' ) => {
|
|
4
|
+
const extendedWindow = window as unknown as ExtendedWindow;
|
|
5
|
+
|
|
6
|
+
return extendedWindow.elementor?.helpers?.enqueueFont( fontFamily, context ) ?? null;
|
|
7
|
+
};
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import getSelectedElements from '
|
|
2
|
-
import getWidgetsCache from './get-widgets-cache';
|
|
1
|
+
import { getSelectedElements, getWidgetsCache } from '@elementor/editor-elements';
|
|
3
2
|
|
|
4
|
-
export const
|
|
3
|
+
export const isAtomicWidgetSelected = () => {
|
|
5
4
|
const selectedElements = getSelectedElements();
|
|
6
5
|
const widgetCache = getWidgetsCache();
|
|
7
6
|
|
package/src/sync/types.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import { type ControlItem, type PropsSchema, type V1Element } from '@elementor/editor-elements';
|
|
2
|
+
|
|
3
|
+
export type SupportedFonts = 'system' | 'googlefonts' | 'customfonts';
|
|
4
|
+
|
|
5
|
+
export type EnqueueFont = ( fontFamily: string, context?: 'preview' | 'editor' ) => void;
|
|
4
6
|
|
|
5
7
|
export type ExtendedWindow = Window & {
|
|
6
8
|
elementor?: {
|
|
@@ -17,23 +19,20 @@ export type ExtendedWindow = Window & {
|
|
|
17
19
|
}
|
|
18
20
|
>;
|
|
19
21
|
getContainer?: ( id: string ) => V1Element;
|
|
22
|
+
helpers?: {
|
|
23
|
+
enqueueFont: EnqueueFont;
|
|
24
|
+
};
|
|
25
|
+
config?: {
|
|
26
|
+
controls?: {
|
|
27
|
+
font?: {
|
|
28
|
+
options?: Record< string, SupportedFonts >;
|
|
29
|
+
};
|
|
30
|
+
};
|
|
31
|
+
};
|
|
32
|
+
};
|
|
33
|
+
elementorFrontend?: {
|
|
34
|
+
config?: {
|
|
35
|
+
is_rtl?: boolean;
|
|
36
|
+
};
|
|
20
37
|
};
|
|
21
|
-
};
|
|
22
|
-
|
|
23
|
-
export type V1Element = {
|
|
24
|
-
model: V1Model< V1ElementModelProps >;
|
|
25
|
-
settings?: V1Model< V1ElementSettingsProps >;
|
|
26
|
-
};
|
|
27
|
-
|
|
28
|
-
export type V1ElementModelProps = {
|
|
29
|
-
widgetType?: string;
|
|
30
|
-
elType: string;
|
|
31
|
-
id: string;
|
|
32
|
-
styles?: Record< StyleDefinitionID, StyleDefinition >;
|
|
33
|
-
};
|
|
34
|
-
|
|
35
|
-
export type V1ElementSettingsProps = Record< string, PropValue >;
|
|
36
|
-
|
|
37
|
-
type V1Model< T > = {
|
|
38
|
-
get: < K extends keyof T >( key: K ) => T[ K ];
|
|
39
38
|
};
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
|
-
import { useId } from 'react';
|
|
3
|
-
import { Accordion, AccordionSummary, AccordionDetails, AccordionSummaryText, Stack } from '@elementor/ui';
|
|
4
|
-
|
|
5
|
-
export type AccordionSectionProps = React.PropsWithChildren< {
|
|
6
|
-
title: React.ReactNode;
|
|
7
|
-
} >;
|
|
8
|
-
|
|
9
|
-
export const AccordionSection = ( { title, children }: AccordionSectionProps ) => {
|
|
10
|
-
const uid = useId();
|
|
11
|
-
const labelId = `label-${ uid }`;
|
|
12
|
-
const contentId = `content-${ uid }`;
|
|
13
|
-
|
|
14
|
-
// TODO: Change to collapsible list item
|
|
15
|
-
return (
|
|
16
|
-
<Accordion disableGutters defaultExpanded>
|
|
17
|
-
<AccordionSummary aria-controls={ contentId } id={ labelId }>
|
|
18
|
-
<AccordionSummaryText primaryTypographyProps={ { variant: 'caption' } }>{ title }</AccordionSummaryText>
|
|
19
|
-
</AccordionSummary>
|
|
20
|
-
<AccordionDetails id={ contentId } aria-labelledby={ labelId }>
|
|
21
|
-
<Stack gap={ 2.5 }>{ children }</Stack>
|
|
22
|
-
</AccordionDetails>
|
|
23
|
-
</Accordion>
|
|
24
|
-
);
|
|
25
|
-
};
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
|
-
import { Typography } from '@elementor/ui';
|
|
3
|
-
|
|
4
|
-
export const ControlLabel = ( { children }: { children: React.ReactNode } ) => {
|
|
5
|
-
return (
|
|
6
|
-
<Typography component="label" variant="caption" color="text.secondary">
|
|
7
|
-
{ children }
|
|
8
|
-
</Typography>
|
|
9
|
-
);
|
|
10
|
-
};
|
|
@@ -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,224 +0,0 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
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';
|
|
11
|
-
|
|
12
|
-
type SetContextValue = ( v: PropValue ) => void;
|
|
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 >();
|
|
30
|
-
|
|
31
|
-
const boxShadowValues = value?.value;
|
|
32
|
-
|
|
33
|
-
const setBoxShadow = ( newValue: BoxShadow[ 'value' ] ) => {
|
|
34
|
-
setValue( {
|
|
35
|
-
$$type: 'box-shadow',
|
|
36
|
-
value: newValue,
|
|
37
|
-
} );
|
|
38
|
-
};
|
|
39
|
-
|
|
40
|
-
return (
|
|
41
|
-
<Repeater
|
|
42
|
-
values={ boxShadowValues }
|
|
43
|
-
setValues={ setBoxShadow }
|
|
44
|
-
label={ __( 'Box shadow', 'elementor' ) }
|
|
45
|
-
itemSettings={ {
|
|
46
|
-
Icon: ItemIcon,
|
|
47
|
-
Label: ItemLabel,
|
|
48
|
-
Content: ItemContent,
|
|
49
|
-
initialValues: initialShadow,
|
|
50
|
-
} }
|
|
51
|
-
/>
|
|
52
|
-
);
|
|
53
|
-
};
|
|
54
|
-
|
|
55
|
-
const ItemIcon = ( { value }: { value: Shadow } ) => (
|
|
56
|
-
<UnstableColorIndicator size="inherit" component="span" value={ value.value.color.value } />
|
|
57
|
-
);
|
|
58
|
-
|
|
59
|
-
const ItemContent = ( {
|
|
60
|
-
anchorEl,
|
|
61
|
-
value,
|
|
62
|
-
setValue,
|
|
63
|
-
}: {
|
|
64
|
-
anchorEl: HTMLElement | null;
|
|
65
|
-
value: Shadow;
|
|
66
|
-
setValue: ( newValue: Shadow ) => void;
|
|
67
|
-
} ) => {
|
|
68
|
-
const setShadow = ( newValue: Shadow[ 'value' ] ) => {
|
|
69
|
-
setValue( {
|
|
70
|
-
$$type: 'shadow',
|
|
71
|
-
value: newValue,
|
|
72
|
-
} );
|
|
73
|
-
};
|
|
74
|
-
|
|
75
|
-
return (
|
|
76
|
-
<Stack gap={ 1.5 }>
|
|
77
|
-
<Grid container spacing={ 1 }>
|
|
78
|
-
<Control
|
|
79
|
-
bind="color"
|
|
80
|
-
value={ value.value.color }
|
|
81
|
-
label={ __( 'Color', 'elementor' ) }
|
|
82
|
-
setValue={ ( v: ColorPropValue ) => setShadow( { ...value.value, color: v } ) }
|
|
83
|
-
>
|
|
84
|
-
<ColorControl
|
|
85
|
-
anchorEl={ anchorEl }
|
|
86
|
-
anchorOrigin={ {
|
|
87
|
-
vertical: 'top',
|
|
88
|
-
horizontal: 'right',
|
|
89
|
-
} }
|
|
90
|
-
transformOrigin={ {
|
|
91
|
-
vertical: 'top',
|
|
92
|
-
horizontal: -10,
|
|
93
|
-
} }
|
|
94
|
-
/>
|
|
95
|
-
</Control>
|
|
96
|
-
<Control
|
|
97
|
-
bind="position"
|
|
98
|
-
value={ value.value.position }
|
|
99
|
-
label={ __( 'Position', 'elementor' ) }
|
|
100
|
-
setValue={ ( v: string ) => setShadow( { ...value.value, position: v } ) }
|
|
101
|
-
>
|
|
102
|
-
<SelectControl
|
|
103
|
-
options={ [
|
|
104
|
-
{ label: 'Inset', value: 'inset' },
|
|
105
|
-
{ label: 'Outset', value: 'outset' },
|
|
106
|
-
] }
|
|
107
|
-
/>
|
|
108
|
-
</Control>
|
|
109
|
-
</Grid>
|
|
110
|
-
<Grid container spacing={ 1 }>
|
|
111
|
-
<Control
|
|
112
|
-
bind="hOffset"
|
|
113
|
-
label={ __( 'Horizontal', 'elementor' ) }
|
|
114
|
-
value={ value.value.hOffset }
|
|
115
|
-
setValue={ ( v: SizeControlValue ) => setShadow( { ...value.value, hOffset: v } ) }
|
|
116
|
-
>
|
|
117
|
-
<SizeControl />
|
|
118
|
-
</Control>
|
|
119
|
-
<Control
|
|
120
|
-
label={ __( 'Vertical', 'elementor' ) }
|
|
121
|
-
bind="vOffset"
|
|
122
|
-
value={ value.value.vOffset }
|
|
123
|
-
setValue={ ( v: SizeControlValue ) => setShadow( { ...value.value, vOffset: v } ) }
|
|
124
|
-
>
|
|
125
|
-
<SizeControl />
|
|
126
|
-
</Control>
|
|
127
|
-
</Grid>
|
|
128
|
-
<Grid container spacing={ 1 }>
|
|
129
|
-
<Control
|
|
130
|
-
bind="blur"
|
|
131
|
-
value={ value.value.blur }
|
|
132
|
-
label={ __( 'Blur', 'elementor' ) }
|
|
133
|
-
setValue={ ( v: SizeControlValue ) => setShadow( { ...value.value, blur: v } ) }
|
|
134
|
-
>
|
|
135
|
-
<SizeControl />
|
|
136
|
-
</Control>
|
|
137
|
-
<Control
|
|
138
|
-
bind="spread"
|
|
139
|
-
label={ __( 'Spread', 'elementor' ) }
|
|
140
|
-
value={ value.value.spread }
|
|
141
|
-
setValue={ ( v: SizeControlValue ) => setShadow( { ...value.value, spread: v } ) }
|
|
142
|
-
>
|
|
143
|
-
<SizeControl />
|
|
144
|
-
</Control>
|
|
145
|
-
</Grid>
|
|
146
|
-
</Stack>
|
|
147
|
-
);
|
|
148
|
-
};
|
|
149
|
-
|
|
150
|
-
const Control = < T extends PropValue >( {
|
|
151
|
-
value,
|
|
152
|
-
setValue,
|
|
153
|
-
label,
|
|
154
|
-
bind,
|
|
155
|
-
children,
|
|
156
|
-
}: {
|
|
157
|
-
value: T;
|
|
158
|
-
bind: string;
|
|
159
|
-
label: string;
|
|
160
|
-
children: React.ReactNode;
|
|
161
|
-
setValue: ( v: T ) => void;
|
|
162
|
-
} ) => (
|
|
163
|
-
<ControlContext.Provider value={ { value, setValue: setValue as SetContextValue, bind } }>
|
|
164
|
-
<Grid item xs={ 6 }>
|
|
165
|
-
<Grid container spacing={ 1 } alignItems="center">
|
|
166
|
-
<Grid item xs={ 12 }>
|
|
167
|
-
<ControlLabel>{ label }</ControlLabel>
|
|
168
|
-
</Grid>
|
|
169
|
-
<Grid item xs={ 12 }>
|
|
170
|
-
{ children }
|
|
171
|
-
</Grid>
|
|
172
|
-
</Grid>
|
|
173
|
-
</Grid>
|
|
174
|
-
</ControlContext.Provider>
|
|
175
|
-
);
|
|
176
|
-
|
|
177
|
-
const ItemLabel = ( { value }: { value: Shadow } ) => {
|
|
178
|
-
const { position, hOffset, vOffset, blur, spread } = value.value;
|
|
179
|
-
|
|
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;
|
|
184
|
-
|
|
185
|
-
const sizes = [
|
|
186
|
-
hOffsetSize + hOffsetUnit,
|
|
187
|
-
vOffsetSize + vOffsetUnit,
|
|
188
|
-
blurSize + blurUnit,
|
|
189
|
-
spreadSize + spreadUnit,
|
|
190
|
-
].join( ' ' );
|
|
191
|
-
|
|
192
|
-
return (
|
|
193
|
-
<span style={ { textTransform: 'capitalize' } }>
|
|
194
|
-
{ position }: { sizes }
|
|
195
|
-
</span>
|
|
196
|
-
);
|
|
197
|
-
};
|
|
198
|
-
|
|
199
|
-
const initialShadow: Shadow = {
|
|
200
|
-
$$type: 'shadow',
|
|
201
|
-
value: {
|
|
202
|
-
hOffset: {
|
|
203
|
-
$$type: 'size',
|
|
204
|
-
value: { unit: 'px', size: 0 },
|
|
205
|
-
},
|
|
206
|
-
vOffset: {
|
|
207
|
-
$$type: 'size',
|
|
208
|
-
value: { unit: 'px', size: 0 },
|
|
209
|
-
},
|
|
210
|
-
blur: {
|
|
211
|
-
$$type: 'size',
|
|
212
|
-
value: { unit: 'px', size: 0 },
|
|
213
|
-
},
|
|
214
|
-
spread: {
|
|
215
|
-
$$type: 'size',
|
|
216
|
-
value: { unit: 'px', size: 0 },
|
|
217
|
-
},
|
|
218
|
-
color: {
|
|
219
|
-
$$type: 'color',
|
|
220
|
-
value: 'rgba(0, 0, 0, 0)',
|
|
221
|
-
},
|
|
222
|
-
position: 'inset',
|
|
223
|
-
},
|
|
224
|
-
};
|
|
@@ -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
|
-
};
|