@fluentui-react-native/callout 0.29.6 → 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.
Files changed (66) hide show
  1. package/CHANGELOG.md +11 -0
  2. package/README.md +18 -0
  3. package/lib/index.d.ts +2 -3
  4. package/lib/index.d.ts.map +1 -1
  5. package/lib/index.js +1 -2
  6. package/lib/index.js.map +1 -1
  7. package/package.json +12 -27
  8. package/src/index.ts +2 -3
  9. package/.cache/tsconfig.tsbuildinfo +0 -1
  10. package/FRNCallout.podspec +0 -24
  11. package/NuGet.config +0 -10
  12. package/SPEC.md +0 -46
  13. package/jest.config.cjs +0 -1
  14. package/lib/Callout.d.ts +0 -6
  15. package/lib/Callout.d.ts.map +0 -1
  16. package/lib/Callout.js +0 -64
  17. package/lib/Callout.js.map +0 -1
  18. package/lib/Callout.types.d.ts +0 -85
  19. package/lib/Callout.types.d.ts.map +0 -1
  20. package/lib/Callout.types.js +0 -2
  21. package/lib/Callout.types.js.map +0 -1
  22. package/lib/CalloutNativeComponent.d.ts +0 -49
  23. package/lib/CalloutNativeComponent.d.ts.map +0 -1
  24. package/lib/CalloutNativeComponent.js +0 -9
  25. package/lib/CalloutNativeComponent.js.map +0 -1
  26. package/lib/__tests__/Callout.test.d.ts +0 -2
  27. package/lib/__tests__/Callout.test.d.ts.map +0 -1
  28. package/lib/__tests__/Callout.test.js +0 -96
  29. package/lib/__tests__/Callout.test.js.map +0 -1
  30. package/lib/__tests__/Callout.types.test.d.ts +0 -2
  31. package/lib/__tests__/Callout.types.test.d.ts.map +0 -1
  32. package/lib/__tests__/Callout.types.test.js +0 -21
  33. package/lib/__tests__/Callout.types.test.js.map +0 -1
  34. package/macos/CalloutManager.swift +0 -16
  35. package/macos/CalloutView.swift +0 -454
  36. package/macos/CalloutWindow.swift +0 -40
  37. package/macos/FRNCallout.h +0 -14
  38. package/macos/FRNCalloutManager.h +0 -5
  39. package/macos/FRNCalloutManager.m +0 -76
  40. package/macos/FlippedVisualEffectView.swift +0 -10
  41. package/macos/GuardedEventMonitor.swift +0 -28
  42. package/macos/RCTCalloutComponentView.h +0 -12
  43. package/macos/RCTCalloutComponentView.mm +0 -209
  44. package/react-native.config.cjs +0 -15
  45. package/src/Callout.stories.tsx +0 -276
  46. package/src/Callout.tsx +0 -111
  47. package/src/Callout.types.ts +0 -106
  48. package/src/CalloutNativeComponent.ts +0 -74
  49. package/src/__tests__/Callout.test.tsx +0 -157
  50. package/src/__tests__/Callout.types.test.ts +0 -30
  51. package/src/__tests__/__snapshots__/Callout.test.tsx.snap +0 -11
  52. package/tsconfig.json +0 -19
  53. package/windows/Callout/Callout.cpp +0 -420
  54. package/windows/Callout/Callout.def +0 -3
  55. package/windows/Callout/Callout.h +0 -25
  56. package/windows/Callout/Callout.vcxproj +0 -152
  57. package/windows/Callout/ReactPackageProvider.cpp +0 -25
  58. package/windows/Callout/ReactPackageProvider.h +0 -25
  59. package/windows/Callout/ReactPackageProvider.idl +0 -12
  60. package/windows/Callout/codegen/.clang-format +0 -2
  61. package/windows/Callout/codegen/react/components/FRNCalloutSpec/Callout.g.h +0 -375
  62. package/windows/Callout/packages.lock.json +0 -151
  63. package/windows/Callout/pch.cpp +0 -1
  64. package/windows/Callout/pch.h +0 -28
  65. package/windows/ExperimentalFeatures.props +0 -33
  66. package/windows/NuGet.Config +0 -13
