@meonode/ui 0.1.30 → 0.1.32

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.
@@ -1,6 +1,5 @@
1
1
  import React from 'react';
2
- import type { ComponentNode, NodeElement, NodeInstance, NodeProps } from './node.type.js';
3
- import { type Root as ReactDOMRoot } from 'react-dom/client';
2
+ import type { ComponentNode, NodeElement, NodeInstance, NodeProps, PortalLauncher, PortalLauncherWithFixedProviders, PortalProps } from './node.type.js';
4
3
  /**
5
4
  * Factory function to create a BaseNode instance.
6
5
  * @param element The React element type.
@@ -34,32 +33,33 @@ export declare function Component<P extends Record<string, any>>(component: (pro
34
33
  children?: NodeElement;
35
34
  }) => ComponentNode): (props?: any) => React.ReactNode;
36
35
  /**
37
- * Creates a portal wrapper component for rendering content outside the normal DOM hierarchy.
38
- * Portals are useful for rendering modals, tooltips, and other overlays that need to break out
39
- * of their parent container's DOM structure while maintaining React context and event bubbling.
36
+ * Creates a portal component that renders its content outside the normal DOM hierarchy.
37
+ * Supports wrapping the portal content with provider components for context/theme inheritance.
40
38
  *
41
- * Key features:
42
- * - Renders content to a separate DOM node outside the parent hierarchy
43
- * - Maintains theme inheritance through the portal
44
- * - Provides portal instance with unmount control
45
- * - Automatically cleans up DOM nodes on unmount
46
- * @template P Props type for the wrapped component including theme and portal instance
47
- * @param component Component function that returns portal content
48
- * @returns Function that creates and manages the portal instance
39
+ * A portal creates a new DOM element and renders React content into it, useful for modals,
40
+ * popovers, and other overlays that need to break out of their parent container's DOM hierarchy.
41
+ *
42
+ * The portal content can be wrapped with provider components to maintain context/theme inheritance:
43
+ * 1. Fixed providers specified when creating the portal via Portal(providers, component)
44
+ * 2. Dynamic providers passed as props when launching the portal
45
+ * @template P_Content - Props type for the portal's content component
49
46
  * @example
50
- * ```ts
51
- * const Modal = Portal(({ portal }) => {
52
- * return Div({
53
- * onClick: () => portal.unmount(),
54
- * children: "Click to close"
55
- * })
47
+ * // Basic portal with no providers
48
+ * const Modal = Portal((props) => Div({ children: props.children }));
49
+ *
50
+ * // Portal with fixed theme provider
51
+ * const ThemedModal = Portal(
52
+ * ThemeProvider({ theme }),
53
+ * (props) => Div({ children: props.children })
54
+ * )
55
+ *
56
+ * // Usage with dynamic providers
57
+ * const modal = Modal({
58
+ * providers: [ThemeProvider({ theme })],
59
+ * children: "Modal content"
56
60
  * })
57
- * ```
61
+ * modal.unmount(); // Clean up when done
58
62
  */
59
- export declare function Portal<P extends Record<string, any>>(component: (props: P & {
60
- children?: NodeElement;
61
- portal: {
62
- unmount: () => void;
63
- };
64
- }) => ComponentNode): (props?: any) => ReactDOMRoot | null;
63
+ export declare function Portal<P_Content extends Record<string, any>>(providers: NodeInstance<any> | NodeInstance<any>[], component: (props: PortalProps<P_Content>) => ComponentNode): PortalLauncherWithFixedProviders<P_Content>;
64
+ export declare function Portal<P_Content extends Record<string, any>>(component: (props: PortalProps<P_Content>) => ComponentNode): PortalLauncher<P_Content>;
65
65
  //# sourceMappingURL=core.node.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"core.node.d.ts","sourceRoot":"","sources":["../src/core.node.ts"],"names":[],"mappings":"AACA,OAAO,KAAyG,MAAM,OAAO,CAAA;AAC7H,OAAO,KAAK,EAAE,aAAa,EAAyC,WAAW,EAAE,YAAY,EAAE,SAAS,EAAuB,MAAM,mBAAmB,CAAA;AAGxJ,OAAO,EAAc,KAAK,IAAI,IAAI,YAAY,EAAE,MAAM,kBAAkB,CAAA;AAuexE;;;;;GAKG;AACH,wBAAgB,IAAI,CAAC,CAAC,SAAS,WAAW,EAAE,OAAO,EAAE,CAAC,EAAE,KAAK,GAAE,OAAO,CAAC,SAAS,CAAC,CAAC,CAAC,CAAM,GAAG,YAAY,CAAC,CAAC,CAAC,CAU1G;AAED;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAgB,SAAS,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EACrD,SAAS,EAAE,CACT,KAAK,EAAE,CAAC,GAAG;IACT,QAAQ,CAAC,EAAE,WAAW,CAAA;CACvB,KACE,aAAa,IAkBV,QAAO,GAAQ,qBACxB;AAED;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAgB,MAAM,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAClD,SAAS,EAAE,CACT,KAAK,EAAE,CAAC,GAAG;IACT,QAAQ,CAAC,EAAE,WAAW,CAAA;IACtB,MAAM,EAAE;QAAE,OAAO,EAAE,MAAM,IAAI,CAAA;KAAE,CAAA;CAChC,KACE,aAAa,IAgBV,QAAO,GAAQ,yBAIxB"}
