import { SvelteComponentTyped } from "svelte"; import type { SvelteHTMLElements } from "svelte/elements"; export type TagSetItem = { id: string; node: HTMLElement; label: string; value?: string | number; type?: import("../Tag/Tag.svelte").TagProps["type"]; size: string; disabled: boolean; filter: boolean; }; export type CarbonTagSetContext = { items: import("svelte/store").Writable; overflowIds: import("svelte/store").Writable>; size: import("svelte/store").Writable<"xs" | "sm" | "default" | "lg" | undefined>; navigation: import("svelte/store").Writable<"tab" | "roving">; tabStopId: import("svelte/store").Writable; register: (item: TagSetItem) => void; unregister: (id: string) => void; update: (id: string, patch: Partial>) => void; notifyClose: (id: string) => void; }; type $RestProps = SvelteHTMLElements["div"]; type $Props = { /** * Horizontal alignment of the visible tag row. * @default "start" */ align?: "start" | "center" | "end"; /** * Alignment of the overflow tooltip relative to the "+N" indicator. * @default "center" */ overflowAlign?: "start" | "center" | "end"; /** * Direction of the overflow tooltip relative to the "+N" indicator. * @default "bottom" */ overflowDirection?: "top" | "bottom"; /** * How the "+N" indicator shows the hidden tags. `"tooltip"` lists their * labels in a hover tooltip. `"popover"` makes the indicator a button that * opens a popover of the hidden tags themselves, so dismissible ones can * still be closed and touch users can reach them. * @default "tooltip" */ overflowMode?: "tooltip" | "popover"; /** * How the "+N" indicator lists the hidden tags: `"default"` lists their * labels as text, `"tag"` as tags in their own colors. In the popover and * the "View all" modal, `"tag"` keeps dismissible tags closable. * Defaults to `"default"` for the tooltip and `"tag"` for the popover. */ overflowType?: "default" | "tag" | undefined; /** * With more hidden tags than this, the popover lists only this many and * adds a "View all" button, and clicking a tooltip-mode "+N" opens the * modal directly. The modal lists every tag, with a search field. * Set to `Infinity` to never offer it. * @default 10 */ viewAllThreshold?: number; /** * Text of the popover's "View all" button. * @default "View all" */ viewAllText?: string; /** * Heading of the "View all" modal, also the name of its tag list. * @default "All tags" */ allTagsTitle?: string; /** * Label and placeholder of the "View all" modal's search field. * @default "Search tags" */ allTagsSearchLabel?: string; /** * Text announced, and shown when nothing matches, for the number of tags * the "View all" search finds. * @default (count) => count === 0 ? "No matching tags" : count === 1 ? "1 tag" : `${count} tags` */ allTagsResultsLabel?: (count: number) => string; /** * Set to `true` to open the "View all" modal. * @default false */ allTagsOpen?: boolean; /** * Accessible name of the "+N" overflow indicator. Keep the visible "+N" * in the name so speech-input users can say what they see. * @default (count) => `+${count} more tags` */ overflowLabel?: (count: number) => string; /** * Hard cap on visible tags regardless of available space. */ maxVisible?: number | undefined; /** * Keyboard navigation between tags. `"tab"` puts every interactive tag in * the tab order. `"roving"` makes the set a single tab stop: arrow keys, * Home, and End move between tags and the "+N" indicator, and Delete or * Backspace closes a focused dismissible tag. * @default "tab" */ navigation?: "tab" | "roving"; /** * Set to `true` to wrap all tags instead of collapsing to overflow. * @default false */ multiline?: boolean; /** * Subtracted from the measured available width before fitting tags. * @default 0 */ measurementOffset?: number; /** * Custom element to measure instead of `TagSet`'s own wrapper. */ containingElement?: HTMLElement | undefined; /** * Size of every tag, including the "+N" overflow indicator. Applies to * slotted `Tag` children without their own `size`. * Also accepts Carbon v11's `"md"` (`"default"`). */ size?: "xs" | "sm" | "default" | "lg" | "md" | undefined; /** * Spacing between tags. Accepts a Carbon layout scale (`0`–`13`) or a CSS * length string. * @default 3 */ gap?: import("../Stack/Stack.svelte").StackScale | string; /** * Set an id for the top-level element. * The overflow tooltip id derives from it as `{id}-overflow`. * @default uniqueId() */ id?: string; /** Override what the "+N" indicator shows: its tooltip, or its popover with `overflowMode="popover"`. Defaults to the hidden labels as text, or as tags in the popover. */ overflowTooltip?: (this: void, ...args: [{ tags: TagSetItem[]; count: number }]) => void; children?: (this: void) => void; [key: `data-${string}`]: unknown; }; export type TagSetProps = Omit<$RestProps, keyof $Props> & $Props; export default class TagSet extends SvelteComponentTyped< TagSetProps, { /** User clicks the "+N" indicator. Cancelable: prevent it to keep a tooltip-mode set from opening the "View all" modal. */ "click:overflow": CustomEvent<{ count: number }>; /** User clicks the close icon on a dismissible (`filter`) tag. */ "close:tag": CustomEvent<{ tag: TagSetItem; index: number }>; /** Dispatched when the number of overflowing tags changes, from a resize, a slotted-children change, or a `maxVisible` change. */ "overflow:change": CustomEvent<{ count: number }>; }, { default: Record; /** Override what the "+N" indicator shows: its tooltip, or its popover with `overflowMode="popover"`. Defaults to the hidden labels as text, or as tags in the popover. */ overflowTooltip: { tags: TagSetItem[]; count: number }; } > {}