@elementor/editor-editing-panel 1.0.0 → 1.2.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 (120) hide show
  1. package/CHANGELOG.md +70 -0
  2. package/dist/index.d.mts +10 -19
  3. package/dist/index.d.ts +10 -19
  4. package/dist/index.js +1539 -1754
  5. package/dist/index.js.map +1 -1
  6. package/dist/index.mjs +1534 -1723
  7. package/dist/index.mjs.map +1 -1
  8. package/package.json +13 -13
  9. package/src/components/add-or-remove-content.tsx +3 -3
  10. package/src/components/collapse-icon.tsx +12 -0
  11. package/src/components/collapsible-content.tsx +5 -14
  12. package/src/components/collapsible-field.tsx +5 -3
  13. package/src/components/css-class-selector.tsx +131 -0
  14. package/src/components/editing-panel-hooks.tsx +2 -0
  15. package/src/components/editing-panel-tabs.tsx +23 -13
  16. package/src/components/editing-panel.tsx +9 -6
  17. package/src/components/multi-combobox/index.ts +3 -0
  18. package/src/components/multi-combobox/multi-combobox.tsx +122 -0
  19. package/src/components/multi-combobox/types.ts +28 -0
  20. package/src/components/multi-combobox/use-combobox-actions.ts +62 -0
  21. package/src/components/section.tsx +37 -0
  22. package/src/components/sections-list.tsx +6 -0
  23. package/src/components/settings-tab.tsx +11 -11
  24. package/src/components/style-sections/background-section/background-color-field.tsx +4 -4
  25. package/src/components/style-sections/background-section/background-section.tsx +9 -7
  26. package/src/components/style-sections/border-section/border-color-field.tsx +4 -4
  27. package/src/components/style-sections/border-section/border-field.tsx +4 -3
  28. package/src/components/style-sections/border-section/border-radius-field.tsx +4 -3
  29. package/src/components/style-sections/border-section/border-section.tsx +7 -10
  30. package/src/components/style-sections/border-section/border-style-field.tsx +4 -4
  31. package/src/components/style-sections/border-section/border-width-field.tsx +4 -3
  32. package/src/components/style-sections/effects-section/effects-section.tsx +7 -10
  33. package/src/components/style-sections/layout-section/align-items-field.tsx +92 -0
  34. package/src/components/style-sections/layout-section/display-field.tsx +32 -0
  35. package/src/components/style-sections/layout-section/flex-direction-field.tsx +64 -0
  36. package/src/components/style-sections/layout-section/flex-order-field.tsx +114 -0
  37. package/src/components/style-sections/layout-section/justify-content-field.tsx +109 -0
  38. package/src/components/style-sections/layout-section/layout-section.tsx +36 -0
  39. package/src/components/style-sections/layout-section/wrap-field.tsx +52 -0
  40. package/src/components/style-sections/position-section/dimensions-field.tsx +6 -6
  41. package/src/components/style-sections/position-section/position-field.tsx +4 -4
  42. package/src/components/style-sections/position-section/position-section.tsx +45 -15
  43. package/src/components/style-sections/position-section/z-index-field.tsx +4 -4
  44. package/src/components/style-sections/size-section/overflow-field.tsx +8 -8
  45. package/src/components/style-sections/size-section/size-section.tsx +33 -26
  46. package/src/components/style-sections/spacing-section/spacing-section.tsx +11 -13
  47. package/src/components/style-sections/typography-section/font-family-field.tsx +40 -0
  48. package/src/components/style-sections/typography-section/font-size-field.tsx +4 -4
  49. package/src/components/style-sections/typography-section/font-weight-field.tsx +4 -4
  50. package/src/components/style-sections/typography-section/letter-spacing-field.tsx +4 -4
  51. package/src/components/style-sections/typography-section/text-alignment-field.tsx +9 -9
  52. package/src/components/style-sections/typography-section/text-color-field.tsx +4 -4
  53. package/src/components/style-sections/typography-section/text-direction-field.tsx +7 -7
  54. package/src/components/style-sections/typography-section/text-stroke-field.tsx +42 -7
  55. package/src/components/style-sections/typography-section/text-style-field.tsx +5 -4
  56. package/src/components/style-sections/typography-section/transform-field.tsx +23 -9
  57. package/src/components/style-sections/typography-section/typography-section.tsx +26 -27
  58. package/src/components/style-sections/typography-section/word-spacing-field.tsx +4 -4
  59. package/src/components/style-tab.tsx +67 -31
  60. package/src/contexts/classes-prop-context.tsx +1 -1
  61. package/src/contexts/element-context.tsx +2 -2
  62. package/src/contexts/style-context.tsx +6 -5
  63. package/src/control-replacement.tsx +1 -1
  64. package/src/controls-actions.ts +3 -2
  65. package/src/controls-registry/control-type-container.tsx +3 -2
  66. package/src/controls-registry/control.tsx +2 -1
  67. package/src/controls-registry/controls-registry.tsx +8 -1
  68. package/src/controls-registry/settings-field.tsx +5 -4
  69. package/src/controls-registry/styles-field.tsx +3 -2
  70. package/src/dynamics/components/dynamic-selection-control.tsx +15 -14
  71. package/src/dynamics/components/dynamic-selection.tsx +9 -8
  72. package/src/dynamics/dynamic-control.tsx +4 -4
  73. package/src/dynamics/hooks/use-dynamic-tag.ts +3 -2
  74. package/src/dynamics/hooks/use-prop-dynamic-action.tsx +6 -5
  75. package/src/dynamics/hooks/use-prop-dynamic-tags.ts +3 -2
  76. package/src/dynamics/init.ts +5 -3
  77. package/src/dynamics/sync/get-elementor-config.ts +1 -1
  78. package/src/dynamics/types.ts +2 -2
  79. package/src/dynamics/utils.ts +3 -2
  80. package/src/hooks/use-close-editor-panel.ts +23 -0
  81. package/src/hooks/use-direction.ts +13 -0
  82. package/src/hooks/use-open-editor-panel.ts +4 -3
  83. package/src/hooks/use-prop-value-history.ts +45 -0
  84. package/src/hooks/use-style-prop-history.ts +75 -0
  85. package/src/hooks/use-styles-field.ts +25 -4
  86. package/src/index.ts +1 -1
  87. package/src/init.ts +5 -4
  88. package/src/panel.ts +1 -0
  89. package/src/popover-action.tsx +1 -1
  90. package/src/sync/enqueue-font.ts +7 -0
  91. package/src/sync/get-elementor-config.ts +7 -0
  92. package/src/sync/{should-use-v2-panel.ts → is-atomic-widget-selected.ts} +1 -1
  93. package/src/sync/types.ts +20 -21
  94. package/src/components/accordion-section.tsx +0 -26
  95. package/src/components/control-label.tsx +0 -10
  96. package/src/controls/bound-prop-context.tsx +0 -30
  97. package/src/controls/components/control-toggle-button-group.tsx +0 -68
  98. package/src/controls/components/repeater.tsx +0 -197
  99. package/src/controls/components/text-field-inner-selection.tsx +0 -75
  100. package/src/controls/control-actions/control-actions-context.tsx +0 -27
  101. package/src/controls/control-actions/control-actions-menu.ts +0 -7
  102. package/src/controls/control-actions/control-actions.tsx +0 -31
  103. package/src/controls/controls/box-shadow-repeater-control.tsx +0 -210
  104. package/src/controls/controls/color-control.tsx +0 -25
  105. package/src/controls/controls/equal-unequal-sizes-control.tsx +0 -196
  106. package/src/controls/controls/image-control.tsx +0 -58
  107. package/src/controls/controls/image-media-control.tsx +0 -64
  108. package/src/controls/controls/linked-dimensions-control.tsx +0 -139
  109. package/src/controls/controls/number-control.tsx +0 -29
  110. package/src/controls/controls/select-control.tsx +0 -30
  111. package/src/controls/controls/size-control.tsx +0 -71
  112. package/src/controls/controls/stroke-control.tsx +0 -105
  113. package/src/controls/controls/text-area-control.tsx +0 -31
  114. package/src/controls/controls/text-control.tsx +0 -17
  115. package/src/controls/controls/toggle-control.tsx +0 -26
  116. package/src/controls/create-control-replacement.tsx +0 -53
  117. package/src/controls/create-control.tsx +0 -40
  118. package/src/controls/hooks/use-sync-external-state.tsx +0 -51
  119. package/src/controls/index.ts +0 -24
  120. package/src/dynamics/hooks/use-prop-value-history.ts +0 -26
