@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.
- package/dist/common.helper.d.ts +85 -0
- package/dist/common.helper.d.ts.map +1 -0
- package/dist/common.helper.js +71 -0
- package/dist/core.node.d.ts +1 -24
- package/dist/core.node.d.ts.map +1 -1
- package/dist/core.node.js +5 -44
- package/dist/node.helper.d.ts +852 -73
- package/dist/node.helper.d.ts.map +1 -1
- package/dist/node.helper.js +37 -61
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"node.helper.d.ts","sourceRoot":"","sources":["../src/node.helper.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"node.helper.d.ts","sourceRoot":"","sources":["../src/node.helper.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,OAAO,CAAA;AAC1C,OAAO,KAAK,EAAE,YAAY,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAA;AAG5D;;;;;;;;;;GAUG;AACH,eAAO,MAAM,cAAc,GAAI,KAAK,OAAO,KAAG,GAAG,IAAI,YAAY,CAAC,GAAG,CASpE,CAAA;AAED;;;;;;;GAOG;AACH,eAAO,MAAM,mBAAmB,GAAI,MAAK,MAAM,CAAC,MAAM,EAAE,GAAG,CAAM,EAAE,QAAQ,KAAK,wBAmE/E,CAAA;AAED;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,mBAAmB,GAAI,OAAO,aAAa;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA4BvD,CAAA"}
|
package/dist/node.helper.js
CHANGED
|
@@ -1,63 +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)}import{
|
|
2
|
-
* Returns a string describing the type of a given React component or element.
|
|
3
|
-
*
|
|
4
|
-
* Checks for common React types (class, forwardRef, memo, etc.) and returns a string
|
|
5
|
-
* such as 'class', 'forwardRef', 'memo', 'object-with-render', 'function', or other
|
|
6
|
-
* React-specific types. Falls back to `typeof` or 'unknown' if not recognized.
|
|
7
|
-
* @param component The React component, element type, or element-like object to check.
|
|
8
|
-
* @returns A string describing the component type.
|
|
9
|
-
* @example
|
|
10
|
-
* getComponentType(class extends React.Component {}) // 'class'
|
|
11
|
-
* getComponentType(React.forwardRef(() => <div/>)) // 'forwardRef'
|
|
12
|
-
* getComponentType(React.memo(() => <div/>)) // 'memo'
|
|
13
|
-
* getComponentType(() => <div/>) // 'function'
|
|
14
|
-
*/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)};/**
|
|
15
|
-
* Generates a string name for an ElementType or ReactElement.
|
|
16
|
-
*
|
|
17
|
-
* This function attempts to extract a meaningful name from a React ElementType
|
|
18
|
-
* (string, function, class, HOC) or a ReactElement instance.
|
|
19
|
-
* It prioritizes `displayName` and `name` properties and unwraps HOCs like
|
|
20
|
-
* `React.memo` and `React.forwardRef` to get the underlying component name.
|
|
21
|
-
*
|
|
22
|
-
* If a name cannot be determined, it returns a fallback like 'UnknownElementType' or 'AnonymousComponent'.
|
|
23
|
-
* @param node The ElementType or ReactElement (e.g., 'div', MyComponent, <MyComponent />).
|
|
24
|
-
* @returns A string representation of the element type's name.
|
|
25
|
-
*/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,">")}}/**
|
|
26
|
-
* A set of valid CSS property names in camelCase, including CSS custom properties, used for validation.
|
|
27
|
-
* This set contains all CSS properties including non-standard vendor prefixed properties.
|
|
28
|
-
*/export var CSSPropertySet=new Set(cssProperties);/**
|
|
29
|
-
* Filters an object to only include valid CSS properties
|
|
30
|
-
* @param props The object containing potential CSS properties
|
|
31
|
-
* @returns An object containing only valid CSS properties
|
|
32
|
-
* @example
|
|
33
|
-
* ```ts
|
|
34
|
-
* getCSSProps({
|
|
35
|
-
* backgroundColor: 'red',
|
|
36
|
-
* invalid: true
|
|
37
|
-
* }) // { backgroundColor: 'red' }
|
|
38
|
-
* ```
|
|
39
|
-
*/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}/**
|
|
40
|
-
* Filters component props to include only valid DOM properties and attributes.
|
|
41
|
-
*
|
|
42
|
-
* This function iterates through the provided props and retains only those that
|
|
43
|
-
* are not CSS properties (as determined by `cssPropertySet`). This is useful for
|
|
44
|
-
* separating style-related props from standard DOM attributes when rendering
|
|
45
|
-
* elements.
|
|
46
|
-
* @ty E - The type of the React element.
|
|
47
|
-
* @typeParam T - The type of the component props.
|
|
48
|
-
* @param props The component props to filter.
|
|
49
|
-
* @returns An object containing only valid DOM props.
|
|
50
|
-
*/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}/**
|
|
51
|
-
* Retrieves a deeply nested value from an object using a dot-separated string path.
|
|
52
|
-
*
|
|
53
|
-
* This function traverses an object based on the provided path, which is a
|
|
54
|
-
* string of keys separated by dots. It returns the value found at the end of
|
|
55
|
-
* the path or `undefined` if any key in the path is not found or if the object
|
|
56
|
-
* is nullish at any point during traversal.
|
|
57
|
-
* @param obj The object to traverse. Defaults to an empty object if not provided.
|
|
58
|
-
* @param path The dot-separated path string (e.g., 'background.primary').
|
|
59
|
-
* @returns The value at the specified path, or undefined if not found.
|
|
60
|
-
*/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)}/**
|
|
1
|
+
"use strict";var _excluded=["flex"];function ownKeys(a,b){var c=Object.keys(a);if(Object.getOwnPropertySymbols){var d=Object.getOwnPropertySymbols(a);b&&(d=d.filter(function(b){return Object.getOwnPropertyDescriptor(a,b).enumerable})),c.push.apply(c,d)}return c}function _objectSpread(a){for(var b,c=1;c<arguments.length;c++)b=null==arguments[c]?{}:arguments[c],c%2?ownKeys(Object(b),!0).forEach(function(c){_defineProperty(a,c,b[c])}):Object.getOwnPropertyDescriptors?Object.defineProperties(a,Object.getOwnPropertyDescriptors(b)):ownKeys(Object(b)).forEach(function(c){Object.defineProperty(a,c,Object.getOwnPropertyDescriptor(b,c))});return a}function _defineProperty(a,b,c){return(b=_toPropertyKey(b))in a?Object.defineProperty(a,b,{value:c,enumerable:!0,configurable:!0,writable:!0}):a[b]=c,a}function _toPropertyKey(a){var b=_toPrimitive(a,"string");return"symbol"==_typeof(b)?b:b+""}function _toPrimitive(a,b){if("object"!=_typeof(a)||!a)return a;var c=a[Symbol.toPrimitive];if(void 0!==c){var d=c.call(a,b||"default");if("object"!=_typeof(d))return d;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===b?String:Number)(a)}function _objectWithoutProperties(a,b){if(null==a)return{};var c,d,e=_objectWithoutPropertiesLoose(a,b);if(Object.getOwnPropertySymbols){var f=Object.getOwnPropertySymbols(a);for(d=0;d<f.length;d++)c=f[d],-1===b.indexOf(c)&&{}.propertyIsEnumerable.call(a,c)&&(e[c]=a[c])}return e}function _objectWithoutPropertiesLoose(a,b){if(null==a)return{};var c={};for(var d in a)if({}.hasOwnProperty.call(a,d)){if(-1!==b.indexOf(d))continue;c[d]=a[d]}return c}function _typeof(a){"@babel/helpers - typeof";return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(a){return typeof a}:function(a){return a&&"function"==typeof Symbol&&a.constructor===Symbol&&a!==Symbol.prototype?"symbol":typeof a},_typeof(a)}import{getValueByPath,isWritable}from"./common.helper";/**
|
|
61
2
|
* Type guard to check if an object is a NodeInstance.
|
|
62
3
|
*
|
|
63
4
|
* A NodeInstance is expected to be a non-null object with:
|
|
@@ -67,4 +8,39 @@
|
|
|
67
8
|
* - and an 'isBaseNode' property.
|
|
68
9
|
* @param obj The object to check.
|
|
69
10
|
* @returns True if the object is a NodeInstance, false otherwise.
|
|
70
|
-
*/export var isNodeInstance=function isNodeInstance(a){return"object"===_typeof(a)&&null!==a&&"element"in a&&"function"==typeof a.render&&"function"==typeof a.toPortal&&"isBaseNode"in a}
|
|
11
|
+
*/export var isNodeInstance=function isNodeInstance(a){return"object"===_typeof(a)&&null!==a&&"element"in a&&"function"==typeof a.render&&"function"==typeof a.toPortal&&"isBaseNode"in a};/**
|
|
12
|
+
* Resolves theme variable references in an object's values recursively.
|
|
13
|
+
* Handles nested objects and prevents circular references.
|
|
14
|
+
* Theme variables are referenced using the format "theme.path.to.value".
|
|
15
|
+
* @param obj The object whose values should be resolved against the theme
|
|
16
|
+
* @param theme Optional theme object containing variable definitions
|
|
17
|
+
* @returns A new object with all theme variables resolved to their values
|
|
18
|
+
*/export var resolveObjWithTheme=function resolveObjWithTheme(){var a=0<arguments.length&&arguments[0]!==void 0?arguments[0]:{},b=1<arguments.length?arguments[1]:void 0;// Early return if no theme or empty object
|
|
19
|
+
if(!b||0===Object.keys(a).length)return a;/**
|
|
20
|
+
* Recursively resolves theme variables in an object, tracking visited objects
|
|
21
|
+
* to prevent infinite recursion with circular references.
|
|
22
|
+
*/var c=function resolveRecursively(a,d){// Skip functions and non-plain objects to prevent unintended flattening or
|
|
23
|
+
// modification of complex instances like React components, DOM elements, or Date objects.
|
|
24
|
+
if(!a||"object"!==_typeof(a)||Array.isArray(a)||Object.getPrototypeOf(a)!==Object.prototype)return a;// Prevent processing same object multiple times
|
|
25
|
+
if(d.has(a))return a;// Track this object to detect circular references
|
|
26
|
+
for(var e in d.add(a),a){var f=a[e];// Conditions for direct assignment (no resolution or deep processing needed)
|
|
27
|
+
if("function"!=typeof f&&"ref"!==e&&"key"!==e&&("object"!==_typeof(f)||null===f||Array.isArray(f)||Object.getPrototypeOf(f)===Object.prototype)&&("string"!=typeof f||f.includes("theme."))&&("object"===_typeof(f)||"string"==typeof f||"function"==typeof f)&&isWritable(a,e))// Resolve theme variables in string values
|
|
28
|
+
if("string"==typeof f&&f.includes("theme.")){var g=f;g=g.replace(/theme\.([a-zA-Z0-9_.-]+)/g,function(a,c){var d=getValueByPath(b,c);// Only convert string/number theme values
|
|
29
|
+
return void 0!==d&&null!==d?"object"===_typeof(d)&&!Array.isArray(d)&&"default"in d?d["default"]:d:a;// Keep original if no valid theme value found
|
|
30
|
+
}),a[e]=g}// Recursively process nested objects
|
|
31
|
+
else a[e]=c(f,d)}return a};return c(a,new Set)};/**
|
|
32
|
+
* Resolves default styles for a given CSSProperties object.
|
|
33
|
+
* This method ensures that certain default styles, such as `minHeight`, `minWidth`,
|
|
34
|
+
* and `flexShrink`, are applied based on the provided style properties.
|
|
35
|
+
*
|
|
36
|
+
* - If the element is a flex container:
|
|
37
|
+
* - Sets `flexShrink` to 0 for specific scenarios:
|
|
38
|
+
* - Column-based layout without wrapping.
|
|
39
|
+
* - Row-based layout without wrapping (a default direction is assumed to be 'row').
|
|
40
|
+
* - If the element is not a flex container:
|
|
41
|
+
* - Defaults `flexShrink` to 0.
|
|
42
|
+
* @param style The CSSProperties object containing style definitions.
|
|
43
|
+
* @returns An object with resolved default styles.
|
|
44
|
+
*/export var resolveDefaultStyle=function resolveDefaultStyle(a){var b,c=a.flex,d=_objectWithoutProperties(a,_excluded),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
|
|
45
|
+
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
|
|
46
|
+
i&&!g?h=0:j&&!g&&(h=0)}return _objectSpread({flex:c,flexShrink:h,minHeight:0,minWidth:0},d)};
|
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.1.
|
|
4
|
+
"version": "0.1.97",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/main.js",
|
|
7
7
|
"types": "./dist/main.d.ts",
|