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