@elementor/editor-editing-panel 1.43.1 → 1.45.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 (53) hide show
  1. package/CHANGELOG.md +41 -0
  2. package/dist/index.d.mts +4 -1
  3. package/dist/index.d.ts +4 -1
  4. package/dist/index.js +1247 -977
  5. package/dist/index.js.map +1 -1
  6. package/dist/index.mjs +1025 -755
  7. package/dist/index.mjs.map +1 -1
  8. package/package.json +8 -8
  9. package/src/action.tsx +1 -1
  10. package/src/components/add-or-remove-content.tsx +3 -4
  11. package/src/components/collapsible-content.tsx +42 -14
  12. package/src/components/control-label.tsx +1 -1
  13. package/src/components/section.tsx +21 -7
  14. package/src/components/style-sections/border-section/border-field.tsx +2 -1
  15. package/src/components/style-sections/border-section/border-radius-field.tsx +12 -9
  16. package/src/components/style-sections/layout-section/align-content-field.tsx +10 -14
  17. package/src/components/style-sections/layout-section/align-items-field.tsx +13 -17
  18. package/src/components/style-sections/layout-section/align-self-child-field.tsx +13 -17
  19. package/src/components/style-sections/layout-section/flex-direction-field.tsx +13 -17
  20. package/src/components/style-sections/layout-section/flex-order-field.tsx +30 -33
  21. package/src/components/style-sections/layout-section/flex-size-field.tsx +60 -59
  22. package/src/components/style-sections/layout-section/justify-content-field.tsx +10 -14
  23. package/src/components/style-sections/layout-section/wrap-field.tsx +13 -17
  24. package/src/components/style-sections/position-section/dimensions-field.tsx +33 -15
  25. package/src/components/style-sections/position-section/offset-field.tsx +5 -2
  26. package/src/components/style-sections/size-section/size-section.tsx +54 -39
  27. package/src/components/style-sections/spacing-section/spacing-section.tsx +1 -1
  28. package/src/components/style-sections/typography-section/column-gap-field.tsx +5 -2
  29. package/src/components/style-sections/typography-section/font-size-field.tsx +5 -2
  30. package/src/components/style-sections/typography-section/letter-spacing-field.tsx +5 -2
  31. package/src/components/style-sections/typography-section/line-height-field.tsx +5 -2
  32. package/src/components/style-sections/typography-section/text-alignment-field.tsx +12 -9
  33. package/src/components/style-sections/typography-section/text-stroke-field.tsx +2 -1
  34. package/src/components/style-sections/typography-section/typography-section.tsx +15 -3
  35. package/src/components/style-sections/typography-section/word-spacing-field.tsx +5 -2
  36. package/src/components/style-tab-collapsible-content.tsx +22 -0
  37. package/src/components/style-tab-section.tsx +30 -0
  38. package/src/components/style-tab.tsx +51 -35
  39. package/src/controls-registry/styles-field.tsx +1 -1
  40. package/src/dynamics/components/background-control-dynamic-tag.tsx +48 -0
  41. package/src/dynamics/components/dynamic-selection-control.tsx +11 -15
  42. package/src/dynamics/init.ts +21 -0
  43. package/src/index.ts +1 -0
  44. package/src/popover-action.tsx +3 -9
  45. package/src/styles-inheritance/components/{label-chip.tsx → infotip/label-chip.tsx} +1 -1
  46. package/src/styles-inheritance/{styles-inheritance-indicator.tsx → components/styles-inheritance-indicator.tsx} +8 -8
  47. package/src/styles-inheritance/{styles-inheritance-infotip.tsx → components/styles-inheritance-infotip.tsx} +7 -7
  48. package/src/styles-inheritance/components/styles-inheritance-section-indicators.tsx +113 -0
  49. package/src/styles-inheritance/components/ui-providers.tsx +18 -0
  50. /package/src/styles-inheritance/components/{action-icons.tsx → infotip/action-icons.tsx} +0 -0
  51. /package/src/styles-inheritance/components/{breakpoint-icon.tsx → infotip/breakpoint-icon.tsx} +0 -0
  52. /package/src/styles-inheritance/components/{index.ts → infotip/index.ts} +0 -0
  53. /package/src/styles-inheritance/components/{value-component.tsx → infotip/value-component.tsx} +0 -0
