summaryrefslogtreecommitdiffstats
path: root/chromium/third_party/node/node_modules/lit-html/directives/repeat.d.ts
diff options
context:
space:
mode:
authorMichal Klocek <michal.klocek@qt.io>2024-05-06 12:49:24 +0200
committerMichal Klocek <michal.klocek@qt.io>2024-05-07 09:51:27 +0000
commit6c04301ecbe57a84d6cc82776b9de9d27fd10076 (patch)
treeed50ecf908d5dec121b5646c69f9da2e6415965f /chromium/third_party/node/node_modules/lit-html/directives/repeat.d.ts
parentbdd23a0120a16de636b411a50c92cd273c4e80fa (diff)
Missing node module sources
* lit-html * lit-element * lit-reactive-element * lit-directive Change-Id: Idb8413411ad45acd9350e5f155c39c9789f15b95 Reviewed-on: https://codereview.qt-project.org/c/qt/qtwebengine-chromium/+/558486 Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
Diffstat (limited to 'chromium/third_party/node/node_modules/lit-html/directives/repeat.d.ts')
-rw-r--r--chromium/third_party/node/node_modules/lit-html/directives/repeat.d.ts64
1 files changed, 64 insertions, 0 deletions
diff --git a/chromium/third_party/node/node_modules/lit-html/directives/repeat.d.ts b/chromium/third_party/node/node_modules/lit-html/directives/repeat.d.ts
new file mode 100644
index 00000000000..b52b52da8c5
--- /dev/null
+++ b/chromium/third_party/node/node_modules/lit-html/directives/repeat.d.ts
@@ -0,0 +1,64 @@
+/**
+ * @license
+ * Copyright 2017 Google LLC
+ * SPDX-License-Identifier: BSD-3-Clause
+ */
+import { ChildPart, noChange } from '../lit-html.js';
+import { Directive, PartInfo } from '../directive.js';
+export type KeyFn<T> = (item: T, index: number) => unknown;
+export type ItemTemplate<T> = (item: T, index: number) => unknown;
+declare class RepeatDirective extends Directive {
+ private _itemKeys?;
+ constructor(partInfo: PartInfo);
+ private _getValuesAndKeys;
+ render<T>(items: Iterable<T>, template: ItemTemplate<T>): Array<unknown>;
+ render<T>(items: Iterable<T>, keyFn: KeyFn<T> | ItemTemplate<T>, template: ItemTemplate<T>): Array<unknown>;
+ update<T>(containerPart: ChildPart, [items, keyFnOrTemplate, template]: [
+ Iterable<T>,
+ KeyFn<T> | ItemTemplate<T>,
+ ItemTemplate<T>
+ ]): unknown[] | typeof noChange;
+}
+export interface RepeatDirectiveFn {
+ <T>(items: Iterable<T>, keyFnOrTemplate: KeyFn<T> | ItemTemplate<T>, template?: ItemTemplate<T>): unknown;
+ <T>(items: Iterable<T>, template: ItemTemplate<T>): unknown;
+ <T>(items: Iterable<T>, keyFn: KeyFn<T> | ItemTemplate<T>, template: ItemTemplate<T>): unknown;
+}
+/**
+ * A directive that repeats a series of values (usually `TemplateResults`)
+ * generated from an iterable, and updates those items efficiently when the
+ * iterable changes based on user-provided `keys` associated with each item.
+ *
+ * Note that if a `keyFn` is provided, strict key-to-DOM mapping is maintained,
+ * meaning previous DOM for a given key is moved into the new position if
+ * needed, and DOM will never be reused with values for different keys (new DOM
+ * will always be created for new keys). This is generally the most efficient
+ * way to use `repeat` since it performs minimum unnecessary work for insertions
+ * and removals.
+ *
+ * The `keyFn` takes two parameters, the item and its index, and returns a unique key value.
+ *
+ * ```js
+ * html`
+ * <ol>
+ * ${repeat(this.items, (item) => item.id, (item, index) => {
+ * return html`<li>${index}: ${item.name}</li>`;
+ * })}
+ * </ol>
+ * `
+ * ```
+ *
+ * **Important**: If providing a `keyFn`, keys *must* be unique for all items in a
+ * given call to `repeat`. The behavior when two or more items have the same key
+ * is undefined.
+ *
+ * If no `keyFn` is provided, this directive will perform similar to mapping
+ * items to values, and DOM will be reused against potentially different items.
+ */
+export declare const repeat: RepeatDirectiveFn;
+/**
+ * The type of the class that powers this directive. Necessary for naming the
+ * directive's return type.
+ */
+export type { RepeatDirective };
+//# sourceMappingURL=repeat.d.ts.map \ No newline at end of file