@fluentui-react-native/callout 0.19.20 → 0.19.21
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 +16 -1
- package/CHANGELOG.md +10 -2
- package/macos/Callout.swift +33 -28
- package/package.json +1 -1
package/CHANGELOG.json
CHANGED
|
@@ -2,7 +2,22 @@
|
|
|
2
2
|
"name": "@fluentui-react-native/callout",
|
|
3
3
|
"entries": [
|
|
4
4
|
{
|
|
5
|
-
"date": "
|
|
5
|
+
"date": "Fri, 28 Jan 2022 20:52:02 GMT",
|
|
6
|
+
"tag": "@fluentui-react-native/callout_v0.19.21",
|
|
7
|
+
"version": "0.19.21",
|
|
8
|
+
"comments": {
|
|
9
|
+
"patch": [
|
|
10
|
+
{
|
|
11
|
+
"author": "sanajmi@microsoft.com",
|
|
12
|
+
"package": "@fluentui-react-native/callout",
|
|
13
|
+
"commit": "de0a37f48e525af8a22a37be8234731308e585c5",
|
|
14
|
+
"comment": "ContextualMenu macOS: fix focus shifting on click"
|
|
15
|
+
}
|
|
16
|
+
]
|
|
17
|
+
}
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
"date": "Wed, 26 Jan 2022 20:31:04 GMT",
|
|
6
21
|
"tag": "@fluentui-react-native/callout_v0.19.20",
|
|
7
22
|
"version": "0.19.20",
|
|
8
23
|
"comments": {
|
package/CHANGELOG.md
CHANGED
|
@@ -1,12 +1,20 @@
|
|
|
1
1
|
# Change Log - @fluentui-react-native/callout
|
|
2
2
|
|
|
3
|
-
This log was last generated on
|
|
3
|
+
This log was last generated on Fri, 28 Jan 2022 20:52:02 GMT and should not be manually modified.
|
|
4
4
|
|
|
5
5
|
<!-- Start content -->
|
|
6
6
|
|
|
7
|
+
## 0.19.21
|
|
8
|
+
|
|
9
|
+
Fri, 28 Jan 2022 20:52:02 GMT
|
|
10
|
+
|
|
11
|
+
### Patches
|
|
12
|
+
|
|
13
|
+
- ContextualMenu macOS: fix focus shifting on click (sanajmi@microsoft.com)
|
|
14
|
+
|
|
7
15
|
## 0.19.20
|
|
8
16
|
|
|
9
|
-
Wed, 26 Jan 2022 20:
|
|
17
|
+
Wed, 26 Jan 2022 20:31:04 GMT
|
|
10
18
|
|
|
11
19
|
### Patches
|
|
12
20
|
|
package/macos/Callout.swift
CHANGED
|
@@ -58,17 +58,6 @@ class CalloutView: RCTView, CalloutWindowLifeCycleDelegate {
|
|
|
58
58
|
// MARK: RCTComponent Overrides
|
|
59
59
|
|
|
60
60
|
override func insertReactSubview(_ subview: NSView!, at atIndex: Int) {
|
|
61
|
-
/*
|
|
62
|
-
If we attach a touch handler to the proxy view directly, the touch coordinates
|
|
63
|
-
are incorrect and the wrong subview recieves the touch event, most likely
|
|
64
|
-
because macOS screen coordinates have a flipped Y axis. The workaround is to
|
|
65
|
-
attach a separate touch handler to each subview
|
|
66
|
-
*/
|
|
67
|
-
guard let touchHandler = RCTTouchHandler(bridge: bridge) else {
|
|
68
|
-
preconditionFailure("Callout could not create RCTTouchHandler")
|
|
69
|
-
}
|
|
70
|
-
touchHandler.attach(to: subview as? RCTUIView)
|
|
71
|
-
|
|
72
61
|
proxyView.insertReactSubview(subview, at: atIndex)
|
|
73
62
|
}
|
|
74
63
|
|
|
@@ -281,37 +270,53 @@ class CalloutView: RCTView, CalloutWindowLifeCycleDelegate {
|
|
|
281
270
|
|
|
282
271
|
// MARK: Private variables
|
|
283
272
|
|
|
273
|
+
/// The view the Callout is presented from, if anchorRect is nil.
|
|
284
274
|
private var anchorView: NSView?
|
|
285
275
|
|
|
286
|
-
|
|
276
|
+
/// The view we forward Callout's Children to. It's hosted within the CalloutWindow's
|
|
277
|
+
/// view heirarchy, ensuring our React Views are not placed in the main window.
|
|
278
|
+
private lazy var proxyView: NSView = {
|
|
279
|
+
let visualEffectView = FlippedVisualEffectView()
|
|
280
|
+
visualEffectView.translatesAutoresizingMaskIntoConstraints = false
|
|
281
|
+
visualEffectView.material = .menu
|
|
282
|
+
visualEffectView.state = .active
|
|
283
|
+
visualEffectView.wantsLayer = true
|
|
284
|
+
visualEffectView.layer?.cornerRadius = calloutWindowCornerRadius
|
|
285
|
+
|
|
286
|
+
/**
|
|
287
|
+
* We can't directly call touchHandler.attach(to:) because `visualEffectView` is not an RCTUIView.
|
|
288
|
+
* We get around this limitation by just replicating what `attach` did internally: add a gestureRecognizer.
|
|
289
|
+
*/
|
|
290
|
+
guard let touchHandler = RCTTouchHandler(bridge: bridge) else {
|
|
291
|
+
preconditionFailure("Callout could not create RCTTouchHandler")
|
|
292
|
+
}
|
|
293
|
+
visualEffectView.addGestureRecognizer(touchHandler)
|
|
294
|
+
|
|
295
|
+
return visualEffectView
|
|
296
|
+
}()
|
|
287
297
|
|
|
288
298
|
private lazy var calloutWindow: CalloutWindow = {
|
|
289
299
|
let window = CalloutWindow()
|
|
290
300
|
window.lifeCycleDelegate = self
|
|
291
301
|
|
|
292
|
-
let visualEffect = NSVisualEffectView()
|
|
293
|
-
visualEffect.translatesAutoresizingMaskIntoConstraints = false
|
|
294
|
-
visualEffect.material = .menu
|
|
295
|
-
visualEffect.state = .active
|
|
296
|
-
visualEffect.wantsLayer = true
|
|
297
|
-
visualEffect.layer?.cornerRadius = calloutWindowCornerRadius
|
|
298
|
-
|
|
299
302
|
guard let contentView = window.contentView else {
|
|
300
303
|
preconditionFailure("Callout window has no content view")
|
|
301
304
|
}
|
|
302
305
|
|
|
303
|
-
contentView.addSubview(
|
|
304
|
-
|
|
305
|
-
visualEffect.leadingAnchor.constraint(equalTo: contentView.leadingAnchor),
|
|
306
|
-
visualEffect.trailingAnchor.constraint(equalTo: contentView.trailingAnchor),
|
|
307
|
-
visualEffect.topAnchor.constraint(equalTo: contentView.topAnchor),
|
|
308
|
-
visualEffect.bottomAnchor.constraint(equalTo: contentView.bottomAnchor),
|
|
309
|
-
])
|
|
310
|
-
|
|
311
|
-
visualEffect.addSubview(proxyView)
|
|
306
|
+
contentView.addSubview(proxyView)
|
|
307
|
+
window.initialFirstResponder = proxyView
|
|
312
308
|
|
|
313
309
|
return window
|
|
314
310
|
}()
|
|
315
311
|
}
|
|
316
312
|
|
|
313
|
+
/// React Native macOS uses a flipped coordinate space by default. Let's stay consistent and
|
|
314
|
+
/// ensure any views hosting React Native views are also flipped. This helps RCTTouchHandler
|
|
315
|
+
/// register clicks in the right location.
|
|
316
|
+
private class FlippedVisualEffectView: NSVisualEffectView {
|
|
317
|
+
override var isFlipped: Bool {
|
|
318
|
+
return true
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
|
|
317
322
|
private var calloutWindowCornerRadius: CGFloat = 5.0
|