@elementor/editor-editing-panel 0.19.0 → 1.0.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 (115) hide show
  1. package/CHANGELOG.md +51 -0
  2. package/dist/index.d.mts +5 -22
  3. package/dist/index.d.ts +5 -22
  4. package/dist/index.js +1444 -1165
  5. package/dist/index.js.map +1 -1
  6. package/dist/index.mjs +1434 -1148
  7. package/dist/index.mjs.map +1 -1
  8. package/package.json +15 -14
  9. package/src/components/accordion-section.tsx +3 -2
  10. package/src/components/add-or-remove-content.tsx +42 -0
  11. package/src/components/collapsible-field.tsx +34 -0
  12. package/src/components/editing-panel.tsx +15 -18
  13. package/src/components/settings-tab.tsx +11 -10
  14. package/src/components/style-sections/background-section/background-color-field.tsx +21 -0
  15. package/src/components/style-sections/background-section/background-section.tsx +2 -2
  16. package/src/components/style-sections/border-section/border-color-field.tsx +21 -0
  17. package/src/components/style-sections/border-section/border-field.tsx +47 -0
  18. package/src/components/style-sections/border-section/border-radius-field.tsx +48 -0
  19. package/src/components/style-sections/border-section/border-section.tsx +16 -0
  20. package/src/components/style-sections/border-section/border-style-field.tsx +32 -0
  21. package/src/components/style-sections/border-section/border-width-field.tsx +42 -0
  22. package/src/components/style-sections/effects-section/effects-section.tsx +5 -5
  23. package/src/components/style-sections/position-section/dimensions-field.tsx +46 -0
  24. package/src/components/style-sections/position-section/position-field.tsx +28 -0
  25. package/src/components/style-sections/position-section/position-section.tsx +15 -2
  26. package/src/components/style-sections/position-section/z-index-field.tsx +21 -0
  27. package/src/components/style-sections/size-section/overflow-field.tsx +45 -0
  28. package/src/components/style-sections/size-section/size-section.tsx +55 -0
  29. package/src/components/style-sections/spacing-section/spacing-section.tsx +6 -6
  30. package/src/components/style-sections/typography-section/font-size-field.tsx +21 -0
  31. package/src/components/style-sections/typography-section/{font-weight-control.tsx → font-weight-field.tsx} +7 -6
  32. package/src/components/style-sections/typography-section/letter-spacing-field.tsx +21 -0
  33. package/src/components/style-sections/typography-section/{text-alignment-control.tsx → text-alignment-field.tsx} +7 -7
  34. package/src/components/style-sections/typography-section/text-color-field.tsx +21 -0
  35. package/src/components/style-sections/typography-section/{text-direction-control.tsx → text-direction-field.tsx} +7 -7
  36. package/src/components/style-sections/typography-section/text-stroke-field.tsx +16 -0
  37. package/src/components/style-sections/typography-section/{text-style-control.tsx → text-style-field.tsx} +4 -4
  38. package/src/components/style-sections/typography-section/{transform-control.tsx → transform-field.tsx} +7 -6
  39. package/src/components/style-sections/typography-section/typography-section.tsx +20 -18
  40. package/src/components/style-sections/typography-section/word-spacing-field.tsx +21 -0
  41. package/src/components/style-tab.tsx +42 -25
  42. package/src/contexts/classes-prop-context.tsx +24 -0
  43. package/src/{controls/providers/element-provider.tsx → contexts/element-context.tsx} +3 -7
  44. package/src/contexts/style-context.tsx +8 -22
  45. package/src/control-replacement.tsx +1 -1
  46. package/src/controls/bound-prop-context.tsx +30 -0
  47. package/src/controls/components/control-toggle-button-group.tsx +15 -6
  48. package/src/controls/components/repeater.tsx +1 -1
  49. package/src/controls/components/text-field-inner-selection.tsx +20 -24
  50. package/src/controls/control-actions/control-actions-context.tsx +27 -0
  51. package/src/controls/control-actions/control-actions-menu.ts +6 -7
  52. package/src/controls/control-actions/control-actions.tsx +14 -26
  53. package/src/{components/style-sections/effects-section/box-shadow-repeater.tsx → controls/controls/box-shadow-repeater-control.tsx} +51 -65
  54. package/src/controls/controls/color-control.tsx +25 -0
  55. package/src/controls/controls/equal-unequal-sizes-control.tsx +196 -0
  56. package/src/controls/{control-types → controls}/image-control.tsx +15 -23
  57. package/src/controls/{control-types → controls}/image-media-control.tsx +5 -14
  58. package/src/{components/style-sections/spacing-section → controls/controls}/linked-dimensions-control.tsx +10 -26
  59. package/src/controls/{control-types → controls}/number-control.tsx +2 -2
  60. package/src/controls/{control-types → controls}/select-control.tsx +4 -4
  61. package/src/controls/{control-types → controls}/size-control.tsx +8 -8
  62. package/src/controls/controls/stroke-control.tsx +105 -0
  63. package/src/controls/{control-types → controls}/text-area-control.tsx +3 -3
  64. package/src/controls/{control-types → controls}/text-control.tsx +3 -3
  65. package/src/controls/{control-types → controls}/toggle-control.tsx +4 -4
  66. package/src/controls/create-control-replacement.tsx +3 -3
  67. package/src/controls/index.ts +24 -0
  68. package/src/controls-actions.ts +8 -0
  69. package/src/{controls/components → controls-registry}/control-type-container.tsx +1 -1
  70. package/src/{controls → controls-registry}/controls-registry.tsx +1 -6
  71. package/src/controls-registry/settings-field.tsx +35 -0
  72. package/src/controls-registry/styles-field.tsx +19 -0
  73. package/src/dynamics/components/dynamic-selection-control.tsx +11 -11
  74. package/src/dynamics/components/dynamic-selection.tsx +3 -3
  75. package/src/dynamics/dynamic-control.tsx +6 -5
  76. package/src/dynamics/hooks/use-dynamic-tag.ts +1 -1
  77. package/src/dynamics/hooks/use-prop-dynamic-action.tsx +6 -6
  78. package/src/dynamics/hooks/use-prop-dynamic-tags.ts +2 -2
  79. package/src/dynamics/hooks/use-prop-value-history.ts +2 -2
  80. package/src/dynamics/init.ts +1 -3
  81. package/src/dynamics/types.ts +2 -2
  82. package/src/dynamics/utils.ts +1 -2
  83. package/src/hooks/use-styles-field.ts +30 -0
  84. package/src/index.ts +2 -3
  85. package/src/sync/should-use-v2-panel.ts +1 -2
  86. package/src/sync/types.ts +3 -3
  87. package/src/components/style-sections/background-section/background-color-control.tsx +0 -20
  88. package/src/components/style-sections/position-section/z-index-control.tsx +0 -20
  89. package/src/components/style-sections/size-section.tsx +0 -49
  90. package/src/components/style-sections/typography-section/font-size-control.tsx +0 -20
  91. package/src/components/style-sections/typography-section/letter-spacing-control.tsx +0 -20
  92. package/src/components/style-sections/typography-section/text-color-control.tsx +0 -20
  93. package/src/components/style-sections/typography-section/word-spacing-control.tsx +0 -20
  94. package/src/controls/control-context.tsx +0 -22
  95. package/src/controls/control-replacement.ts +0 -34
  96. package/src/controls/control-types/color-control.tsx +0 -27
  97. package/src/controls/hooks/use-style-control.ts +0 -29
  98. package/src/controls/hooks/use-widget-settings.ts +0 -16
  99. package/src/controls/props/is-transformable.ts +0 -13
  100. package/src/controls/props/types.ts +0 -51
  101. package/src/controls/settings-control.tsx +0 -37
  102. package/src/controls/style-control.tsx +0 -20
  103. package/src/controls/sync/get-container.ts +0 -8
  104. package/src/controls/sync/update-settings.ts +0 -14
  105. package/src/controls/types.ts +0 -39
  106. package/src/hooks/use-element-style-prop.ts +0 -46
  107. package/src/hooks/use-element-styles.ts +0 -13
  108. package/src/hooks/use-element-type.ts +0 -33
  109. package/src/hooks/use-selected-elements.ts +0 -9
  110. package/src/sync/get-element-styles.ts +0 -9
  111. package/src/sync/get-selected-elements.ts +0 -21
  112. package/src/sync/get-widgets-cache.ts +0 -7
  113. package/src/sync/update-style.ts +0 -25
  114. package/src/{controls → controls-registry}/control.tsx +0 -0
  115. package/src/{controls/control-actions/actions/popover-action.tsx → popover-action.tsx} +1 -1
