@ng-native/expo 0.5.0 → 0.7.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.
@@ -1,5 +1,32 @@
1
+ /**
2
+ * Typed components for the `@expo/ui` views an app reaches for most, named and shaped as SwiftUI's.
3
+ *
4
+ * `EXPO_UI_VIEWS` makes every view reachable by name, and a name is all the renderer needs. What a
5
+ * name cannot give is a type: under strict templates an unknown element is an error, and so is
6
+ * each prop on it. These are the same elements, claimed by a component whose inputs carry the
7
+ * props' types and whose host bindings pass each one straight to the node, so nothing changes at
8
+ * runtime. An unset input stays `undefined` and never reaches native.
9
+ *
10
+ * Events are declared as outputs so that `$event` is typed. SwiftUI's events are never emitted:
11
+ * Angular binds a template's `(dateChange)` to the output *and* to the element, and it is the
12
+ * element's own event that arrives, once. Emitting from a host listener as well would deliver it
13
+ * twice; a host listener of the same name as the output listens to the output itself and recurses.
14
+ * So subscribe in a template, not to the output in code.
15
+ *
16
+ * Where Compose names a prop or an event differently, a component sends Android its own names and
17
+ * emits the output from a host listener for Compose's event, which SwiftUI never sends. Only a few
18
+ * do: the toggle, slider, button, progress, stacks and slot, and the date picker.
19
+ *
20
+ * Only the views and props an app has needed are here; the rest stay names, as before. Add a view
21
+ * when a template wants it typed, from `@expo/ui`'s own props for it.
22
+ *
23
+ * Still register the names with `registerExpoUiViews`: the component types the element, the
24
+ * registration is what makes it commit as the SwiftUI or Compose view.
25
+ */
26
+ import { InjectionToken, type Signal } from '@angular/core';
1
27
  import type { NativeState } from './native-state.ts';
2
28
  import { type NativeSyntheticEvent } from '@ng-native/fabric';
29
+ import { type UiBottomSheetPresentedEvent } from './ui-bottom-sheet-view.ts';
3
30
  import * as i0 from "@angular/core";
4
31
  /** One SwiftUI modifier, as `@expo/ui`'s modifier functions build them: `{ $type: 'frame', ... }`. */