@@ -1,31 +0,0 @@
1
- import * as React from 'react';
2
- import { TextField } from '@elementor/ui';
3
- import { useBoundProp } from '../bound-prop-context';
4
- import ControlActions from '../control-actions/control-actions';
5
- import { createControl } from '../create-control';
6
-
7
- type Props = {
8
- placeholder?: string;
9
- };
10
-
11
- export const TextAreaControl = createControl( ( { placeholder }: Props ) => {
12
- const { value, setValue } = useBoundProp< string >();
13
-
14
- const handleChange = ( event: React.ChangeEvent< HTMLInputElement > ) => {
15
- setValue( event.target.value );
16
- };
17
-
18
- return (
19
- <ControlActions>
20
- <TextField
21
- size="tiny"
22
- multiline
23
- fullWidth
24
- rows={ 5 }
25
- value={ value }
26
- onChange={ handleChange }
27
- placeholder={ placeholder }
28
- />
29
- </ControlActions>
30
- );
31
- } );
@@ -1,17 +0,0 @@
1
- import * as React from 'react';
2
- import { TextField } from '@elementor/ui';
3
- import { useBoundProp } from '../bound-prop-context';
4
- import ControlActions from '../control-actions/control-actions';
5
- import { createControl } from '../create-control';
6
-
7
- export const TextControl = createControl( ( { placeholder }: { placeholder?: string } ) => {
8
- const { value, setValue } = useBoundProp< string >( '' );
9
-
10
- const handleChange = ( event: React.ChangeEvent< HTMLInputElement > ) => setValue( event.target.value );
11
-
12
- return (
13
- <ControlActions>
14
- <TextField type="text" size="tiny" value={ value } onChange={ handleChange } placeholder={ placeholder } />
15
- </ControlActions>
16
- );
17
- } );
@@ -1,26 +0,0 @@
1
- import * as React from 'react';
2
- import { useBoundProp } from '../bound-prop-context';
3
- import { ControlToggleButtonGroup, ToggleButtonGroupItem } from '../components/control-toggle-button-group';
4
- import { PropValue } from '@elementor/editor-props';
5
- import { createControl } from '../create-control';
6
-
7
- type ToggleControlProps< T extends PropValue > = {
8
- options: ToggleButtonGroupItem< T >[];
9
- };
10
-
11
- export const ToggleControl = createControl( < T extends PropValue >( { options }: ToggleControlProps< T > ) => {
12
- const { value, setValue } = useBoundProp< T | null >();
13
-
14
- const handleToggle = ( option: T | null ) => {
15
- setValue( option );
16
- };
17
-
18
- return (
19
- <ControlToggleButtonGroup
20
- items={ options }
21
- value={ value || null }
22
- onChange={ handleToggle }
23
- exclusive={ true }
24
- />
25
- );
26
- } );
@@ -1,53 +0,0 @@
1
- import * as React from 'react';
2
- import { ComponentType, createContext, useContext } from 'react';
3
- import { useBoundProp } from './bound-prop-context';
4
- import { PropValue } from '@elementor/editor-props';
5
-
6
- export type ReplaceWhenParams = {
7
- value: PropValue;
8
- };
9
-
10
- export type CreateControlReplacement = {
11
- component: ComponentType;
12
- condition: ( { value }: ReplaceWhenParams ) => boolean;
13
- };
14
-
15
- const ControlReplacementContext = createContext< CreateControlReplacement | undefined >( undefined );
16
-
17
- export const ControlReplacementProvider = ( {
18
- component,
19
- condition,
20
- children,
21
- }: React.PropsWithChildren< CreateControlReplacement > ) => {
22
- return (
23
- <ControlReplacementContext.Provider value={ { component, condition } }>
24
- { children }
25
- </ControlReplacementContext.Provider>
26
- );
27
- };
28
- export const useControlReplacement = () => {
29
- const { value } = useBoundProp();
30
- const controlReplacement = useContext( ControlReplacementContext );
31
-
32
- let shouldReplace = false;
33
-
34
- try {
35
- shouldReplace = !! controlReplacement?.condition( { value } ) && !! controlReplacement.component;
36
- } catch {}
37
-
38
- return shouldReplace ? controlReplacement?.component : undefined;
39
- };
40
-
41
- export const createControlReplacement = () => {
42
- let controlReplacement: CreateControlReplacement;
43
-
44
- function replaceControl( { component, condition }: CreateControlReplacement ) {
45
- controlReplacement = { component, condition };
46
- }
47
-
48
- function getControlReplacement() {
49
- return controlReplacement;
50
- }
51
-
52
- return { replaceControl, getControlReplacement };
53
- };
@@ -1,40 +0,0 @@
1
- import * as React from 'react';
2
- import { ComponentProps, ComponentType } from 'react';
3
- import { useControlReplacement } from './create-control-replacement';
4
- import { ErrorBoundary } from '@elementor/ui';
5
-
6
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
7
- type AnyComponentType = ComponentType< any >;
8
-
9
- type Options = {
10
- supportsReplacements?: boolean;
11
- };
12
-
13
- const brandSymbol = Symbol( 'control' );
14
-
15
- export type ControlComponent< TComponent extends AnyComponentType = AnyComponentType > = TComponent & {
16
- [ brandSymbol ]: true;
17
- };
18
-
19
- export function createControl< T extends AnyComponentType >(
20
- Component: T,
21
- { supportsReplacements = true }: Options = {}
22
- ) {
23
- return ( ( props: ComponentProps< T > ) => {
24
- const ControlReplacement = useControlReplacement();
25
-
26
- if ( ControlReplacement && supportsReplacements ) {
27
- return (
28
- <ErrorBoundary fallback={ null }>
29
- <ControlReplacement { ...props } />
30
- </ErrorBoundary>
31
- );
32
- }
33
-
34
- return (
35
- <ErrorBoundary fallback={ null }>
36
- <Component { ...props } />
37
- </ErrorBoundary>
38
- );
39
- } ) as ControlComponent< T >;
40
- }
@@ -1,51 +0,0 @@
1
- import { useEffect, useState } from 'react';
2
-
3
- type UseInternalStateOptions< TValue > = {
4
- external: TValue | undefined;
5
- setExternal: ( value: TValue | undefined ) => void;
6
- persistWhen: ( value: TValue | undefined ) => boolean;
7
- fallback: ( value: TValue | undefined ) => TValue;
8
- };
9
-
10
- export const useSyncExternalState = < TValue, >( {
11
- external,
12
- setExternal,
13
- persistWhen,
14
- fallback,
15
- }: UseInternalStateOptions< TValue > ) => {
16
- function toExternal( internalValue: TValue | undefined ) {
17
- if ( persistWhen( internalValue ) ) {
18
- return internalValue;
19
- }
20
-
21
- return undefined;
22
- }
23
-
24
- function toInternal( externalValue: TValue | undefined, internalValue: TValue | undefined ) {
25
- if ( ! externalValue ) {
26
- return fallback( internalValue );
27
- }
28
-
29
- return externalValue;
30
- }
31
-
32
- const [ internal, setInternal ] = useState< TValue >( toInternal( external, undefined ) );
33
-
34
- useEffect( () => {
35
- setInternal( ( prevInternal ) => toInternal( external, prevInternal ) );
36
-
37
- // eslint-disable-next-line react-hooks/exhaustive-deps
38
- }, [ external ] );
39
-
40
- type SetterFunc = ( value: TValue ) => TValue;
41
-
42
- const setInternalValue = ( setter: SetterFunc | TValue ) => {
43
- const setterFn = ( typeof setter === 'function' ? setter : () => setter ) as SetterFunc;
44
- const updated = setterFn( internal );
45
-
46
- setInternal( updated );
47
- setExternal( toExternal( updated ) );
48
- };
49
-
50
- return [ internal, setInternalValue ] as const;
51
- };
@@ -1,24 +0,0 @@
1
- // control types
2
- export { ImageControl } from './controls/image-control';
3
- export { TextControl } from './controls/text-control';
4
- export { TextAreaControl } from './controls/text-area-control';
5
- export { SizeControl } from './controls/size-control';
6
- export { StrokeControl } from './controls/stroke-control';
7
- export { BoxShadowRepeaterControl } from './controls/box-shadow-repeater-control';
8
- export { SelectControl } from './controls/select-control';
9
- export { ColorControl } from './controls/color-control';
10
- export { ToggleControl } from './controls/toggle-control';
11
- export { NumberControl } from './controls/number-control';
12
-
13
- // types
14
- export type { ControlComponent } from './create-control';
15
- export type { ToggleButtonGroupItem } from './components/control-toggle-button-group';
16
- export type { SizeControlValue } from './controls/size-control';
17
-
18
- // Providers
19
- export { ControlActionsProvider } from './control-actions/control-actions-context';
20
- export { createControlReplacement, ControlReplacementProvider } from './create-control-replacement';
21
- export { useBoundProp, BoundPropProvider } from './bound-prop-context';
22
-
23
- // utils
24
- export { createControlActionsMenu } from './control-actions/control-actions-menu';
@@ -1,26 +0,0 @@
1
- import { PropValue } from '@elementor/editor-props';
2
- import { useElement } from '../../contexts/element-context';
3
-
4
- export const PROPS_VALUES_HISTORY_KEY = 'elementor/dynamic/non-dynamic-values-history';
5
-
6
- export const usePropValueHistory = ( path: string ) => {
7
- const valuesHistory = getValues();
8
- const { element } = useElement();
9
- const key = `${ element.id }-${ path }`;
10
-
11
- const value = valuesHistory[ key ] ?? null;
12
-
13
- const setValue = ( newValue: PropValue ) => {
14
- setValues( { ...valuesHistory, [ key ]: newValue } );
15
- };
16
-
17
- return [ value, setValue ] as const;
18
- };
19
-
20
- const getValues = () => {
21
- return JSON.parse( sessionStorage.getItem( PROPS_VALUES_HISTORY_KEY ) || '{}' );
22
- };
23
-
24
- const setValues = ( values: Record< string, PropValue > ) => {
25
- sessionStorage.setItem( PROPS_VALUES_HISTORY_KEY, JSON.stringify( values ) );
26
- };