@health-samurai/react-components 0.0.0-alpha.3 → 0.0.0-alpha.5

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 (251) hide show
  1. package/dist/bundle.css +687 -446
  2. package/dist/src/components/code-editor/http/grammar/http.d.ts +3 -0
  3. package/dist/src/components/code-editor/http/grammar/http.d.ts.map +1 -0
  4. package/dist/src/components/code-editor/http/grammar/http.grammar +74 -0
  5. package/dist/src/components/code-editor/http/grammar/http.js +38 -0
  6. package/dist/src/components/code-editor/http/grammar/http.js.map +1 -0
  7. package/dist/src/components/code-editor/http/grammar/http.terms.d.ts +2 -0
  8. package/dist/src/components/code-editor/http/grammar/http.terms.d.ts.map +1 -0
  9. package/dist/src/components/code-editor/http/grammar/http.terms.js +4 -0
  10. package/dist/src/components/code-editor/http/grammar/http.terms.js.map +1 -0
  11. package/dist/src/components/code-editor/http/grammar/http.test.d.ts +2 -0
  12. package/dist/src/components/code-editor/http/grammar/http.test.d.ts.map +1 -0
  13. package/dist/src/components/code-editor/http/grammar/http.test.js +80 -0
  14. package/dist/src/components/code-editor/http/grammar/http.test.js.map +1 -0
  15. package/dist/src/components/code-editor/http/index.d.ts +4 -0
  16. package/dist/src/components/code-editor/http/index.d.ts.map +1 -0
  17. package/dist/src/components/code-editor/http/index.js +66 -0
  18. package/dist/src/components/code-editor/http/index.js.map +1 -0
  19. package/dist/src/components/code-editor/index.d.ts +13 -2
  20. package/dist/src/components/code-editor/index.d.ts.map +1 -1
  21. package/dist/src/components/code-editor/index.js +161 -20
  22. package/dist/src/components/code-editor/index.js.map +1 -1
  23. package/dist/src/components/code-editor.stories.js +3 -1
  24. package/dist/src/components/code-editor.stories.js.map +1 -1
  25. package/dist/src/components/request-line-editor.d.ts +11 -35
  26. package/dist/src/components/request-line-editor.d.ts.map +1 -1
  27. package/dist/src/components/request-line-editor.js +51 -49
  28. package/dist/src/components/request-line-editor.js.map +1 -1
  29. package/dist/src/components/request-line-editor.stories.d.ts.map +1 -1
  30. package/dist/src/components/request-line-editor.stories.js +17 -53
  31. package/dist/src/components/request-line-editor.stories.js.map +1 -1
  32. package/dist/src/components/tree-view.d.ts +16 -0
  33. package/dist/src/components/tree-view.d.ts.map +1 -0
  34. package/dist/src/components/tree-view.js +67 -0
  35. package/dist/src/components/tree-view.js.map +1 -0
  36. package/dist/src/components/tree-view.stories.d.ts +13 -0
  37. package/dist/src/components/tree-view.stories.d.ts.map +1 -0
  38. package/dist/src/components/tree-view.stories.js +274 -0
  39. package/dist/src/components/tree-view.stories.js.map +1 -0
  40. package/dist/src/icons.d.ts +3 -0
  41. package/dist/src/icons.d.ts.map +1 -0
  42. package/dist/src/icons.js +47 -0
  43. package/dist/src/icons.js.map +1 -0
  44. package/dist/src/index.css +42 -3
  45. package/dist/src/index.d.ts +1 -1
  46. package/dist/src/index.d.ts.map +1 -1
  47. package/dist/src/index.js +1 -1
  48. package/dist/src/index.js.map +1 -1
  49. package/dist/src/shadcn/components/ui/accordion.d.ts.map +1 -1
  50. package/dist/src/shadcn/components/ui/accordion.js +23 -5
  51. package/dist/src/shadcn/components/ui/accordion.js.map +1 -1
  52. package/dist/src/shadcn/components/ui/alert.d.ts.map +1 -1
  53. package/dist/src/shadcn/components/ui/alert.js +12 -5
  54. package/dist/src/shadcn/components/ui/alert.js.map +1 -1
  55. package/dist/src/shadcn/components/ui/avatar.d.ts.map +1 -1
  56. package/dist/src/shadcn/components/ui/avatar.js +4 -3
  57. package/dist/src/shadcn/components/ui/avatar.js.map +1 -1
  58. package/dist/src/shadcn/components/ui/badge.d.ts.map +1 -1
  59. package/dist/src/shadcn/components/ui/badge.js +16 -5
  60. package/dist/src/shadcn/components/ui/badge.js.map +1 -1
  61. package/dist/src/shadcn/components/ui/breadcrumb.d.ts.map +1 -1
  62. package/dist/src/shadcn/components/ui/breadcrumb.js +6 -6
  63. package/dist/src/shadcn/components/ui/breadcrumb.js.map +1 -1
  64. package/dist/src/shadcn/components/ui/button.d.ts.map +1 -1
  65. package/dist/src/shadcn/components/ui/button.js +19 -11
  66. package/dist/src/shadcn/components/ui/button.js.map +1 -1
  67. package/dist/src/shadcn/components/ui/card.d.ts.map +1 -1
  68. package/dist/src/shadcn/components/ui/card.js +14 -6
  69. package/dist/src/shadcn/components/ui/card.js.map +1 -1
  70. package/dist/src/shadcn/components/ui/carousel.d.ts.map +1 -1
  71. package/dist/src/shadcn/components/ui/carousel.js +1 -0
  72. package/dist/src/shadcn/components/ui/carousel.js.map +1 -1
  73. package/dist/src/shadcn/components/ui/checkbox.d.ts.map +1 -1
  74. package/dist/src/shadcn/components/ui/checkbox.js +20 -5
  75. package/dist/src/shadcn/components/ui/checkbox.js.map +1 -1
  76. package/dist/src/shadcn/components/ui/checkbox.stories.d.ts.map +1 -1
  77. package/dist/src/shadcn/components/ui/checkbox.stories.js +44 -35
  78. package/dist/src/shadcn/components/ui/checkbox.stories.js.map +1 -1
  79. package/dist/src/shadcn/components/ui/combobox.d.ts +18 -0
  80. package/dist/src/shadcn/components/ui/combobox.d.ts.map +1 -0
  81. package/dist/src/shadcn/components/ui/combobox.js +121 -0
  82. package/dist/src/shadcn/components/ui/combobox.js.map +1 -0
  83. package/dist/src/shadcn/components/ui/combobox.stories.d.ts +11 -0
  84. package/dist/src/shadcn/components/ui/combobox.stories.d.ts.map +1 -0
  85. package/dist/src/shadcn/components/ui/combobox.stories.js +16 -0
  86. package/dist/src/shadcn/components/ui/combobox.stories.js.map +1 -0
  87. package/dist/src/shadcn/components/ui/command.d.ts.map +1 -1
  88. package/dist/src/shadcn/components/ui/command.js +73 -12
  89. package/dist/src/shadcn/components/ui/command.js.map +1 -1
  90. package/dist/src/shadcn/components/ui/command.stories.js +0 -1
  91. package/dist/src/shadcn/components/ui/command.stories.js.map +1 -1
  92. package/dist/src/shadcn/components/ui/dialog.d.ts.map +1 -1
  93. package/dist/src/shadcn/components/ui/dialog.js +35 -7
  94. package/dist/src/shadcn/components/ui/dialog.js.map +1 -1
  95. package/dist/src/shadcn/components/ui/drawer.d.ts.map +1 -1
  96. package/dist/src/shadcn/components/ui/drawer.js +26 -5
  97. package/dist/src/shadcn/components/ui/drawer.js.map +1 -1
  98. package/dist/src/shadcn/components/ui/dropdown-menu.d.ts.map +1 -1
  99. package/dist/src/shadcn/components/ui/dropdown-menu.js +12 -1
  100. package/dist/src/shadcn/components/ui/dropdown-menu.js.map +1 -1
  101. package/dist/src/shadcn/components/ui/form.d.ts.map +1 -1
  102. package/dist/src/shadcn/components/ui/form.js +12 -4
  103. package/dist/src/shadcn/components/ui/form.js.map +1 -1
  104. package/dist/src/shadcn/components/ui/input-otp.d.ts.map +1 -1
  105. package/dist/src/shadcn/components/ui/input-otp.js +1 -0
  106. package/dist/src/shadcn/components/ui/input-otp.js.map +1 -1
  107. package/dist/src/shadcn/components/ui/input.d.ts.map +1 -1
  108. package/dist/src/shadcn/components/ui/input.js +87 -16
  109. package/dist/src/shadcn/components/ui/input.js.map +1 -1
  110. package/dist/src/shadcn/components/ui/label.d.ts.map +1 -1
  111. package/dist/src/shadcn/components/ui/label.js +8 -1
  112. package/dist/src/shadcn/components/ui/label.js.map +1 -1
  113. package/dist/src/shadcn/components/ui/menubar.d.ts.map +1 -1
  114. package/dist/src/shadcn/components/ui/menubar.js +35 -13
  115. package/dist/src/shadcn/components/ui/menubar.js.map +1 -1
  116. package/dist/src/shadcn/components/ui/pagination.d.ts.map +1 -1
  117. package/dist/src/shadcn/components/ui/pagination.js +6 -6
  118. package/dist/src/shadcn/components/ui/pagination.js.map +1 -1
  119. package/dist/src/shadcn/components/ui/popover.d.ts.map +1 -1
  120. package/dist/src/shadcn/components/ui/popover.js +12 -1
  121. package/dist/src/shadcn/components/ui/popover.js.map +1 -1
  122. package/dist/src/shadcn/components/ui/progress.d.ts.map +1 -1
  123. package/dist/src/shadcn/components/ui/progress.js +6 -2
  124. package/dist/src/shadcn/components/ui/progress.js.map +1 -1
  125. package/dist/src/shadcn/components/ui/radio-group.d.ts.map +1 -1
  126. package/dist/src/shadcn/components/ui/radio-group.js +11 -6
  127. package/dist/src/shadcn/components/ui/radio-group.js.map +1 -1
  128. package/dist/src/shadcn/components/ui/radio-group.stories.d.ts.map +1 -1
  129. package/dist/src/shadcn/components/ui/radio-group.stories.js +57 -34
  130. package/dist/src/shadcn/components/ui/radio-group.stories.js.map +1 -1
  131. package/dist/src/shadcn/components/ui/resizable.d.ts.map +1 -1
  132. package/dist/src/shadcn/components/ui/resizable.js +1 -0
  133. package/dist/src/shadcn/components/ui/resizable.js.map +1 -1
  134. package/dist/src/shadcn/components/ui/scroll-area.d.ts.map +1 -1
  135. package/dist/src/shadcn/components/ui/scroll-area.js +9 -3
  136. package/dist/src/shadcn/components/ui/scroll-area.js.map +1 -1
  137. package/dist/src/shadcn/components/ui/select.d.ts.map +1 -1
  138. package/dist/src/shadcn/components/ui/select.js +49 -14
  139. package/dist/src/shadcn/components/ui/select.js.map +1 -1
  140. package/dist/src/shadcn/components/ui/select.stories.d.ts.map +1 -1
  141. package/dist/src/shadcn/components/ui/select.stories.js +1 -4
  142. package/dist/src/shadcn/components/ui/select.stories.js.map +1 -1
  143. package/dist/src/shadcn/components/ui/separator.d.ts.map +1 -1
  144. package/dist/src/shadcn/components/ui/separator.js +7 -1
  145. package/dist/src/shadcn/components/ui/separator.js.map +1 -1
  146. package/dist/src/shadcn/components/ui/sidebar.d.ts.map +1 -1
  147. package/dist/src/shadcn/components/ui/sidebar.js +20 -6
  148. package/dist/src/shadcn/components/ui/sidebar.js.map +1 -1
  149. package/dist/src/shadcn/components/ui/skeleton.d.ts.map +1 -1
  150. package/dist/src/shadcn/components/ui/skeleton.js +3 -1
  151. package/dist/src/shadcn/components/ui/skeleton.js.map +1 -1
  152. package/dist/src/shadcn/components/ui/slider.d.ts.map +1 -1
  153. package/dist/src/shadcn/components/ui/slider.js +34 -4
  154. package/dist/src/shadcn/components/ui/slider.js.map +1 -1
  155. package/dist/src/shadcn/components/ui/sonner.d.ts +16 -1
  156. package/dist/src/shadcn/components/ui/sonner.d.ts.map +1 -1
  157. package/dist/src/shadcn/components/ui/sonner.js +23 -3
  158. package/dist/src/shadcn/components/ui/sonner.js.map +1 -1
  159. package/dist/src/shadcn/components/ui/sonner.stories.d.ts.map +1 -1
  160. package/dist/src/shadcn/components/ui/sonner.stories.js +19 -11
  161. package/dist/src/shadcn/components/ui/sonner.stories.js.map +1 -1
  162. package/dist/src/shadcn/components/ui/switch.d.ts.map +1 -1
  163. package/dist/src/shadcn/components/ui/switch.js +18 -2
  164. package/dist/src/shadcn/components/ui/switch.js.map +1 -1
  165. package/dist/src/shadcn/components/ui/table.d.ts.map +1 -1
  166. package/dist/src/shadcn/components/ui/table.js +12 -8
  167. package/dist/src/shadcn/components/ui/table.js.map +1 -1
  168. package/dist/src/shadcn/components/ui/tabs.d.ts +21 -3
  169. package/dist/src/shadcn/components/ui/tabs.d.ts.map +1 -1
  170. package/dist/src/shadcn/components/ui/tabs.js +314 -9
  171. package/dist/src/shadcn/components/ui/tabs.js.map +1 -1
  172. package/dist/src/shadcn/components/ui/tabs.stories.d.ts.map +1 -1
  173. package/dist/src/shadcn/components/ui/tabs.stories.js +50 -1
  174. package/dist/src/shadcn/components/ui/tabs.stories.js.map +1 -1
  175. package/dist/src/shadcn/components/ui/textarea.d.ts.map +1 -1
  176. package/dist/src/shadcn/components/ui/textarea.js +15 -1
  177. package/dist/src/shadcn/components/ui/textarea.js.map +1 -1
  178. package/dist/src/shadcn/components/ui/toggle-group.d.ts.map +1 -1
  179. package/dist/src/shadcn/components/ui/toggle-group.js +7 -2
  180. package/dist/src/shadcn/components/ui/toggle-group.js.map +1 -1
  181. package/dist/src/shadcn/components/ui/toggle.d.ts.map +1 -1
  182. package/dist/src/shadcn/components/ui/toggle.js +18 -6
  183. package/dist/src/shadcn/components/ui/toggle.js.map +1 -1
  184. package/dist/src/shadcn/components/ui/tooltip.d.ts.map +1 -1
  185. package/dist/src/shadcn/components/ui/tooltip.js +11 -1
  186. package/dist/src/shadcn/components/ui/tooltip.js.map +1 -1
  187. package/dist/src/shadcn/components/ui/tree.d.ts +20 -0
  188. package/dist/src/shadcn/components/ui/tree.d.ts.map +1 -0
  189. package/dist/src/shadcn/components/ui/tree.js +111 -0
  190. package/dist/src/shadcn/components/ui/tree.js.map +1 -0
  191. package/package.json +9 -2
  192. package/src/components/code-editor/http/grammar/http.grammar +74 -0
  193. package/src/components/code-editor/http/grammar/http.terms.ts +9 -0
  194. package/src/components/code-editor/http/grammar/http.test.ts +110 -0
  195. package/src/components/code-editor/http/grammar/http.ts +21 -0
  196. package/src/components/code-editor/http/index.ts +87 -0
  197. package/src/components/code-editor/index.tsx +182 -21
  198. package/src/components/code-editor.stories.tsx +1 -1
  199. package/src/components/request-line-editor.stories.tsx +17 -27
  200. package/src/components/request-line-editor.tsx +72 -61
  201. package/src/components/tree-view.stories.tsx +260 -0
  202. package/src/components/tree-view.tsx +101 -0
  203. package/src/icons.tsx +45 -0
  204. package/src/index.css +42 -3
  205. package/src/index.tsx +1 -1
  206. package/src/shadcn/components/ui/accordion.tsx +66 -8
  207. package/src/shadcn/components/ui/alert.tsx +53 -15
  208. package/src/shadcn/components/ui/avatar.tsx +17 -6
  209. package/src/shadcn/components/ui/badge.tsx +67 -18
  210. package/src/shadcn/components/ui/breadcrumb.tsx +35 -7
  211. package/src/shadcn/components/ui/button.tsx +118 -57
  212. package/src/shadcn/components/ui/card.tsx +44 -13
  213. package/src/shadcn/components/ui/carousel.tsx +1 -0
  214. package/src/shadcn/components/ui/checkbox.stories.tsx +20 -24
  215. package/src/shadcn/components/ui/checkbox.tsx +45 -4
  216. package/src/shadcn/components/ui/combobox.stories.tsx +19 -0
  217. package/src/shadcn/components/ui/combobox.tsx +142 -0
  218. package/src/shadcn/components/ui/command.stories.tsx +1 -1
  219. package/src/shadcn/components/ui/command.tsx +192 -36
  220. package/src/shadcn/components/ui/dialog.tsx +101 -13
  221. package/src/shadcn/components/ui/drawer.tsx +93 -18
  222. package/src/shadcn/components/ui/dropdown-menu.tsx +38 -9
  223. package/src/shadcn/components/ui/form.tsx +16 -4
  224. package/src/shadcn/components/ui/input-otp.tsx +1 -0
  225. package/src/shadcn/components/ui/input.tsx +281 -29
  226. package/src/shadcn/components/ui/label.tsx +21 -4
  227. package/src/shadcn/components/ui/menubar.tsx +188 -43
  228. package/src/shadcn/components/ui/pagination.tsx +12 -6
  229. package/src/shadcn/components/ui/popover.tsx +35 -4
  230. package/src/shadcn/components/ui/progress.tsx +21 -5
  231. package/src/shadcn/components/ui/radio-group.stories.tsx +22 -14
  232. package/src/shadcn/components/ui/radio-group.tsx +42 -5
  233. package/src/shadcn/components/ui/resizable.tsx +1 -0
  234. package/src/shadcn/components/ui/scroll-area.tsx +33 -5
  235. package/src/shadcn/components/ui/select.stories.tsx +0 -2
  236. package/src/shadcn/components/ui/select.tsx +184 -33
  237. package/src/shadcn/components/ui/separator.tsx +15 -5
  238. package/src/shadcn/components/ui/sidebar.tsx +68 -26
  239. package/src/shadcn/components/ui/skeleton.tsx +4 -1
  240. package/src/shadcn/components/ui/slider.tsx +82 -11
  241. package/src/shadcn/components/ui/sonner.stories.tsx +19 -15
  242. package/src/shadcn/components/ui/sonner.tsx +53 -3
  243. package/src/shadcn/components/ui/switch.tsx +53 -7
  244. package/src/shadcn/components/ui/table.tsx +38 -11
  245. package/src/shadcn/components/ui/tabs.stories.tsx +32 -0
  246. package/src/shadcn/components/ui/tabs.tsx +455 -17
  247. package/src/shadcn/components/ui/textarea.tsx +42 -4
  248. package/src/shadcn/components/ui/toggle-group.tsx +28 -5
  249. package/src/shadcn/components/ui/toggle.tsx +59 -18
  250. package/src/shadcn/components/ui/tooltip.tsx +33 -8
  251. package/src/shadcn/components/ui/tree.tsx +200 -0
