react-confirm 0.4.0-0 → 0.4.0
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/lib/context.js +0 -17
- package/package.json +1 -1
- package/src/context.js +0 -17
- package/typescript/index.d.ts +35 -5
- package/typescript/context.d.ts +0 -38
package/lib/context.js
CHANGED
|
@@ -7,31 +7,14 @@ exports.ContextAwareConfirmation = void 0;
|
|
|
7
7
|
exports.createConfirmationContext = createConfirmationContext;
|
|
8
8
|
var _reactTree = require("./mounter/reactTree");
|
|
9
9
|
var _createConfirmation2 = require("./createConfirmation");
|
|
10
|
-
/**
|
|
11
|
-
* Creates a React context-aware confirmation system.
|
|
12
|
-
* This provides a simple interface for using confirmations within React component tree.
|
|
13
|
-
*
|
|
14
|
-
* @param {HTMLElement} [mountNode] - Optional DOM node to mount dialogs in
|
|
15
|
-
* @returns {Object} Object containing createConfirmation function and ConfirmationRoot component
|
|
16
|
-
*/
|
|
17
10
|
function createConfirmationContext(mountNode) {
|
|
18
11
|
var mounter = (0, _reactTree.createReactTreeMounter)(mountNode);
|
|
19
12
|
var _createConfirmation = (0, _createConfirmation2.createConfirmationCreater)(mounter);
|
|
20
13
|
var ConfirmationRoot = (0, _reactTree.createMountPoint)(mounter);
|
|
21
14
|
return {
|
|
22
|
-
/**
|
|
23
|
-
* Creates a confirmation function for a given component
|
|
24
|
-
* @param {React.ComponentType} component - The confirmable component
|
|
25
|
-
* @param {number} [unmountDelay=1000] - Delay before unmounting the component
|
|
26
|
-
* @returns {Function} Confirmation function that returns a Promise
|
|
27
|
-
*/
|
|
28
15
|
createConfirmation: function createConfirmation(component, unmountDelay) {
|
|
29
16
|
return _createConfirmation(component, unmountDelay);
|
|
30
17
|
},
|
|
31
|
-
/**
|
|
32
|
-
* React component that must be rendered in your app to display confirmations
|
|
33
|
-
* Place this component at the root level of your app or where you want confirmations to appear
|
|
34
|
-
*/
|
|
35
18
|
ConfirmationRoot: ConfirmationRoot
|
|
36
19
|
};
|
|
37
20
|
}
|
package/package.json
CHANGED
package/src/context.js
CHANGED
|
@@ -1,31 +1,14 @@
|
|
|
1
1
|
import { createReactTreeMounter, createMountPoint } from './mounter/reactTree';
|
|
2
2
|
import { createConfirmationCreater } from './createConfirmation';
|
|
3
3
|
|
|
4
|
-
/**
|
|
5
|
-
* Creates a React context-aware confirmation system.
|
|
6
|
-
* This provides a simple interface for using confirmations within React component tree.
|
|
7
|
-
*
|
|
8
|
-
* @param {HTMLElement} [mountNode] - Optional DOM node to mount dialogs in
|
|
9
|
-
* @returns {Object} Object containing createConfirmation function and ConfirmationRoot component
|
|
10
|
-
*/
|
|
11
4
|
export function createConfirmationContext(mountNode) {
|
|
12
5
|
const mounter = createReactTreeMounter(mountNode);
|
|
13
6
|
const createConfirmation = createConfirmationCreater(mounter);
|
|
14
7
|
const ConfirmationRoot = createMountPoint(mounter);
|
|
15
8
|
|
|
16
9
|
return {
|
|
17
|
-
/**
|
|
18
|
-
* Creates a confirmation function for a given component
|
|
19
|
-
* @param {React.ComponentType} component - The confirmable component
|
|
20
|
-
* @param {number} [unmountDelay=1000] - Delay before unmounting the component
|
|
21
|
-
* @returns {Function} Confirmation function that returns a Promise
|
|
22
|
-
*/
|
|
23
10
|
createConfirmation: (component, unmountDelay) => createConfirmation(component, unmountDelay),
|
|
24
11
|
|
|
25
|
-
/**
|
|
26
|
-
* React component that must be rendered in your app to display confirmations
|
|
27
|
-
* Place this component at the root level of your app or where you want confirmations to appear
|
|
28
|
-
*/
|
|
29
12
|
ConfirmationRoot
|
|
30
13
|
};
|
|
31
14
|
}
|
package/typescript/index.d.ts
CHANGED
|
@@ -49,8 +49,38 @@ export declare function createDomTreeMounter(defaultMountNode?: Element | Docume
|
|
|
49
49
|
export declare function createConfirmationCreater(mounter: Mounter): typeof createConfirmation;
|
|
50
50
|
|
|
51
51
|
// Context-aware confirmation system
|
|
52
|
-
export {
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
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;
|
package/typescript/context.d.ts
DELETED
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
|
-
import { ConfirmDialog, ConfirmableDialog } from './index';
|
|
3
|
-
|
|
4
|
-
export interface ConfirmationContext {
|
|
5
|
-
/**
|
|
6
|
-
* Creates a confirmation function for a given component
|
|
7
|
-
* @param component - The confirmable component
|
|
8
|
-
* @param unmountDelay - Delay before unmounting the component (default: 1000ms)
|
|
9
|
-
* @returns Confirmation function that returns a Promise
|
|
10
|
-
*/
|
|
11
|
-
createConfirmation: <P, R>(
|
|
12
|
-
component: ConfirmableDialog<P, R>,
|
|
13
|
-
unmountDelay?: number
|
|
14
|
-
) => (props: P) => Promise<R>;
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* React component that must be rendered in your app to display confirmations
|
|
18
|
-
* Place this component at the root level of your app or where you want confirmations to appear
|
|
19
|
-
*/
|
|
20
|
-
ConfirmationRoot: React.ComponentType;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
/**
|
|
24
|
-
* Creates a React context-aware confirmation system.
|
|
25
|
-
* This provides a simple interface for using confirmations within React component tree.
|
|
26
|
-
*
|
|
27
|
-
* @param mountNode - Optional DOM node to mount dialogs in
|
|
28
|
-
* @returns Object containing createConfirmation function and ConfirmationRoot component
|
|
29
|
-
*/
|
|
30
|
-
export declare function createConfirmationContext(
|
|
31
|
-
mountNode?: Element | DocumentFragment | HTMLElement
|
|
32
|
-
): ConfirmationContext;
|
|
33
|
-
|
|
34
|
-
/**
|
|
35
|
-
* Context-aware confirmation system for convenient usage
|
|
36
|
-
* Use this if you don't need custom mount nodes
|
|
37
|
-
*/
|
|
38
|
-
export declare const ContextAwareConfirmation: ConfirmationContext;
|