mirror of
https://github.com/vercel-labs/json-render.git
synced 2026-09-14 13:41:32 +08:00
40892a6af0
* init
* fix: resolve all type errors, runtime bugs, and test failures in @json-render/shadcn-svelte
- Add /index.js extensions to all ../ui/* imports (NodeNext moduleResolution)
- Type shadcnComponents as Record<string, Component<any>> to fix d.ts generation
- Call getBoundProp() once at top level instead of inside a binding() function
called from event handlers (getContext() only works during initialization)
- Move getOptionalValidationContext() call to top level; update createValidation()
to accept the context as first param instead of calling getContext() itself
- Wrap validation.register() in untrack() to break the fieldConfigs read-write
cycle that caused effect_update_depth_exceeded in tests
- Fix implicit any on Input onkeydown handler (KeyboardEvent type)
- Use untrack() for $state() initializers that read reactive props values
- Call getStateValue() once at top level in Dialog/Drawer (not in a function
called from event handlers)
- Fix test fixtures: use named imports { StateProvider, ValidationProvider }
- Add server.deps.inline for bits-ui and @lucide/svelte so vitest can process
their .svelte source files; add root svelte.config.js with runes: true
- Add role/aria-modal/tabindex/onkeydown a11y attributes to Dialog and Drawer
- Fix self-closing non-void elements in Skeleton, Spinner, Textarea
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
* update shadcn-svelte components
* fixes
* fixes
* fix: address PR review issues for shadcn-svelte renderer
- Fix missing comma in .changeset/config.json (invalid JSON)
- Fix Slider.svelte type errors (single-mode expects number, not array)
- Replace raw <button> with shadcn Button in Pagination.svelte
- Remove global font import and body/html overrides from app.css
- Remove root svelte.config.js (duplicates package-level config)
- Revert unrelated packageManager version bump
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
---------
Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
42 lines
1.1 KiB
Svelte
42 lines
1.1 KiB
Svelte
<script lang="ts">
|
|
import { getBoundProp } from "@json-render/svelte";
|
|
import type { BaseComponentProps } from "@json-render/svelte";
|
|
import type { ShadcnProps } from "./catalog.js";
|
|
import {
|
|
DropdownMenu,
|
|
DropdownMenuContent,
|
|
DropdownMenuItem,
|
|
DropdownMenuTrigger,
|
|
} from "./ui/dropdown-menu/index.js";
|
|
import { Button } from "./ui/button/index.js";
|
|
|
|
interface Props extends BaseComponentProps<ShadcnProps<"DropdownMenu">> {}
|
|
|
|
let { props, bindings, emit }: Props = $props();
|
|
|
|
const valueBound = getBoundProp<string>(
|
|
() => props.value ?? undefined,
|
|
() => bindings?.value,
|
|
);
|
|
|
|
function select(value: string) {
|
|
valueBound.current = value;
|
|
emit("select");
|
|
}
|
|
</script>
|
|
|
|
<DropdownMenu>
|
|
<DropdownMenuTrigger>
|
|
{#snippet child({ props: triggerProps })}
|
|
<Button variant="outline" {...triggerProps}>{props.label}</Button>
|
|
{/snippet}
|
|
</DropdownMenuTrigger>
|
|
<DropdownMenuContent>
|
|
{#each props.items ?? [] as item}
|
|
<DropdownMenuItem onclick={() => select(item.value)}>
|
|
{item.label}
|
|
</DropdownMenuItem>
|
|
{/each}
|
|
</DropdownMenuContent>
|
|
</DropdownMenu>
|