/** * Caller-assigned item tags, shared by every list-like component * (`ixfx-grid-list`, `ixfx-detail-list`, `ixfx-data-grid`, `ixfx-multicol-list`). * * What a tag *means* belongs to the caller. The component only * * 1. exposes it for styling: a `tag-` token in the item's `part`, and * `data-tags` (space-separated, so `[data-tags~="foo"]` matches); * 2. applies the generic interaction flags declared for it in `tagBehaviour`. * * Tokens are prefixed so a caller tag called `selected` cannot collide with * the built-in state token. */ /** Generic interaction flags a tag can switch off. Omitted flags keep the default (`true`). */ type ItemTagBehaviourFlags = { /** `false`: no selection or tickle, no `list-select-intent`; range and select-all skip the item. */ selectable?: boolean; /** `false`: keyboard cursor movement skips the item. */ focusable?: boolean; /** `false`: no drag starts from the item. */ draggable?: boolean; /** `false`: the item is left out of incremental search. */ searchable?: boolean; /** * `false`: the item can't be moved by drag-to-reorder (`items-reorderable`). It is left out of a * dragged block, so the rest of a multi-selection still moves. A gap next to it can still be targeted. */ reorderable?: boolean; }; /** Behaviour declarations keyed by tag name. */ type ItemTagBehaviour = Readonly>; /** Tag assignment by key set: tag name → keys that carry it. Like `partialKeys`, for tags kept apart from the data. */ type ItemTagKeys = ReadonlyMap>; /** The effective flags for an item: every flag is explicit. */ type ResolvedItemTagFlags = Required; declare const DEFAULT_ITEM_TAG_FLAGS: ResolvedItemTagFlags; /** Prefix of a tag's `part` token. */ declare const TAG_PART_PREFIX = "tag-"; /** * Merge the tags from the per-item hook and from `tagKeys`, de-duplicated, * in first-seen order. Empty and whitespace-containing names are dropped * (they could not be a single `part` token). */ declare function collectTags(key: string | undefined, fromHook: readonly string[] | undefined, tagKeys: ItemTagKeys | undefined): readonly string[]; /** Most restrictive wins: any `false` among the item's tags beats the default and any `true`. */ declare function resolveTagFlags(tags: readonly string[], behaviour: ItemTagBehaviour | undefined): ResolvedItemTagFlags; /** ` tag-foo tag-bar` — append to a `part` value. Empty string when there are no tags. */ declare function tagPartTokens(tags: readonly string[]): string; /** Value for `data-tags` (`"foo bar"`), or `undefined` when there are no tags. */ declare function tagsAttribute(tags: readonly string[]): string | undefined; /** Reflect tags onto an element (element mode / light DOM): `data-tags`, and `tag-*` tokens in `part` it didn't set. */ declare function applyTagAttributes(el: Element, tags: readonly string[], basePart?: string): void; /** Whether two tag lists are identical (order matters; lists are tiny). */ declare function sameTags(a: readonly string[], b: readonly string[]): boolean; /** Whether two `tagKeys` maps hold the same tags with the same keys. */ declare function sameTagKeys(a: ItemTagKeys | undefined, b: ItemTagKeys | undefined): boolean; /** * Per-component holder for the two assignment forms and `tagBehaviour`. * Resolves an item's tags and flags; caches nothing (callers re-render on change). */ declare class ItemTagResolver { tagKeys: ItemTagKeys | undefined; behaviour: ItemTagBehaviour | undefined; /** Tags for an item, merging the hook's result with `tagKeys`. */ tagsFor(key: string | undefined, fromHook?: readonly string[]): readonly string[]; flagsFor(tags: readonly string[]): ResolvedItemTagFlags; /** Convenience: flags for an item straight from its key and hook result. */ flagsForItem(key: string | undefined, fromHook?: readonly string[]): ResolvedItemTagFlags; } /** * Shared types for positional drops and drag-to-reorder on the list components * (`ixfx-grid-list`, `ixfx-data-grid`, `ixfx-detail-list`, `ixfx-vertical-list`, * `ixfx-flat-list`). */ /** * Which targets a drag can resolve to. * - `on`: onto an item. * - `between`: into the gap between two items. * - `both`: either — the outer quarters of an item (on the flow axis) mean `between`, the middle half means `on`. */ type ListDropPositions = `on` | `between` | `both`; /** * Why `between` targets are refused, because the visible order is not the item order. * `on` drops still work. */ type ListReorderBlocked = `sorted` | `grouped`; /** The gap a `between` target names. */ type ListDropBetween = { readonly kind: `between`; /** * The item the insertion goes **before** (the one after the gap), in the full, unfiltered * item order. `undefined` at the end of the list. */ readonly beforeKey: string | undefined; /** * The item the insertion goes **after** (the one before the gap), in the full, unfiltered * item order. `undefined` at the start of the list. */ readonly afterKey: string | undefined; /** Insertion index into the full (unfiltered) item order. */ readonly index: number; }; /** * What a drag is over. * * `between` is reported in **full item order** (the unfiltered items the host set), not * visible order. When a filter hides items between two visible neighbours, the drop goes * directly after the visible item before the gap: `afterKey` is that visible item and * `beforeKey` is whatever follows it in full order. */ type ListDropTarget = { readonly kind: `on`; readonly key: string; } | ListDropBetween | { readonly kind: `empty`; }; /** `list-drop` — an external drag was dropped. */ type ListTargetDropDetail = { readonly target: ListDropTarget; readonly dataTransfer: DataTransfer; /** `ixfx-vertical-list` only, kept for older hosts: the key of an `on` target. Use `target`. */ readonly key?: string | undefined; /** `ixfx-vertical-list` only, kept for older hosts: the element of an `on` target. Use `target`. */ readonly item?: Element | undefined; }; /** `list-reorder` — a drag that started in this list ended between its own items. Cancelable. */ type ListReorderDetail = { /** The dragged block, in display order. */ readonly keys: readonly string[]; readonly target: ListDropBetween; }; type ListTargetDropEvent = CustomEvent; type ListReorderEvent = CustomEvent; /** Gate on every `dragover`, given the resolved target. `false` ⇒ no indicator and no event. */ type ListCanDrop = (target: ListDropTarget, dataTransfer: DataTransfer) => boolean; /** Gate for internal moves (`false` ⇒ no indicator and no event). */ type ListCanReorder = (keys: readonly string[], target: ListDropBetween) => boolean; /** * Lets a host that cancels the browser drag (to start an OS drag in its place) still say which * keys a drag carries. Return `undefined` for a drag that is not the host's own. */ type ListResolveInternalDrag = (dataTransfer: DataTransfer) => readonly string[] | undefined; /** Read access to the full (unfiltered) item order. */ type ListFullOrder = { readonly count: number; keyAt: (index: number) => string | undefined; /** Index of `key` in the full order, or `-1`. */ indexOf: (key: string) => number; }; export { sameTagKeys as C, tagsAttribute as E, resolveTagFlags as S, tagPartTokens as T, ItemTagResolver as _, ListDropTarget as a, applyTagAttributes as b, ListReorderDetail as c, ListTargetDropDetail as d, ListTargetDropEvent as f, ItemTagKeys as g, ItemTagBehaviourFlags as h, ListDropPositions as i, ListReorderEvent as l, ItemTagBehaviour as m, ListCanReorder as n, ListFullOrder as o, DEFAULT_ITEM_TAG_FLAGS as p, ListDropBetween as r, ListReorderBlocked as s, ListCanDrop as t, ListResolveInternalDrag as u, ResolvedItemTagFlags as v, sameTags as w, collectTags as x, TAG_PART_PREFIX as y };