@acmekit/docs-ui 2.13.41

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 (236) hide show
  1. package/dist/Items-YPPZD6C6.mjs +312 -0
  2. package/dist/chunk-JD7BP7O5.mjs +13144 -0
  3. package/dist/index.d.mts +1550 -0
  4. package/dist/index.d.ts +1550 -0
  5. package/dist/index.js +15218 -0
  6. package/dist/index.mjs +366 -0
  7. package/package.json +58 -0
  8. package/src/components/Badge/index.tsx +74 -0
  9. package/src/components/BadgesList/index.tsx +18 -0
  10. package/src/components/BetaBadge/index.tsx +24 -0
  11. package/src/components/Bordered/index.tsx +21 -0
  12. package/src/components/BorderedIcon/index.tsx +60 -0
  13. package/src/components/Breadcrumbs/index.tsx +83 -0
  14. package/src/components/Button/index.tsx +100 -0
  15. package/src/components/Card/Layout/Default/index.tsx +124 -0
  16. package/src/components/Card/Layout/Filler/index.tsx +30 -0
  17. package/src/components/Card/Layout/Large/index.tsx +88 -0
  18. package/src/components/Card/Layout/Mini/index.tsx +142 -0
  19. package/src/components/Card/index.tsx +50 -0
  20. package/src/components/CardList/index.tsx +40 -0
  21. package/src/components/ChildDocs/index.tsx +9 -0
  22. package/src/components/CodeBlock/Actions/AskAi/index.tsx +10 -0
  23. package/src/components/CodeBlock/Actions/Copy/index.tsx +59 -0
  24. package/src/components/CodeBlock/Actions/index.tsx +137 -0
  25. package/src/components/CodeBlock/Collapsible/Button/index.tsx +58 -0
  26. package/src/components/CodeBlock/Collapsible/Fade/index.tsx +55 -0
  27. package/src/components/CodeBlock/Collapsible/Lines/index.tsx +22 -0
  28. package/src/components/CodeBlock/Header/Wrapper/index.tsx +46 -0
  29. package/src/components/CodeBlock/Header/index.tsx +67 -0
  30. package/src/components/CodeBlock/Inline/index.tsx +20 -0
  31. package/src/components/CodeBlock/Line/index.tsx +331 -0
  32. package/src/components/CodeBlock/index.tsx +510 -0
  33. package/src/components/CodeMdx/index.tsx +45 -0
  34. package/src/components/CodeTabs/Item/index.tsx +67 -0
  35. package/src/components/CodeTabs/index.tsx +319 -0
  36. package/src/components/ContentMenu/Actions/index.tsx +7 -0
  37. package/src/components/ContentMenu/Products/index.tsx +64 -0
  38. package/src/components/ContentMenu/Toc/index.tsx +148 -0
  39. package/src/components/ContentMenu/Version/index.tsx +77 -0
  40. package/src/components/ContentMenu/index.tsx +31 -0
  41. package/src/components/CopyButton/index.tsx +76 -0
  42. package/src/components/Details/Summary/index.tsx +75 -0
  43. package/src/components/Details/index.tsx +98 -0
  44. package/src/components/DetailsList/index.tsx +32 -0
  45. package/src/components/DottedSeparator/index.tsx +30 -0
  46. package/src/components/EditButton/index.tsx +32 -0
  47. package/src/components/EditDate/index.tsx +33 -0
  48. package/src/components/ErrorPage/Icon/index.tsx +428 -0
  49. package/src/components/ErrorPage/index.tsx +32 -0
  50. package/src/components/Feedback/Solutions/index.tsx +105 -0
  51. package/src/components/Feedback/index.tsx +304 -0
  52. package/src/components/Footer/index.tsx +23 -0
  53. package/src/components/Heading/H1/index.tsx +21 -0
  54. package/src/components/Heading/H2/index.tsx +47 -0
  55. package/src/components/Heading/H3/index.tsx +42 -0
  56. package/src/components/Heading/H4/index.tsx +14 -0
  57. package/src/components/Heading/index.tsx +4 -0
  58. package/src/components/IconHeadline/index.tsx +15 -0
  59. package/src/components/Icons/AiAssistant/index.tsx +462 -0
  60. package/src/components/Icons/ArrowRightDown/index.tsx +30 -0
  61. package/src/components/Icons/BundledProduct/index.tsx +72 -0
  62. package/src/components/Icons/CalendarRefresh/index.tsx +70 -0
  63. package/src/components/Icons/ChefHat/index.tsx +65 -0
  64. package/src/components/Icons/CircleDottedLine/index.tsx +60 -0
  65. package/src/components/Icons/CloudSolid/index.tsx +47 -0
  66. package/src/components/Icons/ColoredAcmeKit/index.tsx +13 -0
  67. package/src/components/Icons/DecisionProcess/index.tsx +58 -0
  68. package/src/components/Icons/Erp/index.tsx +92 -0
  69. package/src/components/Icons/Github/index.tsx +22 -0
  70. package/src/components/Icons/House/index.tsx +23 -0
  71. package/src/components/Icons/ImageBinary/index.tsx +69 -0
  72. package/src/components/Icons/Kapa/index.tsx +22 -0
  73. package/src/components/Icons/Markdown/index.tsx +25 -0
  74. package/src/components/Icons/NavigationDropdown/Admin/index.tsx +33 -0
  75. package/src/components/Icons/NavigationDropdown/Doc/index.tsx +41 -0
  76. package/src/components/Icons/NavigationDropdown/DocV1/index.tsx +37 -0
  77. package/src/components/Icons/NavigationDropdown/Modules/index.tsx +33 -0
  78. package/src/components/Icons/NavigationDropdown/Resources/index.tsx +37 -0
  79. package/src/components/Icons/NavigationDropdown/Store/index.tsx +37 -0
  80. package/src/components/Icons/NavigationDropdown/Ui/index.tsx +37 -0
  81. package/src/components/Icons/NavigationDropdown/User/index.tsx +37 -0
  82. package/src/components/Icons/PuzzleColored/index.tsx +35 -0
  83. package/src/components/Icons/QuestionMark/index.tsx +23 -0
  84. package/src/components/Icons/Restock/index.tsx +55 -0
  85. package/src/components/Icons/ScrollText/index.tsx +68 -0
  86. package/src/components/Icons/ShadedBg/index.tsx +334 -0
  87. package/src/components/Icons/Shop/index.tsx +68 -0
  88. package/src/components/Icons/SidebarLeft/index.tsx +42 -0
  89. package/src/components/Icons/StripeColored/index.tsx +60 -0
  90. package/src/components/Icons/ThumbDown/index.tsx +23 -0
  91. package/src/components/Icons/ThumbUp/index.tsx +23 -0
  92. package/src/components/Icons/WindowPaintbrush/index.tsx +57 -0
  93. package/src/components/Icons/index.tsx +20 -0
  94. package/src/components/InlineCode/index.tsx +42 -0
  95. package/src/components/InlineIcon/index.tsx +21 -0
  96. package/src/components/InlineThemeImage/index.tsx +14 -0
  97. package/src/components/Input/Search/index.tsx +64 -0
  98. package/src/components/Input/Text/index.tsx +39 -0
  99. package/src/components/Kbd/index.tsx +33 -0
  100. package/src/components/Label/index.tsx +19 -0
  101. package/src/components/Link/index.tsx +67 -0
  102. package/src/components/LinkButton/index.tsx +43 -0
  103. package/src/components/Loading/Dots/index.tsx +16 -0
  104. package/src/components/Loading/Spinner/index.tsx +19 -0
  105. package/src/components/Loading/index.tsx +43 -0
  106. package/src/components/MDXComponents/index.tsx +209 -0
  107. package/src/components/MainNav/DesktopMenu/ThemeMenu/index.tsx +76 -0
  108. package/src/components/MainNav/DesktopMenu/index.tsx +100 -0
  109. package/src/components/MainNav/Items/Dropdown/index.tsx +88 -0
  110. package/src/components/MainNav/Items/Link/index.tsx +34 -0
  111. package/src/components/MainNav/Items/index.tsx +61 -0
  112. package/src/components/MainNav/MobileMenu/Main/index.tsx +67 -0
  113. package/src/components/MainNav/MobileMenu/SubMenu/index.tsx +77 -0
  114. package/src/components/MainNav/MobileMenu/index.tsx +103 -0
  115. package/src/components/MainNav/Version/index.tsx +33 -0
  116. package/src/components/MainNav/index.tsx +153 -0
  117. package/src/components/MarkdownContent/index.tsx +41 -0
  118. package/src/components/Menu/Action/index.tsx +43 -0
  119. package/src/components/Menu/Divider/index.tsx +35 -0
  120. package/src/components/Menu/Dropdown/index.tsx +78 -0
  121. package/src/components/Menu/Item/index.tsx +36 -0
  122. package/src/components/Menu/SubMenu/index.tsx +47 -0
  123. package/src/components/Menu/index.tsx +44 -0
  124. package/src/components/Modal/Footer/index.tsx +29 -0
  125. package/src/components/Modal/Header/index.tsx +33 -0
  126. package/src/components/Modal/index.tsx +124 -0
  127. package/src/components/Note/Layout/index.tsx +139 -0
  128. package/src/components/Note/Types/checks.tsx +7 -0
  129. package/src/components/Note/Types/default.tsx +7 -0
  130. package/src/components/Note/Types/error.tsx +7 -0
  131. package/src/components/Note/Types/soon.tsx +7 -0
  132. package/src/components/Note/Types/sucess.tsx +7 -0
  133. package/src/components/Note/Types/warning.tsx +7 -0
  134. package/src/components/Note/index.tsx +32 -0
  135. package/src/components/Notices/DeprecatedNotice/index.tsx +33 -0
  136. package/src/components/Notices/ExpandableNotice/index.tsx +36 -0
  137. package/src/components/Notices/FeatureFlagNotice/index.tsx +36 -0
  138. package/src/components/Notices/VersionNotice/index.tsx +37 -0
  139. package/src/components/Notification/Item/Layout/Default/index.tsx +89 -0
  140. package/src/components/Notification/Item/index.tsx +88 -0
  141. package/src/components/Notification/index.tsx +65 -0
  142. package/src/components/Pagination/Card/index.tsx +80 -0
  143. package/src/components/Pagination/index.tsx +35 -0
  144. package/src/components/Prerequisites/Item/index.tsx +43 -0
  145. package/src/components/Prerequisites/index.tsx +94 -0
  146. package/src/components/RadioItem/index.tsx +38 -0
  147. package/src/components/Rating/index.tsx +133 -0
  148. package/src/components/RootProviders/index.tsx +31 -0
  149. package/src/components/Select/Badge/index.tsx +122 -0
  150. package/src/components/Select/Dropdown/index.tsx +188 -0
  151. package/src/components/Select/Input/index.tsx +123 -0
  152. package/src/components/Select/index.ts +13 -0
  153. package/src/components/Sidebar/Child/index.tsx +43 -0
  154. package/src/components/Sidebar/Item/Category/index.tsx +151 -0
  155. package/src/components/Sidebar/Item/Link/index.tsx +174 -0
  156. package/src/components/Sidebar/Item/Sidebar/index.tsx +67 -0
  157. package/src/components/Sidebar/Item/SubCategory/index.tsx +83 -0
  158. package/src/components/Sidebar/Item/index.tsx +41 -0
  159. package/src/components/Sidebar/Top/MobileClose/index.tsx +21 -0
  160. package/src/components/Sidebar/Top/index.tsx +33 -0
  161. package/src/components/Sidebar/index.tsx +153 -0
  162. package/src/components/SourceCodeLink/index.tsx +37 -0
  163. package/src/components/SplitLists/index.tsx +58 -0
  164. package/src/components/Table/index.tsx +87 -0
  165. package/src/components/Tabs/index.tsx +106 -0
  166. package/src/components/TextArea/index.tsx +30 -0
  167. package/src/components/ThemeImage/index.tsx +26 -0
  168. package/src/components/Toggle/index.tsx +28 -0
  169. package/src/components/Tooltip/index.tsx +65 -0
  170. package/src/components/TypeList/Items/index.tsx +337 -0
  171. package/src/components/TypeList/index.tsx +63 -0
  172. package/src/components/WideSection/index.tsx +25 -0
  173. package/src/components/ZoomImg/index.tsx +17 -0
  174. package/src/components/index.ts +75 -0
  175. package/src/constants.tsx +261 -0
  176. package/src/global-config.ts +11 -0
  177. package/src/hooks/index.ts +14 -0
  178. package/src/hooks/use-active-on-scroll/index.tsx +223 -0
  179. package/src/hooks/use-click-outside/index.tsx +37 -0
  180. package/src/hooks/use-collapsible/index.tsx +128 -0
  181. package/src/hooks/use-collapsible-code-lines/index.tsx +149 -0
  182. package/src/hooks/use-copy/index.tsx +28 -0
  183. package/src/hooks/use-heading-url/index.tsx +32 -0
  184. package/src/hooks/use-is-external-link/index.tsx +19 -0
  185. package/src/hooks/use-keyboard-shortcut/index.tsx +71 -0
  186. package/src/hooks/use-mutation-observer/index.ts +32 -0
  187. package/src/hooks/use-page-scroll-manager/index.tsx +82 -0
  188. package/src/hooks/use-resize-observer/index.ts +20 -0
  189. package/src/hooks/use-scroll-utils/index.tsx +372 -0
  190. package/src/hooks/use-select/index.tsx +99 -0
  191. package/src/hooks/use-tabs/index.tsx +94 -0
  192. package/src/index.ts +8 -0
  193. package/src/layouts/barebone.tsx +18 -0
  194. package/src/layouts/index.ts +4 -0
  195. package/src/layouts/main-content.tsx +86 -0
  196. package/src/layouts/root.tsx +43 -0
  197. package/src/layouts/tight.tsx +29 -0
  198. package/src/layouts/wide.tsx +25 -0
  199. package/src/providers/AiAssistant/index.tsx +65 -0
  200. package/src/providers/BrowserProvider/index.tsx +40 -0
  201. package/src/providers/ColorMode/index.tsx +73 -0
  202. package/src/providers/Layout/index.tsx +52 -0
  203. package/src/providers/MainNav/index.tsx +134 -0
  204. package/src/providers/Mobile/index.tsx +62 -0
  205. package/src/providers/Modal/index.tsx +52 -0
  206. package/src/providers/Notification/index.tsx +149 -0
  207. package/src/providers/Pagination/index.tsx +230 -0
  208. package/src/providers/Search/index.tsx +91 -0
  209. package/src/providers/Sidebar/index.tsx +745 -0
  210. package/src/providers/SiteConfig/index.tsx +70 -0
  211. package/src/providers/index.ts +13 -0
  212. package/src/types/config.ts +34 -0
  213. package/src/types/frontmatter.ts +23 -0
  214. package/src/types/general.ts +1 -0
  215. package/src/types/index.ts +9 -0
  216. package/src/types/menu.ts +40 -0
  217. package/src/types/navigation-dropdown.ts +16 -0
  218. package/src/types/navigation.ts +21 -0
  219. package/src/types/sidebar.ts +109 -0
  220. package/src/types/toc.ts +19 -0
  221. package/src/types/ui.ts +9 -0
  222. package/src/utils/array-same-elms.ts +10 -0
  223. package/src/utils/capitalize.ts +3 -0
  224. package/src/utils/check-sidebar-item-visibility.ts +47 -0
  225. package/src/utils/decode-str.ts +8 -0
  226. package/src/utils/dom-utils.ts +29 -0
  227. package/src/utils/event-parser.ts +54 -0
  228. package/src/utils/get-link-with-base-path.ts +3 -0
  229. package/src/utils/get-navbar-items.ts +55 -0
  230. package/src/utils/get-scrolled-top.ts +8 -0
  231. package/src/utils/index.ts +13 -0
  232. package/src/utils/is-elm-window.ts +3 -0
  233. package/src/utils/is-in-view.ts +10 -0
  234. package/src/utils/os-browser-utils.ts +39 -0
  235. package/src/utils/set-obj-value.ts +38 -0
  236. package/src/utils/sidebar-utils.ts +129 -0
