react-confirm 0.4.0 → 0.5.0-1
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 +4 -6
- package/dist/confirmable.d.ts +3 -0
- package/dist/confirmable.js +46 -0
- package/dist/context.d.ts +3 -0
- package/dist/context.js +18 -0
- package/dist/createConfirmation.d.ts +4 -0
- package/dist/createConfirmation.js +48 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.js +52 -0
- package/dist/mounter/domTree.d.ts +2 -0
- package/dist/mounter/domTree.js +43 -0
- package/dist/mounter/reactTree.d.ts +3 -0
- package/dist/mounter/reactTree.js +62 -0
- package/dist/types.d.ts +43 -0
- package/dist/types.js +6 -0
- package/package.json +34 -18
- package/src/confirmable.tsx +35 -0
- package/src/context.ts +17 -0
- package/src/createConfirmation.ts +43 -0
- package/src/{index.js → index.ts} +9 -0
- package/src/mounter/domTree.tsx +36 -0
- package/src/mounter/reactTree.tsx +62 -0
- package/src/types.ts +59 -0
- package/lib/confirmable.js +0 -50
- package/lib/context.js +0 -26
- package/lib/createConfirmation.js +0 -47
- package/lib/index.js +0 -61
- package/lib/mounter/domTree.js +0 -34
- package/lib/mounter/reactTree.js +0 -77
- package/src/confirmable.js +0 -31
- package/src/context.js +0 -20
- package/src/createConfirmation.js +0 -31
- package/src/mounter/domTree.js +0 -35
- package/src/mounter/reactTree.js +0 -56
- package/typescript/index.d.ts +0 -86
package/typescript/index.d.ts
DELETED
|
@@ -1,86 +0,0 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
|
-
|
|
3
|
-
type ConfirmableProps<P, R> = {
|
|
4
|
-
dispose: () => void;
|
|
5
|
-
resolve: (value: R | PromiseLike<R>) => void;
|
|
6
|
-
reject: (reason?: any) => void;
|
|
7
|
-
} & P;
|
|
8
|
-
|
|
9
|
-
type ConfirmableDialog<P, R> = React.ComponentType<ConfirmableProps<P, R>>;
|
|
10
|
-
|
|
11
|
-
export type ConfirmDialogProps<P, R> = {
|
|
12
|
-
/** Dismiss dialog without resolving the promise. */
|
|
13
|
-
dismiss: () => void;
|
|
14
|
-
/** Resolve the promise with the given value. */
|
|
15
|
-
proceed: (value: R) => void;
|
|
16
|
-
/** Reject the promise with the given value. */
|
|
17
|
-
cancel: (value?: any) => void;
|
|
18
|
-
/** Indicates if the dialog should be shown aka. someone is waiting for a promise. */
|
|
19
|
-
show: boolean;
|
|
20
|
-
} & P;
|
|
21
|
-
|
|
22
|
-
export type ConfirmDialog<P, R> = React.ComponentType<ConfirmDialogProps<P, R>> ;
|
|
23
|
-
|
|
24
|
-
export declare function confirmable<P, R>(
|
|
25
|
-
component: ConfirmDialog<P, R>
|
|
26
|
-
): ConfirmableDialog<P, R>;
|
|
27
|
-
|
|
28
|
-
export declare function createConfirmation<P, R>(
|
|
29
|
-
component: ConfirmableDialog<P, R>,
|
|
30
|
-
unmountDelay?: number,
|
|
31
|
-
mountingNode?: HTMLElement,
|
|
32
|
-
): (props: P) => Promise<R>;
|
|
33
|
-
|
|
34
|
-
type Mounter = {
|
|
35
|
-
mount: (component: React.ComponentType, props: any, mountNode?: HTMLElement) => string
|
|
36
|
-
unmount: (key: string) => void
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
type TreeMounter = {
|
|
40
|
-
options: {
|
|
41
|
-
setMountedCallback: (callback: (components: any) => void) => void
|
|
42
|
-
mountNode?: Element | DocumentFragment | HTMLElement
|
|
43
|
-
}
|
|
44
|
-
} & Mounter
|
|
45
|
-
|
|
46
|
-
export declare function createReactTreeMounter(mountNode?: Element | DocumentFragment | HTMLElement): TreeMounter;
|
|
47
|
-
export declare function createMountPoint(mounter: TreeMounter): React.ComponentType;
|
|
48
|
-
export declare function createDomTreeMounter(defaultMountNode?: Element | DocumentFragment | HTMLElement): Mounter;
|
|
49
|
-
export declare function createConfirmationCreater(mounter: Mounter): typeof createConfirmation;
|
|
50
|
-
|
|
51
|
-
// Context-aware confirmation system
|
|
52
|
-
export interface ConfirmationContext {
|
|
53
|
-
/**
|
|
54
|
-
* Creates a confirmation function for a given component
|
|
55
|
-
* @param component - The confirmable component
|
|
56
|
-
* @param unmountDelay - Delay before unmounting the component (default: 1000ms)
|
|
57
|
-
* @returns Confirmation function that returns a Promise
|
|
58
|
-
*/
|
|
59
|
-
createConfirmation: <P, R>(
|
|
60
|
-
component: ConfirmableDialog<P, R>,
|
|
61
|
-
unmountDelay?: number
|
|
62
|
-
) => (props: P) => Promise<R>;
|
|
63
|
-
|
|
64
|
-
/**
|
|
65
|
-
* React component that must be rendered in your app to display confirmations
|
|
66
|
-
* Place this component at the root level of your app or where you want confirmations to appear
|
|
67
|
-
*/
|
|
68
|
-
ConfirmationRoot: React.ComponentType;
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
/**
|
|
72
|
-
* Creates a React context-aware confirmation system.
|
|
73
|
-
* This provides a simple interface for using confirmations within React component tree.
|
|
74
|
-
*
|
|
75
|
-
* @param mountNode - Optional DOM node to mount dialogs in
|
|
76
|
-
* @returns Object containing createConfirmation function and ConfirmationRoot component
|
|
77
|
-
*/
|
|
78
|
-
export declare function createConfirmationContext(
|
|
79
|
-
mountNode?: Element | DocumentFragment | HTMLElement
|
|
80
|
-
): ConfirmationContext;
|
|
81
|
-
|
|
82
|
-
/**
|
|
83
|
-
* Context-aware confirmation system for convenient usage
|
|
84
|
-
* Use this if you don't need custom mount nodes
|
|
85
|
-
*/
|
|
86
|
-
export declare const ContextAwareConfirmation: ConfirmationContext;
|