react-tooltip 5.0.0-beta.0 → 5.0.0-beta.2

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 (109) hide show
  1. package/.eslintrc.json +2 -1
  2. package/CODE_OF_CONDUCT.md +53 -0
  3. package/LICENSE +1 -2
  4. package/README.md +30 -152
  5. package/coverage/clover.xml +610 -0
  6. package/coverage/coverage-final.json +11 -0
  7. package/coverage/lcov-report/base.css +224 -0
  8. package/coverage/lcov-report/block-navigation.js +87 -0
  9. package/coverage/lcov-report/components/Tooltip/Tooltip.tsx.html +646 -0
  10. package/coverage/lcov-report/components/Tooltip/index.html +146 -0
  11. package/coverage/lcov-report/components/Tooltip/index.ts.html +88 -0
  12. package/coverage/lcov-report/components/Tooltip/styles.module.css.html +277 -0
  13. package/coverage/lcov-report/components/TooltipContent/TooltipContent.tsx.html +109 -0
  14. package/coverage/lcov-report/components/TooltipContent/index.html +131 -0
  15. package/coverage/lcov-report/components/TooltipContent/index.ts.html +88 -0
  16. package/coverage/lcov-report/components/TooltipController/TooltipController.tsx.html +664 -0
  17. package/coverage/lcov-report/components/TooltipController/constants.ts.html +118 -0
  18. package/coverage/lcov-report/components/TooltipController/index.html +146 -0
  19. package/coverage/lcov-report/components/TooltipController/index.ts.html +88 -0
  20. package/coverage/lcov-report/favicon.png +0 -0
  21. package/coverage/lcov-report/index.html +161 -0
  22. package/coverage/lcov-report/prettify.css +1 -0
  23. package/coverage/lcov-report/prettify.js +2 -0
  24. package/coverage/lcov-report/sort-arrow-sprite.png +0 -0
  25. package/coverage/lcov-report/sorter.js +196 -0
  26. package/coverage/lcov-report/sum.js.html +97 -0
  27. package/coverage/lcov-report/sum.ts.html +100 -0
  28. package/coverage/lcov-report/test/index.html +116 -0
  29. package/coverage/lcov-report/test/sum.ts.html +100 -0
  30. package/coverage/lcov-report/utils/compute-positions.ts.html +277 -0
  31. package/coverage/lcov-report/utils/debounce.ts.html +181 -0
  32. package/coverage/lcov-report/utils/index.html +131 -0
  33. package/coverage/lcov.info +729 -0
  34. package/dist/react-tooltip-tokens.css +8 -0
  35. package/dist/react-tooltip.cjs.js +3 -6
  36. package/dist/react-tooltip.cjs.min.js +1 -1
  37. package/dist/react-tooltip.d.ts +25 -0
  38. package/dist/react-tooltip.esm.js +3 -6
  39. package/dist/react-tooltip.esm.min.js +1 -1
  40. package/dist/react-tooltip.umd.js +3 -6
  41. package/dist/react-tooltip.umd.min.js +1 -1
  42. package/jest.config.ts +214 -0
  43. package/package.json +14 -6
  44. package/rollup.config.types.js +13 -3
  45. package/tsconfig.json +2 -2
  46. package/.github/FUNDING.yml +0 -13
  47. package/.github/workflows/lint.yaml +0 -35
  48. package/.github/workflows/pull-request.yaml +0 -11
  49. package/.github/workflows/release.yaml +0 -30
  50. package/.husky/pre-commit +0 -6
  51. package/.vscode/settings.json +0 -27
  52. package/build/dist/react-tooltip.cjs.js +0 -2909
  53. package/build/dist/react-tooltip.cjs.min.js +0 -6
  54. package/build/dist/react-tooltip.css +0 -73
  55. package/build/dist/react-tooltip.esm.js +0 -2901
  56. package/build/dist/react-tooltip.esm.min.js +0 -6
  57. package/build/dist/react-tooltip.min.css +0 -1
  58. package/build/dist/react-tooltip.umd.js +0 -2913
  59. package/build/dist/react-tooltip.umd.min.js +0 -6
  60. package/build/index.css +0 -79
  61. package/build/index.html +0 -19
  62. package/build/index.js +0 -36190
  63. package/docs/README.md +0 -50
  64. package/docs/babel.config.js +0 -3
  65. package/docs/docs/examples/_category_.json +0 -7
  66. package/docs/docs/examples/basic-examples.mdx +0 -68
  67. package/docs/docs/examples/children.mdx +0 -67
  68. package/docs/docs/examples/content.mdx +0 -80
  69. package/docs/docs/examples/delay.mdx +0 -84
  70. package/docs/docs/examples/events.mdx +0 -85
  71. package/docs/docs/examples/get-content.mdx +0 -58
  72. package/docs/docs/examples/html.mdx +0 -75
  73. package/docs/docs/examples/multiline.mdx +0 -91
  74. package/docs/docs/examples/offset.mdx +0 -69
  75. package/docs/docs/examples/place.mdx +0 -55
  76. package/docs/docs/examples/state.mdx +0 -331
  77. package/docs/docs/examples/styling.mdx +0 -388
  78. package/docs/docs/examples/variant.mdx +0 -100
  79. package/docs/docs/getting-started.md +0 -70
  80. package/docs/docs/options.mdx +0 -105
  81. package/docs/docs/upgrade-guide/_category_.json +0 -7
  82. package/docs/docs/upgrade-guide/basic-examples-v4-v5.mdx +0 -119
  83. package/docs/docs/upgrade-guide/changelog-v4-v5.md +0 -85
  84. package/docs/docusaurus.config.js +0 -126
  85. package/docs/package.json +0 -47
  86. package/docs/sidebars.js +0 -33
  87. package/docs/src/components/HomepageFeatures/index.tsx +0 -70
  88. package/docs/src/components/HomepageFeatures/styles.module.css +0 -11
  89. package/docs/src/css/custom.css +0 -74
  90. package/docs/src/pages/index.module.css +0 -35
  91. package/docs/src/pages/index.tsx +0 -42
  92. package/docs/src/pages/markdown-page.md +0 -7
  93. package/docs/static/.nojekyll +0 -0
  94. package/docs/static/img/docusaurus.png +0 -0
  95. package/docs/static/img/favicon.ico +0 -0
  96. package/docs/static/img/logo.svg +0 -1
  97. package/docs/static/img/undraw_docusaurus_mountain.svg +0 -171
  98. package/docs/static/img/undraw_docusaurus_react.svg +0 -170
  99. package/docs/static/img/undraw_docusaurus_tree.svg +0 -40
  100. package/docs/tsconfig.json +0 -7
  101. package/docs/yarn.lock +0 -7579
  102. package/example-v5/package.json +0 -21
  103. package/example-v5/public/index.html +0 -20
  104. package/example-v5/public/manifest.json +0 -8
  105. package/example-v5/src/App.jsx +0 -908
  106. package/example-v5/src/index.css +0 -238
  107. package/example-v5/src/index.js +0 -15
  108. package/example-v5/src/index.scss +0 -251
  109. package/public/index.html +0 -19
