@meonode/ui 0.1.59 → 0.1.61
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.d.ts +86 -57
- package/dist/core.node.d.ts.map +1 -1
- package/dist/core.node.js +3 -66
- package/dist/hoc/component.hoc.d.ts +28 -0
- package/dist/hoc/component.hoc.d.ts.map +1 -0
- package/dist/hoc/component.hoc.js +25 -0
- package/dist/hoc/index.d.ts +3 -0
- package/dist/hoc/index.d.ts.map +1 -0
- package/dist/hoc/index.js +1 -0
- package/dist/hoc/portal.hoc.d.ts +77 -0
- package/dist/hoc/portal.hoc.d.ts.map +1 -0
- package/dist/hoc/portal.hoc.js +94 -0
- package/dist/hook/useClasses.d.ts +20 -3
- package/dist/hook/useClasses.d.ts.map +1 -1
- package/dist/hook/useClasses.js +82 -29
- package/dist/main.d.ts +3 -2
- package/dist/main.d.ts.map +1 -1
- package/dist/main.js +1 -1
- package/dist/node.type.d.ts +8 -9
- package/dist/node.type.d.ts.map +1 -1
- package/dist/react-is.helper.d.ts.map +1 -1
- package/dist/react-is.helper.js +2 -2
- package/package.json +1 -1
package/dist/core.node.d.ts
CHANGED
|
@@ -1,5 +1,89 @@
|
|
|
1
|
-
import
|
|
2
|
-
import type {
|
|
1
|
+
import { type ReactNode } from 'react';
|
|
2
|
+
import type { FinalNodeProps, NodeElement, NodeInstance, NodeProps, RawNodeProps, Theme } from './node.type.js';
|
|
3
|
+
import { type Root as ReactDOMRoot } from 'react-dom/client';
|
|
4
|
+
/**
|
|
5
|
+
* Represents a node in a React component tree with theme and styling capabilities.
|
|
6
|
+
* This class wraps React elements and handles:
|
|
7
|
+
* - Props processing and normalization
|
|
8
|
+
* - Theme inheritance and resolution
|
|
9
|
+
* - Child node processing and management
|
|
10
|
+
* - Style processing with theme variables
|
|
11
|
+
* @template E The type of React element or component this node represents
|
|
12
|
+
*/
|
|
13
|
+
export declare class BaseNode<E extends NodeElement> implements NodeInstance<E> {
|
|
14
|
+
/** The underlying React element or component type that this node represents */
|
|
15
|
+
element: E;
|
|
16
|
+
/** Original props passed during construction, preserved for cloning/recreation */
|
|
17
|
+
rawProps?: RawNodeProps<E>;
|
|
18
|
+
/** Processed props after theme resolution, style processing, and child normalization */
|
|
19
|
+
props: FinalNodeProps;
|
|
20
|
+
private _portalDOMElement;
|
|
21
|
+
private _portalReactRoot;
|
|
22
|
+
/**
|
|
23
|
+
* Creates a new BaseNode instance that wraps a React element.
|
|
24
|
+
* Processes raw props by:
|
|
25
|
+
* - Extracting and resolving theme-aware styles
|
|
26
|
+
* - Processing DOM-related props
|
|
27
|
+
* - Normalizing children with theme inheritance
|
|
28
|
+
* @param element The React element/component to wrap
|
|
29
|
+
* @param rawProps Initial props including theme, styles, and children
|
|
30
|
+
*/
|
|
31
|
+
constructor(element: E, rawProps?: RawNodeProps<E>);
|
|
32
|
+
/**
|
|
33
|
+
* Resolves theme variable references in an object's values recursively.
|
|
34
|
+
* Handles nested objects and prevents circular references.
|
|
35
|
+
* Theme variables are referenced using the format "theme.path.to.value".
|
|
36
|
+
* @param obj The object whose values should be resolved against the theme
|
|
37
|
+
* @param theme Optional theme object containing variable definitions
|
|
38
|
+
* @returns A new object with all theme variables resolved to their values
|
|
39
|
+
*/
|
|
40
|
+
private _resolveObjWithTheme;
|
|
41
|
+
/**
|
|
42
|
+
* React component that renders the result of a function child, supporting theme propagation.
|
|
43
|
+
*
|
|
44
|
+
* This component is used to render children that are functions (i.e., `() => Children`).
|
|
45
|
+
* It ensures that if the returned value is a `BaseNode` instance without an explicit theme,
|
|
46
|
+
* the theme from the parent is injected. Otherwise, the result is rendered as-is.
|
|
47
|
+
* @param props The props for the renderer.
|
|
48
|
+
* @param props.render The function to invoke for rendering the child.
|
|
49
|
+
* @param props.passedTheme The theme to provide to the child, if applicable.
|
|
50
|
+
* @returns The rendered ReactNode, with theme applied if necessary.
|
|
51
|
+
*/
|
|
52
|
+
private _functionRenderer;
|
|
53
|
+
/**
|
|
54
|
+
* Processes a single raw child element, converting it into a ProcessedChild.
|
|
55
|
+
* If the child is part of an array and lacks an explicit key, a stable indexed key
|
|
56
|
+
* (`elementName_child_index`) is generated for new BaseNode instances.
|
|
57
|
+
* @param rawNode The raw child element to process.
|
|
58
|
+
* @param parentTheme The theme inherited from the parent node.
|
|
59
|
+
* @param childIndex Optional index of the child if it's part of an array.
|
|
60
|
+
* @returns The processed child.
|
|
61
|
+
*/
|
|
62
|
+
_processRawNode(rawNode: NodeElement, parentTheme?: Theme, childIndex?: number): NodeElement;
|
|
63
|
+
/**
|
|
64
|
+
* Normalizes a child node into a renderable ReactNode.
|
|
65
|
+
* Processes different types of child nodes to ensure they can be properly rendered
|
|
66
|
+
* while maintaining theme inheritance.
|
|
67
|
+
*
|
|
68
|
+
* Handles:
|
|
69
|
+
* - BaseNode instances (applies theme if needed)
|
|
70
|
+
* - React.Component instances (applies theme if needed)
|
|
71
|
+
* - Other valid React element types (returned as-is)
|
|
72
|
+
* - null/undefined values (returned as-is)
|
|
73
|
+
* @param child The child node to normalize into a renderable form
|
|
74
|
+
* @returns The normalized ReactNode that can be rendered by React
|
|
75
|
+
* @throws Error if child is an invalid element type
|
|
76
|
+
*/
|
|
77
|
+
private _normalizeChild;
|
|
78
|
+
/**
|
|
79
|
+
* Converts this BaseNode instance into a renderable React node.
|
|
80
|
+
* Recursively processes child nodes and uses `React.createElement` to construct the final React element.
|
|
81
|
+
* @returns A ReactNode representing the rendered element.
|
|
82
|
+
*/
|
|
83
|
+
render(): ReactNode;
|
|
84
|
+
private _ensurePortalInfrastructure;
|
|
85
|
+
toPortal(): ReactDOMRoot | null;
|
|
86
|
+
}
|
|
3
87
|
/**
|
|
4
88
|
* Factory function to create a BaseNode instance.
|
|
5
89
|
* @param element The React element type.
|
|
@@ -7,59 +91,4 @@ import type { ComponentNode, NodeElement, NodeInstance, NodeProps, PortalLaunche
|
|
|
7
91
|
* @returns NodeInstance<E> - A new BaseNode instance.
|
|
8
92
|
*/
|
|
9
93
|
export declare function Node<E extends NodeElement>(element: E, props?: Partial<NodeProps<E>>): NodeInstance<E>;
|
|
10
|
-
/**
|
|
11
|
-
* Higher-order component wrapper that converts BaseNode components into React components.
|
|
12
|
-
* This wrapper ensures proper theme propagation and component rendering in the React ecosystem.
|
|
13
|
-
*
|
|
14
|
-
* Key features:
|
|
15
|
-
* - Converts BaseNode instances to React elements via render()
|
|
16
|
-
* - Handles theme inheritance and merging
|
|
17
|
-
* - Preserves component props
|
|
18
|
-
* - Type-safe with generic prop types
|
|
19
|
-
* @template P - The props type for the wrapped component
|
|
20
|
-
* @param component Component function that returns a BaseNode or ReactNode
|
|
21
|
-
* @returns A React function component that handles BaseNode conversion and theme propagation
|
|
22
|
-
* @example
|
|
23
|
-
* ```ts
|
|
24
|
-
* // Basic usage
|
|
25
|
-
* const App = Component(() => {
|
|
26
|
-
* return Div({
|
|
27
|
-
* theme: { color: 'blue' }
|
|
28
|
-
* })
|
|
29
|
-
* })
|
|
30
|
-
* ```
|
|
31
|
-
*/
|
|
32
|
-
export declare function Component<P extends Record<string, any>>(component: (props: P & {
|
|
33
|
-
children?: NodeElement;
|
|
34
|
-
}) => ComponentNode): (props?: Partial<P>) => React.ReactNode;
|
|
35
|
-
/**
|
|
36
|
-
* Creates a portal component that renders its content outside the normal DOM hierarchy.
|
|
37
|
-
* Supports wrapping the portal content with provider components for context/theme inheritance.
|
|
38
|
-
*
|
|
39
|
-
* A portal creates a new DOM element and renders React content into it, useful for modals,
|
|
40
|
-
* popovers, and other overlays that need to break out of their parent container's DOM hierarchy.
|
|
41
|
-
*
|
|
42
|
-
* The portal content can be wrapped with provider components to maintain context/theme inheritance:
|
|
43
|
-
* 1. Fixed providers specified when creating the portal via Portal(providers, component)
|
|
44
|
-
* 2. Dynamic providers passed as props when launching the portal
|
|
45
|
-
* @template P - Props type for the portal's content component
|
|
46
|
-
* @example
|
|
47
|
-
* // Basic portal with no providers
|
|
48
|
-
* const Modal = Portal((props) => Div({ children: props.children }));
|
|
49
|
-
*
|
|
50
|
-
* // Portal with fixed theme provider
|
|
51
|
-
* const ThemedModal = Portal(
|
|
52
|
-
* ThemeProvider({ theme }),
|
|
53
|
-
* (props) => Div({ children: props.children })
|
|
54
|
-
* )
|
|
55
|
-
*
|
|
56
|
-
* // Usage with dynamic providers
|
|
57
|
-
* const modal = Modal({
|
|
58
|
-
* providers: [ThemeProvider({ theme })],
|
|
59
|
-
* children: "Modal content"
|
|
60
|
-
* })
|
|
61
|
-
* modal.unmount(); // Clean up when done
|
|
62
|
-
*/
|
|
63
|
-
export declare function Portal<P extends Record<string, any>>(providers: NodeInstance<any> | NodeInstance<any>[], component: (props: PortalProps<P>) => ComponentNode): PortalLauncherWithFixedProviders<P>;
|
|
64
|
-
export declare function Portal<P extends Record<string, any>>(component: (props: PortalProps<P>) => ComponentNode): PortalLauncher<P>;
|
|
65
94
|
//# sourceMappingURL=core.node.d.ts.map
|
package/dist/core.node.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"core.node.d.ts","sourceRoot":"","sources":["../src/core.node.ts"],"names":[],"mappings":"AACA,
|
|
1
|
+
{"version":3,"file":"core.node.d.ts","sourceRoot":"","sources":["../src/core.node.ts"],"names":[],"mappings":"AACA,OAAc,EAAkF,KAAK,SAAS,EAAE,MAAM,OAAO,CAAA;AAC7H,OAAO,KAAK,EAAE,cAAc,EAAyB,WAAW,EAAE,YAAY,EAAE,SAAS,EAAE,YAAY,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAA;AAGzI,OAAO,EAAc,KAAK,IAAI,IAAI,YAAY,EAAE,MAAM,kBAAkB,CAAA;AAExE;;;;;;;;GAQG;AACH,qBAAa,QAAQ,CAAC,CAAC,SAAS,WAAW,CAAE,YAAW,YAAY,CAAC,CAAC,CAAC;IACrE,+EAA+E;IACxE,OAAO,EAAE,CAAC,CAAA;IAEjB,kFAAkF;IAC3E,QAAQ,CAAC,EAAE,YAAY,CAAC,CAAC,CAAC,CAAA;IAEjC,wFAAwF;IACjF,KAAK,EAAE,cAAc,CAAA;IAE5B,OAAO,CAAC,iBAAiB,CAA8B;IACvD,OAAO,CAAC,gBAAgB,CAA4B;IAEpD;;;;;;;;OAQG;gBACS,OAAO,EAAE,CAAC,EAAE,QAAQ,GAAE,YAAY,CAAC,CAAC,CAAM;IA8CtD;;;;;;;OAOG;IACH,OAAO,CAAC,oBAAoB;IAsE5B;;;;;;;;;;OAUG;IACH,OAAO,CAAC,iBAAiB;IAuDzB;;;;;;;;OAQG;IACI,eAAe,CACpB,OAAO,EAAE,WAAW,EACpB,WAAW,CAAC,EAAE,KAAK,EACnB,UAAU,CAAC,EAAE,MAAM,GAClB,WAAW;IAyFd;;;;;;;;;;;;;OAaG;IACH,OAAO,CAAC,eAAe,CAmCtB;IAED;;;;OAIG;IACI,MAAM,IAAI,SAAS;IAsC1B,OAAO,CAAC,2BAA2B;IAsB5B,QAAQ,IAAI,YAAY,GAAG,IAAI;CAsBvC;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=["children","nodetheme","theme"],_excluded2=["style"],_excluded3=["children","key"]
|
|
1
|
+
"use strict";var _excluded=["children","nodetheme","theme"],_excluded2=["style"],_excluded3=["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 _classCallCheck(b,a){if(!(b instanceof a))throw new TypeError("Cannot call a class as a function")}function _defineProperties(a,b){for(var c,d=0;d<b.length;d++)c=b[d],c.enumerable=c.enumerable||!1,c.configurable=!0,"value"in c&&(c.writable=!0),Object.defineProperty(a,_toPropertyKey(c.key),c)}function _createClass(a,b,c){return b&&_defineProperties(a.prototype,b),c&&_defineProperties(a,c),Object.defineProperty(a,"prototype",{writable:!1}),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}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
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
* - Child node processing and management
|
|
7
7
|
* - Style processing with theme variables
|
|
8
8
|
* @template E The type of React element or component this node represents
|
|
9
|
-
*/var BaseNode=/*#__PURE__*/function(){/**
|
|
9
|
+
*/export var BaseNode=/*#__PURE__*/function(){/**
|
|
10
10
|
* Creates a new BaseNode instance that wraps a React element.
|
|
11
11
|
* Processes raw props by:
|
|
12
12
|
* - Extracting and resolving theme-aware styles
|
|
@@ -127,67 +127,4 @@ var i=_objectSpread(_objectSpread({},f),{},{key:e});return createElement(this.el
|
|
|
127
127
|
*/export function Node(a){var b=1<arguments.length&&void 0!==arguments[1]?arguments[1]:{},c=_objectSpread({},b);// Ensure we are working with a mutable copy
|
|
128
128
|
// 'theme' prop itself is not directly used by BaseNode after this, nodetheme is used.
|
|
129
129
|
// We can keep `theme` in rawProps if needed for cloning or inspection.
|
|
130
|
-
return c.theme&&!c.nodetheme&&(c.nodetheme=c.theme),new BaseNode(a,c)}
|
|
131
|
-
* Higher-order component wrapper that converts BaseNode components into React components.
|
|
132
|
-
* This wrapper ensures proper theme propagation and component rendering in the React ecosystem.
|
|
133
|
-
*
|
|
134
|
-
* Key features:
|
|
135
|
-
* - Converts BaseNode instances to React elements via render()
|
|
136
|
-
* - Handles theme inheritance and merging
|
|
137
|
-
* - Preserves component props
|
|
138
|
-
* - Type-safe with generic prop types
|
|
139
|
-
* @template P - The props type for the wrapped component
|
|
140
|
-
* @param component Component function that returns a BaseNode or ReactNode
|
|
141
|
-
* @returns A React function component that handles BaseNode conversion and theme propagation
|
|
142
|
-
* @example
|
|
143
|
-
* ```ts
|
|
144
|
-
* // Basic usage
|
|
145
|
-
* const App = Component(() => {
|
|
146
|
-
* return Div({
|
|
147
|
-
* theme: { color: 'blue' }
|
|
148
|
-
* })
|
|
149
|
-
* })
|
|
150
|
-
* ```
|
|
151
|
-
*/export function Component(a){// Create a wrapper component that handles theme and rendering
|
|
152
|
-
var b=function Renderer(b){var c=a(b);// Execute wrapped component
|
|
153
|
-
// Handle BaseNode results - requires special processing
|
|
154
|
-
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 function Func(){var a=0<arguments.length&&arguments[0]!==void 0?arguments[0]:{};return Node(b,a).render()}}/**
|
|
155
|
-
* Creates a portal component that renders its content outside the normal DOM hierarchy.
|
|
156
|
-
* Supports wrapping the portal content with provider components for context/theme inheritance.
|
|
157
|
-
*
|
|
158
|
-
* A portal creates a new DOM element and renders React content into it, useful for modals,
|
|
159
|
-
* popovers, and other overlays that need to break out of their parent container's DOM hierarchy.
|
|
160
|
-
*
|
|
161
|
-
* The portal content can be wrapped with provider components to maintain context/theme inheritance:
|
|
162
|
-
* 1. Fixed providers specified when creating the portal via Portal(providers, component)
|
|
163
|
-
* 2. Dynamic providers passed as props when launching the portal
|
|
164
|
-
* @template P - Props type for the portal's content component
|
|
165
|
-
* @example
|
|
166
|
-
* // Basic portal with no providers
|
|
167
|
-
* const Modal = Portal((props) => Div({ children: props.children }));
|
|
168
|
-
*
|
|
169
|
-
* // Portal with fixed theme provider
|
|
170
|
-
* const ThemedModal = Portal(
|
|
171
|
-
* ThemeProvider({ theme }),
|
|
172
|
-
* (props) => Div({ children: props.children })
|
|
173
|
-
* )
|
|
174
|
-
*
|
|
175
|
-
* // Usage with dynamic providers
|
|
176
|
-
* const modal = Modal({
|
|
177
|
-
* providers: [ThemeProvider({ theme })],
|
|
178
|
-
* children: "Modal content"
|
|
179
|
-
* })
|
|
180
|
-
* modal.unmount(); // Clean up when done
|
|
181
|
-
*/export function Portal(a,b){// Track fixed providers passed during portal creation
|
|
182
|
-
var c,d=void 0,e=null;// Parse arguments to determine which overload is being used
|
|
183
|
-
if("function"==typeof b&&(a instanceof BaseNode||Array.isArray(a)&&a.every(function(a){return a instanceof BaseNode})))// Overload 1: Portal(providers, component) - Fixed providers
|
|
184
|
-
d=Array.isArray(a)?a:[a],c=b;else if("function"==typeof a&&b===void 0)// Overload 2: Portal(component) - Dynamic providers via props
|
|
185
|
-
c=a;else throw new Error("Invalid arguments for Portal HOC. Use Portal(component) or Portal(providersArrayOrNodeInstance, component).");// Renderer function that executes portal content with control object
|
|
186
|
-
var f=function Renderer(){var a=0<arguments.length&&arguments[0]!==void 0?arguments[0]:{},b=a.nodetheme,d=_objectWithoutProperties(a,_excluded4),f=c(_objectSpread(_objectSpread({},d),{},{portal:e}));// Handle BaseNode results by properly applying the theme
|
|
187
|
-
if(f instanceof BaseNode){var g,h,i=(null===(g=f.rawProps)||void 0===g?void 0:g.nodetheme)||(null===(h=f.rawProps)||void 0===h?void 0:h.theme)||a.nodetheme;return Node(f.element,_objectSpread(_objectSpread({},f.rawProps),{},{nodetheme:i})).render()}return f};// Return launcher function that creates and manages the portal instance
|
|
188
|
-
return function Func(a){var b,c=void 0;// Combine fixed and dynamic providers in the correct order
|
|
189
|
-
d?c=d:a.providers&&(c=Array.isArray(a.providers)?a.providers:[a.providers]);// Extract props needed for portal setup vs content
|
|
190
|
-
var g=a.providers,h=a.nodetheme,i=_objectWithoutProperties(a,_excluded5),j=_objectSpread(_objectSpread({},i),{},{nodetheme:h}),k=Node(f,j);// Create node for portal content with renderer
|
|
191
|
-
// Wrap content with providers if any exist
|
|
192
|
-
return b=c&&0<c.length?c.reduceRight(function(a,b){var c,d;// Validate each provider is a proper NodeInstance
|
|
193
|
-
return b instanceof BaseNode?Node(b.element,_objectSpread(_objectSpread({},b.rawProps),{},{children:a,nodetheme:(null===(c=b.rawProps)||void 0===c?void 0:c.nodetheme)||(null===(d=b.rawProps)||void 0===d?void 0:d.theme)||h})):(console.warn("Portal: Item in providers array is not a valid NodeInstance. Skipping.",b),a)},k):k,e=b.toPortal(),e}}
|
|
130
|
+
return c.theme&&!c.nodetheme&&(c.nodetheme=c.theme),new BaseNode(a,c)}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { ComponentNode, NodeElement } from '../node.type';
|
|
2
|
+
import type { ReactNode } from 'react';
|
|
3
|
+
/**
|
|
4
|
+
* Higher-order component wrapper that converts BaseNode components into React components.
|
|
5
|
+
* This wrapper ensures proper theme propagation and component rendering in the React ecosystem.
|
|
6
|
+
*
|
|
7
|
+
* Key features:
|
|
8
|
+
* - Converts BaseNode instances to React elements via render()
|
|
9
|
+
* - Handles theme inheritance and merging
|
|
10
|
+
* - Preserves component props
|
|
11
|
+
* - Type-safe with generic prop types
|
|
12
|
+
* @template P - The props type for the wrapped component
|
|
13
|
+
* @param component Component function that returns a BaseNode or ReactNode
|
|
14
|
+
* @returns A React function component that handles BaseNode conversion and theme propagation
|
|
15
|
+
* @example
|
|
16
|
+
* ```ts
|
|
17
|
+
* // Basic usage
|
|
18
|
+
* const App = Component(() => {
|
|
19
|
+
* return Div({
|
|
20
|
+
* theme: { color: 'blue' }
|
|
21
|
+
* })
|
|
22
|
+
* })
|
|
23
|
+
* ```
|
|
24
|
+
*/
|
|
25
|
+
export declare function Component<P extends Record<string, any>>(component: (props: P & {
|
|
26
|
+
children?: NodeElement;
|
|
27
|
+
}) => ComponentNode): (props?: Partial<P>) => ReactNode;
|
|
28
|
+
//# sourceMappingURL=component.hoc.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"component.hoc.d.ts","sourceRoot":"","sources":["../../src/hoc/component.hoc.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAA;AAChE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AAEtC;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAgB,SAAS,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EACrD,SAAS,EAAE,CACT,KAAK,EAAE,CAAC,GAAG;IACT,QAAQ,CAAC,EAAE,WAAW,CAAA;CACvB,KACE,aAAa,IAkBG,QAAO,OAAO,CAAC,CAAC,CAAM,eAG5C"}
|
|
@@ -0,0 +1,25 @@
|
|
|
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";/**
|
|
2
|
+
* Higher-order component wrapper that converts BaseNode components into React components.
|
|
3
|
+
* This wrapper ensures proper theme propagation and component rendering in the React ecosystem.
|
|
4
|
+
*
|
|
5
|
+
* Key features:
|
|
6
|
+
* - Converts BaseNode instances to React elements via render()
|
|
7
|
+
* - Handles theme inheritance and merging
|
|
8
|
+
* - Preserves component props
|
|
9
|
+
* - Type-safe with generic prop types
|
|
10
|
+
* @template P - The props type for the wrapped component
|
|
11
|
+
* @param component Component function that returns a BaseNode or ReactNode
|
|
12
|
+
* @returns A React function component that handles BaseNode conversion and theme propagation
|
|
13
|
+
* @example
|
|
14
|
+
* ```ts
|
|
15
|
+
* // Basic usage
|
|
16
|
+
* const App = Component(() => {
|
|
17
|
+
* return Div({
|
|
18
|
+
* theme: { color: 'blue' }
|
|
19
|
+
* })
|
|
20
|
+
* })
|
|
21
|
+
* ```
|
|
22
|
+
*/export function Component(a){// Create a wrapper component that handles theme and rendering
|
|
23
|
+
var b=function Renderer(b){var c=a(b);// Execute wrapped component
|
|
24
|
+
// Handle BaseNode results - requires special processing
|
|
25
|
+
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 function Func(){var a=0<arguments.length&&arguments[0]!==void 0?arguments[0]:{};return Node(b,a).render()}}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/hoc/index.ts"],"names":[],"mappings":"AAAA,cAAc,qBAAqB,CAAA;AACnC,cAAc,wBAAwB,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export*from"./portal.hoc";export*from"./component.hoc";
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import type { ComponentNode, NodeInstance, PortalLauncher, PortalProps } from '../node.type';
|
|
2
|
+
/**
|
|
3
|
+
* Creates a portal component with a fixed set of providers by passing an array of `NodeInstance`s.
|
|
4
|
+
* The content component will be rendered within these providers. This method is considered deprecated.
|
|
5
|
+
* @deprecated Use `Portal(provider: NodeInstance<any>, component: ...)` instead for fixed providers.
|
|
6
|
+
* Passing an array of providers for fixed setup is deprecated and will trigger a console warning.
|
|
7
|
+
* @param provider An array of `NodeInstance`s that will wrap the portal content. Each NodeInstance
|
|
8
|
+
* should represent a React context provider (e.g., `ThemeProvider({ theme })`).
|
|
9
|
+
* @param component The React component function that defines the portal's content. It receives
|
|
10
|
+
* props of type `PortalProps<P>` and should return a `ComponentNode`.
|
|
11
|
+
* @returns A launcher function that, when called, creates and controls the portal instance.
|
|
12
|
+
* @example
|
|
13
|
+
* ```ts
|
|
14
|
+
* // Example of a deprecated usage with an array of fixed providers:
|
|
15
|
+
* const DeprecatedThemedModal = Portal(
|
|
16
|
+
* [ThemeProvider({ theme: 'dark' }), LanguageProvider({ lang: 'en' })],
|
|
17
|
+
* (props) => Div({ children: props.children, style: { background: props.nodetheme?.background } })
|
|
18
|
+
* );
|
|
19
|
+
*
|
|
20
|
+
* const deprecatedModalInstance = DeprecatedThemedModal({ children: "Deprecated content" });
|
|
21
|
+
* // A console warning will be logged when DeprecatedThemedModal is created.
|
|
22
|
+
* deprecatedModalInstance.unmount();
|
|
23
|
+
* ```
|
|
24
|
+
*/
|
|
25
|
+
export declare function Portal<P extends Record<string, any>>(provider: NodeInstance<any>[], component: (props: PortalProps<P>) => ComponentNode): PortalLauncher<P>;
|
|
26
|
+
/**
|
|
27
|
+
* Creates a portal component with a single fixed provider.
|
|
28
|
+
* The content component will be rendered within this provider. This is the preferred method
|
|
29
|
+
* for providing fixed context to your portal content.
|
|
30
|
+
* @param provider A single `NodeInstance` that will wrap the portal content. This should typically
|
|
31
|
+
* be a React context provider (e.g., `ThemeProvider({ theme })`).
|
|
32
|
+
* @param component The React component function that defines the portal's content. It receives
|
|
33
|
+
* props of type `PortalProps<P>` and should return a `ComponentNode`.
|
|
34
|
+
* @returns A launcher function that, when called, creates and controls the portal instance.
|
|
35
|
+
* @example
|
|
36
|
+
* ```ts
|
|
37
|
+
* // Example of preferred usage with a single fixed provider:
|
|
38
|
+
* const ThemedModal = Portal(
|
|
39
|
+
* ThemeProvider({ theme: 'light' }),
|
|
40
|
+
* (props) => Div({ children: props.children, style: { background: props.nodetheme?.background } })
|
|
41
|
+
* );
|
|
42
|
+
*
|
|
43
|
+
* const modalInstance = ThemedModal({ children: "Preferred content" });
|
|
44
|
+
* modalInstance.unmount();
|
|
45
|
+
* ```
|
|
46
|
+
*/
|
|
47
|
+
export declare function Portal<P extends Record<string, any>>(provider: NodeInstance<any>, component: (props: PortalProps<P>) => ComponentNode): PortalLauncher<P>;
|
|
48
|
+
/**
|
|
49
|
+
* Creates a basic portal component without any fixed providers.
|
|
50
|
+
* Dynamic providers can still be passed as props when launching the portal instance.
|
|
51
|
+
* @param component The React component function that defines the portal's content. It receives
|
|
52
|
+
* props of type `PortalProps<P>` and should return a `ComponentNode`.
|
|
53
|
+
* @returns A launcher function that, when called, creates and controls the portal instance.
|
|
54
|
+
* @example
|
|
55
|
+
* ```ts
|
|
56
|
+
* // Example of basic usage without fixed providers:
|
|
57
|
+
* const BasicModal = Portal(
|
|
58
|
+
* (props) => Div({ children: props.children, style: { padding: '20px', border: '1px solid black' } })
|
|
59
|
+
* );
|
|
60
|
+
*
|
|
61
|
+
* const basicModalInstance = BasicModal({ children: "Hello from a basic portal!" });
|
|
62
|
+
* basicModalInstance.unmount();
|
|
63
|
+
*
|
|
64
|
+
* // Example with dynamic providers when launching:
|
|
65
|
+
* const DynamicThemedModal = Portal(
|
|
66
|
+
* (props) => Div({ children: props.children, style: { background: props.nodetheme?.background || 'white' } })
|
|
67
|
+
* );
|
|
68
|
+
*
|
|
69
|
+
* const dynamicModalInstance = DynamicThemedModal({
|
|
70
|
+
* providers: ThemeProvider({ theme: 'blue' }), // Dynamic provider
|
|
71
|
+
* children: "Content with dynamic theme"
|
|
72
|
+
* });
|
|
73
|
+
* dynamicModalInstance.unmount();
|
|
74
|
+
* ```
|
|
75
|
+
*/
|
|
76
|
+
export declare function Portal<P extends Record<string, any>>(component: (props: PortalProps<P>) => ComponentNode): PortalLauncher<P>;
|
|
77
|
+
//# sourceMappingURL=portal.hoc.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"portal.hoc.d.ts","sourceRoot":"","sources":["../../src/hoc/portal.hoc.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,aAAa,EAAE,YAAY,EAAa,cAAc,EAAE,WAAW,EAAS,MAAM,gBAAgB,CAAA;AAIhH;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAgB,MAAM,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAAE,QAAQ,EAAE,YAAY,CAAC,GAAG,CAAC,EAAE,EAAE,SAAS,EAAE,CAAC,KAAK,EAAE,WAAW,CAAC,CAAC,CAAC,KAAK,aAAa,GAAG,cAAc,CAAC,CAAC,CAAC,CAAA;AAE5J;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,MAAM,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAAE,QAAQ,EAAE,YAAY,CAAC,GAAG,CAAC,EAAE,SAAS,EAAE,CAAC,KAAK,EAAE,WAAW,CAAC,CAAC,CAAC,KAAK,aAAa,GAAG,cAAc,CAAC,CAAC,CAAC,CAAA;AAE1J;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,wBAAgB,MAAM,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAAE,SAAS,EAAE,CAAC,KAAK,EAAE,WAAW,CAAC,CAAC,CAAC,KAAK,aAAa,GAAG,cAAc,CAAC,CAAC,CAAC,CAAA"}
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
"use strict";var _excluded=["nodetheme"],_excluded2=["provider","nodetheme"];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 _toConsumableArray(a){return _arrayWithoutHoles(a)||_iterableToArray(a)||_unsupportedIterableToArray(a)||_nonIterableSpread()}function _nonIterableSpread(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}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 _iterableToArray(a){if("undefined"!=typeof Symbol&&null!=a[Symbol.iterator]||null!=a["@@iterator"])return Array.from(a)}function _arrayWithoutHoles(a){if(Array.isArray(a))return _arrayLikeToArray(a)}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 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}import{BaseNode,Node}from"../core.node";/**
|
|
2
|
+
* Creates a portal component with a fixed set of providers by passing an array of `NodeInstance`s.
|
|
3
|
+
* The content component will be rendered within these providers. This method is considered deprecated.
|
|
4
|
+
* @deprecated Use `Portal(provider: NodeInstance<any>, component: ...)` instead for fixed providers.
|
|
5
|
+
* Passing an array of providers for fixed setup is deprecated and will trigger a console warning.
|
|
6
|
+
* @param provider An array of `NodeInstance`s that will wrap the portal content. Each NodeInstance
|
|
7
|
+
* should represent a React context provider (e.g., `ThemeProvider({ theme })`).
|
|
8
|
+
* @param component The React component function that defines the portal's content. It receives
|
|
9
|
+
* props of type `PortalProps<P>` and should return a `ComponentNode`.
|
|
10
|
+
* @returns A launcher function that, when called, creates and controls the portal instance.
|
|
11
|
+
* @example
|
|
12
|
+
* ```ts
|
|
13
|
+
* // Example of a deprecated usage with an array of fixed providers:
|
|
14
|
+
* const DeprecatedThemedModal = Portal(
|
|
15
|
+
* [ThemeProvider({ theme: 'dark' }), LanguageProvider({ lang: 'en' })],
|
|
16
|
+
* (props) => Div({ children: props.children, style: { background: props.nodetheme?.background } })
|
|
17
|
+
* );
|
|
18
|
+
*
|
|
19
|
+
* const deprecatedModalInstance = DeprecatedThemedModal({ children: "Deprecated content" });
|
|
20
|
+
* // A console warning will be logged when DeprecatedThemedModal is created.
|
|
21
|
+
* deprecatedModalInstance.unmount();
|
|
22
|
+
* ```
|
|
23
|
+
*//**
|
|
24
|
+
* Creates a portal component with a single fixed provider.
|
|
25
|
+
* The content component will be rendered within this provider. This is the preferred method
|
|
26
|
+
* for providing fixed context to your portal content.
|
|
27
|
+
* @param provider A single `NodeInstance` that will wrap the portal content. This should typically
|
|
28
|
+
* be a React context provider (e.g., `ThemeProvider({ theme })`).
|
|
29
|
+
* @param component The React component function that defines the portal's content. It receives
|
|
30
|
+
* props of type `PortalProps<P>` and should return a `ComponentNode`.
|
|
31
|
+
* @returns A launcher function that, when called, creates and controls the portal instance.
|
|
32
|
+
* @example
|
|
33
|
+
* ```ts
|
|
34
|
+
* // Example of preferred usage with a single fixed provider:
|
|
35
|
+
* const ThemedModal = Portal(
|
|
36
|
+
* ThemeProvider({ theme: 'light' }),
|
|
37
|
+
* (props) => Div({ children: props.children, style: { background: props.nodetheme?.background } })
|
|
38
|
+
* );
|
|
39
|
+
*
|
|
40
|
+
* const modalInstance = ThemedModal({ children: "Preferred content" });
|
|
41
|
+
* modalInstance.unmount();
|
|
42
|
+
* ```
|
|
43
|
+
*//**
|
|
44
|
+
* Creates a basic portal component without any fixed providers.
|
|
45
|
+
* Dynamic providers can still be passed as props when launching the portal instance.
|
|
46
|
+
* @param component The React component function that defines the portal's content. It receives
|
|
47
|
+
* props of type `PortalProps<P>` and should return a `ComponentNode`.
|
|
48
|
+
* @returns A launcher function that, when called, creates and controls the portal instance.
|
|
49
|
+
* @example
|
|
50
|
+
* ```ts
|
|
51
|
+
* // Example of basic usage without fixed providers:
|
|
52
|
+
* const BasicModal = Portal(
|
|
53
|
+
* (props) => Div({ children: props.children, style: { padding: '20px', border: '1px solid black' } })
|
|
54
|
+
* );
|
|
55
|
+
*
|
|
56
|
+
* const basicModalInstance = BasicModal({ children: "Hello from a basic portal!" });
|
|
57
|
+
* basicModalInstance.unmount();
|
|
58
|
+
*
|
|
59
|
+
* // Example with dynamic providers when launching:
|
|
60
|
+
* const DynamicThemedModal = Portal(
|
|
61
|
+
* (props) => Div({ children: props.children, style: { background: props.nodetheme?.background || 'white' } })
|
|
62
|
+
* );
|
|
63
|
+
*
|
|
64
|
+
* const dynamicModalInstance = DynamicThemedModal({
|
|
65
|
+
* providers: ThemeProvider({ theme: 'blue' }), // Dynamic provider
|
|
66
|
+
* children: "Content with dynamic theme"
|
|
67
|
+
* });
|
|
68
|
+
* dynamicModalInstance.unmount();
|
|
69
|
+
* ```
|
|
70
|
+
*/// --- Implementation ---
|
|
71
|
+
export function Portal(a,b){// --- Initialization ---
|
|
72
|
+
var c,d=void 0,e=null;// --- Argument Parsing and Overload Handling ---
|
|
73
|
+
// Determines which Portal overload was called (e.g., with fixed provider or just component).
|
|
74
|
+
if("function"==typeof b&&(a instanceof BaseNode||Array.isArray(a)&&a.every(function(a){return a instanceof BaseNode})))Array.isArray(a)?(console.warn("Portal: Passing an array of providers as the first argument is deprecated. Please pass a single NodeInstance instead."),d=a):d=[a],c=b;else if("function"==typeof a&&b===void 0)// Handles the case where only the component function is passed.
|
|
75
|
+
c=a;else throw new Error("Invalid arguments for Portal HOC. Use Portal(component), Portal(providerNodeInstance, component), or (deprecated) Portal(providerArray, component).");// --- Core Content Renderer Function ---
|
|
76
|
+
// This function is the actual React component that will be rendered inside the portal.
|
|
77
|
+
// It receives props and handles theme application and portal control.
|
|
78
|
+
var f=function Renderer(){var a=0<arguments.length&&arguments[0]!==void 0?arguments[0]:{},b=a.nodetheme,d=_objectWithoutProperties(a,_excluded),f=c(_objectSpread(_objectSpread({},d),{},{portal:e// Passes the portal control object to the content component
|
|
79
|
+
}));// Ensures that the theme is correctly applied if the result is a BaseNode.
|
|
80
|
+
if(f instanceof BaseNode){var g,h,i=(null===(g=f.rawProps)||void 0===g?void 0:g.nodetheme)||(null===(h=f.rawProps)||void 0===h?void 0:h.theme)||a.nodetheme;return Node(f.element,_objectSpread(_objectSpread({},f.rawProps),{},{nodetheme:i})).render()}return f};// --- Portal Launcher Function (Returned to User) ---
|
|
81
|
+
// This is the function that developers call to actually create and manage a portal instance.
|
|
82
|
+
return function Func(a){// --- Helper for Deep Content Injection ---
|
|
83
|
+
// Recursively injects content into the deepest child of a provider chain.
|
|
84
|
+
function injectContentDeeply(a,b,c){var d,e,f,g=null===(d=a.rawProps)||void 0===d?void 0:d.children;// If no children, or children is not a NodeInstance, inject directly
|
|
85
|
+
if(!g||!(g instanceof BaseNode)){var h,i;return Node(a.element,_objectSpread(_objectSpread({},a.rawProps),{},{children:b,nodetheme:(null===(h=a.rawProps)||void 0===h?void 0:h.nodetheme)||(null===(i=a.rawProps)||void 0===i?void 0:i.theme)||c}))}// Recursively inject into the deepest node
|
|
86
|
+
var j=injectContentDeeply(g,b);return Node(a.element,_objectSpread(_objectSpread({},a.rawProps),{},{children:j,nodetheme:(null===(e=a.rawProps)||void 0===e?void 0:e.nodetheme)||(null===(f=a.rawProps)||void 0===f?void 0:f.theme)||c}))}// --- Provider Wrapping Logic ---
|
|
87
|
+
// Iterates through the combined providers (fixed + dynamic) to wrap the content.
|
|
88
|
+
// Providers are applied in reverse order to ensure the innermost content is wrapped by the outermost provider.
|
|
89
|
+
var b,c=[];// Combine fixed and dynamic providers
|
|
90
|
+
Array.isArray(a.provider)?(console.warn("Portal: Passing an array of providers as the `provider` prop is deprecated. Please pass a single NodeInstance instead."),c.push.apply(c,_toConsumableArray(a.provider))):a.provider&&c.push(a.provider);var g=[].concat(_toConsumableArray(null!==d&&void 0!==d?d:[]),c),h=a.provider,i=a.nodetheme,j=_objectWithoutProperties(a,_excluded2),k=_objectSpread(_objectSpread({},j),{},{nodetheme:i}),l=Node(f,k);// Separates props for the portal's content from internal props like 'provider' or 'nodetheme'.
|
|
91
|
+
// Creates the base node for the portal's content.
|
|
92
|
+
return b=0<g.length?g.reduceRight(function(a,b){var c,d,e;if(!(b instanceof BaseNode))return console.warn("Portal: Item in provider is not a valid NodeInstance. Skipping.",b),a;var f=(null===(c=b.rawProps)||void 0===c?void 0:c.children)instanceof BaseNode;// If the provider already has nested children, inject content deeply.
|
|
93
|
+
// Otherwise, simply set currentWrappedContent as its direct child.
|
|
94
|
+
return f?injectContentDeeply(b,a,i):Node(b.element,_objectSpread(_objectSpread({},b.rawProps),{},{children:a,nodetheme:(null===(d=b.rawProps)||void 0===d?void 0:d.nodetheme)||(null===(e=b.rawProps)||void 0===e?void 0:e.theme)||i}))},l):l,e=b.toPortal(),e}}
|
|
@@ -1,12 +1,29 @@
|
|
|
1
|
+
import { type CSSProperties } from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* Retrieves the concatenated CSS string for server-side rendering.
|
|
4
|
+
* @returns {string} The CSS string.
|
|
5
|
+
*/
|
|
1
6
|
export declare function getServerStyles(): string;
|
|
2
7
|
type CSSValue = string | number;
|
|
3
|
-
interface NestedStyle {
|
|
4
|
-
[key: string]: CSSValue | NestedStyle;
|
|
8
|
+
interface NestedStyle extends CSSProperties {
|
|
9
|
+
[key: string]: CSSValue | NestedStyle | undefined;
|
|
5
10
|
}
|
|
6
11
|
interface StyleObject extends NestedStyle {
|
|
7
|
-
[key: string]: CSSValue | StyleObject;
|
|
12
|
+
[key: string]: CSSValue | StyleObject | undefined;
|
|
8
13
|
}
|
|
14
|
+
/**
|
|
15
|
+
* Custom React hook to generate and manage CSS classes from a style object.
|
|
16
|
+
* Supports nesting, pseudo-selectors, and at-rules (@media, @container, @supports).
|
|
17
|
+
* Handles both client-side and server-side rendering.
|
|
18
|
+
* @param {StyleObject} sxObject The style object defining the CSS.
|
|
19
|
+
* @param {any[]} deps Dependencies for memoization, similar to `useEffect` or `useMemo`.
|
|
20
|
+
* @returns {string} The generated CSS class name.
|
|
21
|
+
*/
|
|
9
22
|
export declare function useClasses(sxObject: StyleObject, deps?: any[]): string;
|
|
23
|
+
/**
|
|
24
|
+
* Clears all generated styles and resets the internal state.
|
|
25
|
+
* Useful for development or testing environments to ensure a clean slate.
|
|
26
|
+
*/
|
|
10
27
|
export declare function purgeStyles(): void;
|
|
11
28
|
export {};
|
|
12
29
|
//# sourceMappingURL=useClasses.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useClasses.d.ts","sourceRoot":"","sources":["../../src/hook/useClasses.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"useClasses.d.ts","sourceRoot":"","sources":["../../src/hook/useClasses.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,aAAa,EAAsB,MAAM,OAAO,CAAA;AAM9D;;;GAGG;AACH,wBAAgB,eAAe,IAAI,MAAM,CAExC;AA4BD,KAAK,QAAQ,GAAG,MAAM,GAAG,MAAM,CAAA;AAC/B,UAAU,WAAY,SAAQ,aAAa;IACzC,CAAC,GAAG,EAAE,MAAM,GAAG,QAAQ,GAAG,WAAW,GAAG,SAAS,CAAA;CAClD;AACD,UAAU,WAAY,SAAQ,WAAW;IACvC,CAAC,GAAG,EAAE,MAAM,GAAG,QAAQ,GAAG,WAAW,GAAG,SAAS,CAAA;CAClD;AA+CD;;;;;;;GAOG;AACH,wBAAgB,UAAU,CAAC,QAAQ,EAAE,WAAW,EAAE,IAAI,GAAE,GAAG,EAAO,GAAG,MAAM,CA6E1E;AAkKD;;;GAGG;AACH,wBAAgB,WAAW,SAa1B"}
|
package/dist/hook/useClasses.js
CHANGED
|
@@ -1,29 +1,82 @@
|
|
|
1
|
-
function
|
|
2
|
-
var serverStyles=[],serverRuleIndex=0
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
export function
|
|
6
|
-
//
|
|
7
|
-
//
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
function
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
return
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
1
|
+
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 _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 _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 _toConsumableArray(a){return _arrayWithoutHoles(a)||_iterableToArray(a)||_unsupportedIterableToArray(a)||_nonIterableSpread()}function _nonIterableSpread(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}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 _iterableToArray(a){if("undefined"!=typeof Symbol&&null!=a[Symbol.iterator]||null!=a["@@iterator"])return Array.from(a)}function _arrayWithoutHoles(a){if(Array.isArray(a))return _arrayLikeToArray(a)}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}import{useEffect,useMemo}from"react";// Manages styles for server-side rendering (SSR)
|
|
2
|
+
var serverStyles=[],serverRuleIndex=0;/**
|
|
3
|
+
* Retrieves the concatenated CSS string for server-side rendering.
|
|
4
|
+
* @returns {string} The CSS string.
|
|
5
|
+
*/export function getServerStyles(){return serverStyles.join("\n")}// Manages styles for client-side rendering
|
|
6
|
+
var styleSheet;if("undefined"!=typeof document){// Ensures a style tag with id '__sx' exists in the document head
|
|
7
|
+
var styleTag=document.head.querySelector("#__sx")||function(){var a=document.createElement("style");return a.id="__sx",document.head.appendChild(a),a}();styleSheet=styleTag.sheet}// Global index for generating unique class names
|
|
8
|
+
var ruleIndex=0,sxCache=new Map,refCountMap=new Map,ruleMap=new Map,unitlessProperties=new Set(["animationIterationCount","borderImageOutset","borderImageSlice","borderImageWidth","boxFlex","boxFlexGroup","boxOrdinalGroup","columnCount","columns","flex","flexGrow","flexPositive","flexShrink","flexNegative","flexOrder","gridRow","gridRowEnd","gridRowSpan","gridRowStart","gridColumn","gridColumnEnd","gridColumnSpan","gridColumnStart","fontWeight","lineClamp","lineHeight","opacity","order","orphans","tabSize","widows","zIndex","zoom","fillOpacity","floodOpacity","stopOpacity","strokeDasharray","strokeDashoffset","strokeMiterlimit","strokeOpacity","strokeWidth"]);// Cache for mapping style objects to generated class names
|
|
9
|
+
// Reference count for each cached style, used for knowing when to remove styles
|
|
10
|
+
// Maps cache keys to the array of CSS rules it generated
|
|
11
|
+
// Type definitions for CSS values and style objects
|
|
12
|
+
// Set of CSS properties that do not require a 'px' unit when their value is a number
|
|
13
|
+
/**
|
|
14
|
+
* Custom React hook to generate and manage CSS classes from a style object.
|
|
15
|
+
* Supports nesting, pseudo-selectors, and at-rules (@media, @container, @supports).
|
|
16
|
+
* Handles both client-side and server-side rendering.
|
|
17
|
+
* @param {StyleObject} sxObject The style object defining the CSS.
|
|
18
|
+
* @param {any[]} deps Dependencies for memoization, similar to `useEffect` or `useMemo`.
|
|
19
|
+
* @returns {string} The generated CSS class name.
|
|
20
|
+
*/export function useClasses(a){var b=1<arguments.length&&void 0!==arguments[1]?arguments[1]:[],c=useMemo(function(){return"".concat(stableStringify(a),"::").concat(stableStringify(b))},[a,b]);// Generates a stable cache key based on the style object and dependencies
|
|
21
|
+
// Manages the reference count for the generated style, cleaning up when no longer used.
|
|
22
|
+
// Returns the cached class name if the style has already been generated
|
|
23
|
+
if(useEffect(function(){// Decrement reference count and clean up styles when component unmounts
|
|
24
|
+
return refCountMap.set(c,(refCountMap.get(c)||0)+1),function(){var a=refCountMap.get(c)||1;1===a?(removeStyleRules(c),sxCache["delete"](c),refCountMap["delete"](c)):refCountMap.set(c,a-1)}},[c]),sxCache.has(c))return sxCache.get(c);// Generates a new unique class name
|
|
25
|
+
var d="sx-".concat(ruleIndex++),e=[],f={},g={},h={},i={};// Stores the generated CSS rules
|
|
26
|
+
// Stores styles directly applicable to the base class or its nested selectors
|
|
27
|
+
// Stores raw style objects for @media rules
|
|
28
|
+
// Stores raw style objects for @container rules
|
|
29
|
+
// Stores raw style objects for @supports rules
|
|
30
|
+
// First pass: Separates top-level styles from at-rules
|
|
31
|
+
for(var j in a){var k=a[j];j.startsWith("@media")?g[j]=k:j.startsWith("@container")?h[j]=k:j.startsWith("@supports")?i[j]=k:f[j]=k}// Collects all rules for the base class and its nested selectors
|
|
32
|
+
// Injects styles based on the rendering environment
|
|
33
|
+
if(e.push.apply(e,_toConsumableArray(collectRules(f,".".concat(d)))),processAtRuleBlocks(g,e,d),processAtRuleBlocks(h,e,d),processAtRuleBlocks(i,e,d),"undefined"==typeof document){// Server-side rendering: stores CSS and returns a server-specific class name
|
|
34
|
+
var l="sx-".concat(serverRuleIndex++),m=e.map(function(a){return a.replace(new RegExp(d,"g"),l)}).join("\n");return serverStyles.push(m),sxCache.set(c,l),l}// Caches the generated rules and class name
|
|
35
|
+
return styleSheet&&// Client-side injection: inserts rules into the stylesheet
|
|
36
|
+
injectStyles(e),ruleMap.set(c,e),sxCache.set(c,d),d}/**
|
|
37
|
+
* Recursively collects CSS rules from a style object.
|
|
38
|
+
* Handles direct properties, nested selectors (prefixed with '&'), and warns about deeply nested at-rules.
|
|
39
|
+
* @param {StyleObject} sxBlock The style object to process.
|
|
40
|
+
* @param {string} currentSelector The current CSS selector context.
|
|
41
|
+
* @returns {string[]} An array of complete CSS rules.
|
|
42
|
+
*/function collectRules(a,b){var c=[],d={};// Stores direct CSS properties for the current selector
|
|
43
|
+
for(var e in a){var f=a[e];if("object"!==_typeof(f)||null===f)d[e]=f;else if(e.startsWith("&")){// Handles nested selectors (e.g., '&:hover', '& span')
|
|
44
|
+
var g=e.replace(/&/g,b);c.push.apply(c,_toConsumableArray(collectRules(f,g)))}else e.startsWith("@")?// Warns about deeply nested at-rules, as they are processed at top-level or directly under the base class.
|
|
45
|
+
console.warn("Nested at-rule found at key \"".concat(e,"\" within selector \"").concat(b,"\". Current implementation processes at-rules at the top level or directly under the base class.")):// Flattens plain nested objects into the current selector's declarations
|
|
46
|
+
Object.assign(d,f)}// Generates the CSS rule for the current selector's direct properties
|
|
47
|
+
var h=toCssDeclarations(d);return h&&c.unshift("".concat(b," { ").concat(h," }")),c}/**
|
|
48
|
+
* Processes at-rule blocks (@media, @container, @supports) and adds their rules to the output.
|
|
49
|
+
* @param {Record<string, StyleObject>} blocksMap A map where keys are at-rules (e.g., '@media (min-width: 768px)') and values are their style objects.
|
|
50
|
+
* @param {string[]} output The array to which generated CSS rules are added.
|
|
51
|
+
* @param {string} baseClassName The base class name to which the at-rule styles apply.
|
|
52
|
+
*/function processAtRuleBlocks(a,b,c){for(var d=0,e=Object.entries(a);d<e.length;d++){var f=_slicedToArray(e[d],2),g=f[0],h=f[1],i=collectRules(h,".".concat(c));// Collects rules for the at-rule's content, using the base class name for context
|
|
53
|
+
i.length&&b.push("".concat(g," { ").concat(i.join(" ")," }"))}}/**
|
|
54
|
+
* Injects an array of CSS rules into the document's stylesheet.
|
|
55
|
+
* @param {string[]} rules An array of complete CSS rule strings.
|
|
56
|
+
*/function injectStyles(a){if(styleSheet){var b,c=_createForOfIteratorHelper(a);try{for(c.s();!(b=c.n()).done;){var d=b.value;try{styleSheet.insertRule(d,styleSheet.cssRules.length)}catch(a){console.error("Failed to insert CSS rule: ".concat(d),a)}}}catch(a){c.e(a)}finally{c.f()}}}/**
|
|
57
|
+
* Removes CSS rules associated with a specific cache key from the stylesheet.
|
|
58
|
+
* @param {string} cacheKey The cache key identifying the rules to remove.
|
|
59
|
+
*/function removeStyleRules(a){var b=ruleMap.get(a);if(b&&styleSheet){// Iterates in reverse to safely delete rules without affecting indices
|
|
60
|
+
for(var c,d=styleSheet.cssRules.length-1;0<=d;d--)c=styleSheet.cssRules[d],b.includes(c.cssText)&&styleSheet.deleteRule(d);ruleMap["delete"](a)}}/**
|
|
61
|
+
* Converts a flat style object into a CSS declaration string (e.g., "prop: value;").
|
|
62
|
+
* Automatically appends 'px' to number values for non-unitless properties.
|
|
63
|
+
* @param {StyleObject} obj The flat style object containing CSS property-value pairs.
|
|
64
|
+
* @returns {string} The CSS declaration string.
|
|
65
|
+
*/function toCssDeclarations(a){var b=[];for(var c in a){var d=a[c];// Warns if a nested object is encountered, as this function expects flat properties.
|
|
66
|
+
if("object"===_typeof(d)&&null!==d){console.warn("toCssDeclarations received a nested object for key \"".concat(c,"\". This function only processes flat CSS property-value pairs."));continue}"number"!=typeof d||isUnitlessProperty(c)?b.push("".concat(camelToKebab(c),": ").concat(d,";")):b.push("".concat(camelToKebab(c),": ").concat(d,"px;"))}return b.join(" ")}/**
|
|
67
|
+
* Checks if a given CSS property is unitless.
|
|
68
|
+
* @param {string} prop The CSS property name (camelCase).
|
|
69
|
+
* @returns {boolean} True if the property is unitless, false otherwise.
|
|
70
|
+
*/function isUnitlessProperty(a){return unitlessProperties.has(a)}/**
|
|
71
|
+
* Generates a stable JSON string representation of an object.
|
|
72
|
+
* Ensures consistent stringification regardless of property order, useful for cache keys.
|
|
73
|
+
* @param {any} obj The object to stringify.
|
|
74
|
+
* @returns {string} The stable JSON string.
|
|
75
|
+
*/function stableStringify(a){if(null===a||"object"!==_typeof(a))return JSON.stringify(a);if(Array.isArray(a))return"[".concat(a.map(stableStringify).join(","),"]");var b=Object.keys(a).sort(),c=b.map(function(b){return"\"".concat(b,"\":").concat(stableStringify(a[b]))});return"{".concat(c.join(","),"}")}/**
|
|
76
|
+
* Converts a camelCase string to kebab-case.
|
|
77
|
+
* @param {string} str The camelCase string.
|
|
78
|
+
* @returns {string} The kebab-case string.
|
|
79
|
+
*/function camelToKebab(a){return a.replace(/([A-Z])([A-Z])/g,"$1-$2").replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase()}/**
|
|
80
|
+
* Clears all generated styles and resets the internal state.
|
|
81
|
+
* Useful for development or testing environments to ensure a clean slate.
|
|
82
|
+
*/export function purgeStyles(){if(styleSheet)for(;0<styleSheet.cssRules.length;)styleSheet.deleteRule(0);serverStyles=[],sxCache.clear(),ruleMap.clear(),refCountMap.clear(),ruleIndex=0,serverRuleIndex=0}
|
package/dist/main.d.ts
CHANGED
package/dist/main.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"main.d.ts","sourceRoot":"","sources":["../src/main.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"main.d.ts","sourceRoot":"","sources":["../src/main.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,gBAAgB,CAAA;AACrC,cAAc,UAAU,CAAA;AACxB,cAAc,kBAAkB,CAAA;AAChC,cAAc,gBAAgB,CAAA;AAC9B,cAAc,gBAAgB,CAAA"}
|
package/dist/main.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export
|
|
1
|
+
export{Node}from"./core.node";export*from"./hoc";export*from"./node.helper";export*from"./node.type";export*from"./html.node";
|
package/dist/node.type.d.ts
CHANGED
|
@@ -118,19 +118,18 @@ export type PortalProps<T extends Record<string, any>> = T & {
|
|
|
118
118
|
};
|
|
119
119
|
};
|
|
120
120
|
/**
|
|
121
|
-
* Function type for creating portal instances
|
|
121
|
+
* Function type for creating portal instances.
|
|
122
122
|
* Allows passing providers through props at portal creation time.
|
|
123
|
-
* @template
|
|
123
|
+
* @template P The portal content component's prop types
|
|
124
124
|
*/
|
|
125
125
|
export type PortalLauncher<P extends Record<string, any>> = (props: P & {
|
|
126
126
|
/** Optional provider components to wrap the portal content */
|
|
127
|
-
|
|
127
|
+
provider?: NodeInstance<any>
|
|
128
|
+
/**
|
|
129
|
+
* @deprecated
|
|
130
|
+
* Use a single NodeInstance instead of an array for fixed provider.
|
|
131
|
+
*/
|
|
132
|
+
| NodeInstance<any>[];
|
|
128
133
|
} & Omit<PortalProps<P>, 'portal'>) => ReactDOMRoot | null;
|
|
129
|
-
/**
|
|
130
|
-
* Function type for creating portal instances when Portal is called with providers and component.
|
|
131
|
-
* Uses fixed providers specified at HOC creation time.
|
|
132
|
-
* @template P The portal content component's prop types
|
|
133
|
-
*/
|
|
134
|
-
export type PortalLauncherWithFixedProviders<P extends Record<string, any>> = (props: P & Omit<PortalProps<P>, 'portal'>) => ReactDOMRoot | null;
|
|
135
134
|
export {};
|
|
136
135
|
//# sourceMappingURL=node.type.d.ts.map
|
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,EACV,UAAU,IAAI,eAAe,EAC7B,cAAc,EACd,aAAa,EACb,SAAS,EACT,GAAG,EACH,WAAW,EACX,aAAa,EACb,qBAAqB,EACrB,SAAS,EACV,MAAM,OAAO,CAAA;AACd,OAAO,KAAK,EAAE,IAAI,IAAI,YAAY,EAAE,MAAM,kBAAkB,CAAA;AAE5D,MAAM,MAAM,WAAW,GACnB,SAAS,GACT,SAAS,CAAC,GAAG,EAAE,GAAG,CAAC,GACnB,WAAW,GACX,aAAa,CAAC,GAAG,CAAC,GAClB,YAAY,CAAC,GAAG,CAAC,GACjB,CAAC,CAAC,KAAK,CAAC,EAAE,GAAG,KAAK,SAAS,GAAG,OAAO,CAAC,SAAS,CAAC,GAAG,SAAS,CAAC,GAAG,CAAC,GAAG,YAAY,CAAC,GAAG,CAAC,GAAG,aAAa,CAAC,CAAA;AAE1G;;;;;;GAMG;AACH,MAAM,MAAM,QAAQ,GAAG,SAAS,GAAG,SAAS,CAAC,GAAG,CAAC,GAAG,WAAW,GAAG,YAAY,CAAC,GAAG,CAAC,GAAG,aAAa,CAAA;AAEnG;;;;GAIG;AACH,MAAM,WAAW,YAAY,CAAC,CAAC,SAAS,WAAW,GAAG,WAAW;IAC/D,gFAAgF;IAChF,QAAQ,CAAC,OAAO,EAAE,CAAC,CAAA;IAEnB,uFAAuF;IACvF,QAAQ,CAAC,QAAQ,CAAC,EAAE,YAAY,CAAC,CAAC,CAAC,CAAA;IAEnC,uEAAuE;IACvE,MAAM,IAAI,SAAS,CAAA;IAEnB,qFAAqF;IACrF,QAAQ,IAAI,YAAY,GAAG,IAAI,CAAA;CAChC;AAED;;;;GAIG;AACH,MA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;AAED;;;;GAIG;AACH,MAAM,MAAM,cAAc,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,IAAI,CAC1D,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"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"react-is.helper.d.ts","sourceRoot":"","sources":["../src/react-is.helper.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"react-is.helper.d.ts","sourceRoot":"","sources":["../src/react-is.helper.ts"],"names":[],"mappings":"AAEA;;;;GAIG;AAEH,OAAO,KAAK,MAAM,OAAO,CAAA;AAEzB;;;GAGG;AACH,eAAO,MAAM,kBAAkB,eAA2C,CAAA;AAC1E,eAAO,MAAM,iBAAiB,eAA6B,CAAA;AAC3D,eAAO,MAAM,mBAAmB,eAA+B,CAAA;AAC/D,eAAO,MAAM,sBAAsB,eAAkC,CAAA;AACrE,eAAO,MAAM,mBAAmB,eAA+B,CAAA;AAC/D,eAAO,MAAM,mBAAmB,eAA+B,CAAA;AAC/D,eAAO,MAAM,mBAAmB,eAA+B,CAAA;AAC/D,eAAO,MAAM,kBAAkB,eAA8B,CAAA;AAC7D,eAAO,MAAM,sBAAsB,eAAkC,CAAA;AACrE,eAAO,MAAM,mBAAmB,eAA+B,CAAA;AAC/D,eAAO,MAAM,wBAAwB,eAAoC,CAAA;AACzE,eAAO,MAAM,eAAe,eAA2B,CAAA;AACvD,eAAO,MAAM,eAAe,eAA2B,CAAA;AACvD,eAAO,MAAM,0BAA0B,eAAsC,CAAA;AAC7E,eAAO,MAAM,sBAAsB,eAAuC,CAAA;AAE1E;;;GAGG;AACH,MA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F;;;;GAIG;AACH,eAAO,MAAM,UAAU,GAAI,QAAQ,OAAO,KAAG,OAAiD,CAAA;AAE9F;;;;GAIG;AACH,eAAO,MAAM,YAAY,GAAI,QAAQ,OAAO,KAAG,OAAoD,CAAA;AAEnG;;;;GAIG;AACH,eAAO,MAAM,UAAU,GAAI,QAAQ,OAAO,KAAG,OAAiD,CAAA;AAE9F;;;;GAIG;AACH,eAAO,MAAM,cAAc,GAAI,QAAQ,OAAO,KAAG,OAAsD,CAAA;AAgBvG;;;;;;GAMG;AACH,eAAO,MAAM,kBAAkB,GAAI,CAAC,EAAE,MAAM,CAAC,KAAG,OAgB/C,CAAA;AAED;;;;;;GAMG;AACH,eAAO,MAAM,qBAAqB,GAAI,WAAW,OAAO,KAAG,SAAS,IAAI,KAAK,CAAC,aAS7E,CAAA"}
|
package/dist/react-is.helper.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";/**
|
|
2
2
|
* Custom React Type Checker (TypeScript Version)
|
|
3
3
|
* Provides utilities for identifying and checking React component/element types.
|
|
4
4
|
* Inspired by react-is package but implemented in TypeScript with type safety.
|
|
5
|
-
*/import React from"react";/**
|
|
5
|
+
*/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 React from"react";/**
|
|
6
6
|
* Symbol identifiers for React internal component types
|
|
7
7
|
* These are used to identify different kinds of React elements and components
|
|
8
8
|
*/export var REACT_ELEMENT_TYPE=Symbol["for"]("react.transitional.element");export var REACT_PORTAL_TYPE=Symbol["for"]("react.portal");export var REACT_FRAGMENT_TYPE=Symbol["for"]("react.fragment");export var REACT_STRICT_MODE_TYPE=Symbol["for"]("react.strict_mode");export var REACT_PROFILER_TYPE=Symbol["for"]("react.profiler");export var REACT_PROVIDER_TYPE=Symbol["for"]("react.provider");export var REACT_CONSUMER_TYPE=Symbol["for"]("react.consumer");export var REACT_CONTEXT_TYPE=Symbol["for"]("react.context");export var REACT_FORWARD_REF_TYPE=Symbol["for"]("react.forward_ref");export var REACT_SUSPENSE_TYPE=Symbol["for"]("react.suspense");export var REACT_SUSPENSE_LIST_TYPE=Symbol["for"]("react.suspense_list");export var REACT_MEMO_TYPE=Symbol["for"]("react.memo");export var REACT_LAZY_TYPE=Symbol["for"]("react.lazy");export var REACT_VIEW_TRANSITION_TYPE=Symbol["for"]("react.view_transition");export var REACT_CLIENT_REFERENCE=Symbol["for"]("react.client.reference");/**
|
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.61",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/main.js",
|
|
7
7
|
"types": "./dist/main.d.ts",
|