1 | /**
|
2 | * @license
|
3 | * Copyright 2020 Google LLC
|
4 | * SPDX-License-Identifier: BSD-3-Clause
|
5 | */
|
6 | import { Part, DirectiveParent, CompiledTemplateResult, MaybeCompiledTemplateResult, UncompiledTemplateResult } from './lit-html.js';
|
7 | import { DirectiveResult, DirectiveClass, PartInfo } from './directive.js';
|
8 | type Primitive = null | undefined | boolean | number | string | symbol | bigint;
|
9 | declare const ChildPart: typeof import("./lit-html.js").ChildPart;
|
10 | type ChildPart = InstanceType<typeof ChildPart>;
|
11 | /**
|
12 | * Tests if a value is a primitive value.
|
13 | *
|
14 | * See https://tc39.github.io/ecma262/#sec-typeof-operator
|
15 | */
|
16 | export declare const isPrimitive: (value: unknown) => value is Primitive;
|
17 | export declare const TemplateResultType: {
|
18 | readonly HTML: 1;
|
19 | readonly SVG: 2;
|
20 | };
|
21 | export type TemplateResultType = (typeof TemplateResultType)[keyof typeof TemplateResultType];
|
22 | type IsTemplateResult = {
|
23 | (val: unknown): val is MaybeCompiledTemplateResult;
|
24 | <T extends TemplateResultType>(val: unknown, type: T): val is UncompiledTemplateResult<T>;
|
25 | };
|
26 | /**
|
27 | * Tests if a value is a TemplateResult or a CompiledTemplateResult.
|
28 | */
|
29 | export declare const isTemplateResult: IsTemplateResult;
|
30 | /**
|
31 | * Tests if a value is a CompiledTemplateResult.
|
32 | */
|
33 | export declare const isCompiledTemplateResult: (value: unknown) => value is CompiledTemplateResult;
|
34 | /**
|
35 | * Tests if a value is a DirectiveResult.
|
36 | */
|
37 | export declare const isDirectiveResult: (value: unknown) => value is DirectiveResult<DirectiveClass>;
|
38 | /**
|
39 | * Retrieves the Directive class for a DirectiveResult
|
40 | */
|
41 | export declare const getDirectiveClass: (value: unknown) => DirectiveClass | undefined;
|
42 | /**
|
43 | * Tests whether a part has only a single-expression with no strings to
|
44 | * interpolate between.
|
45 | *
|
46 | * Only AttributePart and PropertyPart can have multiple expressions.
|
47 | * Multi-expression parts have a `strings` property and single-expression
|
48 | * parts do not.
|
49 | */
|
50 | export declare const isSingleExpression: (part: PartInfo) => boolean;
|
51 | /**
|
52 | * Inserts a ChildPart into the given container ChildPart's DOM, either at the
|
53 | * end of the container ChildPart, or before the optional `refPart`.
|
54 | *
|
55 | * This does not add the part to the containerPart's committed value. That must
|
56 | * be done by callers.
|
57 | *
|
58 | * @param containerPart Part within which to add the new ChildPart
|
59 | * @param refPart Part before which to add the new ChildPart; when omitted the
|
60 | * part added to the end of the `containerPart`
|
61 | * @param part Part to insert, or undefined to create a new part
|
62 | */
|
63 | export declare const insertPart: (containerPart: ChildPart, refPart?: ChildPart, part?: ChildPart) => ChildPart;
|
64 | /**
|
65 | * Sets the value of a Part.
|
66 | *
|
67 | * Note that this should only be used to set/update the value of user-created
|
68 | * parts (i.e. those created using `insertPart`); it should not be used
|
69 | * by directives to set the value of the directive's container part. Directives
|
70 | * should return a value from `update`/`render` to update their part state.
|
71 | *
|
72 | * For directives that require setting their part value asynchronously, they
|
73 | * should extend `AsyncDirective` and call `this.setValue()`.
|
74 | *
|
75 | * @param part Part to set
|
76 | * @param value Value to set
|
77 | * @param index For `AttributePart`s, the index to set
|
78 | * @param directiveParent Used internally; should not be set by user
|
79 | */
|
80 | export declare const setChildPartValue: <T extends import("./lit-html.js").ChildPart>(part: T, value: unknown, directiveParent?: DirectiveParent) => T;
|
81 | /**
|
82 | * Sets the committed value of a ChildPart directly without triggering the
|
83 | * commit stage of the part.
|
84 | *
|
85 | * This is useful in cases where a directive needs to update the part such
|
86 | * that the next update detects a value change or not. When value is omitted,
|
87 | * the next update will be guaranteed to be detected as a change.
|
88 | *
|
89 | * @param part
|
90 | * @param value
|
91 | */
|
92 | export declare const setCommittedValue: (part: Part, value?: unknown) => unknown;
|
93 | /**
|
94 | * Returns the committed value of a ChildPart.
|
95 | *
|
96 | * The committed value is used for change detection and efficient updates of
|
97 | * the part. It can differ from the value set by the template or directive in
|
98 | * cases where the template value is transformed before being committed.
|
99 | *
|
100 | * - `TemplateResult`s are committed as a `TemplateInstance`
|
101 | * - Iterables are committed as `Array<ChildPart>`
|
102 | * - All other types are committed as the template value or value returned or
|
103 | * set by a directive.
|
104 | *
|
105 | * @param part
|
106 | */
|
107 | export declare const getCommittedValue: (part: ChildPart) => unknown;
|
108 | /**
|
109 | * Removes a ChildPart from the DOM, including any of its content.
|
110 | *
|
111 | * @param part The Part to remove
|
112 | */
|
113 | export declare const removePart: (part: ChildPart) => void;
|
114 | export declare const clearPart: (part: ChildPart) => void;
|
115 | export {};
|
116 | //# sourceMappingURL=directive-helpers.d.ts.map |
\ | No newline at end of file |