@elementor/editor-ui 4.3.0-beta1 → 4.3.0-beta3
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 +7 -4
- package/dist/index.d.ts +7 -4
- package/dist/index.js +43 -14
- package/dist/index.mjs +43 -14
- package/package.json +2 -2
- package/src/components/popover/body.tsx +24 -3
- package/src/components/popover/header.tsx +15 -10
- package/src/components/popover/menu-list.tsx +4 -1
package/dist/index.d.mts
CHANGED
|
@@ -3,7 +3,7 @@ import * as _mui_system from '@mui/system';
|
|
|
3
3
|
import * as React$1 from 'react';
|
|
4
4
|
import { ReactNode, PropsWithChildren, ReactElement, MouseEvent as MouseEvent$1, RefObject, ComponentProps, ElementType, ComponentType } from 'react';
|
|
5
5
|
import * as _mui_material from '@mui/material';
|
|
6
|
-
import { MenuItemProps, MenuItemTextProps, TypographyProps, AlertProps, InfotipProps, BoxProps, ButtonProps, MenuList, DialogProps, DialogContentTextProps } from '@elementor/ui';
|
|
6
|
+
import { MenuItemProps, MenuItemTextProps, TypographyProps, AlertProps, InfotipProps, BoxProps, ButtonProps, StackProps, MenuList, DialogProps, DialogContentTextProps } from '@elementor/ui';
|
|
7
7
|
|
|
8
8
|
declare const CollapseIcon: _emotion_styled.StyledComponent<Omit<_mui_material.SvgIconProps, "ref"> & React$1.RefAttributes<SVGSVGElement> & _mui_system.MUIStyledCommonProps<_mui_material.Theme> & {
|
|
9
9
|
open: boolean;
|
|
@@ -176,8 +176,9 @@ type PopoverBodyProps = PropsWithChildren<{
|
|
|
176
176
|
height?: number | 'auto';
|
|
177
177
|
width?: number;
|
|
178
178
|
id?: string;
|
|
179
|
+
fillWidth?: boolean;
|
|
179
180
|
}>;
|
|
180
|
-
declare const PopoverBody: ({ children, height, width, id }: PopoverBodyProps) => React$1.JSX.Element;
|
|
181
|
+
declare const PopoverBody: ({ children, height, width, id, fillWidth, }: PopoverBodyProps) => React$1.JSX.Element;
|
|
181
182
|
|
|
182
183
|
declare const SectionPopoverBody: (props: ComponentProps<typeof PopoverBody>) => React$1.JSX.Element;
|
|
183
184
|
|
|
@@ -186,8 +187,9 @@ type PopoverHeaderProps = {
|
|
|
186
187
|
onClose: () => void;
|
|
187
188
|
icon?: React$1.ReactNode;
|
|
188
189
|
actions?: React$1.ReactNode[];
|
|
190
|
+
sx?: StackProps['sx'];
|
|
189
191
|
};
|
|
190
|
-
declare const PopoverHeader: ({ title, onClose, icon, actions }: PopoverHeaderProps) => React$1.JSX.Element;
|
|
192
|
+
declare const PopoverHeader: ({ title, onClose, icon, actions, sx }: PopoverHeaderProps) => React$1.JSX.Element;
|
|
191
193
|
|
|
192
194
|
type VirtualizedItem<T, V extends string> = {
|
|
193
195
|
type: T;
|
|
@@ -210,9 +212,10 @@ type PopoverMenuListProps<T, V extends string> = {
|
|
|
210
212
|
menuItemContentTemplate?: (item: VirtualizedItem<T, V>) => React$1.ReactNode;
|
|
211
213
|
categoryItemContentTemplate?: (item: VirtualizedItem<T, V>) => React$1.ReactNode;
|
|
212
214
|
noResultsComponent?: React$1.ReactNode;
|
|
215
|
+
itemHeight?: number;
|
|
213
216
|
};
|
|
214
217
|
declare const ITEM_HEIGHT = 32;
|
|
215
|
-
declare const PopoverMenuList: <T, V extends string>({ items, onSelect, onClose, selectedValue, itemStyle, onChange, "data-testid": dataTestId, menuItemContentTemplate, categoryItemContentTemplate, noResultsComponent, menuListTemplate: CustomMenuList, }: PopoverMenuListProps<T, V>) => React$1.JSX.Element;
|
|
218
|
+
declare const PopoverMenuList: <T, V extends string>({ items, onSelect, onClose, selectedValue, itemStyle, onChange, "data-testid": dataTestId, menuItemContentTemplate, categoryItemContentTemplate, noResultsComponent, menuListTemplate: CustomMenuList, itemHeight, }: PopoverMenuListProps<T, V>) => React$1.JSX.Element;
|
|
216
219
|
declare const StyledMenuList: _emotion_styled.StyledComponent<any, {}, {
|
|
217
220
|
ref?: React$1.Ref<any> | undefined;
|
|
218
221
|
}>;
|
package/dist/index.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ import * as _mui_system from '@mui/system';
|
|
|
3
3
|
import * as React$1 from 'react';
|
|
4
4
|
import { ReactNode, PropsWithChildren, ReactElement, MouseEvent as MouseEvent$1, RefObject, ComponentProps, ElementType, ComponentType } from 'react';
|
|
5
5
|
import * as _mui_material from '@mui/material';
|
|
6
|
-
import { MenuItemProps, MenuItemTextProps, TypographyProps, AlertProps, InfotipProps, BoxProps, ButtonProps, MenuList, DialogProps, DialogContentTextProps } from '@elementor/ui';
|
|
6
|
+
import { MenuItemProps, MenuItemTextProps, TypographyProps, AlertProps, InfotipProps, BoxProps, ButtonProps, StackProps, MenuList, DialogProps, DialogContentTextProps } from '@elementor/ui';
|
|
7
7
|
|
|
8
8
|
declare const CollapseIcon: _emotion_styled.StyledComponent<Omit<_mui_material.SvgIconProps, "ref"> & React$1.RefAttributes<SVGSVGElement> & _mui_system.MUIStyledCommonProps<_mui_material.Theme> & {
|
|
9
9
|
open: boolean;
|
|
@@ -176,8 +176,9 @@ type PopoverBodyProps = PropsWithChildren<{
|
|
|
176
176
|
height?: number | 'auto';
|
|
177
177
|
width?: number;
|
|
178
178
|
id?: string;
|
|
179
|
+
fillWidth?: boolean;
|
|
179
180
|
}>;
|
|
180
|
-
declare const PopoverBody: ({ children, height, width, id }: PopoverBodyProps) => React$1.JSX.Element;
|
|
181
|
+
declare const PopoverBody: ({ children, height, width, id, fillWidth, }: PopoverBodyProps) => React$1.JSX.Element;
|
|
181
182
|
|
|
182
183
|
declare const SectionPopoverBody: (props: ComponentProps<typeof PopoverBody>) => React$1.JSX.Element;
|
|
183
184
|
|
|
@@ -186,8 +187,9 @@ type PopoverHeaderProps = {
|
|
|
186
187
|
onClose: () => void;
|
|
187
188
|
icon?: React$1.ReactNode;
|
|
188
189
|
actions?: React$1.ReactNode[];
|
|
190
|
+
sx?: StackProps['sx'];
|
|
189
191
|
};
|
|
190
|
-
declare const PopoverHeader: ({ title, onClose, icon, actions }: PopoverHeaderProps) => React$1.JSX.Element;
|
|
192
|
+
declare const PopoverHeader: ({ title, onClose, icon, actions, sx }: PopoverHeaderProps) => React$1.JSX.Element;
|
|
191
193
|
|
|
192
194
|
type VirtualizedItem<T, V extends string> = {
|
|
193
195
|
type: T;
|
|
@@ -210,9 +212,10 @@ type PopoverMenuListProps<T, V extends string> = {
|
|
|
210
212
|
menuItemContentTemplate?: (item: VirtualizedItem<T, V>) => React$1.ReactNode;
|
|
211
213
|
categoryItemContentTemplate?: (item: VirtualizedItem<T, V>) => React$1.ReactNode;
|
|
212
214
|
noResultsComponent?: React$1.ReactNode;
|
|
215
|
+
itemHeight?: number;
|
|
213
216
|
};
|
|
214
217
|
declare const ITEM_HEIGHT = 32;
|
|
215
|
-
declare const PopoverMenuList: <T, V extends string>({ items, onSelect, onClose, selectedValue, itemStyle, onChange, "data-testid": dataTestId, menuItemContentTemplate, categoryItemContentTemplate, noResultsComponent, menuListTemplate: CustomMenuList, }: PopoverMenuListProps<T, V>) => React$1.JSX.Element;
|
|
218
|
+
declare const PopoverMenuList: <T, V extends string>({ items, onSelect, onClose, selectedValue, itemStyle, onChange, "data-testid": dataTestId, menuItemContentTemplate, categoryItemContentTemplate, noResultsComponent, menuListTemplate: CustomMenuList, itemHeight, }: PopoverMenuListProps<T, V>) => React$1.JSX.Element;
|
|
216
219
|
declare const StyledMenuList: _emotion_styled.StyledComponent<any, {}, {
|
|
217
220
|
ref?: React$1.Ref<any> | undefined;
|
|
218
221
|
}>;
|
package/dist/index.js
CHANGED
|
@@ -866,7 +866,14 @@ var import_ui21 = require("@elementor/ui");
|
|
|
866
866
|
var SECTION_PADDING_INLINE = 32;
|
|
867
867
|
var DEFAULT_POPOVER_HEIGHT = 348;
|
|
868
868
|
var FALLBACK_POPOVER_WIDTH = 220;
|
|
869
|
-
var PopoverBody = ({
|
|
869
|
+
var PopoverBody = ({
|
|
870
|
+
children,
|
|
871
|
+
height = DEFAULT_POPOVER_HEIGHT,
|
|
872
|
+
width,
|
|
873
|
+
id,
|
|
874
|
+
fillWidth = false
|
|
875
|
+
}) => {
|
|
876
|
+
const resolvedWidth = resolvePopoverWidth(width, fillWidth);
|
|
870
877
|
return /* @__PURE__ */ React21.createElement(
|
|
871
878
|
import_ui21.Box,
|
|
872
879
|
{
|
|
@@ -875,14 +882,23 @@ var PopoverBody = ({ children, height = DEFAULT_POPOVER_HEIGHT, width, id }) =>
|
|
|
875
882
|
sx: {
|
|
876
883
|
height,
|
|
877
884
|
overflow: "hidden",
|
|
878
|
-
width: `${
|
|
879
|
-
maxWidth: 496
|
|
885
|
+
width: `${resolvedWidth}px`,
|
|
886
|
+
maxWidth: fillWidth ? resolvedWidth : 496
|
|
880
887
|
},
|
|
881
888
|
id
|
|
882
889
|
},
|
|
883
890
|
children
|
|
884
891
|
);
|
|
885
892
|
};
|
|
893
|
+
function resolvePopoverWidth(width, fillWidth) {
|
|
894
|
+
if (!width) {
|
|
895
|
+
return FALLBACK_POPOVER_WIDTH;
|
|
896
|
+
}
|
|
897
|
+
if (fillWidth) {
|
|
898
|
+
return width;
|
|
899
|
+
}
|
|
900
|
+
return width - SECTION_PADDING_INLINE;
|
|
901
|
+
}
|
|
886
902
|
|
|
887
903
|
// src/components/popover/section-popover-body.tsx
|
|
888
904
|
var React22 = __toESM(require("react"));
|
|
@@ -907,14 +923,25 @@ var SectionPopoverBody = (props) => {
|
|
|
907
923
|
var React23 = __toESM(require("react"));
|
|
908
924
|
var import_ui22 = require("@elementor/ui");
|
|
909
925
|
var SIZE2 = "tiny";
|
|
910
|
-
var PopoverHeader = ({ title, onClose, icon, actions }) => {
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
926
|
+
var PopoverHeader = ({ title, onClose, icon, actions, sx }) => {
|
|
927
|
+
return /* @__PURE__ */ React23.createElement(
|
|
928
|
+
import_ui22.Stack,
|
|
929
|
+
{
|
|
930
|
+
direction: "row",
|
|
931
|
+
alignItems: "center",
|
|
932
|
+
sx: {
|
|
933
|
+
pl: 2,
|
|
934
|
+
pr: 1,
|
|
935
|
+
py: 1.5,
|
|
936
|
+
maxHeight: 36,
|
|
937
|
+
columnGap: 0.5,
|
|
938
|
+
...sx
|
|
939
|
+
}
|
|
940
|
+
},
|
|
941
|
+
icon,
|
|
942
|
+
/* @__PURE__ */ React23.createElement(import_ui22.Typography, { variant: "subtitle2", sx: { fontSize: "12px", mt: 0.25 } }, title),
|
|
943
|
+
/* @__PURE__ */ React23.createElement(import_ui22.Stack, { direction: "row", sx: { ml: "auto" } }, actions, /* @__PURE__ */ React23.createElement(import_ui22.CloseButton, { slotProps: { icon: { fontSize: SIZE2 } }, sx: { ml: "auto" }, onClick: onClose }))
|
|
944
|
+
);
|
|
918
945
|
};
|
|
919
946
|
|
|
920
947
|
// src/components/popover/menu-list.tsx
|
|
@@ -945,7 +972,8 @@ var PopoverMenuList = ({
|
|
|
945
972
|
menuItemContentTemplate,
|
|
946
973
|
categoryItemContentTemplate,
|
|
947
974
|
noResultsComponent,
|
|
948
|
-
menuListTemplate: CustomMenuList
|
|
975
|
+
menuListTemplate: CustomMenuList,
|
|
976
|
+
itemHeight = ITEM_HEIGHT
|
|
949
977
|
}) => {
|
|
950
978
|
const containerRef = (0, import_react18.useRef)(null);
|
|
951
979
|
const scrollTop = useScrollTop({ containerRef });
|
|
@@ -980,7 +1008,7 @@ var PopoverMenuList = ({
|
|
|
980
1008
|
const virtualizer = (0, import_react_virtual.useVirtualizer)({
|
|
981
1009
|
count: items.length,
|
|
982
1010
|
getScrollElement: () => containerRef.current,
|
|
983
|
-
estimateSize: () =>
|
|
1011
|
+
estimateSize: () => itemHeight,
|
|
984
1012
|
overscan: LIST_ITEMS_BUFFER,
|
|
985
1013
|
rangeExtractor: getActiveItemIndices,
|
|
986
1014
|
onChange: onChangeCallback
|
|
@@ -995,7 +1023,8 @@ var PopoverMenuList = ({
|
|
|
995
1023
|
{
|
|
996
1024
|
role: "listbox",
|
|
997
1025
|
style: { height: `${virtualizer.getTotalSize()}px` },
|
|
998
|
-
"data-testid": dataTestId
|
|
1026
|
+
"data-testid": dataTestId,
|
|
1027
|
+
sx: itemHeight === ITEM_HEIGHT ? void 0 : { "& > li": { height: itemHeight } }
|
|
999
1028
|
},
|
|
1000
1029
|
virtualItems.map((virtualRow) => {
|
|
1001
1030
|
const item = items[virtualRow.index];
|
package/dist/index.mjs
CHANGED
|
@@ -826,7 +826,14 @@ import { Box as Box6 } from "@elementor/ui";
|
|
|
826
826
|
var SECTION_PADDING_INLINE = 32;
|
|
827
827
|
var DEFAULT_POPOVER_HEIGHT = 348;
|
|
828
828
|
var FALLBACK_POPOVER_WIDTH = 220;
|
|
829
|
-
var PopoverBody = ({
|
|
829
|
+
var PopoverBody = ({
|
|
830
|
+
children,
|
|
831
|
+
height = DEFAULT_POPOVER_HEIGHT,
|
|
832
|
+
width,
|
|
833
|
+
id,
|
|
834
|
+
fillWidth = false
|
|
835
|
+
}) => {
|
|
836
|
+
const resolvedWidth = resolvePopoverWidth(width, fillWidth);
|
|
830
837
|
return /* @__PURE__ */ React21.createElement(
|
|
831
838
|
Box6,
|
|
832
839
|
{
|
|
@@ -835,14 +842,23 @@ var PopoverBody = ({ children, height = DEFAULT_POPOVER_HEIGHT, width, id }) =>
|
|
|
835
842
|
sx: {
|
|
836
843
|
height,
|
|
837
844
|
overflow: "hidden",
|
|
838
|
-
width: `${
|
|
839
|
-
maxWidth: 496
|
|
845
|
+
width: `${resolvedWidth}px`,
|
|
846
|
+
maxWidth: fillWidth ? resolvedWidth : 496
|
|
840
847
|
},
|
|
841
848
|
id
|
|
842
849
|
},
|
|
843
850
|
children
|
|
844
851
|
);
|
|
845
852
|
};
|
|
853
|
+
function resolvePopoverWidth(width, fillWidth) {
|
|
854
|
+
if (!width) {
|
|
855
|
+
return FALLBACK_POPOVER_WIDTH;
|
|
856
|
+
}
|
|
857
|
+
if (fillWidth) {
|
|
858
|
+
return width;
|
|
859
|
+
}
|
|
860
|
+
return width - SECTION_PADDING_INLINE;
|
|
861
|
+
}
|
|
846
862
|
|
|
847
863
|
// src/components/popover/section-popover-body.tsx
|
|
848
864
|
import * as React22 from "react";
|
|
@@ -867,14 +883,25 @@ var SectionPopoverBody = (props) => {
|
|
|
867
883
|
import * as React23 from "react";
|
|
868
884
|
import { CloseButton as CloseButton2, Stack as Stack4, Typography as Typography7 } from "@elementor/ui";
|
|
869
885
|
var SIZE2 = "tiny";
|
|
870
|
-
var PopoverHeader = ({ title, onClose, icon, actions }) => {
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
886
|
+
var PopoverHeader = ({ title, onClose, icon, actions, sx }) => {
|
|
887
|
+
return /* @__PURE__ */ React23.createElement(
|
|
888
|
+
Stack4,
|
|
889
|
+
{
|
|
890
|
+
direction: "row",
|
|
891
|
+
alignItems: "center",
|
|
892
|
+
sx: {
|
|
893
|
+
pl: 2,
|
|
894
|
+
pr: 1,
|
|
895
|
+
py: 1.5,
|
|
896
|
+
maxHeight: 36,
|
|
897
|
+
columnGap: 0.5,
|
|
898
|
+
...sx
|
|
899
|
+
}
|
|
900
|
+
},
|
|
901
|
+
icon,
|
|
902
|
+
/* @__PURE__ */ React23.createElement(Typography7, { variant: "subtitle2", sx: { fontSize: "12px", mt: 0.25 } }, title),
|
|
903
|
+
/* @__PURE__ */ React23.createElement(Stack4, { direction: "row", sx: { ml: "auto" } }, actions, /* @__PURE__ */ React23.createElement(CloseButton2, { slotProps: { icon: { fontSize: SIZE2 } }, sx: { ml: "auto" }, onClick: onClose }))
|
|
904
|
+
);
|
|
878
905
|
};
|
|
879
906
|
|
|
880
907
|
// src/components/popover/menu-list.tsx
|
|
@@ -905,7 +932,8 @@ var PopoverMenuList = ({
|
|
|
905
932
|
menuItemContentTemplate,
|
|
906
933
|
categoryItemContentTemplate,
|
|
907
934
|
noResultsComponent,
|
|
908
|
-
menuListTemplate: CustomMenuList
|
|
935
|
+
menuListTemplate: CustomMenuList,
|
|
936
|
+
itemHeight = ITEM_HEIGHT
|
|
909
937
|
}) => {
|
|
910
938
|
const containerRef = useRef5(null);
|
|
911
939
|
const scrollTop = useScrollTop({ containerRef });
|
|
@@ -940,7 +968,7 @@ var PopoverMenuList = ({
|
|
|
940
968
|
const virtualizer = useVirtualizer({
|
|
941
969
|
count: items.length,
|
|
942
970
|
getScrollElement: () => containerRef.current,
|
|
943
|
-
estimateSize: () =>
|
|
971
|
+
estimateSize: () => itemHeight,
|
|
944
972
|
overscan: LIST_ITEMS_BUFFER,
|
|
945
973
|
rangeExtractor: getActiveItemIndices,
|
|
946
974
|
onChange: onChangeCallback
|
|
@@ -955,7 +983,8 @@ var PopoverMenuList = ({
|
|
|
955
983
|
{
|
|
956
984
|
role: "listbox",
|
|
957
985
|
style: { height: `${virtualizer.getTotalSize()}px` },
|
|
958
|
-
"data-testid": dataTestId
|
|
986
|
+
"data-testid": dataTestId,
|
|
987
|
+
sx: itemHeight === ITEM_HEIGHT ? void 0 : { "& > li": { height: itemHeight } }
|
|
959
988
|
},
|
|
960
989
|
virtualItems.map((virtualRow) => {
|
|
961
990
|
const item = items[virtualRow.index];
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@elementor/editor-ui",
|
|
3
3
|
"description": "Elementor Editor UI",
|
|
4
|
-
"version": "4.3.0-
|
|
4
|
+
"version": "4.3.0-beta3",
|
|
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": "4.3.0-
|
|
40
|
+
"@elementor/editor-v1-adapters": "4.3.0-beta3",
|
|
41
41
|
"@elementor/icons": "~1.75.1",
|
|
42
42
|
"@elementor/ui": "1.37.5",
|
|
43
43
|
"@tanstack/react-virtual": "^3.13.3",
|
|
@@ -10,9 +10,18 @@ type PopoverBodyProps = PropsWithChildren< {
|
|
|
10
10
|
height?: number | 'auto';
|
|
11
11
|
width?: number;
|
|
12
12
|
id?: string;
|
|
13
|
+
fillWidth?: boolean;
|
|
13
14
|
} >;
|
|
14
15
|
|
|
15
|
-
export const PopoverBody = ( {
|
|
16
|
+
export const PopoverBody = ( {
|
|
17
|
+
children,
|
|
18
|
+
height = DEFAULT_POPOVER_HEIGHT,
|
|
19
|
+
width,
|
|
20
|
+
id,
|
|
21
|
+
fillWidth = false,
|
|
22
|
+
}: PopoverBodyProps ) => {
|
|
23
|
+
const resolvedWidth = resolvePopoverWidth( width, fillWidth );
|
|
24
|
+
|
|
16
25
|
return (
|
|
17
26
|
<Box
|
|
18
27
|
display="flex"
|
|
@@ -20,8 +29,8 @@ export const PopoverBody = ( { children, height = DEFAULT_POPOVER_HEIGHT, width,
|
|
|
20
29
|
sx={ {
|
|
21
30
|
height,
|
|
22
31
|
overflow: 'hidden',
|
|
23
|
-
width: `${
|
|
24
|
-
maxWidth: 496,
|
|
32
|
+
width: `${ resolvedWidth }px`,
|
|
33
|
+
maxWidth: fillWidth ? resolvedWidth : 496,
|
|
25
34
|
} }
|
|
26
35
|
id={ id }
|
|
27
36
|
>
|
|
@@ -29,3 +38,15 @@ export const PopoverBody = ( { children, height = DEFAULT_POPOVER_HEIGHT, width,
|
|
|
29
38
|
</Box>
|
|
30
39
|
);
|
|
31
40
|
};
|
|
41
|
+
|
|
42
|
+
function resolvePopoverWidth( width: number | undefined, fillWidth: boolean ): number {
|
|
43
|
+
if ( ! width ) {
|
|
44
|
+
return FALLBACK_POPOVER_WIDTH;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
if ( fillWidth ) {
|
|
48
|
+
return width;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
return width - SECTION_PADDING_INLINE;
|
|
52
|
+
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import { CloseButton, Stack, Typography } from '@elementor/ui';
|
|
2
|
+
import { CloseButton, Stack, type StackProps, Typography } from '@elementor/ui';
|
|
3
3
|
|
|
4
4
|
const SIZE = 'tiny';
|
|
5
5
|
|
|
@@ -8,18 +8,23 @@ type PopoverHeaderProps = {
|
|
|
8
8
|
onClose: () => void;
|
|
9
9
|
icon?: React.ReactNode;
|
|
10
10
|
actions?: React.ReactNode[];
|
|
11
|
+
sx?: StackProps[ 'sx' ];
|
|
11
12
|
};
|
|
12
13
|
|
|
13
|
-
export const PopoverHeader = ( { title, onClose, icon, actions }: PopoverHeaderProps ) => {
|
|
14
|
-
const paddingAndSizing = {
|
|
15
|
-
pl: 2,
|
|
16
|
-
pr: 1,
|
|
17
|
-
py: 1.5,
|
|
18
|
-
maxHeight: 36,
|
|
19
|
-
};
|
|
20
|
-
|
|
14
|
+
export const PopoverHeader = ( { title, onClose, icon, actions, sx }: PopoverHeaderProps ) => {
|
|
21
15
|
return (
|
|
22
|
-
<Stack
|
|
16
|
+
<Stack
|
|
17
|
+
direction="row"
|
|
18
|
+
alignItems="center"
|
|
19
|
+
sx={ {
|
|
20
|
+
pl: 2,
|
|
21
|
+
pr: 1,
|
|
22
|
+
py: 1.5,
|
|
23
|
+
maxHeight: 36,
|
|
24
|
+
columnGap: 0.5,
|
|
25
|
+
...sx,
|
|
26
|
+
} }
|
|
27
|
+
>
|
|
23
28
|
{ icon }
|
|
24
29
|
<Typography variant="subtitle2" sx={ { fontSize: '12px', mt: 0.25 } }>
|
|
25
30
|
{ title }
|
|
@@ -27,6 +27,7 @@ export type PopoverMenuListProps< T, V extends string > = {
|
|
|
27
27
|
menuItemContentTemplate?: ( item: VirtualizedItem< T, V > ) => React.ReactNode;
|
|
28
28
|
categoryItemContentTemplate?: ( item: VirtualizedItem< T, V > ) => React.ReactNode;
|
|
29
29
|
noResultsComponent?: React.ReactNode;
|
|
30
|
+
itemHeight?: number;
|
|
30
31
|
};
|
|
31
32
|
|
|
32
33
|
export const ITEM_HEIGHT = 32;
|
|
@@ -63,6 +64,7 @@ export const PopoverMenuList = < T, V extends string >( {
|
|
|
63
64
|
categoryItemContentTemplate,
|
|
64
65
|
noResultsComponent,
|
|
65
66
|
menuListTemplate: CustomMenuList,
|
|
67
|
+
itemHeight = ITEM_HEIGHT,
|
|
66
68
|
}: PopoverMenuListProps< T, V > ) => {
|
|
67
69
|
const containerRef = useRef< HTMLDivElement >( null );
|
|
68
70
|
const scrollTop = useScrollTop( { containerRef } );
|
|
@@ -107,7 +109,7 @@ export const PopoverMenuList = < T, V extends string >( {
|
|
|
107
109
|
const virtualizer = useVirtualizer( {
|
|
108
110
|
count: items.length,
|
|
109
111
|
getScrollElement: () => containerRef.current,
|
|
110
|
-
estimateSize: () =>
|
|
112
|
+
estimateSize: () => itemHeight,
|
|
111
113
|
overscan: LIST_ITEMS_BUFFER,
|
|
112
114
|
rangeExtractor: getActiveItemIndices,
|
|
113
115
|
onChange: onChangeCallback,
|
|
@@ -130,6 +132,7 @@ export const PopoverMenuList = < T, V extends string >( {
|
|
|
130
132
|
role="listbox"
|
|
131
133
|
style={ { height: `${ virtualizer.getTotalSize() }px` } }
|
|
132
134
|
data-testid={ dataTestId }
|
|
135
|
+
sx={ itemHeight === ITEM_HEIGHT ? undefined : { '& > li': { height: itemHeight } } }
|
|
133
136
|
>
|
|
134
137
|
{ virtualItems.map( ( virtualRow ) => {
|
|
135
138
|
const item = items[ virtualRow.index ];
|