@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,70 @@
|
|
|
1
|
+
|
|
2
|
+
import React, { createContext, useContext, useState } from "react"
|
|
3
|
+
import { DocsConfig, FrontMatter, ToCItem } from "../../types"
|
|
4
|
+
import { globalConfig } from "../../global-config"
|
|
5
|
+
import { GITHUB_ISSUES_LINK } from "../../constants"
|
|
6
|
+
|
|
7
|
+
export type SiteConfigContextType = {
|
|
8
|
+
config: DocsConfig
|
|
9
|
+
setConfig: React.Dispatch<React.SetStateAction<DocsConfig>>
|
|
10
|
+
frontmatter: FrontMatter
|
|
11
|
+
setFrontmatter: React.Dispatch<React.SetStateAction<FrontMatter>>
|
|
12
|
+
toc: ToCItem[] | null
|
|
13
|
+
setToc: React.Dispatch<React.SetStateAction<ToCItem[] | null>>
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
const SiteConfigContext = createContext<SiteConfigContextType | null>(null)
|
|
17
|
+
|
|
18
|
+
export type SiteConfigProviderProps = {
|
|
19
|
+
config?: DocsConfig
|
|
20
|
+
children?: React.ReactNode
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export const SiteConfigProvider = ({
|
|
24
|
+
config: initConfig,
|
|
25
|
+
children,
|
|
26
|
+
}: SiteConfigProviderProps) => {
|
|
27
|
+
const [config, setConfig] = useState<DocsConfig>(
|
|
28
|
+
Object.assign(
|
|
29
|
+
{
|
|
30
|
+
baseUrl: "",
|
|
31
|
+
sidebars: [],
|
|
32
|
+
project: {
|
|
33
|
+
title: "",
|
|
34
|
+
key: "",
|
|
35
|
+
},
|
|
36
|
+
reportIssueLink: GITHUB_ISSUES_LINK,
|
|
37
|
+
logo: "",
|
|
38
|
+
},
|
|
39
|
+
globalConfig,
|
|
40
|
+
initConfig || {}
|
|
41
|
+
)
|
|
42
|
+
)
|
|
43
|
+
const [frontmatter, setFrontmatter] = useState<FrontMatter>({})
|
|
44
|
+
const [toc, setToc] = useState<ToCItem[] | null>(null)
|
|
45
|
+
|
|
46
|
+
return (
|
|
47
|
+
<SiteConfigContext.Provider
|
|
48
|
+
value={{
|
|
49
|
+
config,
|
|
50
|
+
setConfig,
|
|
51
|
+
frontmatter,
|
|
52
|
+
setFrontmatter,
|
|
53
|
+
toc,
|
|
54
|
+
setToc,
|
|
55
|
+
}}
|
|
56
|
+
>
|
|
57
|
+
{children}
|
|
58
|
+
</SiteConfigContext.Provider>
|
|
59
|
+
)
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
export const useSiteConfig = (): SiteConfigContextType => {
|
|
63
|
+
const context = useContext(SiteConfigContext)
|
|
64
|
+
|
|
65
|
+
if (!context) {
|
|
66
|
+
throw new Error("useSiteConfig must be used inside a SiteConfigProvider")
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
return context
|
|
70
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export * from "./BrowserProvider"
|
|
2
|
+
export * from "./ColorMode"
|
|
3
|
+
export * from "./Layout"
|
|
4
|
+
export * from "./Mobile"
|
|
5
|
+
export * from "./Modal"
|
|
6
|
+
export * from "./Notification"
|
|
7
|
+
export * from "./Search"
|
|
8
|
+
export * from "./SiteConfig"
|
|
9
|
+
|
|
10
|
+
export * from "./AiAssistant"
|
|
11
|
+
export * from "./MainNav"
|
|
12
|
+
export * from "./Sidebar"
|
|
13
|
+
export * from "./Pagination"
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { Sidebar } from "./index.js"
|
|
2
|
+
|
|
3
|
+
export type BreadcrumbOptions = {
|
|
4
|
+
startItems?: {
|
|
5
|
+
title: string
|
|
6
|
+
link: string
|
|
7
|
+
}[]
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export declare type DocsConfig = {
|
|
11
|
+
titleSuffix?: string
|
|
12
|
+
description?: string
|
|
13
|
+
baseUrl: string
|
|
14
|
+
basePath?: string
|
|
15
|
+
sidebars: Sidebar.Sidebar[]
|
|
16
|
+
filesBasePath?: string
|
|
17
|
+
project: {
|
|
18
|
+
title: string
|
|
19
|
+
key: string
|
|
20
|
+
}
|
|
21
|
+
breadcrumbOptions?: BreadcrumbOptions
|
|
22
|
+
version: {
|
|
23
|
+
number: string
|
|
24
|
+
releaseUrl: string
|
|
25
|
+
releaseDate: string
|
|
26
|
+
hide?: boolean
|
|
27
|
+
bannerImage?: {
|
|
28
|
+
light: string
|
|
29
|
+
dark: string
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
reportIssueLink?: string
|
|
33
|
+
logo: string
|
|
34
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
export declare type FrontMatter = {
|
|
2
|
+
slug?: string
|
|
3
|
+
sidebar_label?: string
|
|
4
|
+
sidebar_group?: string
|
|
5
|
+
sidebar_group_main?: boolean
|
|
6
|
+
sidebar_position?: number
|
|
7
|
+
sidebar_autogenerate_exclude?: boolean
|
|
8
|
+
sidebar_description?: string
|
|
9
|
+
tags?: (
|
|
10
|
+
| string
|
|
11
|
+
| {
|
|
12
|
+
name: string
|
|
13
|
+
label: string
|
|
14
|
+
}
|
|
15
|
+
)[]
|
|
16
|
+
title?: string
|
|
17
|
+
description?: string
|
|
18
|
+
products?: string[]
|
|
19
|
+
toc_max_depth?: number
|
|
20
|
+
generate_toc?: boolean
|
|
21
|
+
hide_content_menu?: boolean
|
|
22
|
+
keywords?: string[]
|
|
23
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export type Ref<T> = React.RefObject<T | null> | ((instance: T | null) => void)
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export * from "./config"
|
|
2
|
+
export * from "./frontmatter"
|
|
3
|
+
export * from "./general"
|
|
4
|
+
export * from "./menu"
|
|
5
|
+
export * from "./navigation"
|
|
6
|
+
export * from "./navigation-dropdown"
|
|
7
|
+
export * as Sidebar from "./sidebar"
|
|
8
|
+
export * from "./toc"
|
|
9
|
+
export * from "./ui"
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import type React from "react"
|
|
2
|
+
|
|
3
|
+
export type MenuItemLink = {
|
|
4
|
+
type: "link"
|
|
5
|
+
icon?: React.ReactNode
|
|
6
|
+
title: string
|
|
7
|
+
link: string
|
|
8
|
+
openInNewTab?: boolean
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export type MenuItemDivider = {
|
|
12
|
+
type: "divider"
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export type MenuItemAction = {
|
|
16
|
+
type: "action"
|
|
17
|
+
icon: React.ReactNode
|
|
18
|
+
title: string
|
|
19
|
+
shortcut?: string
|
|
20
|
+
action: () => void
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export type MenuItemCustom = {
|
|
24
|
+
type: "custom"
|
|
25
|
+
content: React.ReactNode
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export type MenuItemSubMenu = {
|
|
29
|
+
type: "sub-menu"
|
|
30
|
+
items: MenuItem[]
|
|
31
|
+
title: string
|
|
32
|
+
link?: string
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export type MenuItem =
|
|
36
|
+
| MenuItemLink
|
|
37
|
+
| MenuItemDivider
|
|
38
|
+
| MenuItemAction
|
|
39
|
+
| MenuItemCustom
|
|
40
|
+
| MenuItemSubMenu
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { IconProps } from "@acmekit/icons/dist/types.js"
|
|
2
|
+
|
|
3
|
+
export type NavigationDropdownItemLink = {
|
|
4
|
+
path: string
|
|
5
|
+
isActive?: boolean
|
|
6
|
+
title: string
|
|
7
|
+
icon: React.FC<IconProps>
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export type NavigationDropdownItem =
|
|
11
|
+
| ({
|
|
12
|
+
type: "link"
|
|
13
|
+
} & NavigationDropdownItemLink)
|
|
14
|
+
| {
|
|
15
|
+
type: "divider"
|
|
16
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { MenuItem } from "./menu.js"
|
|
2
|
+
|
|
3
|
+
export type NavigationItemDropdown = {
|
|
4
|
+
type: "dropdown"
|
|
5
|
+
title: string
|
|
6
|
+
children: (MenuItem & {
|
|
7
|
+
useAsFallback?: boolean
|
|
8
|
+
})[]
|
|
9
|
+
project?: string
|
|
10
|
+
link?: string
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export type NavigationItemLink = {
|
|
14
|
+
type: "link"
|
|
15
|
+
link: string
|
|
16
|
+
title: string
|
|
17
|
+
project?: string
|
|
18
|
+
useAsFallback?: boolean
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export type NavigationItem = NavigationItemLink | NavigationItemDropdown
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import type React from "react"
|
|
2
|
+
|
|
3
|
+
export type Sidebar = {
|
|
4
|
+
sidebar_id: string
|
|
5
|
+
title: string
|
|
6
|
+
items: SidebarItem[]
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export type SidebarItemCommon = {
|
|
10
|
+
title: string
|
|
11
|
+
children?: SidebarItem[]
|
|
12
|
+
loaded?: boolean
|
|
13
|
+
additionalElms?: React.ReactNode
|
|
14
|
+
badge?: {
|
|
15
|
+
variant: "purple" | "orange" | "green" | "blue" | "red" | "neutral"
|
|
16
|
+
text: string
|
|
17
|
+
}
|
|
18
|
+
chapterTitle?: string
|
|
19
|
+
childSidebarTitle?: string
|
|
20
|
+
hideChildren?: boolean
|
|
21
|
+
// generated by scripts
|
|
22
|
+
number?: string
|
|
23
|
+
// can be used to hold any description relevant when showing cards, etc...
|
|
24
|
+
description?: string
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export type InteractiveSidebarItemTypes =
|
|
28
|
+
| "category"
|
|
29
|
+
| "sub-category"
|
|
30
|
+
| "link"
|
|
31
|
+
| "ref"
|
|
32
|
+
| "external"
|
|
33
|
+
| "sidebar"
|
|
34
|
+
|
|
35
|
+
export type SidebarItemLink = SidebarItemCommon & {
|
|
36
|
+
type: "link" | "ref" | "external"
|
|
37
|
+
path: string
|
|
38
|
+
isPathHref?: boolean
|
|
39
|
+
linkProps?: React.AllHTMLAttributes<HTMLAnchorElement>
|
|
40
|
+
childrenSameLevel?: boolean
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export type SidebarItemSidebar = SidebarItemCommon & {
|
|
44
|
+
type: "sidebar"
|
|
45
|
+
sidebar_id: string
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export type SidebarItemCategory = SidebarItemCommon & {
|
|
49
|
+
type: "category"
|
|
50
|
+
onOpen?: () => void
|
|
51
|
+
initialOpen?: boolean
|
|
52
|
+
showLoadingIfEmpty?: boolean
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
export type SidebarItemSubCategory = SidebarItemCommon & {
|
|
56
|
+
type: "sub-category"
|
|
57
|
+
childrenSameLevel?: boolean
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
export type SidebarItemSeparator = {
|
|
61
|
+
type: "separator"
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
export type InteractiveSidebarItem =
|
|
65
|
+
| SidebarItemLink
|
|
66
|
+
| SidebarItemCategory
|
|
67
|
+
| SidebarItemSubCategory
|
|
68
|
+
| SidebarItemSidebar
|
|
69
|
+
|
|
70
|
+
export type SidebarItemLinkWithParent = SidebarItemLink & {
|
|
71
|
+
parentItem?: InteractiveSidebarItem
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
export type SidebarItem = InteractiveSidebarItem | SidebarItemSeparator
|
|
75
|
+
|
|
76
|
+
export type SidebarSortType = "none" | "alphabetize"
|
|
77
|
+
|
|
78
|
+
export type RawSidebarItem = SidebarItem & {
|
|
79
|
+
autogenerate_path?: string
|
|
80
|
+
autogenerate_tags?: string
|
|
81
|
+
autogenerate_as_ref?: boolean
|
|
82
|
+
sort_sidebar?: SidebarSortType
|
|
83
|
+
custom_autogenerate?: string
|
|
84
|
+
number?: string
|
|
85
|
+
} & (
|
|
86
|
+
| {
|
|
87
|
+
type: InteractiveSidebarItemTypes
|
|
88
|
+
children?: RawSidebarItem[]
|
|
89
|
+
}
|
|
90
|
+
| {
|
|
91
|
+
type: "separator"
|
|
92
|
+
}
|
|
93
|
+
)
|
|
94
|
+
|
|
95
|
+
export type RawSidebar = Omit<Sidebar, "items"> & {
|
|
96
|
+
items: RawSidebarItem[]
|
|
97
|
+
custom_autogenerate?: string
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
export type PersistedSidebarCategoryState = {
|
|
101
|
+
[k: string]: {
|
|
102
|
+
[k: string]: boolean
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
// export type SidebarHeirarchyItem = {
|
|
107
|
+
// title: string
|
|
108
|
+
// path?: string
|
|
109
|
+
// }
|
package/src/types/toc.ts
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export type ToCItem = {
|
|
2
|
+
title: string
|
|
3
|
+
id: string
|
|
4
|
+
level: number
|
|
5
|
+
children?: ToCItem[]
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export type ToCItemUi = Omit<ToCItem, "children"> & {
|
|
9
|
+
children?: ToCItemUi[]
|
|
10
|
+
associatedHeading: HTMLHeadingElement
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export type Product = {
|
|
14
|
+
name: string
|
|
15
|
+
path: string
|
|
16
|
+
title: string
|
|
17
|
+
image: string
|
|
18
|
+
type: "commerce"
|
|
19
|
+
}
|
package/src/types/ui.ts
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
export function checkSidebarItemVisibility(
|
|
2
|
+
item: HTMLElement,
|
|
3
|
+
withTransition = false,
|
|
4
|
+
topMargin = 0
|
|
5
|
+
) {
|
|
6
|
+
return withTransition
|
|
7
|
+
? checkSidebarItemVisibilityTransition(item, topMargin)
|
|
8
|
+
: checkSidebarItemVisibilityRelative(item, topMargin)
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
function checkSidebarItemVisibilityRelative(
|
|
12
|
+
item: HTMLElement,
|
|
13
|
+
topMargin: number
|
|
14
|
+
) {
|
|
15
|
+
const sidebar = document.getElementById("sidebar")
|
|
16
|
+
if (!sidebar) {
|
|
17
|
+
return false
|
|
18
|
+
}
|
|
19
|
+
const sidebarBoundingRect = sidebar.getBoundingClientRect()
|
|
20
|
+
const sidebarTop = sidebarBoundingRect.top - topMargin
|
|
21
|
+
const sidebarBottom = sidebarTop + sidebarBoundingRect.height
|
|
22
|
+
const itemBoundingRect = item.getBoundingClientRect()
|
|
23
|
+
const itemTop =
|
|
24
|
+
item.offsetParent === sidebar ? item.offsetTop : itemBoundingRect.top
|
|
25
|
+
const itemBottom = itemTop + itemBoundingRect.height
|
|
26
|
+
|
|
27
|
+
return itemTop >= sidebarTop && itemBottom <= sidebarBottom
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
function checkSidebarItemVisibilityTransition(
|
|
31
|
+
item: HTMLElement,
|
|
32
|
+
topMargin: number
|
|
33
|
+
) {
|
|
34
|
+
const sidebar = document.getElementById("sidebar")
|
|
35
|
+
if (!sidebar) {
|
|
36
|
+
return false
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
const sidebarBoundingRect = sidebar.getBoundingClientRect()
|
|
40
|
+
const activeItemBoundingRect = item.getBoundingClientRect()
|
|
41
|
+
|
|
42
|
+
return (
|
|
43
|
+
activeItemBoundingRect.top >= topMargin &&
|
|
44
|
+
activeItemBoundingRect.top - sidebarBoundingRect.height + topMargin < 0 &&
|
|
45
|
+
activeItemBoundingRect.bottom > 0
|
|
46
|
+
)
|
|
47
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
export function findPrevSibling(
|
|
2
|
+
element: HTMLElement,
|
|
3
|
+
selector: string
|
|
4
|
+
): HTMLElement | null {
|
|
5
|
+
let prevElement = element.previousElementSibling
|
|
6
|
+
while (prevElement !== null) {
|
|
7
|
+
if (prevElement.matches(selector)) {
|
|
8
|
+
return prevElement as HTMLElement
|
|
9
|
+
}
|
|
10
|
+
prevElement = prevElement.previousElementSibling
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
return null
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export function findNextSibling(
|
|
17
|
+
element: HTMLElement,
|
|
18
|
+
selector: string
|
|
19
|
+
): HTMLElement | null {
|
|
20
|
+
let nextElement = element.nextElementSibling
|
|
21
|
+
while (nextElement !== null) {
|
|
22
|
+
if (nextElement.matches(selector)) {
|
|
23
|
+
return nextElement as HTMLElement
|
|
24
|
+
}
|
|
25
|
+
nextElement = nextElement.nextElementSibling
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
return null
|
|
29
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { OpenAPI } from "../types"
|
|
2
|
+
|
|
3
|
+
export function parseEventPayload(payloadStr: string) {
|
|
4
|
+
const payloadParams = payloadStr.matchAll(/([\w_]+),? \/\/ (\(\w*\) )*(.*)/g)
|
|
5
|
+
const payloadForSnippet: Record<string, unknown> = {}
|
|
6
|
+
const payload = Array.from(payloadParams).map((match) => {
|
|
7
|
+
const name = match[1]
|
|
8
|
+
const type = (match[2]?.replace(/\(|\)/g, "") || "string").trim()
|
|
9
|
+
const description = match[3]
|
|
10
|
+
|
|
11
|
+
if (type === "string") {
|
|
12
|
+
payloadForSnippet[name] = "test"
|
|
13
|
+
} else if (type === "number") {
|
|
14
|
+
payloadForSnippet[name] = 1
|
|
15
|
+
} else if (type === "boolean") {
|
|
16
|
+
payloadForSnippet[name] = true
|
|
17
|
+
} else if (type === "object") {
|
|
18
|
+
payloadForSnippet[name] = {}
|
|
19
|
+
} else if (type === "array") {
|
|
20
|
+
payloadForSnippet[name] = [{}]
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
return {
|
|
24
|
+
name,
|
|
25
|
+
type,
|
|
26
|
+
description,
|
|
27
|
+
}
|
|
28
|
+
})
|
|
29
|
+
return {
|
|
30
|
+
parsed_payload: {
|
|
31
|
+
type: "object",
|
|
32
|
+
required: ["payload"],
|
|
33
|
+
properties: {
|
|
34
|
+
payload: {
|
|
35
|
+
type: "object",
|
|
36
|
+
description: "The payload emitted with the event",
|
|
37
|
+
required: [...payload.map((param) => param.name)],
|
|
38
|
+
properties: payload.reduce(
|
|
39
|
+
(acc, curr) => {
|
|
40
|
+
acc[curr.name] = {
|
|
41
|
+
type: curr.type as OpenAPI.OpenAPIV3.NonArraySchemaObjectType,
|
|
42
|
+
description: curr.description,
|
|
43
|
+
properties: {},
|
|
44
|
+
}
|
|
45
|
+
return acc
|
|
46
|
+
},
|
|
47
|
+
{} as Record<string, OpenAPI.SchemaObject>
|
|
48
|
+
),
|
|
49
|
+
},
|
|
50
|
+
},
|
|
51
|
+
} as OpenAPI.SchemaObject,
|
|
52
|
+
payload_for_snippet: payloadForSnippet,
|
|
53
|
+
}
|
|
54
|
+
}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { MenuItem, NavigationItem } from "../types"
|
|
2
|
+
import { navDropdownItems } from ".."
|
|
3
|
+
|
|
4
|
+
type Options = {
|
|
5
|
+
basePath: string
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export function getNavDropdownItems({ basePath }: Options): NavigationItem[] {
|
|
9
|
+
return navDropdownItems.map((item) => {
|
|
10
|
+
const newItem = {
|
|
11
|
+
...item,
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
if (newItem.link) {
|
|
15
|
+
newItem.link = `${basePath}${newItem.link}`
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
if (newItem.type === "dropdown") {
|
|
19
|
+
newItem.children = normalizeMenuItems({
|
|
20
|
+
basePath,
|
|
21
|
+
items: newItem.children,
|
|
22
|
+
})
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
return newItem
|
|
26
|
+
})
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export function normalizeMenuItems({
|
|
30
|
+
basePath,
|
|
31
|
+
items,
|
|
32
|
+
}: {
|
|
33
|
+
basePath: string
|
|
34
|
+
items: MenuItem[]
|
|
35
|
+
}): MenuItem[] {
|
|
36
|
+
return items.map((item) => {
|
|
37
|
+
const newItem = { ...item }
|
|
38
|
+
if (newItem.type !== "link" && newItem.type !== "sub-menu") {
|
|
39
|
+
return newItem
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
if (newItem.link) {
|
|
43
|
+
newItem.link = `${basePath}${newItem.link}`
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
if (newItem.type === "sub-menu") {
|
|
47
|
+
newItem.items = normalizeMenuItems({
|
|
48
|
+
basePath,
|
|
49
|
+
items: newItem.items,
|
|
50
|
+
})
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
return newItem
|
|
54
|
+
})
|
|
55
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export * from "./array-same-elms"
|
|
2
|
+
export * from "./capitalize"
|
|
3
|
+
export * from "./check-sidebar-item-visibility"
|
|
4
|
+
export * from "./decode-str"
|
|
5
|
+
export * from "./dom-utils"
|
|
6
|
+
export * from "./get-link-with-base-path"
|
|
7
|
+
export * from "./get-navbar-items"
|
|
8
|
+
export * from "./os-browser-utils"
|
|
9
|
+
export * from "./get-scrolled-top"
|
|
10
|
+
export * from "./is-elm-window"
|
|
11
|
+
export * from "./is-in-view"
|
|
12
|
+
export * from "./set-obj-value"
|
|
13
|
+
export * from "./sidebar-utils"
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export function isInView(element: Element): boolean {
|
|
2
|
+
const rect = element.getBoundingClientRect()
|
|
3
|
+
return (
|
|
4
|
+
rect.top >= 0 &&
|
|
5
|
+
rect.left >= 0 &&
|
|
6
|
+
rect.bottom <=
|
|
7
|
+
(window.innerHeight || document.documentElement.clientHeight) &&
|
|
8
|
+
rect.right <= (window.innerWidth || document.documentElement.clientWidth)
|
|
9
|
+
)
|
|
10
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
export function getBrowser():
|
|
2
|
+
| "Chrome"
|
|
3
|
+
| "Safari"
|
|
4
|
+
| "Firefox"
|
|
5
|
+
| "Internet Explorer"
|
|
6
|
+
| "Edge"
|
|
7
|
+
| "unknown" {
|
|
8
|
+
if (typeof navigator === "undefined") {
|
|
9
|
+
return "unknown"
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
const userAgent = navigator.userAgent.toLowerCase()
|
|
13
|
+
|
|
14
|
+
if (userAgent.indexOf("chrome") > -1) {
|
|
15
|
+
return "Chrome"
|
|
16
|
+
} else if (userAgent.indexOf("safari") > -1) {
|
|
17
|
+
return "Safari"
|
|
18
|
+
} else if (userAgent.indexOf("firefox") > -1) {
|
|
19
|
+
return "Firefox"
|
|
20
|
+
} else if (
|
|
21
|
+
userAgent.indexOf("msie") > -1 ||
|
|
22
|
+
userAgent.indexOf("trident") > -1
|
|
23
|
+
) {
|
|
24
|
+
return "Internet Explorer"
|
|
25
|
+
} else if (userAgent.indexOf("edge") > -1) {
|
|
26
|
+
return "Edge"
|
|
27
|
+
} else {
|
|
28
|
+
return "unknown"
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export function getOsShortcut() {
|
|
33
|
+
const isMacOs =
|
|
34
|
+
typeof navigator !== "undefined"
|
|
35
|
+
? navigator.userAgent.toLowerCase().indexOf("mac") !== 0
|
|
36
|
+
: true
|
|
37
|
+
|
|
38
|
+
return isMacOs ? "⌘" : "Ctrl"
|
|
39
|
+
}
|