@thxgg/steward 0.1.0

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 (154) hide show
  1. package/.env.example +7 -0
  2. package/LICENSE +21 -0
  3. package/README.md +175 -0
  4. package/app/app.vue +14 -0
  5. package/app/assets/css/main.css +129 -0
  6. package/app/components/CommandPalette.vue +182 -0
  7. package/app/components/ShortcutsHelp.vue +85 -0
  8. package/app/components/git/ChangesMinimap.vue +143 -0
  9. package/app/components/git/CommitList.vue +224 -0
  10. package/app/components/git/DiffPanel.vue +402 -0
  11. package/app/components/git/DiffViewer.vue +803 -0
  12. package/app/components/layout/RepoSelector.vue +358 -0
  13. package/app/components/layout/Sidebar.vue +91 -0
  14. package/app/components/prd/Meta.vue +69 -0
  15. package/app/components/prd/Viewer.vue +285 -0
  16. package/app/components/tasks/Board.vue +86 -0
  17. package/app/components/tasks/Card.vue +108 -0
  18. package/app/components/tasks/Column.vue +108 -0
  19. package/app/components/tasks/Detail.vue +291 -0
  20. package/app/components/ui/badge/Badge.vue +26 -0
  21. package/app/components/ui/badge/index.ts +26 -0
  22. package/app/components/ui/button/Button.vue +29 -0
  23. package/app/components/ui/button/index.ts +38 -0
  24. package/app/components/ui/card/Card.vue +22 -0
  25. package/app/components/ui/card/CardAction.vue +17 -0
  26. package/app/components/ui/card/CardContent.vue +17 -0
  27. package/app/components/ui/card/CardDescription.vue +17 -0
  28. package/app/components/ui/card/CardFooter.vue +17 -0
  29. package/app/components/ui/card/CardHeader.vue +17 -0
  30. package/app/components/ui/card/CardTitle.vue +17 -0
  31. package/app/components/ui/card/index.ts +7 -0
  32. package/app/components/ui/combobox/Combobox.vue +19 -0
  33. package/app/components/ui/combobox/ComboboxAnchor.vue +23 -0
  34. package/app/components/ui/combobox/ComboboxEmpty.vue +21 -0
  35. package/app/components/ui/combobox/ComboboxGroup.vue +27 -0
  36. package/app/components/ui/combobox/ComboboxInput.vue +42 -0
  37. package/app/components/ui/combobox/ComboboxItem.vue +24 -0
  38. package/app/components/ui/combobox/ComboboxItemIndicator.vue +23 -0
  39. package/app/components/ui/combobox/ComboboxList.vue +33 -0
  40. package/app/components/ui/combobox/ComboboxSeparator.vue +21 -0
  41. package/app/components/ui/combobox/ComboboxTrigger.vue +24 -0
  42. package/app/components/ui/combobox/ComboboxViewport.vue +23 -0
  43. package/app/components/ui/combobox/index.ts +13 -0
  44. package/app/components/ui/command/Command.vue +103 -0
  45. package/app/components/ui/command/CommandDialog.vue +33 -0
  46. package/app/components/ui/command/CommandEmpty.vue +27 -0
  47. package/app/components/ui/command/CommandGroup.vue +45 -0
  48. package/app/components/ui/command/CommandInput.vue +54 -0
  49. package/app/components/ui/command/CommandItem.vue +76 -0
  50. package/app/components/ui/command/CommandList.vue +25 -0
  51. package/app/components/ui/command/CommandSeparator.vue +21 -0
  52. package/app/components/ui/command/CommandShortcut.vue +17 -0
  53. package/app/components/ui/command/index.ts +25 -0
  54. package/app/components/ui/dialog/Dialog.vue +19 -0
  55. package/app/components/ui/dialog/DialogClose.vue +15 -0
  56. package/app/components/ui/dialog/DialogContent.vue +53 -0
  57. package/app/components/ui/dialog/DialogDescription.vue +23 -0
  58. package/app/components/ui/dialog/DialogFooter.vue +15 -0
  59. package/app/components/ui/dialog/DialogHeader.vue +17 -0
  60. package/app/components/ui/dialog/DialogOverlay.vue +21 -0
  61. package/app/components/ui/dialog/DialogScrollContent.vue +59 -0
  62. package/app/components/ui/dialog/DialogTitle.vue +23 -0
  63. package/app/components/ui/dialog/DialogTrigger.vue +15 -0
  64. package/app/components/ui/dialog/index.ts +10 -0
  65. package/app/components/ui/input/Input.vue +33 -0
  66. package/app/components/ui/input/index.ts +1 -0
  67. package/app/components/ui/scroll-area/ScrollArea.vue +33 -0
  68. package/app/components/ui/scroll-area/ScrollBar.vue +32 -0
  69. package/app/components/ui/scroll-area/index.ts +2 -0
  70. package/app/components/ui/separator/Separator.vue +29 -0
  71. package/app/components/ui/separator/index.ts +1 -0
  72. package/app/components/ui/sheet/Sheet.vue +19 -0
  73. package/app/components/ui/sheet/SheetClose.vue +15 -0
  74. package/app/components/ui/sheet/SheetContent.vue +62 -0
  75. package/app/components/ui/sheet/SheetDescription.vue +21 -0
  76. package/app/components/ui/sheet/SheetFooter.vue +16 -0
  77. package/app/components/ui/sheet/SheetHeader.vue +15 -0
  78. package/app/components/ui/sheet/SheetOverlay.vue +21 -0
  79. package/app/components/ui/sheet/SheetTitle.vue +21 -0
  80. package/app/components/ui/sheet/SheetTrigger.vue +15 -0
  81. package/app/components/ui/sheet/index.ts +8 -0
  82. package/app/components/ui/tabs/Tabs.vue +24 -0
  83. package/app/components/ui/tabs/TabsContent.vue +21 -0
  84. package/app/components/ui/tabs/TabsList.vue +24 -0
  85. package/app/components/ui/tabs/TabsTrigger.vue +26 -0
  86. package/app/components/ui/tabs/index.ts +4 -0
  87. package/app/components/ui/tooltip/Tooltip.vue +19 -0
  88. package/app/components/ui/tooltip/TooltipContent.vue +34 -0
  89. package/app/components/ui/tooltip/TooltipProvider.vue +14 -0
  90. package/app/components/ui/tooltip/TooltipTrigger.vue +15 -0
  91. package/app/components/ui/tooltip/index.ts +4 -0
  92. package/app/composables/useFileWatch.ts +78 -0
  93. package/app/composables/useGit.ts +180 -0
  94. package/app/composables/useKeyboard.ts +180 -0
  95. package/app/composables/usePrd.ts +86 -0
  96. package/app/composables/useRepos.ts +108 -0
  97. package/app/composables/useThemeMode.ts +38 -0
  98. package/app/composables/useToast.ts +31 -0
  99. package/app/layouts/default.vue +197 -0
  100. package/app/lib/utils.ts +7 -0
  101. package/app/pages/[repo]/[prd].vue +263 -0
  102. package/app/pages/index.vue +257 -0
  103. package/app/types/git.ts +81 -0
  104. package/app/types/index.ts +29 -0
  105. package/app/types/prd.ts +49 -0
  106. package/app/types/repo.ts +37 -0
  107. package/app/types/task.ts +134 -0
  108. package/bin/prd +21 -0
  109. package/components.json +21 -0
  110. package/dist/app/types/git.js +1 -0
  111. package/dist/app/types/prd.js +1 -0
  112. package/dist/app/types/repo.js +1 -0
  113. package/dist/app/types/task.js +1 -0
  114. package/dist/host/src/api/git.js +96 -0
  115. package/dist/host/src/api/index.js +4 -0
  116. package/dist/host/src/api/prds.js +195 -0
  117. package/dist/host/src/api/repos.js +47 -0
  118. package/dist/host/src/api/state.js +63 -0
  119. package/dist/host/src/executor.js +109 -0
  120. package/dist/host/src/index.js +95 -0
  121. package/dist/host/src/mcp.js +62 -0
  122. package/dist/host/src/ui.js +64 -0
  123. package/dist/server/utils/db.js +125 -0
  124. package/dist/server/utils/git.js +396 -0
  125. package/dist/server/utils/prd-state.js +229 -0
  126. package/dist/server/utils/repos.js +256 -0
  127. package/docs/MCP.md +180 -0
  128. package/nuxt.config.ts +34 -0
  129. package/package.json +88 -0
  130. package/public/favicon.ico +0 -0
  131. package/public/robots.txt +1 -0
  132. package/server/api/browse.get.ts +52 -0
  133. package/server/api/repos/[repoId]/git/commits.get.ts +103 -0
  134. package/server/api/repos/[repoId]/git/diff.get.ts +77 -0
  135. package/server/api/repos/[repoId]/git/file-content.get.ts +66 -0
  136. package/server/api/repos/[repoId]/git/file-diff.get.ts +109 -0
  137. package/server/api/repos/[repoId]/prd/[prdSlug]/progress.get.ts +36 -0
  138. package/server/api/repos/[repoId]/prd/[prdSlug]/tasks/[taskId]/commits.get.ts +146 -0
  139. package/server/api/repos/[repoId]/prd/[prdSlug]/tasks.get.ts +36 -0
  140. package/server/api/repos/[repoId]/prd/[prdSlug].get.ts +97 -0
  141. package/server/api/repos/[repoId]/prds.get.ts +85 -0
  142. package/server/api/repos/[repoId]/refresh-git-repos.post.ts +42 -0
  143. package/server/api/repos/[repoId].delete.ts +27 -0
  144. package/server/api/repos/index.get.ts +5 -0
  145. package/server/api/repos/index.post.ts +39 -0
  146. package/server/api/watch.get.ts +63 -0
  147. package/server/plugins/migrate-legacy-state.ts +19 -0
  148. package/server/tsconfig.json +3 -0
  149. package/server/utils/db.ts +169 -0
  150. package/server/utils/git.ts +478 -0
  151. package/server/utils/prd-state.ts +335 -0
  152. package/server/utils/repos.ts +322 -0
  153. package/server/utils/watcher.ts +179 -0
  154. package/tsconfig.json +4 -0
