@vllnt/ui 0.1.4 → 0.1.7-canary.2c4792f

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (225) hide show
  1. package/dist/components/accordion/accordion.js +172 -0
  2. package/dist/components/accordion/index.js +12 -0
  3. package/dist/components/alert/alert.js +53 -0
  4. package/dist/components/alert/index.js +7 -0
  5. package/dist/components/alert-dialog/alert-dialog.js +117 -0
  6. package/dist/components/alert-dialog/index.js +26 -0
  7. package/dist/components/aspect-ratio/aspect-ratio.js +6 -0
  8. package/dist/components/aspect-ratio/index.js +4 -0
  9. package/dist/components/avatar/avatar.js +43 -0
  10. package/dist/components/avatar/index.js +6 -0
  11. package/dist/components/badge/badge.js +26 -0
  12. package/dist/components/badge/index.js +5 -0
  13. package/dist/components/blog-card/blog-card.js +50 -0
  14. package/dist/components/blog-card/index.js +5 -0
  15. package/dist/components/breadcrumb/breadcrumb.js +61 -0
  16. package/dist/components/breadcrumb/index.js +4 -0
  17. package/dist/components/button/button.js +48 -0
  18. package/dist/components/button/index.js +5 -0
  19. package/dist/components/calendar/calendar.js +71 -0
  20. package/dist/components/calendar/index.js +4 -0
  21. package/dist/components/callout/callout.js +59 -0
  22. package/dist/components/callout/index.js +4 -0
  23. package/dist/components/card/card.js +64 -0
  24. package/dist/components/card/index.js +16 -0
  25. package/dist/components/carousel/carousel.js +239 -0
  26. package/dist/components/carousel/index.js +14 -0
  27. package/dist/components/category-filter/category-filter.js +34 -0
  28. package/dist/components/category-filter/index.js +4 -0
  29. package/dist/components/chart/area-chart.js +99 -0
  30. package/dist/components/chart/bar-chart.js +80 -0
  31. package/dist/components/chart/index.js +3 -0
  32. package/dist/components/chart/line-chart.js +97 -0
  33. package/dist/components/checkbox/checkbox.js +28 -0
  34. package/dist/components/checkbox/index.js +4 -0
  35. package/dist/components/checklist/checklist.js +181 -0
  36. package/dist/components/checklist/index.js +6 -0
  37. package/dist/components/code-block/code-block.js +126 -0
  38. package/dist/components/code-block/index.js +4 -0
  39. package/dist/components/code-playground/code-playground.js +86 -0
  40. package/dist/components/code-playground/index.js +8 -0
  41. package/dist/components/collapsible/collapsible.js +10 -0
  42. package/dist/components/collapsible/index.js +10 -0
  43. package/dist/components/command/command.js +123 -0
  44. package/dist/components/command/index.js +22 -0
  45. package/dist/components/comparison/comparison.js +121 -0
  46. package/dist/components/comparison/index.js +8 -0
  47. package/dist/components/completion-dialog/completion-dialog.js +173 -0
  48. package/dist/components/completion-dialog/index.js +6 -0
  49. package/dist/components/content-intro/content-intro.js +144 -0
  50. package/dist/components/content-intro/index.js +6 -0
  51. package/dist/components/context-menu/context-menu.js +154 -0
  52. package/dist/components/context-menu/index.js +34 -0
  53. package/dist/components/cookie-consent/cookie-consent.js +175 -0
  54. package/dist/components/cookie-consent/index.js +8 -0
  55. package/dist/components/dialog/dialog.js +105 -0
  56. package/dist/components/dialog/index.js +24 -0
  57. package/dist/components/drawer/drawer.js +102 -0
  58. package/dist/components/drawer/index.js +24 -0
  59. package/dist/components/dropdown-menu/dropdown-menu.js +151 -0
  60. package/dist/components/dropdown-menu/index.js +34 -0
  61. package/dist/components/exercise/exercise.js +112 -0
  62. package/dist/components/exercise/index.js +4 -0
  63. package/dist/components/faq/faq.js +56 -0
  64. package/dist/components/faq/index.js +5 -0
  65. package/dist/components/filter-bar/filter-bar.js +244 -0
  66. package/dist/components/filter-bar/index.js +6 -0
  67. package/dist/components/floating-action-button/floating-action-button.js +35 -0
  68. package/dist/components/floating-action-button/index.js +6 -0
  69. package/dist/components/flow-diagram/flow-canvas.js +109 -0
  70. package/dist/components/flow-diagram/flow-controls.js +140 -0
  71. package/dist/components/flow-diagram/flow-diagram.js +114 -0
  72. package/dist/components/flow-diagram/flow-error-boundary.js +63 -0
  73. package/dist/components/flow-diagram/flow-fullscreen.js +58 -0
  74. package/dist/components/flow-diagram/index.js +12 -0
  75. package/dist/components/flow-diagram/types.js +0 -0
  76. package/dist/components/flow-diagram/use-flow-diagram.js +146 -0
  77. package/dist/components/horizontal-scroll-row/horizontal-scroll-row.js +66 -0
  78. package/dist/components/horizontal-scroll-row/index.js +6 -0
  79. package/dist/components/hover-card/hover-card.js +26 -0
  80. package/dist/components/hover-card/index.js +6 -0
  81. package/dist/components/index.js +641 -0
  82. package/dist/components/inline-input/index.js +4 -0
  83. package/dist/components/inline-input/inline-input.js +42 -0
  84. package/dist/components/input/index.js +4 -0
  85. package/dist/components/input/input.js +23 -0
  86. package/dist/components/input-otp/index.js +12 -0
  87. package/dist/components/input-otp/input-otp.js +54 -0
  88. package/dist/components/key-concept/index.js +8 -0
  89. package/dist/components/key-concept/key-concept.js +79 -0
  90. package/dist/components/keyboard-shortcuts-help/index.js +6 -0
  91. package/dist/components/keyboard-shortcuts-help/keyboard-shortcuts-help.js +121 -0
  92. package/dist/components/label/index.js +4 -0
  93. package/dist/components/label/label.js +21 -0
  94. package/dist/components/lang-provider/index.js +4 -0
  95. package/dist/components/lang-provider/lang-provider.js +18 -0
  96. package/dist/components/learning-objectives/index.js +10 -0
  97. package/dist/components/learning-objectives/learning-objectives.js +76 -0
  98. package/dist/components/mdx-content/index.js +4 -0
  99. package/dist/components/mdx-content/mdx-content.js +151 -0
  100. package/dist/components/menubar/index.js +36 -0
  101. package/dist/components/menubar/menubar.js +183 -0
  102. package/dist/components/model-selector/index.js +6 -0
  103. package/dist/components/model-selector/model-selector.js +374 -0
  104. package/dist/components/navbar-saas/index.js +6 -0
  105. package/dist/components/navbar-saas/navbar-saas.js +68 -0
  106. package/dist/components/navbar-saas/use-mobile.js +19 -0
  107. package/dist/components/navigation-menu/index.js +22 -0
  108. package/dist/components/navigation-menu/navigation-menu.js +108 -0
  109. package/dist/components/pagination/index.js +4 -0
  110. package/dist/components/pagination/pagination.js +44 -0
  111. package/dist/components/popover/index.js +12 -0
  112. package/dist/components/popover/popover.js +28 -0
  113. package/dist/components/pro-tip/index.js +8 -0
  114. package/dist/components/pro-tip/pro-tip.js +139 -0
  115. package/dist/components/profile-section/index.js +4 -0
  116. package/dist/components/profile-section/profile-section.js +45 -0
  117. package/dist/components/progress-bar/index.js +4 -0
  118. package/dist/components/progress-bar/progress-bar.js +56 -0
  119. package/dist/components/progress-card/index.js +6 -0
  120. package/dist/components/progress-card/progress-card.js +71 -0
  121. package/dist/components/quiz/index.js +4 -0
  122. package/dist/components/quiz/quiz.js +210 -0
  123. package/dist/components/radio-group/index.js +5 -0
  124. package/dist/components/radio-group/radio-group.js +36 -0
  125. package/dist/components/resizable/index.js +10 -0
  126. package/dist/components/resizable/resizable.js +39 -0
  127. package/dist/components/scroll-area/index.js +5 -0
  128. package/dist/components/scroll-area/scroll-area.js +39 -0
  129. package/dist/components/search-bar/index.js +4 -0
  130. package/dist/components/search-bar/search-bar.js +122 -0
  131. package/dist/components/search-dialog/index.js +4 -0
  132. package/dist/components/search-dialog/search-dialog.js +102 -0
  133. package/dist/components/select/index.js +24 -0
  134. package/dist/components/select/select.js +125 -0
  135. package/dist/components/separator/index.js +4 -0
  136. package/dist/components/separator/separator.js +25 -0
  137. package/dist/components/share-dialog/index.js +6 -0
  138. package/dist/components/share-dialog/share-dialog.js +121 -0
  139. package/dist/components/share-section/index.js +6 -0
  140. package/dist/components/share-section/share-section.js +57 -0
  141. package/dist/components/sheet/index.js +24 -0
  142. package/dist/components/sheet/sheet.js +116 -0
  143. package/dist/components/sidebar/index.js +4 -0
  144. package/dist/components/sidebar/sidebar.js +188 -0
  145. package/dist/components/sidebar-provider/index.js +5 -0
  146. package/dist/components/sidebar-provider/sidebar-provider.js +25 -0
  147. package/dist/components/sidebar-toggle/index.js +4 -0
  148. package/dist/components/sidebar-toggle/sidebar-toggle.js +36 -0
  149. package/dist/components/skeleton/index.js +4 -0
  150. package/dist/components/skeleton/skeleton.js +17 -0
  151. package/dist/components/slider/index.js +4 -0
  152. package/dist/components/slider/slider.js +24 -0
  153. package/dist/components/slideshow/index.js +6 -0
  154. package/dist/components/slideshow/slideshow.js +440 -0
  155. package/dist/components/social-fab/index.js +6 -0
  156. package/dist/components/social-fab/social-fab.js +211 -0
  157. package/dist/components/social-fab/use-social-fab.js +111 -0
  158. package/dist/components/spinner/index.js +4 -0
  159. package/dist/components/spinner/spinner.js +23 -0
  160. package/dist/components/step-by-step/index.js +8 -0
  161. package/dist/components/step-by-step/step-by-step.js +194 -0
  162. package/dist/components/step-navigation/index.js +4 -0
  163. package/dist/components/step-navigation/step-navigation.js +119 -0
  164. package/dist/components/switch/index.js +4 -0
  165. package/dist/components/switch/switch.js +28 -0
  166. package/dist/components/table/index.js +20 -0
  167. package/dist/components/table/table.js +87 -0
  168. package/dist/components/table-of-contents/index.js +4 -0
  169. package/dist/components/table-of-contents/table-of-contents.js +71 -0
  170. package/dist/components/table-of-contents-panel/index.js +6 -0
  171. package/dist/components/table-of-contents-panel/table-of-contents-panel.js +202 -0
  172. package/dist/components/tabs/index.js +12 -0
  173. package/dist/components/tabs/tabs.js +84 -0
  174. package/dist/components/terminal/index.js +8 -0
  175. package/dist/components/terminal/terminal.js +119 -0
  176. package/dist/components/textarea/index.js +4 -0
  177. package/dist/components/textarea/textarea.js +22 -0
  178. package/dist/components/theme-provider/index.js +4 -0
  179. package/dist/components/theme-provider/theme-provider.js +11 -0
  180. package/dist/components/theme-toggle/index.js +4 -0
  181. package/dist/components/theme-toggle/theme-toggle.js +170 -0
  182. package/dist/components/thinking-block/index.js +4 -0
  183. package/dist/components/thinking-block/thinking-block.js +56 -0
  184. package/dist/components/tldr-section/index.js +4 -0
  185. package/dist/components/tldr-section/tldr-section.js +101 -0
  186. package/dist/components/toast/index.js +18 -0
  187. package/dist/components/toast/toast.js +84 -0
  188. package/dist/components/toast/toaster.js +38 -0
  189. package/dist/components/toggle/index.js +5 -0
  190. package/dist/components/toggle/toggle.js +39 -0
  191. package/dist/components/toggle-group/index.js +5 -0
  192. package/dist/components/toggle-group/toggle-group.js +46 -0
  193. package/dist/components/tooltip/index.js +12 -0
  194. package/dist/components/tooltip/tooltip.js +27 -0
  195. package/dist/components/truncated-text/index.js +4 -0
  196. package/dist/components/truncated-text/truncated-text.js +25 -0
  197. package/dist/components/tutorial-card/index.js +6 -0
  198. package/dist/components/tutorial-card/tutorial-card.js +78 -0
  199. package/dist/components/tutorial-complete/index.js +6 -0
  200. package/dist/components/tutorial-complete/tutorial-complete.js +134 -0
  201. package/dist/components/tutorial-filters/index.js +6 -0
  202. package/dist/components/tutorial-filters/tutorial-filters.js +205 -0
  203. package/dist/components/tutorial-intro-content/index.js +6 -0
  204. package/dist/components/tutorial-intro-content/tutorial-intro-content.js +141 -0
  205. package/dist/components/tutorial-mdx/index.js +8 -0
  206. package/dist/components/tutorial-mdx/tutorial-mdx.js +219 -0
  207. package/dist/components/video-embed/index.js +4 -0
  208. package/dist/components/video-embed/video-embed.js +77 -0
  209. package/dist/components/view-switcher/index.js +6 -0
  210. package/dist/components/view-switcher/view-switcher.js +92 -0
  211. package/dist/index.d.ts +44 -2
  212. package/dist/index.js +14 -8556
  213. package/dist/lib/types.js +11 -0
  214. package/dist/lib/use-debounce.js +17 -0
  215. package/dist/lib/use-horizontal-scroll.js +60 -0
  216. package/dist/lib/use-mounted.js +17 -0
  217. package/dist/lib/utils.js +8 -0
  218. package/dist/tailwind-preset.d.ts +5 -0
  219. package/dist/tailwind-preset.js +9 -10
  220. package/dist/types/content.js +0 -0
  221. package/dist/types/index.js +0 -0
  222. package/package.json +42 -23
  223. package/LICENSE +0 -21
  224. package/dist/chunk-XRV5RSYH.js +0 -569
  225. package/dist/flow-diagram-N3EHM6VB.js +0 -2
