@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.
Files changed (225) hide show
  1. package/dist/breadcrumbs-Z-hEqjcp.d.ts +19 -0
  2. package/dist/chunk-Bp6m_JJh.js +13 -0
  3. package/dist/component-generics-DzI21jRn.js +35 -0
  4. package/dist/component-generics-q5Dqiu2D.d.ts +30 -0
  5. package/dist/components/breadcrumbs.d.ts +2 -11
  6. package/dist/components/breadcrumbs.js +16 -52
  7. package/dist/components/chat.d.ts +13 -5
  8. package/dist/components/chat.js +138 -74
  9. package/dist/components/dropdown.d.ts +2 -17
  10. package/dist/components/dropdown.js +4 -18
  11. package/dist/components/icons.d.ts +50 -27
  12. package/dist/components/icons.js +3 -34
  13. package/dist/components/index.d.ts +12 -9
  14. package/dist/components/index.js +16 -10
  15. package/dist/components/method.d.ts +2 -41
  16. package/dist/components/method.js +16 -44
  17. package/dist/components/overview.d.ts +2 -21
  18. package/dist/components/overview.js +16 -49
  19. package/dist/components/primitives.d.ts +2 -60
  20. package/dist/components/primitives.js +16 -117
  21. package/dist/components/properties.d.ts +2 -24
  22. package/dist/components/properties.js +16 -24
  23. package/dist/components/scripts/dropdown.d.ts +11 -4
  24. package/dist/components/scripts/dropdown.js +49 -63
  25. package/dist/components/sdk.d.ts +3 -78
  26. package/dist/components/sdk.js +16 -153
  27. package/dist/components/sidebar.d.ts +2 -22
  28. package/dist/components/sidebar.js +16 -30
  29. package/dist/components/snippets.d.ts +4 -28
  30. package/dist/components/snippets.js +16 -76
  31. package/dist/contexts/component-generics.d.ts +2 -25
  32. package/dist/contexts/component-generics.js +3 -24
  33. package/dist/contexts/component-types.d.ts +18 -4
  34. package/dist/contexts/component-types.js +1 -2
  35. package/dist/contexts/component.d.ts +31 -14
  36. package/dist/contexts/component.js +16 -14
  37. package/dist/contexts/docs.d.ts +2 -34
  38. package/dist/contexts/docs.js +3 -43
  39. package/dist/contexts/index.d.ts +20 -7
  40. package/dist/contexts/index.js +16 -15
  41. package/dist/contexts/markdown.d.ts +2 -13
  42. package/dist/contexts/markdown.js +4 -29
  43. package/dist/contexts/navigation.d.ts +3 -19
  44. package/dist/contexts/navigation.js +3 -14
  45. package/dist/contexts/search.d.ts +4 -13
  46. package/dist/contexts/search.js +16 -15
  47. package/dist/contexts/use-components.d.ts +16 -1
  48. package/dist/contexts/use-components.js +4 -3
  49. package/dist/contexts-DRxRO-xO.js +3747 -0
  50. package/dist/docs-Dh8kE1va.js +50 -0
  51. package/dist/docs-EUy-wfbA.d.ts +43 -0
  52. package/dist/dropdown-B7VyGMOw.d.ts +43 -0
  53. package/dist/dropdown-DtgAi6lb.js +62 -0
  54. package/dist/icons-DdKM-01E.js +753 -0
  55. package/dist/index-AicgPYKB.d.ts +239 -0
  56. package/dist/index-BhwLhiWk.d.ts +14 -0
  57. package/dist/index-YnpUtXLB.d.ts +16 -0
  58. package/dist/index.d.ts +22 -6
  59. package/dist/index.js +16 -7
  60. package/dist/languages/go.d.ts +13 -21
  61. package/dist/languages/go.js +16 -116
  62. package/dist/languages/http.d.ts +13 -25
  63. package/dist/languages/http.js +16 -130
  64. package/dist/languages/index.d.ts +13 -37
  65. package/dist/languages/index.js +16 -10
  66. package/dist/languages/java.d.ts +13 -23
  67. package/dist/languages/java.js +16 -120
  68. package/dist/languages/python.d.ts +13 -22
  69. package/dist/languages/python.js +16 -104
  70. package/dist/languages/ruby.d.ts +13 -22
  71. package/dist/languages/ruby.js +16 -125
  72. package/dist/languages/typescript.d.ts +13 -22
  73. package/dist/languages/typescript.js +16 -134
  74. package/dist/markdown/index.d.ts +11 -6
  75. package/dist/markdown/index.js +16 -80
  76. package/dist/markdown/md.d.ts +15 -11
  77. package/dist/markdown/md.js +3 -34
  78. package/dist/markdown/utils.d.ts +4 -17
  79. package/dist/markdown/utils.js +3 -30
  80. package/dist/markdown-BXfX1D7C.js +42 -0
  81. package/dist/markdown-nFyAEX_K.d.ts +22 -0
  82. package/dist/md-Dg8aOyMA.js +41 -0
  83. package/dist/method-DpsVuzZW.d.ts +71 -0
  84. package/dist/navigation-aoYZ_tl4.js +24 -0
  85. package/dist/navigation-nyXBY-75.d.ts +29 -0
  86. package/dist/overview-C8e-6jGr.d.ts +38 -0
  87. package/dist/pagefind-ChrPfuVv.js +15 -0
  88. package/dist/primitives-DWz23_Ub.d.ts +99 -0
  89. package/dist/properties-CF71V58d.d.ts +46 -0
  90. package/dist/routing-DQjbRxdJ.js +189 -0
  91. package/dist/routing-qc0V00-j.d.ts +51 -0
  92. package/dist/routing.d.ts +2 -44
  93. package/dist/routing.js +3 -169
  94. package/dist/sdk-Zg3Rggk3.d.ts +118 -0
  95. package/dist/search/index.d.ts +26 -1
  96. package/dist/search/index.js +332 -2
  97. package/dist/search/providers/algolia.d.ts +22 -7
  98. package/dist/search/providers/algolia.js +16 -64
  99. package/dist/search/providers/fuse.d.ts +16 -9
  100. package/dist/search/providers/fuse.js +29 -12
  101. package/dist/search/providers/pagefind.d.ts +7 -2
  102. package/dist/search/providers/pagefind.js +3 -19
  103. package/dist/search/providers/walker.d.ts +8 -5
  104. package/dist/search/providers/walker.js +28 -19
  105. package/dist/search/types.d.ts +3 -79
  106. package/dist/search/types.js +3 -24
  107. package/dist/search-B6loAGmB.d.ts +21 -0
  108. package/dist/sidebar-C8KirYjg.d.ts +35 -0
  109. package/dist/snippets-EUzM4fRO.d.ts +45 -0
  110. package/dist/style-pN9hCoec.d.ts +181 -0
  111. package/dist/style-rYbbxIR_.js +182 -0
  112. package/dist/style.d.ts +2 -179
  113. package/dist/style.js +3 -179
  114. package/dist/styles/main.css +740 -746
  115. package/dist/styles/main.js +1 -0
  116. package/dist/styles/primitives.css +436 -428
  117. package/dist/styles/primitives.js +1 -0
  118. package/dist/styles/resets.css +34 -41
  119. package/dist/styles/resets.js +1 -0
  120. package/dist/styles/search.css +248 -248
  121. package/dist/styles/search.js +1 -0
  122. package/dist/styles/sidebar.css +59 -60
  123. package/dist/styles/sidebar.js +1 -0
  124. package/dist/styles/snippets.css +87 -88
  125. package/dist/styles/snippets.js +1 -0
  126. package/dist/styles/variables.css +86 -89
  127. package/dist/styles/variables.js +1 -0
  128. package/dist/types-CTBDtD34.d.ts +82 -0
  129. package/dist/types-DFN4M1Sp.js +34 -0
  130. package/dist/use-components-D9E85p5x.js +7 -0
  131. package/dist/utils-BHwvUDKn.js +30 -0
  132. package/dist/utils-CJfFBNgT.js +32 -0
  133. package/dist/utils-DQhEbvUC.d.ts +20 -0
  134. package/dist/utils-nDazhti8.d.ts +11 -0
  135. package/dist/utils.d.ts +2 -7
  136. package/dist/utils.js +4 -27
  137. package/package.json +2 -2
  138. package/dist/components/breadcrumbs.js.map +0 -1
  139. package/dist/components/chat.js.map +0 -1
  140. package/dist/components/dropdown.js.map +0 -1
  141. package/dist/components/icons.js.map +0 -1
  142. package/dist/components/index.js.map +0 -1
  143. package/dist/components/method.js.map +0 -1
  144. package/dist/components/overview.js.map +0 -1
  145. package/dist/components/primitives.js.map +0 -1
  146. package/dist/components/properties.js.map +0 -1
  147. package/dist/components/scripts/dropdown.js.map +0 -1
  148. package/dist/components/sdk.js.map +0 -1
  149. package/dist/components/sidebar.js.map +0 -1
  150. package/dist/components/snippets.js.map +0 -1
  151. package/dist/contexts/component-generics.js.map +0 -1
  152. package/dist/contexts/component-types.js.map +0 -1
  153. package/dist/contexts/component.js.map +0 -1
  154. package/dist/contexts/docs.js.map +0 -1
  155. package/dist/contexts/index.js.map +0 -1
  156. package/dist/contexts/markdown.js.map +0 -1
  157. package/dist/contexts/navigation.js.map +0 -1
  158. package/dist/contexts/search.js.map +0 -1
  159. package/dist/contexts/use-components.js.map +0 -1
  160. package/dist/index.js.map +0 -1
  161. package/dist/languages/go.js.map +0 -1
  162. package/dist/languages/http.js.map +0 -1
  163. package/dist/languages/index.js.map +0 -1
  164. package/dist/languages/java.js.map +0 -1
  165. package/dist/languages/python.js.map +0 -1
  166. package/dist/languages/ruby.js.map +0 -1
  167. package/dist/languages/typescript.js.map +0 -1
  168. package/dist/markdown/index.js.map +0 -1
  169. package/dist/markdown/md.js.map +0 -1
  170. package/dist/markdown/utils.js.map +0 -1
  171. package/dist/mcp.js +0 -16105
  172. package/dist/routing.js.map +0 -1
  173. package/dist/search/form.d.ts +0 -13
  174. package/dist/search/form.js +0 -55
  175. package/dist/search/form.js.map +0 -1
  176. package/dist/search/index.js.map +0 -1
  177. package/dist/search/indexer.d.ts +0 -31
  178. package/dist/search/indexer.js +0 -212
  179. package/dist/search/indexer.js.map +0 -1
  180. package/dist/search/mcp.d.ts +0 -8
  181. package/dist/search/mcp.js +0 -43
  182. package/dist/search/mcp.js.map +0 -1
  183. package/dist/search/printer.d.ts +0 -6
  184. package/dist/search/printer.js +0 -43
  185. package/dist/search/printer.js.map +0 -1
  186. package/dist/search/providers/algolia.js.map +0 -1
  187. package/dist/search/providers/fuse.js.map +0 -1
  188. package/dist/search/providers/pagefind.js.map +0 -1
  189. package/dist/search/providers/walker.js.map +0 -1
  190. package/dist/search/results.d.ts +0 -21
  191. package/dist/search/results.js +0 -58
  192. package/dist/search/results.js.map +0 -1
  193. package/dist/search/state.d.ts +0 -29
  194. package/dist/search/state.js +0 -38
  195. package/dist/search/state.js.map +0 -1
  196. package/dist/search/types.js.map +0 -1
  197. package/dist/style.js.map +0 -1
  198. package/dist/types/sdkjson.d.ts +0 -1
  199. package/dist/types/sdkjson.js +0 -2
  200. package/dist/types/sdkjson.js.map +0 -1
  201. package/dist/types/stainless-alias/lib/json-spec-v2/GoAST.d.ts +0 -120
  202. package/dist/types/stainless-alias/lib/json-spec-v2/GoAST.js +0 -2
  203. package/dist/types/stainless-alias/lib/json-spec-v2/GoAST.js.map +0 -1
  204. package/dist/types/stainless-alias/lib/json-spec-v2/HttpAST.d.ts +0 -100
  205. package/dist/types/stainless-alias/lib/json-spec-v2/HttpAST.js +0 -3
  206. package/dist/types/stainless-alias/lib/json-spec-v2/HttpAST.js.map +0 -1
  207. package/dist/types/stainless-alias/lib/json-spec-v2/JavaAST.d.ts +0 -87
  208. package/dist/types/stainless-alias/lib/json-spec-v2/JavaAST.js +0 -2
  209. package/dist/types/stainless-alias/lib/json-spec-v2/JavaAST.js.map +0 -1
  210. package/dist/types/stainless-alias/lib/json-spec-v2/PythonAST.d.ts +0 -110
  211. package/dist/types/stainless-alias/lib/json-spec-v2/PythonAST.js +0 -3
  212. package/dist/types/stainless-alias/lib/json-spec-v2/PythonAST.js.map +0 -1
  213. package/dist/types/stainless-alias/lib/json-spec-v2/RubyAST.d.ts +0 -122
  214. package/dist/types/stainless-alias/lib/json-spec-v2/RubyAST.js +0 -2
  215. package/dist/types/stainless-alias/lib/json-spec-v2/RubyAST.js.map +0 -1
  216. package/dist/types/stainless-alias/lib/json-spec-v2/TSAST.d.ts +0 -146
  217. package/dist/types/stainless-alias/lib/json-spec-v2/TSAST.js +0 -3
  218. package/dist/types/stainless-alias/lib/json-spec-v2/TSAST.js.map +0 -1
  219. package/dist/types/stainless-alias/lib/json-spec-v2/TerraformAST.d.ts +0 -89
  220. package/dist/types/stainless-alias/lib/json-spec-v2/TerraformAST.js +0 -3
  221. package/dist/types/stainless-alias/lib/json-spec-v2/TerraformAST.js.map +0 -1
  222. package/dist/types/stainless-alias/lib/json-spec-v2/types.d.ts +0 -190
  223. package/dist/types/stainless-alias/lib/json-spec-v2/types.js +0 -105
  224. package/dist/types/stainless-alias/lib/json-spec-v2/types.js.map +0 -1
  225. 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 type { SDKJSON } from '../types/sdkjson';