@@ -0,0 +1,42 @@
1
+ <script setup lang="ts">
2
+ import type { ComboboxInputEmits, ComboboxInputProps } from "reka-ui"
3
+ import type { HTMLAttributes } from "vue"
4
+ import { reactiveOmit } from "@vueuse/core"
5
+ import { SearchIcon } from "lucide-vue-next"
6
+ import { ComboboxInput, useForwardPropsEmits } from "reka-ui"
7
+ import { cn } from "@/lib/utils"
8
+
9
+ defineOptions({
10
+ inheritAttrs: false,
11
+ })
12
+
13
+ const props = defineProps<ComboboxInputProps & {
14
+ class?: HTMLAttributes["class"]
15
+ }>()
16
+
17
+ const emits = defineEmits<ComboboxInputEmits>()
18
+
19
+ const delegatedProps = reactiveOmit(props, "class")
20
+
21
+ const forwarded = useForwardPropsEmits(delegatedProps, emits)
22
+ </script>
23
+
24
+ <template>
25
+ <div
26
+ data-slot="command-input-wrapper"
27
+ class="flex h-9 items-center gap-2 border-b px-3"
28
+ >
29
+ <SearchIcon class="size-4 shrink-0 opacity-50" />
30
+ <ComboboxInput
31
+ data-slot="command-input"
32
+ :class="cn(
33
+ 'placeholder:text-muted-foreground flex h-10 w-full rounded-md bg-transparent py-3 text-sm outline-hidden disabled:cursor-not-allowed disabled:opacity-50',
34
+ props.class,
35
+ )"
36
+
37
+ v-bind="{ ...$attrs, ...forwarded }"
38
+ >
39
+ <slot />
40
+ </ComboboxInput>
41
+ </div>
42
+ </template>
@@ -0,0 +1,24 @@
1
+ <script setup lang="ts">
2
+ import type { ComboboxItemEmits, ComboboxItemProps } from "reka-ui"
3
+ import type { HTMLAttributes } from "vue"
4
+ import { reactiveOmit } from "@vueuse/core"
5
+ import { ComboboxItem, useForwardPropsEmits } from "reka-ui"
6
+ import { cn } from "@/lib/utils"
7
+
8
+ const props = defineProps<ComboboxItemProps & { class?: HTMLAttributes["class"] }>()
9
+ const emits = defineEmits<ComboboxItemEmits>()
10
+
11
+ const delegatedProps = reactiveOmit(props, "class")
12
+
13
+ const forwarded = useForwardPropsEmits(delegatedProps, emits)
14
+ </script>
15
+
16
+ <template>
17
+ <ComboboxItem
18
+ data-slot="combobox-item"
19
+ v-bind="forwarded"
20
+ :class="cn('data-[highlighted]:bg-accent data-[highlighted]:text-accent-foreground [&_svg:not([class*=\'text-\'])]:text-muted-foreground relative flex cursor-default items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-hidden select-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*=\'size-\'])]:size-4', props.class)"
21
+ >
22
+ <slot />
23
+ </ComboboxItem>
24
+ </template>
@@ -0,0 +1,23 @@
1
+ <script setup lang="ts">
2
+ import type { ComboboxItemIndicatorProps } from "reka-ui"
3
+ import type { HTMLAttributes } from "vue"
4
+ import { reactiveOmit } from "@vueuse/core"
5
+ import { ComboboxItemIndicator, useForwardProps } from "reka-ui"
6
+ import { cn } from "@/lib/utils"
7
+
8
+ const props = defineProps<ComboboxItemIndicatorProps & { class?: HTMLAttributes["class"] }>()
9
+
10
+ const delegatedProps = reactiveOmit(props, "class")
11
+
12
+ const forwarded = useForwardProps(delegatedProps)
13
+ </script>
14
+
15
+ <template>
16
+ <ComboboxItemIndicator
17
+ data-slot="combobox-item-indicator"
18
+ v-bind="forwarded"
19
+ :class="cn('ml-auto', props.class)"
20
+ >
21
+ <slot />
22
+ </ComboboxItemIndicator>
23
+ </template>
@@ -0,0 +1,33 @@
1
+ <script setup lang="ts">
2
+ import type { ComboboxContentEmits, ComboboxContentProps } from "reka-ui"
3
+ import type { HTMLAttributes } from "vue"
4
+ import { reactiveOmit } from "@vueuse/core"
5
+ import { ComboboxContent, ComboboxPortal, useForwardPropsEmits } from "reka-ui"
6
+ import { cn } from "@/lib/utils"
7
+
8
+ defineOptions({
9
+ inheritAttrs: false,
10
+ })
11
+
12
+ const props = withDefaults(defineProps<ComboboxContentProps & { class?: HTMLAttributes["class"] }>(), {
13
+ position: "popper",
14
+ align: "start",
15
+ side: "bottom",
16
+ sideOffset: 4,
17
+ avoidCollisions: false,
18
+ })
19
+ const emits = defineEmits<ComboboxContentEmits>()
20
+
21
+ const delegatedProps = reactiveOmit(props, "class")
22
+ const forwarded = useForwardPropsEmits(delegatedProps, emits)
23
+ </script>
24
+
25
+ <template>
26
+ <ComboboxContent
27
+ data-slot="combobox-list"
28
+ v-bind="{ ...$attrs, ...forwarded }"
29
+ :class="cn('z-[9999] w-[200px] rounded-md border bg-popover text-popover-foreground overflow-hidden shadow-md outline-none', props.class)"
30
+ >
31
+ <slot />
32
+ </ComboboxContent>
33
+ </template>
@@ -0,0 +1,21 @@
1
+ <script setup lang="ts">
2
+ import type { ComboboxSeparatorProps } from "reka-ui"
3
+ import type { HTMLAttributes } from "vue"
4
+ import { reactiveOmit } from "@vueuse/core"
5
+ import { ComboboxSeparator } from "reka-ui"
6
+ import { cn } from "@/lib/utils"
7
+
8
+ const props = defineProps<ComboboxSeparatorProps & { class?: HTMLAttributes["class"] }>()
9
+
10
+ const delegatedProps = reactiveOmit(props, "class")
11
+ </script>
12
+
13
+ <template>
14
+ <ComboboxSeparator
15
+ data-slot="combobox-separator"
16
+ v-bind="delegatedProps"
17
+ :class="cn('bg-border -mx-1 h-px', props.class)"
18
+ >
19
+ <slot />
20
+ </ComboboxSeparator>
21
+ </template>
@@ -0,0 +1,24 @@
1
+ <script setup lang="ts">
2
+ import type { ComboboxTriggerProps } from "reka-ui"
3
+ import type { HTMLAttributes } from "vue"
4
+ import { reactiveOmit } from "@vueuse/core"
5
+ import { ComboboxTrigger, useForwardProps } from "reka-ui"
6
+ import { cn } from "@/lib/utils"
7
+
8
+ const props = defineProps<ComboboxTriggerProps & { class?: HTMLAttributes["class"] }>()
9
+
10
+ const delegatedProps = reactiveOmit(props, "class")
11
+
12
+ const forwarded = useForwardProps(delegatedProps)
13
+ </script>
14
+
15
+ <template>
16
+ <ComboboxTrigger
17
+ data-slot="combobox-trigger"
18
+ v-bind="forwarded"
19
+ :class="cn('', props.class)"
20
+ tabindex="0"
21
+ >
22
+ <slot />
23
+ </ComboboxTrigger>
24
+ </template>
@@ -0,0 +1,23 @@
1
+ <script setup lang="ts">
2
+ import type { ComboboxViewportProps } from "reka-ui"
3
+ import type { HTMLAttributes } from "vue"
4
+ import { reactiveOmit } from "@vueuse/core"
5
+ import { ComboboxViewport, useForwardProps } from "reka-ui"
6
+ import { cn } from "@/lib/utils"
7
+
8
+ const props = defineProps<ComboboxViewportProps & { class?: HTMLAttributes["class"] }>()
9
+
10
+ const delegatedProps = reactiveOmit(props, "class")
11
+
12
+ const forwarded = useForwardProps(delegatedProps)
13
+ </script>
14
+
15
+ <template>
16
+ <ComboboxViewport
17
+ data-slot="combobox-viewport"
18
+ v-bind="forwarded"
19
+ :class="cn('max-h-[300px] scroll-py-1 overflow-x-hidden overflow-y-auto', props.class)"
20
+ >
21
+ <slot />
22
+ </ComboboxViewport>
23
+ </template>
@@ -0,0 +1,13 @@
1
+ export { default as Combobox } from "./Combobox.vue"
2
+ export { default as ComboboxAnchor } from "./ComboboxAnchor.vue"
3
+ export { default as ComboboxEmpty } from "./ComboboxEmpty.vue"
4
+ export { default as ComboboxGroup } from "./ComboboxGroup.vue"
5
+ export { default as ComboboxInput } from "./ComboboxInput.vue"
6
+ export { default as ComboboxItem } from "./ComboboxItem.vue"
7
+ export { default as ComboboxItemIndicator } from "./ComboboxItemIndicator.vue"
8
+ export { default as ComboboxList } from "./ComboboxList.vue"
9
+ export { default as ComboboxSeparator } from "./ComboboxSeparator.vue"
10
+ export { default as ComboboxTrigger } from "./ComboboxTrigger.vue"
11
+ export { default as ComboboxViewport } from "./ComboboxViewport.vue"
12
+
13
+ export { ComboboxCancel } from "reka-ui"
@@ -0,0 +1,103 @@
1
+ <script setup lang="ts">
2
+ import type { ListboxRootEmits, ListboxRootProps } from "reka-ui"
3
+ import type { HTMLAttributes } from "vue"
4
+ import { reactiveOmit } from "@vueuse/core"
5
+ import { ListboxRoot, useFilter, useForwardPropsEmits } from "reka-ui"
6
+ import { reactive, ref, watch } from "vue"
7
+ import { cn } from "@/lib/utils"
8
+ import { provideCommandContext } from "."
9
+
10
+ const props = withDefaults(defineProps<ListboxRootProps & { class?: HTMLAttributes["class"], defaultSearch?: string }>(), {
11
+ modelValue: "",
12
+ loop: true,
13
+ defaultSearch: "",
14
+ })
15
+
16
+ const emits = defineEmits<ListboxRootEmits>()
17
+
18
+ const delegatedProps = reactiveOmit(props, "class")
19
+
20
+ const forwarded = useForwardPropsEmits(delegatedProps, emits)
21
+
22
+ const allItems = ref<Map<string, string>>(new Map())
23
+ const allGroups = ref<Map<string, Set<string>>>(new Map())
24
+
25
+ const { contains } = useFilter({ sensitivity: "base" })
26
+ const filterState = reactive({
27
+ search: props.defaultSearch || "",
28
+ filtered: {
29
+ /** The count of all visible items. */
30
+ count: 0,
31
+ /** Map from visible item id to its search score. */
32
+ items: new Map() as Map<string, number>,
33
+ /** Set of groups with at least one visible item. */
34
+ groups: new Set() as Set<string>,
35
+ },
36
+ })
37
+
38
+ // Watch for changes to defaultSearch prop (e.g., when dialog opens with a filter)
39
+ watch(() => props.defaultSearch, (newSearch) => {
40
+ if (newSearch !== undefined) {
41
+ filterState.search = newSearch
42
+ }
43
+ })
44
+
45
+ function filterItems() {
46
+ if (!filterState.search) {
47
+ filterState.filtered.count = allItems.value.size
48
+ // Do nothing, each item will know to show itself because search is empty
49
+ return
50
+ }
51
+
52
+ // Reset the groups
53
+ filterState.filtered.groups = new Set()
54
+ let itemCount = 0
55
+
56
+ // Check which items should be included
57
+ for (const [id, value] of allItems.value) {
58
+ const score = contains(value, filterState.search)
59
+ filterState.filtered.items.set(id, score ? 1 : 0)
60
+ if (score)
61
+ itemCount++
62
+ }
63
+
64
+ // Check which groups have at least 1 item shown
65
+ for (const [groupId, group] of allGroups.value) {
66
+ for (const itemId of group) {
67
+ if (filterState.filtered.items.get(itemId)! > 0) {
68
+ filterState.filtered.groups.add(groupId)
69
+ break
70
+ }
71
+ }
72
+ }
73
+
74
+ filterState.filtered.count = itemCount
75
+ }
76
+
77
+ watch(() => filterState.search, () => {
78
+ filterItems()
79
+ })
80
+
81
+ // Also re-filter when items are added (important for pre-filtered searches)
82
+ watch(() => allItems.value.size, () => {
83
+ if (filterState.search) {
84
+ filterItems()
85
+ }
86
+ })
87
+
88
+ provideCommandContext({
89
+ allItems,
90
+ allGroups,
91
+ filterState,
92
+ })
93
+ </script>
94
+
95
+ <template>
96
+ <ListboxRoot
97
+ data-slot="command"
98
+ v-bind="forwarded"
99
+ :class="cn('bg-popover text-popover-foreground flex h-full w-full flex-col overflow-hidden rounded-md', props.class)"
100
+ >
101
+ <slot />
102
+ </ListboxRoot>
103
+ </template>
@@ -0,0 +1,33 @@
1
+ <script setup lang="ts">
2
+ import type { DialogRootEmits, DialogRootProps } from "reka-ui"
3
+ import { useForwardPropsEmits } from "reka-ui"
4
+ import { Dialog, DialogContent, DialogDescription, DialogHeader, DialogTitle } from '@/components/ui/dialog'
5
+ import Command from "./Command.vue"
6
+
7
+ const props = withDefaults(defineProps<DialogRootProps & {
8
+ title?: string
9
+ description?: string
10
+ defaultSearch?: string
11
+ }>(), {
12
+ title: "Command Palette",
13
+ description: "Search for a command to run...",
14
+ defaultSearch: "",
15
+ })
16
+ const emits = defineEmits<DialogRootEmits>()
17
+
18
+ const forwarded = useForwardPropsEmits(props, emits)
19
+ </script>
20
+
21
+ <template>
22
+ <Dialog v-slot="slotProps" v-bind="forwarded">
23
+ <DialogContent class="overflow-hidden p-0" :show-close-button="false">
24
+ <DialogHeader class="sr-only">
25
+ <DialogTitle>{{ title }}</DialogTitle>
26
+ <DialogDescription>{{ description }}</DialogDescription>
27
+ </DialogHeader>
28
+ <Command :default-search="defaultSearch">
29
+ <slot v-bind="slotProps" />
30
+ </Command>
31
+ </DialogContent>
32
+ </Dialog>
33
+ </template>
@@ -0,0 +1,27 @@
1
+ <script setup lang="ts">
2
+ import type { PrimitiveProps } from "reka-ui"
3
+ import type { HTMLAttributes } from "vue"
4
+ import { reactiveOmit } from "@vueuse/core"
5
+ import { Primitive } from "reka-ui"
6
+ import { computed } from "vue"
7
+ import { cn } from "@/lib/utils"
8
+ import { useCommand } from "."
9
+
10
+ const props = defineProps<PrimitiveProps & { class?: HTMLAttributes["class"] }>()
11
+
12
+ const delegatedProps = reactiveOmit(props, "class")
13
+
14
+ const { filterState } = useCommand()
15
+ const isRender = computed(() => !!filterState.search && filterState.filtered.count === 0,
16
+ )
17
+ </script>
18
+
19
+ <template>
20
+ <Primitive
21
+ v-if="isRender"
22
+ data-slot="command-empty"
23
+ v-bind="delegatedProps" :class="cn('py-6 text-center text-sm', props.class)"
24
+ >
25
+ <slot />
26
+ </Primitive>
27
+ </template>
@@ -0,0 +1,45 @@
1
+ <script setup lang="ts">
2
+ import type { ListboxGroupProps } from "reka-ui"
3
+ import type { HTMLAttributes } from "vue"
4
+ import { reactiveOmit } from "@vueuse/core"
5
+ import { ListboxGroup, ListboxGroupLabel, useId } from "reka-ui"
6
+ import { computed, onMounted, onUnmounted } from "vue"
7
+ import { cn } from "@/lib/utils"
8
+ import { provideCommandGroupContext, useCommand } from "."
9
+
10
+ const props = defineProps<ListboxGroupProps & {
11
+ class?: HTMLAttributes["class"]
12
+ heading?: string
13
+ }>()
14
+
15
+ const delegatedProps = reactiveOmit(props, "class")
16
+
17
+ const { allGroups, filterState } = useCommand()
18
+ const id = useId()
19
+
20
+ const isRender = computed(() => !filterState.search ? true : filterState.filtered.groups.has(id))
21
+
22
+ provideCommandGroupContext({ id })
23
+ onMounted(() => {
24
+ if (!allGroups.value.has(id))
25
+ allGroups.value.set(id, new Set())
26
+ })
27
+ onUnmounted(() => {
28
+ allGroups.value.delete(id)
29
+ })
30
+ </script>
31
+
32
+ <template>
33
+ <ListboxGroup
34
+ v-bind="delegatedProps"
35
+ :id="id"
36
+ data-slot="command-group"
37
+ :class="cn('text-foreground overflow-hidden p-1', props.class)"
38
+ :hidden="isRender ? undefined : true"
39
+ >
40
+ <ListboxGroupLabel v-if="heading" data-slot="command-group-heading" class="px-2 py-1.5 text-xs font-medium text-muted-foreground">
41
+ {{ heading }}
42
+ </ListboxGroupLabel>
43
+ <slot />
44
+ </ListboxGroup>
45
+ </template>
@@ -0,0 +1,54 @@
1
+ <script setup lang="ts">
2
+ import type { ListboxFilterProps } from "reka-ui"
3
+ import type { HTMLAttributes } from "vue"
4
+ import { reactiveOmit } from "@vueuse/core"
5
+ import { Search } from "lucide-vue-next"
6
+ import { ListboxFilter, useForwardProps } from "reka-ui"
7
+ import { cn } from "@/lib/utils"
8
+ import { useCommand } from "."
9
+ import { ref, onMounted, nextTick } from "vue"
10
+
11
+ defineOptions({
12
+ inheritAttrs: false,
13
+ })
14
+
15
+ const props = defineProps<ListboxFilterProps & {
16
+ class?: HTMLAttributes["class"]
17
+ }>()
18
+
19
+ const delegatedProps = reactiveOmit(props, "class")
20
+
21
+ const forwardedProps = useForwardProps(delegatedProps)
22
+
23
+ const { filterState } = useCommand()
24
+
25
+ const inputRef = ref<{ $el?: HTMLInputElement } | null>(null)
26
+
27
+ // Position cursor at end instead of selecting all text
28
+ onMounted(() => {
29
+ nextTick(() => {
30
+ const input = inputRef.value?.$el
31
+ if (input && filterState.search) {
32
+ const len = filterState.search.length
33
+ input.setSelectionRange(len, len)
34
+ }
35
+ })
36
+ })
37
+ </script>
38
+
39
+ <template>
40
+ <div
41
+ data-slot="command-input-wrapper"
42
+ class="flex h-9 items-center gap-2 border-b px-3"
43
+ >
44
+ <Search class="size-4 shrink-0 opacity-50" />
45
+ <ListboxFilter
46
+ ref="inputRef"
47
+ v-bind="{ ...forwardedProps, ...$attrs }"
48
+ v-model="filterState.search"
49
+ data-slot="command-input"
50
+ auto-focus
51
+ :class="cn('placeholder:text-muted-foreground flex h-10 w-full rounded-md bg-transparent py-3 text-sm outline-hidden disabled:cursor-not-allowed disabled:opacity-50', props.class)"
52
+ />
53
+ </div>
54
+ </template>
@@ -0,0 +1,76 @@
1
+ <script setup lang="ts">
2
+ import type { ListboxItemEmits, ListboxItemProps } from "reka-ui"
3
+ import type { HTMLAttributes } from "vue"
4
+ import { reactiveOmit, useCurrentElement } from "@vueuse/core"
5
+ import { ListboxItem, useForwardPropsEmits, useId } from "reka-ui"
6
+ import { computed, onMounted, onUnmounted, ref } from "vue"
7
+ import { cn } from "@/lib/utils"
8
+ import { useCommand, useCommandGroup } from "."
9
+
10
+ const props = defineProps<ListboxItemProps & { class?: HTMLAttributes["class"] }>()
11
+ const emits = defineEmits<ListboxItemEmits>()
12
+
13
+ const delegatedProps = reactiveOmit(props, "class")
14
+
15
+ const forwarded = useForwardPropsEmits(delegatedProps, emits)
16
+
17
+ const id = useId()
18
+ const { filterState, allItems, allGroups } = useCommand()
19
+ const groupContext = useCommandGroup()
20
+
21
+ const isRender = computed(() => {
22
+ if (!filterState.search) {
23
+ return true
24
+ }
25
+ else {
26
+ const filteredCurrentItem = filterState.filtered.items.get(id)
27
+ // If the filtered items is undefined means not in the all times map yet
28
+ // Do the first render to add into the map
29
+ if (filteredCurrentItem === undefined) {
30
+ return true
31
+ }
32
+
33
+ // Check with filter
34
+ return filteredCurrentItem > 0
35
+ }
36
+ })
37
+
38
+ const itemRef = ref()
39
+ const currentElement = useCurrentElement(itemRef)
40
+ onMounted(() => {
41
+ if (!(currentElement.value instanceof HTMLElement))
42
+ return
43
+
44
+ // textValue to perform filter
45
+ allItems.value.set(id, currentElement.value.textContent ?? (props.value?.toString() ?? ""))
46
+
47
+ const groupId = groupContext?.id
48
+ if (groupId) {
49
+ if (!allGroups.value.has(groupId)) {
50
+ allGroups.value.set(groupId, new Set([id]))
51
+ }
52
+ else {
53
+ allGroups.value.get(groupId)?.add(id)
54
+ }
55
+ }
56
+ })
57
+ onUnmounted(() => {
58
+ allItems.value.delete(id)
59
+ })
60
+ </script>
61
+
62
+ <template>
63
+ <ListboxItem
64
+ v-if="isRender"
65
+ v-bind="forwarded"
66
+ :id="id"
67
+ ref="itemRef"
68
+ data-slot="command-item"
69
+ :class="cn('data-[highlighted]:bg-accent data-[highlighted]:text-accent-foreground [&_svg:not([class*=\'text-\'])]:text-muted-foreground relative flex cursor-default items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-hidden select-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*=\'size-\'])]:size-4', props.class)"
70
+ @select="() => {
71
+ filterState.search = ''
72
+ }"
73
+ >
74
+ <slot />
75
+ </ListboxItem>
76
+ </template>
@@ -0,0 +1,25 @@
1
+ <script setup lang="ts">
2
+ import type { ListboxContentProps } from "reka-ui"
3
+ import type { HTMLAttributes } from "vue"
4
+ import { reactiveOmit } from "@vueuse/core"
5
+ import { ListboxContent, useForwardProps } from "reka-ui"
6
+ import { cn } from "@/lib/utils"
7
+
8
+ const props = defineProps<ListboxContentProps & { class?: HTMLAttributes["class"] }>()
9
+
10
+ const delegatedProps = reactiveOmit(props, "class")
11
+
12
+ const forwarded = useForwardProps(delegatedProps)
13
+ </script>
14
+
15
+ <template>
16
+ <ListboxContent
17
+ data-slot="command-list"
18
+ v-bind="forwarded"
19
+ :class="cn('max-h-[300px] scroll-py-1 overflow-x-hidden overflow-y-auto scrollbar-none', props.class)"
20
+ >
21
+ <div role="presentation">
22
+ <slot />
23
+ </div>
24
+ </ListboxContent>
25
+ </template>
@@ -0,0 +1,21 @@
1
+ <script setup lang="ts">
2
+ import type { SeparatorProps } from "reka-ui"
3
+ import type { HTMLAttributes } from "vue"
4
+ import { reactiveOmit } from "@vueuse/core"
5
+ import { Separator } from "reka-ui"
6
+ import { cn } from "@/lib/utils"
7
+
8
+ const props = defineProps<SeparatorProps & { class?: HTMLAttributes["class"] }>()
9
+
10
+ const delegatedProps = reactiveOmit(props, "class")
11
+ </script>
12
+
13
+ <template>
14
+ <Separator
15
+ data-slot="command-separator"
16
+ v-bind="delegatedProps"
17
+ :class="cn('bg-border -mx-1 h-px', props.class)"
18
+ >
19
+ <slot />
20
+ </Separator>
21
+ </template>
@@ -0,0 +1,17 @@
1
+ <script setup lang="ts">
2
+ import type { HTMLAttributes } from "vue"
3
+ import { cn } from "@/lib/utils"
4
+
5
+ const props = defineProps<{
6
+ class?: HTMLAttributes["class"]
7
+ }>()
8
+ </script>
9
+
10
+ <template>
11
+ <span
12
+ data-slot="command-shortcut"
13
+ :class="cn('text-muted-foreground ml-auto text-xs tracking-widest', props.class)"
14
+ >
15
+ <slot />
16
+ </span>
17
+ </template>
@@ -0,0 +1,25 @@
1
+ import type { Ref } from "vue"
2
+ import { createContext } from "reka-ui"
3
+
4
+ export { default as Command } from "./Command.vue"
5
+ export { default as CommandDialog } from "./CommandDialog.vue"
6
+ export { default as CommandEmpty } from "./CommandEmpty.vue"
7
+ export { default as CommandGroup } from "./CommandGroup.vue"
8
+ export { default as CommandInput } from "./CommandInput.vue"
9
+ export { default as CommandItem } from "./CommandItem.vue"
10
+ export { default as CommandList } from "./CommandList.vue"
11
+ export { default as CommandSeparator } from "./CommandSeparator.vue"
12
+ export { default as CommandShortcut } from "./CommandShortcut.vue"
13
+
14
+ export const [useCommand, provideCommandContext] = createContext<{
15
+ allItems: Ref<Map<string, string>>
16
+ allGroups: Ref<Map<string, Set<string>>>
17
+ filterState: {
18
+ search: string
19
+ filtered: { count: number, items: Map<string, number>, groups: Set<string> }
20
+ }
21
+ }>("Command")
22
+
23
+ export const [useCommandGroup, provideCommandGroupContext] = createContext<{
24
+ id?: string
25
+ }>("CommandGroup")
@@ -0,0 +1,19 @@
1
+ <script setup lang="ts">
2
+ import type { DialogRootEmits, DialogRootProps } from "reka-ui"
3
+ import { DialogRoot, useForwardPropsEmits } from "reka-ui"
4
+
5
+ const props = defineProps<DialogRootProps>()
6
+ const emits = defineEmits<DialogRootEmits>()
7
+
8
+ const forwarded = useForwardPropsEmits(props, emits)
9
+ </script>
10
+
11
+ <template>
12
+ <DialogRoot
13
+ v-slot="slotProps"
14
+ data-slot="dialog"
15
+ v-bind="forwarded"
16
+ >
17
+ <slot v-bind="slotProps" />
18
+ </DialogRoot>
19
+ </template>