@fluentui-react-native/tooltip 0.2.0

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 (46) hide show
  1. package/.eslintrc.js +3 -0
  2. package/CHANGELOG.json +20 -0
  3. package/CHANGELOG.md +13 -0
  4. package/SPEC.md +5 -0
  5. package/babel.config.js +1 -0
  6. package/jest.config.js +2 -0
  7. package/just.config.js +3 -0
  8. package/lib/Tooltip.d.ts +12 -0
  9. package/lib/Tooltip.d.ts.map +1 -0
  10. package/lib/Tooltip.js +25 -0
  11. package/lib/Tooltip.js.map +1 -0
  12. package/lib/Tooltip.types.d.ts +45 -0
  13. package/lib/Tooltip.types.d.ts.map +1 -0
  14. package/lib/Tooltip.types.js +2 -0
  15. package/lib/Tooltip.types.js.map +1 -0
  16. package/lib/__tests__/Tooltip.test.d.ts +2 -0
  17. package/lib/__tests__/Tooltip.test.d.ts.map +1 -0
  18. package/lib/__tests__/Tooltip.test.js +24 -0
  19. package/lib/__tests__/Tooltip.test.js.map +1 -0
  20. package/lib/index.d.ts +4 -0
  21. package/lib/index.d.ts.map +1 -0
  22. package/lib/index.js +3 -0
  23. package/lib/index.js.map +1 -0
  24. package/lib-commonjs/Tooltip.d.ts +12 -0
  25. package/lib-commonjs/Tooltip.d.ts.map +1 -0
  26. package/lib-commonjs/Tooltip.js +29 -0
  27. package/lib-commonjs/Tooltip.js.map +1 -0
  28. package/lib-commonjs/Tooltip.types.d.ts +45 -0
  29. package/lib-commonjs/Tooltip.types.d.ts.map +1 -0
  30. package/lib-commonjs/Tooltip.types.js +5 -0
  31. package/lib-commonjs/Tooltip.types.js.map +1 -0
  32. package/lib-commonjs/__tests__/Tooltip.test.d.ts +2 -0
  33. package/lib-commonjs/__tests__/Tooltip.test.d.ts.map +1 -0
  34. package/lib-commonjs/__tests__/Tooltip.test.js +27 -0
  35. package/lib-commonjs/__tests__/Tooltip.test.js.map +1 -0
  36. package/lib-commonjs/index.d.ts +4 -0
  37. package/lib-commonjs/index.d.ts.map +1 -0
  38. package/lib-commonjs/index.js +8 -0
  39. package/lib-commonjs/index.js.map +1 -0
  40. package/package.json +61 -0
  41. package/src/Tooltip.tsx +31 -0
  42. package/src/Tooltip.types.ts +54 -0
  43. package/src/__tests__/Tooltip.test.tsx +44 -0
  44. package/src/__tests__/__snapshots__/Tooltip.test.tsx.snap +98 -0
  45. package/src/index.ts +3 -0
  46. package/tsconfig.json +9 -0
