-
-
Notifications
You must be signed in to change notification settings - Fork 0
View: Pointer view component #30
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
45 commits
Select commit
Hold shift + click to select a range
825df92
add PointerView component skeleton
kha1dx 29f1d62
install shadcn and define props
kha1dx 72d56a5
add PointerView component skeleton
kha1dx 5162106
search field
kha1dx 973cd53
search field using shadcn
kha1dx 48a22f4
tree node and expandability
kha1dx 86870a0
dummy data and scrollable area
kha1dx 1600b88
shadcn scroll area
kha1dx a48aa87
search logic implemented
kha1dx 8870246
remove resizability and make it full screen
kha1dx 29fab41
fixing data types
kha1dx 12e795d
adding endpoint data type
kha1dx 6f98d77
expandable children
kha1dx fdecac2
remove extra data types
kha1dx 273c5c7
handle 0c0000 to map
kha1dx c474062
fix expanding {} []
kha1dx ea9bca0
toggle showing pointerID
kha1dx 1f609f1
toggle data type, full pointerID, indices
kha1dx a518029
Display options
kha1dx 2bf3d88
update when pointers are removed
kha1dx a677fb6
Detection of circular structures
kha1dx d137f0b
rebased and minor fixes
jonasstrehle ab4acf9
fixes
benStre 1377ff8
added margin
kha1dx 3808f10
Allow click on the whole pointer id to expand
kha1dx b9d4922
Show type hints without quotes
kha1dx c0ea204
Show map keys always
kha1dx 2105e44
update package-lock.json
kha1dx 363e90d
fix type errors
kha1dx e05a377
removed unused var
kha1dx cf799db
usepointerpreferences to composable directory
kha1dx faff1aa
fix imports
kha1dx 4084eb1
map keys type hint
kha1dx c6d2221
Add tooltip for key and value types
kha1dx 5d46eca
decrease padding
kha1dx 77d3331
expanding values on click
kha1dx e369f4a
pointer id tooltip
kha1dx 5c3562c
Pointer go to defintion feature but can be modified later
kha1dx ea745f9
double click on the value to edit
kha1dx f4c88bd
filter by data types
kha1dx 5c0316e
fix type errors
kha1dx bd75363
refactor: update pointer type definitions to use DIFValueContainer
jonasstrehle d579a23
fix package json
jonasstrehle 2e800fd
fix types
jonasstrehle 89af459
fix: correct function name for converting JS value to DIFValueContainer
jonasstrehle File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,117 @@ | ||
| <script setup lang="ts"> | ||
| import { usePointerPreferences } from '@/composable/usePointerPreferences' | ||
| import { Switch } from '@/components/ui/switch' | ||
| import { Button } from '@/components/ui/button' | ||
| import { | ||
| PopoverContent, | ||
| } from '@/components/ui/popover' | ||
|
|
||
| const { preferences, resetPreferences } = usePointerPreferences() | ||
| </script> | ||
|
|
||
| <template> | ||
| <PopoverContent class="w-80" align="start"> | ||
| <div class="space-y-4"> | ||
| <!-- Header --> | ||
| <div class="flex items-center justify-between"> | ||
| <div class="space-y-1"> | ||
| <h4 class="font-medium leading-none">Display Preferences</h4> | ||
| <p class="text-sm text-muted-foreground"> | ||
| Customize how pointers are displayed | ||
| </p> | ||
| </div> | ||
| <Button | ||
| variant="ghost" | ||
| size="sm" | ||
| @click="resetPreferences" | ||
| class="h-8 px-2 text-xs" | ||
| > | ||
| Reset | ||
| </Button> | ||
| </div> | ||
|
|
||
| <!-- Preferences List --> | ||
| <div class="space-y-4"> | ||
| <!-- Show Full Pointer IDs --> | ||
| <div class="flex items-center justify-between space-x-2"> | ||
| <div class="flex flex-col space-y-1 flex-1"> | ||
| <label class="font-medium text-sm cursor-pointer"> | ||
| Full Pointer IDs | ||
| </label> | ||
| <span class="text-xs text-muted-foreground"> | ||
| Show complete pointer identifiers instead of shortened versions | ||
| </span> | ||
| </div> | ||
| <Switch | ||
| v-model="preferences.show_full_pointer_ids" | ||
| id="show-full-ids" | ||
| /> | ||
|
jonasstrehle marked this conversation as resolved.
|
||
| </div> | ||
|
|
||
| <!-- Show Type Hints --> | ||
| <div class="flex items-center justify-between space-x-2"> | ||
| <div class="flex flex-col space-y-1 flex-1"> | ||
| <label class="font-medium text-sm cursor-pointer"> | ||
| Type Hints | ||
| </label> | ||
| <span class="text-xs text-muted-foreground"> | ||
| Display type annotations for values | ||
| </span> | ||
| </div> | ||
| <Switch | ||
| v-model="preferences.show_type_hints" | ||
| id="show-type-hints" | ||
| /> | ||
| </div> | ||
|
|
||
| <!-- Show Array Indices --> | ||
| <div class="flex items-center justify-between space-x-2"> | ||
| <div class="flex flex-col space-y-1 flex-1"> | ||
| <label class="font-medium text-sm cursor-pointer"> | ||
| Array Indices & Keys | ||
| </label> | ||
| <span class="text-xs text-muted-foreground"> | ||
| Show array indices and object keys | ||
| </span> | ||
| </div> | ||
| <Switch | ||
| v-model="preferences.show_array_indicies" | ||
| id="show-array-indices" | ||
| /> | ||
| </div> | ||
|
|
||
| <!-- Hide Type Hints for Primitives --> | ||
| <div class="flex items-center justify-between space-x-2"> | ||
| <div class="flex flex-col space-y-1 flex-1"> | ||
| <label class="font-medium text-sm cursor-pointer"> | ||
| Hide Primitive Type Hints | ||
| </label> | ||
| <span class="text-xs text-muted-foreground"> | ||
| Hide type hints for integers, booleans, and text (show for maps/arrays) | ||
| </span> | ||
| </div> | ||
| <Switch | ||
| v-model="preferences.hide_type_hints_for_primitives" | ||
| id="hide-primitive-hints" | ||
| /> | ||
| </div> | ||
|
|
||
| <!-- Hide Map Key Type Hints for Primitives --> | ||
| <div class="flex items-center justify-between space-x-2"> | ||
| <div class="flex flex-col space-y-1 flex-1"> | ||
| <label class="font-medium text-sm cursor-pointer"> | ||
| Hide Map Key Primitive Type Hints | ||
| </label> | ||
| <span class="text-xs text-muted-foreground"> | ||
| Hide type hints for primitive map keys (text, integer, boolean) | ||
| </span> | ||
| </div> | ||
| <Switch | ||
| v-model="preferences.hide_map_key_type_hints_for_primitives" | ||
| id="hide-map-key-primitive-hints" | ||
| /> | ||
| </div> | ||
| </div> | ||
| </div> | ||
| </PopoverContent> | ||
| </template> | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,91 @@ | ||
| <script setup lang="ts"> | ||
| import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from '@/components/ui/tooltip' | ||
| import { usePointerPreferences } from '@/composable/usePointerPreferences' | ||
| import { getTypeName } from '@/lib/pointer-types' | ||
| import type { DIF } from '@unyt/datex' | ||
| import { computed, inject } from 'vue' | ||
|
|
||
| // Props | ||
| interface PointerRefInlineProps { | ||
| pointerId: string | ||
| } | ||
|
|
||
| const props = defineProps<PointerRefInlineProps>() | ||
|
|
||
| // Emits | ||
| const emit = defineEmits<{ | ||
| click: [pointerId: string] | ||
| }>() | ||
|
|
||
| // Inject the pointers map | ||
| const pointers = inject<Map<string, DIF.Definitions.DIFValueContainer>>('pointers') | ||
|
|
||
| // Use preferences composable | ||
| const { preferences } = usePointerPreferences() | ||
|
|
||
| // Compute display ID based on preferences | ||
| const displayId = computed(() => { | ||
| if (preferences.value.show_full_pointer_ids) { | ||
| return props.pointerId | ||
| } | ||
|
|
||
| // Show abbreviated ID (last 4 chars) | ||
| const numericPart = props.pointerId.slice(1) // Remove $ | ||
| if (numericPart.length > 4) { | ||
| return `$${numericPart.slice(-4)}` | ||
| } | ||
|
|
||
| return props.pointerId | ||
| }) | ||
|
|
||
| // Get the value preview for the pointer | ||
| const valuePreview = computed(() => { | ||
| if (!pointers) return '' | ||
|
|
||
| const difValueContainer = pointers.get(props.pointerId) | ||
| if (!difValueContainer) return '' | ||
|
|
||
| // Extract value from DIF container | ||
| const value = typeof difValueContainer === 'object' && difValueContainer !== null && 'value' in difValueContainer | ||
| ? (difValueContainer as Record<string, unknown>).value | ||
| : difValueContainer | ||
|
|
||
| const typeName = getTypeName(difValueContainer) | ||
|
|
||
| // Format preview based on type | ||
| if (typeName === 'text') return `"${value}"` | ||
| if (typeName === 'boolean') return value ? 'true' : 'false' | ||
| if (typeName === 'integer' || typeName === 'decimal') return String(value) | ||
| if (typeName === 'null') return 'null' | ||
| if (typeName === 'list') return '[...]' | ||
| if (typeName === 'map' || typeName === 'object') return '{...}' | ||
|
|
||
| return String(value) | ||
| }) | ||
|
|
||
| // Handle click | ||
| function handleClick() { | ||
| emit('click', props.pointerId) | ||
| } | ||
| </script> | ||
|
|
||
| <template> | ||
| <TooltipProvider :delay-duration="300"> | ||
| <Tooltip> | ||
| <TooltipTrigger as-child> | ||
| <button | ||
| @click.stop="handleClick" | ||
| class="inline-flex items-center gap-1.5 px-2 py-0.5 rounded text-xs font-medium bg-primary/10 text-primary hover:bg-primary/20 transition-colors cursor-pointer border border-primary/20" | ||
| > | ||
| <span class="font-mono">{{ displayId }}</span> | ||
| <span v-if="valuePreview" class="text-foreground/60 font-normal">→ {{ valuePreview }}</span> | ||
| </button> | ||
| </TooltipTrigger> | ||
| <TooltipContent> | ||
| <p class="text-xs font-mono">{{ pointerId }}</p> | ||
| <p v-if="valuePreview" class="text-xs text-muted-foreground">Value: {{ valuePreview }}</p> | ||
| <p class="text-xs text-muted-foreground mt-1">Click to jump to definition</p> | ||
| </TooltipContent> | ||
| </Tooltip> | ||
| </TooltipProvider> | ||
| </template> |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.