@meonode/ui 0.2.21 → 0.3.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.
@@ -1,5 +1,5 @@
1
1
  import type { CSSProperties } from 'react';
2
- import type { Children, NodeInstance, Theme } from '../node.type.js';
2
+ import type { NodeInstance } from '../node.type.js';
3
3
  /**
4
4
  * Type guard to check if an object is a NodeInstance.
5
5
  *
@@ -893,14 +893,4 @@ export declare const resolveDefaultStyle: (style: CSSProperties) => {
893
893
  minHeight: import("csstype").Property.MinHeight<string | number>;
894
894
  minWidth: import("csstype").Property.MinWidth<string | number>;
895
895
  };
896
- /**
897
- * Public: createStableHash
898
- * Produces a deterministic string signature for children + theme.
899
- * Keep traversal limited so it is cheap in large trees.
900
- *
901
- * If you prefer a shorter hashed output, wrap the returned string in a lightweight
902
- * hash function (fnv1a, xxhash, etc.). Returning the full signature is useful
903
- * for debugging and deterministic comparisons.
904
- */
905
- export declare function createStableHash(children: Children, theme?: Theme): string;
906
896
  //# sourceMappingURL=node.helper.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"node.helper.d.ts","sourceRoot":"","sources":["../../src/helper/node.helper.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,OAAO,CAAA;AAC1C,OAAO,KAAK,EAAE,QAAQ,EAAE,YAAY,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAA;AAItE;;;;;;;;;;GAUG;AACH,eAAO,MAAM,cAAc,4CAS1B,CAAA;AA4DD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqDG;AACH,eAAO,MAAM,mBAAmB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAiE/B,CAAA;AA8FD;;;;;;;;GAQG;AACH,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,QAAQ,EAAE,KAAK,CAAC,EAAE,KAAK,UAIjE"}
1
+ {"version":3,"file":"node.helper.d.ts","sourceRoot":"","sources":["../../src/helper/node.helper.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,OAAO,CAAA;AAC1C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAA;AAErD;;;;;;;;;;GAUG;AACH,eAAO,MAAM,cAAc,4CAS1B,CAAA;AA4DD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqDG;AACH,eAAO,MAAM,mBAAmB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAiE/B,CAAA"}
@@ -1,4 +1,4 @@
1
- "use strict";var _excluded=["flex"];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)}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 _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)}import{getElementTypeName}from"./common.helper.js";import{ObjHelper}from"./obj.helper.js";/**
1
+ "use strict";var _excluded=["flex"];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)}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 _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)}/**
2
2
  * Type guard to check if an object is a NodeInstance.
3
3
  *
4
4
  * A NodeInstance is expected to be a non-null object with:
@@ -109,24 +109,4 @@ if(!f){var k="column"===d.flexDirection||"column-reverse"===d.flexDirection,l="r
109
109
  return _objectSpread({flex:c,// Preserve original flex shorthand
110
110
  flexShrink:j,// Apply computed or explicit flexShrink
111
111
  minHeight:0,// Fix flex item scrolling issues
112
- minWidth:0},d)};/**
113
- * Create a stable signature for a React node (children) with bounded traversal.
114
- * This focuses on the structural identity important for rendering decisions:
115
- * - element type (string or component name)
116
- * - key (if present)
117
- * - basic children shape (recursing within limits)
118
- */function nodeSignature(a){var b=Math.min,c=1<arguments.length&&void 0!==arguments[1]?arguments[1]:5,d=2<arguments.length&&void 0!==arguments[2]?arguments[2]:6,e=3<arguments.length&&void 0!==arguments[3]?arguments[3]:new WeakSet;if(null===a)return"null";if(void 0===a)return"undefined";var f=_typeof(a);if("string"===f)return"s:".concat(a);if("number"===f)return"n:".concat(a+"");if("boolean"===f)return"b:".concat(a+"");if("function"===f)return"\u0192:(".concat(a+"",")");if("symbol"===f)return"sym:".concat(a+"");// Circular reference check for all objects
119
- if("object"===f){if(e.has(a))return"[Circular]";e.add(a)}// Arrays
120
- if(Array.isArray(a)){if(0>=c)return"ary[...]";for(var g=[],h=b(a.length,d),j=0;j<h;j++)g.push(nodeSignature(a[j],c-1,d,e));return a.length>d&&g.push("...len:".concat(a.length)),"ary[".concat(g.join(","),"]")}// React element-ish: require a 'type' property
121
- if("object"===f&&a&&"type"in a){// Type can be string (div) or function/class. Use helper to get name.
122
- var l,m=a.type;try{l=getElementTypeName(m)}catch(a){try{l=m+""}catch(a){l="unknown"}}var n,o="object"===f&&"key"in a&&null!=a.key?"#".concat(a.key+""):"",p="props"in a&&"object"===_typeof(a.props)&&a.props||{};try{n=nodeSignature(p.children,c-1,d,e)}catch(a){n="<err>"}var q=p.id?"@id:".concat(p.id+""):"",r=p.className?"@class:".concat(p.className+""):"";return"el:".concat(l).concat(o).concat(q).concat(r,"{").concat(n,"}")}// Plain object: handles any other object
123
- if("object"===f&&a){if(0>=c)return"obj[...]";for(var s,t=Object.keys(a).sort(),u=[],v=b(t.length,d),w=0;w<v;w++){s=t[w];try{u.push("".concat(s,":").concat(nodeSignature(a[s],c-1,d,e)))}catch(a){u.push("".concat(s,":<err>"))}}return t.length>d&&u.push("...keys:".concat(t.length)),"obj{".concat(u.join(","),"}")}// Fallback
124
- try{return"o:".concat(a+"")}catch(a){return"o:<unserializable>"}}/**
125
- * Public: createStableHash
126
- * Produces a deterministic string signature for children + theme.
127
- * Keep traversal limited so it is cheap in large trees.
128
- *
129
- * If you prefer a shorter hashed output, wrap the returned string in a lightweight
130
- * hash function (fnv1a, xxhash, etc.). Returning the full signature is useful
131
- * for debugging and deterministic comparisons.
132
- */export function createStableHash(a,b){var c=b?ObjHelper.stringify(b,6):"theme:undefined",d=nodeSignature(a,6,8);return"".concat(c,"|").concat(d)}
112
+ minWidth:0},d)};
@@ -1,64 +1,4 @@
1
- import type { Theme } from '../node.type.js';
2
- /**
3
- * Cache manager for theme resolution operations.
4
- * Provides singleton-based caching with different strategies for server vs client environments.
5
- */
6
- declare class ThemeResolverCache {
7
- private static _instance;
8
- private readonly _resolutionCache;
9
- private readonly _pathLookupCache;
10
- private readonly _themeRegex;
11
- // Track cache statistics for performance monitoring
12
- private _stats;
13
- private constructor();
14
- /**
15
- * Get the singleton instance of the cache manager
16
- */
17
- static getInstance(): ThemeResolverCache;
18
- /**
19
- * Generate a stable cache key from object and theme
20
- */
21
- private _generateCacheKey;
22
- /**
23
- * Check if resolution result exists in cache
24
- */
25
- getResolution(obj: Record<string, any>, theme: Theme): any | null;
26
- /**
27
- * Store resolution result in cache
28
- */
29
- setResolution(obj: Record<string, any>, theme: Theme, result: any): void;
30
- /**
31
- * Get cached theme path lookup
32
- */
33
- getPathLookup(theme: Theme, path: string): any | null;
34
- /**
35
- * Cache theme path lookup result
36
- */
37
- setPathLookup(theme: Theme, path: string, value: any): void;
38
- /**
39
- * Get the shared regex instance (reused for performance)
40
- */
41
- getThemeRegex(): RegExp;
42
- /**
43
- * Clear all caches (useful for testing or memory management)
44
- */
45
- clearCaches(): void;
46
- /**
47
- * Get cache statistics for performance monitoring
48
- */
49
- getStats(): {
50
- hits: number;
51
- misses: number;
52
- pathHits: number;
53
- pathMisses: number;
54
- };
55
- /**
56
- * Check if we should use caching (server-side only for RSC optimization)
57
- */
58
- shouldCache(): boolean;
59
- }
60
- // Module-level cache instance
61
- declare const themeCache: ThemeResolverCache;
1
+ import type { ThemeSystem } from '../node.type.js';
62
2
  /**
63
3
  * Resolves theme variable references in an object's values recursively.
64
4
  * This function performs a "smart merge" to maintain object reference identity
@@ -71,9 +11,5 @@ declare const themeCache: ThemeResolverCache;
71
11
  * @returns A new object (or array) with all theme variables resolved to their corresponding values,
72
12
  * or the original object (or array) if no changes were necessary.
73
13
  */
