@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,174 @@
1
+
2
+ // @refresh reset
3
+
4
+ import React, { useCallback, useEffect, useMemo, useRef } from "react"
5
+ import { Sidebar } from "../../../../types"
6
+ import { Badge } from "../../../../components/Badge"
7
+ import { checkSidebarItemVisibility } from "../../../../utils/check-sidebar-item-visibility"
8
+ import { useSidebar } from "../../../../providers/Sidebar"
9
+ import { SidebarItem } from "../../../../components/Sidebar/Item"
10
+ import clsx from "clsx"
11
+ import { Link } from "react-router-dom"
12
+ import { useMobile } from "../../../../providers/Mobile"
13
+
14
+ export type SidebarItemLinkProps = {
15
+ item: Sidebar.SidebarItemLink
16
+ nested?: boolean
17
+ isParentCategoryOpen?: boolean
18
+ } & React.AllHTMLAttributes<HTMLLIElement>
19
+
20
+ export const SidebarItemLink = ({
21
+ item,
22
+ className,
23
+ nested = false,
24
+ isParentCategoryOpen,
25
+ }: SidebarItemLinkProps) => {
26
+ const {
27
+ isItemActive,
28
+ setMobileSidebarOpen: setSidebarOpen,
29
+ disableActiveTransition,
30
+ sidebarRef,
31
+ sidebarTopHeight,
32
+ } = useSidebar()
33
+ const { isMobile } = useMobile()
34
+ const active = useMemo(
35
+ () =>
36
+ isItemActive({
37
+ item,
38
+ checkLinkChildren: false,
39
+ }),
40
+ [isItemActive, item]
41
+ )
42
+ const ref = useRef<HTMLLIElement>(null)
43
+
44
+ const getNewTopCalculator = useCallback(() => {
45
+ if (!sidebarRef.current || !ref.current) {
46
+ return 0
47
+ }
48
+
49
+ const sidebarBoundingRect = sidebarRef.current.getBoundingClientRect()
50
+ const itemBoundingRect = ref.current.getBoundingClientRect()
51
+
52
+ return (
53
+ itemBoundingRect.top -
54
+ (sidebarBoundingRect.top + sidebarTopHeight) +
55
+ sidebarRef.current.scrollTop -
56
+ 10 // remove extra margin just in case
57
+ )
58
+ }, [sidebarTopHeight, sidebarRef.current, ref.current])
59
+
60
+ useEffect(() => {
61
+ if (
62
+ !active ||
63
+ !ref.current ||
64
+ !sidebarRef.current ||
65
+ isMobile ||
66
+ !isParentCategoryOpen
67
+ ) {
68
+ return
69
+ }
70
+
71
+ const isVisible = checkSidebarItemVisibility(
72
+ (ref.current.children.item(0) as HTMLElement) || ref.current,
73
+ !disableActiveTransition
74
+ )
75
+ if (isVisible) {
76
+ return
77
+ }
78
+ if (!disableActiveTransition) {
79
+ ref.current.scrollIntoView({
80
+ block: "center",
81
+ })
82
+ } else {
83
+ sidebarRef.current.scrollTo({
84
+ top: getNewTopCalculator(),
85
+ })
86
+ }
87
+ }, [
88
+ active,
89
+ sidebarRef.current,
90
+ disableActiveTransition,
91
+ isMobile,
92
+ ref.current,
93
+ getNewTopCalculator,
94
+ isParentCategoryOpen,
95
+ ])
96
+
97
+ useEffect(() => {
98
+ if (active && isMobile) {
99
+ setSidebarOpen(false)
100
+ }
101
+ }, [active, isMobile])
102
+
103
+ const hasChildren = useMemo(() => {
104
+ return !item.hideChildren && (item.children?.length || 0) > 0
105
+ }, [item.children])
106
+
107
+ const isTitleOneWord = useMemo(
108
+ () => item.title.split(" ").length === 1,
109
+ [item.title]
110
+ )
111
+
112
+ return (
113
+ <li ref={ref}>
114
+ <span className="block px-docs_0.75">
115
+ <Link
116
+ to={item.isPathHref ? item.path : `#${item.path}`}
117
+ className={clsx(
118
+ "py-docs_0.25 px-docs_0.5",
119
+ "block w-full rounded-docs_sm",
120
+ !isTitleOneWord && "break-words",
121
+ active && [
122
+ "bg-acmekit-bg-base",
123
+ "shadow-elevation-card-rest dark:shadow-elevation-card-rest-dark",
124
+ "text-acmekit-fg-base",
125
+ ],
126
+ !active && [
127
+ !nested && "text-acmekit-fg-subtle",
128
+ nested && "text-acmekit-fg-muted",
129
+ "hover:bg-acmekit-bg-base-hover lg:hover:bg-acmekit-bg-subtle-hover",
130
+ ],
131
+ "text-compact-small-plus",
132
+ "flex justify-between items-center gap-[6px]",
133
+ className
134
+ )}
135
+ target={item.type === "external" ? "_blank" : undefined}
136
+ rel={item.type === "external" ? "noopener noreferrer" : undefined}
137
+ {...item.linkProps}
138
+ >
139
+ <span
140
+ className={clsx(
141
+ isTitleOneWord && "truncate",
142
+ nested && "inline-block pl-docs_1.5"
143
+ )}
144
+ data-testid="sidebar-item-title"
145
+ >
146
+ {item.title}
147
+ </span>
148
+ {item.additionalElms}
149
+ {item.badge && (
150
+ <Badge variant={item.badge.variant}>{item.badge.text}</Badge>
151
+ )}
152
+ </Link>
153
+ </span>
154
+ {hasChildren && (
155
+ <ul
156
+ className={clsx(
157
+ "ease-ease overflow-hidden",
158
+ "flex flex-col gap-docs_0.125",
159
+ "pt-docs_0.125 pb-docs_0.5"
160
+ )}
161
+ >
162
+ {item.children!.map((childItem, index) => (
163
+ <SidebarItem
164
+ item={childItem}
165
+ key={index}
166
+ nested={!item.childrenSameLevel}
167
+ isParentCategoryOpen={isParentCategoryOpen}
168
+ />
169
+ ))}
170
+ </ul>
171
+ )}
172
+ </li>
173
+ )
174
+ }
@@ -0,0 +1,67 @@
1
+
2
+ // @refresh reset
3
+
4
+ import React, { useMemo } from "react"
5
+ import { Sidebar } from "../../../../types"
6
+ import { Badge } from "../../../../components/Badge"
7
+ import { useSidebar } from "../../../../providers/Sidebar"
8
+ import clsx from "clsx"
9
+ import { Link } from "react-router-dom"
10
+
11
+ export type SidebarItemSidebarProps = {
12
+ item: Sidebar.SidebarItemSidebar
13
+ nested?: boolean
14
+ } & React.AllHTMLAttributes<HTMLLIElement>
15
+
16
+ export const SidebarItemSidebar = ({
17
+ item,
18
+ className,
19
+ nested = false,
20
+ }: SidebarItemSidebarProps) => {
21
+ const { getSidebarFirstLinkChild: getSidebarFirstChild } = useSidebar()
22
+
23
+ const isTitleOneWord = useMemo(
24
+ () => item.title.split(" ").length === 1,
25
+ [item.title]
26
+ )
27
+
28
+ const firstChild = useMemo(() => getSidebarFirstChild(item), [item])
29
+
30
+ return (
31
+ <li>
32
+ <span className="block px-docs_0.75">
33
+ <Link
34
+ to={
35
+ firstChild?.isPathHref ? firstChild.path : `#${firstChild?.path}`
36
+ }
37
+ className={clsx(
38
+ "py-docs_0.25 px-docs_0.5",
39
+ "block w-full rounded-docs_sm",
40
+ !isTitleOneWord && "break-words",
41
+ !nested && "text-acmekit-fg-subtle",
42
+ nested && "text-acmekit-fg-muted",
43
+ "hover:bg-acmekit-bg-base-hover lg:hover:bg-acmekit-bg-subtle-hover",
44
+ "text-compact-small-plus",
45
+ "flex justify-between items-center gap-[6px]",
46
+ className
47
+ )}
48
+ {...firstChild?.linkProps}
49
+ >
50
+ <span
51
+ className={clsx(
52
+ isTitleOneWord && "truncate",
53
+ nested && "inline-block pl-docs_1.5"
54
+ )}
55
+ data-testid="sidebar-item-title"
56
+ >
57
+ {item.title}
58
+ </span>
59
+ {item.additionalElms}
60
+ {item.badge && (
61
+ <Badge variant={item.badge.variant}>{item.badge.text}</Badge>
62
+ )}
63
+ </Link>
64
+ </span>
65
+ </li>
66
+ )
67
+ }
@@ -0,0 +1,83 @@
1
+
2
+ // @refresh reset
3
+
4
+ import React, { useMemo, useRef } from "react"
5
+ import { Sidebar } from "../../../../types"
6
+ import { Badge } from "../../../../components/Badge"
7
+ import { SidebarItem } from "../../../../components/Sidebar/Item"
8
+ import clsx from "clsx"
9
+
10
+ export type SidebarItemSubCategoryProps = {
11
+ item: Sidebar.SidebarItemSubCategory
12
+ nested?: boolean
13
+ isParentCategoryOpen?: boolean
14
+ } & React.AllHTMLAttributes<HTMLLIElement>
15
+
16
+ export const SidebarItemSubCategory = ({
17
+ item,
18
+ className,
19
+ nested = false,
20
+ isParentCategoryOpen,
21
+ }: SidebarItemSubCategoryProps) => {
22
+ const ref = useRef<HTMLLIElement>(null)
23
+
24
+ const hasChildren = useMemo(() => {
25
+ return !item.hideChildren && (item.children?.length || 0) > 0
26
+ }, [item.children])
27
+
28
+ const isTitleOneWord = useMemo(
29
+ () => item.title.split(" ").length === 1,
30
+ [item.title]
31
+ )
32
+
33
+ return (
34
+ <li ref={ref}>
35
+ <span className="block px-docs_0.75">
36
+ <span
37
+ className={clsx(
38
+ "py-docs_0.25 px-docs_0.5",
39
+ "block w-full",
40
+ !isTitleOneWord && "break-words",
41
+ !nested && "text-acmekit-fg-subtle",
42
+ nested && "text-acmekit-fg-muted",
43
+ "text-compact-small-plus",
44
+ className
45
+ )}
46
+ data-testid="sidebar-item-container"
47
+ >
48
+ <span
49
+ className={clsx(
50
+ isTitleOneWord && "truncate",
51
+ nested && "pl-docs_1.5"
52
+ )}
53
+ data-testid="sidebar-item-title"
54
+ >
55
+ {item.title}
56
+ </span>
57
+ {item.additionalElms}
58
+ {item.badge && (
59
+ <Badge variant={item.badge.variant}>{item.badge.text}</Badge>
60
+ )}
61
+ </span>
62
+ </span>
63
+ {hasChildren && (
64
+ <ul
65
+ className={clsx(
66
+ "ease-ease",
67
+ "flex flex-col gap-docs_0.125",
68
+ "pb-docs_0.5 pt-docs_0.125"
69
+ )}
70
+ >
71
+ {item.children!.map((childItem, index) => (
72
+ <SidebarItem
73
+ item={childItem}
74
+ key={index}
75
+ nested={!item.childrenSameLevel}
76
+ isParentCategoryOpen={isParentCategoryOpen}
77
+ />
78
+ ))}
79
+ </ul>
80
+ )}
81
+ </li>
82
+ )
83
+ }
@@ -0,0 +1,41 @@
1
+
2
+ import React from "react"
3
+ import { Sidebar } from "../../../types"
4
+ import { SidebarItemLink } from "./Link"
5
+ import { SidebarItemSubCategory } from "./SubCategory"
6
+ import { DottedSeparator } from "../../../components/DottedSeparator"
7
+ import { SidebarItemCategory } from "./Category"
8
+ import { SidebarItemSidebar } from "./Sidebar"
9
+
10
+ export type SidebarItemProps = {
11
+ item: Sidebar.SidebarItem
12
+ nested?: boolean
13
+ hasNextItems?: boolean
14
+ isParentCategoryOpen?: boolean
15
+ } & React.AllHTMLAttributes<HTMLElement>
16
+
17
+ export const SidebarItem = ({
18
+ item,
19
+ hasNextItems = false,
20
+ ...props
21
+ }: SidebarItemProps) => {
22
+ switch (item.type) {
23
+ case "category":
24
+ return (
25
+ <>
26
+ <SidebarItemCategory item={item} {...props} />
27
+ {hasNextItems && <DottedSeparator />}
28
+ </>
29
+ )
30
+ case "sub-category":
31
+ return <SidebarItemSubCategory item={item} {...props} />
32
+ case "link":
33
+ case "ref":
34
+ case "external":
35
+ return <SidebarItemLink item={item} {...props} />
36
+ case "sidebar":
37
+ return <SidebarItemSidebar item={item} {...props} />
38
+ case "separator":
39
+ return <DottedSeparator />
40
+ }
41
+ }
@@ -0,0 +1,21 @@
1
+
2
+ import React from "react"
3
+ import { useSidebar } from "../../../../providers/Sidebar"
4
+ import { Button } from "../../../../components/Button"
5
+ import { XMarkMini } from "@acmekit/icons"
6
+
7
+ export const SidebarTopMobileClose = () => {
8
+ const { setMobileSidebarOpen } = useSidebar()
9
+
10
+ return (
11
+ <div className="m-docs_0.75 lg:hidden">
12
+ <Button
13
+ variant="transparent-clear"
14
+ onClick={() => setMobileSidebarOpen(false)}
15
+ className="!p-0 hover:!bg-transparent"
16
+ >
17
+ <XMarkMini className="text-acmekit-fg-subtle" />
18
+ </Button>
19
+ </div>
20
+ )
21
+ }
@@ -0,0 +1,33 @@
1
+
2
+ import React from "react"
3
+ import { SidebarChild } from "../Child"
4
+ import { SidebarTopMobileClose } from "./MobileClose"
5
+ import { useSidebar } from "../../../providers/Sidebar"
6
+ import { DottedSeparator } from "../../../components/DottedSeparator"
7
+ import clsx from "clsx"
8
+
9
+ export const SidebarTop = React.forwardRef<HTMLDivElement>(
10
+ function SidebarTop(props, ref) {
11
+ const { sidebarHistory } = useSidebar()
12
+
13
+ return (
14
+ <div
15
+ className={clsx(
16
+ "pt-docs_0.25 sticky top-0 z-[5]",
17
+ "bg-acmekit-bg-base lg:bg-acmekit-bg-subtle"
18
+ )}
19
+ ref={ref}
20
+ >
21
+ <SidebarTopMobileClose />
22
+ <div>
23
+ {sidebarHistory.length > 1 && (
24
+ <>
25
+ <SidebarChild />
26
+ <DottedSeparator wrapperClassName="!my-0" />
27
+ </>
28
+ )}
29
+ </div>
30
+ </div>
31
+ )
32
+ }
33
+ )
@@ -0,0 +1,153 @@
1
+
2
+ import React, { Suspense, useMemo, useRef } from "react"
3
+ import { useSidebar } from "../../providers/Sidebar"
4
+ import clsx from "clsx"
5
+ import { Loading } from "../../components/Loading"
6
+ import { SidebarItem } from "./Item"
7
+ // @ts-expect-error can't install the types package because it doesn't support React v19
8
+ import { CSSTransition, SwitchTransition } from "react-transition-group"
9
+ import { SidebarTop } from "./Top"
10
+ import { useClickOutside } from "../../hooks/use-click-outside"
11
+ import { useKeyboardShortcut } from "../../hooks/use-keyboard-shortcut"
12
+ import { useResizeObserver } from "../../hooks/use-resize-observer"
13
+ import { isSidebarItemLink } from "../../utils/sidebar-utils"
14
+
15
+ export type SidebarProps = {
16
+ className?: string
17
+ }
18
+
19
+ export const Sidebar = ({ className = "" }: SidebarProps) => {
20
+ const sidebarWrapperRef = useRef(null)
21
+ const sidebarTopRef = useRef<HTMLDivElement>(null)
22
+ const {
23
+ sidebars,
24
+ shownSidebar,
25
+ mobileSidebarOpen,
26
+ setMobileSidebarOpen,
27
+ isSidebarStatic,
28
+ sidebarRef,
29
+ desktopSidebarOpen,
30
+ setDesktopSidebarOpen,
31
+ setSidebarTopHeight,
32
+ sidebarHistory,
33
+ } = useSidebar()
34
+ useClickOutside({
35
+ elmRef: sidebarWrapperRef,
36
+ onClickOutside: () => {
37
+ if (mobileSidebarOpen) {
38
+ setMobileSidebarOpen(false)
39
+ }
40
+ },
41
+ })
42
+ useKeyboardShortcut({
43
+ metakey: true,
44
+ shortcutKeys: ["\\"],
45
+ action: () => {
46
+ setDesktopSidebarOpen((prev) => !prev)
47
+ },
48
+ })
49
+
50
+ useResizeObserver(sidebarTopRef as React.RefObject<HTMLElement>, () => {
51
+ setSidebarTopHeight(sidebarTopRef.current?.clientHeight || 0)
52
+ })
53
+
54
+ const sidebarItems = useMemo(() => {
55
+ return shownSidebar && "items" in shownSidebar
56
+ ? shownSidebar.items
57
+ : shownSidebar?.children || []
58
+ }, [shownSidebar])
59
+
60
+ return (
61
+ <>
62
+ {mobileSidebarOpen && (
63
+ <div
64
+ className={clsx(
65
+ "lg:hidden bg-acmekit-bg-overlay opacity-70",
66
+ "fixed top-0 left-0 w-full h-full z-[45]"
67
+ )}
68
+ data-testid="mobile-sidebar-overlay"
69
+ ></div>
70
+ )}
71
+ <aside
72
+ className={clsx(
73
+ "bg-acmekit-bg-base lg:bg-transparent block",
74
+ "fixed -left-full top-0 h-[calc(100%-16px)] transition-[left] lg:relative lg:h-auto",
75
+ "max-w-sidebar-xs sm:max-w-sidebar-sm md:max-w-sidebar-md lg:max-w-sidebar-lg",
76
+ "xl:max-w-sidebar-xl xxl:max-w-sidebar-xxl xxxl:max-w-sidebar-xxxl",
77
+ "w-sidebar-xs sm:w-auto",
78
+ mobileSidebarOpen && [
79
+ "!left-docs_0.5 !top-docs_0.5 z-50 shadow-elevation-modal dark:shadow-elevation-modal-dark",
80
+ "rounded",
81
+ "lg:!left-0 lg:!top-0 lg:shadow-none",
82
+ ],
83
+ desktopSidebarOpen && "lg:left-0",
84
+ !desktopSidebarOpen && "lg:!absolute lg:!-left-full",
85
+ className
86
+ )}
87
+ style={{
88
+ animationFillMode: "forwards",
89
+ }}
90
+ ref={sidebarWrapperRef}
91
+ >
92
+ <ul className={clsx("h-full w-full", "flex flex-col")}>
93
+ <SwitchTransition>
94
+ <CSSTransition
95
+ key={
96
+ sidebarHistory.length
97
+ ? sidebarHistory[sidebarHistory.length - 1]
98
+ : sidebars[0].sidebar_id
99
+ }
100
+ nodeRef={sidebarRef}
101
+ classNames={{
102
+ enter: "animate-fadeInLeft animate-fast",
103
+ exit: "animate-fadeOutLeft animate-fast",
104
+ }}
105
+ timeout={200}
106
+ >
107
+ <div
108
+ className={clsx(
109
+ "overflow-y-scroll clip",
110
+ "pb-docs_0.75 flex-1 max-h-screen"
111
+ )}
112
+ ref={sidebarRef as React.RefObject<HTMLDivElement>}
113
+ id="sidebar"
114
+ >
115
+ <SidebarTop ref={sidebarTopRef} />
116
+ <div className="pt-docs_0.75">
117
+ {!sidebarItems.length && !isSidebarStatic && (
118
+ <Loading className="px-docs_0.75" />
119
+ )}
120
+ {sidebarItems.map((item, index) => {
121
+ const itemKey =
122
+ item.type === "separator"
123
+ ? index
124
+ : isSidebarItemLink(item)
125
+ ? `${item.path}-${index}`
126
+ : `${item.title}-${index}`
127
+ return (
128
+ <Suspense
129
+ fallback={
130
+ <Loading
131
+ count={1}
132
+ className="!mb-0 !px-docs_0.5"
133
+ barClassName="h-[20px]"
134
+ />
135
+ }
136
+ key={itemKey}
137
+ >
138
+ <SidebarItem
139
+ item={item}
140
+ hasNextItems={index !== sidebarItems.length - 1}
141
+ />
142
+ </Suspense>
143
+ )
144
+ })}
145
+ </div>
146
+ </div>
147
+ </CSSTransition>
148
+ </SwitchTransition>
149
+ </ul>
150
+ </aside>
151
+ </>
152
+ )
153
+ }
@@ -0,0 +1,37 @@
1
+ import React from "react"
2
+ import { Link } from "../Link"
3
+ import { Badge } from "../Badge"
4
+ import clsx from "clsx"
5
+ import { GithubIcon } from "../Icons/Github"
6
+
7
+ type SourceCodeLinkProps = {
8
+ link: string
9
+ text?: string
10
+ icon?: React.ReactNode
11
+ className?: string
12
+ }
13
+
14
+ export const SourceCodeLink = ({
15
+ link,
16
+ text,
17
+ icon,
18
+ className,
19
+ }: SourceCodeLinkProps) => {
20
+ return (
21
+ <Link
22
+ href={link}
23
+ target="_blank"
24
+ rel="noreferrer"
25
+ className={clsx("my-docs_0.5 align-middle inline-block", className)}
26
+ >
27
+ <Badge
28
+ variant="neutral"
29
+ className="inline-flex hover:bg-acmekit-tag-neutral-bg-hover cursor-pointer"
30
+ childrenWrapperClassName="inline-flex flex-row gap-[3px] items-center"
31
+ >
32
+ {icon || <GithubIcon />}
33
+ <span>{text || "Source Code"}</span>
34
+ </Badge>
35
+ </Link>
36
+ )
37
+ }
@@ -0,0 +1,58 @@
1
+ import React, { useMemo } from "react"
2
+ import { Link } from "../Link"
3
+
4
+ type SplitListItem = {
5
+ title: string
6
+ link: string
7
+ description?: string
8
+ }
9
+
10
+ export type SplitListProps = {
11
+ items: SplitListItem[]
12
+ listsNum?: number
13
+ }
14
+
15
+ export const SplitList = ({ items, listsNum = 2 }: SplitListProps) => {
16
+ const lists = useMemo(() => {
17
+ const lists: SplitListItem[][] = new Array(listsNum).fill(0).map(() => [])
18
+ // Split the items into listsNum lists
19
+ // by pushing each item into the list at index i % listsNum
20
+ // where i is the index of the item in the items array
21
+ // This will create a round-robin distribution of the items
22
+ // across the lists
23
+ // For example, if items = [1, 2, 3, 4, 5] and listsNum = 2
24
+ // the result will be [[1, 3, 5], [2, 4]]
25
+ items.forEach((item, index) => {
26
+ lists[index % listsNum].push(item)
27
+ })
28
+ return lists
29
+ }, [items, listsNum])
30
+
31
+ return (
32
+ <div
33
+ className="flex flex-col md:flex-row gap-docs_0.5 w-full"
34
+ data-testid="split-list-container"
35
+ >
36
+ {lists.map((list, index) => (
37
+ <ul key={index} className="flex-1">
38
+ {list.map((item) => (
39
+ <li key={item.link} className="mb-docs_0.5">
40
+ <Link href={item.link}>{item.title}</Link>
41
+ {item.description && (
42
+ <>
43
+ :{" "}
44
+ <p
45
+ className="text-docs_3"
46
+ data-testid="split-list-description"
47
+ >
48
+ {item.description}
49
+ </p>
50
+ </>
51
+ )}
52
+ </li>
53
+ ))}
54
+ </ul>
55
+ ))}
56
+ </div>
57
+ )
58
+ }