@fluentui-react-native/tooltip 0.3.2 → 0.4.1
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/SPEC.md +128 -1
- package/assets/image.png +0 -0
- package/lib/Tooltip.d.ts +0 -8
- package/lib/Tooltip.d.ts.map +1 -1
- package/lib/Tooltip.js +20 -12
- package/lib/Tooltip.js.map +1 -1
- package/lib-commonjs/Tooltip.d.ts +0 -8
- package/lib-commonjs/Tooltip.d.ts.map +1 -1
- package/lib-commonjs/Tooltip.js +21 -14
- package/lib-commonjs/Tooltip.js.map +1 -1
- package/package.json +2 -2
- package/src/Tooltip.tsx +26 -13
package/CHANGELOG.json
CHANGED
|
@@ -2,7 +2,22 @@
|
|
|
2
2
|
"name": "@fluentui-react-native/tooltip",
|
|
3
3
|
"entries": [
|
|
4
4
|
{
|
|
5
|
-
"date": "
|
|
5
|
+
"date": "Wed, 08 May 2024 16:21:26 GMT",
|
|
6
|
+
"version": "0.4.0",
|
|
7
|
+
"tag": "@fluentui-react-native/tooltip_v0.4.0",
|
|
8
|
+
"comments": {
|
|
9
|
+
"minor": [
|
|
10
|
+
{
|
|
11
|
+
"author": "gulnazsayed@microsoft.com",
|
|
12
|
+
"package": "@fluentui-react-native/tooltip",
|
|
13
|
+
"commit": "16a8753cb5e4e15b7baa1182e60ef3e6c7cd8d4e",
|
|
14
|
+
"comment": "added layoutEffect hook"
|
|
15
|
+
}
|
|
16
|
+
]
|
|
17
|
+
}
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
"date": "Mon, 15 Apr 2024 21:31:44 GMT",
|
|
6
21
|
"version": "0.3.2",
|
|
7
22
|
"tag": "@fluentui-react-native/tooltip_v0.3.2",
|
|
8
23
|
"comments": {
|
package/CHANGELOG.md
CHANGED
|
@@ -1,12 +1,20 @@
|
|
|
1
1
|
# Change Log - @fluentui-react-native/tooltip
|
|
2
2
|
|
|
3
|
-
This log was last generated on
|
|
3
|
+
This log was last generated on Wed, 08 May 2024 16:21:26 GMT and should not be manually modified.
|
|
4
4
|
|
|
5
5
|
<!-- Start content -->
|
|
6
6
|
|
|
7
|
+
## 0.4.0
|
|
8
|
+
|
|
9
|
+
Wed, 08 May 2024 16:21:26 GMT
|
|
10
|
+
|
|
11
|
+
### Minor changes
|
|
12
|
+
|
|
13
|
+
- added layoutEffect hook (gulnazsayed@microsoft.com)
|
|
14
|
+
|
|
7
15
|
## 0.3.2
|
|
8
16
|
|
|
9
|
-
Mon, 15 Apr 2024 21:
|
|
17
|
+
Mon, 15 Apr 2024 21:31:44 GMT
|
|
10
18
|
|
|
11
19
|
### Patches
|
|
12
20
|
|
package/SPEC.md
CHANGED
|
@@ -2,4 +2,131 @@
|
|
|
2
2
|
|
|
3
3
|
## Background
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
A `Tooltip` is a component that displays additional information about another component. The information is displayed above or near the target. At this time, the tooltip is displayed at or near the mouse cursor (target), which is default Win32 behavior.
|
|
6
|
+
|
|
7
|
+
## Sample Code
|
|
8
|
+
|
|
9
|
+
Basic Example:
|
|
10
|
+
|
|
11
|
+
```jsx
|
|
12
|
+
const tooltip = (
|
|
13
|
+
<Tooltip content={defaultContent}>
|
|
14
|
+
<ButtonV1 accessibilityDescription={defaultContent}>Default Tooltip</ButtonV1>
|
|
15
|
+
</Tooltip>
|
|
16
|
+
);
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
More examples on the [Test pages for Tooltip](../../../apps/fluent-tester/src/TestComponents/Tooltip). Instructions on running the tester app can be found [here](../../../apps/fluent-tester/README.md).
|
|
20
|
+
|
|
21
|
+
## Visual Examples
|
|
22
|
+
|
|
23
|
+
### Default Tooltip
|
|
24
|
+
|
|
25
|
+
Win32:
|
|
26
|
+
|
|
27
|
+

|
|
28
|
+
|
|
29
|
+
```tsx
|
|
30
|
+
const defaultContent = 'Tooltip shows relative to mouse cursor.';
|
|
31
|
+
|
|
32
|
+
const tooltip = (
|
|
33
|
+
<Tooltip content={defaultContent}>
|
|
34
|
+
<ButtonV1 accessibilityDescription={defaultContent}>Default Tooltip</ButtonV1>
|
|
35
|
+
</Tooltip>
|
|
36
|
+
);
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
## Variants
|
|
40
|
+
|
|
41
|
+
### Positioning
|
|
42
|
+
|
|
43
|
+
Not yet implemented.
|
|
44
|
+
|
|
45
|
+
The `Tooltip` component will appear in the specified position relative to the anchor (target). In Win32, the positions are denoted by the DirectionalHint: `topLeftEdge`, `topCenter`, `topRightEdge`, `rightTopEdge`, `rightCenter`, `rightBottomEdge`, `bottomLeftEdge`, `bottomCenter`, `bottomRightEdge`, `leftTopEdge`, `leftCenter`, and `leftBottomEdge`.
|
|
46
|
+
|
|
47
|
+
### Target
|
|
48
|
+
|
|
49
|
+
Not yet implemented.
|
|
50
|
+
|
|
51
|
+
The `Tooltip` component can reference a target component that will be used as the position anchor.
|
|
52
|
+
|
|
53
|
+
## API
|
|
54
|
+
|
|
55
|
+
### Slots
|
|
56
|
+
|
|
57
|
+
The `Tooltip` component has one slot, or parts. The slots behave as follows:
|
|
58
|
+
|
|
59
|
+
- `root` - The outer container representing the `Tooltip` itself. The NativeTooltipViewManager is passed into this.
|
|
60
|
+
|
|
61
|
+
### Props
|
|
62
|
+
|
|
63
|
+
Below is the set of props `Tooltip` supports:
|
|
64
|
+
|
|
65
|
+
```ts
|
|
66
|
+
export type TooltipProps = React.PropsWithChildren<{
|
|
67
|
+
/**
|
|
68
|
+
* The text of the tooltip.
|
|
69
|
+
*/
|
|
70
|
+
content: string;
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* Notification when the visibility of the tooltip is changed.
|
|
74
|
+
*/
|
|
75
|
+
onVisibleChange?: (event, data) => void;
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* Positioning of the tooltip relative to the target element.
|
|
79
|
+
*
|
|
80
|
+
* @default topCenter
|
|
81
|
+
*/
|
|
82
|
+
positioning?: DirectionalHint;
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* Allow consumers to pass in Style props
|
|
86
|
+
*/
|
|
87
|
+
style?: ViewStyle;
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* Target anchor that tooltip uses for relative positioning. Certain components may proffer a string as an anchor target, such as
|
|
91
|
+
* anchoring to a point inside the component.
|
|
92
|
+
*
|
|
93
|
+
* If not provided, will anchor to the wrapper element.
|
|
94
|
+
*/
|
|
95
|
+
target?: React.RefObject<React.Component> | string;
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* Controls the tooltip visibility and can be used in conjunction with onVisibleChange to modify show/hide behavior. If not provided, will be updated based on hover/focus events on target element.
|
|
99
|
+
*
|
|
100
|
+
* @default false
|
|
101
|
+
*/
|
|
102
|
+
visible?: boolean;
|
|
103
|
+
}>;
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
### Styling
|
|
107
|
+
|
|
108
|
+
Styling is handled by the native platform for Win32.
|
|
109
|
+
|
|
110
|
+
## Behaviors
|
|
111
|
+
|
|
112
|
+
The user will have the opportunity to see the tooltip on hover or focus of the target component. Tooltips simply display additional information about another component for the user to read.
|
|
113
|
+
|
|
114
|
+
### Interactions
|
|
115
|
+
|
|
116
|
+
#### Keyboard Interaction
|
|
117
|
+
|
|
118
|
+
Focus is set according to the guidelines of the target component (ex. Button). When the component is focused, the `Tooltip` is raisable by Ctrl+Shift+F10.
|
|
119
|
+
|
|
120
|
+
#### Mouse Interaction
|
|
121
|
+
|
|
122
|
+
`Tooltip` is visible when target component is hovered. `Tooltip` is dismissed when the mouse cursor moves again.
|
|
123
|
+
|
|
124
|
+
#### Touch interaction
|
|
125
|
+
|
|
126
|
+
`Tooltip` is rendered on touch/press.
|
|
127
|
+
|
|
128
|
+
## Accessibility
|
|
129
|
+
|
|
130
|
+
### Expected behavior
|
|
131
|
+
|
|
132
|
+
Narrator will read the contents of the `Tooltip` when visible. The user should use `accessibilityDescription` on the target component to set the full description. Win32 platform infrastructure supports narrator default to reading the full description of the target element.
|
package/assets/image.png
ADDED
|
Binary file
|
package/lib/Tooltip.d.ts
CHANGED
|
@@ -4,14 +4,6 @@
|
|
|
4
4
|
* @format
|
|
5
5
|
*/
|
|
6
6
|
import type { TooltipProps } from './Tooltip.types';
|
|
7
|
-
/**
|
|
8
|
-
* A function which determines if a set of styles should be applied to the component given the current state and props of the tooltip.
|
|
9
|
-
*
|
|
10
|
-
* @param layer The name of the state that is being checked for
|
|
11
|
-
* @param userProps The props that were passed into the tooltip
|
|
12
|
-
* @returns Whether the styles that are assigned to the layer should be applied to the tooltip
|
|
13
|
-
*/
|
|
14
|
-
export declare const tooltipLookup: (layer: string, userProps: TooltipProps) => boolean;
|
|
15
7
|
export declare const Tooltip: import("@fluentui-react-native/framework").ComposableFunction<TooltipProps>;
|
|
16
8
|
export default Tooltip;
|
|
17
9
|
//# sourceMappingURL=Tooltip.d.ts.map
|
package/lib/Tooltip.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Tooltip.d.ts","sourceRoot":"","sources":["../src/Tooltip.tsx"],"names":[],"mappings":"AAAA;;;;GAIG;
|
|
1
|
+
{"version":3,"file":"Tooltip.d.ts","sourceRoot":"","sources":["../src/Tooltip.tsx"],"names":[],"mappings":"AAAA;;;;GAIG;AAQH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAIpD,eAAO,MAAM,OAAO,6EA2BlB,CAAC;AAIH,eAAe,OAAO,CAAC"}
|
package/lib/Tooltip.js
CHANGED
|
@@ -6,23 +6,31 @@
|
|
|
6
6
|
import { __assign } from "tslib";
|
|
7
7
|
/** @jsxRuntime classic */
|
|
8
8
|
import * as React from 'react';
|
|
9
|
+
import { findNodeHandle } from 'react-native';
|
|
9
10
|
import { mergeProps, stagedComponent } from '@fluentui-react-native/framework';
|
|
10
11
|
import { tooltipName } from './Tooltip.types';
|
|
11
12
|
import NativeTooltipView from './TooltipNativeComponent';
|
|
12
|
-
/**
|
|
13
|
-
* A function which determines if a set of styles should be applied to the component given the current state and props of the tooltip.
|
|
14
|
-
*
|
|
15
|
-
* @param layer The name of the state that is being checked for
|
|
16
|
-
* @param userProps The props that were passed into the tooltip
|
|
17
|
-
* @returns Whether the styles that are assigned to the layer should be applied to the tooltip
|
|
18
|
-
*/
|
|
19
|
-
export var tooltipLookup = function (layer, userProps) {
|
|
20
|
-
return userProps[layer];
|
|
21
|
-
};
|
|
22
13
|
export var Tooltip = stagedComponent(function (props) {
|
|
23
|
-
|
|
24
|
-
|
|
14
|
+
var target = props.target;
|
|
15
|
+
var _a = React.useState(null), nativeTarget = _a[0], setNativeTarget = _a[1];
|
|
16
|
+
React.useLayoutEffect(function () {
|
|
17
|
+
if (typeof target === 'string') {
|
|
18
|
+
// Pass string type `target` directly
|
|
19
|
+
setNativeTarget(target);
|
|
20
|
+
}
|
|
21
|
+
else if (target === null || target === void 0 ? void 0 : target.current) {
|
|
22
|
+
// Pass the tagID for a valid ref `target`
|
|
23
|
+
setNativeTarget(findNodeHandle(target.current));
|
|
24
|
+
}
|
|
25
|
+
else {
|
|
26
|
+
// Clear `target` so we may fall back on `anchorRect` if provided
|
|
27
|
+
setNativeTarget(null);
|
|
28
|
+
}
|
|
29
|
+
}, [target]);
|
|
30
|
+
var TooltipComponent = function (rest, children) {
|
|
31
|
+
return (React.createElement(NativeTooltipView, __assign({}, (nativeTarget && { target: nativeTarget }), mergeProps(props, rest)), children));
|
|
25
32
|
};
|
|
33
|
+
return TooltipComponent;
|
|
26
34
|
});
|
|
27
35
|
Tooltip.displayName = tooltipName;
|
|
28
36
|
export default Tooltip;
|
package/lib/Tooltip.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Tooltip.js","sourceRoot":"","sources":["../src/Tooltip.tsx"],"names":[],"mappings":"AAAA;;;;GAIG;;AAEH,0BAA0B;AAC1B,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"Tooltip.js","sourceRoot":"","sources":["../src/Tooltip.tsx"],"names":[],"mappings":"AAAA;;;;GAIG;;AAEH,0BAA0B;AAC1B,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAE9C,OAAO,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,kCAAkC,CAAC;AAG/E,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAC9C,OAAO,iBAAiB,MAAM,0BAA0B,CAAC;AAEzD,MAAM,CAAC,IAAM,OAAO,GAAG,eAAe,CAAC,UAAC,KAAmB;IACjD,IAAA,MAAM,GAAK,KAAK,OAAV,CAAW;IAEnB,IAAA,KAAkC,KAAK,CAAC,QAAQ,CAAyB,IAAI,CAAC,EAA7E,YAAY,QAAA,EAAE,eAAe,QAAgD,CAAC;IAErF,KAAK,CAAC,eAAe,CAAC;QACpB,IAAI,OAAO,MAAM,KAAK,QAAQ,EAAE;YAC9B,qCAAqC;YACrC,eAAe,CAAC,MAAM,CAAC,CAAC;SACzB;aAAM,IAAI,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,OAAO,EAAE;YAC1B,0CAA0C;YAC1C,eAAe,CAAC,cAAc,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC;SACjD;aAAM;YACL,iEAAiE;YACjE,eAAe,CAAC,IAAI,CAAC,CAAC;SACvB;IACH,CAAC,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC;IAEb,IAAM,gBAAgB,GAAG,UAAC,IAAkB,EAAE,QAAyB;QACrE,OAAO,CACL,oBAAC,iBAAiB,eAAK,CAAC,YAAY,IAAI,EAAE,MAAM,EAAE,YAAY,EAAE,CAAC,EAAM,UAAU,CAAC,KAAK,EAAE,IAAI,CAAC,GAC3F,QAAQ,CACS,CACrB,CAAC;IACJ,CAAC,CAAC;IAEF,OAAO,gBAAgB,CAAC;AAC1B,CAAC,CAAC,CAAC;AAEH,OAAO,CAAC,WAAW,GAAG,WAAW,CAAC;AAElC,eAAe,OAAO,CAAC"}
|
|
@@ -4,14 +4,6 @@
|
|
|
4
4
|
* @format
|
|
5
5
|
*/
|
|
6
6
|
import type { TooltipProps } from './Tooltip.types';
|
|
7
|
-
/**
|
|
8
|
-
* A function which determines if a set of styles should be applied to the component given the current state and props of the tooltip.
|
|
9
|
-
*
|
|
10
|
-
* @param layer The name of the state that is being checked for
|
|
11
|
-
* @param userProps The props that were passed into the tooltip
|
|
12
|
-
* @returns Whether the styles that are assigned to the layer should be applied to the tooltip
|
|
13
|
-
*/
|
|
14
|
-
export declare const tooltipLookup: (layer: string, userProps: TooltipProps) => boolean;
|
|
15
7
|
export declare const Tooltip: import("@fluentui-react-native/framework").ComposableFunction<TooltipProps>;
|
|
16
8
|
export default Tooltip;
|
|
17
9
|
//# sourceMappingURL=Tooltip.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Tooltip.d.ts","sourceRoot":"","sources":["../src/Tooltip.tsx"],"names":[],"mappings":"AAAA;;;;GAIG;
|
|
1
|
+
{"version":3,"file":"Tooltip.d.ts","sourceRoot":"","sources":["../src/Tooltip.tsx"],"names":[],"mappings":"AAAA;;;;GAIG;AAQH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAIpD,eAAO,MAAM,OAAO,6EA2BlB,CAAC;AAIH,eAAe,OAAO,CAAC"}
|
package/lib-commonjs/Tooltip.js
CHANGED
|
@@ -5,28 +5,35 @@
|
|
|
5
5
|
* @format
|
|
6
6
|
*/
|
|
7
7
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
-
exports.Tooltip =
|
|
8
|
+
exports.Tooltip = void 0;
|
|
9
9
|
var tslib_1 = require("tslib");
|
|
10
10
|
/** @jsxRuntime classic */
|
|
11
11
|
var React = tslib_1.__importStar(require("react"));
|
|
12
|
+
var react_native_1 = require("react-native");
|
|
12
13
|
var framework_1 = require("@fluentui-react-native/framework");
|
|
13
14
|
var Tooltip_types_1 = require("./Tooltip.types");
|
|
14
15
|
var TooltipNativeComponent_1 = tslib_1.__importDefault(require("./TooltipNativeComponent"));
|
|
15
|
-
/**
|
|
16
|
-
* A function which determines if a set of styles should be applied to the component given the current state and props of the tooltip.
|
|
17
|
-
*
|
|
18
|
-
* @param layer The name of the state that is being checked for
|
|
19
|
-
* @param userProps The props that were passed into the tooltip
|
|
20
|
-
* @returns Whether the styles that are assigned to the layer should be applied to the tooltip
|
|
21
|
-
*/
|
|
22
|
-
var tooltipLookup = function (layer, userProps) {
|
|
23
|
-
return userProps[layer];
|
|
24
|
-
};
|
|
25
|
-
exports.tooltipLookup = tooltipLookup;
|
|
26
16
|
exports.Tooltip = (0, framework_1.stagedComponent)(function (props) {
|
|
27
|
-
|
|
28
|
-
|
|
17
|
+
var target = props.target;
|
|
18
|
+
var _a = React.useState(null), nativeTarget = _a[0], setNativeTarget = _a[1];
|
|
19
|
+
React.useLayoutEffect(function () {
|
|
20
|
+
if (typeof target === 'string') {
|
|
21
|
+
// Pass string type `target` directly
|
|
22
|
+
setNativeTarget(target);
|
|
23
|
+
}
|
|
24
|
+
else if (target === null || target === void 0 ? void 0 : target.current) {
|
|
25
|
+
// Pass the tagID for a valid ref `target`
|
|
26
|
+
setNativeTarget((0, react_native_1.findNodeHandle)(target.current));
|
|
27
|
+
}
|
|
28
|
+
else {
|
|
29
|
+
// Clear `target` so we may fall back on `anchorRect` if provided
|
|
30
|
+
setNativeTarget(null);
|
|
31
|
+
}
|
|
32
|
+
}, [target]);
|
|
33
|
+
var TooltipComponent = function (rest, children) {
|
|
34
|
+
return (React.createElement(TooltipNativeComponent_1.default, tslib_1.__assign({}, (nativeTarget && { target: nativeTarget }), (0, framework_1.mergeProps)(props, rest)), children));
|
|
29
35
|
};
|
|
36
|
+
return TooltipComponent;
|
|
30
37
|
});
|
|
31
38
|
exports.Tooltip.displayName = Tooltip_types_1.tooltipName;
|
|
32
39
|
exports.default = exports.Tooltip;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Tooltip.js","sourceRoot":"","sources":["../src/Tooltip.tsx"],"names":[],"mappings":";AAAA;;;;GAIG;;;;AAEH,0BAA0B;AAC1B,mDAA+B;
|
|
1
|
+
{"version":3,"file":"Tooltip.js","sourceRoot":"","sources":["../src/Tooltip.tsx"],"names":[],"mappings":";AAAA;;;;GAIG;;;;AAEH,0BAA0B;AAC1B,mDAA+B;AAC/B,6CAA8C;AAE9C,8DAA+E;AAG/E,iDAA8C;AAC9C,4FAAyD;AAE5C,QAAA,OAAO,GAAG,IAAA,2BAAe,EAAC,UAAC,KAAmB;IACjD,IAAA,MAAM,GAAK,KAAK,OAAV,CAAW;IAEnB,IAAA,KAAkC,KAAK,CAAC,QAAQ,CAAyB,IAAI,CAAC,EAA7E,YAAY,QAAA,EAAE,eAAe,QAAgD,CAAC;IAErF,KAAK,CAAC,eAAe,CAAC;QACpB,IAAI,OAAO,MAAM,KAAK,QAAQ,EAAE;YAC9B,qCAAqC;YACrC,eAAe,CAAC,MAAM,CAAC,CAAC;SACzB;aAAM,IAAI,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,OAAO,EAAE;YAC1B,0CAA0C;YAC1C,eAAe,CAAC,IAAA,6BAAc,EAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC;SACjD;aAAM;YACL,iEAAiE;YACjE,eAAe,CAAC,IAAI,CAAC,CAAC;SACvB;IACH,CAAC,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC;IAEb,IAAM,gBAAgB,GAAG,UAAC,IAAkB,EAAE,QAAyB;QACrE,OAAO,CACL,oBAAC,gCAAiB,uBAAK,CAAC,YAAY,IAAI,EAAE,MAAM,EAAE,YAAY,EAAE,CAAC,EAAM,IAAA,sBAAU,EAAC,KAAK,EAAE,IAAI,CAAC,GAC3F,QAAQ,CACS,CACrB,CAAC;IACJ,CAAC,CAAC;IAEF,OAAO,gBAAgB,CAAC;AAC1B,CAAC,CAAC,CAAC;AAEH,eAAO,CAAC,WAAW,GAAG,2BAAW,CAAC;AAElC,kBAAe,eAAO,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fluentui-react-native/tooltip",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.1",
|
|
4
4
|
"description": "A cross-platform Tooltip component for React Native.",
|
|
5
5
|
"main": "lib-commonjs/index.js",
|
|
6
6
|
"module": "lib/index.js",
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
"tslib": "^2.3.1"
|
|
28
28
|
},
|
|
29
29
|
"devDependencies": {
|
|
30
|
-
"@fluentui-react-native/button": "0.37.
|
|
30
|
+
"@fluentui-react-native/button": "0.37.2",
|
|
31
31
|
"@fluentui-react-native/eslint-config-rules": "0.1.1",
|
|
32
32
|
"@fluentui-react-native/scripts": "0.1.1",
|
|
33
33
|
"@fluentui-react-native/test-tools": "0.1.1",
|
package/src/Tooltip.tsx
CHANGED
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
|
|
7
7
|
/** @jsxRuntime classic */
|
|
8
8
|
import * as React from 'react';
|
|
9
|
+
import { findNodeHandle } from 'react-native';
|
|
9
10
|
|
|
10
11
|
import { mergeProps, stagedComponent } from '@fluentui-react-native/framework';
|
|
11
12
|
|
|
@@ -13,21 +14,33 @@ import type { TooltipProps } from './Tooltip.types';
|
|
|
13
14
|
import { tooltipName } from './Tooltip.types';
|
|
14
15
|
import NativeTooltipView from './TooltipNativeComponent';
|
|
15
16
|
|
|
16
|
-
/**
|
|
17
|
-
* A function which determines if a set of styles should be applied to the component given the current state and props of the tooltip.
|
|
18
|
-
*
|
|
19
|
-
* @param layer The name of the state that is being checked for
|
|
20
|
-
* @param userProps The props that were passed into the tooltip
|
|
21
|
-
* @returns Whether the styles that are assigned to the layer should be applied to the tooltip
|
|
22
|
-
*/
|
|
23
|
-
export const tooltipLookup = (layer: string, userProps: TooltipProps): boolean => {
|
|
24
|
-
return userProps[layer];
|
|
25
|
-
};
|
|
26
|
-
|
|
27
17
|
export const Tooltip = stagedComponent((props: TooltipProps) => {
|
|
28
|
-
|
|
29
|
-
|
|
18
|
+
const { target } = props;
|
|
19
|
+
|
|
20
|
+
const [nativeTarget, setNativeTarget] = React.useState<number | string | null>(null);
|
|
21
|
+
|
|
22
|
+
React.useLayoutEffect(() => {
|
|
23
|
+
if (typeof target === 'string') {
|
|
24
|
+
// Pass string type `target` directly
|
|
25
|
+
setNativeTarget(target);
|
|
26
|
+
} else if (target?.current) {
|
|
27
|
+
// Pass the tagID for a valid ref `target`
|
|
28
|
+
setNativeTarget(findNodeHandle(target.current));
|
|
29
|
+
} else {
|
|
30
|
+
// Clear `target` so we may fall back on `anchorRect` if provided
|
|
31
|
+
setNativeTarget(null);
|
|
32
|
+
}
|
|
33
|
+
}, [target]);
|
|
34
|
+
|
|
35
|
+
const TooltipComponent = (rest: TooltipProps, children: React.ReactNode) => {
|
|
36
|
+
return (
|
|
37
|
+
<NativeTooltipView {...(nativeTarget && { target: nativeTarget })} {...mergeProps(props, rest)}>
|
|
38
|
+
{children}
|
|
39
|
+
</NativeTooltipView>
|
|
40
|
+
);
|
|
30
41
|
};
|
|
42
|
+
|
|
43
|
+
return TooltipComponent;
|
|
31
44
|
});
|
|
32
45
|
|
|
33
46
|
Tooltip.displayName = tooltipName;
|