@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,44 @@
1
+ import clsx from "clsx"
2
+ import React from "react"
3
+ import { MenuItem as MenuItemType } from "../../types"
4
+ import { MenuItem } from "./Item"
5
+ import { MenuDivider } from "./Divider"
6
+ import { MenuAction } from "./Action"
7
+ import { MenuSubMenu } from "./SubMenu"
8
+
9
+ export type MenuProps = {
10
+ items: MenuItemType[]
11
+ className?: string
12
+ itemsOnClick?: (item: MenuItemType) => void
13
+ }
14
+
15
+ export const Menu = ({ items, className, itemsOnClick }: MenuProps) => {
16
+ return (
17
+ <div
18
+ className={clsx(
19
+ "bg-acmekit-bg-component py-docs_0.25 rounded-docs_DEFAULT",
20
+ "shadow-elevation-flyout dark:shadow-elevation-flyout-dark",
21
+ className
22
+ )}
23
+ data-testid="menu"
24
+ >
25
+ {items.map((item, index) => (
26
+ <React.Fragment key={index}>
27
+ {item.type === "link" && (
28
+ <MenuItem item={item} onClick={itemsOnClick} />
29
+ )}
30
+ {item.type === "action" && (
31
+ <MenuAction item={item} onClick={itemsOnClick} />
32
+ )}
33
+ {item.type === "divider" && <MenuDivider />}
34
+ {item.type === "custom" && item.content}
35
+ {item.type === "sub-menu" && (
36
+ <MenuSubMenu item={item} itemsOnClick={itemsOnClick} />
37
+ )}
38
+ </React.Fragment>
39
+ ))}
40
+ </div>
41
+ )
42
+ }
43
+
44
+ export * from "./Dropdown"
@@ -0,0 +1,29 @@
1
+ import React from "react"
2
+ import clsx from "clsx"
3
+ import { Button, ButtonProps } from "../../../components/Button"
4
+
5
+ export type ModalFooterProps = {
6
+ actions?: ButtonProps[]
7
+ children?: React.ReactNode
8
+ className?: string
9
+ }
10
+
11
+ export const ModalFooter = ({
12
+ actions,
13
+ children,
14
+ className,
15
+ }: ModalFooterProps) => {
16
+ return (
17
+ <div
18
+ className={clsx(
19
+ "py-docs_1.5 pl-0 pr-docs_2",
20
+ "border-acmekit-border-base border-0 border-t border-solid",
21
+ "flex justify-end gap-docs_0.5",
22
+ className
23
+ )}
24
+ >
25
+ {actions?.map((action, index) => <Button {...action} key={index} />)}
26
+ {children}
27
+ </div>
28
+ )
29
+ }
@@ -0,0 +1,33 @@
1
+ import React from "react"
2
+ import clsx from "clsx"
3
+ import { useModal } from "../../../providers/Modal"
4
+ import { Button } from "../../../components/Button"
5
+ import { XMark } from "@acmekit/icons"
6
+
7
+ export type ModalHeaderProps = {
8
+ title?: React.ReactNode
9
+ }
10
+
11
+ export const ModalHeader = ({ title }: ModalHeaderProps) => {
12
+ const { closeModal } = useModal()
13
+
14
+ return (
15
+ <div
16
+ className={clsx(
17
+ "border-acmekit-border-base border-0 border-b border-solid py-docs_1.5 px-docs_2",
18
+ "flex items-center justify-between"
19
+ )}
20
+ >
21
+ <span className={clsx("text-acmekit-fg-base text-h2")} data-testid="title">
22
+ {title}
23
+ </span>
24
+ <Button
25
+ variant="transparent"
26
+ className="cursor-pointer"
27
+ onClick={() => closeModal()}
28
+ >
29
+ <XMark />
30
+ </Button>
31
+ </div>
32
+ )
33
+ }
@@ -0,0 +1,124 @@
1
+
2
+ import clsx from "clsx"
3
+ import React, { useCallback, useEffect, useRef } from "react"
4
+ import { useModal } from "../../providers/Modal"
5
+ import { ModalHeader } from "./Header"
6
+ import { ModalFooter } from "./Footer"
7
+ import { useKeyboardShortcut } from "../../hooks/use-keyboard-shortcut"
8
+ import { ButtonProps } from "../../components/Button"
9
+ import { Ref } from "../../types"
10
+
11
+ export type ModalProps = {
12
+ className?: string
13
+ title?: React.ReactNode
14
+ actions?: ButtonProps[]
15
+ modalContainerClassName?: string
16
+ contentClassName?: string
17
+ onClose?: React.ReactEventHandler<HTMLDialogElement>
18
+ open?: boolean
19
+ footerContent?: React.ReactNode
20
+ passedRef?: Ref<HTMLDialogElement>
21
+ headerClassName?: string
22
+ } & Omit<React.ComponentProps<"dialog">, "ref" | "title" | "key">
23
+
24
+ export const Modal = ({
25
+ className,
26
+ title,
27
+ actions,
28
+ children,
29
+ contentClassName,
30
+ modalContainerClassName,
31
+ onClose,
32
+ open = true,
33
+ footerContent,
34
+ passedRef,
35
+ ...props
36
+ }: ModalProps) => {
37
+ const { closeModal } = useModal()
38
+ const ref = useRef<HTMLDialogElement | null>(null)
39
+
40
+ const setRefs = useCallback(
41
+ (node: HTMLDialogElement) => {
42
+ // Ref's from useRef needs to have the node assigned to `current`
43
+ ref.current = node
44
+ if (typeof passedRef === "function") {
45
+ passedRef(node)
46
+ } else if (passedRef && "current" in passedRef) {
47
+ ;(passedRef as React.MutableRefObject<HTMLDialogElement | null>).current = node
48
+ }
49
+ },
50
+ [passedRef]
51
+ )
52
+
53
+ useKeyboardShortcut({
54
+ metakey: false,
55
+ checkEditing: false,
56
+ shortcutKeys: ["escape"],
57
+ action: () => {
58
+ if (open) {
59
+ ref.current?.close()
60
+ }
61
+ },
62
+ })
63
+
64
+ const handleClick = (e: React.MouseEvent<HTMLDialogElement, MouseEvent>) => {
65
+ // close modal when the user clicks outside the content
66
+ if (e.target === ref.current) {
67
+ closeModal()
68
+ onClose?.(e)
69
+ }
70
+ }
71
+
72
+ const handleClose = (e: React.SyntheticEvent<HTMLDialogElement, Event>) => {
73
+ onClose?.(e)
74
+ closeModal()
75
+ }
76
+
77
+ useEffect(() => {
78
+ if (open) {
79
+ document.body.setAttribute("data-modal", "opened")
80
+ } else {
81
+ document.body.removeAttribute("data-modal")
82
+ }
83
+ }, [open])
84
+
85
+ return (
86
+ <dialog
87
+ {...props}
88
+ className={clsx(
89
+ "fixed top-0 left-0 flex h-screen w-screen items-center justify-center",
90
+ "bg-acmekit-bg-overlay z-50",
91
+ "hidden open:flex border-0 px-docs_0.5 lg:p-0",
92
+ className
93
+ )}
94
+ onClick={handleClick}
95
+ ref={setRefs}
96
+ onClose={handleClose}
97
+ open={open}
98
+ >
99
+ <div
100
+ className={clsx(
101
+ "bg-acmekit-bg-base rounded-docs_lg",
102
+ "shadow-elevation-modal dark:shadow-elevation-modal-dark",
103
+ "max-w-full sm:max-w-modal-sm md:max-w-modal-md lg:max-w-modal-lg",
104
+ "h-auto w-full",
105
+ modalContainerClassName
106
+ )}
107
+ data-testid="modal-container"
108
+ >
109
+ {title && <ModalHeader title={title} />}
110
+ <div
111
+ className={clsx(
112
+ "overflow-auto py-docs_1.5 px-docs_2 rounded-docs_lg",
113
+ contentClassName
114
+ )}
115
+ data-testid="modal-content"
116
+ >
117
+ {children}
118
+ </div>
119
+ {actions && actions?.length > 0 && <ModalFooter actions={actions} />}
120
+ {footerContent && <ModalFooter>{footerContent}</ModalFooter>}
121
+ </div>
122
+ </dialog>
123
+ )
124
+ }
@@ -0,0 +1,139 @@
1
+ import React, { useMemo } from "react"
2
+ import { NoteProps } from ".."
3
+ import clsx from "clsx"
4
+ import { MarkdownContent } from "../../MarkdownContent"
5
+
6
+ type StringInfo = {
7
+ allStringChildren: boolean
8
+ stringChildren: string[]
9
+ }
10
+
11
+ type NoteLayoutProps = NoteProps
12
+
13
+ const PUNCTIONATIONS = [".", ":", ";", ",", "!", "?"]
14
+
15
+ export const NoteLayout = ({
16
+ type,
17
+ title,
18
+ children,
19
+ forceMultiline = false,
20
+ }: NoteLayoutProps) => {
21
+ const getStringInfoFromChildren = (nodes: React.ReactNode): StringInfo => {
22
+ let allStringChildren = true
23
+ const stringChildren: string[] = []
24
+
25
+ React.Children.forEach(nodes, (child) => {
26
+ if (!allStringChildren) {
27
+ return
28
+ } else if (["string", "number"].includes(typeof child)) {
29
+ stringChildren.push(`${child}`)
30
+ } else if (Array.isArray(child)) {
31
+ const childInfo = getStringInfoFromChildren(child)
32
+ allStringChildren = childInfo.allStringChildren
33
+ stringChildren.push(...childInfo.stringChildren)
34
+ } else if (
35
+ React.isValidElement(child) &&
36
+ typeof child.props === "object" &&
37
+ child.props &&
38
+ "children" in child.props &&
39
+ child.props.children
40
+ ) {
41
+ const typeStr = child.type.toString()
42
+ if (
43
+ typeStr.includes("InlineCode") &&
44
+ typeof child.props.children === "string"
45
+ ) {
46
+ stringChildren.push(`\`${child.props.children}\``)
47
+ return
48
+ } else if (typeStr.includes(`li`)) {
49
+ allStringChildren = false
50
+ return
51
+ } else if (
52
+ "href" in child.props &&
53
+ typeof child.props.children === "string"
54
+ ) {
55
+ stringChildren.push(`[${child.props.children}](${child.props.href})`)
56
+ return
57
+ }
58
+
59
+ const childInfo = getStringInfoFromChildren(
60
+ child.props.children as React.ReactNode
61
+ )
62
+ allStringChildren = childInfo.allStringChildren
63
+ stringChildren.push(...childInfo.stringChildren)
64
+ }
65
+ })
66
+
67
+ return {
68
+ allStringChildren,
69
+ stringChildren,
70
+ }
71
+ }
72
+ const { allStringChildren, stringChildren } = useMemo(() => {
73
+ if (forceMultiline) {
74
+ return {
75
+ allStringChildren: false,
76
+ stringChildren: "",
77
+ }
78
+ }
79
+
80
+ const { allStringChildren, stringChildren } =
81
+ getStringInfoFromChildren(children)
82
+
83
+ return {
84
+ allStringChildren,
85
+ stringChildren: stringChildren.join(""),
86
+ }
87
+ }, [children, forceMultiline])
88
+
89
+ const showColon = useMemo(() => {
90
+ const lastChar = title?.charAt(title.length - 1) || ""
91
+
92
+ return !PUNCTIONATIONS.includes(lastChar)
93
+ }, [title])
94
+
95
+ return (
96
+ <div
97
+ className={clsx(
98
+ "py-[10px] px-docs_0.75 my-docs_1",
99
+ "flex gap-docs_0.75 rounded-docs_DEFAULT items-stretch",
100
+ "bg-acmekit-bg-component border border-acmekit-border-base"
101
+ )}
102
+ data-testid="note-layout"
103
+ >
104
+ <span
105
+ className={clsx(
106
+ "rounded-full w-docs_0.25",
107
+ // TODO remove once we use the new prerequisites component across docs
108
+ (type === "default" || type === "check") &&
109
+ "bg-acmekit-tag-neutral-icon",
110
+ (type === "error" || type === "warning") && "bg-acmekit-tag-red-icon",
111
+ type === "success" && "bg-acmekit-tag-green-icon",
112
+ // TODO remove once all soon components are removed
113
+ type === "soon" && "bg-acmekit-tag-blue-icon"
114
+ )}
115
+ data-testid="note-layout-indicator"
116
+ ></span>
117
+ <div className="flex-1">
118
+ <div className="text-small text-acmekit-fg-subtle [&_ol]:!mb-0 [&_ul]:!mb-0">
119
+ <span
120
+ className={clsx("text-small-plus text-acmekit-fg-base")}
121
+ data-testid="note-layout-title"
122
+ >
123
+ {title}
124
+ {showColon ? ":" : ""}&nbsp;
125
+ </span>
126
+ {allStringChildren && (
127
+ <MarkdownContent
128
+ allowedElements={["a", "code"]}
129
+ unwrapDisallowed={true}
130
+ >
131
+ {stringChildren}
132
+ </MarkdownContent>
133
+ )}
134
+ {!allStringChildren && children}
135
+ </div>
136
+ </div>
137
+ </div>
138
+ )
139
+ }
@@ -0,0 +1,7 @@
1
+ import React from "react"
2
+ import { NoteProps } from ".."
3
+ import { NoteLayout } from "../Layout"
4
+
5
+ export const CheckNote = ({ title = "Prerequisites", ...props }: NoteProps) => {
6
+ return <NoteLayout title={title} {...props} />
7
+ }
@@ -0,0 +1,7 @@
1
+ import React from "react"
2
+ import { NoteProps } from ".."
3
+ import { NoteLayout } from "../Layout"
4
+
5
+ export const DefaultNote = ({ title = "Note", ...props }: NoteProps) => {
6
+ return <NoteLayout title={title} {...props} />
7
+ }
@@ -0,0 +1,7 @@
1
+ import React from "react"
2
+ import { NoteProps } from ".."
3
+ import { NoteLayout } from "../Layout"
4
+
5
+ export const ErrorNote = ({ title = "Error", ...props }: NoteProps) => {
6
+ return <NoteLayout title={title} {...props} />
7
+ }
@@ -0,0 +1,7 @@
1
+ import React from "react"
2
+ import { NoteProps } from ".."
3
+ import { NoteLayout } from "../Layout"
4
+
5
+ export const SoonNote = ({ title = "Coming soon", ...props }: NoteProps) => {
6
+ return <NoteLayout title={title} {...props} />
7
+ }
@@ -0,0 +1,7 @@
1
+ import React from "react"
2
+ import { NoteProps } from ".."
3
+ import { NoteLayout } from "../Layout"
4
+
5
+ export const SuccessNote = ({ title = "Sucess", ...props }: NoteProps) => {
6
+ return <NoteLayout title={title} {...props} />
7
+ }
@@ -0,0 +1,7 @@
1
+ import React from "react"
2
+ import { NoteProps } from ".."
3
+ import { NoteLayout } from "../Layout"
4
+
5
+ export const WarningNote = ({ title = "Warning", ...props }: NoteProps) => {
6
+ return <NoteLayout title={title} {...props} />
7
+ }
@@ -0,0 +1,32 @@
1
+ import React from "react"
2
+ import { WarningNote } from "./Types/warning"
3
+ import { DefaultNote } from "./Types/default"
4
+ import { SuccessNote } from "./Types/sucess"
5
+ import { ErrorNote } from "./Types/error"
6
+ import { CheckNote } from "./Types/checks"
7
+ import { SoonNote } from "./Types/soon"
8
+
9
+ export type NoteProps = {
10
+ type?: "default" | "warning" | "success" | "error" | "check" | "soon"
11
+ title?: string
12
+ children?: React.ReactNode
13
+ forceMultiline?: boolean
14
+ }
15
+
16
+ export const Note = ({ type = "default", ...props }: NoteProps) => {
17
+ switch (type) {
18
+ case "warning":
19
+ return <WarningNote type={type} {...props} />
20
+ case "success":
21
+ return <SuccessNote type={type} {...props} />
22
+ case "error":
23
+ return <ErrorNote type={type} {...props} />
24
+ // TODO remove both once we've removed all notes using them
25
+ case "check":
26
+ return <CheckNote type={type} {...props} />
27
+ case "soon":
28
+ return <SoonNote type={type} {...props} />
29
+ default:
30
+ return <DefaultNote type={type} {...props} />
31
+ }
32
+ }
@@ -0,0 +1,33 @@
1
+ import React from "react"
2
+ import { Badge } from "../../../components/Badge"
3
+ import { Tooltip } from "../../../components/Tooltip"
4
+
5
+ export type DeprecatedNoticeProps = {
6
+ description?: string
7
+ tooltipTextClassName?: string
8
+ badgeClassName?: string
9
+ badgeContent?: React.ReactNode
10
+ }
11
+
12
+ export const DeprecatedNotice = ({
13
+ description,
14
+ tooltipTextClassName,
15
+ badgeClassName,
16
+ badgeContent = `Deprecated`,
17
+ }: DeprecatedNoticeProps) => {
18
+ return (
19
+ <Tooltip
20
+ tooltipChildren={
21
+ <span className={tooltipTextClassName}>
22
+ {description ||
23
+ "This feature is deprecated and may be removed in future releases."}
24
+ </span>
25
+ }
26
+ clickable
27
+ >
28
+ <Badge variant="neutral" className={badgeClassName}>
29
+ {badgeContent}
30
+ </Badge>
31
+ </Tooltip>
32
+ )
33
+ }
@@ -0,0 +1,36 @@
1
+ import React from "react"
2
+ import { Badge } from "../../../components/Badge"
3
+ import { Link } from "../../../components/Link"
4
+ import { Tooltip } from "../../../components/Tooltip"
5
+
6
+ export type ExpandableNoticeProps = {
7
+ type?: "request" | "method" | "workflow"
8
+ link: string
9
+ badgeContent?: React.ReactNode
10
+ badgeClassName?: string
11
+ }
12
+
13
+ export const ExpandableNotice = ({
14
+ type = "request",
15
+ link,
16
+ badgeContent = "expandable",
17
+ badgeClassName,
18
+ }: ExpandableNoticeProps) => {
19
+ return (
20
+ <Tooltip
21
+ tooltipChildren={
22
+ <>
23
+ If this {type} accepts an <code>expand</code>{" "}
24
+ {type === "request" ? "parameter" : "parameter or property"},
25
+ <br /> this relation can be <Link href={link}>expanded</Link> into an
26
+ object.
27
+ </>
28
+ }
29
+ clickable
30
+ >
31
+ <Badge variant="blue" className={badgeClassName}>
32
+ {badgeContent}
33
+ </Badge>
34
+ </Tooltip>
35
+ )
36
+ }
@@ -0,0 +1,36 @@
1
+ import React from "react"
2
+ import { Badge } from "../../../components/Badge"
3
+ import { Tooltip } from "../../../components/Tooltip"
4
+
5
+ export type FeatureFlagNoticeProps = {
6
+ featureFlag: string
7
+ type?: "endpoint" | "type"
8
+ tooltipTextClassName?: string
9
+ badgeClassName?: string
10
+ badgeContent?: React.ReactNode
11
+ }
12
+
13
+ export const FeatureFlagNotice = ({
14
+ featureFlag,
15
+ type = "endpoint",
16
+ tooltipTextClassName,
17
+ badgeClassName,
18
+ badgeContent = "feature flag",
19
+ }: FeatureFlagNoticeProps) => {
20
+ return (
21
+ <Tooltip
22
+ tooltipChildren={
23
+ <span className={tooltipTextClassName}>
24
+ To use this {type}, make sure to <br />
25
+ {/* TODO add doc link once available */}
26
+ enable its feature flag: <code>{featureFlag}</code>
27
+ </span>
28
+ }
29
+ clickable
30
+ >
31
+ <Badge variant="green" className={badgeClassName}>
32
+ {badgeContent}
33
+ </Badge>
34
+ </Tooltip>
35
+ )
36
+ }
@@ -0,0 +1,37 @@
1
+ import React from "react"
2
+ import { Badge } from "../../../components/Badge"
3
+ import { Tooltip } from "../../../components/Tooltip"
4
+
5
+ export type VersionNoticeProps = {
6
+ version: string
7
+ tooltipTextClassName?: string
8
+ badgeClassName?: string
9
+ badgeContent?: React.ReactNode
10
+ }
11
+
12
+ export const VersionNotice = ({
13
+ version,
14
+ tooltipTextClassName,
15
+ badgeClassName,
16
+ badgeContent = `v${version}`,
17
+ }: VersionNoticeProps) => {
18
+ return (
19
+ <Tooltip
20
+ tooltipChildren={
21
+ <span className={tooltipTextClassName}>
22
+ This is available starting from <br />
23
+ <a
24
+ href={`https://github.com/acmekit/acmekit/releases/tag/${version}`}
25
+ >
26
+ AcmeKit v{version}
27
+ </a>
28
+ </span>
29
+ }
30
+ clickable
31
+ >
32
+ <Badge variant="blue" className={badgeClassName}>
33
+ {badgeContent}
34
+ </Badge>
35
+ </Tooltip>
36
+ )
37
+ }