@@ -0,0 +1,45 @@
1
+ import * as React from 'react';
2
+ import { __ } from '@wordpress/i18n';
3
+ import { Grid } from '@elementor/ui';
4
+ import { EyeIcon, EyeOffIcon, ExpandBottomIcon } from '@elementor/icons';
5
+ import { ToggleButtonGroupItem, ToggleControl } from '../../../controls';
6
+ import { StylesField } from '../../../controls-registry/styles-field';
7
+ import { ControlLabel } from '../../control-label';
8
+
9
+ type Overflows = 'visible' | 'hidden' | 'auto';
10
+
11
+ const options: ToggleButtonGroupItem< Overflows >[] = [
12
+ {
13
+ value: 'visible',
14
+ label: __( 'Visible', 'elementor' ),
15
+ icon: EyeIcon,
16
+ showTooltip: true,
17
+ },
18
+ {
19
+ value: 'hidden',
20
+ label: __( 'Hidden', 'elementor' ),
21
+ icon: EyeOffIcon,
22
+ showTooltip: true,
23
+ },
24
+ {
25
+ value: 'auto',
26
+ label: __( 'Auto', 'elementor' ),
27
+ icon: ExpandBottomIcon,
28
+ showTooltip: true,
29
+ },
30
+ ];
31
+
32
+ export const OverflowField = () => {
33
+ return (
34
+ <StylesField bind={ 'overflow' }>
35
+ <Grid container spacing={ 1 } alignItems="center">
36
+ <Grid item xs={ 6 }>
37
+ <ControlLabel>{ __( 'Overflow', 'elementor' ) }</ControlLabel>
38
+ </Grid>
39
+ <Grid item xs={ 6 } sx={ { display: 'flex', justifyContent: 'flex-end' } }>
40
+ <ToggleControl options={ options } />
41
+ </Grid>
42
+ </Grid>
43
+ </StylesField>
44
+ );
45
+ };
@@ -0,0 +1,55 @@
1
+ import * as React from 'react';
2
+ import { Divider, Grid, Stack } from '@elementor/ui';
3
+ import { __ } from '@wordpress/i18n';
4
+ import { OverflowField } from './overflow-field';
5
+ import { AccordionSection } from '../../accordion-section';
6
+ import { StylesField, StylesFieldProps } from '../../../controls-registry/styles-field';
7
+ import { ControlLabel } from '../../control-label';
8
+ import { SizeControl } from '../../../controls';
9
+
10
+ export const SizeSection = () => {
11
+ return (
12
+ <AccordionSection title={ __( 'Size', 'elementor' ) }>
13
+ <Stack gap={ 1.5 }>
14
+ <Grid container spacing={ 2 }>
15
+ <SizeField bind="width" label={ __( 'Width', 'elementor' ) } />
16
+ <SizeField bind="height" label={ __( 'Height', 'elementor' ) } />
17
+ </Grid>
18
+ <Grid container spacing={ 2 }>
19
+ <SizeField bind="min-width" label={ __( 'Min. Width', 'elementor' ) } />
20
+ <SizeField bind="min-height" label={ __( 'Min. Height', 'elementor' ) } />
21
+ </Grid>
22
+ <Grid container spacing={ 2 }>
23
+ <SizeField bind="max-width" label={ __( 'Max. Width', 'elementor' ) } />
24
+ <SizeField bind="max-height" label={ __( 'Max. Height', 'elementor' ) } />
25
+ </Grid>
26
+ <Divider />
27
+ <Stack>
28
+ <OverflowField />
29
+ </Stack>
30
+ </Stack>
31
+ </AccordionSection>
32
+ );
33
+ };
34
+
35
+ type ControlProps = {
36
+ bind: StylesFieldProps[ 'bind' ];
37
+ label: string;
38
+ };
39
+
40
+ const SizeField = ( { label, bind }: ControlProps ) => {
41
+ return (
42
+ <Grid item xs={ 6 }>
43
+ <StylesField bind={ bind }>
44
+ <Grid container spacing={ 1 } alignItems="center">
45
+ <Grid item xs={ 12 }>
46
+ <ControlLabel>{ label }</ControlLabel>
47
+ </Grid>
48
+ <Grid item xs={ 12 }>
49
+ <SizeControl />
50
+ </Grid>
51
+ </Grid>
52
+ </StylesField>
53
+ </Grid>
54
+ );
55
+ };
@@ -2,20 +2,20 @@ import * as React from 'react';
2
2
  import { AccordionSection } from '../../accordion-section';
