@fluentui-react-native/callout 0.19.33 → 0.19.36

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/CHANGELOG.json CHANGED
@@ -2,7 +2,58 @@
2
2
  "name": "@fluentui-react-native/callout",
3
3
  "entries": [
4
4
  {
5
- "date": "Fri, 18 Mar 2022 07:18:53 GMT",
5
+ "date": "Mon, 28 Mar 2022 15:01:45 GMT",
6
+ "tag": "@fluentui-react-native/callout_v0.19.36",
7
+ "version": "0.19.36",
8
+ "comments": {
9
+ "patch": [
10
+ {
11
+ "author": "beachball",
12
+ "package": "@fluentui-react-native/callout",
13
+ "comment": "Bump @fluentui-react-native/interactive-hooks to v0.14.5",
14
+ "commit": "c85943cf17fb111a721e006e1619084e27650b39"
15
+ }
16
+ ]
17
+ }
18
+ },
19
+ {
20
+ "date": "Wed, 23 Mar 2022 17:24:05 GMT",
21
+ "tag": "@fluentui-react-native/callout_v0.19.35",
22
+ "version": "0.19.35",
23
+ "comments": {
24
+ "patch": [
25
+ {
26
+ "author": "beachball",
27
+ "package": "@fluentui-react-native/callout",
28
+ "comment": "Bump @fluentui-react-native/interactive-hooks to v0.14.4",
29
+ "commit": "0a18d2f8bb6505c6c6e2445ff3ba62ac79334872"
30
+ },
31
+ {
32
+ "author": "beachball",
33
+ "package": "@fluentui-react-native/callout",
34
+ "comment": "Bump @uifabricshared/foundation-compose to v1.11.12",
35
+ "commit": "0a18d2f8bb6505c6c6e2445ff3ba62ac79334872"
36
+ }
37
+ ]
38
+ }
39
+ },
40
+ {
41
+ "date": "Mon, 21 Mar 2022 01:47:54 GMT",
42
+ "tag": "@fluentui-react-native/callout_v0.19.34",
43
+ "version": "0.19.34",
44
+ "comments": {
45
+ "patch": [
46
+ {
47
+ "author": "sanajmi@microsoft.com",
48
+ "package": "@fluentui-react-native/callout",
49
+ "commit": "b772dfe4542b7032f216bf5c2faa807c695fa2a7",
50
+ "comment": "width -> maxWidth"
51
+ }
52
+ ]
53
+ }
54
+ },
55
+ {
56
+ "date": "Fri, 18 Mar 2022 07:19:17 GMT",
6
57
  "tag": "@fluentui-react-native/callout_v0.19.33",
7
58
  "version": "0.19.33",
8
59
  "comments": {
package/CHANGELOG.md CHANGED
@@ -1,12 +1,37 @@
1
1
  # Change Log - @fluentui-react-native/callout
2
2
 
3
- This log was last generated on Fri, 18 Mar 2022 07:18:53 GMT and should not be manually modified.
3
+ This log was last generated on Mon, 28 Mar 2022 15:01:45 GMT and should not be manually modified.
4
4
 
5
5
  <!-- Start content -->
6
6
 
7
+ ## 0.19.36
8
+
9
+ Mon, 28 Mar 2022 15:01:45 GMT
10
+
11
+ ### Patches
12
+
13
+ - Bump @fluentui-react-native/interactive-hooks to v0.14.5
14
+
15
+ ## 0.19.35
16
+
17
+ Wed, 23 Mar 2022 17:24:05 GMT
18
+
19
+ ### Patches
20
+
21
+ - Bump @fluentui-react-native/interactive-hooks to v0.14.4
22
+ - Bump @uifabricshared/foundation-compose to v1.11.12
23
+
24
+ ## 0.19.34
25
+
26
+ Mon, 21 Mar 2022 01:47:54 GMT
27
+
28
+ ### Patches
29
+
30
+ - width -> maxWidth (sanajmi@microsoft.com)
31
+
7
32
  ## 0.19.33
8
33
 
9
- Fri, 18 Mar 2022 07:18:53 GMT
34
+ Fri, 18 Mar 2022 07:19:17 GMT
10
35
 
11
36
  ### Patches
12
37
 
@@ -85,39 +85,47 @@ class CalloutView: RCTView, CalloutWindowLifeCycleDelegate {
85
85
 
86
86
  updateCalloutFrameToAnchor()
87
87
  calloutWindow.makeKeyAndOrderFront(self)
88
-
88
+
89
89
  // Dismiss the Callout if the window is no longer active.
90
90
  NotificationCenter.default.addObserver(self, selector: #selector(dismissCallout), name: NSApplication.didResignActiveNotification, object: nil)
91
91
 
92
- mouseEventMonitor.addLocalMonitorForEvents(matching: .leftMouseUp, handler: { [weak self] (event) -> NSEvent? in
93
- guard let clickedWindow = event.window else {
94
- return event
92
+ mouseEventMonitor.addLocalMonitorForEvents(matching: .leftMouseDown, handler: { [weak self] (event) -> NSEvent? in
93
+ func isClickInsideWindowHierarchy(window: NSWindow?, event: NSEvent) -> Bool {
94
+ guard let window = window else {
95
+ return false
96
+ }
97
+ guard let clickedWindow = event.window else {
98
+ return false
95
99
  }
96
100
 
97
- var shouldDismissCallout = true
98
-
99
- // Did the click happened in our own window?
100
- if (clickedWindow.isEqual(to: self) ) {
101
- shouldDismissCallout = false
102
-
103
- // Are we a child window of a Callout (e.g: a ContextualMenu submenu), where the click happened in our parent?
104
- } else if (clickedWindow.isEqual(to: self?.calloutWindow.parent as? CalloutWindow)) {
105
- shouldDismissCallout = false
101
+ var isClickInHierarchy = false
106
102
 
107
- // Did the click happened in any of our child windows (e.g: our submenus)?
108
- } else if (self?.calloutWindow.childWindows?.contains(clickedWindow) ?? false) {
109
- shouldDismissCallout = false
110
- }
111
-
112
- if (shouldDismissCallout) {
113
- self?.dismissCallout()
103
+ if (window.isEqual(to: clickedWindow)) {
104
+ isClickInHierarchy = true
105
+ } else {
106
+ if let childWindows = window.childWindows {
107
+ for childWindow in childWindows {
108
+ isClickInHierarchy = isClickInsideWindowHierarchy(window: childWindow, event: event)
109
+ }
110
+ }
114
111
  }
115
112
 
116
- return event
117
- })
118
-
113
+ return isClickInHierarchy
114
+ }
115
+
116
+ var window: NSWindow? = self?.calloutWindow
117
+ while (window?.parent as? CalloutWindow != nil) {
118
+ window = window?.parent
119
+ }
120
+
121
+ if (!isClickInsideWindowHierarchy(window: window, event: event)) {
122
+ self?.dismissCallout()
123
+ }
124
+
125
+ return event
126
+ })
127
+
119
128
  isCalloutWindowShown = true
120
-
121
129
  onShowCallout()
122
130
  }
123
131
 
@@ -139,7 +147,7 @@ class CalloutView: RCTView, CalloutWindowLifeCycleDelegate {
139
147
 
140
148
  NotificationCenter.default.removeObserver(self)
141
149
  mouseEventMonitor.removeMonitor()
142
-
150
+
143
151
  isCalloutWindowShown = false
144
152
  }
145
153
 
@@ -328,7 +336,7 @@ class CalloutView: RCTView, CalloutWindowLifeCycleDelegate {
328
336
  private var anchorView: NSView?
329
337
 
330
338
  /// The view we forward Callout's Children to. It's hosted within the CalloutWindow's
331
- /// view heirarchy, ensuring our React Views are not placed in the main window.
339
+ /// view hierarchy, ensuring our React Views are not placed in the main window.
332
340
  private lazy var proxyView: NSView = {
333
341
  let visualEffectView = FlippedVisualEffectView()
334
342
  visualEffectView.translatesAutoresizingMaskIntoConstraints = false
@@ -363,9 +371,9 @@ class CalloutView: RCTView, CalloutWindowLifeCycleDelegate {
363
371
  }
364
372
  return window
365
373
  }()
366
-
374
+
367
375
  private var mouseEventMonitor = GuardedEventMonitor()
368
-
376
+
369
377
  private var isCalloutWindowShown = false
370
378
  }
371
379
 
@@ -2,28 +2,26 @@
2
2
 
3
3
  /// NSEvent localMonitors are an _old_ API that requires you to do some memory management yourself.
4
4
  /// You _must_ call `removeMonitor`exactly once per monitor created from. This helper class enforces
5
- /// that with the use of an extra boolean to track whether we have already allocated/released our monitor.
5
+ /// we set the reference to nil after `removeMonitor` so that subsequent calls don't cause an over release.
6
+ /// One instance should only be used to allocate and manage one NSEvent monitor.
6
7
  /// https://developer.apple.com/documentation/appkit/nsevent/1533709-removemonitor
7
8
  internal class GuardedEventMonitor: Any {
8
-
9
- private var isMonitorAllocated = false
9
+
10
10
  private var allocatedMonitor: Any?
11
-
12
-
11
+
13
12
  func addLocalMonitorForEvents(matching mask: NSEvent.EventTypeMask, handler block: @escaping (NSEvent) -> NSEvent?) {
14
- if (!isMonitorAllocated) {
13
+ if (allocatedMonitor == nil) {
15
14
  allocatedMonitor = NSEvent.addLocalMonitorForEvents(matching: mask, handler: block)
16
- isMonitorAllocated = true
17
15
  }
18
16
  }
19
-
17
+
20
18
  func removeMonitor() {
21
- if (isMonitorAllocated) {
22
- NSEvent.removeMonitor(allocatedMonitor as Any)
23
- isMonitorAllocated = false
19
+ if let monitor = allocatedMonitor {
20
+ NSEvent.removeMonitor(monitor)
21
+ allocatedMonitor = nil
24
22
  }
25
23
  }
26
-
24
+
27
25
  deinit {
28
26
  removeMonitor()
29
27
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fluentui-react-native/callout",
3
- "version": "0.19.33",
3
+ "version": "0.19.36",
4
4
  "description": "A cross-platform Callout component using the Fluent Design System",
5
5
  "license": "MIT",
6
6
  "author": "",
@@ -27,10 +27,10 @@
27
27
  "dependencies": {
28
28
  "@fluentui-react-native/adapters": "^0.8.4",
29
29
  "@fluentui-react-native/component-cache": "^1.3.1",
30
- "@fluentui-react-native/interactive-hooks": ">=0.14.3 <1.0.0",
30
+ "@fluentui-react-native/interactive-hooks": ">=0.14.5 <1.0.0",
31
31
  "@fluentui-react-native/tokens": ">=0.11.8 <1.0.0",
32
32
  "@uifabricshared/foundation-composable": ">=0.10.2 <1.0.0",
33
- "@uifabricshared/foundation-compose": "^1.11.11",
33
+ "@uifabricshared/foundation-compose": "^1.11.12",
34
34
  "@uifabricshared/foundation-settings": ">=0.11.2 <1.0.0"
35
35
  },
36
36
  "devDependencies": {