@elementor/editor-controls 4.4.0-1120 → 4.4.0-1122
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/dist/index.js +640 -641
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +476 -479
- package/dist/index.mjs.map +1 -1
- package/package.json +16 -16
- package/src/controls/icon-library/icon-library-filter.tsx +19 -10
- package/src/controls/icon-library/icon-library-grid.tsx +14 -8
- package/src/controls/icon-library/icon-library-popover.tsx +24 -10
- package/src/controls/icon-library/icon-library-view-toggle.tsx +22 -82
- package/src/controls/icon-library/svg-element-icon.tsx +15 -0
- package/src/controls/svg-media-overlay.tsx +18 -11
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-
|
|
4
|
+
"version": "4.4.0-1122",
|
|
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-
|
|
44
|
-
"@elementor/editor-elements": "4.4.0-
|
|
45
|
-
"@elementor/editor-props": "4.4.0-
|
|
46
|
-
"@elementor/editor-responsive": "4.4.0-
|
|
47
|
-
"@elementor/editor-ui": "4.4.0-
|
|
48
|
-
"@elementor/editor-v1-adapters": "4.4.0-
|
|
49
|
-
"@elementor/env": "4.4.0-
|
|
50
|
-
"@elementor/events": "4.4.0-
|
|
51
|
-
"@elementor/http-client": "4.4.0-
|
|
43
|
+
"@elementor/editor-current-user": "4.4.0-1122",
|
|
44
|
+
"@elementor/editor-elements": "4.4.0-1122",
|
|
45
|
+
"@elementor/editor-props": "4.4.0-1122",
|
|
46
|
+
"@elementor/editor-responsive": "4.4.0-1122",
|
|
47
|
+
"@elementor/editor-ui": "4.4.0-1122",
|
|
48
|
+
"@elementor/editor-v1-adapters": "4.4.0-1122",
|
|
49
|
+
"@elementor/env": "4.4.0-1122",
|
|
50
|
+
"@elementor/events": "4.4.0-1122",
|
|
51
|
+
"@elementor/http-client": "4.4.0-1122",
|
|
52
52
|
"@elementor/icons": "~1.75.1",
|
|
53
|
-
"@elementor/locations": "4.4.0-
|
|
54
|
-
"@elementor/query": "4.4.0-
|
|
55
|
-
"@elementor/schema": "4.4.0-
|
|
56
|
-
"@elementor/session": "4.4.0-
|
|
53
|
+
"@elementor/locations": "4.4.0-1122",
|
|
54
|
+
"@elementor/query": "4.4.0-1122",
|
|
55
|
+
"@elementor/schema": "4.4.0-1122",
|
|
56
|
+
"@elementor/session": "4.4.0-1122",
|
|
57
57
|
"@elementor/ui": "1.37.5",
|
|
58
|
-
"@elementor/utils": "4.4.0-
|
|
59
|
-
"@elementor/wp-media": "4.4.0-
|
|
58
|
+
"@elementor/utils": "4.4.0-1122",
|
|
59
|
+
"@elementor/wp-media": "4.4.0-1122",
|
|
60
60
|
"@monaco-editor/react": "^4.7.0",
|
|
61
61
|
"@tanstack/react-virtual": "^3.13.3",
|
|
62
62
|
"@tiptap/extension-bold": "^3.11.1",
|
|
@@ -1,6 +1,14 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { useId } from 'react';
|
|
3
|
-
import {
|
|
3
|
+
import {
|
|
4
|
+
CheckIcon,
|
|
5
|
+
FilterIcon,
|
|
6
|
+
LibraryIcon,
|
|
7
|
+
MenuIcon,
|
|
8
|
+
RosetteDiscountCheckIcon,
|
|
9
|
+
StarFilledIcon,
|
|
10
|
+
StarIcon,
|
|
11
|
+
} from '@elementor/icons';
|
|
4
12
|
import {
|
|
5
13
|
bindMenu,
|
|
6
14
|
bindToggle,
|
|
@@ -22,23 +30,24 @@ import { ICON_LIBRARY_ACTION_TOOLTIP_ENTER_DELAY } from './icon-library-tooltip'
|
|
|
22
30
|
|
|
23
31
|
const FILTER_MENU_WIDTH = 280;
|
|
24
32
|
const FILTER_INDICATOR_SIZE = 6;
|
|
25
|
-
const
|
|
33
|
+
const FILTER_INDICATOR_CORNER_OFFSET = -( FILTER_INDICATOR_SIZE / 2 );
|
|
26
34
|
const FILTER_TYPE_ALL = 'all';
|
|
27
35
|
const FILTER_TYPE_GROUP = 'group';
|
|
28
36
|
const FILTER_TYPE_ITEM = 'item';
|
|
29
37
|
|
|
30
|
-
const FILTER_ICONS: Record< string, typeof
|
|
31
|
-
list:
|
|
38
|
+
const FILTER_ICONS: Record< string, typeof MenuIcon > = {
|
|
39
|
+
list: MenuIcon,
|
|
32
40
|
star: StarIcon,
|
|
33
41
|
'star-filled': StarFilledIcon,
|
|
34
42
|
library: LibraryIcon,
|
|
43
|
+
rosette: RosetteDiscountCheckIcon,
|
|
35
44
|
};
|
|
36
45
|
|
|
37
46
|
const DEFAULT_FILTER = [
|
|
38
47
|
{ type: FILTER_TYPE_ALL, label: 'All icons', icon: 'list' },
|
|
39
48
|
{ type: FILTER_TYPE_ITEM, value: 'fa-regular', label: 'Font Awesome - Regular', icon: 'star' },
|
|
40
49
|
{ type: FILTER_TYPE_ITEM, value: 'fa-solid', label: 'Font Awesome - Solid', icon: 'star-filled' },
|
|
41
|
-
{ type: FILTER_TYPE_ITEM, value: 'fa-brands', label: 'Font Awesome - Brands', icon: '
|
|
50
|
+
{ type: FILTER_TYPE_ITEM, value: 'fa-brands', label: 'Font Awesome - Brands', icon: 'rosette' },
|
|
42
51
|
] as const;
|
|
43
52
|
|
|
44
53
|
type FilterEntry =
|
|
@@ -86,7 +95,7 @@ export const IconLibraryFilter = ( { value, onChange }: IconLibraryFilterProps )
|
|
|
86
95
|
value="filter"
|
|
87
96
|
size="tiny"
|
|
88
97
|
selected={ popupState.isOpen }
|
|
89
|
-
sx={ { position: 'relative', flexShrink: 0 } }
|
|
98
|
+
sx={ { position: 'relative', flexShrink: 0, overflow: 'visible' } }
|
|
90
99
|
{ ...bindToggle( popupState ) }
|
|
91
100
|
aria-expanded={ popupState.isOpen }
|
|
92
101
|
>
|
|
@@ -97,12 +106,12 @@ export const IconLibraryFilter = ( { value, onChange }: IconLibraryFilterProps )
|
|
|
97
106
|
aria-hidden="true"
|
|
98
107
|
sx={ {
|
|
99
108
|
position: 'absolute',
|
|
100
|
-
insetBlockStart:
|
|
101
|
-
insetInlineEnd:
|
|
109
|
+
insetBlockStart: FILTER_INDICATOR_CORNER_OFFSET,
|
|
110
|
+
insetInlineEnd: FILTER_INDICATOR_CORNER_OFFSET,
|
|
102
111
|
width: FILTER_INDICATOR_SIZE,
|
|
103
112
|
height: FILTER_INDICATOR_SIZE,
|
|
104
113
|
borderRadius: '50%',
|
|
105
|
-
bgcolor: '
|
|
114
|
+
bgcolor: 'text.primary',
|
|
106
115
|
} }
|
|
107
116
|
/>
|
|
108
117
|
) : null }
|
|
@@ -173,7 +182,7 @@ const renderFilterEntry = (
|
|
|
173
182
|
|
|
174
183
|
const getFilterIcon = ( icon?: string ) => FILTER_ICONS[ icon ?? '' ] ?? LibraryIcon;
|
|
175
184
|
|
|
176
|
-
const renderFilterMenuItemContent = ( label: string, Icon: typeof
|
|
185
|
+
const renderFilterMenuItemContent = ( label: string, Icon: typeof MenuIcon, selected: boolean ) => (
|
|
177
186
|
<Stack direction="row" alignItems="center" gap={ 1 } width="100%">
|
|
178
187
|
<Icon fontSize="tiny" />
|
|
179
188
|
<Typography variant="caption" sx={ { flex: 1 } }>
|
|
@@ -13,8 +13,9 @@ export const ICON_LIBRARY_GRID_TOOLTIP_ENTER_DELAY = 1000;
|
|
|
13
13
|
|
|
14
14
|
const ICON_GLYPH_SIZE = 20;
|
|
15
15
|
const GRID_OVERSCAN = 6;
|
|
16
|
-
const
|
|
17
|
-
const GRID_HORIZONTAL_PADDING =
|
|
16
|
+
const GRID_CELL_GAP = 1;
|
|
17
|
+
const GRID_HORIZONTAL_PADDING = 2;
|
|
18
|
+
const GRID_VERTICAL_PADDING = 1.5;
|
|
18
19
|
const HOME_END_KEYS = new Set( [ 'Home', 'End' ] );
|
|
19
20
|
|
|
20
21
|
const getGridMetrics = ( containerWidth: number, columnGap: number, inlinePadding: number ) => {
|
|
@@ -67,10 +68,15 @@ export const IconLibraryGrid = ( {
|
|
|
67
68
|
const [ focusedIndex, setFocusedIndex ] = useState( selectedIndex >= 0 ? selectedIndex : 0 );
|
|
68
69
|
const [ { columnCount, cellSize }, setGridMetrics ] = useState( () => getGridMetrics( 0, 0, 0 ) );
|
|
69
70
|
const rowCount = Math.ceil( items.length / columnCount );
|
|
71
|
+
const cellGap = Number.parseFloat( theme.spacing( GRID_CELL_GAP ) );
|
|
72
|
+
const verticalPadding = Number.parseFloat( theme.spacing( GRID_VERTICAL_PADDING ) );
|
|
70
73
|
const virtualizer = useVirtualizer( {
|
|
71
74
|
count: rowCount,
|
|
72
75
|
getScrollElement: () => containerRef.current,
|
|
73
76
|
estimateSize: () => cellSize,
|
|
77
|
+
gap: cellGap,
|
|
78
|
+
paddingStart: verticalPadding,
|
|
79
|
+
paddingEnd: verticalPadding,
|
|
74
80
|
overscan: GRID_OVERSCAN,
|
|
75
81
|
} );
|
|
76
82
|
const focusedItem = items[ focusedIndex ];
|
|
@@ -90,10 +96,11 @@ export const IconLibraryGrid = ( {
|
|
|
90
96
|
} );
|
|
91
97
|
|
|
92
98
|
if ( selectedIndex >= 0 ) {
|
|
93
|
-
virtualizer.
|
|
99
|
+
virtualizer.measure();
|
|
100
|
+
virtualizer.scrollToIndex( Math.floor( selectedIndex / columnCount ), { align: 'center' } );
|
|
94
101
|
}
|
|
95
102
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
96
|
-
}, [ columnCount, items, selectedIndex, selectedValue ] );
|
|
103
|
+
}, [ cellSize, columnCount, items, selectedIndex, selectedValue ] );
|
|
97
104
|
|
|
98
105
|
useLayoutEffect( () => {
|
|
99
106
|
if ( ! shouldRestoreFocusRef.current || ! focusedItem ) {
|
|
@@ -118,9 +125,8 @@ export const IconLibraryGrid = ( {
|
|
|
118
125
|
}
|
|
119
126
|
|
|
120
127
|
const measureGrid = () => {
|
|
121
|
-
const columnGap = Number.parseFloat( theme.spacing( GRID_COLUMN_GAP ) );
|
|
122
128
|
const inlinePadding = Number.parseFloat( theme.spacing( GRID_HORIZONTAL_PADDING ) ) * 2;
|
|
123
|
-
setGridMetrics( getGridMetrics( container.clientWidth,
|
|
129
|
+
setGridMetrics( getGridMetrics( container.clientWidth, cellGap, inlinePadding ) );
|
|
124
130
|
};
|
|
125
131
|
|
|
126
132
|
measureGrid();
|
|
@@ -130,7 +136,7 @@ export const IconLibraryGrid = ( {
|
|
|
130
136
|
return () => {
|
|
131
137
|
resizeObserver.disconnect();
|
|
132
138
|
};
|
|
133
|
-
}, [ theme, items.length ] );
|
|
139
|
+
}, [ theme, cellGap, items.length ] );
|
|
134
140
|
|
|
135
141
|
useLayoutEffect( () => {
|
|
136
142
|
virtualizer.measure();
|
|
@@ -242,7 +248,7 @@ export const IconLibraryGrid = ( {
|
|
|
242
248
|
transform: `translateY(${ virtualRow.start }px)`,
|
|
243
249
|
display: 'grid',
|
|
244
250
|
gridTemplateColumns: `repeat(${ columnCount }, minmax(0, 1fr))`,
|
|
245
|
-
gap:
|
|
251
|
+
gap: GRID_CELL_GAP,
|
|
246
252
|
px: GRID_HORIZONTAL_PADDING,
|
|
247
253
|
boxSizing: 'border-box',
|
|
248
254
|
} }
|
|
@@ -8,7 +8,7 @@ import {
|
|
|
8
8
|
StyledMenuList,
|
|
9
9
|
type VirtualizedItem,
|
|
10
10
|
} from '@elementor/editor-ui';
|
|
11
|
-
import {
|
|
11
|
+
import { LibraryIcon } from '@elementor/icons';
|
|
12
12
|
import { useSessionStorage } from '@elementor/session';
|
|
13
13
|
import { Box, CircularProgress, Divider, Link, Stack, styled, Typography } from '@elementor/ui';
|
|
14
14
|
import { useDebounceState } from '@elementor/utils';
|
|
@@ -26,25 +26,30 @@ import { FontAwesomeGlyph } from './font-awesome-glyph';
|
|
|
26
26
|
import { IconLibraryFilter } from './icon-library-filter';
|
|
27
27
|
import { IconLibraryGrid } from './icon-library-grid';
|
|
28
28
|
import { type IconLibraryView, IconLibraryViewToggle } from './icon-library-view-toggle';
|
|
29
|
+
import { SvgElementIcon } from './svg-element-icon';
|
|
29
30
|
import { useFontAwesome7Catalog } from './use-font-awesome-7-catalog';
|
|
30
31
|
|
|
31
32
|
export const ICON_LIBRARY_POPOVER_WIDTH = 300;
|
|
32
|
-
export const ICON_LIBRARY_ROW_HEIGHT = 48;
|
|
33
33
|
export const ICON_LIBRARY_SEARCH_DEBOUNCE_DELAY = 300;
|
|
34
34
|
export const ICON_LIBRARY_VIEW_STORAGE_KEY = 'icon-library-view';
|
|
35
35
|
export const ICON_LIBRARY_VIEW_STORAGE_PREFIX = 'editor-controls';
|
|
36
|
-
const DEFAULT_ICON_LIBRARY_VIEW: IconLibraryView = '
|
|
36
|
+
const DEFAULT_ICON_LIBRARY_VIEW: IconLibraryView = 'grid';
|
|
37
37
|
|
|
38
38
|
const isIconLibraryView = ( value: unknown ): value is IconLibraryView => {
|
|
39
39
|
return value === 'grid' || value === 'list';
|
|
40
40
|
};
|
|
41
41
|
const ICON_TILE_SIZE = 40;
|
|
42
|
+
const ICON_LIBRARY_ROW_VERTICAL_PADDING = 0.5;
|
|
43
|
+
const ICON_LIBRARY_ROW_VERTICAL_PADDING_PX = 4;
|
|
44
|
+
export const ICON_LIBRARY_ROW_HEIGHT = ICON_TILE_SIZE + ICON_LIBRARY_ROW_VERTICAL_PADDING_PX * 2;
|
|
42
45
|
const ICON_GLYPH_SIZE = 20;
|
|
43
|
-
const ICON_LIBRARY_INLINE_SPACING =
|
|
46
|
+
const ICON_LIBRARY_INLINE_SPACING = 2;
|
|
47
|
+
const ICON_LIBRARY_SEARCH_PADDING_BOTTOM = 2;
|
|
48
|
+
const ICON_LIBRARY_TITLE_SIZE = '14px';
|
|
44
49
|
|
|
45
50
|
const CompactIconLibraryMenuList = styled( StyledMenuList )( ( { theme } ) => ( {
|
|
46
51
|
'& > [role="option"]': {
|
|
47
|
-
padding: theme.spacing(
|
|
52
|
+
padding: theme.spacing( ICON_LIBRARY_ROW_VERTICAL_PADDING, ICON_LIBRARY_INLINE_SPACING ),
|
|
48
53
|
},
|
|
49
54
|
} ) );
|
|
50
55
|
|
|
@@ -121,11 +126,20 @@ export const IconLibraryPopover = ( {
|
|
|
121
126
|
<PopoverHeader
|
|
122
127
|
title={ __( 'Icon library', 'elementor' ) }
|
|
123
128
|
onClose={ handleClose }
|
|
124
|
-
icon={ <
|
|
129
|
+
icon={ <LibraryIcon fontSize="tiny" /> }
|
|
125
130
|
actions={ [ <IconLibraryViewToggle key="view" value={ view } onChange={ setStoredView } /> ] }
|
|
126
|
-
sx={ {
|
|
131
|
+
sx={ {
|
|
132
|
+
pl: ICON_LIBRARY_INLINE_SPACING,
|
|
133
|
+
pr: 1,
|
|
134
|
+
'& .MuiTypography-subtitle2': { fontSize: ICON_LIBRARY_TITLE_SIZE },
|
|
135
|
+
} }
|
|
127
136
|
/>
|
|
128
|
-
<Stack
|
|
137
|
+
<Stack
|
|
138
|
+
direction="row"
|
|
139
|
+
alignItems="center"
|
|
140
|
+
gap={ 1 }
|
|
141
|
+
sx={ { px: ICON_LIBRARY_INLINE_SPACING, pb: ICON_LIBRARY_SEARCH_PADDING_BOTTOM } }
|
|
142
|
+
>
|
|
129
143
|
<SearchField
|
|
130
144
|
value={ searchInputValue }
|
|
131
145
|
onSearch={ handleSearchChange }
|
|
@@ -269,7 +283,7 @@ const IconLibraryRow = ( item: VirtualizedItem< string, string > ) => {
|
|
|
269
283
|
|
|
270
284
|
const CatalogUnavailable = () => (
|
|
271
285
|
<Stack alignItems="center" justifyContent="center" height="100%" p={ 2.5 } gap={ 1.5 }>
|
|
272
|
-
<
|
|
286
|
+
<SvgElementIcon fontSize="large" />
|
|
273
287
|
<Typography align="center" variant="subtitle2" color="text.secondary">
|
|
274
288
|
{ __( "Icons couldn't be loaded.", 'elementor' ) }
|
|
275
289
|
</Typography>
|
|
@@ -278,7 +292,7 @@ const CatalogUnavailable = () => (
|
|
|
278
292
|
|
|
279
293
|
const NoResults = ( { searchValue, onClear }: { searchValue: string; onClear: () => void } ) => (
|
|
280
294
|
<Stack alignItems="center" justifyContent="center" height="100%" p={ 2.5 } gap={ 1.5 }>
|
|
281
|
-
<
|
|
295
|
+
<SvgElementIcon fontSize="large" />
|
|
282
296
|
<Typography align="center" variant="subtitle2" color="text.secondary">
|
|
283
297
|
{ __( 'Sorry, nothing matched', 'elementor' ) }
|
|
284
298
|
</Typography>
|
|
@@ -1,24 +1,13 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
bindMenu,
|
|
6
|
-
bindToggle,
|
|
7
|
-
Menu,
|
|
8
|
-
MenuItem,
|
|
9
|
-
Stack,
|
|
10
|
-
ToggleButton,
|
|
11
|
-
Tooltip,
|
|
12
|
-
Typography,
|
|
13
|
-
usePopupState,
|
|
14
|
-
} from '@elementor/ui';
|
|
2
|
+
import { ListIcon, WidgetsIcon } from '@elementor/icons';
|
|
3
|
+
import { IconButton, Tooltip } from '@elementor/ui';
|
|
15
4
|
import { __ } from '@wordpress/i18n';
|
|
16
5
|
|
|
17
6
|
import { ICON_LIBRARY_ACTION_TOOLTIP_ENTER_DELAY } from './icon-library-tooltip';
|
|
18
7
|
|
|
19
8
|
export type IconLibraryView = 'grid' | 'list';
|
|
20
9
|
|
|
21
|
-
const
|
|
10
|
+
const HEADER_ACTION_GAP = 0.5;
|
|
22
11
|
|
|
23
12
|
type IconLibraryViewToggleProps = {
|
|
24
13
|
value: IconLibraryView;
|
|
@@ -26,79 +15,30 @@ type IconLibraryViewToggleProps = {
|
|
|
26
15
|
};
|
|
27
16
|
|
|
28
17
|
export const IconLibraryViewToggle = ( { value, onChange }: IconLibraryViewToggleProps ) => {
|
|
29
|
-
const popupId = useId();
|
|
30
|
-
const popupState = usePopupState( {
|
|
31
|
-
variant: 'popover',
|
|
32
|
-
popupId,
|
|
33
|
-
} );
|
|
34
18
|
const isGrid = value === 'grid';
|
|
19
|
+
const nextView: IconLibraryView = isGrid ? 'list' : 'grid';
|
|
35
20
|
const ViewIcon = isGrid ? WidgetsIcon : ListIcon;
|
|
36
21
|
const viewButtonLabel = isGrid ? __( 'Grid view', 'elementor' ) : __( 'List view', 'elementor' );
|
|
22
|
+
const viewButtonAction = isGrid
|
|
23
|
+
? __( 'Switch to list view', 'elementor' )
|
|
24
|
+
: __( 'Switch to grid view', 'elementor' );
|
|
37
25
|
|
|
38
26
|
return (
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
27
|
+
<Tooltip
|
|
28
|
+
title={ viewButtonLabel }
|
|
29
|
+
placement="top"
|
|
30
|
+
enterDelay={ ICON_LIBRARY_ACTION_TOOLTIP_ENTER_DELAY }
|
|
31
|
+
enterNextDelay={ ICON_LIBRARY_ACTION_TOOLTIP_ENTER_DELAY }
|
|
32
|
+
disableInteractive
|
|
33
|
+
>
|
|
34
|
+
<IconButton
|
|
35
|
+
aria-label={ viewButtonAction }
|
|
36
|
+
size="tiny"
|
|
37
|
+
onClick={ () => onChange( nextView ) }
|
|
38
|
+
sx={ { flexShrink: 0, mr: HEADER_ACTION_GAP } }
|
|
46
39
|
>
|
|
47
|
-
<
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
size="tiny"
|
|
51
|
-
selected={ popupState.isOpen }
|
|
52
|
-
sx={ { flexShrink: 0 } }
|
|
53
|
-
{ ...bindToggle( popupState ) }
|
|
54
|
-
aria-expanded={ popupState.isOpen }
|
|
55
|
-
>
|
|
56
|
-
<ViewIcon fontSize="tiny" />
|
|
57
|
-
</ToggleButton>
|
|
58
|
-
</Tooltip>
|
|
59
|
-
<Menu
|
|
60
|
-
{ ...bindMenu( popupState ) }
|
|
61
|
-
MenuListProps={ {
|
|
62
|
-
dense: true,
|
|
63
|
-
autoFocusItem: true,
|
|
64
|
-
'aria-label': __( 'View', 'elementor' ),
|
|
65
|
-
} }
|
|
66
|
-
sx={ { '& .MuiPaper-root': { minWidth: VIEW_MENU_WIDTH } } }
|
|
67
|
-
>
|
|
68
|
-
<ViewMenuItem
|
|
69
|
-
label={ __( 'List', 'elementor' ) }
|
|
70
|
-
selected={ value === 'list' }
|
|
71
|
-
onClick={ () => {
|
|
72
|
-
onChange( 'list' );
|
|
73
|
-
popupState.close();
|
|
74
|
-
} }
|
|
75
|
-
/>
|
|
76
|
-
<ViewMenuItem
|
|
77
|
-
label={ __( 'Grid', 'elementor' ) }
|
|
78
|
-
selected={ value === 'grid' }
|
|
79
|
-
onClick={ () => {
|
|
80
|
-
onChange( 'grid' );
|
|
81
|
-
popupState.close();
|
|
82
|
-
} }
|
|
83
|
-
/>
|
|
84
|
-
</Menu>
|
|
85
|
-
</>
|
|
40
|
+
<ViewIcon fontSize="tiny" />
|
|
41
|
+
</IconButton>
|
|
42
|
+
</Tooltip>
|
|
86
43
|
);
|
|
87
44
|
};
|
|
88
|
-
|
|
89
|
-
type ViewMenuItemProps = {
|
|
90
|
-
label: string;
|
|
91
|
-
selected: boolean;
|
|
92
|
-
onClick: () => void;
|
|
93
|
-
};
|
|
94
|
-
|
|
95
|
-
const ViewMenuItem = ( { label, selected, onClick }: ViewMenuItemProps ) => (
|
|
96
|
-
<MenuItem role="menuitemradio" aria-checked={ selected } selected={ selected } onClick={ onClick }>
|
|
97
|
-
<Stack direction="row" alignItems="center" gap={ 1 } width="100%">
|
|
98
|
-
<Typography variant="caption" sx={ { flex: 1 } }>
|
|
99
|
-
{ label }
|
|
100
|
-
</Typography>
|
|
101
|
-
{ selected ? <CheckIcon fontSize="tiny" aria-hidden="true" /> : null }
|
|
102
|
-
</Stack>
|
|
103
|
-
</MenuItem>
|
|
104
|
-
);
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { SvgIcon } from '@elementor/ui';
|
|
3
|
+
|
|
4
|
+
const SVG_ELEMENT_ICON_PATH =
|
|
5
|
+
'M502 772c10 0 19-6 24-14l201-351c4-9 4-19 0-27-5-9-14-14-24-14h-401c-10 0-19 5-24 14-4 8-5 18 0 27l201 351c5 8 14 14 23 14z m0-82l-154-270h309l-154 270z m-323-471c-6 0-12-2-16-7-4-4-7-10-7-16v-201c0-6 3-12 7-16 4-5 10-7 16-7h201c6 0 12 2 16 7 5 4 7 10 7 16v201c0 6-2 12-7 16-4 5-10 7-16 7h-201z m-54 32c14 14 34 22 54 22h201c20 0 40-8 55-22 14-15 22-35 22-55v-201c0-20-8-40-22-54-15-15-35-23-55-23h-201c-20 0-40 8-54 23-15 14-23 34-23 54v201c0 20 8 40 23 55z m480-30c34 33 79 52 126 52s92-19 125-52c34-33 52-78 52-125s-18-93-52-126c-33-33-78-52-125-52s-92 19-126 52c-33 33-52 78-52 126s19 92 52 125z m126-2c-33 0-64-13-87-36-24-23-37-55-37-87s13-65 37-88c23-23 54-36 87-36s64 13 87 36c23 23 36 55 36 88s-13 64-36 87c-23 23-54 36-87 36z';
|
|
6
|
+
|
|
7
|
+
export const SvgElementIcon = React.forwardRef< SVGSVGElement, React.ComponentProps< typeof SvgIcon > >(
|
|
8
|
+
( props, ref ) => (
|
|
9
|
+
<SvgIcon viewBox="0 0 1000 1000" { ...props } ref={ ref }>
|
|
10
|
+
<g transform="translate(0, 850) scale(1, -1)">
|
|
11
|
+
<path d={ SVG_ELEMENT_ICON_PATH } />
|
|
12
|
+
</g>
|
|
13
|
+
</SvgIcon>
|
|
14
|
+
)
|
|
15
|
+
);
|
|
@@ -8,28 +8,35 @@ import { ConditionalControlInfotip } from '../components/conditional-control-inf
|
|
|
8
8
|
export const SVG_MEDIA_CONTROL_CONTAINER_TEST_ID = 'svg-media-control-container';
|
|
9
9
|
export const SVG_MEDIA_ACTION_GROUP_TEST_ID = 'svg-media-action-group';
|
|
10
10
|
|
|
11
|
-
const
|
|
12
|
-
const
|
|
11
|
+
const SELECT_AREA_WIDTH = 72;
|
|
12
|
+
const UPLOAD_AREA_WIDTH = 48;
|
|
13
|
+
const SPLIT_BUTTON_MIN_HEIGHT = 32;
|
|
14
|
+
const SPLIT_BUTTON_CORNER_RADIUS = '8px';
|
|
15
|
+
const SPLIT_BUTTON_FONT_SIZE = '14px';
|
|
13
16
|
const ICON_LIBRARY_PADDING = 0.625;
|
|
14
17
|
|
|
15
18
|
const svgButtonSx = {
|
|
16
|
-
|
|
17
|
-
|
|
19
|
+
minWidth: 0,
|
|
20
|
+
minHeight: SPLIT_BUTTON_MIN_HEIGHT,
|
|
21
|
+
px: 2,
|
|
22
|
+
fontSize: SPLIT_BUTTON_FONT_SIZE,
|
|
23
|
+
fontWeight: 500,
|
|
24
|
+
lineHeight: 1,
|
|
18
25
|
};
|
|
19
26
|
|
|
20
|
-
const MediaActionGroup = styled( Stack )(
|
|
27
|
+
const MediaActionGroup = styled( Stack )( {
|
|
21
28
|
display: 'inline-flex',
|
|
22
29
|
flexDirection: 'row',
|
|
23
30
|
alignItems: 'stretch',
|
|
24
31
|
border: '1px solid currentColor',
|
|
25
|
-
borderRadius:
|
|
32
|
+
borderRadius: SPLIT_BUTTON_CORNER_RADIUS,
|
|
26
33
|
overflow: 'hidden',
|
|
27
34
|
'& .MuiButton-root': {
|
|
28
35
|
border: 'none',
|
|
29
36
|
borderRadius: 0,
|
|
30
37
|
lineHeight: 1,
|
|
31
38
|
},
|
|
32
|
-
} )
|
|
39
|
+
} );
|
|
33
40
|
|
|
34
41
|
type SvgMediaOverlayProps = {
|
|
35
42
|
isAdmin: boolean;
|
|
@@ -60,7 +67,7 @@ export const SvgMediaOverlay = ( {
|
|
|
60
67
|
variant="text"
|
|
61
68
|
onClick={ onSelectSvg }
|
|
62
69
|
aria-label={ __( 'Select', 'elementor' ) }
|
|
63
|
-
sx={ svgButtonSx }
|
|
70
|
+
sx={ { ...svgButtonSx, minWidth: SELECT_AREA_WIDTH } }
|
|
64
71
|
>
|
|
65
72
|
{ __( 'Select', 'elementor' ) }
|
|
66
73
|
</Button>
|
|
@@ -77,7 +84,7 @@ export const SvgMediaOverlay = ( {
|
|
|
77
84
|
description={ infotipDescription }
|
|
78
85
|
isEnabled={ ! isAdmin }
|
|
79
86
|
>
|
|
80
|
-
<Box component="span" sx={ { display: '
|
|
87
|
+
<Box component="span" sx={ { display: 'flex', width: UPLOAD_AREA_WIDTH } }>
|
|
81
88
|
<UploadControl isAdmin={ isAdmin } onUpload={ onUpload } />
|
|
82
89
|
</Box>
|
|
83
90
|
</ConditionalControlInfotip>
|
|
@@ -124,7 +131,7 @@ const UploadButton = ( {
|
|
|
124
131
|
onClick?: () => void;
|
|
125
132
|
} ) => (
|
|
126
133
|
<Button
|
|
127
|
-
sx={ sx }
|
|
134
|
+
sx={ { ...sx, width: '100%' } }
|
|
128
135
|
size="tiny"
|
|
129
136
|
color="inherit"
|
|
130
137
|
variant="text"
|
|
@@ -132,6 +139,6 @@ const UploadButton = ( {
|
|
|
132
139
|
onClick={ onClick }
|
|
133
140
|
aria-label={ __( 'Upload', 'elementor' ) }
|
|
134
141
|
>
|
|
135
|
-
<UploadIcon />
|
|
142
|
+
<UploadIcon fontSize="small" />
|
|
136
143
|
</Button>
|
|
137
144
|
);
|