@elementor/editor-ui 4.0.0-499 → 4.0.0-501

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
@@ -1,7 +1,7 @@
1
1
  import * as _emotion_styled from '@emotion/styled';
2
2
  import * as _mui_system from '@mui/system';
3
3
  import * as React$1 from 'react';
4
- import { ReactNode, PropsWithChildren, ReactElement } from 'react';
4
+ import { ReactNode, PropsWithChildren, ReactElement, ComponentProps, RefObject } from 'react';
5
5
  import * as _mui_material from '@mui/material';
6
6
  import { MenuItemProps, MenuItemTextProps, TypographyProps, AlertProps, InfotipProps, BoxProps, ButtonProps, MenuList, DialogProps, DialogContentTextProps } from '@elementor/ui';
7
7
 
@@ -132,6 +132,8 @@ type PopoverBodyProps = PropsWithChildren<{
132
132
  }>;
133
133
  declare const PopoverBody: ({ children, height, width, id }: PopoverBodyProps) => React$1.JSX.Element;
134
134
 
135
+ declare const SectionPopoverBody: (props: ComponentProps<typeof PopoverBody>) => React$1.JSX.Element;
136
+
135
137
  type PopoverHeaderProps = {
136
138
  title: React$1.ReactNode;
137
139
  onClose: () => void;
@@ -209,6 +211,9 @@ type ConfirmationDialogActionsProps = {
209
211
  confirmLabel?: string;
210
212
  };
211
213
 
214
+ declare const SectionRefContext: React$1.Context<RefObject<HTMLElement> | null>;
215
+ declare const useSectionWidth: () => number;
216
+
212
217
  type UseEditableParams = {
213
218
  value: string;
214
219
  onSubmit: (value: string) => unknown;
@@ -235,4 +240,4 @@ declare const useEditable: ({ value, onSubmit, validation, onClick, onError }: U
235
240
  };
236
241
  };
237
242
 
238
- export { CollapseIcon, ConfirmationDialog, CtaButton, EditableField, EllipsisWithTooltip, Form, GlobalDialog, ITEM_HEIGHT, InfoAlert, InfoTipCard, IntroductionModal, MenuItemInfotip, MenuListItem, PopoverBody, PopoverHeader, PopoverMenuList, type PopoverMenuListProps, PromotionChip, PromotionInfotip, PromotionPopover, SaveChangesDialog, SearchField, StyledMenuList, ThemeProvider, type VirtualizedItem, WarningInfotip, closeDialog, openDialog, useDialog, useEditable };
243
+ export { CollapseIcon, ConfirmationDialog, CtaButton, EditableField, EllipsisWithTooltip, Form, GlobalDialog, ITEM_HEIGHT, InfoAlert, InfoTipCard, IntroductionModal, MenuItemInfotip, MenuListItem, PopoverBody, PopoverHeader, PopoverMenuList, type PopoverMenuListProps, PromotionChip, PromotionInfotip, PromotionPopover, SaveChangesDialog, SearchField, SectionPopoverBody, SectionRefContext, StyledMenuList, ThemeProvider, type VirtualizedItem, WarningInfotip, closeDialog, openDialog, useDialog, useEditable, useSectionWidth };
package/dist/index.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import * as _emotion_styled from '@emotion/styled';
2
2
  import * as _mui_system from '@mui/system';
3
3
  import * as React$1 from 'react';
4
- import { ReactNode, PropsWithChildren, ReactElement } from 'react';
4
+ import { ReactNode, PropsWithChildren, ReactElement, ComponentProps, RefObject } from 'react';
5
5
  import * as _mui_material from '@mui/material';
6
6
  import { MenuItemProps, MenuItemTextProps, TypographyProps, AlertProps, InfotipProps, BoxProps, ButtonProps, MenuList, DialogProps, DialogContentTextProps } from '@elementor/ui';
7
7
 
@@ -132,6 +132,8 @@ type PopoverBodyProps = PropsWithChildren<{
132
132
  }>;
133
133
  declare const PopoverBody: ({ children, height, width, id }: PopoverBodyProps) => React$1.JSX.Element;
134
134
 
135
+ declare const SectionPopoverBody: (props: ComponentProps<typeof PopoverBody>) => React$1.JSX.Element;
136
+
135
137
  type PopoverHeaderProps = {
136
138
  title: React$1.ReactNode;
137
139
  onClose: () => void;
@@ -209,6 +211,9 @@ type ConfirmationDialogActionsProps = {
209
211
  confirmLabel?: string;
210
212
  };
211
213
 
214
+ declare const SectionRefContext: React$1.Context<RefObject<HTMLElement> | null>;
215
+ declare const useSectionWidth: () => number;
216
+
212
217
  type UseEditableParams = {
213
218
  value: string;
214
219
  onSubmit: (value: string) => unknown;
@@ -235,4 +240,4 @@ declare const useEditable: ({ value, onSubmit, validation, onClick, onError }: U
235
240
  };
236
241
  };
237
242
 
238
- export { CollapseIcon, ConfirmationDialog, CtaButton, EditableField, EllipsisWithTooltip, Form, GlobalDialog, ITEM_HEIGHT, InfoAlert, InfoTipCard, IntroductionModal, MenuItemInfotip, MenuListItem, PopoverBody, PopoverHeader, PopoverMenuList, type PopoverMenuListProps, PromotionChip, PromotionInfotip, PromotionPopover, SaveChangesDialog, SearchField, StyledMenuList, ThemeProvider, type VirtualizedItem, WarningInfotip, closeDialog, openDialog, useDialog, useEditable };
243
+ export { CollapseIcon, ConfirmationDialog, CtaButton, EditableField, EllipsisWithTooltip, Form, GlobalDialog, ITEM_HEIGHT, InfoAlert, InfoTipCard, IntroductionModal, MenuItemInfotip, MenuListItem, PopoverBody, PopoverHeader, PopoverMenuList, type PopoverMenuListProps, PromotionChip, PromotionInfotip, PromotionPopover, SaveChangesDialog, SearchField, SectionPopoverBody, SectionRefContext, StyledMenuList, ThemeProvider, type VirtualizedItem, WarningInfotip, closeDialog, openDialog, useDialog, useEditable, useSectionWidth };
package/dist/index.js CHANGED
@@ -51,13 +51,16 @@ __export(index_exports, {
51
51
  PromotionPopover: () => PromotionPopover,
52
52
  SaveChangesDialog: () => SaveChangesDialog,
53
53
  SearchField: () => SearchField,
54
+ SectionPopoverBody: () => SectionPopoverBody,
55
+ SectionRefContext: () => SectionRefContext,
54
56
  StyledMenuList: () => StyledMenuList,
55
57
  ThemeProvider: () => ThemeProvider,
56
58
  WarningInfotip: () => WarningInfotip,
57
59
  closeDialog: () => closeDialog,
58
60
  openDialog: () => openDialog,
59
61
  useDialog: () => useDialog,
60
- useEditable: () => useEditable
62
+ useEditable: () => useEditable,
63
+ useSectionWidth: () => useSectionWidth
61
64
  });
62
65
  module.exports = __toCommonJS(index_exports);
63
66
 
@@ -601,8 +604,27 @@ var PopoverBody = ({ children, height = DEFAULT_POPOVER_HEIGHT, width, id }) =>
601
604
  );
602
605
  };
