@ng-native/components 0.27.0 → 0.29.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/android/src/main/java/dev/ngnative/components/ColorSchemeModule.kt +116 -11
- package/android/src/main/java/dev/ngnative/components/ContextMenuPopup.kt +61 -19
- package/android/src/main/java/dev/ngnative/components/MenusModule.kt +22 -0
- package/android/src/main/java/dev/ngnative/components/Shortcut.kt +13 -4
- package/dist/context-menu.d.ts +14 -6
- package/dist/context-menu.js +30 -28
- package/dist/context-menu.js.map +1 -1
- package/dist/index.d.ts +4 -1
- package/dist/index.js +4 -1
- package/dist/index.js.map +1 -1
- package/dist/menu.d.ts +17 -8
- package/dist/menu.js +22 -36
- package/dist/menu.js.map +1 -1
- package/dist/modal.d.ts +6 -2
- package/dist/modal.js.map +1 -1
- package/dist/native-button.d.ts +31 -2
- package/dist/native-button.js +104 -6
- package/dist/native-button.js.map +1 -1
- package/dist/press-menu.d.ts +60 -0
- package/dist/press-menu.js +116 -0
- package/dist/press-menu.js.map +1 -0
- package/dist/pressable.d.ts +3 -0
- package/dist/pressable.js +7 -1
- package/dist/pressable.js.map +1 -1
- package/dist/reanimated.js +27 -3
- package/dist/reanimated.js.map +1 -1
- package/dist/scroll-view.d.ts +3 -1
- package/dist/scroll-view.js +7 -2
- package/dist/scroll-view.js.map +1 -1
- package/dist/settled-updates.d.ts +55 -0
- package/dist/settled-updates.js +77 -0
- package/dist/settled-updates.js.map +1 -0
- package/dist/sidebar-item.d.ts +18 -3
- package/dist/sidebar-item.js +29 -3
- package/dist/sidebar-item.js.map +1 -1
- package/dist/sidebar.js +4 -3
- package/dist/sidebar.js.map +1 -1
- package/dist/split-view.d.ts +23 -2
- package/dist/split-view.js +32 -5
- package/dist/split-view.js.map +1 -1
- package/dist/stand-ins/reanimated.d.ts +5 -0
- package/dist/stand-ins/reanimated.js +7 -0
- package/dist/stand-ins/reanimated.js.map +1 -1
- package/dist/sticky-headers.d.ts +19 -0
- package/dist/sticky-headers.js +67 -10
- package/dist/sticky-headers.js.map +1 -1
- package/dist/sticky-rows.d.ts +123 -26
- package/dist/sticky-rows.js +285 -71
- package/dist/sticky-rows.js.map +1 -1
- package/dist/svg-icon.d.ts +23 -0
- package/dist/svg-icon.js +53 -0
- package/dist/svg-icon.js.map +1 -0
- package/dist/tray-icon.d.ts +7 -1
- package/dist/tray-icon.js +15 -3
- package/dist/tray-icon.js.map +1 -1
- package/dist/virtual-list-sticky-level.d.ts +33 -0
- package/dist/virtual-list-sticky-level.js +58 -0
- package/dist/virtual-list-sticky-level.js.map +1 -0
- package/dist/virtual-list-sticky.d.ts +19 -0
- package/dist/virtual-list-sticky.js +13 -0
- package/dist/virtual-list-sticky.js.map +1 -0
- package/dist/virtual-list.d.ts +29 -7
- package/dist/virtual-list.js +127 -59
- package/dist/virtual-list.js.map +1 -1
- package/dist/worklet-style.d.ts +11 -0
- package/dist/worklet-style.js +15 -1
- package/dist/worklet-style.js.map +1 -1
- package/dist/worklets.d.ts +5 -1
- package/dist/worklets.js.map +1 -1
- package/dist/written-props.js +3 -0
- package/dist/written-props.js.map +1 -1
- package/ios/NgNativeButtonComponentView.mm +8 -4
- package/ios/NgNativeButtonMetrics.h +9 -2
- package/ios/NgNativeButtonMetrics.mm +33 -4
- package/ios/NgNativeButtonShadowNode.h +2 -0
- package/ios/NgNativeButtonShadowNode.mm +5 -1
- package/ios/NgNativeMenus.mm +42 -2
- package/ios/NgNativePressMenu.h +28 -0
- package/ios/NgNativePressMenu.mm +45 -0
- package/package.json +3 -3
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAC5D,OAAO,EAAmD,MAAM,gBAAgB,CAAC;AACjF,OAAO,EAwCN,MAAM,aAAa,CAAC;AAC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C,OAAO,EACL,oBAAoB,EACpB,aAAa,EACb,aAAa,EACb,WAAW,EACX,WAAW,EACX,gBAAgB,GAOjB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,OAAO,EAAE,IAAI,EAA4C,MAAM,WAAW,CAAC;AAC3E,OAAO,EACL,SAAS,GAIV,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC1D,OAAO,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAClE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EACL,QAAQ,EACR,YAAY,EACZ,uBAAuB,GAWxB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EACL,WAAW,EACX,cAAc,EACd,oBAAoB,GAMrB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,mBAAmB,EAA0B,MAAM,0BAA0B,CAAC;AACvF,OAAO,EAAE,qBAAqB,EAAE,MAAM,+BAA+B,CAAC;AACtE,OAAO,EAAE,mBAAmB,EAA0B,MAAM,0BAA0B,CAAC;AACvF,OAAO,EAAE,sBAAsB,EAAE,MAAM,gCAAgC,CAAC;AACxE,OAAO,EAA6D,MAAM,sBAAsB,CAAC;AACjG,OAAO,EACL,aAAa,EACb,YAAY,GAMb,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC","sourcesContent":["/**\n * The host primitives, and the platform-capability tokens they inject.\n *\n * Every element a template renders natively is a component here and must be imported by the\n * component whose template uses it, as any Angular component must. A template that uses one\n * without importing it compiles, renders a plain view, and is reported in dev builds.\n *\n * Importing this barrel evaluates decorators, so anything a Node test needs at runtime has to\n * be reached as a source file instead - see the note in `packages/integration-tests/compile.ts`.\n */\nexport { ActivityIndicator } from './activity-indicator.ts';\nexport { type AnimatedPropsHandle, type AnimationBackend } from './animation.ts';\nexport {\n type AccessibilityActionEvent,\n type AccessibilityActionPayload,\n type ContentSizeChangeEvent,\n type ImageErrorEvent,\n type ImageErrorPayload,\n type ImageLoadEvent,\n type ImageLoadPayload,\n type ImageProgressEvent,\n type ImageProgressPayload,\n type Insets,\n type KeyPressEvent,\n type KeyPressPayload,\n type LayoutEvent,\n type LayoutPayload,\n type OrientationChangeEvent,\n type OrientationChangePayload,\n type Point,\n type Rect,\n type ScrollEvent,\n type ScrollPayload,\n type SelectionChangeEvent,\n type SelectionChangePayload,\n type Size,\n type SwitchChangeEvent,\n type SwitchChangePayload,\n type TextInputChangeEvent,\n type TextInputChangePayload,\n type TextInputContentSizeEvent,\n type TextInputContentSizePayload,\n type TextInputEditingEvent,\n type TextInputFocusEvent,\n type TextInputFocusPayload,\n type TextInputScrollEvent,\n type TextInputScrollPayload,\n type TextLayoutEvent,\n type TextLayoutLine,\n type TextLayoutPayload,\n type TouchEvent,\n type TouchEventPayload,\n} from './events.ts';\nexport { Image, type ImageResizeMode, type ImageSource, type ImageURISource } from './image.ts';\nexport { ImageBackground } from './image-background.ts';\nexport { InputAccessoryView } from './input-accessory-view.ts';\nexport {\n KEYBOARD_CONTROLLER,\n KeyboardDock,\n KeyboardLift,\n provideKeyboardController,\n} from './keyboard-dock.ts';\nexport { KeyboardAvoidingView, type KeyboardAvoidingBehavior } from './keyboard-avoiding-view.ts';\nexport {\n Modal,\n type ModalAnchor,\n type ModalOrientation,\n type ModalPresentationStyle,\n} from './modal.ts';\nexport { MenuBar, MenuGroup, MenuItem, MenuSeparator, treeOrder } from './menu.ts';\nexport { CONTEXT_MENU, ContextMenu } from './context-menu.ts';\nexport { PRESS_MENU, PressMenu } from './press-menu.ts';\nexport { Shortcut } from './shortcut.ts';\nexport {\n DragItem,\n FileDrop,\n type DragItemValue,\n type DroppedFile,\n type FileDropEvent,\n} from './drag-and-drop.ts';\nexport { TrayIcon } from './tray-icon.ts';\nexport {\n SplitView,\n SplitViewContent,\n type SplitViewContentStyle,\n type SplitViewShowing,\n} from './split-view.ts';\nexport { Sidebar, type SidebarRow } from './sidebar.ts';\nexport { SidebarSection } from './sidebar-section.ts';\nexport { SidebarItem, type SidebarItemIcon } from './sidebar-item.ts';\nexport { NativeButton, type ButtonIcon, type ButtonKind } from './native-button.ts';\nexport { NativeRef } from './native-ref.ts';\nexport {\n ControlBase,\n PressBehavior,\n Pressable,\n TouchableBase,\n type AndroidRipple,\n type PressEvent,\n} from './pressable.ts';\nexport {\n INTERACTION_OBSERVERS,\n SWIPE_VELOCITY,\n provideInteractionObserver,\n type InteractionDirection,\n type InteractionEvent,\n type InteractionGesture,\n type InteractionObserver,\n type InteractionType,\n} from './interaction-observer.ts';\nexport { RefreshControl } from './refresh-control.ts';\nexport { GradientText } from './gradient-text.ts';\nexport { type SafeAreaEdge, type SafeAreaEdges } from './safe-area.ts';\nexport { SafeAreaProvider } from './safe-area-provider.ts';\nexport { SafeAreaView, type SafeAreaEdgeMode } from './safe-area-view.ts';\nexport { type KeyboardShouldPersistTaps } from './keyboard-taps.ts';\nexport { ScrollView } from './scroll-view.ts';\nexport {\n SectionEdgeSeparator,\n SectionFooter,\n SectionHeader,\n SectionItem,\n SectionList,\n SectionSeparator,\n type SectionContext,\n type SectionEdgeSeparatorContext,\n type SectionItemContext,\n type SectionListSection,\n type SectionRow,\n type SectionSeparatorContext,\n} from './section-list.ts';\nexport { Switch } from './switch.ts';\nexport { Text, type DynamicTypeRamp, type EllipsizeMode } from './text.ts';\nexport {\n TextInput,\n type KeyboardType,\n type ReturnKeyType,\n type SubmitBehavior,\n} from './text-input.ts';\nexport { TouchableOpacity } from './touchable-opacity.ts';\nexport { optionalBoolean, optionalNumber } from './transforms.ts';\nexport { View } from './view.ts';\nexport {\n ViewBase,\n ViewBehavior,\n contributeAccessibility,\n type AccessibilityAction,\n type AccessibilityContribution,\n type AccessibilityLiveRegion,\n type AccessibilityRole,\n type Role,\n type AccessibilityState,\n type AccessibilityValue,\n type AndroidDrawable,\n type ImportantForAccessibility,\n type PointerEvents,\n} from './view-base.ts';\nexport {\n VirtualList,\n VirtualListRow,\n VirtualListSeparator,\n type VirtualItemHeight,\n type VirtualListSeparatorContext,\n type VirtualListPadding,\n type VirtualListVisiblePosition,\n type VirtualRow,\n} from './virtual-list.ts';\nexport { VIRTUAL_LIST_LAYOUT, type VirtualListLayout } from './virtual-list-layout.ts';\nexport { VirtualListNumColumns } from './virtual-list-num-columns.ts';\nexport { VIRTUAL_LIST_STICKY, type VirtualListSticky } from './virtual-list-sticky.ts';\nexport { VirtualListStickyLevel } from './virtual-list-sticky-level.ts';\nexport { type GestureBackend, type GestureSpec, type GestureTarget } from './gesture-backend.ts';\nexport {\n workletScroll,\n workletStyle,\n type SharedValue,\n type WorkletBackend,\n type WorkletScrollSpec,\n type WorkletStyleSpec,\n type WorkletTarget,\n} from './worklets.ts';\nexport { releaseOnDestroy } from './release-on-destroy.ts';\n"]}
|
package/dist/menu.d.ts
CHANGED
|
@@ -4,15 +4,17 @@
|
|
|
4
4
|
* `MENU_MODEL`, and the menu's owner draws it: `Menus` sends a `<menu-bar>` to the host, and a
|
|
5
5
|
* `[contextMenu]` or a `<native-header-item [menu]>` reads a template of items.
|
|
6
6
|
*/
|
|
7
|
-
import { type
|
|
7
|
+
import { type OnChanges, type SimpleChanges } from '@angular/core';
|
|
8
8
|
import { type MenuGroupRole, type MenuRole } from '@ng-native/device';
|
|
9
|
+
import type { ButtonIcon } from './native-button.ts';
|
|
9
10
|
import * as i0 from "@angular/core";
|
|
10
11
|
export { menuModelInTreeOrder, treeOrder } from '@ng-native/device';
|
|
11
12
|
/**
|
|
12
|
-
* One item of a menu. `(select)` fires when it is chosen, and a `[(checked)]` item toggles.
|
|
13
|
-
*
|
|
13
|
+
* One item of a menu. `(select)` fires when it is chosen, and a `[(checked)]` item toggles. A
|
|
14
|
+
* one-way `[checked]` stays as the app binds it, so a menu of choices checks the one the app keeps.
|
|
15
|
+
* An item with a `menuRole` and no `(select)` does what the OS does for that role.
|
|
14
16
|
*/
|
|
15
|
-
export declare class MenuItem {
|
|
17
|
+
export declare class MenuItem implements OnChanges {
|
|
16
18
|
readonly label: import("@angular/core").InputSignal<string>;
|
|
17
19
|
/** What the item is for, where the OS has a standard one: it replaces that default. */
|
|
18
20
|
readonly menuRole: import("@angular/core").InputSignal<MenuRole | undefined>;
|
|
@@ -21,15 +23,21 @@ export declare class MenuItem {
|
|
|
21
23
|
readonly disabled: import("@angular/core").InputSignalWithTransform<boolean, unknown>;
|
|
22
24
|
/** A check mark. Bound two-way, it toggles as the item is chosen. */
|
|
23
25
|
readonly checked: import("@angular/core").ModelSignal<boolean | undefined>;
|
|
26
|
+
private readonly checkedModel;
|
|
24
27
|
readonly destructive: import("@angular/core").InputSignalWithTransform<boolean, unknown>;
|
|
25
28
|
readonly subtitle: import("@angular/core").InputSignal<string | undefined>;
|
|
26
29
|
/** An SF Symbol, on Apple's OSes. */
|
|
27
30
|
readonly sfSymbol: import("@angular/core").InputSignal<string | undefined>;
|
|
28
|
-
/**
|
|
29
|
-
|
|
30
|
-
|
|
31
|
+
/**
|
|
32
|
+
* The picture: a drawable resource's name, on Android, or a `ButtonIcon` as `<native-button>`
|
|
33
|
+
* takes, `{ sfSymbol }`, `{ drawable }`, or an icon's SVG markup, `{ svg }`, in a macOS menu and
|
|
34
|
+
* in a Linux tray icon's menu.
|
|
35
|
+
*/
|
|
36
|
+
readonly icon: import("@angular/core").InputSignal<string | ButtonIcon | undefined>;
|
|
37
|
+
readonly select: import("@angular/core").OutputEmitterRef<void>;
|
|
31
38
|
private readonly handled;
|
|
32
39
|
constructor();
|
|
40
|
+
ngOnChanges(changes: SimpleChanges): void;
|
|
33
41
|
/** One handler for the item's life: the id a host reports a choice by. See `menuActionId`. */
|
|
34
42
|
private readonly choose;
|
|
35
43
|
static ɵfac: i0.ɵɵFactoryDeclaration<MenuItem, never>;
|
|
@@ -51,7 +59,8 @@ export declare class MenuGroup {
|
|
|
51
59
|
readonly menuRole: import("@angular/core").InputSignal<MenuGroupRole | undefined>;
|
|
52
60
|
readonly inline: import("@angular/core").InputSignalWithTransform<boolean, unknown>;
|
|
53
61
|
readonly sfSymbol: import("@angular/core").InputSignal<string | undefined>;
|
|
54
|
-
|
|
62
|
+
/** A drawable's name, or a `ButtonIcon`, as on `<menu-item>`. */
|
|
63
|
+
readonly icon: import("@angular/core").InputSignal<string | ButtonIcon | undefined>;
|
|
55
64
|
readonly destructive: import("@angular/core").InputSignalWithTransform<boolean, unknown>;
|
|
56
65
|
private readonly own;
|
|
57
66
|
constructor();
|
package/dist/menu.js
CHANGED
|
@@ -4,8 +4,10 @@
|
|
|
4
4
|
* `MENU_MODEL`, and the menu's owner draws it: `Menus` sends a `<menu-bar>` to the host, and a
|
|
5
5
|
* `[contextMenu]` or a `<native-header-item [menu]>` reads a template of items.
|
|
6
6
|
*/
|
|
7
|
-
import { Component, DestroyRef, ElementRef, booleanAttribute, computed, inject, input, model, output,
|
|
8
|
-
import { MENU_MODEL, Menus, menuModelInTreeOrder, } from '@ng-native/device';
|
|
7
|
+
import { Component, DestroyRef, ElementRef, booleanAttribute, computed, inject, input, model, output, } from '@angular/core';
|
|
8
|
+
import { MENU_MODEL, Menus, menuModelInTreeOrder, outputListened, } from '@ng-native/device';
|
|
9
|
+
import { ControlledModel } from "./controlled-model.js";
|
|
10
|
+
import { iconFields } from "./svg-icon.js";
|
|
9
11
|
import * as i0 from "@angular/core";
|
|
10
12
|
export { menuModelInTreeOrder, treeOrder } from '@ng-native/device';
|
|
11
13
|
/** Register `entry` with the menu the element is written in, and take it out as it goes. */
|
|
@@ -20,32 +22,9 @@ function registerIn(entry, element) {
|
|
|
20
22
|
inject(DestroyRef).onDestroy(menu.register(entry, node));
|
|
21
23
|
}
|
|
22
24
|
/**
|
|
23
|
-
*
|
|
24
|
-
*
|
|
25
|
-
|
|
26
|
-
function listened(emitter) {
|
|
27
|
-
const listeners = signal(0, /* @ts-ignore */
|
|
28
|
-
...(ngDevMode ? [{ debugName: "listeners" }] : /* istanbul ignore next */ []));
|
|
29
|
-
const subscribe = emitter.subscribe.bind(emitter);
|
|
30
|
-
emitter.subscribe = (callback) => {
|
|
31
|
-
listeners.update((count) => count + 1);
|
|
32
|
-
const subscription = subscribe(callback);
|
|
33
|
-
let stopped = false;
|
|
34
|
-
return {
|
|
35
|
-
unsubscribe: () => {
|
|
36
|
-
if (stopped)
|
|
37
|
-
return;
|
|
38
|
-
stopped = true;
|
|
39
|
-
listeners.update((count) => count - 1);
|
|
40
|
-
subscription.unsubscribe();
|
|
41
|
-
},
|
|
42
|
-
};
|
|
43
|
-
};
|
|
44
|
-
return computed(() => listeners() > 0);
|
|
45
|
-
}
|
|
46
|
-
/**
|
|
47
|
-
* One item of a menu. `(select)` fires when it is chosen, and a `[(checked)]` item toggles. An
|
|
48
|
-
* item with a `menuRole` and no `(select)` does what the OS does for that role.
|
|
25
|
+
* One item of a menu. `(select)` fires when it is chosen, and a `[(checked)]` item toggles. A
|
|
26
|
+
* one-way `[checked]` stays as the app binds it, so a menu of choices checks the one the app keeps.
|
|
27
|
+
* An item with a `menuRole` and no `(select)` does what the OS does for that role.
|
|
49
28
|
*/
|
|
50
29
|
export class MenuItem {
|
|
51
30
|
label = input('', /* @ts-ignore */
|
|
@@ -60,17 +39,22 @@ export class MenuItem {
|
|
|
60
39
|
/** A check mark. Bound two-way, it toggles as the item is chosen. */
|
|
61
40
|
checked = model(undefined, /* @ts-ignore */
|
|
62
41
|
...(ngDevMode ? [{ debugName: "checked" }] : /* istanbul ignore next */ []));
|
|
42
|
+
checkedModel = new ControlledModel(this.checked, 'checked');
|
|
63
43
|
destructive = input(false, { ...(ngDevMode ? { debugName: "destructive" } : /* istanbul ignore next */ {}), transform: booleanAttribute });
|
|
64
44
|
subtitle = input(/* @ts-ignore */
|
|
65
45
|
...(ngDevMode ? [undefined, { debugName: "subtitle" }] : /* istanbul ignore next */ []));
|
|
66
46
|
/** An SF Symbol, on Apple's OSes. */
|
|
67
47
|
sfSymbol = input(/* @ts-ignore */
|
|
68
48
|
...(ngDevMode ? [undefined, { debugName: "sfSymbol" }] : /* istanbul ignore next */ []));
|
|
69
|
-
/**
|
|
49
|
+
/**
|
|
50
|
+
* The picture: a drawable resource's name, on Android, or a `ButtonIcon` as `<native-button>`
|
|
51
|
+
* takes, `{ sfSymbol }`, `{ drawable }`, or an icon's SVG markup, `{ svg }`, in a macOS menu and
|
|
52
|
+
* in a Linux tray icon's menu.
|
|
53
|
+
*/
|
|
70
54
|
icon = input(/* @ts-ignore */
|
|
71
55
|
...(ngDevMode ? [undefined, { debugName: "icon" }] : /* istanbul ignore next */ []));
|
|
72
56
|
select = output();
|
|
73
|
-
handled =
|
|
57
|
+
handled = outputListened(this.select);
|
|
74
58
|
constructor() {
|
|
75
59
|
registerIn(computed(() => {
|
|
76
60
|
const checked = this.checked();
|
|
@@ -85,23 +69,25 @@ export class MenuItem {
|
|
|
85
69
|
...(checked !== undefined && { checked }),
|
|
86
70
|
...(this.destructive() && { destructive: true }),
|
|
87
71
|
...(this.subtitle() && { subtitle: this.subtitle() }),
|
|
88
|
-
...(this.sfSymbol()
|
|
89
|
-
...(this.icon() && { icon: this.icon() }),
|
|
72
|
+
...iconFields(this.sfSymbol(), this.icon(), 'menu-item', true),
|
|
90
73
|
...(own && { select: this.choose }),
|
|
91
74
|
};
|
|
92
75
|
}), 'menu-item');
|
|
93
76
|
}
|
|
77
|
+
ngOnChanges(changes) {
|
|
78
|
+
this.checkedModel.noteChanges(changes);
|
|
79
|
+
}
|
|
94
80
|
/** One handler for the item's life: the id a host reports a choice by. See `menuActionId`. */
|
|
95
81
|
choose = () => {
|
|
96
82
|
if (this.disabled())
|
|
97
83
|
return;
|
|
98
84
|
const checked = this.checked();
|
|
99
85
|
if (checked !== undefined)
|
|
100
|
-
this.
|
|
86
|
+
this.checkedModel.propose(!checked);
|
|
101
87
|
this.select.emit();
|
|
102
88
|
};
|
|
103
89
|
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.2.0", ngImport: i0, type: MenuItem, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
104
|
-
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.1.0", version: "22.2.0", type: MenuItem, isStandalone: true, selector: "menu-item", inputs: { label: { classPropertyName: "label", publicName: "label", isSignal: true, isRequired: false, transformFunction: null }, menuRole: { classPropertyName: "menuRole", publicName: "menuRole", isSignal: true, isRequired: false, transformFunction: null }, shortcut: { classPropertyName: "shortcut", publicName: "shortcut", isSignal: true, isRequired: false, transformFunction: null }, disabled: { classPropertyName: "disabled", publicName: "disabled", isSignal: true, isRequired: false, transformFunction: null }, checked: { classPropertyName: "checked", publicName: "checked", isSignal: true, isRequired: false, transformFunction: null }, destructive: { classPropertyName: "destructive", publicName: "destructive", isSignal: true, isRequired: false, transformFunction: null }, subtitle: { classPropertyName: "subtitle", publicName: "subtitle", isSignal: true, isRequired: false, transformFunction: null }, sfSymbol: { classPropertyName: "sfSymbol", publicName: "sfSymbol", isSignal: true, isRequired: false, transformFunction: null }, icon: { classPropertyName: "icon", publicName: "icon", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { checked: "checkedChange", select: "select" }, host: { properties: { "style.display": "\"none\"" } }, ngImport: i0, template: '', isInline: true });
|
|
90
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.1.0", version: "22.2.0", type: MenuItem, isStandalone: true, selector: "menu-item", inputs: { label: { classPropertyName: "label", publicName: "label", isSignal: true, isRequired: false, transformFunction: null }, menuRole: { classPropertyName: "menuRole", publicName: "menuRole", isSignal: true, isRequired: false, transformFunction: null }, shortcut: { classPropertyName: "shortcut", publicName: "shortcut", isSignal: true, isRequired: false, transformFunction: null }, disabled: { classPropertyName: "disabled", publicName: "disabled", isSignal: true, isRequired: false, transformFunction: null }, checked: { classPropertyName: "checked", publicName: "checked", isSignal: true, isRequired: false, transformFunction: null }, destructive: { classPropertyName: "destructive", publicName: "destructive", isSignal: true, isRequired: false, transformFunction: null }, subtitle: { classPropertyName: "subtitle", publicName: "subtitle", isSignal: true, isRequired: false, transformFunction: null }, sfSymbol: { classPropertyName: "sfSymbol", publicName: "sfSymbol", isSignal: true, isRequired: false, transformFunction: null }, icon: { classPropertyName: "icon", publicName: "icon", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { checked: "checkedChange", select: "select" }, host: { properties: { "style.display": "\"none\"" } }, usesOnChanges: true, ngImport: i0, template: '', isInline: true });
|
|
105
91
|
}
|
|
106
92
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.2.0", ngImport: i0, type: MenuItem, decorators: [{
|
|
107
93
|
type: Component,
|
|
@@ -140,6 +126,7 @@ export class MenuGroup {
|
|
|
140
126
|
inline = input(false, { ...(ngDevMode ? { debugName: "inline" } : /* istanbul ignore next */ {}), transform: booleanAttribute });
|
|
141
127
|
sfSymbol = input(/* @ts-ignore */
|
|
142
128
|
...(ngDevMode ? [undefined, { debugName: "sfSymbol" }] : /* istanbul ignore next */ []));
|
|
129
|
+
/** A drawable's name, or a `ButtonIcon`, as on `<menu-item>`. */
|
|
143
130
|
icon = input(/* @ts-ignore */
|
|
144
131
|
...(ngDevMode ? [undefined, { debugName: "icon" }] : /* istanbul ignore next */ []));
|
|
145
132
|
destructive = input(false, { ...(ngDevMode ? { debugName: "destructive" } : /* istanbul ignore next */ {}), transform: booleanAttribute });
|
|
@@ -150,8 +137,7 @@ export class MenuGroup {
|
|
|
150
137
|
items: this.own.entries(),
|
|
151
138
|
...(this.menuRole() && { group: this.menuRole() }),
|
|
152
139
|
...(this.inline() && { inline: true }),
|
|
153
|
-
...(this.sfSymbol()
|
|
154
|
-
...(this.icon() && { icon: this.icon() }),
|
|
140
|
+
...iconFields(this.sfSymbol(), this.icon(), 'menu-group', true),
|
|
155
141
|
...(this.destructive() && { destructive: true }),
|
|
156
142
|
})), 'menu-group');
|
|
157
143
|
}
|
package/dist/menu.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-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E,CAAC;uGAJU,OAAO;2FAAP,OAAO,8GAFP,CAAC,EAAE,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,oBAAoB,EAAE,CAAC,0BAF5D,gBAAgB;;2FAIf,OAAO;kBANnB,SAAS;mBAAC;oBACT,QAAQ,EAAE,UAAU;oBACpB,QAAQ,EAAE,gBAAgB;oBAC1B,IAAI,EAAE,EAAE,iBAAiB,EAAE,QAAQ,EAAE;oBACrC,SAAS,EAAE,CAAC,EAAE,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,oBAAoB,EAAE,CAAC;iBACvE","sourcesContent":["/**\n * Menus written as elements: `<menu-bar>`, `<menu-group>`, `<menu-item>` and `<menu-separator>`.\n * They draw nothing themselves. Each item registers itself with the menu it is written in, through\n * `MENU_MODEL`, and the menu's owner draws it: `Menus` sends a `<menu-bar>` to the host, and a\n * `[contextMenu]` or a `<native-header-item [menu]>` reads a template of items.\n */\nimport {\n Component,\n DestroyRef,\n ElementRef,\n booleanAttribute,\n computed,\n inject,\n input,\n model,\n output,\n signal,\n type OutputEmitterRef,\n type Signal,\n} from '@angular/core';\nimport {\n MENU_MODEL,\n Menus,\n menuModelInTreeOrder,\n type MenuEntry,\n type MenuGroupRole,\n type MenuRole,\n} from '@ng-native/device';\nimport type { EngineNode } from '@ng-native/fabric';\n\nexport { menuModelInTreeOrder, treeOrder } from '@ng-native/device';\n\n/** Register `entry` with the menu the element is written in, and take it out as it goes. */\nfunction registerIn(entry: Signal<MenuEntry>, element: string): void {\n const menu = inject(MENU_MODEL, { optional: true, skipSelf: true });\n if (!menu) {\n console.warn(\n `[angular-native] <${element}> is outside a menu: write it in a <menu-bar>, a ` +\n '<menu-group>, or a template given to [contextMenu] or <native-header-item [menu]>.',\n );\n return;\n }\n const node = inject(ElementRef).nativeElement as EngineNode;\n inject(DestroyRef).onDestroy(menu.register(entry, node));\n}\n\n/**\n * Count an output's listeners, so an item knows whether the app handles it: as a signal, so the\n * menu follows a listener added or removed after it was first sent.\n */\nfunction listened(emitter: OutputEmitterRef<void>): Signal<boolean> {\n const listeners = signal(0);\n const subscribe = emitter.subscribe.bind(emitter);\n emitter.subscribe = (callback) => {\n listeners.update((count) => count + 1);\n const subscription = subscribe(callback);\n let stopped = false;\n return {\n unsubscribe: () => {\n if (stopped) return;\n stopped = true;\n listeners.update((count) => count - 1);\n subscription.unsubscribe();\n },\n };\n };\n return computed(() => listeners() > 0);\n}\n\n/**\n * One item of a menu. `(select)` fires when it is chosen, and a `[(checked)]` item toggles. An\n * item with a `menuRole` and no `(select)` does what the OS does for that role.\n */\n@Component({\n selector: 'menu-item',\n template: '',\n host: { '[style.display]': '\"none\"' },\n})\nexport class MenuItem {\n readonly label = input('');\n /** What the item is for, where the OS has a standard one: it replaces that default. */\n readonly menuRole = input<MenuRole>();\n /** `mod+s`: Cmd on Apple's OSes, Ctrl on Android. */\n readonly shortcut = input<string>();\n readonly disabled = input(false, { transform: booleanAttribute });\n /** A check mark. Bound two-way, it toggles as the item is chosen. */\n readonly checked = model<boolean | undefined>(undefined);\n readonly destructive = input(false, { transform: booleanAttribute });\n readonly subtitle = input<string>();\n /** An SF Symbol, on Apple's OSes. */\n readonly sfSymbol = input<string>();\n /** A drawable resource's name, on Android. */\n readonly icon = input<string>();\n readonly select = output<void>();\n\n private readonly handled = listened(this.select);\n\n constructor() {\n registerIn(\n computed(() => {\n const checked = this.checked();\n const role = this.menuRole();\n // An item with a role and no handler is the OS's: no `select`, so the host does it.\n const own = !role || this.handled() || checked !== undefined;\n return {\n label: this.label(),\n ...(role && { menuRole: role }),\n ...(this.shortcut() && { shortcut: this.shortcut() }),\n ...(this.disabled() && { disabled: true }),\n ...(checked !== undefined && { checked }),\n ...(this.destructive() && { destructive: true }),\n ...(this.subtitle() && { subtitle: this.subtitle() }),\n ...(this.sfSymbol() && { sfSymbol: this.sfSymbol() }),\n ...(this.icon() && { icon: this.icon() }),\n ...(own && { select: this.choose }),\n };\n }),\n 'menu-item',\n );\n }\n\n /** One handler for the item's life: the id a host reports a choice by. See `menuActionId`. */\n private readonly choose = (): void => {\n if (this.disabled()) return;\n const checked = this.checked();\n if (checked !== undefined) this.checked.set(!checked);\n this.select.emit();\n };\n}\n\n/** A line between items. */\n@Component({\n selector: 'menu-separator',\n template: '',\n host: { '[style.display]': '\"none\"' },\n})\nexport class MenuSeparator {\n constructor() {\n registerIn(\n computed(() => ({ separator: true }) as const),\n 'menu-separator',\n );\n }\n}\n\n/**\n * A submenu, a section of the menu it is in (`inline`), or in a `<menu-bar>` a menu of the bar. In\n * a bar, a `menuRole` of `app`, `file`, `edit`, `view`, `window` or `help` adds its items to that\n * standard menu.\n */\n@Component({\n selector: 'menu-group',\n template: '<ng-content />',\n host: { '[style.display]': '\"none\"' },\n providers: [{ provide: MENU_MODEL, useFactory: menuModelInTreeOrder }],\n})\nexport class MenuGroup {\n readonly label = input('');\n readonly menuRole = input<MenuGroupRole>();\n readonly inline = input(false, { transform: booleanAttribute });\n readonly sfSymbol = input<string>();\n readonly icon = input<string>();\n readonly destructive = input(false, { transform: booleanAttribute });\n\n private readonly own = inject(MENU_MODEL, { self: true });\n\n constructor() {\n registerIn(\n computed(() => ({\n label: this.label(),\n items: this.own.entries(),\n ...(this.menuRole() && { group: this.menuRole() }),\n ...(this.inline() && { inline: true }),\n ...(this.sfSymbol() && { sfSymbol: this.sfSymbol() }),\n ...(this.icon() && { icon: this.icon() }),\n ...(this.destructive() && { destructive: true }),\n })),\n 'menu-group',\n );\n }\n}\n\n/**\n * The app's menus in the menu bar, merged with the menus every desktop app has: App, Edit, View,\n * Window and Help. On macOS and iPadOS it is the menu bar. On iPhone and Android nothing is drawn,\n * and the items' shortcuts work from a hardware keyboard. It can be anywhere in the app, and\n * follows what its items say for as long as it is there.\n */\n@Component({\n selector: 'menu-bar',\n template: '<ng-content />',\n host: { '[style.display]': '\"none\"' },\n providers: [{ provide: MENU_MODEL, useFactory: menuModelInTreeOrder }],\n})\nexport class MenuBar {\n constructor() {\n const own = inject(MENU_MODEL, { self: true });\n inject(DestroyRef).onDestroy(inject(Menus).addMenuBar(own.entries));\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"menu.js","sourceRoot":"","sources":["../src/menu.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,EACL,SAAS,EACT,UAAU,EACV,UAAU,EACV,gBAAgB,EAChB,QAAQ,EACR,MAAM,EACN,KAAK,EACL,KAAK,EACL,MAAM,GAIP,MAAM,eAAe,CAAC;AACvB,OAAO,EACL,UAAU,EACV,KAAK,EACL,oBAAoB,EAIpB,cAAc,GACf,MAAM,mBAAmB,CAAC;AAE3B,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAExD,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;;AAE3C,OAAO,EAAE,oBAAoB,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAEpE,4FAA4F;AAC5F,SAAS,UAAU,CAAC,KAAwB,EAAE,OAAe;IAC3D,MAAM,IAAI,GAAG,MAAM,CAAC,UAAU,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAC;IACpE,IAAI,CAAC,IAAI,EAAE,CAAC;QACV,OAAO,CAAC,IAAI,CACV,qBAAqB,OAAO,mDAAmD;YAC7E,oFAAoF,CACvF,CAAC;QACF,OAAO;IACT,CAAC;IACD,MAAM,IAAI,GAAG,MAAM,CAAC,UAAU,CAAC,CAAC,aAA2B,CAAC;IAC5D,MAAM,CAAC,UAAU,CAAC,CAAC,SAAS,CAAC,IAAI,CAAC,QAAQ,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC,CAAC;AAC3D,CAAC;AAED;;;;GAIG;AAMH,MAAM,OAAO,QAAQ;IACV,KAAK,GAAG,KAAK,CAAC,EAAE;8EAAC,CAAC;IAC3B,uFAAuF;IAC9E,QAAQ,GAAG,KAAK;4FAAY,CAAC;IACtC,qDAAqD;IAC5C,QAAQ,GAAG,KAA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U,SAAS;2FAAT,SAAS,g3BAFT,CAAC,EAAE,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,oBAAoB,EAAE,CAAC,0BAF5D,gBAAgB;;2FAIf,SAAS;kBANrB,SAAS;mBAAC;oBACT,QAAQ,EAAE,YAAY;oBACtB,QAAQ,EAAE,gBAAgB;oBAC1B,IAAI,EAAE,EAAE,iBAAiB,EAAE,QAAQ,EAAE;oBACrC,SAAS,EAAE,CAAC,EAAE,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,oBAAoB,EAAE,CAAC;iBACvE;;AA2BD;;;;;GAKG;AAOH,MAAM,OAAO,OAAO;IAClB;QACE,MAAM,GAAG,GAAG,MAAM,CAAC,UAAU,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC;QAC/C,MAAM,CAAC,UAAU,CAAC,CAAC,SAAS,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,UAAU,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC;IACtE,CAAC;uGAJU,OAAO;2FAAP,OAAO,8GAFP,CAAC,EAAE,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,oBAAoB,EAAE,CAAC,0BAF5D,gBAAgB;;2FAIf,OAAO;kBANnB,SAAS;mBAAC;oBACT,QAAQ,EAAE,UAAU;oBACpB,QAAQ,EAAE,gBAAgB;oBAC1B,IAAI,EAAE,EAAE,iBAAiB,EAAE,QAAQ,EAAE;oBACrC,SAAS,EAAE,CAAC,EAAE,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,oBAAoB,EAAE,CAAC;iBACvE","sourcesContent":["/**\n * Menus written as elements: `<menu-bar>`, `<menu-group>`, `<menu-item>` and `<menu-separator>`.\n * They draw nothing themselves. Each item registers itself with the menu it is written in, through\n * `MENU_MODEL`, and the menu's owner draws it: `Menus` sends a `<menu-bar>` to the host, and a\n * `[contextMenu]` or a `<native-header-item [menu]>` reads a template of items.\n */\nimport {\n Component,\n DestroyRef,\n ElementRef,\n booleanAttribute,\n computed,\n inject,\n input,\n model,\n output,\n type OnChanges,\n type Signal,\n type SimpleChanges,\n} from '@angular/core';\nimport {\n MENU_MODEL,\n Menus,\n menuModelInTreeOrder,\n type MenuEntry,\n type MenuGroupRole,\n type MenuRole,\n outputListened,\n} from '@ng-native/device';\nimport type { EngineNode } from '@ng-native/fabric';\nimport { ControlledModel } from './controlled-model.ts';\nimport type { ButtonIcon } from './native-button.ts';\nimport { iconFields } from './svg-icon.ts';\n\nexport { menuModelInTreeOrder, treeOrder } from '@ng-native/device';\n\n/** Register `entry` with the menu the element is written in, and take it out as it goes. */\nfunction registerIn(entry: Signal<MenuEntry>, element: string): void {\n const menu = inject(MENU_MODEL, { optional: true, skipSelf: true });\n if (!menu) {\n console.warn(\n `[angular-native] <${element}> is outside a menu: write it in a <menu-bar>, a ` +\n '<menu-group>, or a template given to [contextMenu] or <native-header-item [menu]>.',\n );\n return;\n }\n const node = inject(ElementRef).nativeElement as EngineNode;\n inject(DestroyRef).onDestroy(menu.register(entry, node));\n}\n\n/**\n * One item of a menu. `(select)` fires when it is chosen, and a `[(checked)]` item toggles. A\n * one-way `[checked]` stays as the app binds it, so a menu of choices checks the one the app keeps.\n * An item with a `menuRole` and no `(select)` does what the OS does for that role.\n */\n@Component({\n selector: 'menu-item',\n template: '',\n host: { '[style.display]': '\"none\"' },\n})\nexport class MenuItem implements OnChanges {\n readonly label = input('');\n /** What the item is for, where the OS has a standard one: it replaces that default. */\n readonly menuRole = input<MenuRole>();\n /** `mod+s`: Cmd on Apple's OSes, Ctrl on Android. */\n readonly shortcut = input<string>();\n readonly disabled = input(false, { transform: booleanAttribute });\n /** A check mark. Bound two-way, it toggles as the item is chosen. */\n readonly checked = model<boolean | undefined>(undefined);\n private readonly checkedModel = new ControlledModel(this.checked, 'checked');\n readonly destructive = input(false, { transform: booleanAttribute });\n readonly subtitle = input<string>();\n /** An SF Symbol, on Apple's OSes. */\n readonly sfSymbol = input<string>();\n /**\n * The picture: a drawable resource's name, on Android, or a `ButtonIcon` as `<native-button>`\n * takes, `{ sfSymbol }`, `{ drawable }`, or an icon's SVG markup, `{ svg }`, in a macOS menu and\n * in a Linux tray icon's menu.\n */\n readonly icon = input<string | ButtonIcon>();\n readonly select = output<void>();\n\n private readonly handled = outputListened(this.select);\n\n constructor() {\n registerIn(\n computed(() => {\n const checked = this.checked();\n const role = this.menuRole();\n // An item with a role and no handler is the OS's: no `select`, so the host does it.\n const own = !role || this.handled() || checked !== undefined;\n return {\n label: this.label(),\n ...(role && { menuRole: role }),\n ...(this.shortcut() && { shortcut: this.shortcut() }),\n ...(this.disabled() && { disabled: true }),\n ...(checked !== undefined && { checked }),\n ...(this.destructive() && { destructive: true }),\n ...(this.subtitle() && { subtitle: this.subtitle() }),\n ...iconFields(this.sfSymbol(), this.icon(), 'menu-item', true),\n ...(own && { select: this.choose }),\n };\n }),\n 'menu-item',\n );\n }\n\n ngOnChanges(changes: SimpleChanges): void {\n this.checkedModel.noteChanges(changes);\n }\n\n /** One handler for the item's life: the id a host reports a choice by. See `menuActionId`. */\n private readonly choose = (): void => {\n if (this.disabled()) return;\n const checked = this.checked();\n if (checked !== undefined) this.checkedModel.propose(!checked);\n this.select.emit();\n };\n}\n\n/** A line between items. */\n@Component({\n selector: 'menu-separator',\n template: '',\n host: { '[style.display]': '\"none\"' },\n})\nexport class MenuSeparator {\n constructor() {\n registerIn(\n computed(() => ({ separator: true }) as const),\n 'menu-separator',\n );\n }\n}\n\n/**\n * A submenu, a section of the menu it is in (`inline`), or in a `<menu-bar>` a menu of the bar. In\n * a bar, a `menuRole` of `app`, `file`, `edit`, `view`, `window` or `help` adds its items to that\n * standard menu.\n */\n@Component({\n selector: 'menu-group',\n template: '<ng-content />',\n host: { '[style.display]': '\"none\"' },\n providers: [{ provide: MENU_MODEL, useFactory: menuModelInTreeOrder }],\n})\nexport class MenuGroup {\n readonly label = input('');\n readonly menuRole = input<MenuGroupRole>();\n readonly inline = input(false, { transform: booleanAttribute });\n readonly sfSymbol = input<string>();\n /** A drawable's name, or a `ButtonIcon`, as on `<menu-item>`. */\n readonly icon = input<string | ButtonIcon>();\n readonly destructive = input(false, { transform: booleanAttribute });\n\n private readonly own = inject(MENU_MODEL, { self: true });\n\n constructor() {\n registerIn(\n computed(() => ({\n label: this.label(),\n items: this.own.entries(),\n ...(this.menuRole() && { group: this.menuRole() }),\n ...(this.inline() && { inline: true }),\n ...iconFields(this.sfSymbol(), this.icon(), 'menu-group', true),\n ...(this.destructive() && { destructive: true }),\n })),\n 'menu-group',\n );\n }\n}\n\n/**\n * The app's menus in the menu bar, merged with the menus every desktop app has: App, Edit, View,\n * Window and Help. On macOS and iPadOS it is the menu bar. On iPhone and Android nothing is drawn,\n * and the items' shortcuts work from a hardware keyboard. It can be anywhere in the app, and\n * follows what its items say for as long as it is there.\n */\n@Component({\n selector: 'menu-bar',\n template: '<ng-content />',\n host: { '[style.display]': '\"none\"' },\n providers: [{ provide: MENU_MODEL, useFactory: menuModelInTreeOrder }],\n})\nexport class MenuBar {\n constructor() {\n const own = inject(MENU_MODEL, { self: true });\n inject(DestroyRef).onDestroy(inject(Menus).addMenuBar(own.entries));\n }\n}\n"]}
|
package/dist/modal.d.ts
CHANGED
|
@@ -3,8 +3,12 @@ import { type EngineNode } from '@ng-native/fabric';
|
|
|
3
3
|
import { ViewBase } from './view-base.ts';
|
|
4
4
|
import * as i0 from "@angular/core";
|
|
5
5
|
export type ModalPresentationStyle = 'fullScreen' | 'pageSheet' | 'formSheet' | 'overFullScreen';
|
|
6
|
-
/**
|
|
7
|
-
|
|
6
|
+
/**
|
|
7
|
+
* What `anchor` takes: an element, its `ElementRef`, or a component such as a `<pressable>`. A
|
|
8
|
+
* template reference types as `HTMLElement` for an element and as its class for a component, so
|
|
9
|
+
* both are named; at run time an element is its engine node, and a component's is its `node`.
|
|
10
|
+
*/
|
|
11
|
+
export type ModalAnchor = ElementRef | EngineNode | HTMLElement | ViewBase | {
|
|
8
12
|
readonly node: unknown;
|
|
9
13
|
} | null | undefined;
|
|
10
14
|
export type ModalOrientation = 'portrait' | 'portrait-upside-down' | 'landscape' | 'landscape-left' | 'landscape-right';
|
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,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;iGAAU,CAAC;IACz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;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"]}
|
|
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;;AAW1C,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,0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,uBAAuB,EAAE,uBAAuB;wBAChD,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/**\n * What `anchor` takes: an element, its `ElementRef`, or a component such as a `<pressable>`. A\n * template reference types as `HTMLElement` for an element and as its class for a component, so\n * both are named; at run time an element is its engine node, and a component's is its `node`.\n */\nexport type ModalAnchor =\n ElementRef | EngineNode | HTMLElement | ViewBase | { 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
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type ControlSize } from '@ng-native/device';
|
|
2
|
+
import { type ImageURISource } from './image.ts';
|
|
2
3
|
import { ControlBase } from './pressable.ts';
|
|
3
4
|
import * as i0 from "@angular/core";
|
|
4
5
|
/**
|
|
@@ -6,11 +7,18 @@ import * as i0 from "@angular/core";
|
|
|
6
7
|
* On iOS they are styles only.
|
|
7
8
|
*/
|
|
8
9
|
export type ButtonKind = 'default' | 'cancel' | 'destructive' | 'plain';
|
|
9
|
-
/**
|
|
10
|
+
/**
|
|
11
|
+
* A button's picture, as on `<native-tab>`: an SF Symbol on Apple's OSes, a drawable on Android, or
|
|
12
|
+
* an icon's SVG markup, such as an `@ng-icons` set's. macOS and Linux draw the markup themselves,
|
|
13
|
+
* and iOS and Android draw it through the renderer `SVG_ICON_RENDERER` provides. It is drawn in the
|
|
14
|
+
* button's text colour, as a symbol is, and an SF Symbol given too wins on macOS.
|
|
15
|
+
*/
|
|
10
16
|
export type ButtonIcon = {
|
|
11
17
|
readonly sfSymbol: string;
|
|
12
18
|
} | {
|
|
13
19
|
readonly drawable: string;
|
|
20
|
+
} | {
|
|
21
|
+
readonly svg: string;
|
|
14
22
|
};
|
|
15
23
|
/**
|
|
16
24
|
* A platform button, its label the text inside it:
|
|
@@ -39,6 +47,27 @@ export declare class NativeButton extends ControlBase {
|
|
|
39
47
|
readonly icon: import("@angular/core").InputSignal<ButtonIcon | undefined>;
|
|
40
48
|
protected readonly symbol: import("@angular/core").Signal<string | undefined>;
|
|
41
49
|
protected readonly drawableResource: import("@angular/core").Signal<string | undefined>;
|
|
50
|
+
private readonly svgRenderer;
|
|
51
|
+
private readonly svgHost;
|
|
52
|
+
private readonly errors;
|
|
53
|
+
protected readonly android: boolean;
|
|
54
|
+
/** Where the markup is drawn here, by the app's renderer, as an image. */
|
|
55
|
+
private readonly drawsSvg;
|
|
56
|
+
protected readonly svgIcon: import("@angular/core").Signal<string | undefined>;
|
|
57
|
+
/** The markup drawn as an image, on iOS and Android, once the renderer has answered. */
|
|
58
|
+
private readonly drawnSvg;
|
|
59
|
+
/** The image iOS draws before the title, tinted as a symbol is. */
|
|
60
|
+
protected readonly iosPicture: import("@angular/core").Signal<ImageURISource | undefined>;
|
|
61
|
+
/** Android: the image before the label, a drawable's or the drawn markup. */
|
|
62
|
+
protected readonly androidPicture: import("@angular/core").Signal<ImageURISource | undefined>;
|
|
63
|
+
/** The label's colour, which an Android icon is tinted in: black, as text is, where none is set. */
|
|
64
|
+
protected readonly tint: import("@angular/core").WritableSignal<string | undefined>;
|
|
65
|
+
constructor();
|
|
66
|
+
/**
|
|
67
|
+
* The markup drawn once by the app's renderer, where the platform draws no SVG itself. An answer
|
|
68
|
+
* for an icon the button no longer has is dropped.
|
|
69
|
+
*/
|
|
70
|
+
private drawSvg;
|
|
42
71
|
/**
|
|
43
72
|
* Where the host draws the button (AppKit, UIKit, GTK), it presses it: the responder would press
|
|
44
73
|
* it twice.
|
package/dist/native-button.js
CHANGED
|
@@ -1,7 +1,19 @@
|
|
|
1
|
-
import { Component, computed, forwardRef, input } from '@angular/core';
|
|
1
|
+
import { Component, ErrorHandler, ViewContainerRef, computed, effect, forwardRef, inject, input, signal, } from '@angular/core';
|
|
2
2
|
import { isApplePlatform, nativePlatform, registerViewName, } from '@ng-native/fabric';
|
|
3
|
+
import { SVG_ICON_RENDERER } from '@ng-native/device';
|
|
4
|
+
import { Image } from "./image.js";
|
|
3
5
|
import { ControlBase, TouchableBase } from "./pressable.js";
|
|
6
|
+
import { svgIconMarkup } from "./svg-icon.js";
|
|
4
7
|
import * as i0 from "@angular/core";
|
|
8
|
+
/** Platforms already told that a button's SVG icon has nothing to draw it. */
|
|
9
|
+
const warnedNoRenderer = new Set();
|
|
10
|
+
/**
|
|
11
|
+
* The side of an SVG icon drawn for iOS, in points. The button sizes it to its title's font, so
|
|
12
|
+
* it is drawn large enough for the largest text size to scale it down rather than up.
|
|
13
|
+
*/
|
|
14
|
+
const IOS_SVG_SIZE = 40;
|
|
15
|
+
/** The side of an Android button's icon, in points: Material's for an icon in a button. */
|
|
16
|
+
const ANDROID_ICON_SIZE = 18;
|
|
5
17
|
/**
|
|
6
18
|
* The button on Apple's OSes is the host's: NSButton on macOS and UIButton on iOS. Android has no
|
|
7
19
|
* platform button React Native draws, so there it is a view this component makes pressable.
|
|
@@ -46,6 +58,66 @@ export class NativeButton extends ControlBase {
|
|
|
46
58
|
return this.drawableName() ?? (icon && 'drawable' in icon ? icon.drawable : undefined);
|
|
47
59
|
}, /* @ts-ignore */
|
|
48
60
|
...(ngDevMode ? [{ debugName: "drawableResource" }] : /* istanbul ignore next */ []));
|
|
61
|
+
svgRenderer = inject(SVG_ICON_RENDERER);
|
|
62
|
+
svgHost = inject(ViewContainerRef);
|
|
63
|
+
errors = inject(ErrorHandler);
|
|
64
|
+
android = nativePlatform() === 'android';
|
|
65
|
+
/** Where the markup is drawn here, by the app's renderer, as an image. */
|
|
66
|
+
drawsSvg = this.android || nativePlatform() === 'ios';
|
|
67
|
+
svgIcon = computed(() => svgIconMarkup(this.icon(), 'native-button', !this.drawsSvg, 'macOS, Linux, iOS and Android'), /* @ts-ignore */
|
|
68
|
+
...(ngDevMode ? [{ debugName: "svgIcon" }] : /* istanbul ignore next */ []));
|
|
69
|
+
/** The markup drawn as an image, on iOS and Android, once the renderer has answered. */
|
|
70
|
+
drawnSvg = this.drawSvg();
|
|
71
|
+
/** The image iOS draws before the title, tinted as a symbol is. */
|
|
72
|
+
iosPicture = computed(() => this.android ? undefined : this.drawnSvg(), /* @ts-ignore */
|
|
73
|
+
...(ngDevMode ? [{ debugName: "iosPicture" }] : /* istanbul ignore next */ []));
|
|
74
|
+
/** Android: the image before the label, a drawable's or the drawn markup. */
|
|
75
|
+
androidPicture = computed(() => {
|
|
76
|
+
if (!this.android)
|
|
77
|
+
return undefined;
|
|
78
|
+
const drawable = this.drawableResource();
|
|
79
|
+
if (drawable)
|
|
80
|
+
return { uri: drawable };
|
|
81
|
+
return this.drawnSvg();
|
|
82
|
+
}, /* @ts-ignore */
|
|
83
|
+
...(ngDevMode ? [{ debugName: "androidPicture" }] : /* istanbul ignore next */ []));
|
|
84
|
+
/** The label's colour, which an Android icon is tinted in: black, as text is, where none is set. */
|
|
85
|
+
tint = signal(undefined, /* @ts-ignore */
|
|
86
|
+
...(ngDevMode ? [{ debugName: "tint" }] : /* istanbul ignore next */ []));
|
|
87
|
+
constructor() {
|
|
88
|
+
super();
|
|
89
|
+
// Only a button with an icon follows its colour: a watch is a look at every commit.
|
|
90
|
+
effect((onCleanup) => {
|
|
91
|
+
if (!this.androidPicture())
|
|
92
|
+
return;
|
|
93
|
+
const follow = (colour) => this.tint.set(colour ?? 'black');
|
|
94
|
+
follow(this.engine.colour(this.node));
|
|
95
|
+
onCleanup(this.engine.watchColour(this.node, follow));
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* The markup drawn once by the app's renderer, where the platform draws no SVG itself. An answer
|
|
100
|
+
* for an icon the button no longer has is dropped.
|
|
101
|
+
*/
|
|
102
|
+
drawSvg() {
|
|
103
|
+
const drawn = signal(undefined, /* @ts-ignore */
|
|
104
|
+
...(ngDevMode ? [{ debugName: "drawn" }] : /* istanbul ignore next */ []));
|
|
105
|
+
if (!this.drawsSvg)
|
|
106
|
+
return drawn;
|
|
107
|
+
effect((onCleanup) => {
|
|
108
|
+
const markup = this.svgIcon();
|
|
109
|
+
drawn.set(undefined);
|
|
110
|
+
if (!markup)
|
|
111
|
+
return;
|
|
112
|
+
if (!this.svgRenderer)
|
|
113
|
+
return warnNoRenderer();
|
|
114
|
+
let current = true;
|
|
115
|
+
onCleanup(() => (current = false));
|
|
116
|
+
const size = this.android ? ANDROID_ICON_SIZE : IOS_SVG_SIZE;
|
|
117
|
+
this.svgRenderer.render(markup, size, this.svgHost).then((source) => current && drawn.set(source ?? undefined), (error) => this.errors.handleError(error));
|
|
118
|
+
});
|
|
119
|
+
return drawn;
|
|
120
|
+
}
|
|
49
121
|
/**
|
|
50
122
|
* Where the host draws the button (AppKit, UIKit, GTK), it presses it: the responder would press
|
|
51
123
|
* it twice.
|
|
@@ -81,22 +153,48 @@ export class NativeButton extends ControlBase {
|
|
|
81
153
|
super.ngOnDestroy();
|
|
82
154
|
this.stopPress?.();
|
|
83
155
|
}
|
|
84
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.2.0", ngImport: i0, type: NativeButton, deps:
|
|
85
|
-
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.
|
|
156
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.2.0", ngImport: i0, type: NativeButton, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
157
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.2.0", type: NativeButton, isStandalone: true, selector: "native-button", inputs: { kind: { classPropertyName: "kind", publicName: "kind", isSignal: true, isRequired: false, transformFunction: null }, controlSize: { classPropertyName: "controlSize", publicName: "controlSize", isSignal: true, isRequired: false, transformFunction: null }, sfSymbol: { classPropertyName: "sfSymbol", publicName: "sfSymbol", isSignal: true, isRequired: false, transformFunction: null }, drawableName: { classPropertyName: "drawableName", publicName: "drawable", isSignal: true, isRequired: false, transformFunction: null }, icon: { classPropertyName: "icon", publicName: "icon", isSignal: true, isRequired: false, transformFunction: null } }, host: { properties: { "kind": "kind()", "controlSize": "controlSize()", "sfSymbol": "symbol()", "drawable": "android ? undefined : drawableResource()", "svgIcon": "svgIcon()", "iconImage": "iosPicture()?.uri", "style.flexDirection": "androidPicture() ? \"row\" : undefined", "style.alignItems": "androidPicture() ? \"center\" : undefined", "style.gap": "androidPicture() ? \"8px\" : undefined", "enabled": "!pressDisabled()" } }, providers: [{ provide: TouchableBase, useExisting: forwardRef(() => NativeButton) }], usesInheritance: true, ngImport: i0, template: `
|
|
158
|
+
@if (androidPicture(); as source) {
|
|
159
|
+
<image [source]="source" [tintColor]="tint()" style="width: 18px; height: 18px" />
|
|
160
|
+
}
|
|
161
|
+
<ng-content />
|
|
162
|
+
`, isInline: true, dependencies: [{ kind: "directive", type: Image, selector: "image", inputs: ["source", "src", "srcSet", "defaultSource", "loadingIndicatorSource", "resizeMode", "resizeMethod", "resizeMultiplier", "blurRadius", "capInsets", "tintColor", "fadeDuration", "progressiveRenderingEnabled", "alt", "crossOrigin", "referrerPolicy"] }] });
|
|
86
163
|
}
|
|
87
164
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.2.0", ngImport: i0, type: NativeButton, decorators: [{
|
|
88
165
|
type: Component,
|
|
89
166
|
args: [{
|
|
90
167
|
selector: 'native-button',
|
|
91
|
-
|
|
168
|
+
imports: [Image],
|
|
169
|
+
template: `
|
|
170
|
+
@if (androidPicture(); as source) {
|
|
171
|
+
<image [source]="source" [tintColor]="tint()" style="width: 18px; height: 18px" />
|
|
172
|
+
}
|
|
173
|
+
<ng-content />
|
|
174
|
+
`,
|
|
92
175
|
providers: [{ provide: TouchableBase, useExisting: forwardRef(() => NativeButton) }],
|
|
93
176
|
host: {
|
|
94
177
|
'[kind]': 'kind()',
|
|
95
178
|
'[controlSize]': 'controlSize()',
|
|
96
179
|
'[sfSymbol]': 'symbol()',
|
|
97
|
-
'[drawable]': 'drawableResource()',
|
|
180
|
+
'[drawable]': 'android ? undefined : drawableResource()',
|
|
181
|
+
'[svgIcon]': 'svgIcon()',
|
|
182
|
+
'[iconImage]': 'iosPicture()?.uri',
|
|
183
|
+
'[style.flexDirection]': 'androidPicture() ? "row" : undefined',
|
|
184
|
+
'[style.alignItems]': 'androidPicture() ? "center" : undefined',
|
|
185
|
+
'[style.gap]': 'androidPicture() ? "8px" : undefined',
|
|
98
186
|
'[enabled]': '!pressDisabled()',
|
|
99
187
|
},
|
|
100
188
|
}]
|
|
101
|
-
}], propDecorators: { kind: [{ type: i0.Input, args: [{ isSignal: true, alias: "kind", required: false }] }], controlSize: [{ type: i0.Input, args: [{ isSignal: true, alias: "controlSize", required: false }] }], sfSymbol: [{ type: i0.Input, args: [{ isSignal: true, alias: "sfSymbol", required: false }] }], drawableName: [{ type: i0.Input, args: [{ isSignal: true, alias: "drawable", required: false }] }], icon: [{ type: i0.Input, args: [{ isSignal: true, alias: "icon", required: false }] }] } });
|
|
189
|
+
}], ctorParameters: () => [], propDecorators: { kind: [{ type: i0.Input, args: [{ isSignal: true, alias: "kind", required: false }] }], controlSize: [{ type: i0.Input, args: [{ isSignal: true, alias: "controlSize", required: false }] }], sfSymbol: [{ type: i0.Input, args: [{ isSignal: true, alias: "sfSymbol", required: false }] }], drawableName: [{ type: i0.Input, args: [{ isSignal: true, alias: "drawable", required: false }] }], icon: [{ type: i0.Input, args: [{ isSignal: true, alias: "icon", required: false }] }] } });
|
|
190
|
+
/** Says once, in development, that a button's SVG icon has nothing to draw it, so it shows none. */
|
|
191
|
+
function warnNoRenderer() {
|
|
192
|
+
const os = nativePlatform();
|
|
193
|
+
if ((typeof ngDevMode !== 'undefined' && !ngDevMode) || warnedNoRenderer.has(os))
|
|
194
|
+
return;
|
|
195
|
+
warnedNoRenderer.add(os);
|
|
196
|
+
console.warn(`[angular-native] <native-button> has an SVG icon and nothing to draw it on ${os}, so it ` +
|
|
197
|
+
`shows none. Add withSvgIcons(SvgImages) to provideNativeRouter (withSvgIcons from ` +
|
|
198
|
+
`@ng-native/router, SvgImages from @ng-native/icons), or provide SVG_ICON_RENDERER.`);
|
|
199
|
+
}
|
|
102
200
|
//# sourceMappingURL=native-button.js.map
|