@elementor/editor-ui 0.11.0 → 0.12.0
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/.turbo/turbo-build.log +10 -10
- package/CHANGELOG.md +13 -0
- package/dist/index.d.mts +44 -6
- package/dist/index.d.ts +44 -6
- package/dist/index.js +256 -35
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +258 -41
- package/dist/index.mjs.map +1 -1
- package/package.json +5 -3
- package/src/components/info-alert.tsx +11 -21
- package/src/components/menu-item.tsx +1 -1
- package/src/components/popover/index.ts +5 -0
- package/src/components/popover/menu-list.tsx +199 -0
- package/src/components/popover/scrollable-content.tsx +17 -0
- package/src/components/popover/search.tsx +54 -0
- package/src/components/warning-infotip.tsx +3 -12
- package/src/hooks/index.ts +2 -0
- package/src/hooks/use-scroll-to-selected.ts +28 -0
- package/src/hooks/use-scroll-top.ts +26 -0
- package/src/index.ts +1 -1
package/.turbo/turbo-build.log
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
|
|
2
|
-
> @elementor/editor-ui@0.
|
|
2
|
+
> @elementor/editor-ui@0.12.0 build
|
|
3
3
|
> tsup --config=../../tsup.build.ts
|
|
4
4
|
|
|
5
5
|
[34mCLI[39m Building entry: src/index.ts
|
|
@@ -10,13 +10,13 @@
|
|
|
10
10
|
[34mCLI[39m Cleaning output folder
|
|
11
11
|
[34mESM[39m Build start
|
|
12
12
|
[34mCJS[39m Build start
|
|
13
|
-
[32mCJS[39m [1mdist/index.js [22m[
|
|
14
|
-
[32mCJS[39m [1mdist/index.js.map [22m[
|
|
15
|
-
[32mCJS[39m ⚡️ Build success in
|
|
16
|
-
[32mESM[39m [1mdist/index.mjs [22m[
|
|
17
|
-
[32mESM[39m [1mdist/index.mjs.map [22m[
|
|
18
|
-
[32mESM[39m ⚡️ Build success in
|
|
13
|
+
[32mCJS[39m [1mdist/index.js [22m[32m21.64 KB[39m
|
|
14
|
+
[32mCJS[39m [1mdist/index.js.map [22m[32m37.24 KB[39m
|
|
15
|
+
[32mCJS[39m ⚡️ Build success in 259ms
|
|
16
|
+
[32mESM[39m [1mdist/index.mjs [22m[32m18.99 KB[39m
|
|
17
|
+
[32mESM[39m [1mdist/index.mjs.map [22m[32m36.83 KB[39m
|
|
18
|
+
[32mESM[39m ⚡️ Build success in 276ms
|
|
19
19
|
[34mDTS[39m Build start
|
|
20
|
-
[32mDTS[39m ⚡️ Build success in
|
|
21
|
-
[32mDTS[39m [1mdist/index.d.mts [22m[
|
|
22
|
-
[32mDTS[39m [1mdist/index.d.ts [22m[
|
|
20
|
+
[32mDTS[39m ⚡️ Build success in 21292ms
|
|
21
|
+
[32mDTS[39m [1mdist/index.d.mts [22m[32m5.11 KB[39m
|
|
22
|
+
[32mDTS[39m [1mdist/index.d.ts [22m[32m5.11 KB[39m
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,18 @@
|
|
|
1
1
|
# @elementor/editor-ui
|
|
2
2
|
|
|
3
|
+
## 0.12.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- da0c4ca: Ability to search variables by name
|
|
8
|
+
- 17b73ab: Update `@elementor/ui` version.
|
|
9
|
+
- 7a4178f: Remove alert custom styling.
|
|
10
|
+
- 8e18905: Update the autofocus and padding of the popover search component.
|
|
11
|
+
- 3daa1c9: Extract font family content list to a standalone component inside the Editor UI package.
|
|
12
|
+
- 40d00c2: Implement the Popover Menu List inside the Dynamic Tags and the Variables.
|
|
13
|
+
- d5e9011: Implement the Popover Search component inside the Dynamic Tags, Font Families and the Variables.
|
|
14
|
+
- f37c325: Extract the popover scrollable content box to a standalone component inside the Editor UI package.
|
|
15
|
+
|
|
3
16
|
## 0.11.0
|
|
4
17
|
|
|
5
18
|
### Minor Changes
|
package/dist/index.d.mts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import * as React$1 from 'react';
|
|
2
2
|
import { ReactNode, PropsWithChildren } from 'react';
|
|
3
|
-
import { MenuItemProps,
|
|
3
|
+
import { MenuItemProps, AlertProps, InfotipProps, MenuList } from '@elementor/ui';
|
|
4
|
+
import * as _emotion_styled from '@emotion/styled';
|
|
4
5
|
|
|
5
6
|
type EllipsisWithTooltipProps<T extends React$1.ElementType> = {
|
|
6
7
|
maxWidth?: React$1.CSSProperties['maxWidth'];
|
|
@@ -45,10 +46,7 @@ type InfoTipCardProps = {
|
|
|
45
46
|
};
|
|
46
47
|
declare const InfoTipCard: ({ content, svgIcon, learnMoreButton, ctaButton }: InfoTipCardProps) => React$1.JSX.Element;
|
|
47
48
|
|
|
48
|
-
declare const InfoAlert: (
|
|
49
|
-
content: string;
|
|
50
|
-
sx?: SxProps;
|
|
51
|
-
}) => React$1.JSX.Element;
|
|
49
|
+
declare const InfoAlert: (props: AlertProps) => React$1.JSX.Element;
|
|
52
50
|
|
|
53
51
|
interface WarningInfotipProps extends PropsWithChildren {
|
|
54
52
|
open: boolean;
|
|
@@ -68,6 +66,46 @@ type PopoverHeaderProps = {
|
|
|
68
66
|
};
|
|
69
67
|
declare const PopoverHeader: ({ title, onClose, icon, actions }: PopoverHeaderProps) => React$1.JSX.Element;
|
|
70
68
|
|
|
69
|
+
type VirtualizedItem<T, V extends string> = {
|
|
70
|
+
type: T;
|
|
71
|
+
value: V;
|
|
72
|
+
label?: string;
|
|
73
|
+
icon?: React$1.ReactNode;
|
|
74
|
+
secondaryText?: string;
|
|
75
|
+
[key: string]: unknown;
|
|
76
|
+
};
|
|
77
|
+
type PopoverMenuListProps<T, V extends string> = {
|
|
78
|
+
items: VirtualizedItem<T, V>[];
|
|
79
|
+
onSelect: (value: V) => void;
|
|
80
|
+
onClose: () => void;
|
|
81
|
+
selectedValue?: V;
|
|
82
|
+
itemStyle?: (item: VirtualizedItem<T, V>) => React$1.CSSProperties;
|
|
83
|
+
'data-testid'?: string;
|
|
84
|
+
onChange?: (params: {
|
|
85
|
+
getVirtualIndexes: () => number[];
|
|
86
|
+
}) => void;
|
|
87
|
+
menuListTemplate?: React$1.ComponentType<React$1.ComponentProps<typeof MenuList>>;
|
|
88
|
+
menuItemContentTemplate?: (item: VirtualizedItem<T, V>) => React$1.ReactNode;
|
|
89
|
+
noResultsComponent?: React$1.ReactNode;
|
|
90
|
+
};
|
|
91
|
+
declare const PopoverMenuList: <T, V extends string>({ items, onSelect, onClose, selectedValue, itemStyle, onChange, "data-testid": dataTestId, menuItemContentTemplate, noResultsComponent, menuListTemplate: CustomMenuList, }: PopoverMenuListProps<T, V>) => React$1.JSX.Element;
|
|
92
|
+
declare const StyledMenuList: _emotion_styled.StyledComponent<any, {}, {
|
|
93
|
+
ref?: React$1.Ref<any> | undefined;
|
|
94
|
+
}>;
|
|
95
|
+
|
|
96
|
+
declare const PopoverScrollableContent: React$1.ForwardRefExoticComponent<{
|
|
97
|
+
height?: number;
|
|
98
|
+
} & {
|
|
99
|
+
children?: React$1.ReactNode | undefined;
|
|
100
|
+
} & React$1.RefAttributes<HTMLDivElement>>;
|
|
101
|
+
|
|
102
|
+
type Props = {
|
|
103
|
+
value: string;
|
|
104
|
+
onSearch: (search: string) => void;
|
|
105
|
+
placeholder: string;
|
|
106
|
+
};
|
|
107
|
+
declare const PopoverSearch: ({ value, onSearch, placeholder }: Props) => React$1.JSX.Element;
|
|
108
|
+
|
|
71
109
|
type UseEditableParams = {
|
|
72
110
|
value: string;
|
|
73
111
|
onSubmit: (value: string) => unknown;
|
|
@@ -94,4 +132,4 @@ declare const useEditable: ({ value, onSubmit, validation, onClick, onError }: U
|
|
|
94
132
|
};
|
|
95
133
|
};
|
|
96
134
|
|
|
97
|
-
export { EditableField, EllipsisWithTooltip, InfoAlert, InfoTipCard, IntroductionModal, MenuItemInfotip, MenuListItem, PopoverHeader, ThemeProvider, WarningInfotip, useEditable };
|
|
135
|
+
export { EditableField, EllipsisWithTooltip, InfoAlert, InfoTipCard, IntroductionModal, MenuItemInfotip, MenuListItem, PopoverHeader, PopoverMenuList, type PopoverMenuListProps, PopoverScrollableContent, PopoverSearch, StyledMenuList, ThemeProvider, type VirtualizedItem, WarningInfotip, useEditable };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import * as React$1 from 'react';
|
|
2
2
|
import { ReactNode, PropsWithChildren } from 'react';
|
|
3
|
-
import { MenuItemProps,
|
|
3
|
+
import { MenuItemProps, AlertProps, InfotipProps, MenuList } from '@elementor/ui';
|
|
4
|
+
import * as _emotion_styled from '@emotion/styled';
|
|
4
5
|
|
|
5
6
|
type EllipsisWithTooltipProps<T extends React$1.ElementType> = {
|
|
6
7
|
maxWidth?: React$1.CSSProperties['maxWidth'];
|
|
@@ -45,10 +46,7 @@ type InfoTipCardProps = {
|
|
|
45
46
|
};
|
|
46
47
|
declare const InfoTipCard: ({ content, svgIcon, learnMoreButton, ctaButton }: InfoTipCardProps) => React$1.JSX.Element;
|
|
47
48
|
|
|
48
|
-
declare const InfoAlert: (
|
|
49
|
-
content: string;
|
|
50
|
-
sx?: SxProps;
|
|
51
|
-
}) => React$1.JSX.Element;
|
|
49
|
+
declare const InfoAlert: (props: AlertProps) => React$1.JSX.Element;
|
|
52
50
|
|
|
53
51
|
interface WarningInfotipProps extends PropsWithChildren {
|
|
54
52
|
open: boolean;
|
|
@@ -68,6 +66,46 @@ type PopoverHeaderProps = {
|
|
|
68
66
|
};
|
|
69
67
|
declare const PopoverHeader: ({ title, onClose, icon, actions }: PopoverHeaderProps) => React$1.JSX.Element;
|
|
70
68
|
|
|
69
|
+
type VirtualizedItem<T, V extends string> = {
|
|
70
|
+
type: T;
|
|
71
|
+
value: V;
|
|
72
|
+
label?: string;
|
|
73
|
+
icon?: React$1.ReactNode;
|
|
74
|
+
secondaryText?: string;
|
|
75
|
+
[key: string]: unknown;
|
|
76
|
+
};
|
|
77
|
+
type PopoverMenuListProps<T, V extends string> = {
|
|
78
|
+
items: VirtualizedItem<T, V>[];
|
|
79
|
+
onSelect: (value: V) => void;
|
|
80
|
+
onClose: () => void;
|
|
81
|
+
selectedValue?: V;
|
|
82
|
+
itemStyle?: (item: VirtualizedItem<T, V>) => React$1.CSSProperties;
|
|
83
|
+
'data-testid'?: string;
|
|
84
|
+
onChange?: (params: {
|
|
85
|
+
getVirtualIndexes: () => number[];
|
|
86
|
+
}) => void;
|
|
87
|
+
menuListTemplate?: React$1.ComponentType<React$1.ComponentProps<typeof MenuList>>;
|
|
88
|
+
menuItemContentTemplate?: (item: VirtualizedItem<T, V>) => React$1.ReactNode;
|
|
89
|
+
noResultsComponent?: React$1.ReactNode;
|
|
90
|
+
};
|
|
91
|
+
declare const PopoverMenuList: <T, V extends string>({ items, onSelect, onClose, selectedValue, itemStyle, onChange, "data-testid": dataTestId, menuItemContentTemplate, noResultsComponent, menuListTemplate: CustomMenuList, }: PopoverMenuListProps<T, V>) => React$1.JSX.Element;
|
|
92
|
+
declare const StyledMenuList: _emotion_styled.StyledComponent<any, {}, {
|
|
93
|
+
ref?: React$1.Ref<any> | undefined;
|
|
94
|
+
}>;
|
|
95
|
+
|
|
96
|
+
declare const PopoverScrollableContent: React$1.ForwardRefExoticComponent<{
|
|
97
|
+
height?: number;
|
|
98
|
+
} & {
|
|
99
|
+
children?: React$1.ReactNode | undefined;
|
|
100
|
+
} & React$1.RefAttributes<HTMLDivElement>>;
|
|
101
|
+
|
|
102
|
+
type Props = {
|
|
103
|
+
value: string;
|
|
104
|
+
onSearch: (search: string) => void;
|
|
105
|
+
placeholder: string;
|
|
106
|
+
};
|
|
107
|
+
declare const PopoverSearch: ({ value, onSearch, placeholder }: Props) => React$1.JSX.Element;
|
|
108
|
+
|
|
71
109
|
type UseEditableParams = {
|
|
72
110
|
value: string;
|
|
73
111
|
onSubmit: (value: string) => unknown;
|
|
@@ -94,4 +132,4 @@ declare const useEditable: ({ value, onSubmit, validation, onClick, onError }: U
|
|
|
94
132
|
};
|
|
95
133
|
};
|
|
96
134
|
|
|
97
|
-
export { EditableField, EllipsisWithTooltip, InfoAlert, InfoTipCard, IntroductionModal, MenuItemInfotip, MenuListItem, PopoverHeader, ThemeProvider, WarningInfotip, useEditable };
|
|
135
|
+
export { EditableField, EllipsisWithTooltip, InfoAlert, InfoTipCard, IntroductionModal, MenuItemInfotip, MenuListItem, PopoverHeader, PopoverMenuList, type PopoverMenuListProps, PopoverScrollableContent, PopoverSearch, StyledMenuList, ThemeProvider, type VirtualizedItem, WarningInfotip, useEditable };
|
package/dist/index.js
CHANGED
|
@@ -38,6 +38,10 @@ __export(index_exports, {
|
|
|
38
38
|
MenuItemInfotip: () => MenuItemInfotip,
|
|
39
39
|
MenuListItem: () => MenuListItem,
|
|
40
40
|
PopoverHeader: () => PopoverHeader,
|
|
41
|
+
PopoverMenuList: () => PopoverMenuList,
|
|
42
|
+
PopoverScrollableContent: () => PopoverScrollableContent,
|
|
43
|
+
PopoverSearch: () => PopoverSearch,
|
|
44
|
+
StyledMenuList: () => StyledMenuList,
|
|
41
45
|
ThemeProvider: () => ThemeProvider,
|
|
42
46
|
WarningInfotip: () => WarningInfotip,
|
|
43
47
|
useEditable: () => useEditable
|
|
@@ -190,22 +194,17 @@ var import_ui6 = require("@elementor/ui");
|
|
|
190
194
|
var React5 = __toESM(require("react"));
|
|
191
195
|
var import_icons = require("@elementor/icons");
|
|
192
196
|
var import_ui5 = require("@elementor/ui");
|
|
193
|
-
var InfoAlert = (
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
{
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
elevation: 0
|
|
205
|
-
},
|
|
206
|
-
/* @__PURE__ */ React5.createElement(import_ui5.Stack, null, /* @__PURE__ */ React5.createElement(import_ui5.Typography, { variant: "caption", color: "text.primary" }, content))
|
|
207
|
-
);
|
|
208
|
-
};
|
|
197
|
+
var InfoAlert = (props) => /* @__PURE__ */ React5.createElement(
|
|
198
|
+
import_ui5.Alert,
|
|
199
|
+
{
|
|
200
|
+
icon: /* @__PURE__ */ React5.createElement(import_icons.InfoCircleFilledIcon, { fontSize: "small", color: "secondary" }),
|
|
201
|
+
variant: "standard",
|
|
202
|
+
color: "secondary",
|
|
203
|
+
elevation: 0,
|
|
204
|
+
size: "small",
|
|
205
|
+
...props
|
|
206
|
+
}
|
|
207
|
+
);
|
|
209
208
|
|
|
210
209
|
// src/components/menu-item.tsx
|
|
211
210
|
var MenuListItem = ({ children, ...props }) => {
|
|
@@ -240,7 +239,7 @@ var MenuItemInfotip = (0, import_react5.forwardRef)(
|
|
|
240
239
|
ref,
|
|
241
240
|
placement: "right",
|
|
242
241
|
arrow: false,
|
|
243
|
-
content: /* @__PURE__ */ React6.createElement(InfoAlert, {
|
|
242
|
+
content: /* @__PURE__ */ React6.createElement(InfoAlert, { sx: { maxWidth: 325 } }, content)
|
|
244
243
|
},
|
|
245
244
|
/* @__PURE__ */ React6.createElement("div", { style: { pointerEvents: "initial", width: "100%" }, onClick: (e) => e.stopPropagation() }, children)
|
|
246
245
|
);
|
|
@@ -274,19 +273,7 @@ var WarningInfotip = (0, import_react6.forwardRef)(
|
|
|
274
273
|
modifiers: offset ? [{ name: "offset", options: { offset } }] : []
|
|
275
274
|
},
|
|
276
275
|
arrow: false,
|
|
277
|
-
content: /* @__PURE__ */ React8.createElement(
|
|
278
|
-
import_ui8.Alert,
|
|
279
|
-
{
|
|
280
|
-
color: "error",
|
|
281
|
-
severity: "warning",
|
|
282
|
-
variant: "standard",
|
|
283
|
-
sx: (theme) => ({
|
|
284
|
-
".MuiAlert-icon": { fontSize: "1.25rem", marginRight: theme.spacing(0.5) }
|
|
285
|
-
})
|
|
286
|
-
},
|
|
287
|
-
title ? /* @__PURE__ */ React8.createElement(import_ui8.AlertTitle, null, title) : null,
|
|
288
|
-
/* @__PURE__ */ React8.createElement(import_ui8.Typography, { variant: "caption", sx: { color: "text.primary" } }, text)
|
|
289
|
-
)
|
|
276
|
+
content: /* @__PURE__ */ React8.createElement(import_ui8.Alert, { color: "error", severity: "warning", variant: "standard", size: "small" }, title ? /* @__PURE__ */ React8.createElement(import_ui8.AlertTitle, null, title) : null, text)
|
|
290
277
|
},
|
|
291
278
|
children
|
|
292
279
|
);
|
|
@@ -299,11 +286,241 @@ var import_ui9 = require("@elementor/ui");
|
|
|
299
286
|
var SIZE = "tiny";
|
|
300
287
|
var PopoverHeader = ({ title, onClose, icon, actions }) => /* @__PURE__ */ React9.createElement(import_ui9.Stack, { direction: "row", alignItems: "center", pl: 1.5, pr: 0.5, py: 1.5, sx: { columnGap: 0.5 } }, icon, /* @__PURE__ */ React9.createElement(import_ui9.Typography, { variant: "subtitle2" }, title), /* @__PURE__ */ React9.createElement(import_ui9.Stack, { direction: "row", sx: { ml: "auto" } }, actions, /* @__PURE__ */ React9.createElement(import_ui9.CloseButton, { slotProps: { icon: { fontSize: SIZE } }, sx: { ml: "auto" }, onClick: onClose })));
|
|
301
288
|
|
|
302
|
-
// src/
|
|
289
|
+
// src/components/popover/menu-list.tsx
|
|
290
|
+
var React11 = __toESM(require("react"));
|
|
291
|
+
var import_react9 = require("react");
|
|
292
|
+
var import_ui11 = require("@elementor/ui");
|
|
293
|
+
var import_react_virtual = require("@tanstack/react-virtual");
|
|
294
|
+
|
|
295
|
+
// src/hooks/use-scroll-to-selected.ts
|
|
303
296
|
var import_react7 = require("react");
|
|
297
|
+
var useScrollToSelected = ({
|
|
298
|
+
selectedValue,
|
|
299
|
+
items,
|
|
300
|
+
virtualizer
|
|
301
|
+
}) => {
|
|
302
|
+
(0, import_react7.useEffect)(() => {
|
|
303
|
+
if (!selectedValue || items.length === 0) {
|
|
304
|
+
return;
|
|
305
|
+
}
|
|
306
|
+
const selectedIndex = items.findIndex((item) => item.value === selectedValue);
|
|
307
|
+
if (selectedIndex !== -1) {
|
|
308
|
+
virtualizer.scrollToIndex(selectedIndex, { align: "center" });
|
|
309
|
+
}
|
|
310
|
+
}, [selectedValue, items, virtualizer]);
|
|
311
|
+
};
|
|
312
|
+
|
|
313
|
+
// src/hooks/use-scroll-top.ts
|
|
314
|
+
var import_react8 = require("react");
|
|
315
|
+
var useScrollTop = ({ containerRef }) => {
|
|
316
|
+
const [scrollTop, setScrollTop] = (0, import_react8.useState)(0);
|
|
317
|
+
(0, import_react8.useEffect)(() => {
|
|
318
|
+
const container = containerRef.current;
|
|
319
|
+
if (!container) {
|
|
320
|
+
return;
|
|
321
|
+
}
|
|
322
|
+
const handleScroll = () => {
|
|
323
|
+
setScrollTop(container.scrollTop);
|
|
324
|
+
};
|
|
325
|
+
container.addEventListener("scroll", handleScroll);
|
|
326
|
+
return () => container.removeEventListener("scroll", handleScroll);
|
|
327
|
+
}, [containerRef]);
|
|
328
|
+
return scrollTop;
|
|
329
|
+
};
|
|
330
|
+
|
|
331
|
+
// src/components/popover/scrollable-content.tsx
|
|
332
|
+
var React10 = __toESM(require("react"));
|
|
333
|
+
var import_ui10 = require("@elementor/ui");
|
|
334
|
+
var PopoverScrollableContent = React10.forwardRef(
|
|
335
|
+
({ children, height = 260 }, ref) => {
|
|
336
|
+
return /* @__PURE__ */ React10.createElement(import_ui10.Box, { ref, sx: { overflowY: "auto", height, width: 220 } }, children);
|
|
337
|
+
}
|
|
338
|
+
);
|
|
339
|
+
|
|
340
|
+
// src/components/popover/menu-list.tsx
|
|
341
|
+
var ITEM_HEIGHT = 32;
|
|
342
|
+
var LIST_ITEMS_BUFFER = 6;
|
|
343
|
+
var MENU_LIST_PADDING_TOP = 8;
|
|
344
|
+
var menuSubHeaderAbsoluteStyling = (start) => ({
|
|
345
|
+
position: "absolute",
|
|
346
|
+
transform: `translateY(${start + MENU_LIST_PADDING_TOP}px)`
|
|
347
|
+
});
|
|
348
|
+
var PopoverMenuList = ({
|
|
349
|
+
items,
|
|
350
|
+
onSelect,
|
|
351
|
+
onClose,
|
|
352
|
+
selectedValue,
|
|
353
|
+
itemStyle,
|
|
354
|
+
onChange,
|
|
355
|
+
"data-testid": dataTestId,
|
|
356
|
+
menuItemContentTemplate,
|
|
357
|
+
noResultsComponent,
|
|
358
|
+
menuListTemplate: CustomMenuList
|
|
359
|
+
}) => {
|
|
360
|
+
const containerRef = (0, import_react9.useRef)(null);
|
|
361
|
+
const scrollTop = useScrollTop({ containerRef });
|
|
362
|
+
const MenuListComponent = CustomMenuList || StyledMenuList;
|
|
363
|
+
const stickyIndices = (0, import_react9.useMemo)(
|
|
364
|
+
() => items.reduce((categoryIndices, item, index) => {
|
|
365
|
+
if (item.type === "category") {
|
|
366
|
+
categoryIndices.push(index);
|
|
367
|
+
}
|
|
368
|
+
return categoryIndices;
|
|
369
|
+
}, []),
|
|
370
|
+
[items]
|
|
371
|
+
);
|
|
372
|
+
const getActiveItemIndices = (range) => {
|
|
373
|
+
const visibleAndStickyIndexes = [];
|
|
374
|
+
for (let i = range.startIndex; i <= range.endIndex; i++) {
|
|
375
|
+
visibleAndStickyIndexes.push(i);
|
|
376
|
+
}
|
|
377
|
+
stickyIndices.forEach((stickyIndex) => {
|
|
378
|
+
if (!visibleAndStickyIndexes.includes(stickyIndex)) {
|
|
379
|
+
visibleAndStickyIndexes.push(stickyIndex);
|
|
380
|
+
}
|
|
381
|
+
});
|
|
382
|
+
return visibleAndStickyIndexes.sort((a, b) => a - b);
|
|
383
|
+
};
|
|
384
|
+
const virtualizer = (0, import_react_virtual.useVirtualizer)({
|
|
385
|
+
count: items.length,
|
|
386
|
+
getScrollElement: () => containerRef.current,
|
|
387
|
+
estimateSize: () => ITEM_HEIGHT,
|
|
388
|
+
overscan: LIST_ITEMS_BUFFER,
|
|
389
|
+
rangeExtractor: getActiveItemIndices,
|
|
390
|
+
onChange
|
|
391
|
+
});
|
|
392
|
+
useScrollToSelected({ selectedValue, items, virtualizer });
|
|
393
|
+
return /* @__PURE__ */ React11.createElement(PopoverScrollableContent, { ref: containerRef }, items.length === 0 && noResultsComponent ? noResultsComponent : /* @__PURE__ */ React11.createElement(
|
|
394
|
+
MenuListComponent,
|
|
395
|
+
{
|
|
396
|
+
role: "listbox",
|
|
397
|
+
style: { height: `${virtualizer.getTotalSize()}px` },
|
|
398
|
+
"data-testid": dataTestId
|
|
399
|
+
},
|
|
400
|
+
virtualizer.getVirtualItems().map((virtualRow) => {
|
|
401
|
+
const item = items[virtualRow.index];
|
|
402
|
+
const isLast = virtualRow.index === items.length - 1;
|
|
403
|
+
const isFirst = items[0]?.type === "category" ? virtualRow.index === 1 : virtualRow.index === 0;
|
|
404
|
+
const isSelected = selectedValue === item.value;
|
|
405
|
+
const tabIndexFallback = !selectedValue ? 0 : -1;
|
|
406
|
+
if (!item) {
|
|
407
|
+
return null;
|
|
408
|
+
}
|
|
409
|
+
if (item.type === "category") {
|
|
410
|
+
const shouldStick = virtualRow.start + MENU_LIST_PADDING_TOP <= scrollTop;
|
|
411
|
+
return /* @__PURE__ */ React11.createElement(
|
|
412
|
+
import_ui11.MenuSubheader,
|
|
413
|
+
{
|
|
414
|
+
key: virtualRow.key,
|
|
415
|
+
style: shouldStick ? {} : menuSubHeaderAbsoluteStyling(virtualRow.start)
|
|
416
|
+
},
|
|
417
|
+
item.label || item.value
|
|
418
|
+
);
|
|
419
|
+
}
|
|
420
|
+
return /* @__PURE__ */ React11.createElement(
|
|
421
|
+
"li",
|
|
422
|
+
{
|
|
423
|
+
key: virtualRow.key,
|
|
424
|
+
role: "option",
|
|
425
|
+
"aria-selected": isSelected,
|
|
426
|
+
onClick: (e) => {
|
|
427
|
+
if (e.target.closest("button")) {
|
|
428
|
+
return;
|
|
429
|
+
}
|
|
430
|
+
onSelect(item.value);
|
|
431
|
+
onClose();
|
|
432
|
+
},
|
|
433
|
+
onKeyDown: (event) => {
|
|
434
|
+
if (event.key === "Enter") {
|
|
435
|
+
onSelect(item.value);
|
|
436
|
+
onClose();
|
|
437
|
+
}
|
|
438
|
+
if (event.key === "ArrowDown" && isLast) {
|
|
439
|
+
event.preventDefault();
|
|
440
|
+
event.stopPropagation();
|
|
441
|
+
}
|
|
442
|
+
if (event.key === "ArrowUp" && isFirst) {
|
|
443
|
+
event.preventDefault();
|
|
444
|
+
event.stopPropagation();
|
|
445
|
+
}
|
|
446
|
+
},
|
|
447
|
+
tabIndex: isSelected ? 0 : tabIndexFallback,
|
|
448
|
+
style: {
|
|
449
|
+
transform: `translateY(${virtualRow.start + MENU_LIST_PADDING_TOP}px)`,
|
|
450
|
+
...itemStyle ? itemStyle(item) : {}
|
|
451
|
+
}
|
|
452
|
+
},
|
|
453
|
+
menuItemContentTemplate ? menuItemContentTemplate(item) : item.label || item.value
|
|
454
|
+
);
|
|
455
|
+
})
|
|
456
|
+
));
|
|
457
|
+
};
|
|
458
|
+
var StyledMenuList = (0, import_ui11.styled)(import_ui11.MenuList)(({ theme }) => ({
|
|
459
|
+
"& > li": {
|
|
460
|
+
height: ITEM_HEIGHT,
|
|
461
|
+
width: "100%",
|
|
462
|
+
display: "flex",
|
|
463
|
+
alignItems: "center"
|
|
464
|
+
},
|
|
465
|
+
'& > [role="option"]': {
|
|
466
|
+
...theme.typography.caption,
|
|
467
|
+
lineHeight: "inherit",
|
|
468
|
+
padding: theme.spacing(0.75, 2, 0.75, 4),
|
|
469
|
+
"&:hover, &:focus": {
|
|
470
|
+
backgroundColor: theme.palette.action.hover
|
|
471
|
+
},
|
|
472
|
+
'&[aria-selected="true"]': {
|
|
473
|
+
backgroundColor: theme.palette.action.selected
|
|
474
|
+
},
|
|
475
|
+
cursor: "pointer",
|
|
476
|
+
textOverflow: "ellipsis",
|
|
477
|
+
position: "absolute",
|
|
478
|
+
top: 0,
|
|
479
|
+
left: 0
|
|
480
|
+
},
|
|
481
|
+
width: "100%",
|
|
482
|
+
position: "relative"
|
|
483
|
+
}));
|
|
484
|
+
|
|
485
|
+
// src/components/popover/search.tsx
|
|
486
|
+
var React12 = __toESM(require("react"));
|
|
487
|
+
var import_react10 = require("react");
|
|
488
|
+
var import_icons2 = require("@elementor/icons");
|
|
489
|
+
var import_ui12 = require("@elementor/ui");
|
|
490
|
+
var import_i18n2 = require("@wordpress/i18n");
|
|
491
|
+
var SIZE2 = "tiny";
|
|
492
|
+
var PopoverSearch = ({ value, onSearch, placeholder }) => {
|
|
493
|
+
const inputRef = (0, import_react10.useRef)(null);
|
|
494
|
+
const handleClear = () => {
|
|
495
|
+
onSearch("");
|
|
496
|
+
inputRef.current?.focus();
|
|
497
|
+
};
|
|
498
|
+
const handleInputChange = (event) => {
|
|
499
|
+
onSearch(event.target.value);
|
|
500
|
+
};
|
|
501
|
+
return /* @__PURE__ */ React12.createElement(import_ui12.Box, { px: 1.5, pb: 1 }, /* @__PURE__ */ React12.createElement(
|
|
502
|
+
import_ui12.TextField,
|
|
503
|
+
{
|
|
504
|
+
autoFocus: true,
|
|
505
|
+
fullWidth: true,
|
|
506
|
+
size: SIZE2,
|
|
507
|
+
value,
|
|
508
|
+
inputRef,
|
|
509
|
+
onChange: handleInputChange,
|
|
510
|
+
placeholder,
|
|
511
|
+
InputProps: {
|
|
512
|
+
startAdornment: /* @__PURE__ */ React12.createElement(import_ui12.InputAdornment, { position: "start" }, /* @__PURE__ */ React12.createElement(import_icons2.SearchIcon, { fontSize: SIZE2 })),
|
|
513
|
+
endAdornment: value && /* @__PURE__ */ React12.createElement(import_ui12.IconButton, { size: SIZE2, onClick: handleClear, "aria-label": (0, import_i18n2.__)("Clear", "elementor") }, /* @__PURE__ */ React12.createElement(import_icons2.XIcon, { color: "action", fontSize: SIZE2 }))
|
|
514
|
+
}
|
|
515
|
+
}
|
|
516
|
+
));
|
|
517
|
+
};
|
|
518
|
+
|
|
519
|
+
// src/hooks/use-editable.ts
|
|
520
|
+
var import_react11 = require("react");
|
|
304
521
|
var useEditable = ({ value, onSubmit, validation, onClick, onError }) => {
|
|
305
|
-
const [isEditing, setIsEditing] = (0,
|
|
306
|
-
const [error, setError] = (0,
|
|
522
|
+
const [isEditing, setIsEditing] = (0, import_react11.useState)(false);
|
|
523
|
+
const [error, setError] = (0, import_react11.useState)(null);
|
|
307
524
|
const ref = useSelection(isEditing);
|
|
308
525
|
const isDirty = (newValue) => newValue !== value;
|
|
309
526
|
const openEditMode = () => {
|
|
@@ -376,8 +593,8 @@ var useEditable = ({ value, onSubmit, validation, onClick, onError }) => {
|
|
|
376
593
|
};
|
|
377
594
|
};
|
|
378
595
|
var useSelection = (isEditing) => {
|
|
379
|
-
const ref = (0,
|
|
380
|
-
(0,
|
|
596
|
+
const ref = (0, import_react11.useRef)(null);
|
|
597
|
+
(0, import_react11.useEffect)(() => {
|
|
381
598
|
if (isEditing) {
|
|
382
599
|
selectAll(ref.current);
|
|
383
600
|
}
|
|
@@ -404,6 +621,10 @@ var selectAll = (el) => {
|
|
|
404
621
|
MenuItemInfotip,
|
|
405
622
|
MenuListItem,
|
|
406
623
|
PopoverHeader,
|
|
624
|
+
PopoverMenuList,
|
|
625
|
+
PopoverScrollableContent,
|
|
626
|
+
PopoverSearch,
|
|
627
|
+
StyledMenuList,
|
|
407
628
|
ThemeProvider,
|
|
408
629
|
WarningInfotip,
|
|
409
630
|
useEditable
|