@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.
- package/dist/Items-YPPZD6C6.mjs +312 -0
- package/dist/chunk-JD7BP7O5.mjs +13144 -0
- package/dist/index.d.mts +1550 -0
- package/dist/index.d.ts +1550 -0
- package/dist/index.js +15218 -0
- package/dist/index.mjs +366 -0
- package/package.json +58 -0
- package/src/components/Badge/index.tsx +74 -0
- package/src/components/BadgesList/index.tsx +18 -0
- package/src/components/BetaBadge/index.tsx +24 -0
- package/src/components/Bordered/index.tsx +21 -0
- package/src/components/BorderedIcon/index.tsx +60 -0
- package/src/components/Breadcrumbs/index.tsx +83 -0
- package/src/components/Button/index.tsx +100 -0
- package/src/components/Card/Layout/Default/index.tsx +124 -0
- package/src/components/Card/Layout/Filler/index.tsx +30 -0
- package/src/components/Card/Layout/Large/index.tsx +88 -0
- package/src/components/Card/Layout/Mini/index.tsx +142 -0
- package/src/components/Card/index.tsx +50 -0
- package/src/components/CardList/index.tsx +40 -0
- package/src/components/ChildDocs/index.tsx +9 -0
- package/src/components/CodeBlock/Actions/AskAi/index.tsx +10 -0
- package/src/components/CodeBlock/Actions/Copy/index.tsx +59 -0
- package/src/components/CodeBlock/Actions/index.tsx +137 -0
- package/src/components/CodeBlock/Collapsible/Button/index.tsx +58 -0
- package/src/components/CodeBlock/Collapsible/Fade/index.tsx +55 -0
- package/src/components/CodeBlock/Collapsible/Lines/index.tsx +22 -0
- package/src/components/CodeBlock/Header/Wrapper/index.tsx +46 -0
- package/src/components/CodeBlock/Header/index.tsx +67 -0
- package/src/components/CodeBlock/Inline/index.tsx +20 -0
- package/src/components/CodeBlock/Line/index.tsx +331 -0
- package/src/components/CodeBlock/index.tsx +510 -0
- package/src/components/CodeMdx/index.tsx +45 -0
- package/src/components/CodeTabs/Item/index.tsx +67 -0
- package/src/components/CodeTabs/index.tsx +319 -0
- package/src/components/ContentMenu/Actions/index.tsx +7 -0
- package/src/components/ContentMenu/Products/index.tsx +64 -0
- package/src/components/ContentMenu/Toc/index.tsx +148 -0
- package/src/components/ContentMenu/Version/index.tsx +77 -0
- package/src/components/ContentMenu/index.tsx +31 -0
- package/src/components/CopyButton/index.tsx +76 -0
- package/src/components/Details/Summary/index.tsx +75 -0
- package/src/components/Details/index.tsx +98 -0
- package/src/components/DetailsList/index.tsx +32 -0
- package/src/components/DottedSeparator/index.tsx +30 -0
- package/src/components/EditButton/index.tsx +32 -0
- package/src/components/EditDate/index.tsx +33 -0
- package/src/components/ErrorPage/Icon/index.tsx +428 -0
- package/src/components/ErrorPage/index.tsx +32 -0
- package/src/components/Feedback/Solutions/index.tsx +105 -0
- package/src/components/Feedback/index.tsx +304 -0
- package/src/components/Footer/index.tsx +23 -0
- package/src/components/Heading/H1/index.tsx +21 -0
- package/src/components/Heading/H2/index.tsx +47 -0
- package/src/components/Heading/H3/index.tsx +42 -0
- package/src/components/Heading/H4/index.tsx +14 -0
- package/src/components/Heading/index.tsx +4 -0
- package/src/components/IconHeadline/index.tsx +15 -0
- package/src/components/Icons/AiAssistant/index.tsx +462 -0
- package/src/components/Icons/ArrowRightDown/index.tsx +30 -0
- package/src/components/Icons/BundledProduct/index.tsx +72 -0
- package/src/components/Icons/CalendarRefresh/index.tsx +70 -0
- package/src/components/Icons/ChefHat/index.tsx +65 -0
- package/src/components/Icons/CircleDottedLine/index.tsx +60 -0
- package/src/components/Icons/CloudSolid/index.tsx +47 -0
- package/src/components/Icons/ColoredAcmeKit/index.tsx +13 -0
- package/src/components/Icons/DecisionProcess/index.tsx +58 -0
- package/src/components/Icons/Erp/index.tsx +92 -0
- package/src/components/Icons/Github/index.tsx +22 -0
- package/src/components/Icons/House/index.tsx +23 -0
- package/src/components/Icons/ImageBinary/index.tsx +69 -0
- package/src/components/Icons/Kapa/index.tsx +22 -0
- package/src/components/Icons/Markdown/index.tsx +25 -0
- package/src/components/Icons/NavigationDropdown/Admin/index.tsx +33 -0
- package/src/components/Icons/NavigationDropdown/Doc/index.tsx +41 -0
- package/src/components/Icons/NavigationDropdown/DocV1/index.tsx +37 -0
- package/src/components/Icons/NavigationDropdown/Modules/index.tsx +33 -0
- package/src/components/Icons/NavigationDropdown/Resources/index.tsx +37 -0
- package/src/components/Icons/NavigationDropdown/Store/index.tsx +37 -0
- package/src/components/Icons/NavigationDropdown/Ui/index.tsx +37 -0
- package/src/components/Icons/NavigationDropdown/User/index.tsx +37 -0
- package/src/components/Icons/PuzzleColored/index.tsx +35 -0
- package/src/components/Icons/QuestionMark/index.tsx +23 -0
- package/src/components/Icons/Restock/index.tsx +55 -0
- package/src/components/Icons/ScrollText/index.tsx +68 -0
- package/src/components/Icons/ShadedBg/index.tsx +334 -0
- package/src/components/Icons/Shop/index.tsx +68 -0
- package/src/components/Icons/SidebarLeft/index.tsx +42 -0
- package/src/components/Icons/StripeColored/index.tsx +60 -0
- package/src/components/Icons/ThumbDown/index.tsx +23 -0
- package/src/components/Icons/ThumbUp/index.tsx +23 -0
- package/src/components/Icons/WindowPaintbrush/index.tsx +57 -0
- package/src/components/Icons/index.tsx +20 -0
- package/src/components/InlineCode/index.tsx +42 -0
- package/src/components/InlineIcon/index.tsx +21 -0
- package/src/components/InlineThemeImage/index.tsx +14 -0
- package/src/components/Input/Search/index.tsx +64 -0
- package/src/components/Input/Text/index.tsx +39 -0
- package/src/components/Kbd/index.tsx +33 -0
- package/src/components/Label/index.tsx +19 -0
- package/src/components/Link/index.tsx +67 -0
- package/src/components/LinkButton/index.tsx +43 -0
- package/src/components/Loading/Dots/index.tsx +16 -0
- package/src/components/Loading/Spinner/index.tsx +19 -0
- package/src/components/Loading/index.tsx +43 -0
- package/src/components/MDXComponents/index.tsx +209 -0
- package/src/components/MainNav/DesktopMenu/ThemeMenu/index.tsx +76 -0
- package/src/components/MainNav/DesktopMenu/index.tsx +100 -0
- package/src/components/MainNav/Items/Dropdown/index.tsx +88 -0
- package/src/components/MainNav/Items/Link/index.tsx +34 -0
- package/src/components/MainNav/Items/index.tsx +61 -0
- package/src/components/MainNav/MobileMenu/Main/index.tsx +67 -0
- package/src/components/MainNav/MobileMenu/SubMenu/index.tsx +77 -0
- package/src/components/MainNav/MobileMenu/index.tsx +103 -0
- package/src/components/MainNav/Version/index.tsx +33 -0
- package/src/components/MainNav/index.tsx +153 -0
- package/src/components/MarkdownContent/index.tsx +41 -0
- package/src/components/Menu/Action/index.tsx +43 -0
- package/src/components/Menu/Divider/index.tsx +35 -0
- package/src/components/Menu/Dropdown/index.tsx +78 -0
- package/src/components/Menu/Item/index.tsx +36 -0
- package/src/components/Menu/SubMenu/index.tsx +47 -0
- package/src/components/Menu/index.tsx +44 -0
- package/src/components/Modal/Footer/index.tsx +29 -0
- package/src/components/Modal/Header/index.tsx +33 -0
- package/src/components/Modal/index.tsx +124 -0
- package/src/components/Note/Layout/index.tsx +139 -0
- package/src/components/Note/Types/checks.tsx +7 -0
- package/src/components/Note/Types/default.tsx +7 -0
- package/src/components/Note/Types/error.tsx +7 -0
- package/src/components/Note/Types/soon.tsx +7 -0
- package/src/components/Note/Types/sucess.tsx +7 -0
- package/src/components/Note/Types/warning.tsx +7 -0
- package/src/components/Note/index.tsx +32 -0
- package/src/components/Notices/DeprecatedNotice/index.tsx +33 -0
- package/src/components/Notices/ExpandableNotice/index.tsx +36 -0
- package/src/components/Notices/FeatureFlagNotice/index.tsx +36 -0
- package/src/components/Notices/VersionNotice/index.tsx +37 -0
- package/src/components/Notification/Item/Layout/Default/index.tsx +89 -0
- package/src/components/Notification/Item/index.tsx +88 -0
- package/src/components/Notification/index.tsx +65 -0
- package/src/components/Pagination/Card/index.tsx +80 -0
- package/src/components/Pagination/index.tsx +35 -0
- package/src/components/Prerequisites/Item/index.tsx +43 -0
- package/src/components/Prerequisites/index.tsx +94 -0
- package/src/components/RadioItem/index.tsx +38 -0
- package/src/components/Rating/index.tsx +133 -0
- package/src/components/RootProviders/index.tsx +31 -0
- package/src/components/Select/Badge/index.tsx +122 -0
- package/src/components/Select/Dropdown/index.tsx +188 -0
- package/src/components/Select/Input/index.tsx +123 -0
- package/src/components/Select/index.ts +13 -0
- package/src/components/Sidebar/Child/index.tsx +43 -0
- package/src/components/Sidebar/Item/Category/index.tsx +151 -0
- package/src/components/Sidebar/Item/Link/index.tsx +174 -0
- package/src/components/Sidebar/Item/Sidebar/index.tsx +67 -0
- package/src/components/Sidebar/Item/SubCategory/index.tsx +83 -0
- package/src/components/Sidebar/Item/index.tsx +41 -0
- package/src/components/Sidebar/Top/MobileClose/index.tsx +21 -0
- package/src/components/Sidebar/Top/index.tsx +33 -0
- package/src/components/Sidebar/index.tsx +153 -0
- package/src/components/SourceCodeLink/index.tsx +37 -0
- package/src/components/SplitLists/index.tsx +58 -0
- package/src/components/Table/index.tsx +87 -0
- package/src/components/Tabs/index.tsx +106 -0
- package/src/components/TextArea/index.tsx +30 -0
- package/src/components/ThemeImage/index.tsx +26 -0
- package/src/components/Toggle/index.tsx +28 -0
- package/src/components/Tooltip/index.tsx +65 -0
- package/src/components/TypeList/Items/index.tsx +337 -0
- package/src/components/TypeList/index.tsx +63 -0
- package/src/components/WideSection/index.tsx +25 -0
- package/src/components/ZoomImg/index.tsx +17 -0
- package/src/components/index.ts +75 -0
- package/src/constants.tsx +261 -0
- package/src/global-config.ts +11 -0
- package/src/hooks/index.ts +14 -0
- package/src/hooks/use-active-on-scroll/index.tsx +223 -0
- package/src/hooks/use-click-outside/index.tsx +37 -0
- package/src/hooks/use-collapsible/index.tsx +128 -0
- package/src/hooks/use-collapsible-code-lines/index.tsx +149 -0
- package/src/hooks/use-copy/index.tsx +28 -0
- package/src/hooks/use-heading-url/index.tsx +32 -0
- package/src/hooks/use-is-external-link/index.tsx +19 -0
- package/src/hooks/use-keyboard-shortcut/index.tsx +71 -0
- package/src/hooks/use-mutation-observer/index.ts +32 -0
- package/src/hooks/use-page-scroll-manager/index.tsx +82 -0
- package/src/hooks/use-resize-observer/index.ts +20 -0
- package/src/hooks/use-scroll-utils/index.tsx +372 -0
- package/src/hooks/use-select/index.tsx +99 -0
- package/src/hooks/use-tabs/index.tsx +94 -0
- package/src/index.ts +8 -0
- package/src/layouts/barebone.tsx +18 -0
- package/src/layouts/index.ts +4 -0
- package/src/layouts/main-content.tsx +86 -0
- package/src/layouts/root.tsx +43 -0
- package/src/layouts/tight.tsx +29 -0
- package/src/layouts/wide.tsx +25 -0
- package/src/providers/AiAssistant/index.tsx +65 -0
- package/src/providers/BrowserProvider/index.tsx +40 -0
- package/src/providers/ColorMode/index.tsx +73 -0
- package/src/providers/Layout/index.tsx +52 -0
- package/src/providers/MainNav/index.tsx +134 -0
- package/src/providers/Mobile/index.tsx +62 -0
- package/src/providers/Modal/index.tsx +52 -0
- package/src/providers/Notification/index.tsx +149 -0
- package/src/providers/Pagination/index.tsx +230 -0
- package/src/providers/Search/index.tsx +91 -0
- package/src/providers/Sidebar/index.tsx +745 -0
- package/src/providers/SiteConfig/index.tsx +70 -0
- package/src/providers/index.ts +13 -0
- package/src/types/config.ts +34 -0
- package/src/types/frontmatter.ts +23 -0
- package/src/types/general.ts +1 -0
- package/src/types/index.ts +9 -0
- package/src/types/menu.ts +40 -0
- package/src/types/navigation-dropdown.ts +16 -0
- package/src/types/navigation.ts +21 -0
- package/src/types/sidebar.ts +109 -0
- package/src/types/toc.ts +19 -0
- package/src/types/ui.ts +9 -0
- package/src/utils/array-same-elms.ts +10 -0
- package/src/utils/capitalize.ts +3 -0
- package/src/utils/check-sidebar-item-visibility.ts +47 -0
- package/src/utils/decode-str.ts +8 -0
- package/src/utils/dom-utils.ts +29 -0
- package/src/utils/event-parser.ts +54 -0
- package/src/utils/get-link-with-base-path.ts +3 -0
- package/src/utils/get-navbar-items.ts +55 -0
- package/src/utils/get-scrolled-top.ts +8 -0
- package/src/utils/index.ts +13 -0
- package/src/utils/is-elm-window.ts +3 -0
- package/src/utils/is-in-view.ts +10 -0
- package/src/utils/os-browser-utils.ts +39 -0
- package/src/utils/set-obj-value.ts +38 -0
- package/src/utils/sidebar-utils.ts +129 -0
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
|
|
2
|
+
import React, { useState } from "react"
|
|
3
|
+
import clsx from "clsx"
|
|
4
|
+
import { Tooltip } from "../../components/Tooltip"
|
|
5
|
+
import { useCopy } from "../../hooks/use-copy"
|
|
6
|
+
|
|
7
|
+
export type CopyButtonChildFn = (props: {
|
|
8
|
+
isCopied: boolean
|
|
9
|
+
}) => React.ReactNode
|
|
10
|
+
|
|
11
|
+
export type CopyButtonProps = {
|
|
12
|
+
text: string
|
|
13
|
+
buttonClassName?: string
|
|
14
|
+
tooltipClassName?: string
|
|
15
|
+
tooltipInnerClassName?: string
|
|
16
|
+
tooltipText?: string
|
|
17
|
+
onCopy?: (
|
|
18
|
+
e:
|
|
19
|
+
| React.MouseEvent<HTMLSpanElement, MouseEvent>
|
|
20
|
+
| React.TouchEvent<HTMLSpanElement>
|
|
21
|
+
) => void
|
|
22
|
+
handleTouch?: boolean
|
|
23
|
+
children?: React.ReactNode | CopyButtonChildFn
|
|
24
|
+
} & Omit<React.HTMLAttributes<HTMLDivElement>, "onCopy" | "children">
|
|
25
|
+
|
|
26
|
+
export const CopyButton = ({
|
|
27
|
+
text,
|
|
28
|
+
buttonClassName = "",
|
|
29
|
+
tooltipClassName = "",
|
|
30
|
+
tooltipText = "Copy to Clipboard",
|
|
31
|
+
children,
|
|
32
|
+
className,
|
|
33
|
+
onCopy,
|
|
34
|
+
handleTouch,
|
|
35
|
+
tooltipInnerClassName,
|
|
36
|
+
}: CopyButtonProps) => {
|
|
37
|
+
const { isCopied, handleCopy } = useCopy(text)
|
|
38
|
+
const [touchCount, setTouchCount] = useState(0)
|
|
39
|
+
|
|
40
|
+
return (
|
|
41
|
+
<Tooltip
|
|
42
|
+
text={isCopied ? `Copied!` : tooltipText}
|
|
43
|
+
tooltipClassName={clsx(tooltipClassName, handleTouch && "!block")}
|
|
44
|
+
className={className}
|
|
45
|
+
innerClassName={tooltipInnerClassName}
|
|
46
|
+
>
|
|
47
|
+
<span
|
|
48
|
+
className={clsx("cursor-pointer", buttonClassName)}
|
|
49
|
+
onClick={(e) => {
|
|
50
|
+
if (touchCount > 0) {
|
|
51
|
+
// prevent the on-click event from triggering if a touch event occurred.
|
|
52
|
+
return
|
|
53
|
+
}
|
|
54
|
+
onCopy?.(e)
|
|
55
|
+
handleCopy()
|
|
56
|
+
}}
|
|
57
|
+
onTouchEnd={(e) => {
|
|
58
|
+
if (!handleTouch) {
|
|
59
|
+
return
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
if (touchCount === 0) {
|
|
63
|
+
setTouchCount(touchCount + 1)
|
|
64
|
+
} else {
|
|
65
|
+
onCopy?.(e)
|
|
66
|
+
handleCopy()
|
|
67
|
+
setTouchCount(0)
|
|
68
|
+
}
|
|
69
|
+
}}
|
|
70
|
+
data-testid="copy-button"
|
|
71
|
+
>
|
|
72
|
+
{typeof children === "function" ? children({ isCopied }) : children}
|
|
73
|
+
</span>
|
|
74
|
+
</Tooltip>
|
|
75
|
+
)
|
|
76
|
+
}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import React from "react"
|
|
2
|
+
import clsx from "clsx"
|
|
3
|
+
import { PlusMini } from "@acmekit/icons"
|
|
4
|
+
|
|
5
|
+
export type DetailsSummaryProps = {
|
|
6
|
+
title?: React.ReactNode
|
|
7
|
+
subtitle?: React.ReactNode
|
|
8
|
+
badge?: React.ReactNode
|
|
9
|
+
expandable?: boolean
|
|
10
|
+
open?: boolean
|
|
11
|
+
className?: string
|
|
12
|
+
titleClassName?: string
|
|
13
|
+
hideExpandableIcon?: boolean
|
|
14
|
+
summaryRef?: React.LegacyRef<HTMLDivElement>
|
|
15
|
+
} & Omit<React.HTMLAttributes<HTMLElement>, "title">
|
|
16
|
+
|
|
17
|
+
export const DetailsSummary = ({
|
|
18
|
+
title,
|
|
19
|
+
subtitle,
|
|
20
|
+
children,
|
|
21
|
+
badge,
|
|
22
|
+
expandable = true,
|
|
23
|
+
open = false,
|
|
24
|
+
className,
|
|
25
|
+
titleClassName,
|
|
26
|
+
hideExpandableIcon = false,
|
|
27
|
+
summaryRef,
|
|
28
|
+
...rest
|
|
29
|
+
}: DetailsSummaryProps) => {
|
|
30
|
+
return (
|
|
31
|
+
<summary
|
|
32
|
+
className={clsx(
|
|
33
|
+
"py-docs_0.75 flex items-center justify-between",
|
|
34
|
+
expandable && "cursor-pointer",
|
|
35
|
+
!expandable &&
|
|
36
|
+
"border-acmekit-border-base border-y border-solid border-x-0",
|
|
37
|
+
(expandable || badge !== undefined) && "gap-0.5",
|
|
38
|
+
"no-marker",
|
|
39
|
+
className
|
|
40
|
+
)}
|
|
41
|
+
ref={summaryRef}
|
|
42
|
+
{...rest}
|
|
43
|
+
>
|
|
44
|
+
<span className="gap-docs_0.25 flex flex-col">
|
|
45
|
+
<span
|
|
46
|
+
className={clsx(
|
|
47
|
+
"text-compact-medium-plus text-acmekit-fg-base",
|
|
48
|
+
titleClassName
|
|
49
|
+
)}
|
|
50
|
+
data-testid="details-summary-title"
|
|
51
|
+
>
|
|
52
|
+
{title || children}
|
|
53
|
+
</span>
|
|
54
|
+
{subtitle && (
|
|
55
|
+
<span
|
|
56
|
+
className="text-compact-medium text-acmekit-fg-subtle mt-0.5"
|
|
57
|
+
data-testid="details-summary-subtitle"
|
|
58
|
+
>
|
|
59
|
+
{subtitle}
|
|
60
|
+
</span>
|
|
61
|
+
)}
|
|
62
|
+
</span>
|
|
63
|
+
{(badge || expandable) && (
|
|
64
|
+
<span className="flex gap-docs_0.5" data-testid="details-summary-extra">
|
|
65
|
+
{badge}
|
|
66
|
+
{expandable && !hideExpandableIcon && (
|
|
67
|
+
<PlusMini
|
|
68
|
+
className={clsx("transition-transform", open && "rotate-45")}
|
|
69
|
+
/>
|
|
70
|
+
)}
|
|
71
|
+
</span>
|
|
72
|
+
)}
|
|
73
|
+
</summary>
|
|
74
|
+
)
|
|
75
|
+
}
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
|
|
2
|
+
import React, { Suspense, cloneElement, useRef, useState } from "react"
|
|
3
|
+
import { Loading } from "../../components/Loading"
|
|
4
|
+
import clsx from "clsx"
|
|
5
|
+
import { DetailsSummary, DetailsSummaryProps } from "./Summary"
|
|
6
|
+
import { useCollapsible } from "../../hooks/use-collapsible"
|
|
7
|
+
|
|
8
|
+
export type DetailsProps = {
|
|
9
|
+
openInitial?: boolean
|
|
10
|
+
summaryContent?: React.ReactNode
|
|
11
|
+
summaryElm?: React.ReactNode
|
|
12
|
+
heightAnimation?: boolean
|
|
13
|
+
} & React.HTMLAttributes<HTMLDetailsElement>
|
|
14
|
+
|
|
15
|
+
export const Details = ({
|
|
16
|
+
openInitial = false,
|
|
17
|
+
summaryContent,
|
|
18
|
+
summaryElm,
|
|
19
|
+
children,
|
|
20
|
+
heightAnimation = false,
|
|
21
|
+
...props
|
|
22
|
+
}: DetailsProps) => {
|
|
23
|
+
const [open, setOpen] = useState(openInitial)
|
|
24
|
+
const ref = useRef<HTMLDetailsElement>(null)
|
|
25
|
+
const childrenWrapperRef = useRef<HTMLDivElement>(null)
|
|
26
|
+
const { getCollapsibleElms, setCollapsed } = useCollapsible({
|
|
27
|
+
initialValue: !openInitial,
|
|
28
|
+
heightAnimation,
|
|
29
|
+
onClose: () => setOpen(false),
|
|
30
|
+
childrenRef: childrenWrapperRef,
|
|
31
|
+
})
|
|
32
|
+
|
|
33
|
+
const handleToggle = (e: React.MouseEvent<HTMLElement>) => {
|
|
34
|
+
const targetElm = e.target as HTMLElement
|
|
35
|
+
if (targetElm.tagName.toLowerCase() === "a") {
|
|
36
|
+
window.location.href =
|
|
37
|
+
targetElm.getAttribute("href") || window.location.href
|
|
38
|
+
return
|
|
39
|
+
}
|
|
40
|
+
if (targetElm.tagName.toLowerCase() === "code") {
|
|
41
|
+
return
|
|
42
|
+
}
|
|
43
|
+
if (open) {
|
|
44
|
+
setCollapsed(true)
|
|
45
|
+
} else {
|
|
46
|
+
setOpen(true)
|
|
47
|
+
setCollapsed(false)
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
return (
|
|
52
|
+
<details
|
|
53
|
+
{...props}
|
|
54
|
+
ref={ref}
|
|
55
|
+
open={open}
|
|
56
|
+
onClick={(event) => {
|
|
57
|
+
event.preventDefault()
|
|
58
|
+
}}
|
|
59
|
+
onToggle={(event) => {
|
|
60
|
+
// this is to avoid event propagation
|
|
61
|
+
// when details are nested, which is a bug
|
|
62
|
+
// in react. Learn more here:
|
|
63
|
+
// https://github.com/facebook/react/issues/22718
|
|
64
|
+
event.stopPropagation()
|
|
65
|
+
}}
|
|
66
|
+
className={clsx(
|
|
67
|
+
"border-acmekit-border-base border-y border-solid border-x-0",
|
|
68
|
+
"overflow-hidden [&>summary]:relative",
|
|
69
|
+
props.className
|
|
70
|
+
)}
|
|
71
|
+
>
|
|
72
|
+
{summaryContent && (
|
|
73
|
+
<DetailsSummary
|
|
74
|
+
open={open}
|
|
75
|
+
onClick={handleToggle}
|
|
76
|
+
className="cursor-pointer"
|
|
77
|
+
title={summaryContent}
|
|
78
|
+
/>
|
|
79
|
+
)}
|
|
80
|
+
{summaryElm &&
|
|
81
|
+
cloneElement<DetailsSummaryProps>(
|
|
82
|
+
summaryElm as React.ReactElement<
|
|
83
|
+
DetailsSummaryProps,
|
|
84
|
+
React.FunctionComponent<DetailsSummaryProps>
|
|
85
|
+
>,
|
|
86
|
+
{
|
|
87
|
+
open,
|
|
88
|
+
onClick: handleToggle,
|
|
89
|
+
}
|
|
90
|
+
)}
|
|
91
|
+
{getCollapsibleElms(
|
|
92
|
+
<Suspense fallback={<Loading className="!mb-docs_2 !mt-0" />}>
|
|
93
|
+
<div ref={childrenWrapperRef}>{children}</div>
|
|
94
|
+
</Suspense>
|
|
95
|
+
)}
|
|
96
|
+
</details>
|
|
97
|
+
)
|
|
98
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import React from "react"
|
|
2
|
+
import clsx from "clsx"
|
|
3
|
+
import { Details } from "../../components/Details"
|
|
4
|
+
import { MarkdownContent } from "../../components/MarkdownContent"
|
|
5
|
+
|
|
6
|
+
type TroubleshootingSection = {
|
|
7
|
+
title: string
|
|
8
|
+
content: React.ReactNode
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
type DetailsListProps = {
|
|
12
|
+
sections: TroubleshootingSection[]
|
|
13
|
+
} & React.AllHTMLAttributes<HTMLDivElement>
|
|
14
|
+
|
|
15
|
+
export const DetailsList = ({ sections }: DetailsListProps) => {
|
|
16
|
+
return (
|
|
17
|
+
<>
|
|
18
|
+
{sections.map(({ title, content }, index) => (
|
|
19
|
+
<Details
|
|
20
|
+
summaryContent={title}
|
|
21
|
+
key={index}
|
|
22
|
+
className={clsx(index !== 0 && "border-t-0")}
|
|
23
|
+
>
|
|
24
|
+
{React.isValidElement(content) && content}
|
|
25
|
+
{!React.isValidElement(content) && typeof content === "string" && (
|
|
26
|
+
<MarkdownContent>{content}</MarkdownContent>
|
|
27
|
+
)}
|
|
28
|
+
</Details>
|
|
29
|
+
))}
|
|
30
|
+
</>
|
|
31
|
+
)
|
|
32
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
|
|
2
|
+
import clsx from "clsx"
|
|
3
|
+
import React from "react"
|
|
4
|
+
|
|
5
|
+
export type DottedSeparatorProps = {
|
|
6
|
+
wrapperClassName?: string
|
|
7
|
+
className?: string
|
|
8
|
+
"data-testid"?: string
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export const DottedSeparator = ({
|
|
12
|
+
className,
|
|
13
|
+
wrapperClassName,
|
|
14
|
+
"data-testid": testId,
|
|
15
|
+
}: DottedSeparatorProps) => {
|
|
16
|
+
return (
|
|
17
|
+
<div
|
|
18
|
+
className={clsx("px-docs_0.75 my-docs_0.75", wrapperClassName)}
|
|
19
|
+
data-testid={testId}
|
|
20
|
+
>
|
|
21
|
+
<span
|
|
22
|
+
className={clsx(
|
|
23
|
+
"block w-full h-px relative bg-border-dotted",
|
|
24
|
+
"bg-[length:4px_1px] bg-repeat-x bg-bottom",
|
|
25
|
+
className
|
|
26
|
+
)}
|
|
27
|
+
></span>
|
|
28
|
+
</div>
|
|
29
|
+
)
|
|
30
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import React from "react"
|
|
2
|
+
import clsx from "clsx"
|
|
3
|
+
import { ArrowUpRightOnBox } from "@acmekit/icons"
|
|
4
|
+
import { EditDate } from "../EditDate"
|
|
5
|
+
|
|
6
|
+
type EditButtonProps = {
|
|
7
|
+
filePath: string
|
|
8
|
+
editDate?: string
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export const EditButton = ({ filePath, editDate }: EditButtonProps) => {
|
|
12
|
+
return (
|
|
13
|
+
<div className="flex flex-wrap gap-docs_0.5 mt-docs_2 text-acmekit-fg-subtle">
|
|
14
|
+
{editDate && <EditDate date={editDate} />}
|
|
15
|
+
|
|
16
|
+
<a
|
|
17
|
+
href={`https://github.com/acmekit/acmekit/edit/develop${filePath}`}
|
|
18
|
+
target="_blank"
|
|
19
|
+
rel="noopener noreferrer"
|
|
20
|
+
className={clsx(
|
|
21
|
+
"flex w-fit gap-docs_0.25 items-center",
|
|
22
|
+
"text-acmekit-fg-subtle hover:text-acmekit-fg-base",
|
|
23
|
+
"text-compact-small-plus"
|
|
24
|
+
)}
|
|
25
|
+
data-testid="edit-button"
|
|
26
|
+
>
|
|
27
|
+
<span>Edit this page</span>
|
|
28
|
+
<ArrowUpRightOnBox />
|
|
29
|
+
</a>
|
|
30
|
+
</div>
|
|
31
|
+
)
|
|
32
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import React from "react"
|
|
2
|
+
|
|
3
|
+
const DATE_REGEX = /^[a-zA-Z]+ (?<month>[a-zA-Z]+)/
|
|
4
|
+
|
|
5
|
+
type EditDateProps = {
|
|
6
|
+
date: string
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export const EditDate = ({ date }: EditDateProps) => {
|
|
10
|
+
const today = new Date()
|
|
11
|
+
const dateObj = new Date(date)
|
|
12
|
+
if (isNaN(dateObj.getTime())) {
|
|
13
|
+
return <></>
|
|
14
|
+
}
|
|
15
|
+
const formattedDate = dateObj.toString()
|
|
16
|
+
const dateMatch = DATE_REGEX.exec(formattedDate)
|
|
17
|
+
|
|
18
|
+
if (!dateMatch?.groups?.month) {
|
|
19
|
+
return <></>
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
return (
|
|
23
|
+
<>
|
|
24
|
+
<span className="text-compact-small-plus" data-testid="edit-date">
|
|
25
|
+
Edited {dateMatch.groups.month} {dateObj.getDate()}
|
|
26
|
+
{dateObj.getFullYear() !== today.getFullYear()
|
|
27
|
+
? `, ${dateObj.getFullYear()}`
|
|
28
|
+
: ""}
|
|
29
|
+
</span>
|
|
30
|
+
<span className="text-compact-small">·</span>
|
|
31
|
+
</>
|
|
32
|
+
)
|
|
33
|
+
}
|