@fluentui-react-native/callout 0.29.5 → 0.29.7
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.md +18 -0
- package/README.md +18 -0
- package/lib/index.d.ts +2 -3
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +1 -2
- package/lib/index.js.map +1 -1
- package/package.json +12 -27
- package/src/index.ts +2 -3
- package/.cache/tsconfig.tsbuildinfo +0 -1
- package/FRNCallout.podspec +0 -24
- package/NuGet.config +0 -10
- package/SPEC.md +0 -46
- package/jest.config.cjs +0 -1
- package/lib/Callout.d.ts +0 -6
- package/lib/Callout.d.ts.map +0 -1
- package/lib/Callout.js +0 -64
- package/lib/Callout.js.map +0 -1
- package/lib/Callout.types.d.ts +0 -85
- package/lib/Callout.types.d.ts.map +0 -1
- package/lib/Callout.types.js +0 -2
- package/lib/Callout.types.js.map +0 -1
- package/lib/CalloutNativeComponent.d.ts +0 -49
- package/lib/CalloutNativeComponent.d.ts.map +0 -1
- package/lib/CalloutNativeComponent.js +0 -9
- package/lib/CalloutNativeComponent.js.map +0 -1
- package/lib/__tests__/Callout.test.d.ts +0 -2
- package/lib/__tests__/Callout.test.d.ts.map +0 -1
- package/lib/__tests__/Callout.test.js +0 -96
- package/lib/__tests__/Callout.test.js.map +0 -1
- package/lib/__tests__/Callout.types.test.d.ts +0 -2
- package/lib/__tests__/Callout.types.test.d.ts.map +0 -1
- package/lib/__tests__/Callout.types.test.js +0 -21
- package/lib/__tests__/Callout.types.test.js.map +0 -1
- package/macos/CalloutManager.swift +0 -16
- package/macos/CalloutView.swift +0 -454
- package/macos/CalloutWindow.swift +0 -40
- package/macos/FRNCallout.h +0 -14
- package/macos/FRNCalloutManager.h +0 -5
- package/macos/FRNCalloutManager.m +0 -76
- package/macos/FlippedVisualEffectView.swift +0 -10
- package/macos/GuardedEventMonitor.swift +0 -28
- package/macos/RCTCalloutComponentView.h +0 -12
- package/macos/RCTCalloutComponentView.mm +0 -209
- package/react-native.config.cjs +0 -15
- package/src/Callout.stories.tsx +0 -276
- package/src/Callout.tsx +0 -111
- package/src/Callout.types.ts +0 -106
- package/src/CalloutNativeComponent.ts +0 -74
- package/src/__tests__/Callout.test.tsx +0 -157
- package/src/__tests__/Callout.types.test.ts +0 -30
- package/src/__tests__/__snapshots__/Callout.test.tsx.snap +0 -11
- package/tsconfig.json +0 -19
- package/windows/Callout/Callout.cpp +0 -420
- package/windows/Callout/Callout.def +0 -3
- package/windows/Callout/Callout.h +0 -25
- package/windows/Callout/Callout.vcxproj +0 -152
- package/windows/Callout/ReactPackageProvider.cpp +0 -25
- package/windows/Callout/ReactPackageProvider.h +0 -25
- package/windows/Callout/ReactPackageProvider.idl +0 -12
- package/windows/Callout/codegen/.clang-format +0 -2
- package/windows/Callout/codegen/react/components/FRNCalloutSpec/Callout.g.h +0 -375
- package/windows/Callout/packages.lock.json +0 -151
- package/windows/Callout/pch.cpp +0 -1
- package/windows/Callout/pch.h +0 -28
- package/windows/ExperimentalFeatures.props +0 -33
- package/windows/NuGet.Config +0 -13
|
@@ -1,420 +0,0 @@
|
|
|
1
|
-
// Copyright (c) Microsoft Corporation.
|
|
2
|
-
// Licensed under the MIT License.
|
|
3
|
-
#include "pch.h"
|
|
4
|
-
|
|
5
|
-
#include "Callout.h"
|
|
6
|
-
|
|
7
|
-
#include <winrt/Microsoft.UI.Content.h>
|
|
8
|
-
#include <winrt/Microsoft.UI.Input.h>
|
|
9
|
-
#include <winrt/Microsoft.UI.Windowing.h>
|
|
10
|
-
#include <winrt/Microsoft.UI.interop.h>
|
|
11
|
-
#include <winrt/Windows.System.h>
|
|
12
|
-
|
|
13
|
-
namespace winrt::FluentUI::Callout {
|
|
14
|
-
|
|
15
|
-
enum class DirectionalHint {
|
|
16
|
-
LeftTopEdge,
|
|
17
|
-
LeftCenter,
|
|
18
|
-
LeftBottomEdge,
|
|
19
|
-
TopLeftEdge,
|
|
20
|
-
TopAutoEdge,
|
|
21
|
-
TopCenter,
|
|
22
|
-
TopRightEdge,
|
|
23
|
-
RightTopEdge,
|
|
24
|
-
RightCenter,
|
|
25
|
-
RightBottomEdge,
|
|
26
|
-
BottomLeftEdge,
|
|
27
|
-
BottomAutoEdge,
|
|
28
|
-
BottomCenter,
|
|
29
|
-
BottomRightEdge
|
|
30
|
-
};
|
|
31
|
-
|
|
32
|
-
DirectionalHint parseDirectionHint(std::string &directionHint) {
|
|
33
|
-
if (directionHint == "leftTopEdge") {
|
|
34
|
-
return DirectionalHint::LeftTopEdge;
|
|
35
|
-
} else if (directionHint == "leftCenter") {
|
|
36
|
-
return DirectionalHint::LeftCenter;
|
|
37
|
-
} else if (directionHint == "leftBottomEdge") {
|
|
38
|
-
return DirectionalHint::LeftBottomEdge;
|
|
39
|
-
} else if (directionHint == "topLeftEdge") {
|
|
40
|
-
return DirectionalHint::TopLeftEdge;
|
|
41
|
-
} else if (directionHint == "topAutoEdge") {
|
|
42
|
-
return DirectionalHint::TopAutoEdge;
|
|
43
|
-
} else if (directionHint == "topCenter") {
|
|
44
|
-
return DirectionalHint::TopCenter;
|
|
45
|
-
} else if (directionHint == "topRightEdge") {
|
|
46
|
-
return DirectionalHint::TopRightEdge;
|
|
47
|
-
} else if (directionHint == "rightTopEdge") {
|
|
48
|
-
return DirectionalHint::RightTopEdge;
|
|
49
|
-
} else if (directionHint == "rightCenter") {
|
|
50
|
-
return DirectionalHint::RightCenter;
|
|
51
|
-
} else if (directionHint == "rightBottomEdge") {
|
|
52
|
-
return DirectionalHint::RightBottomEdge;
|
|
53
|
-
} else if (directionHint == "bottomLeftEdge") {
|
|
54
|
-
return DirectionalHint::BottomLeftEdge;
|
|
55
|
-
} else if (directionHint == "bottomAutoEdge") {
|
|
56
|
-
return DirectionalHint::BottomAutoEdge;
|
|
57
|
-
} else if (directionHint == "bottomCenter") {
|
|
58
|
-
return DirectionalHint::BottomCenter;
|
|
59
|
-
} else if (directionHint == "bottomRightEdge") {
|
|
60
|
-
return DirectionalHint::BottomRightEdge;
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
return DirectionalHint::LeftTopEdge;
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
struct CalloutComponentView
|
|
67
|
-
: public winrt::implements<CalloutComponentView,
|
|
68
|
-
winrt::Windows::Foundation::IInspectable>,
|
|
69
|
-
Codegen::BaseCallout<CalloutComponentView> {
|
|
70
|
-
~CalloutComponentView() {
|
|
71
|
-
if (m_popup && !m_popup.IsClosed()) {
|
|
72
|
-
/*
|
|
73
|
-
// Unregister closing event handler
|
|
74
|
-
if (m_appWindowClosingToken)
|
|
75
|
-
{
|
|
76
|
-
m_rnWindow.AppWindow().Closing(m_appWindowClosingToken);
|
|
77
|
-
m_appWindowClosingToken = {};
|
|
78
|
-
}
|
|
79
|
-
*/
|
|
80
|
-
|
|
81
|
-
// Hide popup
|
|
82
|
-
if (m_popup.IsVisible()) {
|
|
83
|
-
m_popup.Hide();
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
if (m_rnWindow.AppWindow()) {
|
|
87
|
-
m_rnWindow.Close();
|
|
88
|
-
m_rnWindow = nullptr;
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
// Close bridge
|
|
92
|
-
m_popup.Close();
|
|
93
|
-
m_popup = nullptr;
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
void UpdateProps(const winrt::Microsoft::ReactNative::ComponentView &view,
|
|
98
|
-
const winrt::com_ptr<Codegen::CalloutProps> &newProps,
|
|
99
|
-
const winrt::com_ptr<Codegen::CalloutProps>
|
|
100
|
-
&oldProps) noexcept override {
|
|
101
|
-
if (!oldProps || newProps->directionalHint != oldProps->directionalHint) {
|
|
102
|
-
m_directionalHint =
|
|
103
|
-
newProps->directionalHint
|
|
104
|
-
? parseDirectionHint(newProps->directionalHint.value())
|
|
105
|
-
: DirectionalHint::LeftTopEdge;
|
|
106
|
-
|
|
107
|
-
auto portal = view.as<
|
|
108
|
-
winrt::Microsoft::ReactNative::Composition::PortalComponentView>();
|
|
109
|
-
if (portal.ContentRoot().Children().Size() != 0) {
|
|
110
|
-
AdjustWindowSize(
|
|
111
|
-
portal.ContentRoot().Children().GetAt(0).LayoutMetrics());
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
__super::UpdateProps(view, newProps, oldProps);
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
void InitializePortalViewComponent(
|
|
119
|
-
const winrt::Microsoft::ReactNative::Composition::PortalComponentView
|
|
120
|
-
&portalComponentView) noexcept {
|
|
121
|
-
m_reactContext = portalComponentView.ReactContext();
|
|
122
|
-
|
|
123
|
-
portalComponentView.Mounted([](const auto & /*sender*/, const auto &view) {
|
|
124
|
-
view.UserData().as<CalloutComponentView>()->OnMounted(view);
|
|
125
|
-
});
|
|
126
|
-
portalComponentView.Unmounted(
|
|
127
|
-
[](const auto & /*sender*/, const auto &view) {
|
|
128
|
-
view.UserData().as<CalloutComponentView>()->OnUnmounted(view);
|
|
129
|
-
});
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
void HandleFocusWindowCommand() noexcept override {
|
|
133
|
-
// nyi
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
// You must provide an implementation of this method to handle the
|
|
137
|
-
// "blurWindow" command
|
|
138
|
-
void HandleBlurWindowCommand() noexcept override {
|
|
139
|
-
// nyi
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
void MountChildComponentView(
|
|
143
|
-
const winrt::Microsoft::ReactNative::ComponentView & /*view*/,
|
|
144
|
-
const winrt::Microsoft::ReactNative::MountChildComponentViewArgs
|
|
145
|
-
&args) noexcept override {
|
|
146
|
-
AdjustWindowSize(args.Child().LayoutMetrics());
|
|
147
|
-
// TODO These asserts are currently hit if the root view of the callout is collapsed.
|
|
148
|
-
// Need to handle this case
|
|
149
|
-
// assert(args.Index() == 0);
|
|
150
|
-
// assert(!m_childLayoutMetricsToken);
|
|
151
|
-
m_childLayoutMetricsToken = args.Child().LayoutMetricsChanged(
|
|
152
|
-
[wkThis = get_weak()](
|
|
153
|
-
auto &/*sender*/,
|
|
154
|
-
const winrt::Microsoft::ReactNative::LayoutMetricsChangedArgs
|
|
155
|
-
&layoutMetricsChangedArgs) {
|
|
156
|
-
if (auto strongThis = wkThis.get()) {
|
|
157
|
-
strongThis->AdjustWindowSize(
|
|
158
|
-
layoutMetricsChangedArgs.NewLayoutMetrics());
|
|
159
|
-
}
|
|
160
|
-
});
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
void UnmountChildComponentView(
|
|
164
|
-
const winrt::Microsoft::ReactNative::ComponentView & /*view*/,
|
|
165
|
-
const winrt::Microsoft::ReactNative::UnmountChildComponentViewArgs
|
|
166
|
-
&args) noexcept override {
|
|
167
|
-
// TODO These asserts are currently hit if the root view of the callout is collapsed.
|
|
168
|
-
// Need to handle this case
|
|
169
|
-
// assert(args.Index() == 0);
|
|
170
|
-
// assert(m_childLayoutMetricsToken);
|
|
171
|
-
args.Child().LayoutMetricsChanged(m_childLayoutMetricsToken);
|
|
172
|
-
// m_childLayoutMetricsToken.value = 0;
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
private:
|
|
176
|
-
void
|
|
177
|
-
OnMounted(const winrt::Microsoft::ReactNative::ComponentView &view) noexcept {
|
|
178
|
-
assert(!m_mounted);
|
|
179
|
-
m_mounted = true;
|
|
180
|
-
|
|
181
|
-
CreatePopup(view);
|
|
182
|
-
|
|
183
|
-
m_showQueued = true;
|
|
184
|
-
|
|
185
|
-
m_reactContext.UIDispatcher().Post(
|
|
186
|
-
[wkThis = get_weak(), wkView = winrt::weak_ref(view)]() {
|
|
187
|
-
if (auto strongThis = wkThis.get()) {
|
|
188
|
-
strongThis->m_showQueued = false;
|
|
189
|
-
|
|
190
|
-
if (!strongThis->m_mounted) {
|
|
191
|
-
return;
|
|
192
|
-
}
|
|
193
|
-
if (auto v = wkView.get()) {
|
|
194
|
-
strongThis->Show();
|
|
195
|
-
}
|
|
196
|
-
}
|
|
197
|
-
});
|
|
198
|
-
}
|
|
199
|
-
|
|
200
|
-
void OnUnmounted(
|
|
201
|
-
const winrt::Microsoft::ReactNative::ComponentView & /*view*/) noexcept {
|
|
202
|
-
assert(m_mounted);
|
|
203
|
-
m_mounted = false;
|
|
204
|
-
}
|
|
205
|
-
|
|
206
|
-
void OnLightDismissDismissed(
|
|
207
|
-
const winrt::Microsoft::UI::Input::InputLightDismissAction &,
|
|
208
|
-
const winrt::Microsoft::UI::Input::InputLightDismissEventArgs &) {
|
|
209
|
-
HidePopup();
|
|
210
|
-
}
|
|
211
|
-
|
|
212
|
-
void HidePopup() {
|
|
213
|
-
if (!m_popup)
|
|
214
|
-
return;
|
|
215
|
-
m_popup.Hide();
|
|
216
|
-
if (auto eventEmitter = EventEmitter())
|
|
217
|
-
eventEmitter->onDismiss({});
|
|
218
|
-
}
|
|
219
|
-
|
|
220
|
-
void CreatePopup(
|
|
221
|
-
const winrt::Microsoft::ReactNative::ComponentView &view) noexcept {
|
|
222
|
-
if (m_popup)
|
|
223
|
-
return;
|
|
224
|
-
|
|
225
|
-
auto portal = view.as<
|
|
226
|
-
winrt::Microsoft::ReactNative::Composition::PortalComponentView>();
|
|
227
|
-
m_popup = winrt::Microsoft::UI::Content::DesktopPopupSiteBridge::Create(
|
|
228
|
-
portal.Parent()
|
|
229
|
-
.as<winrt::Microsoft::ReactNative::Composition::ComponentView>()
|
|
230
|
-
.Root()
|
|
231
|
-
.ReactNativeIsland()
|
|
232
|
-
.Island());
|
|
233
|
-
|
|
234
|
-
assert(!m_rnWindow);
|
|
235
|
-
m_rnWindow = winrt::Microsoft::ReactNative::ReactNativeWindow::
|
|
236
|
-
CreateFromContentSiteBridgeAndIsland(
|
|
237
|
-
m_popup,
|
|
238
|
-
winrt::Microsoft::ReactNative::ReactNativeIsland::CreatePortal(
|
|
239
|
-
portal));
|
|
240
|
-
m_rnWindow.ResizePolicy(
|
|
241
|
-
winrt::Microsoft::ReactNative::ContentSizePolicy::None);
|
|
242
|
-
|
|
243
|
-
auto inputLightDismissAction =
|
|
244
|
-
winrt::Microsoft::UI::Input::InputLightDismissAction::GetForWindowId(
|
|
245
|
-
m_rnWindow.AppWindow().Id());
|
|
246
|
-
inputLightDismissAction.Dismissed(
|
|
247
|
-
{get_weak(), &CalloutComponentView::OnLightDismissDismissed});
|
|
248
|
-
|
|
249
|
-
if (portal.ContentRoot().Children().Size()) {
|
|
250
|
-
AdjustWindowSize(
|
|
251
|
-
portal.ContentRoot().Children().GetAt(0).LayoutMetrics());
|
|
252
|
-
}
|
|
253
|
-
}
|
|
254
|
-
|
|
255
|
-
void RegisterLightDismissAction() noexcept {}
|
|
256
|
-
|
|
257
|
-
void Show() noexcept {
|
|
258
|
-
m_popup.Show();
|
|
259
|
-
|
|
260
|
-
winrt::Microsoft::UI::Input::InputFocusController::GetForIsland(
|
|
261
|
-
m_rnWindow.ReactNativeIsland().Island())
|
|
262
|
-
.TrySetFocus();
|
|
263
|
-
m_rnWindow.ReactNativeIsland().NavigateFocus(
|
|
264
|
-
winrt::Microsoft::ReactNative::FocusNavigationRequest::
|
|
265
|
-
FocusNavigationRequest(
|
|
266
|
-
winrt::Microsoft::ReactNative::FocusNavigationReason::First));
|
|
267
|
-
|
|
268
|
-
if (auto eventEmitter = EventEmitter()) {
|
|
269
|
-
eventEmitter->onShow({});
|
|
270
|
-
}
|
|
271
|
-
}
|
|
272
|
-
|
|
273
|
-
void AdjustWindowSize(const winrt::Microsoft::ReactNative::LayoutMetrics
|
|
274
|
-
&layoutMetrics) noexcept {
|
|
275
|
-
if (!m_rnWindow) {
|
|
276
|
-
return;
|
|
277
|
-
}
|
|
278
|
-
|
|
279
|
-
if (layoutMetrics.Frame.Width == 0 && layoutMetrics.Frame.Height == 0) {
|
|
280
|
-
return;
|
|
281
|
-
}
|
|
282
|
-
|
|
283
|
-
// Calculate physical pixels from DIPs
|
|
284
|
-
int32_t clientWidthPx = static_cast<int32_t>(
|
|
285
|
-
layoutMetrics.Frame.Width * layoutMetrics.PointScaleFactor);
|
|
286
|
-
int32_t clientHeightPx = static_cast<int32_t>(
|
|
287
|
-
layoutMetrics.Frame.Height * layoutMetrics.PointScaleFactor);
|
|
288
|
-
|
|
289
|
-
// Size the client area directly
|
|
290
|
-
m_rnWindow.AppWindow().ResizeClient({clientWidthPx, clientHeightPx});
|
|
291
|
-
|
|
292
|
-
// Target can be either a view tag of a view to anchor to, or a string for
|
|
293
|
-
// an anchor id
|
|
294
|
-
if (Props()->target.Type() ==
|
|
295
|
-
winrt::Microsoft::ReactNative::JSValueType::Int64) {
|
|
296
|
-
auto targetView = winrt::Microsoft::ReactNative::Composition::
|
|
297
|
-
CompositionUIService::ComponentFromReactTag(
|
|
298
|
-
m_reactContext.Handle(), Props()->target.AsInt64());
|
|
299
|
-
auto targetPos = ViewToScreenOffset(targetView);
|
|
300
|
-
auto targetScaleFactor =
|
|
301
|
-
targetView.LayoutMetrics().PointScaleFactor;
|
|
302
|
-
auto targetWidthPx = static_cast<int32_t>(
|
|
303
|
-
targetView.LayoutMetrics().Frame.Width * targetScaleFactor);
|
|
304
|
-
auto targetHeightPx = static_cast<int32_t>(
|
|
305
|
-
targetView.LayoutMetrics().Frame.Height * targetScaleFactor);
|
|
306
|
-
auto targetRight = targetPos.X + targetWidthPx;
|
|
307
|
-
auto targetBottom = targetPos.Y + targetHeightPx;
|
|
308
|
-
auto targetCenterX = targetPos.X + targetWidthPx / 2;
|
|
309
|
-
auto targetCenterY = targetPos.Y + targetHeightPx / 2;
|
|
310
|
-
|
|
311
|
-
POINT anchorPoint{targetPos.X, targetPos.Y};
|
|
312
|
-
SIZE windowSize{clientWidthPx, clientHeightPx};
|
|
313
|
-
|
|
314
|
-
RECT excludeRect{targetPos.X, targetPos.Y, targetRight, targetBottom};
|
|
315
|
-
|
|
316
|
-
UINT flags = 0;
|
|
317
|
-
|
|
318
|
-
if (m_directionalHint == DirectionalHint::LeftTopEdge) {
|
|
319
|
-
anchorPoint = {targetPos.X, targetPos.Y};
|
|
320
|
-
flags = TPM_RIGHTALIGN | TPM_TOPALIGN | TPM_HORIZONTAL;
|
|
321
|
-
} else if (m_directionalHint == DirectionalHint::LeftCenter) {
|
|
322
|
-
anchorPoint = {targetPos.X, targetCenterY};
|
|
323
|
-
flags = TPM_RIGHTALIGN | TPM_VCENTERALIGN | TPM_HORIZONTAL;
|
|
324
|
-
} else if (m_directionalHint == DirectionalHint::LeftBottomEdge) {
|
|
325
|
-
anchorPoint = {targetPos.X, targetBottom};
|
|
326
|
-
flags = TPM_RIGHTALIGN | TPM_BOTTOMALIGN | TPM_HORIZONTAL;
|
|
327
|
-
} else if (m_directionalHint == DirectionalHint::TopLeftEdge) {
|
|
328
|
-
anchorPoint = {targetPos.X, targetPos.Y};
|
|
329
|
-
flags = TPM_LEFTALIGN | TPM_BOTTOMALIGN | TPM_VERTICAL;
|
|
330
|
-
} else if (m_directionalHint == DirectionalHint::TopAutoEdge) {
|
|
331
|
-
anchorPoint = {targetPos.X, targetPos.Y};
|
|
332
|
-
flags = TPM_LEFTALIGN | TPM_BOTTOMALIGN | TPM_VERTICAL;
|
|
333
|
-
} else if (m_directionalHint == DirectionalHint::TopCenter) {
|
|
334
|
-
anchorPoint = {targetCenterX, targetPos.Y};
|
|
335
|
-
flags = TPM_CENTERALIGN | TPM_BOTTOMALIGN | TPM_VERTICAL;
|
|
336
|
-
} else if (m_directionalHint == DirectionalHint::TopRightEdge) {
|
|
337
|
-
anchorPoint = {targetRight, targetPos.Y};
|
|
338
|
-
flags = TPM_RIGHTALIGN | TPM_BOTTOMALIGN | TPM_VERTICAL;
|
|
339
|
-
} else if (m_directionalHint == DirectionalHint::RightTopEdge) {
|
|
340
|
-
anchorPoint = {targetRight, targetPos.Y};
|
|
341
|
-
flags = TPM_LEFTALIGN | TPM_TOPALIGN | TPM_HORIZONTAL;
|
|
342
|
-
} else if (m_directionalHint == DirectionalHint::RightCenter) {
|
|
343
|
-
anchorPoint = {targetRight, targetCenterY};
|
|
344
|
-
flags = TPM_LEFTALIGN | TPM_VCENTERALIGN | TPM_HORIZONTAL;
|
|
345
|
-
} else if (m_directionalHint == DirectionalHint::RightBottomEdge) {
|
|
346
|
-
anchorPoint = {targetRight, targetBottom};
|
|
347
|
-
flags = TPM_LEFTALIGN | TPM_BOTTOMALIGN | TPM_HORIZONTAL;
|
|
348
|
-
} else if (m_directionalHint == DirectionalHint::BottomLeftEdge) {
|
|
349
|
-
anchorPoint = {targetPos.X, targetBottom};
|
|
350
|
-
flags = TPM_LEFTALIGN | TPM_TOPALIGN | TPM_VERTICAL;
|
|
351
|
-
} else if (m_directionalHint == DirectionalHint::BottomAutoEdge) {
|
|
352
|
-
anchorPoint = {targetPos.X, targetBottom};
|
|
353
|
-
flags = TPM_LEFTALIGN | TPM_TOPALIGN | TPM_VERTICAL;
|
|
354
|
-
} else if (m_directionalHint == DirectionalHint::BottomCenter) {
|
|
355
|
-
anchorPoint = {targetCenterX, targetBottom};
|
|
356
|
-
flags = TPM_CENTERALIGN | TPM_TOPALIGN | TPM_VERTICAL;
|
|
357
|
-
} else if (m_directionalHint == DirectionalHint::BottomRightEdge) {
|
|
358
|
-
anchorPoint = {targetRight, targetBottom};
|
|
359
|
-
flags = TPM_RIGHTALIGN | TPM_TOPALIGN | TPM_VERTICAL;
|
|
360
|
-
}
|
|
361
|
-
|
|
362
|
-
flags |= TPM_WORKAREA;
|
|
363
|
-
|
|
364
|
-
RECT finalPos;
|
|
365
|
-
|
|
366
|
-
CalculatePopupWindowPosition(&anchorPoint, &windowSize, flags,
|
|
367
|
-
&excludeRect, &finalPos);
|
|
368
|
-
|
|
369
|
-
m_rnWindow.AppWindow().Move({finalPos.left, finalPos.top});
|
|
370
|
-
} else {
|
|
371
|
-
// TODO target named anchors
|
|
372
|
-
m_rnWindow.AppWindow().Move({0, 0});
|
|
373
|
-
}
|
|
374
|
-
};
|
|
375
|
-
|
|
376
|
-
winrt::Windows::Graphics::PointInt32
|
|
377
|
-
ViewToScreenOffset(const winrt::Microsoft::ReactNative::ComponentView &view) {
|
|
378
|
-
winrt::Windows::Foundation::Point pt{
|
|
379
|
-
(view.LayoutMetrics().Frame.X) * view.LayoutMetrics().PointScaleFactor,
|
|
380
|
-
(view.LayoutMetrics().Frame.Y) * view.LayoutMetrics().PointScaleFactor};
|
|
381
|
-
|
|
382
|
-
for (auto p = view.Parent(); p; p = p.Parent()) {
|
|
383
|
-
pt.X += p.LayoutMetrics().Frame.X * p.LayoutMetrics().PointScaleFactor;
|
|
384
|
-
pt.Y += p.LayoutMetrics().Frame.Y * p.LayoutMetrics().PointScaleFactor;
|
|
385
|
-
}
|
|
386
|
-
|
|
387
|
-
auto root =
|
|
388
|
-
view.as<winrt::Microsoft::ReactNative::Composition::ComponentView>()
|
|
389
|
-
.Root();
|
|
390
|
-
auto cc = root.ReactNativeIsland().Island().CoordinateConverter();
|
|
391
|
-
return cc.ConvertLocalToScreen(pt);
|
|
392
|
-
}
|
|
393
|
-
|
|
394
|
-
DirectionalHint m_directionalHint{DirectionalHint::LeftTopEdge};
|
|
395
|
-
bool m_showQueued{false};
|
|
396
|
-
bool m_mounted{false};
|
|
397
|
-
winrt::event_token m_childLayoutMetricsToken;
|
|
398
|
-
winrt::Microsoft::UI::Content::DesktopPopupSiteBridge m_popup{nullptr};
|
|
399
|
-
winrt::Microsoft::ReactNative::ReactNativeWindow m_rnWindow{nullptr};
|
|
400
|
-
winrt::Microsoft::ReactNative::ReactContext m_reactContext{nullptr};
|
|
401
|
-
};
|
|
402
|
-
|
|
403
|
-
} // namespace winrt::FluentUI::Callout
|
|
404
|
-
|
|
405
|
-
void RegisterCalloutComponentView(
|
|
406
|
-
winrt::Microsoft::ReactNative::IReactPackageBuilder const &packageBuilder) {
|
|
407
|
-
winrt::FluentUI::Callout::Codegen::RegisterCalloutNativeComponent<
|
|
408
|
-
winrt::FluentUI::Callout::CalloutComponentView>(
|
|
409
|
-
packageBuilder, [](const winrt::Microsoft::ReactNative::Composition::
|
|
410
|
-
IReactCompositionViewComponentBuilder &builder) {
|
|
411
|
-
builder.SetPortalComponentViewInitializer(
|
|
412
|
-
[](const winrt::Microsoft::ReactNative::Composition::
|
|
413
|
-
PortalComponentView &portalComponentView) noexcept {
|
|
414
|
-
auto userData = winrt::make_self<
|
|
415
|
-
winrt::FluentUI::Callout::CalloutComponentView>();
|
|
416
|
-
userData->InitializePortalViewComponent(portalComponentView);
|
|
417
|
-
portalComponentView.UserData(*userData);
|
|
418
|
-
});
|
|
419
|
-
});
|
|
420
|
-
};
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
// Copyright (c) Microsoft Corporation.
|
|
2
|
-
// Licensed under the MIT License.
|
|
3
|
-
#pragma once
|
|
4
|
-
|
|
5
|
-
#include "pch.h"
|
|
6
|
-
|
|
7
|
-
#include "NativeModules.h"
|
|
8
|
-
|
|
9
|
-
#include "codegen/react/components/FRNCalloutSpec/Callout.g.h"
|
|
10
|
-
|
|
11
|
-
#include <winrt/Microsoft.ReactNative.Composition.Experimental.h>
|
|
12
|
-
#include <winrt/Microsoft.ReactNative.Composition.Input.h>
|
|
13
|
-
#include <winrt/Microsoft.ReactNative.Composition.h>
|
|
14
|
-
#include <winrt/Microsoft.ReactNative.h>
|
|
15
|
-
#include <winrt/Microsoft.UI.Composition.h>
|
|
16
|
-
#include <winrt/Microsoft.UI.Content.h>
|
|
17
|
-
#include <winrt/Microsoft.UI.interop.h>
|
|
18
|
-
#include <winrt/Windows.UI.h>
|
|
19
|
-
|
|
20
|
-
namespace winrt::FluentUI::Callout {
|
|
21
|
-
|
|
22
|
-
} // namespace winrt::FluentUI::Callout
|
|
23
|
-
|
|
24
|
-
void RegisterCalloutComponentView(
|
|
25
|
-
winrt::Microsoft::ReactNative::IReactPackageBuilder const &packageBuilder);
|
|
@@ -1,152 +0,0 @@
|
|
|
1
|
-
<?xml version="1.0" encoding="utf-8"?>
|
|
2
|
-
<Project ToolsVersion="16.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
|
3
|
-
<Import Project="$(SolutionDir)\ExperimentalFeatures.props" Condition="Exists('$(SolutionDir)\ExperimentalFeatures.props')" />
|
|
4
|
-
<Import Project="$(SolutionDir)\packages\Microsoft.Windows.CppWinRT.2.0.210621.3\build\native\Microsoft.Windows.CppWinRT.props" Condition="Exists('$(SolutionDir)\packages\Microsoft.Windows.CppWinRT.2.0.210621.3\build\native\Microsoft.Windows.CppWinRT.props')" />
|
|
5
|
-
<PropertyGroup Label="Globals">
|
|
6
|
-
<CppWinRTOptimized>true</CppWinRTOptimized>
|
|
7
|
-
<CppWinRTRootNamespaceAutoMerge>true</CppWinRTRootNamespaceAutoMerge>
|
|
8
|
-
<MinimalCoreWin>true</MinimalCoreWin>
|
|
9
|
-
<ProjectGuid>{FE36524A-FE8C-456A-9368-08FB1EB16CF8}</ProjectGuid>
|
|
10
|
-
<ProjectName>FluentUICallout</ProjectName>
|
|
11
|
-
<RootNamespace>FluentUI.Callout</RootNamespace>
|
|
12
|
-
<DefaultLanguage>en-US</DefaultLanguage>
|
|
13
|
-
<MinimumVisualStudioVersion>16.0</MinimumVisualStudioVersion>
|
|
14
|
-
<AppContainerApplication>false</AppContainerApplication>
|
|
15
|
-
<ApplicationType>Windows Store</ApplicationType>
|
|
16
|
-
<ApplicationTypeRevision>10.0</ApplicationTypeRevision>
|
|
17
|
-
<WindowsTargetPlatformVersion Condition=" '$(WindowsTargetPlatformVersion)' == '' ">10.0.19041.0</WindowsTargetPlatformVersion>
|
|
18
|
-
<WindowsTargetPlatformMinVersion>10.0.17763.0</WindowsTargetPlatformMinVersion>
|
|
19
|
-
</PropertyGroup>
|
|
20
|
-
<PropertyGroup Label="ReactNativeWindowsProps">
|
|
21
|
-
<ReactNativeWindowsDir Condition="'$(ReactNativeWindowsDir)' == ''">$([MSBuild]::GetDirectoryNameOfFileAbove($(SolutionDir), 'node_modules\react-native-windows\package.json'))\node_modules\react-native-windows\</ReactNativeWindowsDir>
|
|
22
|
-
<RnwNewArchOnly>true</RnwNewArchOnly>
|
|
23
|
-
</PropertyGroup>
|
|
24
|
-
<Import Project="$(ReactNativeWindowsDir)\PropertySheets\External\Microsoft.ReactNative.WindowsSdk.Default.props" />
|
|
25
|
-
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
|
26
|
-
<ItemGroup Label="ProjectConfigurations">
|
|
27
|
-
<ProjectConfiguration Include="Debug|ARM">
|
|
28
|
-
<Configuration>Debug</Configuration>
|
|
29
|
-
<Platform>ARM</Platform>
|
|
30
|
-
</ProjectConfiguration>
|
|
31
|
-
<ProjectConfiguration Include="Debug|ARM64">
|
|
32
|
-
<Configuration>Debug</Configuration>
|
|
33
|
-
<Platform>ARM64</Platform>
|
|
34
|
-
</ProjectConfiguration>
|
|
35
|
-
<ProjectConfiguration Include="Debug|Win32">
|
|
36
|
-
<Configuration>Debug</Configuration>
|
|
37
|
-
<Platform>Win32</Platform>
|
|
38
|
-
</ProjectConfiguration>
|
|
39
|
-
<ProjectConfiguration Include="Debug|x64">
|
|
40
|
-
<Configuration>Debug</Configuration>
|
|
41
|
-
<Platform>x64</Platform>
|
|
42
|
-
</ProjectConfiguration>
|
|
43
|
-
<ProjectConfiguration Include="Release|ARM">
|
|
44
|
-
<Configuration>Release</Configuration>
|
|
45
|
-
<Platform>ARM</Platform>
|
|
46
|
-
</ProjectConfiguration>
|
|
47
|
-
<ProjectConfiguration Include="Release|ARM64">
|
|
48
|
-
<Configuration>Release</Configuration>
|
|
49
|
-
<Platform>ARM64</Platform>
|
|
50
|
-
</ProjectConfiguration>
|
|
51
|
-
<ProjectConfiguration Include="Release|Win32">
|
|
52
|
-
<Configuration>Release</Configuration>
|
|
53
|
-
<Platform>Win32</Platform>
|
|
54
|
-
</ProjectConfiguration>
|
|
55
|
-
<ProjectConfiguration Include="Release|x64">
|
|
56
|
-
<Configuration>Release</Configuration>
|
|
57
|
-
<Platform>x64</Platform>
|
|
58
|
-
</ProjectConfiguration>
|
|
59
|
-
</ItemGroup>
|
|
60
|
-
<PropertyGroup Label="Configuration">
|
|
61
|
-
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
|
62
|
-
<CharacterSet>Unicode</CharacterSet>
|
|
63
|
-
<GenerateManifest>false</GenerateManifest>
|
|
64
|
-
</PropertyGroup>
|
|
65
|
-
<PropertyGroup Condition="'$(Configuration)'=='Debug'" Label="Configuration">
|
|
66
|
-
<UseDebugLibraries>true</UseDebugLibraries>
|
|
67
|
-
<LinkIncremental>true</LinkIncremental>
|
|
68
|
-
</PropertyGroup>
|
|
69
|
-
<PropertyGroup Condition="'$(Configuration)'=='Release'" Label="Configuration">
|
|
70
|
-
<UseDebugLibraries>false</UseDebugLibraries>
|
|
71
|
-
<WholeProgramOptimization>true</WholeProgramOptimization>
|
|
72
|
-
<LinkIncremental>false</LinkIncremental>
|
|
73
|
-
</PropertyGroup>
|
|
74
|
-
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
|
75
|
-
<ImportGroup Label="ExtensionSettings">
|
|
76
|
-
</ImportGroup>
|
|
77
|
-
<ImportGroup Label="PropertySheets">
|
|
78
|
-
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
|
79
|
-
</ImportGroup>
|
|
80
|
-
<ImportGroup Label="ReactNativeWindowsPropertySheets">
|
|
81
|
-
<Import Project="$(ReactNativeWindowsDir)\PropertySheets\external\Microsoft.ReactNative.Composition.CppLib.props" Condition="Exists('$(ReactNativeWindowsDir)\PropertySheets\External\Microsoft.ReactNative.Composition.CppLib.props')" />
|
|
82
|
-
</ImportGroup>
|
|
83
|
-
<PropertyGroup Label="UserMacros" />
|
|
84
|
-
<ItemDefinitionGroup>
|
|
85
|
-
<ClCompile>
|
|
86
|
-
<PrecompiledHeader>Use</PrecompiledHeader>
|
|
87
|
-
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
|
|
88
|
-
<PrecompiledHeaderOutputFile>$(IntDir)pch.pch</PrecompiledHeaderOutputFile>
|
|
89
|
-
<WarningLevel>Level4</WarningLevel>
|
|
90
|
-
<AdditionalOptions>%(AdditionalOptions) /bigobj</AdditionalOptions>
|
|
91
|
-
<DisableSpecificWarnings>4453;28204</DisableSpecificWarnings>
|
|
92
|
-
<PreprocessorDefinitions>_WINRT_DLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
|
93
|
-
<AdditionalUsingDirectories>$(WindowsSDK_WindowsMetadata);$(AdditionalUsingDirectories)</AdditionalUsingDirectories>
|
|
94
|
-
</ClCompile>
|
|
95
|
-
<Link>
|
|
96
|
-
<AdditionalDependencies>User32.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
|
97
|
-
<SubSystem>Console</SubSystem>
|
|
98
|
-
<GenerateWindowsMetadata>true</GenerateWindowsMetadata>
|
|
99
|
-
<ModuleDefinitionFile>Callout.def</ModuleDefinitionFile>
|
|
100
|
-
</Link>
|
|
101
|
-
</ItemDefinitionGroup>
|
|
102
|
-
<ItemDefinitionGroup Condition="'$(Configuration)'=='Debug'">
|
|
103
|
-
<ClCompile>
|
|
104
|
-
<PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
|
105
|
-
</ClCompile>
|
|
106
|
-
</ItemDefinitionGroup>
|
|
107
|
-
<ItemDefinitionGroup Condition="'$(Configuration)'=='Release'">
|
|
108
|
-
<ClCompile>
|
|
109
|
-
<PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
|
110
|
-
</ClCompile>
|
|
111
|
-
</ItemDefinitionGroup>
|
|
112
|
-
<ItemDefinitionGroup>
|
|
113
|
-
<Reference>
|
|
114
|
-
<Private Condition="'$(ConfigurationType)' != 'Application'">false</Private>
|
|
115
|
-
</Reference>
|
|
116
|
-
</ItemDefinitionGroup>
|
|
117
|
-
<ItemGroup>
|
|
118
|
-
<ClInclude Include="Callout.h" />
|
|
119
|
-
<ClInclude Include="ReactPackageProvider.h">
|
|
120
|
-
<DependentUpon>ReactPackageProvider.idl</DependentUpon>
|
|
121
|
-
</ClInclude>
|
|
122
|
-
<ClInclude Include="pch.h" />
|
|
123
|
-
</ItemGroup>
|
|
124
|
-
<ItemGroup>
|
|
125
|
-
<ClCompile Include="Callout.cpp" />
|
|
126
|
-
<ClCompile Include="pch.cpp">
|
|
127
|
-
<PrecompiledHeader>Create</PrecompiledHeader>
|
|
128
|
-
</ClCompile>
|
|
129
|
-
<ClCompile Include="ReactPackageProvider.cpp">
|
|
130
|
-
<DependentUpon>ReactPackageProvider.idl</DependentUpon>
|
|
131
|
-
</ClCompile>
|
|
132
|
-
<ClCompile Include="$(GeneratedFilesDir)module.g.cpp" />
|
|
133
|
-
</ItemGroup>
|
|
134
|
-
<ItemGroup>
|
|
135
|
-
<Midl Include="ReactPackageProvider.idl" />
|
|
136
|
-
</ItemGroup>
|
|
137
|
-
<ItemGroup>
|
|
138
|
-
<None Include="packages.config" />
|
|
139
|
-
<None Include="PropertySheet.props" />
|
|
140
|
-
</ItemGroup>
|
|
141
|
-
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
|
142
|
-
<ImportGroup Label="ReactNativeWindowsTargets">
|
|
143
|
-
<Import Project="$(ReactNativeWindowsDir)\PropertySheets\External\Microsoft.ReactNative.Composition.CppLib.targets" Condition="Exists('$(ReactNativeWindowsDir)\PropertySheets\External\Microsoft.ReactNative.Composition.CppLib.targets')" />
|
|
144
|
-
</ImportGroup>
|
|
145
|
-
<Target Name="EnsureReactNativeWindowsTargets" BeforeTargets="PrepareForBuild">
|
|
146
|
-
<PropertyGroup>
|
|
147
|
-
<ErrorText>This project references targets in your node_modules\react-native-windows folder that are missing. The missing file is {0}.</ErrorText>
|
|
148
|
-
</PropertyGroup>
|
|
149
|
-
<Error Condition="!Exists('$(ReactNativeWindowsDir)\PropertySheets\External\Microsoft.ReactNative.Composition.CppLib.props')" Text="$([System.String]::Format('$(ErrorText)', '$(ReactNativeWindowsDir)\PropertySheets\External\Microsoft.ReactNative.Composition.CppLib.props'))" />
|
|
150
|
-
<Error Condition="!Exists('$(ReactNativeWindowsDir)\PropertySheets\External\Microsoft.ReactNative.Composition.CppLib.targets')" Text="$([System.String]::Format('$(ErrorText)', '$(ReactNativeWindowsDir)\PropertySheets\External\Microsoft.ReactNative.Composition.CppLib.targets'))" />
|
|
151
|
-
</Target>
|
|
152
|
-
</Project>
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
// Copyright (c) Microsoft Corporation.
|
|
2
|
-
// Licensed under the MIT License.
|
|
3
|
-
#include "pch.h"
|
|
4
|
-
|
|
5
|
-
#include "ReactPackageProvider.h"
|
|
6
|
-
#if __has_include("ReactPackageProvider.g.cpp")
|
|
7
|
-
#include "ReactPackageProvider.g.cpp"
|
|
8
|
-
#endif
|
|
9
|
-
|
|
10
|
-
#include "Callout.h"
|
|
11
|
-
|
|
12
|
-
using namespace winrt::Microsoft::ReactNative;
|
|
13
|
-
|
|
14
|
-
namespace winrt::FluentUI::Callout::implementation {
|
|
15
|
-
|
|
16
|
-
void ReactPackageProvider::CreatePackage(
|
|
17
|
-
IReactPackageBuilder const &packageBuilder) noexcept {
|
|
18
|
-
AddAttributedModules(packageBuilder, true);
|
|
19
|
-
|
|
20
|
-
#ifdef RNW_NEW_ARCH
|
|
21
|
-
RegisterCalloutComponentView(packageBuilder);
|
|
22
|
-
#endif // #ifdef RNW_NEW_ARCH
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
} // namespace winrt::FluentUI::Callout::implementation
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
// Copyright (c) Microsoft Corporation.
|
|
2
|
-
// Licensed under the MIT License.
|
|
3
|
-
#pragma once
|
|
4
|
-
|
|
5
|
-
#include "ReactPackageProvider.g.h"
|
|
6
|
-
|
|
7
|
-
using namespace winrt::Microsoft::ReactNative;
|
|
8
|
-
|
|
9
|
-
namespace winrt::FluentUI::Callout::implementation {
|
|
10
|
-
|
|
11
|
-
struct ReactPackageProvider : ReactPackageProviderT<ReactPackageProvider> {
|
|
12
|
-
ReactPackageProvider() = default;
|
|
13
|
-
|
|
14
|
-
void CreatePackage(IReactPackageBuilder const &packageBuilder) noexcept;
|
|
15
|
-
};
|
|
16
|
-
|
|
17
|
-
} // namespace winrt::FluentUI::Callout::implementation
|
|
18
|
-
|
|
19
|
-
namespace winrt::FluentUI::Callout::factory_implementation {
|
|
20
|
-
|
|
21
|
-
struct ReactPackageProvider
|
|
22
|
-
: ReactPackageProviderT<ReactPackageProvider,
|
|
23
|
-
implementation::ReactPackageProvider> {};
|
|
24
|
-
|
|
25
|
-
} // namespace winrt::FluentUI::Callout::factory_implementation
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
// Copyright (c) Microsoft Corporation.
|
|
2
|
-
// Licensed under the MIT License.
|
|
3
|
-
|
|
4
|
-
namespace FluentUI.Callout
|
|
5
|
-
{
|
|
6
|
-
[webhosthidden]
|
|
7
|
-
[default_interface]
|
|
8
|
-
runtimeclass ReactPackageProvider : Microsoft.ReactNative.IReactPackageProvider
|
|
9
|
-
{
|
|
10
|
-
ReactPackageProvider();
|
|
11
|
-
};
|
|
12
|
-
}
|