@ng-native/components 0.26.1 → 0.27.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/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/modal.d.ts +6 -6
- package/dist/modal.js +8 -8
- package/dist/modal.js.map +1 -1
- package/dist/native-button.d.ts +5 -2
- package/dist/native-button.js +7 -4
- package/dist/native-button.js.map +1 -1
- package/dist/safe-area-provider.js +9 -7
- package/dist/safe-area-provider.js.map +1 -1
- package/dist/sidebar-item.d.ts +1 -1
- package/dist/sidebar-item.js +4 -3
- package/dist/sidebar-item.js.map +1 -1
- package/dist/sidebar-section.js +3 -2
- package/dist/sidebar-section.js.map +1 -1
- package/package.json +3 -3
package/dist/drag-and-drop.d.ts
CHANGED
|
@@ -17,7 +17,7 @@ export interface DragItemValue {
|
|
|
17
17
|
readonly url?: string;
|
|
18
18
|
}
|
|
19
19
|
/**
|
|
20
|
-
* Files, text and urls dragged onto a view, on macOS and iPadOS: `(fileDragEnter)` as a drag
|
|
20
|
+
* Files, text and urls dragged onto a view, on macOS, Linux and iPadOS: `(fileDragEnter)` as a drag
|
|
21
21
|
* comes over it, `(fileDragLeave)` as it goes off without dropping, and `(fileDrop)` when it is
|
|
22
22
|
* dropped. Each carries a `FileDropEvent`. On iPhone, Android and the web host nothing fires.
|
|
23
23
|
*
|
|
@@ -36,9 +36,9 @@ export declare class FileDrop {
|
|
|
36
36
|
static ɵdir: i0.ɵɵDirectiveDeclaration<FileDrop, "[fileDrop],[fileDragEnter],[fileDragLeave]", never, {}, { "fileDragEnter": "fileDragEnter"; "fileDragLeave": "fileDragLeave"; "fileDrop": "fileDrop"; }, never, never, true, never>;
|
|
37
37
|
}
|
|
38
38
|
/**
|
|
39
|
-
* A view that can be dragged out, on macOS and iPadOS: to
|
|
40
|
-
* view. `[dragItem]="{ files: [path] }"`, `{ text }` or `{ url }`, or several of
|
|
41
|
-
* none. A mouse drag starts it on macOS and a long press on iPadOS.
|
|
39
|
+
* A view that can be dragged out, on macOS, Linux and iPadOS: to a file manager, another app, or a
|
|
40
|
+
* `(fileDrop)` view. `[dragItem]="{ files: [path] }"`, `{ text }` or `{ url }`, or several of
|
|
41
|
+
* them; null for none. A mouse drag starts it on macOS and Linux, and a long press on iPadOS.
|
|
42
42
|
*
|
|
43
43
|
* The host contract: the view takes a `dragItem` prop of `{ files, text, url }`, with each file
|
|
44
44
|
* as a `file://` url and the others a string or null, or null to take it away. On iOS the item
|
package/dist/drag-and-drop.js
CHANGED
|
@@ -3,15 +3,15 @@ import { DragAndDrop, OS } from '@ng-native/device';
|
|
|
3
3
|
import { HostEngine } from '@ng-native/fabric';
|
|
4
4
|
import { byNativeId } from "./native-id.js";
|
|
5
5
|
import * as i0 from "@angular/core";
|
|
6
|
-
/** Drag and drop exists on macOS and iPadOS; iPhone's host ignores both props. */
|
|
7
|
-
const takesDrags = (os) => os === 'macos' || os === 'ios';
|
|
6
|
+
/** Drag and drop exists on macOS, Linux and iPadOS; iPhone's host ignores both props. */
|
|
7
|
+
const takesDrags = (os) => os === 'macos' || os === 'linux' || os === 'ios';
|
|
8
8
|
/** iOS's host module, which takes both by the view's `nativeID`, where the app has it. */
|
|
9
9
|
function moduleOnIos(os) {
|
|
10
10
|
const module = inject(DragAndDrop);
|
|
11
11
|
return os === 'ios' && module.available() ? module : null;
|
|
12
12
|
}
|
|
13
13
|
/**
|
|
14
|
-
* Files, text and urls dragged onto a view, on macOS and iPadOS: `(fileDragEnter)` as a drag
|
|
14
|
+
* Files, text and urls dragged onto a view, on macOS, Linux and iPadOS: `(fileDragEnter)` as a drag
|
|
15
15
|
* comes over it, `(fileDragLeave)` as it goes off without dropping, and `(fileDrop)` when it is
|
|
16
16
|
* dropped. Each carries a `FileDropEvent`. On iPhone, Android and the web host nothing fires.
|
|
17
17
|
*
|
|
@@ -55,9 +55,9 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.2.0", ngImpor
|
|
|
55
55
|
args: [{ selector: '[fileDrop],[fileDragEnter],[fileDragLeave]' }]
|
|
56
56
|
}], ctorParameters: () => [], propDecorators: { fileDragEnter: [{ type: i0.Output, args: ["fileDragEnter"] }], fileDragLeave: [{ type: i0.Output, args: ["fileDragLeave"] }], fileDrop: [{ type: i0.Output, args: ["fileDrop"] }] } });
|
|
57
57
|
/**
|
|
58
|
-
* A view that can be dragged out, on macOS and iPadOS: to
|
|
59
|
-
* view. `[dragItem]="{ files: [path] }"`, `{ text }` or `{ url }`, or several of
|
|
60
|
-
* none. A mouse drag starts it on macOS and a long press on iPadOS.
|
|
58
|
+
* A view that can be dragged out, on macOS, Linux and iPadOS: to a file manager, another app, or a
|
|
59
|
+
* `(fileDrop)` view. `[dragItem]="{ files: [path] }"`, `{ text }` or `{ url }`, or several of
|
|
60
|
+
* them; null for none. A mouse drag starts it on macOS and Linux, and a long press on iPadOS.
|
|
61
61
|
*
|
|
62
62
|
* The host contract: the view takes a `dragItem` prop of `{ files, text, url }`, with each file
|
|
63
63
|
* as a `file://` url and the others a string or null, or null to take it away. On iOS the item
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"drag-and-drop.js","sourceRoot":"","sources":["../src/drag-and-drop.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,UAAU,EACV,SAAS,EACT,UAAU,EACV,MAAM,EACN,MAAM,EACN,KAAK,EACL,MAAM,EACN,SAAS,GACV,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,WAAW,EAAE,EAAE,EAAuB,MAAM,mBAAmB,CAAC;AACzE,OAAO,EAAE,UAAU,EAAiB,MAAM,mBAAmB,CAAC;AAC9D,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;;AAsB5C,
|
|
1
|
+
{"version":3,"file":"drag-and-drop.js","sourceRoot":"","sources":["../src/drag-and-drop.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,U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AC,GAAG,CAAC,OAAO,CAAC;QACtC,IAAI,EAAE,IAAI,CAAC,IAAI,IAAI,IAAI;QACvB,GAAG,EAAE,IAAI,CAAC,GAAG,IAAI,IAAI;KACtB,CAAC;AACJ,CAAC;AAED,qDAAqD;AACrD,SAAS,OAAO,CAAC,IAAY;IAC3B,IAAI,sBAAsB,CAAC,IAAI,CAAC,IAAI,CAAC;QAAE,OAAO,IAAI,CAAC;IACnD,OAAO,UAAU,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,kBAAkB,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC;AACvE,CAAC;AAED,SAAS,MAAM,CAAC,OAAgB;IAC9B,MAAM,MAAM,GAAG,CAAC,OAAO,IAAI,EAAE,CAA2B,CAAC;IACzD,OAAO,EAAE,KAAK,EAAE,MAAM,CAAC,KAAK,IAAI,EAAE,EAAE,IAAI,EAAE,MAAM,CAAC,IAAI,IAAI,IAAI,EAAE,IAAI,EAAE,MAAM,CAAC,IAAI,IAAI,EAAE,EAAE,CAAC;AAC3F,CAAC","sourcesContent":["import {\n DestroyRef,\n Directive,\n ElementRef,\n effect,\n inject,\n input,\n output,\n untracked,\n} from '@angular/core';\nimport { DragAndDrop, OS, type NativeDragItem } from '@ng-native/device';\nimport { HostEngine, type HostNode } from '@ng-native/fabric';\nimport { byNativeId } from './native-id.ts';\n\n/** A file dragged onto a view: its `file://` url and its name. */\nexport interface DroppedFile {\n readonly uri: string;\n readonly name: string;\n}\n\n/** What is dragged onto a view: files, plain text, and urls that are not files. */\nexport interface FileDropEvent {\n readonly files: readonly DroppedFile[];\n readonly text: string | null;\n readonly urls: readonly string[];\n}\n\n/** What a `[dragItem]` view offers when it is dragged out. Files are paths or `file://` urls. */\nexport interface DragItemValue {\n readonly files?: readonly string[];\n readonly text?: string;\n readonly url?: string;\n}\n\n/** Drag and drop exists on macOS, Linux and iPadOS; iPhone's host ignores both props. */\nconst takesDrags = (os: string): boolean => os === 'macos' || os === 'linux' || os === 'ios';\n\n/** iOS's host module, which takes both by the view's `nativeID`, where the app has it. */\nfunction moduleOnIos(os: string): DragAndDrop | null {\n const module = inject(DragAndDrop);\n return os === 'ios' && module.available() ? module : null;\n}\n\n/**\n * Files, text and urls dragged onto a view, on macOS, Linux and iPadOS: `(fileDragEnter)` as a drag\n * comes over it, `(fileDragLeave)` as it goes off without dropping, and `(fileDrop)` when it is\n * dropped. Each carries a `FileDropEvent`. On iPhone, Android and the web host nothing fires.\n *\n * The host contract: the view takes a `fileDrop` prop of `true`, and sends `topDropEnter`,\n * `topDropLeave` and `topDropPerform` with `{ files, text, urls }`. Those names differ from the\n * outputs', which a binding also listens for, so each output fires once. On iOS, where React\n * Native's view reads no such prop, the view goes to `DragAndDrop` by its `nativeID` instead, and\n * the same events come back from its module (iPadOS; a development build, not Expo Go).\n */\n@Directive({ selector: '[fileDrop],[fileDragEnter],[fileDragLeave]' })\nexport class FileDrop {\n readonly fileDragEnter = output<FileDropEvent>();\n readonly fileDragLeave = output<void>();\n readonly fileDrop = output<FileDropEvent>();\n\n constructor() {\n const os = inject(OS);\n if (!takesDrags(os)) return;\n const node = inject(ElementRef).nativeElement as HostNode;\n const engine = inject(HostEngine);\n engine.setProp(node, 'fileDrop', true);\n const hear = (type: string, native: unknown) => {\n if (type === 'topDropEnter' || type === 'dropEnter') this.fileDragEnter.emit(dropOf(native));\n else if (type === 'topDropLeave' || type === 'dropLeave') this.fileDragLeave.emit();\n else this.fileDrop.emit(dropOf(native));\n };\n const stops = ['topDropEnter', 'topDropLeave', 'topDropPerform'].map((type) =>\n engine.setEventListener(node, type, (event) =>\n hear(type, (event as { nativeEvent?: unknown }).nativeEvent),\n ),\n );\n inject(DestroyRef).onDestroy(() => stops.forEach((stop) => stop()));\n const module = moduleOnIos(os);\n if (module) {\n byNativeId(\n engine,\n node,\n (nativeID) => module.setFileDrop(nativeID, (event) => hear(event.type, event)),\n (nativeID) => module.setFileDrop(nativeID, null),\n )();\n }\n }\n}\n\n/**\n * A view that can be dragged out, on macOS, Linux and iPadOS: to a file manager, another app, or a\n * `(fileDrop)` view. `[dragItem]=\"{ files: [path] }\"`, `{ text }` or `{ url }`, or several of\n * them; null for none. A mouse drag starts it on macOS and Linux, and a long press on iPadOS.\n *\n * The host contract: the view takes a `dragItem` prop of `{ files, text, url }`, with each file\n * as a `file://` url and the others a string or null, or null to take it away. On iOS the item\n * goes to `DragAndDrop` by the view's `nativeID` too.\n */\n@Directive({ selector: '[dragItem]' })\nexport class DragItem {\n readonly dragItem = input<DragItemValue | null>();\n\n constructor() {\n const os = inject(OS);\n if (!takesDrags(os)) return;\n const node = inject(ElementRef).nativeElement as HostNode;\n const engine = inject(HostEngine);\n const module = moduleOnIos(os);\n const offered = () => {\n const item = untracked(this.dragItem);\n return item ? committedItem(item) : null;\n };\n const send =\n module &&\n byNativeId(\n engine,\n node,\n (nativeID) => module.setDragItem(nativeID, offered()),\n (nativeID) => module.setDragItem(nativeID, null),\n );\n effect(() => {\n this.dragItem();\n engine.setProp(node, 'dragItem', offered());\n send?.();\n });\n }\n}\n\nfunction committedItem(item: DragItemValue): NativeDragItem {\n return {\n files: (item.files ?? []).map(fileUrl),\n text: item.text ?? null,\n url: item.url ?? null,\n };\n}\n\n/** A path as a `file://` url, and a url as it is. */\nfunction fileUrl(file: string): string {\n if (/^[a-z][a-z0-9+.-]*:/i.test(file)) return file;\n return `file://${file.split('/').map(encodeURIComponent).join('/')}`;\n}\n\nfunction dropOf(payload: unknown): FileDropEvent {\n const native = (payload ?? {}) as Partial<FileDropEvent>;\n return { files: native.files ?? [], text: native.text ?? null, urls: native.urls ?? [] };\n}\n"]}
|
package/dist/modal.d.ts
CHANGED
|
@@ -55,13 +55,13 @@ export declare class Modal extends ViewBase {
|
|
|
55
55
|
/** Android: give the modal's window a hardware-accelerated surface. */
|
|
56
56
|
readonly hardwareAccelerated: import("@angular/core").InputSignalWithTransform<boolean | undefined, unknown>;
|
|
57
57
|
/**
|
|
58
|
-
* The element the modal points at. With one, it shows as a popover at the element on macOS
|
|
59
|
-
* every other OS, iPadOS included, it shows as it would without one. Committed as the
|
|
60
|
-
* of the element's view.
|
|
58
|
+
* The element the modal points at. With one, it shows as a popover at the element on macOS and
|
|
59
|
+
* Linux; on every other OS, iPadOS included, it shows as it would without one. Committed as the
|
|
60
|
+
* react tag of the element's view.
|
|
61
61
|
*/
|
|
62
62
|
readonly anchor: import("@angular/core").InputSignal<ModalAnchor>;
|
|
63
63
|
private readonly direction;
|
|
64
|
-
/** Only
|
|
64
|
+
/** Only the desktop host reads the anchor, so only there does the modal wait for it. */
|
|
65
65
|
private readonly readsAnchor;
|
|
66
66
|
/** For the anchor view tag, which only the engine itself hands out. */
|
|
67
67
|
private readonly views;
|
|
@@ -69,8 +69,8 @@ export declare class Modal extends ViewBase {
|
|
|
69
69
|
/** The anchor's view tag, committed as `anchor`, or undefined with none. */
|
|
70
70
|
protected readonly anchorTag: import("@angular/core").WritableSignal<number | undefined>;
|
|
71
71
|
/**
|
|
72
|
-
* Whether the anchor's view has still to commit, which gives it its tag. On
|
|
73
|
-
* the host reads the anchor as it presents, and one presented without it stays a sheet.
|
|
72
|
+
* Whether the anchor's view has still to commit, which gives it its tag. On a desktop OS the modal
|
|
73
|
+
* waits: the host reads the anchor as it presents, and one presented without it stays a sheet.
|
|
74
74
|
*/
|
|
75
75
|
protected readonly awaitingAnchor: import("@angular/core").WritableSignal<boolean>;
|
|
76
76
|
protected readonly resolvedPresentationStyle: import("@angular/core").Signal<ModalPresentationStyle | undefined>;
|
package/dist/modal.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Component, DestroyRef, ElementRef, Injector, afterNextRender, booleanAttribute, computed, effect, inject, input, signal, } from '@angular/core';
|
|
2
|
-
import {
|
|
2
|
+
import { DESKTOP, Direction } from '@ng-native/device';
|
|
3
3
|
import { Engine, HostEngine } from '@ng-native/fabric';
|
|
4
4
|
import { optionalBoolean } from "./transforms.js";
|
|
5
5
|
import { View } from "./view.js";
|
|
@@ -66,15 +66,15 @@ export class Modal extends ViewBase {
|
|
|
66
66
|
/** Android: give the modal's window a hardware-accelerated surface. */
|
|
67
67
|
hardwareAccelerated = input(undefined, { ...(ngDevMode ? { debugName: "hardwareAccelerated" } : /* istanbul ignore next */ {}), transform: optionalBoolean });
|
|
68
68
|
/**
|
|
69
|
-
* The element the modal points at. With one, it shows as a popover at the element on macOS
|
|
70
|
-
* every other OS, iPadOS included, it shows as it would without one. Committed as the
|
|
71
|
-
* of the element's view.
|
|
69
|
+
* The element the modal points at. With one, it shows as a popover at the element on macOS and
|
|
70
|
+
* Linux; on every other OS, iPadOS included, it shows as it would without one. Committed as the
|
|
71
|
+
* react tag of the element's view.
|
|
72
72
|
*/
|
|
73
73
|
anchor = input(/* @ts-ignore */
|
|
74
74
|
...(ngDevMode ? [undefined, { debugName: "anchor" }] : /* istanbul ignore next */ []));
|
|
75
75
|
direction = inject(Direction);
|
|
76
|
-
/** Only
|
|
77
|
-
readsAnchor = inject(
|
|
76
|
+
/** Only the desktop host reads the anchor, so only there does the modal wait for it. */
|
|
77
|
+
readsAnchor = inject(DESKTOP);
|
|
78
78
|
/** For the anchor view tag, which only the engine itself hands out. */
|
|
79
79
|
views = inject(Engine, { optional: true });
|
|
80
80
|
injector = inject(Injector);
|
|
@@ -82,8 +82,8 @@ export class Modal extends ViewBase {
|
|
|
82
82
|
anchorTag = signal(undefined, /* @ts-ignore */
|
|
83
83
|
...(ngDevMode ? [{ debugName: "anchorTag" }] : /* istanbul ignore next */ []));
|
|
84
84
|
/**
|
|
85
|
-
* Whether the anchor's view has still to commit, which gives it its tag. On
|
|
86
|
-
* the host reads the anchor as it presents, and one presented without it stays a sheet.
|
|
85
|
+
* Whether the anchor's view has still to commit, which gives it its tag. On a desktop OS the modal
|
|
86
|
+
* waits: the host reads the anchor as it presents, and one presented without it stays a sheet.
|
|
87
87
|
*/
|
|
88
88
|
awaitingAnchor = signal(false, /* @ts-ignore */
|
|
89
89
|
...(ngDevMode ? [{ debugName: "awaitingAnchor" }] : /* istanbul ignore next */ []));
|
package/dist/modal.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"modal.js","sourceRoot":"","sources":["../src/modal.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,SAAS,EACT,UAAU,EACV,UAAU,EACV,QAAQ,EACR,eAAe,EACf,gBAAgB,EAChB,QAAQ,EACR,MAAM,EACN,MAAM,EACN,KAAK,EACL,MAAM,GACP,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,SAAS,EAAE,EAAE,EAAE,MAAM,mBAAmB,CAAC;AAClD,OAAO,EAAE,MAAM,EAAE,UAAU,EAAmB,MAAM,mBAAmB,CAAC;AACxE,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAClD,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;;AAM1C,4CAA4C;AAC5C,SAAS,UAAU,CAAC,MAAmB;IACrC,IAAI,CAAC,MAAM;QAAE,OAAO,IAAI,CAAC;IACzB,IAAI,MAAM,YAAY,UAAU;QAAE,OAAO,MAAM,CAAC,aAA2B,CAAC;IAC5E,IAAI,UAAU,IAAI,MAAM;QAAE,OAAO,MAAoB,CAAC;IACtD,OAAS,MAA6B,CAAC,IAA+B,IAAI,IAAI,CAAC;AACjF,CAAC;AAKD;;;;;;;;;;;;;GAaG;AAkBH,MAAM,OAAO,KAAM,SAAQ,QAAQ;IACjC;;;;;OAKG;IACM,OAAO,GAAG,KAAK,CAAC,IAAI,+EAAI,SAAS,EAAE,gBAAgB,GAAG,CAAC;IAChE,wEAAwE;IAC/D,WAAW,GAAG,KAAK,CAAC,KAAK,mFAAI,SAAS,EAAE,gBAAgB,GAAG,CAAC;IACrE,0EAA0E;IACjE,aAAa,GAAG,KAAK;iGAAU,CAAC;IACzC,4DAA4D;IACnD,aAAa,GAAG,K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cesContent":["import {\n Component,\n DestroyRef,\n ElementRef,\n Injector,\n afterNextRender,\n booleanAttribute,\n computed,\n effect,\n inject,\n input,\n signal,\n} from '@angular/core';\nimport { Direction, OS } from '@ng-native/device';\nimport { Engine, HostEngine, type EngineNode } from '@ng-native/fabric';\nimport { optionalBoolean } from './transforms.ts';\nimport { View } from './view.ts';\nimport { ViewBase } from './view-base.ts';\n\nexport type ModalPresentationStyle = 'fullScreen' | 'pageSheet' | 'formSheet' | 'overFullScreen';\n/** What `anchor` takes: an element, its `ElementRef`, or a component or directive with a `node`. */\nexport type ModalAnchor = ElementRef | EngineNode | { readonly node: unknown } | null | undefined;\n\n/** The engine node an anchor stands for. */\nfunction anchorNode(anchor: ModalAnchor): EngineNode | null {\n if (!anchor) return null;\n if (anchor instanceof ElementRef) return anchor.nativeElement as EngineNode;\n if ('nodeKind' in anchor) return anchor as EngineNode;\n return ((anchor as { node?: unknown }).node as EngineNode | undefined) ?? null;\n}\n\nexport type ModalOrientation =\n 'portrait' | 'portrait-upside-down' | 'landscape' | 'landscape-left' | 'landscape-right';\n\n/**\n * Content presented over everything else. Commits as `ModalHostView`.\n *\n * RN's `Modal.js` gives the native host `{position: 'absolute'}` (the engine's default for it)\n * and puts the children inside a full-bleed view carrying the backdrop colour. Without the\n * container the content has no backdrop and no layout box, so a modal renders as nothing.\n *\n * Events are element events: `(requestClose)` for the Android back button and an iOS swipe,\n * `(show)`, `(dismiss)`, and `(orientationChange)`.\n *\n * The container is pinned to the leading edge with `[side]: 0`, the same as RN's own Modal.js -\n * `left` in a left-to-right layout, `right` in a right-to-left one - so the backdrop starts from\n * the edge content actually begins at rather than always the physical left.\n */\n@Component({\n selector: 'modal',\n imports: [View],\n template: `<view [style]=\"containerStyle()\" collapsable=\"false\"><ng-content /></view>`,\n host: {\n '[visible]': 'visible() && !awaitingAnchor()',\n '[transparent]': 'transparent()',\n '[animationType]': 'animationType()',\n '[presentationStyle]': 'resolvedPresentationStyle()',\n '[supportedOrientations]': 'supportedOrientations()',\n '[allowSwipeDismissal]': 'allowSwipeDismissal()',\n '[statusBarTranslucent]': 'statusBarTranslucent()',\n '[navigationBarTranslucent]': 'navigationBarTranslucent()',\n '[hardwareAccelerated]': 'hardwareAccelerated()',\n '[anchor]': 'anchorTag()',\n },\n})\nexport class Modal extends ViewBase {\n /**\n * Whether the modal is showing. Defaults to true, as in RN. While false the engine leaves the\n * native host out of the commit, as RN's Modal returns null when hidden, because the host\n * covers the screen and takes every touch whether or not it presents; on iOS a modal that was\n * showing stays until native reports its dismissal.\n */\n readonly visible = input(true, { transform: booleanAttribute });\n /** See through to the screen behind; the container gets no backdrop. */\n readonly transparent = input(false, { transform: booleanAttribute });\n /** The container's background when not transparent. Defaults to white. */\n readonly backdropColor = input<string>();\n /** How the modal appears and leaves. Defaults to `none`. */\n readonly animationType = input<'none' | 'slide' | 'fade'>();\n /** iOS: full screen, a sheet, or over the current content. `overFullScreen` if transparent. */\n readonly presentationStyle = input<ModalPresentationStyle>();\n /** iOS: which orientations the modal may rotate to. Defaults to portrait. */\n readonly supportedOrientations = input<readonly ModalOrientation[]>();\n /** iOS: let a downward swipe dismiss the modal, reported through `(requestClose)`. */\n readonly allowSwipeDismissal = input(undefined, { transform: optionalBoolean });\n /**\n * Android: draw under the status bar. Always on under Android edge-to-edge (Expo SDK 57), where\n * React Native ignores `false`.\n */\n readonly statusBarTranslucent = input(undefined, { transform: optionalBoolean });\n /**\n * Android: draw under the navigation bar. Always on under Android edge-to-edge (Expo SDK 57),\n * where React Native ignores `false`. In an app that opts out, it needs `statusBarTranslucent`.\n */\n readonly navigationBarTranslucent = input(undefined, { transform: optionalBoolean });\n /** Android: give the modal's window a hardware-accelerated surface. */\n readonly hardwareAccelerated = input(undefined, { transform: optionalBoolean });\n\n /**\n * The element the modal points at. With one, it shows as a popover at the element on macOS; on\n * every other OS, iPadOS included, it shows as it would without one. Committed as the react tag\n * of the element's view.\n */\n readonly anchor = input<ModalAnchor>();\n\n private readonly direction = inject(Direction);\n /** Only macOS reads the anchor, so only there does the modal wait for it. */\n private readonly readsAnchor = inject(OS) === 'macos';\n /** For the anchor view tag, which only the engine itself hands out. */\n private readonly views = inject(Engine, { optional: true });\n private readonly injector = inject(Injector);\n\n /** The anchor's view tag, committed as `anchor`, or undefined with none. */\n protected readonly anchorTag = signal<number | undefined>(undefined);\n /**\n * Whether the anchor's view has still to commit, which gives it its tag. On macOS the modal waits:\n * the host reads the anchor as it presents, and one presented without it stays a sheet.\n */\n protected readonly awaitingAnchor = signal(false);\n\n protected readonly resolvedPresentationStyle = computed(\n () => this.presentationStyle() ?? (this.transparent() ? 'overFullScreen' : undefined),\n );\n\n protected readonly containerStyle = computed(() => ({\n [this.direction.rtl() ? 'right' : 'left']: 0,\n top: 0,\n flex: 1,\n backgroundColor: this.transparent() ? 'transparent' : (this.backdropColor() ?? 'white'),\n }));\n\n constructor() {\n super();\n // RN's host claims any touch that reaches it, so nothing inside the modal can hand a\n // gesture to the screen underneath.\n const stop = inject(HostEngine).setResponder(this.node, {\n onStartShouldSetResponder: () => true,\n });\n inject(DestroyRef).onDestroy(stop);\n\n effect(() => this.followAnchor(anchorNode(this.anchor())));\n\n effect(() => {\n const style = this.presentationStyle();\n if (this.transparent() && style && style !== 'overFullScreen') {\n console.warn(\n `[angular-native] <modal> is transparent, which needs presentationStyle=\"overFullScreen\" on iOS; '${style}' will not be see-through.`,\n );\n }\n });\n }\n\n /**\n * Commit the anchor's tag. A view not yet committed has none, so it is read again once the\n * commit that makes it has happened.\n */\n private followAnchor(node: EngineNode | null): void {\n if (!node) {\n // The engine commits a prop that goes as null, which takes it off the native view.\n this.anchorTag.set(undefined);\n this.awaitingAnchor.set(false);\n return;\n }\n const tag = this.views?.tagOf(node);\n if (tag != null) {\n this.anchorTag.set(tag);\n this.awaitingAnchor.set(false);\n return;\n }\n // Elsewhere nothing reads the anchor, and a modal hidden to wait for it would be dismissed.\n if (this.readsAnchor) this.awaitingAnchor.set(true);\n afterNextRender(\n () => {\n if (anchorNode(this.anchor()) !== node) return;\n this.anchorTag.set(this.views?.tagOf(node) ?? undefined);\n // Once: an anchor that has still not committed is left out, and the modal shows anyway.\n this.awaitingAnchor.set(false);\n },\n { injector: this.injector },\n );\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"modal.js","sourceRoot":"","sources":["../src/modal.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,SAAS,EACT,UAAU,EACV,UAAU,EACV,QAAQ,EACR,eAAe,EACf,gBAAgB,EAChB,QAAQ,EACR,MAAM,EACN,MAAM,EACN,KAAK,EACL,MAAM,GACP,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AACvD,OAAO,EAAE,MAAM,EAAE,UAAU,EAAmB,MAAM,mBAAmB,CAAC;AACxE,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAClD,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;;AAM1C,4CAA4C;AAC5C,SAAS,UAAU,CAAC,MAAmB;IACrC,IAAI,CAAC,MAAM;QAAE,OAAO,IAAI,CAAC;IACzB,IAAI,MAAM,YAAY,UAAU;QAAE,OAAO,MAAM,CAAC,aAA2B,CAAC;IAC5E,IAAI,UAAU,IAAI,MAAM;QAAE,OAAO,MAAoB,CAAC;IACtD,OAAS,MAA6B,CAAC,IAA+B,IAAI,IAAI,CAAC;AACjF,CAAC;AAKD;;;;;;;;;;;;;GAaG;AAkBH,MAAM,OAAO,KAAM,SAAQ,QAAQ;IACjC;;;;;OAKG;IACM,OAAO,GAAG,KAAK,CAAC,IAAI,+EAAI,SAAS,EAAE,gBAAgB,GAAG,CAAC;IAChE,wEAAwE;IAC/D,WAAW,GAAG,KAAK,CAAC,KAAK,mFAAI,SAAS,EAAE,gBAAgB,GAAG,CAAC;IACrE,0EAA0E;IACjE,aAAa,GAAG,KAAK;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UAAU,EAAE,aAAa;qBAC1B;iBACF","sourcesContent":["import {\n Component,\n DestroyRef,\n ElementRef,\n Injector,\n afterNextRender,\n booleanAttribute,\n computed,\n effect,\n inject,\n input,\n signal,\n} from '@angular/core';\nimport { DESKTOP, Direction } from '@ng-native/device';\nimport { Engine, HostEngine, type EngineNode } from '@ng-native/fabric';\nimport { optionalBoolean } from './transforms.ts';\nimport { View } from './view.ts';\nimport { ViewBase } from './view-base.ts';\n\nexport type ModalPresentationStyle = 'fullScreen' | 'pageSheet' | 'formSheet' | 'overFullScreen';\n/** What `anchor` takes: an element, its `ElementRef`, or a component or directive with a `node`. */\nexport type ModalAnchor = ElementRef | EngineNode | { readonly node: unknown } | null | undefined;\n\n/** The engine node an anchor stands for. */\nfunction anchorNode(anchor: ModalAnchor): EngineNode | null {\n if (!anchor) return null;\n if (anchor instanceof ElementRef) return anchor.nativeElement as EngineNode;\n if ('nodeKind' in anchor) return anchor as EngineNode;\n return ((anchor as { node?: unknown }).node as EngineNode | undefined) ?? null;\n}\n\nexport type ModalOrientation =\n 'portrait' | 'portrait-upside-down' | 'landscape' | 'landscape-left' | 'landscape-right';\n\n/**\n * Content presented over everything else. Commits as `ModalHostView`.\n *\n * RN's `Modal.js` gives the native host `{position: 'absolute'}` (the engine's default for it)\n * and puts the children inside a full-bleed view carrying the backdrop colour. Without the\n * container the content has no backdrop and no layout box, so a modal renders as nothing.\n *\n * Events are element events: `(requestClose)` for the Android back button and an iOS swipe,\n * `(show)`, `(dismiss)`, and `(orientationChange)`.\n *\n * The container is pinned to the leading edge with `[side]: 0`, the same as RN's own Modal.js -\n * `left` in a left-to-right layout, `right` in a right-to-left one - so the backdrop starts from\n * the edge content actually begins at rather than always the physical left.\n */\n@Component({\n selector: 'modal',\n imports: [View],\n template: `<view [style]=\"containerStyle()\" collapsable=\"false\"><ng-content /></view>`,\n host: {\n '[visible]': 'visible() && !awaitingAnchor()',\n '[transparent]': 'transparent()',\n '[animationType]': 'animationType()',\n '[presentationStyle]': 'resolvedPresentationStyle()',\n '[supportedOrientations]': 'supportedOrientations()',\n '[allowSwipeDismissal]': 'allowSwipeDismissal()',\n '[statusBarTranslucent]': 'statusBarTranslucent()',\n '[navigationBarTranslucent]': 'navigationBarTranslucent()',\n '[hardwareAccelerated]': 'hardwareAccelerated()',\n '[anchor]': 'anchorTag()',\n },\n})\nexport class Modal extends ViewBase {\n /**\n * Whether the modal is showing. Defaults to true, as in RN. While false the engine leaves the\n * native host out of the commit, as RN's Modal returns null when hidden, because the host\n * covers the screen and takes every touch whether or not it presents; on iOS a modal that was\n * showing stays until native reports its dismissal.\n */\n readonly visible = input(true, { transform: booleanAttribute });\n /** See through to the screen behind; the container gets no backdrop. */\n readonly transparent = input(false, { transform: booleanAttribute });\n /** The container's background when not transparent. Defaults to white. */\n readonly backdropColor = input<string>();\n /** How the modal appears and leaves. Defaults to `none`. */\n readonly animationType = input<'none' | 'slide' | 'fade'>();\n /** iOS: full screen, a sheet, or over the current content. `overFullScreen` if transparent. */\n readonly presentationStyle = input<ModalPresentationStyle>();\n /** iOS: which orientations the modal may rotate to. Defaults to portrait. */\n readonly supportedOrientations = input<readonly ModalOrientation[]>();\n /** iOS: let a downward swipe dismiss the modal, reported through `(requestClose)`. */\n readonly allowSwipeDismissal = input(undefined, { transform: optionalBoolean });\n /**\n * Android: draw under the status bar. Always on under Android edge-to-edge (Expo SDK 57), where\n * React Native ignores `false`.\n */\n readonly statusBarTranslucent = input(undefined, { transform: optionalBoolean });\n /**\n * Android: draw under the navigation bar. Always on under Android edge-to-edge (Expo SDK 57),\n * where React Native ignores `false`. In an app that opts out, it needs `statusBarTranslucent`.\n */\n readonly navigationBarTranslucent = input(undefined, { transform: optionalBoolean });\n /** Android: give the modal's window a hardware-accelerated surface. */\n readonly hardwareAccelerated = input(undefined, { transform: optionalBoolean });\n\n /**\n * The element the modal points at. With one, it shows as a popover at the element on macOS and\n * Linux; on every other OS, iPadOS included, it shows as it would without one. Committed as the\n * react tag of the element's view.\n */\n readonly anchor = input<ModalAnchor>();\n\n private readonly direction = inject(Direction);\n /** Only the desktop host reads the anchor, so only there does the modal wait for it. */\n private readonly readsAnchor = inject(DESKTOP);\n /** For the anchor view tag, which only the engine itself hands out. */\n private readonly views = inject(Engine, { optional: true });\n private readonly injector = inject(Injector);\n\n /** The anchor's view tag, committed as `anchor`, or undefined with none. */\n protected readonly anchorTag = signal<number | undefined>(undefined);\n /**\n * Whether the anchor's view has still to commit, which gives it its tag. On a desktop OS the modal\n * waits: the host reads the anchor as it presents, and one presented without it stays a sheet.\n */\n protected readonly awaitingAnchor = signal(false);\n\n protected readonly resolvedPresentationStyle = computed(\n () => this.presentationStyle() ?? (this.transparent() ? 'overFullScreen' : undefined),\n );\n\n protected readonly containerStyle = computed(() => ({\n [this.direction.rtl() ? 'right' : 'left']: 0,\n top: 0,\n flex: 1,\n backgroundColor: this.transparent() ? 'transparent' : (this.backdropColor() ?? 'white'),\n }));\n\n constructor() {\n super();\n // RN's host claims any touch that reaches it, so nothing inside the modal can hand a\n // gesture to the screen underneath.\n const stop = inject(HostEngine).setResponder(this.node, {\n onStartShouldSetResponder: () => true,\n });\n inject(DestroyRef).onDestroy(stop);\n\n effect(() => this.followAnchor(anchorNode(this.anchor())));\n\n effect(() => {\n const style = this.presentationStyle();\n if (this.transparent() && style && style !== 'overFullScreen') {\n console.warn(\n `[angular-native] <modal> is transparent, which needs presentationStyle=\"overFullScreen\" on iOS; '${style}' will not be see-through.`,\n );\n }\n });\n }\n\n /**\n * Commit the anchor's tag. A view not yet committed has none, so it is read again once the\n * commit that makes it has happened.\n */\n private followAnchor(node: EngineNode | null): void {\n if (!node) {\n // The engine commits a prop that goes as null, which takes it off the native view.\n this.anchorTag.set(undefined);\n this.awaitingAnchor.set(false);\n return;\n }\n const tag = this.views?.tagOf(node);\n if (tag != null) {\n this.anchorTag.set(tag);\n this.awaitingAnchor.set(false);\n return;\n }\n // Elsewhere nothing reads the anchor, and a modal hidden to wait for it would be dismissed.\n if (this.readsAnchor) this.awaitingAnchor.set(true);\n afterNextRender(\n () => {\n if (anchorNode(this.anchor()) !== node) return;\n this.anchorTag.set(this.views?.tagOf(node) ?? undefined);\n // Once: an anchor that has still not committed is left out, and the modal shows anyway.\n this.awaitingAnchor.set(false);\n },\n { injector: this.injector },\n );\n }\n}\n"]}
|
package/dist/native-button.d.ts
CHANGED
|
@@ -17,7 +17,7 @@ export type ButtonIcon = {
|
|
|
17
17
|
*
|
|
18
18
|
* <native-button kind="default" (press)="save()">Save</native-button>
|
|
19
19
|
*
|
|
20
|
-
* On macOS it is an NSButton and on iOS a UIButton, drawn by the host, which sends
|
|
20
|
+
* On macOS it is an NSButton, on Linux a GtkButton and on iOS a UIButton, drawn by the host, which sends
|
|
21
21
|
* `topButtonPress` when it is clicked, tapped, or pressed by Space, and on macOS by Return (a
|
|
22
22
|
* `default` button) or Escape (a `cancel` one). On Android it is a view pressed through the responder, as a
|
|
23
23
|
* `<pressable>` is, and takes `android_ripple` as one does. The web host draws an HTML `button`.
|
|
@@ -39,7 +39,10 @@ export declare class NativeButton extends ControlBase {
|
|
|
39
39
|
readonly icon: import("@angular/core").InputSignal<ButtonIcon | undefined>;
|
|
40
40
|
protected readonly symbol: import("@angular/core").Signal<string | undefined>;
|
|
41
41
|
protected readonly drawableResource: import("@angular/core").Signal<string | undefined>;
|
|
42
|
-
/**
|
|
42
|
+
/**
|
|
43
|
+
* Where the host draws the button (AppKit, UIKit, GTK), it presses it: the responder would press
|
|
44
|
+
* it twice.
|
|
45
|
+
*/
|
|
43
46
|
private readonly drawnByHost;
|
|
44
47
|
private stopPress;
|
|
45
48
|
protected roleByDefault(): 'button';
|
package/dist/native-button.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Component, computed, forwardRef, input } from '@angular/core';
|
|
2
|
-
import { isApplePlatform, registerViewName } from '@ng-native/fabric';
|
|
2
|
+
import { isApplePlatform, nativePlatform, registerViewName, } from '@ng-native/fabric';
|
|
3
3
|
import { ControlBase, TouchableBase } from "./pressable.js";
|
|
4
4
|
import * as i0 from "@angular/core";
|
|
5
5
|
/**
|
|
@@ -12,7 +12,7 @@ registerViewName('native-button', { ios: 'NgNativeButton', android: 'View', maco
|
|
|
12
12
|
*
|
|
13
13
|
* <native-button kind="default" (press)="save()">Save</native-button>
|
|
14
14
|
*
|
|
15
|
-
* On macOS it is an NSButton and on iOS a UIButton, drawn by the host, which sends
|
|
15
|
+
* On macOS it is an NSButton, on Linux a GtkButton and on iOS a UIButton, drawn by the host, which sends
|
|
16
16
|
* `topButtonPress` when it is clicked, tapped, or pressed by Space, and on macOS by Return (a
|
|
17
17
|
* `default` button) or Escape (a `cancel` one). On Android it is a view pressed through the responder, as a
|
|
18
18
|
* `<pressable>` is, and takes `android_ripple` as one does. The web host draws an HTML `button`.
|
|
@@ -46,8 +46,11 @@ export class NativeButton extends ControlBase {
|
|
|
46
46
|
return this.drawableName() ?? (icon && 'drawable' in icon ? icon.drawable : undefined);
|
|
47
47
|
}, /* @ts-ignore */
|
|
48
48
|
...(ngDevMode ? [{ debugName: "drawableResource" }] : /* istanbul ignore next */ []));
|
|
49
|
-
/**
|
|
50
|
-
|
|
49
|
+
/**
|
|
50
|
+
* Where the host draws the button (AppKit, UIKit, GTK), it presses it: the responder would press
|
|
51
|
+
* it twice.
|
|
52
|
+
*/
|
|
53
|
+
drawnByHost = isApplePlatform() || nativePlatform() === 'linux';
|
|
51
54
|
stopPress = null;
|
|
52
55
|
roleByDefault() {
|
|
53
56
|
return 'button';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"native-button.js","sourceRoot":"","sources":["../src/native-button.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,UAAU,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AACvE,OAAO,
|
|
1
|
+
{"version":3,"file":"native-button.js","sourceRoot":"","sources":["../src/native-button.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,E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BACT,QAAQ,EAAE,eAAe;oBACzB,QAAQ,EAAE,gBAAgB;oBAC1B,SAAS,EAAE,CAAC,EAAE,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,UAAU,CAAC,GAAG,EAAE,aAAa,CAAC,EAAE,CAAC;oBACpF,IAAI,EAAE;wBACJ,QAAQ,EAAE,QAAQ;wBAClB,eAAe,EAAE,eAAe;wBAChC,YAAY,EAAE,UAAU;wBACxB,YAAY,EAAE,oBAAoB;wBAClC,WAAW,EAAE,kBAAkB;qBAChC;iBACF","sourcesContent":["import { Component, computed, forwardRef, input } from '@angular/core';\nimport {\n isApplePlatform,\n nativePlatform,\n registerViewName,\n type HostNode,\n} from '@ng-native/fabric';\nimport type { ControlSize } from '@ng-native/device';\nimport { ControlBase, TouchableBase } from './pressable.ts';\n\n/**\n * What a button does in its window: on macOS, Return presses `default` and Escape presses `cancel`.\n * On iOS they are styles only.\n */\nexport type ButtonKind = 'default' | 'cancel' | 'destructive' | 'plain';\n\n/** A button's picture, as on `<native-tab>`: an SF Symbol on Apple's OSes, a drawable on Android. */\nexport type ButtonIcon = { readonly sfSymbol: string } | { readonly drawable: string };\n\n/**\n * The button on Apple's OSes is the host's: NSButton on macOS and UIButton on iOS. Android has no\n * platform button React Native draws, so there it is a view this component makes pressable.\n */\nregisterViewName(\n 'native-button',\n { ios: 'NgNativeButton', android: 'View', macos: 'NgNativeButton' },\n undefined,\n { textContent: 'title' },\n);\n\n/**\n * A platform button, its label the text inside it:\n *\n * <native-button kind=\"default\" (press)=\"save()\">Save</native-button>\n *\n * On macOS it is an NSButton, on Linux a GtkButton and on iOS a UIButton, drawn by the host, which sends\n * `topButtonPress` when it is clicked, tapped, or pressed by Space, and on macOS by Return (a\n * `default` button) or Escape (a `cancel` one). On Android it is a view pressed through the responder, as a\n * `<pressable>` is, and takes `android_ripple` as one does. The web host draws an HTML `button`.\n * It is a button to assistive technology everywhere, and takes focus.\n */\n@Component({\n selector: 'native-button',\n template: '<ng-content />',\n providers: [{ provide: TouchableBase, useExisting: forwardRef(() => NativeButton) }],\n host: {\n '[kind]': 'kind()',\n '[controlSize]': 'controlSize()',\n '[sfSymbol]': 'symbol()',\n '[drawable]': 'drawableResource()',\n '[enabled]': '!pressDisabled()',\n },\n})\nexport class NativeButton extends ControlBase {\n /**\n * What the button does in its window. In a desktop window `default` takes Return and `cancel`\n * takes Escape; elsewhere the kind is a style alone. Unset, it is a plain push button.\n */\n readonly kind = input<ButtonKind>();\n /** AppKit's control size on macOS, and UIKit's button size on iOS. Ignored elsewhere. */\n readonly controlSize = input<ControlSize>();\n /** An SF Symbol beside the label, on iOS and macOS. */\n readonly sfSymbol = input<string>();\n /** Android: a drawable resource beside the label. */\n readonly drawableName = input<string>(undefined, { alias: 'drawable' });\n /** The picture for each OS at once, as on `<native-tab>`. */\n readonly icon = input<ButtonIcon>();\n\n protected readonly symbol = computed(() => {\n const icon = this.icon();\n return this.sfSymbol() ?? (icon && 'sfSymbol' in icon ? icon.sfSymbol : undefined);\n });\n\n protected readonly drawableResource = computed(() => {\n const icon = this.icon();\n return this.drawableName() ?? (icon && 'drawable' in icon ? icon.drawable : undefined);\n });\n\n /**\n * Where the host draws the button (AppKit, UIKit, GTK), it presses it: the responder would press\n * it twice.\n */\n private readonly drawnByHost = isApplePlatform() || nativePlatform() === 'linux';\n private stopPress: (() => void) | null = null;\n\n protected override roleByDefault(): 'button' {\n return 'button';\n }\n\n protected override accessibleByDefault(): boolean {\n return true;\n }\n\n protected override focusableByDefault(): boolean {\n return true;\n }\n\n protected override disabledForAccessibility(): boolean | undefined {\n return this.disabled();\n }\n\n protected override claims(): boolean {\n return !this.drawnByHost && super.claims();\n }\n\n override ngOnInit(): void {\n super.ngOnInit();\n if (!this.drawnByHost || this.stopPress) return;\n this.stopPress = this.engine.setEventListener(\n this.node as HostNode,\n 'topButtonPress',\n (event) => {\n if (this.pressDisabled()) return;\n this.emitReported(this.press, 'click', event as never, 'click');\n },\n );\n }\n\n override ngOnDestroy(): void {\n super.ngOnDestroy();\n this.stopPress?.();\n }\n}\n"]}
|
|
@@ -29,12 +29,14 @@ import { booleanOr } from "./transforms.js";
|
|
|
29
29
|
import * as i0 from "@angular/core";
|
|
30
30
|
/**
|
|
31
31
|
* The insets, in the form the cascade carries: one custom property per edge, in points, and the
|
|
32
|
-
* extent of a desktop window's title bar controls into the provider's pane (zero in
|
|
33
|
-
* pane beside a sidebar, which they do not reach, and on every OS that has none).
|
|
32
|
+
* extent of a desktop window's title bar controls into the provider's pane from each side (zero in
|
|
33
|
+
* the content pane beside a sidebar, which they do not reach, and on every OS that has none).
|
|
34
34
|
*/
|
|
35
|
-
function insetTokens(
|
|
35
|
+
function insetTokens(area) {
|
|
36
|
+
const insets = area.insets();
|
|
36
37
|
return {
|
|
37
|
-
'--safe-area-inset-titlebar-leading': { length: titlebarLeading },
|
|
38
|
+
'--safe-area-inset-titlebar-leading': { length: area.titlebarLeading() },
|
|
39
|
+
'--safe-area-inset-titlebar-trailing': { length: area.titlebarTrailing() },
|
|
38
40
|
'--safe-area-inset-top': { length: insets.top },
|
|
39
41
|
'--safe-area-inset-right': { length: insets.right },
|
|
40
42
|
'--safe-area-inset-bottom': { length: insets.bottom },
|
|
@@ -58,10 +60,10 @@ export class SafeAreaProvider {
|
|
|
58
60
|
const change = event?.nativeEvent;
|
|
59
61
|
if (!change || !this.reportInsets())
|
|
60
62
|
return;
|
|
61
|
-
area.report(change.insets, change.frame, this, change.titlebarLeading);
|
|
63
|
+
area.report(change.insets, change.frame, this, change.titlebarLeading, change.titlebarTrailing);
|
|
62
64
|
// Also published to the stylesheet, where a padding that clears the home indicator
|
|
63
65
|
// belongs. `env()` on the web; a seeded custom property here.
|
|
64
|
-
engine?.updateTokens(insetTokens(area
|
|
66
|
+
engine?.updateTokens(insetTokens(area));
|
|
65
67
|
});
|
|
66
68
|
inject(DestroyRef).onDestroy(() => {
|
|
67
69
|
stop();
|
|
@@ -70,7 +72,7 @@ export class SafeAreaProvider {
|
|
|
70
72
|
if (app.injector.destroyed)
|
|
71
73
|
return;
|
|
72
74
|
if (area.withdraw(this)) {
|
|
73
|
-
engine?.updateTokens(insetTokens(area
|
|
75
|
+
engine?.updateTokens(insetTokens(area));
|
|
74
76
|
}
|
|
75
77
|
});
|
|
76
78
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"safe-area-provider.js","sourceRoot":"","sources":["../src/safe-area-provider.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,OAAO,EACL,cAAc,EACd,SAAS,EACT,UAAU,EACV,UAAU,EACV,SAAS,EACT,MAAM,EACN,KAAK,GACN,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,QAAQ,EAA2B,MAAM,mBAAmB,CAAC;AACtE,OAAO,EAAE,MAAM,EAAE,SAAS,EAAiB,MAAM,mBAAmB,CAAC;AACrE,OAAO,EAAE,0BAA0B,EAAE,MAAM,gBAAgB,CAAC;AAC5D,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;;AAE5C;;;;GAIG;AACH,SAAS,WAAW,CAAC,
|
|
1
|
+
{"version":3,"file":"safe-area-provider.js","sourceRoot":"","sources":["../src/safe-area-provider.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,OAAO,EACL,cAAc,EACd,SAAS,EACT,UAAU,EACV,UAAU,EACV,SAAS,EACT,MAAM,EACN,KAAK,GACN,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,QAAQ,EAA2B,MAAM,mBAAmB,CAAC;AACtE,OAAO,EAAE,MAAM,EAAE,SAAS,EAAiB,MAAM,mBAAmB,CAAC;AACrE,OAAO,EAAE,0BAA0B,EAAE,MAAM,gBAAgB,CAAC;AAC5D,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;;AAE5C;;;;GAIG;AACH,SAAS,WAAW,CAAC,IAAc;IACjC,MAAM,MAAM,GAAG,IAAI,CAAC,MAAM,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,EACJ,MAAM,CAAC,eAAe,EACtB,MAAM,CAAC,gBAAgB,CACxB,CAAC;YACF,mFAAmF;YACnF,8DAA8D;YAC9D,MAAM,EAAE,YAAY,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC,CAAC;QAC1C,CAAC,CACF,CAAC;QACF,MAAM,CAAC,UAAU,CAAC,CAAC,SAAS,CAAC,GAAG,EAAE;YAChC,IAAI,EAAE,CAAC;YACP,0FAA0F;YAC1F,kDAAkD;YAClD,IAAI,GAAG,CAAC,QAAQ,CAAC,SAAS;gBAAE,OAAO;YACnC,IAAI,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC;gBACxB,MAAM,EAAE,YAAY,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC,CAAC;YAC1C,CAAC;QACH,CAAC,CAAC,CAAC;IACL,CAAC;uGA1CU,gBAAgB;2FAAhB,gBAAgB,uOAFjB,gBAAgB;;2FAEf,gBAAgB;kBAJ5B,SAAS;mBAAC;oBACT,QAAQ,EAAE,oBAAoB;oBAC9B,QAAQ,EAAE,gBAAgB;iBAC3B","sourcesContent":["/**\n * The view that measures the safe area and reports it, for the layouts that need the numbers.\n *\n * ```html\n * <safe-area-provider>\n * <native-stack-outlet />\n * </safe-area-provider>\n * ```\n *\n * One, at the root, wrapping everything. What it measures is its own frame and the insets around\n * it, which is why it has to be the thing filling the window rather than a view somewhere inside\n * it. It fills by default and paints nothing.\n *\n * **A `<safe-area-view>` needs one above it**, which is less obvious than it sounds. The native\n * view walks its superviews for a provider and falls back to reading its own insets - but only\n * once, as it enters the window, before it has been laid out, and nothing notifies it when they\n * change. With no provider it therefore insets by zero and looks like it is working, until a later\n * update to that view happens to re-read them and the content jumps.\n *\n * That is also why a presented screen needs its own: it is outside the stack's view tree, which\n * is the same reason it has no header. Give a modal a provider of its own with\n * `[reportInsets]=\"false\"`, so its geometry stays out of the app-wide `SafeArea` while it is up.\n */\nimport {\n ApplicationRef,\n Component,\n DestroyRef,\n ElementRef,\n Renderer2,\n inject,\n input,\n} from '@angular/core';\nimport { SafeArea, type Frame, type Insets } from '@ng-native/device';\nimport { Engine, claimHost, type HostNode } from '@ng-native/fabric';\nimport { registerSafeAreaComponents } from './safe-area.ts';\nimport { booleanOr } from './transforms.ts';\n\n/**\n * The insets, in the form the cascade carries: one custom property per edge, in points, and the\n * extent of a desktop window's title bar controls into the provider's pane from each side (zero in\n * the content pane beside a sidebar, which they do not reach, and on every OS that has none).\n */\nfunction insetTokens(area: SafeArea): Record<string, { length: number }> {\n const insets = area.insets();\n return {\n '--safe-area-inset-titlebar-leading': { length: area.titlebarLeading() },\n '--safe-area-inset-titlebar-trailing': { length: area.titlebarTrailing() },\n '--safe-area-inset-top': { length: insets.top },\n '--safe-area-inset-right': { length: insets.right },\n '--safe-area-inset-bottom': { length: insets.bottom },\n '--safe-area-inset-left': { length: insets.left },\n };\n}\n\ninterface InsetsChange {\n readonly insets: Insets;\n readonly frame: Frame;\n /** The desktop host's window controls' extent from each side of the pane. Absent elsewhere. */\n readonly titlebarLeading?: number;\n readonly titlebarTrailing?: number;\n}\n\n@Component({\n selector: 'safe-area-provider',\n template: '<ng-content />',\n})\nexport class SafeAreaProvider {\n /**\n * Whether what this measures becomes `SafeArea.insets`. The app has one safe area; a second\n * provider inside a modal is there so native descendants can find one, not to redefine it.\n */\n readonly reportInsets = input(true, { transform: booleanOr(true) });\n\n constructor() {\n registerSafeAreaComponents();\n const host = inject(ElementRef).nativeElement as HostNode;\n claimHost(host);\n\n const area = inject(SafeArea);\n const engine = inject(Engine, { optional: true });\n const app = inject(ApplicationRef);\n const stop = inject(Renderer2).listen(\n host,\n 'insetsChange',\n (event: { nativeEvent?: InsetsChange }) => {\n const change = event?.nativeEvent;\n if (!change || !this.reportInsets()) return;\n area.report(\n change.insets,\n change.frame,\n this,\n change.titlebarLeading,\n change.titlebarTrailing,\n );\n // Also published to the stylesheet, where a padding that clears the home indicator\n // belongs. `env()` on the web; a seeded custom property here.\n engine?.updateTokens(insetTokens(area));\n },\n );\n inject(DestroyRef).onDestroy(() => {\n stop();\n // The whole app going takes `SafeArea` and the stylesheet with it: a restyle and a commit\n // of a tree on its way out would be all this did.\n if (app.injector.destroyed) return;\n if (area.withdraw(this)) {\n engine?.updateTokens(insetTokens(area));\n }\n });\n }\n}\n"]}
|
package/dist/sidebar-item.d.ts
CHANGED
|
@@ -18,7 +18,7 @@ export type SidebarItemIcon = ButtonIcon;
|
|
|
18
18
|
*/
|
|
19
19
|
export declare class SidebarItem extends ControlBase implements SidebarRow {
|
|
20
20
|
private readonly sidebar;
|
|
21
|
-
/** Whether this row is
|
|
21
|
+
/** Whether this row is drawn here rather than by the desktop host. */
|
|
22
22
|
protected readonly drawnHere: boolean;
|
|
23
23
|
/** The row's text, and what it is announced as. */
|
|
24
24
|
readonly label: import("@angular/core").InputSignal<string | undefined>;
|
package/dist/sidebar-item.js
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { Component, DestroyRef, computed, forwardRef, inject, input, model, output, } from '@angular/core';
|
|
2
2
|
import { SIDEBAR_SELECTION } from '@ng-native/device';
|
|
3
|
-
import {
|
|
3
|
+
import { registerViewName } from '@ng-native/fabric';
|
|
4
4
|
import { ControlBase, TouchableBase } from "./pressable.js";
|
|
5
5
|
import { Sidebar } from "./sidebar.js";
|
|
6
|
+
import { hostDraws } from "./split-view.js";
|
|
6
7
|
import { Text } from "./text.js";
|
|
7
8
|
import * as i0 from "@angular/core";
|
|
8
9
|
/**
|
|
@@ -29,8 +30,8 @@ registerViewName('sidebar-item', {
|
|
|
29
30
|
*/
|
|
30
31
|
export class SidebarItem extends ControlBase {
|
|
31
32
|
sidebar = inject(Sidebar, { optional: true });
|
|
32
|
-
/** Whether this row is
|
|
33
|
-
drawnHere =
|
|
33
|
+
/** Whether this row is drawn here rather than by the desktop host. */
|
|
34
|
+
drawnHere = !hostDraws('sidebar-item');
|
|
34
35
|
/** The row's text, and what it is announced as. */
|
|
35
36
|
label = input(/* @ts-ignore */
|
|
36
37
|
...(ngDevMode ? [undefined, { debugName: "label" }] : /* istanbul ignore next */ []));
|
package/dist/sidebar-item.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sidebar-item.js","sourceRoot":"","sources":["../src/sidebar-item.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,SAAS,EACT,UAAU,EACV,QAAQ,EACR,UAAU,EACV,MAAM,EACN,KAAK,EACL,KAAK,EACL,MAAM,GACP,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AACtD,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"sidebar-item.js","sourceRoot":"","sources":["../src/sidebar-item.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,SAAS,EACT,UAAU,EACV,QAAQ,EACR,UAAU,EACV,MAAM,EACN,KAAK,EACL,KAAK,EACL,MAAM,GACP,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AACtD,OAAO,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAErD,OAAO,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAC5D,OAAO,EAAE,OAAO,EAAmB,MAAM,cAAc,CAAC;AACxD,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;;AAEjC;;;;GAIG;AACH,gBAAgB,CAAC,cAAc,EAAE;IAC/B,GAAG,EAAE,MAAM;IACX,OAAO,EAAE,MAAM;IACf,KAAK,EAAE,qBAAqB;CAC7B,CAAC,CAAC;AAKH;;;;;;;;;;;GAWG;AA8CH,MAAM,OAAO,WAAY,SAAQ,WAAW;IACzB,OAAO,GAAG,MAAM,CAAC,OAAO,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAC;IAC/D,sEAAsE;IACnD,SAAS,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,CAAC,IAAI,EAAE,CAAC;IACrB,CAAC;IAED,QAAQ;QACN,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;IAC3B,CAAC;uGAjFU,WAAW;2FAAX,WAAW,ytCAjBX;YACT,EAAE,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,UAAU,CAAC,GAAG,EAAE,CAAC,WAAW,CAAC,EAAE;YACtE;gBACE,OAAO,EAAE,iBAAiB;gBAC1B,UAAU,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,UAAU,CAAC,GAAG,EAAE,CAAC,WAAW,CAAC,CAAC,CAAC,QAAQ;aACjE;SACF,iDA/BS;;;;;;;;;GAST,kaAVS,IAAI;;2FA2CH,WAAW;kBA7CvB,SAAS;+BACE,cAAc,WACf,CAAC,IAAI,CAAC,YACL;;;;;;;;;GAST,aAgBU;wBACT,EAAE,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,UAAU,CAAC,GAAG,EAAE,YAAY,CAAC,EAAE;wBACtE;4BACE,OAAO,EAAE,iBAAiB;4BAC1B,UAAU,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,UAAU,CAAC,GAAG,EAAE,YAAY,CAAC,CAAC,CAAC,QAAQ;yBACjE;qBACF,QACK;wBACJ,SAAS,EAAE,iCAAiC;wBAC5C,SAAS,EAAE,iCAAiC;wBAC5C,YAAY,EAAE,kCAAkC;wBAChD,YAAY,EAAE,4CAA4C;wBAC1D,YAAY,EAAE,oCAAoC;wBAClD,sBAAsB,EAAE,wBAAwB;wBAChD,4BAA4B,EAAE,WAAW;qBAC1C","sourcesContent":["import {\n Component,\n DestroyRef,\n computed,\n forwardRef,\n inject,\n input,\n model,\n output,\n} from '@angular/core';\nimport { SIDEBAR_SELECTION } from '@ng-native/device';\nimport { registerViewName } from '@ng-native/fabric';\nimport type { ButtonIcon } from './native-button.ts';\nimport { ControlBase, TouchableBase } from './pressable.ts';\nimport { Sidebar, type SidebarRow } from './sidebar.ts';\nimport { hostDraws } from './split-view.ts';\nimport { Text } from './text.ts';\n\n/**\n * On macOS a row of the sidebar's source list, a model object the desktop host builds an\n * NSTableCellView from. An item with children is a custom row: the host puts its views in a cell\n * of its own. Elsewhere a pressable view, drawnHere here.\n */\nregisterViewName('sidebar-item', {\n ios: 'View',\n android: 'View',\n macos: 'NgNativeSidebarItem',\n});\n\n/** A sidebar item's picture, as on `<native-tab>` and `<native-button>`. */\nexport type SidebarItemIcon = ButtonIcon;\n\n/**\n * A row of the sidebar:\n *\n * <sidebar-item label=\"Inbox\" sfSymbol=\"tray\" [badge]=\"unread()\" [(selected)]=\"inbox\" />\n *\n * With `path`, from `@ng-native/router`, the route selects it, as a `<native-tab>`'s does, and\n * choosing it navigates there. Without, `[(selected)]` holds the selection. Either way choosing it\n * fires `(select)` and deselects the sidebar's other items.\n *\n * Content inside the element replaces the default row of icon, label and badge: its pressables\n * take clicks, and while the row is selected its host has `data-selected` for CSS to restyle it.\n */\n@Component({\n selector: 'sidebar-item',\n imports: [Text],\n template: `\n <ng-content>\n @if (drawnHere) {\n <text class=\"sidebar-item-label\">{{ label() }}</text>\n @if (badge()) {\n <text class=\"sidebar-item-badge\">{{ badge() }}</text>\n }\n }\n </ng-content>\n `,\n styles: `\n /* A row drawn here. On macOS the host's cell is the row, and custom content fills it. */\n :host(.sidebar-item-drawn) {\n flex-direction: row;\n align-items: center;\n gap: 8px;\n padding: 6px 12px;\n }\n .sidebar-item-label {\n flex: 1;\n }\n .sidebar-item-badge {\n opacity: 0.6;\n }\n `,\n providers: [\n { provide: TouchableBase, useExisting: forwardRef(() => SidebarItem) },\n {\n provide: SIDEBAR_SELECTION,\n useFactory: () => inject(forwardRef(() => SidebarItem)).selected,\n },\n ],\n host: {\n '[label]': 'drawnHere ? undefined : label()',\n '[badge]': 'drawnHere ? undefined : badge()',\n '[sfSymbol]': 'drawnHere ? undefined : symbol()',\n '[drawable]': 'drawnHere ? undefined : drawableResource()',\n '[selected]': 'drawnHere ? undefined : selected()',\n '[attr.data-selected]': \"selected() ? '' : null\",\n '[class.sidebar-item-drawn]': 'drawnHere',\n },\n})\nexport class SidebarItem extends ControlBase implements SidebarRow {\n private readonly sidebar = inject(Sidebar, { optional: true });\n /** Whether this row is drawn here rather than by the desktop host. */\n protected readonly drawnHere = !hostDraws('sidebar-item');\n\n /** The row's text, and what it is announced as. */\n readonly label = input<string>();\n /** A count or a short word at the trailing edge. */\n readonly badge = input<string | undefined, string | number | null | undefined>(undefined, {\n transform: (value) => (value == null ? undefined : String(value)),\n });\n /** An SF Symbol before the label, on macOS and iOS. */\n readonly sfSymbol = input<string>();\n /** Android: a drawable resource before the label. */\n readonly drawableName = input<string>(undefined, { alias: 'drawable' });\n /** The picture for each OS at once, as on `<native-tab>`. */\n readonly icon = input<SidebarItemIcon>();\n /** Whether this is the sidebar's selected item. A `path` from the router sets it by route. */\n readonly selected = model(false);\n /** The user chose this item. */\n readonly select = output<void>();\n\n protected readonly symbol = computed(() => {\n const icon = this.icon();\n return this.sfSymbol() ?? (icon && 'sfSymbol' in icon ? icon.sfSymbol : undefined);\n });\n\n protected readonly drawableResource = computed(() => {\n const icon = this.icon();\n return this.drawableName() ?? (icon && 'drawable' in icon ? icon.drawable : undefined);\n });\n\n private stopSelect: (() => void) | null = null;\n\n constructor() {\n super();\n const remove = this.sidebar?.addRow(this);\n if (remove) inject(DestroyRef).onDestroy(remove);\n this.press.subscribe(() => this.choose());\n }\n\n protected override roleByDefault(): 'button' {\n return 'button';\n }\n\n protected override accessibleByDefault(): boolean {\n return true;\n }\n\n protected override focusableByDefault(): boolean {\n return true;\n }\n\n /** On macOS the source list takes the click and selects the row: the responder never does. */\n protected override claims(): boolean {\n return this.drawnHere && super.claims();\n }\n\n override ngOnInit(): void {\n super.ngOnInit();\n if (this.drawnHere || this.stopSelect) return;\n this.stopSelect = this.engine.setEventListener(this.node, 'topSidebarSelect', (event) => {\n if ((event as { target?: unknown }).target === this.node) this.choose();\n });\n }\n\n override ngOnDestroy(): void {\n super.ngOnDestroy();\n this.stopSelect?.();\n }\n\n /** The user chose this row: select it, deselect the rest, and say so. */\n choose(): void {\n if (this.pressDisabled()) return;\n this.selected.set(true);\n this.sidebar?.chose(this);\n this.select.emit();\n }\n\n deselect(): void {\n this.selected.set(false);\n }\n}\n"]}
|
package/dist/sidebar-section.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { Component, computed, input, signal } from '@angular/core';
|
|
2
|
-
import {
|
|
2
|
+
import { registerViewName } from '@ng-native/fabric';
|
|
3
3
|
import { Pressable } from "./pressable.js";
|
|
4
|
+
import { hostDraws } from "./split-view.js";
|
|
4
5
|
import { optionalBoolean } from "./transforms.js";
|
|
5
6
|
import { Text } from "./text.js";
|
|
6
7
|
import { ViewBase } from "./view-base.js";
|
|
@@ -21,7 +22,7 @@ registerViewName('sidebar-section', {
|
|
|
21
22
|
*/
|
|
22
23
|
export class SidebarSection extends ViewBase {
|
|
23
24
|
/** Whether this section is drawn here rather than by the desktop host. */
|
|
24
|
-
drawn =
|
|
25
|
+
drawn = !hostDraws('sidebar-section');
|
|
25
26
|
/** Drawn, whether the items show: a collapsible section's title toggles it. */
|
|
26
27
|
expanded = signal(true, /* @ts-ignore */
|
|
27
28
|
...(ngDevMode ? [{ debugName: "expanded" }] : /* istanbul ignore next */ []));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sidebar-section.js","sourceRoot":"","sources":["../src/sidebar-section.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AACnE,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"sidebar-section.js","sourceRoot":"","sources":["../src/sidebar-section.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AACnE,OAAO,EAAE,gBAAgB,EAAE,MAAM,mB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computed, input, signal } from '@angular/core';\nimport { registerViewName } from '@ng-native/fabric';\nimport { Pressable } from './pressable.ts';\nimport { hostDraws } from './split-view.ts';\nimport { optionalBoolean } from './transforms.ts';\nimport { Text } from './text.ts';\nimport { ViewBase } from './view-base.ts';\n\n/**\n * On macOS a group of the sidebar's source list, a model object the desktop host reads its rows\n * from. Neighbouring sections in one parent are one NSOutlineView. Elsewhere a view, drawn here.\n */\nregisterViewName('sidebar-section', {\n ios: 'View',\n android: 'View',\n macos: 'NgNativeSidebarSection',\n});\n\n/**\n * A group of `<sidebar-item>`s with an optional `title`. A `collapsible` one shows and hides its\n * items from its title: on macOS with the source list's own disclosure, drawn by a press on the\n * title elsewhere. Selection survives the section collapsing.\n */\n@Component({\n selector: 'sidebar-section',\n imports: [Pressable, Text],\n template: `\n @if (drawn && title()) {\n <pressable\n class=\"sidebar-section-title\"\n accessibilityRole=\"header\"\n [disabled]=\"!collapsible()\"\n (press)=\"expanded.set(!expanded())\"\n >\n <text>{{ title() }}</text>\n </pressable>\n }\n @if (shown()) {\n <ng-content />\n }\n `,\n styles: `\n .sidebar-section-title {\n padding: 8px 12px 4px;\n opacity: 0.6;\n }\n `,\n host: {\n '[title]': 'drawn ? undefined : title()',\n '[collapsible]': 'drawn ? undefined : collapsible()',\n },\n})\nexport class SidebarSection extends ViewBase {\n /** Whether this section is drawn here rather than by the desktop host. */\n protected readonly drawn = !hostDraws('sidebar-section');\n /** Drawn, whether the items show: a collapsible section's title toggles it. */\n protected readonly expanded = signal(true);\n\n /** The heading over the section's items. None gives an untitled group. */\n readonly title = input<string>();\n /** Whether the title shows and hides the section's items. */\n readonly collapsible = input(false, { transform: optionalBoolean });\n\n /** Whether the items show: always, unless a title that can show them again hid them. */\n protected readonly shown = computed(\n () => !this.drawn || this.expanded() || !(this.collapsible() && this.title()),\n );\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ng-native/components",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.27.0",
|
|
4
4
|
"description": "Angular Native's core components: view, text, image, pressable, scroll-view, virtual-list, text-input and the rest of React Native's set.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"angular",
|
|
@@ -61,8 +61,8 @@
|
|
|
61
61
|
"access": "public"
|
|
62
62
|
},
|
|
63
63
|
"dependencies": {
|
|
64
|
-
"@ng-native/device": "0.
|
|
65
|
-
"@ng-native/fabric": "0.
|
|
64
|
+
"@ng-native/device": "0.27.0",
|
|
65
|
+
"@ng-native/fabric": "0.27.0"
|
|
66
66
|
},
|
|
67
67
|
"peerDependencies": {
|
|
68
68
|
"@angular/core": "^22.0.0",
|