74
- export declare const resolveObjWithTheme: (obj?: Record<string, any>, theme?: Partial<{
75
- [key: string]: any;
76
- }> | undefined) => any;
77
- // Export cache instance for testing and monitoring
78
- export { themeCache as ThemeResolverCache };
14
+ export declare const resolveObjWithTheme: (obj?: Record<string, any>, theme?: ThemeSystem | undefined) => any;
79
15
  //# sourceMappingURL=theme.helper.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"theme.helper.d.ts","sourceRoot":"","sources":["../../src/helper/theme.helper.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAA;AAG9C;;;GAGG;AACH,cAAM,kBAAkB;IACtB,OAAO,CAAC,MAAM,CAAC,SAAS,CAAkC;IAE1D,OAAO,CAAC,QAAQ,CAAC,gBAAgB,CAAyB;IAC1D,OAAO,CAAC,QAAQ,CAAC,gBAAgB,CAAyB;IAC1D,OAAO,CAAC,QAAQ,CAAC,WAAW,CAA8B;IAE1D,oDAAoD;IACpD,OAAO,CAAC,MAAM,CAKb;IAED,OAAO,eAEN;IAED;;OAEG;IACH,MAAM,CAAC,WAAW,IAAI,kBAAkB,CAKvC;IAED;;OAEG;IACH,OAAO,CAAC,iBAAiB;IAKzB;;OAEG;IACH,aAAa,CAAC,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAAE,KAAK,EAAE,KAAK,GAAG,GAAG,GAAG,IAAI,CAUhE;IAED;;OAEG;IACH,aAAa,CAAC,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,GAAG,IAAI,CAGvE;IAED;;OAEG;IACH,aAAa,CAAC,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,GAAG,GAAG,GAAG,IAAI,CAUpD;IAED;;OAEG;IACH,aAAa,CAAC,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,GAAG,IAAI,CAG1D;IAED;;OAEG;IACH,aAAa,IAAI,MAAM,CAItB;IAED;;OAEG;IACH,WAAW,IAAI,IAAI,CAIlB;IAED;;OAEG;IACH,QAAQ;;;;;MAEP;IAED;;OAEG;IACH,WAAW,IAAI,OAAO,CAErB;CACF;AAED,8BAA8B;AAC9B,QAAA,MAAM,UAAU,oBAAmC,CAAA;AAEnD;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,mBAAmB;;sBAwI/B,CAAA;AAED,mDAAmD;AACnD,OAAO,EAAE,UAAU,IAAI,kBAAkB,EAAE,CAAA"}
