@stainless-api/docs-ui 0.1.0-beta.9 → 0.1.0-beta.91

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 (162) hide show
  1. package/dist/breadcrumbs-BaNU4WsC.d.ts +25 -0
  2. package/dist/chunk-pbuEa-1d.js +13 -0
  3. package/dist/component-generics-D9XaPlr8.d.ts +30 -0
  4. package/dist/component-generics-DYxBWv1v.js +42 -0
  5. package/dist/components/MaskedInput.d.ts +14 -0
  6. package/dist/components/MaskedInput.js +74 -0
  7. package/dist/components/breadcrumbs.d.ts +2 -0
  8. package/dist/components/breadcrumbs.js +61 -0
  9. package/dist/components/icons.d.ts +72 -0
  10. package/dist/components/icons.js +953 -0
  11. package/dist/components/index.d.ts +10 -0
  12. package/dist/components/index.js +72 -0
  13. package/dist/components/method.d.ts +2 -0
  14. package/dist/components/method.js +94 -0
  15. package/dist/components/overview.d.ts +2 -0
  16. package/dist/components/overview.js +139 -0
  17. package/dist/components/primitives.d.ts +2 -0
  18. package/dist/components/primitives.js +250 -0
  19. package/dist/components/properties.d.ts +2 -0
  20. package/dist/components/properties.js +143 -0
  21. package/dist/components/sdk-sidebar.d.ts +2 -0
  22. package/dist/components/sdk-sidebar.js +49 -0
  23. package/dist/components/sdk.d.ts +2 -0
  24. package/dist/components/sdk.js +487 -0
  25. package/dist/components/snippets.d.ts +2 -0
  26. package/dist/components/snippets.js +183 -0
  27. package/dist/components/stl-sidebar.d.ts +2 -0
  28. package/dist/components/stl-sidebar.js +111 -0
  29. package/dist/contexts/component-generics.d.ts +2 -0
  30. package/dist/contexts/component-generics.js +2 -0
  31. package/dist/contexts/component-types.d.ts +7 -0
  32. package/dist/contexts/component-types.js +0 -0
  33. package/dist/contexts/component.d.ts +20 -0
  34. package/dist/contexts/component.js +21 -0
  35. package/dist/contexts/docs.d.ts +2 -0
  36. package/dist/contexts/docs.js +89 -0
  37. package/dist/contexts/index.d.ts +6 -0
  38. package/dist/contexts/index.js +43 -0
  39. package/dist/contexts/markdown.d.ts +2 -0
  40. package/dist/contexts/markdown.js +62 -0
  41. package/dist/contexts/navigation.d.ts +2 -0
  42. package/dist/contexts/navigation.js +21 -0
  43. package/dist/contexts/use-components.d.ts +6 -0
  44. package/dist/contexts/use-components.js +5 -0
  45. package/dist/docs-D0qzNoXq.d.ts +62 -0
  46. package/dist/index-DFr9Mesr.d.ts +1776 -0
  47. package/dist/index-Dt9uPKZP.d.ts +464 -0
  48. package/dist/index.d.ts +5 -0
  49. package/dist/index.js +7 -7542
  50. package/dist/languages/cli.d.ts +2 -0
  51. package/dist/languages/cli.js +164 -0
  52. package/dist/languages/csharp.d.ts +2 -0
  53. package/dist/languages/csharp.js +281 -0
  54. package/dist/languages/go.d.ts +2 -0
  55. package/dist/languages/go.js +301 -0
  56. package/dist/languages/http.d.ts +2 -0
  57. package/dist/languages/http.js +381 -0
  58. package/dist/languages/index.d.ts +2 -0
  59. package/dist/languages/index.js +30 -0
  60. package/dist/languages/java.d.ts +2 -0
  61. package/dist/languages/java.js +401 -0
  62. package/dist/languages/php.d.ts +2 -0
  63. package/dist/languages/php.js +310 -0
  64. package/dist/languages/python.d.ts +2 -0
  65. package/dist/languages/python.js +267 -0
  66. package/dist/languages/ruby.d.ts +2 -0
  67. package/dist/languages/ruby.js +385 -0
  68. package/dist/languages/terraform.d.ts +2 -0
  69. package/dist/languages/terraform.js +258 -0
  70. package/dist/languages/typescript.d.ts +2 -0
  71. package/dist/languages/typescript.js +447 -0
  72. package/dist/markdown/index.d.ts +11 -0
  73. package/dist/markdown/index.js +86 -0
  74. package/dist/markdown/md.d.ts +15 -0
  75. package/dist/markdown/md.js +39 -0
  76. package/dist/markdown/printer.d.ts +13 -0
  77. package/dist/markdown/printer.js +73 -0
  78. package/dist/markdown/utils.d.ts +28 -0
  79. package/dist/markdown/utils.js +31 -0
  80. package/dist/markdown-B30HO-Vy.d.ts +33 -0
  81. package/dist/method-BKJnP-rW.d.ts +59 -0
  82. package/dist/navigation-DGl8lR6w.d.ts +29 -0
  83. package/dist/overview-iH1evPEF.d.ts +39 -0
  84. package/dist/primitives-BHt-BuLf.d.ts +107 -0
  85. package/dist/properties-CCbMRhSX.d.ts +54 -0
  86. package/dist/routing-yTSG7nWM.d.ts +61 -0
  87. package/dist/routing.d.ts +2 -0
  88. package/dist/routing.js +174 -150
  89. package/dist/sdk-BengV7mg.d.ts +128 -0
  90. package/dist/sdk-sidebar-CRqLm3YO.d.ts +15 -0
  91. package/dist/spec.d.ts +65 -0
  92. package/dist/spec.js +165 -0
  93. package/dist/stl-sidebar-Pra9uCYo.d.ts +58 -0
  94. package/dist/style.d.ts +178 -0
  95. package/dist/style.js +178 -0
  96. package/dist/styles/main.css +765 -755
  97. package/dist/styles/primitives.css +359 -442
  98. package/dist/styles/resets.css +25 -41
  99. package/dist/styles/search.css +187 -270
  100. package/dist/styles/sidebar.css +155 -69
  101. package/dist/styles/variables.css +23 -89
  102. package/dist/styles.css +3171 -0
  103. package/dist/utils.d.ts +20 -0
  104. package/dist/utils.js +52 -0
  105. package/package.json +75 -22
  106. package/dist/mcp.js +0 -16003
  107. package/dist/styles/snippets.css +0 -132
  108. package/src/components/breadcrumbs.tsx +0 -94
  109. package/src/components/chat.tsx +0 -154
  110. package/src/components/dropdown.tsx +0 -91
  111. package/src/components/icons.tsx +0 -584
  112. package/src/components/index.ts +0 -9
  113. package/src/components/method.tsx +0 -146
  114. package/src/components/overview.tsx +0 -160
  115. package/src/components/primitives.tsx +0 -284
  116. package/src/components/properties.tsx +0 -130
  117. package/src/components/scripts/dropdown.ts +0 -78
  118. package/src/components/sdk.tsx +0 -403
  119. package/src/components/sidebar.tsx +0 -99
  120. package/src/components/snippets.tsx +0 -180
  121. package/src/contexts/component-generics.tsx +0 -48
  122. package/src/contexts/component-types.tsx +0 -5
  123. package/src/contexts/component.tsx +0 -32
  124. package/src/contexts/docs.tsx +0 -75
  125. package/src/contexts/index.tsx +0 -17
  126. package/src/contexts/markdown.tsx +0 -43
  127. package/src/contexts/navigation.tsx +0 -44
  128. package/src/contexts/search.tsx +0 -28
  129. package/src/contexts/use-components.tsx +0 -4
  130. package/src/index.ts +0 -6
  131. package/src/languages/go.tsx +0 -281
  132. package/src/languages/http.tsx +0 -321
  133. package/src/languages/index.ts +0 -26
  134. package/src/languages/java.tsx +0 -358
  135. package/src/languages/python.tsx +0 -255
  136. package/src/languages/ruby.tsx +0 -320
  137. package/src/languages/typescript.tsx +0 -393
  138. package/src/markdown/index.ts +0 -107
  139. package/src/markdown/md.ts +0 -45
  140. package/src/markdown/utils.ts +0 -49
  141. package/src/routing.ts +0 -238
  142. package/src/search/form.tsx +0 -127
  143. package/src/search/index.tsx +0 -1
  144. package/src/search/indexer.ts +0 -246
  145. package/src/search/mcp.ts +0 -61
  146. package/src/search/printer.tsx +0 -86
  147. package/src/search/providers/algolia.ts +0 -88
  148. package/src/search/providers/fuse.ts +0 -19
  149. package/src/search/providers/pagefind.ts +0 -17
  150. package/src/search/providers/walker.ts +0 -30
  151. package/src/search/results.tsx +0 -182
  152. package/src/search/state.ts +0 -64
  153. package/src/search/types.ts +0 -116
  154. package/src/style.ts +0 -196
  155. package/src/styles/main.css +0 -986
  156. package/src/styles/primitives.css +0 -580
  157. package/src/styles/resets.css +0 -39
  158. package/src/styles/search.css +0 -341
  159. package/src/styles/sidebar.css +0 -85
  160. package/src/styles/snippets.css +0 -130
  161. package/src/styles/variables.css +0 -86
  162. package/src/utils.ts +0 -41