@@ -0,0 +1,210 @@
1
+ "use client";
2
+ import { jsx, jsxs } from "react/jsx-runtime";
3
+ import { useState } from "react";
4
+ import { cn } from "../../lib/utils";
5
+ function QuizOptionButton({
6
+ index,
7
+ onSelect,
8
+ option,
9
+ selectedIndex,
10
+ submitted
11
+ }) {
12
+ const isSelected = selectedIndex === index;
13
+ const showResult = submitted && isSelected;
14
+ return /* @__PURE__ */ jsxs(
15
+ "button",
16
+ {
17
+ className: cn(
18
+ "w-full text-left p-3 rounded-md border transition-colors hover:bg-muted/50 focus:outline-none focus:ring-2 focus:ring-primary",
19
+ isSelected && !submitted && "border-primary bg-primary/10",
20
+ showResult && option.correct && "border-green-500 bg-green-500/10",
21
+ showResult && !option.correct && "border-red-500 bg-red-500/10",
22
+ submitted && !isSelected && option.correct && "border-green-500/50 bg-green-500/5"
23
+ ),
24
+ disabled: submitted,
25
+ onClick: () => {
26
+ onSelect(index);
27
+ },
28
+ type: "button",
29
+ children: [
30
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between", children: [
31
+ /* @__PURE__ */ jsx("span", { className: "text-sm", children: option.label }),
32
+ showResult ? option.correct ? /* @__PURE__ */ jsx(
33
+ "svg",
34
+ {
35
+ className: "h-4 w-4 text-green-500",
36
+ fill: "none",
37
+ stroke: "currentColor",
38
+ viewBox: "0 0 24 24",
39
+ children: /* @__PURE__ */ jsx(
40
+ "path",
41
+ {
42
+ d: "M5 13l4 4L19 7",
43
+ strokeLinecap: "round",
44
+ strokeLinejoin: "round",
45
+ strokeWidth: 2
46
+ }
47
+ )
48
+ }
49
+ ) : /* @__PURE__ */ jsx(
50
+ "svg",
51
+ {
52
+ className: "h-4 w-4 text-red-500",
53
+ fill: "none",
54
+ stroke: "currentColor",
55
+ viewBox: "0 0 24 24",
56
+ children: /* @__PURE__ */ jsx(
57
+ "path",
58
+ {
59
+ d: "M6 18L18 6M6 6l12 12",
60
+ strokeLinecap: "round",
61
+ strokeLinejoin: "round",
62
+ strokeWidth: 2
63
+ }
64
+ )
65
+ }
66
+ ) : null,
67
+ submitted && !isSelected && option.correct ? /* @__PURE__ */ jsx(
68
+ "svg",
69
+ {
70
+ className: "h-4 w-4 text-green-500/50",
71
+ fill: "none",
72
+ stroke: "currentColor",
73
+ viewBox: "0 0 24 24",
74
+ children: /* @__PURE__ */ jsx(
75
+ "path",
76
+ {
77
+ d: "M5 13l4 4L19 7",
78
+ strokeLinecap: "round",
79
+ strokeLinejoin: "round",
80
+ strokeWidth: 2
81
+ }
82
+ )
83
+ }
84
+ ) : null
85
+ ] }),
86
+ submitted && option.explanation ? /* @__PURE__ */ jsx("p", { className: "text-xs text-muted-foreground mt-2", children: option.explanation }) : null
87
+ ]
88
+ }
89
+ );
90
+ }
91
+ function QuizHint({ hint, onShow, showHint }) {
92
+ return /* @__PURE__ */ jsx("div", { className: "mb-4", children: showHint ? /* @__PURE__ */ jsx("p", { className: "text-sm text-muted-foreground italic bg-muted/50 p-2 rounded", children: hint }) : /* @__PURE__ */ jsx(
93
+ "button",
94
+ {
95
+ className: "text-sm text-primary hover:underline",
96
+ onClick: onShow,
97
+ type: "button",
98
+ children: "Show hint"
99
+ }
100
+ ) });
101
+ }
102
+ function QuizResult({
103
+ explanation,
104
+ isCorrect
105
+ }) {
106
+ return /* @__PURE__ */ jsxs(
107
+ "div",
108
+ {
109
+ className: cn(
110
+ "p-3 rounded-md text-sm mb-4",
111
+ isCorrect ? "bg-green-500/10 text-green-700 dark:text-green-300" : "bg-muted"
112
+ ),
113
+ children: [
114
+ /* @__PURE__ */ jsx("p", { className: "font-medium mb-1", children: isCorrect ? "Correct!" : "Not quite right." }),
115
+ /* @__PURE__ */ jsx("div", { className: "[&>p]:mb-0", children: explanation })
116
+ ]
117
+ }
118
+ );
119
+ }
120
+ function Quiz({
121
+ className,
122
+ explanation,
123
+ hint,
124
+ onAnswer,
125
+ options,
126
+ question
127
+ }) {
128
+ const [selectedIndex, setSelectedIndex] = useState(null);
129
+ const [showHint, setShowHint] = useState(false);
130
+ const [submitted, setSubmitted] = useState(false);
131
+ const handleReset = () => {
132
+ setSelectedIndex(null);
133
+ setSubmitted(false);
134
+ setShowHint(false);
135
+ };
136
+ const handleSubmit = () => {
137
+ setSubmitted(true);
138
+ const isCorrect2 = selectedIndex !== null && options[selectedIndex]?.correct;
139
+ onAnswer?.(Boolean(isCorrect2));
140
+ };
141
+ const isCorrect = selectedIndex !== null && options[selectedIndex]?.correct;
142
+ return /* @__PURE__ */ jsxs("div", { className: cn("my-6 rounded-lg border bg-card p-6", className), children: [
143
+ /* @__PURE__ */ jsxs("div", { className: "flex items-start gap-3 mb-4", children: [
144
+ /* @__PURE__ */ jsx(
145
+ "svg",
146
+ {
147
+ className: "h-5 w-5 text-primary flex-shrink-0 mt-0.5",
148
+ fill: "none",
149
+ stroke: "currentColor",
150
+ viewBox: "0 0 24 24",
151
+ children: /* @__PURE__ */ jsx(
152
+ "path",
153
+ {
154
+ d: "M8.228 9c.549-1.165 2.03-2 3.772-2 2.21 0 4 1.343 4 3 0 1.4-1.278 2.575-3.006 2.907-.542.104-.994.54-.994 1.093m0 3h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z",
155
+ strokeLinecap: "round",
156
+ strokeLinejoin: "round",
157
+ strokeWidth: 2
158
+ }
159
+ )
160
+ }
161
+ ),
162
+ /* @__PURE__ */ jsx("h4", { className: "font-semibold text-foreground", children: question })
163
+ ] }),
164
+ /* @__PURE__ */ jsx("div", { className: "space-y-2 mb-4", children: options.map((opt, index) => /* @__PURE__ */ jsx(
165
+ QuizOptionButton,
166
+ {
167
+ index,
168
+ onSelect: (index_) => {
169
+ if (!submitted) setSelectedIndex(index_);
170
+ },
171
+ option: opt,
172
+ selectedIndex,
173
+ submitted
174
+ },
175
+ index
176
+ )) }),
177
+ hint && !submitted ? /* @__PURE__ */ jsx(
178
+ QuizHint,
179
+ {
180
+ hint,
181
+ onShow: () => {
182
+ setShowHint(true);
183
+ },
184
+ showHint
185
+ }
186
+ ) : null,
187
+ submitted && explanation ? /* @__PURE__ */ jsx(QuizResult, { explanation, isCorrect: Boolean(isCorrect) }) : null,
188
+ /* @__PURE__ */ jsx("div", { className: "flex gap-2", children: submitted ? /* @__PURE__ */ jsx(
189
+ "button",
190
+ {
191
+ className: "px-3 py-1.5 text-sm rounded-md border border-border hover:bg-muted transition-colors",
192
+ onClick: handleReset,
193
+ type: "button",
194
+ children: "Try Again"
195
+ }
196
+ ) : /* @__PURE__ */ jsx(
197
+ "button",
198
+ {
199
+ className: "px-3 py-1.5 text-sm rounded-md bg-primary text-primary-foreground hover:bg-primary/90 disabled:opacity-50 disabled:pointer-events-none transition-colors",
200
+ disabled: selectedIndex === null,
201
+ onClick: handleSubmit,
202
+ type: "button",
203
+ children: "Check Answer"
204
+ }
205
+ ) })
206
+ ] });
207
+ }
208
+ export {
209
+ Quiz
210
+ };
@@ -0,0 +1,5 @@
1
+ import { RadioGroup, RadioGroupItem } from "./radio-group";
2
+ export {
3
+ RadioGroup,
4
+ RadioGroupItem
5
+ };
@@ -0,0 +1,36 @@
1
+ "use client";
2
+ import { jsx } from "react/jsx-runtime";
3
+ import { forwardRef } from "react";
4
+ import * as RadioGroupPrimitive from "@radix-ui/react-radio-group";
5
+ import { Circle } from "lucide-react";
6
+ import { cn } from "../../lib/utils";
7
+ const RadioGroup = forwardRef(({ className, ...props }, ref) => {
8
+ return /* @__PURE__ */ jsx(
9
+ RadioGroupPrimitive.Root,
10
+ {
11
+ className: cn("grid gap-2", className),
12
+ ...props,
13
+ ref
14
+ }
15
+ );
16
+ });
17
+ RadioGroup.displayName = RadioGroupPrimitive.Root.displayName;
18
+ const RadioGroupItem = forwardRef(({ className, ...props }, ref) => {
19
+ return /* @__PURE__ */ jsx(
20
+ RadioGroupPrimitive.Item,
21
+ {
22
+ className: cn(
23
+ "aspect-square h-4 w-4 rounded-full border border-primary text-primary ring-offset-background focus:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",
24
+ className
25
+ ),
26
+ ref,
27
+ ...props,
28
+ children: /* @__PURE__ */ jsx(RadioGroupPrimitive.Indicator, { className: "flex items-center justify-center", children: /* @__PURE__ */ jsx(Circle, { className: "h-2.5 w-2.5 fill-current text-current" }) })
29
+ }
30
+ );
31
+ });
32
+ RadioGroupItem.displayName = RadioGroupPrimitive.Item.displayName;
33
+ export {
34
+ RadioGroup,
35
+ RadioGroupItem
36
+ };
@@ -0,0 +1,10 @@
1
+ import {
2
+ ResizableHandle,
3
+ ResizablePanel,
4
+ ResizablePanelGroup
5
+ } from "./resizable";
6
+ export {
7
+ ResizableHandle,
8
+ ResizablePanel,
9
+ ResizablePanelGroup
10
+ };
@@ -0,0 +1,39 @@
1
+ "use client";
2
+ import { jsx } from "react/jsx-runtime";
3
+ import { GripVertical } from "lucide-react";
4
+ import { Group, Panel, Separator } from "react-resizable-panels";
5
+ import { cn } from "../../lib/utils";
6
+ const ResizablePanelGroup = ({
7
+ className,
8
+ ...props
9
+ }) => /* @__PURE__ */ jsx(
10
+ Group,
11
+ {
12
+ className: cn(
13
+ "flex h-full w-full data-[panel-group-direction=vertical]:flex-col",
14
+ className
15
+ ),
16
+ ...props
17
+ }
18
+ );
19
+ const ResizablePanel = Panel;
20
+ const ResizableHandle = ({
21
+ className,
22
+ withHandle,
23
+ ...props
24
+ }) => /* @__PURE__ */ jsx(
25
+ Separator,
26
+ {
27
+ className: cn(
28
+ "relative flex w-px items-center justify-center bg-border after:absolute after:inset-y-0 after:left-1/2 after:w-1 after:-translate-x-1/2 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring focus-visible:ring-offset-1 data-[panel-group-direction=vertical]:h-px data-[panel-group-direction=vertical]:w-full data-[panel-group-direction=vertical]:after:left-0 data-[panel-group-direction=vertical]:after:h-1 data-[panel-group-direction=vertical]:after:w-full data-[panel-group-direction=vertical]:after:-translate-y-1/2 data-[panel-group-direction=vertical]:after:translate-x-0 [&[data-panel-group-direction=vertical]>div]:rotate-90",
29
+ className
30
+ ),
31
+ ...props,
32
+ children: withHandle ? /* @__PURE__ */ jsx("div", { className: "z-10 flex h-4 w-3 items-center justify-center rounded-sm border bg-border", children: /* @__PURE__ */ jsx(GripVertical, { className: "h-2.5 w-2.5" }) }) : null
33
+ }
34
+ );
35
+ export {
36
+ ResizableHandle,
37
+ ResizablePanel,
38
+ ResizablePanelGroup
39
+ };
@@ -0,0 +1,5 @@
1
+ import { ScrollArea, ScrollBar } from "./scroll-area";
2
+ export {
3
+ ScrollArea,
4
+ ScrollBar
5
+ };
@@ -0,0 +1,39 @@
1
+ "use client";
2
+ import { jsx, jsxs } from "react/jsx-runtime";
3
+ import { forwardRef } from "react";
4
+ import * as ScrollAreaPrimitive from "@radix-ui/react-scroll-area";
5
+ import { cn } from "../../lib/utils";
6
+ const ScrollArea = forwardRef(({ children, className, ...props }, ref) => /* @__PURE__ */ jsxs(
7
+ ScrollAreaPrimitive.Root,
8
+ {
9
+ className: cn("relative overflow-hidden", className),
10
+ ref,
11
+ ...props,
12
+ children: [
13
+ /* @__PURE__ */ jsx(ScrollAreaPrimitive.Viewport, { className: "h-full w-full rounded-[inherit]", children }),
14
+ /* @__PURE__ */ jsx(ScrollBar, {}),
15
+ /* @__PURE__ */ jsx(ScrollAreaPrimitive.Corner, {})
16
+ ]
17
+ }
18
+ ));
19
+ ScrollArea.displayName = ScrollAreaPrimitive.Root.displayName;
20
+ const ScrollBar = forwardRef(({ className, orientation = "vertical", ...props }, ref) => /* @__PURE__ */ jsx(
21
+ ScrollAreaPrimitive.ScrollAreaScrollbar,
22
+ {
23
+ className: cn(
24
+ "flex touch-none select-none transition-colors",
25
+ orientation === "vertical" && "h-full w-2.5 border-l border-l-transparent p-[1px]",
26
+ orientation === "horizontal" && "h-2.5 flex-col border-t border-t-transparent p-[1px]",
27
+ className
28
+ ),
29
+ orientation,
30
+ ref,
31
+ ...props,
32
+ children: /* @__PURE__ */ jsx(ScrollAreaPrimitive.ScrollAreaThumb, { className: "relative flex-1 rounded-full bg-border" })
33
+ }
34
+ ));
35
+ ScrollBar.displayName = ScrollAreaPrimitive.ScrollAreaScrollbar.displayName;
36
+ export {
37
+ ScrollArea,
38
+ ScrollBar
39
+ };
@@ -0,0 +1,4 @@
1
+ import { SearchBar } from "./search-bar";
2
+ export {
3
+ SearchBar
4
+ };
@@ -0,0 +1,122 @@
1
+ "use client";
2
+ import { jsx, jsxs } from "react/jsx-runtime";
3
+ import { useEffect, useRef, useState } from "react";
4
+ import { useRouter, useSearchParams } from "next/navigation";
5
+ import { useDebounce } from "../../lib/use-debounce";
6
+ import { Button } from "../button/button";
7
+ import { Input } from "../input/input";
8
+ function SearchBar({
9
+ className,
10
+ onSearch,
11
+ placeholder = "Search posts..."
12
+ }) {
13
+ const router = useRouter();
14
+ const searchParameters = useSearchParams();
15
+ const initialQuery = searchParameters.get("search") ?? "";
16
+ const [query, setQuery] = useState(initialQuery);
17
+ const debouncedQuery = useDebounce(query, 300);
18
+ const isInitialMount = useRef(true);
19
+ const isUserTyping = useRef(false);
20
+ const typingTimeoutReference = useRef(void 0);
21
+ const lastSetSearchParameterReference = useRef("");
22
+ const lastDebouncedQueryReference = useRef("");
23
+ useEffect(() => {
24
+ const searchParameter = searchParameters.get("search") ?? "";
25
+ if (searchParameter === lastSetSearchParameterReference.current) {
26
+ return;
27
+ }
28
+ if (!isUserTyping.current && query !== searchParameter) {
29
+ requestAnimationFrame(() => {
30
+ setQuery(searchParameter);
31
+ lastDebouncedQueryReference.current = searchParameter;
32
+ });
33
+ }
34
+ }, [searchParameters, query]);
35
+ useEffect(() => {
36
+ if (isInitialMount.current) {
37
+ isInitialMount.current = false;
38
+ const initialTrimmed = debouncedQuery.trim();
39
+ lastDebouncedQueryReference.current = initialTrimmed;
40
+ lastSetSearchParameterReference.current = initialTrimmed;
41
+ return;
42
+ }
43
+ const trimmedQuery = debouncedQuery.trim();
44
+ if (trimmedQuery === lastDebouncedQueryReference.current) {
45
+ return;
46
+ }
47
+ lastDebouncedQueryReference.current = trimmedQuery;
48
+ if (onSearch) {
49
+ onSearch(trimmedQuery);
50
+ return;
51
+ }
52
+ const currentUrlParameter = searchParameters.get("search") ?? "";
53
+ if (trimmedQuery === currentUrlParameter) {
54
+ lastSetSearchParameterReference.current = trimmedQuery;
55
+ return;
56
+ }
57
+ const parameters = new URLSearchParams(searchParameters);
58
+ if (trimmedQuery) {
59
+ parameters.set("search", trimmedQuery);
60
+ } else {
61
+ parameters.delete("search");
62
+ }
63
+ const newUrl = parameters.toString();
64
+ lastSetSearchParameterReference.current = trimmedQuery;
65
+ router.replace(`?${newUrl}`);
66
+ }, [debouncedQuery, router, onSearch, searchParameters]);
67
+ useEffect(() => {
68
+ return () => {
69
+ if (typingTimeoutReference.current) {
70
+ clearTimeout(typingTimeoutReference.current);
71
+ }
72
+ };
73
+ }, []);
74
+ const handleInputChange = (event) => {
75
+ isUserTyping.current = true;
76
+ setQuery(event.target.value);
77
+ if (typingTimeoutReference.current) {
78
+ clearTimeout(typingTimeoutReference.current);
79
+ }
80
+ typingTimeoutReference.current = setTimeout(() => {
81
+ isUserTyping.current = false;
82
+ }, 350);
83
+ };
84
+ const handleSubmit = (event) => {
85
+ event.preventDefault();
86
+ isUserTyping.current = false;
87
+ if (typingTimeoutReference.current) {
88
+ clearTimeout(typingTimeoutReference.current);
89
+ }
90
+ const trimmedQuery = query.trim();
91
+ if (onSearch) {
92
+ onSearch(trimmedQuery);
93
+ } else {
94
+ const parameters = new URLSearchParams(searchParameters);
95
+ if (trimmedQuery) {
96
+ parameters.set("search", trimmedQuery);
97
+ } else {
98
+ parameters.delete("search");
99
+ }
100
+ const newUrl = parameters.toString();
101
+ lastSetSearchParameterReference.current = trimmedQuery;
102
+ router.replace(`?${newUrl}`);
103
+ }
104
+ };
105
+ return /* @__PURE__ */ jsxs("form", { className: `flex gap-2 ${className}`, onSubmit: handleSubmit, children: [
106
+ /* @__PURE__ */ jsx(
107
+ Input,
108
+ {
109
+ "aria-label": placeholder,
110
+ className: "flex-1",
111
+ onChange: handleInputChange,
112
+ placeholder,
113
+ type: "text",
114
+ value: query
115
+ }
116
+ ),
117
+ /* @__PURE__ */ jsx(Button, { type: "submit", variant: "outline", children: "Search" })
118
+ ] });
119
+ }
120
+ export {
121
+ SearchBar
122
+ };
@@ -0,0 +1,4 @@
1
+ import { SearchDialog } from "./search-dialog";
2
+ export {
3
+ SearchDialog
4
+ };
@@ -0,0 +1,102 @@
1
+ "use client";
2
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
3
+ import { useEffect, useState } from "react";
4
+ import { Search } from "lucide-react";
5
+ import { cn } from "../../lib/utils";
6
+ import { Button } from "../button";
7
+ import {
8
+ CommandDialog,
9
+ CommandEmpty,
10
+ CommandGroup,
11
+ CommandInput,
12
+ CommandItem,
13
+ CommandList
14
+ } from "../command";
15
+ function useKeyboardShortcut(callback) {
16
+ useEffect(() => {
17
+ const down = (event) => {
18
+ if ((event.key === "k" || event.key === "K") && (event.metaKey || event.ctrlKey)) {
19
+ const target = event.target;
20
+ if (target && (target.tagName === "INPUT" || target.tagName === "TEXTAREA" || target.isContentEditable)) {
21
+ return;
22
+ }
23
+ event.preventDefault();
24
+ event.stopPropagation();
25
+ event.stopImmediatePropagation();
26
+ callback();
27
+ }
28
+ };
29
+ window.addEventListener("keydown", down, { capture: true, passive: false });
30
+ return () => {
31
+ window.removeEventListener("keydown", down, { capture: true });
32
+ };
33
+ }, [callback]);
34
+ }
35
+ function SearchDialog({
36
+ buttonText = "Search...",
37
+ buttonTextMobile = "Search...",
38
+ emptyText = "No results found.",
39
+ enableKeyboardShortcut = true,
40
+ groupHeading,
41
+ items,
42
+ onSelect,
43
+ searchPlaceholder = "Search..."
44
+ }) {
45
+ const [open, setOpen] = useState(false);
46
+ const sortedItems = [...items].sort((a, b) => a.title.localeCompare(b.title));
47
+ useKeyboardShortcut(() => {
48
+ if (enableKeyboardShortcut) {
49
+ setOpen((previous) => !previous);
50
+ }
51
+ });
52
+ const handleSelect = (item) => {
53
+ setOpen(false);
54
+ onSelect(item);
55
+ };
56
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
57
+ /* @__PURE__ */ jsxs(
58
+ Button,
59
+ {
60
+ className: cn(
61
+ "relative h-9 w-full justify-start text-sm text-muted-foreground sm:pr-12 md:w-40 lg:w-64"
62
+ ),
63
+ onClick: () => {
64
+ setOpen(true);
65
+ },
66
+ variant: "outline",
67
+ children: [
68
+ /* @__PURE__ */ jsx(Search, { className: "mr-2 h-4 w-4" }),
69
+ /* @__PURE__ */ jsx("span", { className: "hidden lg:inline-flex", children: buttonText }),
70
+ /* @__PURE__ */ jsx("span", { className: "inline-flex lg:hidden", children: buttonTextMobile }),
71
+ /* @__PURE__ */ jsxs("kbd", { className: "pointer-events-none absolute right-1.5 top-1.5 hidden h-5 select-none items-center gap-1 rounded border bg-muted px-1.5 font-mono text-[10px] font-medium opacity-100 sm:flex", children: [
72
+ /* @__PURE__ */ jsx("span", { className: "text-xs", children: "\u2318" }),
73
+ "K"
74
+ ] })
75
+ ]
76
+ }
77
+ ),
78
+ /* @__PURE__ */ jsxs(CommandDialog, { onOpenChange: setOpen, open, children: [
79
+ /* @__PURE__ */ jsx(CommandInput, { placeholder: searchPlaceholder }),
80
+ /* @__PURE__ */ jsxs(CommandList, { children: [
81
+ /* @__PURE__ */ jsx(CommandEmpty, { children: emptyText }),
82
+ /* @__PURE__ */ jsx(CommandGroup, { heading: groupHeading, children: sortedItems.map((item) => /* @__PURE__ */ jsx(
83
+ CommandItem,
84
+ {
85
+ onSelect: () => {
86
+ handleSelect(item);
87
+ },
88
+ value: `${item.title} ${item.description || ""} ${item.keywords || ""} ${item.id}`,
89
+ children: /* @__PURE__ */ jsxs("div", { className: "flex flex-col", children: [
90
+ /* @__PURE__ */ jsx("span", { className: "font-medium", children: item.title }),
91
+ item.description ? /* @__PURE__ */ jsx("span", { className: "text-xs text-muted-foreground", children: item.description }) : null
92
+ ] })
93
+ },
94
+ item.id
95
+ )) })
96
+ ] })
97
+ ] })
98
+ ] });
99
+ }
100
+ export {
101
+ SearchDialog
102
+ };
@@ -0,0 +1,24 @@
1
+ import {
2
+ Select,
3
+ SelectContent,
4
+ SelectGroup,
5
+ SelectItem,
6
+ SelectLabel,
7
+ SelectScrollDownButton,
8
+ SelectScrollUpButton,
9
+ SelectSeparator,
10
+ SelectTrigger,
11
+ SelectValue
12
+ } from "./select";
13
+ export {
14
+ Select,
15
+ SelectContent,
16
+ SelectGroup,
17
+ SelectItem,
18
+ SelectLabel,
19
+ SelectScrollDownButton,
20
+ SelectScrollUpButton,
21
+ SelectSeparator,
22
+ SelectTrigger,
23
+ SelectValue
24
+ };