Skip to content

Commit

Permalink
fix(next): ensure registry:ui components don't depend on themselves (#…
Browse files Browse the repository at this point in the history
…1490)

Co-authored-by: AdrianGonz97 <[email protected]>
fixes #1489
  • Loading branch information
ieedan authored Nov 15, 2024
1 parent 378b615 commit a817cfb
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 11 deletions.
9 changes: 9 additions & 0 deletions sites/docs/scripts/build-registry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,15 @@ function writeFileWithDirs(

async function main() {
const registry = await buildRegistry();

const selfReferenced = registry.filter((item) => item.registryDependencies.includes(item.name));
const selfReferenceError = selfReferenced
.map((item) => `Registry item '${item.name}' depends on itself`)
.join("\n");
if (selfReferenceError) {
throw new Error(selfReferenceError);
}

const result = registrySchema.safeParse(registry);

if (!result.success) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,7 @@
lang="ts"
generics="TData, TValue, TContext extends HeaderContext<TData, TValue> | CellContext<TData, TValue>"
>
import {
RenderComponentConfig,
RenderSnippetConfig,
} from "$lib/registry/default/ui/data-table/render-helpers.js";
import { RenderComponentConfig, RenderSnippetConfig } from "./render-helpers.js";
type Props = {
/** The cell or header field of the current cell's column definition. */
content?: TContext extends HeaderContext<TData, TValue>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<script lang="ts">
import { ToggleGroup as ToggleGroupPrimitive } from "bits-ui";
import { getToggleGroupCtx } from "$lib/registry/default/ui/toggle-group/toggle-group.svelte";
import { getToggleGroupCtx } from "./toggle-group.svelte";
import { cn } from "$lib/utils.js";
import { type ToggleVariants, toggleVariants } from "$lib/registry/default/ui/toggle/index.js";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,7 @@
lang="ts"
generics="TData, TValue, TContext extends HeaderContext<TData, TValue> | CellContext<TData, TValue>"
>
import {
RenderComponentConfig,
RenderSnippetConfig,
} from "$lib/registry/new-york/ui/data-table/render-helpers.js";
import { RenderComponentConfig, RenderSnippetConfig } from "./render-helpers.js";
type Props = {
/** The cell or header field of the current cell's column definition. */
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<script lang="ts">
import { Select as SelectPrimitive, type WithoutChild } from "bits-ui";
import * as Select from "$lib/registry/new-york/ui/select/index.js";
import * as Select from "./index.js";
import { cn } from "$lib/utils.js";
let {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<script lang="ts">
import { ToggleGroup as ToggleGroupPrimitive } from "bits-ui";
import { getToggleGroupCtx } from "$lib/registry/new-york/ui/toggle-group/toggle-group.svelte";
import { getToggleGroupCtx } from "./toggle-group.svelte";
import { cn } from "$lib/utils.js";
import { type ToggleVariants, toggleVariants } from "$lib/registry/new-york/ui/toggle/index.js";
Expand Down

0 comments on commit a817cfb

Please sign in to comment.