@elementor/editor-editing-panel 4.4.0-1148 → 4.4.0-1149
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/dist/index.js +188 -134
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +103 -49
- package/dist/index.mjs.map +1 -1
- package/package.json +25 -25
- package/src/components/settings-tab.tsx +11 -4
- package/src/controls-registry/settings-field.tsx +4 -1
- package/src/hooks/use-is-hidden-by-ancestor.ts +25 -0
- package/src/utils/ancestor-dependency-utils.ts +35 -0
- package/src/utils/prop-dependency-utils.ts +9 -5
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@elementor/editor-editing-panel",
|
|
3
|
-
"version": "4.4.0-
|
|
3
|
+
"version": "4.4.0-1149",
|
|
4
4
|
"private": false,
|
|
5
5
|
"author": "Elementor Team",
|
|
6
6
|
"homepage": "https://elementor.com/",
|
|
@@ -39,32 +39,32 @@
|
|
|
39
39
|
"dev": "tsup --config=../../tsup.dev.ts"
|
|
40
40
|
},
|
|
41
41
|
"dependencies": {
|
|
42
|
-
"@elementor/editor": "4.4.0-
|
|
43
|
-
"@elementor/editor-canvas": "4.4.0-
|
|
44
|
-
"@elementor/editor-controls": "4.4.0-
|
|
45
|
-
"@elementor/editor-current-user": "4.4.0-
|
|
46
|
-
"@elementor/editor-documents": "4.4.0-
|
|
47
|
-
"@elementor/editor-elements": "4.4.0-
|
|
48
|
-
"@elementor/editor-interactions": "4.4.0-
|
|
49
|
-
"@elementor/editor-notifications": "4.4.0-
|
|
50
|
-
"@elementor/editor-panels": "4.4.0-
|
|
51
|
-
"@elementor/editor-props": "4.4.0-
|
|
52
|
-
"@elementor/editor-responsive": "4.4.0-
|
|
53
|
-
"@elementor/editor-styles": "4.4.0-
|
|
54
|
-
"@elementor/editor-styles-repository": "4.4.0-
|
|
55
|
-
"@elementor/editor-ui": "4.4.0-
|
|
56
|
-
"@elementor/editor-v1-adapters": "4.4.0-
|
|
57
|
-
"@elementor/http-client": "4.4.0-
|
|
42
|
+
"@elementor/editor": "4.4.0-1149",
|
|
43
|
+
"@elementor/editor-canvas": "4.4.0-1149",
|
|
44
|
+
"@elementor/editor-controls": "4.4.0-1149",
|
|
45
|
+
"@elementor/editor-current-user": "4.4.0-1149",
|
|
46
|
+
"@elementor/editor-documents": "4.4.0-1149",
|
|
47
|
+
"@elementor/editor-elements": "4.4.0-1149",
|
|
48
|
+
"@elementor/editor-interactions": "4.4.0-1149",
|
|
49
|
+
"@elementor/editor-notifications": "4.4.0-1149",
|
|
50
|
+
"@elementor/editor-panels": "4.4.0-1149",
|
|
51
|
+
"@elementor/editor-props": "4.4.0-1149",
|
|
52
|
+
"@elementor/editor-responsive": "4.4.0-1149",
|
|
53
|
+
"@elementor/editor-styles": "4.4.0-1149",
|
|
54
|
+
"@elementor/editor-styles-repository": "4.4.0-1149",
|
|
55
|
+
"@elementor/editor-ui": "4.4.0-1149",
|
|
56
|
+
"@elementor/editor-v1-adapters": "4.4.0-1149",
|
|
57
|
+
"@elementor/http-client": "4.4.0-1149",
|
|
58
58
|
"@elementor/icons": "~1.78.1",
|
|
59
|
-
"@elementor/editor-variables": "4.4.0-
|
|
60
|
-
"@elementor/locations": "4.4.0-
|
|
61
|
-
"@elementor/menus": "4.4.0-
|
|
62
|
-
"@elementor/query": "4.4.0-
|
|
63
|
-
"@elementor/schema": "4.4.0-
|
|
64
|
-
"@elementor/session": "4.4.0-
|
|
59
|
+
"@elementor/editor-variables": "4.4.0-1149",
|
|
60
|
+
"@elementor/locations": "4.4.0-1149",
|
|
61
|
+
"@elementor/menus": "4.4.0-1149",
|
|
62
|
+
"@elementor/query": "4.4.0-1149",
|
|
63
|
+
"@elementor/schema": "4.4.0-1149",
|
|
64
|
+
"@elementor/session": "4.4.0-1149",
|
|
65
65
|
"@elementor/ui": "1.41.4",
|
|
66
|
-
"@elementor/utils": "4.4.0-
|
|
67
|
-
"@elementor/wp-media": "4.4.0-
|
|
66
|
+
"@elementor/utils": "4.4.0-1149",
|
|
67
|
+
"@elementor/wp-media": "4.4.0-1149",
|
|
68
68
|
"@wordpress/i18n": "^5.13.0"
|
|
69
69
|
},
|
|
70
70
|
"peerDependencies": {
|
|
@@ -5,6 +5,7 @@ import { SessionStorageProvider } from '@elementor/session';
|
|
|
5
5
|
|
|
6
6
|
import { useElement } from '../contexts/element-context';
|
|
7
7
|
import { useDefaultPanelSettings } from '../hooks/use-default-panel-settings';
|
|
8
|
+
import { isHiddenByAncestor } from '../utils/ancestor-dependency-utils';
|
|
8
9
|
import { extractDependencyEffect } from '../utils/prop-dependency-utils';
|
|
9
10
|
import { Section } from './section';
|
|
10
11
|
import { SectionsList } from './sections-list';
|
|
@@ -88,7 +89,7 @@ function renderSectionItems( {
|
|
|
88
89
|
return [];
|
|
89
90
|
}
|
|
90
91
|
|
|
91
|
-
if ( item.type === 'control' && isControlHiddenByDependencies( item, propsSchema, settings ) ) {
|
|
92
|
+
if ( item.type === 'control' && isControlHiddenByDependencies( item, propsSchema, settings, element.id ) ) {
|
|
92
93
|
return [];
|
|
93
94
|
}
|
|
94
95
|
|
|
@@ -97,8 +98,14 @@ function renderSectionItems( {
|
|
|
97
98
|
);
|
|
98
99
|
}
|
|
99
100
|
|
|
100
|
-
function isControlHiddenByDependencies(
|
|
101
|
-
|
|
101
|
+
function isControlHiddenByDependencies(
|
|
102
|
+
control: Control,
|
|
103
|
+
propsSchema: PropsSchema,
|
|
104
|
+
settings: Props,
|
|
105
|
+
elementId: string
|
|
106
|
+
) {
|
|
107
|
+
const { bind } = control.value;
|
|
108
|
+
const { isHidden } = extractDependencyEffect( bind, propsSchema, settings );
|
|
102
109
|
|
|
103
|
-
return isHidden;
|
|
110
|
+
return isHidden || isHiddenByAncestor( elementId, propsSchema[ bind ] );
|
|
104
111
|
}
|
|
@@ -15,6 +15,7 @@ import { undoable } from '@elementor/editor-v1-adapters';
|
|
|
15
15
|
import { __ } from '@wordpress/i18n';
|
|
16
16
|
|
|
17
17
|
import { useElement } from '../contexts/element-context';
|
|
18
|
+
import { useIsHiddenByAncestor } from '../hooks/use-is-hidden-by-ancestor';
|
|
18
19
|
import { isResponsivePropType } from '../utils/is-responsive-prop-type';
|
|
19
20
|
import {
|
|
20
21
|
extractDependencyEffect,
|
|
@@ -49,9 +50,11 @@ export const SettingsField = ( { bind, children, propDisplayName }: SettingsFiel
|
|
|
49
50
|
propDisplayName,
|
|
50
51
|
} );
|
|
51
52
|
|
|
53
|
+
const isHiddenByAncestor = useIsHiddenByAncestor( bind );
|
|
54
|
+
|
|
52
55
|
const { isDisabled, isHidden } = extractDependencyEffect( bind, propsSchema, currentElementSettings );
|
|
53
56
|
|
|
54
|
-
if ( isHidden ) {
|
|
57
|
+
if ( isHidden || isHiddenByAncestor ) {
|
|
55
58
|
return null;
|
|
56
59
|
}
|
|
57
60
|
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { __privateUseListenTo as useListenTo, commandEndEvent, v1ReadyEvent } from '@elementor/editor-v1-adapters';
|
|
2
|
+
|
|
3
|
+
import { useElement } from '../contexts/element-context';
|
|
4
|
+
import { isHiddenByAncestor } from '../utils/ancestor-dependency-utils';
|
|
5
|
+
|
|
6
|
+
export function useIsHiddenByAncestor( bind: string ): boolean {
|
|
7
|
+
const {
|
|
8
|
+
element: { id: elementId },
|
|
9
|
+
elementType: { propsSchema },
|
|
10
|
+
} = useElement();
|
|
11
|
+
|
|
12
|
+
const propType = propsSchema[ bind ];
|
|
13
|
+
|
|
14
|
+
return useListenTo(
|
|
15
|
+
[
|
|
16
|
+
v1ReadyEvent(),
|
|
17
|
+
commandEndEvent( 'document/elements/set-settings' ),
|
|
18
|
+
commandEndEvent( 'document/elements/create' ),
|
|
19
|
+
commandEndEvent( 'document/elements/delete' ),
|
|
20
|
+
commandEndEvent( 'document/elements/move' ),
|
|
21
|
+
],
|
|
22
|
+
() => isHiddenByAncestor( elementId, propType ),
|
|
23
|
+
[ elementId, propType ]
|
|
24
|
+
);
|
|
25
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { findClosestContainer, getContainer, getWidgetsCache, type V1Element } from '@elementor/editor-elements';
|
|
2
|
+
import { type PropType } from '@elementor/editor-props';
|
|
3
|
+
|
|
4
|
+
import { getElementSettingsWithDefaults, isHiddenByDependency } from './prop-dependency-utils';
|
|
5
|
+
|
|
6
|
+
function getSettingsWithDefaults( ancestor: V1Element, elementType: string ) {
|
|
7
|
+
const schema = getWidgetsCache()?.[ elementType ]?.atomic_props_schema ?? {};
|
|
8
|
+
const settings = Object.fromEntries(
|
|
9
|
+
Object.keys( schema ).map( ( key ) => [ key, ancestor.settings.get( key ) ?? null ] )
|
|
10
|
+
);
|
|
11
|
+
|
|
12
|
+
return getElementSettingsWithDefaults( schema, settings );
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export function isHiddenByAncestor( elementId: string, propType: PropType | undefined ): boolean {
|
|
16
|
+
const ancestorDependency = propType?.meta?.ancestor_dependency;
|
|
17
|
+
|
|
18
|
+
if ( ! Array.isArray( ancestorDependency?.dependency?.terms ) ) {
|
|
19
|
+
return false;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
const ancestor = findClosestContainer(
|
|
23
|
+
getContainer( elementId )?.parent,
|
|
24
|
+
( container ) => container.model.get( 'elType' ) === ancestorDependency.element_type
|
|
25
|
+
);
|
|
26
|
+
|
|
27
|
+
if ( ! ancestor ) {
|
|
28
|
+
return false;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
return isHiddenByDependency(
|
|
32
|
+
ancestorDependency.dependency,
|
|
33
|
+
getSettingsWithDefaults( ancestor, ancestorDependency.element_type )
|
|
34
|
+
);
|
|
35
|
+
}
|
|
@@ -34,16 +34,20 @@ export function getElementSettingsWithDefaults( propsSchema: PropsSchema, elemen
|
|
|
34
34
|
return elementSettingsWithDefaults as Values;
|
|
35
35
|
}
|
|
36
36
|
|
|
37
|
+
export function isHiddenByDependency( dependency: Dependency | undefined, values: Values ): boolean {
|
|
38
|
+
const depCheck = isDependencyMet( dependency, values );
|
|
39
|
+
|
|
40
|
+
const failingTerm = ! depCheck.isMet ? depCheck.failingDependencies[ 0 ] : undefined;
|
|
41
|
+
|
|
42
|
+
return !! failingTerm && ! isDependency( failingTerm ) && failingTerm.effect === 'hide';
|
|
43
|
+
}
|
|
44
|
+
|
|
37
45
|
export function extractDependencyEffect( bind: string, propsSchema: PropsSchema, settings: Props ): DependencyEffect {
|
|
38
46
|
const settingsWithDefaults = getElementSettingsWithDefaults( propsSchema, settings );
|
|
39
47
|
const propType = propsSchema[ bind ];
|
|
40
|
-
const depCheck = isDependencyMet( propType?.dependencies, settingsWithDefaults );
|
|
41
|
-
|
|
42
|
-
const failingTerm = ! depCheck.isMet ? depCheck.failingDependencies[ 0 ] : undefined;
|
|
43
|
-
const isHidden = !! failingTerm && ! isDependency( failingTerm ) && failingTerm?.effect === 'hide';
|
|
44
48
|
|
|
45
49
|
return {
|
|
46
|
-
isHidden,
|
|
50
|
+
isHidden: isHiddenByDependency( propType?.dependencies, settingsWithDefaults ),
|
|
47
51
|
isDisabled: ( prop: PropType ) => ! isDependencyMet( prop?.dependencies, settingsWithDefaults ).isMet,
|
|
48
52
|
};
|
|
49
53
|
}
|