@stainless-api/docs-ui 0.1.0-beta.29 → 0.1.0-beta.30

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 (194) hide show
  1. package/dist/{breadcrumbs-D5viAm7a.d.ts → breadcrumbs-wJ7A9MGt.d.ts} +2 -2
  2. package/dist/{component-generics-BnrVqdQj.d.ts → component-generics--y1IC_M-.d.ts} +2 -1
  3. package/dist/{component-generics-Df4EDvxk.js → component-generics-D3ybuN5r.js} +5 -1
  4. package/dist/components/breadcrumbs.d.ts +1 -1
  5. package/dist/components/breadcrumbs.js +13 -14
  6. package/dist/components/chat.d.ts +3 -3
  7. package/dist/components/chat.js +64 -50
  8. package/dist/components/icons.d.ts +10 -10
  9. package/dist/components/icons.js +1 -1
  10. package/dist/components/index.d.ts +11 -12
  11. package/dist/components/index.js +14 -15
  12. package/dist/components/method.d.ts +1 -1
  13. package/dist/components/method.js +13 -14
  14. package/dist/components/overview.d.ts +1 -1
  15. package/dist/components/overview.js +13 -14
  16. package/dist/components/primitives.d.ts +1 -1
  17. package/dist/components/primitives.js +13 -14
  18. package/dist/components/properties.d.ts +1 -1
  19. package/dist/components/properties.js +13 -14
  20. package/dist/components/sdk.d.ts +2 -2
  21. package/dist/components/sdk.js +13 -14
  22. package/dist/components/sidebar.d.ts +1 -1
  23. package/dist/components/sidebar.js +13 -14
  24. package/dist/components/snippets.d.ts +3 -3
  25. package/dist/components/snippets.js +13 -14
  26. package/dist/contexts/component-generics.d.ts +1 -1
  27. package/dist/contexts/component-generics.js +1 -1
  28. package/dist/contexts/component-types.d.ts +11 -12
  29. package/dist/contexts/component-types.js +0 -1
  30. package/dist/contexts/component.d.ts +14 -14
  31. package/dist/contexts/component.js +13 -14
  32. package/dist/contexts/docs.d.ts +1 -1
  33. package/dist/contexts/docs.js +1 -1
  34. package/dist/contexts/index.d.ts +18 -19
  35. package/dist/contexts/index.js +13 -14
  36. package/dist/contexts/markdown.d.ts +1 -1
  37. package/dist/contexts/markdown.js +2 -2
  38. package/dist/contexts/navigation.d.ts +2 -2
  39. package/dist/contexts/navigation.js +1 -1
  40. package/dist/contexts/search.d.ts +3 -3
  41. package/dist/contexts/search.js +13 -14
  42. package/dist/contexts/use-components.d.ts +10 -11
  43. package/dist/contexts/use-components.js +2 -2
  44. package/dist/contexts-CMNI3ctP.js +3799 -0
  45. package/dist/{docs-DhNaW0DE.d.ts → docs-BvahWQ28.d.ts} +2 -1
  46. package/dist/{docs-Cj25B-Sh.js → docs-CopwX9a7.js} +5 -1
  47. package/dist/icons-yb-Jhkmg.js +753 -0
  48. package/dist/{index-d8_VR8Z5.d.ts → index-BmPNhnpe.d.ts} +6 -6
  49. package/dist/{index-BXO3gZup.d.ts → index-D5NMSAld.d.ts} +26 -25
  50. package/dist/index-rVFBdVz8.d.ts +15 -0
  51. package/dist/index.d.ts +20 -21
  52. package/dist/index.js +15 -7700
  53. package/dist/languages/go.d.ts +11 -12
  54. package/dist/languages/go.js +13 -14
  55. package/dist/languages/http.d.ts +11 -12
  56. package/dist/languages/http.js +13 -14
  57. package/dist/languages/index.d.ts +11 -12
  58. package/dist/languages/index.js +13 -14
  59. package/dist/languages/java.d.ts +11 -12
  60. package/dist/languages/java.js +13 -14
  61. package/dist/languages/python.d.ts +11 -12
  62. package/dist/languages/python.js +13 -14
  63. package/dist/languages/ruby.d.ts +11 -12
  64. package/dist/languages/ruby.js +13 -14
  65. package/dist/languages/typescript.d.ts +11 -12
  66. package/dist/languages/typescript.js +13 -14
  67. package/dist/markdown/index.d.ts +3 -3
  68. package/dist/markdown/index.js +13 -14
  69. package/dist/markdown/md.js +1 -1
  70. package/dist/markdown/utils.d.ts +3 -3
  71. package/dist/markdown/utils.js +1 -1
  72. package/dist/{markdown-DunIdqFE.js → markdown-BmpyokB7.js} +9 -5
  73. package/dist/{markdown-DN8KaRR2.d.ts → markdown-w5UpIiGc.d.ts} +2 -1
  74. package/dist/{method-c3XDArUn.d.ts → method-CLpRObBV.d.ts} +7 -6
  75. package/dist/{navigation-BSn6PX-7.d.ts → navigation-Blr3LaES.d.ts} +3 -2
  76. package/dist/{navigation-CuCg3le8.js → navigation-CGr5_w6z.js} +5 -1
  77. package/dist/{overview-D21weqVJ.d.ts → overview-DBnqhjAg.d.ts} +6 -6
  78. package/dist/{primitives-iB9fIrMF.d.ts → primitives-BFubD3w8.d.ts} +9 -8
  79. package/dist/{properties-Ba6F_GGj.d.ts → properties-DeQRa6VK.d.ts} +4 -4
  80. package/dist/{routing-C8oZYLsf.js → routing-8itEXLx6.js} +1 -1
  81. package/dist/{routing-BE6Vrs-z.d.ts → routing-DNN8R6bZ.d.ts} +1 -1
  82. package/dist/routing.d.ts +1 -1
  83. package/dist/routing.js +3 -180
  84. package/dist/{sdk-D2x2l6JH.d.ts → sdk-BVQyp5Dw.d.ts} +14 -13
  85. package/dist/search/index.d.ts +6 -6
  86. package/dist/search/index.js +233 -110
  87. package/dist/search/providers/algolia.d.ts +2 -2
  88. package/dist/search/providers/algolia.js +13 -14
  89. package/dist/search/providers/fuse.d.ts +2 -2
  90. package/dist/search/providers/fuse.js +13 -14
  91. package/dist/search/providers/pagefind.d.ts +2 -2
  92. package/dist/search/providers/pagefind.js +1 -1
  93. package/dist/search/providers/walker.d.ts +2 -2
  94. package/dist/search/providers/walker.js +13 -14
  95. package/dist/search/types.d.ts +2 -2
  96. package/dist/search/types.js +1 -1
  97. package/dist/{search-KMqOU2tz.d.ts → search-CPp6HpUy.d.ts} +3 -2
  98. package/dist/{sidebar-B1X4gmY2.d.ts → sidebar-BoPLeaxp.d.ts} +5 -4
  99. package/dist/{snippets-BApdMOXp.d.ts → snippets-DLHH_Voi.d.ts} +7 -6
  100. package/dist/{style-BWu-Pqcm.d.ts → style-BEMLtSIK.d.ts} +0 -10
  101. package/dist/{style-CkbsakoF.js → style-CPgcT0Fw.js} +1 -11
  102. package/dist/style.d.ts +1 -1
  103. package/dist/style.js +1 -1
  104. package/dist/styles/main.css +51 -20
  105. package/dist/styles/main.js +0 -0
  106. package/dist/styles/primitives.css +1 -0
  107. package/dist/styles/primitives.js +0 -0
  108. package/dist/styles/resets.css +1 -0
  109. package/dist/styles/resets.js +0 -0
  110. package/dist/styles/search.css +1 -0
  111. package/dist/styles/search.js +0 -0
  112. package/dist/styles/sidebar.css +1 -0
  113. package/dist/styles/sidebar.js +0 -0
  114. package/dist/styles/snippets.css +1 -0
  115. package/dist/styles/snippets.js +0 -0
  116. package/dist/styles/variables.css +2 -0
  117. package/dist/styles/variables.js +0 -0
  118. package/dist/{types-BLgvxY4i.d.ts → types-DNSz4kuM.d.ts} +1 -1
  119. package/dist/{use-components-DI-AbT-D.js → use-components-BHEwm0mE.js} +1 -1
  120. package/dist/{utils-BhYTrLot.js → utils-2FmcHPHp.js} +2 -2
  121. package/dist/{utils-B9JL_XWH.d.ts → utils-DVi3gJLL.d.ts} +2 -2
  122. package/dist/utils.d.ts +1 -1
  123. package/dist/utils.js +2 -2
  124. package/package.json +63 -10
  125. package/dist/components/dropdown.d.ts +0 -2
  126. package/dist/components/dropdown.js +0 -4
  127. package/dist/components/scripts/dropdown.d.ts +0 -12
  128. package/dist/components/scripts/dropdown.js +0 -50
  129. package/dist/contexts-DO0sMzym.js +0 -2581
  130. package/dist/dropdown-Dv9VAYCW.d.ts +0 -42
  131. package/dist/dropdown-kUhwBigR.js +0 -38
  132. package/dist/icons--8QR-PrL.js +0 -222
  133. package/dist/index-BW6OPqAo.d.ts +0 -16
  134. package/dist/mcp.cjs +0 -983418
  135. package/src/components/breadcrumbs.tsx +0 -94
  136. package/src/components/chat.tsx +0 -157
  137. package/src/components/icons.tsx +0 -584
  138. package/src/components/index.ts +0 -8
  139. package/src/components/method.tsx +0 -145
  140. package/src/components/overview.tsx +0 -172
  141. package/src/components/primitives.tsx +0 -301
  142. package/src/components/properties.tsx +0 -132
  143. package/src/components/sdk.tsx +0 -408
  144. package/src/components/sidebar.tsx +0 -99
  145. package/src/components/snippets.tsx +0 -197
  146. package/src/contexts/component-generics.tsx +0 -43
  147. package/src/contexts/component-types.tsx +0 -5
  148. package/src/contexts/component.tsx +0 -32
  149. package/src/contexts/docs.tsx +0 -86
  150. package/src/contexts/index.tsx +0 -20
  151. package/src/contexts/markdown.tsx +0 -44
  152. package/src/contexts/navigation.tsx +0 -44
  153. package/src/contexts/search.tsx +0 -27
  154. package/src/contexts/use-components.tsx +0 -4
  155. package/src/hooks/use-strict-context.tsx +0 -16
  156. package/src/index.ts +0 -6
  157. package/src/languages/go.tsx +0 -281
  158. package/src/languages/http.tsx +0 -329
  159. package/src/languages/index.ts +0 -26
  160. package/src/languages/java.tsx +0 -358
  161. package/src/languages/python.tsx +0 -258
  162. package/src/languages/ruby.tsx +0 -327
  163. package/src/languages/typescript.tsx +0 -399
  164. package/src/markdown/index.ts +0 -112
  165. package/src/markdown/md.ts +0 -45
  166. package/src/markdown/utils.ts +0 -52
  167. package/src/routing.ts +0 -238
  168. package/src/search/form.tsx +0 -130
  169. package/src/search/index.tsx +0 -1
  170. package/src/search/indexer.ts +0 -248
  171. package/src/search/mcp.ts +0 -156
  172. package/src/search/printer.tsx +0 -86
  173. package/src/search/providers/algolia.ts +0 -88
  174. package/src/search/providers/fuse.ts +0 -19
  175. package/src/search/providers/pagefind.ts +0 -17
  176. package/src/search/providers/walker.ts +0 -32
  177. package/src/search/results.tsx +0 -183
  178. package/src/search/state.ts +0 -64
  179. package/src/search/types.ts +0 -116
  180. package/src/style.ts +0 -185
  181. package/src/styles/main.css +0 -989
  182. package/src/styles/primitives.css +0 -392
  183. package/src/styles/resets.css +0 -39
  184. package/src/styles/search.css +0 -359
  185. package/src/styles/sidebar.css +0 -85
  186. package/src/styles/snippets.css +0 -130
  187. package/src/styles/variables.css +0 -86
  188. package/src/utils.ts +0 -40
  189. /package/dist/{chunk-Bp6m_JJh.js → chunk-DsStOjWQ.js} +0 -0
  190. /package/dist/{md-Dg8aOyMA.js → md-DxiV1_vy.js} +0 -0
  191. /package/dist/{pagefind-ChrPfuVv.js → pagefind-BaK1krMe.js} +0 -0
  192. /package/dist/{types-DFN4M1Sp.js → types-__XoFvJ_.js} +0 -0
  193. /package/dist/{utils-ByZH9QWT.js → utils-BCfb0F9R.js} +0 -0
  194. /package/dist/{utils-DlayebL1.d.ts → utils-D43p_yTd.d.ts} +0 -0
