@stainless-api/docs-ui 0.1.0-beta.5 → 0.1.0-beta.51

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 (212) hide show
  1. package/dist/breadcrumbs-BdYnaHA8.d.ts +20 -0
  2. package/dist/breadcrumbs-CA7GmW_8.d.ts +20 -0
  3. package/dist/breadcrumbs-nSFZO5Gf.js +63 -0
  4. package/dist/chunk-DRcLgZ1e.js +18 -0
  5. package/dist/component-DRO8kQSp.js +23 -0
  6. package/dist/component-generics-B6Fn47Mz.js +45 -0
  7. package/dist/component-generics-BHFUK06s.d.ts +30 -0
  8. package/dist/component-generics-BJSyydZ-.d.ts +30 -0
  9. package/dist/components/MaskedInput.d.ts +14 -0
  10. package/dist/components/MaskedInput.js +76 -0
  11. package/dist/components/breadcrumbs.d.ts +2 -0
  12. package/dist/components/breadcrumbs.js +9 -0
  13. package/dist/components/icons.d.ts +55 -0
  14. package/dist/components/icons.js +3 -0
  15. package/dist/components/index.d.ts +10 -0
  16. package/dist/components/index.js +18 -0
  17. package/dist/components/method.d.ts +2 -0
  18. package/dist/components/method.js +10 -0
  19. package/dist/components/overview.d.ts +2 -0
  20. package/dist/components/overview.js +11 -0
  21. package/dist/components/primitives.d.ts +2 -0
  22. package/dist/components/primitives.js +8 -0
  23. package/dist/components/properties.d.ts +2 -0
  24. package/dist/components/properties.js +9 -0
  25. package/dist/components/sdk.d.ts +2 -0
  26. package/dist/components/sdk.js +10 -0
  27. package/dist/components/sidebar.d.ts +2 -0
  28. package/dist/components/sidebar.js +11 -0
  29. package/dist/components/snippets.d.ts +3 -0
  30. package/dist/components/snippets.js +9 -0
  31. package/dist/components-D7M-BwNI.js +71 -0
  32. package/dist/contexts/component-generics.d.ts +2 -0
  33. package/dist/contexts/component-generics.js +3 -0
  34. package/dist/contexts/component-types.d.ts +16 -0
  35. package/dist/contexts/component-types.js +0 -0
  36. package/dist/contexts/component.d.ts +29 -0
  37. package/dist/contexts/component.js +27 -0
  38. package/dist/contexts/docs.d.ts +2 -0
  39. package/dist/contexts/docs.js +3 -0
  40. package/dist/contexts/index.d.ts +16 -0
  41. package/dist/contexts/index.js +7 -0
  42. package/dist/contexts/markdown.d.ts +2 -0
  43. package/dist/contexts/markdown.js +4 -0
  44. package/dist/contexts/navigation.d.ts +2 -0
  45. package/dist/contexts/navigation.js +3 -0
  46. package/dist/contexts/use-components.d.ts +14 -0
  47. package/dist/contexts/use-components.js +4 -0
  48. package/dist/contexts-p3rRZDlM.js +39 -0
  49. package/dist/csharp-CDSxfCZE.js +283 -0
  50. package/dist/docs-BUS__I1m.d.ts +47 -0
  51. package/dist/docs-CXqi26jB.js +54 -0
  52. package/dist/docs-fKyo35eI.d.ts +47 -0
  53. package/dist/go-1c3S5ETL.js +303 -0
  54. package/dist/http-2QNWXH9t.js +330 -0
  55. package/dist/icons-Ckod9aod.js +869 -0
  56. package/dist/index-5Yl-BBg3.d.ts +15 -0
  57. package/dist/index-9LRO8R1a.d.ts +274 -0
  58. package/dist/index-CBIJwoyp.d.ts +13 -0
  59. package/dist/index-ClCZKGcw.d.ts +274 -0
  60. package/dist/index-pMKpm2Jk.d.ts +13 -0
  61. package/dist/index-q3bZhNWj.d.ts +15 -0
  62. package/dist/index.d.ts +19 -0
  63. package/dist/index.js +29 -7542
  64. package/dist/java-BbjF_oUI.js +403 -0
  65. package/dist/languages/csharp.d.ts +11 -0
  66. package/dist/languages/csharp.js +9 -0
  67. package/dist/languages/go.d.ts +11 -0
  68. package/dist/languages/go.js +9 -0
  69. package/dist/languages/http.d.ts +11 -0
  70. package/dist/languages/http.js +19 -0
  71. package/dist/languages/index.d.ts +11 -0
  72. package/dist/languages/index.js +26 -0
  73. package/dist/languages/java.d.ts +11 -0
  74. package/dist/languages/java.js +9 -0
  75. package/dist/languages/python.d.ts +11 -0
  76. package/dist/languages/python.js +9 -0
  77. package/dist/languages/ruby.d.ts +11 -0
  78. package/dist/languages/ruby.js +9 -0
  79. package/dist/languages/typescript.d.ts +11 -0
  80. package/dist/languages/typescript.js +9 -0
  81. package/dist/languages-BCYZjzuS.js +26 -0
  82. package/dist/markdown/index.d.ts +12 -0
  83. package/dist/markdown/index.js +104 -0
  84. package/dist/markdown/md.d.ts +15 -0
  85. package/dist/markdown/md.js +3 -0
  86. package/dist/markdown/printer.d.ts +2 -0
  87. package/dist/markdown/printer.js +28 -0
  88. package/dist/markdown/utils.d.ts +3 -0
  89. package/dist/markdown/utils.js +3 -0
  90. package/dist/markdown-C8o8WrwG.d.ts +22 -0
  91. package/dist/markdown-CqJohZei.d.ts +22 -0
  92. package/dist/markdown-CxdeWgjV.js +48 -0
  93. package/dist/md-oM2tUaCA.js +41 -0
  94. package/dist/method-CE08mUME.js +115 -0
  95. package/dist/method-CMt6uyix.d.ts +71 -0
  96. package/dist/method-r5UAB40b.d.ts +71 -0
  97. package/dist/navigation-9_4wRkcT.d.ts +29 -0
  98. package/dist/navigation-C5TN0SgC.js +24 -0
  99. package/dist/navigation-zuoWsXzh.d.ts +29 -0
  100. package/dist/overview-DXmLmmr7.d.ts +39 -0
  101. package/dist/overview-S2hUqPXA.js +139 -0
  102. package/dist/overview-ixhAhHj8.d.ts +39 -0
  103. package/dist/primitives-BIWfwN5L.js +258 -0
  104. package/dist/primitives-BVXfSSiS.d.ts +97 -0
  105. package/dist/primitives-Bl0wzAGo.d.ts +97 -0
  106. package/dist/printer-DBw4S_Jn.d.ts +13 -0
  107. package/dist/printer-bNxiG6UB.js +74 -0
  108. package/dist/properties-C-NU_ghj.d.ts +54 -0
  109. package/dist/properties-GT9ixNTg.d.ts +54 -0
  110. package/dist/properties-jlGW3USi.js +131 -0
  111. package/dist/python-USOwFDv_.js +279 -0
  112. package/dist/routing-CMqh1cTZ.d.ts +54 -0
  113. package/dist/routing-Wbb7YECB.js +194 -0
  114. package/dist/routing.d.ts +2 -0
  115. package/dist/routing.js +3 -180
  116. package/dist/ruby-CSvGbSLe.js +387 -0
  117. package/dist/sdk-B5W3VipN.d.ts +118 -0
  118. package/dist/sdk-CS6A3HW3.d.ts +118 -0
  119. package/dist/sdk-CSCbbn3O.js +336 -0
  120. package/dist/sidebar-C3fZrgmP.d.ts +36 -0
  121. package/dist/sidebar-CWyvCrJ0.js +81 -0
  122. package/dist/sidebar-CbCLUteD.d.ts +36 -0
  123. package/dist/snippets-BQLXEIf6.js +161 -0
  124. package/dist/snippets-C72s2IwS.d.ts +51 -0
  125. package/dist/snippets-DcFph7ir.d.ts +51 -0
  126. package/dist/spec.d.ts +65 -0
  127. package/dist/spec.js +167 -0
  128. package/dist/style-D7RO5ymE.d.ts +168 -0
  129. package/dist/style-gnVEeXFj.js +169 -0
  130. package/dist/style.d.ts +2 -0
  131. package/dist/style.js +3 -0
  132. package/dist/styles/main.css +727 -754
  133. package/dist/styles/main.js +0 -0
  134. package/dist/styles/primitives.css +317 -461
  135. package/dist/styles/primitives.js +0 -0
  136. package/dist/styles/resets.css +32 -41
  137. package/dist/styles/resets.js +0 -0
  138. package/dist/styles/search.css +175 -274
  139. package/dist/styles/search.js +0 -0
  140. package/dist/styles/sidebar.css +59 -60
  141. package/dist/styles/sidebar.js +0 -0
  142. package/dist/styles/variables.css +26 -89
  143. package/dist/styles/variables.js +0 -0
  144. package/dist/styles.css +2910 -0
  145. package/dist/styles.mjs +1 -0
  146. package/dist/typescript-DXG9psK3.js +449 -0
  147. package/dist/use-components-RWQbviGq.js +7 -0
  148. package/dist/utils-CqnL9Fc3.js +31 -0
  149. package/dist/utils-DGnJ6mcU.d.ts +21 -0
  150. package/dist/utils-D_1AWSRX.js +32 -0
  151. package/dist/utils-d8paVwKN.d.ts +14 -0
  152. package/dist/utils-uQbtk0-_.d.ts +21 -0
  153. package/dist/utils.d.ts +2 -0
  154. package/dist/utils.js +3 -0
  155. package/package.json +73 -21
  156. package/dist/mcp.js +0 -16003
  157. package/dist/styles/snippets.css +0 -132
  158. package/src/components/breadcrumbs.tsx +0 -94
  159. package/src/components/chat.tsx +0 -154
  160. package/src/components/dropdown.tsx +0 -91
  161. package/src/components/icons.tsx +0 -584
  162. package/src/components/index.ts +0 -9
  163. package/src/components/method.tsx +0 -144
  164. package/src/components/overview.tsx +0 -159
  165. package/src/components/primitives.tsx +0 -284
  166. package/src/components/properties.tsx +0 -130
  167. package/src/components/scripts/dropdown.ts +0 -78
  168. package/src/components/sdk.tsx +0 -402
  169. package/src/components/sidebar.tsx +0 -99
  170. package/src/components/snippets.tsx +0 -179
  171. package/src/contexts/component-generics.tsx +0 -48
  172. package/src/contexts/component-types.tsx +0 -5
  173. package/src/contexts/component.tsx +0 -32
  174. package/src/contexts/docs.tsx +0 -75
  175. package/src/contexts/index.tsx +0 -17
  176. package/src/contexts/markdown.tsx +0 -43
  177. package/src/contexts/navigation.tsx +0 -44
  178. package/src/contexts/search.tsx +0 -28
  179. package/src/contexts/use-components.tsx +0 -4
  180. package/src/index.ts +0 -6
  181. package/src/languages/go.tsx +0 -281
  182. package/src/languages/http.tsx +0 -321
  183. package/src/languages/index.ts +0 -26
  184. package/src/languages/java.tsx +0 -358
  185. package/src/languages/python.tsx +0 -255
  186. package/src/languages/ruby.tsx +0 -320
  187. package/src/languages/typescript.tsx +0 -393
  188. package/src/markdown/index.ts +0 -107
  189. package/src/markdown/md.ts +0 -45
  190. package/src/markdown/utils.ts +0 -49
  191. package/src/routing.ts +0 -238
  192. package/src/search/form.tsx +0 -127
  193. package/src/search/index.tsx +0 -1
  194. package/src/search/indexer.ts +0 -246
  195. package/src/search/mcp.ts +0 -61
  196. package/src/search/printer.tsx +0 -86
  197. package/src/search/providers/algolia.ts +0 -88
  198. package/src/search/providers/fuse.ts +0 -19
  199. package/src/search/providers/pagefind.ts +0 -17
  200. package/src/search/providers/walker.ts +0 -30
  201. package/src/search/results.tsx +0 -181
  202. package/src/search/state.ts +0 -64
  203. package/src/search/types.ts +0 -116
  204. package/src/style.ts +0 -197
  205. package/src/styles/main.css +0 -993
  206. package/src/styles/primitives.css +0 -573
  207. package/src/styles/resets.css +0 -47
  208. package/src/styles/search.css +0 -342
  209. package/src/styles/sidebar.css +0 -87
  210. package/src/styles/snippets.css +0 -132
  211. package/src/styles/variables.css +0 -90
  212. package/src/utils.ts +0 -41
