@meonode/ui 0.1.27 → 0.1.29

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,5 +1,5 @@
1
1
  import React from 'react';
2
- import type { ComponentNode, NodeElement, NodeInstance, NodeProps, Theme } from './node.type.js';
2
+ import type { ComponentNode, NodeElement, NodeInstance, NodeProps } from './node.type.js';
3
3
  import { type Root as ReactDOMRoot } from 'react-dom/client';
4
4
  /**
5
5
  * Factory function to create a BaseNode instance.
@@ -30,9 +30,7 @@ export declare function Node<E extends NodeElement>(element: E, props?: Partial<
30
30
  * })
31
31
  * ```
32
32
  */
33
- export declare function Component<P extends Record<string, any> & {
34
- theme?: Theme;
35
- }>(component: (props: P) => ComponentNode): (props?: any) => React.ReactNode;
33
+ export declare function Component<P extends Record<string, any>>(component: (props: P) => ComponentNode): (props?: any) => React.ReactNode;
36
34
  /**
37
35
  * Creates a portal wrapper component for rendering content outside the normal DOM hierarchy.
38
36
  * Portals are useful for rendering modals, tooltips, and other overlays that need to break out
@@ -56,10 +54,9 @@ export declare function Component<P extends Record<string, any> & {
56
54
  * })
57
55
  * ```
58
56
  */
59
- export declare function Portal<P extends Record<string, any> & {
60
- theme?: Theme;
57
+ export declare function Portal<P extends Record<string, any>>(component: (props: P & {
61
58
  portal: {
62
59
  unmount: () => void;
63
60
  };
64
- }>(component: (props: P) => ComponentNode): (props?: any) => ReactDOMRoot | null;
61
+ }) => ComponentNode): (props?: any) => ReactDOMRoot | null;
65
62
  //# 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,EAAgB,KAAK,EAAE,MAAM,mBAAmB,CAAA;AAGxJ,OAAO,EAAc,KAAK,IAAI,IA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;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAgB,SAAS,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAAE,SAAS,EAAE,CAAC,KAAK,EAAE,CAAC,KAAK,aAAa,IAiBrF,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,MAAM,EAAE;QAAE,OAAO,EAAE,MAAM,IAAI,CAAA;KAAE,CAAA;CAChC,KACE,aAAa,IAgBV,QAAO,GAAQ,yBAIxB"}
package/dist/core.node.js CHANGED
@@ -24,25 +24,51 @@ 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})}/**
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
+ /**
28
29
  * Resolves obj properties by replacing theme path placeholders with actual theme values.
29
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.
30
32
  * @param obj The initial obj properties object.
31
33
  * @param theme The theme object to use for resolving paths.
32
34
  * @returns A new CSSProperties object with theme values resolved.
33
35
  */return _createClass(BaseNode,[{key:"_resolveObjWithTheme",value:function _resolveObjWithTheme(a,b){var c;// Return early if no theme or empty object
34
36
  if(!b||0===Object.keys(a).length)return a;// Merge raw nodetheme with passed theme for resolution
35
- var d=_objectSpread(_objectSpread({},null===(c=this.rawProps)||void 0===c?void 0:c.nodetheme),b),e=function resolveRecursively(a){var b={};// Process each property in the current object
36
- for(var c in a){var f=a[c];// if (key.startsWith('_')) return currentObj // Hack to pass Next.js shitty error caused by Turbopack development thingy
37
- // Handle string values containing theme references
38
- if("string"==typeof f&&f.includes("theme.")){var g=f;// Replace theme path placeholders with actual theme values
39
- g=g.replace(/theme\.([a-zA-Z0-9_.-]+)/g,function(a,b){var c=getValueByPath(d,b);// Convert the theme value to string if it exists and is a valid type
40
- return null!=c&&["string","number"].includes(_typeof(c))?c+"":a}),b[c]=g}// Recursively process nested objects (excluding arrays)
41
- else b[c]=f&&"object"===_typeof(f)&&!Array.isArray(f)?e(f):f}return b};/**
42
- * Recursively resolves theme values in an object
43
- * @param currentObj The current object level being processed
44
- * @returns New object with resolved theme values
45
- */return e(a)}/**
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)}/**
46
72
  * React component that renders the result of a function child, supporting theme propagation.
47
73
  *
48
74
  * This component is used to render children that are functions (i.e., `() => Children`).
@@ -65,5 +65,5 @@ export declare function getDOMProps<E extends ElementType, T extends ComponentPr
65
65
  * @param path The dot-separated path string (e.g., 'background.primary').
66
66
  * @returns The value at the specified path, or undefined if not found.
67
67
  */
68
- export declare function getValueByPath(obj: Record<string, any> | undefined, path: string): any;
68
+ export declare function getValueByPath(obj: Record<string, any> | undefined, path: string): Record<string, any>;
69
69
  //# 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,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AU,GACV,UAAU,GACV,QAAQ,GACR,UAAU,GACV,aAAa,GACb,UAAU,GACV,eAAe,GACf,kBAAkB,GAClB,kBAAkB,GAClB,MAAM,GACN,SAAS,GACT,SAAS,GACT,MAgBH,CAAA;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,OAAO,GAAG,MAAM,CAsFxD;AAwBD;;;;;;;;;;;GAWG;AACH,wBAAgB,WAAW,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAAE,KAAK,EAAE,CAAC,GAAG,OAAO,CAAC,aAAa,CAAC,CAU3F;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,WAAW,CAAC,CAAC,SAAS,WAAW,EAAE,CAAC,SAAS,cAAc,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,GAAG,OAAO,CAAC,cAAc,CAAC,CAUjH;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,cAAc,CAAC,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,YAAK,EAAE,IAAI,EAAE,MAAM,uBAEzE"}
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.27",
4
+ "version": "0.1.29",
5
5
  "type": "module",
6
6
  "main": "./dist/main.js",
7
7
  "types": "./dist/main.d.ts",