@elementor/editor-controls 4.4.0-1139 → 4.4.0-1141

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": "4.4.0-1139",
4
+ "version": "4.4.0-1141",
5
5
  "private": false,
6
6
  "author": "Elementor Team",
7
7
  "homepage": "https://elementor.com/",
@@ -40,23 +40,23 @@
40
40
  "dev": "tsup --config=../../tsup.dev.ts"
41
41
  },
42
42
  "dependencies": {
43
- "@elementor/editor-current-user": "4.4.0-1139",
44
- "@elementor/editor-elements": "4.4.0-1139",
45
- "@elementor/editor-props": "4.4.0-1139",
46
- "@elementor/editor-responsive": "4.4.0-1139",
47
- "@elementor/editor-ui": "4.4.0-1139",
48
- "@elementor/editor-v1-adapters": "4.4.0-1139",
49
- "@elementor/env": "4.4.0-1139",
50
- "@elementor/events": "4.4.0-1139",
51
- "@elementor/http-client": "4.4.0-1139",
43
+ "@elementor/editor-current-user": "4.4.0-1141",
44
+ "@elementor/editor-elements": "4.4.0-1141",
45
+ "@elementor/editor-props": "4.4.0-1141",
46
+ "@elementor/editor-responsive": "4.4.0-1141",
47
+ "@elementor/editor-ui": "4.4.0-1141",
48
+ "@elementor/editor-v1-adapters": "4.4.0-1141",
49
+ "@elementor/env": "4.4.0-1141",
50
+ "@elementor/events": "4.4.0-1141",
51
+ "@elementor/http-client": "4.4.0-1141",
52
52
  "@elementor/icons": "~1.78.1",
53
- "@elementor/locations": "4.4.0-1139",
54
- "@elementor/query": "4.4.0-1139",
55
- "@elementor/schema": "4.4.0-1139",
56
- "@elementor/session": "4.4.0-1139",
53
+ "@elementor/locations": "4.4.0-1141",
54
+ "@elementor/query": "4.4.0-1141",
55
+ "@elementor/schema": "4.4.0-1141",
56
+ "@elementor/session": "4.4.0-1141",
57
57
  "@elementor/ui": "1.41.3",
58
- "@elementor/utils": "4.4.0-1139",
59
- "@elementor/wp-media": "4.4.0-1139",
58
+ "@elementor/utils": "4.4.0-1141",
59
+ "@elementor/wp-media": "4.4.0-1141",
60
60
  "@monaco-editor/react": "^4.7.0",
61
61
  "@tanstack/react-virtual": "^3.13.3",
62
62
  "@tiptap/extension-bold": "^3.11.1",
@@ -25,6 +25,7 @@ import { FontAwesomeGlyph } from './font-awesome-glyph';
25
25
  import { IconLibraryFilter } from './icon-library-filter';
26
26
  import { IconLibraryGrid } from './icon-library-grid';
27
27
  import { useIconLibraryProviderIcons } from './icon-library-providers';
28
+ import { IconLibraryUploadAction, IconLibraryUploadActionSlot } from './icon-library-upload-action';
28
29
  import { type IconLibraryView, IconLibraryViewToggle } from './icon-library-view-toggle';
29
30
  import { SvgElementIcon } from './svg-element-icon';
30
31
  import { useFontAwesome7Catalog } from './use-font-awesome-7-catalog';
@@ -127,7 +128,12 @@ export const IconLibraryPopover = ( {
127
128
  title={ __( 'Icon library', 'elementor' ) }
128
129
  onClose={ handleClose }
129
130
  icon={ <LibraryIcon fontSize="tiny" /> }
130
- actions={ [ <IconLibraryViewToggle key="view" value={ view } onChange={ setStoredView } /> ] }
131
+ actions={ [
132
+ <IconLibraryViewToggle key="view" value={ view } onChange={ setStoredView } />,
133
+ <IconLibraryUploadActionSlot key="upload">
134
+ <IconLibraryUploadAction />
135
+ </IconLibraryUploadActionSlot>,
136
+ ] }
131
137
  sx={ {
132
138
  pl: ICON_LIBRARY_INLINE_SPACING,
133
139
  pr: 1,
@@ -0,0 +1,108 @@
1
+ import * as React from 'react';
2
+ import { forwardRef, type MouseEvent, useRef, useState } from 'react';
3
+ import { PromotionPopover, useCanvasClickHandler } from '@elementor/editor-ui';
4
+ import { UploadIcon } from '@elementor/icons';
5
+ import { createReplaceableLocation } from '@elementor/locations';
6
+ import { Box, IconButton, Tooltip } from '@elementor/ui';
7
+ import { __ } from '@wordpress/i18n';
8
+
9
+ import { trackUpgradePromotionClick, trackViewPromotion } from '../../utils/tracking';
10
+
11
+ export const ICON_LIBRARY_UPLOAD_UPGRADE_URL = 'https://go.elementor.com/go-pro-svg-library-upload-upgrade/';
12
+
13
+ const TRACKING_DATA = { target_name: 'icon_library_upload', location_l2: 'general' } as const;
14
+
15
+ export const { Slot: IconLibraryUploadActionSlot, inject: injectIntoIconLibraryUploadAction } =
16
+ createReplaceableLocation();
17
+
18
+ type IconLibraryUploadButtonProps = {
19
+ onClick: () => void;
20
+ 'aria-haspopup'?: 'dialog';
21
+ 'aria-expanded'?: boolean;
22
+ };
23
+
24
+ export const IconLibraryUploadButton = forwardRef< HTMLButtonElement, IconLibraryUploadButtonProps >(
25
+ ( props, ref ) => {
26
+ const label = __( 'Upload library', 'elementor' );
27
+
28
+ return (
29
+ <Tooltip title={ label } placement="top">
30
+ <IconButton ref={ ref } size="tiny" aria-label={ label } { ...props }>
31
+ <UploadIcon fontSize="tiny" />
32
+ </IconButton>
33
+ </Tooltip>
34
+ );
35
+ }
36
+ );
37
+
38
+ type IconLibraryUploadPromotionProps = {
39
+ ctaUrl?: string;
40
+ ctaText?: string;
41
+ title?: string;
42
+ content?: string;
43
+ };
44
+
45
+ export const IconLibraryUploadPromotion = ( {
46
+ ctaUrl = ICON_LIBRARY_UPLOAD_UPGRADE_URL,
47
+ ctaText = __( 'Upgrade now', 'elementor' ),
48
+ title = __( 'Upload custom icons', 'elementor' ),
49
+ content = __( 'Add your own icon font library to use across your site.', 'elementor' ),
50
+ }: IconLibraryUploadPromotionProps ) => {
51
+ const [ isOpen, setIsOpen ] = useState( false );
52
+ const triggerRef = useRef< HTMLButtonElement >( null );
53
+
54
+ const canSeePromotions = !! window.elementor?.config?.v4Promotions;
55
+
56
+ const close = () => {
57
+ setIsOpen( false );
58
+ triggerRef.current?.focus();
59
+ };
60
+
61
+ useCanvasClickHandler( isOpen, close );
62
+
63
+ const toggle = () => {
64
+ if ( ! isOpen ) {
65
+ trackViewPromotion( TRACKING_DATA );
66
+ }
67
+
68
+ setIsOpen( ! isOpen );
69
+ };
70
+
71
+ if ( ! canSeePromotions ) {
72
+ return null;
73
+ }
74
+
75
+ return (
76
+ <PromotionPopover
77
+ open={ isOpen }
78
+ placement="top"
79
+ arrow
80
+ title={ title }
81
+ content={ content }
82
+ ctaText={ ctaText }
83
+ ctaUrl={ ctaUrl }
84
+ onClose={ ( event: MouseEvent ) => {
85
+ event.stopPropagation();
86
+ close();
87
+ } }
88
+ onCtaClick={ () => trackUpgradePromotionClick( TRACKING_DATA ) }
89
+ >
90
+ <Box component="span" sx={ { display: 'inline-flex' } }>
91
+ <IconLibraryUploadButton
92
+ ref={ triggerRef }
93
+ aria-haspopup="dialog"
94
+ aria-expanded={ isOpen }
95
+ onClick={ toggle }
96
+ />
97
+ </Box>
98
+ </PromotionPopover>
99
+ );
100
+ };
101
+
102
+ export const IconLibraryUploadAction = () => {
103
+ if ( window.elementorPro ) {
104
+ return null;
105
+ }
106
+
107
+ return <IconLibraryUploadPromotion />;
108
+ };
package/src/index.ts CHANGED
@@ -44,6 +44,11 @@ export {
44
44
  type IconLibraryProvider,
45
45
  } from './controls/icon-library/icon-library-providers';
46
46
  export { enqueueIconFonts } from './controls/open-icon-library';
47
+ export {
48
+ IconLibraryUploadButton,
49
+ IconLibraryUploadPromotion,
50
+ injectIntoIconLibraryUploadAction,
51
+ } from './controls/icon-library/icon-library-upload-action';
47
52
  export { type FontAwesome7Icon } from './controls/icon-library/font-awesome-7-catalog';
48
53
  export {
49
54
  getFontAwesome7IconName,