@ethisyscore/plugin-ui 1.61.0 → 1.63.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.
@@ -4,6 +4,8 @@ var react = require('react');
4
4
  var reactQuery = require('@tanstack/react-query');
5
5
  var componentsReact = require('@ethisyscore/components-react');
6
6
  var plugin = require('@ethisyscore/extension-runtime/plugin');
7
+ var material = require('@mui/material');
8
+ var jsxRuntime = require('react/jsx-runtime');
7
9
 
8
10
  // src/platform-react/definePlatformReactPluginPage.tsx
9
11
  var TemplateContext = react.createContext(null);
@@ -111,6 +113,42 @@ function isHostChromeCompatible(hostVersion) {
111
113
  if (Number.isNaN(hostMajor) || Number.isNaN(sdkMajor)) return false;
112
114
  return hostMajor === sdkMajor;
113
115
  }
116
+ var EHX_PLUGIN_PORTAL_CLASS = "ehx-plugin-portal-root";
117
+ var EHX_PLUGIN_PORTAL_ATTR = "data-ehx-plugin-portal";
118
+ function withPortalContainer(theme, containerElement) {
119
+ const slots = theme.components ?? {};
120
+ const tooltip = slots.MuiTooltip;
121
+ const container = () => containerElement;
122
+ return {
123
+ ...theme,
124
+ components: {
125
+ ...slots,
126
+ MuiModal: { ...slots.MuiModal, defaultProps: { ...slots.MuiModal?.defaultProps, container } },
127
+ MuiPopper: { ...slots.MuiPopper, defaultProps: { ...slots.MuiPopper?.defaultProps, container } },
128
+ MuiPopover: { ...slots.MuiPopover, defaultProps: { ...slots.MuiPopover?.defaultProps, container } },
129
+ MuiMenu: { ...slots.MuiMenu, defaultProps: { ...slots.MuiMenu?.defaultProps, container } },
130
+ MuiTooltip: {
131
+ ...tooltip,
132
+ defaultProps: {
133
+ ...tooltip?.defaultProps,
134
+ PopperProps: { ...tooltip?.defaultProps?.PopperProps, container }
135
+ }
136
+ }
137
+ }
138
+ };
139
+ }
140
+ function PluginPortalScope({ children }) {
141
+ const [container, setContainer] = react.useState(null);
142
+ const hostTheme = material.useTheme();
143
+ const theme = react.useMemo(
144
+ () => container ? withPortalContainer(hostTheme, container) : hostTheme,
145
+ [hostTheme, container]
146
+ );
147
+ return /* @__PURE__ */ jsxRuntime.jsxs(material.ThemeProvider, { theme, children: [
148
+ children,
149
+ /* @__PURE__ */ jsxRuntime.jsx("div", { ref: setContainer, className: EHX_PLUGIN_PORTAL_CLASS, ...{ [EHX_PLUGIN_PORTAL_ATTR]: "" } })
150
+ ] });
151
+ }
114
152
 
115
153
  // src/platform-react/definePlatformReactPluginPage.tsx
116
154
  function makeDefaultQueryClient() {
@@ -151,7 +189,10 @@ function definePlatformReactPluginPage(Page, options) {
151
189
  react.createElement(
152
190
  "div",
153
191
  { className: `${EHX_PLUGIN_ROOT_CLASS} ${rootClassName}` },
154
- body
192
+ // PluginPortalScope sits INSIDE the style root, so the portal container
193
+ // it renders is a descendant of it and MUI overlays (dialogs, menus,
194
+ // poppers, tooltips) open inside the plugin's scoped CSS.
195
+ react.createElement(PluginPortalScope, null, body)
155
196
  )
156
197
  )
157
198
  )
@@ -519,7 +560,9 @@ function definePlatformReactPluginOverlay(Overlay, options) {
519
560
  react.createElement(
520
561
  "div",
521
562
  { className: `${EHX_PLUGIN_ROOT_CLASS} ${rootClassName}` },
522
- react.createElement(Overlay, props)
563
+ // Overlay surfaces open their own dialogs and menus, so they need the same
564
+ // portal containment as pages (see definePlatformReactPluginPage).
565
+ react.createElement(PluginPortalScope, null, react.createElement(Overlay, props))
523
566
  )
524
567
  )
525
568
  );
@@ -824,12 +867,15 @@ function menuConfigToHostSidebarInput(config, opts) {
824
867
 
825
868
  exports.BaseMcpService = BaseMcpService;
826
869
  exports.DEFAULT_MAX_UPLOAD_BYTES = DEFAULT_MAX_UPLOAD_BYTES;
870
+ exports.EHX_PLUGIN_PORTAL_ATTR = EHX_PLUGIN_PORTAL_ATTR;
871
+ exports.EHX_PLUGIN_PORTAL_CLASS = EHX_PLUGIN_PORTAL_CLASS;
827
872
  exports.EHX_PLUGIN_ROOT_CLASS = EHX_PLUGIN_ROOT_CLASS;
828
873
  exports.HOST_CHROME_CONTRACT_VERSION = HOST_CHROME_CONTRACT_VERSION;
829
874
  exports.HostSidebarActionsContext = HostSidebarActionsContext;
830
875
  exports.MissingViewFallback = MissingViewFallback;
831
876
  exports.OVERLAY_HOST_CONTRACT_VERSION = OVERLAY_HOST_CONTRACT_VERSION;
832
877
  exports.OverlayHostContext = OverlayHostContext;
878
+ exports.PluginPortalScope = PluginPortalScope;
833
879
  exports.PluginStyleScope = PluginStyleScope;
834
880
  exports.SIDEBAR_MODE = SIDEBAR_MODE;
835
881
  exports.SurfaceBaseContext = SurfaceBaseContext;