@meonode/ui 0.1.83 → 0.1.85

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/README.md CHANGED
@@ -4,9 +4,11 @@
4
4
  [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
5
5
  [![Bundle Size](https://img.shields.io/bundlephobia/minzip/@meonode/ui)](https://bundlephobia.com/package/@meonode/ui)
6
6
 
7
- **Build React UIs with Type-Safe Fluency**
8
- A structured approach to component composition with built-in theming, prop separation, and dynamic children handling.
7
+ ## **Build React UIs with Type-Safe Fluency Without JSX Syntax**
9
8
 
9
+ 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.
10
+
11
+ ### Quick Example
10
12
  ```tsx
11
13
  // Quick Start Example
12
14
  import { Component, Div, H1, Button } from '@meonode/ui';
@@ -42,6 +44,7 @@ const App = Component(() =>
42
44
  - 🎯 **Type-Safe Design** - Full TypeScript support with autocomplete for styles, props, and theme paths
43
45
  - 🎨 **Theme-Aware Styles** - Write styles directly in props with dynamic theme resolution
44
46
  - 🧩 **Component-First Architecture** - Compose UIs from structured nodes instead of JSX
47
+ - 🧩 **CSS-First Prop Styling** - Style components directly via props using CSS property names
45
48
  - 🌐 **Contextual Theming** - Theme values propagate automatically through nested components
46
49
  - ⚡ **Optimized Bundle** - Efficient core with tree-shaking support
47
50
  - 🔄 **Seamless React Integration** - Works with hooks, HOCs, and React 18+ features
@@ -150,19 +153,10 @@ const ProfileCard = Component<{ user: User }>(({ user }) =>
150
153
 
151
154
  ---
152
155
 
153
- ## Key Features
154
-
155
- | Feature | Description |
156
- |----------------------|-----------------------------------------------------------------------------|
157
- | **Smart Prop Merge** | CSS props merge with style objects; DOM props pass to underlying elements |
158
- | **Theme Resolution** | `theme.` references resolve through component hierarchy |
159
- | **Type Guards** | Autocomplete for CSS properties and theme paths with strict type checks |
160
- | **HOC Support** | Wrap existing components with `Component()` for theme integration |
161
- | **Dynamic Children** | Supports function-as-child pattern with automatic theme propagation |
156
+ ### 4. Passing Context Wrapper To Portal
162
157
 
163
- ---
158
+ Learn how to wrap a portal-rendered component with a context provider (like Redux Provider) using the `Portal` API from `@meonode/ui`. This lets portal components access context (such as the Redux store) even when rendered outside the main React tree.
164
159
 
165
- ## Passing Context Wrapper To Portal
166
160
  ```ts
167
161
  import { Provider, useSelector } from 'react-redux'
168
162
  import store from '/path/to/redux/store'
package/dist/core.node.js CHANGED
@@ -1,4 +1,4 @@
1
- "use strict";var _excluded=["ref","children","nodetheme","theme","props"],_excluded2=["style"],_excluded3=["flex"],_excluded4=["style"],_excluded5=["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";/**
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=getCSSProps(o),q=this._resolveDefaultStyle(_objectSpread(_objectSpread({},p),n)),r=getDOMProps(o),s=void 0;// Resolve any theme variables in the remaining props
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)?s=e.map(function(a,c){return b._processRawNode(a,j,c)}):s=this._processRawNode(e,j)),this.props=_objectSpread(_objectSpread(_objectSpread({ref:d,nodetheme:j,theme:g,style:q},r),m),{},{children:s})}/**
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,_excluded3),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
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,_excluded4),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
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,_excluded5),g=void 0;// Extract children and key
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/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.83",
4
+ "version": "0.1.85",
5
5
  "type": "module",
6
6
  "main": "./dist/main.js",
7
7
  "types": "./dist/main.d.ts",