@meonode/ui 0.2.14 → 0.2.16
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/CHANGELOG.md +102 -25
- package/dist/components/html.node.d.ts +41 -41
- package/dist/components/styled-renderer.client.js +1 -1
- package/dist/core.node.d.ts +51 -19
- package/dist/core.node.d.ts.map +1 -1
- package/dist/core.node.js +54 -26
- package/dist/helper/node.helper.d.ts +8 -19
- package/dist/helper/node.helper.d.ts.map +1 -1
- package/dist/helper/node.helper.js +18 -18
- package/dist/helper/obj.helper.d.ts +11 -0
- package/dist/helper/obj.helper.d.ts.map +1 -1
- package/dist/helper/obj.helper.js +19 -1
- package/dist/hoc/component.hoc.d.ts +3 -3
- package/dist/hoc/component.hoc.d.ts.map +1 -1
- package/dist/hoc/component.hoc.js +2 -2
- package/dist/node.type.d.ts +22 -15
- package/dist/node.type.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/core.node.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";var _excluded=["ref","key","children","nodetheme","theme","props"],_excluded2=["style"],_excluded3=["style","css"],_excluded4=["style"],_excluded5=["children","key","nativeProps"];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 _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 React,{Fragment,
|
|
1
|
+
"use strict";var _excluded=["ref","key","children","nodetheme","theme","props"],_excluded2=["style"],_excluded3=["style","css"],_excluded4=["style"],_excluded5=["children","key","nativeProps"];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 _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 React,{createElement,Fragment,isValidElement}from"react";import{createStableHash,isNodeInstance,resolveDefaultStyle}from"./helper/node.helper.js";import{isForwardRef,isFragment,isMemo,isReactClassComponent,isValidElementType}from"./helper/react-is.helper.js";import{createRoot}from"react-dom/client";import{getComponentType,getCSSProps,getDOMProps,getElementTypeName,hasNoStyleTag}from"./helper/common.helper.js";import StyledRenderer from"./components/styled-renderer.client.js";import{resolveObjWithTheme}from"./helper/theme.helper.js";/**
|
|
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
|
|
@@ -67,29 +67,52 @@ return a}),this.element=a,this.rawProps=c}/**
|
|
|
67
67
|
var a=this.rawProps,b=a.ref,c=a.key,d=a.children,e=a.nodetheme,f=a.theme,g=a.props,h=void 0===g?{}:g,i=_objectWithoutProperties(a,_excluded),j=f||e,k=h,l=k.style,m=_objectWithoutProperties(k,_excluded2),n=resolveObjWithTheme(i,j),o=resolveObjWithTheme(l,j),p=n.style,q=n.css,r=_objectWithoutProperties(n,_excluded3),s=getCSSProps(r),t=getDOMProps(r),u=resolveDefaultStyle(_objectSpread(_objectSpread({},s),p)),v=this._processChildren(d,j);// Process children while maintaining theme inheritance
|
|
68
68
|
// Combine processed props into final normalized form
|
|
69
69
|
return _objectSpread(_objectSpread({ref:b,key:c,nodetheme:j,theme:f,css:_objectSpread(_objectSpread({},u),q),style:o},t),{},{nativeProps:m,children:v})}/**
|
|
70
|
-
*
|
|
71
|
-
*
|
|
72
|
-
*
|
|
73
|
-
*
|
|
70
|
+
* Deeply clones processed children before returning them from cache so that each parent receives
|
|
71
|
+
* independent `BaseNode` instances (prevents sharing cycles and mutation bugs).
|
|
72
|
+
*
|
|
73
|
+
* - If the input is an array, each child is cloned recursively.
|
|
74
|
+
* - If the input is a `BaseNode`, a new instance is created with the same element and copied rawProps.
|
|
75
|
+
* - For other objects/primitives, the value is returned as-is (they are immutable or safe to reuse).
|
|
76
|
+
*
|
|
77
|
+
* This ensures that cached children are never shared between different parents in the React tree.
|
|
78
|
+
* @param processed The processed child or array of children to clone.
|
|
79
|
+
* @returns A deep clone of the processed children, safe for use in multiple parents.
|
|
80
|
+
* @private
|
|
81
|
+
*/static _cloneProcessedChildren(a){var b=function cloneOne(a){return a instanceof BaseNode?new BaseNode(a.element,_objectSpread({},a.rawProps)):a;// NodeInstance returns its own instances when render() is called - we avoid calling render here.
|
|
82
|
+
// For other objects/primitives, return as-is (they are immutable or safe to reuse).
|
|
83
|
+
};return Array.isArray(a)?a.map(function(a){return b(a)}):b(a)}/**
|
|
84
|
+
* Retrieves cached processed children for a given set of `children` and an optional `theme`.
|
|
85
|
+
*
|
|
86
|
+
* - Skips caching entirely when executed on the server (returns `null`).
|
|
87
|
+
* - Uses a **WeakMap** for identity-based caching when `children` is an object or array,
|
|
88
|
+
* ensuring garbage collection safety.
|
|
89
|
+
* - Falls back to a **Map** keyed by a stable hash of `children` and `theme`
|
|
90
|
+
* for value-based caching.
|
|
91
|
+
* - Only returns cached entries that are **not server-side**.
|
|
92
|
+
* @param children The child node(s) to resolve cached results for.
|
|
93
|
+
* @param theme The theme context that may influence child processing.
|
|
94
|
+
* @returns A cloned version of the cached processed children if available, otherwise `null`.
|
|
74
95
|
* @private
|
|
75
|
-
*/_getCachedChildren(a,b){
|
|
76
|
-
|
|
77
|
-
var c=
|
|
96
|
+
*/_getCachedChildren(a,b){if(BaseNode._isServer)return null;// No server caching
|
|
97
|
+
// Compute hash once
|
|
98
|
+
var c=createStableHash(a,b);// If children is an object (array or object), try identity-keyed WeakMap first
|
|
99
|
+
if(a&&"object"===_typeof(a)){var d=BaseNode._processedChildrenWeakCache.get(a);if(d&&d.hash===c&&!d.isServerSide)return BaseNode._cloneProcessedChildren(d.children)}// Fallback to string-hash Map cache
|
|
100
|
+
var e=BaseNode._processedChildrenMapCache.get(c);return e&&!e.isServerSide?BaseNode._cloneProcessedChildren(e.children):null}/**
|
|
78
101
|
* Caches processed children for a given set of children and theme.
|
|
79
|
-
* This method stores the processed
|
|
80
|
-
*
|
|
81
|
-
* No caching is performed on the server to avoid
|
|
102
|
+
* This method stores the processed NodeElement(s) in a Map keyed by a stable hash.
|
|
103
|
+
* The cache is bounded to avoid unbounded memory growth.
|
|
104
|
+
* No caching is performed on the server to avoid RSC issues.
|
|
82
105
|
* @param children The original children to cache.
|
|
83
106
|
* @param theme The theme associated with the children.
|
|
84
|
-
* @param processed The processed
|
|
107
|
+
* @param processed The processed NodeElement(s) to cache.
|
|
85
108
|
* @private
|
|
86
|
-
*/_setCachedChildren(a,b,c){
|
|
87
|
-
if(
|
|
109
|
+
*/_setCachedChildren(a,b,c){if(!BaseNode._isServer){var d=createStableHash(a,b);if(a&&"object"===_typeof(a))return void BaseNode._processedChildrenWeakCache.set(a,{hash:d,children:c,isServerSide:!1});// Manage bounded Map cache (FIFO eviction)
|
|
110
|
+
if(BaseNode._processedChildrenMapCache.has(d))return void BaseNode._processedChildrenMapCache.set(d,{children:c,isServerSide:!1});if(BaseNode._processedChildrenMapCache.size>=BaseNode._MAX_PROCESSED_CHILDREN_CACHE){var e=BaseNode._processedChildrenMapCache.keys().next().value;void 0!==e&&BaseNode._processedChildrenMapCache["delete"](e)}BaseNode._processedChildrenMapCache.set(d,{children:c,isServerSide:!1})}}/**
|
|
88
111
|
* Recursively processes raw children, converting them into `BaseNode` instances as needed
|
|
89
112
|
* and propagating the provided theme.
|
|
90
113
|
*
|
|
91
114
|
* This method ensures consistent theme handling for all children and optimizes performance
|
|
92
|
-
* using caching strategies: a
|
|
115
|
+
* using caching strategies: a Map for client-side and no caching for server-side.
|
|
93
116
|
*
|
|
94
117
|
* - If `children` is an array, each child is processed individually.
|
|
95
118
|
* - If `children` is a single node, it is processed directly.
|
|
@@ -100,7 +123,7 @@ if("undefined"!=typeof window){var d=createStableHash(a,b);BaseNode._processedCh
|
|
|
100
123
|
* @private
|
|
101
124
|
*/_processChildren(a,b){var c=this;if(a){// Use RSC-safe caching strategy
|
|
102
125
|
var d=this._getCachedChildren(a,b);if(d)return d;var e=Array.isArray(a)?a.map(function(a,d){return c._processRawNode(a,b,d)}):this._processRawNode(a,b);// Only cache on client-side
|
|
103
|
-
return
|
|
126
|
+
return BaseNode._isServer||this._setCachedChildren(a,b,e),e}}/**
|
|
104
127
|
* Renders a processed `NodeElement` into a `ReactNode`, applying a theme and key if necessary.
|
|
105
128
|
*
|
|
106
129
|
* This static method centralizes the logic for converting various types of processed elements
|
|
@@ -132,15 +155,14 @@ return isReactClassComponent(a)?new BaseNode(a,d).render():isNodeInstance(a)?a.r
|
|
|
132
155
|
* @param props The properties for the function renderer.
|
|
133
156
|
* @param props.render The function to execute to get the child content.
|
|
134
157
|
* @param props.passedTheme The theme to propagate to the rendered child.
|
|
135
|
-
* @param props.passedKey The React key to assign to the rendered node.
|
|
136
158
|
* @param props.processRawNode A reference to the `_processRawNode` method for recursive processing.
|
|
137
159
|
* @returns The rendered `ReactNode`.
|
|
138
160
|
* @private
|
|
139
|
-
*/_functionRenderer(a){var b,c=a.render,d=a.passedTheme,e=a.
|
|
161
|
+
*/_functionRenderer(a){var b,c=a.render,d=a.passedTheme,e=a.processRawNode;// Invoke the render function to get the child node.
|
|
140
162
|
try{b=c()}catch(a){b=null}// Handle React.Component instance
|
|
141
|
-
if(b instanceof React.Component){var
|
|
142
|
-
if(b instanceof BaseNode||isNodeInstance(b)){var i
|
|
143
|
-
var
|
|
163
|
+
if(b instanceof React.Component){var f=b.render(),g=e(f,d);return BaseNode._renderProcessedNode(g,d)}// Handle BaseNode instance
|
|
164
|
+
if(b instanceof BaseNode||isNodeInstance(b)){var h,i=b;return void 0===(null===(h=i.rawProps)||void 0===h?void 0:h.nodetheme)&&void 0!==d?new BaseNode(i.element,_objectSpread(_objectSpread({},i.rawProps),{},{nodetheme:d})).render():i.render()}// Process other result types
|
|
165
|
+
var j=e(b,d);return j?BaseNode._renderProcessedNode(j,d):b}/**
|
|
144
166
|
* Processes a single raw node, recursively converting it into a `BaseNode` or other renderable type.
|
|
145
167
|
*
|
|
146
168
|
* This is a central method for normalizing children. It handles various types of input:
|
|
@@ -200,7 +222,9 @@ return a}/**
|
|
|
200
222
|
var c=this.props,d=c.children,e=c.key,f=c.nativeProps,g=_objectWithoutProperties(c,_excluded5),h=void 0;if(void 0!==d&&null!==d){if(!this._normalizedChildren||this._childrenHash!==createStableHash(d,this.props.nodetheme||this.props.theme))if(!Array.isArray(d))this._normalizedChildren=this._normalizeChild(d);else if(0<d.length){var i=d.map(function(b){return a._normalizeChild(b)});this._normalizedChildren=i.every(function(a){return null===a||void 0===a})?void 0:i}else this._normalizedChildren=void 0;h=this._normalizedChildren}// Prepare props for React.createElement
|
|
201
223
|
var j;// If the element has a `css` prop and has style tag, render using the `StyledRenderer` component
|
|
202
224
|
// This enables emotion-based style handling for the element
|
|
203
|
-
|
|
225
|
+
if(j=this.element===Fragment||isFragment(this.element)?{key:e}:_objectSpread(_objectSpread(_objectSpread({},g),{},{key:e},f),{},{suppressHydrationWarning:!0}),this.element&&!hasNoStyleTag(this.element)&&j.css){var k=_objectSpread({element:this.element},j);try{var l=getElementTypeName(k.element);StyledRenderer.displayName="Styled(".concat(l,")")}catch(a){// swallow: displayName is not critical
|
|
226
|
+
}return createElement(StyledRenderer,k,h)}try{this.element.displayName=getElementTypeName(this.element)}catch(a){// swallow: displayName is not critical
|
|
227
|
+
}return createElement(this.element,j,h)}/**
|
|
204
228
|
* Ensures the necessary DOM elements for portal rendering are created and attached.
|
|
205
229
|
*
|
|
206
230
|
* On the client-side, this method checks for or creates a `div` element appended
|
|
@@ -209,7 +233,7 @@ return j=this.element===Fragment||isFragment(this.element)?{key:e}:_objectSpread
|
|
|
209
233
|
* to call multiple times.
|
|
210
234
|
* @returns `true` if the portal infrastructure is ready, `false` if on the server.
|
|
211
235
|
* @private
|
|
212
|
-
*/_ensurePortalInfrastructure(){if(
|
|
236
|
+
*/_ensurePortalInfrastructure(){if(BaseNode._isServer)return!1;// If both exist and DOM is connected, we're ready
|
|
213
237
|
if(this._portalDOMElement&&this._portalReactRoot&&this._portalDOMElement.isConnected)return!0;// If DOM element exists but isn't connected, clear both DOM element and root
|
|
214
238
|
if(this._portalDOMElement&&!this._portalDOMElement.isConnected){// attempt to unmount root if present
|
|
215
239
|
if(this._portalReactRoot){try{this._portalReactRoot.unmount()}catch(a){// swallow: unmount might fail if already removed; avoid breaking the app
|
|
@@ -226,7 +250,11 @@ if(this._portalDOMElement||(this._portalDOMElement=document.createElement("div")
|
|
|
226
250
|
* @returns A `ReactDOMRoot` instance for managing the portal, or `null` if
|
|
227
251
|
* called in a server-side environment. The returned instance is enhanced
|
|
228
252
|
* with a custom `unmount` method that also cleans up the associated DOM element.
|
|
229
|
-
*/toPortal(){var a=this;if(!this._ensurePortalInfrastructure()||!this._portalReactRoot)return null;var b=this.render();
|
|
253
|
+
*/toPortal(){var a=this;if(!this._ensurePortalInfrastructure()||!this._portalReactRoot)return null;var b=this.render();this._portalReactRoot.render(b);// Augment the actual root's unmount to also clean up the DOM element and internal refs.
|
|
254
|
+
try{var c=this._portalReactRoot.unmount.bind(this._portalReactRoot);this._portalReactRoot.unmount=function(){try{c()}catch(a){// swallow: original unmount might throw in edge cases
|
|
255
|
+
}// Clear references and remove DOM element
|
|
256
|
+
a._portalDOMElement&&(a._portalDOMElement.parentNode&&a._portalDOMElement.parentNode.removeChild(a._portalDOMElement),a._portalDOMElement=null),a._portalReactRoot=null}}catch(a){// swallow: if anything goes wrong while patching, still return the root
|
|
257
|
+
}return this._portalReactRoot}}/**
|
|
230
258
|
* Factory function to create a `BaseNode` instance.
|
|
231
259
|
* @template AdditionalProps Additional props to merge with node props.
|
|
232
260
|
* @template E The React element or component type.
|
|
@@ -234,10 +262,10 @@ if(this._portalDOMElement||(this._portalDOMElement=document.createElement("div")
|
|
|
234
262
|
* @param props The props for the node (optional).
|
|
235
263
|
* @param additionalProps Additional props to merge into the node (optional).
|
|
236
264
|
* @returns A new `BaseNode` instance as a `NodeInstance<E>`.
|
|
237
|
-
*/_defineProperty(BaseNode,"
|
|
265
|
+
*/_defineProperty(BaseNode,"_isServer","undefined"==typeof window),_defineProperty(BaseNode,"_processedChildrenWeakCache",new WeakMap),_defineProperty(BaseNode,"_processedChildrenMapCache",new Map),_defineProperty(BaseNode,"_MAX_PROCESSED_CHILDREN_CACHE",1e3);export function Node(a){var b=1<arguments.length&&void 0!==arguments[1]?arguments[1]:{},c=2<arguments.length&&void 0!==arguments[2]?arguments[2]:{},d=_objectSpread(_objectSpread({},b),c);return d.theme&&!d.nodetheme&&(d.nodetheme=d.theme),new BaseNode(a,d)}/**
|
|
238
266
|
* Creates a curried node factory for a given React element or component type.
|
|
239
267
|
*
|
|
240
|
-
* Returns a function that, when called with props, produces a `
|
|
268
|
+
* Returns a function that, when called with props, produces a `NodeInstance<E>`.
|
|
241
269
|
* Useful for creating reusable node factories for specific components or element types.
|
|
242
270
|
* @template AdditionalInitialProps Additional initial props to merge with node props.
|
|
243
271
|
* @template E The React element or component type.
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { CSSProperties } from 'react';
|
|
2
|
-
import type {
|
|
2
|
+
import type { Children, NodeInstance, Theme } from '../node.type.js';
|
|
3
3
|
/**
|
|
4
4
|
* Type guard to check if an object is a NodeInstance.
|
|
5
5
|
*
|
|
@@ -894,24 +894,13 @@ export declare const resolveDefaultStyle: (style: CSSProperties) => {
|
|
|
894
894
|
minWidth: import("csstype").Property.MinWidth<string | number>;
|
|
895
895
|
};
|
|
896
896
|
/**
|
|
897
|
-
*
|
|
897
|
+
* Public: createStableHash
|
|
898
|
+
* Produces a deterministic string signature for children + theme.
|
|
899
|
+
* Keep traversal limited so it is cheap in large trees.
|
|
898
900
|
*
|
|
899
|
-
*
|
|
900
|
-
*
|
|
901
|
-
*
|
|
902
|
-
*
|
|
903
|
-
* The hashing strategy includes:
|
|
904
|
-
* - For arrays of children, it includes the length and samples the types of the first few children.
|
|
905
|
-
* - For single child nodes, it includes the type of the node.
|
|
906
|
-
* - For primitive values (strings, numbers, etc.), it includes their type.
|
|
907
|
-
* - If a theme is provided, it includes a stringified version of the theme.
|
|
908
|
-
*
|
|
909
|
-
* This approach avoids deep traversal of potentially large or complex node trees,
|
|
910
|
-
* focusing instead on key characteristics that are likely to change when the structure
|
|
911
|
-
* or content changes.
|
|
912
|
-
* @param children The child nodes to hash, which can be a single node or an array of nodes.
|
|
913
|
-
* @param theme An optional theme object or string to include in the hash.
|
|
914
|
-
* @returns A stable hash string representing the structure and types of the children and theme.
|
|
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.
|
|
915
904
|
*/
|
|
916
|
-
export declare function createStableHash(children:
|
|
905
|
+
export declare function createStableHash(children: Children, theme?: Theme): string;
|
|
917
906
|
//# 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,
|
|
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;AAiGD;;;;;;;;GAQG;AACH,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,QAAQ,EAAE,KAAK,CAAC,EAAE,KAAK,UAIjE"}
|
|
@@ -110,22 +110,22 @@ 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
112
|
minWidth:0},d)};/**
|
|
113
|
-
*
|
|
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()";if("symbol"===f)return"sym:".concat(a+"");// Arrays
|
|
119
|
+
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: detect common shapes (type + props)
|
|
120
|
+
if("object"===f&&(Object.prototype.hasOwnProperty.call(a,"type")||Object.prototype.hasOwnProperty.call(a,"props"))){var l,m,n=null!==(l=a.type)&&void 0!==l?l:a,o="";// Type can be string (div) or function/class. Use helper to get name.
|
|
121
|
+
try{o=getElementTypeName(n)}catch(a){try{o=n+""}catch(a){o="unknown"}}var p="key"in a&&void 0!==a.key&&null!==a.key?"#".concat(a.key+""):"",q="props"in a&&"object"===_typeof(a.props)?null!==(m=a.props)&&void 0!==m?m:{}:{},r="";try{r=nodeSignature(q.children,c-1,d,e)}catch(a){r="<err>"}var s=q&&"object"===_typeof(q)&&"id"in q&&q.id?"@id:".concat(q.id+""):"",t=q&&"object"===_typeof(q)&&"className"in q&&q.className?"@class:".concat(q.className+""):"";return"el:".concat(o).concat(p).concat(s).concat(t,"{").concat(r,"}")}// Plain object
|
|
122
|
+
if("object"===f&&a&&"object"===_typeof(a)&&!("type"in a)&&!("props"in a)){if(e.has(a))return"[Circular]";if(e.add(a),0>=c)return"obj[...]";for(var u,v=Object.keys(a).sort(),w=[],x=b(v.length,d),y=0;y<x;y++){u=v[y];try{w.push("".concat(u,":").concat(nodeSignature(a[u],c-1,d,e)))}catch(a){w.push("".concat(u,":<err>"))}}return v.length>d&&w.push("...keys:".concat(v.length)),"obj{".concat(w.join(","),"}")}// Fallback
|
|
123
|
+
try{return"o:".concat(a+"")}catch(a){return"o:<unserializable>"}}/**
|
|
124
|
+
* Public: createStableHash
|
|
125
|
+
* Produces a deterministic string signature for children + theme.
|
|
126
|
+
* Keep traversal limited so it is cheap in large trees.
|
|
114
127
|
*
|
|
115
|
-
*
|
|
116
|
-
*
|
|
117
|
-
*
|
|
118
|
-
|
|
119
|
-
* The hashing strategy includes:
|
|
120
|
-
* - For arrays of children, it includes the length and samples the types of the first few children.
|
|
121
|
-
* - For single child nodes, it includes the type of the node.
|
|
122
|
-
* - For primitive values (strings, numbers, etc.), it includes their type.
|
|
123
|
-
* - If a theme is provided, it includes a stringified version of the theme.
|
|
124
|
-
*
|
|
125
|
-
* This approach avoids deep traversal of potentially large or complex node trees,
|
|
126
|
-
* focusing instead on key characteristics that are likely to change when the structure
|
|
127
|
-
* or content changes.
|
|
128
|
-
* @param children The child nodes to hash, which can be a single node or an array of nodes.
|
|
129
|
-
* @param theme An optional theme object or string to include in the hash.
|
|
130
|
-
* @returns A stable hash string representing the structure and types of the children and theme.
|
|
131
|
-
*/export function createStableHash(a,b){var c=Math.min,d="";if(b&&(d+="t:".concat("object"===_typeof(b)?ObjHelper.stringify(b):b+"",";")),Array.isArray(a)){d+="a:".concat(a.length,";");for(var e,f=c(3,a.length),g=0;g<f;g++)e=a[g],d+=e&&"object"===_typeof(e)&&"type"in e?"c".concat(g,":").concat(getElementTypeName(e),";"):"c".concat(g,":").concat(_typeof(e),";")}else d+=a&&"object"===_typeof(a)&&"type"in a?"s:".concat(getElementTypeName(a),";"):"s:".concat(_typeof(a),";");return d}
|
|
128
|
+
* If you prefer a shorter hashed output, wrap the returned string in a lightweight
|
|
129
|
+
* hash function (fnv1a, xxhash, etc.). Returning the full signature is useful
|
|
130
|
+
* for debugging and deterministic comparisons.
|
|
131
|
+
*/export function createStableHash(a,b){var c=b?ObjHelper.stringify(b,6):"theme:undefined",d=nodeSignature(a,6,8);return"".concat(c,"|").concat(d)}
|
|
@@ -1,5 +1,16 @@
|
|
|
1
1
|
export declare class ObjHelper {
|
|
2
2
|
private constructor();
|
|
3
|
+
/**
|
|
4
|
+
* Build a deterministic, serializable representation of `value`.
|
|
5
|
+
* - sorts plain object keys
|
|
6
|
+
* - preserves encoded placeholders for special types
|
|
7
|
+
* - emits { $type: 'Circular', ref: id } for circular refs
|
|
8
|
+
*/
|
|
9
|
+
private static buildSerializable;
|
|
10
|
+
/**
|
|
11
|
+
* Deterministic stringify: first build a canonical serializable structure
|
|
12
|
+
* (with sorted object keys and encoded special types), then JSON.stringify it.
|
|
13
|
+
*/
|
|
3
14
|
static stringify(obj: any, space?: number): string;
|
|
4
15
|
static parse(str: string): any;
|
|
5
16
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"obj.helper.d.ts","sourceRoot":"","sources":["../../src/helper/obj.helper.ts"],"names":[],"mappings":"AAWA,qBAAa,SAAS;IACpB,OAAO,eAAiB;IAExB,MAAM,CAAC,SAAS,CAAC,GAAG,EAAE,GAAG,EAAE,KAAK,SAAI,GAAG,MAAM,
|
|
1
|
+
{"version":3,"file":"obj.helper.d.ts","sourceRoot":"","sources":["../../src/helper/obj.helper.ts"],"names":[],"mappings":"AAWA,qBAAa,SAAS;IACpB,OAAO,eAAiB;IAExB;;;;;OAKG;IACH,OAAO,CAAC,MAAM,CAAC,iBAAiB;IA2FhC;;;OAGG;IACH,MAAM,CAAC,SAAS,CAAC,GAAG,EAAE,GAAG,EAAE,KAAK,SAAI,GAAG,MAAM,CAO5C;IAED,MAAM,CAAC,KAAK,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CA+C7B;CACF"}
|
|
@@ -1 +1,19 @@
|
|
|
1
|
-
function
|
|
1
|
+
function _slicedToArray(a,b){return _arrayWithHoles(a)||_iterableToArrayLimit(a,b)||_unsupportedIterableToArray(a,b)||_nonIterableRest()}function _nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _iterableToArrayLimit(b,c){var d=null==b?null:"undefined"!=typeof Symbol&&b[Symbol.iterator]||b["@@iterator"];if(null!=d){var g,h,j,k,l=[],a=!0,m=!1;try{if(j=(d=d.call(b)).next,0===c){if(Object(d)!==d)return;a=!1}else for(;!(a=(g=j.call(d)).done)&&(l.push(g.value),l.length!==c);a=!0);}catch(a){m=!0,h=a}finally{try{if(!a&&null!=d["return"]&&(k=d["return"](),Object(k)!==k))return}finally{if(m)throw h}}return l}}function _arrayWithHoles(a){if(Array.isArray(a))return a}function _createForOfIteratorHelper(b,c){var d="undefined"!=typeof Symbol&&b[Symbol.iterator]||b["@@iterator"];if(!d){if(Array.isArray(b)||(d=_unsupportedIterableToArray(b))||c&&b&&"number"==typeof b.length){d&&(b=d);var e=0,f=function F(){};return{s:f,n:function n(){return e>=b.length?{done:!0}:{done:!1,value:b[e++]}},e:function e(a){throw a},f:f}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var g,h=!0,i=!1;return{s:function s(){d=d.call(b)},n:function n(){var a=d.next();return h=a.done,a},e:function e(a){i=!0,g=a},f:function f(){try{h||null==d["return"]||d["return"]()}finally{if(i)throw g}}}}function _unsupportedIterableToArray(b,c){if(b){if("string"==typeof b)return _arrayLikeToArray(b,c);var a={}.toString.call(b).slice(8,-1);return"Object"===a&&b.constructor&&(a=b.constructor.name),"Map"===a||"Set"===a?Array.from(b):"Arguments"===a||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(a)?_arrayLikeToArray(b,c):void 0}}function _arrayLikeToArray(b,c){(null==c||c>b.length)&&(c=b.length);for(var d=0,f=Array(c);d<c;d++)f[d]=b[d];return f}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)}export class ObjHelper{constructor(){}/**
|
|
2
|
+
* Build a deterministic, serializable representation of `value`.
|
|
3
|
+
* - sorts plain object keys
|
|
4
|
+
* - preserves encoded placeholders for special types
|
|
5
|
+
* - emits { $type: 'Circular', ref: id } for circular refs
|
|
6
|
+
*/static buildSerializable(a,b,c,d){// primitives & simple types
|
|
7
|
+
if(null===a||a===void 0)return a;var e=_typeof(a);if("string"===e||"number"===e||"boolean"===e)return a;if("function"===e)return c.has(a)||c.set(a,d.nextFunctionId++),{$type:"Function",name:a.name||"",id:c.get(a)};if("symbol"===e){var f;return{$type:"Symbol",key:null!==(f=a.description)&&void 0!==f?f:""}}if("bigint"===e)return{$type:"BigInt",value:a.toString()};// Date
|
|
8
|
+
if(a instanceof Date)return{$type:"Date",value:a.toISOString()};// RegExp
|
|
9
|
+
if(a instanceof RegExp)return{$type:"RegExp",source:a.source,flags:a.flags};// Map
|
|
10
|
+
if(a instanceof Map){var g,h=[],j=_createForOfIteratorHelper(a.entries());try{for(j.s();!(g=j.n()).done;){var l=_slicedToArray(g.value,2),m=l[0],n=l[1];h.push([ObjHelper.buildSerializable(m,b,c,d),ObjHelper.buildSerializable(n,b,c,d)])}}catch(a){j.e(a)}finally{j.f()}return{$type:"Map",entries:h}}// Set
|
|
11
|
+
if(a instanceof Set){var o,p=[],q=_createForOfIteratorHelper(a.values());try{for(q.s();!(o=q.n()).done;){var r=o.value;p.push(ObjHelper.buildSerializable(r,b,c,d))}}catch(a){q.e(a)}finally{q.f()}return{$type:"Set",values:p}}// Objects and arrays
|
|
12
|
+
if("object"===e){// Circular detection
|
|
13
|
+
if(b.has(a))return{$type:"Circular",ref:b.get(a)};// assign id
|
|
14
|
+
var s=d.nextObjId++;if(b.set(a,s),Array.isArray(a)){for(var t=[],u=0;u<a.length;u++)t.push(ObjHelper.buildSerializable(a[u],b,c,d));return t}// Plain object: sort keys for determinism
|
|
15
|
+
var w,x=Object.keys(a).sort(),y={},z=_createForOfIteratorHelper(x);try{for(z.s();!(w=z.n()).done;){var A=w.value;try{y[A]=ObjHelper.buildSerializable(a[A],b,c,d)}catch(a){y[A]="<unserializable>"}}}catch(a){z.e(a)}finally{z.f()}return y}// Fallback: try to stringify
|
|
16
|
+
try{return a+""}catch(a){return"<unserializable>"}}/**
|
|
17
|
+
* Deterministic stringify: first build a canonical serializable structure
|
|
18
|
+
* (with sorted object keys and encoded special types), then JSON.stringify it.
|
|
19
|
+
*/static stringify(a){var b=1<arguments.length&&arguments[1]!==void 0?arguments[1]:2,c=new Map,d=new Map,e=ObjHelper.buildSerializable(a,c,d,{nextObjId:0,nextFunctionId:0});return JSON.stringify(e,null,b)}static parse(a){var b=[],c=function reviver(a,b){if(b&&"object"===_typeof(b)&&"$type"in b)switch(b.$type){case"Function":return function FunctionPlaceholder(){throw new Error("Function placeholder called: ".concat(b.name||"anonymous","#").concat(b.id))};case"Symbol":return Symbol(b.key);case"BigInt":return BigInt(b.value);case"Date":return new Date(b.value);case"RegExp":return new RegExp(b.source,b.flags);case"Map":return new Map(b.entries);case"Set":return new Set(b.values);case"Circular":return{$circularRef:b.ref}}return b},d=JSON.parse(a,c),e=function fixCirculars(a){if(a&&"object"===_typeof(a)){if(a.$circularRef!==void 0)return b[a.$circularRef];if(!b.includes(a)){b.push(a);for(var c,d=0,f=Object.keys(a);d<f.length;d++)c=f[d],a[c]=e(a[c])}}return a};return e(d)}}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ComponentNode, HasCSSCompatibleStyleProp,
|
|
1
|
+
import type { Children, ComponentNode, HasCSSCompatibleStyleProp, Theme } 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.
|
|
@@ -15,11 +15,11 @@ import { type CSSProperties, type ReactElement } from 'react';
|
|
|
15
15
|
* If the component supports inline styles (determined via `HasCSSCompatibleStyleProp`), the props also allow `CSSProperties`.
|
|
16
16
|
*/
|
|
17
17
|
export type ComponentNodeProps<TProps> = TProps extends undefined ? Partial<{
|
|
18
|
-
children:
|
|
18
|
+
children: Children;
|
|
19
19
|
theme: Theme;
|
|
20
20
|
}> : TProps & (HasCSSCompatibleStyleProp<TProps> extends true ? CSSProperties : object) & Partial<{
|
|
21
21
|
props: Partial<Omit<TProps, 'children'>>;
|
|
22
|
-
children:
|
|
22
|
+
children: Children;
|
|
23
23
|
theme: Theme;
|
|
24
24
|
}>;
|
|
25
25
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"component.hoc.d.ts","sourceRoot":"","sources":["../../src/hoc/component.hoc.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,
|
|
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;AAG7E;;;;;;;;;;;;;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,4 +1,4 @@
|
|
|
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";/**
|
|
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";/**
|
|
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:
|
|
@@ -48,4 +48,4 @@
|
|
|
48
48
|
*//**
|
|
49
49
|
* Internal implementation of the `Component` HOC.
|
|
50
50
|
* Handles theme propagation, BaseNode conversion, and wrapper creation.
|
|
51
|
-
*/export function Component(a){var b=function Renderer(b){var c=a(b);if(c instanceof BaseNode){var d,e,f=(null===(d=c.rawProps)||void 0===d?void 0:d.nodetheme)||(null===(e=c.rawProps)||void 0===e?void 0:e.theme)||b.nodetheme||b.theme;return Node(c.element,_objectSpread(_objectSpread({},c.rawProps),{},{nodetheme:f})).render()}return c};return
|
|
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){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}
|
package/dist/node.type.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React, { type
|
|
1
|
+
import React, { type CSSProperties, type ReactNode, type JSX, type ElementType, type ComponentType, type JSXElementConstructor, type Component, type ExoticComponent, type ReactElement } from 'react';
|
|
2
2
|
import type { Root as ReactDOMRoot } from 'react-dom/client';
|
|
3
3
|
import type { CSSInterpolation } from '@emotion/serialize';
|
|
4
4
|
import type { NO_STYLE_TAGS } from './constants/common.const.js';
|
|
@@ -9,6 +9,10 @@ type RequiredKeys<T> = {
|
|
|
9
9
|
}[keyof T];
|
|
10
10
|
// Utility to check if a type T has any required properties.
|
|
11
11
|
export type HasRequiredProps<T> = RequiredKeys<T> extends never ? false : true;
|
|
12
|
+
/** Basic React attributes, currently only includes 'key' */
|
|
13
|
+
export interface ReactAttributes {
|
|
14
|
+
key?: string;
|
|
15
|
+
}
|
|
12
16
|
/**
|
|
13
17
|
* Excludes array types from ReactNode, ensuring a single, non-array React element or primitive.
|
|
14
18
|
*/
|
|
@@ -17,7 +21,9 @@ export type NonArrayReactNode = Exclude<ReactNode, ReactNode[]>;
|
|
|
17
21
|
* Defines the various types that can represent a "node" in the Meonode system.
|
|
18
22
|
* This includes React elements, components, promises resolving to React nodes, and NodeInstance objects.
|
|
19
23
|
*/
|
|
20
|
-
export type NodeElement = ExoticComponent<
|
|
24
|
+
export type NodeElement = ExoticComponent<any> | NonArrayReactNode | Promise<Awaited<NonArrayReactNode>> | Component<any, any, any> | ElementType | ComponentType<any> | NodeInstance<any> | ((props?: any) => NonArrayReactNode | Promise<Awaited<NonArrayReactNode>> | Component<any, any, any> | NodeInstance<any> | ComponentNode);
|
|
25
|
+
/** A single NodeElement or an array of NodeElements */
|
|
26
|
+
export type Children = NodeElement | NodeElement[];
|
|
21
27
|
/**
|
|
22
28
|
* Forward declaration of the BaseNode interface to avoid circular dependencies.
|
|
23
29
|
* Defines the core structure and capabilities of a BaseNode instance.
|
|
@@ -65,15 +71,18 @@ export type Theme = Partial<{
|
|
|
65
71
|
* - Handles theme context propagation
|
|
66
72
|
* @template E - The element type these props apply to
|
|
67
73
|
*/
|
|
68
|
-
export type FinalNodeProps = ReactAttributes & {
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
74
|
+
export type FinalNodeProps = ReactAttributes & Partial<{
|
|
75
|
+
nativeProps: Omit<Omit<PropsOf<NodeElement>, 'children'>, 'style'>;
|
|
76
|
+
key: React.Key | any | null | undefined;
|
|
77
|
+
ref: any | React.Ref<unknown> | undefined;
|
|
78
|
+
style: any;
|
|
79
|
+
css: any;
|
|
80
|
+
children: Children;
|
|
81
|
+
theme: Partial<{
|
|
82
|
+
[p: string]: any;
|
|
83
|
+
}> | any | undefined;
|
|
84
|
+
nodetheme: Theme;
|
|
85
|
+
}>;
|
|
77
86
|
/**
|
|
78
87
|
* Helper type to determine if the props P have a 'style' property
|
|
79
88
|
* that is compatible with CSSProperties.
|
|
@@ -106,7 +115,7 @@ export type NodeProps<E extends NodeElement> = Omit<PropsOf<E>, keyof CSSPropert
|
|
|
106
115
|
css: CSSInterpolation;
|
|
107
116
|
}> : object) & Partial<{
|
|
108
117
|
props: Partial<Omit<PropsOf<E>, 'children'>>;
|
|
109
|
-
children:
|
|
118
|
+
children: Children;
|
|
110
119
|
theme: Theme;
|
|
111
120
|
}>;
|
|
112
121
|
/**
|
|
@@ -131,8 +140,6 @@ export interface FunctionRendererProps<E extends NodeElement> {
|
|
|
131
140
|
render: (props?: NodeProps<E>) => ReactNode | Promise<Awaited<ReactNode>> | React.Component | NodeInstance<E>;
|
|
132
141
|
/** Theme context to be applied to the rendered content */
|
|
133
142
|
passedTheme?: Theme;
|
|
134
|
-
/** Optional key prop to help React identify unique instances in lists */
|
|
135
|
-
passedKey?: string;
|
|
136
143
|
processRawNode: (node: NodeElement, parentTheme?: Theme, childIndex?: number) => NodeElement;
|
|
137
144
|
}
|
|
138
145
|
export type ComponentNode = (NodeInstance<any> | ReactNode) | (() => NodeInstance<any> | ReactNode);
|
|
@@ -144,7 +151,7 @@ export type ComponentNode = (NodeInstance<any> | ReactNode) | (() => NodeInstanc
|
|
|
144
151
|
*/
|
|
145
152
|
export interface BasePortalProps {
|
|
146
153
|
/** Content to render within the portal */
|
|
147
|
-
children?:
|
|
154
|
+
children?: Children;
|
|
148
155
|
/** Portal control object containing lifecycle methods */
|
|
149
156
|
portal: {
|
|
150
157
|
/** Unmounts and cleans up the portal */
|
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,EAAE,EACZ,KAAK,
|
|
1
|
+
{"version":3,"file":"node.type.d.ts","sourceRoot":"","sources":["../src/node.type.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,EACZ,KAAK,aAAa,EAClB,KAAK,SAAS,EACd,KAAK,GAAG,EACR,KAAK,WAAW,EAChB,KAAK,aAAa,EAClB,KAAK,qBAAqB,EAC1B,KAAK,SAAS,EACd,KAAK,eAAe,EACpB,KAAK,YAAY,EAClB,MAAM,OAAO,CAAA;AACd,OAAO,KAAK,EAAE,IAAI,IAAI,YAAY,EAAE,MAAM,kBAAkB,CAAA;AAC5D,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,oBAA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AE9F;;;;GAIG;AACH,MAAM,MAAM,cAAc,CAAC,CAAC,SAAS,eAAe,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,IAAI,CAAC,SAAS,eAAe,GACnG,CAAC,KAAK,CAAC,EAAE;IACP,8DAA8D;IAC9D,QAAQ,CAAC,EAAE,YAAY,CAAC,GAAG,CAAC,CAAA;CAC7B,KAAK,YAAY,GAAG,IAAI,GACzB,CACE,KAAK,EAAE,CAAC,GAAG;IACT,8DAA8D;IAC9D,QAAQ,CAAC,EAAE,YAAY,CAAC,GAAG,CAAC,CAAA;CAC7B,GAAG,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC,EAAE,QAAQ,CAAC,KAC/B,YAAY,GAAG,IAAI,CAAA;AAE5B;;;;;GAKG;AACH,MAAM,MAAM,WAAW,CAAC,CAAC,SAAS,WAAW,EAAE,eAAe,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,IAAI,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,GAAG,eAAe,EAAE,MAAM,eAAe,CAAC,GACvJ,eAAe,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, direct CSS-first prop styling, built-in theming, smart prop handling (including raw property pass-through), and dynamic children.",
|
|
4
|
-
"version": "0.2.
|
|
4
|
+
"version": "0.2.16",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/main.js",
|
|
7
7
|
"types": "./dist/main.d.ts",
|