@@ -1,3 +1,4 @@
1
+ import { cva } from "class-variance-authority";
1
2
  import type * as React from "react";
2
3
  import { Input } from "#shadcn/components/ui/input";
3
4
  import {
@@ -10,63 +11,66 @@ import {
10
11
  import { cn } from "#shadcn/lib/utils";
11
12
  import { CopyIcon } from "./copy-icon";
12
13
 
13
- interface RequestLineEditorProps extends React.ComponentProps<"div"> {
14
- selectedMethod: string;
15
- setMethod: (value: string) => void;
16
- methods: string[];
17
- inputValue?: string | undefined;
18
- onInputChange?: React.ChangeEventHandler<HTMLInputElement>;
19
- }
14
+ const METHODS = ["GET", "POST", "PUT", "PATCH", "DELETE"] as const;
15
+ type RequestMethod = (typeof METHODS)[number];
20
16
 
21
- const METHOD_COLORS = {
22
- GET: {
23
- text: "text-[#6D9F0F] [&_svg]:text-[#6D9F0F]!",
24
- background: "bg-green-200",
25
- border:
26
- "border-fg-success-secondary! hover:border-fg-success-secondary ring-green-200!",
27
- },
28
- POST: {
29
- text: "text-yellow-600 [&_svg]:text-yellow-600!",
30
- background: "bg-yellow-200",
31
- border: "border-[#F4CB00]! hover:border-[#F4CB00] ring-yellow-200!",
32
- },
33
- PUT: {
34
- text: "text-blue-500 [&_svg]:text-blue-500!",
35
- background: "bg-blue-200",
36
- border: "border-blue-400! hover:border-blue-400 ring-blue-200!",
37
- },
38
- PATCH: {
39
- text: "text-violet-600 [&_svg]:text-violet-600",
40
- background: "bg-violet-200",
41
- border: "border-violet-400! hover:border-violet-400 ring-violet-200!",
42
- },
43
- DELETE: {
44
- text: "text-red-600 [&_svg]:text-red-600!",
45
- background: "bg-red-200",
46
- border: "border-red-300! hover:border-red-300 ring-red-200!",
17
+ const requestMethodVariants = cva<{ method: { [K in RequestMethod]: string } }>(
18
+ cn(
19
+ "border-r-0",
20
+ "rounded-r-none",
21
+ "shadow-none",
22
+ "typo-label",
23
+ "text-left",
24
+ "items-center",
25
+ "w-26",
26
+ ),
27
+ {
28
+ variants: {
29
+ method: {
30
+ GET: "text-utility-green [&_svg]:text-utility-green",
31
+ POST: "text-utility-yellow [&_svg]:text-utility-yellow",
32
+ PUT: "text-utility-blue [&_svg]:text-utility-blue ",
33
+ PATCH: "text-utility-violet [&_svg]:text-utility-violet",
34
+ DELETE: "text-utility-red [&_svg]:text-utility-red",
35
+ },
36
+ },
47
37
  },
38
+ );
39
+
40
+ type RequestMethodSelectorProps = {
41
+ value: string;
42
+ onValueChange?: (newMethod: string) => void;
48
43
  };
49
44
 
45
+ function isKnownMethod(candidate: string): candidate is RequestMethod {
46
+ const methods: readonly string[] = METHODS;
47
+ return methods.includes(candidate);
48
+ }
49
+
50
50
  function RequestMethodSelector({
51
- selectedMethod,
52
- setMethod,
53
- methods,
54
- }: RequestLineEditorProps) {
51
+ value,
52
+ onValueChange,
53
+ }: RequestMethodSelectorProps) {
54
+ console.log(value);
55
+ console.log(requestMethodVariants());
56
+ console.log(requestMethodVariants(undefined));
55
57
  return (
56
- <Select value={selectedMethod} onValueChange={setMethod}>
58
+ <Select
59
+ value={value}
60
+ {...(onValueChange ? { onValueChange: onValueChange } : {})}
61
+ >
57
62
  <SelectTrigger
58
- className={`min-w-26 border-r-0 rounded-r-none shadow-none ${METHOD_COLORS[selectedMethod as keyof typeof METHOD_COLORS].text} ${METHOD_COLORS[selectedMethod as keyof typeof METHOD_COLORS].background} ${METHOD_COLORS[selectedMethod as keyof typeof METHOD_COLORS].border}`}
63
+ className={requestMethodVariants(
64
+ isKnownMethod(value) ? { method: value } : undefined,
65
+ )}
59
66
  >
60
- <SelectValue />
67
+ <SelectValue>{value}</SelectValue>
61
68
  </SelectTrigger>
62
69
  <SelectContent>
63
- {methods.map((method) => (
70
+ {METHODS.map((method) => (
64
71
  <SelectItem key={method} value={method}>
65
- <span
66
- className={`${METHOD_COLORS[method as keyof typeof METHOD_COLORS].text}`}
67
- >
68
- {" "}
69
- {method}{" "}
72
+ <span className={requestMethodVariants({ method: method })}>
73
+ {method}
70
74
  </span>
71
75
  </SelectItem>
72
76
  ))}
@@ -75,29 +79,36 @@ function RequestMethodSelector({
75
79
  );
76
80
  }
77
81
 
82
+ type RequestLineEditorProps = {
83
+ method: string;
84
+ onMethodChange: (newMethod: string) => void;
85
+ path?: string | undefined;
86
+ onPathChange?: React.ChangeEventHandler<HTMLInputElement>;
87
+ className?: string;
88
+ };
89
+
78
90
  function RequestLineEditor({
79
91
  className,
80
- selectedMethod,
81
- setMethod,
82
- methods,
83
- inputValue,
84
- onInputChange,
92
+ method,
93
+ onMethodChange,
94
+ path,
95
+ onPathChange,
85
96
  }: RequestLineEditorProps) {
86
97
  return (
87
98
  <div className={cn("flex", className)}>
88
- <RequestMethodSelector
89
- selectedMethod={selectedMethod}
90
- setMethod={setMethod}
91
- methods={methods}
92
- />
99
+ <RequestMethodSelector value={method} onValueChange={onMethodChange} />
93
100
  <Input
94
- className={`rounded-l-none ${METHOD_COLORS[selectedMethod as keyof typeof METHOD_COLORS].border}`}
95
- value={inputValue}
96
- rightSlot={<CopyIcon text={`${selectedMethod} ${inputValue}`} />}
97
- {...(onInputChange !== undefined ? { onChange: onInputChange } : {})}
101
+ className="rounded-l-none"
102
+ value={path}
103
+ rightSlot={<CopyIcon text={`${method} ${path}`} />}
104
+ {...(onPathChange !== undefined ? { onChange: onPathChange } : {})}
98
105
  />
99
106
  </div>
100
107
  );
101
108
  }
102
109
 
103
- export { RequestLineEditor, type RequestLineEditorProps, METHOD_COLORS };
110
+ export {
111
+ RequestLineEditor,
112
+ type RequestLineEditorProps,
113
+ requestMethodVariants,
114
+ };
@@ -0,0 +1,260 @@
1
+ import type { ItemInstance } from "@headless-tree/core";
2
+ import type { Meta, StoryObj } from "@storybook/react-vite";
3
+ import { Ellipsis, Pin, Plus } from "lucide-react";
4
+ import React from "react";
5
+ import { action } from "storybook/actions";
6
+ import { Button } from "#shadcn/components/ui/button.js";
7
+ import { PinIcon } from "../icons";
8
+ import type { Item } from "./tree-view";
9
+ import TreeView from "./tree-view";
10
+
11
+ const meta: Meta<typeof TreeView> = {
12
+ title: "Component/Tree view",
13
+ component: TreeView,
14
+ parameters: {
15
+ layout: "fullscreen",
16
+ },
17
+ tags: ["autodocs"],
18
+ };
19
+
20
+ export default meta;
21
+ type Story = StoryObj<typeof TreeView<ItemMeta>>;
22
+
23
+ type ItemMeta = {
24
+ pinned?: boolean;
25
+ method?: "GET" | "POST" | "PUT" | "DELETE" | "PATCH";
26
+ path?: string;
27
+ };
28
+
29
+ const items: Record<string, Item<ItemMeta>> = {
30
+ root: {
31
+ name: "Root",
32
+ children: ["collection1", "collection2", "collection3"],
33
+ },
34
+ collection1: {
35
+ name: "Collection 1",
36
+ children: ["request1", "request2", "request3"],
37
+ meta: {
38
+ pinned: true,
39
+ },
40
+ },
41
+ collection2: {
42
+ name: "Collection 2",
43
+ children: ["request4", "request5", "request6"],
44
+ },
45
+ collection3: {
46
+ name: "New Collection",
47
+ children: [
48
+ "request7",
49
+ "request8",
50
+ "request9",
51
+ "request10",
52
+ "request11",
53
+ "collection4",
54
+ ],
55
+ },
56
+ collection4: {
57
+ name: "New Collection",
58
+ children: ["request12", "request13", "request14"],
59
+ },
60
+ request1: {
61
+ meta: {
62
+ method: "GET",
63
+ path: "/request1",
64
+ },
65
+ name: "Request 1",
66
+ },
67
+ request2: {
68
+ meta: {
69
+ method: "POST",
70
+ path: "/request2",
71
+ },
72
+ name: "Request 2",
73
+ },
74
+ request3: {
75
+ meta: {
76
+ method: "PUT",
77
+ path: "/request3",
78
+ },
79
+ name: "Request 3",
80
+ },
81
+ request4: {
82
+ meta: {
83
+ method: "DELETE",
84
+ path: "/request4",
85
+ },
86
+ name: "Request 4",
87
+ },
88
+ request5: {
89
+ meta: {
90
+ method: "PATCH",
91
+ path: "/request5",
92
+ },
93
+ name: "Request 5",
94
+ },
95
+ request6: {
96
+ meta: {
97
+ method: "GET",
98
+ path: "/request6",
99
+ },
100
+ name: "Request 6",
101
+ },
102
+ request7: {
103
+ meta: {
104
+ method: "PATCH",
105
+ path: "/fhir/Patient/123",
106
+ },
107
+ name: "Request 7",
108
+ },
109
+ request8: {
110
+ meta: {
111
+ method: "DELETE",
112
+ path: "/fhir/Patient/123",
113
+ },
114
+ name: "Request 8",
115
+ },
116
+ request9: {
117
+ meta: {
118
+ method: "PUT",
119
+ path: "/fhir/Patient/123",
120
+ },
121
+ name: "Request 9",
122
+ },
123
+ request10: {
124
+ meta: {
125
+ method: "POST",
126
+ path: "/fhir/Patient/123",
127
+ },
128
+ name: "Request 10",
129
+ },
130
+ request11: {
131
+ meta: {
132
+ method: "GET",
133
+ path: "/fhir/Patient/123",
134
+ },
135
+ name: "Request 11",
136
+ },
137
+ request12: {
138
+ meta: {
139
+ method: "PUT",
140
+ path: "/fhir/Patient/123",
141
+ },
142
+ name: "Request 12",
143
+ },
144
+ request13: {
145
+ meta: {
146
+ method: "PUT",
147
+ path: "/fhir/Patient/123",
148
+ },
149
+ name: "Request 13",
150
+ },
151
+ request14: {
152
+ meta: {
153
+ method: "PUT",
154
+ path: "/fhir/Patient/123",
155
+ },
156
+ name: "Request 14",
157
+ },
158
+ };
159
+
160
+ export const Default: Story = {
161
+ args: {
162
+ items: items,
163
+ rootItemId: "root",
164
+ selectedItemId: "request9",
165
+ expandedItemIds: ["collection3"],
166
+ onSelectItem: (a) => action("onSelectItem")(a),
167
+ },
168
+ render: (args) => <TreeView {...args} />,
169
+ };
170
+
171
+ const customItemView = (item: ItemInstance<Item<ItemMeta>>) => {
172
+ const isRootLevel = item.getItemMeta().level === 0;
173
+ const hasChildren = item.getItemData()?.children !== undefined;
174
+ const requestMethhod = item.getItemData()?.meta?.method;
175
+ const requestPath = item.getItemData()?.meta?.path;
176
+ const itemName = item.getItemData()?.name;
177
+
178
+ const requestMethodView = () => {
179
+ switch (requestMethhod) {
180
+ case "GET":
181
+ return (
182
+ <div className=" opacity-50 group-hover/tree-item-label:opacity-100 in-data-[selected=true]:opacity-100 font-medium min-w-13 w-13 text-utility-green text-left">
183
+ GET
184
+ </div>
185
+ );
186
+ case "POST":
187
+ return (
188
+ <div className="opacity-50 group-hover/tree-item-label:opacity-100 in-data-[selected=true]:opacity-100 font-medium min-w-13 w-13 text-utility-yellow text-left">
189
+ POST
190
+ </div>
191
+ );
192
+ case "PUT":
193
+ return (
194
+ <div className="opacity-50 group-hover/tree-item-label:opacity-100 in-data-[selected=true]:opacity-100 font-medium min-w-13 w-13 text-utility-blue text-left">
195
+ PUT
196
+ </div>
197
+ );
198
+ case "PATCH":
199
+ return (
200
+ <div className="opacity-50 group-hover/tree-item-label:opacity-100 in-data-[selected=true]:opacity-100 font-medium min-w-13 w-13 text-utility-violet text-left">
201
+ PATCH
202
+ </div>
203
+ );
204
+ case "DELETE":
205
+ return (
206
+ <div className="opacity-50 group-hover/tree-item-label:opacity-100 in-data-[selected=true]:opacity-100 font-medium min-w-13 w-13 text-utility-red text-left">
207
+ DELETE
208
+ </div>
209
+ );
210
+ default:
211
+ return (
212
+ <div className="opacity-50 group-hover/tree-item-label:opacity-100 in-data-[selected=true]:opacity-100 font-medium min-w-13 w-13 text-utility-gray text-left">
213
+ Unknown
214
+ </div>
215
+ );
216
+ }
217
+ };
218
+
219
+ return (
220
+ <div className="w-full flex justify-between gap-2">
221
+ <div className="flex items-center gap-2 truncate">
222
+ {hasChildren ? (
223
+ itemName
224
+ ) : (
225
+ <React.Fragment>
226
+ {requestMethodView()}
227
+ {requestPath}
228
+ </React.Fragment>
229
+ )}
230
+ </div>
231
+ <div className="gap-2 hidden group-hover/tree-item-label:flex items-center">
232
+ {isRootLevel && (
233
+ <Button variant="link" size="small" className="p-0 h-4">
234
+ {item.getItemData()?.meta?.pinned ? <PinIcon /> : <Pin />}
235
+ </Button>
236
+ )}
237
+ {hasChildren && (
238
+ <Button variant="link" size="small" className="p-0 h-4">
239
+ <Plus />
240
+ </Button>
241
+ )}
242
+ <Button variant="link" size="small" className="p-0 h-4">
243
+ <Ellipsis />
244
+ </Button>
245
+ </div>
246
+ </div>
247
+ );
248
+ };
249
+
250
+ export const CustomItemView: Story = {
251
+ args: {
252
+ items: items,
253
+ rootItemId: "root",
254
+ selectedItemId: "request11",
255
+ expandedItemIds: ["collection3", "collection4"],
256
+ onSelectItem: (a) => action("onSelectItem")(a.getItemData()?.name),
257
+ customItemView: customItemView,
258
+ },
259
+ render: (args) => <TreeView {...args} />,
260
+ };
@@ -0,0 +1,101 @@
1
+ import type {
2
+ FeatureImplementation,
3
+ ItemInstance,
4
+ TreeConfig,
5
+ } from "@headless-tree/core";
6
+ import {
7
+ hotkeysCoreFeature,
8
+ selectionFeature,
9
+ syncDataLoaderFeature,
10
+ } from "@headless-tree/core";
11
+ import { useTree } from "@headless-tree/react";
12
+ import type React from "react";
13
+ import { Tree, TreeItem, TreeItemLabel } from "#shadcn/components/ui/tree";
14
+
15
+ export interface Item<T> {
16
+ name: string;
17
+ children?: string[];
18
+ meta?: T;
19
+ }
20
+
21
+ const customClickBehavior: FeatureImplementation = {
22
+ itemInstance: {
23
+ getProps: ({ tree, item, prev }) => ({
24
+ ...prev?.(),
25
+ onClick: () => {
26
+ item.primaryAction();
27
+ if (item.isExpanded()) {
28
+ item.collapse();
29
+ } else {
30
+ item.expand();
31
+ }
32
+ if (!item.isFolder()) {
33
+ tree.setSelectedItems([item.getItemMeta().itemId]);
34
+ }
35
+ },
36
+ }),
37
+ },
38
+ };
39
+
40
+ const indent = 20;
41
+
42
+ export default function TreeView<T>({
43
+ rootItemId,
44
+ items,
45
+ selectedItemId,
46
+ expandedItemIds,
47
+ onSelectItem,
48
+ customItemView,
49
+ }: {
50
+ rootItemId: string;
51
+ selectedItemId?: string;
52
+ expandedItemIds?: string[];
53
+ onSelectItem?: (item: ItemInstance<Item<T>>) => void;
54
+ items: Record<string, Item<T>>;
55
+ customItemView?: (item: ItemInstance<Item<T>>) => React.ReactNode;
56
+ }) {
57
+ const treeConfig: TreeConfig<Item<T>> = {
58
+ initialState: {
59
+ selectedItems: selectedItemId ? [selectedItemId] : [],
60
+ expandedItems: expandedItemIds ?? [],
61
+ },
62
+ indent,
63
+ rootItemId: rootItemId,
64
+ isItemFolder: (item: ItemInstance<Item<T>>) =>
65
+ item.getItemData()?.children !== undefined,
66
+ getItemName: (item: ItemInstance<Item<T>>) => item.getItemData()?.name,
67
+ dataLoader: {
68
+ getItem: (itemId) => items[itemId] as Item<T>,
69
+ getChildren: (itemId) => items[itemId]?.children ?? [],
70
+ },
71
+ features: [
72
+ syncDataLoaderFeature,
73
+ hotkeysCoreFeature,
74
+ selectionFeature,
75
+ customClickBehavior,
76
+ ],
77
+ };
78
+
79
+ const tree = useTree<Item<T>>(treeConfig);
80
+
81
+ return (
82
+ <Tree tree={tree} indent={indent}>
83
+ {tree.getItems().map((item) => {
84
+ return (
85
+ <TreeItem
86
+ key={item.getId()}
87
+ item={item}
88
+ className="relative before:absolute before:inset-0 before:-ms-1 before:bg-[repeating-linear-gradient(to_right,transparent_0,transparent_calc(var(--tree-indent)-1px),var(--border)_calc(var(--tree-indent)-1px),var(--border)_calc(var(--tree-indent)))]"
89
+ >
90
+ <TreeItemLabel
91
+ className="before:bg-background relative before:absolute before:inset-x-0 before:-inset-y-0 before:-z-10"
92
+ onClick={() => onSelectItem?.(item)}
93
+ >
94
+ {customItemView ? customItemView(item) : item.getItemData()?.name}
95
+ </TreeItemLabel>
96
+ </TreeItem>
97
+ );
98
+ })}
99
+ </Tree>
100
+ );
101
+ }
package/src/icons.tsx ADDED
@@ -0,0 +1,45 @@
1
+ export const PlayIcon = () => {
2
+ return (
3
+ <svg
4
+ width="16"
5
+ height="16"
6
+ viewBox="0 0 16 16"
7
+ fill="none"
8
+ xmlns="http://www.w3.org/2000/svg"
9
+ aria-label="Play"
10
+ role="img"
11
+ >
12
+ <title>Play</title>
13
+ <path
14
+ d="M3.76074 1.56153C3.92124 1.47395 4.11669 1.48025 4.27051 1.57911L13.6035 7.57911C13.7466 7.67111 13.833 7.82988 13.833 8.00001C13.833 8.17014 13.7466 8.32891 13.6035 8.42091L4.27051 14.4209C4.11669 14.5198 3.92124 14.5261 3.76074 14.4385C3.60021 14.3508 3.5 14.1829 3.5 14V2.00001C3.5 1.81711 3.60021 1.64918 3.76074 1.56153Z"
15
+ fill="white"
16
+ />
17
+ </svg>
18
+ );
19
+ };
20
+
21
+ export const PinIcon = () => {
22
+ return (
23
+ <svg
24
+ width="16"
25
+ height="16"
26
+ viewBox="0 0 16 16"
27
+ fill="none"
28
+ xmlns="http://www.w3.org/2000/svg"
29
+ aria-label="Pin"
30
+ role="img"
31
+ >
32
+ <path
33
+ d="M8 11.3334V14.6667"
34
+ stroke="#717684"
35
+ stroke-width="1.25"
36
+ stroke-linecap="round"
37
+ stroke-linejoin="round"
38
+ />
39
+ <path
40
+ d="M5.9987 7.17337C5.99857 7.42143 5.92924 7.66453 5.79851 7.87534C5.66778 8.08616 5.48084 8.25632 5.2587 8.36671L4.07203 8.96671C3.84989 9.07709 3.66295 9.24726 3.53222 9.45807C3.40149 9.66888 3.33216 9.91198 3.33203 10.16V10.6667C3.33203 10.8435 3.40227 11.0131 3.52729 11.1381C3.65232 11.2631 3.82189 11.3334 3.9987 11.3334H11.9987C12.1755 11.3334 12.3451 11.2631 12.4701 11.1381C12.5951 11.0131 12.6654 10.8435 12.6654 10.6667V10.16C12.6652 9.91198 12.5959 9.66888 12.4652 9.45807C12.3345 9.24726 12.1475 9.07709 11.9254 8.96671L10.7387 8.36671C10.5166 8.25632 10.3296 8.08616 10.1989 7.87534C10.0682 7.66453 9.99883 7.42143 9.9987 7.17337V4.66671C9.9987 4.4899 10.0689 4.32033 10.194 4.1953C10.319 4.07028 10.4886 4.00004 10.6654 4.00004C11.019 4.00004 11.3581 3.85957 11.6082 3.60952C11.8582 3.35947 11.9987 3.02033 11.9987 2.66671C11.9987 2.31309 11.8582 1.97395 11.6082 1.7239C11.3581 1.47385 11.019 1.33337 10.6654 1.33337H5.33203C4.97841 1.33337 4.63927 1.47385 4.38922 1.7239C4.13917 1.97395 3.9987 2.31309 3.9987 2.66671C3.9987 3.02033 4.13917 3.35947 4.38922 3.60952C4.63927 3.85957 4.97841 4.00004 5.33203 4.00004C5.50884 4.00004 5.67841 4.07028 5.80344 4.1953C5.92846 4.32033 5.9987 4.4899 5.9987 4.66671V7.17337Z"
41
+ fill="#717684"
42
+ />
43
+ </svg>
44
+ );
45
+ };
package/src/index.css CHANGED
@@ -3,6 +3,11 @@
3
3
  @import "./tokens.css";
4
4
  @import "./typography.css";
5
5
 
6
+ .lucide {
7
+ /* Change this! */
8
+ stroke-width: 1.5px;
9
+ }
10
+
6
11
  @theme {
7
12
  --color-selection: var(--color-blue-300);
8
13
  --color-ring-red: var(--color-red-200);
@@ -11,7 +16,7 @@
11
16
  --color-ring-purple: var(--color-purple-200);
12
17
  --color-ring-orange: var(--color-orange-200);
13
18
  --color-ring-pink: var(--color-pink-200);
14
- --color-ring-blue: var(--color-blue-300);
19
+ --color-ring-blue: var(--color-blue-200);
15
20
  --color-ring-red: var(--color-red-200);
16
21
  --color-text-primary: var(--color-neutral-900);
17
22
  --color-text-secondary: var(--color-neutral-500);
@@ -19,12 +24,13 @@
19
24
  --color-text-primary_on-brand: var(--color-neutral-50);
20
25
  --color-text-secondary_on-brand: var(--color-neutral-100);
21
26
  --color-text-tertiary: var(--color-neutral-400);
27
+ --color-text-tertiary_hover: var(--color-neutral-500);
22
28
  --color-text-quternary: var(--color-neutral-400);
23
29
  --color-text-quternary_hover: var(--color-neutral-500);
24
30
  --color-text-quternary_on-brand: var(--color-neutral-200);
25
31
  --color-text-disabled: var(--color-neutral-300);
26
32
  --color-text-link: var(--color-blue-500);
27
- --color-text-link_hover: var(--color-blue-600);
33
+ --color-text-link_hover: var(--color-blue-700);
28
34
  --color-text-link_disabled: var(--color-blue-400);
29
35
  --color-text-brand-primary: var(--color-brand-500);
30
36
  --color-text-brand-secondary: var(--color-brand-300);
@@ -39,6 +45,7 @@
39
45
  --color-border-secondary: var(--color-neutral-200);
40
46
  --color-border-separator: var(--color-neutral-200);
41
47
  --color-border-disabled: var(--color-neutral-100);
48
+ --color-border-dark: var(--color-neutral-500);
42
49
  --color-border-brand: var(--color-brand-500);
43
50
  --color-border-link: var(--color-blue-500);
44
51
  --color-border-error: var(--color-red-500);
@@ -90,7 +97,6 @@
90
97
  --color-fg-success-secondary: var(--color-green-400);
91
98
  --color-fg-warning-primary: var(--color-yellow-500);
92
99
  --color-fg-warning-secondary: var(--color-yellow-400);
93
-
94
100
  --color-utility-green: var(--color-green-500);
95
101
  --color-utility-yellow: var(--color-yellow-600);
96
102
  --color-utility-blue: var(--color-blue-500);
@@ -102,3 +108,36 @@
102
108
  --font-family-sans: "Inter", system-ui, sans-serif;
103
109
  --font-family-mono: "JetBrains Mono", monospace;
104
110
  }
111
+
112
+ .no-scrollbar::-webkit-scrollbar {
113
+ display: none;
114
+ }
115
+
116
+ .no-scrollbar {
117
+ -ms-overflow-style: none;
118
+ scrollbar-width: none;
119
+ }
120
+
121
+ body ::-webkit-scrollbar {
122
+ width: 6px;
123
+ height: 6px;
124
+ }
125
+
126
+ body ::-webkit-scrollbar-track {
127
+ background: transparent;
128
+ }
129
+
130
+ body ::-webkit-scrollbar-thumb {
131
+ background-color: var(--color-elements-disabled);
132
+ border-radius: 4px;
133
+ }
134
+
135
+ body ::-webkit-scrollbar-thumb:hover {
136
+ background-color: var(--color-elements-assistive);
137
+ }
138
+ @supports not selector(::-webkit-scrollbar) {
139
+ body {
140
+ scrollbar-color: var(--color-elements-disabled) rgba(0, 0, 0, 0);
141
+ scrollbar-width: thin;
142
+ }
143
+ }
package/src/index.tsx CHANGED
@@ -1,9 +1,9 @@
1
1
  // Shadcn Components
2
2
 
3
- export * from "./components/code-editor";
4
3
  export * from "./components/code-editor";
5
4
  export * from "./components/copy-icon";
6
5
  export * from "./components/request-line-editor";
6
+ export * from "./icons";
7
7
  export * from "./shadcn/components/ui/accordion";
8
8
  export * from "./shadcn/components/ui/alert";
9
9
  export * from "./shadcn/components/ui/alert-dialog";