@meonode/ui 0.1.95 → 0.1.97

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.
@@ -0,0 +1,85 @@
1
+ import type { FinalNodeProps, NodeElement } from './node.type';
2
+ import type { ComponentProps, CSSProperties, ElementType } from 'react';
3
+ /**
4
+ * Retrieves a deeply nested value from an object using a dot-separated string path.
5
+ *
6
+ * This function traverses an object based on the provided path, which is a
7
+ * string of keys separated by dots. It returns the value found at the end of
8
+ * the path or `undefined` if any key in the path is not found or if the object
9
+ * is nullish at any point during traversal.
10
+ * @param obj The object to traverse, defaults to an empty object if not provided.
11
+ * @param path The dot-separated path string (e.g., 'background.primary').
12
+ * @returns The value at the specified path, or undefined if not found.
13
+ */
14
+ export declare function getValueByPath(obj: Record<string, any> | undefined, path: string): Record<string, any>;
15
+ /**
16
+ * Returns a string describing the type of a given React component or element.
17
+ *
18
+ * Checks for common React types (class, forwardRef, memo, etc.) and returns a string
19
+ * such as 'class', 'forwardRef', 'memo', 'object-with-render', 'function', or other
20
+ * React-specific types. Falls back to `typeof` or 'unknown' if not recognized.
21
+ * @param component The React component, element type, or element-like object to check.
22
+ * @returns A string describing the component type.
23
+ * @example
24
+ * getComponentType(class extends React.Component {}) // 'class'
25
+ * getComponentType(React.forwardRef(() => <div/>)) // 'forwardRef'
26
+ * getComponentType(React.memo(() => <div/>)) // 'memo'
27
+ * getComponentType(() => <div/>) // 'function'
28
+ */
29
+ export declare const getComponentType: (component?: NodeElement) => "class" | "forwardRef" | "memo" | "object" | "function" | "fragment" | "portal" | "profiler" | "strict-mode" | "suspense" | "suspense-list" | "context-consumer" | "context-provider" | "lazy" | "element" | "unknown" | string;
30
+ /**
31
+ * Generates a string name for an ElementType or ReactElement.
32
+ *
33
+ * This function attempts to extract a meaningful name from a React ElementType
34
+ * (string, function, class, HOC) or a ReactElement instance.
35
+ * It prioritizes `displayName` and `name` properties and unwraps HOCs like
36
+ * `React.memo` and `React.forwardRef` to get the underlying component name.
37
+ *
38
+ * If a name cannot be determined, it returns a fallback like 'UnknownElementType' or 'AnonymousComponent'.
39
+ * @param node The ElementType or ReactElement (e.g., 'div', MyComponent, <MyComponent />).
40
+ * @returns A string representation of the element type's name.
41
+ */
42
+ export declare function getElementTypeName(node: unknown): string;
43
+ /**
44
+ * A set of valid CSS property names in camelCase, including CSS custom properties, used for validation.
45
+ * This set contains all CSS properties including non-standard vendor prefixed properties.
46
+ */
47
+ export declare const CSSPropertySet: Set<string>;
48
+ /**
49
+ * Filters an object to only include valid CSS properties
50
+ * @param props The object containing potential CSS properties
51
+ * @returns An object containing only valid CSS properties
52
+ * @example
53
+ * ```ts
54
+ * getCSSProps({
55
+ * backgroundColor: 'red',
56
+ * invalid: true
57
+ * }) // { backgroundColor: 'red' }
58
+ * ```
59
+ */
60
+ export declare function getCSSProps<T extends Record<string, any>>(props: T): Partial<CSSProperties>;
61
+ /**
62
+ * Filters component props to include only valid DOM properties and attributes.
63
+ *
64
+ * This function iterates through the provided props and retains only those that
65
+ * are not CSS properties (as determined by `cssPropertySet`). This is useful for
66
+ * separating style-related props from standard DOM attributes when rendering
67
+ * elements.
68
+ * @ty E - The type of the React element.
69
+ * @typeParam T - The type of the component props.
70
+ * @param props The component props to filter.
71
+ * @returns An object containing only valid DOM props.
72
+ */
73
+ export declare function getDOMProps<E extends ElementType, T extends ComponentProps<E>>(props: T): Partial<FinalNodeProps>;
74
+ /**
75
+ * Checks if a property on an object is writable.
76
+ *
77
+ * This function uses `Object.getOwnPropertyDescriptor` to determine if the specified
78
+ * property is writable. If the property descriptor is not found (property does not exist
79
+ * or is inherited), it returns `true` by default.
80
+ * @param obj The object to check.
81
+ * @param key The property name to check for writability.
82
+ * @returns `true` if the property is writable or not explicitly defined, otherwise `false`.
83
+ */
84
+ export declare function isWritable(obj: Record<string, any>, key: string): boolean;
85
+ //# sourceMappingURL=common.helper.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"common.helper.d.ts","s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71 @@
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)}import{isContextConsumer,isContextProvider,isElement,isForwardRef,isFragment,isLazy,isMemo,isPortal,isProfiler,isReactClassComponent,isStrictMode,isSuspense,isSuspenseList}from"./react-is.helper.js";import cssProperties from"./data/css-properties";/**
2
+ * Retrieves a deeply nested value from an object using a dot-separated string path.
3
+ *
4
+ * This function traverses an object based on the provided path, which is a
5
+ * string of keys separated by dots. It returns the value found at the end of
6
+ * the path or `undefined` if any key in the path is not found or if the object
7
+ * is nullish at any point during traversal.
8
+ * @param obj The object to traverse, defaults to an empty object if not provided.
9
+ * @param path The dot-separated path string (e.g., 'background.primary').
10
+ * @returns The value at the specified path, or undefined if not found.
11
+ */export function getValueByPath(){var a=0<arguments.length&&arguments[0]!==void 0?arguments[0]:{},b=1<arguments.length?arguments[1]:void 0;return b.split(".").reduce(function(a,b){return null===a||void 0===a?void 0:a[b]},a)}/**
12
+ * Returns a string describing the type of a given React component or element.
13
+ *
14
+ * Checks for common React types (class, forwardRef, memo, etc.) and returns a string
15
+ * such as 'class', 'forwardRef', 'memo', 'object-with-render', 'function', or other
16
+ * React-specific types. Falls back to `typeof` or 'unknown' if not recognized.
17
+ * @param component The React component, element type, or element-like object to check.
18
+ * @returns A string describing the component type.
19
+ * @example
20
+ * getComponentType(class extends React.Component {}) // 'class'
21
+ * getComponentType(React.forwardRef(() => <div/>)) // 'forwardRef'
22
+ * getComponentType(React.memo(() => <div/>)) // 'memo'
23
+ * getComponentType(() => <div/>) // 'function'
24
+ */export var getComponentType=function getComponentType(a){return isForwardRef(a)?"forwardRef":isMemo(a)?"memo":isFragment(a)?"fragment":isPortal(a)?"portal":isProfiler(a)?"profiler":isStrictMode(a)?"strict-mode":isSuspense(a)?"suspense":isSuspenseList(a)?"suspense-list":isContextConsumer(a)?"context-consumer":isContextProvider(a)?"context-provider":isLazy(a)?"lazy":isElement(a)?"element":isReactClassComponent(a)?"class":_typeof(a)};/**
25
+ * Generates a string name for an ElementType or ReactElement.
26
+ *
27
+ * This function attempts to extract a meaningful name from a React ElementType
28
+ * (string, function, class, HOC) or a ReactElement instance.
29
+ * It prioritizes `displayName` and `name` properties and unwraps HOCs like
30
+ * `React.memo` and `React.forwardRef` to get the underlying component name.
31
+ *
32
+ * If a name cannot be determined, it returns a fallback like 'UnknownElementType' or 'AnonymousComponent'.
33
+ * @param node The ElementType or ReactElement (e.g., 'div', MyComponent, <MyComponent />).
34
+ * @returns A string representation of the element type's name.
35
+ */export function getElementTypeName(a){var b,c;function getDisplayName(a,b){var c=(null===a||void 0===a?void 0:a.displayName)||(null===a||void 0===a?void 0:a.name);return!c||"render"===c?b:c}if(null===a||a===void 0)return"UnknownElementType";var d=a,e=getComponentType(d);switch(e){case"string":return a;case"class":return getDisplayName(d,"ClassComponent");case"function":return getDisplayName(d,"AnonymousFunctionComponent");case"forwardRef":return getDisplayName(d,"")||getDisplayName(d.render,"")||"ForwardRefComponent";case"memo":return getDisplayName(d,"")||(d.type?getElementTypeName(d.type):"MemoComponent");case"element":return getElementTypeName(d.type);case"fragment":return"Fragment";case"portal":return"Portal";case"profiler":return getDisplayName(d,"Profiler");case"strict-mode":return"StrictMode";case"suspense":return getDisplayName(d,"Suspense");case"suspense-list":return"SuspenseList";case"context-consumer":return null!==(b=d._context)&&void 0!==b&&b.displayName?"".concat(d._context.displayName,".Consumer"):"ContextConsumer";case"context-provider":return null!==(c=d._context)&&void 0!==c&&c.displayName?"".concat(d._context.displayName,".Provider"):"ContextProvider";case"lazy":return getDisplayName(d,"LazyComponent");case"object":return getDisplayName(d,"")?getDisplayName(d,""):"function"==typeof d.render?getDisplayName(d.render,"ObjectWithRender"):d.type&&d.type!==a?"Wrapped<".concat(getElementTypeName(d.type),">"):getDisplayName(d,"ObjectComponent");case"symbol":if("symbol"===_typeof(a)){var f;return(null===(f=a.description)||void 0===f?void 0:f.replace(/^react\./,"").split(".").map(function(a){var b;return(null===(b=a[0])||void 0===b?void 0:b.toUpperCase())+a.slice(1)}).join(""))||a.toString()}return"SymbolComponent";case"unknown":return"UnknownElementType";default:return"UnsupportedType<".concat(e,">")}}/**
36
+ * A set of valid CSS property names in camelCase, including CSS custom properties, used for validation.
37
+ * This set contains all CSS properties including non-standard vendor prefixed properties.
38
+ */export var CSSPropertySet=new Set(cssProperties);/**
39
+ * Filters an object to only include valid CSS properties
40
+ * @param props The object containing potential CSS properties
41
+ * @returns An object containing only valid CSS properties
42
+ * @example
43
+ * ```ts
44
+ * getCSSProps({
45
+ * backgroundColor: 'red',
46
+ * invalid: true
47
+ * }) // { backgroundColor: 'red' }
48
+ * ```
49
+ */export function getCSSProps(a){var b={};for(var c in a)Object.prototype.hasOwnProperty.call(a,c)&&CSSPropertySet.has(c)&&(b[c]=a[c]);return b}/**
50
+ * Filters component props to include only valid DOM properties and attributes.
51
+ *
52
+ * This function iterates through the provided props and retains only those that
53
+ * are not CSS properties (as determined by `cssPropertySet`). This is useful for
54
+ * separating style-related props from standard DOM attributes when rendering
55
+ * elements.
56
+ * @ty E - The type of the React element.
57
+ * @typeParam T - The type of the component props.
58
+ * @param props The component props to filter.
59
+ * @returns An object containing only valid DOM props.
60
+ */export function getDOMProps(a){var b={};for(var c in a)Object.prototype.hasOwnProperty.call(a,c)&&!CSSPropertySet.has(c)&&(b[c]=a[c]);return b}/**
61
+ * Checks if a property on an object is writable.
62
+ *
63
+ * This function uses `Object.getOwnPropertyDescriptor` to determine if the specified
64
+ * property is writable. If the property descriptor is not found (property does not exist
65
+ * or is inherited), it returns `true` by default.
66
+ * @param obj The object to check.
67
+ * @param key The property name to check for writability.
68
+ * @returns `true` if the property is writable or not explicitly defined, otherwise `false`.
69
+ */export function isWritable(a,b){var c=Object.getOwnPropertyDescriptor(a,b);// If the property doesn't exist or is inherited, desc will be undefined.
70
+ // In such cases, it's typically considered writable unless explicitly defined otherwise.
71
+ return!c||!!c.writable}
@@ -30,30 +30,7 @@ export declare class BaseNode<E extends NodeElement = NodeElement> implements No
30
30
  * @param rawProps Initial props including theme, styles, and children