1
+ {"version":3,"file":"theme.helper.d.ts","sourceRoot":"","sources":["../../src/helper/theme.helper.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAA;AA8GpD;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,mBAAmB,qEAwI/B,CAAA"}
@@ -1,4 +1,4 @@
1
- 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 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{getValueByPath}from"./common.helper.js";import{ObjHelper}from"./obj.helper.js";/**
1
+ 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 _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 _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{getValueByPath}from"./common.helper.js";import{ObjHelper}from"./obj.helper.js";/**
2
2
  * Cache manager for theme resolution operations.
3
3
  * Provides singleton-based caching with different strategies for server vs client environments.
4
4
  */class ThemeResolverCache{constructor(){// Track cache statistics for performance monitoring
@@ -19,10 +19,6 @@ return"".concat(ObjHelper.stringify(a),"_").concat(ObjHelper.stringify(b))}/**
19
19
  */setPathLookup(a,b,c){var d="".concat(ObjHelper.stringify(a),"_").concat(b);this._pathLookupCache.set(d,c)}/**
20
20
  * Get the shared regex instance (reused for performance)
21
21
  */getThemeRegex(){return this._themeRegex.lastIndex=0,this._themeRegex}/**
22
- * Clear all caches (useful for testing or memory management)
23
- */clearCaches(){this._resolutionCache.clear(),this._pathLookupCache.clear(),this._stats={hits:0,misses:0,pathHits:0,pathMisses:0}}/**
24
- * Get cache statistics for performance monitoring
25
- */getStats(){return _objectSpread({},this._stats)}/**
26
22
  * Check if we should use caching (server-side only for RSC optimization)
27
23
  */shouldCache(){return"undefined"==typeof window}}// Module-level cache instance
28
24
  _defineProperty(ThemeResolverCache,"_instance",null);var themeCache=ThemeResolverCache.getInstance();/**
@@ -55,5 +51,4 @@ g=g.replace(i,function(a,c){// Check path lookup cache first
55
51
  var d=themeCache.getPathLookup(b,c);return null===d&&(d=getValueByPath(b,c),themeCache.setPathLookup(b,c,d)),void 0!==d&&null!==d?(h=!0,"object"===_typeof(d)&&!Array.isArray(d)&&"default"in d?d["default"]:d):a}),f=h&&g!==e?g:e}else"object"===_typeof(e)&&null!==e&&(// Recursively process nested objects or arrays
56
52
  f=d(e,c));f===e?l&&(k[n]=e):(!l&&(k=_objectSpread({},a),l=!0),k[n]=f)};for(var n in a)m();return k},e=d(a,new Set);// Perform the resolution
57
53
  // Cache the result (only on server-side)
58
- return themeCache.shouldCache()&&themeCache.setResolution(a,b,e),e};// Export cache instance for testing and monitoring
59
- export{themeCache as ThemeResolverCache};
54
+ return themeCache.shouldCache()&&themeCache.setResolution(a,b,e),e};
@@ -1,32 +1,29 @@
1
- import type { Children, ComponentNode, HasCSSCompatibleStyleProp, Theme } from '../node.type.js';
1
+ import type { Children, ComponentNode, HasCSSCompatibleStyleProp } from '../node.type.js';
2
2
  import { type CSSProperties, type ReactElement } from 'react';
3
3
  /**
4
4
  * Props definition for components wrapped using the `Component` higher-order function.
5
5
  *
6
6
  * This type adapts based on whether the underlying component defines its own props:
7
7
  *
8
- * - If `TProps` is `undefined`, only `children` and `theme` can be passed.
8
+ * - If `TProps` is `undefined`, only `children` can be passed.
9
9
  * - If `TProps` is defined, the component will accept:
10
10
  * - The full prop shape `TProps`
11
11
  * - Optional `props` to override part of `TProps` (excluding `children`)
12
12
  * - Optional `children`
13
- * - Optional `theme`
14
13
  *
15
14
  * If the component supports inline styles (determined via `HasCSSCompatibleStyleProp`), the props also allow `CSSProperties`.
16
15
  */
17
16
  export type ComponentNodeProps<TProps> = TProps extends undefined ? Partial<{
18
17
  children: Children;
19
- theme: Theme;
20
18
  }> : TProps & (HasCSSCompatibleStyleProp<TProps> extends true ? CSSProperties : object) & Partial<{
21
19
  props: Partial<Omit<TProps, 'children'>>;
22
20
  children: Children;
23
- theme: Theme;
24
21
  }>;
25
22
  /**
26
23
  * Creates a component from a function that uses no custom props.
27
24
  * @template TProps Must be `undefined`
28
- * @param component A function that returns a MeoNode `ComponentNode` and only uses basic props like `children` and `theme`.
29
- * @returns A React-compatible component that can accept `children` and `theme`.
25
+ * @param component A function that returns a MeoNode `ComponentNode` and only uses basic props like `children`.
26
+ * @returns A React-compatible component that can accept `children`.
30
27
  * @example
31
28
  * ```ts
32
29
  * const Title = Component((props) => {
@@ -41,7 +38,7 @@ export declare function Component<TProps extends undefined>(component: (props: C
41
38
  * Creates a component from a function that uses a defined props interface.
42
39
  * @template TProps Props interface expected by the component.
43
40
  * @param component A function that returns a MeoNode `ComponentNode` using props of type `TProps`.
44
- * @returns A React-compatible component that supports full prop shape and `theme`/`children`/`props` overrides.
41
+ * @returns A React-compatible component that supports full prop shape and `children`/`props` overrides.
45
42
  * @example
46
43
  * ```ts
47
44
  * interface ButtonProps {
@@ -1 +1 @@
1
- {"version":3,"file":"component.hoc.d.ts","sourceRoot":"","sources":["../../src/hoc/component.hoc.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,QAAQ,EAAE,aAAa,EAAE,yBAAyB,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAA;AAClG,OAAO,EAAE,KAAK,aAAa,EAAE,KAAK,YAAY,EAAkB,MAAM,OAAO,CAAA;AAI7E;;;;;;;;;;;;;GAaG;AACH,MAAM,MAAM,kBAAkB,CAAC,MAAM,IAAI,MAAM,SAAS,SAAS,GAC7D,OAAO,CAAC;IACN,QAAQ,EAAE,QAAQ,CAAA;IAClB,KAAK,EAAE,KAAK,CAAA;CACb,CAAC,GACF,MAAM,GACJ,CAAC,yBAAyB,CAAC,MAAM,CAAC,SAAS,IAAI,GAAG,aAAa,GAAG,MAAM,CAAC,GACzE,OAAO,CAAC;IACN,KAAK,EAAE,OAAO,CAAC,IAAI,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC,CAAA;IACxC,QAAQ,EAAE,QAAQ,CAAA;IAClB,KAAK,EAAE,KAAK,CAAA;CACb,CAAC,CAAA;AAER;;;;;;;;;;;;;GAaG;AACH,wBAAgB,SAAS,CAAC,MAAM,SAAS,SAAS,EAChD,SAAS,EAAE,CAAC,KAAK,EAAE,kBAAkB,CAAC,MAAM,CAAC,KAAK,aAAa,GAC9D,CAAC,KAAK,CAAC,EAAE,kBAAkB,CAAC,MAAM,CAAC,KAAK,YAAY,GAAG,OAAO,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC,CAAA;AAExF;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAgB,SAAS,CAAC,MAAM,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAC1D,SAAS,EAAE,CAAC,KAAK,EAAE,kBAAkB,CAAC,MAAM,CAAC,KAAK,aAAa,GAC9D,CAAC,KAAK,EAAE,kBAAkB,CAAC,MAAM,CAAC,KAAK,YAAY,GAAG,OAAO,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC,CAAA"}
1
+ {"version":3,"file":"component.hoc.d.ts","sourceRoot":"","sources":["../../src/hoc/component.hoc.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,QAAQ,EAAE,aAAa,EAAE,yBAAyB,EAAE,MAAM,mBAAmB,CAAA;AAC3F,OAAO,EAAE,KAAK,aAAa,EAAE,KAAK,YAAY,EAAkB,MAAM,OAAO,CAAA;AAI7E;;;;;;;;;;;;GAYG;AACH,MAAM,MAAM,kBAAkB,CAAC,MAAM,IAAI,MAAM,SAAS,SAAS,GAC7D,OAAO,CAAC;IACN,QAAQ,EAAE,QAAQ,CAAA;CACnB,CAAC,GACF,MAAM,GACJ,CAAC,yBAAyB,CAAC,MAAM,CAAC,SAAS,IAAI,GAAG,aAAa,GAAG,MAAM,CAAC,GACzE,OAAO,CAAC;IACN,KAAK,EAAE,OAAO,CAAC,IAAI,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC,CAAA;IACxC,QAAQ,EAAE,QAAQ,CAAA;CACnB,CAAC,CAAA;AAER;;;;;;;;;;;;;GAaG;AACH,wBAAgB,SAAS,CAAC,MAAM,SAAS,SAAS,EAChD,SAAS,EAAE,CAAC,KAAK,EAAE,kBAAkB,CAAC,MAAM,CAAC,KAAK,aAAa,GAC9D,CAAC,KAAK,CAAC,EAAE,kBAAkB,CAAC,MAAM,CAAC,KAAK,YAAY,GAAG,OAAO,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC,CAAA;AAExF;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAgB,SAAS,CAAC,MAAM,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAC1D,SAAS,EAAE,CAAC,KAAK,EAAE,kBAAkB,CAAC,MAAM,CAAC,KAAK,aAAa,GAC9D,CAAC,KAAK,EAAE,kBAAkB,CAAC,MAAM,CAAC,KAAK,YAAY,GAAG,OAAO,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC,CAAA"}
@@ -1,21 +1,20 @@
1
- "use strict";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 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{BaseNode,Node}from"../core.node.js";import{getElementTypeName}from"../helper/common.helper.js";import{isNodeInstance}from"../helper/node.helper.js";/**
1
+ "use strict";import{BaseNode,Node}from"../core.node.js";import{getElementTypeName}from"../helper/common.helper.js";import{isNodeInstance}from"../helper/node.helper.js";/**
2
2
  * Props definition for components wrapped using the `Component` higher-order function.
3
3
  *
4
4
  * This type adapts based on whether the underlying component defines its own props:
5
5
  *
6
- * - If `TProps` is `undefined`, only `children` and `theme` can be passed.
6
+ * - If `TProps` is `undefined`, only `children` can be passed.
7
7
  * - If `TProps` is defined, the component will accept:
8
8
  * - The full prop shape `TProps`
9
9
  * - Optional `props` to override part of `TProps` (excluding `children`)
10
10
  * - Optional `children`
11
- * - Optional `theme`
12
11
  *
13
12
  * If the component supports inline styles (determined via `HasCSSCompatibleStyleProp`), the props also allow `CSSProperties`.
14
13
  *//**
15
14
  * Creates a component from a function that uses no custom props.
16
15
  * @template TProps Must be `undefined`
17
- * @param component A function that returns a MeoNode `ComponentNode` and only uses basic props like `children` and `theme`.
18
- * @returns A React-compatible component that can accept `children` and `theme`.
16
+ * @param component A function that returns a MeoNode `ComponentNode` and only uses basic props like `children`.
17
+ * @returns A React-compatible component that can accept `children`.
19
18
  * @example
20
19
  * ```ts
21
20
  * const Title = Component((props) => {
@@ -28,7 +27,7 @@
28
27
  * Creates a component from a function that uses a defined props interface.
29
28
  * @template TProps Props interface expected by the component.
30
29
  * @param component A function that returns a MeoNode `ComponentNode` using props of type `TProps`.
31
- * @returns A React-compatible component that supports full prop shape and `theme`/`children`/`props` overrides.
30
+ * @returns A React-compatible component that supports full prop shape and `children`/`props` overrides.
32
31
  * @example
33
32
  * ```ts
34
33
  * interface ButtonProps {
@@ -47,5 +46,5 @@
47
46
  * ```
48
47
  *//**
49
48
  * Internal implementation of the `Component` HOC.
50
- * Handles theme propagation, BaseNode conversion, and wrapper creation.
51
- */export function Component(a){function Func(){var a=0<arguments.length&&void 0!==arguments[0]?arguments[0]:{};return Node(c,a).render()}var b=getElementTypeName(a),c=function Renderer(b){var c=a(b);if(c instanceof BaseNode||isNodeInstance(c)){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 c.displayName="Renderer(".concat(b,")"),Func.displayName="Component(".concat(b,")"),Func}
49
+ * Handles BaseNode conversion and wrapper creation.
50
+ */export function Component(a){function Func(){var a=0<arguments.length&&void 0!==arguments[0]?arguments[0]:{};return Node(c,a).render()}var b=getElementTypeName(a),c=function Renderer(b){var c=a(b);return c instanceof BaseNode||isNodeInstance(c)?Node(c.element,c.rawProps).render():c};return c.displayName="Renderer(".concat(b,")"),Func.displayName="Component(".concat(b,")"),Func}
@@ -1,53 +1,53 @@
1
1
  import type { BasePortalProps, ComponentNode, NodeInstance, PortalLauncher, PortalProps } from '../node.type.js';
2
+ // --- Function Overloads ---
2
3
  /**
3
- * Creates a portal component with a single fixed provider.
4
- * The content component will be rendered within this provider. This is the preferred method
5
- * for providing fixed context to your portal content.
6
- * @param provider A single `NodeInstance` that will wrap the portal content. This should typically
7
- * be a React context provider (e.g., `ThemeProvider({ theme })`).
8
- * @param component The React component function that defines the portal's content. It receives
9
- * props of type `PortalProps<P>` and should return a `ComponentNode`.
10
- * @returns A launcher function that, when called, creates and controls the portal instance.
4
+ * Higher-Order Component (HOC) to create and manage React portals with optional provider wrapping.
5
+ * This function supports two overloads:
6
+ * 1. `Portal(providerNodeInstance, component)` - Creates a portal with a fixed provider node instance.
7
+ * 2. `Portal(component)` - Creates a portal without a fixed provider, allowing dynamic providers at launch time.
8
+ * @template P The prop types for the component rendered inside the portal, extending BasePortalProps.
9
+ * @param provider Optional NodeInstance to wrap the portal content (fixed provider).
10
+ * @param component The component function that returns the content to render inside the portal.
11
+ * @returns A function that launches the portal instance, accepting props and optional dynamic providers.
11
12
  * @example
12
- * ```ts
13
- * // Example of preferred usage with a single fixed provider:
14
- * const ThemedModal = Portal(
15
- * ThemeProvider({ theme: 'light' }),
16
- * (props) => Div({ children: props.children, style: { background: props.nodetheme?.background } })
17
- * );
13
+ * // Using Portal with a fixed provider
14
+ * const MyPortal = Portal(MyProviderNodeInstance, (props) => (
15
+ * Div({
16
+ * backgroundColor: 'white',
17
+ * padding: '20px',
18
+ * borderRadius: '8px',
19
+ * children: [
20
+ * H1({ children: 'Fixed Provider Portal' }),
21
+ * Button({
22
+ * onClick: () => props.portal.unmount(),
23
+ * children: 'Close',
24
+ * }),
25
+ * ],
26
+ * })
27
+ * ));
18
28
  *
19
- * const modalInstance = ThemedModal({ children: "Preferred content" });
20
- * modalInstance.unmount();
21
- * ```
22
- */
23
- export declare function Portal<P extends BasePortalProps | Record<string, any> = BasePortalProps>(provider: NodeInstance<any>, component: (props: PortalProps<P>) => ComponentNode): PortalLauncher<P>;
24
- /**
25
- * Creates a basic portal component without any fixed providers.
26
- * Dynamic providers can still be passed as props when launching the portal instance.
27
- * @param component The React component function that defines the portal's content. It receives
28
- * props of type `PortalProps<P>` and should return a `ComponentNode`.
29
- * @returns A launcher function that, when called, creates and controls the portal instance.
29
+ * // Launching the portal
30
+ * const portalInstance = MyPortal({ someProp: 'value' });
30
31
  * @example
31
- * ```ts
32
- * // Example of basic usage without fixed providers:
33
- * const BasicModal = Portal(
34
- * (props) => Div({ children: props.children, style: { padding: '20px', border: '1px solid black' } })
35
- * );
32
+ * // Using Portal without a fixed provider
33
+ * const MyPortal = Portal((props) => (
34
+ * Div({
35
+ * backgroundColor: 'white',
36
+ * padding: '20px',
37
+ * borderRadius: '8px',
38
+ * children: [
39
+ * H1({ children: 'Dynamic Provider Portal' }),
40
+ * Button({
41
+ * onClick: () => props.portal.unmount(),
42
+ * children: 'Close',
43
+ * }),
44
+ * ],
45
+ * })
46
+ * ));
36
47
  *
37
- * const basicModalInstance = BasicModal({ children: "Hello from a basic portal!" });
38
- * basicModalInstance.unmount();
39
- *
40
- * // Example with dynamic providers when launching:
41
- * const DynamicThemedModal = Portal(
42
- * (props) => Div({ children: props.children, style: { background: props.nodetheme?.background || 'white' } })
43
- * );
44
- *
45
- * const dynamicModalInstance = DynamicThemedModal({
46
- * providers: ThemeProvider({ theme: 'blue' }), // Dynamic provider
47
- * children: "Content with dynamic theme"
48
- * });
49
- * dynamicModalInstance.unmount();
50
- * ```
48
+ * // Launching the portal with a dynamic provider
49
+ * const portalInstance = MyPortal({ provider: AnotherProviderNodeInstance, someProp: 'value' });
51
50
  */
51
+ export declare function Portal<P extends BasePortalProps | Record<string, any> = BasePortalProps>(provider: NodeInstance<any>, component: (props: PortalProps<P>) => ComponentNode): PortalLauncher<P>;
52
52
  export declare function Portal<P extends BasePortalProps | Record<string, any> = BasePortalProps>(component: (props: PortalProps<P>) => ComponentNode): PortalLauncher<P>;
53
53
  //# sourceMappingURL=portal.hoc.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"portal.hoc.d.ts","sourceRoot":"","sources":["../../src/hoc/portal.hoc.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,eAAe,EAAE,aAAa,EAAe,YAAY,EAAyB,cAAc,EAAE,WAAW,EAAS,MAAM,mBAAmB,CAAA;AAG7J;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,MAAM,CAAC,CAAC,SAAS,eAAe,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,eAAe,EACtF,QAAQ,EAAE,YAAY,CAAC,GAAG,CAAC,EAC3B,SAAS,EAAE,CAAC,KAAK,EAAE,WAAW,CAAC,CAAC,CAAC,KAAK,aAAa,GAClD,cAAc,CAAC,CAAC,CAAC,CAAA;AAEpB;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,wBAAgB,MAAM,CAAC,CAAC,SAAS,eAAe,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,eAAe,EACtF,SAAS,EAAE,CAAC,KAAK,EAAE,WAAW,CAAC,CAAC,CAAC,KAAK,aAAa,GAClD,cAAc,CAAC,CAAC,CAAC,CAAA"}
1
+ {"version":3,"file":"portal.hoc.d.ts","sourceRoot":"","sources":["../../src/hoc/portal.hoc.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,eAAe,EAAE,aAAa,EAAe,YAAY,EAAyB,cAAc,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAA;AAGtJ,6BAA6B;AAE7B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+CG;AACH,wBAAgB,MAAM,CAAC,CAAC,SAAS,eAAe,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,eAAe,EACtF,QAAQ,EAAE,YAAY,CAAC,GAAG,CAAC,EAC3B,SAAS,EAAE,CAAC,KAAK,EAAE,WAAW,CAAC,CAAC,CAAC,KAAK,aAAa,GAClD,cAAc,CAAC,CAAC,CAAC,CAAA;AAEpB,wBAAgB,MAAM,CAAC,CAAC,SAAS,eAAe,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,eAAe,EACtF,SAAS,EAAE,CAAC,KAAK,EAAE,WAAW,CAAC,CAAC,CAAC,KAAK,aAAa,GAClD,cAAc,CAAC,CAAC,CAAC,CAAA"}
@@ -1,50 +1,51 @@
1
- "use strict";var _excluded=["nodetheme"],_excluded2=["provider","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 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)}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}import{BaseNode,Node}from"../core.node.js";/**
2
- * Creates a portal component with a single fixed provider.
3
- * The content component will be rendered within this provider. This is the preferred method
4
- * for providing fixed context to your portal content.
5
- * @param provider A single `NodeInstance` that will wrap the portal content. This should typically
6
- * be a React context provider (e.g., `ThemeProvider({ theme })`).
7
- * @param component The React component function that defines the portal's content. It receives
8
- * props of type `PortalProps<P>` and should return a `ComponentNode`.
9
- * @returns A launcher function that, when called, creates and controls the portal instance.
1
+ "use strict";var _excluded=["provider"];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{BaseNode,Node}from"../core.node.js";// --- Function Overloads ---
2
+ /**
3
+ * Higher-Order Component (HOC) to create and manage React portals with optional provider wrapping.
4
+ * This function supports two overloads:
5
+ * 1. `Portal(providerNodeInstance, component)` - Creates a portal with a fixed provider node instance.
6
+ * 2. `Portal(component)` - Creates a portal without a fixed provider, allowing dynamic providers at launch time.
7
+ * @template P The prop types for the component rendered inside the portal, extending BasePortalProps.
8
+ * @param provider Optional NodeInstance to wrap the portal content (fixed provider).
9
+ * @param component The component function that returns the content to render inside the portal.
10
+ * @returns A function that launches the portal instance, accepting props and optional dynamic providers.
10
11
  * @example
11
- * ```ts
12
- * // Example of preferred usage with a single fixed provider:
13
- * const ThemedModal = Portal(
14
- * ThemeProvider({ theme: 'light' }),
15
- * (props) => Div({ children: props.children, style: { background: props.nodetheme?.background } })
16
- * );
12
+ * // Using Portal with a fixed provider
13
+ * const MyPortal = Portal(MyProviderNodeInstance, (props) => (
14
+ * Div({
15
+ * backgroundColor: 'white',
16
+ * padding: '20px',
17
+ * borderRadius: '8px',
18
+ * children: [
19
+ * H1({ children: 'Fixed Provider Portal' }),
20
+ * Button({
21
+ * onClick: () => props.portal.unmount(),
22
+ * children: 'Close',
23
+ * }),
24
+ * ],
25
+ * })
26
+ * ));
17
27
  *
18
- * const modalInstance = ThemedModal({ children: "Preferred content" });
19
- * modalInstance.unmount();
20
- * ```
21
- *//**
22
- * Creates a basic portal component without any fixed providers.
23
- * Dynamic providers can still be passed as props when launching the portal instance.
24
- * @param component The React component function that defines the portal's content. It receives
25
- * props of type `PortalProps<P>` and should return a `ComponentNode`.
26
- * @returns A launcher function that, when called, creates and controls the portal instance.
28
+ * // Launching the portal
29
+ * const portalInstance = MyPortal({ someProp: 'value' });
27
30
  * @example
28
- * ```ts
29
- * // Example of basic usage without fixed providers:
30
- * const BasicModal = Portal(
31
- * (props) => Div({ children: props.children, style: { padding: '20px', border: '1px solid black' } })
32
- * );
31
+ * // Using Portal without a fixed provider
32
+ * const MyPortal = Portal((props) => (
33
+ * Div({
34
+ * backgroundColor: 'white',
35
+ * padding: '20px',
36
+ * borderRadius: '8px',
37
+ * children: [
38
+ * H1({ children: 'Dynamic Provider Portal' }),
39
+ * Button({
40
+ * onClick: () => props.portal.unmount(),
41
+ * children: 'Close',
42
+ * }),
43
+ * ],
44
+ * })
45
+ * ));
33
46
  *
34
- * const basicModalInstance = BasicModal({ children: "Hello from a basic portal!" });
35
- * basicModalInstance.unmount();
36
- *
37
- * // Example with dynamic providers when launching:
38
- * const DynamicThemedModal = Portal(
39
- * (props) => Div({ children: props.children, style: { background: props.nodetheme?.background || 'white' } })
40
- * );
41
- *
42
- * const dynamicModalInstance = DynamicThemedModal({
43
- * providers: ThemeProvider({ theme: 'blue' }), // Dynamic provider
44
- * children: "Content with dynamic theme"
45
- * });
46
- * dynamicModalInstance.unmount();
47
- * ```
47
+ * // Launching the portal with a dynamic provider
48
+ * const portalInstance = MyPortal({ provider: AnotherProviderNodeInstance, someProp: 'value' });
48
49
  */// --- Implementation ---
49
50
  export function Portal(a,b){// --- Initialization ---
50
51
  var c,d=void 0,e={unmount:function unmount(){console.warn("Portal instance not yet created. Cannot unmount.")},update:function update(a){console.warn("Portal instance not yet created. Cannot update.",a)}};// --- Argument Parsing and Overload Handling ---
@@ -53,21 +54,20 @@ if("function"==typeof b&&a instanceof BaseNode)// Handles the case where a fixed
53
54
  d=[a],c=b;else if("function"==typeof a&&b===void 0)// Handles the case where only the component function is passed.
54
55
  c=a;else throw new Error("Invalid arguments for Portal HOC. Use Portal(component) or Portal(providerNodeInstance, component).");// --- Core Content Renderer Function ---
55
56
  // This function is the actual React component that will be rendered inside the portal.
56
- // It receives props and handles theme application and portal control.
57
- 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
58
- }));// Ensures that the theme is correctly applied if the result is a BaseNode.
59
- 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) ---
57
+ var f=function Renderer(){var a=0<arguments.length&&arguments[0]!==void 0?arguments[0]:{},b=c(_objectSpread(_objectSpread({},a),{},{portal:e// Passes the portal control object to the content component
58
+ }));// If the result is a BaseNode, render it.
59
+ return b instanceof BaseNode?b.render():b};// --- Portal Launcher Function (Returned to User) ---
60
60
  // This is the function that developers call to actually create and manage a portal instance.
61
61
  return function Func(){// --- Helper for Deep Content Injection ---
62
62
  // Recursively injects content into the deepest child of a provider chain.
63
- function injectContentDeeply(a,b,c){var d,e,f,g=null===(d=a.rawProps)||void 0===d?void 0:d.children;// If no children, or children is not a NodeInstance, inject directly
64
- if(!g||!(g instanceof BaseNode)){var h,i;return Node(a.element,_objectSpread(_objectSpread({},a.rawProps),{},{children:b,nodetheme:(null===(h=a.rawProps)||void 0===h?void 0:h.nodetheme)||(null===(i=a.rawProps)||void 0===i?void 0:i.theme)||c}))}// Recursively inject into the deepest node
65
- var j=injectContentDeeply(g,b);return Node(a.element,_objectSpread(_objectSpread({},a.rawProps),{},{children:j,nodetheme:(null===(e=a.rawProps)||void 0===e?void 0:e.nodetheme)||(null===(f=a.rawProps)||void 0===f?void 0:f.theme)||c}))}// --- Provider Wrapping Logic ---
63
+ function injectContentDeeply(a,b){var c,d=null===(c=a.rawProps)||void 0===c?void 0:c.children;// If no children, or children is not a NodeInstance, inject directly
64
+ if(!d||!(d instanceof BaseNode))return Node(a.element,_objectSpread(_objectSpread({},a.rawProps),{},{children:b}));// Recursively inject into the deepest node
65
+ var e=injectContentDeeply(d,b);return Node(a.element,_objectSpread(_objectSpread({},a.rawProps),{},{children:e}))}// --- Provider Wrapping Logic ---
66
66
  // Iterates through the combined providers (fixed + dynamic) to wrap the content.
67
67
  // Providers are applied in reverse order to ensure the innermost content is wrapped by the outermost provider.
68
68
  var a,b=0<arguments.length&&void 0!==arguments[0]?arguments[0]:{},c=[];// Combine fixed and dynamic providers
69
- b.provider&&c.push(b.provider);var g=[...(null!==d&&void 0!==d?d:[]),...c],h=b.provider,i=b.nodetheme,j=_objectWithoutProperties(b,_excluded2),k=_objectSpread(_objectSpread({},j),{},{nodetheme:i}),l=Node(f,k);// Separates props for the portal's content from internal props like 'provider' or 'nodetheme'.
69
+ b.provider&&c.push(b.provider);var g=[...(null!==d&&void 0!==d?d:[]),...c],h=b.provider,i=_objectWithoutProperties(b,_excluded),j=Node(f,i);// Separates props for the portal's content from internal props like 'provider'.
70
70
  // Creates the base node for the portal's content.
71
- return a=0<g.length?g.reduceRight(function(a,b){var c,d,e;if(!(b instanceof BaseNode))return console.warn("Portal: Item in provider is not a valid NodeInstance. Skipping.",b),a;var f=(null===(c=b.rawProps)||void 0===c?void 0:c.children)instanceof BaseNode;// If the provider already has nested children, inject content deeply.
71
+ return a=0<g.length?g.reduceRight(function(a,b){var c;if(!(b instanceof BaseNode))return console.warn("Portal: Item in provider is not a valid NodeInstance. Skipping.",b),a;var d=(null===(c=b.rawProps)||void 0===c?void 0:c.children)instanceof BaseNode;// If the provider already has nested children, inject content deeply.
72
72
  // Otherwise, simply set currentWrappedContent as its direct child.
73
- return f?injectContentDeeply(b,a,i):Node(b.element,_objectSpread(_objectSpread({},b.rawProps),{},{children:a,nodetheme:(null===(d=b.rawProps)||void 0===d?void 0:d.nodetheme)||(null===(e=b.rawProps)||void 0===e?void 0:e.theme)||i}))},l):l,e=a.toPortal(),e}}
73
+ return d?injectContentDeeply(b,a):Node(b.element,_objectSpread(_objectSpread({},b.rawProps),{},{children:a}))},j):j,e=a.toPortal(),e}}
@@ -1,2 +1,3 @@
1
1
  export * from '../hook/usePortal.js';
