@redocly/theme 0.64.0-next.1 → 0.64.0-next.3

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 (223) hide show
  1. package/lib/components/Admonition/Admonition.d.ts +1 -1
  2. package/lib/components/Admonition/Admonition.js +2 -0
  3. package/lib/components/Admonition/variables.dark.js +3 -0
  4. package/lib/components/Admonition/variables.js +13 -0
  5. package/lib/components/Banner/Banner.js +3 -3
  6. package/lib/components/Button/variables.dark.js +2 -2
  7. package/lib/components/Button/variables.js +3 -3
  8. package/lib/components/Catalog/CatalogActionsRow.d.ts +3 -3
  9. package/lib/components/Catalog/CatalogCardView/CatalogCard.js +4 -6
  10. package/lib/components/Catalog/CatalogEntities.d.ts +2 -2
  11. package/lib/components/Catalog/CatalogEntities.js +1 -1
  12. package/lib/components/Catalog/CatalogEntity/CatalogEntity.d.ts +1 -8
  13. package/lib/components/Catalog/CatalogEntity/CatalogEntityHistory/CatalogEntityVersionItem.js +3 -1
  14. package/lib/components/Catalog/CatalogEntity/CatalogEntityMetadata.js +1 -1
  15. package/lib/components/Catalog/CatalogEntity/CatalogEntityMethodAndPath.js +1 -1
  16. package/lib/components/Catalog/CatalogEntity/CatalogEntityProperties/CatalogEntityProperties.js +1 -0
  17. package/lib/components/Catalog/CatalogEntity/CatalogEntityProperties/CatalogEntityPropertyCard.js +2 -1
  18. package/lib/components/Catalog/CatalogEntity/CatalogEntityProperties/ContactProperty.js +2 -6
  19. package/lib/components/Catalog/CatalogEntity/CatalogEntityProperties/DomainsProperty.js +5 -5
  20. package/lib/components/Catalog/CatalogEntity/CatalogEntityProperties/FormatProperty.js +1 -1
  21. package/lib/components/Catalog/CatalogEntity/CatalogEntityProperties/OwnersProperty.js +15 -7
  22. package/lib/components/Catalog/CatalogEntity/CatalogEntityProperties/TagsProperty.js +2 -2
  23. package/lib/components/Catalog/CatalogEntity/CatalogEntityRelations/CatalogEntityApiDescriptionRelations.d.ts +3 -3
  24. package/lib/components/Catalog/CatalogEntity/CatalogEntityRelations/CatalogEntityApiDescriptionRelations.js +4 -1
  25. package/lib/components/Catalog/CatalogEntity/CatalogEntityRelations/CatalogEntityDefaultRelations.d.ts +3 -3
  26. package/lib/components/Catalog/CatalogEntity/CatalogEntityRelations/CatalogEntityDefaultRelations.js +14 -2
  27. package/lib/components/Catalog/CatalogEntity/CatalogEntityRelations/CatalogEntityRelations.js +1 -1
  28. package/lib/components/Catalog/CatalogEntity/CatalogEntityRelations/CatalogEntityRelationsTable.d.ts +3 -3
  29. package/lib/components/Catalog/CatalogEntity/CatalogEntityRelations/CatalogEntityRelationsTable.js +1 -1
  30. package/lib/components/Catalog/CatalogEntity/CatalogEntityRelations/CatalogEntityRelationsTableContent.d.ts +2 -2
  31. package/lib/components/Catalog/CatalogEntity/CatalogEntityRelations/CatalogEntityTeamRelations.d.ts +3 -3
  32. package/lib/components/Catalog/CatalogEntity/CatalogEntityRelations/CatalogEntityTeamRelations.js +13 -3
  33. package/lib/components/Catalog/CatalogEntity/CatalogEntitySchema.js +4 -3
  34. package/lib/components/Catalog/CatalogEntityTypeIcon.d.ts +3 -2
  35. package/lib/components/Catalog/CatalogEntityTypeIcon.js +9 -9
  36. package/lib/components/Catalog/CatalogMobileTopBar/CatalogMobileTopBar.d.ts +2 -3
  37. package/lib/components/Catalog/CatalogMobileTopBar/CatalogMobileTopBarControls.d.ts +2 -3
  38. package/lib/components/Catalog/CatalogPageDescription.js +1 -1
  39. package/lib/components/Catalog/CatalogSortButton.d.ts +4 -5
  40. package/lib/components/Catalog/CatalogTableView/CatalogDomainsCell.js +6 -2
  41. package/lib/components/Catalog/CatalogTableView/CatalogEntityCell.js +2 -2
  42. package/lib/components/Catalog/CatalogTableView/CatalogLastUpdateCell.d.ts +5 -0
  43. package/lib/components/Catalog/CatalogTableView/CatalogLastUpdateCell.js +45 -0
  44. package/lib/components/Catalog/CatalogTableView/CatalogOwnersCell.js +5 -3
  45. package/lib/components/Catalog/CatalogTableView/CatalogTableHeaderCell.d.ts +2 -3
  46. package/lib/components/Catalog/CatalogTableView/CatalogTableHeaderCell.js +3 -2
  47. package/lib/components/Catalog/CatalogTableView/CatalogTableView.d.ts +1 -2
  48. package/lib/components/Catalog/CatalogTableView/CatalogTableView.js +15 -5
  49. package/lib/components/Catalog/CatalogTableView/CatalogTagsCell.js +3 -2
  50. package/lib/components/Catalog/CatalogTableView/CatalogUserEntityCell.js +2 -2
  51. package/lib/components/Catalog/CatalogTags.d.ts +11 -0
  52. package/lib/components/Catalog/CatalogTags.js +62 -0
  53. package/lib/components/Catalog/variables.js +22 -14
  54. package/lib/components/Filter/variables.js +1 -1
  55. package/lib/components/Link/Link.js +2 -2
  56. package/lib/components/Menu/MenuItem.js +1 -0
  57. package/lib/components/Menu/variables.dark.js +2 -0
  58. package/lib/components/Menu/variables.js +4 -3
  59. package/lib/components/Search/SearchDialog.js +118 -116
  60. package/lib/components/SvgViewer/variables.dark.js +1 -1
  61. package/lib/components/Switch/variables.dark.js +2 -2
  62. package/lib/components/Switch/variables.js +1 -1
  63. package/lib/components/TableOfContent/TableOfContent.js +1 -0
  64. package/lib/components/TableOfContent/variables.js +3 -2
  65. package/lib/components/Toast/Toast.d.ts +14 -0
  66. package/lib/components/Toast/Toast.js +239 -0
  67. package/lib/components/Toast/variables.d.ts +1 -0
  68. package/lib/components/Toast/variables.js +64 -0
  69. package/lib/components/Tooltip/JsTooltip.js +1 -1
  70. package/lib/core/constants/catalog.d.ts +1 -1
  71. package/lib/core/constants/catalog.js +1 -1
  72. package/lib/core/constants/toast.d.ts +1 -0
  73. package/lib/core/constants/toast.js +5 -0
  74. package/lib/core/contexts/Toast/ToastContext.d.ts +2 -0
  75. package/lib/core/contexts/Toast/ToastContext.js +6 -0
  76. package/lib/core/contexts/Toast/ToastProvider.d.ts +3 -0
  77. package/lib/core/contexts/Toast/ToastProvider.js +156 -0
  78. package/lib/core/contexts/index.d.ts +2 -0
  79. package/lib/core/contexts/index.js +2 -0
  80. package/lib/core/hooks/catalog/use-catalog-entity-link.d.ts +8 -0
  81. package/lib/core/hooks/catalog/use-catalog-entity-link.js +42 -0
  82. package/lib/core/hooks/catalog/use-catalog-table-header-cell-actions.d.ts +2 -1
  83. package/lib/core/hooks/catalog/use-catalog-table-header-cell-actions.js +5 -3
  84. package/lib/core/hooks/index.d.ts +3 -0
  85. package/lib/core/hooks/index.js +3 -0
  86. package/lib/core/hooks/use-toast-logic.d.ts +18 -0
  87. package/lib/core/hooks/use-toast-logic.js +141 -0
  88. package/lib/core/hooks/use-toast.d.ts +11 -0
  89. package/lib/core/hooks/use-toast.js +17 -0
  90. package/lib/core/styles/dark.d.ts +3 -1
  91. package/lib/core/styles/dark.js +37 -33
  92. package/lib/core/styles/global.d.ts +6 -2
  93. package/lib/core/styles/global.js +56 -46
  94. package/lib/core/styles/palette.d.ts +6 -0
  95. package/lib/core/styles/palette.dark.d.ts +3 -0
  96. package/lib/core/styles/palette.dark.js +201 -0
  97. package/lib/core/styles/palette.js +175 -0
  98. package/lib/core/types/catalog.d.ts +23 -7
  99. package/lib/core/types/hooks.d.ts +6 -4
  100. package/lib/core/types/index.d.ts +1 -0
  101. package/lib/core/types/search.d.ts +1 -0
  102. package/lib/core/types/toast.d.ts +23 -0
  103. package/lib/core/types/toast.js +3 -0
  104. package/lib/core/utils/get-auto-dismiss-duration.d.ts +2 -0
  105. package/lib/core/utils/get-auto-dismiss-duration.js +15 -0
  106. package/lib/core/utils/index.d.ts +1 -0
  107. package/lib/core/utils/index.js +1 -0
  108. package/lib/icons/CheckboxIcon/CheckboxIcon.js +6 -4
  109. package/lib/icons/CheckboxIcon/variables.dark.js +2 -1
  110. package/lib/icons/CheckboxIcon/variables.js +3 -3
  111. package/lib/icons/IdeaIcon/IdeaIcon.d.ts +9 -0
  112. package/lib/icons/IdeaIcon/IdeaIcon.js +24 -0
  113. package/lib/icons/NewChatIcon/NewChatIcon.d.ts +11 -0
  114. package/lib/icons/NewChatIcon/NewChatIcon.js +25 -0
  115. package/lib/index.d.ts +5 -1
  116. package/lib/index.js +5 -1
  117. package/lib/markdoc/components/Heading/Heading.js +2 -2
  118. package/lib/markdoc/components/Mermaid/Mermaid.js +0 -2
  119. package/lib/markdoc/components/Tabs/variables.js +3 -3
  120. package/lib/markdoc/components/default.d.ts +0 -1
  121. package/lib/markdoc/components/default.js +0 -1
  122. package/lib/markdoc/tags/admonition.js +1 -1
  123. package/package.json +2 -2
  124. package/src/components/Admonition/Admonition.tsx +3 -1
  125. package/src/components/Admonition/variables.dark.ts +3 -0
  126. package/src/components/Admonition/variables.ts +13 -0
  127. package/src/components/Banner/Banner.tsx +7 -7
  128. package/src/components/Button/variables.dark.ts +2 -2
  129. package/src/components/Button/variables.ts +3 -3
  130. package/src/components/Catalog/CatalogActionsRow.tsx +3 -3
  131. package/src/components/Catalog/CatalogCardView/CatalogCard.tsx +4 -6
  132. package/src/components/Catalog/CatalogEntities.tsx +3 -3
  133. package/src/components/Catalog/CatalogEntity/CatalogEntity.tsx +3 -24
  134. package/src/components/Catalog/CatalogEntity/CatalogEntityHistory/CatalogEntityVersionItem.tsx +3 -1
  135. package/src/components/Catalog/CatalogEntity/CatalogEntityMetadata.tsx +1 -1
  136. package/src/components/Catalog/CatalogEntity/CatalogEntityMethodAndPath.tsx +1 -1
  137. package/src/components/Catalog/CatalogEntity/CatalogEntityProperties/CatalogEntityProperties.tsx +1 -0
  138. package/src/components/Catalog/CatalogEntity/CatalogEntityProperties/CatalogEntityPropertyCard.tsx +2 -1
  139. package/src/components/Catalog/CatalogEntity/CatalogEntityProperties/ContactProperty.tsx +8 -10
  140. package/src/components/Catalog/CatalogEntity/CatalogEntityProperties/DomainsProperty.tsx +13 -8
  141. package/src/components/Catalog/CatalogEntity/CatalogEntityProperties/FormatProperty.tsx +1 -0
  142. package/src/components/Catalog/CatalogEntity/CatalogEntityProperties/OwnersProperty.tsx +27 -15
  143. package/src/components/Catalog/CatalogEntity/CatalogEntityProperties/TagsProperty.tsx +2 -2
  144. package/src/components/Catalog/CatalogEntity/CatalogEntityRelations/CatalogEntityApiDescriptionRelations.tsx +9 -9
  145. package/src/components/Catalog/CatalogEntity/CatalogEntityRelations/CatalogEntityDefaultRelations.tsx +17 -9
  146. package/src/components/Catalog/CatalogEntity/CatalogEntityRelations/CatalogEntityRelations.tsx +1 -1
  147. package/src/components/Catalog/CatalogEntity/CatalogEntityRelations/CatalogEntityRelationsTable.tsx +4 -8
  148. package/src/components/Catalog/CatalogEntity/CatalogEntityRelations/CatalogEntityRelationsTableContent.tsx +2 -2
  149. package/src/components/Catalog/CatalogEntity/CatalogEntityRelations/CatalogEntityTeamRelations.tsx +16 -10
  150. package/src/components/Catalog/CatalogEntity/CatalogEntitySchema.tsx +4 -3
  151. package/src/components/Catalog/CatalogEntityTypeIcon.tsx +18 -11
  152. package/src/components/Catalog/CatalogMobileTopBar/CatalogMobileTopBar.tsx +3 -3
  153. package/src/components/Catalog/CatalogMobileTopBar/CatalogMobileTopBarControls.tsx +2 -3
  154. package/src/components/Catalog/CatalogPageDescription.tsx +1 -1
  155. package/src/components/Catalog/CatalogSortButton.tsx +5 -6
  156. package/src/components/Catalog/CatalogTableView/CatalogDomainsCell.tsx +6 -2
  157. package/src/components/Catalog/CatalogTableView/CatalogEntityCell.tsx +2 -2
  158. package/src/components/Catalog/CatalogTableView/CatalogLastUpdateCell.tsx +54 -0
  159. package/src/components/Catalog/CatalogTableView/CatalogOwnersCell.tsx +5 -2
  160. package/src/components/Catalog/CatalogTableView/CatalogTableHeaderCell.tsx +4 -3
  161. package/src/components/Catalog/CatalogTableView/CatalogTableView.tsx +17 -7
  162. package/src/components/Catalog/CatalogTableView/CatalogTagsCell.tsx +3 -2
  163. package/src/components/Catalog/CatalogTableView/CatalogUserEntityCell.tsx +2 -2
  164. package/src/components/Catalog/CatalogTags.tsx +115 -0
  165. package/src/components/Catalog/variables.ts +22 -14
  166. package/src/components/Filter/variables.ts +1 -1
  167. package/src/components/Link/Link.tsx +1 -1
  168. package/src/components/Menu/MenuItem.tsx +5 -1
  169. package/src/components/Menu/variables.dark.ts +2 -0
  170. package/src/components/Menu/variables.ts +4 -3
  171. package/src/components/Search/SearchDialog.tsx +299 -293
  172. package/src/components/SvgViewer/variables.dark.ts +1 -1
  173. package/src/components/Switch/variables.dark.ts +2 -2
  174. package/src/components/Switch/variables.ts +1 -1
  175. package/src/components/TableOfContent/TableOfContent.tsx +1 -0
  176. package/src/components/TableOfContent/variables.ts +3 -2
  177. package/src/components/Toast/Toast.tsx +289 -0
  178. package/src/components/Toast/variables.ts +61 -0
  179. package/src/components/Tooltip/JsTooltip.tsx +1 -1
  180. package/src/core/constants/catalog.ts +1 -1
  181. package/src/core/constants/toast.ts +1 -0
  182. package/src/core/contexts/Toast/ToastContext.tsx +5 -0
  183. package/src/core/contexts/Toast/ToastProvider.tsx +206 -0
  184. package/src/core/contexts/index.ts +2 -0
  185. package/src/core/hooks/catalog/use-catalog-entity-link.ts +46 -0
  186. package/src/core/hooks/catalog/use-catalog-table-header-cell-actions.ts +10 -2
  187. package/src/core/hooks/index.ts +3 -0
  188. package/src/core/hooks/use-toast-logic.ts +203 -0
  189. package/src/core/hooks/use-toast.ts +47 -0
  190. package/src/core/styles/dark.ts +9 -4
  191. package/src/core/styles/global.ts +30 -20
  192. package/src/core/styles/palette.dark.ts +199 -0
  193. package/src/core/styles/palette.ts +173 -0
  194. package/src/core/types/catalog.ts +24 -8
  195. package/src/core/types/hooks.ts +5 -10
  196. package/src/core/types/index.ts +1 -0
  197. package/src/core/types/search.ts +1 -0
  198. package/src/core/types/toast.ts +28 -0
  199. package/src/core/utils/get-auto-dismiss-duration.ts +20 -0
  200. package/src/core/utils/index.ts +1 -0
  201. package/src/icons/CheckboxIcon/CheckboxIcon.tsx +26 -17
  202. package/src/icons/CheckboxIcon/variables.dark.ts +2 -1
  203. package/src/icons/CheckboxIcon/variables.ts +3 -3
  204. package/src/icons/IdeaIcon/IdeaIcon.tsx +32 -0
  205. package/src/icons/NewChatIcon/NewChatIcon.tsx +39 -0
  206. package/src/index.ts +5 -1
  207. package/src/markdoc/components/Heading/Heading.tsx +2 -1
  208. package/src/markdoc/components/Mermaid/Mermaid.tsx +0 -2
  209. package/src/markdoc/components/Tabs/variables.ts +3 -3
  210. package/src/markdoc/components/default.ts +0 -1
  211. package/src/markdoc/tags/admonition.ts +1 -1
  212. package/lib/components/Catalog/CatalogTagsWithTooltip.d.ts +0 -10
  213. package/lib/components/Catalog/CatalogTagsWithTooltip.js +0 -57
  214. package/lib/markdoc/components/ExcalidrawDiagram/ExcalidrawDiagram.d.ts +0 -7
  215. package/lib/markdoc/components/ExcalidrawDiagram/ExcalidrawDiagram.js +0 -95
  216. package/lib/markdoc/components/ExcalidrawDiagram/variables.d.ts +0 -1
  217. package/lib/markdoc/components/ExcalidrawDiagram/variables.dark.d.ts +0 -1
  218. package/lib/markdoc/components/ExcalidrawDiagram/variables.dark.js +0 -8
  219. package/lib/markdoc/components/ExcalidrawDiagram/variables.js +0 -15
  220. package/src/components/Catalog/CatalogTagsWithTooltip.tsx +0 -101
  221. package/src/markdoc/components/ExcalidrawDiagram/ExcalidrawDiagram.tsx +0 -85
  222. package/src/markdoc/components/ExcalidrawDiagram/variables.dark.ts +0 -5
  223. package/src/markdoc/components/ExcalidrawDiagram/variables.ts +0 -12