3
3
  import { Divider, Stack } from '@elementor/ui';
4
4
  import { __ } from '@wordpress/i18n';
5
- import { LinkedDimensionsControl } from './linked-dimensions-control';
6
- import { StyleControl } from '../../../controls/style-control';
5
+ import { StylesField } from '../../../controls-registry/styles-field';
6
+ import { LinkedDimensionsControl } from '../../../controls/controls/linked-dimensions-control';
7
7
 
8
8
  export const SpacingSection = () => {
9
9
  return (
10
10
  <AccordionSection title={ __( 'Spacing', 'elementor' ) }>
11
11
  <Stack gap={ 1.5 }>
12
- <StyleControl bind={ 'padding' }>
12
+ <StylesField bind={ 'padding' }>
13
13
  <LinkedDimensionsControl label={ __( 'Padding', 'elementor' ) } />
14
- </StyleControl>
14
+ </StylesField>
15
15
  <Divider />
16
- <StyleControl bind={ 'margin' }>
16
+ <StylesField bind={ 'margin' }>
17
17
  <LinkedDimensionsControl label={ __( 'Margin', 'elementor' ) } />
18
- </StyleControl>
18
+ </StylesField>
19
19
  </Stack>
20
20
  </AccordionSection>
21
21
  );
@@ -0,0 +1,21 @@
1
+ import * as React from 'react';
2
+ import { __ } from '@wordpress/i18n';
3
+ import { Grid } from '@elementor/ui';
4
+ import { StylesField } from '../../../controls-registry/styles-field';
5
+ import { SizeControl } from '../../../controls';
6
+ import { ControlLabel } from '../../control-label';
7
+
8
+ export const FontSizeField = () => {
9
+ return (
10
+ <StylesField bind="font-size">
11
+ <Grid container spacing={ 1 } alignItems="center">
12
+ <Grid item xs={ 6 }>
13
+ <ControlLabel>{ __( 'Font Size', 'elementor' ) }</ControlLabel>
14
+ </Grid>
15
+ <Grid item xs={ 6 }>
16
+ <SizeControl />
17
+ </Grid>
18
+ </Grid>
19
+ </StylesField>
20
+ );
21
+ };
@@ -1,8 +1,9 @@
1
1
  import * as React from 'react';
2
2
  import { __ } from '@wordpress/i18n';
3
3
  import { Grid } from '@elementor/ui';
4
- import { StyleControl } from '../../../controls/style-control';
5
- import { SelectControl } from '../../../controls/control-types/select-control';
4
+ import { StylesField } from '../../../controls-registry/styles-field';
5
+ import { SelectControl } from '../../../controls';
6
+ import { ControlLabel } from '../../control-label';
6
7
 
7
8
  const fontWeightOptions = [
8
9
  { label: __( 'Light - 400', 'elementor' ), value: '400' },
@@ -12,17 +13,17 @@ const fontWeightOptions = [
12
13
  { label: __( 'Black - 900', 'elementor' ), value: '900' },
13
14
  ];
14
15
 
15
- export const FontWeightControl = () => {
16
+ export const FontWeightField = () => {
16
17
  return (
17
- <StyleControl bind="font-weight">
18
+ <StylesField bind="font-weight">
18
19
  <Grid container spacing={ 1 } alignItems="center">
19
20
  <Grid item xs={ 6 }>
20
- <StyleControl.Label>{ __( 'Font Weight', 'elementor' ) }</StyleControl.Label>
21
+ <ControlLabel>{ __( 'Font Weight', 'elementor' ) }</ControlLabel>
21
22
  </Grid>
22
23
  <Grid item xs={ 6 }>
23
24
  <SelectControl options={ fontWeightOptions } />
24
25
  </Grid>
25
26
  </Grid>
26
- </StyleControl>
27
+ </StylesField>
27
28
  );
28
29
  };
@@ -0,0 +1,21 @@
1
+ import * as React from 'react';
2
+ import { __ } from '@wordpress/i18n';
3
+ import { Grid } from '@elementor/ui';
4
+ import { StylesField } from '../../../controls-registry/styles-field';
5
+ import { SizeControl } from '../../../controls';
6
+ import { ControlLabel } from '../../control-label';
7
+
8
+ export const LetterSpacingField = () => {
9
+ return (
10
+ <StylesField bind="letter-spacing">
11
+ <Grid container spacing={ 1 } alignItems="center">
12
+ <Grid item xs={ 6 }>
13
+ <ControlLabel>{ __( 'Letter Spacing', 'elementor' ) }</ControlLabel>
14
+ </Grid>
15
+ <Grid item xs={ 6 }>
16
+ <SizeControl />
17
+ </Grid>
18
+ </Grid>
19
+ </StylesField>
20
+ );
21
+ };
@@ -2,9 +2,9 @@ import * as React from 'react';
2
2
  import { __ } from '@wordpress/i18n';
3
3
  import { Grid } from '@elementor/ui';
4
4
  import { AlignLeftIcon, AlignCenterIcon, AlignRightIcon, AlignJustifiedIcon } from '@elementor/icons';
5
- import { ToggleButtonGroupItem } from '../../../controls/components/control-toggle-button-group';
6
- import { StyleControl } from '../../../controls/style-control';
7
- import { ToggleControl } from '../../../controls/control-types/toggle-control';
5
+ import { StylesField } from '../../../controls-registry/styles-field';
6
+ import { ToggleControl, ToggleButtonGroupItem } from '../../../controls';
7
+ import { ControlLabel } from '../../control-label';
8
8
 
9
9
  type Alignments = 'left' | 'center' | 'right' | 'justify';
10
10
 
@@ -31,17 +31,17 @@ const options: ToggleButtonGroupItem< Alignments >[] = [
31
31
  },
32
32
  ];
33
33
 
34
- export const TextAlignmentControl = () => {
34
+ export const TextAlignmentField = () => {
35
35
  return (
36
- <StyleControl bind={ 'text-align' }>
36
+ <StylesField bind={ 'text-align' }>
37
37
  <Grid container spacing={ 1 } alignItems="center">
38
38
  <Grid item xs={ 6 }>
39
- <StyleControl.Label>{ __( 'Alignment', 'elementor' ) }</StyleControl.Label>
39
+ <ControlLabel>{ __( 'Alignment', 'elementor' ) }</ControlLabel>
40
40
  </Grid>
41
41
  <Grid item xs={ 6 } display="flex" justifyContent="end">
42
42
  <ToggleControl options={ options } />
43
43
  </Grid>
44
44
  </Grid>
45
- </StyleControl>
45
+ </StylesField>
46
46
  );
47
47
  };
@@ -0,0 +1,21 @@
1
+ import * as React from 'react';
2
+ import { __ } from '@wordpress/i18n';
3
+ import { Grid } from '@elementor/ui';
4
+ import { StylesField } from '../../../controls-registry/styles-field';
5
+ import { ColorControl } from '../../../controls';
6
+ import { ControlLabel } from '../../control-label';
7
+
8
+ export const TextColorField = () => {
9
+ return (
10
+ <StylesField bind="color">
11
+ <Grid container spacing={ 1 } alignItems="center">
12
+ <Grid item xs={ 6 }>
13
+ <ControlLabel>{ __( 'Text Color', 'elementor' ) }</ControlLabel>
14
+ </Grid>
15
+ <Grid item xs={ 6 }>
16
+ <ColorControl />
17
+ </Grid>
18
+ </Grid>
19
+ </StylesField>
20
+ );
21
+ };
@@ -2,9 +2,9 @@ import * as React from 'react';
2
2
  import { __ } from '@wordpress/i18n';
3
3
  import { Grid } from '@elementor/ui';
4
4
  import { TextDirectionLtrIcon, TextDirectionRtlIcon } from '@elementor/icons';
5
- import { ToggleButtonGroupItem } from '../../../controls/components/control-toggle-button-group';
6
- import { StyleControl } from '../../../controls/style-control';
7
- import { ToggleControl } from '../../../controls/control-types/toggle-control';
5
+ import { StylesField } from '../../../controls-registry/styles-field';
6
+ import { ToggleControl, ToggleButtonGroupItem } from '../../../controls';
7
+ import { ControlLabel } from '../../control-label';
8
8
 
9
9
  type Direction = 'ltr' | 'rtl';
10
10
 
@@ -21,17 +21,17 @@ const options: ToggleButtonGroupItem< Direction >[] = [
21
21
  },
22
22
  ];
23
23
 
24
- export const TextDirectionControl = () => {
24
+ export const TextDirectionField = () => {
25
25
  return (
26
- <StyleControl bind={ 'direction' }>
26
+ <StylesField bind={ 'direction' }>
27
27
  <Grid container spacing={ 1 } alignItems="center">
28
28
  <Grid item xs={ 6 }>
29
- <StyleControl.Label>{ __( 'Direction', 'elementor' ) }</StyleControl.Label>
29
+ <ControlLabel>{ __( 'Direction', 'elementor' ) }</ControlLabel>
30
30
  </Grid>
31
31
  <Grid item xs={ 6 } display="flex" justifyContent="end">
32
32
  <ToggleControl options={ options } />
33
33
  </Grid>
34
34
  </Grid>
35
- </StyleControl>
35
+ </StylesField>
36
36
  );
37
37
  };
@@ -0,0 +1,16 @@
1
+ import * as React from 'react';
2
+ import { __ } from '@wordpress/i18n';
3
+ import { CollapsibleField } from '../../collapsible-field';
4
+ import { ControlLabel } from '../../control-label';
5
+ import { StylesField } from '../../../controls-registry/styles-field';
6
+ import { StrokeControl } from '../../../controls';
7
+
8
+ export const TextStrokeField = () => {
9
+ return (
10
+ <StylesField bind="-webkit-text-stroke">
11
+ <CollapsibleField label={ <ControlLabel>{ __( 'Text Stroke', 'elementor' ) }</ControlLabel> }>
12
+ <StrokeControl />
13
+ </CollapsibleField>
14
+ </StylesField>
15
+ );
16
+ };
@@ -3,13 +3,13 @@ import { __ } from '@wordpress/i18n';
3
3
  import { Grid, ToggleButton as ToggleButtonBase, ToggleButtonGroup, ToggleButtonProps } from '@elementor/ui';
4
4
  import { ItalicIcon, StrikethroughIcon, UnderlineIcon } from '@elementor/icons';
5
5
  import { ControlLabel } from '../../control-label';
6
- import { useStyleControl } from '../../../controls/hooks/use-style-control';
6
+ import { useStylesField } from '../../../hooks/use-styles-field';
7
7
 
8
8
  const buttonSize = 'tiny';
9
9
 
10
- export const TextStyleControl = () => {
11
- const [ fontStyle, setFontStyle ] = useStyleControl< string | null >( 'font-style' );
12
- const [ textDecoration, setTextDecoration ] = useStyleControl< string | null >( 'text-decoration' );
10
+ export const TextStyleField = () => {
11
+ const [ fontStyle, setFontStyle ] = useStylesField< string | null >( 'font-style' );
12
+ const [ textDecoration, setTextDecoration ] = useStylesField< string | null >( 'text-decoration' );
13
13
 
14
14
  const formats = [ fontStyle, ...( textDecoration || '' ).split( ' ' ) ];
15
15
 
@@ -2,8 +2,9 @@ import * as React from 'react';
2
2
  import { __ } from '@wordpress/i18n';
3
3
  import { Grid } from '@elementor/ui';
4
4
  import { LetterCaseIcon, LetterCaseLowerIcon, LetterCaseUpperIcon } from '@elementor/icons';
5
- import { StyleControl } from '../../../controls/style-control';
6
- import { ToggleControl } from '../../../controls/control-types/toggle-control';
5
+ import { StylesField } from '../../../controls-registry/styles-field';
6
+ import { ToggleControl } from '../../../controls';
7
+ import { ControlLabel } from '../../control-label';
7
8
 
8
9
  const options = [
9
10
  { value: 'capitalize', label: __( 'Capitalize', 'elementor' ), icon: LetterCaseIcon },
@@ -11,15 +12,15 @@ const options = [
11
12
  { value: 'lowercase', label: __( 'Lowercase', 'elementor' ), icon: LetterCaseLowerIcon },
12
13
  ];
13
14
 
14
- export const TransformControl = () => (
15
- <StyleControl bind={ 'text-transform' }>
15
+ export const TransformField = () => (
16
+ <StylesField bind={ 'text-transform' }>
16
17
  <Grid container spacing={ 1 } alignItems="center">
17
18
  <Grid item xs={ 6 }>
18
- <StyleControl.Label>{ __( 'Transform', 'elementor' ) }</StyleControl.Label>
19
+ <ControlLabel>{ __( 'Transform', 'elementor' ) }</ControlLabel>
19
20
  </Grid>
20
21
  <Grid item xs={ 6 } display="flex" justifyContent="end">
21
22
  <ToggleControl options={ options } />
22
23
  </Grid>
23
24
  </Grid>
24
- </StyleControl>
25
+ </StylesField>
25
26
  );
@@ -1,35 +1,37 @@
1
1
  import * as React from 'react';
2
2
  import { AccordionSection } from '../../accordion-section';
3
3
  import { Divider, Stack } from '@elementor/ui';
4
- import { TextStyleControl } from './text-style-control';
4
+ import { TextStyleField } from './text-style-field';
5
5
  import { __ } from '@wordpress/i18n';
6
- import { FontSizeControl } from './font-size-control';
7
- import { FontWeightControl } from './font-weight-control';
8
- import { TextColorControl } from './text-color-control';
9
- import { LetterSpacingControl } from './letter-spacing-control';
10
- import { WordSpacingControl } from './word-spacing-control';
6
+ import { FontSizeField } from './font-size-field';
7
+ import { FontWeightField } from './font-weight-field';
8
+ import { TextColorField } from './text-color-field';
9
+ import { LetterSpacingField } from './letter-spacing-field';
10
+ import { WordSpacingField } from './word-spacing-field';
11
11
  import { CollapsibleContent } from '../../collapsible-content';
12
- import { TransformControl } from './transform-control';
13
- import { TextAlignmentControl } from './text-alignment-control';
14
- import { TextDirectionControl } from './text-direction-control';
12
+ import { TransformField } from './transform-field';
13
+ import { TextAlignmentField } from './text-alignment-field';
14
+ import { TextDirectionField } from './text-direction-field';
15
+ import { TextStrokeField } from './text-stroke-field';
15
16
 
16
17
  export const TypographySection = () => {
17
18
  return (
18
19
  <AccordionSection title={ __( 'Typography', 'elementor' ) }>
19
20
  <Stack gap={ 1.5 }>
20
- <FontWeightControl />
21
- <FontSizeControl />
21
+ <FontWeightField />
22
+ <FontSizeField />
22
23
  <Divider />
23
- <TextColorControl />
24
+ <TextColorField />
24
25
  <CollapsibleContent>
25
26
  <Stack gap={ 1.5 } sx={ { pt: 1.5 } }>
26
- <LetterSpacingControl />
27
- <WordSpacingControl />
27
+ <LetterSpacingField />
28
+ <WordSpacingField />
28
29
  <Divider />
29
- <TextAlignmentControl />
30
- <TextStyleControl />
31
- <TransformControl />
32
- <TextDirectionControl />
30
+ <TextAlignmentField />
31
+ <TextStyleField />
32
+ <TransformField />
33
+ <TextDirectionField />
34
+ <TextStrokeField />
33
35
  </Stack>
34
36
  </CollapsibleContent>
35
37
  </Stack>
@@ -0,0 +1,21 @@
1
+ import * as React from 'react';
2
+ import { __ } from '@wordpress/i18n';
3
+ import { Grid } from '@elementor/ui';
4
+ import { StylesField } from '../../../controls-registry/styles-field';
5
+ import { SizeControl } from '../../../controls';
6
+ import { ControlLabel } from '../../control-label';
7
+
8
+ export const WordSpacingField = () => {
9
+ return (
10
+ <StylesField bind="word-spacing">
11
+ <Grid container spacing={ 1 } alignItems="center">
12
+ <Grid item xs={ 6 }>
13
+ <ControlLabel>{ __( 'Word Spacing', 'elementor' ) }</ControlLabel>
14
+ </Grid>
15
+ <Grid item xs={ 6 }>
16
+ <SizeControl />
17
+ </Grid>
18
+ </Grid>
19
+ </StylesField>
20
+ );
21
+ };
@@ -1,37 +1,61 @@
1
1
  import * as React from 'react';
2
- import { StyleContext } from '../contexts/style-context';
3
- import { useElement } from '../controls/providers/element-provider';
4
- import { useElementStyles } from '../hooks/use-element-styles';
2
+ import { useState } from 'react';
5
3
  import { Stack } from '@elementor/ui';
6
- import { SizeSection } from './style-sections/size-section';
4
+ import { generateId, StyleDefinition } from '@elementor/editor-styles';
5
+ import { useActiveBreakpoint } from '@elementor/editor-responsive';
6
+ import { getElementStyles, getElementSetting } from '@elementor/editor-elements';
7
+ import { StyleProvider } from '../contexts/style-context';
8
+ import { SizeSection } from './style-sections/size-section/size-section';
7
9
  import { TypographySection } from './style-sections/typography-section/typography-section';
8
10
  import { PositionSection } from './style-sections/position-section/position-section';
9
- import { StyleDefinition } from '@elementor/editor-style';
10
11
  import { SpacingSection } from './style-sections/spacing-section/spacing-section';
11
12
  import { EffectsSection } from './style-sections/effects-section/effects-section';
12
13
  import { BackgroundSection } from './style-sections/background-section/background-section';
14
+ import { BorderSection } from './style-sections/border-section/border-section';
15
+ import { useElement } from '../contexts/element-context';
16
+ import { ClassesPropValue, PropKey } from '@elementor/editor-props';
17
+ import { ClassesPropProvider } from '../contexts/classes-prop-context';
13
18
 
14
19
  const CLASSES_PROP_KEY = 'classes';
15
20
 
16
21
  export const StyleTab = () => {
17
- const styleDefinition = useStyleDefinition();
18
- const classesProp = useClassesProp();
22
+ const currentClassesProp = useCurrentClassesProp();
23
+ const [ selectedStyleDefId ] = useSelectedStyleDefId( currentClassesProp );
24
+ const breakpoint = useActiveBreakpoint();
19
25
 
20
26
  return (
21
- <StyleContext selectedStyleDef={ styleDefinition } selectedClassesProp={ classesProp }>
22
- <Stack>
23
- <SizeSection />
24
- <PositionSection />
25
- <TypographySection />
26
- <BackgroundSection />
27
- <SpacingSection />
28
- <EffectsSection />
29
- </Stack>
30
- </StyleContext>
27
+ <ClassesPropProvider prop={ currentClassesProp }>
28
+ <StyleProvider meta={ { breakpoint, state: null } } id={ selectedStyleDefId }>
29
+ <Stack>
30
+ <SpacingSection />
31
+ <SizeSection />
32
+ <PositionSection />
33
+ <TypographySection />
34
+ <BackgroundSection />
35
+ <BorderSection />
36
+ <EffectsSection />
37
+ </Stack>
38
+ </StyleProvider>
39
+ </ClassesPropProvider>
31
40
  );
32
41
  };
33
42
 
34
- function useClassesProp(): string {
43
+ function useSelectedStyleDefId( currentClassesProp: PropKey ) {
44
+ const { element } = useElement();
45
+
46
+ const [ selectedStyleDefId, setSelectedStyleDefId ] = useState< StyleDefinition[ 'id' ] >( () => {
47
+ const styleIds = getElementSetting< ClassesPropValue >( element.id, currentClassesProp )?.value ?? [];
48
+ const stylesDefs = getElementStyles( element.id ) ?? {};
49
+
50
+ return (
51
+ styleIds.find( ( id ) => id in stylesDefs ) ?? generateId( `e-${ element.id }-`, Object.keys( stylesDefs ) )
52
+ );
53
+ } );
54
+
55
+ return [ selectedStyleDefId, setSelectedStyleDefId ] as const;
56
+ }
57
+
58
+ function useCurrentClassesProp(): string {
35
59
  const { elementType } = useElement();
36
60
 
37
61
  const prop = Object.entries( elementType.propsSchema ).find(
@@ -44,10 +68,3 @@ function useClassesProp(): string {
44
68
 
45
69
  return prop[ 0 ];
46
70
  }
47
-
48
- function useStyleDefinition(): StyleDefinition | null {
49
- const { element } = useElement();
50
- const elementStyles = useElementStyles( element.id );
51
-
52
- return Object.values( elementStyles || {} )[ 0 ] ?? null;
53
- }
@@ -0,0 +1,24 @@
1
+ import * as React from 'react';
2
+ import { createContext, PropsWithChildren, useContext } from 'react';
3
+
4
+ type ContextValue = {
5
+ prop: string;
6
+ };
7
+
8
+ const Context = createContext< ContextValue | null >( null );
9
+
10
+ type Props = PropsWithChildren< ContextValue >;
11
+
12
+ export function ClassesPropProvider( { children, prop }: Props ) {
13
+ return <Context.Provider value={ { prop } }>{ children }</Context.Provider>;
14
+ }
15
+
16
+ export function useClassesProp() {
17
+ const context = useContext( Context );
18
+
19
+ if ( ! context ) {
20
+ throw new Error( 'useClassesProp must be used within a ClassesPropProvider' );
21
+ }
22
+
23
+ return context.prop;
24
+ }
@@ -1,6 +1,6 @@
1
1
  import * as React from 'react';
2
- import { createContext, ReactNode, useContext } from 'react';
3
- import { Element, ElementType } from '../types';
2
+ import { createContext, PropsWithChildren, useContext } from 'react';
3
+ import { ElementType, Element } from '@elementor/editor-elements';
4
4
 
5
5
  type ContextValue = {
6
6
  element: Element;
@@ -9,11 +9,7 @@ type ContextValue = {
9
9
 
10
10
  const Context = createContext< ContextValue | null >( null );
11
11
 
12
- type Props = {
13
- element: Element;
14
- children?: ReactNode;
15
- elementType: ElementType;
16
- };
12
+ type Props = PropsWithChildren< ContextValue >;
17
13
 
18
14
  export function ElementProvider( { children, element, elementType }: Props ) {
19
15
  return <Context.Provider value={ { element, elementType } }>{ children }</Context.Provider>;
@@ -1,35 +1,21 @@
1
1
  import * as React from 'react';
2
- import { createContext, ReactNode, useContext } from 'react';
3
- import { useActiveBreakpoint } from '@elementor/editor-responsive';
4
- import { StyleDefinition, StyleVariant } from '@elementor/editor-style';
2
+ import { createContext, PropsWithChildren, useContext } from 'react';
3
+ import { StyleDefinition, StyleVariant } from '@elementor/editor-styles';
5
4
 
6
5
  type ContextValue = {
7
- selectedStyleDef: StyleDefinition | null;
8
- selectedMeta: StyleVariant[ 'meta' ];
9
- selectedClassesProp: string;
6
+ id: StyleDefinition[ 'id' ];
7
+ meta: StyleVariant[ 'meta' ];
10
8
  };
11
9
 
12
10
  const Context = createContext< ContextValue | null >( null );
13
11
 
14
- type Props = {
15
- children: ReactNode;
16
- selectedStyleDef: StyleDefinition | null;
17
- selectedClassesProp: string;
18
- };
19
-
20
- export function StyleContext( { children, selectedStyleDef, selectedClassesProp }: Props ) {
21
- const breakpoint = useActiveBreakpoint();
22
- // TODO: Handle state when we support it.
23
- const selectedMeta = { breakpoint, state: null } as const;
12
+ type Props = PropsWithChildren< ContextValue >;
24
13
 
25
- return (
26
- <Context.Provider value={ { selectedStyleDef, selectedMeta, selectedClassesProp } }>
27
- { children }
28
- </Context.Provider>
29
- );
14
+ export function StyleProvider( { children, id, meta }: Props ) {
15
+ return <Context.Provider value={ { id, meta } }>{ children }</Context.Provider>;
30
16
  }
31
17
 
32
- export function useStyleContext() {
18
+ export function useStyle() {
33
19
  const context = useContext( Context );
34
20
 
35
21
  if ( ! context ) {
@@ -1,3 +1,3 @@
1
- import { createControlReplacement } from './controls/create-control-replacement';
1
+ import { createControlReplacement } from './controls';
2
2
 
3
3
  export const { replaceControl, getControlReplacement } = createControlReplacement();