5
32
  export interface UiModifier {
@@ -19,8 +46,8 @@ export declare class UiHost {
19
46
  readonly vertical?: boolean;
20
47
  readonly horizontal?: boolean;
21
48
  } | undefined>;
22
- protected readonly matchVertical: import("@angular/core").Signal<boolean | undefined>;
23
- protected readonly matchHorizontal: import("@angular/core").Signal<boolean | undefined>;
49
+ protected readonly matchVertical: Signal<boolean | undefined>;
50
+ protected readonly matchHorizontal: Signal<boolean | undefined>;
24
51
  readonly ignoreSafeArea: import("@angular/core").InputSignal<"all" | "keyboard" | "container" | undefined>;
25
52
  readonly useViewportSizeMeasurement: import("@angular/core").InputSignalWithTransform<boolean | undefined, unknown>;
26
53
  static ɵfac: i0.ɵɵFactoryDeclaration<UiHost, never>;
@@ -76,7 +103,8 @@ export declare class UiContextMenu {
76
103
  }
77
104
  /**
78
105
  * A SwiftUI `Button`, as a menu item or on its own, or Compose's on Android, which draws `label` as
79
- * text inside it. `systemImage` and `role` are SwiftUI's alone.
106
+ * text inside it. `systemImage` and `role` are SwiftUI's alone. A `close` button with no label and
107
+ * no content is the system's own close button, from iOS 26.
80
108
  */
81
109
  export declare class UiButton {
82
110
  protected readonly nativeView: true;
@@ -84,7 +112,7 @@ export declare class UiButton {
84
112
  readonly label: import("@angular/core").InputSignal<string | undefined>;
85
113
  /** An SF Symbol name. */
86
114
  readonly systemImage: import("@angular/core").InputSignal<string | undefined>;
87
- readonly role: import("@angular/core").InputSignal<"default" | "cancel" | "destructive" | undefined>;
115
+ readonly role: import("@angular/core").InputSignal<"default" | "cancel" | "destructive" | "close" | undefined>;
88
116
  /**
89
117
  * In a home-screen widget's layout, what a tap on it records for the app: see
90
118
  * `@ng-native/expo/widget`.
@@ -157,9 +185,9 @@ export declare class UiSlider {
157
185
  /** A whole number of steps, which is all Compose can draw. */
158
186
  private readonly wholeSteps;
159
187
  /** SwiftUI takes a step size, and draws 0 to 1 unless it has both ends. */
160
- protected readonly stepSize: import("@angular/core").Signal<number | undefined>;
188
+ protected readonly stepSize: Signal<number | undefined>;
161
189
  /** Compose takes the number of points between the ends. */
162
- protected readonly stepsBetween: import("@angular/core").Signal<number | undefined>;
190
+ protected readonly stepsBetween: Signal<number | undefined>;
163
191
  static ɵfac: i0.ɵɵFactoryDeclaration<UiSlider, never>;
164
192
  static ɵcmp: i0.ɵɵComponentDeclaration<UiSlider, "ui-slider", never, { "value": { "alias": "value"; "required": false; "isSignal": true; }; "min": { "alias": "min"; "required": false; "isSignal": true; }; "max": { "alias": "max"; "required": false; "isSignal": true; }; "steps": { "alias": "steps"; "required": false; "isSignal": true; }; "modifiers": { "alias": "modifiers"; "required": false; "isSignal": true; }; }, { "valueChanged": "valueChanged"; }, never, never, true, never>;
165
193
  }
@@ -240,9 +268,9 @@ export declare class UiDatePicker {
240
268
  readonly touch: import("@angular/core").OutputEmitterRef<void>;
241
269
  readonly dateChange: import("@angular/core").OutputEmitterRef<UiDateChangeEvent>;
242
270
  private readonly android;
243
- protected readonly resolvedSelection: import("@angular/core").Signal<string | undefined>;
244
- protected readonly initialDate: import("@angular/core").Signal<number | null | undefined>;
245
- protected readonly resolvedModifiers: import("@angular/core").Signal<readonly UiModifier[] | undefined>;
271
+ protected readonly resolvedSelection: Signal<string | undefined>;
272
+ protected readonly initialDate: Signal<number | null | undefined>;
273
+ protected readonly resolvedModifiers: Signal<readonly UiModifier[] | undefined>;
246
274
  /**
247
275
  * SwiftUI's picker cannot be empty: it shows today, and reports that as a change the moment it
248
276
  * appears. Taken as the user's choice, an empty date field would fill itself in, pass
@@ -283,8 +311,8 @@ export declare class UiPicker {
283
311
  readonly selection: string | number;
284
312
  }>>;
285
313
  /** Each option's `tag`, one array per value, so a pass hands native the same objects. */
286
- protected readonly tags: import("@angular/core").Signal<Map<string | number, readonly UiModifier[]>>;
287
- protected readonly resolvedModifiers: import("@angular/core").Signal<readonly UiModifier[] | undefined>;
314
+ protected readonly tags: Signal<Map<string | number, readonly UiModifier[]>>;
315
+ protected readonly resolvedModifiers: Signal<readonly UiModifier[] | undefined>;
288
316
  constructor();
289
317
  static ɵfac: i0.ɵɵFactoryDeclaration<UiPicker, never>;
290
318
  static ɵcmp: i0.ɵɵComponentDeclaration<UiPicker, "ui-picker", never, { "label": { "alias": "label"; "required": false; "isSignal": true; }; "systemImage": { "alias": "systemImage"; "required": false; "isSignal": true; }; "options": { "alias": "options"; "required": false; "isSignal": true; }; "pickerStyle": { "alias": "pickerStyle"; "required": false; "isSignal": true; }; "modifiers": { "alias": "modifiers"; "required": false; "isSignal": true; }; "value": { "alias": "value"; "required": false; "isSignal": true; }; "disabled": { "alias": "disabled"; "required": false; "isSignal": true; }; }, { "value": "valueChange"; "touch": "touch"; "selectionChange": "selectionChange"; }, never, ["*"], true, never>;
@@ -604,4 +632,220 @@ export declare class UiSection {
604
632
  static ɵfac: i0.ɵɵFactoryDeclaration<UiSection, never>;
605
633
  static ɵcmp: i0.ɵɵComponentDeclaration<UiSection, "ui-section", never, { "title": { "alias": "title"; "required": false; "isSignal": true; }; "modifiers": { "alias": "modifiers"; "required": false; "isSignal": true; }; }, {}, never, ["*"], true, never>;
606
634
  }
635
+ /**
636
+ * A SwiftUI `Group`, iOS only: its children as they are, with no layout of its own. What it is for
637
+ * is `modifiers` that belong to several views at once, or to content that takes none itself, as a
638
+ * sheet's presentation modifiers go on a group around a `ui-view-host`.
639
+ */
640
+ export declare class UiGroup {
641
+ protected readonly nativeView: true;
642
+ readonly modifiers: import("@angular/core").InputSignal<readonly UiModifier[] | undefined>;
643
+ static ɵfac: i0.ɵɵFactoryDeclaration<UiGroup, never>;
644
+ static ɵcmp: i0.ɵɵComponentDeclaration<UiGroup, "ui-group", never, { "modifiers": { "alias": "modifiers"; "required": false; "isSignal": true; }; }, {}, never, ["*"], true, never>;
645
+ }
646
+ /**
647
+ * A SwiftUI `NavigationStack`, iOS only: the bar a `ui-toolbar` inside it puts its items in, and
648
+ * that a `navigationTitle` modifier on its content titles.
649
+ */
650
+ export declare class UiNavigationStack {
651
+ protected readonly nativeView: true;
652
+ readonly modifiers: import("@angular/core").InputSignal<readonly UiModifier[] | undefined>;
653
+ static ɵfac: i0.ɵɵFactoryDeclaration<UiNavigationStack, never>;
654
+ static ɵcmp: i0.ɵɵComponentDeclaration<UiNavigationStack, "ui-navigation-stack", never, { "modifiers": { "alias": "modifiers"; "required": false; "isSignal": true; }; }, {}, never, ["*"], true, never>;
655
+ }
656
+ /**
657
+ * SwiftUI's `toolbar`, iOS only. Its children are the view the toolbar belongs to, and its items go
658
+ * in `<ui-slot name="content">`, each a `ui-toolbar-item`. It shows in the bar of the
659
+ * `ui-navigation-stack` around it.
660
+ */
661
+ export declare class UiToolbar {
662
+ protected readonly nativeView: true;
663
+ readonly modifiers: import("@angular/core").InputSignal<readonly UiModifier[] | undefined>;
664
+ static ɵfac: i0.ɵɵFactoryDeclaration<UiToolbar, never>;
665
+ static ɵcmp: i0.ɵɵComponentDeclaration<UiToolbar, "ui-toolbar", never, { "modifiers": { "alias": "modifiers"; "required": false; "isSignal": true; }; }, {}, never, ["*"], true, never>;
666
+ }
667
+ /** Where a `ui-toolbar-item` sits, as SwiftUI's `ToolbarItemPlacement` names them. */
668
+ export type UiToolbarItemPlacement = 'automatic' | 'principal' | 'navigation' | 'primaryAction' | 'secondaryAction' | 'status' | 'confirmationAction' | 'cancellationAction' | 'destructiveAction' | 'keyboard' | 'topBarLeading' | 'topBarTrailing' | 'topBarPinnedTrailing' | 'largeTitle' | 'bottomBar';
669
+ /**
670
+ * One item of a `ui-toolbar`, SwiftUI's `ToolbarItem`: a `ui-button`, or a `ui-text` as a title
671
+ * with `placement="principal"`. Unplaced, SwiftUI places it. A placement the OS does not have is
672
+ * read as `automatic`.
673
+ *
674
+ * Written inside a `ui-bottom-sheet` it goes in the sheet's own toolbar, which is how a sheet
675
+ * shows the system's close button.
676
+ */
677
+ export declare class UiToolbarItem {
678
+ protected readonly nativeView: true;
679
+ readonly placement: import("@angular/core").InputSignal<UiToolbarItemPlacement | undefined>;
680
+ /** How readily the item gives up its place when the bar runs out of room, from iOS 27. */
681
+ readonly visibilityPriority: import("@angular/core").InputSignal<"low" | "high" | "automatic" | undefined>;
682
+ /** What the slot tells the toolbar about itself: only what is set, so SwiftUI decides the rest. */
683
+ protected readonly extraProps: Signal<{
684
+ visibilityPriority?: "low" | "high" | "automatic" | undefined;
685
+ placement?: UiToolbarItemPlacement | undefined;
686
+ } | undefined>;
687
+ static ɵfac: i0.ɵɵFactoryDeclaration<UiToolbarItem, never>;
688
+ static ɵcmp: i0.ɵɵComponentDeclaration<UiToolbarItem, "ui-toolbar-item", never, { "placement": { "alias": "placement"; "required": false; "isSignal": true; }; "visibilityPriority": { "alias": "visibilityPriority"; "required": false; "isSignal": true; }; }, {}, never, ["*"], true, never>;
689
+ }
690
+ /**
691
+ * A height a SwiftUI sheet rests at, as `@expo/ui`'s `PresentationDetent`: about half the screen,
692
+ * all of it, a fraction of it from 0 to 1, or a height in points.
693
+ */
694
+ export type UiPresentationDetent = 'medium' | 'large' | {
695
+ readonly fraction: number;
696
+ } | {
697
+ readonly height: number;
698
+ };
699
+ /** The functions `@expo/ui` defines on Compose's sheet, called with the view's tag as `this`. */
700
+ export interface UiBottomSheetViewFunctions {
701
+ /** Slides the sheet away, answering once it has gone. */
702
+ hide?(this: {
703
+ nativeTag: number;
704
+ }): Promise<void>;
705
+ }
706
+ /**
707
+ * A sheet that slides up from the bottom of the screen, opened from any component: SwiftUI's on
708
+ * iOS, Material's on Android.
709
+ *
710
+ * ```html
711
+ * <ui-bottom-sheet [(open)]="sorting" fitToContents>
712
+ * <app-sort-options (done)="sorting.set(false)" />
713
+ * </ui-bottom-sheet>
714
+ * ```
715
+ *
716
+ * `open` presents and dismisses it, and is written back when the user dismisses it. Its content is
717
+ * what is written inside it, the app's own components, in the tree while the sheet is on screen.
718
+ *
719
+ * A `ui-toolbar-item` written inside it is not content: on iOS it goes in a toolbar of the sheet's
720
+ * own, in a bar across its top, which is where the system's close button belongs.
721
+ *
722
+ * ```html
723
+ * <ui-bottom-sheet [(open)]="sorting">
724
+ * <ui-toolbar-item placement="cancellationAction">
725
+ * <ui-button role="close" (buttonPress)="sorting.set(false)" />
726
+ * </ui-toolbar-item>
727
+ * <app-sort-options />
728
+ * </ui-bottom-sheet>
729
+ * ```
730
+ *
731
+ * Compose's sheet has no toolbar, so Android draws no item. Nor does an iOS build whose `@expo/ui`
732
+ * is older than 57.0.20, which Expo Go's can be: it warns, and shows the sheet without one.
733
+ *
734
+ * The two platforms drive a sheet differently, and this is where that difference ends. SwiftUI's
735
+ * stays in the tree and is presented by `isPresented`, reporting `isPresentedChange` and
736
+ * `dismiss`. Compose's shows for as long as it is in the tree, and reports `dismissRequest`.
737
+ *
738
+ * Unlike the other components here, the element this is mounted on is a plain view, which takes
739
+ * no room and needs no `ui-host` around it. The sheet is inside it, wrapped as `@expo/ui`'s own
740
+ * React component wraps one: a `ui-host`, the sheet, on iOS a `ui-group` that carries the
741
+ * presentation modifiers, and a `ui-view-host` holding the one view the content goes in. With
742
+ * toolbar items, the view host is in a `ui-toolbar` in a `ui-navigation-stack`, under the group.
743
+ */
744
+ export declare class UiBottomSheet {
745
+ /**
746
+ * The functions of Compose's sheet, none of them on iOS, or null where `@expo/ui` is not in the
747
+ * build and there is no sheet. Overridden in a test to hide a sheet without a device.
748
+ */
749
+ static readonly SOURCE: InjectionToken<UiBottomSheetViewFunctions | null>;
750
+ /**
751
+ * Whether the build has SwiftUI's toolbar. `@expo/ui` has had it since 57.0.20, and Expo Go has
752
+ * the version its SDK shipped with. A SwiftUI view under one the build lacks is a crash, so a
753
+ * sheet there leaves its toolbar out. Overridden in a test.
754
+ */
755
+ static readonly TOOLBAR: InjectionToken<boolean>;
756
+ private readonly functions;
757
+ private readonly toolbarInBuild;
758
+ private readonly engine;
759
+ private readonly injector;
760
+ private readonly sheet;
761
+ /** Whether the sheet is on screen. Written back as false when the user dismisses it. */
762
+ readonly open: import("@angular/core").ModelSignal<boolean>;
763
+ /**
764
+ * The sheet is as tall as its content. Without it the sheet rests at half the screen's height
765
+ * and drags up to all of it. Read as the sheet opens. A sheet with a toolbar on iOS is not
766
+ * sized to its content: it rests at its `detents`, or at half and full height.
767
+ */
768
+ readonly fitToContents: import("@angular/core").InputSignalWithTransform<boolean, unknown>;
769
+ /**
770
+ * The heights the sheet rests at, iOS only: SwiftUI's `presentationDetents`. Compose's sheet has
771
+ * a half and a full height and no others, so Android takes no notice of this. On iOS a sheet
772
+ * given detents rests at them rather than at the height of its content, whatever `fitToContents`
773
+ * says, as `@expo/ui`'s own sheets do. None, or an empty list, is the sheet without them.
774
+ */
775
+ readonly detents: import("@angular/core").InputSignal<readonly UiPresentationDetent[] | undefined>;
776
+ /** Whether the grabber shows at the top of the sheet. */
777
+ readonly showDragIndicator: import("@angular/core").InputSignalWithTransform<boolean, unknown>;
778
+ /**
779
+ * The sheet has finished closing, whether the user dismissed it or `open` was set false: the
780
+ * moment another sheet or a dialog can be presented.
781
+ */
782
+ readonly dismissed: import("@angular/core").OutputEmitterRef<void>;
783
+ /** The toolbar items written inside the sheet, which give it a bar to hold them. */
784
+ private readonly toolbarItems;
785
+ /** Whether the sheet has a toolbar: it has items for one, and the build has the views. */
786
+ protected readonly toolbar: Signal<boolean>;
787
+ /** SwiftUI's sheet stays in the tree; anywhere else it is there while it shows. */
788
+ protected readonly swiftUI: boolean;
789
+ protected readonly width: Signal<number | undefined>;
790
+ /**
791
+ * Whether the content is in the tree: from when the sheet opens until it has gone, which is
792
+ * after `open` turns false, so that it slides away with its content still in it.
793
+ */
794
+ protected readonly mounted: import("@angular/core").WritableSignal<boolean>;
795
+ /**
796
+ * Whether the sheet is sized to its content, as it opened: a view host takes its sizing once,
797
+ * as it mounts. SwiftUI's sheet is not where it has detents to rest at, nor where it has a
798
+ * toolbar: a navigation stack fills what it is given, and the bar is no part of the content.
799
+ * A toolbar that comes or goes while the sheet is open is followed, since the view host is made
800
+ * again around it.
801
+ */
802
+ protected readonly fits: Signal<boolean>;
803
+ /**
804
+ * SwiftUI reads how a sheet is presented from modifiers on its content, not from props. The
805
+ * detents of a sheet not sized to its content are followed while it is open.
806
+ */
807
+ protected readonly presentation: Signal<readonly UiModifier[]>;
808
+ /**
809
+ * The one view a view host holds. Sized to its content it needs a width of its own, the
810
+ * window's; otherwise it fills the height the sheet gives it.
811
+ */
812
+ protected readonly body: Signal<{
813
+ width: number | undefined;
814
+ flexGrow?: undefined;
815
+ height?: undefined;
816
+ } | {
817
+ flexGrow: number;
818
+ height: number;
819
+ width?: undefined;
820
+ }>;
821
+ /** Whether `open` has turned false on a sheet that has yet to go. */
822
+ private closing;
823
+ /** Whether Compose is sliding the sheet away. */
824
+ private hiding;
825
+ constructor();
826
+ protected presented(event: UiBottomSheetPresentedEvent): void;
827
+ protected dismissRequested(event: NativeSyntheticEvent): void;
828
+ /**
829
+ * SwiftUI has finished dismissing the sheet. After a swipe it says so before it reports that the
830
+ * sheet is no longer presented, so a sheet that has gone while `open`, and was not closing, is
831
+ * one the user dismissed.
832
+ */
833
+ protected gone(event: NativeSyntheticEvent): void;
834
+ /**
835
+ * Whether an event is this sheet's own, which it then stops. Events bubble, so a `dismiss` from
836
+ * a modal in the content arrives here too, and the sheet's own would go on to a listener around
837
+ * it.
838
+ */
839
+ private own;
840
+ /**
841
+ * `open` turned false. SwiftUI dismisses its sheet on the prop, and says when it has gone.
842
+ * Compose shows a sheet for as long as it is in the tree, so one taken out is gone at once:
843
+ * its `hide` slides it away first, as `@expo/ui`'s own component calls it before unmounting.
844
+ */
845
+ private close;
846
+ /** The sheet has gone: its content leaves the tree. */
847
+ private finish;
848
+ static ɵfac: i0.ɵɵFactoryDeclaration<UiBottomSheet, never>;
849
+ static ɵcmp: i0.ɵɵComponentDeclaration<UiBottomSheet, "ui-bottom-sheet", never, { "open": { "alias": "open"; "required": false; "isSignal": true; }; "fitToContents": { "alias": "fitToContents"; "required": false; "isSignal": true; }; "detents": { "alias": "detents"; "required": false; "isSignal": true; }; "showDragIndicator": { "alias": "showDragIndicator"; "required": false; "isSignal": true; }; }, { "open": "openChange"; "dismissed": "dismissed"; }, ["toolbarItems"], ["*", "ui-toolbar-item"], true, never>;
850
+ }
607
851
  export {};