@@ -0,0 +1,113 @@
1
+ import * as React from 'react';
2
+ import { type PropKey } from '@elementor/editor-props';
3
+ import { type StyleDefinitionVariant } from '@elementor/editor-styles';
4
+ import { ELEMENTS_BASE_STYLES_PROVIDER_KEY, isElementsStylesProvider } from '@elementor/editor-styles-repository';
5
+ import { Stack, Tooltip } from '@elementor/ui';
6
+ import { __ } from '@wordpress/i18n';
7
+
8
+ import { StyleIndicator } from '../../components/style-indicator';
9
+ import { useStyle } from '../../contexts/style-context';
10
+ import { useStylesInheritanceSnapshot } from '../../contexts/styles-inheritance-context';
11
+ import { type SnapshotPropValue } from '../types';
12
+
13
+ type Props = {
14
+ fields: PropKey[];
15
+ };
16
+
17
+ type Indicators = {
18
+ global?: true;
19
+ local?: true;
20
+ overridden?: true;
21
+ };
22
+
23
+ const orderedVariants = [ 'global', 'local', 'overridden' ] as ( keyof Indicators )[];
24
+
25
+ export const StylesInheritanceSectionIndicators = ( { fields }: Props ) => {
26
+ const { id, meta } = useStyle();
27
+ const snapshot = useStylesInheritanceSnapshot();
28
+
29
+ const snapshotFields = Object.fromEntries(
30
+ Object.entries( snapshot ?? {} ).filter( ( [ key ] ) => fields.includes( key as PropKey ) )
31
+ );
32
+
33
+ const indicators = getIndicators( snapshotFields, id ?? '', meta );
34
+
35
+ if ( Object.values( indicators ).filter( Boolean ).length === 0 ) {
36
+ return null;
37
+ }
38
+
39
+ const hasActualValues = __( 'Has effective styles', 'elementor' );
40
+ const hasOverriddenValues = __( 'Has overridden styles', 'elementor' );
41
+
42
+ return (
43
+ <Tooltip title={ __( 'Has styles', 'elementor' ) } placement="top">
44
+ <Stack direction="row" sx={ { '& > *': { marginInlineStart: -0.25 } } } role="list">
45
+ { orderedVariants.map(
46
+ ( variant ) =>
47
+ indicators[ variant ] && (
48
+ <StyleIndicator
49
+ key={ variant }
50
+ variant={ variant }
51
+ data-variant={ variant }
52
+ role="listitem"
53
+ aria-label={ variant === 'overridden' ? hasOverriddenValues : hasActualValues }
54
+ />
55
+ )
56
+ ) }
57
+ </Stack>
58
+ </Tooltip>
59
+ );
60
+ };
61
+
62
+ function getIndicators(
63
+ snapshotFields: Record< PropKey, SnapshotPropValue[] >,
64
+ styleId: string,
65
+ meta: StyleDefinitionVariant[ 'meta' ]
66
+ ): Indicators {
67
+ const indicators: Indicators = {};
68
+
69
+ Object.values( snapshotFields ).forEach( ( inheritanceChain ) => {
70
+ const currentStyle = getCurrentStyleFromChain( inheritanceChain, styleId, meta );
71
+
72
+ if ( ! currentStyle ) {
73
+ return;
74
+ }
75
+
76
+ const [ actualStyle ] = inheritanceChain;
77
+
78
+ if ( currentStyle === actualStyle ) {
79
+ const providerKey = actualStyle.provider ?? '';
80
+
81
+ if ( isElementsStylesProvider( providerKey ) ) {
82
+ indicators.local = true;
83
+
84
+ return;
85
+ }
86
+
87
+ if ( providerKey !== ELEMENTS_BASE_STYLES_PROVIDER_KEY ) {
88
+ indicators.global = true;
89
+ }
90
+
91
+ return;
92
+ }
93
+
94
+ indicators.overridden = true;
95
+ } );
96
+
97
+ return indicators;
98
+ }
99
+
100
+ function getCurrentStyleFromChain(
101
+ chain: SnapshotPropValue[],
102
+ styleId: string,
103
+ meta: StyleDefinitionVariant[ 'meta' ]
104
+ ): SnapshotPropValue | undefined {
105
+ return chain.find(
106
+ ( {
107
+ style: { id },
108
+ variant: {
109
+ meta: { breakpoint, state },
110
+ },
111
+ } ) => id === styleId && breakpoint === meta.breakpoint && state === meta.state
112
+ );
113
+ }
@@ -0,0 +1,18 @@
1
+ import * as React from 'react';
2
+ import { DirectionProvider, ThemeProvider } from '@elementor/ui';
3
+
4
+ import { useDirection } from '../../hooks/use-direction';
5
+
6
+ interface UiProvidersProps {
7
+ children: React.ReactNode;
8
+ }
9
+
10
+ export const UiProviders: React.FC< UiProvidersProps > = ( { children } ) => {
11
+ const { isSiteRtl } = useDirection();
12
+
13
+ return (
14
+ <DirectionProvider rtl={ isSiteRtl }>
15
+ <ThemeProvider>{ children }</ThemeProvider>
16
+ </DirectionProvider>
17
+ );
18
+ };