@elementor/editor-editing-panel 4.2.0-872 → 4.2.0-873

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@elementor/editor-editing-panel",
3
- "version": "4.2.0-872",
3
+ "version": "4.2.0-873",
4
4
  "private": false,
5
5
  "author": "Elementor Team",
6
6
  "homepage": "https://elementor.com/",
@@ -39,31 +39,31 @@
39
39
  "dev": "tsup --config=../../tsup.dev.ts"
40
40
  },
41
41
  "dependencies": {
42
- "@elementor/editor": "4.2.0-872",
43
- "@elementor/editor-canvas": "4.2.0-872",
44
- "@elementor/editor-controls": "4.2.0-872",
45
- "@elementor/editor-documents": "4.2.0-872",
46
- "@elementor/editor-elements": "4.2.0-872",
47
- "@elementor/editor-interactions": "4.2.0-872",
48
- "@elementor/editor-notifications": "4.2.0-872",
49
- "@elementor/editor-panels": "4.2.0-872",
50
- "@elementor/editor-props": "4.2.0-872",
51
- "@elementor/editor-responsive": "4.2.0-872",
52
- "@elementor/editor-styles": "4.2.0-872",
53
- "@elementor/editor-styles-repository": "4.2.0-872",
54
- "@elementor/editor-ui": "4.2.0-872",
55
- "@elementor/editor-v1-adapters": "4.2.0-872",
56
- "@elementor/http-client": "4.2.0-872",
42
+ "@elementor/editor": "4.2.0-873",
43
+ "@elementor/editor-canvas": "4.2.0-873",
44
+ "@elementor/editor-controls": "4.2.0-873",
45
+ "@elementor/editor-documents": "4.2.0-873",
46
+ "@elementor/editor-elements": "4.2.0-873",
47
+ "@elementor/editor-interactions": "4.2.0-873",
48
+ "@elementor/editor-notifications": "4.2.0-873",
49
+ "@elementor/editor-panels": "4.2.0-873",
50
+ "@elementor/editor-props": "4.2.0-873",
51
+ "@elementor/editor-responsive": "4.2.0-873",
52
+ "@elementor/editor-styles": "4.2.0-873",
53
+ "@elementor/editor-styles-repository": "4.2.0-873",
54
+ "@elementor/editor-ui": "4.2.0-873",
55
+ "@elementor/editor-v1-adapters": "4.2.0-873",
56
+ "@elementor/http-client": "4.2.0-873",
57
57
  "@elementor/icons": "~1.75.1",
58
- "@elementor/editor-variables": "4.2.0-872",
59
- "@elementor/locations": "4.2.0-872",
60
- "@elementor/menus": "4.2.0-872",
61
- "@elementor/query": "4.2.0-872",
62
- "@elementor/schema": "4.2.0-872",
63
- "@elementor/session": "4.2.0-872",
58
+ "@elementor/editor-variables": "4.2.0-873",
59
+ "@elementor/locations": "4.2.0-873",
60
+ "@elementor/menus": "4.2.0-873",
61
+ "@elementor/query": "4.2.0-873",
62
+ "@elementor/schema": "4.2.0-873",
63
+ "@elementor/session": "4.2.0-873",
64
64
  "@elementor/ui": "1.37.5",
65
- "@elementor/utils": "4.2.0-872",
66
- "@elementor/wp-media": "4.2.0-872",
65
+ "@elementor/utils": "4.2.0-873",
66
+ "@elementor/wp-media": "4.2.0-873",
67
67
  "@wordpress/i18n": "^5.13.0"
68
68
  },
69
69
  "peerDependencies": {
@@ -1,16 +1,19 @@
1
1
  import * as React from 'react';
2
2
  import { type Control, type ControlItem, type Element, type ElementControl } from '@elementor/editor-elements';
3
+ import { type Props, type PropsSchema } from '@elementor/editor-props';
3
4
  import { SessionStorageProvider } from '@elementor/session';
4
5
 
5
6
  import { useElement } from '../contexts/element-context';
6
7
  import { useDefaultPanelSettings } from '../hooks/use-default-panel-settings';
8
+ import { extractDependencyEffect } from '../utils/prop-dependency-utils';
7
9
  import { Section } from './section';
8
10
  import { SectionsList } from './sections-list';
9
11
  import { SettingsControl } from './settings-control';
10
12
 
11
13
  export const SettingsTab = () => {
12
- const { elementType, element } = useElement();
14
+ const { elementType, element, settings } = useElement();
13
15
  const settingsDefault = useDefaultPanelSettings();
16
+ const currentSettings = settings as Props;
14
17
 
15
18
  const isDefaultExpanded = ( sectionId: string ) =>
16
19
  settingsDefault.defaultSectionsExpanded.settings?.includes( sectionId );
@@ -26,20 +29,24 @@ export const SettingsTab = () => {
26
29
  const { type, value } = control;
27
30
 
28
31
  if ( type === 'section' ) {
32
+ const sectionItems = renderSectionItems( {
33
+ items: value.items,
34
+ element,
35
+ propsSchema: elementType.propsSchema,
36
+ settings: currentSettings,
37
+ } );
38
+
39
+ if ( ! sectionItems.length ) {
40
+ return null;
41
+ }
42
+
29
43
  return (
30
44
  <Section
31
45
  title={ value.label }
32
46
  key={ type + '.' + index }
33
47
  defaultExpanded={ isDefaultExpanded( value.label ) }
34
48
  >
35
- { value.items?.map( ( item ) => {
36
- if ( isControl( item ) ) {
37
- return <SettingsControl key={ getKey( item, element ) } control={ item } />;
38
- }
39
-
40
- // TODO: Handle 2nd level sections
41
- return null;
42
- } ) }
49
+ { sectionItems }
43
50
  </Section>
44
51
  );
45
52
  }
@@ -62,3 +69,36 @@ function getKey( control: Control | ElementControl, element: Element ) {
62
69
  function isControl( control: ControlItem ): control is Control | ElementControl {
63
70
  return control.type === 'control' || control.type === 'element-control';
64
71
  }
72
+
73
+ function renderSectionItems( {
74
+ items,
75
+ element,
76
+ propsSchema,
77
+ settings,
78
+ }: {
79
+ items?: ControlItem[];
80
+ element: Element;
81
+ propsSchema: PropsSchema;
82
+ settings: Props;
83
+ } ) {
84
+ return (
85
+ items?.flatMap( ( item ) => {
86
+ if ( ! isControl( item ) ) {
87
+ // TODO: Handle 2nd level sections
88
+ return [];
89
+ }
90
+
91
+ if ( item.type === 'control' && isControlHiddenByDependencies( item, propsSchema, settings ) ) {
92
+ return [];
93
+ }
94
+
95
+ return [ <SettingsControl key={ getKey( item, element ) } control={ item } /> ];
96
+ } ) ?? []
97
+ );
98
+ }
99
+
100
+ function isControlHiddenByDependencies( control: Control, propsSchema: PropsSchema, settings: Props ) {
101
+ const { isHidden } = extractDependencyEffect( control.value.bind, propsSchema, settings );
102
+
103
+ return isHidden;
104
+ }