@meonode/ui 0.1.33 → 0.1.35
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +69 -7
- package/dist/json/standard.css-properties.json +2 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -205,6 +205,7 @@ const LoginForm = Component(() =>
|
|
|
205
205
|
```
|
|
206
206
|
|
|
207
207
|
## Comprehensive Example: Theme-Switching & Conditional Components
|
|
208
|
+
|
|
208
209
|
```tsx
|
|
209
210
|
'use client'
|
|
210
211
|
/**
|
|
@@ -213,7 +214,19 @@ const LoginForm = Component(() =>
|
|
|
213
214
|
* approaches, the use of Higher-Order Components (HOCs), and how theme context
|
|
214
215
|
* is managed and propagated within the @meonode/ui component tree.
|
|
215
216
|
*/
|
|
216
|
-
import {
|
|
217
|
+
import {
|
|
218
|
+
Button,
|
|
219
|
+
Center,
|
|
220
|
+
Column,
|
|
221
|
+
Component,
|
|
222
|
+
Fixed,
|
|
223
|
+
Node,
|
|
224
|
+
type NodeInstance,
|
|
225
|
+
P,
|
|
226
|
+
Portal,
|
|
227
|
+
Row,
|
|
228
|
+
type Theme
|
|
229
|
+
} from '@meonode/ui'
|
|
217
230
|
import { useState, useEffect, ReactElement, ReactNode } from 'react'
|
|
218
231
|
import { CssBaseline, FormControlLabel, TextField } from '@meonode/mui'
|
|
219
232
|
import { Switch as MUISwitch } from '@mui/material'
|
|
@@ -602,18 +615,67 @@ const Modal = Portal(({ theme, portal }) => {
|
|
|
602
615
|
})
|
|
603
616
|
```
|
|
604
617
|
|
|
618
|
+
## Passing Context Wrapper To Portal
|
|
619
|
+
```ts
|
|
620
|
+
import { Provider, useSelector } from 'react-redux'
|
|
621
|
+
import store from '/path/to/redux/store'
|
|
622
|
+
|
|
623
|
+
/**
|
|
624
|
+
* ReduxProvider
|
|
625
|
+
*
|
|
626
|
+
* A wrapper component that integrates the Redux store with a React application.
|
|
627
|
+
* It utilizes the `Provider` component from `react-redux` to make the Redux store
|
|
628
|
+
* available to the entire component tree.
|
|
629
|
+
*
|
|
630
|
+
* @constant
|
|
631
|
+
* @type {ReactNode}
|
|
632
|
+
* @param {Object} store - The Redux store instance to be passed down to the application.
|
|
633
|
+
*/
|
|
634
|
+
const ReduxProvider = Node(Provider, { store })
|
|
635
|
+
|
|
636
|
+
/**
|
|
637
|
+
* Represents a modal component that is implemented using a portal
|
|
638
|
+
* and wrapped with a Redux provider. This component retrieves state
|
|
639
|
+
* from the Redux store and responds to state changes.
|
|
640
|
+
*
|
|
641
|
+
* The `Modal` leverages the Redux `useSelector` hook to access specific
|
|
642
|
+
* Redux state values and ensure dynamic behavior within the modal based
|
|
643
|
+
* on the application's state.
|
|
644
|
+
*
|
|
645
|
+
* Dependencies:
|
|
646
|
+
* - ReduxProvider: Ensures the modal has access to the Redux store.
|
|
647
|
+
* - Portal: Renders the modal outside of its parent hierarchy.
|
|
648
|
+
* - useSelector: Accesses specific data from the Redux state.
|
|
649
|
+
*
|
|
650
|
+
* Side Effects:
|
|
651
|
+
* - The component logs the specific Redux state changes to the console
|
|
652
|
+
* when the state is updated.
|
|
653
|
+
*
|
|
654
|
+
* Props:
|
|
655
|
+
* - portal: Configuration for where the modal portal is rendered.
|
|
656
|
+
*/
|
|
657
|
+
const Modal = Portal(ReduxProvider, ({ portal }) => {
|
|
658
|
+
const someReduxState = useSelector(state => state.someReduxState)
|
|
659
|
+
|
|
660
|
+
useEffect(() => {
|
|
661
|
+
console.log('Redux State value: ', someReduxState)
|
|
662
|
+
}, [])
|
|
663
|
+
|
|
664
|
+
// ...
|
|
665
|
+
})
|
|
666
|
+
```
|
|
667
|
+
|
|
605
668
|
---
|
|
606
669
|
|
|
607
670
|
## API Reference
|
|
608
671
|
|
|
609
672
|
### Core Functions
|
|
610
673
|
|
|
611
|
-
| Function | Parameters
|
|
612
|
-
|
|
613
|
-
| `Node` | `element: NodeElement \| React.ComponentType`, `baseProps: object`
|
|
614
|
-
| `Component` | `(props: P) => ComponentNode`
|
|
615
|
-
| `Portal` | `(props: P) => ComponentNode`
|
|
616
|
-
|
|
|
674
|
+
| Function | Parameters | Description |
|
|
675
|
+
|-------------|---------------------------------------------------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
|
|
676
|
+
| `Node` | `element: NodeElement \| React.ComponentType`, `baseProps: object` | Constructs a configurable UI node that supports flexible properties and dynamic styling. |
|
|
677
|
+
| `Component` | `(props: P) => ComponentNode` | Transforms node trees into reusable React components with built-in type safety and seamless integration. |
|
|
678
|
+
| `Portal` | • `(component: (props: P) => ComponentNode)` or <br/> • `(providers: NodeElement \| NodeElement[], component: (props: P) => ComponentNode)` | Creates a React Portal component. Accepts either a component function directly, or a tuple of providers (e.g. Redux Provider) and the component. The component receives portal controls for mounting/unmounting. |
|
|
617
679
|
|
|
618
680
|
---
|
|
619
681
|
|
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.35",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/main.js",
|
|
7
7
|
"types": "./dist/main.d.ts",
|