@khanacademy/wonder-blocks-tooltip 0.0.0-PR2041-20230908193853

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 (38) hide show
  1. package/CHANGELOG.md +539 -0
  2. package/dist/components/tooltip-anchor.d.ts +85 -0
  3. package/dist/components/tooltip-bubble.d.ts +39 -0
  4. package/dist/components/tooltip-content.d.ts +42 -0
  5. package/dist/components/tooltip-popper.d.ts +32 -0
  6. package/dist/components/tooltip-tail.d.ts +61 -0
  7. package/dist/components/tooltip.d.ts +158 -0
  8. package/dist/es/index.js +798 -0
  9. package/dist/index.d.ts +8 -0
  10. package/dist/index.js +830 -0
  11. package/dist/util/active-tracker.d.ts +61 -0
  12. package/dist/util/constants.d.ts +6 -0
  13. package/dist/util/ref-tracker.d.ts +17 -0
  14. package/dist/util/types.d.ts +18 -0
  15. package/package.json +36 -0
  16. package/src/components/__tests__/tooltip-anchor.test.tsx +938 -0
  17. package/src/components/__tests__/tooltip-bubble.test.tsx +64 -0
  18. package/src/components/__tests__/tooltip-popper.test.tsx +72 -0
  19. package/src/components/__tests__/tooltip-tail.test.tsx +135 -0
  20. package/src/components/__tests__/tooltip.integration.test.tsx +78 -0
  21. package/src/components/__tests__/tooltip.test.tsx +364 -0
  22. package/src/components/tooltip-anchor.tsx +329 -0
  23. package/src/components/tooltip-bubble.tsx +150 -0
  24. package/src/components/tooltip-content.tsx +96 -0
  25. package/src/components/tooltip-popper.tsx +99 -0
  26. package/src/components/tooltip-tail.tsx +449 -0
  27. package/src/components/tooltip.tsx +293 -0
  28. package/src/index.ts +11 -0
  29. package/src/util/__tests__/__snapshots__/active-tracker.test.ts.snap +3 -0
  30. package/src/util/__tests__/__snapshots__/ref-tracker.test.tsx.snap +3 -0
  31. package/src/util/__tests__/active-tracker.test.ts +142 -0
  32. package/src/util/__tests__/ref-tracker.test.tsx +158 -0
  33. package/src/util/active-tracker.ts +92 -0
  34. package/src/util/constants.ts +6 -0
  35. package/src/util/ref-tracker.ts +48 -0
  36. package/src/util/types.ts +40 -0
  37. package/tsconfig-build.json +16 -0
  38. package/tsconfig-build.tsbuildinfo +1 -0