@@ -0,0 +1,331 @@
1
+ import React, { useMemo } from "react"
2
+ import { Highlight } from "../../CodeBlock"
3
+ import { RenderProps, Token } from "prism-react-renderer"
4
+ import clsx from "clsx"
5
+ import { Tooltip } from "../../../components/Tooltip"
6
+ import { MarkdownContent } from "../../MarkdownContent"
7
+
8
+ type HighlightedTokens = {
9
+ start: number
10
+ end: number
11
+ highlight: Highlight
12
+ }
13
+
14
+ type TokensWithHighlights = {
15
+ tokens: Token[]
16
+ type: "default" | "highlighted"
17
+ highlight?: Highlight
18
+ }
19
+
20
+ type CodeBlockLineProps = {
21
+ line: Token[]
22
+ highlights?: Highlight[]
23
+ lineNumber: number
24
+ showLineNumber: boolean
25
+ lineNumberColorClassName: string
26
+ lineNumberBgClassName: string
27
+ isTerminal: boolean
28
+ animateTokenHighlights?: boolean
29
+ } & Pick<RenderProps, "getLineProps" | "getTokenProps">
30
+
31
+ export const CodeBlockLine = ({
32
+ line,
33
+ highlights = [],
34
+ lineNumber,
35
+ getLineProps,
36
+ getTokenProps,
37
+ showLineNumber,
38
+ lineNumberColorClassName,
39
+ lineNumberBgClassName,
40
+ isTerminal,
41
+ animateTokenHighlights = false,
42
+ }: CodeBlockLineProps) => {
43
+ const { key: _lineKey, ...lineProps } = getLineProps({ line, key: lineNumber })
44
+
45
+ // collect highlighted tokens, if there are any
46
+ const highlightedTokens: HighlightedTokens[] = useMemo(() => {
47
+ const highlightedTokensArr: HighlightedTokens[] = []
48
+ highlights.forEach((highlight) => {
49
+ if (!highlight.text) {
50
+ return
51
+ }
52
+ let startIndex: number | undefined = undefined
53
+ let currentPositionInHighlightedText = 0
54
+ let endIndex = 0
55
+ const found = line.some((token, tokenIndex) => {
56
+ if (token.empty || !token.content.length) {
57
+ startIndex = undefined
58
+ currentPositionInHighlightedText = 0
59
+ return false
60
+ }
61
+ const startNotSet = startIndex === undefined
62
+ // trim the start of the script if the start
63
+ // of the highlight hasn't been found yet
64
+ const tokenContent = startNotSet
65
+ ? token.content.trimStart()
66
+ : token.content
67
+ if (!tokenContent.length && startNotSet) {
68
+ return false
69
+ }
70
+ const comparisonLength = Math.min(
71
+ tokenContent.length,
72
+ highlight.text!.substring(currentPositionInHighlightedText).length
73
+ )
74
+ const nextPositionInHighlightedText =
75
+ currentPositionInHighlightedText + comparisonLength
76
+
77
+ const canHighlight =
78
+ !highlightedTokensArr.length ||
79
+ !highlightedTokensArr.some(
80
+ (token) => tokenIndex >= token.start && tokenIndex <= token.end
81
+ )
82
+
83
+ const isMatching =
84
+ tokenContent.substring(0, comparisonLength) ===
85
+ highlight.text?.substring(
86
+ currentPositionInHighlightedText,
87
+ nextPositionInHighlightedText
88
+ )
89
+
90
+ if (isMatching && canHighlight) {
91
+ if (startNotSet) {
92
+ startIndex = tokenIndex
93
+ }
94
+ currentPositionInHighlightedText = nextPositionInHighlightedText
95
+ }
96
+
97
+ if (currentPositionInHighlightedText === highlight.text!.length) {
98
+ // matching text was found, break loop
99
+ endIndex = tokenIndex
100
+ const trimmedContent = token.content.trimEnd()
101
+ const endingSpacesLength =
102
+ token.content.length - trimmedContent.length
103
+ if (endingSpacesLength) {
104
+ line.splice(tokenIndex + 1, 0, {
105
+ content: new Array(endingSpacesLength).fill(" ").join(""),
106
+ types: ["plain"],
107
+ })
108
+ token.content = trimmedContent
109
+ }
110
+ return true
111
+ }
112
+ })
113
+
114
+ if (found && startIndex !== undefined) {
115
+ highlightedTokensArr.push({
116
+ start: startIndex,
117
+ end: endIndex,
118
+ highlight,
119
+ })
120
+ }
121
+ })
122
+
123
+ // sort highlighted tokens by their start position
124
+ highlightedTokensArr.sort((tokensA, tokensB) => {
125
+ if (tokensA.start < tokensB.start) {
126
+ return -1
127
+ }
128
+
129
+ return tokensA.start > tokensB.start ? 1 : 0
130
+ })
131
+
132
+ return highlightedTokensArr
133
+ }, [highlights, line])
134
+
135
+ // if there are highlighted tokens, split tokens in the
136
+ // line by segments of not highlighted and highlighted token
137
+ // if there are no highlighted tokens, the line is used as-is.
138
+ const transformedLine: TokensWithHighlights[] = useMemo(() => {
139
+ if (!highlightedTokens.length) {
140
+ return [
141
+ {
142
+ tokens: line,
143
+ type: "default",
144
+ },
145
+ ]
146
+ }
147
+ const transformedLineArr: TokensWithHighlights[] = []
148
+
149
+ let lastIndex = 0
150
+ // go through highlighted tokens to add the segments before/after to the
151
+ // transformLineArr array
152
+ highlightedTokens.forEach((highlightedTokensItem, index) => {
153
+ if (lastIndex < highlightedTokensItem.start) {
154
+ transformedLineArr.push({
155
+ tokens: line.slice(lastIndex, highlightedTokensItem.start),
156
+ type: "default",
157
+ })
158
+ }
159
+ // check if the start text should be trimmed
160
+ const token = Object.assign({}, line[highlightedTokensItem.start])
161
+ if (
162
+ token.content.startsWith(" ") &&
163
+ !highlightedTokensItem.highlight.text?.startsWith(" ")
164
+ ) {
165
+ const originalLength = token.content.length
166
+ token.content = token.content.trimStart()
167
+ // push the spaces as a separate token
168
+ // so that they won't be highlighted.
169
+ transformedLineArr.push({
170
+ tokens: [
171
+ {
172
+ content: " ".repeat(originalLength - token.content.length),
173
+ types: ["plain"],
174
+ },
175
+ ],
176
+ type: "default",
177
+ })
178
+ }
179
+ transformedLineArr.push({
180
+ tokens: [
181
+ token,
182
+ ...line.slice(
183
+ highlightedTokensItem.start + 1,
184
+ highlightedTokensItem.end + 1
185
+ ),
186
+ ],
187
+ type: "highlighted",
188
+ highlight: highlightedTokensItem.highlight,
189
+ })
190
+ lastIndex = highlightedTokensItem.end + 1
191
+
192
+ // if this is the last item in `highlightedTokens` and
193
+ // its end index is less than the line's length, that means
194
+ // there are tokens at the end of the line that aren't highlighted
195
+ // and should be pushed as-is to the `transformLineArr` array.
196
+ if (
197
+ index === highlightedTokens.length - 1 &&
198
+ lastIndex < line.length - 1
199
+ ) {
200
+ transformedLineArr.push({
201
+ tokens: line.slice(lastIndex),
202
+ type: "default",
203
+ })
204
+ }
205
+ })
206
+
207
+ return transformedLineArr
208
+ }, [highlightedTokens])
209
+
210
+ const getTokensElm = ({
211
+ tokens,
212
+ isTokenHighlighted,
213
+ offset,
214
+ }: {
215
+ tokens: Token[]
216
+ isTokenHighlighted: boolean
217
+ offset: number
218
+ }) => (
219
+ <span
220
+ className={clsx(isTokenHighlighted && "relative")}
221
+ data-testid="code-block-line-tokens"
222
+ >
223
+ {isTokenHighlighted && (
224
+ <span
225
+ className={clsx(
226
+ animateTokenHighlights && [
227
+ "animate-fast animate-growWidth animation-fill-forwards",
228
+ ],
229
+ !animateTokenHighlights && "w-full",
230
+ "absolute left-0 top-0 h-full z-0",
231
+ "lg:bg-acmekit-alpha-white-alpha-6 lg:border lg:border-acmekit-alpha-white-alpha-12",
232
+ "lg:rounded-docs_xs scale-x-[1.05]"
233
+ )}
234
+ data-testid="code-block-line-highlight"
235
+ />
236
+ )}
237
+ {tokens.map((token, key) => {
238
+ const tokenKey = offset + key
239
+ const { className: tokenClassName, key: _tokenKey, ...rest } = getTokenProps({
240
+ token,
241
+ key: tokenKey,
242
+ })
243
+ return (
244
+ <span
245
+ key={tokenKey}
246
+ className={clsx(
247
+ tokenClassName,
248
+ isTokenHighlighted && "relative z-[1]"
249
+ )}
250
+ data-testid="code-block-line-token"
251
+ {...rest}
252
+ />
253
+ )
254
+ })}
255
+ </span>
256
+ )
257
+
258
+ const isHighlightedLine = useMemo(
259
+ () => highlights.length !== 0 && highlightedTokens.length === 0,
260
+ [highlights, highlightedTokens]
261
+ )
262
+
263
+ return (
264
+ <span
265
+ key={lineNumber}
266
+ {...lineProps}
267
+ className={clsx(
268
+ "table-row",
269
+ isHighlightedLine && "bg-acmekit-alpha-white-alpha-6",
270
+ lineProps.className
271
+ )}
272
+ data-testid="code-block-line"
273
+ >
274
+ {(showLineNumber || isTerminal) && (
275
+ <span
276
+ className={clsx(
277
+ "mr-docs_1 table-cell select-none",
278
+ "sticky left-0 w-[1%] px-docs_1 text-right",
279
+ lineNumberColorClassName,
280
+ lineNumberBgClassName
281
+ )}
282
+ data-testid="line-number"
283
+ >
284
+ {isTerminal ? "❯" : showLineNumber ? lineNumber + 1 : ""}
285
+ </span>
286
+ )}
287
+ <span>
288
+ {transformedLine.map(({ tokens, type, highlight }, index) => {
289
+ const offset =
290
+ index === 0 ? 0 : transformedLine[index - 1].tokens.length
291
+ const tooltipText =
292
+ highlight?.tooltipText ||
293
+ (isHighlightedLine
294
+ ? highlights.find((h) => h.tooltipText !== undefined)?.tooltipText
295
+ : undefined)
296
+ const isHighlighted = type === "highlighted"
297
+ return (
298
+ <React.Fragment key={index}>
299
+ {tooltipText && (
300
+ <Tooltip
301
+ text={tooltipText}
302
+ tooltipClassName="font-base"
303
+ render={({ content }) => (
304
+ <MarkdownContent
305
+ allowedElements={["a", "strong", "code", "br"]}
306
+ unwrapDisallowed={true}
307
+ >
308
+ {content || ""}
309
+ </MarkdownContent>
310
+ )}
311
+ >
312
+ {getTokensElm({
313
+ tokens,
314
+ isTokenHighlighted: isHighlighted,
315
+ offset,
316
+ })}
317
+ </Tooltip>
318
+ )}
319
+ {!tooltipText &&
320
+ getTokensElm({
321
+ tokens,
322
+ isTokenHighlighted: isHighlighted,
323
+ offset,
324
+ })}
325
+ </React.Fragment>
326
+ )
327
+ })}
328
+ </span>
329
+ </span>
330
+ )
331
+ }