@@ -5,18 +5,26 @@ import {
5
5
 
6
6
  type CatalogTableHeaderCellActionsProps<T extends BaseEntity> = {
7
7
  column: CatalogColumn<T>;
8
+ currentSortOption?: string | null;
8
9
  handleSortClick: (sortKey: string, direction: 'asc' | 'desc') => void;
9
10
  isColumnSorted: (sortKey: string, direction: 'asc' | 'desc') => boolean;
10
11
  };
11
12
 
12
13
  export function useCatalogTableHeaderCellActions<T extends BaseEntity>({
13
14
  column,
15
+ currentSortOption,
14
16
  handleSortClick,
15
17
  isColumnSorted,
16
18
  }: CatalogTableHeaderCellActionsProps<T>) {
17
19
  const sortKey = column.sortKey;
18
- const isUpActive = sortKey ? isColumnSorted(sortKey, 'desc') : false;
19
- const isDownActive = sortKey ? isColumnSorted(sortKey, 'asc') : false;
20
+ const isUpActive = Boolean(
21
+ sortKey &&
22
+ (currentSortOption ? currentSortOption === sortKey : isColumnSorted(sortKey, 'desc')),
23
+ );
24
+ const isDownActive = Boolean(
25
+ sortKey &&
26
+ (currentSortOption ? currentSortOption === `-${sortKey}` : isColumnSorted(sortKey, 'asc')),
27
+ );
20
28
 
21
29
  const handleCellClick = (): void => {
22
30
  if (!column.sortable || !sortKey) return;
@@ -46,7 +46,10 @@ export * from './use-page-actions';
46
46
  export * from './use-mcp-config';
47
47
  export * from './use-connect-mcp-button';
48
48
  export * from './catalog/use-catalog-entity-details';
49
+ export * from './catalog/use-catalog-entity-link';
49
50
  export * from './catalog/use-catalog-entity-schema';
50
51
  export * from './catalog/use-catalog-table-header-cell-actions';
51
52
  export * from './use-store';
52
53
  export * from './use-is-truncated';
54
+ export * from './use-toast';
55
+ export * from './use-toast-logic';
@@ -0,0 +1,203 @@
1
+ import { useCallback, useEffect, useLayoutEffect, useMemo, useRef } from 'react';
2
+
3
+ import type { RefObject } from 'react';
4
+ import type { ToastItem } from '../types/toast';
5
+
6
+ import { getAutoDismissDuration } from '../utils';
7
+
8
+ const STACK_SHIFT_ENTER_DURATION_MS = 280;
9
+ const STACK_SHIFT_EXIT_DURATION_MS = 200;
10
+
11
+ interface UseToastLogicOptions {
12
+ toast: ToastItem;
13
+ onDismiss: (id: string) => void;
14
+ stackIndex: number;
15
+ }
16
+
17
+ interface UseToastLogicReturn {
18
+ wrapperRef: RefObject<HTMLDivElement | null>;
19
+ hasDetails: boolean;
20
+ dismissToast: () => void;
21
+ handleMouseEnter: () => void;
22
+ handleMouseLeave: () => void;
23
+ ariaRole: 'alert' | 'status';
24
+ ariaLive: 'assertive' | 'polite';
25
+ }
26
+
27
+ export function useToastLogic({
28
+ toast,
29
+ onDismiss,
30
+ stackIndex,
31
+ }: UseToastLogicOptions): UseToastLogicReturn {
32
+ const wrapperRef = useRef<HTMLDivElement | null>(null);
33
+ const previousTopRef = useRef<number | null>(null);
34
+ const previousStackIndexRef = useRef<number | null>(null);
35
+ const timerRef = useRef<ReturnType<typeof setTimeout> | null>(null);
36
+ const startedAtRef = useRef<number | null>(null);
37
+ const remainingTimeRef = useRef<number>(0);
38
+ const animationFrameRef = useRef<number | null>(null);
39
+ const isHoveredRef = useRef<boolean>(false);
40
+
41
+ const hasDetails = Boolean(toast.description);
42
+ const resolvedDuration = useMemo(
43
+ () => getAutoDismissDuration(hasDetails, toast.type, toast.duration),
44
+ [hasDetails, toast.duration, toast.type],
45
+ );
46
+ const ariaRole = toast.type === 'error' ? 'alert' : 'status';
47
+ const ariaLive = toast.type === 'error' ? 'assertive' : 'polite';
48
+
49
+ const clearTimer = useCallback((): void => {
50
+ if (timerRef.current) {
51
+ clearTimeout(timerRef.current);
52
+ timerRef.current = null;
53
+ }
54
+
55
+ startedAtRef.current = null;
56
+ }, []);
57
+
58
+ const dismissToast = useCallback((): void => {
59
+ onDismiss(toast.id);
60
+ }, [onDismiss, toast.id]);
61
+
62
+ const startTimer = useCallback(
63
+ (delay: number): void => {
64
+ clearTimer();
65
+
66
+ if (delay <= 0) {
67
+ dismissToast();
68
+ return;
69
+ }
70
+
71
+ remainingTimeRef.current = delay;
72
+ startedAtRef.current = Date.now();
73
+ timerRef.current = setTimeout(() => {
74
+ dismissToast();
75
+ }, delay);
76
+ },
77
+ [clearTimer, dismissToast],
78
+ );
79
+
80
+ useEffect(() => {
81
+ if (toast.isExiting || resolvedDuration === null) {
82
+ clearTimer();
83
+ return undefined;
84
+ }
85
+
86
+ if (!isHoveredRef.current) {
87
+ startTimer(resolvedDuration);
88
+ }
89
+
90
+ return () => {
91
+ clearTimer();
92
+ };
93
+ }, [
94
+ clearTimer,
95
+ resolvedDuration,
96
+ startTimer,
97
+ toast.description,
98
+ toast.isExiting,
99
+ toast.title,
100
+ toast.type,
101
+ ]);
102
+
103
+ useLayoutEffect(() => {
104
+ const node = wrapperRef.current;
105
+
106
+ if (!node) {
107
+ return undefined;
108
+ }
109
+
110
+ node.style.transition = 'none';
111
+ node.style.transform = '';
112
+
113
+ const currentTop = node.getBoundingClientRect().top;
114
+ const previousTop = previousTopRef.current;
115
+ const previousStackIndex = previousStackIndexRef.current;
116
+
117
+ if (toast.isExiting) {
118
+ previousTopRef.current = currentTop;
119
+ previousStackIndexRef.current = stackIndex;
120
+
121
+ return () => {
122
+ if (animationFrameRef.current !== null) {
123
+ window.cancelAnimationFrame(animationFrameRef.current);
124
+ animationFrameRef.current = null;
125
+ }
126
+ };
127
+ }
128
+
129
+ const didStackIndexChange = previousStackIndex !== null && previousStackIndex !== stackIndex;
130
+
131
+ if (didStackIndexChange && previousTop !== null && previousTop !== currentTop) {
132
+ const delta = previousTop - currentTop;
133
+ const shiftDuration =
134
+ delta > 0 ? STACK_SHIFT_ENTER_DURATION_MS : STACK_SHIFT_EXIT_DURATION_MS;
135
+
136
+ node.style.transform = `translateY(${delta}px)`;
137
+ node.getBoundingClientRect();
138
+
139
+ animationFrameRef.current = window.requestAnimationFrame(() => {
140
+ animationFrameRef.current = null;
141
+
142
+ if (!wrapperRef.current) {
143
+ return;
144
+ }
145
+
146
+ wrapperRef.current.style.transition = `transform ${shiftDuration}ms ease-out`;
147
+ wrapperRef.current.style.transform = 'translateY(0)';
148
+ });
149
+ }
150
+
151
+ previousTopRef.current = currentTop;
152
+ previousStackIndexRef.current = stackIndex;
153
+
154
+ return () => {
155
+ if (animationFrameRef.current !== null) {
156
+ window.cancelAnimationFrame(animationFrameRef.current);
157
+ animationFrameRef.current = null;
158
+ }
159
+ };
160
+ });
161
+
162
+ useEffect(() => {
163
+ return () => {
164
+ clearTimer();
165
+
166
+ if (animationFrameRef.current !== null) {
167
+ window.cancelAnimationFrame(animationFrameRef.current);
168
+ }
169
+ };
170
+ }, [clearTimer]);
171
+
172
+ const handleMouseEnter = useCallback((): void => {
173
+ isHoveredRef.current = true;
174
+
175
+ if (resolvedDuration === null || startedAtRef.current === null) {
176
+ return;
177
+ }
178
+
179
+ const elapsed = Date.now() - startedAtRef.current;
180
+ remainingTimeRef.current = Math.max(remainingTimeRef.current - elapsed, 0);
181
+ clearTimer();
182
+ }, [clearTimer, resolvedDuration]);
183
+
184
+ const handleMouseLeave = useCallback((): void => {
185
+ isHoveredRef.current = false;
186
+
187
+ if (toast.isExiting || resolvedDuration === null) {
188
+ return;
189
+ }
190
+
191
+ startTimer(remainingTimeRef.current || resolvedDuration);
192
+ }, [resolvedDuration, startTimer, toast.isExiting]);
193
+
194
+ return {
195
+ wrapperRef,
196
+ hasDetails,
197
+ dismissToast,
198
+ handleMouseEnter,
199
+ handleMouseLeave,
200
+ ariaRole,
201
+ ariaLive,
202
+ };
203
+ }
@@ -0,0 +1,47 @@
1
+ import { useContext, useMemo } from 'react';
2
+
3
+ import type { ToastContextValue, ToastOptions, ToastType } from '../types/toast';
4
+
5
+ import { ToastContext } from '../contexts/Toast/ToastContext';
6
+
7
+ type TypedToastOptions = Omit<ToastOptions, 'title' | 'type'>;
8
+
9
+ interface UseToastReturn extends ToastContextValue {
10
+ info: (title: string, options?: TypedToastOptions) => string;
11
+ success: (title: string, options?: TypedToastOptions) => string;
12
+ warning: (title: string, options?: TypedToastOptions) => string;
13
+ error: (title: string, options?: TypedToastOptions) => string;
14
+ loading: (title: string, options?: TypedToastOptions) => string;
15
+ }
16
+
17
+ function createTypedToast(
18
+ showToast: ToastContextValue['showToast'],
19
+ type: ToastType,
20
+ ): (title: string, options?: TypedToastOptions) => string {
21
+ return (title: string, options?: TypedToastOptions): string =>
22
+ showToast({
23
+ ...options,
24
+ title,
25
+ type,
26
+ });
27
+ }
28
+
29
+ export function useToast(): UseToastReturn {
30
+ const context = useContext(ToastContext);
31
+
32
+ if (!context) {
33
+ throw new Error('useToast must be used within a ToastProvider');
34
+ }
35
+
36
+ return useMemo(
37
+ () => ({
38
+ ...context,
39
+ info: createTypedToast(context.showToast, 'info'),
40
+ success: createTypedToast(context.showToast, 'success'),
41
+ warning: createTypedToast(context.showToast, 'warning'),
42
+ error: createTypedToast(context.showToast, 'error'),
43
+ loading: createTypedToast(context.showToast, 'loading'),
44
+ }),
45
+ [context],
46
+ );
47
+ }
@@ -2,7 +2,6 @@ import { css } from 'styled-components';
2
2
 
3
3
  import { scorecardDarkMode } from '@redocly/theme/components/Scorecard/variables.dark';
4
4
  import { mermaidDarkMode } from '@redocly/theme/markdoc/components/Mermaid/variables.dark'
5
- import { excalidrawDarkMode } from '@redocly/theme/markdoc/components/ExcalidrawDiagram/variables.dark'
6
5
  import { menuDarkMode } from '@redocly/theme/components/Menu/variables.dark';
7
6
  import { buttonDarkMode } from '@redocly/theme/components/Button/variables.dark';
8
7
  import { aiAssistantButtonDarkMode } from '@redocly/theme/components/Buttons/variables.dark';
@@ -19,7 +18,9 @@ import { bannerDarkMode } from '@redocly/theme/components/Banner/variables.dark'
19
18
  import { admonitionDarkMode } from '@redocly/theme/components/Admonition/variables.dark';
20
19
  import { svgViewerDarkMode } from '@redocly/theme/components/SvgViewer/variables.dark';
21
20
 
22
- const replayDarkMode = css`
21
+ import { activeBrandPaletteDark } from './palette.dark';
22
+
23
+ const replayDarkMode = css<{ palette?: string }>`
23
24
  /**
24
25
  * @tokens Replay Colors
25
26
  * @presenter Color
@@ -267,6 +268,11 @@ export const darkMode = css`
267
268
  --layer-accent-hover: var(--color-warm-grey-10);
268
269
  --layer-color-raised: var(--color-warm-grey-3);
269
270
 
271
+ --color-brand-subtle-bg: var(--color-brand-subtle-1);
272
+ --color-brand-subtle-bg-hover: var(--color-brand-subtle-2);
273
+ --color-brand-subtle-border: var(--color-brand-subtle-3);
274
+ --color-brand-subtle-border-hover: var(--color-brand-subtle-4);
275
+
270
276
  /**
271
277
  * @tokens Border Colors
272
278
  * @presenter Color
@@ -338,7 +344,6 @@ export const darkMode = css`
338
344
  ${statusCodeDarkMode}
339
345
  ${menuDarkMode}
340
346
  ${mermaidDarkMode}
341
- ${excalidrawDarkMode}
342
347
  ${scorecardDarkMode}
343
348
  ${replayDarkMode}
344
349
  ${switcherDarkMode}
@@ -350,7 +355,7 @@ export const darkMode = css`
350
355
  ${admonitionDarkMode}
351
356
  ${svgViewerDarkMode}
352
357
  ${badgesDarkMode}
353
-
358
+ ${activeBrandPaletteDark}
354
359
  /**
355
360
  * @tokens Dark Theme Scrollbar Config
356
361
  * @presenter Color
@@ -29,7 +29,6 @@ import { markdown } from '@redocly/theme/components/Markdown/variables';
29
29
  import { banner } from '@redocly/theme/components/Banner/variables';
30
30
  import { markdownTabs } from '@redocly/theme/markdoc/components/Tabs/variables';
31
31
  import { mermaid } from '@redocly/theme/markdoc/components/Mermaid/variables';
32
- import { excalidraw } from '@redocly/theme/markdoc/components/ExcalidrawDiagram/variables';
33
32
  import { lastUpdated } from '@redocly/theme/components/LastUpdated/variables';
34
33
  import { logo } from '@redocly/theme/components/Logo/variables';
35
34
  import { statusCode } from '@redocly/theme/components/StatusCode/variables';
@@ -44,7 +43,9 @@ import { codeWalkthrough } from '@redocly/theme/markdoc/components/CodeWalkthrou
44
43
  import { skipContent } from '@redocly/theme/components/SkipContent/variables';
45
44
  import { pageActions } from '@redocly/theme/components/PageActions/variables';
46
45
  import { svgViewer } from '@redocly/theme/components/SvgViewer/variables';
46
+ import { toast } from '@redocly/theme/components/Toast/variables';
47
47
 
48
+ import { activeBrandPaletteLight } from './palette';
48
49
  import { darkMode } from './dark';
49
50
 
50
51
  const themeColors = css`
@@ -226,17 +227,6 @@ const themeColors = css`
226
227
  --color-white: #ffffff;
227
228
  --color-static-white: #ffffff;
228
229
 
229
- --color-primary-bg: var(--color-blueberry-1);
230
- --color-primary-bg-hover: var(--color-blueberry-2);
231
- --color-primary-border: var(--color-blueberry-3);
232
- --color-primary-border-hover: var(--color-blueberry-4);
233
- --color-primary-hover: var(--color-blueberry-5);
234
- --color-primary-base: var(--color-blueberry-6);
235
- --color-primary-active: var(--color-blueberry-7);
236
- --color-primary-text-hover: var(--color-blueberry-8);
237
- --color-primary-text: var(--color-blueberry-9);
238
- --color-primary-text-active: var(--color-blueberry-10);
239
-
240
230
  --color-success-bg: var(--color-green-1);
241
231
  --color-success-bg-hover: var(--color-green-2);
242
232
  --color-success-border: var(--color-green-3);
@@ -281,6 +271,18 @@ const themeColors = css`
281
271
  --color-info-text: var(--color-blue-9);
282
272
  --color-info-text-active: var(--color-blue-10);
283
273
 
274
+ --color-primary-bg: var(--color-brand-1); // @presenter Color
275
+ --color-primary-bg-hover: var(--color-brand-2); // @presenter Color
276
+ --color-primary-border: var(--color-brand-3); // @presenter Color
277
+ --color-primary-border-hover: var(--color-brand-4); // @presenter Color
278
+ --color-primary-hover: var(--color-brand-8); // @presenter Color
279
+ --color-primary-base: var(--color-brand-6); // @presenter Color
280
+ --color-primary-active: var(--color-brand-7); // @presenter Color
281
+ --color-primary-text-hover: var(--color-brand-9); // @presenter Color
282
+ --color-primary-text: var(--color-brand-8); // @presenter Color
283
+ --color-primary-text-active: var(--color-brand-7); // @presenter Color
284
+ --color-primary-text-on-color: var(--text-color-on-color); // @presenter Color
285
+
284
286
  /**
285
287
  * @tokens Elevation Colors
286
288
  * @presenter Color
@@ -763,24 +765,24 @@ const apiReferenceDocs = css`
763
765
  --schema-chevron-color: var(--text-color-secondary); // @presenter Color
764
766
  --schema-chevron-size: 9px;
765
767
 
766
- --schema-property-deep-link-icon-color: var(--color-primary-base); // @presenter Color
768
+ --schema-property-deep-link-icon-color: var(--color-primary-base, var(--color-blueberry-6)); // @presenter Color
767
769
  --schema-property-deep-link-icon: none;
768
770
 
769
771
  /**
770
772
  * @tokens API Reference Other
771
773
  */
772
774
 
773
- --loading-spinner-color: var(--color-primary-base); // @presenter Color
775
+ --loading-spinner-color: var(--color-primary-base, var(--color-blueberry-6)); // @presenter Color
774
776
  --linear-progress-color: var(--color-info-base); // @presenter Color
775
777
  --linear-progress-bg-color: var(--color-info-bg); // @presenter Color
776
778
 
777
- --fab-bg-color: var(--color-primary-base); // @presenter Color
779
+ --fab-bg-color: var(--color-primary-base, var(--color-blueberry-6)); // @presenter Color
778
780
  --fab-box-shadow: var(--bg-raised-shadow); // @presenter Shadow
779
781
 
780
- --fab-bg-color-hover: var(--color-primary-base); // @presenter Color
782
+ --fab-bg-color-hover: var(--color-primary-base, var(--color-blueberry-6)); // @presenter Color
781
783
  --fab-box-shadow-hover: var(--bg-raised-shadow); // @presenter Shadow
782
784
 
783
- --fab-bg-color-active: var(--color-primary-base); // @presenter Color
785
+ --fab-bg-color-active: var(--color-primary-base, var(--color-blueberry-6)); // @presenter Color
784
786
  --fab-box-shadow-active: var(--bg-raised-shadow); // @presenter Shadow
785
787
 
786
788
  --fab-icon-color: var(--navbar-text-color); // @presenter Color
@@ -1257,11 +1259,18 @@ const replay = css`
1257
1259
  --replay-ai-user-message-gradient: linear-gradient(73.52deg, rgba(113, 94, 254, 0.08) 10.13%, rgba(255, 92, 220, 0.08) 87.29%);
1258
1260
 
1259
1261
  --replay-ai-send-button-disabled-border: 1px solid #ffffff33;
1262
+
1263
+ --replay-transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
1264
+ --replay-transition-duration: 300ms;
1265
+
1266
+ @media (prefers-reduced-motion: reduce) {
1267
+ --replay-transition-duration: 0s;
1268
+ }
1260
1269
  // @tokens End
1261
1270
  `;
1262
1271
 
1263
1272
 
1264
- export const styles = css`
1273
+ export const styles = css<{ palette?: string }>`
1265
1274
  :root {
1266
1275
  ${accordion}
1267
1276
  ${admonition}
@@ -1295,7 +1304,6 @@ export const styles = css`
1295
1304
  ${markdown}
1296
1305
  ${markdownTabs}
1297
1306
  ${mermaid}
1298
- ${excalidraw}
1299
1307
  ${menu}
1300
1308
  ${mobileMenu}
1301
1309
  ${modal}
@@ -1309,6 +1317,7 @@ export const styles = css`
1309
1317
  ${sizeAndSpace}
1310
1318
  ${tag}
1311
1319
  ${themeColors}
1320
+ ${activeBrandPaletteLight}
1312
1321
  ${tile}
1313
1322
  ${toc}
1314
1323
  ${tooltip}
@@ -1331,6 +1340,7 @@ export const styles = css`
1331
1340
  ${skipContent}
1332
1341
  ${pageActions}
1333
1342
  ${svgViewer}
1343
+ ${toast}
1334
1344
 
1335
1345
  background-color: var(--bg-color);
1336
1346
  color: var(--text-color-primary);
@@ -1348,6 +1358,6 @@ export const styles = css`
1348
1358
  ${browserOverrides}
1349
1359
  `;
1350
1360
 
1351
- export const GlobalStyle = createGlobalStyle`
1361
+ export const GlobalStyle = createGlobalStyle<{ palette?: string }>`
1352
1362
  ${styles};
1353
1363
  `;
@@ -0,0 +1,199 @@
1
+ import { css, type FlattenSimpleInterpolation } from 'styled-components';
2
+
3
+ function brandPaletteDark(palette: string | undefined): FlattenSimpleInterpolation {
4
+ switch (palette) {
5
+ case 'slate':
6
+ return css`
7
+ --color-brand-1: #2a2b33;
8
+ --color-brand-2: #3b3c45;
9
+ --color-brand-3: #555761;
10
+ --color-brand-4: #6e6f7a;
11
+ --color-brand-5: #9b9ca8;
12
+ --color-brand-6: #fbfbfc;
13
+ --color-brand-7: #ededf2;
14
+ --color-brand-8: #dcdde5;
15
+ --color-brand-9: #c4c6d1;
16
+ --color-brand-10: #9b9ca8;
17
+ --color-brand-11: #6e6f7a;
18
+ --color-brand-subtle-1: #2a2b3366;
19
+ --color-brand-subtle-2: #3b3c4566;
20
+ --color-brand-subtle-3: #55576166;
21
+ --color-brand-subtle-4: #6e6f7a66;
22
+ --text-color-on-color: #000000;
23
+ `;
24
+ case 'pink':
25
+ return css`
26
+ --color-brand-1: #4f2841;
27
+ --color-brand-2: #6a3055;
28
+ --color-brand-3: #853668;
29
+ --color-brand-4: #a03a7b;
30
+ --color-brand-5: #bb3d8d;
31
+ --color-brand-6: #d6409f;
32
+ --color-brand-7: #de59ad;
33
+ --color-brand-8: #e677bd;
34
+ --color-brand-9: #ef99cf;
35
+ --color-brand-10: #f7bfe2;
36
+ --color-brand-11: #ffe8f7;
37
+ --color-brand-subtle-1: #4f284166;
38
+ --color-brand-subtle-2: #6a305566;
39
+ --color-brand-subtle-3: #85366866;
40
+ --color-brand-subtle-4: #a03a7b66;
41
+ --text-color-on-color: #ffffff;
42
+ `;
43
+ case 'coral':
44
+ return css`
45
+ --color-brand-1: #4f282b;
46
+ --color-brand-2: #6d3338;
47
+ --color-brand-3: #8b3c42;
48
+ --color-brand-4: #a9434c;
49
+ --color-brand-5: #c74b55;
50
+ --color-brand-6: #e5535f;
51
+ --color-brand-7: #ea6a75;
52
+ --color-brand-8: #ef858d;
53
+ --color-brand-9: #f5a3aa;
54
+ --color-brand-10: #fac5c9;
55
+ --color-brand-11: #ffe8ea;
56
+ --color-brand-subtle-1: #4f282b66;
57
+ --color-brand-subtle-2: #6d333866;
58
+ --color-brand-subtle-3: #8b3c4266;
59
+ --color-brand-subtle-4: #a9434c66;
60
+ --text-color-on-color: #ffffff;
61
+ `;
62
+ case 'amber':
63
+ return css`
64
+ --color-brand-1: #4f3c28;
65
+ --color-brand-2: #71512e;
66
+ --color-brand-3: #93632f;
67
+ --color-brand-4: #b6732a;
68
+ --color-brand-5: #d88121;
69
+ --color-brand-6: #fa8d15;
70
+ --color-brand-7: #fb9f3a;
71
+ --color-brand-8: #fcb261;
72
+ --color-brand-9: #fdc78c;
73
+ --color-brand-10: #feddba;
74
+ --color-brand-11: #fff4e8;
75
+ --color-brand-subtle-1: #4f3c2866;
76
+ --color-brand-subtle-2: #71512e66;
77
+ --color-brand-subtle-3: #93632f66;
78
+ --color-brand-subtle-4: #b6732a66;
79
+ --text-color-on-color: #ffffff;
80
+ `;
81
+ case 'jade':
82
+ return css`
83
+ --color-brand-1: #284f45;
84
+ --color-brand-2: #2a6052;
85
+ --color-brand-3: #2b715e;
86
+ --color-brand-4: #2b816b;
87
+ --color-brand-5: #2a9277;
88
+ --color-brand-6: #29a383;
89
+ --color-brand-7: #42b597;
90
+ --color-brand-8: #61c8ad;
91
+ --color-brand-9: #88dac4;
92
+ --color-brand-10: #b5edde;
93
+ --color-brand-11: #e8fff9;
94
+ --color-brand-subtle-1: #284f4566;
95
+ --color-brand-subtle-2: #2a605266;
96
+ --color-brand-subtle-3: #2b715e66;
97
+ --color-brand-subtle-4: #2b816b66;
98
+ --text-color-on-color: #ffffff;
99
+ `;
100
+ case 'cyan':
101
+ return css`
102
+ --color-brand-1: #28484f;
103
+ --color-brand-2: #285c67;
104
+ --color-brand-3: #246e7f;
105
+ --color-brand-4: #1b8097;
106
+ --color-brand-5: #0f91af;
107
+ --color-brand-6: #00a2c7;
108
+ --color-brand-7: #22b2d2;
109
+ --color-brand-8: #4ac2dd;
110
+ --color-brand-9: #79d4e9;
111
+ --color-brand-10: #aee7f4;
112
+ --color-brand-11: #e8fbff;
113
+ --color-brand-subtle-1: #28484f66;
114
+ --color-brand-subtle-2: #285c6766;
115
+ --color-brand-subtle-3: #246e7f66;
116
+ --color-brand-subtle-4: #1b809766;
117
+ --text-color-on-color: #ffffff;
118
+ `;
119
+ case 'ocean':
120
+ return css`
121
+ --color-brand-1: #283e4f;
122
+ --color-brand-2: #2d5472;
123
+ --color-brand-3: #2a6795;
124
+ --color-brand-4: #2277b9;
125
+ --color-brand-5: #1384dc;
126
+ --color-brand-6: #0090ff;
127
+ --color-brand-7: #29a2ff;
128
+ --color-brand-8: #56b5ff;
129
+ --color-brand-9: #85caff;
130
+ --color-brand-10: #b6dfff;
131
+ --color-brand-11: #e8f5ff;
132
+ --color-brand-subtle-1: #283e4f66;
133
+ --color-brand-subtle-2: #2d547266;
134
+ --color-brand-subtle-3: #2a679566;
135
+ --color-brand-subtle-4: #2277b966;
136
+ --text-color-on-color: #ffffff;
137
+ `;
138
+ case 'indigo':
139
+ return css`
140
+ --color-brand-1: #28314f;
141
+ --color-brand-2: #303e6b;
142
+ --color-brand-3: #364988;
143
+ --color-brand-4: #3952a4;
144
+ --color-brand-5: #3c5bc1;
145
+ --color-brand-6: #3e63dd;
146
+ --color-brand-7: #5879e4;
147
+ --color-brand-8: #7691eb;
148
+ --color-brand-9: #99aef1;
149
+ --color-brand-10: #bfcdf8;
150
+ --color-brand-11: #e8edff;
151
+ --color-brand-subtle-1: #28314f66;
152
+ --color-brand-subtle-2: #303e6b66;
153
+ --color-brand-subtle-3: #36498866;
154
+ --color-brand-subtle-4: #3952a466;
155
+ --text-color-on-color: #ffffff;
156
+ `;
157
+ case 'iris':
158
+ return css`
159
+ --color-brand-1: #2e2e4f;
160
+ --color-brand-2: #3a3a6a;
161
+ --color-brand-3: #434385;
162
+ --color-brand-4: #4c4ca0;
163
+ --color-brand-5: #5353bb;
164
+ --color-brand-6: #5b5bd6;
165
+ --color-brand-7: #7070de;
166
+ --color-brand-8: #8a8ae6;
167
+ --color-brand-9: #a7a7ef;
168
+ --color-brand-10: #c8c8f7;
169
+ --color-brand-11: #ebebff;
170
+ --color-brand-subtle-1: #2e2e4f80;
171
+ --color-brand-subtle-2: #3a3a6a80;
172
+ --color-brand-subtle-3: #43438580;
173
+ --color-brand-subtle-4: #4c4ca080;
174
+ --text-color-on-color: #ffffff;
175
+ `;
176
+ default:
177
+ return css`
178
+ --button-bg-color-primary-hover-legacy: var(--color-blue-5);
179
+ --button-bg-color-primary-pressed-legacy: var(--color-blue-4);
180
+
181
+ --toc-item-text-color-active-legacy: var(--text-color-primary);
182
+ --toc-item-border-color-active-legacy: var(--border-color-invers);
183
+
184
+ --checkbox-border-color-legacy: var(--border-color-primary);
185
+
186
+ --switch-bg-color-selected-legacy: var(--color-warm-grey-7);
187
+ --switch-border-color-selected-legacy: var(--color-warm-grey-7);
188
+
189
+ --md-tabs-active-tab-bg-color-legacy: var(--bg-color-active);
190
+
191
+ --admonition-default-bg-color-legacy: var(--color-warm-grey-3);
192
+ --admonition-default-border-color-legacy: var(--color-warm-grey-5);
193
+ `;
194
+ }
195
+ }
196
+
197
+ export const activeBrandPaletteDark = css<{ palette?: string }>`
198
+ ${({ palette }) => brandPaletteDark(palette)}
199
+ `;