@elementor/editor-ui 0.10.1 → 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 +19 -0
- package/dist/index.d.mts +52 -6
- package/dist/index.d.ts +52 -6
- package/dist/index.js +264 -35
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +263 -39
- 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/header.tsx +25 -0
- 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 -0
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
|
-
[
|
|
14
|
-
[
|
|
15
|
-
[
|
|
16
|
-
[
|
|
17
|
-
[
|
|
18
|
-
[
|
|
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,24 @@
|
|
|
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
|
+
|
|
16
|
+
## 0.11.0
|
|
17
|
+
|
|
18
|
+
### Minor Changes
|
|
19
|
+
|
|
20
|
+
- 80dbf43: Extract popover headers to a standalone component inside the Editor UI package.
|
|
21
|
+
|
|
3
22
|
## 0.10.1
|
|
4
23
|
|
|
5
24
|
### Patch 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;
|
|
@@ -60,6 +58,54 @@ interface WarningInfotipProps extends PropsWithChildren {
|
|
|
60
58
|
}
|
|
61
59
|
declare const WarningInfotip: React$1.ForwardRefExoticComponent<WarningInfotipProps & React$1.RefAttributes<unknown>>;
|
|
62
60
|
|
|
61
|
+
type PopoverHeaderProps = {
|
|
62
|
+
title: string;
|
|
63
|
+
onClose: () => void;
|
|
64
|
+
icon?: React$1.ReactNode;
|
|
65
|
+
actions?: React$1.ReactNode[];
|
|
66
|
+
};
|
|
67
|
+
declare const PopoverHeader: ({ title, onClose, icon, actions }: PopoverHeaderProps) => React$1.JSX.Element;
|
|
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
|
+
|
|
63
109
|
type UseEditableParams = {
|
|
64
110
|
value: string;
|
|
65
111
|
onSubmit: (value: string) => unknown;
|
|
@@ -86,4 +132,4 @@ declare const useEditable: ({ value, onSubmit, validation, onClick, onError }: U
|
|
|
86
132
|
};
|
|
87
133
|
};
|
|
88
134
|
|
|
89
|
-
export { EditableField, EllipsisWithTooltip, InfoAlert, InfoTipCard, IntroductionModal, MenuItemInfotip, MenuListItem, 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;
|
|
@@ -60,6 +58,54 @@ interface WarningInfotipProps extends PropsWithChildren {
|
|
|
60
58
|
}
|
|
61
59
|
declare const WarningInfotip: React$1.ForwardRefExoticComponent<WarningInfotipProps & React$1.RefAttributes<unknown>>;
|
|
62
60
|
|
|
61
|
+
type PopoverHeaderProps = {
|
|
62
|
+
title: string;
|
|
63
|
+
onClose: () => void;
|
|
64
|
+
icon?: React$1.ReactNode;
|
|
65
|
+
actions?: React$1.ReactNode[];
|
|
66
|
+
};
|
|
67
|
+
declare const PopoverHeader: ({ title, onClose, icon, actions }: PopoverHeaderProps) => React$1.JSX.Element;
|
|
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
|
+
|
|
63
109
|
type UseEditableParams = {
|
|
64
110
|
value: string;
|
|
65
111
|
onSubmit: (value: string) => unknown;
|
|
@@ -86,4 +132,4 @@ declare const useEditable: ({ value, onSubmit, validation, onClick, onError }: U
|
|
|
86
132
|
};
|
|
87
133
|
};
|
|
88
134
|
|
|
89
|
-
export { EditableField, EllipsisWithTooltip, InfoAlert, InfoTipCard, IntroductionModal, MenuItemInfotip, MenuListItem, 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
|
@@ -37,6 +37,11 @@ __export(index_exports, {
|
|
|
37
37
|
IntroductionModal: () => IntroductionModal,
|
|
38
38
|
MenuItemInfotip: () => MenuItemInfotip,
|
|
39
39
|
MenuListItem: () => MenuListItem,
|
|
40
|
+
PopoverHeader: () => PopoverHeader,
|
|
41
|
+
PopoverMenuList: () => PopoverMenuList,
|
|
42
|
+
PopoverScrollableContent: () => PopoverScrollableContent,
|
|
43
|
+
PopoverSearch: () => PopoverSearch,
|
|
44
|
+
StyledMenuList: () => StyledMenuList,
|
|
40
45
|
ThemeProvider: () => ThemeProvider,
|
|
41
46
|
WarningInfotip: () => WarningInfotip,
|
|
42
47
|
useEditable: () => useEditable
|
|
@@ -189,22 +194,17 @@ var import_ui6 = require("@elementor/ui");
|
|
|
189
194
|
var React5 = __toESM(require("react"));
|
|
190
195
|
var import_icons = require("@elementor/icons");
|
|
191
196
|
var import_ui5 = require("@elementor/ui");
|
|
192
|
-
var InfoAlert = (
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
{
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
elevation: 0
|
|
204
|
-
},
|
|
205
|
-
/* @__PURE__ */ React5.createElement(import_ui5.Stack, null, /* @__PURE__ */ React5.createElement(import_ui5.Typography, { variant: "caption", color: "text.primary" }, content))
|
|
206
|
-
);
|
|
207
|
-
};
|
|
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
|
+
);
|
|
208
208
|
|
|
209
209
|
// src/components/menu-item.tsx
|
|
210
210
|
var MenuListItem = ({ children, ...props }) => {
|
|
@@ -239,7 +239,7 @@ var MenuItemInfotip = (0, import_react5.forwardRef)(
|
|
|
239
239
|
ref,
|
|
240
240
|
placement: "right",
|
|
241
241
|
arrow: false,
|
|
242
|
-
content: /* @__PURE__ */ React6.createElement(InfoAlert, {
|
|
242
|
+
content: /* @__PURE__ */ React6.createElement(InfoAlert, { sx: { maxWidth: 325 } }, content)
|
|
243
243
|
},
|
|
244
244
|
/* @__PURE__ */ React6.createElement("div", { style: { pointerEvents: "initial", width: "100%" }, onClick: (e) => e.stopPropagation() }, children)
|
|
245
245
|
);
|
|
@@ -273,30 +273,254 @@ var WarningInfotip = (0, import_react6.forwardRef)(
|
|
|
273
273
|
modifiers: offset ? [{ name: "offset", options: { offset } }] : []
|
|
274
274
|
},
|
|
275
275
|
arrow: false,
|
|
276
|
-
content: /* @__PURE__ */ React8.createElement(
|
|
277
|
-
import_ui8.Alert,
|
|
278
|
-
{
|
|
279
|
-
color: "error",
|
|
280
|
-
severity: "warning",
|
|
281
|
-
variant: "standard",
|
|
282
|
-
sx: (theme) => ({
|
|
283
|
-
".MuiAlert-icon": { fontSize: "1.25rem", marginRight: theme.spacing(0.5) }
|
|
284
|
-
})
|
|
285
|
-
},
|
|
286
|
-
title ? /* @__PURE__ */ React8.createElement(import_ui8.AlertTitle, null, title) : null,
|
|
287
|
-
/* @__PURE__ */ React8.createElement(import_ui8.Typography, { variant: "caption", sx: { color: "text.primary" } }, text)
|
|
288
|
-
)
|
|
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)
|
|
289
277
|
},
|
|
290
278
|
children
|
|
291
279
|
);
|
|
292
280
|
}
|
|
293
281
|
);
|
|
294
282
|
|
|
295
|
-
// src/
|
|
283
|
+
// src/components/popover/header.tsx
|
|
284
|
+
var React9 = __toESM(require("react"));
|
|
285
|
+
var import_ui9 = require("@elementor/ui");
|
|
286
|
+
var SIZE = "tiny";
|
|
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 })));
|
|
288
|
+
|
|
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
|
|
296
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");
|
|
297
521
|
var useEditable = ({ value, onSubmit, validation, onClick, onError }) => {
|
|
298
|
-
const [isEditing, setIsEditing] = (0,
|
|
299
|
-
const [error, setError] = (0,
|
|
522
|
+
const [isEditing, setIsEditing] = (0, import_react11.useState)(false);
|
|
523
|
+
const [error, setError] = (0, import_react11.useState)(null);
|
|
300
524
|
const ref = useSelection(isEditing);
|
|
301
525
|
const isDirty = (newValue) => newValue !== value;
|
|
302
526
|
const openEditMode = () => {
|
|
@@ -369,8 +593,8 @@ var useEditable = ({ value, onSubmit, validation, onClick, onError }) => {
|
|
|
369
593
|
};
|
|
370
594
|
};
|
|
371
595
|
var useSelection = (isEditing) => {
|
|
372
|
-
const ref = (0,
|
|
373
|
-
(0,
|
|
596
|
+
const ref = (0, import_react11.useRef)(null);
|
|
597
|
+
(0, import_react11.useEffect)(() => {
|
|
374
598
|
if (isEditing) {
|
|
375
599
|
selectAll(ref.current);
|
|
376
600
|
}
|
|
@@ -396,6 +620,11 @@ var selectAll = (el) => {
|
|
|
396
620
|
IntroductionModal,
|
|
397
621
|
MenuItemInfotip,
|
|
398
622
|
MenuListItem,
|
|
623
|
+
PopoverHeader,
|
|
624
|
+
PopoverMenuList,
|
|
625
|
+
PopoverScrollableContent,
|
|
626
|
+
PopoverSearch,
|
|
627
|
+
StyledMenuList,
|
|
399
628
|
ThemeProvider,
|
|
400
629
|
WarningInfotip,
|
|
401
630
|
useEditable
|