@meonode/ui 0.1.71 → 0.1.73
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 +1 -1
- package/dist/core.node.d.ts.map +1 -1
- package/dist/core.node.js +13 -17
- package/package.json +1 -1
package/dist/core.node.d.ts
CHANGED
|
@@ -69,7 +69,7 @@ export declare class BaseNode<E extends NodeElement = NodeElement> implements No
|
|
|
69
69
|
* @param passedKey The key to assign, if any.
|
|
70
70
|
* @returns The rendered ReactNode.
|
|
71
71
|
*/
|
|
72
|
-
|
|
72
|
+
static _renderProcessedNode(processedElement: NodeElement, passedTheme: Theme | undefined, passedKey: string | undefined): ReactNode;
|
|
73
73
|
/**
|
|
74
74
|
* Renders the result of a function child, supporting theme propagation.
|
|
75
75
|
*
|
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,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAA;AAGzI,OAAO,EAAc,KAAK,IAAI,IAAI,YAAY,EAAE,MAAM,kBAAkB,CAAA;AAExE;;;;;;;;GAQG;AACH,qBAAa,QAAQ,CAAC,CAAC,SAAS,WAAW,GAAG,WAAW,CAAE,YAAW,YAAY,CAAC,CAAC,CAAC;IACnF,+EAA+E;IACxE,OAAO,EAAE,CAAC,CAAA;IAEjB,kFAAkF;IAC3E,QAAQ,EAAE,YAAY,CAAC,CAAC,CAAC,CAAK;IAErC,wFAAwF;IACjF,KAAK,EAAE,cAAc,CAAA;IAE5B,SAAgB,UAAU,QAAO;IAEjC,OAAO,CAAC,iBAAiB,CAA8B;IACvD,OAAO,CAAC,gBAA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G,SAAS;IAwCpI;;;;;;;;;;;;OAYG;IACH,OAAO,CAAC,iBAAiB;IAgCzB;;;;;;;;OAQG;IACI,eAAe,CACpB,OAAO,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
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
* @param rawProps Initial props including theme, styles, and children
|
|
17
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
|
-
if(a instanceof React.Component)return a.props.nodetheme||void 0===e?a.render():new BaseNode(a
|
|
19
|
+
if(a instanceof React.Component)return a.props.nodetheme||void 0===e?a.render():new BaseNode(a,_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
|
|
21
21
|
return a}),this.element=a,this.rawProps=c;// Destructure raw props into relevant parts
|
|
22
22
|
var d=c.ref,e=c.children,f=c.nodetheme,g=c.theme,h=c.props,i=_objectWithoutProperties(c,_excluded),j=g||f,k=this._resolveObjWithTheme(i,j),l=getCSSProps(k),m=this._resolveDefaultStyle(l),n=_objectSpread(_objectSpread({},m),k.style),o=getDOMProps(k),p=void 0;// Resolve any theme variables in the remaining props
|
|
@@ -50,20 +50,18 @@ i&&!g?h=0:j&&!g&&(h=0)}return _objectSpread({flex:c,flexShrink:h,minHeight:0,min
|
|
|
50
50
|
* @returns A new object with all theme variables resolved to their values
|
|
51
51
|
*/_resolveObjWithTheme(a,b){var c;// Early return if no theme or empty object
|
|
52
52
|
if(!b||0===Object.keys(a).length)return a;// Merge parent theme with current theme
|
|
53
|
-
var d=_objectSpread(_objectSpread({},null===(c=this.rawProps)||void 0===c?void 0:c.nodetheme),b),e=
|
|
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
|
|
56
|
-
//
|
|
57
|
-
//
|
|
58
|
-
if("
|
|
59
|
-
if("string"==typeof h&&h.includes("theme.")){var i=h;i=i.replace(/theme\.([a-zA-Z0-9_.-]+)/g,function(a,b){var c=getValueByPath(d,b);// Only convert string/number theme values
|
|
55
|
+
b.add(a);var c={};for(var f in a){var g=a[f];// Skip functions and non-plain objects to prevent unintended flattening or
|
|
56
|
+
// modification of complex instances like React components, DOM elements, or Date objects.
|
|
57
|
+
if("function"==typeof g||g&&"object"===_typeof(g)&&!Array.isArray(g)&&Object.getPrototypeOf(g)!==Object.prototype){c[f]=g;continue}// Resolve theme variables in string values
|
|
58
|
+
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
|
|
60
59
|
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
|
|
61
|
-
}),c[
|
|
62
|
-
else c[
|
|
63
|
-
/**
|
|
60
|
+
}),c[f]=h}// Recursively process nested objects
|
|
61
|
+
else c[f]=g&&"object"===_typeof(g)&&!Array.isArray(g)?e(g,b):g}return c};/**
|
|
64
62
|
* Recursively resolves theme variables in an object, tracking visited objects
|
|
65
63
|
* to prevent infinite recursion with circular references.
|
|
66
|
-
*/return
|
|
64
|
+
*/return e(a,new Set)}/**
|
|
67
65
|
* Renders a processed NodeElement into a ReactNode, applying theme and key if needed.
|
|
68
66
|
*
|
|
69
67
|
* Handles the following cases:
|
|
@@ -77,7 +75,7 @@ else c[g]=h&&"object"===_typeof(h)&&!Array.isArray(h)?f(h,b):h}return c};// Dete
|
|
|
77
75
|
* @param passedTheme The theme to apply, if any.
|
|
78
76
|
* @param passedKey The key to assign, if any.
|
|
79
77
|
* @returns The rendered ReactNode.
|
|
80
|
-
*/_renderProcessedNode(a,b,c){var d={};// 1. BaseNode instance: re-wrap to apply key/theme if needed
|
|
78
|
+
*/static _renderProcessedNode(a,b,c){var d={};// 1. BaseNode instance: re-wrap to apply key/theme if needed
|
|
81
79
|
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
|
|
82
80
|
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
|
|
83
81
|
// 4. React.Component instance: call its render
|
|
@@ -97,11 +95,9 @@ return isReactClassComponent(a)?new BaseNode(a,d).render():isNodeInstance(a)?a.r
|
|
|
97
95
|
* @returns The rendered ReactNode, with theme applied if necessary.
|
|
98
96
|
*/_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.
|
|
99
97
|
// Handle React.Component instance
|
|
100
|
-
if(f instanceof React.Component){var g=f.render(),h=e(g,c);return
|
|
101
|
-
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
|
|
102
|
-
var k=e(f,c);return k?
|
|
103
|
-
// Non-BaseNode results will not automatically receive the theme.
|
|
104
|
-
}/**
|
|
98
|
+
if(f instanceof React.Component){var g=f.render(),h=e(g,c);return BaseNode._renderProcessedNode(h,c,d)}// Handle BaseNode instance
|
|
99
|
+
if(f instanceof BaseNode||isNodeInstance(f)){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
|
|
100
|
+
var k=e(f,c);return k?BaseNode._renderProcessedNode(k,c,d):f}/**
|
|
105
101
|
* Processes a single raw child element, converting it into a ProcessedChild.
|
|
106
102
|
* If the child is part of an array and lacks an explicit key, a stable indexed key
|
|
107
103
|
* (`elementName_child_index`) is generated for new BaseNode instances.
|
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.73",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/main.js",
|
|
7
7
|
"types": "./dist/main.d.ts",
|