31
31
  */
32
32
  constructor(element: E, rawProps?: RawNodeProps<E>);
33
- /**
34
- * Resolves default styles for a given CSSProperties object.
35
- * This method ensures that certain default styles, such as `minHeight`, `minWidth`,
36
- * and `flexShrink`, are applied based on the provided style properties.
37
- *
38
- * - If the element is a flex container:
39
- * - Sets `flexShrink` to 0 for specific scenarios:
40
- * - Column-based layout without wrapping.
41
- * - Row-based layout without wrapping (a default direction is assumed to be 'row').
42
- * - If the element is not a flex container:
43
- * - Defaults `flexShrink` to 0.
44
- * @param style The CSSProperties object containing style definitions.
45
- * @returns An object with resolved default styles.
46
- */
47
- private _resolveDefaultStyle;
48
- /**
49
- * Resolves theme variable references in an object's values recursively.
50
- * Handles nested objects and prevents circular references.
51
- * Theme variables are referenced using the format "theme.path.to.value".
52
- * @param obj The object whose values should be resolved against the theme
53
- * @param theme Optional theme object containing variable definitions
54
- * @returns A new object with all theme variables resolved to their values
55
- */
56
- private _resolveObjWithTheme;
33
+ private _processChildren;
57
34
  /**
58
35
  * Renders a processed NodeElement into a ReactNode, applying theme and key if needed.
59
36
  *
@@ -1 +1 @@
1
- {"version":3,"file":"core.node.d.ts","sourceRoot":"","sources":["../src/core.node.ts"],"names":[],"mappings":"AACA,OAAc,EAAsG,KAAK,SAAS,EAAE,MAAM,OAAO,CAAA;AACjJ,OAAO,KAAK,EAAE,cAAc,EAAyB,WAAW,EAAE,YAAY,EAAE,SAAS,EAAW,YAAY,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAA;AAGlJ,OAAO,EAAc,KAAK,IAAI,IAAI,YAAY,EAAE,MAAM,kBAAkB,CAAA;AAExE;;;;;;;;GAQG;AACH,qBAAa,QAAQ,CAAC,CAAC,SAAS,WAAW,GAAG,WAAW,CAAE,YAAW,YAAY,CAAC,CAAC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BvC;AAED;;;;;GAKG;AACH,wBAAgB,IAAI,CAAC,CAAC,SAAS,WAAW,EAAE,OAAO,EAAE,CAAC,EAAE,KAAK,GAAE,OAAO,CAAC,SAAS,CAAC,CAAC,CAAC,CAAM,GAAG,YAAY,CAAC,CAAC,CAAC,CAU1G"}
package/dist/core.node.js CHANGED
@@ -1,4 +1,4 @@
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";/**
1
+ "use strict";var _excluded=["ref","children","nodetheme","theme","props"],_excluded2=["style"],_excluded3=["style"],_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{isNodeInstance,resolveDefaultStyle,resolveObjWithTheme}from"./node.helper.js";import{isForwardRef,isMemo,isReactClassComponent,isValidElementType}from"./react-is.helper.js";import{createRoot}from"react-dom/client";import{getComponentType,getCSSProps,getDOMProps,getElementTypeName}from"./common.helper";/**
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,48 +18,9 @@
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=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
- // Extract CSS-related properties from the resolved theme-aware props
23
- // Resolve default styles
24
- // Extract remaining props that are valid DOM attributes
25
- // Process children while maintaining theme inheritance
21
+ var d=c.ref,e=c.children,f=c.nodetheme,g=c.theme,h=c.props,i=void 0===h?{}:h,j=_objectWithoutProperties(c,_excluded),k=g||f,l=i,m=l.style,n=_objectWithoutProperties(l,_excluded2),o=resolveObjWithTheme(_objectSpread(_objectSpread({},j),{},{style:_objectSpread(_objectSpread({},null===j||void 0===j?void 0:j.style),m)}),k),p=o.style,q=_objectWithoutProperties(o,_excluded3),r=getCSSProps(q),s=getDOMProps(q),t=resolveDefaultStyle(_objectSpread(_objectSpread({},r),p)),u=this._processChildren(e,k);// Process children while maintaining theme inheritance
26
22
  // Combine processed props into final normalized form
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
- * Resolves default styles for a given CSSProperties object.
29
- * This method ensures that certain default styles, such as `minHeight`, `minWidth`,
30
- * and `flexShrink`, are applied based on the provided style properties.
31
- *
32
- * - If the element is a flex container:
33
- * - Sets `flexShrink` to 0 for specific scenarios:
34
- * - Column-based layout without wrapping.
35
- * - Row-based layout without wrapping (a default direction is assumed to be 'row').
36
- * - If the element is not a flex container:
37
- * - Defaults `flexShrink` to 0.
38
- * @param style The CSSProperties object containing style definitions.
39
- * @returns An object with resolved default styles.
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
- 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
- i&&!g?h=0:j&&!g&&(h=0)}return _objectSpread({flex:c,flexShrink:h,minHeight:0,minWidth:0},d)}/**
43
- * Resolves theme variable references in an object's values recursively.
44
- * Handles nested objects and prevents circular references.
45
- * Theme variables are referenced using the format "theme.path.to.value".
46
- * @param obj The object whose values should be resolved against the theme
47
- * @param theme Optional theme object containing variable definitions
48
- * @returns A new object with all theme variables resolved to their values
49
- */_resolveObjWithTheme(){var a,b=0<arguments.length&&arguments[0]!==void 0?arguments[0]:{},c=1<arguments.length?arguments[1]:void 0;// Early return if no theme or empty object
50
- if(!c||0===Object.keys(b).length)return b;// Merge parent theme with current theme
51
- var d=_objectSpread(_objectSpread({},null===(a=this.rawProps)||void 0===a?void 0:a.nodetheme),c),e=function resolveRecursively(a,b){// Prevent processing same object multiple times
52
- if(b.has(a))return a;// Track this object to detect circular references
53
- b.add(a);var c={};for(var f in a){var g=a[f];// Skip functions and non-plain objects to prevent unintended flattening or
54
- // modification of complex instances like React components, DOM elements, or Date objects.
55
- if("function"==typeof g||g&&"object"===_typeof(g)&&!Array.isArray(g)&&Object.getPrototypeOf(g)!==Object.prototype){c[f]=g;continue}// Resolve theme variables in string values
56
- if("string"==typeof g&&g.includes("theme.")){var h=g;h=h.replace(/theme\.([a-zA-Z0-9_.-]+)/g,function(a,b){var c=getValueByPath(d,b);// Only convert string/number theme values
57
- return void 0!==c&&null!==c?"object"===_typeof(c)&&!Array.isArray(c)&&"default"in c?c["default"]:c:a;// Keep original if no valid theme value found
58
- }),c[f]=h}// Recursively process nested objects
59
- else c[f]=g&&"object"===_typeof(g)&&!Array.isArray(g)?e(g,b):g}return c};/**
60
- * Recursively resolves theme variables in an object, tracking visited objects
61
- * to prevent infinite recursion with circular references.
62
- */return e(b,new Set)}/**
23
+ this.props=_objectSpread(_objectSpread(_objectSpread({ref:d,nodetheme:k,theme:g,style:t},s),n),{},{children:u})}_processChildren(a,b){var c=this;return a?Array.isArray(a)?a.map(function(a,d){return c._processRawNode(a,b,d)}):this._processRawNode(a,b):void 0}/**
63
24
  * Renders a processed NodeElement into a ReactNode, applying theme and key if needed.
64
25
  *
65
26
  * Handles the following cases:
@@ -120,7 +81,7 @@ if("function"===d&&!isReactClassComponent(a)&&!isMemo(a)&&!isForwardRef(a)){// T
120
81
  var j=e(this._functionRenderer,void 0);// Generate key for function renderer
121
82
  return new BaseNode(this._functionRenderer,{processRawNode:this._processRawNode.bind(this),render:a,passedTheme:b,key:j// Assign the generated key
122
83
  })}// 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,_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
84
+ 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
124
85
  return new BaseNode(a.type,_objectSpread(_objectSpread({},n),{},{// Pass the combined props
125
86
  nodetheme:o,key:p}))}// Case 5: Child is an ElementType (string tag, class component, Memo/ForwardRef)
126
87
  if(isReactClassComponent(a)||"object"===d&&(isMemo(a)||isForwardRef(a))){// ElementTypes don't have an intrinsic key from the rawNode itself.
@@ -147,7 +108,7 @@ return a}/**
147
108
  * Converts this BaseNode instance into a renderable React node.
148
109
  * Recursively processes child nodes and uses `React.createElement` to construct the final React element.
149
110
  * @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,_excluded6),g=void 0;// Extract children and key
111
+ */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
151
112
  // More accurate type
152
113
  if(d!==void 0&&null!==d)if(!Array.isArray(d))// Single child
153
114
  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