2
+ export * from '../hook/useTheme.js';
2
3
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/hook/index.ts"],"names":[],"mappings":"AAAA,cAAc,wBAAwB,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/hook/index.ts"],"names":[],"mappings":"AAAA,cAAc,wBAAwB,CAAA;AACtC,cAAc,uBAAuB,CAAA"}
@@ -1 +1 @@
1
- export*from"./usePortal.js";
1
+ export*from"./usePortal.js";export*from"./useTheme.js";
@@ -0,0 +1,8 @@
1
+ /**
2
+ * A hook that provides access to the theme context.
3
+ * It also handles side effects like updating localStorage and applying the theme to the document root.
4
+ * @returns {ThemeContextValue} The theme context value.
5
+ * @throws {Error} If used outside of a ThemeProvider.
6
+ */
7
+ export declare const useTheme: () => import("../main").ThemeContextValue;
8
+ //# sourceMappingURL=useTheme.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useTheme.d.ts","sourceRoot":"","sources":["../../src/hook/useTheme.ts"],"names":[],"mappings":"AAIA;;;;;GAKG;AACH,eAAO,MAAM,QAAQ,6CA+BpB,CAAA"}
@@ -0,0 +1,8 @@
1
+ "use client";import{useContext,useEffect}from"react";import{ThemeContext}from"../components/theme-provider.client.js";/**
2
+ * A hook that provides access to the theme context.
3
+ * It also handles side effects like updating localStorage and applying the theme to the document root.
4
+ * @returns {ThemeContextValue} The theme context value.
5
+ * @throws {Error} If used outside of a ThemeProvider.
6
+ */export var useTheme=function useTheme(){var a=useContext(ThemeContext);if(!a)throw new Error("useTheme must be used within a ThemeProvider");var b=a.theme;return useEffect(function(){// Sync theme mode with localStorage
7
+ var a=localStorage.getItem("theme");a&&a===b.mode||localStorage.setItem("theme",b.mode);// Apply theme to document root
8
+ var c=document.documentElement;"dark"===b.mode?(c.setAttribute("data-theme","dark"),c.classList.add("dark-theme"),c.classList.remove("light-theme")):(c.setAttribute("data-theme","light"),c.classList.add("light-theme"),c.classList.remove("dark-theme"))},[b.mode,b.system]),a};
package/dist/main.d.ts CHANGED
@@ -3,5 +3,6 @@ export * from './hoc/index.js';
3
3
  export * from './helper/node.helper.js';