package/.eslintrc.js ADDED
@@ -0,0 +1,3 @@
1
+ module.exports = {
2
+ extends: ['@fluentui-react-native/eslint-config-rules'],
3
+ };
package/CHANGELOG.json ADDED
@@ -0,0 +1,20 @@
1
+ {
2
+ "name": "@fluentui-react-native/tooltip",
3
+ "entries": [
4
+ {
5
+ "date": "Thu, 30 Nov 2023 21:39:48 GMT",
6
+ "version": "0.2.0",
7
+ "tag": "@fluentui-react-native/tooltip_v0.2.0",
8
+ "comments": {
9
+ "minor": [
10
+ {
11
+ "author": "gulnazsayed@microsoft.com",
12
+ "package": "@fluentui-react-native/tooltip",
13
+ "commit": "b5a9fdefb58572ac6976e682563a190cb8a644b7",
14
+ "comment": "adding new package"
15
+ }
16
+ ]
17
+ }
18
+ }
19
+ ]
20
+ }
package/CHANGELOG.md ADDED
@@ -0,0 +1,13 @@
1
+ # Change Log - @fluentui-react-native/tooltip
2
+
3
+ This log was last generated on Thu, 30 Nov 2023 21:39:48 GMT and should not be manually modified.
4
+
5
+ <!-- Start content -->
6
+
7
+ ## 0.2.0
8
+
9
+ Thu, 30 Nov 2023 21:39:48 GMT
10
+
11
+ ### Minor changes
12
+
13
+ - adding new package (gulnazsayed@microsoft.com)
package/SPEC.md ADDED
@@ -0,0 +1,5 @@
1
+ # Tooltip
2
+
3
+ ## Background
4
+
5
+ Please write here you documentation...
@@ -0,0 +1 @@
1
+ module.exports = require('@fluentui-react-native/scripts/babel.config');
package/jest.config.js ADDED
@@ -0,0 +1,2 @@
1
+ const { configureReactNativeJest } = require('@fluentui-react-native/scripts');
2
+ module.exports = configureReactNativeJest('win32');
package/just.config.js ADDED
@@ -0,0 +1,3 @@
1
+ const { preset } = require('@fluentui-react-native/scripts');
2
+
3
+ preset();
@@ -0,0 +1,12 @@
1
+ import type { TooltipProps } from './Tooltip.types';
2
+ /**
3
+ * A function which determines if a set of styles should be applied to the component given the current state and props of the tooltip.
4
+ *
5
+ * @param layer The name of the state that is being checked for
6
+ * @param userProps The props that were passed into the tooltip
7
+ * @returns Whether the styles that are assigned to the layer should be applied to the tooltip
8
+ */
9
+ export declare const tooltipLookup: (layer: string, userProps: TooltipProps) => boolean;
10
+ export declare const Tooltip: import("@fluentui-react-native/framework").ComposableFunction<TooltipProps>;
11
+ export default Tooltip;
12
+ //# sourceMappingURL=Tooltip.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Tooltip.d.ts","sourceRoot":"","sources":["../src/Tooltip.tsx"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAKpD;;;;;;GAMG;AACH,eAAO,MAAM,aAAa,UAAW,MAAM,aAAa,YAAY,KAAG,OAEtE,CAAC;AAEF,eAAO,MAAM,OAAO,6EAIlB,CAAC;AAIH,eAAe,OAAO,CAAC"}
package/lib/Tooltip.js ADDED
@@ -0,0 +1,25 @@
1
+ import { __assign } from "tslib";
2
+ /** @jsxRuntime classic */
3
+ import * as React from 'react';
4
+ import { ensureNativeComponent } from '@fluentui-react-native/component-cache';
5
+ import { mergeProps, stagedComponent } from '@fluentui-react-native/framework';
6
+ import { tooltipName } from './Tooltip.types';
7
+ var NativeTooltipView = ensureNativeComponent('RCTTooltip');
8
+ /**
9
+ * A function which determines if a set of styles should be applied to the component given the current state and props of the tooltip.
10
+ *
11
+ * @param layer The name of the state that is being checked for
12
+ * @param userProps The props that were passed into the tooltip
13
+ * @returns Whether the styles that are assigned to the layer should be applied to the tooltip
14
+ */
15
+ export var tooltipLookup = function (layer, userProps) {
16
+ return userProps[layer];
17
+ };
18
+ export var Tooltip = stagedComponent(function (props) {
19
+ return function (rest, children) {
20
+ return React.createElement(NativeTooltipView, __assign({}, mergeProps(props, rest)), children);
21
+ };
22
+ });
23
+ Tooltip.displayName = tooltipName;
24
+ export default Tooltip;
25
+ //# sourceMappingURL=Tooltip.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Tooltip.js","sourceRoot":"","sources":["../src/Tooltip.tsx"],"names":[],"mappings":";AAAA,0BAA0B;AAC1B,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,EAAE,qBAAqB,EAAE,MAAM,wCAAwC,CAAC;AAC/E,OAAO,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,kCAAkC,CAAC;AAG/E,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAE9C,IAAM,iBAAiB,GAAG,qBAAqB,CAAC,YAAY,CAAC,CAAC;AAE9D;;;;;;GAMG;AACH,MAAM,CAAC,IAAM,aAAa,GAAG,UAAC,KAAa,EAAE,SAAuB;IAClE,OAAO,SAAS,CAAC,KAAK,CAAC,CAAC;AAC1B,CAAC,CAAC;AAEF,MAAM,CAAC,IAAM,OAAO,GAAG,eAAe,CAAC,UAAC,KAAmB;IACzD,OAAO,UAAC,IAAkB,EAAE,QAAyB;QACnD,OAAO,oBAAC,iBAAiB,eAAK,UAAU,CAAC,KAAK,EAAE,IAAI,CAAC,GAAG,QAAQ,CAAqB,CAAC;IACxF,CAAC,CAAC;AACJ,CAAC,CAAC,CAAC;AAEH,OAAO,CAAC,WAAW,GAAG,WAAW,CAAC;AAElC,eAAe,OAAO,CAAC"}
@@ -0,0 +1,45 @@
1
+ import type * as React from 'react';
2
+ import type { ViewStyle } from 'react-native';
3
+ import type { DirectionalHint } from '@fluentui-react-native/callout';
4
+ export declare const tooltipName = "Tooltip";
5
+ export type TooltipProps = React.PropsWithChildren<{
6
+ /**
7
+ * The text of the tooltip.
8
+ */
9
+ content: string;
10
+ /**
11
+ * Notification when the visibility of the tooltip is changed.
12
+ */
13
+ onVisibleChange?: (event: any, data: any) => void;
14
+ /**
15
+ * Positioning of the tooltip relative to the target element.
16
+ *
17
+ * @default topCenter
18
+ */
19
+ positioning?: DirectionalHint;
20
+ /**
21
+ * Allow consumers to pass in Style props
22
+ */
23
+ style?: ViewStyle;
24
+ /**
25
+ * Target anchor that tooltip uses for relative positioning. Certain components may proffer a string as an anchor target, such as
26
+ * anchoring to a point inside the component.
27
+ *
28
+ * If not provided, will anchor to the wrapper element.
29
+ */
30
+ target?: React.RefObject<React.Component> | string;
31
+ /**
32
+ * 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.
33
+ *
34
+ * @default false
35
+ */
36
+ visible?: boolean;
37
+ }>;
38
+ export interface TooltipSlotProps {
39
+ root: TooltipProps;
40
+ }
41
+ export interface TooltipType {
42
+ props: TooltipProps;
43
+ slotProps: TooltipSlotProps;
44
+ }
45
+ //# sourceMappingURL=Tooltip.types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Tooltip.types.d.ts","sourceRoot":"","sources":["../src/Tooltip.types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,KAAK,MAAM,OAAO,CAAC;AACpC,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAE9C,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,gCAAgC,CAAC;AAEtE,eAAO,MAAM,WAAW,YAAY,CAAC;AAErC,MAAM,MAAM,YAAY,GAAG,KAAK,CAAC,iBAAiB,CAAC;IACjD;;OAEG;IACH,OAAO,EAAE,MAAM,CAAC;IAEhB;;OAEG;IACH,eAAe,CAAC,EAAE,CAAC,KAAK,KAAA,EAAE,IAAI,KAAA,KAAK,IAAI,CAAC;IAExC;;;;OAIG;IACH,WAAW,CAAC,EAAE,eAAe,CAAC;IAE9B;;OAEG;IACH,KAAK,CAAC,EAAE,SAAS,CAAC;IAElB;;;;;OAKG;IACH,MAAM,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC,KAAK,CAAC,SAAS,CAAC,GAAG,MAAM,CAAC;IAEnD;;;;OAIG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB,CAAC,CAAC;AAEH,MAAM,WAAW,gBAAgB;IAC/B,IAAI,EAAE,YAAY,CAAC;CACpB;AAED,MAAM,WAAW,WAAW;IAC1B,KAAK,EAAE,YAAY,CAAC;IACpB,SAAS,EAAE,gBAAgB,CAAC;CAC7B"}
@@ -0,0 +1,2 @@
1
+ export var tooltipName = 'Tooltip';
2
+ //# sourceMappingURL=Tooltip.types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Tooltip.types.js","sourceRoot":"","sources":["../src/Tooltip.types.ts"],"names":[],"mappings":"AAKA,MAAM,CAAC,IAAM,WAAW,GAAG,SAAS,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=Tooltip.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Tooltip.test.d.ts","sourceRoot":"","sources":["../../src/__tests__/Tooltip.test.tsx"],"names":[],"mappings":""}
@@ -0,0 +1,24 @@
1
+ import * as React from 'react';
2
+ import { ButtonV1 } from '@fluentui-react-native/button';
3
+ import { checkRenderConsistency, checkReRender } from '@fluentui-react-native/test-tools';
4
+ import * as renderer from 'react-test-renderer';
5
+ import { Tooltip } from '../Tooltip';
6
+ describe('Tooltip component tests', function () {
7
+ it('Tooltip default', function () {
8
+ var tree = renderer
9
+ .create(React.createElement(Tooltip, { content: "Your component" },
10
+ React.createElement(ButtonV1, null, "Your component")))
11
+ .toJSON();
12
+ expect(tree).toMatchSnapshot();
13
+ });
14
+ it('Tooltip simple rendering does not invalidate styling', function () {
15
+ checkRenderConsistency(function () { return (React.createElement(Tooltip, { content: "Default Tooltip" },
16
+ React.createElement(ButtonV1, null, "Default Tooltip"))); }, 2);
17
+ });
18
+ it('Tooltip re-renders correctly', function () {
19
+ checkReRender(function () { return (React.createElement(Tooltip, { content: "Render twice" },
20
+ React.createElement(ButtonV1, null, "Render twice"))); }, 2);
21
+ });
22
+ // Feel free to add more tests here
23
+ });
24
+ //# sourceMappingURL=Tooltip.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Tooltip.test.js","sourceRoot":"","sources":["../../src/__tests__/Tooltip.test.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,EAAE,QAAQ,EAAE,MAAM,+BAA+B,CAAC;AACzD,OAAO,EAAE,sBAAsB,EAAE,aAAa,EAAE,MAAM,mCAAmC,CAAC;AAC1F,OAAO,KAAK,QAAQ,MAAM,qBAAqB,CAAC;AAEhD,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAErC,QAAQ,CAAC,yBAAyB,EAAE;IAClC,EAAE,CAAC,iBAAiB,EAAE;QACpB,IAAM,IAAI,GAAG,QAAQ;aAClB,MAAM,CACL,oBAAC,OAAO,IAAC,OAAO,EAAC,gBAAgB;YAC/B,oBAAC,QAAQ,yBAA0B,CAC3B,CACX;aACA,MAAM,EAAE,CAAC;QACZ,MAAM,CAAC,IAAI,CAAC,CAAC,eAAe,EAAE,CAAC;IACjC,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,sDAAsD,EAAE;QACzD,sBAAsB,CACpB,cAAM,OAAA,CACJ,oBAAC,OAAO,IAAC,OAAO,EAAC,iBAAiB;YAChC,oBAAC,QAAQ,0BAA2B,CAC5B,CACX,EAJK,CAIL,EACD,CAAC,CACF,CAAC;IACJ,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,8BAA8B,EAAE;QACjC,aAAa,CACX,cAAM,OAAA,CACJ,oBAAC,OAAO,IAAC,OAAO,EAAC,cAAc;YAC7B,oBAAC,QAAQ,uBAAwB,CACzB,CACX,EAJK,CAIL,EACD,CAAC,CACF,CAAC;IACJ,CAAC,CAAC,CAAC;IAEH,mCAAmC;AACrC,CAAC,CAAC,CAAC"}
package/lib/index.d.ts ADDED
@@ -0,0 +1,4 @@
1
+ export { Tooltip } from './Tooltip';
2
+ export { tooltipName } from './Tooltip.types';
3
+ export type { TooltipProps, TooltipSlotProps, TooltipType } from './Tooltip.types';
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAC9C,YAAY,EAAE,YAAY,EAAE,gBAAgB,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC"}
package/lib/index.js ADDED
@@ -0,0 +1,3 @@
1
+ export { Tooltip } from './Tooltip';
2
+ export { tooltipName } from './Tooltip.types';
3
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC"}
@@ -0,0 +1,12 @@
1
+ import type { TooltipProps } from './Tooltip.types';
2
+ /**
3
+ * A function which determines if a set of styles should be applied to the component given the current state and props of the tooltip.
4
+ *
5
+ * @param layer The name of the state that is being checked for
6
+ * @param userProps The props that were passed into the tooltip
7
+ * @returns Whether the styles that are assigned to the layer should be applied to the tooltip
8
+ */
9
+ export declare const tooltipLookup: (layer: string, userProps: TooltipProps) => boolean;
10
+ export declare const Tooltip: import("@fluentui-react-native/framework").ComposableFunction<TooltipProps>;
11
+ export default Tooltip;
12
+ //# sourceMappingURL=Tooltip.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Tooltip.d.ts","sourceRoot":"","sources":["../src/Tooltip.tsx"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAKpD;;;;;;GAMG;AACH,eAAO,MAAM,aAAa,UAAW,MAAM,aAAa,YAAY,KAAG,OAEtE,CAAC;AAEF,eAAO,MAAM,OAAO,6EAIlB,CAAC;AAIH,eAAe,OAAO,CAAC"}
@@ -0,0 +1,29 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Tooltip = exports.tooltipLookup = void 0;
4
+ var tslib_1 = require("tslib");
5
+ /** @jsxRuntime classic */
6
+ var React = tslib_1.__importStar(require("react"));
7
+ var component_cache_1 = require("@fluentui-react-native/component-cache");
8
+ var framework_1 = require("@fluentui-react-native/framework");
9
+ var Tooltip_types_1 = require("./Tooltip.types");
10
+ var NativeTooltipView = (0, component_cache_1.ensureNativeComponent)('RCTTooltip');
11
+ /**
12
+ * A function which determines if a set of styles should be applied to the component given the current state and props of the tooltip.
13
+ *
14
+ * @param layer The name of the state that is being checked for
15
+ * @param userProps The props that were passed into the tooltip
16
+ * @returns Whether the styles that are assigned to the layer should be applied to the tooltip
17
+ */
18
+ var tooltipLookup = function (layer, userProps) {
19
+ return userProps[layer];
20
+ };
21
+ exports.tooltipLookup = tooltipLookup;
22
+ exports.Tooltip = (0, framework_1.stagedComponent)(function (props) {
23
+ return function (rest, children) {
24
+ return React.createElement(NativeTooltipView, tslib_1.__assign({}, (0, framework_1.mergeProps)(props, rest)), children);
25
+ };
26
+ });
27
+ exports.Tooltip.displayName = Tooltip_types_1.tooltipName;
28
+ exports.default = exports.Tooltip;
29
+ //# sourceMappingURL=Tooltip.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Tooltip.js","sourceRoot":"","sources":["../src/Tooltip.tsx"],"names":[],"mappings":";;;;AAAA,0BAA0B;AAC1B,mDAA+B;AAE/B,0EAA+E;AAC/E,8DAA+E;AAG/E,iDAA8C;AAE9C,IAAM,iBAAiB,GAAG,IAAA,uCAAqB,EAAC,YAAY,CAAC,CAAC;AAE9D;;;;;;GAMG;AACI,IAAM,aAAa,GAAG,UAAC,KAAa,EAAE,SAAuB;IAClE,OAAO,SAAS,CAAC,KAAK,CAAC,CAAC;AAC1B,CAAC,CAAC;AAFW,QAAA,aAAa,iBAExB;AAEW,QAAA,OAAO,GAAG,IAAA,2BAAe,EAAC,UAAC,KAAmB;IACzD,OAAO,UAAC,IAAkB,EAAE,QAAyB;QACnD,OAAO,oBAAC,iBAAiB,uBAAK,IAAA,sBAAU,EAAC,KAAK,EAAE,IAAI,CAAC,GAAG,QAAQ,CAAqB,CAAC;IACxF,CAAC,CAAC;AACJ,CAAC,CAAC,CAAC;AAEH,eAAO,CAAC,WAAW,GAAG,2BAAW,CAAC;AAElC,kBAAe,eAAO,CAAC"}
@@ -0,0 +1,45 @@
1
+ import type * as React from 'react';
2
+ import type { ViewStyle } from 'react-native';
3
+ import type { DirectionalHint } from '@fluentui-react-native/callout';
4
+ export declare const tooltipName = "Tooltip";
5
+ export type TooltipProps = React.PropsWithChildren<{
6
+ /**
7
+ * The text of the tooltip.
8
+ */
9
+ content: string;
10
+ /**
11
+ * Notification when the visibility of the tooltip is changed.
12
+ */
13
+ onVisibleChange?: (event: any, data: any) => void;
14
+ /**
15
+ * Positioning of the tooltip relative to the target element.
16
+ *
17
+ * @default topCenter
18
+ */
19
+ positioning?: DirectionalHint;
20
+ /**
21
+ * Allow consumers to pass in Style props
22
+ */
23
+ style?: ViewStyle;
24
+ /**
25
+ * Target anchor that tooltip uses for relative positioning. Certain components may proffer a string as an anchor target, such as
26
+ * anchoring to a point inside the component.
27
+ *
28
+ * If not provided, will anchor to the wrapper element.
29
+ */
30
+ target?: React.RefObject<React.Component> | string;
31
+ /**
32
+ * 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.
33
+ *
34
+ * @default false
35
+ */
36
+ visible?: boolean;
37
+ }>;
38
+ export interface TooltipSlotProps {
39
+ root: TooltipProps;
40
+ }
41
+ export interface TooltipType {
42
+ props: TooltipProps;
43
+ slotProps: TooltipSlotProps;
44
+ }
45
+ //# sourceMappingURL=Tooltip.types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Tooltip.types.d.ts","sourceRoot":"","sources":["../src/Tooltip.types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,KAAK,MAAM,OAAO,CAAC;AACpC,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAE9C,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,gCAAgC,CAAC;AAEtE,eAAO,MAAM,WAAW,YAAY,CAAC;AAErC,MAAM,MAAM,YAAY,GAAG,KAAK,CAAC,iBAAiB,CAAC;IACjD;;OAEG;IACH,OAAO,EAAE,MAAM,CAAC;IAEhB;;OAEG;IACH,eAAe,CAAC,EAAE,CAAC,KAAK,KAAA,EAAE,IAAI,KAAA,KAAK,IAAI,CAAC;IAExC;;;;OAIG;IACH,WAAW,CAAC,EAAE,eAAe,CAAC;IAE9B;;OAEG;IACH,KAAK,CAAC,EAAE,SAAS,CAAC;IAElB;;;;;OAKG;IACH,MAAM,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC,KAAK,CAAC,SAAS,CAAC,GAAG,MAAM,CAAC;IAEnD;;;;OAIG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB,CAAC,CAAC;AAEH,MAAM,WAAW,gBAAgB;IAC/B,IAAI,EAAE,YAAY,CAAC;CACpB;AAED,MAAM,WAAW,WAAW;IAC1B,KAAK,EAAE,YAAY,CAAC;IACpB,SAAS,EAAE,gBAAgB,CAAC;CAC7B"}
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.tooltipName = void 0;
4
+ exports.tooltipName = 'Tooltip';
5
+ //# sourceMappingURL=Tooltip.types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Tooltip.types.js","sourceRoot":"","sources":["../src/Tooltip.types.ts"],"names":[],"mappings":";;;AAKa,QAAA,WAAW,GAAG,SAAS,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=Tooltip.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Tooltip.test.d.ts","sourceRoot":"","sources":["../../src/__tests__/Tooltip.test.tsx"],"names":[],"mappings":""}
@@ -0,0 +1,27 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ var tslib_1 = require("tslib");
4
+ var React = tslib_1.__importStar(require("react"));
5
+ var button_1 = require("@fluentui-react-native/button");
6
+ var test_tools_1 = require("@fluentui-react-native/test-tools");
7
+ var renderer = tslib_1.__importStar(require("react-test-renderer"));
8
+ var Tooltip_1 = require("../Tooltip");
9
+ describe('Tooltip component tests', function () {
10
+ it('Tooltip default', function () {
11
+ var tree = renderer
12
+ .create(React.createElement(Tooltip_1.Tooltip, { content: "Your component" },
13
+ React.createElement(button_1.ButtonV1, null, "Your component")))
14
+ .toJSON();
15
+ expect(tree).toMatchSnapshot();
16
+ });
17
+ it('Tooltip simple rendering does not invalidate styling', function () {
18
+ (0, test_tools_1.checkRenderConsistency)(function () { return (React.createElement(Tooltip_1.Tooltip, { content: "Default Tooltip" },
19
+ React.createElement(button_1.ButtonV1, null, "Default Tooltip"))); }, 2);
20
+ });
21
+ it('Tooltip re-renders correctly', function () {
22
+ (0, test_tools_1.checkReRender)(function () { return (React.createElement(Tooltip_1.Tooltip, { content: "Render twice" },
23
+ React.createElement(button_1.ButtonV1, null, "Render twice"))); }, 2);
24
+ });
25
+ // Feel free to add more tests here
26
+ });
27
+ //# sourceMappingURL=Tooltip.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Tooltip.test.js","sourceRoot":"","sources":["../../src/__tests__/Tooltip.test.tsx"],"names":[],"mappings":";;;AAAA,mDAA+B;AAE/B,wDAAyD;AACzD,gEAA0F;AAC1F,oEAAgD;AAEhD,sCAAqC;AAErC,QAAQ,CAAC,yBAAyB,EAAE;IAClC,EAAE,CAAC,iBAAiB,EAAE;QACpB,IAAM,IAAI,GAAG,QAAQ;aAClB,MAAM,CACL,oBAAC,iBAAO,IAAC,OAAO,EAAC,gBAAgB;YAC/B,oBAAC,iBAAQ,yBAA0B,CAC3B,CACX;aACA,MAAM,EAAE,CAAC;QACZ,MAAM,CAAC,IAAI,CAAC,CAAC,eAAe,EAAE,CAAC;IACjC,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,sDAAsD,EAAE;QACzD,IAAA,mCAAsB,EACpB,cAAM,OAAA,CACJ,oBAAC,iBAAO,IAAC,OAAO,EAAC,iBAAiB;YAChC,oBAAC,iBAAQ,0BAA2B,CAC5B,CACX,EAJK,CAIL,EACD,CAAC,CACF,CAAC;IACJ,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,8BAA8B,EAAE;QACjC,IAAA,0BAAa,EACX,cAAM,OAAA,CACJ,oBAAC,iBAAO,IAAC,OAAO,EAAC,cAAc;YAC7B,oBAAC,iBAAQ,uBAAwB,CACzB,CACX,EAJK,CAIL,EACD,CAAC,CACF,CAAC;IACJ,CAAC,CAAC,CAAC;IAEH,mCAAmC;AACrC,CAAC,CAAC,CAAC"}
@@ -0,0 +1,4 @@
1
+ export { Tooltip } from './Tooltip';
2
+ export { tooltipName } from './Tooltip.types';
3
+ export type { TooltipProps, TooltipSlotProps, TooltipType } from './Tooltip.types';
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAC9C,YAAY,EAAE,YAAY,EAAE,gBAAgB,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC"}
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.tooltipName = exports.Tooltip = void 0;
4
+ var Tooltip_1 = require("./Tooltip");
5
+ Object.defineProperty(exports, "Tooltip", { enumerable: true, get: function () { return Tooltip_1.Tooltip; } });
6
+ var Tooltip_types_1 = require("./Tooltip.types");
7
+ Object.defineProperty(exports, "tooltipName", { enumerable: true, get: function () { return Tooltip_types_1.tooltipName; } });
8
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,qCAAoC;AAA3B,kGAAA,OAAO,OAAA;AAChB,iDAA8C;AAArC,4GAAA,WAAW,OAAA"}
package/package.json ADDED
@@ -0,0 +1,61 @@
1
+ {
2
+ "name": "@fluentui-react-native/tooltip",
3
+ "version": "0.2.0",
4
+ "description": "A cross-platform Tooltip component for React Native.",
5
+ "main": "lib-commonjs/index.js",
6
+ "module": "lib/index.js",
7
+ "typings": "lib/index.d.ts",
8
+ "scripts": {
9
+ "build": "fluentui-scripts build",
10
+ "clean": "fluentui-scripts clean",
11
+ "depcheck": "fluentui-scripts depcheck",
12
+ "just": "fluentui-scripts",
13
+ "lint": "fluentui-scripts eslint",
14
+ "test": "fluentui-scripts jest",
15
+ "update-snapshots": "fluentui-scripts jest -u",
16
+ "prettier": "fluentui-scripts prettier",
17
+ "prettier-fix": "fluentui-scripts prettier --fix true"
18
+ },
19
+ "repository": {
20
+ "type": "git",
21
+ "url": "https://github.com/microsoft/fluentui-react-native.git",
22
+ "directory": "packages/experimental/Tooltip"
23
+ },
24
+ "dependencies": {
25
+ "@fluentui-react-native/callout": "^0.25.0",
26
+ "@fluentui-react-native/component-cache": "^1.6.0",
27
+ "@fluentui-react-native/framework": "0.12.0",
28
+ "tslib": "^2.3.1"
29
+ },
30
+ "devDependencies": {
31
+ "@fluentui-react-native/button": "^0.36.1",
32
+ "@fluentui-react-native/eslint-config-rules": "^0.1.1",
33
+ "@fluentui-react-native/scripts": "^0.1.1",
34
+ "@fluentui-react-native/test-tools": ">=0.1.1 <1.0.0",
35
+ "@office-iss/react-native-win32": "^0.72.0",
36
+ "@react-native/metro-config": "^0.72.0",
37
+ "react": "18.2.0",
38
+ "react-native": "^0.72.0"
39
+ },
40
+ "peerDependencies": {
41
+ "react": "18.2.0",
42
+ "react-native": "^0.72.0"
43
+ },
44
+ "author": "",
45
+ "license": "MIT",
46
+ "rnx-kit": {
47
+ "kitType": "library",
48
+ "alignDeps": {
49
+ "presets": [
50
+ "microsoft/react-native"
51
+ ],
52
+ "requirements": [
53
+ "react-native@0.72"
54
+ ],
55
+ "capabilities": [
56
+ "core",
57
+ "react"
58
+ ]
59
+ }
60
+ }
61
+ }
@@ -0,0 +1,31 @@
1
+ /** @jsxRuntime classic */
2
+ import * as React from 'react';
3
+
4
+ import { ensureNativeComponent } from '@fluentui-react-native/component-cache';
5
+ import { mergeProps, stagedComponent } from '@fluentui-react-native/framework';
6
+
7
+ import type { TooltipProps } from './Tooltip.types';
8
+ import { tooltipName } from './Tooltip.types';
9
+
10
+ const NativeTooltipView = ensureNativeComponent('RCTTooltip');
11
+
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 const tooltipLookup = (layer: string, userProps: TooltipProps): boolean => {
20
+ return userProps[layer];
21
+ };
22
+
23
+ export const Tooltip = stagedComponent((props: TooltipProps) => {
24
+ return (rest: TooltipProps, children: React.ReactNode) => {
25
+ return <NativeTooltipView {...mergeProps(props, rest)}>{children}</NativeTooltipView>;
26
+ };
27
+ });
28
+
29
+ Tooltip.displayName = tooltipName;
30
+
31
+ export default Tooltip;
@@ -0,0 +1,54 @@
1
+ import type * as React from 'react';
2
+ import type { ViewStyle } from 'react-native';
3
+
4
+ import type { DirectionalHint } from '@fluentui-react-native/callout';
5
+
6
+ export const tooltipName = 'Tooltip';
7
+
8
+ export type TooltipProps = React.PropsWithChildren<{
9
+ /**
10
+ * The text of the tooltip.
11
+ */
12
+ content: string;
13
+
14
+ /**
15
+ * Notification when the visibility of the tooltip is changed.
16
+ */
17
+ onVisibleChange?: (event, data) => void;
18
+
19
+ /**
20
+ * Positioning of the tooltip relative to the target element.
21
+ *
22
+ * @default topCenter
23
+ */
24
+ positioning?: DirectionalHint;
25
+
26
+ /**
27
+ * Allow consumers to pass in Style props
28
+ */
29
+ style?: ViewStyle;
30
+
31
+ /**
32
+ * Target anchor that tooltip uses for relative positioning. Certain components may proffer a string as an anchor target, such as
33
+ * anchoring to a point inside the component.
34
+ *
35
+ * If not provided, will anchor to the wrapper element.
36
+ */
37
+ target?: React.RefObject<React.Component> | string;
38
+
39
+ /**
40
+ * 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.
41
+ *
42
+ * @default false
43
+ */
44
+ visible?: boolean;
45
+ }>;
46
+
47
+ export interface TooltipSlotProps {
48
+ root: TooltipProps;
49
+ }
50
+
51
+ export interface TooltipType {
52
+ props: TooltipProps;
53
+ slotProps: TooltipSlotProps;
54
+ }
@@ -0,0 +1,44 @@
1
+ import * as React from 'react';
2
+
3
+ import { ButtonV1 } from '@fluentui-react-native/button';
4
+ import { checkRenderConsistency, checkReRender } from '@fluentui-react-native/test-tools';
5
+ import * as renderer from 'react-test-renderer';
6
+
7
+ import { Tooltip } from '../Tooltip';
8
+
9
+ describe('Tooltip component tests', () => {
10
+ it('Tooltip default', () => {
11
+ const tree = renderer
12
+ .create(
13
+ <Tooltip content="Your component">
14
+ <ButtonV1>Your component</ButtonV1>
15
+ </Tooltip>,
16
+ )
17
+ .toJSON();
18
+ expect(tree).toMatchSnapshot();
19
+ });
20
+
21
+ it('Tooltip simple rendering does not invalidate styling', () => {
22
+ checkRenderConsistency(
23
+ () => (
24
+ <Tooltip content="Default Tooltip">
25
+ <ButtonV1>Default Tooltip</ButtonV1>
26
+ </Tooltip>
27
+ ),
28
+ 2,
29
+ );
30
+ });
31
+
32
+ it('Tooltip re-renders correctly', () => {
33
+ checkReRender(
34
+ () => (
35
+ <Tooltip content="Render twice">
36
+ <ButtonV1>Render twice</ButtonV1>
37
+ </Tooltip>
38
+ ),
39
+ 2,
40
+ );
41
+ });
42
+
43
+ // Feel free to add more tests here
44
+ });
@@ -0,0 +1,98 @@
1
+ // Jest Snapshot v1, https://goo.gl/fbAQLP
2
+
3
+ exports[`Tooltip component tests Tooltip default 1`] = `
4
+ <RCTTooltip
5
+ content="Your component"
6
+ >
7
+ <View
8
+ accessibilityLabel="Your component"
9
+ accessibilityRole="button"
10
+ accessibilityState={
11
+ {
12
+ "busy": undefined,
13
+ "checked": undefined,
14
+ "disabled": false,
15
+ "expanded": undefined,
16
+ "multiselectable": undefined,
17
+ "required": undefined,
18
+ "selected": undefined,
19
+ }
20
+ }
21
+ accessibilityValue={
22
+ {
23
+ "max": undefined,
24
+ "min": undefined,
25
+ "now": undefined,
26
+ "text": undefined,
27
+ }
28
+ }
29
+ accessible={true}
30
+ enableFocusRing={true}
31
+ focusable={true}
32
+ keyUpEvents={
33
+ [
34
+ {
35
+ "key": " ",
36
+ },
37
+ {
38
+ "key": "Enter",
39
+ },
40
+ ]
41
+ }
42
+ onBlur={[Function]}
43
+ onClick={[Function]}
44
+ onFocus={[Function]}
45
+ onKeyDown={[Function]}
46
+ onKeyUp={[Function]}
47
+ onLayout={[Function]}
48
+ onMouseEnter={[Function]}
49
+ onMouseLeave={[Function]}
50
+ onResponderGrant={[Function]}
51
+ onResponderMove={[Function]}
52
+ onResponderRelease={[Function]}
53
+ onResponderTerminate={[Function]}
54
+ onResponderTerminationRequest={[Function]}
55
+ onStartShouldSetResponder={[Function]}
56
+ style={
57
+ {
58
+ "alignItems": "center",
59
+ "alignSelf": "flex-start",
60
+ "backgroundColor": "#ffffff",
61
+ "borderColor": "#d1d1d1",
62
+ "borderRadius": 4,
63
+ "borderWidth": 1,
64
+ "display": "flex",
65
+ "flexDirection": "row",
66
+ "justifyContent": "center",
67
+ "minHeight": 24,
68
+ "minWidth": 64,
69
+ "padding": 3,
70
+ "paddingHorizontal": 7,
71
+ "width": undefined,
72
+ }
73
+ }
74
+ >
75
+ <Text
76
+ accessible={false}
77
+ ellipsizeMode="tail"
78
+ numberOfLines={0}
79
+ onAccessibilityTap={[Function]}
80
+ style={
81
+ {
82
+ "color": "#242424",
83
+ "fontFamily": "Segoe UI",
84
+ "fontSize": 12,
85
+ "fontWeight": "400",
86
+ "margin": 0,
87
+ "marginBottom": 1,
88
+ "marginEnd": -2,
89
+ "marginStart": 0,
90
+ "marginTop": -1,
91
+ }
92
+ }
93
+ >
94
+ Your component
95
+ </Text>
96
+ </View>
97
+ </RCTTooltip>
98
+ `;
package/src/index.ts ADDED
@@ -0,0 +1,3 @@
1
+ export { Tooltip } from './Tooltip';
2
+ export { tooltipName } from './Tooltip.types';
3
+ export type { TooltipProps, TooltipSlotProps, TooltipType } from './Tooltip.types';
package/tsconfig.json ADDED
@@ -0,0 +1,9 @@
1
+ {
2
+ "extends": "@fluentui-react-native/scripts/tsconfig.json",
3
+ "compilerOptions": {
4
+ "importHelpers": true,
5
+ "outDir": "lib",
6
+ "types": ["node", "jest"]
7
+ },
8
+ "include": ["src"]
9
+ }