@elementor/editor-controls 3.35.0 → 3.35.2

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.
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@elementor/editor-controls",
3
3
  "description": "This package contains the controls model and utils for the Elementor editor",
4
- "version": "3.35.0",
4
+ "version": "3.35.2",
5
5
  "private": false,
6
6
  "author": "Elementor Team",
7
7
  "homepage": "https://elementor.com/",
@@ -40,22 +40,22 @@
40
40
  "dev": "tsup --config=../../tsup.dev.ts"
41
41
  },
42
42
  "dependencies": {
43
- "@elementor/editor-current-user": "3.35.0",
44
- "@elementor/editor-elements": "3.35.0",
45
- "@elementor/editor-props": "3.35.0",
46
- "@elementor/editor-responsive": "3.35.0",
47
- "@elementor/editor-ui": "3.35.0",
48
- "@elementor/editor-v1-adapters": "3.35.0",
49
- "@elementor/env": "3.35.0",
50
- "@elementor/http-client": "3.35.0",
43
+ "@elementor/editor-current-user": "3.35.2",
44
+ "@elementor/editor-elements": "3.35.2",
45
+ "@elementor/editor-props": "3.35.2",
46
+ "@elementor/editor-responsive": "3.35.2",
47
+ "@elementor/editor-ui": "3.35.2",
48
+ "@elementor/editor-v1-adapters": "3.35.2",
49
+ "@elementor/env": "3.35.2",
50
+ "@elementor/http-client": "3.35.2",
51
51
  "@elementor/icons": "^1.63.0",
52
- "@elementor/locations": "3.35.0",
53
- "@elementor/mixpanel": "3.35.0",
54
- "@elementor/query": "3.35.0",
55
- "@elementor/session": "3.35.0",
52
+ "@elementor/locations": "3.35.2",
53
+ "@elementor/events": "3.35.2",
54
+ "@elementor/query": "3.35.2",
55
+ "@elementor/session": "3.35.2",
56
56
  "@elementor/ui": "1.36.17",
57
- "@elementor/utils": "3.35.0",
58
- "@elementor/wp-media": "3.35.0",
57
+ "@elementor/utils": "3.35.2",
58
+ "@elementor/wp-media": "3.35.2",
59
59
  "@wordpress/i18n": "^5.13.0",
60
60
  "@monaco-editor/react": "^4.7.0",
61
61
  "dayjs": "^1.11.18",
@@ -0,0 +1,36 @@
1
+ import * as React from 'react';
2
+ import { useRef } from 'react';
3
+ import { PlusIcon } from '@elementor/icons';
4
+ import { Stack, Tooltip } from '@elementor/ui';
5
+ import { __ } from '@wordpress/i18n';
6
+
7
+ import { createControl } from '../../create-control';
8
+ import { PromotionTrigger, type PromotionTriggerRef } from './promotion-trigger';
9
+
10
+ const ARIA_LABEL = __( 'Attributes', 'elementor' );
11
+
12
+ export const AttributesControl = createControl( () => {
13
+ const triggerRef = useRef< PromotionTriggerRef >( null );
14
+
15
+ return (
16
+ <Stack
17
+ direction="row"
18
+ spacing={ 2 }
19
+ sx={ {
20
+ justifyContent: 'flex-end',
21
+ alignItems: 'center',
22
+ } }
23
+ >
24
+ <PromotionTrigger ref={ triggerRef } promotionKey="attributes" />
25
+ <Tooltip title={ ARIA_LABEL } placement="top">
26
+ <PlusIcon
27
+ aria-label={ ARIA_LABEL }
28
+ fontSize="tiny"
29
+ color="disabled"
30
+ onClick={ () => triggerRef.current?.toggle() }
31
+ sx={ { cursor: 'pointer' } }
32
+ />
33
+ </Tooltip>
34
+ </Stack>
35
+ );
36
+ } );
@@ -1,21 +1,16 @@
1
1
  import * as React from 'react';
2
- import { useState } from 'react';
3
- import { PromotionChip, PromotionInfotip } from '@elementor/editor-ui';
2
+ import { useRef } from 'react';
4
3
  import { SitemapIcon } from '@elementor/icons';
5
- import { Box, IconButton, Stack, Tooltip } from '@elementor/ui';
4
+ import { IconButton, Stack, Tooltip } from '@elementor/ui';
6
5
  import { __ } from '@wordpress/i18n';
7
6
 
8
7
  import { createControl } from '../../create-control';
8
+ import { PromotionTrigger, type PromotionTriggerRef } from './promotion-trigger';
9
9
 
10
10
  const ARIA_LABEL = __( 'Display Conditions', 'elementor' );
11
11
 
12
- function getDisplayConditionPromotion() {
13
- return window.elementor?.config?.v4Promotions?.displayConditions;
14
- }
15
-
16
12
  export const DisplayConditionsControl = createControl( () => {
17
- const [ isInfotipOpen, setIsInfotipOpen ] = useState( false );
18
- const promotion = getDisplayConditionPromotion();
13
+ const triggerRef = useRef< PromotionTriggerRef >( null );
19
14
 
20
15
  return (
21
16
  <Stack
@@ -26,27 +21,13 @@ export const DisplayConditionsControl = createControl( () => {
26
21
  alignItems: 'center',
27
22
  } }
28
23
  >
29
- <PromotionInfotip
30
- title={ promotion?.title ?? '' }
31
- content={ promotion?.content ?? '' }
32
- assetUrl={ promotion?.image ?? '' }
33
- ctaUrl={ promotion?.ctaUrl ?? '' }
34
- open={ isInfotipOpen }
35
- onClose={ () => setIsInfotipOpen( false ) }
36
- >
37
- <Box
38
- onClick={ () => setIsInfotipOpen( ( prev ) => ! prev ) }
39
- sx={ { cursor: 'pointer', display: 'inline-flex' } }
40
- >
41
- <PromotionChip />
42
- </Box>
43
- </PromotionInfotip>
24
+ <PromotionTrigger ref={ triggerRef } promotionKey="displayConditions" />
44
25
  <Tooltip title={ ARIA_LABEL } placement="top">
45
26
  <IconButton
46
27
  size="tiny"
47
28
  aria-label={ ARIA_LABEL }
48
29
  data-behavior="display-conditions"
49
- onClick={ () => setIsInfotipOpen( ( prev ) => ! prev ) }
30
+ onClick={ () => triggerRef.current?.toggle() }
50
31
  sx={ {
51
32
  border: '1px solid',
52
33
  borderColor: 'divider',
@@ -0,0 +1,58 @@
1
+ import * as React from 'react';
2
+ import { forwardRef, type ReactNode, useImperativeHandle, useState } from 'react';
3
+ import { PromotionChip, PromotionInfotip } from '@elementor/editor-ui';
4
+ import { Box } from '@elementor/ui';
5
+
6
+ import type { V4PromotionData, V4PromotionKey } from './types';
7
+
8
+ function getV4Promotion( key: V4PromotionKey ): V4PromotionData | undefined {
9
+ return window.elementor?.config?.v4Promotions?.[ key ];
10
+ }
11
+
12
+ type PromotionTriggerProps = {
13
+ promotionKey: V4PromotionKey;
14
+ children?: ReactNode;
15
+ };
16
+
17
+ export type PromotionTriggerRef = {
18
+ toggle: () => void;
19
+ };
20
+
21
+ export const PromotionTrigger = forwardRef< PromotionTriggerRef, PromotionTriggerProps >(
22
+ ( { promotionKey, children }, ref ) => {
23
+ const [ isOpen, setIsOpen ] = useState( false );
24
+ const promotion = getV4Promotion( promotionKey );
25
+
26
+ const toggle = () => setIsOpen( ( prev ) => ! prev );
27
+
28
+ useImperativeHandle( ref, () => ( { toggle } ), [] );
29
+
30
+ return (
31
+ <>
32
+ { promotion && (
33
+ <PromotionInfotip
34
+ title={ promotion.title }
35
+ content={ promotion.content }
36
+ assetUrl={ promotion.image }
37
+ ctaUrl={ promotion.ctaUrl }
38
+ open={ isOpen }
39
+ onClose={ ( e: MouseEvent ) => {
40
+ e.stopPropagation();
41
+ setIsOpen( false );
42
+ } }
43
+ >
44
+ <Box
45
+ onClick={ ( e: MouseEvent ) => {
46
+ e.stopPropagation();
47
+ toggle();
48
+ } }
49
+ sx={ { cursor: 'pointer', display: 'inline-flex' } }
50
+ >
51
+ { children ?? <PromotionChip /> }
52
+ </Box>
53
+ </PromotionInfotip>
54
+ ) }
55
+ </>
56
+ );
57
+ }
58
+ );
@@ -0,0 +1,8 @@
1
+ export type V4PromotionData = {
2
+ title: string;
3
+ content: string;
4
+ image: string;
5
+ ctaUrl: string;
6
+ };
7
+
8
+ export type V4PromotionKey = 'displayConditions' | 'customCss' | 'attributes';
@@ -1,5 +1,5 @@
1
1
  import { getSelectedElements } from '@elementor/editor-elements';
2
- import { trackEvent } from '@elementor/mixpanel';
2
+ import { trackEvent } from '@elementor/events';
3
3
 
4
4
  import { eventBus } from '../../services/event-bus';
5
5
  import { type initialTransitionValue } from './data';
package/src/index.ts CHANGED
@@ -35,10 +35,12 @@ export { enqueueFont } from './controls/font-family-control/enqueue-font';
35
35
  export { transitionProperties, transitionsItemsList } from './controls/transition-control/data';
36
36
  export { DateTimeControl } from './controls/date-time-control';
37
37
  export { InlineEditingControl } from './controls/inline-editing-control';
38
- export { DisplayConditionsControl } from './components/promotions/display-conditions-control';
39
38
 
40
39
  // components
41
40
  export { ControlFormLabel } from './components/control-form-label';
41
+ export { DisplayConditionsControl } from './components/promotions/display-conditions-control';
42
+ export { AttributesControl } from './components/promotions/attributes-control';
43
+ export { PromotionTrigger } from './components/promotions/promotion-trigger';
42
44
  export { ControlToggleButtonGroup } from './components/control-toggle-button-group';
43
45
  export { ToggleButtonGroupUi } from './components/control-toggle-button-group';
44
46
  export { ClearIconButton } from './components/icon-buttons/clear-icon-button';
@@ -65,6 +67,8 @@ export type { ExtendedOption, Unit, LengthUnit, AngleUnit, TimeUnit } from './ut
65
67
  export type { ToggleControlProps } from './controls/toggle-control';
66
68
  export type { FontCategory } from './controls/font-family-control/font-family-control';
67
69
  export type { InlineEditorToolbarProps } from './components/inline-editor-toolbar';
70
+ export type { V4PromotionData, V4PromotionKey } from './components/promotions/types';
71
+ export type { PromotionTriggerRef } from './components/promotions/promotion-trigger';
68
72
 
69
73
  // providers
70
74
  export {