Skip to content

Commit 45ca4d6

Browse files
committed
fix(tabs): id composition
1 parent 6537759 commit 45ca4d6

File tree

3 files changed

+9
-4
lines changed

3 files changed

+9
-4
lines changed

.changeset/ripe-coats-retire.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@zag-js/tabs": patch
3+
---
4+
5+
Fix issue where ids for item and content could not be customized.

packages/machines/tabs/src/tabs.dom.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ import { first, last } from "@zag-js/utils"
44

55
export const getRootId = (ctx: Scope) => ctx.ids?.root ?? `tabs:${ctx.id}`
66
export const getListId = (ctx: Scope) => ctx.ids?.list ?? `tabs:${ctx.id}:list`
7-
export const getContentId = (ctx: Scope, id: string) => ctx.ids?.content ?? `tabs:${ctx.id}:content-${id}`
8-
export const getTriggerId = (ctx: Scope, id: string) => ctx.ids?.trigger ?? `tabs:${ctx.id}:trigger-${id}`
7+
export const getContentId = (ctx: Scope, id: string) => ctx.ids?.content?.(id) ?? `tabs:${ctx.id}:content-${id}`
8+
export const getTriggerId = (ctx: Scope, id: string) => ctx.ids?.trigger?.(id) ?? `tabs:${ctx.id}:trigger-${id}`
99
export const getIndicatorId = (ctx: Scope) => ctx.ids?.indicator ?? `tabs:${ctx.id}:indicator`
1010

1111
export const getListEl = (ctx: Scope) => ctx.getById(getListId(ctx))

packages/machines/tabs/src/tabs.types.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,9 @@ export interface IntlTranslations {
2929

3030
export type ElementIds = Partial<{
3131
root: string
32-
trigger: string
32+
trigger: (value: string) => string
3333
list: string
34-
content: string
34+
content: (value: string) => string
3535
indicator: string
3636
}>
3737

0 commit comments

Comments
 (0)