603
606
 
604
- // src/components/popover/header.tsx
607
+ // src/components/popover/section-popover-body.tsx
605
608
  var React17 = __toESM(require("react"));
609
+
610
+ // src/contexts/section-context.tsx
611
+ var import_react11 = require("react");
612
+ var FALLBACK_SECTION_WIDTH = 320;
613
+ var SectionRefContext = (0, import_react11.createContext)(null);
614
+ var useSectionRef = () => (0, import_react11.useContext)(SectionRefContext);
615
+ var useSectionWidth = () => {
616
+ const sectionRef = useSectionRef();
617
+ return sectionRef?.current?.offsetWidth ?? FALLBACK_SECTION_WIDTH;
618
+ };
619
+
620
+ // src/components/popover/section-popover-body.tsx
621
+ var SectionPopoverBody = (props) => {
622
+ const sectionWidth = useSectionWidth();
623
+ return /* @__PURE__ */ React17.createElement(PopoverBody, { ...props, width: sectionWidth });
624
+ };
625
+
626
+ // src/components/popover/header.tsx
627
+ var React18 = __toESM(require("react"));
606
628
  var import_ui17 = require("@elementor/ui");
607
629
  var SIZE2 = "tiny";
608
630
  var PopoverHeader = ({ title, onClose, icon, actions }) => {
@@ -612,23 +634,23 @@ var PopoverHeader = ({ title, onClose, icon, actions }) => {
612
634
  py: 1.5,
613
635
  maxHeight: 36
614
636
  };
615
- return /* @__PURE__ */ React17.createElement(import_ui17.Stack, { direction: "row", alignItems: "center", ...paddingAndSizing, sx: { columnGap: 0.5 } }, icon, /* @__PURE__ */ React17.createElement(import_ui17.Typography, { variant: "subtitle2", sx: { fontSize: "12px", mt: 0.25 } }, title), /* @__PURE__ */ React17.createElement(import_ui17.Stack, { direction: "row", sx: { ml: "auto" } }, actions, /* @__PURE__ */ React17.createElement(import_ui17.CloseButton, { slotProps: { icon: { fontSize: SIZE2 } }, sx: { ml: "auto" }, onClick: onClose })));
637
+ return /* @__PURE__ */ React18.createElement(import_ui17.Stack, { direction: "row", alignItems: "center", ...paddingAndSizing, sx: { columnGap: 0.5 } }, icon, /* @__PURE__ */ React18.createElement(import_ui17.Typography, { variant: "subtitle2", sx: { fontSize: "12px", mt: 0.25 } }, title), /* @__PURE__ */ React18.createElement(import_ui17.Stack, { direction: "row", sx: { ml: "auto" } }, actions, /* @__PURE__ */ React18.createElement(import_ui17.CloseButton, { slotProps: { icon: { fontSize: SIZE2 } }, sx: { ml: "auto" }, onClick: onClose })));
616
638
  };
617
639
 
618
640
  // src/components/popover/menu-list.tsx
619
- var React18 = __toESM(require("react"));
620
- var import_react13 = require("react");
641
+ var React19 = __toESM(require("react"));
642
+ var import_react14 = require("react");
621
643
  var import_ui18 = require("@elementor/ui");
622
644
  var import_react_virtual = require("@tanstack/react-virtual");
623
645
 
