@clayui/tooltip 3.49.0 → 3.56.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.
- package/README.md +19 -0
- package/lib/Tooltip.d.ts +10 -0
- package/lib/TooltipProvider.d.ts +21 -0
- package/lib/TooltipProvider.js +1 -0
- package/lib/index.d.ts +4 -0
- package/package.json +5 -5
- package/src/TooltipProvider.tsx +2 -0
- package/README.mdx +0 -45
package/README.md
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# `@clayui/tooltip`
|
|
2
|
+
|
|
3
|
+
Tooltips are brief pieces of information that appear on hover state over an element to clarify its meaning or use for the user.
|
|
4
|
+
|
|
5
|
+
- [Documentation](https://clayui.com/docs/components/tooltip.html)
|
|
6
|
+
- [Changelog](./CHANGELOG.md)
|
|
7
|
+
- [Breaking change schedule](./BREAKING.md)
|
|
8
|
+
|
|
9
|
+
## Install
|
|
10
|
+
|
|
11
|
+
Run `yarn`
|
|
12
|
+
|
|
13
|
+
```shell
|
|
14
|
+
yarn add @clayui/tooltip
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
## Contribute
|
|
18
|
+
|
|
19
|
+
We'd love to get contributions from you! Please, check our [Contributing Guidelines](https://github.com/liferay/clay/blob/master/CONTRIBUTING.md) to see how you can help us improve.
|
package/lib/Tooltip.d.ts
CHANGED
|
@@ -1,7 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SPDX-FileCopyrightText: © 2019 Liferay, Inc. <https://liferay.com>
|
|
3
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
4
|
+
*/
|
|
1
5
|
import React from 'react';
|
|
2
6
|
export declare const ALIGN_POSITIONS: readonly ["top", "top-left", "top-right", "bottom", "bottom-left", "bottom-right", "left", "right"];
|
|
3
7
|
interface IProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
8
|
+
/**
|
|
9
|
+
* Position in which the tooltip will be aligned to the element.
|
|
10
|
+
*/
|
|
4
11
|
alignPosition?: typeof ALIGN_POSITIONS[number];
|
|
12
|
+
/**
|
|
13
|
+
* Flag to indicate if tooltip is displayed.
|
|
14
|
+
*/
|
|
5
15
|
show?: boolean;
|
|
6
16
|
}
|
|
7
17
|
declare const ClayTooltip: React.ForwardRefExoticComponent<IProps & React.RefAttributes<HTMLElement>>;
|
package/lib/TooltipProvider.d.ts
CHANGED
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SPDX-FileCopyrightText: © 2019 Liferay, Inc. <https://liferay.com>
|
|
3
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
4
|
+
*/
|
|
1
5
|
import { IPortalBaseProps } from '@clayui/shared';
|
|
2
6
|
import React from 'react';
|
|
3
7
|
declare type TContentRenderer = (props: {
|
|
@@ -5,9 +9,21 @@ declare type TContentRenderer = (props: {
|
|
|
5
9
|
title: string;
|
|
6
10
|
}) => React.ReactElement | React.ReactNode;
|
|
7
11
|
interface IPropsBase {
|
|
12
|
+
/**
|
|
13
|
+
* Flag to indicate if tooltip should automatically align based on the window
|
|
14
|
+
*/
|
|
8
15
|
autoAlign?: boolean;
|
|
16
|
+
/**
|
|
17
|
+
* Props to add to the <ClayPortal/>.
|
|
18
|
+
*/
|
|
9
19
|
containerProps?: IPortalBaseProps;
|
|
20
|
+
/**
|
|
21
|
+
* Custom function for rendering the contents of the tooltip
|
|
22
|
+
*/
|
|
10
23
|
contentRenderer?: TContentRenderer;
|
|
24
|
+
/**
|
|
25
|
+
* Delay in miliseconds before showing tooltip
|
|
26
|
+
*/
|
|
11
27
|
delay?: number;
|
|
12
28
|
}
|
|
13
29
|
interface IPropsWithChildren extends IPropsBase {
|
|
@@ -16,6 +32,11 @@ interface IPropsWithChildren extends IPropsBase {
|
|
|
16
32
|
}
|
|
17
33
|
interface IPropsWithScope extends IPropsBase {
|
|
18
34
|
children?: never;
|
|
35
|
+
/**
|
|
36
|
+
* CSS selector to scope provider to. All titles within this scope will be
|
|
37
|
+
* rendered in the tooltip. Titles outside of this scope will be styled
|
|
38
|
+
* as with the default browser.
|
|
39
|
+
*/
|
|
19
40
|
scope: string;
|
|
20
41
|
}
|
|
21
42
|
declare const TooltipProvider: React.FunctionComponent<IPropsWithChildren | IPropsWithScope>;
|
package/lib/TooltipProvider.js
CHANGED
|
@@ -233,6 +233,7 @@ var TooltipProvider = function TooltipProvider(_ref2) {
|
|
|
233
233
|
|
|
234
234
|
var _setAsHTML = !!titleNode.getAttribute('data-title-set-as-html');
|
|
235
235
|
|
|
236
|
+
clearTimeout(timeoutIdRef.current);
|
|
236
237
|
timeoutIdRef.current = setTimeout(function () {
|
|
237
238
|
dispatch({
|
|
238
239
|
align: newAlign || align,
|
package/lib/index.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@clayui/tooltip",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.56.0",
|
|
4
4
|
"description": "ClayTooltip component",
|
|
5
5
|
"license": "BSD-3-Clause",
|
|
6
6
|
"repository": "https://github.com/liferay/clay",
|
|
@@ -17,8 +17,8 @@
|
|
|
17
17
|
],
|
|
18
18
|
"scripts": {
|
|
19
19
|
"build": "cross-env NODE_ENV=production babel src --root-mode upward --out-dir lib --extensions .ts,.tsx",
|
|
20
|
-
"
|
|
21
|
-
"prepublishOnly": "yarn build && yarn
|
|
20
|
+
"buildTypes": "cross-env NODE_ENV=production tsc --project ./tsconfig.declarations.json",
|
|
21
|
+
"prepublishOnly": "yarn build && yarn buildTypes",
|
|
22
22
|
"test": "jest --config ../../jest.config.js"
|
|
23
23
|
},
|
|
24
24
|
"keywords": [
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
"react"
|
|
27
27
|
],
|
|
28
28
|
"dependencies": {
|
|
29
|
-
"@clayui/shared": "^3.
|
|
29
|
+
"@clayui/shared": "^3.56.0",
|
|
30
30
|
"classnames": "^2.2.6",
|
|
31
31
|
"warning": "^4.0.3"
|
|
32
32
|
},
|
|
@@ -38,5 +38,5 @@
|
|
|
38
38
|
"browserslist": [
|
|
39
39
|
"extends browserslist-config-clay"
|
|
40
40
|
],
|
|
41
|
-
"gitHead": "
|
|
41
|
+
"gitHead": "1c33d9c709d8ce071862f0087c76ac23ce11465b"
|
|
42
42
|
}
|
package/src/TooltipProvider.tsx
CHANGED
package/README.mdx
DELETED
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
title: 'Tooltip'
|
|
3
|
-
description: 'Tooltips are brief pieces of information that appear on hover state over an element to clarify its meaning or use for the user.'
|
|
4
|
-
lexiconDefinition: 'https://liferay.design/lexicon/core-components/popovers-tooltips/'
|
|
5
|
-
packageNpm: '@clayui/tooltip'
|
|
6
|
-
---
|
|
7
|
-
|
|
8
|
-
import {
|
|
9
|
-
Tooltip,
|
|
10
|
-
TooltipProvider,
|
|
11
|
-
TooltipProviderRenderer,
|
|
12
|
-
} from '$packages/clay-tooltip/docs/index';
|
|
13
|
-
|
|
14
|
-
<div class="nav-toc-absolute">
|
|
15
|
-
<div class="nav-toc">
|
|
16
|
-
|
|
17
|
-
- [TooltipProvider](#tooltipprovider)
|
|
18
|
-
- [contentRenderer](#contentrenderer)
|
|
19
|
-
|
|
20
|
-
</div>
|
|
21
|
-
</div>
|
|
22
|
-
|
|
23
|
-
Simplest way of using Tooltip is by leveraging it's `show` prop and specifying `alignPosition` to determine it's position relative to the element it's aligned to.
|
|
24
|
-
|
|
25
|
-
If you have multiple Tooltips on the page, [TooltipProvider](#tooltipprovider) allows you to only have to instantiate the component once and simply provide html attributes to the elements that need tooltips.
|
|
26
|
-
|
|
27
|
-
<Tooltip />
|
|
28
|
-
|
|
29
|
-
## TooltipProvider
|
|
30
|
-
|
|
31
|
-
By using the `<TooltipProvider>` it allows you to add the desired tooltip content on each element as a data attribute.
|
|
32
|
-
|
|
33
|
-
Here's a list of html attributes that you can provide to children elements of the TooltipProvider:
|
|
34
|
-
|
|
35
|
-
- `title` is for the tooltip content.
|
|
36
|
-
- `data-tooltip-align` is for alignment direction.
|
|
37
|
-
- `data-tooltip-delay` is for the delay(ms) before showing the tooltip.
|
|
38
|
-
|
|
39
|
-
<TooltipProvider />
|
|
40
|
-
|
|
41
|
-
### contentRenderer
|
|
42
|
-
|
|
43
|
-
`contentRenderer` prop gives you the ability to format the content passed to the Tooltip via the `title` attribute to meet your requirements.
|
|
44
|
-
|
|
45
|
-
<TooltipProviderRenderer />
|