@elementor/editor-editing-panel 1.24.0 → 1.28.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.
Files changed (36) hide show
  1. package/CHANGELOG.md +102 -0
  2. package/dist/index.d.mts +3 -1
  3. package/dist/index.d.ts +3 -1
  4. package/dist/index.js +448 -309
  5. package/dist/index.js.map +1 -1
  6. package/dist/index.mjs +426 -287
  7. package/dist/index.mjs.map +1 -1
  8. package/package.json +11 -10
  9. package/src/components/css-classes/css-class-item.tsx +8 -10
  10. package/src/components/css-classes/css-class-menu.tsx +60 -12
  11. package/src/components/css-classes/css-class-selector.tsx +28 -27
  12. package/src/components/editing-panel-tabs.tsx +1 -8
  13. package/src/components/multi-combobox.tsx +3 -0
  14. package/src/components/style-indicator.tsx +23 -0
  15. package/src/components/style-sections/border-section/border-radius-field.tsx +4 -5
  16. package/src/components/style-sections/border-section/border-width-field.tsx +2 -3
  17. package/src/components/style-sections/layout-section/display-field.tsx +34 -28
  18. package/src/components/style-sections/layout-section/flex-size-field.tsx +28 -18
  19. package/src/components/style-sections/layout-section/layout-section.tsx +14 -2
  20. package/src/components/style-sections/typography-section/text-alignment-field.tsx +5 -6
  21. package/src/components/style-tab.tsx +2 -19
  22. package/src/contexts/style-context.tsx +2 -2
  23. package/src/controls-registry/control-type-container.tsx +2 -2
  24. package/src/controls-registry/styles-field.tsx +9 -2
  25. package/src/dynamics/dynamic-transformer.ts +61 -0
  26. package/src/dynamics/errors.ts +6 -0
  27. package/src/dynamics/init.ts +6 -0
  28. package/src/dynamics/types.ts +17 -0
  29. package/src/hooks/use-active-style-def-id.ts +36 -0
  30. package/src/hooks/use-styles-fields.ts +7 -7
  31. package/src/index.ts +1 -3
  32. package/src/init.ts +1 -1
  33. package/src/styles-inheritance/create-snapshots-manager.ts +16 -9
  34. package/src/styles-inheritance/create-styles-inheritance.ts +8 -4
  35. package/src/styles-inheritance/styles-inheritance-indicator.tsx +13 -31
  36. package/src/styles-inheritance/types.ts +7 -6
@@ -1,32 +1,12 @@
1
1
  import * as React from 'react';
2
2
  import { useBoundProp } from '@elementor/editor-controls';
3
- import { ELEMENTS_STYLES_PROVIDER_KEY } from '@elementor/editor-styles-repository';
4
- import { styled } from '@elementor/ui';
3
+ import { ELEMENTS_BASE_STYLES_PROVIDER_KEY, isElementsStylesProvider } from '@elementor/editor-styles-repository';
5
4
  import { __ } from '@wordpress/i18n';
6
5
 
6
+ import { StyleIndicator } from '../components/style-indicator';
7
7
  import { useStyle } from '../contexts/style-context';
8
8
  import { useStylesInheritanceField } from '../contexts/styles-inheritance-context';
9
9
 