@@ -1,132 +0,0 @@
1
- @layer docs-ui {
2
- .stldocs-root {
3
- .snippet {
4
- color: #d8d8d8;
5
- --orange: 24 76% 51%;
6
- --teal: 208 100% 66%;
7
- --magenta: 324 54% 48.6%;
8
- --purple: 274 41% 47%;
9
- }
10
-
11
- .hljs-comment,
12
- .hljs-quote {
13
- color: #adadad;
14
- }
15
-
16
- .hljs-doctag,
17
- .hljs-keyword,
18
- .hljs-formula {
19
- color: #fb8f44;
20
- }
21
-
22
- .hljs-section,
23
- .hljs-name,
24
- .hljs-selector-tag,
25
- .hljs-deletion,
26
- .hljs-subst {
27
- color: #f7585c;
28
- }
29
-
30
- .hjs-literal,
31
- .hljs-string,
32
- .hljs-regexp,
33
- .hljs-addition,
34
- .hljs-attribute,
35
- .hljs-meta .hljs-string {
36
- color: #54aeff;
37
- }
38
-
39
- .hljs-attr,
40
- .hljs-variable,
41
- .hljs-template-variable,
42
- .hljs-type,
43
- .hljs-selector-class,
44
- .hljs-selector-attr,
45
- .hljs-selector-pseudo,
46
- .hljs-number {
47
- color: #4ac26b;
48
- }
49
-
50
- .hljs-symbol,
51
- .hljs-bullet,
52
- .hljs-link,
53
- .hljs-meta,
54
- .hljs-selector-id,
55
- .hljs-title,
56
- .hljs-built_in,
57
- .hljs-title.class_,
58
- .hljs-class .hljs-title {
59
- color: #b68eff;
60
- }
61
-
62
- .hljs-emphasis {
63
- font-style: italic;
64
- }
65
-
66
- .hljs-strong {
67
- font-weight: bold;
68
- }
69
-
70
- .hljs-link {
71
- text-decoration: underline;
72
- }
73
-
74
- .snippet-json {
75
- color: #a5a5ac;
76
-
77
- .hljs-comment,
78
- .hljs-quote {
79
- color: #adadad;
80
- }
81
-
82
- .hljs-doctag,
83
- .hljs-keyword,
84
- .hljs-formula,
85
- .hljs-number {
86
- color: var(--stldocs-syntax-color-orange);
87
- }
88
-
89
- .hljs-section,
90
- .hljs-name,
91
- .hljs-selector-tag,
92
- .hljs-deletion,
93
- .hljs-subst {
94
- color: var(--stldocs-syntax-color-red);
95
- }
96
-
97
- .hjs-literal,
98
- .hljs-string,
99
- .hljs-regexp,
100
- .hljs-addition,
101
- .hljs-attribute,
102
- .hljs-meta .hljs-string {
103
- color: var(--stldocs-syntax-color-green);
104
- }
105
-
106
- .hljs-attr,
107
- .hljs-variable,
108
- .hljs-template-variable,
109
- .hljs-type,
110
- .hljs-selector-class,
111
- .hljs-selector-attr,
112
- .hljs-selector-pseudo {
113
- color: var(--stldocs-color-text);
114
- }
115
-
116
- .hljs-symbol,
117
- .hljs-bullet,
118
- .hljs-link,
119
- .hljs-meta,
120
- .hljs-selector-id,
121
- .hljs-title {
122
- color: var(--stldocs-syntax-color-purple);
123
- }
124
-
125
- .hljs-built_in,
126
- .hljs-title.class_,
127
- .hljs-class .hljs-title {
128
- color: var(--stldocs-syntax-color-blue);
129
- }
130
- }
131
- }
132
- }
@@ -1,94 +0,0 @@
1
- import type * as SDKJSON from '~/lib/json-spec-v2/types';
2
- import { Languages } from '../routing';
3
- import { ChevronRight } from 'lucide-react';
4
- import style from '../style';
5
- import { Join } from './primitives';
6
-
7
- type Breadcrumb = { title: string; href: string };
8
-
9
- type BreadcrumbConfig = {
10
- includeCurrentPage?: boolean;
11
- };
12
-
13
- function generateApiBreadcrumbs(fullPath: string, spec: any, basePath: string): Breadcrumb[] | null {
14
- // Normalize paths. Mostly for basePath since it's configurable and may have trailing slashes
15
- const cleanBasePath = basePath.replace(/\/+$/, '');
16
- const cleanPath = fullPath.replace(/\/+$/, '');
17
-
18
- if (!cleanPath.startsWith(cleanBasePath)) return null;
19
-
20
- // Slice off the basePath
21
- const rest = cleanPath.slice(cleanBasePath.length).split('/').filter(Boolean);
22
-
23
- const breadcrumbs: Breadcrumb[] = [];
24
- let href = cleanBasePath;
25
- let i = 0;
26
-
27
- // Handle sdk language prefix
28
- if (Languages.includes(rest[0] as (typeof Languages)[number])) {
29
- href += `/${rest[0]}`;
30
- i++;
31
- }
32
-
33
- // Always start with API Reference
34
- breadcrumbs.push({ title: 'API Reference', href });
35
-
36
- let currentSpec = spec;
37
-
38
- while (i < rest.length) {
39
- const idType = rest[i];
40
- const idValue = rest[i + 1];
41
- if (!idType || !idValue || !currentSpec?.[idType]?.[idValue]) break;
42
-
43
- currentSpec = currentSpec[idType][idValue];
44
- href += `/${idType}/${idValue}`;
45
-
46
- // This should always exist, but just in case fallback to the raw url value
47
- const title = (idType === 'methods' ? currentSpec.summary : currentSpec.title) ?? idValue;
48
-
49
- breadcrumbs.push({
50
- title,
51
- href,
52
- });
53
-
54
- i += 2;
55
- }
56
-
57
- return breadcrumbs;
58
- }
59
-
60
- export function SDKBreadcrumbs({
61
- spec,
62
- currentPath,
63
- basePath = '/api',
64
- config = { includeCurrentPage: false },
65
- }: {
66
- spec: SDKJSON.Spec;
67
- currentPath: string;
68
- basePath?: string;
69
- config?: BreadcrumbConfig | null;
70
- }) {
71
- const breadcrumbs = generateApiBreadcrumbs(currentPath, spec, basePath);
72
-
73
- if (!breadcrumbs || breadcrumbs.length === 0) return null;
74
-
75
- if (!config?.includeCurrentPage) {
76
- breadcrumbs.pop();
77
- }
78
-
79
- const items = breadcrumbs.map((crumb, index) => (
80
- <div key={index} className={style.BreadcrumbsItem}>
81
- <a href={crumb.href} className={style.BreadcrumbsLink}>
82
- {crumb.title}
83
- </a>
84
- </div>
85
- ));
86
-
87
- return (
88
- <div className={style.Breadcrumbs}>
89
- <Join limit={breadcrumbs.length} items={items}>
90
- <ChevronRight />
91
- </Join>
92
- </div>
93
- );
94
- }
@@ -1,154 +0,0 @@
1
- import * as React from 'react';
2
- import { useChat } from 'ai/react';
3
- import { ArrowUpIcon, BotMessageSquareIcon, LoaderCircleIcon, SquareIcon, TrashIcon } from 'lucide-react';
4
- import { useLanguage, useSearchContext } from '../contexts';
5
- import { Markdown } from './primitives';
6
- import type { SearchSettings } from '../search/types';
7
- import type { UIMessage } from 'ai';
8
- import style from '../style';
9
-
10
- const BASEURL = 'https://askai.algolia.com';
11
-
12
- function buildFetch({ appId, searchKey, indexName, assistant }: SearchSettings) {
13
- const headers = {
14
- 'X-Algolia-Application-Id': appId,
15
- 'X-Algolia-API-Key': searchKey,
16
- 'X-Algolia-Index-Name': `${indexName}-chat`,
17
- 'X-Algolia-Assistant-Id': assistant,
18
- };
19
-
20
- return async (input, init) => {
21
- const response = await fetch(`${BASEURL}/chat/token`, { method: 'POST', headers });
22
- const data = await response.json();
23
- return fetch(input, {
24
- ...init,
25
- headers: {
26
- ...init.headers,
27
- ...headers,
28
- Authorization: `TOKEN ${data['token']}`,
29
- },
30
- });
31
- };
32
- }
33
-
34
- function RenderMessage({ message }: { message: UIMessage }) {
35
- return message.parts
36
- .filter((part) => part.type === 'text')
37
- .map((part, key) => <Markdown key={key} content={part['text']} />);
38
- }
39
-
40
- export function Chat() {
41
- const language = useLanguage();
42
- const { settings } = useSearchContext();
43
- const messageListRef = React.useRef<HTMLDivElement>(null);
44
-
45
- const { messages, setMessages, status, input, setInput, append, stop } = useChat({
46
- body: { searchParameters: { filters: `language:${language ?? 'http'}` } },
47
- sendExtraMessageFields: true,
48
- fetch: buildFetch(settings),
49
- api: `${BASEURL}/chat`,
50
- });
51
-
52
- React.useEffect(() => {
53
- const content = sessionStorage.getItem('stldocs-chat-messages');
54
- if (!content) return;
55
-
56
- setMessages(JSON.parse(content));
57
- setTimeout(() => {
58
- if (!messageListRef.current) return;
59
- messageListRef.current.scrollTop = messageListRef.current.scrollHeight;
60
- }, 10);
61
- }, [setMessages]);
62
-
63
- React.useEffect(() => {
64
- if (status !== 'submitted') return;
65
- const messageElements = messageListRef?.current.querySelectorAll('[data-stldocs-chat-message]');
66
- [...messageElements].at(-1)?.scrollIntoView({ behavior: 'smooth', block: 'start' });
67
- }, [status]);
68
-
69
- React.useEffect(() => {
70
- sessionStorage.setItem('stldocs-chat-messages', JSON.stringify(messages));
71
- }, [messages]);
72
-
73
- function handleSend() {
74
- append({ role: 'user', content: input });
75
- setInput('');
76
- }
77
-
78
- function handleKeyUp(ev) {
79
- if (ev.key === 'Enter' && !ev.shiftKey) {
80
- ev.preventDefault();
81
- handleSend();
82
- }
83
- }
84
-
85
- return (
86
- <>
87
- <div className={style.ChatMessages} ref={messageListRef}>
88
- {messages.map((message) => (
89
- <div key={message.id} className={style.ChatMessage} data-stldocs-chat-message={message.role}>
90
- <RenderMessage message={message} />
91
- </div>
92
- ))}
93
-
94
- {status === 'submitted' && (
95
- <div className={style.LoadingSpinner}>
96
- <LoaderCircleIcon />
97
- </div>
98
- )}
99
-
100
- {['submitted', 'streaming'].includes(status) && <div style={{ height: '800px' }}></div>}
101
- </div>
102
- <div className={style.ChatInput}>
103
- <textarea
104
- value={input}
105
- placeholder="Ask a question"
106
- onKeyUp={handleKeyUp}
107
- onChange={(ev) => setInput(ev.target.value)}
108
- autoFocus
109
- />
110
-
111
- <div className={style.ChatInputButtons}>
112
- {status === 'submitted' ? (
113
- <button onClick={stop}>
114
- <SquareIcon />
115
- </button>
116
- ) : (
117
- <button onClick={handleSend} disabled={input.length < 1}>
118
- <ArrowUpIcon />
119
- </button>
120
- )}
121
-
122
- <button onClick={() => setMessages([])}>
123
- <TrashIcon />
124
- </button>
125
- </div>
126
- </div>
127
- </>
128
- );
129
- }
130
-
131
- export type ChatModalProps = {
132
- id?: string;
133
- open?: boolean;
134
- };
135
-
136
- export function ChatModal({ id, open: isOpen }: ChatModalProps) {
137
- const [open, setOpen] = React.useState<boolean>(isOpen);
138
-
139
- return (
140
- <div
141
- id={id}
142
- onToggle={(ev) => setOpen(ev.newState === 'open')}
143
- className={style.SearchModal}
144
- popover="auto"
145
- data-stldocs-modal-open={open}
146
- >
147
- <div className={style.ChatHeader}>
148
- <BotMessageSquareIcon />
149
- <h5>Docs Assistant</h5>
150
- </div>
151
- {open && <Chat />}
152
- </div>
153
- );
154
- }
@@ -1,91 +0,0 @@
1
- import * as React from 'react';
2
- import style from '../style';
3
- import { ChevronsUpDown } from 'lucide-react';
4
- import clsx from 'clsx';
5
-
6
- export const Dropdown = ({ className, children, ...rest }: React.HTMLProps<HTMLDivElement>) => {
7
- return (
8
- <div {...rest} className={`${style.Dropdown} ${className ?? ''}`}>
9
- {children}
10
- </div>
11
- );
12
- };
13
-
14
- export const DropdownTrigger = ({
15
- children,
16
- withChevron,
17
- className,
18
- isIcon,
19
- ...rest
20
- }: {
21
- children: React.ReactNode;
22
- withChevron?: boolean;
23
- isIcon?: boolean;
24
- } & (React.HTMLProps<HTMLButtonElement> & {
25
- type?: 'submit' | 'reset' | 'button';
26
- })) => {
27
- return (
28
- <button
29
- className={`${style.Button} ${style.ButtonSecondary} ${style.DropdownTrigger} ${isIcon ? style.ButtonIcon : ''} ${className ?? ''}`}
30
- aria-haspopup="listbox"
31
- {...rest}
32
- >
33
- <div className={style.DropdownTriggerContent}>{children}</div>
34
- {withChevron && (
35
- <span className={style.DropdownChevron}>
36
- <ChevronsUpDown size={16} />
37
- </span>
38
- )}
39
- </button>
40
- );
41
- };
42
-
43
- export const DropdownMenu = ({
44
- position,
45
- className,
46
- children,
47
- ...rest
48
- }: { position?: 'below' } & React.HTMLProps<HTMLUListElement>) => {
49
- return (
50
- <ul className={`${style.DropdownMenu} ${position ?? ''} ${className ?? ''}`} {...rest}>
51
- {children}
52
- </ul>
53
- );
54
- };
55
-
56
- export const DropdownItem = ({
57
- children,
58
- className,
59
- value,
60
- selected,
61
- href,
62
- }: React.HTMLProps<HTMLLIElement> & { value?: string; selected?: boolean; href?: string }) => {
63
- const inner = (
64
- <>
65
- {children}
66
- <svg
67
- xmlns="http://www.w3.org/2000/svg"
68
- width="24"
69
- height="24"
70
- viewBox="0 0 24 24"
71
- fill="none"
72
- stroke="currentColor"
73
- strokeWidth="2"
74
- strokeLinecap="round"
75
- strokeLinejoin="round"
76
- className="lucide lucide-check-icon lucide-check"
77
- >
78
- <path d="M20 6 9 17l-5-5" />
79
- </svg>
80
- </>
81
- );
82
- return (
83
- <li
84
- className={clsx(style.DropdownItem, className, selected && 'selected', href && style.DropdownItemLink)}
85
- role="option"
86
- data-dropdown-value={value}
87
- >
88
- {href ? <a href={href}>{inner}</a> : inner}
89
- </li>
90
- );
91
- };