@fluentui-react-native/callout 0.19.2 → 0.19.6

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,67 @@
2
2
  "name": "@fluentui-react-native/callout",
3
3
  "entries": [
4
4
  {
5
- "date": "Fri, 17 Dec 2021 01:23:52 GMT",
5
+ "date": "Fri, 17 Dec 2021 22:42:02 GMT",
6
+ "tag": "@fluentui-react-native/callout_v0.19.6",
7
+ "version": "0.19.6",
8
+ "comments": {
9
+ "patch": [
10
+ {
11
+ "author": "sanajmi@microsoft.com",
12
+ "package": "@fluentui-react-native/callout",
13
+ "commit": "9dc61df83605c035822518c18cc46fb5503dff70",
14
+ "comment": "remove carbon header"
15
+ }
16
+ ]
17
+ }
18
+ },
19
+ {
20
+ "date": "Fri, 17 Dec 2021 22:06:58 GMT",
21
+ "tag": "@fluentui-react-native/callout_v0.19.5",
22
+ "version": "0.19.5",
23
+ "comments": {
24
+ "patch": [
25
+ {
26
+ "author": "beachball",
27
+ "package": "@fluentui-react-native/callout",
28
+ "comment": "Bump @fluentui-react-native/interactive-hooks to v0.11.4",
29
+ "commit": "9dc61df83605c035822518c18cc46fb5503dff70"
30
+ }
31
+ ]
32
+ }
33
+ },
34
+ {
35
+ "date": "Fri, 17 Dec 2021 19:53:21 GMT",
36
+ "tag": "@fluentui-react-native/callout_v0.19.4",
37
+ "version": "0.19.4",
38
+ "comments": {
39
+ "patch": [
40
+ {
41
+ "author": "beachball",
42
+ "package": "@fluentui-react-native/callout",
43
+ "comment": "Bump @fluentui-react-native/interactive-hooks to v0.11.3",
44
+ "commit": "3012e075ca89e36931357442679b73d20540af8b"
45
+ }
46
+ ]
47
+ }
48
+ },
49
+ {
50
+ "date": "Fri, 17 Dec 2021 18:39:08 GMT",
51
+ "tag": "@fluentui-react-native/callout_v0.19.3",
52
+ "version": "0.19.3",
53
+ "comments": {
54
+ "patch": [
55
+ {
56
+ "author": "sanajmi@microsoft.com",
57
+ "package": "@fluentui-react-native/callout",
58
+ "commit": "b7787516d0c417fbe350793713ffce3330c0f4a7",
59
+ "comment": "Documentation fixes"
60
+ }
61
+ ]
62
+ }
63
+ },
64
+ {
65
+ "date": "Fri, 17 Dec 2021 01:26:42 GMT",
6
66
  "tag": "@fluentui-react-native/callout_v0.19.2",
7
67
  "version": "0.19.2",
8
68
  "comments": {
package/CHANGELOG.md CHANGED
@@ -1,12 +1,44 @@
1
1
  # Change Log - @fluentui-react-native/callout
2
2
 
3
- This log was last generated on Fri, 17 Dec 2021 01:23:52 GMT and should not be manually modified.
3
+ This log was last generated on Fri, 17 Dec 2021 22:42:02 GMT and should not be manually modified.
4
4
 
5
5
  <!-- Start content -->
6
6
 
7
+ ## 0.19.6
8
+
9
+ Fri, 17 Dec 2021 22:42:02 GMT
10
+
11
+ ### Patches
12
+
13
+ - remove carbon header (sanajmi@microsoft.com)
14
+
15
+ ## 0.19.5
16
+
17
+ Fri, 17 Dec 2021 22:06:58 GMT
18
+
19
+ ### Patches
20
+
21
+ - Bump @fluentui-react-native/interactive-hooks to v0.11.4
22
+
23
+ ## 0.19.4
24
+
25
+ Fri, 17 Dec 2021 19:53:21 GMT
26
+
27
+ ### Patches
28
+
29
+ - Bump @fluentui-react-native/interactive-hooks to v0.11.3
30
+
31
+ ## 0.19.3
32
+
33
+ Fri, 17 Dec 2021 18:39:08 GMT
34
+
35
+ ### Patches
36
+
37
+ - Documentation fixes (sanajmi@microsoft.com)
38
+
7
39
  ## 0.19.2
8
40
 
9
- Fri, 17 Dec 2021 01:23:52 GMT
41
+ Fri, 17 Dec 2021 01:26:42 GMT
10
42
 
11
43
  ### Patches
12
44
 
@@ -71,8 +71,8 @@ export interface ICalloutTokens extends IBackgroundColorTokens, CalloutBorderTok
71
71
  }
72
72
  export interface ICalloutProps extends IViewProps, ICalloutTokens {
73
73
  /**
74
- * @platform win32
75
74
  * A string that should be announced when the callout is shown.
75
+ * @platform win32
76
76
  */
77
77
  accessibilityOnShowAnnouncement?: string;
78
78
  /**
@@ -80,10 +80,10 @@ export interface ICalloutProps extends IViewProps, ICalloutTokens {
80
80
  */
81
81
  componentRef?: React.RefObject<IFocusable>;
82
82
  /**
83
- * @platform win32
84
83
  * Adds a beak to the Callout, pointing to the anchor target.
85
84
  * Notable Win32 limitation: Beak rendering currently limits the border width to its default, and the
86
85
  * border width prop will not be honored.
86
+ * @platform win32
87
87
  */
88
88
  isBeakVisible?: boolean;
89
89
  /**
@@ -91,7 +91,6 @@ export interface ICalloutProps extends IViewProps, ICalloutTokens {
91
91
  */
92
92
  onDismiss?: () => void;
93
93
  /**
94
- * @platform win32
95
94
  * Callback invoked during callout dismissal; if set, focus will not be restored by the callout and onRestoreFocus must
96
95
  * result in focus being moved to the appropriate focusable target.
97
96
  *
@@ -100,6 +99,7 @@ export interface ICalloutProps extends IViewProps, ICalloutTokens {
100
99
  * this callback is most appropriate for components strictly controlling focus.
101
100
  *
102
101
  * restoreFocusEvent.nativeEvent.containsFocus is true if the Callout had focus while being dismissed.
102
+ * @platform win32
103
103
  */
104
104
  onRestoreFocus?: (restoreFocusEvent: RestoreFocusEvent) => void;
105
105
  /**
@@ -71,8 +71,8 @@ export interface ICalloutTokens extends IBackgroundColorTokens, CalloutBorderTok
71
71
  }
72
72
  export interface ICalloutProps extends IViewProps, ICalloutTokens {
73
73
  /**
74
- * @platform win32
75
74
  * A string that should be announced when the callout is shown.
75
+ * @platform win32
76
76
  */
77
77
  accessibilityOnShowAnnouncement?: string;
78
78
  /**
@@ -80,10 +80,10 @@ export interface ICalloutProps extends IViewProps, ICalloutTokens {
80
80
  */
81
81
  componentRef?: React.RefObject<IFocusable>;
82
82
  /**
83
- * @platform win32
84
83
  * Adds a beak to the Callout, pointing to the anchor target.
85
84
  * Notable Win32 limitation: Beak rendering currently limits the border width to its default, and the
86
85
  * border width prop will not be honored.
86
+ * @platform win32
87
87
  */
88
88
  isBeakVisible?: boolean;
89
89
  /**
@@ -91,7 +91,6 @@ export interface ICalloutProps extends IViewProps, ICalloutTokens {
91
91
  */
92
92
  onDismiss?: () => void;
93
93
  /**
94
- * @platform win32
95
94
  * Callback invoked during callout dismissal; if set, focus will not be restored by the callout and onRestoreFocus must
96
95
  * result in focus being moved to the appropriate focusable target.
97
96
  *
@@ -100,6 +99,7 @@ export interface ICalloutProps extends IViewProps, ICalloutTokens {
100
99
  * this callback is most appropriate for components strictly controlling focus.
101
100
  *
102
101
  * restoreFocusEvent.nativeEvent.containsFocus is true if the Callout had focus while being dismissed.
102
+ * @platform win32
103
103
  */
104
104
  onRestoreFocus?: (restoreFocusEvent: RestoreFocusEvent) => void;
105
105
  /**
@@ -83,12 +83,8 @@ class CalloutView: RCTView, CalloutWindowLifeCycleDelegate {
83
83
 
84
84
  // MARK: WindowLifeCycleDelegate
85
85
 
86
- func didDetectHitOutsideCallout(calloutWindow: CalloutWindow) {
87
- dismissCallout()
88
- }
89
-
90
- func applicationDidResignActiveForCalloutWindow(calloutWindow: CalloutWindow) {
91
- dismissCallout()
86
+ func calloutWillDismiss(window: CalloutWindow) {
87
+ onDismissCallout()
92
88
  }
93
89
 
94
90
  // MARK: Private methods
@@ -96,12 +92,12 @@ class CalloutView: RCTView, CalloutWindowLifeCycleDelegate {
96
92
  private func showCallout() {
97
93
  updateCalloutFrameToAnchor()
98
94
  calloutWindow.makeKeyAndOrderFront(self)
99
- didShowCallout()
95
+ onShowCallout()
100
96
  }
101
97
 
102
98
  private func dismissCallout() {
103
99
  calloutWindow.close()
104
- didDismissCallout()
100
+ onDismissCallout()
105
101
  }
106
102
 
107
103
  /// Sets the frame of the Callout Window (in screen coordinates to be off of the Anchor on the preferred edge
@@ -268,11 +264,11 @@ class CalloutView: RCTView, CalloutWindowLifeCycleDelegate {
268
264
  return calloutScreenRect
269
265
  }
270
266
 
271
- private func didShowCallout() {
267
+ private func onShowCallout() {
272
268
  onShow?([:])
273
269
  }
274
270
 
275
- private func didDismissCallout() {
271
+ private func onDismissCallout() {
276
272
  if let onDismiss = onDismiss {
277
273
  guard let reactTag = reactTag else {
278
274
  preconditionFailure("React Tag missing")
@@ -286,11 +282,11 @@ class CalloutView: RCTView, CalloutWindowLifeCycleDelegate {
286
282
 
287
283
  private var anchorView: NSView?
288
284
 
289
- private var proxyView: RCTView = RCTView()
285
+ private var proxyView = RCTView()
290
286
 
291
287
  private lazy var calloutWindow: CalloutWindow = {
292
288
  let window = CalloutWindow()
293
- window.windowLifeCycleDelegate = self
289
+ window.lifeCycleDelegate = self
294
290
 
295
291
  let visualEffect = NSVisualEffectView()
296
292
  visualEffect.translatesAutoresizingMaskIntoConstraints = false
@@ -1,41 +1,37 @@
1
1
  import Foundation
2
2
  import AppKit
3
3
 
4
- protocol CalloutWindowLifeCycleDelegate {
5
- /*
6
- * Notify the CalloutWindowLifeCycle object that the user touched/clicked outside the bounds of the callout.
7
- */
8
- func didDetectHitOutsideCallout(calloutWindow: CalloutWindow)
9
-
10
- /*
11
- * Notify the CalloutWindowLifeCycle object that the window the callout is in is no longer active.
12
- */
13
- func applicationDidResignActiveForCalloutWindow(calloutWindow: CalloutWindow)
4
+ protocol CalloutWindowLifeCycleDelegate: AnyObject {
5
+ /// Notify the delegate that the Callout is about to dismiss
6
+ func calloutWillDismiss(window: CalloutWindow)
14
7
  }
15
8
 
16
9
  class CalloutWindow: NSWindow {
17
10
 
18
- public var windowLifeCycleDelegate: CalloutWindowLifeCycleDelegate?
11
+ weak var lifeCycleDelegate: CalloutWindowLifeCycleDelegate?
19
12
 
20
13
  override init(contentRect: NSRect, styleMask style: NSWindow.StyleMask, backing backingStoreType: NSWindow.BackingStoreType, defer flag: Bool) {
21
14
  super.init(contentRect: contentRect, styleMask: style, backing: backingStoreType, defer: flag)
22
- isReleasedWhenClosed = true
15
+ isReleasedWhenClosed = false
23
16
 
24
17
  styleMask = .borderless
25
18
  level = .popUpMenu
26
19
  backgroundColor = .clear
27
20
  isMovable = false
28
21
 
29
- NotificationCenter.default.addObserver(self, selector: #selector(appDidChangeActive(notification:)), name: NSApplication.didResignActiveNotification, object: nil)
22
+ // Dismiss the Callout if the window is no longer active.
23
+ NotificationCenter.default.addObserver(self, selector: #selector(dismissCallout), name: NSApplication.didResignActiveNotification, object: nil)
30
24
 
31
- mouseEventMonitor = NSEvent.addLocalMonitorForEvents(matching: .leftMouseUp, handler: { (event) -> NSEvent? in
25
+ // Dismiss the Callout if the user touched/clicked outside the bounds of the callout.
26
+ mouseEventMonitor = NSEvent.addLocalMonitorForEvents(matching: .leftMouseUp, handler: { [weak self] (event) -> NSEvent? in
32
27
  if (event.window != self) {
33
- self.windowLifeCycleDelegate?.didDetectHitOutsideCallout(calloutWindow: self)
28
+ self?.dismissCallout()
34
29
  }
35
30
  return event
36
31
  })
37
32
  }
38
33
 
34
+ // Required to get a key view loop in the window
39
35
  override var canBecomeKey: Bool {
40
36
  return true
41
37
  }
@@ -44,9 +40,15 @@ class CalloutWindow: NSWindow {
44
40
  return false
45
41
  }
46
42
 
47
- @objc func appDidChangeActive(notification: NSNotification) {
48
- windowLifeCycleDelegate?.applicationDidResignActiveForCalloutWindow(calloutWindow: self)
43
+ // Required to close the window on escape key press
44
+ override func cancelOperation(_ sender: Any?) {
45
+ dismissCallout()
46
+ }
47
+
48
+ @objc private func dismissCallout() {
49
+ lifeCycleDelegate?.calloutWillDismiss(window: self)
50
+ close()
49
51
  }
50
52
 
51
53
  private var mouseEventMonitor: Any?
52
- }
54
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fluentui-react-native/callout",
3
- "version": "0.19.2",
3
+ "version": "0.19.6",
4
4
  "description": "A cross-platform Callout component using the Fluent Design System",
5
5
  "license": "MIT",
6
6
  "author": "",
@@ -22,7 +22,7 @@
22
22
  "dependencies": {
23
23
  "@fluentui-react-native/adapters": "^0.8.1",
24
24
  "@fluentui-react-native/component-cache": "^1.3.0",
25
- "@fluentui-react-native/interactive-hooks": ">=0.11.2 <1.0.0",
25
+ "@fluentui-react-native/interactive-hooks": ">=0.11.4 <1.0.0",
26
26
  "@fluentui-react-native/tokens": ">=0.11.1 <1.0.0",
27
27
  "@uifabricshared/foundation-composable": ">=0.10.0 <1.0.0",
28
28
  "@uifabricshared/foundation-compose": "^1.11.2",
@@ -100,8 +100,8 @@ export interface ICalloutTokens extends IBackgroundColorTokens, CalloutBorderTok
100
100
 
101
101
  export interface ICalloutProps extends IViewProps, ICalloutTokens {
102
102
  /**
103
- * @platform win32
104
103
  * A string that should be announced when the callout is shown.
104
+ * @platform win32
105
105
  */
106
106
  accessibilityOnShowAnnouncement?: string;
107
107
 
@@ -111,10 +111,10 @@ export interface ICalloutProps extends IViewProps, ICalloutTokens {
111
111
  componentRef?: React.RefObject<IFocusable>;
112
112
 
113
113
  /**
114
- * @platform win32
115
114
  * Adds a beak to the Callout, pointing to the anchor target.
116
115
  * Notable Win32 limitation: Beak rendering currently limits the border width to its default, and the
117
116
  * border width prop will not be honored.
117
+ * @platform win32
118
118
  */
119
119
  isBeakVisible?: boolean;
120
120
 
@@ -124,7 +124,6 @@ export interface ICalloutProps extends IViewProps, ICalloutTokens {
124
124
  onDismiss?: () => void;
125
125
 
126
126
  /**
127
- * @platform win32
128
127
  * Callback invoked during callout dismissal; if set, focus will not be restored by the callout and onRestoreFocus must
129
128
  * result in focus being moved to the appropriate focusable target.
130
129
  *
@@ -133,6 +132,7 @@ export interface ICalloutProps extends IViewProps, ICalloutTokens {
133
132
  * this callback is most appropriate for components strictly controlling focus.
134
133
  *
135
134
  * restoreFocusEvent.nativeEvent.containsFocus is true if the Callout had focus while being dismissed.
135
+ * @platform win32
136
136
  */
137
137
  onRestoreFocus?: (restoreFocusEvent: RestoreFocusEvent) => void;
138
138