import { isString, TypedMap } from '@kraftr/common'; import type { Binding } from './binding'; export declare type BindingFilter = { (binding: Readonly>): boolean; }; /** * A function to check if a given tag value match for `filterByTag` */ export declare type TagValueMatcher> = { /** * Check if the given tag value matches the search criteria * @param tagValue - Tag value from the binding * @param tagName - Tag name * @param tagMap - Tag map from the binding */ (tagValue: Value, tagName: Name, tagMap: TypedMap): boolean; }; /** * A symbol that can be used to match binding tags by name regardless of the * value. * * @example * * The following code matches bindings with tag `{controller: 'A'}` or * `{controller: 'controller'}`. But if the tag name 'controller' does not * exist for a binding, the binding will NOT be included. * * ```ts * ctx.findByTag({controller: ANY_TAG_VALUE}) * ``` */ export declare const ANY_TAG_VALUE: TagValueMatcher; export declare type UnionOf = T extends unknown[] ? T[number] : T; /** * Create a tag value matcher function that returns `true` if the target tag * value equals to the item value or is an array that includes the item value. * @param itemValues - A list of tag item value */ export declare function includesTagValue(...items: [...UnionOf[]]): TagValueMatcher; export declare function filterByTag>(tagMap: { [Key in keyof Tags]?: TagValueMatcher, Tags> | Tags[Key]; }): BindingFilter;