@meonode/ui 0.1.65 → 0.1.67
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/core.node.d.ts +28 -9
- package/dist/core.node.d.ts.map +1 -1
- package/dist/core.node.js +42 -20
- package/dist/hoc/component.hoc.d.ts.map +1 -1
- package/dist/hoc/component.hoc.js +1 -1
- package/dist/hoc/portal.hoc.js +1 -1
- package/dist/node.helper.d.ts +13 -1
- package/dist/node.helper.d.ts.map +1 -1
- package/dist/node.helper.js +11 -1
- package/dist/node.type.d.ts +5 -4
- package/dist/node.type.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/core.node.d.ts
CHANGED
|
@@ -10,13 +10,14 @@ import { type Root as ReactDOMRoot } from 'react-dom/client';
|
|
|
10
10
|
* - Style processing with theme variables
|
|
11
11
|
* @template E The type of React element or component this node represents
|
|
12
12
|
*/
|
|
13
|
-
export declare class BaseNode<E extends NodeElement> implements NodeInstance<E> {
|
|
13
|
+
export declare class BaseNode<E extends NodeElement = NodeElement> implements NodeInstance<E> {
|
|
14
14
|
/** The underlying React element or component type that this node represents */
|
|
15
15
|
element: E;
|
|
16
16
|
/** Original props passed during construction, preserved for cloning/recreation */
|
|
17
|
-
rawProps
|
|
17
|
+
rawProps: RawNodeProps<E>;
|
|
18
18
|
/** Processed props after theme resolution, style processing, and child normalization */
|
|
19
19
|
props: FinalNodeProps;
|
|
20
|
+
readonly isBaseNode = true;
|
|
20
21
|
private _portalDOMElement;
|
|
21
22
|
private _portalReactRoot;
|
|
22
23
|
/**
|
|
@@ -54,14 +55,32 @@ export declare class BaseNode<E extends NodeElement> implements NodeInstance<E>
|
|
|
54
55
|
*/
|
|
55
56
|
private _resolveObjWithTheme;
|
|
56
57
|
/**
|
|
57
|
-
*
|
|
58
|
+
* Renders a processed NodeElement into a ReactNode, applying theme and key if needed.
|
|
58
59
|
*
|
|
59
|
-
*
|
|
60
|
-
*
|
|
61
|
-
*
|
|
62
|
-
*
|
|
63
|
-
*
|
|
64
|
-
*
|
|
60
|
+
* Handles the following cases:
|
|
61
|
+
* 1. If the element is a BaseNode instance, it re-wraps it to apply the key and theme if needed.
|
|
62
|
+
* 2. If the element is a React class component type, it wraps it in a BaseNode.
|
|
63
|
+
* 3. If the element is a NodeInstance object, it calls its render method.
|
|
64
|
+
* 4. If the element is a React.Component instance, it calls its render method.
|
|
65
|
+
* 5. If the element is a functional component, it creates a React element with the provided key.
|
|
66
|
+
* 6. For all other valid ReactNode types, it returns the element as-is.
|
|
67
|
+
* @param processedElement The processed node element to render.
|
|
68
|
+
* @param passedTheme The theme to apply, if any.
|
|
69
|
+
* @param passedKey The key to assign, if any.
|
|
70
|
+
* @returns The rendered ReactNode.
|
|
71
|
+
*/
|
|
72
|
+
private _renderProcessedNode;
|
|
73
|
+
/**
|
|
74
|
+
* Renders the result of a function child, supporting theme propagation.
|
|
75
|
+
*
|
|
76
|
+
* Used for children that are functions (`() => Children`). If the returned value is a `BaseNode`
|
|
77
|
+
* without an explicit theme, the parent theme is injected. Otherwise, the result is rendered as-is.
|
|
78
|
+
* @template E - The type of ReactNode or NodeInstance.
|
|
79
|
+
* @param props Renderer props.
|
|
80
|
+
* @param props.render Function to invoke for rendering the child.
|
|
81
|
+
* @param props.passedTheme Theme to provide to the child, if applicable.
|
|
82
|
+
* @param props.passedKey Key to assign to the rendered node.
|
|
83
|
+
* @param props.processRawNode Function to process raw nodes.
|
|
65
84
|
* @returns The rendered ReactNode, with theme applied if necessary.
|
|
66
85
|
*/
|
|
67
86
|
private _functionRenderer;
|
package/dist/core.node.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"core.node.d.ts","sourceRoot":"","sources":["../src/core.node.ts"],"names":[],"mappings":"AACA,OAAc,EAAsG,KAAK,SAAS,EAAE,MAAM,OAAO,CAAA;AACjJ,OAAO,KAAK,EAAE,cAAc,EAAyB,WAAW,EAAE,YAAY,EAAE,SAAS,EAAE,YAAY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AAO,EAAE,WAAW,EACpB,WAAW,CAAC,EAAE,KAAK,EACnB,UAAU,CAAC,EAAE,MAAM,GAClB,WAAW;IAyFd;;;;;;;;;;;;;OAaG;IACH,OAAO,CAAC,eAAe,CAmCtB;IAED;;;;OAIG;IACI,MAAM,IAAI,SAAS;IAsC1B,OAAO,CAAC,2BAA2B;IAsB5B,QAAQ,IAAI,YAAY,GAAG,IAAI;CAsBvC;AAED;;;;;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"}
|
package/dist/core.node.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";var _excluded=["ref","children","nodetheme","theme","props"],_excluded2=["flex"],_excluded3=["style"],_excluded4=["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 _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=["ref","children","nodetheme","theme","props"],_excluded2=["flex"],_excluded3=["style"],_excluded4=["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 _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,isNodeInstance}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
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
* - Normalizing children with theme inheritance
|
|
15
15
|
* @param element The React element/component to wrap
|
|
16
16
|
* @param rawProps Initial props including theme, styles, and children
|
|
17
|
-
*/constructor(a){var b=this,c=1<arguments.length&&arguments[1]!==void 0?arguments[1]:{};_defineProperty(this,"_portalDOMElement",null),_defineProperty(this,"_portalReactRoot",null),_defineProperty(this,"_normalizeChild",function(a){var c,d;if(!a)return a;var e=(null===(c=b.rawProps)||void 0===c?void 0:c.nodetheme)||(null===(d=b.rawProps)||void 0===d?void 0:d.theme)||b.props.nodetheme||b.props.theme;// For BaseNode instances, apply current theme if child has no theme
|
|
17
|
+
*/constructor(a){var b=this,c=1<arguments.length&&arguments[1]!==void 0?arguments[1]:{};_defineProperty(this,"rawProps",{}),_defineProperty(this,"isBaseNode",!0),_defineProperty(this,"_portalDOMElement",null),_defineProperty(this,"_portalReactRoot",null),_defineProperty(this,"_normalizeChild",function(a){var c,d;if(!a)return a;var e=(null===(c=b.rawProps)||void 0===c?void 0:c.nodetheme)||(null===(d=b.rawProps)||void 0===d?void 0:d.theme)||b.props.nodetheme||b.props.theme;// For BaseNode instances, apply current theme if child has no theme
|
|
18
18
|
if(a instanceof BaseNode){var f;return null!==(f=a.rawProps)&&void 0!==f&&f.nodetheme||void 0===e?a.render():new BaseNode(a.element,_objectSpread(_objectSpread({},a.rawProps),{},{nodetheme:e})).render()}// For React.Component instances, wrap in BaseNode with theme if needed
|
|
19
19
|
if(a instanceof React.Component)return a.props.nodetheme||void 0===e?a.render():new BaseNode(a.render(),_objectSpread(_objectSpread({},a.props),{},{nodetheme:e})).render();// Validate element type before returning
|
|
20
20
|
if(!isValidElementType(a)){var g=getComponentType(a);throw new Error("Invalid element type: ".concat(g," provided!"))}// Return valid React elements as-is
|
|
@@ -52,9 +52,10 @@ i&&!g?h=0:j&&!g&&(h=0)}return _objectSpread({flex:c,flexShrink:h,minHeight:0,min
|
|
|
52
52
|
if(!b||0===Object.keys(a).length)return a;// Merge parent theme with current theme
|
|
53
53
|
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
|
|
54
54
|
if(b.has(a))return a;// Track this object to detect circular references
|
|
55
|
-
b.add(a);var c={};for(var f in a)
|
|
56
|
-
|
|
57
|
-
|
|
55
|
+
b.add(a);var c={};for(var f in a){var g=a[f];// Skip complex objects/functions unless they are specifically targeted for theme resolution
|
|
56
|
+
// This prevents inadvertently flattening or stripping methods from instances like dayjs, React components, etc.
|
|
57
|
+
// You might need to refine this condition based on what specific types you want to *never* resolve/transform
|
|
58
|
+
if("function"==typeof g||g instanceof HTMLElement||g instanceof Date||g&&"object"===_typeof(g)&&!Array.isArray(g)&&Object.getPrototypeOf(g)!==Object.prototype){c[f]=g;continue}// Resolve theme variables in string values
|
|
58
59
|
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
|
|
59
60
|
return void 0!==c&&null!==c?"object"===_typeof(c)&&!Array.isArray(c)&&"default"in c?c["default"]:c:a;// Keep original if no valid theme value found
|
|
60
61
|
}),c[f]=h}// Recursively process nested objects
|
|
@@ -62,23 +63,44 @@ else c[f]=g&&"object"===_typeof(g)&&!Array.isArray(g)?e(g,b):g}return c};/**
|
|
|
62
63
|
* Recursively resolves theme variables in an object, tracking visited objects
|
|
63
64
|
* to prevent infinite recursion with circular references.
|
|
64
65
|
*/return e(a,new Set)}/**
|
|
65
|
-
*
|
|
66
|
+
* Renders a processed NodeElement into a ReactNode, applying theme and key if needed.
|
|
66
67
|
*
|
|
67
|
-
*
|
|
68
|
-
*
|
|
69
|
-
*
|
|
70
|
-
*
|
|
71
|
-
*
|
|
72
|
-
*
|
|
68
|
+
* Handles the following cases:
|
|
69
|
+
* 1. If the element is a BaseNode instance, it re-wraps it to apply the key and theme if needed.
|
|
70
|
+
* 2. If the element is a React class component type, it wraps it in a BaseNode.
|
|
71
|
+
* 3. If the element is a NodeInstance object, it calls its render method.
|
|
72
|
+
* 4. If the element is a React.Component instance, it calls its render method.
|
|
73
|
+
* 5. If the element is a functional component, it creates a React element with the provided key.
|
|
74
|
+
* 6. For all other valid ReactNode types, it returns the element as-is.
|
|
75
|
+
* @param processedElement The processed node element to render.
|
|
76
|
+
* @param passedTheme The theme to apply, if any.
|
|
77
|
+
* @param passedKey The key to assign, if any.
|
|
78
|
+
* @returns The rendered ReactNode.
|
|
79
|
+
*/_renderProcessedNode(a,b,c){var d={};// 1. BaseNode instance: re-wrap to apply key/theme if needed
|
|
80
|
+
if(void 0!==c&&(d.key=c),a instanceof BaseNode){var e,f,g=(null===(e=a.rawProps)||void 0===e?void 0:e.theme)||(null===(f=a.rawProps)||void 0===f?void 0:f.nodetheme)||b;return new BaseNode(a.element,_objectSpread(_objectSpread(_objectSpread({},a.rawProps),d),{},{nodetheme:g})).render()}// 2. React class component type: wrap in BaseNode
|
|
81
|
+
return isReactClassComponent(a)?new BaseNode(a,d).render():isNodeInstance(a)?a.render():a instanceof React.Component?a.render():"function"==typeof a?createElement(a,{key:c}):a;// 3. NodeInstance object: call its render
|
|
82
|
+
// 4. React.Component instance: call its render
|
|
83
|
+
// 5. Functional component: create element with key
|
|
84
|
+
// 6. Other valid ReactNode types
|
|
85
|
+
}/**
|
|
86
|
+
* Renders the result of a function child, supporting theme propagation.
|
|
87
|
+
*
|
|
88
|
+
* Used for children that are functions (`() => Children`). If the returned value is a `BaseNode`
|
|
89
|
+
* without an explicit theme, the parent theme is injected. Otherwise, the result is rendered as-is.
|
|
90
|
+
* @template E - The type of ReactNode or NodeInstance.
|
|
91
|
+
* @param props Renderer props.
|
|
92
|
+
* @param props.render Function to invoke for rendering the child.
|
|
93
|
+
* @param props.passedTheme Theme to provide to the child, if applicable.
|
|
94
|
+
* @param props.passedKey Key to assign to the rendered node.
|
|
95
|
+
* @param props.processRawNode Function to process raw nodes.
|
|
73
96
|
* @returns The rendered ReactNode, with theme applied if necessary.
|
|
74
|
-
*/_functionRenderer(a){var b=a.render,c=a.passedTheme,d=a.passedKey,e=a.processRawNode,f=b();//
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
return void 0===(null===(
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
return f}/**
|
|
97
|
+
*/_functionRenderer(a){var b=a.render,c=a.passedTheme,d=a.passedKey,e=a.processRawNode,f=b();// Invoke the render function to get the child node.
|
|
98
|
+
// Handle React.Component instance
|
|
99
|
+
if(f instanceof React.Component){var g=f.render(),h=e(g,c);return this._renderProcessedNode(h,c,d)}// Handle BaseNode instance
|
|
100
|
+
if(f instanceof BaseNode){var i,j=f;return void 0===(null===(i=j.rawProps)||void 0===i?void 0:i.nodetheme)&&void 0!==c?new BaseNode(j.element,_objectSpread(_objectSpread({key:d},j.rawProps),{},{nodetheme:c})).render():j.render()}// Process other result types
|
|
101
|
+
var k=e(f,c);return k?this._renderProcessedNode(k,c,d):isNodeInstance(f)?f.render():f;// Fallback: return result directly (e.g., JSX, string, etc.)
|
|
102
|
+
// Non-BaseNode results will not automatically receive the theme.
|
|
103
|
+
}/**
|
|
82
104
|
* Processes a single raw child element, converting it into a ProcessedChild.
|
|
83
105
|
* If the child is part of an array and lacks an explicit key, a stable indexed key
|
|
84
106
|
* (`elementName_child_index`) is generated for new BaseNode instances.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"component.hoc.d.ts","sourceRoot":"","sources":["../../src/hoc/component.hoc.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAA;AAChE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AAEtC;;;;;;;;;;;;;;;;;;;;;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,
|
|
1
|
+
{"version":3,"file":"component.hoc.d.ts","sourceRoot":"","sources":["../../src/hoc/component.hoc.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAA;AAChE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AAEtC;;;;;;;;;;;;;;;;;;;;;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,IAiBG,QAAO,OAAO,CAAC,CAAC,CAAM,eAG5C"}
|
|
@@ -22,4 +22,4 @@
|
|
|
22
22
|
*/export function Component(a){// Create a wrapper component that handles theme and rendering
|
|
23
23
|
var b=function Renderer(b){var c=a(b);// Execute wrapped component
|
|
24
24
|
// Handle BaseNode results - requires special processing
|
|
25
|
-
if(c instanceof BaseNode){var d,e,
|
|
25
|
+
if(c instanceof BaseNode){var d,e;return Node(c.element,_objectSpread(_objectSpread({},c.rawProps),{},{nodetheme:(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})).render()}return c};return function Func(){var a=0<arguments.length&&arguments[0]!==void 0?arguments[0]:{};return Node(b,a).render()}}
|
package/dist/hoc/portal.hoc.js
CHANGED
|
@@ -77,7 +77,7 @@ c=a;else throw new Error("Invalid arguments for Portal HOC. Use Portal(component
|
|
|
77
77
|
// It receives props and handles theme application and portal control.
|
|
78
78
|
var f=function Renderer(){var a=0<arguments.length&&arguments[0]!==void 0?arguments[0]:{},b=a.nodetheme,d=_objectWithoutProperties(a,_excluded),f=c(_objectSpread(_objectSpread({},d),{},{portal:e// Passes the portal control object to the content component
|
|
79
79
|
}));// Ensures that the theme is correctly applied if the result is a BaseNode.
|
|
80
|
-
if(f instanceof BaseNode){var g,h,
|
|
80
|
+
if(f instanceof BaseNode){var g,h;return Node(f.element,_objectSpread(_objectSpread({},f.rawProps),{},{nodetheme:(null===(g=f.rawProps)||void 0===g?void 0:g.nodetheme)||(null===(h=f.rawProps)||void 0===h?void 0:h.theme)||a.nodetheme})).render()}return f};// --- Portal Launcher Function (Returned to User) ---
|
|
81
81
|
// This is the function that developers call to actually create and manage a portal instance.
|
|
82
82
|
return function Func(a){// --- Helper for Deep Content Injection ---
|
|
83
83
|
// Recursively injects content into the deepest child of a provider chain.
|
package/dist/node.helper.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { ComponentProps, CSSProperties, ElementType } from 'react';
|
|
2
|
-
import type { NodeElement, FinalNodeProps } from './node.type.js';
|
|
2
|
+
import type { NodeElement, FinalNodeProps, NodeInstance } from './node.type.js';
|
|
3
3
|
/**
|
|
4
4
|
* Returns a string describing the type of a given React component or element.
|
|
5
5
|
*
|
|
@@ -71,4 +71,16 @@ export declare function getDOMProps<E extends ElementType, T extends ComponentPr
|
|
|
71
71
|
* @returns The value at the specified path, or undefined if not found.
|
|
72
72
|
*/
|
|
73
73
|
export declare function getValueByPath(obj: Record<string, any> | undefined, path: string): Record<string, any>;
|
|
74
|
+
/**
|
|
75
|
+
* Type guard to check if an object is a NodeInstance.
|
|
76
|
+
*
|
|
77
|
+
* A NodeInstance is expected to be a non-null object with:
|
|
78
|
+
* - an 'element' property,
|
|
79
|
+
* - a 'render' method,
|
|
80
|
+
* - a 'toPortal' method,
|
|
81
|
+
* - and an 'isBaseNode' property.
|
|
82
|
+
* @param obj The object to check.
|
|
83
|
+
* @returns True if the object is a NodeInstance, false otherwise.
|
|
84
|
+
*/
|
|
85
|
+
export declare const isNodeInstance: (obj: unknown) => obj is NodeInstance<any>;
|
|
74
86
|
//# sourceMappingURL=node.helper.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"node.helper.d.ts","sourceRoot":"","sources":["../src/node.helper.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,OAAO,CAAA;AACvE,OAAO,KAAK,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAA;
|
|
1
|
+
{"version":3,"file":"node.helper.d.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.js
CHANGED
|
@@ -57,4 +57,14 @@
|
|
|
57
57
|
* @param obj The object to traverse. Defaults to an empty object if not provided.
|
|
58
58
|
* @param path The dot-separated path string (e.g., 'background.primary').
|
|
59
59
|
* @returns The value at the specified path, or undefined if not found.
|
|
60
|
-
*/export function getValueByPath(){var a=0<arguments.length&&arguments[0]!==void 0?arguments[0]:{},b=1<arguments.length?arguments[1]:void 0;return b.split(".").reduce(function(a,b){return null===a||void 0===a?void 0:a[b]},a)}
|
|
60
|
+
*/export function getValueByPath(){var a=0<arguments.length&&arguments[0]!==void 0?arguments[0]:{},b=1<arguments.length?arguments[1]:void 0;return b.split(".").reduce(function(a,b){return null===a||void 0===a?void 0:a[b]},a)}/**
|
|
61
|
+
* Type guard to check if an object is a NodeInstance.
|
|
62
|
+
*
|
|
63
|
+
* A NodeInstance is expected to be a non-null object with:
|
|
64
|
+
* - an 'element' property,
|
|
65
|
+
* - a 'render' method,
|
|
66
|
+
* - a 'toPortal' method,
|
|
67
|
+
* - and an 'isBaseNode' property.
|
|
68
|
+
* @param obj The object to check.
|
|
69
|
+
* @returns True if the object is a NodeInstance, false otherwise.
|
|
70
|
+
*/export var isNodeInstance=function isNodeInstance(a){return"object"===_typeof(a)&&null!==a&&"element"in a&&"function"==typeof a.render&&"function"==typeof a.toPortal&&"isBaseNode"in a};
|
package/dist/node.type.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { Attributes as ReactAttributes, ComponentProps, CSSProperties, ReactNode, JSX, ElementType, ComponentType, JSXElementConstructor, Component, Ref } from 'react';
|
|
2
2
|
import type { Root as ReactDOMRoot } from 'react-dom/client';
|
|
3
|
-
export type NodeElement = ReactNode | Component<any, any> | ElementType | ComponentType<any> | NodeInstance<any> | ((props?: any) => ReactNode | Promise<ReactNode> | Component<any> | NodeInstance<any> | ComponentNode);
|
|
3
|
+
export type NodeElement = ReactNode | Component<any, any, any> | ElementType | ComponentType<any> | NodeInstance<any> | ((props?: any) => ReactNode | Promise<ReactNode> | Component<any, any, any> | NodeInstance<any> | ComponentNode);
|
|
4
4
|
/**
|
|
5
5
|
* Defines valid child types that can be passed to a node:
|
|
6
6
|
* - ReactNode: Any valid React child (elements, strings, numbers, etc.)
|
|
@@ -18,7 +18,8 @@ export interface NodeInstance<T extends NodeElement = NodeElement> {
|
|
|
18
18
|
/** The underlying React element or component type that this node will render */
|
|
19
19
|
readonly element: T;
|
|
20
20
|
/** Original props passed during node construction, preserved for cloning/recreation */
|
|
21
|
-
readonly rawProps
|
|
21
|
+
readonly rawProps: RawNodeProps<T>;
|
|
22
|
+
readonly isBaseNode: true;
|
|
22
23
|
/** Converts this node instance into a renderable React element/tree */
|
|
23
24
|
render(): ReactNode;
|
|
24
25
|
/** Creates Portal-compatible React elements for rendering outside of the DOM tree */
|
|
@@ -73,7 +74,7 @@ type HasCSSCompatibleStyleProp<P> = P extends {
|
|
|
73
74
|
* - Maintains React's key prop for reconciliation
|
|
74
75
|
* @template E - The element type these props apply to
|
|
75
76
|
*/
|
|
76
|
-
export type NodeProps<E extends NodeElement> = Omit<PropsOf<E>, 'children'> & ReactAttributes & (HasCSSCompatibleStyleProp<PropsOf<E>> extends true ?
|
|
77
|
+
export type NodeProps<E extends NodeElement> = Omit<PropsOf<E>, keyof CSSProperties | 'children'> & ReactAttributes & (HasCSSCompatibleStyleProp<PropsOf<E>> extends true ? CSSProperties : object) & Partial<{
|
|
77
78
|
props: Omit<PropsOf<E>, 'children'>;
|
|
78
79
|
children: Children | Children[];
|
|
79
80
|
theme: Theme;
|
|
@@ -102,7 +103,7 @@ export interface FunctionRendererProps<E extends NodeElement> {
|
|
|
102
103
|
passedTheme?: Theme;
|
|
103
104
|
/** Optional key prop to help React identify unique instances in lists */
|
|
104
105
|
passedKey?: string;
|
|
105
|
-
processRawNode: (node: NodeElement, parentTheme?: Theme, childIndex?: number) =>
|
|
106
|
+
processRawNode: (node: NodeElement, parentTheme?: Theme, childIndex?: number) => NodeElement;
|
|
106
107
|
}
|
|
107
108
|
export type ComponentNode = (NodeInstance<any> | ReactNode) | (() => NodeInstance<any> | ReactNode);
|
|
108
109
|
/**
|
package/dist/node.type.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"node.type.d.ts","sourceRoot":"","sources":["../src/node.type.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,UAAU,IAAI,eAAe,EAC7B,cAAc,EACd,aAAa,EACb,SAAS,EACT,GAAG,EACH,WAAW,EACX,aAAa,EACb,qBAAqB,EACrB,SAAS,EACT,GAAG,EACJ,MAAM,OAAO,CAAA;AACd,OAAO,KAAK,EAAE,IAAI,IAAI,YAAY,EAAE,MAAM,kBAAkB,CAAA;AAE5D,MAAM,MAAM,WAAW,GACnB,SAAS,GACT,SAAS,CAAC,GAAG,EAAE,GAAG,CAAC,
|
|
1
|
+
{"version":3,"file":"node.type.d.ts","sourceRoot":"","sources":["../src/node.type.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,UAAU,IAAI,eAAe,EAC7B,cAAc,EACd,aAAa,EACb,SAAS,EACT,GAAG,EACH,WAAW,EACX,aAAa,EACb,qBAAqB,EACrB,SAAS,EACT,GAAG,EACJ,MAAM,OAAO,CAAA;AACd,OAAO,KAAK,EAAE,IAAI,IAAI,YAAY,EAAE,MAAM,kBAAkB,CAAA;AAE5D,MAAM,MAAM,WAAW,GACnB,SAAS,GACT,SAAS,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,GACxB,WAAW,GACX,aAAa,CAAC,GAAG,CAAC,GAClB,YAAY,CAAC,GAAG,CAAC,GACjB,CAAC,CAAC,KAAK,CAAC,EAAE,GAAG,KAAK,SAAS,GAAG,OAAO,CAAC,SAAS,CAAC,GAAG,SAAS,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,GAAG,YAAY,CAAC,GAAG,CAAC,GAAG,aAAa,CAAC,CAAA;AAEpH;;;;;;GAMG;AACH,MAAM,MAAM,QAAQ,G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E,WAAW,CAAC,EAAE,KAAK,EAAE,UAAU,CAAC,EAAE,MAAM,KAAK,WAAW,CAAA;CAC7F;AAED,MAAM,MAAM,aAAa,GAAG,CAAC,YAAY,CAAC,GAAG,CAAC,GAAG,SAAS,CAAC,GAAG,CAAC,MAAM,YAAY,CAAC,GAAG,CAAC,GAAG,SAAS,CAAC,CAAA;AAEnG;;;;GAIG;AACH,MAAM,MAAM,WAAW,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,IAAI,CAAC,GAAG;IAC3D,0CAA0C;IAC1C,QAAQ,CAAC,EAAE,WAAW,GAAG,WAAW,EAAE,CAAA;IAEtC,yDAAyD;IACzD,MAAM,EAAE;QACN,wCAAwC;QACxC,OAAO,EAAE,MAAM,IAAI,CAAA;KACpB,CAAA;CACF,CAAA;AAED;;;;GAIG;AACH,MAAM,MAAM,cAAc,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,IAAI,CAC1D,KAAK,EAAE,CAAC,GAAG;IACT,8DAA8D;IAC9D,QAAQ,CAAC,EACL,YAAY,CAAC,GAAG,CAAC;IAEnB;;;OAGG;OACD,YAAY,CAAC,GAAG,CAAC,EAAE,CAAA;CACxB,GAAG,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC,EAAE,QAAQ,CAAC,KAC/B,YAAY,GAAG,IAAI,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@meonode/ui",
|
|
3
3
|
"description": "A structured approach to component composition with built-in theming, prop separation, and dynamic children handling.",
|
|
4
|
-
"version": "0.1.
|
|
4
|
+
"version": "0.1.67",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/main.js",
|
|
7
7
|
"types": "./dist/main.d.ts",
|