@ng-native/components 0.26.1 → 0.28.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/android/src/main/java/dev/ngnative/components/ContextMenuPopup.kt +61 -19
- package/android/src/main/java/dev/ngnative/components/MenusModule.kt +22 -0
- package/android/src/main/java/dev/ngnative/components/Shortcut.kt +13 -4
- package/dist/context-menu.d.ts +14 -6
- package/dist/context-menu.js +30 -28
- package/dist/context-menu.js.map +1 -1
- package/dist/drag-and-drop.d.ts +4 -4
- package/dist/drag-and-drop.js +6 -6
- package/dist/drag-and-drop.js.map +1 -1
- package/dist/index.d.ts +3 -0
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -1
- package/dist/menu.d.ts +7 -4
- package/dist/menu.js +10 -4
- package/dist/menu.js.map +1 -1
- package/dist/modal.d.ts +12 -8
- package/dist/modal.js +8 -8
- package/dist/modal.js.map +1 -1
- package/dist/native-button.d.ts +13 -3
- package/dist/native-button.js +12 -5
- package/dist/native-button.js.map +1 -1
- package/dist/press-menu.d.ts +39 -0
- package/dist/press-menu.js +76 -0
- package/dist/press-menu.js.map +1 -0
- package/dist/pressable.d.ts +3 -0
- package/dist/pressable.js +6 -1
- package/dist/pressable.js.map +1 -1
- package/dist/reanimated.js +27 -3
- package/dist/reanimated.js.map +1 -1
- package/dist/safe-area-provider.js +9 -7
- package/dist/safe-area-provider.js.map +1 -1
- package/dist/settled-updates.d.ts +55 -0
- package/dist/settled-updates.js +77 -0
- package/dist/settled-updates.js.map +1 -0
- package/dist/sidebar-item.d.ts +19 -4
- package/dist/sidebar-item.js +33 -6
- package/dist/sidebar-item.js.map +1 -1
- package/dist/sidebar-section.js +3 -2
- package/dist/sidebar-section.js.map +1 -1
- package/dist/stand-ins/reanimated.d.ts +5 -0
- package/dist/stand-ins/reanimated.js +7 -0
- package/dist/stand-ins/reanimated.js.map +1 -1
- package/dist/sticky-rows.d.ts +120 -25
- package/dist/sticky-rows.js +265 -65
- package/dist/sticky-rows.js.map +1 -1
- package/dist/svg-icon.d.ts +9 -0
- package/dist/svg-icon.js +37 -0
- package/dist/svg-icon.js.map +1 -0
- package/dist/virtual-list-sticky-level.d.ts +39 -0
- package/dist/virtual-list-sticky-level.js +82 -0
- package/dist/virtual-list-sticky-level.js.map +1 -0
- package/dist/virtual-list-sticky.d.ts +19 -0
- package/dist/virtual-list-sticky.js +13 -0
- package/dist/virtual-list-sticky.js.map +1 -0
- package/dist/virtual-list.d.ts +6 -2
- package/dist/virtual-list.js +60 -43
- package/dist/virtual-list.js.map +1 -1
- package/dist/worklet-style.d.ts +11 -0
- package/dist/worklet-style.js +15 -1
- package/dist/worklet-style.js.map +1 -1
- package/dist/worklets.d.ts +5 -1
- package/dist/worklets.js.map +1 -1
- package/dist/written-props.js +1 -0
- package/dist/written-props.js.map +1 -1
- package/package.json +3 -3
package/dist/svg-icon.js
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The `{ svg }` form of a `ButtonIcon`: an icon's SVG markup, such as an `@ng-icons` set's, which
|
|
3
|
+
* the macOS and Linux hosts draw as their own icon (a template image AppKit tints, and a symbolic
|
|
4
|
+
* icon GTK draws in the text colour). They take it as the `svgIcon` prop.
|
|
5
|
+
*/
|
|
6
|
+
import { nativePlatform } from '@ng-native/fabric';
|
|
7
|
+
/** What was already said, so a list of rows says it once. */
|
|
8
|
+
const warned = new Set();
|
|
9
|
+
function warnOnce(key, message) {
|
|
10
|
+
if ((typeof ngDevMode !== 'undefined' && !ngDevMode) || warned.has(key))
|
|
11
|
+
return;
|
|
12
|
+
warned.add(key);
|
|
13
|
+
console.warn(`[angular-native] ${message}`);
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* The markup to commit as `svgIcon` for an icon, or undefined when it is not `{ svg }`. Says once,
|
|
17
|
+
* in development, when the markup is no `<svg>` element (the icon's name in place of its markup is
|
|
18
|
+
* the usual slip), and with `offDesktop` when the platform running draws a symbol or a drawable for
|
|
19
|
+
* the element but no SVG, since either shows no icon.
|
|
20
|
+
*/
|
|
21
|
+
export function svgIconMarkup(icon, element, offDesktop = false) {
|
|
22
|
+
if (!icon || !('svg' in icon) || typeof icon.svg !== 'string')
|
|
23
|
+
return undefined;
|
|
24
|
+
const markup = icon.svg;
|
|
25
|
+
if (!/<svg[\s/>]/i.test(markup)) {
|
|
26
|
+
warnOnce(`markup:${markup}`, `<${element}> was given an SVG icon that is no <svg> element, so it shows none: ` +
|
|
27
|
+
`"${markup.slice(0, 40)}". Pass the icon's markup, such as the string ` +
|
|
28
|
+
`@ng-icons/lucide exports, not its name.`);
|
|
29
|
+
}
|
|
30
|
+
const os = nativePlatform();
|
|
31
|
+
if (offDesktop && os !== 'macos' && os !== 'linux') {
|
|
32
|
+
warnOnce(`platform:${element}:${os}`, `<${element}> draws an SVG icon on macOS and Linux only, so on ${os} it shows none. ` +
|
|
33
|
+
`Give it { sfSymbol } or { drawable } there.`);
|
|
34
|
+
}
|
|
35
|
+
return markup;
|
|
36
|
+
}
|
|
37
|
+
//# sourceMappingURL=svg-icon.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"svg-icon.js","sourceRoot":"","sources":["../src/svg-icon.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAInD,6DAA6D;AAC7D,MAAM,MAAM,GAAG,IAAI,GAAG,EAAU,CAAC;AAEjC,SAAS,QAAQ,CAAC,GAAW,EAAE,OAAe;IAC5C,IAAI,CAAC,OAAO,SAAS,KAAK,WAAW,IAAI,CAAC,SAAS,CAAC,IAAI,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC;QAAE,OAAO;IAChF,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IAChB,OAAO,CAAC,IAAI,CAAC,oBAAoB,OAAO,EAAE,CAAC,CAAC;AAC9C,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,aAAa,CAC3B,IAAoD,EACpD,OAAe,EACf,UAAU,GAAG,KAAK;IAElB,IAAI,CAAC,IAAI,IAAI,CAAC,CAAC,KAAK,IAAI,IAAI,CAAC,IAAI,OAAO,IAAI,CAAC,GAAG,KAAK,QAAQ;QAAE,OAAO,SAAS,CAAC;IAChF,MAAM,MAAM,GAAG,IAAI,CAAC,GAAG,CAAC;IACxB,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC;QAChC,QAAQ,CACN,UAAU,MAAM,EAAE,EAClB,IAAI,OAAO,sEAAsE;YAC/E,IAAI,MAAM,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,gDAAgD;YACvE,yCAAyC,CAC5C,CAAC;IACJ,CAAC;IACD,MAAM,EAAE,GAAG,cAAc,EAAE,CAAC;IAC5B,IAAI,UAAU,IAAI,EAAE,KAAK,OAAO,IAAI,EAAE,KAAK,OAAO,EAAE,CAAC;QACnD,QAAQ,CACN,YAAY,OAAO,IAAI,EAAE,EAAE,EAC3B,IAAI,OAAO,sDAAsD,EAAE,kBAAkB;YACnF,6CAA6C,CAChD,CAAC;IACJ,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC","sourcesContent":["/**\n * The `{ svg }` form of a `ButtonIcon`: an icon's SVG markup, such as an `@ng-icons` set's, which\n * the macOS and Linux hosts draw as their own icon (a template image AppKit tints, and a symbolic\n * icon GTK draws in the text colour). They take it as the `svgIcon` prop.\n */\nimport { nativePlatform } from '@ng-native/fabric';\n\ndeclare const ngDevMode: unknown;\n\n/** What was already said, so a list of rows says it once. */\nconst warned = new Set<string>();\n\nfunction warnOnce(key: string, message: string): void {\n if ((typeof ngDevMode !== 'undefined' && !ngDevMode) || warned.has(key)) return;\n warned.add(key);\n console.warn(`[angular-native] ${message}`);\n}\n\n/**\n * The markup to commit as `svgIcon` for an icon, or undefined when it is not `{ svg }`. Says once,\n * in development, when the markup is no `<svg>` element (the icon's name in place of its markup is\n * the usual slip), and with `offDesktop` when the platform running draws a symbol or a drawable for\n * the element but no SVG, since either shows no icon.\n */\nexport function svgIconMarkup(\n icon: { readonly svg?: string } | object | undefined,\n element: string,\n offDesktop = false,\n): string | undefined {\n if (!icon || !('svg' in icon) || typeof icon.svg !== 'string') return undefined;\n const markup = icon.svg;\n if (!/<svg[\\s/>]/i.test(markup)) {\n warnOnce(\n `markup:${markup}`,\n `<${element}> was given an SVG icon that is no <svg> element, so it shows none: ` +\n `\"${markup.slice(0, 40)}\". Pass the icon's markup, such as the string ` +\n `@ng-icons/lucide exports, not its name.`,\n );\n }\n const os = nativePlatform();\n if (offDesktop && os !== 'macos' && os !== 'linux') {\n warnOnce(\n `platform:${element}:${os}`,\n `<${element}> draws an SVG icon on macOS and Linux only, so on ${os} it shows none. ` +\n `Give it { sfSymbol } or { drawable } there.`,\n );\n }\n return markup;\n}\n"]}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { type VirtualListSticky } from './virtual-list-sticky.ts';
|
|
2
|
+
import * as i0 from "@angular/core";
|
|
3
|
+
/**
|
|
4
|
+
* Sticky rows at more than one level, on `<virtual-list>` itself: a year pinned at the leading
|
|
5
|
+
* edge, its month under it and the day under that, each pushed off by the next of its own level
|
|
6
|
+
* or of one further out.
|
|
7
|
+
*
|
|
8
|
+
* ```html
|
|
9
|
+
* <virtual-list #list [items]="rows" [itemHeight]="44" [virtualListStickyLevel]="levelOf">
|
|
10
|
+
* @for (row of list.window(); track row.slot) {
|
|
11
|
+
* <view [virtualListRow]="row"><text>{{ row.item.label }}</text></view>
|
|
12
|
+
* }
|
|
13
|
+
* </virtual-list>
|
|
14
|
+
* ```
|
|
15
|
+
*
|
|
16
|
+
* `levelOf` is given each item and its index and returns the row's level: 0 for the outermost,
|
|
17
|
+
* 1 for the rows pinned under those, and so on, or `null` for a row that scrolls with the rest.
|
|
18
|
+
* A row pins under the nearest row before it of each level further out than its own, and stays
|
|
19
|
+
* until the next row of its own level, or of one further out, pushes it off. The rows of
|
|
20
|
+
* `stickyIndices` are at level 0, so the two can be given together.
|
|
21
|
+
*
|
|
22
|
+
* ponytail: rows that size themselves pin level 0 alone, with a warning in development, and
|
|
23
|
+
* deeper rows scroll with the rest: where a row pins under others depends on their heights, which
|
|
24
|
+
* are not known until each has been measured.
|
|
25
|
+
*/
|
|
26
|
+
export declare class VirtualListStickyLevel<T = unknown> implements VirtualListSticky {
|
|
27
|
+
/** A row's level, from 0 for the outermost, or `null` for a row that is not sticky. */
|
|
28
|
+
readonly level: import("@angular/core").InputSignal<((item: T, index: number) => number | null | undefined) | null | undefined>;
|
|
29
|
+
/**
|
|
30
|
+
* How many levels pin at once, from the outermost. Rows deeper than that are not sticky. It
|
|
31
|
+
* limits the levels the function gives: the rows of `stickyIndices` pin whatever it is.
|
|
32
|
+
*/
|
|
33
|
+
readonly maxLevels: import("@angular/core").InputSignalWithTransform<number, unknown>;
|
|
34
|
+
private readonly injector;
|
|
35
|
+
readonly levelOf: import("@angular/core").Signal<((item: unknown, index: number) => number | null) | null>;
|
|
36
|
+
constructor();
|
|
37
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<VirtualListStickyLevel<any>, never>;
|
|
38
|
+
static ɵdir: i0.ɵɵDirectiveDeclaration<VirtualListStickyLevel<any>, "virtual-list[virtualListStickyLevel]", never, { "level": { "alias": "virtualListStickyLevel"; "required": false; "isSignal": true; }; "maxLevels": { "alias": "virtualListMaxStickyLevels"; "required": false; "isSignal": true; }; }, {}, never, never, true, never>;
|
|
39
|
+
}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { Directive, Injector, computed, effect, forwardRef, inject, input } from '@angular/core';
|
|
2
|
+
import { numberOr } from "./transforms.js";
|
|
3
|
+
import { VirtualList } from "./virtual-list.js";
|
|
4
|
+
import { VIRTUAL_LIST_STICKY } from "./virtual-list-sticky.js";
|
|
5
|
+
import * as i0 from "@angular/core";
|
|
6
|
+
/**
|
|
7
|
+
* Sticky rows at more than one level, on `<virtual-list>` itself: a year pinned at the leading
|
|
8
|
+
* edge, its month under it and the day under that, each pushed off by the next of its own level
|
|
9
|
+
* or of one further out.
|
|
10
|
+
*
|
|
11
|
+
* ```html
|
|
12
|
+
* <virtual-list #list [items]="rows" [itemHeight]="44" [virtualListStickyLevel]="levelOf">
|
|
13
|
+
* @for (row of list.window(); track row.slot) {
|
|
14
|
+
* <view [virtualListRow]="row"><text>{{ row.item.label }}</text></view>
|
|
15
|
+
* }
|
|
16
|
+
* </virtual-list>
|
|
17
|
+
* ```
|
|
18
|
+
*
|
|
19
|
+
* `levelOf` is given each item and its index and returns the row's level: 0 for the outermost,
|
|
20
|
+
* 1 for the rows pinned under those, and so on, or `null` for a row that scrolls with the rest.
|
|
21
|
+
* A row pins under the nearest row before it of each level further out than its own, and stays
|
|
22
|
+
* until the next row of its own level, or of one further out, pushes it off. The rows of
|
|
23
|
+
* `stickyIndices` are at level 0, so the two can be given together.
|
|
24
|
+
*
|
|
25
|
+
* ponytail: rows that size themselves pin level 0 alone, with a warning in development, and
|
|
26
|
+
* deeper rows scroll with the rest: where a row pins under others depends on their heights, which
|
|
27
|
+
* are not known until each has been measured.
|
|
28
|
+
*/
|
|
29
|
+
export class VirtualListStickyLevel {
|
|
30
|
+
/** A row's level, from 0 for the outermost, or `null` for a row that is not sticky. */
|
|
31
|
+
level = input(undefined, { ...(ngDevMode ? { debugName: "level" } : /* istanbul ignore next */ {}), alias: 'virtualListStickyLevel' });
|
|
32
|
+
/**
|
|
33
|
+
* How many levels pin at once, from the outermost. Rows deeper than that are not sticky. It
|
|
34
|
+
* limits the levels the function gives: the rows of `stickyIndices` pin whatever it is.
|
|
35
|
+
*/
|
|
36
|
+
maxLevels = input(Infinity, { ...(ngDevMode ? { debugName: "maxLevels" } : /* istanbul ignore next */ {}), alias: 'virtualListMaxStickyLevels',
|
|
37
|
+
transform: numberOr(Infinity) });
|
|
38
|
+
// Looked up once the list exists: the list injects this directive while it is being made.
|
|
39
|
+
injector = inject(Injector);
|
|
40
|
+
levelOf = computed(() => {
|
|
41
|
+
const level = this.level();
|
|
42
|
+
if (!level)
|
|
43
|
+
return null;
|
|
44
|
+
const levels = this.maxLevels();
|
|
45
|
+
return (item, index) => {
|
|
46
|
+
const at = level(item, index);
|
|
47
|
+
return typeof at === 'number' && at >= 0 && at < levels ? Math.floor(at) : null;
|
|
48
|
+
};
|
|
49
|
+
}, /* @ts-ignore */
|
|
50
|
+
...(ngDevMode ? [{ debugName: "levelOf" }] : /* istanbul ignore next */ []));
|
|
51
|
+
constructor() {
|
|
52
|
+
if (typeof ngDevMode === 'undefined' || !ngDevMode)
|
|
53
|
+
return;
|
|
54
|
+
const unsupported = effect(() => {
|
|
55
|
+
const levelOf = this.levelOf();
|
|
56
|
+
const list = this.injector.get(VirtualList, null, { self: true });
|
|
57
|
+
if (!levelOf || !list?.measuring())
|
|
58
|
+
return;
|
|
59
|
+
if (!list.items().some((item, index) => (levelOf(item, index) ?? 0) > 0))
|
|
60
|
+
return;
|
|
61
|
+
unsupported.destroy();
|
|
62
|
+
console.warn(`[angular-native] virtualListStickyLevel pins level 0 alone on rows without itemHeight: ` +
|
|
63
|
+
`a row pins under others by their heights, which rows that size themselves do not ` +
|
|
64
|
+
`have until they are measured.`);
|
|
65
|
+
}, /* @ts-ignore */
|
|
66
|
+
...(ngDevMode ? [{ debugName: "unsupported" }] : /* istanbul ignore next */ []));
|
|
67
|
+
}
|
|
68
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.2.0", ngImport: i0, type: VirtualListStickyLevel, deps: [], target: i0.ɵɵFactoryTarget.Directive });
|
|
69
|
+
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "22.2.0", type: VirtualListStickyLevel, isStandalone: true, selector: "virtual-list[virtualListStickyLevel]", inputs: { level: { classPropertyName: "level", publicName: "virtualListStickyLevel", isSignal: true, isRequired: false, transformFunction: null }, maxLevels: { classPropertyName: "maxLevels", publicName: "virtualListMaxStickyLevels", isSignal: true, isRequired: false, transformFunction: null } }, providers: [
|
|
70
|
+
{ provide: VIRTUAL_LIST_STICKY, useExisting: forwardRef(() => VirtualListStickyLevel) },
|
|
71
|
+
], ngImport: i0 });
|
|
72
|
+
}
|
|
73
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.2.0", ngImport: i0, type: VirtualListStickyLevel, decorators: [{
|
|
74
|
+
type: Directive,
|
|
75
|
+
args: [{
|
|
76
|
+
selector: 'virtual-list[virtualListStickyLevel]',
|
|
77
|
+
providers: [
|
|
78
|
+
{ provide: VIRTUAL_LIST_STICKY, useExisting: forwardRef(() => VirtualListStickyLevel) },
|
|
79
|
+
],
|
|
80
|
+
}]
|
|
81
|
+
}], ctorParameters: () => [], propDecorators: { level: [{ type: i0.Input, args: [{ isSignal: true, alias: "virtualListStickyLevel", required: false }] }], maxLevels: [{ type: i0.Input, args: [{ isSignal: true, alias: "virtualListMaxStickyLevels", required: false }] }] } });
|
|
82
|
+
//# sourceMappingURL=virtual-list-sticky-level.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"virtual-list-sticky-level.js","sourceRoot":"","sources":["../src/virtual-list-sticky-level.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AACjG,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAC3C,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,mBAAmB,EAA0B,MAAM,0BAA0B,CAAC;;AAEvF;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAOH,MAAM,OAAO,sBAAsB;IACjC,uFAAuF;IAC9E,KAAK,GAAG,KAAK,CAEpB,SAAS,6EAAI,KAAK,EAAE,wBAAwB,GAAG,CAAC;IAClD;;;OAGG;IACM,SAAS,GAAG,KAAK,CAAC,QAAQ,iFACjC,KAAK,EAAE,4BAA4B;QACnC,SAAS,EAAE,QAAQ,CAAC,QAAQ,CAAC,GAC7B,CAAC;IAEH,0FAA0F;IACzE,QAAQ,GAAG,MAAM,CAAC,QAAQ,CAAC,CAAC;IAEpC,OAAO,GAAG,QAAQ,CAAC,GAAG,EAAE;QAC/B,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,EAAE,CAAC;QAC3B,IAAI,CAAC,KAAK;YAAE,OAAO,IAAI,CAAC;QACxB,MAAM,MAAM,GAAG,IAAI,CAAC,SAAS,EAAE,CAAC;QAChC,OAAO,CAAC,IAAa,EAAE,KAAa,EAAE,EAAE;YACtC,MAAM,EAAE,GAAG,KAAK,CAAC,IAAS,EAAE,KAAK,CAAC,CAAC;YACnC,OAAO,OAAO,EAAE,KAAK,QAAQ,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,GAAG,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;QAClF,CAAC,CAAC;IACJ,CAAC;gFAAC,CAAC;IAEH;QACE,IAAI,OAAO,SAAS,KAAK,WAAW,IAAI,CAAC,SAAS;YAAE,OAAO;QAC3D,MAAM,WAAW,GAAG,MAAM,CAAC,GAAG,EAAE;YAC9B,MAAM,OAAO,GAAG,IAAI,CAAC,OAAO,EAAE,CAAC;YAC/B,MAAM,IAAI,GAAG,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,WAAW,EAAE,IAAI,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC;YAClE,IAAI,CAAC,OAAO,IAAI,CAAC,IAAI,EAAE,SAAS,EAAE;gBAAE,OAAO;YAC3C,IAAI,CAAC,IAAI,CAAC,KAAK,EAAE,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,CAAC,CAAC,OAAO,CAAC,IAAI,EAAE,KAAK,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC;gBAAE,OAAO;YACjF,WAAW,CAAC,OAAO,EAAE,CAAC;YACtB,OAAO,CAAC,IAAI,CACV,yFAAyF;gBACvF,mFAAmF;gBACnF,+BAA+B,CAClC,CAAC;QACJ,CAAC;wFAAC,CAAC;IACL,CAAC;uGAzCU,sBAAsB;2FAAtB,sBAAsB,6XAJtB;YACT,EAAE,OAAO,EAAE,mBAAmB,EAAE,WAAW,EAAE,UAAU,CAAC,GAAG,EAAE,CAAC,sBAAsB,CAAC,EAAE;SACxF;;2FAEU,sBAAsB;kBANlC,SAAS;mBAAC;oBACT,QAAQ,EAAE,sCAAsC;oBAChD,SAAS,EAAE;wBACT,EAAE,OAAO,EAAE,mBAAmB,EAAE,WAAW,EAAE,UAAU,CAAC,GAAG,EAAE,uBAAuB,CAAC,EAAE;qBACxF;iBACF","sourcesContent":["import { Directive, Injector, computed, effect, forwardRef, inject, input } from '@angular/core';\nimport { numberOr } from './transforms.ts';\nimport { VirtualList } from './virtual-list.ts';\nimport { VIRTUAL_LIST_STICKY, type VirtualListSticky } from './virtual-list-sticky.ts';\n\n/**\n * Sticky rows at more than one level, on `<virtual-list>` itself: a year pinned at the leading\n * edge, its month under it and the day under that, each pushed off by the next of its own level\n * or of one further out.\n *\n * ```html\n * <virtual-list #list [items]=\"rows\" [itemHeight]=\"44\" [virtualListStickyLevel]=\"levelOf\">\n * @for (row of list.window(); track row.slot) {\n * <view [virtualListRow]=\"row\"><text>{{ row.item.label }}</text></view>\n * }\n * </virtual-list>\n * ```\n *\n * `levelOf` is given each item and its index and returns the row's level: 0 for the outermost,\n * 1 for the rows pinned under those, and so on, or `null` for a row that scrolls with the rest.\n * A row pins under the nearest row before it of each level further out than its own, and stays\n * until the next row of its own level, or of one further out, pushes it off. The rows of\n * `stickyIndices` are at level 0, so the two can be given together.\n *\n * ponytail: rows that size themselves pin level 0 alone, with a warning in development, and\n * deeper rows scroll with the rest: where a row pins under others depends on their heights, which\n * are not known until each has been measured.\n */\n@Directive({\n selector: 'virtual-list[virtualListStickyLevel]',\n providers: [\n { provide: VIRTUAL_LIST_STICKY, useExisting: forwardRef(() => VirtualListStickyLevel) },\n ],\n})\nexport class VirtualListStickyLevel<T = unknown> implements VirtualListSticky {\n /** A row's level, from 0 for the outermost, or `null` for a row that is not sticky. */\n readonly level = input<\n ((item: T, index: number) => number | null | undefined) | null | undefined\n >(undefined, { alias: 'virtualListStickyLevel' });\n /**\n * How many levels pin at once, from the outermost. Rows deeper than that are not sticky. It\n * limits the levels the function gives: the rows of `stickyIndices` pin whatever it is.\n */\n readonly maxLevels = input(Infinity, {\n alias: 'virtualListMaxStickyLevels',\n transform: numberOr(Infinity),\n });\n\n // Looked up once the list exists: the list injects this directive while it is being made.\n private readonly injector = inject(Injector);\n\n readonly levelOf = computed(() => {\n const level = this.level();\n if (!level) return null;\n const levels = this.maxLevels();\n return (item: unknown, index: number) => {\n const at = level(item as T, index);\n return typeof at === 'number' && at >= 0 && at < levels ? Math.floor(at) : null;\n };\n });\n\n constructor() {\n if (typeof ngDevMode === 'undefined' || !ngDevMode) return;\n const unsupported = effect(() => {\n const levelOf = this.levelOf();\n const list = this.injector.get(VirtualList, null, { self: true });\n if (!levelOf || !list?.measuring()) return;\n if (!list.items().some((item, index) => (levelOf(item, index) ?? 0) > 0)) return;\n unsupported.destroy();\n console.warn(\n `[angular-native] virtualListStickyLevel pins level 0 alone on rows without itemHeight: ` +\n `a row pins under others by their heights, which rows that size themselves do not ` +\n `have until they are measured.`,\n );\n });\n }\n}\n\ndeclare const ngDevMode: unknown;\n"]}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Which of `<virtual-list>`'s rows pin at more than one level, when a directive on the list says
|
|
3
|
+
* so.
|
|
4
|
+
*
|
|
5
|
+
* `stickyIndices` pins rows one at a time: each pushes the one before it off. A list grouped more
|
|
6
|
+
* than once, days in months in years, pins a row under the rows of the groups it is in, and how
|
|
7
|
+
* deep each row is comes from the items rather than from a list of indices. A directive on the
|
|
8
|
+
* list's own element provides this, as `[virtualListNumColumns]` provides `VIRTUAL_LIST_LAYOUT`,
|
|
9
|
+
* and the list reads it with `{ self: true, optional: true }`.
|
|
10
|
+
*/
|
|
11
|
+
import { InjectionToken, type Signal } from '@angular/core';
|
|
12
|
+
export interface VirtualListSticky {
|
|
13
|
+
/**
|
|
14
|
+
* What gives a row's level, or null when nothing does. A level is a whole number from 0, the
|
|
15
|
+
* outermost; null is a row that scrolls with the rest.
|
|
16
|
+
*/
|
|
17
|
+
readonly levelOf: Signal<((item: unknown, index: number) => number | null) | null>;
|
|
18
|
+
}
|
|
19
|
+
export declare const VIRTUAL_LIST_STICKY: InjectionToken<VirtualListSticky>;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Which of `<virtual-list>`'s rows pin at more than one level, when a directive on the list says
|
|
3
|
+
* so.
|
|
4
|
+
*
|
|
5
|
+
* `stickyIndices` pins rows one at a time: each pushes the one before it off. A list grouped more
|
|
6
|
+
* than once, days in months in years, pins a row under the rows of the groups it is in, and how
|
|
7
|
+
* deep each row is comes from the items rather than from a list of indices. A directive on the
|
|
8
|
+
* list's own element provides this, as `[virtualListNumColumns]` provides `VIRTUAL_LIST_LAYOUT`,
|
|
9
|
+
* and the list reads it with `{ self: true, optional: true }`.
|
|
10
|
+
*/
|
|
11
|
+
import { InjectionToken } from '@angular/core';
|
|
12
|
+
export const VIRTUAL_LIST_STICKY = new InjectionToken('angular-native.virtualListSticky');
|
|
13
|
+
//# sourceMappingURL=virtual-list-sticky.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"virtual-list-sticky.js","sourceRoot":"","sources":["../src/virtual-list-sticky.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,OAAO,EAAE,cAAc,EAAe,MAAM,eAAe,CAAC;AAU5D,MAAM,CAAC,MAAM,mBAAmB,GAAG,IAAI,cAAc,CACnD,kCAAkC,CACnC,CAAC","sourcesContent":["/**\n * Which of `<virtual-list>`'s rows pin at more than one level, when a directive on the list says\n * so.\n *\n * `stickyIndices` pins rows one at a time: each pushes the one before it off. A list grouped more\n * than once, days in months in years, pins a row under the rows of the groups it is in, and how\n * deep each row is comes from the items rather than from a list of indices. A directive on the\n * list's own element provides this, as `[virtualListNumColumns]` provides `VIRTUAL_LIST_LAYOUT`,\n * and the list reads it with `{ self: true, optional: true }`.\n */\nimport { InjectionToken, type Signal } from '@angular/core';\n\nexport interface VirtualListSticky {\n /**\n * What gives a row's level, or null when nothing does. A level is a whole number from 0, the\n * outermost; null is a row that scrolls with the rest.\n */\n readonly levelOf: Signal<((item: unknown, index: number) => number | null) | null>;\n}\n\nexport const VIRTUAL_LIST_STICKY = new InjectionToken<VirtualListSticky>(\n 'angular-native.virtualListSticky',\n);\n"]}
|
package/dist/virtual-list.d.ts
CHANGED
|
@@ -125,7 +125,8 @@ interface Gap<T> {
|
|
|
125
125
|
* the first sticky row pushes it off as RN's sticky headers push each other. Neither is native:
|
|
126
126
|
* RN's `ScrollView.js` translates a sticky child against the scroll offset in JavaScript, and a
|
|
127
127
|
* row here follows the offset the same way while it is the current one - by its `top` when
|
|
128
|
-
* absolutely positioned, by a transform when in flow.
|
|
128
|
+
* absolutely positioned, by a transform when in flow. `[virtualListStickyLevel]` on the list pins
|
|
129
|
+
* rows at more than one level, each under the rows of the levels further out.
|
|
129
130
|
*
|
|
130
131
|
* What is on screen stays on screen when a measured row above it turns out taller or shorter than
|
|
131
132
|
* its estimate: the offset is corrected by the difference. `maintainVisibleContentPosition` does
|
|
@@ -251,6 +252,7 @@ export declare class VirtualList<T> extends ScrollViewProps {
|
|
|
251
252
|
private readonly reach;
|
|
252
253
|
private fillTimer;
|
|
253
254
|
private readonly canvasView;
|
|
255
|
+
private readonly headerView;
|
|
254
256
|
/** The sticky rows and header: see `StickyRows`. */
|
|
255
257
|
private readonly sticky;
|
|
256
258
|
/** Rows size themselves and are laid out in flow, rather than placed at a known offset. */
|
|
@@ -432,7 +434,7 @@ export declare class VirtualList<T> extends ScrollViewProps {
|
|
|
432
434
|
height: number;
|
|
433
435
|
width?: undefined;
|
|
434
436
|
}>;
|
|
435
|
-
/** The rows from `first` up to `last`, and the pinned
|
|
437
|
+
/** The rows from `first` up to `last`, and the pinned rows above them if there are any. */
|
|
436
438
|
private rowsFor;
|
|
437
439
|
/**
|
|
438
440
|
* A pinned row native moves stays at its own place, so the rows between it and the window are
|
|
@@ -563,6 +565,8 @@ export declare class VirtualList<T> extends ScrollViewProps {
|
|
|
563
565
|
};
|
|
564
566
|
timestamp?: number;
|
|
565
567
|
}>): void;
|
|
568
|
+
/** Take the viewport's leading edge, in the rows' own space, as where the list is. */
|
|
569
|
+
private follow;
|
|
566
570
|
/**
|
|
567
571
|
* Points the window reaches past the viewport for the scroll's speed, positive toward the end,
|
|
568
572
|
* in steps of a quarter viewport: written only when it moves a step, so a fling costs a pass
|
package/dist/virtual-list.js
CHANGED
|
@@ -8,6 +8,7 @@ import { TemplateSlot } from "./template-slot.js";
|
|
|
8
8
|
import { ZeroSizeWarning, checksZeroSize, written } from "./zero-size-warning.js";
|
|
9
9
|
import { View } from "./view.js";
|
|
10
10
|
import { VIRTUAL_LIST_LAYOUT } from "./virtual-list-layout.js";
|
|
11
|
+
import { VIRTUAL_LIST_STICKY } from "./virtual-list-sticky.js";
|
|
11
12
|
import { ScrollViewProps } from "./scroll-view-props.js";
|
|
12
13
|
import { numberOr } from "./transforms.js";
|
|
13
14
|
import * as i0 from "@angular/core";
|
|
@@ -102,7 +103,8 @@ const PAUSE_MS = 200;
|
|
|
102
103
|
* the first sticky row pushes it off as RN's sticky headers push each other. Neither is native:
|
|
103
104
|
* RN's `ScrollView.js` translates a sticky child against the scroll offset in JavaScript, and a
|
|
104
105
|
* row here follows the offset the same way while it is the current one - by its `top` when
|
|
105
|
-
* absolutely positioned, by a transform when in flow.
|
|
106
|
+
* absolutely positioned, by a transform when in flow. `[virtualListStickyLevel]` on the list pins
|
|
107
|
+
* rows at more than one level, each under the rows of the levels further out.
|
|
106
108
|
*
|
|
107
109
|
* What is on screen stays on screen when a measured row above it turns out taller or shorter than
|
|
108
110
|
* its estimate: the offset is corrected by the difference. `maintainVisibleContentPosition` does
|
|
@@ -247,9 +249,12 @@ export class VirtualList extends ScrollViewProps {
|
|
|
247
249
|
...(ngDevMode ? [{ debugName: "reach" }] : /* istanbul ignore next */ []));
|
|
248
250
|
fillTimer;
|
|
249
251
|
canvasView = viewChild.required('rows', { ...(ngDevMode ? { debugName: "canvasView" } : /* istanbul ignore next */ {}), read: ElementRef });
|
|
252
|
+
headerView = viewChild.required('header', { ...(ngDevMode ? { debugName: "headerView" } : /* istanbul ignore next */ {}), read: ElementRef });
|
|
250
253
|
/** The sticky rows and header: see `StickyRows`. */
|
|
251
254
|
sticky = new StickyRows(this.engine, this.node, {
|
|
252
255
|
indices: this.stickyIndices,
|
|
256
|
+
levels: inject(VIRTUAL_LIST_STICKY, { self: true, optional: true }),
|
|
257
|
+
items: this.items,
|
|
253
258
|
header: this.stickyHeader,
|
|
254
259
|
headerHeight: this.headerHeight,
|
|
255
260
|
horizontal: () => this.horizontal(),
|
|
@@ -301,7 +306,7 @@ export class VirtualList extends ScrollViewProps {
|
|
|
301
306
|
if (columns === 1)
|
|
302
307
|
return null;
|
|
303
308
|
const count = this.items().length;
|
|
304
|
-
const sticky = this.sticky.
|
|
309
|
+
const sticky = this.sticky.rows();
|
|
305
310
|
const of = new Int32Array(count);
|
|
306
311
|
const starts = [];
|
|
307
312
|
let column = columns;
|
|
@@ -329,7 +334,7 @@ export class VirtualList extends ScrollViewProps {
|
|
|
329
334
|
/** An item's insets across the axis: its column's, or the whole width's. */
|
|
330
335
|
acrossOf(index) {
|
|
331
336
|
const lines = this.lines();
|
|
332
|
-
if (!lines || this.sticky.
|
|
337
|
+
if (!lines || this.sticky.rows().has(index))
|
|
333
338
|
return this.across();
|
|
334
339
|
return this.columnAcross()[index - lines.starts[lines.of[index]]];
|
|
335
340
|
}
|
|
@@ -800,33 +805,33 @@ export class VirtualList extends ScrollViewProps {
|
|
|
800
805
|
spacer = computed(() => {
|
|
801
806
|
const span = this.span();
|
|
802
807
|
let lead = span ? this.topOf(span.first) : 0;
|
|
803
|
-
const pinned = this.sticky.pinned();
|
|
804
|
-
if (span && pinned !==
|
|
808
|
+
const [pinned] = this.sticky.pinned();
|
|
809
|
+
if (span && pinned !== undefined && pinned < span.first) {
|
|
805
810
|
lead = this.sticky.native ? this.topOf(pinned) : lead - this.heightOf(pinned) - this.rowGap();
|
|
806
811
|
}
|
|
807
812
|
return this.horizontal() ? { width: Math.max(0, lead) } : { height: Math.max(0, lead) };
|
|
808
813
|
}, /* @ts-ignore */
|
|
809
814
|
...(ngDevMode ? [{ debugName: "spacer" }] : /* istanbul ignore next */ []));
|
|
810
|
-
/** The rows from `first` up to `last`, and the pinned
|
|
815
|
+
/** The rows from `first` up to `last`, and the pinned rows above them if there are any. */
|
|
811
816
|
rowsFor(items, first, last) {
|
|
812
817
|
const rows = [];
|
|
813
818
|
const pinned = this.sticky.pinned();
|
|
814
|
-
const
|
|
815
|
-
this.releaseRecycled(first, last,
|
|
816
|
-
//
|
|
819
|
+
const above = pinned.filter((index) => index < first);
|
|
820
|
+
this.releaseRecycled(first, last, above);
|
|
821
|
+
// A pinned row is on screen even when its own place in the list is not, which is the whole
|
|
817
822
|
// point of it, so it is rendered whether or not the window reaches that far.
|
|
818
|
-
|
|
819
|
-
const key = this.keyAt(
|
|
823
|
+
for (const index of above) {
|
|
824
|
+
const key = this.keyAt(index);
|
|
820
825
|
rows.push(this.hold({
|
|
821
|
-
index
|
|
822
|
-
slot: this.recycledSlot(key, items[
|
|
826
|
+
index,
|
|
827
|
+
slot: this.recycledSlot(key, items[index], index),
|
|
823
828
|
key,
|
|
824
|
-
item: items[
|
|
829
|
+
item: items[index],
|
|
825
830
|
style: this.sticky.native
|
|
826
|
-
? this.sticky.style(
|
|
831
|
+
? this.sticky.style(index)
|
|
827
832
|
: this.measuring()
|
|
828
|
-
? this.sticky.flowStyle(this.topOf(first) - this.heightOf(
|
|
829
|
-
: this.
|
|
833
|
+
? this.sticky.flowStyle(index, this.topOf(first) - this.heightOf(index) - this.rowGap())
|
|
834
|
+
: this.sticky.slotStyle(index),
|
|
830
835
|
}));
|
|
831
836
|
}
|
|
832
837
|
for (let index = first; index < last; index++) {
|
|
@@ -836,11 +841,14 @@ export class VirtualList extends ScrollViewProps {
|
|
|
836
841
|
slot: this.recycledSlot(key, items[index], index),
|
|
837
842
|
key,
|
|
838
843
|
item: items[index],
|
|
839
|
-
style: this.styleFor(index, index
|
|
844
|
+
style: this.styleFor(index, pinned.includes(index)),
|
|
840
845
|
}));
|
|
841
846
|
}
|
|
842
|
-
|
|
843
|
-
|
|
847
|
+
// Rows in flow pin one at a time, so the one above the window is the only one.
|
|
848
|
+
const [lead] = above;
|
|
849
|
+
if (lead !== undefined && this.sticky.native && this.measuring()) {
|
|
850
|
+
this.leadWindow(rows, lead, first);
|
|
851
|
+
}
|
|
844
852
|
return rows;
|
|
845
853
|
}
|
|
846
854
|
/**
|
|
@@ -858,12 +866,12 @@ export class VirtualList extends ScrollViewProps {
|
|
|
858
866
|
rows[1] = this.hold({ ...lead, style: { ...lead.style, [margin]: between } });
|
|
859
867
|
}
|
|
860
868
|
styleFor(index, pinned) {
|
|
861
|
-
if (this.sticky.native && this.sticky.
|
|
869
|
+
if (this.sticky.native && this.sticky.rows().has(index))
|
|
862
870
|
return this.sticky.style(index);
|
|
863
871
|
if (this.measuring()) {
|
|
864
|
-
return pinned ? this.sticky.flowStyle(this.topOf(index)) : this.flowStyle();
|
|
872
|
+
return pinned ? this.sticky.flowStyle(index, this.topOf(index)) : this.flowStyle();
|
|
865
873
|
}
|
|
866
|
-
return pinned ? this.slotStyle(index
|
|
874
|
+
return pinned ? this.sticky.slotStyle(index) : this.slotStyle(index);
|
|
867
875
|
}
|
|
868
876
|
/**
|
|
869
877
|
* Hand each rendered sticky row's view to native to move. The rows' views are the canvas's
|
|
@@ -874,7 +882,7 @@ export class VirtualList extends ScrollViewProps {
|
|
|
874
882
|
const views = () => this.canvasView().nativeElement.childList
|
|
875
883
|
.filter((child) => child.nodeKind === 'element')
|
|
876
884
|
.slice(this.measuring() ? 1 : 0);
|
|
877
|
-
this.sticky.drive(() => this.window(), views);
|
|
885
|
+
this.sticky.drive(() => this.window(), views, () => this.headerView().nativeElement);
|
|
878
886
|
}
|
|
879
887
|
/** Which recycling slot each rendered item holds, by key: its type, and the row it last drew. */
|
|
880
888
|
recycled = new Map();
|
|
@@ -900,8 +908,8 @@ export class VirtualList extends ScrollViewProps {
|
|
|
900
908
|
const keep = new Set();
|
|
901
909
|
for (let index = first; index < last; index++)
|
|
902
910
|
keep.add(this.keyAt(index));
|
|
903
|
-
|
|
904
|
-
keep.add(this.keyAt(
|
|
911
|
+
for (const index of pinned)
|
|
912
|
+
keep.add(this.keyAt(index));
|
|
905
913
|
for (const [key, held] of this.recycled) {
|
|
906
914
|
if (keep.has(key))
|
|
907
915
|
continue;
|
|
@@ -930,7 +938,7 @@ export class VirtualList extends ScrollViewProps {
|
|
|
930
938
|
// A sticky row is a type of its own: native keeps the translate it moved one by, and a plain
|
|
931
939
|
// row taking its slot commits no transform to put it back. A row that stops or starts being
|
|
932
940
|
// sticky takes a new slot for the same reason.
|
|
933
|
-
const sticky = this.sticky.
|
|
941
|
+
const sticky = this.sticky.rows().has(index);
|
|
934
942
|
const held = this.recycled.get(key);
|
|
935
943
|
if (held && this.sticky.isType(held.type) === sticky)
|
|
936
944
|
return held.slot;
|
|
@@ -1161,8 +1169,8 @@ export class VirtualList extends ScrollViewProps {
|
|
|
1161
1169
|
this.jumpTo(this.items().length - 1);
|
|
1162
1170
|
this.engine.dispatchCommand(this.node, 'scrollToEnd', [options.animated ?? true]);
|
|
1163
1171
|
}
|
|
1164
|
-
slotStyle(index
|
|
1165
|
-
const start =
|
|
1172
|
+
slotStyle(index) {
|
|
1173
|
+
const start = this.topOf(index);
|
|
1166
1174
|
const size = this.heightOf(index);
|
|
1167
1175
|
const horizontal = this.horizontal();
|
|
1168
1176
|
const key = horizontal ? 'left' : 'top';
|
|
@@ -1173,15 +1181,12 @@ export class VirtualList extends ScrollViewProps {
|
|
|
1173
1181
|
// The flip is part of the comparison because turning the list over changes every row, and a
|
|
1174
1182
|
// cached slot would otherwise keep the orientation it was built with.
|
|
1175
1183
|
const placed = { ...across, [extent]: size, [key]: start, transform: flip };
|
|
1176
|
-
const stale = !style ||
|
|
1184
|
+
const stale = !style || !holds(style, placed);
|
|
1177
1185
|
if (stale) {
|
|
1178
1186
|
style = horizontal
|
|
1179
1187
|
? { position: 'absolute', ...across, left: start, width: size }
|
|
1180
1188
|
: { position: 'absolute', ...across, top: start, height: size };
|
|
1181
|
-
//
|
|
1182
|
-
// the inversion.
|
|
1183
|
-
if (pinnedAt !== undefined)
|
|
1184
|
-
style['zIndex'] = 1;
|
|
1189
|
+
// The transform is the row's half of the inversion.
|
|
1185
1190
|
if (flip)
|
|
1186
1191
|
style['transform'] = flip;
|
|
1187
1192
|
this.slots.set(index, style);
|
|
@@ -1198,14 +1203,18 @@ export class VirtualList extends ScrollViewProps {
|
|
|
1198
1203
|
// Not clamped to the items: an input set in the same task as this event has not reached the
|
|
1199
1204
|
// list yet, and the window clamps when it renders.
|
|
1200
1205
|
this.trackSpeed(content, event.nativeEvent?.timestamp);
|
|
1206
|
+
this.follow(content);
|
|
1207
|
+
this.sticky.scrolled(along);
|
|
1208
|
+
this.checkEnd(along);
|
|
1209
|
+
this.announceViewable(content);
|
|
1210
|
+
}
|
|
1211
|
+
/** Take the viewport's leading edge, in the rows' own space, as where the list is. */
|
|
1212
|
+
follow(content) {
|
|
1201
1213
|
const visible = this.indexAt(content);
|
|
1202
1214
|
if (visible !== this.visible())
|
|
1203
1215
|
this.moveTo(visible);
|
|
1204
1216
|
this.lastOffset = content;
|
|
1205
1217
|
this.anchorAt(visible, content);
|
|
1206
|
-
this.sticky.scrolled(content, along);
|
|
1207
|
-
this.checkEnd(along);
|
|
1208
|
-
this.announceViewable(content);
|
|
1209
1218
|
}
|
|
1210
1219
|
/**
|
|
1211
1220
|
* Points the window reaches past the viewport for the scroll's speed, positive toward the end,
|
|
@@ -1329,8 +1338,15 @@ export class VirtualList extends ScrollViewProps {
|
|
|
1329
1338
|
const height = (this.horizontal() ? layout?.width : layout?.height) ?? 0;
|
|
1330
1339
|
if (height === this.headerHeight())
|
|
1331
1340
|
return;
|
|
1341
|
+
const along = this.headerHeight() + this.lastOffset;
|
|
1332
1342
|
this.headerHeight.set(height);
|
|
1333
|
-
this.holdPastHeader()
|
|
1343
|
+
if (this.holdPastHeader())
|
|
1344
|
+
return;
|
|
1345
|
+
// Native keeps its offset and sends no scroll event, so the rows moved under the viewport by
|
|
1346
|
+
// the difference: the window, the end and what is viewable are taken again from there.
|
|
1347
|
+
this.follow(along - height);
|
|
1348
|
+
this.checkEnd(along);
|
|
1349
|
+
this.announceViewable(along - height);
|
|
1334
1350
|
}
|
|
1335
1351
|
/**
|
|
1336
1352
|
* The header grew or shrank - a typing indicator in a chat's, a banner in a feed's - and every
|
|
@@ -1342,8 +1358,9 @@ export class VirtualList extends ScrollViewProps {
|
|
|
1342
1358
|
holdPastHeader() {
|
|
1343
1359
|
const hold = this.maintainVisibleContentPosition();
|
|
1344
1360
|
if (!hold || this.lastOffset <= (hold.autoscrollToTopThreshold ?? 0))
|
|
1345
|
-
return;
|
|
1361
|
+
return false;
|
|
1346
1362
|
this.scrollToOffset({ offset: this.headerHeight() + this.lastOffset, animated: false });
|
|
1363
|
+
return true;
|
|
1347
1364
|
}
|
|
1348
1365
|
onContentSize(event) {
|
|
1349
1366
|
const size = event.nativeEvent;
|
|
@@ -1396,10 +1413,10 @@ export class VirtualList extends ScrollViewProps {
|
|
|
1396
1413
|
this.endReached.emit({ distanceFromEnd });
|
|
1397
1414
|
}
|
|
1398
1415
|
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.2.0", ngImport: i0, type: VirtualList, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
1399
|
-
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.2.0", type: VirtualList, isStandalone: true, selector: "virtual-list", inputs: { items: { classPropertyName: "items", publicName: "items", isSignal: true, isRequired: true, transformFunction: null }, itemHeight: { classPropertyName: "itemHeight", publicName: "itemHeight", isSignal: true, isRequired: false, transformFunction: null }, estimatedItemHeight: { classPropertyName: "estimatedItemHeight", publicName: "estimatedItemHeight", isSignal: true, isRequired: false, transformFunction: null }, contentPadding: { classPropertyName: "contentPadding", publicName: "contentPadding", isSignal: true, isRequired: false, transformFunction: null }, rowGap: { classPropertyName: "rowGap", publicName: "rowGap", isSignal: true, isRequired: false, transformFunction: null }, keyExtractor: { classPropertyName: "keyExtractor", publicName: "keyExtractor", isSignal: true, isRequired: false, transformFunction: null }, itemType: { classPropertyName: "itemType", publicName: "itemType", isSignal: true, isRequired: false, transformFunction: null }, maintainVisibleContentPosition: { classPropertyName: "maintainVisibleContentPosition", publicName: "maintainVisibleContentPosition", isSignal: true, isRequired: false, transformFunction: null }, overscan: { classPropertyName: "overscan", publicName: "overscan", isSignal: true, isRequired: false, transformFunction: null }, windowSize: { classPropertyName: "windowSize", publicName: "windowSize", isSignal: true, isRequired: false, transformFunction: null }, velocityLead: { classPropertyName: "velocityLead", publicName: "velocityLead", isSignal: true, isRequired: false, transformFunction: null }, endReachedThreshold: { classPropertyName: "endReachedThreshold", publicName: "endReachedThreshold", isSignal: true, isRequired: false, transformFunction: null }, horizontal: { classPropertyName: "horizontal", publicName: "horizontal", isSignal: true, isRequired: false, transformFunction: null }, inverted: { classPropertyName: "inverted", publicName: "inverted", isSignal: true, isRequired: false, transformFunction: null }, stickyIndices: { classPropertyName: "stickyIndices", publicName: "stickyIndices", isSignal: true, isRequired: false, transformFunction: null }, stickyHeader: { classPropertyName: "stickyHeader", publicName: "stickyHeader", isSignal: true, isRequired: false, transformFunction: null }, keyboardShouldPersistTaps: { classPropertyName: "keyboardShouldPersistTaps", publicName: "keyboardShouldPersistTaps", isSignal: true, isRequired: false, transformFunction: null }, itemVisiblePercentThreshold: { classPropertyName: "itemVisiblePercentThreshold", publicName: "itemVisiblePercentThreshold", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { endReached: "endReached", viewableItemsChanged: "viewableItemsChanged" }, host: { listeners: { "scrollBeginDrag": "onDragBegin()", "momentumScrollEnd": "onScrollEnd()", "layout": "onLayout($event)", "contentSizeChange": "onContentSize($event)" }, properties: { "flexDirection": "horizontal() ? 'row' : 'column'", "horizontal": "horizontal()", "nestedScrollEnabled": "nestedScroll()", "transform": "flip()", "scrollEventThrottle": "scrollEventThrottle()" } }, queries: [{ propertyName: "separator", first: true, predicate: VirtualListSeparator, descendants: true, isSignal: true }, { propertyName: "refreshControl", first: true, predicate: RefreshControl, descendants: true, isSignal: true }], viewQueries: [{ propertyName: "canvasView", first: true, predicate: ["rows"], descendants: true, read: ElementRef, isSignal: true }], exportAs: ["virtualList"], usesInheritance: true, ngImport: i0, template: `
|
|
1416
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.2.0", type: VirtualList, isStandalone: true, selector: "virtual-list", inputs: { items: { classPropertyName: "items", publicName: "items", isSignal: true, isRequired: true, transformFunction: null }, itemHeight: { classPropertyName: "itemHeight", publicName: "itemHeight", isSignal: true, isRequired: false, transformFunction: null }, estimatedItemHeight: { classPropertyName: "estimatedItemHeight", publicName: "estimatedItemHeight", isSignal: true, isRequired: false, transformFunction: null }, contentPadding: { classPropertyName: "contentPadding", publicName: "contentPadding", isSignal: true, isRequired: false, transformFunction: null }, rowGap: { classPropertyName: "rowGap", publicName: "rowGap", isSignal: true, isRequired: false, transformFunction: null }, keyExtractor: { classPropertyName: "keyExtractor", publicName: "keyExtractor", isSignal: true, isRequired: false, transformFunction: null }, itemType: { classPropertyName: "itemType", publicName: "itemType", isSignal: true, isRequired: false, transformFunction: null }, maintainVisibleContentPosition: { classPropertyName: "maintainVisibleContentPosition", publicName: "maintainVisibleContentPosition", isSignal: true, isRequired: false, transformFunction: null }, overscan: { classPropertyName: "overscan", publicName: "overscan", isSignal: true, isRequired: false, transformFunction: null }, windowSize: { classPropertyName: "windowSize", publicName: "windowSize", isSignal: true, isRequired: false, transformFunction: null }, velocityLead: { classPropertyName: "velocityLead", publicName: "velocityLead", isSignal: true, isRequired: false, transformFunction: null }, endReachedThreshold: { classPropertyName: "endReachedThreshold", publicName: "endReachedThreshold", isSignal: true, isRequired: false, transformFunction: null }, horizontal: { classPropertyName: "horizontal", publicName: "horizontal", isSignal: true, isRequired: false, transformFunction: null }, inverted: { classPropertyName: "inverted", publicName: "inverted", isSignal: true, isRequired: false, transformFunction: null }, stickyIndices: { classPropertyName: "stickyIndices", publicName: "stickyIndices", isSignal: true, isRequired: false, transformFunction: null }, stickyHeader: { classPropertyName: "stickyHeader", publicName: "stickyHeader", isSignal: true, isRequired: false, transformFunction: null }, keyboardShouldPersistTaps: { classPropertyName: "keyboardShouldPersistTaps", publicName: "keyboardShouldPersistTaps", isSignal: true, isRequired: false, transformFunction: null }, itemVisiblePercentThreshold: { classPropertyName: "itemVisiblePercentThreshold", publicName: "itemVisiblePercentThreshold", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { endReached: "endReached", viewableItemsChanged: "viewableItemsChanged" }, host: { listeners: { "scrollBeginDrag": "onDragBegin()", "momentumScrollEnd": "onScrollEnd()", "layout": "onLayout($event)", "contentSizeChange": "onContentSize($event)" }, properties: { "flexDirection": "horizontal() ? 'row' : 'column'", "horizontal": "horizontal()", "nestedScrollEnabled": "nestedScroll()", "transform": "flip()", "scrollEventThrottle": "scrollEventThrottle()" } }, queries: [{ propertyName: "separator", first: true, predicate: VirtualListSeparator, descendants: true, isSignal: true }, { propertyName: "refreshControl", first: true, predicate: RefreshControl, descendants: true, isSignal: true }], viewQueries: [{ propertyName: "canvasView", first: true, predicate: ["rows"], descendants: true, read: ElementRef, isSignal: true }, { propertyName: "headerView", first: true, predicate: ["header"], descendants: true, read: ElementRef, isSignal: true }], exportAs: ["virtualList"], usesInheritance: true, ngImport: i0, template: `
|
|
1400
1417
|
<ng-content select="refresh-control" />
|
|
1401
1418
|
<view [style]="content()" collapsable="false">
|
|
1402
|
-
<view [style]="headerStyle()" (layout)="onHeaderLayout($event)"
|
|
1419
|
+
<view #header [style]="headerStyle()" (layout)="onHeaderLayout($event)"
|
|
1403
1420
|
><ng-content select="[listHeader]"
|
|
1404
1421
|
/></view>
|
|
1405
1422
|
<view #rows [style]="canvas()" collapsable="false">
|
|
@@ -1437,7 +1454,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.2.0", ngImpor
|
|
|
1437
1454
|
template: `
|
|
1438
1455
|
<ng-content select="refresh-control" />
|
|
1439
1456
|
<view [style]="content()" collapsable="false">
|
|
1440
|
-
<view [style]="headerStyle()" (layout)="onHeaderLayout($event)"
|
|
1457
|
+
<view #header [style]="headerStyle()" (layout)="onHeaderLayout($event)"
|
|
1441
1458
|
><ng-content select="[listHeader]"
|
|
1442
1459
|
/></view>
|
|
1443
1460
|
<view #rows [style]="canvas()" collapsable="false">
|
|
@@ -1476,7 +1493,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.2.0", ngImpor
|
|
|
1476
1493
|
'(contentSizeChange)': 'onContentSize($event)',
|
|
1477
1494
|
},
|
|
1478
1495
|
}]
|
|
1479
|
-
}], ctorParameters: () => [], propDecorators: { items: [{ type: i0.Input, args: [{ isSignal: true, alias: "items", required: true }] }], itemHeight: [{ type: i0.Input, args: [{ isSignal: true, alias: "itemHeight", required: false }] }], estimatedItemHeight: [{ type: i0.Input, args: [{ isSignal: true, alias: "estimatedItemHeight", required: false }] }], contentPadding: [{ type: i0.Input, args: [{ isSignal: true, alias: "contentPadding", required: false }] }], rowGap: [{ type: i0.Input, args: [{ isSignal: true, alias: "rowGap", required: false }] }], keyExtractor: [{ type: i0.Input, args: [{ isSignal: true, alias: "keyExtractor", required: false }] }], itemType: [{ type: i0.Input, args: [{ isSignal: true, alias: "itemType", required: false }] }], maintainVisibleContentPosition: [{ type: i0.Input, args: [{ isSignal: true, alias: "maintainVisibleContentPosition", required: false }] }], overscan: [{ type: i0.Input, args: [{ isSignal: true, alias: "overscan", required: false }] }], windowSize: [{ type: i0.Input, args: [{ isSignal: true, alias: "windowSize", required: false }] }], velocityLead: [{ type: i0.Input, args: [{ isSignal: true, alias: "velocityLead", required: false }] }], endReachedThreshold: [{ type: i0.Input, args: [{ isSignal: true, alias: "endReachedThreshold", required: false }] }], horizontal: [{ type: i0.Input, args: [{ isSignal: true, alias: "horizontal", required: false }] }], inverted: [{ type: i0.Input, args: [{ isSignal: true, alias: "inverted", required: false }] }], stickyIndices: [{ type: i0.Input, args: [{ isSignal: true, alias: "stickyIndices", required: false }] }], stickyHeader: [{ type: i0.Input, args: [{ isSignal: true, alias: "stickyHeader", required: false }] }], keyboardShouldPersistTaps: [{ type: i0.Input, args: [{ isSignal: true, alias: "keyboardShouldPersistTaps", required: false }] }], itemVisiblePercentThreshold: [{ type: i0.Input, args: [{ isSignal: true, alias: "itemVisiblePercentThreshold", required: false }] }], endReached: [{ type: i0.Output, args: ["endReached"] }], viewableItemsChanged: [{ type: i0.Output, args: ["viewableItemsChanged"] }], separator: [{ type: i0.ContentChild, args: [i0.forwardRef(() => VirtualListSeparator), { isSignal: true }] }], refreshControl: [{ type: i0.ContentChild, args: [i0.forwardRef(() => RefreshControl), { isSignal: true }] }], canvasView: [{ type: i0.ViewChild, args: ['rows', { ...{ read: ElementRef }, isSignal: true }] }] } });
|
|
1496
|
+
}], ctorParameters: () => [], propDecorators: { items: [{ type: i0.Input, args: [{ isSignal: true, alias: "items", required: true }] }], itemHeight: [{ type: i0.Input, args: [{ isSignal: true, alias: "itemHeight", required: false }] }], estimatedItemHeight: [{ type: i0.Input, args: [{ isSignal: true, alias: "estimatedItemHeight", required: false }] }], contentPadding: [{ type: i0.Input, args: [{ isSignal: true, alias: "contentPadding", required: false }] }], rowGap: [{ type: i0.Input, args: [{ isSignal: true, alias: "rowGap", required: false }] }], keyExtractor: [{ type: i0.Input, args: [{ isSignal: true, alias: "keyExtractor", required: false }] }], itemType: [{ type: i0.Input, args: [{ isSignal: true, alias: "itemType", required: false }] }], maintainVisibleContentPosition: [{ type: i0.Input, args: [{ isSignal: true, alias: "maintainVisibleContentPosition", required: false }] }], overscan: [{ type: i0.Input, args: [{ isSignal: true, alias: "overscan", required: false }] }], windowSize: [{ type: i0.Input, args: [{ isSignal: true, alias: "windowSize", required: false }] }], velocityLead: [{ type: i0.Input, args: [{ isSignal: true, alias: "velocityLead", required: false }] }], endReachedThreshold: [{ type: i0.Input, args: [{ isSignal: true, alias: "endReachedThreshold", required: false }] }], horizontal: [{ type: i0.Input, args: [{ isSignal: true, alias: "horizontal", required: false }] }], inverted: [{ type: i0.Input, args: [{ isSignal: true, alias: "inverted", required: false }] }], stickyIndices: [{ type: i0.Input, args: [{ isSignal: true, alias: "stickyIndices", required: false }] }], stickyHeader: [{ type: i0.Input, args: [{ isSignal: true, alias: "stickyHeader", required: false }] }], keyboardShouldPersistTaps: [{ type: i0.Input, args: [{ isSignal: true, alias: "keyboardShouldPersistTaps", required: false }] }], itemVisiblePercentThreshold: [{ type: i0.Input, args: [{ isSignal: true, alias: "itemVisiblePercentThreshold", required: false }] }], endReached: [{ type: i0.Output, args: ["endReached"] }], viewableItemsChanged: [{ type: i0.Output, args: ["viewableItemsChanged"] }], separator: [{ type: i0.ContentChild, args: [i0.forwardRef(() => VirtualListSeparator), { isSignal: true }] }], refreshControl: [{ type: i0.ContentChild, args: [i0.forwardRef(() => RefreshControl), { isSignal: true }] }], canvasView: [{ type: i0.ViewChild, args: ['rows', { ...{ read: ElementRef }, isSignal: true }] }], headerView: [{ type: i0.ViewChild, args: ['header', { ...{ read: ElementRef }, isSignal: true }] }] } });
|
|
1480
1497
|
/** Whether a cached slot style already has every one of these props. */
|
|
1481
1498
|
function holds(style, props) {
|
|
1482
1499
|
return Object.entries(props).every(([prop, value]) => style[prop] === value);
|