/** * @license * Copyright 2021 Google LLC * SPDX-License-Identifier: BSD-3-Clause */ import ts from 'typescript'; import type { LitClassContext } from '../lit-class-context.js'; import type { MemberDecoratorVisitor } from '../visitor.js'; /** * Transform: * * @queryAssignedElements({slot: 'list', selector: '.item'}) * listItems * * Into: * * get listItems() { * return this.renderRoot * ?.querySelector('slot[name=list]') * ?.assignedElements() * ?.filter((node) => node.matches('.item') * } */ export declare class QueryAssignedElementsVisitor implements MemberDecoratorVisitor { readonly kind = "memberDecorator"; decoratorName: string; /** * The method used to query the HTMLSlot element. */ protected slottedQuery: string; protected readonly _factory: ts.NodeFactory; constructor({ factory }: ts.TransformationContext); visit(litClassContext: LitClassContext, property: ts.ClassElement, decorator: ts.Decorator): void; /** * @param opts object literal node passed into the queryAssignedElements decorator * @returns expression nodes for the slot and selector. */ private _retrieveSlotAndSelector; /** * queryAssignedElements options contains a superset of the options that * `HTMLSlotElement.assignedElements` accepts. This method takes the original * optional options passed into `queryAssignedElements` and filters out any * decorator specific property assignments. * * Given: * * ```ts * { slot: 'example', flatten: false } * ``` * * returns: * * ```ts * { flatten: false } * ``` * * Returns `undefined` instead of an empty object literal if no property * assignments are left after filtering, such that we don't generate code * like `HTMLSlotElement.assignedElements({})`. */ private _filterAssignedOptions; private _createQueryAssignedGetter; /** * @param selector User supplied CSS selector. * @returns Expression used to filter the queried Elements. */ protected getSelectorFilter(selector: ts.Expression): ts.Expression; /** * Returns a template string which resolves the passed in slot name * expression. * * Special handling is included for string literals and no substitution * template literals. In this case we inline the slot name into the selector * to match what is more likely to have been authored. * * @param slot Expression that evaluates to the slot name. * @returns Template string node representing `slot[name=${slot}]` except when * `slot` is a string literal. Then the literal is inlined. I.e. for a slot * expression of `"list"`, return `slot[name=list]`. */ private createNamedSlotSelector; /** * @returns Template string node representing `slot:not([name])` */ private createDefaultSlotSelector; }