@redocly/theme 0.62.0-next.6 → 0.62.0-next.8

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 (51) hide show
  1. package/lib/components/Breadcrumbs/Breadcrumb.js +1 -1
  2. package/lib/components/Breadcrumbs/BreadcrumbDropdown.js +1 -1
  3. package/lib/components/Catalog/CatalogTagsWithTooltip.js +1 -1
  4. package/lib/components/CodeBlock/CodeBlockControls.js +5 -5
  5. package/lib/components/Menu/variables.js +3 -3
  6. package/lib/components/Search/SearchAiDialog.d.ts +4 -2
  7. package/lib/components/Search/SearchAiDialog.js +23 -4
  8. package/lib/components/Search/SearchAiMessage.d.ts +4 -2
  9. package/lib/components/Search/SearchAiMessage.js +72 -16
  10. package/lib/components/Search/SearchDialog.js +1 -1
  11. package/lib/components/Tooltip/Tooltip.d.ts +2 -3
  12. package/lib/components/Tooltip/Tooltip.js +66 -113
  13. package/lib/components/Tooltip/variables.dark.js +4 -0
  14. package/lib/components/Tooltip/variables.js +3 -3
  15. package/lib/components/UserMenu/LoginButton.js +1 -1
  16. package/lib/core/constants/search.d.ts +5 -1
  17. package/lib/core/constants/search.js +24 -1
  18. package/lib/core/hooks/use-outside-click.d.ts +3 -1
  19. package/lib/core/hooks/use-outside-click.js +8 -4
  20. package/lib/core/types/hooks.d.ts +10 -1
  21. package/lib/core/types/l10n.d.ts +1 -1
  22. package/lib/core/types/search.d.ts +24 -0
  23. package/lib/core/types/search.js +9 -1
  24. package/lib/core/utils/content-segments.d.ts +2 -0
  25. package/lib/core/utils/content-segments.js +22 -0
  26. package/lib/core/utils/index.d.ts +1 -0
  27. package/lib/core/utils/index.js +1 -0
  28. package/package.json +7 -7
  29. package/src/components/Breadcrumbs/Breadcrumb.tsx +3 -3
  30. package/src/components/Breadcrumbs/BreadcrumbDropdown.tsx +3 -3
  31. package/src/components/Catalog/CatalogTagsWithTooltip.tsx +3 -3
  32. package/src/components/CodeBlock/CodeBlockControls.tsx +13 -9
  33. package/src/components/Menu/variables.ts +3 -3
  34. package/src/components/Search/SearchAiDialog.tsx +31 -2
  35. package/src/components/Search/SearchAiMessage.tsx +94 -10
  36. package/src/components/Search/SearchDialog.tsx +2 -0
  37. package/src/components/Tooltip/Tooltip.tsx +77 -120
  38. package/src/components/Tooltip/variables.dark.ts +4 -0
  39. package/src/components/Tooltip/variables.ts +3 -3
  40. package/src/components/UserMenu/LoginButton.tsx +2 -2
  41. package/src/core/constants/search.ts +27 -1
  42. package/src/core/hooks/__mocks__/use-theme-hooks.ts +9 -1
  43. package/src/core/hooks/use-outside-click.ts +16 -5
  44. package/src/core/types/hooks.ts +9 -0
  45. package/src/core/types/l10n.ts +3 -0
  46. package/src/core/types/search.ts +19 -0
  47. package/src/core/utils/content-segments.ts +27 -0
  48. package/src/core/utils/index.ts +1 -0
  49. package/lib/components/Tooltip/TooltipWrapper.d.ts +0 -12
  50. package/lib/components/Tooltip/TooltipWrapper.js +0 -34
  51. package/src/components/Tooltip/TooltipWrapper.tsx +0 -70
@@ -1,70 +0,0 @@
1
- import styled from 'styled-components';
2
- import React from 'react';
3
-
4
- import type { JSX, ReactElement } from 'react';
5
- import type { TooltipProps } from '@redocly/theme/components/Tooltip/Tooltip';
6
-
7
- import { useControl } from '@redocly/theme/core/hooks';
8
- import { Tooltip } from '@redocly/theme/components/Tooltip/Tooltip';
9
-
10
- export type TooltipWrapperProps = {
11
- children: ReactElement;
12
- tip: string;
13
- placement?: TooltipProps['placement'];
14
- width?: string;
15
- className?: string;
16
- showOnHover?: boolean;
17
- disabled?: boolean;
18
- };
19
-
20
- export function TooltipWrapper({
21
- children,
22
- tip,
23
- placement = 'top',
24
- width = 'max-content',
25
- className = '',
26
- showOnHover = true,
27
- disabled = false,
28
- }: TooltipWrapperProps): JSX.Element {
29
- const tooltip = useControl(false);
30
-
31
- const handleMouseEnter = (): void => {
32
- if (showOnHover && !disabled) {
33
- tooltip.handleOpen();
34
- }
35
- };
36
-
37
- const handleMouseLeave = (): void => {
38
- if (showOnHover) {
39
- tooltip.handleClose();
40
- }
41
- };
42
-
43
- const handleClick = (): void => {
44
- if (showOnHover) {
45
- tooltip.handleClose();
46
- }
47
- };
48
-
49
- return (
50
- <Tooltip
51
- className={className}
52
- tip={tip}
53
- isOpen={tooltip.isOpened}
54
- placement={placement}
55
- width={width}
56
- >
57
- <TooltipEventWrapper
58
- onMouseEnter={handleMouseEnter}
59
- onMouseLeave={handleMouseLeave}
60
- onClick={handleClick}
61
- >
62
- {children}
63
- </TooltipEventWrapper>
64
- </Tooltip>
65
- );
66
- }
67
-
68
- const TooltipEventWrapper = styled.div`
69
- display: contents;
70
- `;