624
646
  // src/hooks/use-scroll-to-selected.ts
625
- var import_react11 = require("react");
647
+ var import_react12 = require("react");
626
648
  var useScrollToSelected = ({
627
649
  selectedValue,
628
650
  items,
629
651
  virtualizer
630
652
  }) => {
631
- (0, import_react11.useEffect)(() => {
653
+ (0, import_react12.useEffect)(() => {
632
654
  if (!selectedValue || items.length === 0) {
633
655
  return;
634
656
  }
@@ -640,10 +662,10 @@ var useScrollToSelected = ({
640
662
  };
641
663
 
642
664
  // src/hooks/use-scroll-top.ts
643
- var import_react12 = require("react");
665
+ var import_react13 = require("react");
644
666
  var useScrollTop = ({ containerRef }) => {
645
- const [scrollTop, setScrollTop] = (0, import_react12.useState)(0);
646
- (0, import_react12.useEffect)(() => {
667
+ const [scrollTop, setScrollTop] = (0, import_react13.useState)(0);
668
+ (0, import_react13.useEffect)(() => {
647
669
  const container = containerRef.current;
648
670
  if (!container) {
649
671
  return;
@@ -683,11 +705,11 @@ var PopoverMenuList = ({
683
705
  noResultsComponent,
684
706
  menuListTemplate: CustomMenuList
685
707
  }) => {
686
- const containerRef = (0, import_react13.useRef)(null);
708
+ const containerRef = (0, import_react14.useRef)(null);
687
709
  const scrollTop = useScrollTop({ containerRef });
688
710
  const theme = (0, import_ui18.useTheme)();
689
711
  const MenuListComponent = CustomMenuList || StyledMenuList;
690
- const stickyIndices = (0, import_react13.useMemo)(
712
+ const stickyIndices = (0, import_react14.useMemo)(
691
713
  () => items.reduce((categoryIndices, item, index) => {
692
714
  if (item.type === "category") {
693
715
  categoryIndices.push(index);
@@ -721,12 +743,12 @@ var PopoverMenuList = ({
721
743
  rangeExtractor: getActiveItemIndices,
722
744
  onChange: onChangeCallback
723
745
  });
724
- (0, import_react13.useEffect)(() => {
746
+ (0, import_react14.useEffect)(() => {
725
747
  onChangeCallback(virtualizer);
726
748
  }, [items]);
727
749
  useScrollToSelected({ selectedValue, items, virtualizer });
728
750
  const virtualItems = virtualizer.getVirtualItems();
729
- return /* @__PURE__ */ React18.createElement(import_ui18.Box, { ref: containerRef, sx: { height: "100%", overflowY: "auto" } }, items.length === 0 && noResultsComponent ? noResultsComponent : /* @__PURE__ */ React18.createElement(
751
+ return /* @__PURE__ */ React19.createElement(import_ui18.Box, { ref: containerRef, sx: { height: "100%", overflowY: "auto" } }, items.length === 0 && noResultsComponent ? noResultsComponent : /* @__PURE__ */ React19.createElement(
730
752
  MenuListComponent,
731
753
  {
732
754
  role: "listbox",
@@ -744,7 +766,7 @@ var PopoverMenuList = ({
744
766
  }
745
767
  if (item.type === "category") {
746
768
  const shouldStick = virtualRow.start + MENU_LIST_PADDING_TOP <= scrollTop;
747
- return /* @__PURE__ */ React18.createElement(
769
+ return /* @__PURE__ */ React19.createElement(
748
770
  import_ui18.MenuSubheader,
749
771
  {
750
772
  key: virtualRow.key,
@@ -755,7 +777,7 @@ var PopoverMenuList = ({
755
777
  );
756
778
  }
757
779
  const isDisabled = item.disabled;
758
- return /* @__PURE__ */ React18.createElement(
780
+ return /* @__PURE__ */ React19.createElement(
759
781
  import_ui18.ListItem,
760
782
  {
761
783
  key: virtualRow.key,
@@ -825,13 +847,13 @@ var StyledMenuList = (0, import_ui18.styled)(import_ui18.MenuList)(({ theme }) =
825
847
  }));
826
848
 
827
849
  // src/components/save-changes-dialog.tsx
828
- var React19 = __toESM(require("react"));
829
- var import_react14 = require("react");
850
+ var React20 = __toESM(require("react"));
851
+ var import_react15 = require("react");
830
852
  var import_icons7 = require("@elementor/icons");
831
853
  var import_ui19 = require("@elementor/ui");
832
854
  var TITLE_ID = "save-changes-dialog";
833
- var SaveChangesDialog = ({ children, onClose }) => /* @__PURE__ */ React19.createElement(import_ui19.Dialog, { open: true, onClose, "aria-labelledby": TITLE_ID, maxWidth: "xs" }, children);
834
- var SaveChangesDialogTitle = ({ children, onClose }) => /* @__PURE__ */ React19.createElement(
855
+ var SaveChangesDialog = ({ children, onClose }) => /* @__PURE__ */ React20.createElement(import_ui19.Dialog, { open: true, onClose, "aria-labelledby": TITLE_ID, maxWidth: "xs" }, children);
856
+ var SaveChangesDialogTitle = ({ children, onClose }) => /* @__PURE__ */ React20.createElement(
835
857
  import_ui19.DialogTitle,
836
858
  {
837
859
  id: TITLE_ID,
@@ -840,58 +862,58 @@ var SaveChangesDialogTitle = ({ children, onClose }) => /* @__PURE__ */ React19.
840
862
  gap: 1,
841
863
  sx: { lineHeight: 1, justifyContent: "space-between" }
842
864
  },
843
- /* @__PURE__ */ React19.createElement(import_ui19.Stack, { direction: "row", alignItems: "center", gap: 1 }, /* @__PURE__ */ React19.createElement(import_icons7.AlertTriangleFilledIcon, { color: "secondary" }), children),
844
- onClose && /* @__PURE__ */ React19.createElement(import_ui19.IconButton, { onClick: onClose, size: "small" }, /* @__PURE__ */ React19.createElement(import_icons7.XIcon, null))
865
+ /* @__PURE__ */ React20.createElement(import_ui19.Stack, { direction: "row", alignItems: "center", gap: 1 }, /* @__PURE__ */ React20.createElement(import_icons7.AlertTriangleFilledIcon, { color: "secondary" }), children),
866
+ onClose && /* @__PURE__ */ React20.createElement(import_ui19.IconButton, { onClick: onClose, size: "small" }, /* @__PURE__ */ React20.createElement(import_icons7.XIcon, null))
845
867
  );
846
- var SaveChangesDialogContent = ({ children }) => /* @__PURE__ */ React19.createElement(import_ui19.DialogContent, null, children);
847
- var SaveChangesDialogContentText = (props) => /* @__PURE__ */ React19.createElement(import_ui19.DialogContentText, { variant: "body2", color: "textPrimary", display: "flex", flexDirection: "column", ...props });
868
+ var SaveChangesDialogContent = ({ children }) => /* @__PURE__ */ React20.createElement(import_ui19.DialogContent, null, children);
869
+ var SaveChangesDialogContentText = (props) => /* @__PURE__ */ React20.createElement(import_ui19.DialogContentText, { variant: "body2", color: "textPrimary", display: "flex", flexDirection: "column", ...props });
848
870
  var SaveChangesDialogActions = ({ actions }) => {
849
- const [isConfirming, setIsConfirming] = (0, import_react14.useState)(false);
871
+ const [isConfirming, setIsConfirming] = (0, import_react15.useState)(false);
850
872
  const { cancel, confirm, discard } = actions;
851
873
  const onConfirm = async () => {
852
874
  setIsConfirming(true);
853
875
  await confirm.action();
854
876
  setIsConfirming(false);
855
877
  };
856
- return /* @__PURE__ */ React19.createElement(import_ui19.DialogActions, null, cancel && /* @__PURE__ */ React19.createElement(import_ui19.Button, { variant: "text", color: "secondary", onClick: cancel.action }, cancel.label), discard && /* @__PURE__ */ React19.createElement(import_ui19.Button, { variant: "text", color: "secondary", onClick: discard.action }, discard.label), /* @__PURE__ */ React19.createElement(import_ui19.Button, { variant: "contained", color: "secondary", onClick: onConfirm, loading: isConfirming }, confirm.label));
878
+ return /* @__PURE__ */ React20.createElement(import_ui19.DialogActions, null, cancel && /* @__PURE__ */ React20.createElement(import_ui19.Button, { variant: "text", color: "secondary", onClick: cancel.action }, cancel.label), discard && /* @__PURE__ */ React20.createElement(import_ui19.Button, { variant: "text", color: "secondary", onClick: discard.action }, discard.label), /* @__PURE__ */ React20.createElement(import_ui19.Button, { variant: "contained", color: "secondary", onClick: onConfirm, loading: isConfirming }, confirm.label));
857
879
  };
858
880
  SaveChangesDialog.Title = SaveChangesDialogTitle;
859
881
  SaveChangesDialog.Content = SaveChangesDialogContent;
860
882
  SaveChangesDialog.ContentText = SaveChangesDialogContentText;
861
883
  SaveChangesDialog.Actions = SaveChangesDialogActions;
862
884
  var useDialog = () => {
863
- const [isOpen, setIsOpen] = (0, import_react14.useState)(false);
885
+ const [isOpen, setIsOpen] = (0, import_react15.useState)(false);
864
886
  const open = () => setIsOpen(true);
865
887
  const close = () => setIsOpen(false);
866
888
  return { isOpen, open, close };
867
889
  };
868
890
 
869
891
  // src/components/confirmation-dialog.tsx
870
- var React20 = __toESM(require("react"));
892
+ var React21 = __toESM(require("react"));
871
893
  var import_icons8 = require("@elementor/icons");
872
894
  var import_ui20 = require("@elementor/ui");
873
895
  var import_i18n4 = require("@wordpress/i18n");
874
896
  var TITLE_ID2 = "confirmation-dialog";
875
- var ConfirmationDialog = ({ open, onClose, children }) => /* @__PURE__ */ React20.createElement(import_ui20.Dialog, { open, onClose, "aria-labelledby": TITLE_ID2, maxWidth: "xs" }, children);
876
- var ConfirmationDialogTitle = ({ children }) => /* @__PURE__ */ React20.createElement(import_ui20.DialogTitle, { id: TITLE_ID2, display: "flex", alignItems: "center", gap: 1, sx: { lineHeight: 1 } }, /* @__PURE__ */ React20.createElement(import_icons8.AlertOctagonFilledIcon, { color: "error" }), children);
877
- var ConfirmationDialogContent = ({ children }) => /* @__PURE__ */ React20.createElement(import_ui20.DialogContent, null, children);
878
- var ConfirmationDialogContentText = (props) => /* @__PURE__ */ React20.createElement(import_ui20.DialogContentText, { variant: "body2", color: "textPrimary", ...props });
897
+ var ConfirmationDialog = ({ open, onClose, children }) => /* @__PURE__ */ React21.createElement(import_ui20.Dialog, { open, onClose, "aria-labelledby": TITLE_ID2, maxWidth: "xs" }, children);
898
+ var ConfirmationDialogTitle = ({ children }) => /* @__PURE__ */ React21.createElement(import_ui20.DialogTitle, { id: TITLE_ID2, display: "flex", alignItems: "center", gap: 1, sx: { lineHeight: 1 } }, /* @__PURE__ */ React21.createElement(import_icons8.AlertOctagonFilledIcon, { color: "error" }), children);
899
+ var ConfirmationDialogContent = ({ children }) => /* @__PURE__ */ React21.createElement(import_ui20.DialogContent, null, children);
900
+ var ConfirmationDialogContentText = (props) => /* @__PURE__ */ React21.createElement(import_ui20.DialogContentText, { variant: "body2", color: "textPrimary", ...props });
879
901
  var ConfirmationDialogActions = ({
880
902
  onClose,
881
903
  onConfirm,
882
904
  cancelLabel,
883
905
  confirmLabel
884
- }) => /* @__PURE__ */ React20.createElement(import_ui20.DialogActions, null, /* @__PURE__ */ React20.createElement(import_ui20.Button, { color: "secondary", onClick: onClose }, cancelLabel ?? (0, import_i18n4.__)("Not now", "elementor")), /* @__PURE__ */ React20.createElement(import_ui20.Button, { autoFocus: true, variant: "contained", color: "error", onClick: onConfirm }, confirmLabel ?? (0, import_i18n4.__)("Delete", "elementor")));
906
+ }) => /* @__PURE__ */ React21.createElement(import_ui20.DialogActions, null, /* @__PURE__ */ React21.createElement(import_ui20.Button, { color: "secondary", onClick: onClose }, cancelLabel ?? (0, import_i18n4.__)("Not now", "elementor")), /* @__PURE__ */ React21.createElement(import_ui20.Button, { autoFocus: true, variant: "contained", color: "error", onClick: onConfirm }, confirmLabel ?? (0, import_i18n4.__)("Delete", "elementor")));
885
907
  ConfirmationDialog.Title = ConfirmationDialogTitle;
886
908
  ConfirmationDialog.Content = ConfirmationDialogContent;
887
909
  ConfirmationDialog.ContentText = ConfirmationDialogContentText;
888
910
  ConfirmationDialog.Actions = ConfirmationDialogActions;
889
911
 
890
912
  // src/hooks/use-editable.ts
891
- var import_react15 = require("react");
913
+ var import_react16 = require("react");
892
914
  var useEditable = ({ value, onSubmit, validation, onClick, onError }) => {
893
- const [isEditing, setIsEditing] = (0, import_react15.useState)(false);
894
- const [error, setError] = (0, import_react15.useState)(null);
915
+ const [isEditing, setIsEditing] = (0, import_react16.useState)(false);
916
+ const [error, setError] = (0, import_react16.useState)(null);
895
917
  const ref = useSelection(isEditing);
896
918
  const isDirty = (newValue) => newValue !== value;
897
919
  const openEditMode = () => {
@@ -973,8 +995,8 @@ var useEditable = ({ value, onSubmit, validation, onClick, onError }) => {
973
995
  };
974
996
  };
975
997
  var useSelection = (isEditing) => {
976
- const ref = (0, import_react15.useRef)(null);
977
- (0, import_react15.useEffect)(() => {
998
+ const ref = (0, import_react16.useRef)(null);
999
+ (0, import_react16.useEffect)(() => {
978
1000
  if (isEditing) {
979
1001
  selectAll(ref.current);
980
1002
  }
@@ -1014,12 +1036,15 @@ var selectAll = (el) => {
1014
1036
  PromotionPopover,
1015
1037
  SaveChangesDialog,
1016
1038
  SearchField,
1039
+ SectionPopoverBody,
1040
+ SectionRefContext,
1017
1041
  StyledMenuList,
1018
1042
  ThemeProvider,
1019
1043
  WarningInfotip,
1020
1044
  closeDialog,
1021
1045
  openDialog,
1022
1046
  useDialog,
1023
- useEditable
1047
+ useEditable,
1048
+ useSectionWidth
1024
1049
  });
1025
1050
  //# sourceMappingURL=index.js.map
package/dist/index.mjs CHANGED
@@ -574,8 +574,27 @@ var PopoverBody = ({ children, height = DEFAULT_POPOVER_HEIGHT, width, id }) =>
574
574
  );
575
575
  };
576
576
 
577
- // src/components/popover/header.tsx
577
+ // src/components/popover/section-popover-body.tsx
578
578
  import * as React17 from "react";
579
+
580
+ // src/contexts/section-context.tsx
581
+ import { createContext, useContext } from "react";
582
+ var FALLBACK_SECTION_WIDTH = 320;
583
+ var SectionRefContext = createContext(null);
584
+ var useSectionRef = () => useContext(SectionRefContext);
585
+ var useSectionWidth = () => {
586
+ const sectionRef = useSectionRef();
587
+ return sectionRef?.current?.offsetWidth ?? FALLBACK_SECTION_WIDTH;
588
+ };
589
+
590
+ // src/components/popover/section-popover-body.tsx
591
+ var SectionPopoverBody = (props) => {
592
+ const sectionWidth = useSectionWidth();
593
+ return /* @__PURE__ */ React17.createElement(PopoverBody, { ...props, width: sectionWidth });
594
+ };
595
+
596
+ // src/components/popover/header.tsx
597
+ import * as React18 from "react";
579
598
  import { CloseButton as CloseButton2, Stack, Typography as Typography5 } from "@elementor/ui";
580
599
  var SIZE2 = "tiny";
581
600
  var PopoverHeader = ({ title, onClose, icon, actions }) => {
@@ -585,11 +604,11 @@ var PopoverHeader = ({ title, onClose, icon, actions }) => {
585
604
  py: 1.5,
586
605
  maxHeight: 36
587
606
  };
588
- return /* @__PURE__ */ React17.createElement(Stack, { direction: "row", alignItems: "center", ...paddingAndSizing, sx: { columnGap: 0.5 } }, icon, /* @__PURE__ */ React17.createElement(Typography5, { variant: "subtitle2", sx: { fontSize: "12px", mt: 0.25 } }, title), /* @__PURE__ */ React17.createElement(Stack, { direction: "row", sx: { ml: "auto" } }, actions, /* @__PURE__ */ React17.createElement(CloseButton2, { slotProps: { icon: { fontSize: SIZE2 } }, sx: { ml: "auto" }, onClick: onClose })));
607
+ return /* @__PURE__ */ React18.createElement(Stack, { direction: "row", alignItems: "center", ...paddingAndSizing, sx: { columnGap: 0.5 } }, icon, /* @__PURE__ */ React18.createElement(Typography5, { variant: "subtitle2", sx: { fontSize: "12px", mt: 0.25 } }, title), /* @__PURE__ */ React18.createElement(Stack, { direction: "row", sx: { ml: "auto" } }, actions, /* @__PURE__ */ React18.createElement(CloseButton2, { slotProps: { icon: { fontSize: SIZE2 } }, sx: { ml: "auto" }, onClick: onClose })));
589
608
  };
590
609
 
591
610
  // src/components/popover/menu-list.tsx
592
- import * as React18 from "react";
611
+ import * as React19 from "react";
593
612
  import { useEffect as useEffect7, useMemo, useRef as useRef3 } from "react";
594
613
  import { Box as Box7, ListItem, MenuList, MenuSubheader, styled as styled3, useTheme } from "@elementor/ui";
595
614
  import { useVirtualizer } from "@tanstack/react-virtual";
@@ -699,7 +718,7 @@ var PopoverMenuList = ({
699
718
  }, [items]);
700
719
  useScrollToSelected({ selectedValue, items, virtualizer });
701
720
  const virtualItems = virtualizer.getVirtualItems();
702
- return /* @__PURE__ */ React18.createElement(Box7, { ref: containerRef, sx: { height: "100%", overflowY: "auto" } }, items.length === 0 && noResultsComponent ? noResultsComponent : /* @__PURE__ */ React18.createElement(
721
+ return /* @__PURE__ */ React19.createElement(Box7, { ref: containerRef, sx: { height: "100%", overflowY: "auto" } }, items.length === 0 && noResultsComponent ? noResultsComponent : /* @__PURE__ */ React19.createElement(
703
722
  MenuListComponent,
704
723
  {
705
724
  role: "listbox",
@@ -717,7 +736,7 @@ var PopoverMenuList = ({
717
736
  }
718
737
  if (item.type === "category") {
719
738
  const shouldStick = virtualRow.start + MENU_LIST_PADDING_TOP <= scrollTop;
720
- return /* @__PURE__ */ React18.createElement(
739
+ return /* @__PURE__ */ React19.createElement(
721
740
  MenuSubheader,
722
741
  {
723
742
  key: virtualRow.key,
@@ -728,7 +747,7 @@ var PopoverMenuList = ({
728
747
  );
729
748
  }
730
749
  const isDisabled = item.disabled;
731
- return /* @__PURE__ */ React18.createElement(
750
+ return /* @__PURE__ */ React19.createElement(
732
751
  ListItem,
733
752
  {
734
753
  key: virtualRow.key,
@@ -798,7 +817,7 @@ var StyledMenuList = styled3(MenuList)(({ theme }) => ({
798
817
  }));
799
818
 
800
819
  // src/components/save-changes-dialog.tsx
801
- import * as React19 from "react";
820
+ import * as React20 from "react";
802
821
  import { useState as useState6 } from "react";
803
822
  import { AlertTriangleFilledIcon, XIcon as XIcon2 } from "@elementor/icons";
804
823
  import {
@@ -812,8 +831,8 @@ import {
812
831
  Stack as Stack2
813
832
  } from "@elementor/ui";
814
833
  var TITLE_ID = "save-changes-dialog";
815
- var SaveChangesDialog = ({ children, onClose }) => /* @__PURE__ */ React19.createElement(Dialog3, { open: true, onClose, "aria-labelledby": TITLE_ID, maxWidth: "xs" }, children);
816
- var SaveChangesDialogTitle = ({ children, onClose }) => /* @__PURE__ */ React19.createElement(
834
+ var SaveChangesDialog = ({ children, onClose }) => /* @__PURE__ */ React20.createElement(Dialog3, { open: true, onClose, "aria-labelledby": TITLE_ID, maxWidth: "xs" }, children);
835
+ var SaveChangesDialogTitle = ({ children, onClose }) => /* @__PURE__ */ React20.createElement(
817
836
  DialogTitle2,
818
837
  {
819
838
  id: TITLE_ID,
@@ -822,11 +841,11 @@ var SaveChangesDialogTitle = ({ children, onClose }) => /* @__PURE__ */ React19.
822
841
  gap: 1,
823
842
  sx: { lineHeight: 1, justifyContent: "space-between" }
824
843
  },
825
- /* @__PURE__ */ React19.createElement(Stack2, { direction: "row", alignItems: "center", gap: 1 }, /* @__PURE__ */ React19.createElement(AlertTriangleFilledIcon, { color: "secondary" }), children),
826
- onClose && /* @__PURE__ */ React19.createElement(IconButton2, { onClick: onClose, size: "small" }, /* @__PURE__ */ React19.createElement(XIcon2, null))
844
+ /* @__PURE__ */ React20.createElement(Stack2, { direction: "row", alignItems: "center", gap: 1 }, /* @__PURE__ */ React20.createElement(AlertTriangleFilledIcon, { color: "secondary" }), children),
845
+ onClose && /* @__PURE__ */ React20.createElement(IconButton2, { onClick: onClose, size: "small" }, /* @__PURE__ */ React20.createElement(XIcon2, null))
827
846
  );
828
- var SaveChangesDialogContent = ({ children }) => /* @__PURE__ */ React19.createElement(DialogContent, null, children);
829
- var SaveChangesDialogContentText = (props) => /* @__PURE__ */ React19.createElement(DialogContentText, { variant: "body2", color: "textPrimary", display: "flex", flexDirection: "column", ...props });
847
+ var SaveChangesDialogContent = ({ children }) => /* @__PURE__ */ React20.createElement(DialogContent, null, children);
848
+ var SaveChangesDialogContentText = (props) => /* @__PURE__ */ React20.createElement(DialogContentText, { variant: "body2", color: "textPrimary", display: "flex", flexDirection: "column", ...props });
830
849
  var SaveChangesDialogActions = ({ actions }) => {
831
850
  const [isConfirming, setIsConfirming] = useState6(false);
832
851
  const { cancel, confirm, discard } = actions;
@@ -835,7 +854,7 @@ var SaveChangesDialogActions = ({ actions }) => {
835
854
  await confirm.action();
836
855
  setIsConfirming(false);
837
856
  };
838
- return /* @__PURE__ */ React19.createElement(DialogActions2, null, cancel && /* @__PURE__ */ React19.createElement(Button4, { variant: "text", color: "secondary", onClick: cancel.action }, cancel.label), discard && /* @__PURE__ */ React19.createElement(Button4, { variant: "text", color: "secondary", onClick: discard.action }, discard.label), /* @__PURE__ */ React19.createElement(Button4, { variant: "contained", color: "secondary", onClick: onConfirm, loading: isConfirming }, confirm.label));
857
+ return /* @__PURE__ */ React20.createElement(DialogActions2, null, cancel && /* @__PURE__ */ React20.createElement(Button4, { variant: "text", color: "secondary", onClick: cancel.action }, cancel.label), discard && /* @__PURE__ */ React20.createElement(Button4, { variant: "text", color: "secondary", onClick: discard.action }, discard.label), /* @__PURE__ */ React20.createElement(Button4, { variant: "contained", color: "secondary", onClick: onConfirm, loading: isConfirming }, confirm.label));
839
858
  };
840
859
  SaveChangesDialog.Title = SaveChangesDialogTitle;
841
860
  SaveChangesDialog.Content = SaveChangesDialogContent;
@@ -849,7 +868,7 @@ var useDialog = () => {
849
868
  };
850
869
 
851
870
  // src/components/confirmation-dialog.tsx
852
- import * as React20 from "react";
871
+ import * as React21 from "react";
853
872
  import { AlertOctagonFilledIcon } from "@elementor/icons";
854
873
  import {
855
874
  Button as Button5,
@@ -861,16 +880,16 @@ import {
861
880
  } from "@elementor/ui";
862
881
  import { __ as __4 } from "@wordpress/i18n";
863
882
  var TITLE_ID2 = "confirmation-dialog";
864
- var ConfirmationDialog = ({ open, onClose, children }) => /* @__PURE__ */ React20.createElement(Dialog4, { open, onClose, "aria-labelledby": TITLE_ID2, maxWidth: "xs" }, children);
865
- var ConfirmationDialogTitle = ({ children }) => /* @__PURE__ */ React20.createElement(DialogTitle3, { id: TITLE_ID2, display: "flex", alignItems: "center", gap: 1, sx: { lineHeight: 1 } }, /* @__PURE__ */ React20.createElement(AlertOctagonFilledIcon, { color: "error" }), children);
866
- var ConfirmationDialogContent = ({ children }) => /* @__PURE__ */ React20.createElement(DialogContent2, null, children);
867
- var ConfirmationDialogContentText = (props) => /* @__PURE__ */ React20.createElement(DialogContentText2, { variant: "body2", color: "textPrimary", ...props });
883
+ var ConfirmationDialog = ({ open, onClose, children }) => /* @__PURE__ */ React21.createElement(Dialog4, { open, onClose, "aria-labelledby": TITLE_ID2, maxWidth: "xs" }, children);
884
+ var ConfirmationDialogTitle = ({ children }) => /* @__PURE__ */ React21.createElement(DialogTitle3, { id: TITLE_ID2, display: "flex", alignItems: "center", gap: 1, sx: { lineHeight: 1 } }, /* @__PURE__ */ React21.createElement(AlertOctagonFilledIcon, { color: "error" }), children);
885
+ var ConfirmationDialogContent = ({ children }) => /* @__PURE__ */ React21.createElement(DialogContent2, null, children);
886
+ var ConfirmationDialogContentText = (props) => /* @__PURE__ */ React21.createElement(DialogContentText2, { variant: "body2", color: "textPrimary", ...props });
868
887
  var ConfirmationDialogActions = ({
869
888
  onClose,
870
889
  onConfirm,
871
890
  cancelLabel,
872
891
  confirmLabel
873
- }) => /* @__PURE__ */ React20.createElement(DialogActions3, null, /* @__PURE__ */ React20.createElement(Button5, { color: "secondary", onClick: onClose }, cancelLabel ?? __4("Not now", "elementor")), /* @__PURE__ */ React20.createElement(Button5, { autoFocus: true, variant: "contained", color: "error", onClick: onConfirm }, confirmLabel ?? __4("Delete", "elementor")));
892
+ }) => /* @__PURE__ */ React21.createElement(DialogActions3, null, /* @__PURE__ */ React21.createElement(Button5, { color: "secondary", onClick: onClose }, cancelLabel ?? __4("Not now", "elementor")), /* @__PURE__ */ React21.createElement(Button5, { autoFocus: true, variant: "contained", color: "error", onClick: onConfirm }, confirmLabel ?? __4("Delete", "elementor")));
874
893
  ConfirmationDialog.Title = ConfirmationDialogTitle;
875
894
  ConfirmationDialog.Content = ConfirmationDialogContent;
876
895
  ConfirmationDialog.ContentText = ConfirmationDialogContentText;
@@ -1002,12 +1021,15 @@ export {
1002
1021
  PromotionPopover,
1003
1022
  SaveChangesDialog,
1004
1023
  SearchField,
1024
+ SectionPopoverBody,
1025
+ SectionRefContext,
1005
1026
  StyledMenuList,
1006
1027
  ThemeProvider,
1007
1028
  WarningInfotip,
1008
1029
  closeDialog,
1009
1030
  openDialog,
1010
1031
  useDialog,
1011
- useEditable
1032
+ useEditable,
1033
+ useSectionWidth
1012
1034
  };
1013
1035
  //# sourceMappingURL=index.mjs.map
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.0.0-499",
4
+ "version": "4.0.0-501",
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.0.0-499",
40
+ "@elementor/editor-v1-adapters": "4.0.0-501",
41
41
  "@elementor/icons": "^1.63.0",
42
42
  "@elementor/ui": "1.36.17",
43
43
  "@tanstack/react-virtual": "^3.13.3",
@@ -1,4 +1,5 @@
1
1
  export { PopoverBody } from './body';
2
+ export { SectionPopoverBody } from './section-popover-body';
2
3
  export { PopoverHeader } from './header';
3
4
  export { ITEM_HEIGHT, PopoverMenuList, StyledMenuList } from './menu-list';
4
5
  export type { PopoverMenuListProps, VirtualizedItem } from './menu-list';
@@ -0,0 +1,11 @@
1
+ import * as React from 'react';
2
+ import { type ComponentProps } from 'react';
3
+
4
+ import { useSectionWidth } from '../../contexts/section-context';
5
+ import { PopoverBody as BasePopoverBody } from './body';
6
+
7
+ export const SectionPopoverBody = ( props: ComponentProps< typeof BasePopoverBody > ) => {
8
+ const sectionWidth = useSectionWidth();
9
+
10
+ return <BasePopoverBody { ...props } width={ sectionWidth } />;
11
+ };
@@ -0,0 +1,14 @@
1
+ import { createContext, useContext } from 'react';
2
+ import type { RefObject } from 'react';
3
+
4
+ const FALLBACK_SECTION_WIDTH = 320;
5
+
6
+ export const SectionRefContext = createContext< RefObject< HTMLElement > | null >( null );
7
+
8
+ const useSectionRef = () => useContext( SectionRefContext );
9
+
10
+ export const useSectionWidth = (): number => {
11
+ const sectionRef = useSectionRef();
12
+
13
+ return sectionRef?.current?.offsetWidth ?? FALLBACK_SECTION_WIDTH;
14
+ };
package/src/index.ts CHANGED
@@ -20,5 +20,8 @@ export * from './components/popover';
20
20
  export * from './components/save-changes-dialog';
21
21
  export { ConfirmationDialog } from './components/confirmation-dialog';
22
22
 
23
+ // contexts
24
+ export { SectionRefContext, useSectionWidth } from './contexts/section-context';
25
+
23
26
  // hooks
24
27
  export { useEditable } from './hooks/use-editable';