@@ -1,106 +0,0 @@
1
- import type * as React from 'react';
2
- import type { AnimatableNumericValue, ColorValue, KeyboardMetrics, ViewProps } from 'react-native';
3
-
4
- export const calloutName = 'Callout';
5
-
6
- export type DirectionalHint =
7
- | 'leftTopEdge'
8
- | 'leftCenter'
9
- | 'leftBottomEdge'
10
- | 'topLeftEdge'
11
- | 'topAutoEdge'
12
- | 'topCenter'
13
- | 'topRightEdge'
14
- | 'rightTopEdge'
15
- | 'rightCenter'
16
- | 'rightBottomEdge'
17
- | 'bottomLeftEdge'
18
- | 'bottomAutoEdge'
19
- | 'bottomCenter'
20
- | 'bottomRightEdge';
21
-
22
- export type DismissBehaviors = 'preventDismissOnKeyDown' | 'preventDismissOnClickOutside';
23
-
24
- export interface RestoreFocusEvent {
25
- nativeEvent: {
26
- /** True when the Callout contained focus while it was dismissed. */
27
- containsFocus: boolean;
28
- };
29
- }
30
-
31
- /**
32
- * Optional native appearance and positioning values. Callout applies only values
33
- * supplied by the caller and does not resolve theme defaults.
34
- */
35
- export interface CalloutTokens {
36
- /** Anchor rectangle in DIPs relative to the React surface origin. */
37
- anchorRect?: KeyboardMetrics;
38
- /** Native Callout background color. */
39
- backgroundColor?: ColorValue;
40
- /** Width of the beak that points toward the anchor. */
41
- beakWidth?: number;
42
- /** Native Callout border color. */
43
- borderColor?: ColorValue;
44
- /** Native Callout corner radius. */
45
- borderRadius?: AnimatableNumericValue | string;
46
- /** Native Callout border width. */
47
- borderWidth?: number;
48
- /** Preferred placement relative to the anchor. */
49
- directionalHint?: DirectionalHint;
50
- /** Native dismissal behaviors that may be combined. */
51
- dismissBehaviors?: DismissBehaviors[];
52
- /** Gap between the anchor and Callout. */
53
- gapSpace?: number;
54
- /** Maximum Callout height. */
55
- maxHeight?: number | `${number}%`;
56
- /** Maximum Callout width. */
57
- maxWidth?: number | `${number}%`;
58
- /** Minimum padding from display edges. */
59
- minPadding?: number;
60
- /** Minimum Callout width. */
61
- minWidth?: number | `${number}%`;
62
- }
63
-
64
- export interface CalloutHandle {
65
- /** Makes the native Callout window resign key status. */
66
- blurWindow: () => void;
67
- /** Makes the native Callout window key. */
68
- focusWindow: () => void;
69
- }
70
-
71
- export interface CalloutProps extends ViewProps, CalloutTokens {
72
- /**
73
- * A string announced when the Callout is shown.
74
- * @platform win32
75
- */
76
- accessibilityOnShowAnnouncement?: string;
77
- /** Ref used to invoke native Callout window commands. */
78
- componentRef?: React.Ref<CalloutHandle>;
79
- /**
80
- * Prevents the native Callout from taking pointer capture when shown.
81
- * @platform win32
82
- */
83
- doNotTakePointerCapture?: boolean;
84
- /** Displays a beak that points toward the anchor. */
85
- isBeakVisible?: boolean;
86
- /** Invoked after native dismissal. */
87
- onDismiss?: () => void;
88
- /**
89
- * Invoked during dismissal when the caller owns focus restoration.
90
- * @platform win32
91
- */
92
- onRestoreFocus?: (event: RestoreFocusEvent) => void;
93
- /** Invoked after the Callout is shown. */
94
- onShow?: () => void;
95
- /** Requests initial focus when the Callout is shown. */
96
- setInitialFocus?: boolean;
97
- /** Ref or registered native anchor identifier used for relative positioning. */
98
- target?: React.RefObject<React.Component | null> | string;
99
- }
100
-
101
- /** @deprecated Use CalloutProps. */
102
- export type ICalloutProps = CalloutProps;
103
- /** @deprecated Use CalloutTokens. */
104
- export type ICalloutTokens = CalloutTokens;
105
- /** @deprecated Use CalloutHandle. */
106
- export type CalloutNativeCommands = CalloutHandle;
@@ -1,74 +0,0 @@
1
- import codegenNativeCommands from 'react-native/Libraries/Utilities/codegenNativeCommands';
2
- import codegenNativeComponent from 'react-native/Libraries/Utilities/codegenNativeComponent';
3
-
4
- import type { HostComponent, ViewProps } from 'react-native';
5
- import type { WithDefault, UnsafeMixed, Int32, DirectEventHandler, Double } from 'react-native/Libraries/Types/CodegenTypes';
6
-
7
- interface AnchorRect {
8
- screenX: Double;
9
- screenY: Double;
10
- width: Double;
11
- height: Double;
12
- }
13
-
14
- /**
15
- * Shared native props specific to Callout native component
16
- */
17
- export interface NativeProps extends ViewProps {
18
- accessibilityLabel?: string;
19
- accessibilityOnShowAnnouncement?: string;
20
- anchorRect?: AnchorRect;
21
-
22
- beakWidth?: Int32;
23
- dismissBehaviors?: string[];
24
- doNotTakePointerCapture?: boolean;
25
- focusable?: boolean;
26
- gapSpace?: Int32;
27
- isBeakVisible?: boolean;
28
- maxHeight?: Int32;
29
- maxWidth?: Int32;
30
- minPadding?: Int32;
31
- minWidth?: Int32;
32
- setInitialFocus?: boolean;
33
-
34
- // targetAnchor?: string; // Win32 only Callout can target an anchor registered in the anchor registry // Can be a node id or an anchor ID - This need to be reworked as Mixed types are not supported going forward
35
- testID?: string;
36
-
37
- onRestoreFocus?: DirectEventHandler<{ target: Int32; containsFocus: boolean }>;
38
- onDismiss?: DirectEventHandler<{ target: Int32 }>;
39
- onShow?: DirectEventHandler<{ target: Int32 }>;
40
-
41
- directionalHint?: WithDefault<
42
- | 'leftTopEdge'
43
- | 'leftCenter'
44
- | 'leftBottomEdge'
45
- | 'topLeftEdge'
46
- | 'topAutoEdge'
47
- | 'topCenter'
48
- | 'topRightEdge'
49
- | 'rightTopEdge'
50
- | 'rightCenter'
51
- | 'rightBottomEdge'
52
- | 'bottomLeftEdge'
53
- | 'bottomAutoEdge'
54
- | 'bottomCenter'
55
- | 'bottomRightEdge',
56
- 'bottomLeftEdge'
57
- >;
58
- target?: UnsafeMixed;
59
- }
60
-
61
- export type CalloutComponentType = HostComponent<NativeProps>;
62
-
63
- interface NativeCalloutCommands {
64
- focusWindow: (viewRef: React.ElementRef<CalloutComponentType>) => void;
65
- blurWindow: (viewRef: React.ElementRef<CalloutComponentType>) => void;
66
- }
67
-
68
- export const Commands: NativeCalloutCommands = codegenNativeCommands<NativeCalloutCommands>({
69
- supportedCommands: ['blurWindow', 'focusWindow'],
70
- });
71
-
72
- export default codegenNativeComponent<NativeProps>('Callout', {
73
- paperComponentName: 'RCTCallout',
74
- }) as CalloutComponentType;
@@ -1,157 +0,0 @@
1
- /** @jsxImportSource @fluentui-react-native/framework-base */
2
- import * as React from 'react';
3
- import { StyleSheet, Text, View } from 'react-native';
4
-
5
- import { act, render } from '@testing-library/react-native';
6
- import { isPhasedComponent, useSlot } from '@fluentui-react-native/framework-base';
7
- import type { SlotProp } from '@fluentui-react-native/framework-base';
8
-
9
- import { Callout } from '../Callout';
10
- import type { CalloutHandle } from '../Callout.types';
11
- import { Commands } from '../CalloutNativeComponent';
12
-
13
- jest.mock('react-native/Libraries/ReactNative/RendererProxy', () => ({
14
- ...jest.requireActual('react-native/Libraries/ReactNative/RendererProxy'),
15
- findNodeHandle: jest.fn(() => 42),
16
- }));
17
-
18
- type CalloutSlotConsumerProps = {
19
- callout: SlotProp<typeof Callout>;
20
- };
21
-
22
- function CalloutSlotConsumer({ callout }: CalloutSlotConsumerProps) {
23
- const CalloutSlot = useSlot(Callout, callout);
24
- return (
25
- <CalloutSlot accessibilityHint="rendered as a slot" testID="slotted-callout">
26
- <Text>Slot content</Text>
27
- </CalloutSlot>
28
- );
29
- }
30
-
31
- describe('Callout', () => {
32
- afterEach(() => {
33
- jest.restoreAllMocks();
34
- });
35
-
36
- it('uses phased rendering and applies native-safe default styling', async () => {
37
- expect(isPhasedComponent(Callout)).toBe(true);
38
-
39
- const component = await render(<Callout testID="callout" />);
40
- const callout = component.getByTestId('callout');
41
-
42
- expect(callout.type).toBe('RCTCallout');
43
- expect(StyleSheet.flatten(callout.props.style)).toMatchSnapshot();
44
- });
45
-
46
- it('translates caller-supplied appearance values and preserves user style precedence', async () => {
47
- const component = await render(
48
- <Callout
49
- backgroundColor="red"
50
- borderColor="green"
51
- borderRadius={8}
52
- borderWidth={2}
53
- maxHeight={240}
54
- maxWidth="80%"
55
- minWidth={120}
56
- style={{ backgroundColor: 'blue', opacity: 0.5 }}
57
- testID="callout"
58
- />,
59
- );
60
- const callout = component.getByTestId('callout');
61
-
62
- expect(StyleSheet.flatten(callout.props.style)).toEqual({
63
- position: 'absolute',
64
- backgroundColor: 'blue',
65
- borderColor: 'green',
66
- borderRadius: 8,
67
- borderWidth: 2,
68
- maxHeight: 240,
69
- maxWidth: '80%',
70
- minWidth: 120,
71
- opacity: 0.5,
72
- });
73
- expect(callout.props.backgroundColor).toBeUndefined();
74
- expect(callout.props.maxHeight).toBe(240);
75
- expect(callout.props.maxWidth).toBeUndefined();
76
- expect(callout.props.minWidth).toBe(120);
77
- });
78
-
79
- it('forwards native behavior, accessibility, callbacks, and children', async () => {
80
- const onDismiss = jest.fn();
81
- const onShow = jest.fn();
82
- const anchorRect = { screenX: 10, screenY: 20, width: 30, height: 40 };
83
- const component = await render(
84
- <Callout
85
- accessibilityLabel="Formatting options"
86
- anchorRect={anchorRect}
87
- beakWidth={12}
88
- directionalHint="rightTopEdge"
89
- dismissBehaviors={['preventDismissOnClickOutside']}
90
- gapSpace={4}
91
- minPadding={8}
92
- onDismiss={onDismiss}
93
- onShow={onShow}
94
- target="editor-anchor"
95
- testID="callout"
96
- >
97
- <Text>Callout content</Text>
98
- </Callout>,
99
- );
100
- const callout = component.getByTestId('callout');
101
-
102
- expect(callout.props).toMatchObject({
103
- accessibilityLabel: 'Formatting options',
104
- anchorRect,
105
- beakWidth: 12,
106
- directionalHint: 'rightTopEdge',
107
- dismissBehaviors: ['preventDismissOnClickOutside'],
108
- gapSpace: 4,
109
- minPadding: 8,
110
- onDismiss,
111
- onShow,
112
- target: 'editor-anchor',
113
- });
114
- expect(component.getByText('Callout content')).toBeTruthy();
115
- });
116
-
117
- it('resolves a React target ref to its native handle', async () => {
118
- const target = React.createRef<View>();
119
- const component = await render(
120
- <>
121
- <View ref={target} />
122
- <Callout target={target} testID="callout" />
123
- </>,
124
- );
125
-
126
- expect(target.current).not.toBeNull();
127
- expect(component.getByTestId('callout').props.target).toBe(42);
128
- });
129
-
130
- it('exposes native window commands through componentRef', async () => {
131
- const focusWindow = jest.spyOn(Commands, 'focusWindow').mockImplementation(() => undefined);
132
- const blurWindow = jest.spyOn(Commands, 'blurWindow').mockImplementation(() => undefined);
133
- const componentRef = React.createRef<CalloutHandle>();
134
-
135
- await render(<Callout componentRef={componentRef} testID="callout" />);
136
-
137
- await act(async () => {
138
- componentRef.current?.focusWindow();
139
- componentRef.current?.blurWindow();
140
- });
141
-
142
- expect(focusWindow).toHaveBeenCalledTimes(1);
143
- expect(blurWindow).toHaveBeenCalledTimes(1);
144
- });
145
-
146
- it('can be consumed as a slot with merged render props', async () => {
147
- const component = await render(<CalloutSlotConsumer callout={{ accessibilityLabel: 'Slotted Callout', target: 'slot-anchor' }} />);
148
- const callout = component.getByTestId('slotted-callout');
149
-
150
- expect(callout.props).toMatchObject({
151
- accessibilityHint: 'rendered as a slot',
152
- accessibilityLabel: 'Slotted Callout',
153
- target: 'slot-anchor',
154
- });
155
- expect(component.getByText('Slot content')).toBeTruthy();
156
- });
157
- });
@@ -1,30 +0,0 @@
1
- /* eslint-disable @typescript-eslint/no-unused-vars */
2
- import * as React from 'react';
3
-
4
- import type { SlotProp } from '@fluentui-react-native/framework-base';
5
-
6
- import type { Callout } from '../Callout';
7
- import type { CalloutHandle, CalloutProps, ICalloutProps } from '../Callout.types';
8
-
9
- const componentRef = React.createRef<CalloutHandle>();
10
- const target = React.createRef<React.Component>();
11
-
12
- const props: CalloutProps = {
13
- accessibilityLabel: 'Formatting options',
14
- componentRef,
15
- directionalHint: 'bottomCenter',
16
- target,
17
- };
18
-
19
- const calloutSlot: SlotProp<typeof Callout> = props;
20
- const legacyProps: ICalloutProps = props;
21
-
22
- // @ts-expect-error Callout targets must be a ref or registered native anchor identifier.
23
- const invalidTarget: CalloutProps = { target: 42 };
24
-
25
- describe('Callout types', () => {
26
- it('accepts public props as a slot contract', () => {
27
- expect(calloutSlot).toBeDefined();
28
- expect(legacyProps).toBeDefined();
29
- });
30
- });
@@ -1,11 +0,0 @@
1
- // Jest Snapshot v1, https://goo.gl/fbAQLP
2
-
3
- exports[`Callout uses phased rendering and applies native-safe default styling 1`] = `
4
- {
5
- "backgroundColor": "#00000000",
6
- "borderColor": "#00000000",
7
- "borderRadius": 0,
8
- "borderWidth": 0,
9
- "position": "absolute",
10
- }
11
- `;
package/tsconfig.json DELETED
@@ -1,19 +0,0 @@
1
- {
2
- "extends": "@fluentui-react-native/scripts/tsconfig",
3
- "compilerOptions": {
4
- "outDir": "lib",
5
- "rootDir": "src",
6
- "composite": true,
7
- "tsBuildInfoFile": ".cache/tsconfig.tsbuildinfo"
8
- },
9
- "include": ["src"],
10
- "exclude": ["**/*.stories.ts", "**/*.stories.tsx"],
11
- "references": [
12
- {
13
- "path": "../../framework-base/tsconfig.json"
14
- },
15
- {
16
- "path": "../../../scripts/tsconfig.json"
17
- }
18
- ]
19
- }