@elementor/editor-ui 3.35.0-417 → 3.35.0-418
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.d.mts
CHANGED
|
@@ -158,9 +158,7 @@ type PopoverMenuListProps<T, V extends string> = {
|
|
|
158
158
|
selectedValue?: V;
|
|
159
159
|
itemStyle?: (item: VirtualizedItem<T, V>) => React$1.CSSProperties;
|
|
160
160
|
'data-testid'?: string;
|
|
161
|
-
onChange?: (
|
|
162
|
-
getVirtualIndexes: () => number[];
|
|
163
|
-
}) => void;
|
|
161
|
+
onChange?: (visibleItems: VirtualizedItem<T, V>[]) => void;
|
|
164
162
|
menuListTemplate?: React$1.ComponentType<React$1.ComponentProps<typeof MenuList>>;
|
|
165
163
|
menuItemContentTemplate?: (item: VirtualizedItem<T, V>) => React$1.ReactNode;
|
|
166
164
|
noResultsComponent?: React$1.ReactNode;
|
package/dist/index.d.ts
CHANGED
|
@@ -158,9 +158,7 @@ type PopoverMenuListProps<T, V extends string> = {
|
|
|
158
158
|
selectedValue?: V;
|
|
159
159
|
itemStyle?: (item: VirtualizedItem<T, V>) => React$1.CSSProperties;
|
|
160
160
|
'data-testid'?: string;
|
|
161
|
-
onChange?: (
|
|
162
|
-
getVirtualIndexes: () => number[];
|
|
163
|
-
}) => void;
|
|
161
|
+
onChange?: (visibleItems: VirtualizedItem<T, V>[]) => void;
|
|
164
162
|
menuListTemplate?: React$1.ComponentType<React$1.ComponentProps<typeof MenuList>>;
|
|
165
163
|
menuItemContentTemplate?: (item: VirtualizedItem<T, V>) => React$1.ReactNode;
|
|
166
164
|
noResultsComponent?: React$1.ReactNode;
|
package/dist/index.js
CHANGED
|
@@ -676,6 +676,7 @@ var PopoverMenuList = ({
|
|
|
676
676
|
}) => {
|
|
677
677
|
const containerRef = (0, import_react12.useRef)(null);
|
|
678
678
|
const scrollTop = useScrollTop({ containerRef });
|
|
679
|
+
const theme = (0, import_ui18.useTheme)();
|
|
679
680
|
const MenuListComponent = CustomMenuList || StyledMenuList;
|
|
680
681
|
const stickyIndices = (0, import_react12.useMemo)(
|
|
681
682
|
() => items.reduce((categoryIndices, item, index) => {
|
|
@@ -699,14 +700,21 @@ var PopoverMenuList = ({
|
|
|
699
700
|
});
|
|
700
701
|
return visibleAndStickyIndexes.sort((a, b) => a - b);
|
|
701
702
|
};
|
|
703
|
+
const onChangeCallback = ({ getVirtualIndexes }) => {
|
|
704
|
+
const visibleItems = getVirtualIndexes().map((index) => items[index]);
|
|
705
|
+
onChange?.(visibleItems);
|
|
706
|
+
};
|
|
702
707
|
const virtualizer = (0, import_react_virtual.useVirtualizer)({
|
|
703
708
|
count: items.length,
|
|
704
709
|
getScrollElement: () => containerRef.current,
|
|
705
710
|
estimateSize: () => ITEM_HEIGHT,
|
|
706
711
|
overscan: LIST_ITEMS_BUFFER,
|
|
707
712
|
rangeExtractor: getActiveItemIndices,
|
|
708
|
-
onChange
|
|
713
|
+
onChange: onChangeCallback
|
|
709
714
|
});
|
|
715
|
+
(0, import_react12.useEffect)(() => {
|
|
716
|
+
onChangeCallback(virtualizer);
|
|
717
|
+
}, [items]);
|
|
710
718
|
useScrollToSelected({ selectedValue, items, virtualizer });
|
|
711
719
|
const virtualItems = virtualizer.getVirtualItems();
|
|
712
720
|
return /* @__PURE__ */ React18.createElement(import_ui18.Box, { ref: containerRef, sx: { height: "100%", overflowY: "auto" } }, items.length === 0 && noResultsComponent ? noResultsComponent : /* @__PURE__ */ React18.createElement(
|
|
@@ -769,6 +777,7 @@ var PopoverMenuList = ({
|
|
|
769
777
|
tabIndex: isSelected ? 0 : tabIndexFallback,
|
|
770
778
|
sx: {
|
|
771
779
|
transform: `translateY(${virtualRow.start + MENU_LIST_PADDING_TOP}px)`,
|
|
780
|
+
...theme.typography.caption,
|
|
772
781
|
...itemStyle ? itemStyle(item) : {}
|
|
773
782
|
}
|
|
774
783
|
},
|
|
@@ -785,7 +794,6 @@ var StyledMenuList = (0, import_ui18.styled)(import_ui18.MenuList)(({ theme }) =
|
|
|
785
794
|
alignItems: "center"
|
|
786
795
|
},
|
|
787
796
|
'& > [role="option"]': {
|
|
788
|
-
...theme.typography.caption,
|
|
789
797
|
lineHeight: "inherit",
|
|
790
798
|
padding: theme.spacing(0.75, 2, 0.75, 4),
|
|
791
799
|
"&:hover, &:focus": {
|
package/dist/index.mjs
CHANGED
|
@@ -583,8 +583,8 @@ var PopoverHeader = ({ title, onClose, icon, actions }) => {
|
|
|
583
583
|
|
|
584
584
|
// src/components/popover/menu-list.tsx
|
|
585
585
|
import * as React18 from "react";
|
|
586
|
-
import { useMemo, useRef as useRef3 } from "react";
|
|
587
|
-
import { Box as Box7, ListItem, MenuList, MenuSubheader, styled as styled3 } from "@elementor/ui";
|
|
586
|
+
import { useEffect as useEffect6, useMemo, useRef as useRef3 } from "react";
|
|
587
|
+
import { Box as Box7, ListItem, MenuList, MenuSubheader, styled as styled3, useTheme } from "@elementor/ui";
|
|
588
588
|
import { useVirtualizer } from "@tanstack/react-virtual";
|
|
589
589
|
|
|
590
590
|
// src/hooks/use-scroll-to-selected.ts
|
|
@@ -650,6 +650,7 @@ var PopoverMenuList = ({
|
|
|
650
650
|
}) => {
|
|
651
651
|
const containerRef = useRef3(null);
|
|
652
652
|
const scrollTop = useScrollTop({ containerRef });
|
|
653
|
+
const theme = useTheme();
|
|
653
654
|
const MenuListComponent = CustomMenuList || StyledMenuList;
|
|
654
655
|
const stickyIndices = useMemo(
|
|
655
656
|
() => items.reduce((categoryIndices, item, index) => {
|
|
@@ -673,14 +674,21 @@ var PopoverMenuList = ({
|
|
|
673
674
|
});
|
|
674
675
|
return visibleAndStickyIndexes.sort((a, b) => a - b);
|
|
675
676
|
};
|
|
677
|
+
const onChangeCallback = ({ getVirtualIndexes }) => {
|
|
678
|
+
const visibleItems = getVirtualIndexes().map((index) => items[index]);
|
|
679
|
+
onChange?.(visibleItems);
|
|
680
|
+
};
|
|
676
681
|
const virtualizer = useVirtualizer({
|
|
677
682
|
count: items.length,
|
|
678
683
|
getScrollElement: () => containerRef.current,
|
|
679
684
|
estimateSize: () => ITEM_HEIGHT,
|
|
680
685
|
overscan: LIST_ITEMS_BUFFER,
|
|
681
686
|
rangeExtractor: getActiveItemIndices,
|
|
682
|
-
onChange
|
|
687
|
+
onChange: onChangeCallback
|
|
683
688
|
});
|
|
689
|
+
useEffect6(() => {
|
|
690
|
+
onChangeCallback(virtualizer);
|
|
691
|
+
}, [items]);
|
|
684
692
|
useScrollToSelected({ selectedValue, items, virtualizer });
|
|
685
693
|
const virtualItems = virtualizer.getVirtualItems();
|
|
686
694
|
return /* @__PURE__ */ React18.createElement(Box7, { ref: containerRef, sx: { height: "100%", overflowY: "auto" } }, items.length === 0 && noResultsComponent ? noResultsComponent : /* @__PURE__ */ React18.createElement(
|
|
@@ -743,6 +751,7 @@ var PopoverMenuList = ({
|
|
|
743
751
|
tabIndex: isSelected ? 0 : tabIndexFallback,
|
|
744
752
|
sx: {
|
|
745
753
|
transform: `translateY(${virtualRow.start + MENU_LIST_PADDING_TOP}px)`,
|
|
754
|
+
...theme.typography.caption,
|
|
746
755
|
...itemStyle ? itemStyle(item) : {}
|
|
747
756
|
}
|
|
748
757
|
},
|
|
@@ -759,7 +768,6 @@ var StyledMenuList = styled3(MenuList)(({ theme }) => ({
|
|
|
759
768
|
alignItems: "center"
|
|
760
769
|
},
|
|
761
770
|
'& > [role="option"]': {
|
|
762
|
-
...theme.typography.caption,
|
|
763
771
|
lineHeight: "inherit",
|
|
764
772
|
padding: theme.spacing(0.75, 2, 0.75, 4),
|
|
765
773
|
"&:hover, &:focus": {
|
|
@@ -833,7 +841,7 @@ var useDialog = () => {
|
|
|
833
841
|
};
|
|
834
842
|
|
|
835
843
|
// src/hooks/use-editable.ts
|
|
836
|
-
import { useEffect as
|
|
844
|
+
import { useEffect as useEffect7, useRef as useRef4, useState as useState7 } from "react";
|
|
837
845
|
var useEditable = ({ value, onSubmit, validation, onClick, onError }) => {
|
|
838
846
|
const [isEditing, setIsEditing] = useState7(false);
|
|
839
847
|
const [error, setError] = useState7(null);
|
|
@@ -919,7 +927,7 @@ var useEditable = ({ value, onSubmit, validation, onClick, onError }) => {
|
|
|
919
927
|
};
|
|
920
928
|
var useSelection = (isEditing) => {
|
|
921
929
|
const ref = useRef4(null);
|
|
922
|
-
|
|
930
|
+
useEffect7(() => {
|
|
923
931
|
if (isEditing) {
|
|
924
932
|
selectAll(ref.current);
|
|
925
933
|
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@elementor/editor-ui",
|
|
3
3
|
"description": "Elementor Editor UI",
|
|
4
|
-
"version": "3.35.0-
|
|
4
|
+
"version": "3.35.0-418",
|
|
5
5
|
"private": false,
|
|
6
6
|
"author": "Elementor Team",
|
|
7
7
|
"homepage": "https://elementor.com/",
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
"react-dom": "^18.3.1"
|
|
38
38
|
},
|
|
39
39
|
"dependencies": {
|
|
40
|
-
"@elementor/editor-v1-adapters": "3.35.0-
|
|
40
|
+
"@elementor/editor-v1-adapters": "3.35.0-418",
|
|
41
41
|
"@elementor/icons": "^1.63.0",
|
|
42
42
|
"@elementor/ui": "1.36.17",
|
|
43
43
|
"@tanstack/react-virtual": "^3.13.3",
|
|
@@ -21,6 +21,7 @@ jest.mock( '@tanstack/react-virtual', () => ( {
|
|
|
21
21
|
.mockReturnValue( mockItems.map( ( item, index ) => ( { key: item.value, index, start: index * 10 } ) ) ),
|
|
22
22
|
getTotalSize: jest.fn().mockReturnValue( mockItems.length ),
|
|
23
23
|
scrollToIndex: jest.fn(),
|
|
24
|
+
getVirtualIndexes: jest.fn().mockReturnValue( mockItems.map( ( _, index ) => index ) ),
|
|
24
25
|
} ) ),
|
|
25
26
|
} ) );
|
|
26
27
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import { useMemo, useRef } from 'react';
|
|
3
|
-
import { Box, ListItem, MenuList, MenuSubheader, styled } from '@elementor/ui';
|
|
4
|
-
import { useVirtualizer } from '@tanstack/react-virtual';
|
|
2
|
+
import { useEffect, useMemo, useRef } from 'react';
|
|
3
|
+
import { Box, ListItem, MenuList, MenuSubheader, styled, useTheme } from '@elementor/ui';
|
|
4
|
+
import { useVirtualizer, type Virtualizer } from '@tanstack/react-virtual';
|
|
5
5
|
|
|
6
6
|
import { useScrollTop, useScrollToSelected } from '../../hooks';
|
|
7
7
|
|
|
@@ -22,7 +22,7 @@ export type PopoverMenuListProps< T, V extends string > = {
|
|
|
22
22
|
selectedValue?: V;
|
|
23
23
|
itemStyle?: ( item: VirtualizedItem< T, V > ) => React.CSSProperties;
|
|
24
24
|
'data-testid'?: string;
|
|
25
|
-
onChange?: (
|
|
25
|
+
onChange?: ( visibleItems: VirtualizedItem< T, V >[] ) => void;
|
|
26
26
|
menuListTemplate?: React.ComponentType< React.ComponentProps< typeof MenuList > >;
|
|
27
27
|
menuItemContentTemplate?: ( item: VirtualizedItem< T, V > ) => React.ReactNode;
|
|
28
28
|
noResultsComponent?: React.ReactNode;
|
|
@@ -64,6 +64,7 @@ export const PopoverMenuList = < T, V extends string >( {
|
|
|
64
64
|
}: PopoverMenuListProps< T, V > ) => {
|
|
65
65
|
const containerRef = useRef< HTMLDivElement >( null );
|
|
66
66
|
const scrollTop = useScrollTop( { containerRef } );
|
|
67
|
+
const theme = useTheme();
|
|
67
68
|
|
|
68
69
|
const MenuListComponent = CustomMenuList || StyledMenuList;
|
|
69
70
|
|
|
@@ -96,15 +97,25 @@ export const PopoverMenuList = < T, V extends string >( {
|
|
|
96
97
|
return visibleAndStickyIndexes.sort( ( a, b ) => a - b );
|
|
97
98
|
};
|
|
98
99
|
|
|
100
|
+
const onChangeCallback = ( { getVirtualIndexes }: Virtualizer< HTMLDivElement, Element > ) => {
|
|
101
|
+
const visibleItems = getVirtualIndexes().map( ( index ) => items[ index ] );
|
|
102
|
+
onChange?.( visibleItems );
|
|
103
|
+
};
|
|
104
|
+
|
|
99
105
|
const virtualizer = useVirtualizer( {
|
|
100
106
|
count: items.length,
|
|
101
107
|
getScrollElement: () => containerRef.current,
|
|
102
108
|
estimateSize: () => ITEM_HEIGHT,
|
|
103
109
|
overscan: LIST_ITEMS_BUFFER,
|
|
104
110
|
rangeExtractor: getActiveItemIndices,
|
|
105
|
-
onChange,
|
|
111
|
+
onChange: onChangeCallback,
|
|
106
112
|
} );
|
|
107
113
|
|
|
114
|
+
useEffect( () => {
|
|
115
|
+
onChangeCallback( virtualizer );
|
|
116
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
117
|
+
}, [ items ] );
|
|
118
|
+
|
|
108
119
|
useScrollToSelected( { selectedValue, items, virtualizer } );
|
|
109
120
|
const virtualItems = virtualizer.getVirtualItems();
|
|
110
121
|
|
|
@@ -180,6 +191,7 @@ export const PopoverMenuList = < T, V extends string >( {
|
|
|
180
191
|
tabIndex={ isSelected ? 0 : tabIndexFallback }
|
|
181
192
|
sx={ {
|
|
182
193
|
transform: `translateY(${ virtualRow.start + MENU_LIST_PADDING_TOP }px)`,
|
|
194
|
+
...theme.typography.caption,
|
|
183
195
|
...( itemStyle ? itemStyle( item ) : {} ),
|
|
184
196
|
} }
|
|
185
197
|
>
|
|
@@ -201,7 +213,6 @@ export const StyledMenuList = styled( MenuList )( ( { theme } ) => ( {
|
|
|
201
213
|
alignItems: 'center',
|
|
202
214
|
},
|
|
203
215
|
'& > [role="option"]': {
|
|
204
|
-
...theme.typography.caption,
|
|
205
216
|
lineHeight: 'inherit',
|
|
206
217
|
padding: theme.spacing( 0.75, 2, 0.75, 4 ),
|
|
207
218
|
'&:hover, &:focus': {
|