@@ -1,132 +0,0 @@
1
- import { type ReactNode } from 'react';
2
- import { useLanguage, useSettings } from '../contexts';
3
- import { useComponents } from '../contexts/use-components';
4
- import style from '../style';
5
- import { ArrowDownWideNarrowIcon, ArrowUpNarrowWideIcon } from 'lucide-react';
6
-
7
- export type PropertyToggleProps = {
8
- target: string;
9
- };
10
-
11
- export function PropertyToggle({ target }: PropertyToggleProps) {
12
- return (
13
- <span
14
- className={style.ExpandToggle}
15
- data-stldocs-property-toggle-expanded="false"
16
- data-stldocs-property-toggle-target={target}
17
- >
18
- <span className={style.ExpandToggleContent}>
19
- Expand <ArrowDownWideNarrowIcon className={style.Icon} size={16} />
20
- </span>
21
- <span className={style.ExpandToggleContent}>
22
- Collapse <ArrowUpNarrowWideIcon className={style.Icon} size={16} />
23
- </span>
24
- </span>
25
- );
26
- }
27
-
28
- export type PropertyDescriptionProps = {
29
- description?: string;
30
- };
31
-
32
- export function PropertyDescription({ description }: PropertyDescriptionProps) {
33
- const { Markdown } = useComponents();
34
-
35
- if (description)
36
- return (
37
- <div className={style.PropertyDescription}>
38
- <Markdown content={description} />
39
- </div>
40
- );
41
- }
42
-
43
- export type PropertyProps = {
44
- id?: string;
45
- name?: ReactNode;
46
- typeName?: ReactNode;
47
- badges?: ReactNode;
48
- type?: ReactNode;
49
- description?: string;
50
- expand?: boolean;
51
- deprecated?: boolean | string;
52
- additional?: ReactNode;
53
- declaration?: ReactNode;
54
- constraints?: ReactNode;
55
- children?: ReactNode;
56
- };
57
-
58
- export function Property({
59
- id,
60
- name,
61
- typeName,
62
- badges,
63
- type,
64
- declaration,
65
- description,
66
- deprecated,
67
- expand,
68
- additional,
69
- constraints,
70
- children,
71
- }: PropertyProps) {
72
- const Docs = useComponents();
73
- const language = useLanguage();
74
-
75
- const properties = useSettings()?.properties;
76
- const collapseDescription = properties?.collapseDescription;
77
- const types = properties?.types;
78
-
79
- const textContent = (
80
- <>
81
- {typeof deprecated === 'string' && <div className={style.PropertyDeprecatedMessage}>{deprecated}</div>}
82
- {description && <Docs.PropertyDescription description={description} />}
83
- {constraints && <div className={style.PropertyContent}>{constraints}</div>}
84
- </>
85
- );
86
-
87
- const rich = (
88
- <>
89
- <div className={style.PropertyDeclaration}>
90
- {deprecated && <span className={style.PropertyDeprecated}>Deprecated</span>}
91
- {declaration}
92
- {badges && <span className={style.PropertyBadges}>{badges}</span>}
93
- </div>
94
- {collapseDescription === false ? textContent : null}
95
- </>
96
- );
97
-
98
- const simple = (
99
- <>
100
- {name && (
101
- <div className={style.PropertyHeader}>
102
- {deprecated && <span className={style.PropertyDeprecated}>Deprecated</span>}
103
- {name && <span className={style.PropertyName}>{name}</span>}
104
- {typeName && <span className={style.PropertyTypeName}>{typeName}</span>}
105
- {badges && <span className={style.PropertyBadges}>{badges}</span>}
106
- </div>
107
- )}
108
- {type && <div className={style.PropertyType}>{type}</div>}
109
- {collapseDescription === false ? textContent : null}
110
- </>
111
- );
112
-
113
- const content = (
114
- <div id={id} className={style.PropertyInfo}>
115
- {types === 'simple' ? simple : rich}
116
- </div>
117
- );
118
-
119
- return (
120
- <div className={style.Property} data-stldocs-language={language}>
121
- {children || (collapseDescription !== false && description) ? (
122
- <Docs.Expander summary={content} muted={!children} open={expand}>
123
- {collapseDescription !== false ? textContent : null}
124
- {additional}
125
- {children && <div className={style.PropertyChildren}>{children}</div>}
126
- </Docs.Expander>
127
- ) : (
128
- content
129
- )}
130
- </div>
131
- );
132
- }
@@ -1,408 +0,0 @@
1
- import * as React from 'react';
2
- import type * as SDKJSON from '@stainless/sdk-json';
3
- import { useComponents } from '../contexts/use-components';
4
- import {
5
- useLanguageComponents,
6
- useDeclaration,
7
- useLanguage,
8
- useSpec,
9
- useContentPanelLayout,
10
- useSettings,
11
- useNavigation,
12
- } from '../contexts';
13
- import style from '../style';
14
- import { DocsLanguage, getLanguageSnippet } from '../routing';
15
- import { BookOpen, Copy, Github } from 'lucide-react';
16
- import clsx from 'clsx';
17
- import {
18
- GoIcon,
19
- JavaIcon,
20
- KotlinIcon,
21
- PythonIcon,
22
- RubyIcon,
23
- TerraformIcon,
24
- TypescriptIcon,
25
- CurlIcon,
26
- PowershellIcon,
27
- } from './icons';
28
- import { Button } from '@stainless-api/ui-primitives';
29
-
30
- export type PropertyModelContextType = {
31
- modelPath?: string;
32
- propertyPath?: string;
33
- };
34
-
35
- export const PropertyModelContext = React.createContext<PropertyModelContextType>({});
36
- export function usePropertyModel() {
37
- return React.useContext(PropertyModelContext);
38
- }
39
-
40
- export type ReferenceNestingContextType = string[];
41
- export const ReferenceNestingContext = React.createContext<ReferenceNestingContextType>([]);
42
- export function useReferenceNesting() {
43
- return React.useContext(ReferenceNestingContext);
44
- }
45
-
46
- export type SDKSnippetLanguagesType = Record<SDKJSON.SnippetLanguage, { name: string; icon: string }>;
47
-
48
- export const SDKSnippetLanguages: SDKSnippetLanguagesType = {
49
- 'node.default': { name: 'TypeScript', icon: 'typescript' },
50
- 'typescript.default': { name: 'TypeScript', icon: 'typescript' },
51
- 'python.default': { name: 'Python', icon: 'python' },
52
- 'go.default': { name: 'Go', icon: 'go' },
53
- 'java.default': { name: 'Java', icon: 'java' },
54
- 'kotlin.default': { name: 'Kotlin', icon: 'kotlin' },
55
- 'http.curl': { name: 'cURL', icon: 'http' },
56
- 'http.powershell': { name: 'Powershell', icon: 'powershell' },
57
- 'terraform.default': { name: 'Terraform', icon: 'terraform' },
58
- 'ruby.default': { name: 'Ruby', icon: 'ruby' },
59
- };
60
-
61
- export type TransformRequestSnippetFn = ({
62
- snippet,
63
- language,
64
- }: {
65
- snippet: string;
66
- language: DocsLanguage;
67
- }) => string;
68
-
69
- type SDKChildrenProps = {
70
- paths: SDKJSON.ID[];
71
- expand?: boolean;
72
- depth?: number;
73
- };
74
-
75
- export function SDKChildren({ paths, expand, depth }: SDKChildrenProps) {
76
- const Docs = useComponents();
77
-
78
- return (
79
- <div className={style.Properties}>
80
- {paths.map((path, i) => (
81
- <Docs.SDKDeclaration path={path} key={i} expand={expand} depth={depth} />
82
- ))}
83
- </div>
84
- );
85
- }
86
-
87
- type SDKDeclarationProps = {
88
- path: string;
89
- expand?: boolean;
90
- depth?: number;
91
- };
92
-
93
- export function SDKDeclaration({ path, expand, depth = 0 }: SDKDeclarationProps) {
94
- const Lang = useLanguageComponents();
95
- const Docs = useComponents();
96
- const decl = useDeclaration(path, true);
97
- const settings = useSettings();
98
- const model = usePropertyModel();
99
- const nesting = useReferenceNesting();
100
- const { selectedPath } = useNavigation();
101
-
102
- if (decl.kind.endsWith('Reference')) {
103
- const refId =
104
- 'type' in decl && typeof decl.type !== 'string' && '$ref' in decl.type ? decl.type['$ref'] : undefined;
105
- if (refId && refId !== path && !nesting.includes(refId)) {
106
- return (
107
- <ReferenceNestingContext.Provider value={[...nesting, refId]}>
108
- <SDKDeclaration path={refId} expand={expand} depth={depth} />
109
- </ReferenceNestingContext.Provider>
110
- );
111
- }
112
- }
113
-
114
- const isUnion =
115
- 'childrenParentSchema' in decl &&
116
- decl.childrenParentSchema &&
117
- ['enum', 'union'].includes(decl.childrenParentSchema);
118
- const id = model?.propertyPath ? `${model.propertyPath} + ${path}` : path;
119
- const shouldExpand =
120
- (selectedPath?.startsWith(path) && nesting.length < 1) ||
121
- (settings?.properties?.expandDepth && depth <= settings?.properties?.expandDepth && !isUnion) ||
122
- expand;
123
-
124
- const content = (
125
- <Lang.Property decl={decl}>
126
- {({ ...props }) => (
127
- <Docs.Property
128
- id={id}
129
- expand={shouldExpand}
130
- constraints={'constraints' in decl && <Docs.SDKConstraints constraints={decl['constraints']} />}
131
- declaration={<Lang.Declaration decl={decl} />}
132
- description={'docstring' in decl ? decl['docstring'] : undefined}
133
- deprecated={decl.deprecated}
134
- {...props}
135
- >
136
- {'children' in decl &&
137
- (decl.children?.length ?? 0) > 0 &&
138
- (settings?.properties?.includeModelProperties !== false || !('modelPath' in decl)) && (
139
- <>
140
- {isUnion && <div className={style.PropertyAnnotation}>Accepts one of the following:</div>}
141
- <Docs.SDKChildren paths={decl.children ?? []} depth={depth + 1} />
142
- </>
143
- )}
144
- </Docs.Property>
145
- )}
146
- </Lang.Property>
147
- );
148
-
149
- if ('modelPath' in decl) {
150
- const value = { modelPath: decl.modelPath, propertyPath: decl.stainlessPath };
151
- return <PropertyModelContext.Provider value={value}>{content}</PropertyModelContext.Provider>;
152
- }
153
-
154
- return content;
155
- }
156
-
157
- export type SDKConstraintsProps = {
158
- constraints?: Record<string, any>;
159
- };
160
-
161
- export function SDKConstraints({ constraints }: SDKConstraintsProps) {
162
- if (constraints)
163
- return (
164
- <div className={style.PropertyConstraints}>
165
- {Object.entries(constraints).map(([name, value]) => (
166
- <div className={style.PropertyConstraint} key={name}>
167
- <span className={style.PropertyConstraintName}>{name}</span>
168
- <span className={style.PropertyConstraintValue}>{value}</span>
169
- </div>
170
- ))}
171
- </div>
172
- );
173
- }
174
-
175
- type SDKIconProps = {
176
- language: SDKJSON.SnippetLanguage;
177
- size?: number;
178
- };
179
-
180
- const snippetIcons: Record<
181
- SDKJSON.SnippetLanguage,
182
- ({ className }: { className?: string }) => React.JSX.Element
183
- > = {
184
- 'node.default': TypescriptIcon,
185
- 'typescript.default': TypescriptIcon,
186
- 'go.default': GoIcon,
187
- 'python.default': PythonIcon,
188
- 'terraform.default': TerraformIcon,
189
- 'http.curl': CurlIcon,
190
- 'http.powershell': PowershellIcon,
191
- 'ruby.default': RubyIcon,
192
- 'java.default': JavaIcon,
193
- 'kotlin.default': KotlinIcon,
194
- };
195
-
196
- export function SDKIcon({ language }: SDKIconProps) {
197
- const LangIcon = snippetIcons[language];
198
- if (!LangIcon) return null;
199
- return <LangIcon className={clsx(style.Icon, language.split('.').shift())} />;
200
- }
201
-
202
- export type SDKRequestTitleProps = {
203
- snippetLanguage: SDKJSON.SnippetLanguage;
204
- };
205
-
206
- export function SDKRequestTitle({ snippetLanguage }: SDKRequestTitleProps) {
207
- const languageName = SDKSnippetLanguages[snippetLanguage]?.name;
208
-
209
- return (
210
- <span className={style.SnippetRequestTitleLanguage}>
211
- <SDKIcon language={snippetLanguage} /> {languageName}
212
- </span>
213
- );
214
- }
215
-
216
- type SDKExampleProps = {
217
- method: SDKJSON.Method;
218
- transformRequestSnippet?: TransformRequestSnippetFn;
219
- };
220
-
221
- export function SDKExample({ method, transformRequestSnippet }: SDKExampleProps) {
222
- // TODO: support language variants in snippets
223
- const Docs = useComponents();
224
- const language = useLanguage();
225
- const snippetLanguage = getLanguageSnippet(language);
226
-
227
- return (
228
- <Docs.Snippet
229
- requestTitle={<Docs.SDKRequestTitle snippetLanguage={snippetLanguage} />}
230
- method={method}
231
- transformRequestSnippet={transformRequestSnippet}
232
- />
233
- );
234
- }
235
-
236
- export type SDKMethodProps = {
237
- method: SDKJSON.Method;
238
- transformRequestSnippet?: TransformRequestSnippetFn;
239
- };
240
-
241
- export function SDKMethodHeader({ method }: SDKMethodProps) {
242
- const Docs = useComponents();
243
- const Lang = useLanguageComponents();
244
- const decl = useDeclaration(method.stainlessPath, true);
245
-
246
- return (
247
- <Docs.MethodHeader
248
- level="h1"
249
- title={method.summary ?? method.title}
250
- signature={<Lang.MethodSignature decl={decl} />}
251
- badges={method.deprecated && <Docs.Badge id="deprecated">Deprecated</Docs.Badge>}
252
- >
253
- <Docs.MethodRoute httpMethod={method.httpMethod} endpoint={method.endpoint.split(' ', 2).at(-1)} />
254
- </Docs.MethodHeader>
255
- );
256
- }
257
-
258
- export function SDKMethodInfo({ method }: SDKMethodProps) {
259
- const Docs = useComponents();
260
- const Lang = useLanguageComponents();
261
- const decl = useDeclaration(method.stainlessPath, true);
262
- const spec = useSpec();
263
- const language = useLanguage();
264
-
265
- if (Lang.MethodInfo) return <Lang.MethodInfo decl={decl} />;
266
-
267
- function shouldExpand(items: SDKJSON.ID[]) {
268
- if (items.length > 1) return false;
269
- const item = items[0];
270
- if (!item) return false;
271
- const decl = spec?.decls?.[language]?.[item];
272
- return decl && 'children' in decl && decl.children && decl.children.length > 0;
273
- }
274
-
275
- return (
276
- <Docs.MethodInfo
277
- parameters={
278
- 'paramsChildren' in decl &&
279
- Array.isArray(decl.paramsChildren) &&
280
- decl.paramsChildren.length > 0 && (
281
- <Docs.SDKChildren expand={shouldExpand(decl.paramsChildren)} paths={decl.paramsChildren} />
282
- )
283
- }
284
- returns={
285
- 'responseChildren' in decl &&
286
- decl.responseChildren &&
287
- decl.responseChildren.length > 0 && (
288
- <Docs.SDKChildren expand={shouldExpand(decl.responseChildren)} paths={decl.responseChildren} />
289
- )
290
- }
291
- />
292
- );
293
- }
294
-
295
- export function SDKMethod({ method, transformRequestSnippet }: SDKMethodProps) {
296
- const Docs = useComponents();
297
- const decl = useDeclaration(method?.stainlessPath, true);
298
- const layout = useContentPanelLayout();
299
-
300
- if (!decl) return;
301
-
302
- return (
303
- <Docs.Method
304
- id={method.stainlessPath}
305
- header={<Docs.SDKMethodHeader method={method} />}
306
- className={clsx({
307
- [style.MethodSinglePane]: layout === 'single-pane',
308
- [style.MethodDoublePane]: layout === 'double-pane',
309
- })}
310
- >
311
- <div className={style.MethodContentColumn}>
312
- <Docs.MethodDescription description={method.description} />
313
- <Docs.SDKMethodInfo method={method} />
314
- </div>
315
- <div className={style.MethodExample + ' not-content'}>
316
- <Docs.SDKExample method={method} transformRequestSnippet={transformRequestSnippet} />
317
- </div>
318
- <div className={style.MethodResponseColumn}>
319
- <h5>Returns Examples</h5>
320
- <Docs.SnippetResponse responses={method.exampleResponses} />
321
- </div>
322
- </Docs.Method>
323
- );
324
- }
325
-
326
- export type SDKModelProps = {
327
- model: SDKJSON.Model;
328
- };
329
-
330
- export function SDKModel({ model }: SDKModelProps) {
331
- const Docs = useComponents();
332
- const decl = useDeclaration(`${model.stainlessPath} > (schema)`, true);
333
-
334
- if (!decl) return null;
335
-
336
- return (
337
- <div className={style.Model} tabIndex={0}>
338
- <div className={style.ResourceContentProperties}>
339
- <Docs.SDKDeclaration path={`${model.stainlessPath} > (schema)`} />
340
- </div>
341
- </div>
342
- );
343
- }
344
-
345
- type SDKReferenceProps = {
346
- stainlessPath: string;
347
- children?: React.ReactNode;
348
- };
349
-
350
- export function SDKReference({ stainlessPath, children }: SDKReferenceProps) {
351
- const Docs = useComponents();
352
-
353
- if (!stainlessPath || !stainlessPath.endsWith('(schema)')) return children;
354
-
355
- const link = (
356
- <span className={style.TypeReference}>
357
- <Docs.Link stainlessPath={stainlessPath}>{children}</Docs.Link>
358
- </span>
359
- );
360
-
361
- return link;
362
- }
363
-
364
- type SDKLanguageBlockProps = {
365
- language: DocsLanguage;
366
- version: string;
367
- install: string;
368
- links: {
369
- repo: string;
370
- docs: string;
371
- };
372
- };
373
-
374
- export function SDKLanguageBlock({ language, version, install, links }: SDKLanguageBlockProps) {
375
- const Docs = useComponents();
376
- const lang = `${language}.default` as SDKJSON.SnippetLanguage;
377
-
378
- return (
379
- <div className={style.LanguageBlock}>
380
- <div className={style.LanguageBlockContent}>
381
- <div className={style.LanguageBlockContentIcon}>
382
- <Docs.SDKIcon language={lang} size={24} />
383
- </div>
384
- <div className={style.LanguageBlockContentInfo}>
385
- <div className={style.LanguageBlockContentInfoLanguage}>{Docs.SDKSnippetLanguages[lang].name}</div>
386
- <div className={style.LanguageBlockContentInfoVersion}>{version}</div>
387
- </div>
388
- </div>
389
-
390
- <div className={style.LanguageBlockInstall} data-stldocs-copy-parent>
391
- <pre data-stldocs-copy-content>{install}</pre>{' '}
392
- <Button variant="ghost" size="sm" data-stldocs-snippet-copy>
393
- <Copy size={16} className={style.Icon} />
394
- </Button>
395
- </div>
396
-
397
- <div className={style.LanguageBlockLinks}>
398
- <Button href={links.repo} variant="outline">
399
- <Button.Icon icon={Github} />
400
- </Button>
401
- <Button href={links.docs} variant="outline">
402
- <Button.Icon icon={BookOpen} />
403
- <Button.Label>Read Docs</Button.Label>
404
- </Button>
405
- </div>
406
- </div>
407
- );
408
- }
@@ -1,99 +0,0 @@
1
- import * as React from 'react';
2
- import type * as SDKJSON from '@stainless/sdk-json';
3
- import { useNavigation } from '../contexts';
4
- import { useComponents } from '../contexts/use-components';
5
- import { ChevronDown, ChevronRight } from 'lucide-react';
6
- import style from '../style';
7
- import { MethodIconBadge } from './method';
8
- import { isResourceEmpty } from '../utils';
9
-
10
- type SidebarExpanderProps = {
11
- open?: boolean;
12
- summary: React.ReactNode;
13
- children?: React.ReactNode;
14
- };
15
-
16
- export function SidebarExpander({ open, summary, children }: SidebarExpanderProps) {
17
- return (
18
- <details className={style.SidebarExpander} open={open}>
19
- <summary className={style.ExpanderSummary}>
20
- <div className={style.ExpanderSummaryContent}>{summary}</div>
21
- <div className={style.ExpanderSummaryIcon}>
22
- <ChevronRight size={16} strokeWidth={1} className={style.Icon} />
23
- <ChevronDown size={16} strokeWidth={1} className={style.Icon} />
24
- </div>
25
- </summary>
26
- <div className={style.ExpanderContent}>{children}</div>
27
- </details>
28
- );
29
- }
30
-
31
- export type SidebarMethodProps = {
32
- method: SDKJSON.Method;
33
- };
34
-
35
- export function SidebarMethod({ method }: SidebarMethodProps) {
36
- const Docs = useComponents();
37
- const { selectedPath } = useNavigation();
38
-
39
- return (
40
- <div className={style.SidebarMethod} data-selected={method.stainlessPath === selectedPath}>
41
- <MethodIconBadge httpMethod={method.httpMethod} />
42
- <Docs.Link stainlessPath={method.stainlessPath}>{method.summary}</Docs.Link>
43
- </div>
44
- );
45
- }
46
-
47
- export type SidebarResourceProps = {
48
- resource: SDKJSON.Resource;
49
- };
50
-
51
- export function SidebarResource({ resource }: SidebarResourceProps) {
52
- const Docs = useComponents();
53
- const { selectedPath } = useNavigation();
54
- const subresources = Object.values(resource.subresources ?? {}).map((sub) => (
55
- <SidebarResource resource={sub} key={sub.stainlessPath} />
56
- ));
57
-
58
- const methods = Object.values(resource.methods).map((method) => (
59
- <SidebarMethod method={method} key={method.stainlessPath} />
60
- ));
61
-
62
- const hasChildren = subresources.length > 0 || methods.length > 0;
63
-
64
- const title = (
65
- <div className={style.SidebarResourceTitle}>
66
- <Docs.Link stainlessPath={resource.stainlessPath}>{resource.title}</Docs.Link>
67
- </div>
68
- );
69
-
70
- return (
71
- <div className={style.SidebarResource} data-selected={resource.stainlessPath === selectedPath}>
72
- {hasChildren ? (
73
- <SidebarExpander summary={title} open={true}>
74
- {methods}
75
- {subresources}
76
- </SidebarExpander>
77
- ) : (
78
- title
79
- )}
80
- </div>
81
- );
82
- }
83
-
84
- export type SidebarProps = {
85
- resources: SDKJSON.Resource[];
86
- selectedPath?: string;
87
- };
88
-
89
- export function Sidebar({ resources }: SidebarProps) {
90
- return (
91
- <div className={`${style.Root} ${style.Sidebar}`}>
92
- {resources
93
- .filter((resource) => !isResourceEmpty(resource))
94
- .map((resource) => (
95
- <SidebarResource resource={resource} key={resource.stainlessPath} />
96
- ))}
97
- </div>
98
- );
99
- }