brew-js-react 0.2.9 → 0.3.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/dialog.d.ts CHANGED
@@ -11,6 +11,7 @@ export interface DialogBaseProps<T> {
11
11
  className?: string;
12
12
  showCloseButton?: boolean;
13
13
  preventLeave?: boolean;
14
+ preventNavigation?: boolean;
14
15
  modal?: boolean;
15
16
  onCommit?: (value: T | undefined) => void;
16
17
  onOpen?: (root: HTMLElement) => void;
package/dialog.js CHANGED
@@ -14,26 +14,20 @@ const createRoot = ReactDOM.createRoot;
14
14
  export function createDialog(props) {
15
15
  var root = document.createElement('div');
16
16
  var reactRoot = createRoot && createRoot(root);
17
- var closing = false;
17
+ var closeDialog = closeFlyout.bind(0, root);
18
18
  var promise;
19
19
 
20
- function closeDialog(value) {
21
- if (!closing) {
22
- closing = true;
23
- closeFlyout(root, value).then(function () {
24
- closing = false;
25
- removeNode(root);
26
- (props.onClose || noop)(root);
27
- if (props.onRender) {
28
- if (reactRoot) {
29
- reactRoot.unmount();
30
- } else {
31
- ReactDOM.unmountComponentAtNode(root);
32
- }
33
- }
34
- });
20
+ dom.on(root, 'flyouthide', function () {
21
+ removeNode(root);
22
+ (props.onClose || noop)(root);
23
+ if (props.onRender) {
24
+ if (reactRoot) {
25
+ reactRoot.unmount();
26
+ } else {
27
+ ReactDOM.unmountComponentAtNode(root);
28
+ }
35
29
  }
36
- }
30
+ });
37
31
 
38
32
  return {
39
33
  root: root,
@@ -70,6 +64,8 @@ export function createDialog(props) {
70
64
  promise = openFlyout(root);
71
65
  if (props.preventLeave) {
72
66
  preventLeave(root, promise);
67
+ } else if (props.preventNavigation) {
68
+ lock(root, promise);
73
69
  }
74
70
  always(promise, function () {
75
71
  promise = null;