@elementor/editor-editing-panel 1.50.0 → 3.32.0-21

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 (55) hide show
  1. package/CHANGELOG.md +0 -27
  2. package/dist/index.d.mts +78 -47
  3. package/dist/index.d.ts +78 -47
  4. package/dist/index.js +1723 -1384
  5. package/dist/index.js.map +1 -1
  6. package/dist/index.mjs +1510 -1143
  7. package/dist/index.mjs.map +1 -1
  8. package/package.json +22 -22
  9. package/src/components/css-classes/css-class-convert-local.tsx +77 -0
  10. package/src/components/css-classes/css-class-item.tsx +15 -1
  11. package/src/components/css-classes/css-class-menu.tsx +8 -1
  12. package/src/components/css-classes/local-class-sub-menu.tsx +23 -0
  13. package/src/components/css-classes/use-apply-and-unapply-class.ts +7 -50
  14. package/src/components/css-classes/use-can-convert-local-class-to-global.ts +22 -0
  15. package/src/components/custom-css.tsx +21 -0
  16. package/src/components/editing-panel-tabs.tsx +1 -5
  17. package/src/components/section.tsx +1 -5
  18. package/src/components/settings-tab.tsx +6 -15
  19. package/src/components/style-sections/effects-section/effects-section.tsx +30 -22
  20. package/src/components/style-sections/layout-section/display-field.tsx +11 -20
  21. package/src/components/style-sections/layout-section/flex-size-field.tsx +86 -52
  22. package/src/components/style-sections/position-section/offset-field.tsx +2 -2
  23. package/src/components/style-sections/position-section/position-section.tsx +2 -8
  24. package/src/components/style-sections/size-section/size-section.tsx +16 -31
  25. package/src/components/style-sections/typography-section/typography-section.tsx +2 -19
  26. package/src/components/style-tab-collapsible-content.tsx +1 -5
  27. package/src/components/style-tab-section.tsx +1 -5
  28. package/src/components/style-tab.tsx +15 -2
  29. package/src/controls-actions.ts +1 -1
  30. package/src/controls-registry/conditional-field.tsx +26 -0
  31. package/src/controls-registry/control.tsx +2 -2
  32. package/src/controls-registry/controls-registry.tsx +44 -3
  33. package/src/controls-registry/settings-field.tsx +33 -45
  34. package/src/controls-registry/styles-field.tsx +14 -14
  35. package/src/dynamics/components/dynamic-selection-control.tsx +2 -2
  36. package/src/errors.ts +10 -0
  37. package/src/hooks/use-custom-css.ts +184 -0
  38. package/src/hooks/use-state-by-element.ts +1 -4
  39. package/src/hooks/use-styles-fields.ts +129 -106
  40. package/src/index.ts +9 -10
  41. package/src/init.ts +2 -5
  42. package/src/popover-action.tsx +36 -15
  43. package/src/reset-style-props.tsx +2 -6
  44. package/src/styles-inheritance/components/infotip/value-component.tsx +1 -0
  45. package/src/styles-inheritance/components/styles-inheritance-indicator.tsx +6 -23
  46. package/src/styles-inheritance/components/styles-inheritance-infotip.tsx +17 -8
  47. package/src/styles-inheritance/consts.ts +0 -4
  48. package/src/styles-inheritance/init.ts +1 -4
  49. package/src/styles-inheritance/transformers/background-color-overlay-transformer.tsx +5 -1
  50. package/src/styles-inheritance/transformers/background-gradient-overlay-transformer.tsx +3 -3
  51. package/src/styles-inheritance/transformers/background-image-overlay-transformer.tsx +2 -1
  52. package/src/utils/prop-dependency-utils.ts +156 -0
  53. package/src/components/style-sections/size-section/object-position-field.tsx +0 -15
  54. package/src/sync/experiments-flags.ts +0 -5
  55. /package/src/components/style-sections/{layout-section → effects-section}/opacity-control-field.tsx +0 -0
@@ -17,7 +17,7 @@ type Gradient = {
17
17
  };
18
18
 