4
4
  export * from './node.type.js';
5
5
  export * from './components/html.node.js';
6
+ export * from './components/theme-provider.client.js';
6
7
  export * from './hook/index.js';
7
8
  //# sourceMappingURL=main.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"main.d.ts","sourceRoot":"","sources":["../src/main.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,uBAAuB,EAAE,MAAM,mBAAmB,CAAA;AAC7E,cAAc,mBAAmB,CAAA;AACjC,cAAc,4BAA4B,CAAA;AAC1C,cAAc,mBAAmB,CAAA;AACjC,cAAc,8BAA8B,CAAA;AAC5C,cAAc,oBAAoB,CAAA"}
1
+ {"version":3,"file":"main.d.ts","sourceRoot":"","sources":["../src/main.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,uBAAuB,EAAE,MAAM,mBAAmB,CAAA;AAE7E,cAAc,mBAAmB,CAAA;AAEjC,cAAc,4BAA4B,CAAA;AAE1C,cAAc,mBAAmB,CAAA;AAEjC,cAAc,8BAA8B,CAAA;AAC5C,cAAc,0CAA0C,CAAA;AAExD,cAAc,oBAAoB,CAAA"}
package/dist/main.js CHANGED
@@ -1 +1 @@
1
- export{Node,createNode,createChildrenFirstNode}from"./core.node.js";export*from"./hoc/index.js";export*from"./helper/node.helper.js";export*from"./node.type.js";export*from"./components/html.node.js";export*from"./hook/index.js";
1
+ export{Node,createNode,createChildrenFirstNode}from"./core.node.js";export*from"./hoc/index.js";export*from"./helper/node.helper.js";export*from"./node.type.js";export*from"./components/html.node.js";export*from"./components/theme-provider.client.js";export*from"./hook/index.js";