@@ -1,69 +0,0 @@
1
- ---
2
- sidebar_position: 1
3
- ---
4
-
5
- # Offset
6
-
7
- Offset param of ReactTooltip component.
8
-
9
- import { Tooltip } from 'react-tooltip'
10
- import 'react-tooltip/dist/react-tooltip.css'
11
-
12
- export const TooltipAnchor = ({ children, id, ...rest }) => {
13
- return (
14
- <span
15
- id={id}
16
- style={{
17
- display: 'flex',
18
- justifyContent: 'center',
19
- alignItems: 'center',
20
- width: '60px',
21
- height: '60px',
22
- borderRadius: '60px',
23
- color: '#222',
24
- background: 'rgba(255, 255, 255, 1)',
25
- cursor: 'pointer',
26
- boxShadow: '3px 4px 3px rgba(0, 0, 0, 0.5)',
27
- border: '1px solid #333',
28
- }}
29
- {...rest}
30
- >
31
- {children}
32
- </span>
33
- )
34
- }
35
-
36
- `offset` accepts any `number` as param
37
-
38
- ```jsx
39
- import { Tooltip } from 'react-tooltip';
40
- import 'react-tooltip/dist/react-tooltip.css';
41
-
42
- <a id="tooltip-anchor"> ◕‿‿◕ </a>
43
- <Tooltip anchorId="tooltip-anchor" content="Hello World" />
44
-
45
- <a id="tooltip-anchor-20"> ◕‿‿◕ </a>
46
- <Tooltip anchorId="tooltip-anchor-20" content="Hello World" offset={20} />
47
-
48
- <a id="tooltip-anchor-30"> ◕‿‿◕ </a>
49
- <Tooltip anchorId="tooltip-anchor-30" content="Hello World" offset={30} />
50
-
51
- <a id="tooltip-anchor-40"> ◕‿‿◕ </a>
52
- <Tooltip anchorId="tooltip-anchor-40" content="Hello World" offset={40} />
53
-
54
- <a id="tooltip-anchor-50"> ◕‿‿◕ </a>
55
- <Tooltip anchorId="tooltip-anchor-50" content="Hello World" offset={50} />
56
- ```
57
-
58
- <div style={{ display: 'flex', columnGap: '16px', justifyContent: 'center', paddingTop: '36px' }}>
59
- <TooltipAnchor id="tooltip-anchor">◕‿‿◕</TooltipAnchor>
60
- <TooltipAnchor id="tooltip-anchor-20">◕‿‿◕</TooltipAnchor>
61
- <TooltipAnchor id="tooltip-anchor-30">◕‿‿◕</TooltipAnchor>
62
- <TooltipAnchor id="tooltip-anchor-40">◕‿‿◕</TooltipAnchor>
63
- <TooltipAnchor id="tooltip-anchor-50">◕‿‿◕</TooltipAnchor>
64
- <Tooltip anchorId="tooltip-anchor" content="Hello World" />
65
- <Tooltip anchorId="tooltip-anchor-20" content="Hello World" offset={20} />
66
- <Tooltip anchorId="tooltip-anchor-30" content="Hello World" offset={30} />
67
- <Tooltip anchorId="tooltip-anchor-40" content="Hello World" offset={40} />
68
- <Tooltip anchorId="tooltip-anchor-50" content="Hello World" offset={50} />
69
- </div>
@@ -1,55 +0,0 @@
1
- ---
2
- sidebar_position: 1
3
- ---
4
-
5
- # Place
6
-
7
- Available places of ReactTooltip component.
8
-
9
- import { Tooltip } from 'react-tooltip'
10
- import 'react-tooltip/dist/react-tooltip.css'
11
-
12
- export const TooltipAnchor = ({ children, id, ...rest }) => {
13
- return (
14
- <span
15
- id={id}
16
- style={{
17
- display: 'flex',
18
- justifyContent: 'center',
19
- alignItems: 'center',
20
- width: '60px',
21
- height: '60px',
22
- borderRadius: '60px',
23
- color: '#222',
24
- background: 'rgba(255, 255, 255, 1)',
25
- cursor: 'pointer',
26
- boxShadow: '3px 4px 3px rgba(0, 0, 0, 0.5)',
27
- border: '1px solid #333',
28
- }}
29
- {...rest}
30
- >
31
- {children}
32
- </span>
33
- )
34
- }
35
-
36
- `place` available values `top` | `right` | `bottom` | `left`
37
-
38
- ```jsx
39
- import { Tooltip } from 'react-tooltip';
40
- import 'react-tooltip/dist/react-tooltip.css';
41
-
42
- <a id="tooltip-anchor"> ◕‿‿◕ </a>
43
- <Tooltip anchorId="tooltip-anchor" content="Hello World - top" place="top" />
44
- <Tooltip anchorId="tooltip-anchor" content="Hello World - right" place="right" />
45
- <Tooltip anchorId="tooltip-anchor" content="Hello World - bottom" place="bottom" />
46
- <Tooltip anchorId="tooltip-anchor" content="Hello World - left" place="left" />
47
- ```
48
-
49
- <div style={{ display: 'flex', columnGap: '16px', justifyContent: 'center', paddingTop: '36px' }}>
50
- <TooltipAnchor id="tooltip-anchor">◕‿‿◕</TooltipAnchor>
51
- <Tooltip anchorId="tooltip-anchor" content="Hello World - top" place="top" />
52
- <Tooltip anchorId="tooltip-anchor" content="Hello World - right" place="right" />
53
- <Tooltip anchorId="tooltip-anchor" content="Hello World - bottom" place="bottom" />
54
- <Tooltip anchorId="tooltip-anchor" content="Hello World - left" place="left" />
55
- </div>
@@ -1,331 +0,0 @@
1
- ---
2
- sidebar_position: 1
3
- ---
4
-
5
- # State
6
-
7
- Controlled and uncontrolled state examples of ReactTooltip component.
8
-
9
- import { useState } from 'react'
10
- import { Tooltip } from 'react-tooltip'
11
- import 'react-tooltip/dist/react-tooltip.css'
12
-
13
- export const TooltipAnchor = ({ children, id, ...rest }) => {
14
- return (
15
- <span
16
- id={id}
17
- style={{
18
- display: 'flex',
19
- justifyContent: 'center',
20
- alignItems: 'center',
21
- width: '60px',
22
- height: '60px',
23
- borderRadius: '60px',
24
- color: '#222',
25
- background: 'rgba(255, 255, 255, 1)',
26
- cursor: 'pointer',
27
- boxShadow: '3px 4px 3px rgba(0, 0, 0, 0.5)',
28
- border: '1px solid #333',
29
- }}
30
- {...rest}
31
- >
32
- {children}
33
- </span>
34
- )
35
- }
36
-
37
- export const ControlledExample = () => {
38
- const [isOpen, setIsOpen] = useState(false)
39
- const [anchorId, setAnchorId] = useState('tooltip-anchor')
40
- return (
41
- <>
42
- <TooltipAnchor
43
- id="tooltip-anchor"
44
- data-tooltip-content="1"
45
- onMouseEnter={() => {
46
- setAnchorId('tooltip-anchor')
47
- if (!isOpen) {
48
- setIsOpen(true)
49
- }
50
- }}
51
- >
52
- ◕‿‿◕
53
- </TooltipAnchor>
54
- <TooltipAnchor
55
- id="tooltip-anchor-2"
56
- data-tooltip-content="2"
57
- onMouseEnter={() => {
58
- setAnchorId('tooltip-anchor-2')
59
- if (!isOpen) {
60
- setIsOpen(true)
61
- }
62
- }}
63
- >
64
- ◕‿‿◕
65
- </TooltipAnchor>
66
- <TooltipAnchor
67
- id="tooltip-anchor-3"
68
- data-tooltip-content="3"
69
- onMouseEnter={() => {
70
- setAnchorId('tooltip-anchor-3')
71
- if (!isOpen) {
72
- setIsOpen(true)
73
- }
74
- }}
75
- >
76
- ◕‿‿◕
77
- </TooltipAnchor>
78
- <TooltipAnchor
79
- id="tooltip-anchor-4"
80
- data-tooltip-content="4"
81
- onMouseEnter={() => {
82
- setAnchorId('tooltip-anchor-4')
83
- if (!isOpen) {
84
- setIsOpen(true)
85
- }
86
- }}
87
- >
88
- ◕‿‿◕
89
- </TooltipAnchor>
90
- <TooltipAnchor
91
- id="tooltip-anchor-5"
92
- data-tooltip-content="5"
93
- onMouseEnter={() => {
94
- setAnchorId('tooltip-anchor-5')
95
- if (!isOpen) {
96
- setIsOpen(true)
97
- }
98
- }}
99
- >
100
- ◕‿‿◕
101
- </TooltipAnchor>
102
- <TooltipAnchor
103
- id="tooltip-anchor-6"
104
- data-tooltip-content="6"
105
- onMouseEnter={() => {
106
- setAnchorId('tooltip-anchor-6')
107
- if (!isOpen) {
108
- setIsOpen(true)
109
- }
110
- }}
111
- >
112
- ◕‿‿◕
113
- </TooltipAnchor>
114
- <Tooltip
115
- anchorId={anchorId}
116
- getContent={(dataTip) =>
117
- `Same Tooltip, different anchor element. This little buddy is ${dataTip}`
118
- }
119
- isOpen={isOpen}
120
- />
121
- </>
122
- )
123
- }
124
-
125
- ### Controlled tooltip state
126
-
127
- We can have a situation when we want to change the anchor id (the reference element id) and we want to let the tooltip being displayed.
128
- In this case, the code is only updating isOpen to `true` and never to `false`, but this can be easy changed if you want.
129
-
130
- ```jsx
131
- import { useState } from 'react';
132
- import { Tooltip } from 'react-tooltip';
133
- import 'react-tooltip/dist/react-tooltip.css';
134
-
135
- const [isOpen, setIsOpen] = useState(false)
136
- const [anchorId, setAnchorId] = useState('tooltip-anchor')
137
-
138
- <a id="tooltip-anchor"
139
- onMouseEnter={() => {
140
- setAnchorId('tooltip-anchor')
141
- // in this example we only want to trigger the isOpen as true by one time
142
- if (!isOpen) {
143
- setIsOpen(true)
144
- }
145
- }}
146
- > ◕‿‿◕ </a>
147
- <a id="tooltip-anchor-2"
148
- onMouseEnter={() => {
149
- setAnchorId('tooltip-anchor-2')
150
- // in this example we only want to trigger the isOpen as true by one time
151
- if (!isOpen) {
152
- setIsOpen(true)
153
- }
154
- }}
155
- > ◕‿‿◕ </a>
156
- <a id="tooltip-anchor-3"
157
- onMouseEnter={() => {
158
- setAnchorId('tooltip-anchor-3')
159
- // in this example we only want to trigger the isOpen as true by one time
160
- if (!isOpen) {
161
- setIsOpen(true)
162
- }
163
- }}
164
- > ◕‿‿◕ </a>
165
- <a id="tooltip-anchor-4"
166
- onMouseEnter={() => {
167
- setAnchorId('tooltip-anchor-4')
168
- // in this example we only want to trigger the isOpen as true by one time
169
- if (!isOpen) {
170
- setIsOpen(true)
171
- }
172
- }}
173
- > ◕‿‿◕ </a>
174
- <a id="tooltip-anchor-5"
175
- onMouseEnter={() => {
176
- setAnchorId('tooltip-anchor-5')
177
- // in this example we only want to trigger the isOpen as true by one time
178
- if (!isOpen) {
179
- setIsOpen(true)
180
- }
181
- }}
182
- > ◕‿‿◕ </a>
183
- <a id="tooltip-anchor-6"
184
- onMouseEnter={() => {
185
- setAnchorId('tooltip-anchor-6')
186
- // in this example we only want to trigger the isOpen as true by one time
187
- if (!isOpen) {
188
- setIsOpen(true)
189
- }
190
- }}
191
- > ◕‿‿◕ </a>
192
- <Tooltip
193
- anchorId={anchorId}
194
- getContent={(dataTip) => `Same Tooltip, different anchor element. This little buddy is ${dataTip}`}
195
- isOpen={isOpen}
196
- />
197
- ```
198
-
199
- <div style={{ display: 'flex', columnGap: '8px', justifyContent: 'center', paddingTop: '36px' }}>
200
- <ControlledExample />
201
- </div>
202
-
203
- export const UncontrolledExample = () => {
204
- const [anchorId, setAnchorId] = useState('tooltip-anchor-uncontrolled')
205
- return (
206
- <>
207
- <TooltipAnchor
208
- id="tooltip-anchor-uncontrolled"
209
- data-tooltip-content="1"
210
- onMouseEnter={() => {
211
- setAnchorId('tooltip-anchor-uncontrolled')
212
- }}
213
- >
214
- ◕‿‿◕
215
- </TooltipAnchor>
216
- <TooltipAnchor
217
- id="tooltip-anchor-uncontrolled-2"
218
- data-tooltip-content="2"
219
- onMouseEnter={() => {
220
- setAnchorId('tooltip-anchor-uncontrolled-2')
221
- }}
222
- >
223
- ◕‿‿◕
224
- </TooltipAnchor>
225
- <TooltipAnchor
226
- id="tooltip-anchor-uncontrolled-3"
227
- data-tooltip-content="3"
228
- onMouseEnter={() => {
229
- setAnchorId('tooltip-anchor-uncontrolled-3')
230
- }}
231
- >
232
- ◕‿‿◕
233
- </TooltipAnchor>
234
- <TooltipAnchor
235
- id="tooltip-anchor-uncontrolled-4"
236
- data-tooltip-content="4"
237
- onMouseEnter={() => {
238
- setAnchorId('tooltip-anchor-uncontrolled-4')
239
- }}
240
- >
241
- ◕‿‿◕
242
- </TooltipAnchor>
243
- <TooltipAnchor
244
- id="tooltip-anchor-uncontrolled-5"
245
- data-tooltip-content="5"
246
- onMouseEnter={() => {
247
- setAnchorId('tooltip-anchor-uncontrolled-5')
248
- }}
249
- >
250
- ◕‿‿◕
251
- </TooltipAnchor>
252
- <TooltipAnchor
253
- id="tooltip-anchor-uncontrolled-6"
254
- data-tooltip-content="6"
255
- onMouseEnter={() => {
256
- setAnchorId('tooltip-anchor-uncontrolled-6')
257
- }}
258
- >
259
- ◕‿‿◕
260
- </TooltipAnchor>
261
- <Tooltip
262
- anchorId={anchorId}
263
- getContent={(dataTip) =>
264
- `Same Tooltip, different anchor element. This little buddy is ${dataTip}`
265
- }
266
- />
267
- </>
268
- )
269
- }
270
-
271
- #### Observation
272
-
273
- If we pass `setIsOpen` to the tooltip, the `isOpen` from parent will be updated by Tooltip events instead of the internal tooltip state, but if we don't and only use `isOpen` value,
274
- we can control this state outside tooltip.
275
-
276
- ### Uncontrolled tooltip state
277
-
278
- This is almost the same example as before, but now we doesn't control `isOpen` and the tooltip will handle the state internally.
279
- With this, when the mouse leaves the element, the state is updated to `open` as `false`, because of that, we need to leave and enter a tooltip again.
280
- So, the controlled state can be a great option to handle this situation.
281
-
282
- ```jsx
283
- import { useState } from 'react';
284
- import { Tooltip } from 'react-tooltip';
285
- import 'react-tooltip/dist/react-tooltip.css';
286
-
287
- const [anchorId, setAnchorId] = useState('tooltip-anchor')
288
-
289
- <a id="tooltip-anchor"
290
- onMouseEnter={() => {
291
- setAnchorId('tooltip-anchor')
292
- }}
293
- > ◕‿‿◕ </a>
294
- <a id="tooltip-anchor-2"
295
- onMouseEnter={() => {
296
- setAnchorId('tooltip-anchor-2')
297
- }}
298
- > ◕‿‿◕ </a>
299
- <a id="tooltip-anchor-3"
300
- onMouseEnter={() => {
301
- setAnchorId('tooltip-anchor-3')
302
- }}
303
- > ◕‿‿◕ </a>
304
- <a id="tooltip-anchor-4"
305
- onMouseEnter={() => {
306
- setAnchorId('tooltip-anchor-4')
307
- }}
308
- > ◕‿‿◕ </a>
309
- <a id="tooltip-anchor-5"
310
- onMouseEnter={() => {
311
- setAnchorId('tooltip-anchor-5')
312
- }}
313
- > ◕‿‿◕ </a>
314
- <a id="tooltip-anchor-6"
315
- onMouseEnter={() => {
316
- setAnchorId('tooltip-anchor-6')
317
- }}
318
- > ◕‿‿◕ </a>
319
- <Tooltip
320
- anchorId={anchorId}
321
- getContent={(dataTip) => `Same Tooltip, different anchor element. This little buddy is ${dataTip}`}
322
- />
323
- ```
324
-
325
- <div style={{ display: 'flex', columnGap: '8px', justifyContent: 'center', paddingTop: '36px' }}>
326
- <UncontrolledExample />
327
- </div>
328
-
329
- #### Observation
330
-
331
- In this case, the internal state behavior will be very similar as using `setIsOpen` together with `isOpen` prop, the only difference is that state can be modified outside tooltip when using `setIsOpen` too.