19
19
  export const backgroundGradientOverlayTransformer = createTransformer( ( value: Gradient ) => (
20
- <Stack direction="row" gap={ 10 }>
20
+ <Stack direction="row" gap={ 1 } alignItems="center">
21
21
  <ItemIconGradient value={ value } />
22
22
  <ItemLabelGradient value={ value } />
23
23
  </Stack>
@@ -31,10 +31,10 @@ const ItemIconGradient = ( { value }: { value: Gradient } ) => {
31
31
 
32
32
  const ItemLabelGradient = ( { value }: { value: Gradient } ) => {
33
33
  if ( value.type === 'linear' ) {
34
- return <span>{ __( 'Linear Gradient', 'elementor' ) }</span>;
34
+ return <span>{ __( 'Linear gradient', 'elementor' ) }</span>;
35
35
  }
36
36
 
37
- return <span>{ __( 'Radial Gradient', 'elementor' ) }</span>;
37
+ return <span>{ __( 'Radial gradient', 'elementor' ) }</span>;
38
38
  };
39
39
 
40
40
  const getGradientValue = ( gradient: Gradient ) => {
@@ -16,7 +16,7 @@ type Image = {
16
16
  };
17
17
 
18
18
  export const backgroundImageOverlayTransformer = createTransformer( ( value: Image ) => (
19
- <Stack direction="row" gap={ 10 }>
19
+ <Stack direction="row" gap={ 1 } alignItems="center">
20
20
  <ItemIconImage value={ value } />
21
21
  <ItemLabelImage value={ value } />
22
22
  </Stack>
@@ -33,6 +33,7 @@ const ItemIconImage = ( { value }: { value: Image } ) => {
33
33
  width: '1em',
34
34
  borderRadius: `${ theme.shape.borderRadius / 2 }px`,
35
35
  outline: `1px solid ${ theme.palette.action.disabled }`,
36
+ flexShrink: 0,
36
37
  } ) }
37
38
  />
38
39
  );
@@ -0,0 +1,156 @@
1
+ import {
2
+ extractValue,
3
+ isDependencyMet,
4
+ type PropsSchema,
5
+ type PropType,
6
+ type TransformablePropValue,
7
+ } from '@elementor/editor-props';
8
+
9
+ type Value = TransformablePropValue< string > | null;
10
+
11
+ export type Values = Record< string, Value >;
12
+
13
+ export function extractOrderedDependencies(
14
+ bind: string,
15
+ propsSchema: PropsSchema,
16
+ elementValues: Values,
17
+ dependenciesPerTargetMapping: Record< string, string[] >
18
+ ): string[] {
19
+ const prop = getPropType( propsSchema, elementValues, bind.split( '.' ) );
20
+
21
+ if ( ! prop ) {
22
+ return [];
23
+ }
24
+
25
+ const dependencies: string[] = [];
26
+
27
+ if ( 'object' === prop.kind ) {
28
+ dependencies.push( ...Object.keys( prop.shape ).map( ( key ) => bind + '.' + key ) );
29
+ }
30
+
31
+ const directDependencies = extractPropOrderedDependencies( bind, dependenciesPerTargetMapping );
32
+
33
+ if ( ! dependencies.length ) {
34
+ return directDependencies;
35
+ }
36
+
37
+ return dependencies.reduce(
38
+ ( carry, dependency ) => [
39
+ ...carry,
40
+ ...extractOrderedDependencies( dependency, propsSchema, elementValues, dependenciesPerTargetMapping ),
41
+ ],
42
+ directDependencies
43
+ );
44
+ }
45
+
46
+ function extractPropOrderedDependencies(
47
+ bind: string,
48
+ dependenciesPerTargetMapping: Record< string, string[] >
49
+ ): string[] {
50
+ if ( ! dependenciesPerTargetMapping?.[ bind ]?.length ) {
51
+ return [];
52
+ }
53
+
54
+ return dependenciesPerTargetMapping[ bind ].reduce< string[] >(
55
+ ( dependencies, dependency ) => [
56
+ ...dependencies,
57
+ dependency,
58
+ ...extractPropOrderedDependencies( dependency, dependenciesPerTargetMapping ),
59
+ ],
60
+ []
61
+ );
62
+ }
63
+
64
+ export function updateValues(
65
+ values: Values,
66
+ dependencies: string[],
67
+ propsSchema: PropsSchema,
68
+ elementValues: Values
69
+ ): Values {
70
+ if ( ! dependencies.length ) {
71
+ return values;
72
+ }
73
+
74
+ return dependencies.reduce(
75
+ ( newValues, dependency ) => {
76
+ const path = dependency.split( '.' );
77
+ const propType = getPropType( propsSchema, elementValues, path );
78
+ const combinedValues = { ...elementValues, ...newValues };
79
+
80
+ if ( ! propType ) {
81
+ return newValues;
82
+ }
83
+
84
+ if ( ! isDependencyMet( propType?.dependencies, combinedValues ) ) {
85
+ return {
86
+ ...newValues,
87
+ ...updateValue( path, null, combinedValues ),
88
+ };
89
+ }
90
+
91
+ return newValues;
92
+ },
93
+ { ...values }
94
+ );
95
+ }
96
+
97
+ function getPropType( schema: PropsSchema, elementValues: Values, path: string[] ): PropType | null {
98
+ if ( ! path.length ) {
99
+ return null;
100
+ }
101
+
102
+ const [ basePropKey, ...keys ] = path;
103
+ const baseProp = schema[ basePropKey ];
104
+
105
+ if ( ! baseProp ) {
106
+ return null;
107
+ }
108
+
109
+ return keys.reduce( ( prop: PropType | null, key, index ) => {
110
+ if ( ! prop?.kind ) {
111
+ return null;
112
+ }
113
+
114
+ if ( 'union' === prop.kind ) {
115
+ const value = extractValue( path.slice( 0, index + 1 ), elementValues );
116
+ const type = ( value?.$$type as string ) ?? null;
117
+
118
+ return getPropType(
119
+ { [ basePropKey ]: prop.prop_types?.[ type ] },
120
+ elementValues,
121
+ path.slice( 0, index + 2 )
122
+ );
123
+ }
124
+
125
+ if ( 'array' === prop.kind ) {
126
+ return prop.item_prop_type;
127
+ }
128
+
129
+ if ( 'object' === prop.kind ) {
130
+ return prop.shape[ key ];
131
+ }
132
+
133
+ return prop[ key as keyof typeof prop ] as PropType;
134
+ }, baseProp );
135
+ }
136
+
137
+ function updateValue( path: string[], value: Value, values: Values ) {
138
+ const topPropKey = path[ 0 ];
139
+ const newValue: Values = { ...values };
140
+
141
+ path.reduce( ( carry: Values | null, key, index ) => {
142
+ if ( ! carry ) {
143
+ return null;
144
+ }
145
+
146
+ if ( index === path.length - 1 ) {
147
+ carry[ key ] = value !== null ? ( { ...( carry[ key ] ?? {} ), value } as Value ) : null;
148
+
149
+ return ( carry[ key ]?.value as Values ) ?? carry.value;
150
+ }
151
+
152
+ return ( carry[ key ]?.value as Values ) ?? carry.value;
153
+ }, newValue );
154
+
155
+ return { [ topPropKey ]: newValue[ topPropKey ] ?? null };
156
+ }
@@ -1,15 +0,0 @@
1
- import * as React from 'react';
2
- import { PositionControl } from '@elementor/editor-controls';
3
- import { __ } from '@wordpress/i18n';
4
-
5
- import { StylesField } from '../../../controls-registry/styles-field';
6
-
7
- const OBJECT_POSITION_LABEL = __( 'Object position', 'elementor' );
8
-
9
- export const ObjectPositionField = () => {
10
- return (
11
- <StylesField bind="object-position" propDisplayName={ OBJECT_POSITION_LABEL }>
12
- <PositionControl />
13
- </StylesField>
14
- );
15
- };
@@ -1,5 +0,0 @@
1
- // Experimental features flags
2
- export const EXPERIMENTAL_FEATURES = {
3
- V_3_30: 'e_v_3_30',
4
- V_3_31: 'e_v_3_31',
5
- };