10
- const Circle = styled( 'div', {
11
- shouldForwardProp: ( prop ) => prop !== 'variant',
12
- } )< { variant?: 'overridden' | 'local-affects' | 'global-affects' } >`
13
- width: 5px;
14
- height: 5px;
15
- border-radius: 50%;
16
- background-color: ${ ( { theme, variant } ) => {
17
- switch ( variant ) {
18
- case 'overridden':
19
- return theme.palette.warning.light;
20
- case 'global-affects':
21
- return theme.palette.global.dark;
22
- case 'local-affects':
23
- return theme.palette.primary.main;
24
- default:
25
- return theme.palette.text.disabled;
26
- }
27
- } };
28
- `;
29
-
30
10
  export const StylesInheritanceIndicator = () => {
31
11
  const { value, path } = useBoundProp();
32
12
  const { id: currentStyleId, provider: currentStyleProvider, meta: currentStyleMeta } = useStyle();
@@ -39,33 +19,35 @@ export const StylesInheritanceIndicator = () => {
39
19
  return null;
40
20
  }
41
21
 
42
- const [ { styleId, styleVariant } ] = inheritanceChain;
22
+ const [ { style, variant, provider } ] = inheritanceChain;
23
+
24
+ if ( provider === ELEMENTS_BASE_STYLES_PROVIDER_KEY ) {
25
+ return null;
26
+ }
43
27
 
44
- const { breakpoint, state } = styleVariant.meta;
28
+ const { breakpoint, state } = variant.meta;
45
29
 
46
30
  if (
47
- styleId === currentStyleId &&
31
+ style.id === currentStyleId &&
48
32
  breakpoint === currentStyleMeta.breakpoint &&
49
33
  state === currentStyleMeta.state
50
34
  ) {
51
35
  return (
52
- <Circle
36
+ <StyleIndicator
53
37
  aria-label={ __( 'This is the final value', 'elementor' ) }
54
- variant={
55
- currentStyleProvider?.key === ELEMENTS_STYLES_PROVIDER_KEY ? 'local-affects' : 'global-affects'
56
- }
38
+ variant={ isElementsStylesProvider( currentStyleProvider?.getKey() ) ? 'local' : 'global' }
57
39
  />
58
40
  );
59
41
  }
60
42
 
61
43
  if ( value !== null && value !== undefined ) {
62
44
  return (
63
- <Circle
45
+ <StyleIndicator
64
46
  aria-label={ __( 'This value is overridden by another style', 'elementor' ) }
65
47
  variant="overridden"
66
48
  />
67
49
  );
68
50
  }
69
51
 
70
- return <Circle aria-label={ __( 'This has value from another style', 'elementor' ) } />;
52
+ return <StyleIndicator aria-label={ __( 'This has value from another style', 'elementor' ) } />;
71
53
  };
@@ -1,17 +1,18 @@
1
1
  import { type PropValue } from '@elementor/editor-props';
2
2
  import { type BreakpointId } from '@elementor/editor-responsive';
3
- import { type StyleDefinitionState, type StyleDefinitionVariant } from '@elementor/editor-styles';
3
+ import { type StyleDefinition, type StyleDefinitionState, type StyleDefinitionVariant } from '@elementor/editor-styles';
4
4
 
5
5
  export type StyleDefinitionStateWithNormal = NonNullable< StyleDefinitionState > | 'normal';
6
6
 
7
7
  type StatesMapping< T > = Partial< Record< StyleDefinitionStateWithNormal, T > >;
8
8
 
9
- export type StyleVariantWithId = {
10
- styleId: string;
11
- styleVariant: StyleDefinitionVariant;
9
+ export type StyleVariantDetails = {
10
+ style: StyleDefinition;
11
+ provider: string | null;
12
+ variant: StyleDefinitionVariant;
12
13
  };
13
14
 
14
- export type SnapshotPropValue = StyleVariantWithId & {
15
+ export type SnapshotPropValue = StyleVariantDetails & {
15
16
  value: PropValue;
16
17
  };
17
18
 
@@ -26,7 +27,7 @@ export type BreakpointStatesSlotsMapping = StatesMapping< StylesInheritanceSnaps
26
27
 
27
28
  export type BreakpointsStatesSnapshotsMapping = Partial< Record< BreakpointId, BreakpointStatesSlotsMapping > >;
28
29
 
29
- type BreakpointStatesStyles = StatesMapping< StyleVariantWithId[] >;
30
+ type BreakpointStatesStyles = StatesMapping< StyleVariantDetails[] >;
30
31
 
31
32
  export type BreakpointsStatesStyles = Partial< Record< BreakpointId, Partial< BreakpointStatesStyles > > >;
32
33