@@ -1,180 +0,0 @@
1
- import * as React from 'react';
2
- import { CheckIcon, CircleAlertIcon, CopyIcon, LucideIcon } from 'lucide-react';
3
- import { useDeclaration, useHighlight, useLanguage, useSnippet } from '../contexts';
4
- import { useComponents } from '../contexts/use-components';
5
- import style from '../style';
6
- import clsx from 'clsx';
7
- import type * as SDKJSON from '~/lib/json-spec-v2/types';
8
- import type { TransformRequestSnippetFn } from './sdk';
9
- import { Button } from '@stainless-api/ui-primitives';
10
-
11
- export type SnippetCodeProps = {
12
- content: string;
13
- signature?: string;
14
- language?: string;
15
- };
16
-
17
- export function SnippetCode({ content, language }: SnippetCodeProps) {
18
- const lang = useLanguage();
19
- const highlighted = useHighlight(content, language || lang);
20
-
21
- return (
22
- <div className={style.SnippetCode}>
23
- <pre className={style.SnippetCodeContent} data-stldocs-copy-content>
24
- <code
25
- className={(language as string) === 'json' ? 'snippet-json' : 'snippet'}
26
- dangerouslySetInnerHTML={{ __html: highlighted }}
27
- />
28
- </pre>
29
- </div>
30
- );
31
- }
32
-
33
- export type SnippetProps = {
34
- method: SDKJSON.Method;
35
- requestTitle?: React.ReactNode;
36
- transformRequestSnippet?: TransformRequestSnippetFn;
37
- };
38
-
39
- export type SnippetContainerProps = {
40
- children: React.ReactNode;
41
- signature?: string;
42
- };
43
-
44
- export function SnippetContainer({ children }: SnippetContainerProps) {
45
- return <div className={clsx(style.Snippet)}>{children}</div>;
46
- }
47
-
48
- export type SnippetRequestContainerProps = {
49
- children?: React.ReactNode;
50
- signature?: string;
51
- };
52
-
53
- export function SnippetRequestContainer({ children }: SnippetRequestContainerProps) {
54
- return <div>{children}</div>;
55
- }
56
-
57
- export function Snippet({ requestTitle, method, transformRequestSnippet }: SnippetProps) {
58
- const Docs = useComponents();
59
- const language = useLanguage();
60
- const [CopyButtonIcon, setCopyIcon] = React.useState<LucideIcon>(CopyIcon);
61
-
62
- let snippet = useSnippet(method.stainlessPath, null, language === 'http' ? 'curl' : 'default');
63
- const decl = useDeclaration(method.stainlessPath);
64
-
65
- const signature = 'qualified' in decl ? decl.qualified : undefined;
66
- const responses = method.exampleResponses;
67
-
68
- if (transformRequestSnippet) {
69
- snippet = transformRequestSnippet({ snippet, language });
70
- }
71
-
72
- async function handleCopy() {
73
- try {
74
- await navigator.clipboard.writeText(snippet);
75
- setCopyIcon(CheckIcon);
76
- } catch {
77
- setCopyIcon(CircleAlertIcon);
78
- }
79
-
80
- setTimeout(() => setCopyIcon(CopyIcon), 1000);
81
- }
82
-
83
- return (
84
- <Docs.SnippetContainer signature={signature}>
85
- {snippet && (
86
- <Docs.SnippetRequestContainer signature={signature}>
87
- <div className={style.SnippetRequest} data-stldocs-copy-parent>
88
- <div className={style.SnippetRequestTitle}>
89
- <div className={style.SnippetRequestTitleMethod}>
90
- <Docs.MethodRoute httpMethod={method.httpMethod} iconOnly />
91
- <h5>{method.summary}</h5>
92
- </div>
93
- <div className={style.SnippetRequestTitleContent}>{requestTitle}</div>
94
- <Button variant="ghost" data-stldocs-snippet-copy>
95
- <CopyButtonIcon size={16} className={style.Icon} onClick={handleCopy} />
96
- </Button>
97
- </div>
98
- <Docs.SnippetCode content={snippet} signature={signature} />
99
- </div>
100
- </Docs.SnippetRequestContainer>
101
- )}
102
- {responses && <Docs.SnippetResponse responses={responses} />}
103
- </Docs.SnippetContainer>
104
- );
105
- }
106
-
107
- export function SnippetResponse({ responses }: { responses: SDKJSON.Method['exampleResponses'] }) {
108
- const { SnippetCode } = useComponents();
109
-
110
- if (!responses) {
111
- return null;
112
- }
113
-
114
- const mappedResponses = Object.keys(responses)
115
- .map((key) => {
116
- // Get the first response type ie application/json or text/plain
117
- const responseType = Object.keys(responses[key])[0];
118
- const response = responses[key][responseType];
119
-
120
- const examples = response?.examples;
121
-
122
- if (!examples) return null;
123
-
124
- // Get the first example type, ie Example or html
125
- const exampleType = Object.keys(examples)[0];
126
- let value = examples[exampleType]?.value;
127
-
128
- if (!value) return null;
129
-
130
- if (responseType === 'application/json') {
131
- value = JSON.stringify(value, null, 2);
132
- }
133
-
134
- return {
135
- responseCode: key,
136
- content: value,
137
- };
138
- })
139
- .filter(Boolean);
140
-
141
- if (mappedResponses.length === 0) return null;
142
-
143
- return (
144
- <div className={style.SnippetMultiResponse}>
145
- <div className={clsx(style.Snippet)}>
146
- <div
147
- className={clsx(
148
- style.SnippetResponseTab,
149
- mappedResponses.length === 1 && style.SnippetResponseTabSingleReturn,
150
- )}
151
- >
152
- {mappedResponses.map(({ responseCode }, index) => (
153
- <button
154
- className={clsx(
155
- style.SnippetResponseTabItem,
156
- index === 0 && style.SnippetResponseTabItemActive,
157
- )}
158
- key={`snippet-response-tab-item-${responseCode}-${index}`}
159
- data-snippet-response-tab-id={`snippet-response-tab-${responseCode}-${index}`}
160
- disabled={mappedResponses.length === 1}
161
- >
162
- {responseCode} example
163
- </button>
164
- ))}
165
- </div>
166
- {mappedResponses.map(({ responseCode, content }, index) => {
167
- return (
168
- <div
169
- className={clsx(style.SnippetResponsePane, index === 0 && style.SnippetResponsePaneActive)}
170
- key={`snippet-response-${responseCode}-${index}`}
171
- data-snippet-response-pane-id={`snippet-response-tab-${responseCode}-${index}`}
172
- >
173
- <SnippetCode content={content} language="json" />
174
- </div>
175
- );
176
- })}
177
- </div>
178
- </div>
179
- );
180
- }
@@ -1,48 +0,0 @@
1
- // This file should never import from ../components or ../languages to avoid circular dependencies
2
-
3
- import * as React from 'react';
4
-
5
- type DeepPartialMap<L> = { [K in keyof L]?: Partial<L[K]> };
6
-
7
- export type ComponentsContextType<C, L> = {
8
- components: C;
9
- language: L;
10
- };
11
-
12
- const ComponentContext = React.createContext<ComponentsContextType<any, any> | null>(null);
13
- ComponentContext.displayName = 'ComponentContext';
14
-
15
- export function useComponents<C = unknown>() {
16
- const ctx = React.useContext(ComponentContext);
17
- if (!ctx) throw new Error('useComponents must be used within a ComponentContext.Provider');
18
- return ctx.components as C;
19
- }
20
-
21
- export function customizeComponents<C, L>(
22
- defaults: { components: C; language: L },
23
- overrides: { components?: Partial<C>; language?: DeepPartialMap<L> } = {},
24
- ): { components: C; language: L } {
25
- const mergedComponents = { ...defaults.components, ...(overrides.components ?? {}) } as C;
26
-
27
- const mergedLanguage = Object.keys(defaults.language as Record<string, unknown>).reduce(
28
- (acc, key) => {
29
- acc[key] = { ...(defaults.language as any)[key], ...(overrides.language?.[key] ?? {}) };
30
- return acc;
31
- },
32
- {} as any as L,
33
- );
34
-
35
- return { components: mergedComponents, language: mergedLanguage };
36
- }
37
-
38
- export function ComponentProvider<C, L>({
39
- value,
40
- children,
41
- }: {
42
- value: ComponentsContextType<C, L>;
43
- children: React.ReactNode;
44
- }) {
45
- return <ComponentContext.Provider value={value}>{children}</ComponentContext.Provider>;
46
- }
47
-
48
- export { ComponentContext };
@@ -1,5 +0,0 @@
1
- import type * as DefaultComponents from '../components';
2
- import type * as DefaultLanguage from '../languages';
3
-
4
- export type AppComponents = typeof DefaultComponents;
5
- export type AppLanguage = typeof DefaultLanguage;
@@ -1,32 +0,0 @@
1
- import React from 'react';
2
- import * as DefaultComponents from '../components';
3
- import * as DefaultLanguage from '../languages';
4
- import {
5
- ComponentProvider as GenericComponentProvider,
6
- customizeComponents,
7
- type ComponentsContextType,
8
- } from './component-generics';
9
-
10
- export type AppComponents = typeof DefaultComponents;
11
- export type AppLanguage = typeof DefaultLanguage;
12
-
13
- export const defaultContextValue: ComponentsContextType<AppComponents, AppLanguage> = {
14
- components: DefaultComponents,
15
- language: DefaultLanguage,
16
- };
17
-
18
- export function ComponentProvider({
19
- components,
20
- language,
21
- children,
22
- }: {
23
- components?: Partial<AppComponents>;
24
- language?: { [K in keyof AppLanguage]?: Partial<AppLanguage[K]> };
25
- children: React.ReactNode;
26
- }) {
27
- const value = React.useMemo(
28
- () => customizeComponents(defaultContextValue, { components, language }),
29
- [components, language],
30
- );
31
- return <GenericComponentProvider value={value}>{children}</GenericComponentProvider>;
32
- }
@@ -1,75 +0,0 @@
1
- import * as React from 'react';
2
- import type { Spec, SpecLanguage } from '~/lib/json-spec-v2/types';
3
-
4
- export type ContentPanelLayout = 'double-pane' | 'single-pane';
5
- export type PropertySettingsType = {
6
- types?: 'simple' | 'rich';
7
- includeModelProperties?: boolean;
8
- collapseDescription?: boolean;
9
- expandDepth?: number;
10
- };
11
-
12
- export type DocsContextType = {
13
- language: SpecLanguage;
14
- spec: Spec | null;
15
- settings?: {
16
- properties?: PropertySettingsType;
17
- contentPanelLayout?: ContentPanelLayout;
18
- virtualExpanders?: boolean;
19
- };
20
- };
21
-
22
- const DocsContextDefaults: DocsContextType = {
23
- settings: {},
24
- language: 'node',
25
- spec: null,
26
- };
27
-
28
- const DocsContext = React.createContext<DocsContextType>(DocsContextDefaults);
29
-
30
- export function useDocs() {
31
- return React.useContext(DocsContext);
32
- }
33
-
34
- export function useSpec() {
35
- return useDocs().spec;
36
- }
37
-
38
- export function useSettings() {
39
- return useDocs().settings;
40
- }
41
-
42
- export function useSnippet(stainlessPath: string, language?: SpecLanguage, variant?: string) {
43
- const snippetLanguage = [language ?? useLanguage(), variant ?? 'default'].join('.');
44
-
45
- return useSpec()?.snippets?.[snippetLanguage]?.[stainlessPath];
46
- }
47
-
48
- export function useDeclaration(stainlessPath: string, language?: SpecLanguage) {
49
- return useSpec()?.decls?.[language ?? useLanguage()]?.[stainlessPath];
50
- }
51
-
52
- export function useResource(name: string) {
53
- return useSpec()?.resources?.[name];
54
- }
55
-
56
- export function useLanguage() {
57
- return useDocs().language;
58
- }
59
-
60
- export function useContentPanelLayout() {
61
- return useDocs().settings?.contentPanelLayout ?? 'double-pane';
62
- }
63
-
64
- export type DocsProviderProps = DocsContextType & { children: React.ReactNode };
65
-
66
- export function DocsProvider({ spec, language, settings, children }: DocsProviderProps) {
67
- const value = {
68
- ...DocsContextDefaults,
69
- spec,
70
- settings: settings ?? DocsContextDefaults.settings,
71
- language: language ?? DocsContextDefaults.language,
72
- };
73
-
74
- return <DocsContext.Provider value={value}>{children}</DocsContext.Provider>;
75
- }
@@ -1,17 +0,0 @@
1
- import * as React from 'react';
2
- import { ComponentContext } from './component-generics';
3
- import { useLanguage } from './docs';
4
- import { LanguageComponentDefinition } from '../languages';
5
-
6
- // DO NOT re-export component contexts from here. Only export generics.
7
- export * from './navigation';
8
- export * from './markdown';
9
- export * from './component-generics';
10
- export * from './search';
11
- export * from './docs';
12
-
13
- export function useLanguageComponents() {
14
- const language = useLanguage();
15
- const context = React.useContext(ComponentContext);
16
- return context.language[language] as LanguageComponentDefinition;
17
- }
@@ -1,43 +0,0 @@
1
- import * as React from 'react';
2
- import { useLanguage } from './docs';
3
-
4
- const HighlightLanguageMappings = {
5
- node: 'typescript',
6
- http: 'bash',
7
- };
8
-
9
- export type MarkdownContext = {
10
- highlight?: (content: string, language?: string) => string | Promise<string>;
11
- render?: (content: string) => string;
12
- };
13
-
14
- export const MarkdownContext = React.createContext<MarkdownContext>({
15
- highlight: (content) => content,
16
- render: (content) => content,
17
- });
18
-
19
- export const useMarkdownContext = () => React.useContext(MarkdownContext);
20
-
21
- export function useRenderMarkdown(content?: string) {
22
- const { render } = React.useContext(MarkdownContext);
23
- return React.useMemo(() => (content ? render(content) : undefined), [content, render]);
24
- }
25
-
26
- export function useHighlight(content?: string, language?: string) {
27
- const { highlight } = React.useContext(MarkdownContext);
28
- const lang = language ?? useLanguage();
29
-
30
- return React.useMemo(() => {
31
- const highlightLanguage = HighlightLanguageMappings[lang] ?? lang;
32
- const rendered = highlight(content, highlightLanguage);
33
- return typeof rendered === 'string' ? rendered : React.use(rendered);
34
- }, [content, language, highlight]);
35
- }
36
-
37
- export type MarkdownProviderProps = MarkdownContext & {
38
- children: React.ReactNode;
39
- };
40
-
41
- export function MarkdownProvider({ render, highlight, children }: MarkdownProviderProps) {
42
- return <MarkdownContext.Provider value={{ render, highlight }}>{children}</MarkdownContext.Provider>;
43
- }
@@ -1,44 +0,0 @@
1
- import * as React from 'react';
2
- import { DocsLanguage } from '../routing';
3
-
4
- export type NavigationHandler = (
5
- ev: React.MouseEvent | null,
6
- opts: {
7
- href: string;
8
- language: DocsLanguage;
9
- stainlessPath: string;
10
- scroll: boolean;
11
- },
12
- ) => void;
13
-
14
- export type NavigationContextType = {
15
- basePath?: string;
16
- selectedPath?: string;
17
- navigationPath?: string[];
18
- onNavigate?: NavigationHandler;
19
- };
20
-
21
- const Defaults: NavigationContextType = {
22
- basePath: '/',
23
- };
24
-
25
- const NavigationContext = React.createContext<NavigationContextType>(Defaults);
26
-
27
- export function useNavigation() {
28
- return React.useContext(NavigationContext);
29
- }
30
-
31
- export type NavigationProviderProps = NavigationContextType & {
32
- children: React.ReactNode;
33
- };
34
-
35
- export function NavigationProvider({
36
- basePath,
37
- selectedPath,
38
- onNavigate,
39
- children,
40
- }: NavigationProviderProps) {
41
- const value = { ...Defaults, onNavigate, basePath, selectedPath };
42
-
43
- return <NavigationContext.Provider value={value}>{children}</NavigationContext.Provider>;
44
- }
@@ -1,28 +0,0 @@
1
- import * as React from 'react';
2
- import { search } from '../search/providers/algolia';
3
- import { SearchParams, SearchSettings } from '../search/types';
4
-
5
- export type SearchContextType = {
6
- settings: SearchSettings;
7
- onSelect?: (stainlessPath: string) => void;
8
- pageFind?: string;
9
- };
10
-
11
- const SearchContext = React.createContext<SearchContextType>(null);
12
-
13
- export function useSearchContext() {
14
- return React.useContext(SearchContext);
15
- }
16
-
17
- export function useSearch() {
18
- const { settings } = useSearchContext();
19
- return (params: SearchParams) => search({ settings, params });
20
- }
21
-
22
- export type SearchProviderProps = SearchContextType & {
23
- children: React.ReactNode;
24
- };
25
-
26
- export function SearchProvider({ children, ...props }: SearchProviderProps) {
27
- return <SearchContext value={props}>{children}</SearchContext>;
28
- }
@@ -1,4 +0,0 @@
1
- import { useComponents as base } from './component-generics';
2
- import type { AppComponents } from './component-types';
3
-
4
- export const useComponents = () => base<AppComponents>();
package/src/index.ts DELETED
@@ -1,6 +0,0 @@
1
- export * as contexts from './contexts';
2
- export * as components from './components';
3
- export * as languages from './languages';
4
- export * as routing from './routing';
5
- export * as utils from './utils';
6
- export { default as style } from './style';