@meonode/ui 0.1.82 → 0.1.84
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/core.node.js +6 -6
- package/dist/node.type.d.ts +3 -3
- 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","children","nodetheme","theme","props"],_excluded2=["style"],_excluded3=["
|
|
1
|
+
"use strict";var _excluded=["ref","children","nodetheme","theme","props"],_excluded2=["style"],_excluded3=["style"],_excluded4=["flex"],_excluded5=["style"],_excluded6=["children","key"];function _typeof(a){"@babel/helpers - typeof";return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(a){return typeof a}:function(a){return a&&"function"==typeof Symbol&&a.constructor===Symbol&&a!==Symbol.prototype?"symbol":typeof a},_typeof(a)}function _objectWithoutProperties(a,b){if(null==a)return{};var c,d,e=_objectWithoutPropertiesLoose(a,b);if(Object.getOwnPropertySymbols){var f=Object.getOwnPropertySymbols(a);for(d=0;d<f.length;d++)c=f[d],-1===b.indexOf(c)&&{}.propertyIsEnumerable.call(a,c)&&(e[c]=a[c])}return e}function _objectWithoutPropertiesLoose(a,b){if(null==a)return{};var c={};for(var d in a)if({}.hasOwnProperty.call(a,d)){if(-1!==b.indexOf(d))continue;c[d]=a[d]}return c}function ownKeys(a,b){var c=Object.keys(a);if(Object.getOwnPropertySymbols){var d=Object.getOwnPropertySymbols(a);b&&(d=d.filter(function(b){return Object.getOwnPropertyDescriptor(a,b).enumerable})),c.push.apply(c,d)}return c}function _objectSpread(a){for(var b,c=1;c<arguments.length;c++)b=null==arguments[c]?{}:arguments[c],c%2?ownKeys(Object(b),!0).forEach(function(c){_defineProperty(a,c,b[c])}):Object.getOwnPropertyDescriptors?Object.defineProperties(a,Object.getOwnPropertyDescriptors(b)):ownKeys(Object(b)).forEach(function(c){Object.defineProperty(a,c,Object.getOwnPropertyDescriptor(b,c))});return a}function _defineProperty(a,b,c){return(b=_toPropertyKey(b))in a?Object.defineProperty(a,b,{value:c,enumerable:!0,configurable:!0,writable:!0}):a[b]=c,a}function _toPropertyKey(a){var b=_toPrimitive(a,"string");return"symbol"==_typeof(b)?b:b+""}function _toPrimitive(a,b){if("object"!=_typeof(a)||!a)return a;var c=a[Symbol.toPrimitive];if(void 0!==c){var d=c.call(a,b||"default");if("object"!=_typeof(d))return d;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===b?String:Number)(a)}import React,{createElement,isValidElement}from"react";import{getComponentType,getCSSProps,getDOMProps,getElementTypeName,getValueByPath,isNodeInstance}from"./node.helper.js";import{isForwardRef,isMemo,isReactClassComponent,isValidElementType}from"./react-is.helper.js";import{createRoot}from"react-dom/client";/**
|
|
2
2
|
* Represents a node in a React component tree with theme and styling capabilities.
|
|
3
3
|
* This class wraps React elements and handles:
|
|
4
4
|
* - Props processing and normalization
|
|
@@ -18,13 +18,13 @@
|
|
|
18
18
|
if(a instanceof BaseNode){var f;return null!==(f=a.rawProps)&&void 0!==f&&f.nodetheme||void 0===e?a.render():new BaseNode(a.element,_objectSpread(_objectSpread({},a.rawProps),{},{nodetheme:e})).render()}// Validate element type before returning
|
|
19
19
|
if(!isValidElementType(a)){var g=getComponentType(a);throw new Error("Invalid element type: ".concat(g," provided!"))}// Return valid React elements as-is
|
|
20
20
|
return a}),this.element=a,this.rawProps=c;// Destructure raw props into relevant parts
|
|
21
|
-
var d=c.ref,e=c.children,f=c.nodetheme,g=c.theme,h=c.props,i=_objectWithoutProperties(c,_excluded),j=g||f,k=h||{},l=k.style,m=_objectWithoutProperties(k,_excluded2),n=this._resolveObjWithTheme(l,j),o=this._resolveObjWithTheme(i,j),p=
|
|
21
|
+
var d=c.ref,e=c.children,f=c.nodetheme,g=c.theme,h=c.props,i=_objectWithoutProperties(c,_excluded),j=g||f,k=h||{},l=k.style,m=_objectWithoutProperties(k,_excluded2),n=this._resolveObjWithTheme(l,j),o=this._resolveObjWithTheme(i,j),p=o.style,q=_objectWithoutProperties(o,_excluded3),r=getCSSProps(q),s=this._resolveDefaultStyle(_objectSpread(_objectSpread(_objectSpread({},p),r),n)),t=getDOMProps(q),u=void 0;// Resolve any theme variables in the remaining props
|
|
22
22
|
// Extract CSS-related properties from the resolved theme-aware props
|
|
23
23
|
// Resolve default styles
|
|
24
24
|
// Extract remaining props that are valid DOM attributes
|
|
25
25
|
// Process children while maintaining theme inheritance
|
|
26
26
|
// Combine processed props into final normalized form
|
|
27
|
-
e&&(Array.isArray(e)?
|
|
27
|
+
e&&(Array.isArray(e)?u=e.map(function(a,c){return b._processRawNode(a,j,c)}):u=this._processRawNode(e,j)),this.props=_objectSpread(_objectSpread(_objectSpread({ref:d,nodetheme:j,theme:g,style:s},t),m),{},{children:u})}/**
|
|
28
28
|
* Resolves default styles for a given CSSProperties object.
|
|
29
29
|
* This method ensures that certain default styles, such as `minHeight`, `minWidth`,
|
|
30
30
|
* and `flexShrink`, are applied based on the provided style properties.
|
|
@@ -37,7 +37,7 @@ e&&(Array.isArray(e)?s=e.map(function(a,c){return b._processRawNode(a,j,c)}):s=t
|
|
|
37
37
|
* - Defaults `flexShrink` to 0.
|
|
38
38
|
* @param style The CSSProperties object containing style definitions.
|
|
39
39
|
* @returns An object with resolved default styles.
|
|
40
|
-
*/_resolveDefaultStyle(a){var b,c=a.flex,d=_objectWithoutProperties(a,
|
|
40
|
+
*/_resolveDefaultStyle(a){var b,c=a.flex,d=_objectWithoutProperties(a,_excluded4),e="flex"===d.display,f=!!(d.overflow||d.overflowY||d.overflowX),g=(null===(b=d.flexFlow)||void 0===b?void 0:b.includes("wrap"))||"wrap"===d.flexWrap,h=void 0;if(!e)// If it's not a flex container, default flex-shrink to 0
|
|
41
41
|
h=0;else if(!f){var i="column"===d.flexDirection||"column-reverse"===d.flexDirection,j="row"===d.flexDirection||"row-reverse"===d.flexDirection||!d.flexDirection;// Scenario 1: Column-based layout
|
|
42
42
|
i&&!g?h=0:j&&!g&&(h=0)}return _objectSpread({flex:c,flexShrink:h,minHeight:0,minWidth:0},d)}/**
|
|
43
43
|
* Resolves theme variable references in an object's values recursively.
|
|
@@ -120,7 +120,7 @@ if("function"===d&&!isReactClassComponent(a)&&!isMemo(a)&&!isForwardRef(a)){// T
|
|
|
120
120
|
var j=e(this._functionRenderer,void 0);// Generate key for function renderer
|
|
121
121
|
return new BaseNode(this._functionRenderer,{processRawNode:this._processRawNode.bind(this),render:a,passedTheme:b,key:j// Assign the generated key
|
|
122
122
|
})}// Case 4: Child is a React Element (JSX element like <div> or <MyComponent>)
|
|
123
|
-
if(isValidElement(a)){var k=a.props,l=k.style,m=_objectWithoutProperties(k,
|
|
123
|
+
if(isValidElement(a)){var k=a.props,l=k.style,m=_objectWithoutProperties(k,_excluded5),n=_objectSpread(_objectSpread({},m),l||{}),o=n.theme||n.nodetheme||b,p=e(a.type,a.key);// Combine top-level props from the element with its flattened style object properties
|
|
124
124
|
return new BaseNode(a.type,_objectSpread(_objectSpread({},n),{},{// Pass the combined props
|
|
125
125
|
nodetheme:o,key:p}))}// Case 5: Child is an ElementType (string tag, class component, Memo/ForwardRef)
|
|
126
126
|
if(isReactClassComponent(a)||"object"===d&&(isMemo(a)||isForwardRef(a))){// ElementTypes don't have an intrinsic key from the rawNode itself.
|
|
@@ -147,7 +147,7 @@ return a}/**
|
|
|
147
147
|
* Converts this BaseNode instance into a renderable React node.
|
|
148
148
|
* Recursively processes child nodes and uses `React.createElement` to construct the final React element.
|
|
149
149
|
* @returns A ReactNode representing the rendered element.
|
|
150
|
-
*/render(){var a=this;if(!isValidElementType(this.element)){var b=getComponentType(this.element);throw new Error("Invalid element type: ".concat(b," provided!"))}var c=this.props,d=c.children,e=c.key,f=_objectWithoutProperties(c,
|
|
150
|
+
*/render(){var a=this;if(!isValidElementType(this.element)){var b=getComponentType(this.element);throw new Error("Invalid element type: ".concat(b," provided!"))}var c=this.props,d=c.children,e=c.key,f=_objectWithoutProperties(c,_excluded6),g=void 0;// Extract children and key
|
|
151
151
|
// More accurate type
|
|
152
152
|
if(d!==void 0&&null!==d)if(!Array.isArray(d))// Single child
|
|
153
153
|
g=this._normalizeChild(d);else if(0<d.length){var h=d.map(function(b){return a._normalizeChild(b)});// Normalize each child in the array
|
package/dist/node.type.d.ts
CHANGED
|
@@ -40,9 +40,9 @@ export type PropsOf<E extends NodeElement> = E extends keyof JSX.IntrinsicElemen
|
|
|
40
40
|
* - Custom theme variables and tokens
|
|
41
41
|
* Used for consistent styling and dynamic theme application.
|
|
42
42
|
*/
|
|
43
|
-
export
|
|
43
|
+
export type Theme = Partial<{
|
|
44
44
|
[key: string]: string | number | boolean | null | undefined | any | Theme | Record<string, Theme | string | number | boolean | null | undefined | any>;
|
|
45
|
-
}
|
|
45
|
+
}>;
|
|
46
46
|
/**
|
|
47
47
|
* Internal props type used by BaseNode instances after initial processing.
|
|
48
48
|
* Ensures consistent prop shape throughout the node's lifecycle:
|
|
@@ -74,7 +74,7 @@ type HasCSSCompatibleStyleProp<P> = P extends {
|
|
|
74
74
|
* - Maintains React's key prop for reconciliation
|
|
75
75
|
* @template E - The element type these props apply to
|
|
76
76
|
*/
|
|
77
|
-
export type NodeProps<E extends NodeElement> = Omit<PropsOf<E>, keyof CSSProperties | 'children' | 'style'> & ReactAttributes & (HasCSSCompatibleStyleProp<PropsOf<E>> extends true ? CSSProperties : object) & Partial<{
|
|
77
|
+
export type NodeProps<E extends NodeElement> = Omit<PropsOf<E>, keyof CSSProperties | 'children' | 'style' | 'theme' | 'props'> & ReactAttributes & (HasCSSCompatibleStyleProp<PropsOf<E>> extends true ? CSSProperties : object) & Partial<{
|
|
78
78
|
props: Partial<Omit<PropsOf<E>, 'children'>>;
|
|
79
79
|
children: Children | Children[];
|
|
80
80
|
theme: Theme;
|
package/dist/node.type.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"node.type.d.ts","sourceRoot":"","sources":["../src/node.type.ts"],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W,eAAe;IAC9B,0CAA0C;IAC1C,QAAQ,CAAC,EAAE,WAAW,GAAG,WAAW,EAAE,CAAA;IAEtC,yDAAyD;IACzD,MAAM,EAAE;QACN,wCAAwC;QACxC,OAAO,EAAE,MAAM,IAAI,CAAA;KACpB,CAAA;CACF;AAED;;;;GAIG;AACH,MAAM,MAAM,WAAW,CAAC,CAAC,SAAS,eAAe,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,IAAI,CAAC,GAAG,eAAe,CAAA;AAE9F;;;;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,EACL,YAAY,CAAC,GAAG,CAAC;IAEnB;;;OAGG;OACD,YAAY,CAAC,GAAG,CAAC,EAAE,CAAA;CACxB,KAAK,YAAY,GAAG,IAAI,GACzB,CACE,KAAK,EAAE,CAAC,GAAG;IACT,8DAA8D;IAC9D,QAAQ,CAAC,EACL,YAAY,CAAC,GAAG,CAAC;IAEnB;;;OAGG;OACD,YAAY,CAAC,GAAG,CAAC,EAAE,CAAA;CACxB,GAAG,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC,EAAE,QAAQ,CAAC,KAC/B,YAAY,GAAG,IAAI,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@meonode/ui",
|
|
3
3
|
"description": "A structured approach to component composition with built-in theming, prop separation, and dynamic children handling.",
|
|
4
|
-
"version": "0.1.
|
|
4
|
+
"version": "0.1.84",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/main.js",
|
|
7
7
|
"types": "./dist/main.d.ts",
|