UNPKG

bits-ui

Version:

The headless components for Svelte.

27 lines (26 loc) 928 B
import { attachRef } from "svelte-toolbelt"; import { createBitsAttrs, getAriaHidden, getAriaOrientation, getDataOrientation, } from "../../internal/attrs.js"; const separatorAttrs = createBitsAttrs({ component: "separator", parts: ["root"], }); export class SeparatorRootState { static create(opts) { return new SeparatorRootState(opts); } opts; attachment; constructor(opts) { this.opts = opts; this.attachment = attachRef(opts.ref); } props = $derived.by(() => ({ id: this.opts.id.current, role: this.opts.decorative.current ? "none" : "separator", "aria-orientation": getAriaOrientation(this.opts.orientation.current), "aria-hidden": getAriaHidden(this.opts.decorative.current), "data-orientation": getDataOrientation(this.opts.orientation.current), [separatorAttrs.root]: "", ...this.attachment, })); }