react-dialog-router
Advanced tools
Comparing version 1.0.3 to 1.0.4
@@ -1,5 +0,24 @@ | ||
import React from 'react'; | ||
import React, { FunctionComponent } from 'react'; | ||
export declare const switchCase: (cases: object) => (defaultCase: any) => (key: any) => any; | ||
export declare const useDialogs: () => {}; | ||
export declare const withDialogs: (Component: any) => (props: any) => React.JSX.Element; | ||
export declare const DialogRouterProvider: ({ children, dialogs }: any) => React.JSX.Element; | ||
type DialogObj = { | ||
name: string; | ||
props: object; | ||
}; | ||
type ContextObject = { | ||
openDialog: (obj: DialogObj) => void; | ||
closeAll: () => void; | ||
closeLastDialog: () => void; | ||
goBackToName: (name: string) => void; | ||
openSecondaryDialog: (obj: DialogObj) => void; | ||
closeSecondaryDialog: () => void; | ||
}; | ||
export declare const useDialogs: () => {} | ContextObject; | ||
export declare const withDialogs: (Component: FunctionComponent) => (props: any) => React.JSX.Element; | ||
type DialogsObj = { | ||
[dialogName: string]: FunctionComponent; | ||
}; | ||
export declare const DialogRouterProvider: ({ children, dialogs }: { | ||
children: React.ReactNode; | ||
dialogs: DialogsObj; | ||
}) => React.JSX.Element; | ||
export {}; |
@@ -24,6 +24,2 @@ "use strict"; | ||
exports.withDialogs = withDialogs; | ||
// { | ||
// 'DIALOG_NAME': DialogComponent, | ||
// 'DIALOG_NAME_2': DialogComponent2 | ||
// } | ||
var getModalByType = function (dialogs) { return (0, exports.switchCase)(dialogs)('div'); }; | ||
@@ -30,0 +26,0 @@ // eslint-disable-next-line react/display-name |
@@ -1,5 +0,24 @@ | ||
import React from 'react'; | ||
import React, { FunctionComponent } from 'react'; | ||
export declare const switchCase: (cases: object) => (defaultCase: any) => (key: any) => any; | ||
export declare const useDialogs: () => {}; | ||
export declare const withDialogs: (Component: any) => (props: any) => React.JSX.Element; | ||
export declare const DialogRouterProvider: ({ children, dialogs }: any) => React.JSX.Element; | ||
type DialogObj = { | ||
name: string; | ||
props: object; | ||
}; | ||
type ContextObject = { | ||
openDialog: (obj: DialogObj) => void; | ||
closeAll: () => void; | ||
closeLastDialog: () => void; | ||
goBackToName: (name: string) => void; | ||
openSecondaryDialog: (obj: DialogObj) => void; | ||
closeSecondaryDialog: () => void; | ||
}; | ||
export declare const useDialogs: () => {} | ContextObject; | ||
export declare const withDialogs: (Component: FunctionComponent) => (props: any) => React.JSX.Element; | ||
type DialogsObj = { | ||
[dialogName: string]: FunctionComponent; | ||
}; | ||
export declare const DialogRouterProvider: ({ children, dialogs }: { | ||
children: React.ReactNode; | ||
dialogs: DialogsObj; | ||
}) => React.JSX.Element; | ||
export {}; |
@@ -18,6 +18,2 @@ import { __assign } from "tslib"; | ||
}; | ||
// { | ||
// 'DIALOG_NAME': DialogComponent, | ||
// 'DIALOG_NAME_2': DialogComponent2 | ||
// } | ||
var getModalByType = function (dialogs) { return switchCase(dialogs)('div'); }; | ||
@@ -24,0 +20,0 @@ // eslint-disable-next-line react/display-name |
{ | ||
"name": "react-dialog-router", | ||
"version": "1.0.3", | ||
"version": "1.0.4", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "main": "./dist/cjs/index.js", |
@@ -5,2 +5,5 @@ # React Dialog Router | ||
## Playground | ||
Here is a [codesandbox](https://codesandbox.io/s/react-dialog-router-example-746c29) | ||
## Installation | ||
@@ -16,9 +19,9 @@ | ||
## Usage | ||
To use the React Dialog Router, you first need to initialize it with a set of dialogs. Here's an example of how to set it up: | ||
To use the React Dialog Router, you first need to import DialogRouterProvider and add it to your root app. Here's an example of how to set it up: | ||
```js | ||
//dialogRoot.js | ||
import { initDialogRouter } from 'react-dialog-router'; | ||
//App.js | ||
import { DialogRouterProvider } from 'react-dialog-router'; | ||
import { DialogComponent, DialogComponent2 } from './dialogs'; | ||
// Define your dialog components | ||
const dialogs = { | ||
@@ -28,20 +31,5 @@ 'DIALOG_NAME': DialogComponent, | ||
}; | ||
const { DialogRouter, useDialogs: useDialogsHook, withDialogs: withDialogsHOC } = initDialogRouter(dialogs); | ||
export const useDialogs = useDialogsHook | ||
export const withDialogs = withDialogsHOC | ||
export default DialogRouter | ||
``` | ||
```js | ||
//App.js | ||
import DialogRouter from './dialogRoot'; | ||
function App() { | ||
return ( | ||
<DialogRouter> | ||
<DialogRouter dialogs={dialogs}> | ||
{/* Your application content */} | ||
@@ -91,3 +79,3 @@ </DialogRouter> | ||
```js | ||
import { withDialogs } from './dialogRoot'; | ||
import { withDialogs } from 'react-dialog-router'; | ||
@@ -107,3 +95,3 @@ const MyComponent = ({ dialogContext }) => { | ||
import React from 'react'; | ||
import { useDialogs } from './dialogRoot'; // Replace with the actual path | ||
import { useDialogs } from 'react-dialog-router'; // Replace with the actual path | ||
@@ -110,0 +98,0 @@ function MyButton() { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
20316
198
108