@ng-native/components 0.22.2 → 0.23.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/build.gradle +22 -0
- package/android/src/main/java/dev/ngnative/components/ContextMenuAccessibility.kt +71 -0
- package/android/src/main/java/dev/ngnative/components/ContextMenuGesture.kt +161 -0
- package/android/src/main/java/dev/ngnative/components/ContextMenuPopup.kt +197 -0
- package/android/src/main/java/dev/ngnative/components/MenuHost.kt +45 -0
- package/android/src/main/java/dev/ngnative/components/MenuWindowCallback.kt +76 -0
- package/android/src/main/java/dev/ngnative/components/MenusModule.kt +85 -0
- package/android/src/main/java/dev/ngnative/components/Shortcut.kt +144 -0
- package/android/src/main/java/dev/ngnative/components/WindowWrapper.kt +22 -0
- package/dist/activity-indicator.d.ts +4 -1
- package/dist/activity-indicator.js +6 -2
- package/dist/activity-indicator.js.map +1 -1
- package/dist/context-menu.d.ts +52 -0
- package/dist/context-menu.js +101 -0
- package/dist/context-menu.js.map +1 -0
- package/dist/drag-and-drop.d.ts +52 -0
- package/dist/drag-and-drop.js +112 -0
- package/dist/drag-and-drop.js.map +1 -0
- package/dist/gesture-backend.d.ts +32 -2
- package/dist/gesture-backend.js.map +1 -1
- package/dist/gesture-dispatch.d.ts +8 -1
- package/dist/gesture-dispatch.js +60 -16
- package/dist/gesture-dispatch.js.map +1 -1
- package/dist/gesture-interaction.d.ts +13 -0
- package/dist/gesture-interaction.js +97 -0
- package/dist/gesture-interaction.js.map +1 -0
- package/dist/gesture-tracking.d.ts +18 -0
- package/dist/gesture-tracking.js +28 -0
- package/dist/gesture-tracking.js.map +1 -0
- package/dist/gestures-web.d.ts +3 -1
- package/dist/gestures-web.js +5 -2
- package/dist/gestures-web.js.map +1 -1
- package/dist/gestures.d.ts +1 -0
- package/dist/gestures.js +45 -3
- package/dist/gestures.js.map +1 -1
- package/dist/image.d.ts +1 -1
- package/dist/index.d.ts +12 -1
- package/dist/index.js +12 -1
- package/dist/index.js.map +1 -1
- package/dist/interaction-observer.d.ts +11 -0
- package/dist/interaction-observer.js +12 -0
- package/dist/interaction-observer.js.map +1 -0
- package/dist/keyboard-avoiding-view.js +3 -3
- package/dist/keyboard-avoiding-view.js.map +1 -1
- package/dist/markdown-stream.d.ts +3 -1
- package/dist/markdown-stream.js +14 -2
- package/dist/markdown-stream.js.map +1 -1
- package/dist/markdown.d.ts +2 -0
- package/dist/markdown.js +5 -3
- package/dist/markdown.js.map +1 -1
- package/dist/menu.d.ts +71 -0
- package/dist/menu.js +193 -0
- package/dist/menu.js.map +1 -0
- package/dist/modal.d.ts +30 -1
- package/dist/modal.js +67 -6
- package/dist/modal.js.map +1 -1
- package/dist/native-button.d.ts +54 -0
- package/dist/native-button.js +100 -0
- package/dist/native-button.js.map +1 -0
- package/dist/native-gesture.d.ts +9 -1
- package/dist/native-gesture.js +32 -3
- package/dist/native-gesture.js.map +1 -1
- package/dist/native-id.d.ts +10 -0
- package/dist/native-id.js +70 -0
- package/dist/native-id.js.map +1 -0
- package/dist/pressable.d.ts +31 -0
- package/dist/pressable.js +102 -9
- package/dist/pressable.js.map +1 -1
- package/dist/safe-area-provider.js +15 -8
- package/dist/safe-area-provider.js.map +1 -1
- package/dist/scroll-view-props.d.ts +7 -1
- package/dist/scroll-view-props.js +54 -3
- package/dist/scroll-view-props.js.map +1 -1
- package/dist/section-list.js +2 -2
- package/dist/section-list.js.map +1 -1
- package/dist/shortcut.d.ts +21 -0
- package/dist/shortcut.js +34 -0
- package/dist/shortcut.js.map +1 -0
- package/dist/sidebar-item.d.ts +53 -0
- package/dist/sidebar-item.js +152 -0
- package/dist/sidebar-item.js.map +1 -0
- package/dist/sidebar-section.d.ts +21 -0
- package/dist/sidebar-section.js +74 -0
- package/dist/sidebar-section.js.map +1 -0
- package/dist/sidebar.d.ts +47 -0
- package/dist/sidebar.js +110 -0
- package/dist/sidebar.js.map +1 -0
- package/dist/split-view.d.ts +63 -0
- package/dist/split-view.js +121 -0
- package/dist/split-view.js.map +1 -0
- package/dist/switch.d.ts +9 -1
- package/dist/switch.js +23 -2
- package/dist/switch.js.map +1 -1
- package/dist/text-input.d.ts +8 -3
- package/dist/text-input.js +10 -4
- package/dist/text-input.js.map +1 -1
- package/dist/transforms.d.ts +5 -0
- package/dist/transforms.js +7 -0
- package/dist/transforms.js.map +1 -1
- package/dist/tray-icon.d.ts +18 -0
- package/dist/tray-icon.js +46 -0
- package/dist/tray-icon.js.map +1 -0
- package/dist/view-base.d.ts +42 -1
- package/dist/view-base.js +67 -39
- package/dist/view-base.js.map +1 -1
- package/dist/virtual-list.js +12 -1
- package/dist/virtual-list.js.map +1 -1
- package/dist/written-props.js +25 -0
- package/dist/written-props.js.map +1 -1
- package/expo-module.config.json +6 -0
- package/ios/NgNativeButtonComponentView.mm +132 -0
- package/ios/NgNativeButtonMetrics.h +28 -0
- package/ios/NgNativeButtonMetrics.mm +68 -0
- package/ios/NgNativeButtonShadowNode.h +65 -0
- package/ios/NgNativeButtonShadowNode.mm +40 -0
- package/ios/NgNativeComponents.podspec +28 -0
- package/ios/NgNativeDragAndDrop.mm +342 -0
- package/ios/NgNativeDropItems.h +29 -0
- package/ios/NgNativeDropItems.mm +55 -0
- package/ios/NgNativeMenuBuilding.h +40 -0
- package/ios/NgNativeMenuBuilding.mm +217 -0
- package/ios/NgNativeMenus.mm +320 -0
- package/ios/NgNativeResponderHooks.h +53 -0
- package/ios/NgNativeResponderHooks.mm +215 -0
- package/ios/NgNativeSceneKeys.h +36 -0
- package/ios/NgNativeSceneKeys.mm +56 -0
- package/ios/NgNativeSplitView.mm +433 -0
- package/ios/NgNativeSplitViewDelegate.h +29 -0
- package/ios/NgNativeSplitViewDelegate.mm +122 -0
- package/ios/NgNativeSplitViewShadowNodes.h +115 -0
- package/ios/NgNativeSplitViewShadowNodes.mm +31 -0
- package/ios/NgNativeUndo.mm +107 -0
- package/ios/NgNativeUndoSteps.h +17 -0
- package/ios/NgNativeUndoSteps.mm +22 -0
- package/ios/NgNativeViewBinder.h +54 -0
- package/ios/NgNativeViewBinder.mm +225 -0
- package/ios/NgNativeWindows.mm +1126 -0
- package/package.json +13 -5
|
@@ -0,0 +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,cAAc,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAErE,OAAO,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAC5D,OAAO,EAAE,OAAO,EAAmB,MAAM,cAAc,CAAC;AACxD,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,0EAA0E;IACvD,SAAS,GAAG,cAAc,EAAE,KAAK,OAAO,CAAC;IAE5D,mDAAmD;IAC1C,KAAK,GAAG,KAAK;yFAAU,CAAC;IACjC,oDAAoD;IAC3C,KAAK,GAAG,KAAK,CAAyD,SAAS,6EACtF,SAAS,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,KAAK,IAAI,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,GACjE,CAAC;IACH,uDAAuD;I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AAC,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 { nativePlatform, 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 { 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 drawnHere here rather than by the desktop host. */\n protected readonly drawnHere = nativePlatform() !== 'macos';\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"]}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { ViewBase } from './view-base.ts';
|
|
2
|
+
import * as i0 from "@angular/core";
|
|
3
|
+
/**
|
|
4
|
+
* A group of `<sidebar-item>`s with an optional `title`. A `collapsible` one shows and hides its
|
|
5
|
+
* items from its title: on macOS with the source list's own disclosure, drawn by a press on the
|
|
6
|
+
* title elsewhere. Selection survives the section collapsing.
|
|
7
|
+
*/
|
|
8
|
+
export declare class SidebarSection extends ViewBase {
|
|
9
|
+
/** Whether this section is drawn here rather than by the desktop host. */
|
|
10
|
+
protected readonly drawn: boolean;
|
|
11
|
+
/** Drawn, whether the items show: a collapsible section's title toggles it. */
|
|
12
|
+
protected readonly expanded: import("@angular/core").WritableSignal<boolean>;
|
|
13
|
+
/** The heading over the section's items. None gives an untitled group. */
|
|
14
|
+
readonly title: import("@angular/core").InputSignal<string | undefined>;
|
|
15
|
+
/** Whether the title shows and hides the section's items. */
|
|
16
|
+
readonly collapsible: import("@angular/core").InputSignalWithTransform<boolean | undefined, unknown>;
|
|
17
|
+
/** Whether the items show: always, unless a title that can show them again hid them. */
|
|
18
|
+
protected readonly shown: import("@angular/core").Signal<boolean>;
|
|
19
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<SidebarSection, never>;
|
|
20
|
+
static ɵcmp: i0.ɵɵComponentDeclaration<SidebarSection, "sidebar-section", never, { "title": { "alias": "title"; "required": false; "isSignal": true; }; "collapsible": { "alias": "collapsible"; "required": false; "isSignal": true; }; }, {}, never, ["*"], true, never>;
|
|
21
|
+
}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { Component, computed, input, signal } from '@angular/core';
|
|
2
|
+
import { nativePlatform, registerViewName } from '@ng-native/fabric';
|
|
3
|
+
import { Pressable } from "./pressable.js";
|
|
4
|
+
import { optionalBoolean } from "./transforms.js";
|
|
5
|
+
import { Text } from "./text.js";
|
|
6
|
+
import { ViewBase } from "./view-base.js";
|
|
7
|
+
import * as i0 from "@angular/core";
|
|
8
|
+
/**
|
|
9
|
+
* On macOS a group of the sidebar's source list, a model object the desktop host reads its rows
|
|
10
|
+
* from. Neighbouring sections in one parent are one NSOutlineView. Elsewhere a view, drawn here.
|
|
11
|
+
*/
|
|
12
|
+
registerViewName('sidebar-section', {
|
|
13
|
+
ios: 'View',
|
|
14
|
+
android: 'View',
|
|
15
|
+
macos: 'NgNativeSidebarSection',
|
|
16
|
+
});
|
|
17
|
+
/**
|
|
18
|
+
* A group of `<sidebar-item>`s with an optional `title`. A `collapsible` one shows and hides its
|
|
19
|
+
* items from its title: on macOS with the source list's own disclosure, drawn by a press on the
|
|
20
|
+
* title elsewhere. Selection survives the section collapsing.
|
|
21
|
+
*/
|
|
22
|
+
export class SidebarSection extends ViewBase {
|
|
23
|
+
/** Whether this section is drawn here rather than by the desktop host. */
|
|
24
|
+
drawn = nativePlatform() !== 'macos';
|
|
25
|
+
/** Drawn, whether the items show: a collapsible section's title toggles it. */
|
|
26
|
+
expanded = signal(true, /* @ts-ignore */
|
|
27
|
+
...(ngDevMode ? [{ debugName: "expanded" }] : /* istanbul ignore next */ []));
|
|
28
|
+
/** The heading over the section's items. None gives an untitled group. */
|
|
29
|
+
title = input(/* @ts-ignore */
|
|
30
|
+
...(ngDevMode ? [undefined, { debugName: "title" }] : /* istanbul ignore next */ []));
|
|
31
|
+
/** Whether the title shows and hides the section's items. */
|
|
32
|
+
collapsible = input(false, { ...(ngDevMode ? { debugName: "collapsible" } : /* istanbul ignore next */ {}), transform: optionalBoolean });
|
|
33
|
+
/** Whether the items show: always, unless a title that can show them again hid them. */
|
|
34
|
+
shown = computed(() => !this.drawn || this.expanded() || !(this.collapsible() && this.title()), /* @ts-ignore */
|
|
35
|
+
...(ngDevMode ? [{ debugName: "shown" }] : /* istanbul ignore next */ []));
|
|
36
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.2.0", ngImport: i0, type: SidebarSection, deps: null, target: i0.ɵɵFactoryTarget.Component });
|
|
37
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.2.0", type: SidebarSection, isStandalone: true, selector: "sidebar-section", inputs: { title: { classPropertyName: "title", publicName: "title", isSignal: true, isRequired: false, transformFunction: null }, collapsible: { classPropertyName: "collapsible", publicName: "collapsible", isSignal: true, isRequired: false, transformFunction: null } }, host: { properties: { "title": "drawn ? undefined : title()", "collapsible": "drawn ? undefined : collapsible()" } }, usesInheritance: true, ngImport: i0, template: `
|
|
38
|
+
@if (drawn && title()) {
|
|
39
|
+
<pressable
|
|
40
|
+
class="sidebar-section-title"
|
|
41
|
+
accessibilityRole="header"
|
|
42
|
+
[disabled]="!collapsible()"
|
|
43
|
+
(press)="expanded.set(!expanded())"
|
|
44
|
+
>
|
|
45
|
+
<text>{{ title() }}</text>
|
|
46
|
+
</pressable>
|
|
47
|
+
}
|
|
48
|
+
@if (shown()) {
|
|
49
|
+
<ng-content />
|
|
50
|
+
}
|
|
51
|
+
`, isInline: true, styles: ["\n .sidebar-section-title {\n padding: 8px 12px 4px;\n opacity: 0.6;\n }\n "], dependencies: [{ kind: "directive", type: Pressable, selector: "pressable", exportAs: ["pressable"] }, { kind: "directive", type: Text, selector: "text", inputs: ["numberOfLines", "ellipsizeMode", "selectable", "selectionColor", "allowFontScaling", "maxFontSizeMultiplier", "dynamicTypeRamp", "adjustsFontSizeToFit", "minimumFontScale", "lineBreakStrategyIOS", "textBreakStrategy", "dataDetectorType", "android_hyphenationFrequency", "pressable", "suppressHighlighting"], exportAs: ["text"] }] });
|
|
52
|
+
}
|
|
53
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.2.0", ngImport: i0, type: SidebarSection, decorators: [{
|
|
54
|
+
type: Component,
|
|
55
|
+
args: [{ selector: 'sidebar-section', imports: [Pressable, Text], template: `
|
|
56
|
+
@if (drawn && title()) {
|
|
57
|
+
<pressable
|
|
58
|
+
class="sidebar-section-title"
|
|
59
|
+
accessibilityRole="header"
|
|
60
|
+
[disabled]="!collapsible()"
|
|
61
|
+
(press)="expanded.set(!expanded())"
|
|
62
|
+
>
|
|
63
|
+
<text>{{ title() }}</text>
|
|
64
|
+
</pressable>
|
|
65
|
+
}
|
|
66
|
+
@if (shown()) {
|
|
67
|
+
<ng-content />
|
|
68
|
+
}
|
|
69
|
+
`, host: {
|
|
70
|
+
'[title]': 'drawn ? undefined : title()',
|
|
71
|
+
'[collapsible]': 'drawn ? undefined : collapsible()',
|
|
72
|
+
}, styles: ["\n .sidebar-section-title {\n padding: 8px 12px 4px;\n opacity: 0.6;\n }\n "] }]
|
|
73
|
+
}], propDecorators: { title: [{ type: i0.Input, args: [{ isSignal: true, alias: "title", required: false }] }], collapsible: [{ type: i0.Input, args: [{ isSignal: true, alias: "collapsible", required: false }] }] } });
|
|
74
|
+
//# sourceMappingURL=sidebar-section.js.map
|
|
@@ -0,0 +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,cAAc,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AACrE,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAC3C,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAClD,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;;AAE1C;;;GAGG;AACH,gBAAgB,CAAC,iBAAiB,EAAE;IAClC,GAAG,EAAE,MAAM;IACX,OAAO,EAAE,MAAM;IACf,KAAK,EAAE,wBAAwB;CAChC,CAAC,CAAC;AAEH;;;;GAIG;AA8BH,MAAM,OAAO,cAAe,SAAQ,QAAQ;IAC1C,0EAA0E;IACvD,KAAK,GAAG,cAAc,EAAE,KAAK,OAAO,CAAC;IACxD,+EAA+E;IAC5D,QAAQ,GAAG,MAAM,CAAC,IAAI;iFAAC,CAAC;IAE3C,0EAA0E;IACjE,KAAK,GAAG,KAAK;yFAAU,CAAC;IACjC,6DAA6D;IACpD,WAAW,GAAG,KAAK,CAAC,KAAK,mFAAI,SAAS,EAAE,eAAe,GAAG,CAAC;IAEpE,wFAAwF;IACrE,KAAK,GAAG,QAAQ,CACjC,GAAG,EAAE,CAAC,CAAC,IAAI,CAAC,KAAK,IAAI,IAAI,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAC,IAAI,CAAC,WAAW,EAAE,IAAI,IAAI,CAAC,KAAK,EAAE,CAAC;8EAC9E,CAAC;uGAdS,cAAc;2FAAd,cAAc,seA1Bf;;;;;;;;;;;;;;GAcT,sKAfS,SAAS,+EAAE,IAAI;;2FA2Bd,cAAc;kBA7B1B,SAAS;+BACE,iBAAiB,WAClB,CAAC,SAAS,EAAE,IAAI,CAAC,YAChB;;;;;;;;;;;;;;GAcT,QAOK;wBACJ,SAAS,EAAE,6BAA6B;wBACxC,eAAe,EAAE,mCAAmC;qBACrD","sourcesContent":["import { Component, computed, input, signal } from '@angular/core';\nimport { nativePlatform, registerViewName } from '@ng-native/fabric';\nimport { Pressable } from './pressable.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 = nativePlatform() !== 'macos';\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"]}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { type OnDestroy, type OnInit } from '@angular/core';
|
|
2
|
+
import { SplitView } from './split-view.ts';
|
|
3
|
+
import { ViewBase } from './view-base.ts';
|
|
4
|
+
import * as i0 from "@angular/core";
|
|
5
|
+
/** A selectable row of the sidebar, as the sidebar sees it. */
|
|
6
|
+
export interface SidebarRow {
|
|
7
|
+
/** Deselect, because another row of the same sidebar was chosen. */
|
|
8
|
+
deselect(): void;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* The sidebar of a `<split-view>`. Its `<sidebar-section>`s and `<sidebar-item>`s are a source
|
|
12
|
+
* list on macOS, an NSOutlineView; anything else in it (a search field, a footer) is drawn and
|
|
13
|
+
* styled by CSS on every OS.
|
|
14
|
+
*
|
|
15
|
+
* `[(collapsed)]` follows the title bar's sidebar button, View > Show Sidebar and a drag that shuts
|
|
16
|
+
* it, on macOS, and the sidebar button and swipe of a UISplitViewController on an iPad. `minWidth`
|
|
17
|
+
* and `maxWidth` bound a drag of the divider on macOS and the sidebar column's width on an iPad,
|
|
18
|
+
* and `autosave` names where macOS keeps the width and collapsed state across launches. Drawn, a collapsed sidebar is hidden,
|
|
19
|
+
* the widths bound its style, and `autosave` is ignored.
|
|
20
|
+
*/
|
|
21
|
+
export declare class Sidebar extends ViewBase implements OnInit, OnDestroy {
|
|
22
|
+
protected readonly split: SplitView | null;
|
|
23
|
+
/** Whether the host draws this sidebar: on macOS, and on an iPad. */
|
|
24
|
+
protected readonly native: boolean;
|
|
25
|
+
/** Whether the sidebar is shut. Kept in step with the user's own toggles on macOS. */
|
|
26
|
+
readonly collapsed: import("@angular/core").ModelSignal<boolean>;
|
|
27
|
+
/** The narrowest a drag of the divider leaves it, in points. */
|
|
28
|
+
readonly minWidth: import("@angular/core").InputSignalWithTransform<number | undefined, unknown>;
|
|
29
|
+
/** The widest a drag of the divider leaves it, in points. */
|
|
30
|
+
readonly maxWidth: import("@angular/core").InputSignalWithTransform<number | undefined, unknown>;
|
|
31
|
+
/** macOS: the name the width and collapsed state are kept under across launches. */
|
|
32
|
+
readonly autosave: import("@angular/core").InputSignal<string | undefined>;
|
|
33
|
+
private readonly rows;
|
|
34
|
+
private stopCollapsed;
|
|
35
|
+
/** Drawn, hidden while collapsed beside the content, or while a stack shows the content. */
|
|
36
|
+
protected readonly hidden: import("@angular/core").Signal<boolean>;
|
|
37
|
+
/** Drawn beside the content, a column of a set width that the app's style can override. */
|
|
38
|
+
protected readonly drawnWidth: import("@angular/core").Signal<240 | undefined>;
|
|
39
|
+
ngOnInit(): void;
|
|
40
|
+
ngOnDestroy(): void;
|
|
41
|
+
/** Called by a row of this sidebar as it is created; answers the call that takes it away. */
|
|
42
|
+
addRow(row: SidebarRow): () => void;
|
|
43
|
+
/** A row was chosen: the sidebar selects one row at a time, so every other one is deselected. */
|
|
44
|
+
chose(row: SidebarRow): void;
|
|
45
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<Sidebar, never>;
|
|
46
|
+
static ɵcmp: i0.ɵɵComponentDeclaration<Sidebar, "sidebar", never, { "collapsed": { "alias": "collapsed"; "required": false; "isSignal": true; }; "minWidth": { "alias": "minWidth"; "required": false; "isSignal": true; }; "maxWidth": { "alias": "maxWidth"; "required": false; "isSignal": true; }; "autosave": { "alias": "autosave"; "required": false; "isSignal": true; }; }, { "collapsed": "collapsedChange"; }, never, ["*"], true, never>;
|
|
47
|
+
}
|
package/dist/sidebar.js
ADDED
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
import { Component, computed, inject, input, model, } from '@angular/core';
|
|
2
|
+
import { nativeSplitViews } from '@ng-native/device';
|
|
3
|
+
import { registerViewName } from '@ng-native/fabric';
|
|
4
|
+
import { optionalNumber } from "./transforms.js";
|
|
5
|
+
import { SplitView, hostDraws } from "./split-view.js";
|
|
6
|
+
import { ViewBase } from "./view-base.js";
|
|
7
|
+
import * as i0 from "@angular/core";
|
|
8
|
+
/**
|
|
9
|
+
* On macOS the sidebar pane of the desktop host's split view, and on an iPad the sidebar column of
|
|
10
|
+
* a UISplitViewController: the host owns its width, and Yoga gets the pane's frame back from it.
|
|
11
|
+
* Elsewhere a view, drawn here.
|
|
12
|
+
*/
|
|
13
|
+
registerViewName('sidebar', {
|
|
14
|
+
get ios() {
|
|
15
|
+
return nativeSplitViews() ? 'NgNativeSidebar' : 'View';
|
|
16
|
+
},
|
|
17
|
+
android: 'View',
|
|
18
|
+
macos: 'NgNativeSidebar',
|
|
19
|
+
});
|
|
20
|
+
/** The width a drawn sidebar starts at, in points, where nothing styles one. */
|
|
21
|
+
const DRAWN_WIDTH = 240;
|
|
22
|
+
/**
|
|
23
|
+
* The sidebar of a `<split-view>`. Its `<sidebar-section>`s and `<sidebar-item>`s are a source
|
|
24
|
+
* list on macOS, an NSOutlineView; anything else in it (a search field, a footer) is drawn and
|
|
25
|
+
* styled by CSS on every OS.
|
|
26
|
+
*
|
|
27
|
+
* `[(collapsed)]` follows the title bar's sidebar button, View > Show Sidebar and a drag that shuts
|
|
28
|
+
* it, on macOS, and the sidebar button and swipe of a UISplitViewController on an iPad. `minWidth`
|
|
29
|
+
* and `maxWidth` bound a drag of the divider on macOS and the sidebar column's width on an iPad,
|
|
30
|
+
* and `autosave` names where macOS keeps the width and collapsed state across launches. Drawn, a collapsed sidebar is hidden,
|
|
31
|
+
* the widths bound its style, and `autosave` is ignored.
|
|
32
|
+
*/
|
|
33
|
+
export class Sidebar extends ViewBase {
|
|
34
|
+
split = inject(SplitView, { optional: true });
|
|
35
|
+
/** Whether the host draws this sidebar: on macOS, and on an iPad. */
|
|
36
|
+
native = hostDraws('sidebar');
|
|
37
|
+
/** Whether the sidebar is shut. Kept in step with the user's own toggles on macOS. */
|
|
38
|
+
collapsed = model(false, /* @ts-ignore */
|
|
39
|
+
...(ngDevMode ? [{ debugName: "collapsed" }] : /* istanbul ignore next */ []));
|
|
40
|
+
/** The narrowest a drag of the divider leaves it, in points. */
|
|
41
|
+
minWidth = input(undefined, { ...(ngDevMode ? { debugName: "minWidth" } : /* istanbul ignore next */ {}), transform: optionalNumber });
|
|
42
|
+
/** The widest a drag of the divider leaves it, in points. */
|
|
43
|
+
maxWidth = input(undefined, { ...(ngDevMode ? { debugName: "maxWidth" } : /* istanbul ignore next */ {}), transform: optionalNumber });
|
|
44
|
+
/** macOS: the name the width and collapsed state are kept under across launches. */
|
|
45
|
+
autosave = input(/* @ts-ignore */
|
|
46
|
+
...(ngDevMode ? [undefined, { debugName: "autosave" }] : /* istanbul ignore next */ []));
|
|
47
|
+
rows = new Set();
|
|
48
|
+
stopCollapsed = null;
|
|
49
|
+
/** Drawn, hidden while collapsed beside the content, or while a stack shows the content. */
|
|
50
|
+
hidden = computed(() => {
|
|
51
|
+
if (this.native)
|
|
52
|
+
return false;
|
|
53
|
+
if (this.split?.stacked())
|
|
54
|
+
return this.split.showing() === 'content';
|
|
55
|
+
return this.collapsed();
|
|
56
|
+
}, /* @ts-ignore */
|
|
57
|
+
...(ngDevMode ? [{ debugName: "hidden" }] : /* istanbul ignore next */ []));
|
|
58
|
+
/** Drawn beside the content, a column of a set width that the app's style can override. */
|
|
59
|
+
drawnWidth = computed(() => this.native || this.split?.stacked() ? undefined : DRAWN_WIDTH, /* @ts-ignore */
|
|
60
|
+
...(ngDevMode ? [{ debugName: "drawnWidth" }] : /* istanbul ignore next */ []));
|
|
61
|
+
ngOnInit() {
|
|
62
|
+
super.ngOnInit();
|
|
63
|
+
if (!this.native || this.stopCollapsed)
|
|
64
|
+
return;
|
|
65
|
+
this.stopCollapsed = this.engine.setEventListener(this.node, 'topSidebarCollapse', (event) => {
|
|
66
|
+
const { target, nativeEvent } = event;
|
|
67
|
+
// A sidebar inside this one's content reports its own.
|
|
68
|
+
if (target !== this.node)
|
|
69
|
+
return;
|
|
70
|
+
if (typeof nativeEvent?.collapsed === 'boolean')
|
|
71
|
+
this.collapsed.set(nativeEvent.collapsed);
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
ngOnDestroy() {
|
|
75
|
+
this.stopCollapsed?.();
|
|
76
|
+
}
|
|
77
|
+
/** Called by a row of this sidebar as it is created; answers the call that takes it away. */
|
|
78
|
+
addRow(row) {
|
|
79
|
+
this.rows.add(row);
|
|
80
|
+
return () => this.rows.delete(row);
|
|
81
|
+
}
|
|
82
|
+
/** A row was chosen: the sidebar selects one row at a time, so every other one is deselected. */
|
|
83
|
+
chose(row) {
|
|
84
|
+
for (const other of this.rows)
|
|
85
|
+
if (other !== row)
|
|
86
|
+
other.deselect();
|
|
87
|
+
this.split?.showContent();
|
|
88
|
+
}
|
|
89
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.2.0", ngImport: i0, type: Sidebar, deps: null, target: i0.ɵɵFactoryTarget.Component });
|
|
90
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.1.0", version: "22.2.0", type: Sidebar, isStandalone: true, selector: "sidebar", inputs: { collapsed: { classPropertyName: "collapsed", publicName: "collapsed", isSignal: true, isRequired: false, transformFunction: null }, minWidth: { classPropertyName: "minWidth", publicName: "minWidth", isSignal: true, isRequired: false, transformFunction: null }, maxWidth: { classPropertyName: "maxWidth", publicName: "maxWidth", isSignal: true, isRequired: false, transformFunction: null }, autosave: { classPropertyName: "autosave", publicName: "autosave", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { collapsed: "collapsedChange" }, host: { properties: { "collapsed": "native ? collapsed() : undefined", "paneMinWidth": "native ? minWidth() : undefined", "paneMaxWidth": "native ? maxWidth() : undefined", "autosaveName": "native ? autosave() : undefined", "style.display": "hidden() ? 'none' : undefined", "style.width": "drawnWidth()", "style.minWidth": "native ? undefined : minWidth()", "style.maxWidth": "native ? undefined : maxWidth()", "style.flex": "split?.stacked() ? 1 : undefined" } }, usesInheritance: true, ngImport: i0, template: '<ng-content />', isInline: true });
|
|
91
|
+
}
|
|
92
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.2.0", ngImport: i0, type: Sidebar, decorators: [{
|
|
93
|
+
type: Component,
|
|
94
|
+
args: [{
|
|
95
|
+
selector: 'sidebar',
|
|
96
|
+
template: '<ng-content />',
|
|
97
|
+
host: {
|
|
98
|
+
'[collapsed]': 'native ? collapsed() : undefined',
|
|
99
|
+
'[paneMinWidth]': 'native ? minWidth() : undefined',
|
|
100
|
+
'[paneMaxWidth]': 'native ? maxWidth() : undefined',
|
|
101
|
+
'[autosaveName]': 'native ? autosave() : undefined',
|
|
102
|
+
'[style.display]': "hidden() ? 'none' : undefined",
|
|
103
|
+
'[style.width]': 'drawnWidth()',
|
|
104
|
+
'[style.minWidth]': 'native ? undefined : minWidth()',
|
|
105
|
+
'[style.maxWidth]': 'native ? undefined : maxWidth()',
|
|
106
|
+
'[style.flex]': 'split?.stacked() ? 1 : undefined',
|
|
107
|
+
},
|
|
108
|
+
}]
|
|
109
|
+
}], propDecorators: { collapsed: [{ type: i0.Input, args: [{ isSignal: true, alias: "collapsed", required: false }] }, { type: i0.Output, args: ["collapsedChange"] }], minWidth: [{ type: i0.Input, args: [{ isSignal: true, alias: "minWidth", required: false }] }], maxWidth: [{ type: i0.Input, args: [{ isSignal: true, alias: "maxWidth", required: false }] }], autosave: [{ type: i0.Input, args: [{ isSignal: true, alias: "autosave", required: false }] }] } });
|
|
110
|
+
//# sourceMappingURL=sidebar.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sidebar.js","sourceRoot":"","sources":["../src/sidebar.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,SAAS,EACT,QAAQ,EACR,MAAM,EACN,KAAK,EACL,KAAK,GAGN,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AACrD,OAAO,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AACrD,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AACjD,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AACvD,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;;AAE1C;;;;GAIG;AACH,gBAAgB,CAAC,SAAS,EAAE;IAC1B,IAAI,GAAG;QACL,OAAO,gBAAgB,EAAE,CAAC,CAAC,CAAC,iBAAiB,CAAC,CAAC,CAAC,MAAM,CAAC;IACzD,CAAC;IACD,OAAO,EAAE,MAAM;IACf,KAAK,EAAE,iBAAiB;CACzB,CAAC,CAAC;AAEH,gFAAgF;AAChF,MAAM,WAAW,GAAG,GAAG,CAAC;AAQxB;;;;;;;;;;GAUG;AAgBH,MAAM,OAAO,OAAQ,SAAQ,QAAQ;IAChB,KAAK,GAAG,MAAM,CAAC,SAAS,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAC;IACjE,qEAAqE;IAClD,MAAM,GAAG,SAAS,CAAC,SAAS,CAAC,CAAC;IAEjD,sFAAsF;IAC7E,SAAS,GAAG,KAAK,CAAC,KAAK;kFAAC,CAAC;IAClC,gEAAgE;IACvD,QAAQ,GAAG,KAAK,CAAC,SAAS,gFAAI,SAAS,EAAE,cAAc,GAAG,CAAC;IACpE,6DAA6D;IACpD,QAAQ,GAAG,KAAK,CAAC,SAAS,gFAAI,SAAS,EAAE,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AAC;IAED,6FAA6F;IAC7F,MAAM,CAAC,GAAe;QACpB,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;QACnB,OAAO,GAAG,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;IACrC,CAAC;IAED,iGAAiG;IACjG,KAAK,CAAC,GAAe;QACnB,KAAK,MAAM,KAAK,IAAI,IAAI,CAAC,IAAI;YAAE,IAAI,KAAK,KAAK,GAAG;gBAAE,KAAK,CAAC,QAAQ,EAAE,CAAC;QACnE,IAAI,CAAC,KAAK,EAAE,WAAW,EAAE,CAAC;IAC5B,CAAC;uGAzDU,OAAO;2FAAP,OAAO,ymCAbR,gBAAgB;;2FAaf,OAAO;kBAfnB,SAAS;mBAAC;oBACT,QAAQ,EAAE,SAAS;oBACnB,QAAQ,EAAE,gBAAgB;oBAC1B,IAAI,EAAE;wBACJ,aAAa,EAAE,kCAAkC;wBACjD,gBAAgB,EAAE,iCAAiC;wBACnD,gBAAgB,EAAE,iCAAiC;wBACnD,gBAAgB,EAAE,iCAAiC;wBACnD,iBAAiB,EAAE,+BAA+B;wBAClD,eAAe,EAAE,cAAc;wBAC/B,kBAAkB,EAAE,iCAAiC;wBACrD,kBAAkB,EAAE,iCAAiC;wBACrD,cAAc,EAAE,kCAAkC;qBACnD;iBACF","sourcesContent":["import {\n Component,\n computed,\n inject,\n input,\n model,\n type OnDestroy,\n type OnInit,\n} from '@angular/core';\nimport { nativeSplitViews } from '@ng-native/device';\nimport { registerViewName } from '@ng-native/fabric';\nimport { optionalNumber } from './transforms.ts';\nimport { SplitView, hostDraws } from './split-view.ts';\nimport { ViewBase } from './view-base.ts';\n\n/**\n * On macOS the sidebar pane of the desktop host's split view, and on an iPad the sidebar column of\n * a UISplitViewController: the host owns its width, and Yoga gets the pane's frame back from it.\n * Elsewhere a view, drawn here.\n */\nregisterViewName('sidebar', {\n get ios() {\n return nativeSplitViews() ? 'NgNativeSidebar' : 'View';\n },\n android: 'View',\n macos: 'NgNativeSidebar',\n});\n\n/** The width a drawn sidebar starts at, in points, where nothing styles one. */\nconst DRAWN_WIDTH = 240;\n\n/** A selectable row of the sidebar, as the sidebar sees it. */\nexport interface SidebarRow {\n /** Deselect, because another row of the same sidebar was chosen. */\n deselect(): void;\n}\n\n/**\n * The sidebar of a `<split-view>`. Its `<sidebar-section>`s and `<sidebar-item>`s are a source\n * list on macOS, an NSOutlineView; anything else in it (a search field, a footer) is drawn and\n * styled by CSS on every OS.\n *\n * `[(collapsed)]` follows the title bar's sidebar button, View > Show Sidebar and a drag that shuts\n * it, on macOS, and the sidebar button and swipe of a UISplitViewController on an iPad. `minWidth`\n * and `maxWidth` bound a drag of the divider on macOS and the sidebar column's width on an iPad,\n * and `autosave` names where macOS keeps the width and collapsed state across launches. Drawn, a collapsed sidebar is hidden,\n * the widths bound its style, and `autosave` is ignored.\n */\n@Component({\n selector: 'sidebar',\n template: '<ng-content />',\n host: {\n '[collapsed]': 'native ? collapsed() : undefined',\n '[paneMinWidth]': 'native ? minWidth() : undefined',\n '[paneMaxWidth]': 'native ? maxWidth() : undefined',\n '[autosaveName]': 'native ? autosave() : undefined',\n '[style.display]': \"hidden() ? 'none' : undefined\",\n '[style.width]': 'drawnWidth()',\n '[style.minWidth]': 'native ? undefined : minWidth()',\n '[style.maxWidth]': 'native ? undefined : maxWidth()',\n '[style.flex]': 'split?.stacked() ? 1 : undefined',\n },\n})\nexport class Sidebar extends ViewBase implements OnInit, OnDestroy {\n protected readonly split = inject(SplitView, { optional: true });\n /** Whether the host draws this sidebar: on macOS, and on an iPad. */\n protected readonly native = hostDraws('sidebar');\n\n /** Whether the sidebar is shut. Kept in step with the user's own toggles on macOS. */\n readonly collapsed = model(false);\n /** The narrowest a drag of the divider leaves it, in points. */\n readonly minWidth = input(undefined, { transform: optionalNumber });\n /** The widest a drag of the divider leaves it, in points. */\n readonly maxWidth = input(undefined, { transform: optionalNumber });\n /** macOS: the name the width and collapsed state are kept under across launches. */\n readonly autosave = input<string>();\n\n private readonly rows = new Set<SidebarRow>();\n private stopCollapsed: (() => void) | null = null;\n\n /** Drawn, hidden while collapsed beside the content, or while a stack shows the content. */\n protected readonly hidden = computed(() => {\n if (this.native) return false;\n if (this.split?.stacked()) return this.split.showing() === 'content';\n return this.collapsed();\n });\n\n /** Drawn beside the content, a column of a set width that the app's style can override. */\n protected readonly drawnWidth = computed(() =>\n this.native || this.split?.stacked() ? undefined : DRAWN_WIDTH,\n );\n\n override ngOnInit(): void {\n super.ngOnInit();\n if (!this.native || this.stopCollapsed) return;\n this.stopCollapsed = this.engine.setEventListener(this.node, 'topSidebarCollapse', (event) => {\n const { target, nativeEvent } = event as {\n target?: unknown;\n nativeEvent?: { collapsed?: unknown };\n };\n // A sidebar inside this one's content reports its own.\n if (target !== this.node) return;\n if (typeof nativeEvent?.collapsed === 'boolean') this.collapsed.set(nativeEvent.collapsed);\n });\n }\n\n ngOnDestroy(): void {\n this.stopCollapsed?.();\n }\n\n /** Called by a row of this sidebar as it is created; answers the call that takes it away. */\n addRow(row: SidebarRow): () => void {\n this.rows.add(row);\n return () => this.rows.delete(row);\n }\n\n /** A row was chosen: the sidebar selects one row at a time, so every other one is deselected. */\n chose(row: SidebarRow): void {\n for (const other of this.rows) if (other !== row) other.deselect();\n this.split?.showContent();\n }\n}\n"]}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { type Signal } from '@angular/core';
|
|
2
|
+
import { ViewBase } from './view-base.ts';
|
|
3
|
+
import * as i0 from "@angular/core";
|
|
4
|
+
/** Whether the host draws `element`, rather than a view drawn here. */
|
|
5
|
+
export declare function hostDraws(element: string): boolean;
|
|
6
|
+
/**
|
|
7
|
+
* Material's expanded window width, in dp: from it Android's list-detail layout shows the list
|
|
8
|
+
* pane beside the content, and below it one pane at a time.
|
|
9
|
+
*/
|
|
10
|
+
export declare const ANDROID_EXPANDED_WIDTH = 840;
|
|
11
|
+
/** Which pane a split view shows: both side by side, or one of them as a stack's top. */
|
|
12
|
+
export type SplitViewShowing = 'both' | 'sidebar' | 'content';
|
|
13
|
+
/** The content pane: everything in a `<split-view>` but its `<sidebar>`. */
|
|
14
|
+
export declare class SplitViewContent extends ViewBase {
|
|
15
|
+
protected readonly split: SplitView;
|
|
16
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<SplitViewContent, never>;
|
|
17
|
+
static ɵcmp: i0.ɵɵComponentDeclaration<SplitViewContent, "split-view-content", never, {}, {}, never, ["*"], true, never>;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* A sidebar beside the app's content:
|
|
21
|
+
*
|
|
22
|
+
* <split-view>
|
|
23
|
+
* <sidebar [(collapsed)]="hidden">
|
|
24
|
+
* <sidebar-section title="Library">
|
|
25
|
+
* <sidebar-item path="songs" label="Songs" sfSymbol="music.note" />
|
|
26
|
+
* </sidebar-section>
|
|
27
|
+
* </sidebar>
|
|
28
|
+
* <router-outlet />
|
|
29
|
+
* </split-view>
|
|
30
|
+
*
|
|
31
|
+
* On macOS the first one in a window becomes its NSSplitViewController, with the full-height
|
|
32
|
+
* sidebar and the toolbar's sidebar button; a nested or second one is a plain NSSplitView. On an
|
|
33
|
+
* iPad it is a UISplitViewController, whose sidebar column holds the sidebar's rows drawn here,
|
|
34
|
+
* and which collapses into a stack itself at a compact width (Slide Over, a narrow Split View),
|
|
35
|
+
* the sidebar its root. On an iPhone and Android it is drawn: two columns, and at a compact width (`Screen.compact`) a stack whose
|
|
36
|
+
* root is the sidebar. On Android the columns wait for Material's expanded width,
|
|
37
|
+
* `ANDROID_EXPANDED_WIDTH`, as its list-detail layout does. There, choosing an item shows the content, and `showSidebar()` (or
|
|
38
|
+
* Android's back button) returns to the sidebar.
|
|
39
|
+
*/
|
|
40
|
+
export declare class SplitView extends ViewBase {
|
|
41
|
+
/** Whether this split view is drawn from views here, rather than by the host. */
|
|
42
|
+
readonly drawn: boolean;
|
|
43
|
+
/** Whether the host is iOS's, whose split view controller pushes and pops the content. */
|
|
44
|
+
private readonly stacksNatively;
|
|
45
|
+
private readonly screen;
|
|
46
|
+
/** Too narrow for the panes side by side: below Material's expanded width on Android. */
|
|
47
|
+
private readonly compact;
|
|
48
|
+
private readonly top;
|
|
49
|
+
/** Whether the panes are a stack, one at a time: at a compact width, where it is drawn. */
|
|
50
|
+
readonly stacked: Signal<boolean>;
|
|
51
|
+
/** Which pane is showing. Both, unless the split view is a stack. */
|
|
52
|
+
readonly showing: Signal<SplitViewShowing>;
|
|
53
|
+
constructor();
|
|
54
|
+
/** Show the content over the sidebar, where the panes are a stack. A choice in the sidebar does. */
|
|
55
|
+
showContent(): void;
|
|
56
|
+
/**
|
|
57
|
+
* Go back to the sidebar, where the panes are a stack and the content is in front. Whether it
|
|
58
|
+
* did, so Android's back button leaves the app from the sidebar.
|
|
59
|
+
*/
|
|
60
|
+
showSidebar(): boolean;
|
|
61
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<SplitView, never>;
|
|
62
|
+
static ɵcmp: i0.ɵɵComponentDeclaration<SplitView, "split-view", never, {}, {}, never, ["sidebar", "*"], true, never>;
|
|
63
|
+
}
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
import { Component, DestroyRef, computed, inject, signal } from '@angular/core';
|
|
2
|
+
import { HardwareBack, Screen, nativeSplitViews } from '@ng-native/device';
|
|
3
|
+
import { nativePlatform, registerViewName, registeredViewName } from '@ng-native/fabric';
|
|
4
|
+
import { ViewBase } from "./view-base.js";
|
|
5
|
+
import * as i0 from "@angular/core";
|
|
6
|
+
/**
|
|
7
|
+
* The host draws a split view on macOS: an NSSplitViewController for the first one in a window, a
|
|
8
|
+
* plain NSSplitView for any other. On an iPad with the components pod it is a
|
|
9
|
+
* UISplitViewController (`nativeSplitViews()`). Everywhere else it is drawn here, from views: two
|
|
10
|
+
* columns, or at a compact width a stack whose root is the sidebar.
|
|
11
|
+
*/
|
|
12
|
+
registerViewName('split-view', {
|
|
13
|
+
get ios() {
|
|
14
|
+
return nativeSplitViews() ? 'NgNativeSplitView' : 'View';
|
|
15
|
+
},
|
|
16
|
+
android: 'View',
|
|
17
|
+
macos: 'NgNativeSplitView',
|
|
18
|
+
});
|
|
19
|
+
registerViewName('split-view-content', {
|
|
20
|
+
get ios() {
|
|
21
|
+
return nativeSplitViews() ? 'NgNativeSplitContent' : 'View';
|
|
22
|
+
},
|
|
23
|
+
android: 'View',
|
|
24
|
+
macos: 'NgNativeSplitContent',
|
|
25
|
+
});
|
|
26
|
+
/** Whether the host draws `element`, rather than a view drawn here. */
|
|
27
|
+
export function hostDraws(element) {
|
|
28
|
+
return registeredViewName(element) !== 'View';
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Material's expanded window width, in dp: from it Android's list-detail layout shows the list
|
|
32
|
+
* pane beside the content, and below it one pane at a time.
|
|
33
|
+
*/
|
|
34
|
+
export const ANDROID_EXPANDED_WIDTH = 840;
|
|
35
|
+
/** The content pane: everything in a `<split-view>` but its `<sidebar>`. */
|
|
36
|
+
export class SplitViewContent extends ViewBase {
|
|
37
|
+
split = inject(SplitView);
|
|
38
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.2.0", ngImport: i0, type: SplitViewContent, deps: null, target: i0.ɵɵFactoryTarget.Component });
|
|
39
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "22.2.0", type: SplitViewContent, isStandalone: true, selector: "split-view-content", host: { properties: { "style.display": "split.showing() === 'sidebar' ? 'none' : undefined" } }, usesInheritance: true, ngImport: i0, template: '<ng-content />', isInline: true, styles: [":host { flex: 1; }"] });
|
|
40
|
+
}
|
|
41
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.2.0", ngImport: i0, type: SplitViewContent, decorators: [{
|
|
42
|
+
type: Component,
|
|
43
|
+
args: [{ selector: 'split-view-content', template: '<ng-content />', host: { '[style.display]': "split.showing() === 'sidebar' ? 'none' : undefined" }, styles: [":host { flex: 1; }"] }]
|
|
44
|
+
}] });
|
|
45
|
+
/**
|
|
46
|
+
* A sidebar beside the app's content:
|
|
47
|
+
*
|
|
48
|
+
* <split-view>
|
|
49
|
+
* <sidebar [(collapsed)]="hidden">
|
|
50
|
+
* <sidebar-section title="Library">
|
|
51
|
+
* <sidebar-item path="songs" label="Songs" sfSymbol="music.note" />
|
|
52
|
+
* </sidebar-section>
|
|
53
|
+
* </sidebar>
|
|
54
|
+
* <router-outlet />
|
|
55
|
+
* </split-view>
|
|
56
|
+
*
|
|
57
|
+
* On macOS the first one in a window becomes its NSSplitViewController, with the full-height
|
|
58
|
+
* sidebar and the toolbar's sidebar button; a nested or second one is a plain NSSplitView. On an
|
|
59
|
+
* iPad it is a UISplitViewController, whose sidebar column holds the sidebar's rows drawn here,
|
|
60
|
+
* and which collapses into a stack itself at a compact width (Slide Over, a narrow Split View),
|
|
61
|
+
* the sidebar its root. On an iPhone and Android it is drawn: two columns, and at a compact width (`Screen.compact`) a stack whose
|
|
62
|
+
* root is the sidebar. On Android the columns wait for Material's expanded width,
|
|
63
|
+
* `ANDROID_EXPANDED_WIDTH`, as its list-detail layout does. There, choosing an item shows the content, and `showSidebar()` (or
|
|
64
|
+
* Android's back button) returns to the sidebar.
|
|
65
|
+
*/
|
|
66
|
+
export class SplitView extends ViewBase {
|
|
67
|
+
/** Whether this split view is drawn from views here, rather than by the host. */
|
|
68
|
+
drawn = !hostDraws('split-view');
|
|
69
|
+
/** Whether the host is iOS's, whose split view controller pushes and pops the content. */
|
|
70
|
+
stacksNatively = !this.drawn && nativePlatform() === 'ios';
|
|
71
|
+
screen = inject(Screen);
|
|
72
|
+
/** Too narrow for the panes side by side: below Material's expanded width on Android. */
|
|
73
|
+
compact = computed(() => nativePlatform() === 'android'
|
|
74
|
+
? this.screen.window().width < ANDROID_EXPANDED_WIDTH
|
|
75
|
+
: this.screen.compact(), /* @ts-ignore */
|
|
76
|
+
...(ngDevMode ? [{ debugName: "compact" }] : /* istanbul ignore next */ []));
|
|
77
|
+
top = signal('sidebar', /* @ts-ignore */
|
|
78
|
+
...(ngDevMode ? [{ debugName: "top" }] : /* istanbul ignore next */ []));
|
|
79
|
+
/** Whether the panes are a stack, one at a time: at a compact width, where it is drawn. */
|
|
80
|
+
stacked = computed(() => this.drawn && this.compact(), /* @ts-ignore */
|
|
81
|
+
...(ngDevMode ? [{ debugName: "stacked" }] : /* istanbul ignore next */ []));
|
|
82
|
+
/** Which pane is showing. Both, unless the split view is a stack. */
|
|
83
|
+
showing = computed(() => this.stacked() ? this.top() : 'both', /* @ts-ignore */
|
|
84
|
+
...(ngDevMode ? [{ debugName: "showing" }] : /* istanbul ignore next */ []));
|
|
85
|
+
constructor() {
|
|
86
|
+
super();
|
|
87
|
+
const stop = inject(HardwareBack).handle(() => this.showSidebar());
|
|
88
|
+
inject(DestroyRef).onDestroy(stop);
|
|
89
|
+
}
|
|
90
|
+
/** Show the content over the sidebar, where the panes are a stack. A choice in the sidebar does. */
|
|
91
|
+
showContent() {
|
|
92
|
+
this.top.set('content');
|
|
93
|
+
if (this.stacksNatively)
|
|
94
|
+
this.engine.dispatchCommand(this.node, 'showContent');
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Go back to the sidebar, where the panes are a stack and the content is in front. Whether it
|
|
98
|
+
* did, so Android's back button leaves the app from the sidebar.
|
|
99
|
+
*/
|
|
100
|
+
showSidebar() {
|
|
101
|
+
if (this.stacksNatively)
|
|
102
|
+
this.engine.dispatchCommand(this.node, 'showSidebar');
|
|
103
|
+
if (this.showing() !== 'content')
|
|
104
|
+
return false;
|
|
105
|
+
this.top.set('sidebar');
|
|
106
|
+
return true;
|
|
107
|
+
}
|
|
108
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.2.0", ngImport: i0, type: SplitView, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
109
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "22.2.0", type: SplitView, isStandalone: true, selector: "split-view", host: { properties: { "style.flexDirection": "drawn && !stacked() ? 'row' : undefined" } }, usesInheritance: true, ngImport: i0, template: `
|
|
110
|
+
<ng-content select="sidebar" />
|
|
111
|
+
<split-view-content><ng-content /></split-view-content>
|
|
112
|
+
`, isInline: true, styles: [":host { flex: 1; }"], dependencies: [{ kind: "component", type: SplitViewContent, selector: "split-view-content" }] });
|
|
113
|
+
}
|
|
114
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.2.0", ngImport: i0, type: SplitView, decorators: [{
|
|
115
|
+
type: Component,
|
|
116
|
+
args: [{ selector: 'split-view', imports: [SplitViewContent], template: `
|
|
117
|
+
<ng-content select="sidebar" />
|
|
118
|
+
<split-view-content><ng-content /></split-view-content>
|
|
119
|
+
`, host: { '[style.flexDirection]': "drawn && !stacked() ? 'row' : undefined" }, styles: [":host { flex: 1; }"] }]
|
|
120
|
+
}], ctorParameters: () => [] });
|
|
121
|
+
//# sourceMappingURL=split-view.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"split-view.js","sourceRoot":"","sources":["../src/split-view.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAe,MAAM,eAAe,CAAC;AAC7F,OAAO,EAAE,YAAY,EAAE,MAAM,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAC3E,OAAO,EAAE,cAAc,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AACzF,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;;AAE1C;;;;;GAKG;AACH,gBAAgB,CAAC,YAAY,EAAE;IAC7B,IAAI,GAAG;QACL,OAAO,gBAAgB,EAAE,CAAC,CAAC,CAAC,mBAAmB,CAAC,CAAC,CAAC,MAAM,CAAC;IAC3D,CAAC;IACD,OAAO,EAAE,MAAM;IACf,KAAK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uB,EAAE,yCAAyC,EAAE","sourcesContent":["import { Component, DestroyRef, computed, inject, signal, type Signal } from '@angular/core';\nimport { HardwareBack, Screen, nativeSplitViews } from '@ng-native/device';\nimport { nativePlatform, registerViewName, registeredViewName } from '@ng-native/fabric';\nimport { ViewBase } from './view-base.ts';\n\n/**\n * The host draws a split view on macOS: an NSSplitViewController for the first one in a window, a\n * plain NSSplitView for any other. On an iPad with the components pod it is a\n * UISplitViewController (`nativeSplitViews()`). Everywhere else it is drawn here, from views: two\n * columns, or at a compact width a stack whose root is the sidebar.\n */\nregisterViewName('split-view', {\n get ios() {\n return nativeSplitViews() ? 'NgNativeSplitView' : 'View';\n },\n android: 'View',\n macos: 'NgNativeSplitView',\n});\nregisterViewName('split-view-content', {\n get ios() {\n return nativeSplitViews() ? 'NgNativeSplitContent' : 'View';\n },\n android: 'View',\n macos: 'NgNativeSplitContent',\n});\n\n/** Whether the host draws `element`, rather than a view drawn here. */\nexport function hostDraws(element: string): boolean {\n return registeredViewName(element) !== 'View';\n}\n\n/**\n * Material's expanded window width, in dp: from it Android's list-detail layout shows the list\n * pane beside the content, and below it one pane at a time.\n */\nexport const ANDROID_EXPANDED_WIDTH = 840;\n\n/** Which pane a split view shows: both side by side, or one of them as a stack's top. */\nexport type SplitViewShowing = 'both' | 'sidebar' | 'content';\n\n/** The content pane: everything in a `<split-view>` but its `<sidebar>`. */\n@Component({\n selector: 'split-view-content',\n template: '<ng-content />',\n host: { '[style.display]': \"split.showing() === 'sidebar' ? 'none' : undefined\" },\n styles: ':host { flex: 1; }',\n})\nexport class SplitViewContent extends ViewBase {\n protected readonly split = inject(SplitView);\n}\n\n/**\n * A sidebar beside the app's content:\n *\n * <split-view>\n * <sidebar [(collapsed)]=\"hidden\">\n * <sidebar-section title=\"Library\">\n * <sidebar-item path=\"songs\" label=\"Songs\" sfSymbol=\"music.note\" />\n * </sidebar-section>\n * </sidebar>\n * <router-outlet />\n * </split-view>\n *\n * On macOS the first one in a window becomes its NSSplitViewController, with the full-height\n * sidebar and the toolbar's sidebar button; a nested or second one is a plain NSSplitView. On an\n * iPad it is a UISplitViewController, whose sidebar column holds the sidebar's rows drawn here,\n * and which collapses into a stack itself at a compact width (Slide Over, a narrow Split View),\n * the sidebar its root. On an iPhone and Android it is drawn: two columns, and at a compact width (`Screen.compact`) a stack whose\n * root is the sidebar. On Android the columns wait for Material's expanded width,\n * `ANDROID_EXPANDED_WIDTH`, as its list-detail layout does. There, choosing an item shows the content, and `showSidebar()` (or\n * Android's back button) returns to the sidebar.\n */\n@Component({\n selector: 'split-view',\n imports: [SplitViewContent],\n template: `\n <ng-content select=\"sidebar\" />\n <split-view-content><ng-content /></split-view-content>\n `,\n styles: ':host { flex: 1; }',\n host: { '[style.flexDirection]': \"drawn && !stacked() ? 'row' : undefined\" },\n})\nexport class SplitView extends ViewBase {\n /** Whether this split view is drawn from views here, rather than by the host. */\n readonly drawn = !hostDraws('split-view');\n /** Whether the host is iOS's, whose split view controller pushes and pops the content. */\n private readonly stacksNatively = !this.drawn && nativePlatform() === 'ios';\n private readonly screen = inject(Screen);\n /** Too narrow for the panes side by side: below Material's expanded width on Android. */\n private readonly compact = computed(() =>\n nativePlatform() === 'android'\n ? this.screen.window().width < ANDROID_EXPANDED_WIDTH\n : this.screen.compact(),\n );\n private readonly top = signal<'sidebar' | 'content'>('sidebar');\n\n /** Whether the panes are a stack, one at a time: at a compact width, where it is drawn. */\n readonly stacked: Signal<boolean> = computed(() => this.drawn && this.compact());\n\n /** Which pane is showing. Both, unless the split view is a stack. */\n readonly showing: Signal<SplitViewShowing> = computed(() =>\n this.stacked() ? this.top() : 'both',\n );\n\n constructor() {\n super();\n const stop = inject(HardwareBack).handle(() => this.showSidebar());\n inject(DestroyRef).onDestroy(stop);\n }\n\n /** Show the content over the sidebar, where the panes are a stack. A choice in the sidebar does. */\n showContent(): void {\n this.top.set('content');\n if (this.stacksNatively) this.engine.dispatchCommand(this.node, 'showContent');\n }\n\n /**\n * Go back to the sidebar, where the panes are a stack and the content is in front. Whether it\n * did, so Android's back button leaves the app from the sidebar.\n */\n showSidebar(): boolean {\n if (this.stacksNatively) this.engine.dispatchCommand(this.node, 'showSidebar');\n if (this.showing() !== 'content') return false;\n this.top.set('sidebar');\n return true;\n }\n}\n"]}
|
package/dist/switch.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { type SimpleChanges } from '@angular/core';
|
|
2
2
|
import { type NativeSyntheticEvent } from '@ng-native/fabric';
|
|
3
|
+
import type { ControlSize } from '@ng-native/device';
|
|
3
4
|
import { ViewBase } from './view-base.ts';
|
|
4
5
|
import * as i0 from "@angular/core";
|
|
5
6
|
/**
|
|
@@ -22,6 +23,8 @@ import * as i0 from "@angular/core";
|
|
|
22
23
|
*/
|
|
23
24
|
export declare class Switch extends ViewBase {
|
|
24
25
|
readonly checked: import("@angular/core").ModelSignal<boolean>;
|
|
26
|
+
/** AppKit's control size on macOS, and UIKit's on iOS 26 and later. Ignored elsewhere. */
|
|
27
|
+
readonly controlSize: import("@angular/core").InputSignal<ControlSize | undefined>;
|
|
25
28
|
/** Ignore touches and grey out. */
|
|
26
29
|
readonly disabled: import("@angular/core").InputSignalWithTransform<boolean | undefined, unknown>;
|
|
27
30
|
/** Published as `data-invalid`; nothing native reads it. */
|
|
@@ -53,6 +56,11 @@ export declare class Switch extends ViewBase {
|
|
|
53
56
|
protected onNativeChange(event: NativeSyntheticEvent<{
|
|
54
57
|
value?: boolean;
|
|
55
58
|
}>): void;
|
|
59
|
+
/**
|
|
60
|
+
* Tell the app's interaction observers, if it has any, as a `click` with no value: whether a
|
|
61
|
+
* switch is on can be user data. Looked up only once the user has flipped it.
|
|
62
|
+
*/
|
|
63
|
+
private reportFlip;
|
|
56
64
|
/**
|
|
57
65
|
* After the app's bindings have settled, not before: a flip the app accepts reaches the model
|
|
58
66
|
* during change detection, and comparing any earlier would send native back the value it is
|
|
@@ -60,5 +68,5 @@ export declare class Switch extends ViewBase {
|
|
|
60
68
|
*/
|
|
61
69
|
private reconcile;
|
|
62
70
|
static ɵfac: i0.ɵɵFactoryDeclaration<Switch, never>;
|
|
63
|
-
static ɵdir: i0.ɵɵDirectiveDeclaration<Switch, "switch", never, { "checked": { "alias": "checked"; "required": false; "isSignal": true; }; "disabled": { "alias": "disabled"; "required": false; "isSignal": true; }; "invalid": { "alias": "invalid"; "required": false; "isSignal": true; }; "touched": { "alias": "touched"; "required": false; "isSignal": true; }; "thumbColor": { "alias": "thumbColor"; "required": false; "isSignal": true; }; "trackColor": { "alias": "trackColor"; "required": false; "isSignal": true; }; "iosBackgroundColor": { "alias": "ios_backgroundColor"; "required": false; "isSignal": true; }; }, { "checked": "checkedChange"; "touch": "touch"; }, never, never, true, never>;
|
|
71
|
+
static ɵdir: i0.ɵɵDirectiveDeclaration<Switch, "switch", never, { "checked": { "alias": "checked"; "required": false; "isSignal": true; }; "controlSize": { "alias": "controlSize"; "required": false; "isSignal": true; }; "disabled": { "alias": "disabled"; "required": false; "isSignal": true; }; "invalid": { "alias": "invalid"; "required": false; "isSignal": true; }; "touched": { "alias": "touched"; "required": false; "isSignal": true; }; "thumbColor": { "alias": "thumbColor"; "required": false; "isSignal": true; }; "trackColor": { "alias": "trackColor"; "required": false; "isSignal": true; }; "iosBackgroundColor": { "alias": "ios_backgroundColor"; "required": false; "isSignal": true; }; }, { "checked": "checkedChange"; "touch": "touch"; }, never, never, true, never>;
|
|
64
72
|
}
|