2
- type BreadcrumbConfig = {
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 { jsx as _jsx } from "react/jsx-runtime";
2
- import { Languages } from '../routing';
3
- import { ChevronRight } from 'lucide-react';
4
- import style from '../style';
5
- import { Join } from './primitives';
6
- function generateApiBreadcrumbs(fullPath, spec, basePath) {
7
- // Normalize paths. Mostly for basePath since it's configurable and may have trailing slashes
8
- const cleanBasePath = basePath.replace(/\/+$/, '');
9
- const cleanPath = fullPath.replace(/\/+$/, '');
10
- if (!cleanPath.startsWith(cleanBasePath))
11
- return null;
12
- // Slice off the basePath
13
- const rest = cleanPath.slice(cleanBasePath.length).split('/').filter(Boolean);
14
- const breadcrumbs = [];
15
- let href = cleanBasePath;
16
- let i = 0;
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
- export declare function Chat(): import("react/jsx-runtime").JSX.Element;
2
- export type ChatModalProps = {
3
- id?: string;
4
- open?: boolean;
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
- export declare function ChatModal({ id, open: isOpen }: ChatModalProps): import("react/jsx-runtime").JSX.Element;
9
+ declare function ChatModal({
10
+ id,
11
+ open: isOpen
12
+ }: ChatModalProps): react_jsx_runtime65.JSX.Element;
13
+ //#endregion
14
+ export { Chat, ChatModal, ChatModalProps };
@@ -1,80 +1,144 @@
1
- import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
- import * as React from 'react';
3
- import { useChat } from 'ai/react';
4
- import { ArrowUpIcon, BotMessageSquareIcon, LoaderCircleIcon, SquareIcon, TrashIcon } from 'lucide-react';
5
- import { useLanguage, useSearchContext } from '../contexts';
6
- import { Markdown } from './primitives';
7
- import style from '../style';
8
- const BASEURL = 'https://askai.algolia.com';
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
- const headers = {
11
- 'X-Algolia-Application-Id': appId,
12
- 'X-Algolia-API-Key': searchKey,
13
- 'X-Algolia-Index-Name': `${indexName}-chat`,
14
- 'X-Algolia-Assistant-Id': assistant,
15
- };
16
- return async (input, init) => {
17
- const response = await fetch(`${BASEURL}/chat/token`, { method: 'POST', headers });
18
- const data = await response.json();
19
- return fetch(input, {
20
- ...init,
21
- headers: {
22
- ...init.headers,
23
- ...headers,
24
- Authorization: `TOKEN ${data['token']}`,
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
- return message.parts
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
- export function Chat() {
35
- const language = useLanguage();
36
- const { settings } = useSearchContext();
37
- const messageListRef = React.useRef(null);
38
- const { messages, setMessages, status, input, setInput, append, stop } = useChat({
39
- body: { searchParameters: { filters: `language:${language ?? 'http'}` } },
40
- sendExtraMessageFields: true,
41
- fetch: buildFetch(settings),
42
- api: `${BASEURL}/chat`,
43
- });
44
- React.useEffect(() => {
45
- const content = sessionStorage.getItem('stldocs-chat-messages');
46
- if (!content)
47
- return;
48
- setMessages(JSON.parse(content));
49
- setTimeout(() => {
50
- if (!messageListRef.current)
51
- return;
52
- messageListRef.current.scrollTop = messageListRef.current.scrollHeight;
53
- }, 10);
54
- }, [setMessages]);
55
- React.useEffect(() => {
56
- if (status !== 'submitted')
57
- return;
58
- const messageElements = messageListRef?.current.querySelectorAll('[data-stldocs-chat-message]');
59
- [...messageElements].at(-1)?.scrollIntoView({ behavior: 'smooth', block: 'start' });
60
- }, [status]);
61
- React.useEffect(() => {
62
- sessionStorage.setItem('stldocs-chat-messages', JSON.stringify(messages));
63
- }, [messages]);
64
- function handleSend() {
65
- append({ role: 'user', content: input });
66
- setInput('');
67
- }
68
- function handleKeyUp(ev) {
69
- if (ev.key === 'Enter' && !ev.shiftKey) {
70
- ev.preventDefault();
71
- handleSend();
72
- }
73
- }
74
- return (_jsxs(_Fragment, { children: [_jsxs("div", { className: style.ChatMessages, ref: messageListRef, children: [messages.map((message) => (_jsx("div", { className: style.ChatMessage, "data-stldocs-chat-message": message.role, children: _jsx(RenderMessage, { message: message }) }, message.id))), status === 'submitted' && (_jsx("div", { className: style.LoadingSpinner, children: _jsx(LoaderCircleIcon, {}) })), ['submitted', 'streaming'].includes(status) && _jsx("div", { style: { height: '800px' } })] }), _jsxs("div", { className: style.ChatInput, children: [_jsx("textarea", { value: input, placeholder: "Ask a question", onKeyUp: handleKeyUp, onChange: (ev) => setInput(ev.target.value), autoFocus: true }), _jsxs("div", { className: style.ChatInputButtons, children: [status === 'submitted' ? (_jsx("button", { onClick: stop, children: _jsx(SquareIcon, {}) })) : (_jsx("button", { onClick: handleSend, disabled: input.length < 1, children: _jsx(ArrowUpIcon, {}) })), _jsx("button", { onClick: () => setMessages([]), children: _jsx(TrashIcon, {}) })] })] })] }));
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
- export function ChatModal({ id, open: isOpen }) {
77
- const [open, setOpen] = React.useState(isOpen);
78
- return (_jsxs("div", { id: id, onToggle: (ev) => setOpen(ev.newState === 'open'), className: style.SearchModal, popover: "auto", "data-stldocs-modal-open": open, children: [_jsxs("div", { className: style.ChatHeader, children: [_jsx(BotMessageSquareIcon, {}), _jsx("h5", { children: "Docs Assistant" })] }), open && _jsx(Chat, {})] }));
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
- //# sourceMappingURL=chat.js.map
142
+
143
+ //#endregion
144
+ export { Chat, ChatModal };
@@ -1,17 +1,2 @@
1
- import * as React from 'react';
2
- export declare const Dropdown: ({ className, children, ...rest }: React.HTMLProps<HTMLDivElement>) => import("react/jsx-runtime").JSX.Element;
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 { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
- import style from '../style';
3
- import { ChevronsUpDown } from 'lucide-react';
4
- import clsx from 'clsx';
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
- export declare function GoIcon({ className }: {
2
- className?: string;
3
- }): import("react/jsx-runtime").JSX.Element;
4
- export declare function JavaIcon({ className }: {
5
- className?: string;
6
- }): import("react/jsx-runtime").JSX.Element;
7
- export declare function KotlinIcon({ className }: {
8
- className?: string;
9
- }): import("react/jsx-runtime").JSX.Element;
10
- export declare function PythonIcon({ className }: {
11
- className?: string;
12
- }): import("react/jsx-runtime").JSX.Element;
13
- export declare function RubyIcon({ className }: {
14
- className?: string;
15
- }): import("react/jsx-runtime").JSX.Element;
16
- export declare function TerraformIcon({ className }: {
17
- className?: string;
18
- }): import("react/jsx-runtime").JSX.Element;
19
- export declare function TypescriptIcon({ className }: {
20
- className?: string;
21
- }): import("react/jsx-runtime").JSX.Element;
22
- export declare function CurlIcon({ className }: {
23
- className?: string;
24
- }): import("react/jsx-runtime").JSX.Element;
25
- export declare function PowershellIcon({ className }: {
26
- className?: string;
27
- }): import("react/jsx-runtime").JSX.Element;
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 };