@stainless-api/docs-ui 0.1.0-beta.10 → 0.1.0-beta.12
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/breadcrumbs-Z-hEqjcp.d.ts +19 -0
- package/dist/chunk-Bp6m_JJh.js +13 -0
- package/dist/component-generics-DzI21jRn.js +35 -0
- package/dist/component-generics-q5Dqiu2D.d.ts +30 -0
- package/dist/components/breadcrumbs.d.ts +2 -11
- package/dist/components/breadcrumbs.js +16 -52
- package/dist/components/chat.d.ts +13 -5
- package/dist/components/chat.js +138 -74
- package/dist/components/dropdown.d.ts +2 -17
- package/dist/components/dropdown.js +4 -18
- package/dist/components/icons.d.ts +50 -27
- package/dist/components/icons.js +3 -34
- package/dist/components/index.d.ts +12 -9
- package/dist/components/index.js +16 -10
- package/dist/components/method.d.ts +2 -41
- package/dist/components/method.js +16 -44
- package/dist/components/overview.d.ts +2 -21
- package/dist/components/overview.js +16 -49
- package/dist/components/primitives.d.ts +2 -60
- package/dist/components/primitives.js +16 -117
- package/dist/components/properties.d.ts +2 -24
- package/dist/components/properties.js +16 -24
- package/dist/components/scripts/dropdown.d.ts +11 -4
- package/dist/components/scripts/dropdown.js +49 -63
- package/dist/components/sdk.d.ts +3 -78
- package/dist/components/sdk.js +16 -153
- package/dist/components/sidebar.d.ts +2 -22
- package/dist/components/sidebar.js +16 -30
- package/dist/components/snippets.d.ts +4 -28
- package/dist/components/snippets.js +16 -76
- package/dist/contexts/component-generics.d.ts +2 -25
- package/dist/contexts/component-generics.js +3 -24
- package/dist/contexts/component-types.d.ts +18 -4
- package/dist/contexts/component-types.js +1 -2
- package/dist/contexts/component.d.ts +31 -14
- package/dist/contexts/component.js +16 -14
- package/dist/contexts/docs.d.ts +2 -34
- package/dist/contexts/docs.js +3 -43
- package/dist/contexts/index.d.ts +20 -7
- package/dist/contexts/index.js +16 -15
- package/dist/contexts/markdown.d.ts +2 -13
- package/dist/contexts/markdown.js +4 -29
- package/dist/contexts/navigation.d.ts +3 -19
- package/dist/contexts/navigation.js +3 -14
- package/dist/contexts/search.d.ts +4 -13
- package/dist/contexts/search.js +16 -15
- package/dist/contexts/use-components.d.ts +16 -1
- package/dist/contexts/use-components.js +4 -3
- package/dist/contexts-DRxRO-xO.js +3747 -0
- package/dist/docs-Dh8kE1va.js +50 -0
- package/dist/docs-EUy-wfbA.d.ts +43 -0
- package/dist/dropdown-B7VyGMOw.d.ts +43 -0
- package/dist/dropdown-DtgAi6lb.js +62 -0
- package/dist/icons-DdKM-01E.js +753 -0
- package/dist/index-AicgPYKB.d.ts +239 -0
- package/dist/index-BhwLhiWk.d.ts +14 -0
- package/dist/index-YnpUtXLB.d.ts +16 -0
- package/dist/index.d.ts +22 -6
- package/dist/index.js +16 -7
- package/dist/languages/go.d.ts +13 -21
- package/dist/languages/go.js +16 -116
- package/dist/languages/http.d.ts +13 -25
- package/dist/languages/http.js +16 -130
- package/dist/languages/index.d.ts +13 -37
- package/dist/languages/index.js +16 -10
- package/dist/languages/java.d.ts +13 -23
- package/dist/languages/java.js +16 -120
- package/dist/languages/python.d.ts +13 -22
- package/dist/languages/python.js +16 -104
- package/dist/languages/ruby.d.ts +13 -22
- package/dist/languages/ruby.js +16 -125
- package/dist/languages/typescript.d.ts +13 -22
- package/dist/languages/typescript.js +16 -134
- package/dist/markdown/index.d.ts +11 -6
- package/dist/markdown/index.js +16 -80
- package/dist/markdown/md.d.ts +15 -11
- package/dist/markdown/md.js +3 -34
- package/dist/markdown/utils.d.ts +4 -17
- package/dist/markdown/utils.js +3 -30
- package/dist/markdown-BXfX1D7C.js +42 -0
- package/dist/markdown-nFyAEX_K.d.ts +22 -0
- package/dist/md-Dg8aOyMA.js +41 -0
- package/dist/method-DpsVuzZW.d.ts +71 -0
- package/dist/navigation-aoYZ_tl4.js +24 -0
- package/dist/navigation-nyXBY-75.d.ts +29 -0
- package/dist/overview-C8e-6jGr.d.ts +38 -0
- package/dist/pagefind-ChrPfuVv.js +15 -0
- package/dist/primitives-DWz23_Ub.d.ts +99 -0
- package/dist/properties-CF71V58d.d.ts +46 -0
- package/dist/routing-DQjbRxdJ.js +189 -0
- package/dist/routing-qc0V00-j.d.ts +51 -0
- package/dist/routing.d.ts +2 -44
- package/dist/routing.js +3 -169
- package/dist/sdk-Zg3Rggk3.d.ts +118 -0
- package/dist/search/index.d.ts +26 -1
- package/dist/search/index.js +332 -2
- package/dist/search/providers/algolia.d.ts +22 -7
- package/dist/search/providers/algolia.js +16 -64
- package/dist/search/providers/fuse.d.ts +16 -9
- package/dist/search/providers/fuse.js +29 -12
- package/dist/search/providers/pagefind.d.ts +7 -2
- package/dist/search/providers/pagefind.js +3 -19
- package/dist/search/providers/walker.d.ts +8 -5
- package/dist/search/providers/walker.js +28 -19
- package/dist/search/types.d.ts +3 -79
- package/dist/search/types.js +3 -24
- package/dist/search-B6loAGmB.d.ts +21 -0
- package/dist/sidebar-C8KirYjg.d.ts +35 -0
- package/dist/snippets-EUzM4fRO.d.ts +45 -0
- package/dist/style-pN9hCoec.d.ts +181 -0
- package/dist/style-rYbbxIR_.js +182 -0
- package/dist/style.d.ts +2 -179
- package/dist/style.js +3 -179
- package/dist/styles/main.css +740 -746
- package/dist/styles/main.js +1 -0
- package/dist/styles/primitives.css +436 -428
- package/dist/styles/primitives.js +1 -0
- package/dist/styles/resets.css +34 -41
- package/dist/styles/resets.js +1 -0
- package/dist/styles/search.css +248 -248
- package/dist/styles/search.js +1 -0
- package/dist/styles/sidebar.css +59 -60
- package/dist/styles/sidebar.js +1 -0
- package/dist/styles/snippets.css +87 -88
- package/dist/styles/snippets.js +1 -0
- package/dist/styles/variables.css +86 -89
- package/dist/styles/variables.js +1 -0
- package/dist/types-CTBDtD34.d.ts +82 -0
- package/dist/types-DFN4M1Sp.js +34 -0
- package/dist/use-components-D9E85p5x.js +7 -0
- package/dist/utils-BHwvUDKn.js +30 -0
- package/dist/utils-CJfFBNgT.js +32 -0
- package/dist/utils-DQhEbvUC.d.ts +20 -0
- package/dist/utils-nDazhti8.d.ts +11 -0
- package/dist/utils.d.ts +2 -7
- package/dist/utils.js +4 -27
- package/package.json +2 -2
- package/dist/components/breadcrumbs.js.map +0 -1
- package/dist/components/chat.js.map +0 -1
- package/dist/components/dropdown.js.map +0 -1
- package/dist/components/icons.js.map +0 -1
- package/dist/components/index.js.map +0 -1
- package/dist/components/method.js.map +0 -1
- package/dist/components/overview.js.map +0 -1
- package/dist/components/primitives.js.map +0 -1
- package/dist/components/properties.js.map +0 -1
- package/dist/components/scripts/dropdown.js.map +0 -1
- package/dist/components/sdk.js.map +0 -1
- package/dist/components/sidebar.js.map +0 -1
- package/dist/components/snippets.js.map +0 -1
- package/dist/contexts/component-generics.js.map +0 -1
- package/dist/contexts/component-types.js.map +0 -1
- package/dist/contexts/component.js.map +0 -1
- package/dist/contexts/docs.js.map +0 -1
- package/dist/contexts/index.js.map +0 -1
- package/dist/contexts/markdown.js.map +0 -1
- package/dist/contexts/navigation.js.map +0 -1
- package/dist/contexts/search.js.map +0 -1
- package/dist/contexts/use-components.js.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/languages/go.js.map +0 -1
- package/dist/languages/http.js.map +0 -1
- package/dist/languages/index.js.map +0 -1
- package/dist/languages/java.js.map +0 -1
- package/dist/languages/python.js.map +0 -1
- package/dist/languages/ruby.js.map +0 -1
- package/dist/languages/typescript.js.map +0 -1
- package/dist/markdown/index.js.map +0 -1
- package/dist/markdown/md.js.map +0 -1
- package/dist/markdown/utils.js.map +0 -1
- package/dist/mcp.js +0 -16105
- package/dist/routing.js.map +0 -1
- package/dist/search/form.d.ts +0 -13
- package/dist/search/form.js +0 -55
- package/dist/search/form.js.map +0 -1
- package/dist/search/index.js.map +0 -1
- package/dist/search/indexer.d.ts +0 -31
- package/dist/search/indexer.js +0 -212
- package/dist/search/indexer.js.map +0 -1
- package/dist/search/mcp.d.ts +0 -8
- package/dist/search/mcp.js +0 -43
- package/dist/search/mcp.js.map +0 -1
- package/dist/search/printer.d.ts +0 -6
- package/dist/search/printer.js +0 -43
- package/dist/search/printer.js.map +0 -1
- package/dist/search/providers/algolia.js.map +0 -1
- package/dist/search/providers/fuse.js.map +0 -1
- package/dist/search/providers/pagefind.js.map +0 -1
- package/dist/search/providers/walker.js.map +0 -1
- package/dist/search/results.d.ts +0 -21
- package/dist/search/results.js +0 -58
- package/dist/search/results.js.map +0 -1
- package/dist/search/state.d.ts +0 -29
- package/dist/search/state.js +0 -38
- package/dist/search/state.js.map +0 -1
- package/dist/search/types.js.map +0 -1
- package/dist/style.js.map +0 -1
- package/dist/types/sdkjson.d.ts +0 -1
- package/dist/types/sdkjson.js +0 -2
- package/dist/types/sdkjson.js.map +0 -1
- package/dist/types/stainless-alias/lib/json-spec-v2/GoAST.d.ts +0 -120
- package/dist/types/stainless-alias/lib/json-spec-v2/GoAST.js +0 -2
- package/dist/types/stainless-alias/lib/json-spec-v2/GoAST.js.map +0 -1
- package/dist/types/stainless-alias/lib/json-spec-v2/HttpAST.d.ts +0 -100
- package/dist/types/stainless-alias/lib/json-spec-v2/HttpAST.js +0 -3
- package/dist/types/stainless-alias/lib/json-spec-v2/HttpAST.js.map +0 -1
- package/dist/types/stainless-alias/lib/json-spec-v2/JavaAST.d.ts +0 -87
- package/dist/types/stainless-alias/lib/json-spec-v2/JavaAST.js +0 -2
- package/dist/types/stainless-alias/lib/json-spec-v2/JavaAST.js.map +0 -1
- package/dist/types/stainless-alias/lib/json-spec-v2/PythonAST.d.ts +0 -110
- package/dist/types/stainless-alias/lib/json-spec-v2/PythonAST.js +0 -3
- package/dist/types/stainless-alias/lib/json-spec-v2/PythonAST.js.map +0 -1
- package/dist/types/stainless-alias/lib/json-spec-v2/RubyAST.d.ts +0 -122
- package/dist/types/stainless-alias/lib/json-spec-v2/RubyAST.js +0 -2
- package/dist/types/stainless-alias/lib/json-spec-v2/RubyAST.js.map +0 -1
- package/dist/types/stainless-alias/lib/json-spec-v2/TSAST.d.ts +0 -146
- package/dist/types/stainless-alias/lib/json-spec-v2/TSAST.js +0 -3
- package/dist/types/stainless-alias/lib/json-spec-v2/TSAST.js.map +0 -1
- package/dist/types/stainless-alias/lib/json-spec-v2/TerraformAST.d.ts +0 -89
- package/dist/types/stainless-alias/lib/json-spec-v2/TerraformAST.js +0 -3
- package/dist/types/stainless-alias/lib/json-spec-v2/TerraformAST.js.map +0 -1
- package/dist/types/stainless-alias/lib/json-spec-v2/types.d.ts +0 -190
- package/dist/types/stainless-alias/lib/json-spec-v2/types.js +0 -105
- package/dist/types/stainless-alias/lib/json-spec-v2/types.js.map +0 -1
- package/dist/utils.js.map +0 -1
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import * as react_jsx_runtime0 from "react/jsx-runtime";
|
|
2
|
+
|
|
3
|
+
//#region src/components/breadcrumbs.d.ts
|
|
4
|
+
type BreadcrumbConfig = {
|
|
5
|
+
includeCurrentPage?: boolean;
|
|
6
|
+
};
|
|
7
|
+
declare function SDKBreadcrumbs({
|
|
8
|
+
spec,
|
|
9
|
+
currentPath,
|
|
10
|
+
basePath,
|
|
11
|
+
config
|
|
12
|
+
}: {
|
|
13
|
+
spec: SDKJSON.Spec;
|
|
14
|
+
currentPath: string;
|
|
15
|
+
basePath?: string;
|
|
16
|
+
config?: BreadcrumbConfig | null;
|
|
17
|
+
}): react_jsx_runtime0.JSX.Element | null;
|
|
18
|
+
//#endregion
|
|
19
|
+
export { SDKBreadcrumbs as t };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
//#region rolldown:runtime
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __export = (all) => {
|
|
4
|
+
let target = {};
|
|
5
|
+
for (var name in all) __defProp(target, name, {
|
|
6
|
+
get: all[name],
|
|
7
|
+
enumerable: true
|
|
8
|
+
});
|
|
9
|
+
return target;
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
//#endregion
|
|
13
|
+
export { __export as t };
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import * as React$1 from "react";
|
|
2
|
+
import { jsx } from "react/jsx-runtime";
|
|
3
|
+
|
|
4
|
+
//#region src/contexts/component-generics.tsx
|
|
5
|
+
const ComponentContext = React$1.createContext(null);
|
|
6
|
+
ComponentContext.displayName = "ComponentContext";
|
|
7
|
+
function useComponents() {
|
|
8
|
+
const ctx = React$1.useContext(ComponentContext);
|
|
9
|
+
if (!ctx) throw new Error("useComponents must be used within a ComponentContext.Provider");
|
|
10
|
+
return ctx.components;
|
|
11
|
+
}
|
|
12
|
+
function customizeComponents(defaults, overrides = {}) {
|
|
13
|
+
return {
|
|
14
|
+
components: {
|
|
15
|
+
...defaults.components,
|
|
16
|
+
...overrides.components ?? {}
|
|
17
|
+
},
|
|
18
|
+
language: Object.keys(defaults.language).reduce((acc, key) => {
|
|
19
|
+
acc[key] = {
|
|
20
|
+
...defaults.language[key],
|
|
21
|
+
...overrides.language?.[key] ?? {}
|
|
22
|
+
};
|
|
23
|
+
return acc;
|
|
24
|
+
}, {})
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
function ComponentProvider({ value, children }) {
|
|
28
|
+
return /* @__PURE__ */ jsx(ComponentContext.Provider, {
|
|
29
|
+
value,
|
|
30
|
+
children
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
//#endregion
|
|
35
|
+
export { useComponents as i, ComponentProvider as n, customizeComponents as r, ComponentContext as t };
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import * as React$1 from "react";
|
|
2
|
+
import * as react_jsx_runtime29 from "react/jsx-runtime";
|
|
3
|
+
|
|
4
|
+
//#region src/contexts/component-generics.d.ts
|
|
5
|
+
type DeepPartialMap<L> = { [K in keyof L]?: Partial<L[K]> };
|
|
6
|
+
type ComponentsContextType<C, L> = {
|
|
7
|
+
components: C;
|
|
8
|
+
language: L;
|
|
9
|
+
};
|
|
10
|
+
declare const ComponentContext: React$1.Context<ComponentsContextType<any, any> | null>;
|
|
11
|
+
declare function useComponents<C = unknown>(): C;
|
|
12
|
+
declare function customizeComponents<C, L>(defaults: {
|
|
13
|
+
components: C;
|
|
14
|
+
language: L;
|
|
15
|
+
}, overrides?: {
|
|
16
|
+
components?: Partial<C>;
|
|
17
|
+
language?: DeepPartialMap<L>;
|
|
18
|
+
}): {
|
|
19
|
+
components: C;
|
|
20
|
+
language: L;
|
|
21
|
+
};
|
|
22
|
+
declare function ComponentProvider<C, L>({
|
|
23
|
+
value,
|
|
24
|
+
children
|
|
25
|
+
}: {
|
|
26
|
+
value: ComponentsContextType<C, L>;
|
|
27
|
+
children: React$1.ReactNode;
|
|
28
|
+
}): react_jsx_runtime29.JSX.Element;
|
|
29
|
+
//#endregion
|
|
30
|
+
export { useComponents as a, customizeComponents as i, ComponentProvider as n, ComponentsContextType as r, ComponentContext as t };
|
|
@@ -1,11 +1,2 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
includeCurrentPage?: boolean;
|
|
4
|
-
};
|
|
5
|
-
export declare function SDKBreadcrumbs({ spec, currentPath, basePath, config, }: {
|
|
6
|
-
spec: SDKJSON.Spec;
|
|
7
|
-
currentPath: string;
|
|
8
|
-
basePath?: string;
|
|
9
|
-
config?: BreadcrumbConfig | null;
|
|
10
|
-
}): import("react/jsx-runtime").JSX.Element | null;
|
|
11
|
-
export {};
|
|
1
|
+
import { t as SDKBreadcrumbs } from "../breadcrumbs-Z-hEqjcp.js";
|
|
2
|
+
export { SDKBreadcrumbs };
|
|
@@ -1,52 +1,16 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
// Handle sdk language prefix
|
|
18
|
-
if (Languages.includes(rest[0])) {
|
|
19
|
-
href += `/${rest[0]}`;
|
|
20
|
-
i++;
|
|
21
|
-
}
|
|
22
|
-
// Always start with API Reference
|
|
23
|
-
breadcrumbs.push({ title: 'API Reference', href });
|
|
24
|
-
let currentSpec = spec;
|
|
25
|
-
while (i < rest.length) {
|
|
26
|
-
const idType = rest[i];
|
|
27
|
-
const idValue = rest[i + 1];
|
|
28
|
-
if (!idType || !idValue || !currentSpec?.[idType]?.[idValue])
|
|
29
|
-
break;
|
|
30
|
-
currentSpec = currentSpec[idType][idValue];
|
|
31
|
-
href += `/${idType}/${idValue}`;
|
|
32
|
-
// This should always exist, but just in case fallback to the raw url value
|
|
33
|
-
const title = (idType === 'methods' ? currentSpec.summary : currentSpec.title) ?? idValue;
|
|
34
|
-
breadcrumbs.push({
|
|
35
|
-
title,
|
|
36
|
-
href,
|
|
37
|
-
});
|
|
38
|
-
i += 2;
|
|
39
|
-
}
|
|
40
|
-
return breadcrumbs;
|
|
41
|
-
}
|
|
42
|
-
export function SDKBreadcrumbs({ spec, currentPath, basePath = '/api', config = { includeCurrentPage: false }, }) {
|
|
43
|
-
const breadcrumbs = generateApiBreadcrumbs(currentPath, spec, basePath);
|
|
44
|
-
if (!breadcrumbs || breadcrumbs.length === 0)
|
|
45
|
-
return null;
|
|
46
|
-
if (!config?.includeCurrentPage && breadcrumbs.length > 1) {
|
|
47
|
-
breadcrumbs.pop();
|
|
48
|
-
}
|
|
49
|
-
const items = breadcrumbs.map((crumb, index) => (_jsx("div", { className: style.BreadcrumbsItem, children: _jsx("a", { href: crumb.href, className: style.BreadcrumbsLink, children: crumb.title }) }, index)));
|
|
50
|
-
return (_jsx("div", { className: style.Breadcrumbs, children: _jsx(Join, { limit: breadcrumbs.length, items: items, children: _jsx(ChevronRight, {}) }) }));
|
|
51
|
-
}
|
|
52
|
-
//# sourceMappingURL=breadcrumbs.js.map
|
|
1
|
+
import "../component-generics-DzI21jRn.js";
|
|
2
|
+
import "../docs-Dh8kE1va.js";
|
|
3
|
+
import "../navigation-aoYZ_tl4.js";
|
|
4
|
+
import "../markdown-BXfX1D7C.js";
|
|
5
|
+
import "../routing-DQjbRxdJ.js";
|
|
6
|
+
import "../style-rYbbxIR_.js";
|
|
7
|
+
import "../use-components-D9E85p5x.js";
|
|
8
|
+
import { ot as SDKBreadcrumbs } from "../contexts-DRxRO-xO.js";
|
|
9
|
+
import "../icons-DdKM-01E.js";
|
|
10
|
+
import "../utils-CJfFBNgT.js";
|
|
11
|
+
import "../dropdown-DtgAi6lb.js";
|
|
12
|
+
import "../md-Dg8aOyMA.js";
|
|
13
|
+
import "../utils-BHwvUDKn.js";
|
|
14
|
+
import "../types-DFN4M1Sp.js";
|
|
15
|
+
|
|
16
|
+
export { SDKBreadcrumbs };
|
|
@@ -1,6 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import * as react_jsx_runtime65 from "react/jsx-runtime";
|
|
2
|
+
|
|
3
|
+
//#region src/components/chat.d.ts
|
|
4
|
+
declare function Chat(): react_jsx_runtime65.JSX.Element;
|
|
5
|
+
type ChatModalProps = {
|
|
6
|
+
id?: string;
|
|
7
|
+
open?: boolean;
|
|
5
8
|
};
|
|
6
|
-
|
|
9
|
+
declare function ChatModal({
|
|
10
|
+
id,
|
|
11
|
+
open: isOpen
|
|
12
|
+
}: ChatModalProps): react_jsx_runtime65.JSX.Element;
|
|
13
|
+
//#endregion
|
|
14
|
+
export { Chat, ChatModal, ChatModalProps };
|
package/dist/components/chat.js
CHANGED
|
@@ -1,80 +1,144 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import {
|
|
7
|
-
import
|
|
8
|
-
|
|
1
|
+
import "../component-generics-DzI21jRn.js";
|
|
2
|
+
import { a as useLanguage } from "../docs-Dh8kE1va.js";
|
|
3
|
+
import "../navigation-aoYZ_tl4.js";
|
|
4
|
+
import "../markdown-BXfX1D7C.js";
|
|
5
|
+
import "../routing-DQjbRxdJ.js";
|
|
6
|
+
import { t as style_default } from "../style-rYbbxIR_.js";
|
|
7
|
+
import "../use-components-D9E85p5x.js";
|
|
8
|
+
import { Bt as Markdown, a as useSearchContext } from "../contexts-DRxRO-xO.js";
|
|
9
|
+
import "../icons-DdKM-01E.js";
|
|
10
|
+
import "../utils-CJfFBNgT.js";
|
|
11
|
+
import "../dropdown-DtgAi6lb.js";
|
|
12
|
+
import "../md-Dg8aOyMA.js";
|
|
13
|
+
import "../utils-BHwvUDKn.js";
|
|
14
|
+
import "../types-DFN4M1Sp.js";
|
|
15
|
+
import * as React$1 from "react";
|
|
16
|
+
import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
|
|
17
|
+
import { ArrowUpIcon, BotMessageSquareIcon, LoaderCircleIcon, SquareIcon, TrashIcon } from "lucide-react";
|
|
18
|
+
import { useChat } from "ai/react";
|
|
19
|
+
|
|
20
|
+
//#region src/components/chat.tsx
|
|
21
|
+
const BASEURL = "https://askai.algolia.com";
|
|
9
22
|
function buildFetch({ appId, searchKey, indexName, assistant }) {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
23
|
+
const headers = {
|
|
24
|
+
"X-Algolia-Application-Id": appId,
|
|
25
|
+
"X-Algolia-API-Key": searchKey,
|
|
26
|
+
"X-Algolia-Index-Name": `${indexName}-chat`,
|
|
27
|
+
"X-Algolia-Assistant-Id": assistant
|
|
28
|
+
};
|
|
29
|
+
return async (input, init) => {
|
|
30
|
+
const data = await (await fetch(`${BASEURL}/chat/token`, {
|
|
31
|
+
method: "POST",
|
|
32
|
+
headers
|
|
33
|
+
})).json();
|
|
34
|
+
return fetch(input, {
|
|
35
|
+
...init,
|
|
36
|
+
headers: {
|
|
37
|
+
...init.headers,
|
|
38
|
+
...headers,
|
|
39
|
+
Authorization: `TOKEN ${data["token"]}`
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
};
|
|
28
43
|
}
|
|
29
44
|
function RenderMessage({ message }) {
|
|
30
|
-
|
|
31
|
-
.filter((part) => part.type === 'text')
|
|
32
|
-
.map((part, key) => _jsx(Markdown, { content: part['text'] }, key));
|
|
45
|
+
return message.parts.filter((part) => part.type === "text").map((part, key) => /* @__PURE__ */ jsx(Markdown, { content: part["text"] }, key));
|
|
33
46
|
}
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
47
|
+
function Chat() {
|
|
48
|
+
const language = useLanguage();
|
|
49
|
+
const { settings } = useSearchContext();
|
|
50
|
+
const messageListRef = React$1.useRef(null);
|
|
51
|
+
const { messages, setMessages, status, input, setInput, append, stop } = useChat({
|
|
52
|
+
body: { searchParameters: { filters: `language:${language ?? "http"}` } },
|
|
53
|
+
sendExtraMessageFields: true,
|
|
54
|
+
fetch: buildFetch(settings),
|
|
55
|
+
api: `${BASEURL}/chat`
|
|
56
|
+
});
|
|
57
|
+
React$1.useEffect(() => {
|
|
58
|
+
const content = sessionStorage.getItem("stldocs-chat-messages");
|
|
59
|
+
if (!content) return;
|
|
60
|
+
setMessages(JSON.parse(content));
|
|
61
|
+
setTimeout(() => {
|
|
62
|
+
if (!messageListRef.current) return;
|
|
63
|
+
messageListRef.current.scrollTop = messageListRef.current.scrollHeight;
|
|
64
|
+
}, 10);
|
|
65
|
+
}, [setMessages]);
|
|
66
|
+
React$1.useEffect(() => {
|
|
67
|
+
if (status !== "submitted") return;
|
|
68
|
+
[...messageListRef?.current.querySelectorAll("[data-stldocs-chat-message]")].at(-1)?.scrollIntoView({
|
|
69
|
+
behavior: "smooth",
|
|
70
|
+
block: "start"
|
|
71
|
+
});
|
|
72
|
+
}, [status]);
|
|
73
|
+
React$1.useEffect(() => {
|
|
74
|
+
sessionStorage.setItem("stldocs-chat-messages", JSON.stringify(messages));
|
|
75
|
+
}, [messages]);
|
|
76
|
+
function handleSend() {
|
|
77
|
+
append({
|
|
78
|
+
role: "user",
|
|
79
|
+
content: input
|
|
80
|
+
});
|
|
81
|
+
setInput("");
|
|
82
|
+
}
|
|
83
|
+
function handleKeyUp(ev) {
|
|
84
|
+
if (ev.key === "Enter" && !ev.shiftKey) {
|
|
85
|
+
ev.preventDefault();
|
|
86
|
+
handleSend();
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
return /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsxs("div", {
|
|
90
|
+
className: style_default.ChatMessages,
|
|
91
|
+
ref: messageListRef,
|
|
92
|
+
children: [
|
|
93
|
+
messages.map((message) => /* @__PURE__ */ jsx("div", {
|
|
94
|
+
className: style_default.ChatMessage,
|
|
95
|
+
"data-stldocs-chat-message": message.role,
|
|
96
|
+
children: /* @__PURE__ */ jsx(RenderMessage, { message })
|
|
97
|
+
}, message.id)),
|
|
98
|
+
status === "submitted" && /* @__PURE__ */ jsx("div", {
|
|
99
|
+
className: style_default.LoadingSpinner,
|
|
100
|
+
children: /* @__PURE__ */ jsx(LoaderCircleIcon, {})
|
|
101
|
+
}),
|
|
102
|
+
["submitted", "streaming"].includes(status) && /* @__PURE__ */ jsx("div", { style: { height: "800px" } })
|
|
103
|
+
]
|
|
104
|
+
}), /* @__PURE__ */ jsxs("div", {
|
|
105
|
+
className: style_default.ChatInput,
|
|
106
|
+
children: [/* @__PURE__ */ jsx("textarea", {
|
|
107
|
+
value: input,
|
|
108
|
+
placeholder: "Ask a question",
|
|
109
|
+
onKeyUp: handleKeyUp,
|
|
110
|
+
onChange: (ev) => setInput(ev.target.value),
|
|
111
|
+
autoFocus: true
|
|
112
|
+
}), /* @__PURE__ */ jsxs("div", {
|
|
113
|
+
className: style_default.ChatInputButtons,
|
|
114
|
+
children: [status === "submitted" ? /* @__PURE__ */ jsx("button", {
|
|
115
|
+
onClick: stop,
|
|
116
|
+
children: /* @__PURE__ */ jsx(SquareIcon, {})
|
|
117
|
+
}) : /* @__PURE__ */ jsx("button", {
|
|
118
|
+
onClick: handleSend,
|
|
119
|
+
disabled: input.length < 1,
|
|
120
|
+
children: /* @__PURE__ */ jsx(ArrowUpIcon, {})
|
|
121
|
+
}), /* @__PURE__ */ jsx("button", {
|
|
122
|
+
onClick: () => setMessages([]),
|
|
123
|
+
children: /* @__PURE__ */ jsx(TrashIcon, {})
|
|
124
|
+
})]
|
|
125
|
+
})]
|
|
126
|
+
})] });
|
|
75
127
|
}
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
128
|
+
function ChatModal({ id, open: isOpen }) {
|
|
129
|
+
const [open, setOpen] = React$1.useState(isOpen);
|
|
130
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
131
|
+
id,
|
|
132
|
+
onToggle: (ev) => setOpen(ev.newState === "open"),
|
|
133
|
+
className: style_default.SearchModal,
|
|
134
|
+
popover: "auto",
|
|
135
|
+
"data-stldocs-modal-open": open,
|
|
136
|
+
children: [/* @__PURE__ */ jsxs("div", {
|
|
137
|
+
className: style_default.ChatHeader,
|
|
138
|
+
children: [/* @__PURE__ */ jsx(BotMessageSquareIcon, {}), /* @__PURE__ */ jsx("h5", { children: "Docs Assistant" })]
|
|
139
|
+
}), open && /* @__PURE__ */ jsx(Chat, {})]
|
|
140
|
+
});
|
|
79
141
|
}
|
|
80
|
-
|
|
142
|
+
|
|
143
|
+
//#endregion
|
|
144
|
+
export { Chat, ChatModal };
|
|
@@ -1,17 +1,2 @@
|
|
|
1
|
-
import
|
|
2
|
-
export
|
|
3
|
-
export declare const DropdownTrigger: ({ children, withChevron, className, isIcon, ...rest }: {
|
|
4
|
-
children: React.ReactNode;
|
|
5
|
-
withChevron?: boolean;
|
|
6
|
-
isIcon?: boolean;
|
|
7
|
-
} & (React.HTMLProps<HTMLButtonElement> & {
|
|
8
|
-
type?: "submit" | "reset" | "button";
|
|
9
|
-
})) => import("react/jsx-runtime").JSX.Element;
|
|
10
|
-
export declare const DropdownMenu: ({ position, className, children, ...rest }: {
|
|
11
|
-
position?: "below";
|
|
12
|
-
} & React.HTMLProps<HTMLUListElement>) => import("react/jsx-runtime").JSX.Element;
|
|
13
|
-
export declare const DropdownItem: ({ children, className, value, selected, href, }: React.HTMLProps<HTMLLIElement> & {
|
|
14
|
-
value?: string;
|
|
15
|
-
selected?: boolean;
|
|
16
|
-
href?: string;
|
|
17
|
-
}) => import("react/jsx-runtime").JSX.Element;
|
|
1
|
+
import { i as DropdownTrigger, n as DropdownItem, r as DropdownMenu, t as Dropdown } from "../dropdown-B7VyGMOw.js";
|
|
2
|
+
export { Dropdown, DropdownItem, DropdownMenu, DropdownTrigger };
|
|
@@ -1,18 +1,4 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
export const Dropdown = ({ className, children, ...rest }) => {
|
|
6
|
-
return (_jsx("div", { ...rest, className: `${style.Dropdown} ${className ?? ''}`, children: children }));
|
|
7
|
-
};
|
|
8
|
-
export const DropdownTrigger = ({ children, withChevron, className, isIcon, ...rest }) => {
|
|
9
|
-
return (_jsxs("button", { className: `${style.Button} ${style.ButtonSecondary} ${style.DropdownTrigger} ${isIcon ? style.ButtonIcon : ''} ${className ?? ''}`, "aria-haspopup": "listbox", ...rest, children: [_jsx("div", { className: style.DropdownTriggerContent, children: children }), withChevron && (_jsx("span", { className: style.DropdownChevron, children: _jsx(ChevronsUpDown, { size: 16 }) }))] }));
|
|
10
|
-
};
|
|
11
|
-
export const DropdownMenu = ({ position, className, children, ...rest }) => {
|
|
12
|
-
return (_jsx("ul", { className: `${style.DropdownMenu} ${position ?? ''} ${className ?? ''}`, ...rest, children: children }));
|
|
13
|
-
};
|
|
14
|
-
export const DropdownItem = ({ children, className, value, selected, href, }) => {
|
|
15
|
-
const inner = (_jsxs(_Fragment, { children: [children, _jsx("svg", { xmlns: "http://www.w3.org/2000/svg", width: "24", height: "24", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", className: "lucide lucide-check-icon lucide-check", children: _jsx("path", { d: "M20 6 9 17l-5-5" }) })] }));
|
|
16
|
-
return (_jsx("li", { className: clsx(style.DropdownItem, className, selected && 'selected', href && style.DropdownItemLink), role: "option", "data-dropdown-value": value, children: href ? _jsx("a", { href: href, children: inner }) : inner }));
|
|
17
|
-
};
|
|
18
|
-
//# sourceMappingURL=dropdown.js.map
|
|
1
|
+
import "../style-rYbbxIR_.js";
|
|
2
|
+
import { i as DropdownTrigger, n as DropdownItem, r as DropdownMenu, t as Dropdown } from "../dropdown-DtgAi6lb.js";
|
|
3
|
+
|
|
4
|
+
export { Dropdown, DropdownItem, DropdownMenu, DropdownTrigger };
|
|
@@ -1,27 +1,50 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
}):
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
1
|
+
import * as react_jsx_runtime79 from "react/jsx-runtime";
|
|
2
|
+
|
|
3
|
+
//#region src/components/icons.d.ts
|
|
4
|
+
declare function GoIcon({
|
|
5
|
+
className
|
|
6
|
+
}: {
|
|
7
|
+
className?: string;
|
|
8
|
+
}): react_jsx_runtime79.JSX.Element;
|
|
9
|
+
declare function JavaIcon({
|
|
10
|
+
className
|
|
11
|
+
}: {
|
|
12
|
+
className?: string;
|
|
13
|
+
}): react_jsx_runtime79.JSX.Element;
|
|
14
|
+
declare function KotlinIcon({
|
|
15
|
+
className
|
|
16
|
+
}: {
|
|
17
|
+
className?: string;
|
|
18
|
+
}): react_jsx_runtime79.JSX.Element;
|
|
19
|
+
declare function PythonIcon({
|
|
20
|
+
className
|
|
21
|
+
}: {
|
|
22
|
+
className?: string;
|
|
23
|
+
}): react_jsx_runtime79.JSX.Element;
|
|
24
|
+
declare function RubyIcon({
|
|
25
|
+
className
|
|
26
|
+
}: {
|
|
27
|
+
className?: string;
|
|
28
|
+
}): react_jsx_runtime79.JSX.Element;
|
|
29
|
+
declare function TerraformIcon({
|
|
30
|
+
className
|
|
31
|
+
}: {
|
|
32
|
+
className?: string;
|
|
33
|
+
}): react_jsx_runtime79.JSX.Element;
|
|
34
|
+
declare function TypescriptIcon({
|
|
35
|
+
className
|
|
36
|
+
}: {
|
|
37
|
+
className?: string;
|
|
38
|
+
}): react_jsx_runtime79.JSX.Element;
|
|
39
|
+
declare function CurlIcon({
|
|
40
|
+
className
|
|
41
|
+
}: {
|
|
42
|
+
className?: string;
|
|
43
|
+
}): react_jsx_runtime79.JSX.Element;
|
|
44
|
+
declare function PowershellIcon({
|
|
45
|
+
className
|
|
46
|
+
}: {
|
|
47
|
+
className?: string;
|
|
48
|
+
}): react_jsx_runtime79.JSX.Element;
|
|
49
|
+
//#endregion
|
|
50
|
+
export { CurlIcon, GoIcon, JavaIcon, KotlinIcon, PowershellIcon, PythonIcon, RubyIcon, TerraformIcon, TypescriptIcon };
|