1
+ {"version":3,"file":"core.node.d.ts","sourceRoot":"","sources":["../src/core.node.ts"],"names":[],"mappings":"AACA,OAAO,KAAyG,MAAM,OAAO,CAAA;AAC7H,OAAO,KAAK,EACV,aAAa,EAGb,WAAW,EACX,YAAY,EACZ,SAAS,EACT,cAAc,EACd,gCAAgC,EAChC,WAAW,EAGZ,MAAM,mBAAmB,CAAA;AA2c1B;;;;;GAKG;AACH,wBAAgB,IAAI,CAAC,CAAC,SAAS,WAAW,EAAE,OAAO,EAAE,CAAC,EAAE,KAAK,GAAE,OAAO,CAAC,SAAS,CAAC,CAAC,CAAC,CAAM,GAAG,YAAY,CAAC,CAAC,CAAC,CAU1G;AAED;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAgB,SAAS,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EACrD,SAAS,EAAE,CACT,KAAK,EAAE,CAAC,GAAG;IACT,QAAQ,CAAC,EAAE,WAAW,CAAA;CACvB,KACE,aAAa,IAkBV,QAAO,GAAQ,qBACxB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,wBAAgB,MAAM,CAAC,SAAS,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAC1D,SAAS,EAAE,YAAY,CAAC,GAAG,CAAC,GAAG,YAAY,CAAC,GAAG,CAAC,EAAE,EAClD,SAAS,EAAE,CAAC,KAAK,EAAE,WAAW,CAAC,SAAS,CAAC,KAAK,aAAa,GAC1D,gCAAgC,CAAC,SAAS,CAAC,CAAA;AAC9C,wBAAgB,MAAM,CAAC,SAAS,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAAE,SAAS,EAAE,CAAC,KAAK,EAAE,WAAW,CAAC,SAAS,CAAC,KAAK,aAAa,GAAG,cAAc,CAAC,SAAS,CAAC,CAAA"}
package/dist/core.node.js CHANGED
@@ -1,4 +1,4 @@
1
- "use strict";var _excluded=["children","nodetheme","theme"],_excluded2=["style"],_excluded3=["children","key"];function _typeof(a){"@babel/helpers - typeof";return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(a){return typeof a}:function(a){return a&&"function"==typeof Symbol&&a.constructor===Symbol&&a!==Symbol.prototype?"symbol":typeof a},_typeof(a)}function _objectWithoutProperties(a,b){if(null==a)return{};var c,d,e=_objectWithoutPropertiesLoose(a,b);if(Object.getOwnPropertySymbols){var f=Object.getOwnPropertySymbols(a);for(d=0;d<f.length;d++)c=f[d],-1===b.indexOf(c)&&{}.propertyIsEnumerable.call(a,c)&&(e[c]=a[c])}return e}function _objectWithoutPropertiesLoose(a,b){if(null==a)return{};var c={};for(var d in a)if({}.hasOwnProperty.call(a,d)){if(-1!==b.indexOf(d))continue;c[d]=a[d]}return c}function ownKeys(a,b){var c=Object.keys(a);if(Object.getOwnPropertySymbols){var d=Object.getOwnPropertySymbols(a);b&&(d=d.filter(function(b){return Object.getOwnPropertyDescriptor(a,b).enumerable})),c.push.apply(c,d)}return c}function _objectSpread(a){for(var b,c=1;c<arguments.length;c++)b=null==arguments[c]?{}:arguments[c],c%2?ownKeys(Object(b),!0).forEach(function(c){_defineProperty(a,c,b[c])}):Object.getOwnPropertyDescriptors?Object.defineProperties(a,Object.getOwnPropertyDescriptors(b)):ownKeys(Object(b)).forEach(function(c){Object.defineProperty(a,c,Object.getOwnPropertyDescriptor(b,c))});return a}function _classCallCheck(b,a){if(!(b instanceof a))throw new TypeError("Cannot call a class as a function")}function _defineProperties(a,b){for(var c,d=0;d<b.length;d++)c=b[d],c.enumerable=c.enumerable||!1,c.configurable=!0,"value"in c&&(c.writable=!0),Object.defineProperty(a,_toPropertyKey(c.key),c)}function _createClass(a,b,c){return b&&_defineProperties(a.prototype,b),c&&_defineProperties(a,c),Object.defineProperty(a,"prototype",{writable:!1}),a}function _defineProperty(a,b,c){return(b=_toPropertyKey(b))in a?Object.defineProperty(a,b,{value:c,enumerable:!0,configurable:!0,writable:!0}):a[b]=c,a}function _toPropertyKey(a){var b=_toPrimitive(a,"string");return"symbol"==_typeof(b)?b:b+""}function _toPrimitive(a,b){if("object"!=_typeof(a)||!a)return a;var c=a[Symbol.toPrimitive];if(void 0!==c){var d=c.call(a,b||"default");if("object"!=_typeof(d))return d;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===b?String:Number)(a)}import React,{createElement,isValidElement}from"react";import{getComponentType,getCSSProps,getDOMProps,getElementTypeName,getValueByPath}from"./node.helper.js";import{isForwardRef,isMemo,isReactClassComponent,isValidElementType}from"./react-is.helper.js";import{createRoot}from"react-dom/client";/**
1
+ "use strict";var _excluded=["children","nodetheme","theme"],_excluded2=["style"],_excluded3=["children","key"],_excluded4=["nodetheme"],_excluded5=["providers","nodetheme"];function _typeof(a){"@babel/helpers - typeof";return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(a){return typeof a}:function(a){return a&&"function"==typeof Symbol&&a.constructor===Symbol&&a!==Symbol.prototype?"symbol":typeof a},_typeof(a)}function _objectWithoutProperties(a,b){if(null==a)return{};var c,d,e=_objectWithoutPropertiesLoose(a,b);if(Object.getOwnPropertySymbols){var f=Object.getOwnPropertySymbols(a);for(d=0;d<f.length;d++)c=f[d],-1===b.indexOf(c)&&{}.propertyIsEnumerable.call(a,c)&&(e[c]=a[c])}return e}function _objectWithoutPropertiesLoose(a,b){if(null==a)return{};var c={};for(var d in a)if({}.hasOwnProperty.call(a,d)){if(-1!==b.indexOf(d))continue;c[d]=a[d]}return c}function ownKeys(a,b){var c=Object.keys(a);if(Object.getOwnPropertySymbols){var d=Object.getOwnPropertySymbols(a);b&&(d=d.filter(function(b){return Object.getOwnPropertyDescriptor(a,b).enumerable})),c.push.apply(c,d)}return c}function _objectSpread(a){for(var b,c=1;c<arguments.length;c++)b=null==arguments[c]?{}:arguments[c],c%2?ownKeys(Object(b),!0).forEach(function(c){_defineProperty(a,c,b[c])}):Object.getOwnPropertyDescriptors?Object.defineProperties(a,Object.getOwnPropertyDescriptors(b)):ownKeys(Object(b)).forEach(function(c){Object.defineProperty(a,c,Object.getOwnPropertyDescriptor(b,c))});return a}function _classCallCheck(b,a){if(!(b instanceof a))throw new TypeError("Cannot call a class as a function")}function _defineProperties(a,b){for(var c,d=0;d<b.length;d++)c=b[d],c.enumerable=c.enumerable||!1,c.configurable=!0,"value"in c&&(c.writable=!0),Object.defineProperty(a,_toPropertyKey(c.key),c)}function _createClass(a,b,c){return b&&_defineProperties(a.prototype,b),c&&_defineProperties(a,c),Object.defineProperty(a,"prototype",{writable:!1}),a}function _defineProperty(a,b,c){return(b=_toPropertyKey(b))in a?Object.defineProperty(a,b,{value:c,enumerable:!0,configurable:!0,writable:!0}):a[b]=c,a}function _toPropertyKey(a){var b=_toPrimitive(a,"string");return"symbol"==_typeof(b)?b:b+""}function _toPrimitive(a,b){if("object"!=_typeof(a)||!a)return a;var c=a[Symbol.toPrimitive];if(void 0!==c){var d=c.call(a,b||"default");if("object"!=_typeof(d))return d;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===b?String:Number)(a)}import React,{createElement,isValidElement}from"react";import{getComponentType,getCSSProps,getDOMProps,getElementTypeName,getValueByPath}from"./node.helper.js";import{isForwardRef,isMemo,isReactClassComponent,isValidElementType}from"./react-is.helper.js";import{createRoot}from"react-dom/client";/**
2
2
  * Represents a node in a React component tree with theme and styling capabilities.
3
3
  * This class wraps React elements and handles:
4
4
  * - Props processing and normalization
@@ -24,51 +24,27 @@ var d=c.children,e=c.nodetheme,f=c.theme,g=_objectWithoutProperties(c,_excluded)
24
24
  // Extract remaining props that are valid DOM attributes
25
25
  // Process children while maintaining theme inheritance
26
26
  // Combine processed props into final normalized form
27
- d&&(Array.isArray(d)?l=d.map(function(a,c){return b._processRawNode(a,h,c)}):l=this._processRawNode(d,h)),this.props=_objectSpread(_objectSpread({},k),{},{style:j,nodetheme:h,theme:f,children:l})}// In class BaseNode
28
- /**
29
- * Resolves obj properties by replacing theme path placeholders with actual theme values.
30
- * Handles complex strings like '1px solid theme.background.primary' and nested objects.
31
- * This version includes detection for circular references to prevent infinite loops.
32
- * @param obj The initial obj properties object.
33
- * @param theme The theme object to use for resolving paths.
34
- * @returns A new CSSProperties object with theme values resolved.
35
- */return _createClass(BaseNode,[{key:"_resolveObjWithTheme",value:function _resolveObjWithTheme(a,b){var c;// Return early if no theme or empty object
36
- if(!b||0===Object.keys(a).length)return a;// Merge raw nodetheme with passed theme for resolution
37
- var d=_objectSpread(_objectSpread({},null===(c=this.rawProps)||void 0===c?void 0:c.nodetheme),b),e=function resolveRecursively(a,b){// Prevent infinite recursion by detecting cycles in the object graph
38
- // If this object was already processed in the current branch, return it as-is
39
- if(b.has(a))return a;// Track this object to detect future cycles
40
- b.add(a);var c={};// Process all enumerable properties of the current object
41
- for(var f in a)// Skip inherited properties from the prototype chain
42
- // This ensures we only process the object's own properties
43
- if(Object.prototype.hasOwnProperty.call(a,f)){var g=a[f];// Special handling for "private" properties that start with underscore
44
- // These are exempt from theme resolution to allow implementation details
45
- if(f.startsWith("_")){c[f]=g;continue}// Process string values that contain theme path references
46
- // Example: "1px solid theme.colors.border" -> "1px solid #ccc"
47
- if("string"==typeof g&&g.includes("theme.")){var h=g;// Find and replace all theme path references using regex
48
- h=h.replace(/theme\.([a-zA-Z0-9_.-]+)/g,function(a,b){var c=getValueByPath(d,b);// Only convert theme values that are strings or numbers
49
- // Other types are left as-is to maintain the reference format
50
- return void 0!==c&&null!==c&&("string"==typeof c||"number"==typeof c)?c+"":a;// Theme path not found - keep original reference
51
- // Could add warning: console.warn(`Theme path ${path} not found`)
52
- }),c[f]=h}// Recursively process nested objects, excluding arrays
53
- // This allows theme resolution in deeply nested structures
54
- else c[f]=g&&"object"===_typeof(g)&&!Array.isArray(g)?// Use same visited set to maintain cycle detection across the entire tree
55
- e(g,b):g}// Important: We added `currentObj` to `visited` at the start of this function call.
56
- // For cycle detection within a single top-level `_resolveObjWithTheme` call,
57
- // we don't remove it here. The `visited` set is fresh for each top-level call.
58
- // If `visited` was a longer-lived cache across multiple calls, cleanup logic might be needed.
59
- return c};/**
60
- * Recursively resolves theme values in an object by traversing its properties and replacing theme path references.
61
- *
62
- * This function handles:
63
- * - Theme path resolution (e.g. 'theme.colors.primary' -> '#ff0000')
64
- * - Nested object traversal with cycle detection
65
- * - Type preservation for non-theme values
66
- * - Special case handling for private props (starting with '_')
67
- * @param currentObj The current object being processed in the recursion
68
- * @param visited Set tracking visited objects to prevent infinite loops from circular references
69
- * @returns A new object with all theme path references resolved to actual values
70
- */// Initial call to the recursive function with a new Set to track visited objects for this resolution.
71
- return e(a,new Set)}/**
27
+ d&&(Array.isArray(d)?l=d.map(function(a,c){return b._processRawNode(a,h,c)}):l=this._processRawNode(d,h)),this.props=_objectSpread(_objectSpread({},k),{},{style:j,nodetheme:h,theme:f,children:l})}/**
28
+ * Resolves theme variable references in an object's values recursively.
29
+ * Handles nested objects and prevents circular references.
30
+ * Theme variables are referenced using the format "theme.path.to.value".
31
+ * @param obj The object whose values should be resolved against the theme
32
+ * @param theme Optional theme object containing variable definitions
33
+ * @returns A new object with all theme variables resolved to their values
34
+ */return _createClass(BaseNode,[{key:"_resolveObjWithTheme",value:function _resolveObjWithTheme(a,b){var c;// Early return if no theme or empty object
35
+ if(!b||0===Object.keys(a).length)return a;// Merge parent theme with current theme
36
+ var d=_objectSpread(_objectSpread({},null===(c=this.rawProps)||void 0===c?void 0:c.nodetheme),b),e=function resolveRecursively(a,b){// Prevent processing same object multiple times
37
+ if(b.has(a))return a;// Track this object to detect circular references
38
+ b.add(a);var c={};for(var f in a)// Skip non-own properties
39
+ if(Object.prototype.hasOwnProperty.call(a,f)){var g=a[f];// Skip private props (starting with _)
40
+ if(f.startsWith("_")){c[f]=g;continue}// Resolve theme variables in string values
41
+ if("string"==typeof g&&g.includes("theme.")){var h=g;h=h.replace(/theme\.([a-zA-Z0-9_.-]+)/g,function(a,b){var c=getValueByPath(d,b);// Only convert string/number theme values
42
+ return void 0!==c&&null!==c&&"object"!==_typeof(c)?c:a;// Keep original if no valid theme value found
43
+ }),c[f]=h}// Recursively process nested objects
44
+ else c[f]=g&&"object"===_typeof(g)&&!Array.isArray(g)?e(g,b):g}return c};/**
45
+ * Recursively resolves theme variables in an object, tracking visited objects
46
+ * to prevent infinite recursion with circular references.
47
+ */return e(a,new Set)}/**
72
48
  * React component that renders the result of a function child, supporting theme propagation.
73
49
  *
74
50
  * This component is used to render children that are functions (i.e., `() => Children`).
@@ -179,25 +155,43 @@ return c.theme&&!c.nodetheme&&(c.nodetheme=c.theme),new BaseNode(a,c)}/**
179
155
  var b=function renderer(){var b=0<arguments.length&&arguments[0]!==void 0?arguments[0]:{},c=a(b);// Execute wrapped component
180
156
  // Handle BaseNode results - requires special processing
181
157
  if(c instanceof BaseNode){var d,e,f=(null===(d=c.rawProps)||void 0===d?void 0:d.nodetheme)||(null===(e=c.rawProps)||void 0===e?void 0:e.theme)||b.nodetheme||b.theme;return Node(c.element,_objectSpread(_objectSpread({},c.rawProps),{},{nodetheme:f})).render()}return c};return function(){var a=0<arguments.length&&arguments[0]!==void 0?arguments[0]:{};return Node(b,a).render()}}/**
182
- * Creates a portal wrapper component for rendering content outside the normal DOM hierarchy.
183
- * Portals are useful for rendering modals, tooltips, and other overlays that need to break out
184
- * of their parent container's DOM structure while maintaining React context and event bubbling.
158
+ * Creates a portal component that renders its content outside the normal DOM hierarchy.
159
+ * Supports wrapping the portal content with provider components for context/theme inheritance.
185
160
  *
186
- * Key features:
187
- * - Renders content to a separate DOM node outside the parent hierarchy
188
- * - Maintains theme inheritance through the portal
189
- * - Provides portal instance with unmount control
190
- * - Automatically cleans up DOM nodes on unmount
191
- * @template P Props type for the wrapped component including theme and portal instance
192
- * @param component Component function that returns portal content
193
- * @returns Function that creates and manages the portal instance
161
+ * A portal creates a new DOM element and renders React content into it, useful for modals,
162
+ * popovers, and other overlays that need to break out of their parent container's DOM hierarchy.
163
+ *
164
+ * The portal content can be wrapped with provider components to maintain context/theme inheritance:
165
+ * 1. Fixed providers specified when creating the portal via Portal(providers, component)
166
+ * 2. Dynamic providers passed as props when launching the portal
167
+ * @template P_Content - Props type for the portal's content component
194
168
  * @example
195
- * ```ts
196
- * const Modal = Portal(({ portal }) => {
197
- * return Div({
198
- * onClick: () => portal.unmount(),
199
- * children: "Click to close"
200
- * })
169
+ * // Basic portal with no providers
170
+ * const Modal = Portal((props) => Div({ children: props.children }));
171
+ *
172
+ * // Portal with fixed theme provider
173
+ * const ThemedModal = Portal(
174
+ * ThemeProvider({ theme }),
175
+ * (props) => Div({ children: props.children })
176
+ * )
177
+ *
178
+ * // Usage with dynamic providers
179
+ * const modal = Modal({
180
+ * providers: [ThemeProvider({ theme })],
181
+ * children: "Modal content"
201
182
  * })
202
- * ```
203
- */export function Portal(a){var b=null,c=function renderer(){var c=0<arguments.length&&arguments[0]!==void 0?arguments[0]:{},d=a(_objectSpread(_objectSpread({},c),{},{portal:b}));if(d instanceof BaseNode){var e,f,g=(null===(e=d.rawProps)||void 0===e?void 0:e.nodetheme)||(null===(f=d.rawProps)||void 0===f?void 0:f.theme)||c.nodetheme||c.theme;return Node(d.element,_objectSpread(_objectSpread({},d.rawProps),{},{nodetheme:g})).render()}return d};return function(){var a=0<arguments.length&&void 0!==arguments[0]?arguments[0]:{};return b=Node(c,a).toPortal(),b}}
183
+ * modal.unmount(); // Clean up when done
184
+ */export function Portal(a,b){// Track fixed providers passed during portal creation
185
+ var c,d=void 0,e=null;// Parse arguments to determine which overload is being used
186
+ if("function"==typeof b&&(a instanceof BaseNode||Array.isArray(a)&&a.every(function(a){return a instanceof BaseNode})))// Overload 1: Portal(providers, component) - Fixed providers
187
+ d=Array.isArray(a)?a:[a],c=b;else if("function"==typeof a&&b===void 0)// Overload 2: Portal(component) - Dynamic providers via props
188
+ c=a;else throw new Error("Invalid arguments for Portal HOC. Use Portal(component) or Portal(providersArrayOrNodeInstance, component).");// Control object passed to portal content for cleanup
189
+ var f={unmount:function unmount(){e&&(e.unmount(),e=null)}},g=function renderer(){var a=0<arguments.length&&arguments[0]!==void 0?arguments[0]:{},b=a.nodetheme,d=_objectWithoutProperties(a,_excluded4),e=c(_objectSpread(_objectSpread({},d),{},{portal:f}));// Handle BaseNode results by properly applying the theme
190
+ if(e instanceof BaseNode){var g,h,i=(null===(g=e.rawProps)||void 0===g?void 0:g.nodetheme)||(null===(h=e.rawProps)||void 0===h?void 0:h.theme)||a.nodetheme;return Node(e.element,_objectSpread(_objectSpread({},e.rawProps),{},{nodetheme:i})).render()}return e};// Renderer function that executes portal content with control object
191
+ // Return launcher function that creates and manages the portal instance
192
+ return function(a){var b,c=void 0;// Combine fixed and dynamic providers in the correct order
193
+ d?c=d:a.providers&&(c=Array.isArray(a.providers)?a.providers:[a.providers]);// Extract props needed for portal setup vs content
194
+ var f=a.providers,h=a.nodetheme,i=_objectWithoutProperties(a,_excluded5),j=_objectSpread(_objectSpread({},i),{},{nodetheme:h}),k=Node(g,j);// Create node for portal content with renderer
195
+ // Wrap content with providers if any exist
196
+ return b=c&&0<c.length?c.reduceRight(function(a,b){var c,d;// Validate each provider is a proper NodeInstance
197
+ return b instanceof BaseNode?Node(b.element,_objectSpread(_objectSpread({},b.rawProps),{},{children:a,nodetheme:(null===(c=b.rawProps)||void 0===c?void 0:c.nodetheme)||(null===(d=b.rawProps)||void 0===d?void 0:d.theme)||h})):(console.warn("Portal: Item in providers array is not a valid NodeInstance. Skipping.",b),a)},k):k,e=b.toPortal(),e}}