package/CHANGELOG.md ADDED
@@ -0,0 +1,539 @@
1
+ # @khanacademy/wonder-blocks-tooltip
2
+
3
+ ## 0.0.0-PR2041-20230908193853
4
+
5
+ ### Patch Changes
6
+
7
+ - @khanacademy/wonder-blocks-modal@0.0.0-PR2041-20230908193853
8
+
9
+ ## 2.1.9
10
+
11
+ ### Patch Changes
12
+
13
+ - @khanacademy/wonder-blocks-modal@4.0.26
14
+
15
+ ## 2.1.8
16
+
17
+ ### Patch Changes
18
+
19
+ - Updated dependencies [4b97b9a2]
20
+ - @khanacademy/wonder-blocks-core@6.2.0
21
+ - @khanacademy/wonder-blocks-layout@2.0.22
22
+ - @khanacademy/wonder-blocks-modal@4.0.25
23
+ - @khanacademy/wonder-blocks-typography@2.1.8
24
+
25
+ ## 2.1.7
26
+
27
+ ### Patch Changes
28
+
29
+ - Updated dependencies [2871f0a9]
30
+ - @khanacademy/wonder-blocks-core@6.1.1
31
+ - @khanacademy/wonder-blocks-layout@2.0.21
32
+ - @khanacademy/wonder-blocks-modal@4.0.24
33
+ - @khanacademy/wonder-blocks-typography@2.1.7
34
+
35
+ ## 2.1.6
36
+
37
+ ### Patch Changes
38
+
39
+ - Updated dependencies [efb59c29]
40
+ - Updated dependencies [8bc40ed2]
41
+ - @khanacademy/wonder-blocks-core@6.1.0
42
+ - @khanacademy/wonder-blocks-layout@2.0.20
43
+ - @khanacademy/wonder-blocks-modal@4.0.23
44
+ - @khanacademy/wonder-blocks-typography@2.1.6
45
+
46
+ ## 2.1.5
47
+
48
+ ### Patch Changes
49
+
50
+ - Updated dependencies [f19da46e]
51
+ - @khanacademy/wonder-blocks-core@6.0.2
52
+ - @khanacademy/wonder-blocks-layout@2.0.19
53
+ - @khanacademy/wonder-blocks-modal@4.0.22
54
+ - @khanacademy/wonder-blocks-typography@2.1.5
55
+
56
+ ## 2.1.4
57
+
58
+ ### Patch Changes
59
+
60
+ - Updated dependencies [1920feb8]
61
+ - @khanacademy/wonder-blocks-core@6.0.1
62
+ - @khanacademy/wonder-blocks-layout@2.0.18
63
+ - @khanacademy/wonder-blocks-modal@4.0.21
64
+ - @khanacademy/wonder-blocks-typography@2.1.4
65
+
66
+ ## 2.1.3
67
+
68
+ ### Patch Changes
69
+
70
+ - @khanacademy/wonder-blocks-modal@4.0.20
71
+
72
+ ## 2.1.2
73
+
74
+ ### Patch Changes
75
+
76
+ - Updated dependencies [674a1e5c]
77
+ - Updated dependencies [674a1e5c]
78
+ - @khanacademy/wonder-blocks-modal@4.0.19
79
+ - @khanacademy/wonder-blocks-core@6.0.0
80
+ - @khanacademy/wonder-blocks-layout@2.0.17
81
+ - @khanacademy/wonder-blocks-typography@2.1.3
82
+
83
+ ## 2.1.1
84
+
85
+ ### Patch Changes
86
+
87
+ - Updated dependencies [1344436f]
88
+ - @khanacademy/wonder-blocks-core@5.4.0
89
+ - @khanacademy/wonder-blocks-modal@4.0.18
90
+ - @khanacademy/wonder-blocks-layout@2.0.16
91
+ - @khanacademy/wonder-blocks-typography@2.1.2
92
+
93
+ ## 2.1.0
94
+
95
+ ### Minor Changes
96
+
97
+ - 9f3752d4: Added custom styling for background color, text color, and padding to Tooltip
98
+
99
+ ### Patch Changes
100
+
101
+ - Updated dependencies [9f3752d4]
102
+ - @khanacademy/wonder-blocks-typography@2.1.1
103
+ - @khanacademy/wonder-blocks-core@5.3.1
104
+ - @khanacademy/wonder-blocks-modal@4.0.17
105
+ - @khanacademy/wonder-blocks-layout@2.0.15
106
+
107
+ ## 2.0.16
108
+
109
+ ### Patch Changes
110
+
111
+ - Updated dependencies [0423a440]
112
+ - Updated dependencies [c37b99aa]
113
+ - Updated dependencies [afd5a801]
114
+ - Updated dependencies [13c48aa0]
115
+ - Updated dependencies [cade62f3]
116
+ - Updated dependencies [c4cef3e6]
117
+ - Updated dependencies [4c900085]
118
+ - @khanacademy/wonder-blocks-typography@2.1.0
119
+ - @khanacademy/wonder-blocks-core@5.3.0
120
+ - @khanacademy/wonder-blocks-modal@4.0.16
121
+ - @khanacademy/wonder-blocks-layout@2.0.14
122
+
123
+ ## 2.0.15
124
+
125
+ ### Patch Changes
126
+
127
+ - @khanacademy/wonder-blocks-modal@4.0.15
128
+
129
+ ## 2.0.14
130
+
131
+ ### Patch Changes
132
+
133
+ - Updated dependencies [d4c412b5]
134
+ - @khanacademy/wonder-blocks-core@5.2.3
135
+ - @khanacademy/wonder-blocks-layout@2.0.13
136
+ - @khanacademy/wonder-blocks-modal@4.0.14
137
+ - @khanacademy/wonder-blocks-typography@2.0.13
138
+
139
+ ## 2.0.13
140
+
141
+ ### Patch Changes
142
+
143
+ - Updated dependencies [64a188e3]
144
+ - @khanacademy/wonder-blocks-core@5.2.2
145
+ - @khanacademy/wonder-blocks-layout@2.0.12
146
+ - @khanacademy/wonder-blocks-modal@4.0.13
147
+ - @khanacademy/wonder-blocks-typography@2.0.12
148
+
149
+ ## 2.0.12
150
+
151
+ ### Patch Changes
152
+
153
+ - 86f58e6b: Allow the popover tail to be optional. This is a non-breaking change as it defaults to being visible as before. The TooltipTail export of wonder-blocks-tooltip is modified to support this, but it is a minor change that does not impact the primary API and hence is a patch update. While the Popover change is similar, it has a direct impact to primary uses and so is a minor update.
154
+ - df9a10aa: Update state and props to be readonly in components using getDerivedStateFromProps()
155
+ - Updated dependencies [5a1ea891]
156
+ - Updated dependencies [df9a10aa]
157
+ - @khanacademy/wonder-blocks-layout@2.0.11
158
+ - @khanacademy/wonder-blocks-modal@4.0.12
159
+ - @khanacademy/wonder-blocks-core@5.2.1
160
+ - @khanacademy/wonder-blocks-typography@2.0.11
161
+
162
+ ## 2.0.11
163
+
164
+ ### Patch Changes
165
+
166
+ - fa70c895: Remove all TypeScript error suppressions on JSX attributes
167
+ - Updated dependencies [fa70c895]
168
+ - Updated dependencies [19ab0408]
169
+ - Updated dependencies [fa70c895]
170
+ - @khanacademy/wonder-blocks-core@5.2.0
171
+ - @khanacademy/wonder-blocks-modal@4.0.11
172
+ - @khanacademy/wonder-blocks-layout@2.0.10
173
+ - @khanacademy/wonder-blocks-typography@2.0.10
174
+
175
+ ## 2.0.10
176
+
177
+ ### Patch Changes
178
+
179
+ - @khanacademy/wonder-blocks-modal@4.0.10
180
+
181
+ ## 2.0.9
182
+
183
+ ### Patch Changes
184
+
185
+ - Updated dependencies [3c400719]
186
+ - Updated dependencies [a6164ed0]
187
+ - @khanacademy/wonder-blocks-core@5.1.0
188
+ - @khanacademy/wonder-blocks-modal@4.0.9
189
+ - @khanacademy/wonder-blocks-layout@2.0.9
190
+ - @khanacademy/wonder-blocks-typography@2.0.9
191
+
192
+ ## 2.0.8
193
+
194
+ ### Patch Changes
195
+
196
+ - @khanacademy/wonder-blocks-layout@2.0.8
197
+ - @khanacademy/wonder-blocks-modal@4.0.8
198
+ - @khanacademy/wonder-blocks-typography@2.0.8
199
+
200
+ ## 2.0.7
201
+
202
+ ### Patch Changes
203
+
204
+ - @khanacademy/wonder-blocks-layout@2.0.7
205
+ - @khanacademy/wonder-blocks-modal@4.0.7
206
+ - @khanacademy/wonder-blocks-typography@2.0.7
207
+
208
+ ## 2.0.6
209
+
210
+ ### Patch Changes
211
+
212
+ - c20f48f3: Don't transpile classes when building bundles
213
+ - Updated dependencies [c20f48f3]
214
+ - @khanacademy/wonder-blocks-core@5.0.4
215
+ - @khanacademy/wonder-blocks-layout@2.0.6
216
+ - @khanacademy/wonder-blocks-modal@4.0.6
217
+ - @khanacademy/wonder-blocks-typography@2.0.6
218
+
219
+ ## 2.0.5
220
+
221
+ ### Patch Changes
222
+
223
+ - @khanacademy/wonder-blocks-layout@2.0.5
224
+ - @khanacademy/wonder-blocks-modal@4.0.5
225
+ - @khanacademy/wonder-blocks-typography@2.0.5
226
+
227
+ ## 2.0.4
228
+
229
+ ### Patch Changes
230
+
231
+ - @khanacademy/wonder-blocks-layout@2.0.4
232
+ - @khanacademy/wonder-blocks-modal@4.0.4
233
+ - @khanacademy/wonder-blocks-typography@2.0.4
234
+
235
+ ## 2.0.3
236
+
237
+ ### Patch Changes
238
+
239
+ - Updated dependencies [b281e2eb]
240
+ - @khanacademy/wonder-blocks-core@5.0.3
241
+ - @khanacademy/wonder-blocks-layout@2.0.3
242
+ - @khanacademy/wonder-blocks-modal@4.0.3
243
+ - @khanacademy/wonder-blocks-typography@2.0.3
244
+
245
+ ## 2.0.2
246
+
247
+ ### Patch Changes
248
+
249
+ - Updated dependencies [21ce20c7]
250
+ - @khanacademy/wonder-blocks-core@5.0.2
251
+ - @khanacademy/wonder-blocks-layout@2.0.2
252
+ - @khanacademy/wonder-blocks-modal@4.0.2
253
+ - @khanacademy/wonder-blocks-typography@2.0.2
254
+
255
+ ## 2.0.1
256
+
257
+ ### Patch Changes
258
+
259
+ - ccb6fe00: Miscellaneous TS type fixes
260
+ - d4c2b18c: Fix a variety of issues with Flow types generated by flowgen
261
+ - Updated dependencies [ccb6fe00]
262
+ - Updated dependencies [d4c2b18c]
263
+ - @khanacademy/wonder-blocks-core@5.0.1
264
+ - @khanacademy/wonder-blocks-layout@2.0.1
265
+ - @khanacademy/wonder-blocks-modal@4.0.1
266
+ - @khanacademy/wonder-blocks-typography@2.0.1
267
+ - @khanacademy/wonder-blocks-color@2.0.1
268
+ - @khanacademy/wonder-blocks-spacing@4.0.1
269
+
270
+ ## 2.0.0
271
+
272
+ ### Major Changes
273
+
274
+ - 1ca4d7e3: Fix minor issue with generate Flow types (this is a major bump b/c I forgot to do one after doing the TS conversion)
275
+
276
+ ### Patch Changes
277
+
278
+ - Updated dependencies [1ca4d7e3]
279
+ - @khanacademy/wonder-blocks-color@2.0.0
280
+ - @khanacademy/wonder-blocks-core@5.0.0
281
+ - @khanacademy/wonder-blocks-layout@2.0.0
282
+ - @khanacademy/wonder-blocks-modal@4.0.0
283
+ - @khanacademy/wonder-blocks-spacing@4.0.0
284
+ - @khanacademy/wonder-blocks-typography@2.0.0
285
+
286
+ ## 1.4.9
287
+
288
+ ### Patch Changes
289
+
290
+ - b5ba5568: Ensure that flow lib defs use React.ElementConfig<> isntead of JSX.LibraryManagedAttributes<>
291
+ - Updated dependencies [b5ba5568]
292
+ - @khanacademy/wonder-blocks-color@1.2.3
293
+ - @khanacademy/wonder-blocks-core@4.9.1
294
+ - @khanacademy/wonder-blocks-layout@1.4.19
295
+ - @khanacademy/wonder-blocks-modal@3.0.10
296
+ - @khanacademy/wonder-blocks-spacing@3.0.7
297
+ - @khanacademy/wonder-blocks-typography@1.1.41
298
+
299
+ ## 1.4.8
300
+
301
+ ### Patch Changes
302
+
303
+ - Updated dependencies [779b031d]
304
+ - @khanacademy/wonder-blocks-core@4.9.0
305
+ - @khanacademy/wonder-blocks-layout@1.4.18
306
+ - @khanacademy/wonder-blocks-modal@3.0.9
307
+ - @khanacademy/wonder-blocks-typography@1.1.40
308
+
309
+ ## 1.4.7
310
+
311
+ ### Patch Changes
312
+
313
+ - d816af08: Update build and test configs use TypeScript
314
+ - 3891f544: Update babel config to include plugins that Storybook needed
315
+ - 0d28bb1c: Configured TypeScript
316
+ - 3d05f764: Fix HOCs and other type errors
317
+ - c2ec4902: Update eslint configuration, fix lint
318
+ - 2983c05b: Include 'types' field in package.json
319
+ - 77ff6a66: Generate Flow types from TypeScript types
320
+ - 873f4a14: Tweak 'Offset' type to use React.CSSProperties
321
+ - ec8d4b7f: Fix miscellaneous TypeScript errors
322
+ - Updated dependencies [d816af08]
323
+ - Updated dependencies [3891f544]
324
+ - Updated dependencies [0d28bb1c]
325
+ - Updated dependencies [873f4a14]
326
+ - Updated dependencies [3d05f764]
327
+ - Updated dependencies [c2ec4902]
328
+ - Updated dependencies [2983c05b]
329
+ - Updated dependencies [77ff6a66]
330
+ - Updated dependencies [ec8d4b7f]
331
+ - @khanacademy/wonder-blocks-color@1.2.2
332
+ - @khanacademy/wonder-blocks-core@4.8.0
333
+ - @khanacademy/wonder-blocks-layout@1.4.17
334
+ - @khanacademy/wonder-blocks-modal@3.0.8
335
+ - @khanacademy/wonder-blocks-spacing@3.0.6
336
+ - @khanacademy/wonder-blocks-typography@1.1.39
337
+
338
+ ## 1.4.6
339
+
340
+ ### Patch Changes
341
+
342
+ - 91cb727c: Remove file extensions from imports
343
+ - Updated dependencies [91cb727c]
344
+ - Updated dependencies [91cb727c]
345
+ - Updated dependencies [91cb727c]
346
+ - @khanacademy/wonder-blocks-color@1.2.1
347
+ - @khanacademy/wonder-blocks-core@4.7.0
348
+ - @khanacademy/wonder-blocks-layout@1.4.16
349
+ - @khanacademy/wonder-blocks-modal@3.0.7
350
+ - @khanacademy/wonder-blocks-typography@1.1.38
351
+
352
+ ## 1.4.5
353
+
354
+ ### Patch Changes
355
+
356
+ - @khanacademy/wonder-blocks-modal@3.0.6
357
+
358
+ ## 1.4.4
359
+
360
+ ### Patch Changes
361
+
362
+ - Updated dependencies [496119f2]
363
+ - @khanacademy/wonder-blocks-core@4.6.2
364
+ - @khanacademy/wonder-blocks-modal@3.0.5
365
+ - @khanacademy/wonder-blocks-layout@1.4.15
366
+ - @khanacademy/wonder-blocks-typography@1.1.37
367
+
368
+ ## 1.4.3
369
+
370
+ ### Patch Changes
371
+
372
+ - @khanacademy/wonder-blocks-core@4.6.1
373
+ - @khanacademy/wonder-blocks-layout@1.4.14
374
+ - @khanacademy/wonder-blocks-modal@3.0.4
375
+ - @khanacademy/wonder-blocks-typography@1.1.36
376
+
377
+ ## 1.4.2
378
+
379
+ ### Patch Changes
380
+
381
+ - 5712eb36: Remove an unused function in TooltipTail: `_minDistanceFromCorners`
382
+ - Updated dependencies [b561425a]
383
+ - Updated dependencies [a566e232]
384
+ - Updated dependencies [d2b21a6e]
385
+ - @khanacademy/wonder-blocks-core@4.6.0
386
+ - @khanacademy/wonder-blocks-layout@1.4.13
387
+ - @khanacademy/wonder-blocks-modal@3.0.3
388
+ - @khanacademy/wonder-blocks-typography@1.1.35
389
+
390
+ ## 1.4.1
391
+
392
+ ### Patch Changes
393
+
394
+ - @khanacademy/wonder-blocks-modal@3.0.2
395
+
396
+ ## 1.4.0
397
+
398
+ ### Minor Changes
399
+
400
+ - b784d7a8: Allow Tooltip to be open/closed by its parent (controlled)
401
+
402
+ ## 1.3.23
403
+
404
+ ### Patch Changes
405
+
406
+ - @khanacademy/wonder-blocks-modal@3.0.1
407
+
408
+ ## 1.3.22
409
+
410
+ ### Patch Changes
411
+
412
+ - Updated dependencies [13cdc7fe]
413
+ - @khanacademy/wonder-blocks-modal@3.0.0
414
+
415
+ ## 1.3.21
416
+
417
+ ### Patch Changes
418
+
419
+ - Updated dependencies [f3bcc1a9]
420
+ - @khanacademy/wonder-blocks-modal@2.3.11
421
+
422
+ ## 1.3.20
423
+
424
+ ### Patch Changes
425
+
426
+ - Updated dependencies [175a2dd2]
427
+ - @khanacademy/wonder-blocks-core@4.5.0
428
+ - @khanacademy/wonder-blocks-layout@1.4.12
429
+ - @khanacademy/wonder-blocks-modal@2.3.10
430
+ - @khanacademy/wonder-blocks-typography@1.1.34
431
+
432
+ ## 1.3.19
433
+
434
+ ### Patch Changes
435
+
436
+ - @khanacademy/wonder-blocks-modal@2.3.9
437
+
438
+ ## 1.3.18
439
+
440
+ ### Patch Changes
441
+
442
+ - @khanacademy/wonder-blocks-modal@2.3.8
443
+
444
+ ## 1.3.17
445
+
446
+ ### Patch Changes
447
+
448
+ - Updated dependencies [6ee20af9]
449
+ - @khanacademy/wonder-blocks-core@4.4.0
450
+ - @khanacademy/wonder-blocks-layout@1.4.11
451
+ - @khanacademy/wonder-blocks-modal@2.3.7
452
+ - @khanacademy/wonder-blocks-typography@1.1.33
453
+
454
+ ## 1.3.16
455
+
456
+ ### Patch Changes
457
+
458
+ - e9364406: hide tooltip-tail from screen readers
459
+ - Updated dependencies [2546b126]
460
+ - @khanacademy/wonder-blocks-modal@2.3.6
461
+
462
+ ## 1.3.15
463
+
464
+ ### Patch Changes
465
+
466
+ - Updated dependencies [34c7aacb]
467
+ - @khanacademy/wonder-blocks-color@1.2.0
468
+ - @khanacademy/wonder-blocks-modal@2.3.5
469
+
470
+ ## 1.3.14
471
+
472
+ ### Patch Changes
473
+
474
+ - @khanacademy/wonder-blocks-modal@2.3.4
475
+
476
+ ## 1.3.13
477
+
478
+ ### Patch Changes
479
+
480
+ - @khanacademy/wonder-blocks-modal@2.3.3
481
+
482
+ ## 1.3.12
483
+
484
+ ### Patch Changes
485
+
486
+ - Updated dependencies [5f4a4297]
487
+ - Updated dependencies [2b96fd59]
488
+ - @khanacademy/wonder-blocks-core@4.3.2
489
+ - @khanacademy/wonder-blocks-layout@1.4.10
490
+ - @khanacademy/wonder-blocks-modal@2.3.2
491
+ - @khanacademy/wonder-blocks-typography@1.1.32
492
+
493
+ ## 1.3.11
494
+
495
+ ### Patch Changes
496
+
497
+ - @khanacademy/wonder-blocks-core@4.3.1
498
+ - @khanacademy/wonder-blocks-layout@1.4.9
499
+ - @khanacademy/wonder-blocks-modal@2.3.1
500
+ - @khanacademy/wonder-blocks-typography@1.1.31
501
+
502
+ ## 1.3.10
503
+
504
+ ### Patch Changes
505
+
506
+ - Updated dependencies [7eaf74bd]
507
+ - @khanacademy/wonder-blocks-modal@2.3.0
508
+
509
+ ## 1.3.9
510
+
511
+ ### Patch Changes
512
+
513
+ - Updated dependencies [246a921d]
514
+ - @khanacademy/wonder-blocks-core@4.3.0
515
+ - @khanacademy/wonder-blocks-layout@1.4.8
516
+ - @khanacademy/wonder-blocks-modal@2.2.3
517
+ - @khanacademy/wonder-blocks-typography@1.1.30
518
+
519
+ ## 1.3.8
520
+
521
+ ### Patch Changes
522
+
523
+ - @khanacademy/wonder-blocks-modal@2.2.2
524
+
525
+ ## 1.3.7
526
+
527
+ ### Patch Changes
528
+
529
+ - @khanacademy/wonder-blocks-core@4.2.1
530
+ - @khanacademy/wonder-blocks-layout@1.4.7
531
+ - @khanacademy/wonder-blocks-modal@2.2.1
532
+ - @khanacademy/wonder-blocks-typography@1.1.29
533
+
534
+ ## 1.3.6
535
+
536
+ ### Patch Changes
537
+
538
+ - Updated dependencies [e7bbf149]
539
+ - @khanacademy/wonder-blocks-modal@2.2.0
@@ -0,0 +1,85 @@
1
+ /**
2
+ * This component turns the given content into an accessible anchor for
3
+ * positioning and displaying tooltips.
4
+ */
5
+ import * as React from "react";
6
+ import type { IIdentifierFactory } from "@khanacademy/wonder-blocks-core";
7
+ import type { IActiveTrackerSubscriber } from "../util/active-tracker";
8
+ type Props = {
9
+ /**
10
+ * The content for anchoring the tooltip.
11
+ * This element will be used to position the tooltip.
12
+ * If a string is passed as children we wrap it in a Text element.
13
+ * We allow children to be a string so that we can add tooltips to
14
+ * words within a large block of text easily.
15
+ */
16
+ children: React.ReactElement<any> | string;
17
+ /**
18
+ * Callback to be invoked when the anchored content is mounted.
19
+ * This provides a reference to the anchored content, which can then be
20
+ * used for calculating tooltip bubble positioning.
21
+ */
22
+ anchorRef: (arg1?: Element | null | undefined) => unknown;
23
+ /**
24
+ * When true, if a tabindex attribute is not already present on the element
25
+ * wrapped by the anchor, the element will be given tabindex=0 to make it
26
+ * keyboard focusable; otherwise, does not attempt to change the ability to
27
+ * focus the anchor element.
28
+ *
29
+ * Defaults to true.
30
+ *
31
+ * One might set this to false in circumstances where the wrapped component
32
+ * already can receive focus or contains an element that can.
33
+ * Use good judgement when overriding this value, the tooltip content should
34
+ * be accessible via keyboard in all circumstances where the tooltip would
35
+ * appear using the mouse, so verify those use-cases.
36
+ */
37
+ forceAnchorFocusivity?: boolean;
38
+ /**
39
+ * Callback to pass active state back to Tooltip.
40
+ *
41
+ * `active` will be true whenever the anchor is hovered or focused and false
42
+ * otherwise.
43
+ */
44
+ onActiveChanged: (active: boolean) => unknown;
45
+ /**
46
+ * Optional unique id factory.
47
+ */
48
+ ids?: IIdentifierFactory;
49
+ };
50
+ type DefaultProps = {
51
+ forceAnchorFocusivity: Props["forceAnchorFocusivity"];
52
+ };
53
+ type State = {
54
+ /** Is the anchor active or not? */
55
+ active: boolean;
56
+ };
57
+ export default class TooltipAnchor extends React.Component<Props, State> implements IActiveTrackerSubscriber {
58
+ _weSetFocusivity: boolean | null | undefined;
59
+ _anchorNode: Element | null | undefined;
60
+ _focused: boolean;
61
+ _hovered: boolean;
62
+ _stolenFromUs: boolean;
63
+ _unsubscribeFromTracker: () => void | null | undefined;
64
+ _timeoutID: number | null | undefined;
65
+ static defaultProps: DefaultProps;
66
+ constructor(props: Props);
67
+ componentDidMount(): void;
68
+ componentDidUpdate(prevProps: Props): void;
69
+ componentWillUnmount(): void;
70
+ static ariaContentId: string;
71
+ activeStateStolen: () => void;
72
+ _updateFocusivity(): void;
73
+ _updateActiveState(hovered: boolean, focused: boolean): void;
74
+ _clearPendingAction(): void;
75
+ _setActiveState(active: boolean, instant?: boolean): void;
76
+ _handleFocusIn: () => void;
77
+ _handleFocusOut: () => void;
78
+ _handleMouseEnter: () => void;
79
+ _handleMouseLeave: () => void;
80
+ _handleKeyUp: (e: KeyboardEvent) => void;
81
+ _renderAnchorableChildren(): React.ReactElement<any>;
82
+ _renderAccessibleChildren(ids: IIdentifierFactory): React.ReactNode;
83
+ render(): React.ReactNode;
84
+ }
85
+ export {};
@@ -0,0 +1,39 @@
1
+ import * as React from "react";
2
+ import Colors from "@khanacademy/wonder-blocks-color";
3
+ import type { StyleType } from "@khanacademy/wonder-blocks-core";
4
+ import TooltipContent from "./tooltip-content";
5
+ import type { getRefFn, Offset, Placement } from "../util/types";
6
+ export type PopperElementProps = {
7
+ /** The placement of the bubble with respect to the anchor. */
8
+ placement: Placement;
9
+ /** Whether the bubble is out of bounds or not. */
10
+ isReferenceHidden?: boolean | null | undefined;
11
+ /** A callback for updating the ref of the bubble itself. */
12
+ updateBubbleRef?: getRefFn;
13
+ /** A callback for updating the ref of the bubble's tail. */
14
+ updateTailRef?: getRefFn;
15
+ /** Where the tail is to be rendered. */
16
+ tailOffset?: Offset;
17
+ /** Additional styles to be applied by the bubble. */
18
+ style?: StyleType;
19
+ };
20
+ export type Props = {
21
+ /** The unique identifier for this component. */
22
+ id: string;
23
+ /** The `TooltipContent` element that will be rendered in the bubble. */
24
+ children: React.ReactElement<React.ComponentProps<typeof TooltipContent>>;
25
+ onActiveChanged: (active: boolean) => unknown;
26
+ /** Optional background color. */
27
+ backgroundColor?: keyof typeof Colors;
28
+ } & PopperElementProps;
29
+ type State = {
30
+ active: boolean;
31
+ };
32
+ export default class TooltipBubble extends React.Component<Props, State> {
33
+ state: State;
34
+ _setActiveState(active: boolean): void;
35
+ handleMouseEnter: () => void;
36
+ handleMouseLeave: () => void;
37
+ render(): React.ReactNode;
38
+ }
39
+ export {};
@@ -0,0 +1,42 @@
1
+ import * as React from "react";
2
+ import type { Typography } from "@khanacademy/wonder-blocks-typography";
3
+ import { ContentStyle } from "../util/types";
4
+ type Props = {
5
+ /**
6
+ * The title for the tooltip content.
7
+ * Optional.
8
+ */
9
+ title?: string | React.ReactElement<React.ComponentProps<Typography>>;
10
+ /**
11
+ * The main content for a tooltip.
12
+ */
13
+ children: string | React.ReactElement<React.ComponentProps<Typography>> | Array<React.ReactElement<React.ComponentProps<Typography>>>;
14
+ /**
15
+ * Optional custom styles for the tooltip which are a subset of valid CSS styles
16
+ */
17
+ contentStyle?: ContentStyle;
18
+ /**
19
+ * Test ID used for e2e testing.
20
+ */
21
+ testId?: string;
22
+ };
23
+ /**
24
+ * This component is used to provide the content that is to be rendered in the
25
+ * tooltip bubble.
26
+ *
27
+ * ### Usage
28
+ *
29
+ * ```jsx
30
+ * import {TooltipContent} from "@khanacademy/wonder-blocks-tooltip";
31
+ *
32
+ * <TooltipContent title="Title text!">
33
+ * Some content in my tooltip.
34
+ * </TooltipContent>
35
+ * ```
36
+ */
37
+ export default class TooltipContent extends React.Component<Props> {
38
+ _renderTitle(): React.ReactNode;
39
+ _renderChildren(): React.ReactNode;
40
+ render(): React.ReactNode;
41
+ }
42
+ export {};