@symbiote-native/angular 3.2.0 → 3.3.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/babel-register-composed.cjs +1 -0
- package/build/angular/components/checkbox-props.d.ts +2 -0
- package/build/angular/components/checkbox-props.js +2 -0
- package/build/angular/components/checkbox-props.js.map +1 -0
- package/build/angular/components.d.ts +1 -0
- package/build/angular/components.js.map +1 -1
- package/build/angular/descriptor-to-angular/descriptor-host.d.ts +8 -0
- package/build/angular/descriptor-to-angular/descriptor-host.js +38 -0
- package/build/angular/descriptor-to-angular/descriptor-host.js.map +1 -0
- package/build/angular/descriptor-to-angular/index.d.ts +1 -0
- package/build/angular/descriptor-to-angular/index.js +4 -0
- package/build/angular/descriptor-to-angular/index.js.map +1 -1
- package/build/angular/element-base.d.ts +153 -0
- package/build/angular/element-base.js +272 -0
- package/build/angular/element-base.js.map +1 -0
- package/build/angular/elements-controls.d.ts +165 -0
- package/build/angular/elements-controls.js +382 -0
- package/build/angular/elements-controls.js.map +1 -0
- package/build/angular/elements-layout.d.ts +122 -0
- package/build/angular/elements-layout.js +242 -0
- package/build/angular/elements-layout.js.map +1 -0
- package/build/angular/elements-press.d.ts +96 -0
- package/build/angular/elements-press.js +227 -0
- package/build/angular/elements-press.js.map +1 -0
- package/build/angular/elements.d.ts +6 -516
- package/build/angular/elements.js +8 -1091
- package/build/angular/elements.js.map +1 -1
- package/build/angular/host-instance/index.d.ts +2 -0
- package/build/angular/host-instance/index.js +4 -4
- package/build/angular/host-instance/index.js.map +1 -1
- package/build/angular/index.d.ts +5 -4
- package/build/angular/index.js +4 -3
- package/build/angular/index.js.map +1 -1
- package/build/angular/native-view-base.d.ts +10 -2
- package/build/angular/native-view-base.js +23 -2
- package/build/angular/native-view-base.js.map +1 -1
- package/build/angular/services/index.d.ts +1 -0
- package/build/angular/services/index.js +1 -0
- package/build/angular/services/index.js.map +1 -1
- package/build/angular/services/inject-event.d.ts +6 -0
- package/build/angular/services/inject-event.js +24 -0
- package/build/angular/services/inject-event.js.map +1 -0
- package/package.json +6 -6
- package/src/components/checkbox-props.ts +12 -0
- package/src/components.ts +1 -0
- package/src/descriptor-to-angular/descriptor-host.ts +27 -0
- package/src/descriptor-to-angular/index.ts +5 -0
- package/src/element-base.ts +272 -0
- package/src/elements-controls.ts +282 -0
- package/src/elements-layout.ts +141 -0
- package/src/elements-press.ts +145 -0
- package/src/elements.ts +73 -788
- package/src/host-instance/index.ts +4 -4
- package/src/index.ts +6 -1
- package/src/native-view-base.ts +37 -2
- package/src/services/index.ts +1 -0
- package/src/services/inject-event.ts +52 -0
|
@@ -0,0 +1,272 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ChangeDetectorRef,
|
|
3
|
+
Directive,
|
|
4
|
+
ElementRef,
|
|
5
|
+
ErrorHandler,
|
|
6
|
+
Input,
|
|
7
|
+
Renderer2,
|
|
8
|
+
inject,
|
|
9
|
+
} from '@angular/core';
|
|
10
|
+
import type {
|
|
11
|
+
OnChanges,
|
|
12
|
+
OnDestroy,
|
|
13
|
+
OnInit,
|
|
14
|
+
SimpleChanges,
|
|
15
|
+
} from '@angular/core';
|
|
16
|
+
import { VALUE_CHANGE_EVENT } from './renderer/value-change';
|
|
17
|
+
import {
|
|
18
|
+
registerViewFlush,
|
|
19
|
+
unregisterViewFlush,
|
|
20
|
+
} from './change-detection-flush';
|
|
21
|
+
import type { IElementProps } from './element-props';
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* The shared half of every element directive: the prop surface all tags accept, and the ONE
|
|
25
|
+
* generic forward that puts a claimed binding back on the engine node.
|
|
26
|
+
*
|
|
27
|
+
* The forward is the deciding fact of this whole route. A binding claimed by a directive input
|
|
28
|
+
* never reaches `Renderer2.setProperty` on its own — Angular writes it to the directive instance
|
|
29
|
+
* — so without this loop a bare tag commits nothing at all. It stays generic on purpose: per-prop
|
|
30
|
+
* forwarding code is a component wrapper by another name, which is what this migration removes.
|
|
31
|
+
* `renderer.setProperty` lands in the adapter's own renderer, which routes the value through the
|
|
32
|
+
* engine's `routeProp` and applies the `id` -> `nativeID` alias.
|
|
33
|
+
*/
|
|
34
|
+
@Directive()
|
|
35
|
+
export abstract class SymbioteElement implements OnChanges {
|
|
36
|
+
private readonly renderer = inject(Renderer2);
|
|
37
|
+
protected readonly host = inject(ElementRef);
|
|
38
|
+
|
|
39
|
+
// NO `ChangeDetectorRef` HERE, and its absence is the point. This class is instantiated once per
|
|
40
|
+
// ELEMENT, so injecting one cost ~1.0-2.4 us on every tag of a screen to serve the few that carry
|
|
41
|
+
// an `on*` prop — ten thousand `ViewRef`s on a thousand-row create, read by none of them
|
|
42
|
+
// (`core/engine/cpp/tests/js/angular-directive-cost.itest.ts`). `SymbioteCallbackHost` owns one and
|
|
43
|
+
// MATCHES on the callback attributes instead, registering it against the node; `markViewFor` is how
|
|
44
|
+
// the wrapper reaches it. The inputs did not move, so nothing about this file's public surface did.
|
|
45
|
+
|
|
46
|
+
// No `on*` wrapper here: `SymbioteRenderer.setProperty` handles it. Most directives are withheld
|
|
47
|
+
// from runtime matching (`./runtime-matching`), so a binding reaches the renderer through
|
|
48
|
+
// `ɵɵproperty` without passing through any directive — the renderer is reached by every path.
|
|
49
|
+
|
|
50
|
+
@Input() testID?: IElementProps['testID'];
|
|
51
|
+
@Input() nativeID?: IElementProps['nativeID'];
|
|
52
|
+
@Input() id?: IElementProps['id'];
|
|
53
|
+
@Input() accessible?: IElementProps['accessible'];
|
|
54
|
+
@Input() accessibilityLabel?: IElementProps['accessibilityLabel'];
|
|
55
|
+
@Input() accessibilityHint?: IElementProps['accessibilityHint'];
|
|
56
|
+
@Input() accessibilityRole?: IElementProps['accessibilityRole'];
|
|
57
|
+
@Input() accessibilityState?: IElementProps['accessibilityState'];
|
|
58
|
+
@Input() accessibilityValue?: IElementProps['accessibilityValue'];
|
|
59
|
+
@Input() accessibilityActions?: IElementProps['accessibilityActions'];
|
|
60
|
+
@Input() accessibilityLabelledBy?: IElementProps['accessibilityLabelledBy'];
|
|
61
|
+
@Input()
|
|
62
|
+
importantForAccessibility?: IElementProps['importantForAccessibility'];
|
|
63
|
+
@Input() accessibilityLiveRegion?: IElementProps['accessibilityLiveRegion'];
|
|
64
|
+
@Input() screenReaderFocusable?: IElementProps['screenReaderFocusable'];
|
|
65
|
+
@Input() accessibilityViewIsModal?: IElementProps['accessibilityViewIsModal'];
|
|
66
|
+
@Input()
|
|
67
|
+
accessibilityElementsHidden?: IElementProps['accessibilityElementsHidden'];
|
|
68
|
+
@Input()
|
|
69
|
+
accessibilityIgnoresInvertColors?: IElementProps['accessibilityIgnoresInvertColors'];
|
|
70
|
+
@Input() accessibilityLanguage?: IElementProps['accessibilityLanguage'];
|
|
71
|
+
@Input()
|
|
72
|
+
accessibilityRespondsToUserInteraction?: IElementProps['accessibilityRespondsToUserInteraction'];
|
|
73
|
+
@Input()
|
|
74
|
+
accessibilityShowsLargeContentViewer?: IElementProps['accessibilityShowsLargeContentViewer'];
|
|
75
|
+
@Input()
|
|
76
|
+
accessibilityLargeContentTitle?: IElementProps['accessibilityLargeContentTitle'];
|
|
77
|
+
@Input() onAccessibilityAction?: IElementProps['onAccessibilityAction'];
|
|
78
|
+
@Input() onAccessibilityTap?: IElementProps['onAccessibilityTap'];
|
|
79
|
+
@Input() onMagicTap?: IElementProps['onMagicTap'];
|
|
80
|
+
@Input() onAccessibilityEscape?: IElementProps['onAccessibilityEscape'];
|
|
81
|
+
|
|
82
|
+
// The web aliases. Native reads only `accessibility*`; the engine folds these on the way in.
|
|
83
|
+
@Input() role?: IElementProps['role'];
|
|
84
|
+
@Input() 'aria-label'?: IElementProps['aria-label'];
|
|
85
|
+
@Input() 'aria-labelledby'?: IElementProps['aria-labelledby'];
|
|
86
|
+
@Input() 'aria-live'?: IElementProps['aria-live'];
|
|
87
|
+
@Input() 'aria-hidden'?: IElementProps['aria-hidden'];
|
|
88
|
+
@Input() 'aria-busy'?: IElementProps['aria-busy'];
|
|
89
|
+
@Input() 'aria-checked'?: IElementProps['aria-checked'];
|
|
90
|
+
@Input() 'aria-disabled'?: IElementProps['aria-disabled'];
|
|
91
|
+
@Input() 'aria-expanded'?: IElementProps['aria-expanded'];
|
|
92
|
+
@Input() 'aria-selected'?: IElementProps['aria-selected'];
|
|
93
|
+
@Input() 'aria-modal'?: IElementProps['aria-modal'];
|
|
94
|
+
@Input() 'aria-valuemax'?: IElementProps['aria-valuemax'];
|
|
95
|
+
@Input() 'aria-valuemin'?: IElementProps['aria-valuemin'];
|
|
96
|
+
@Input() 'aria-valuenow'?: IElementProps['aria-valuenow'];
|
|
97
|
+
@Input() 'aria-valuetext'?: IElementProps['aria-valuetext'];
|
|
98
|
+
|
|
99
|
+
// The responder gates return a boolean, which an Angular `(event)` binding cannot carry back to
|
|
100
|
+
// the caller — so the whole family is inputs, never outputs.
|
|
101
|
+
@Input()
|
|
102
|
+
onStartShouldSetResponder?: IElementProps['onStartShouldSetResponder'];
|
|
103
|
+
@Input()
|
|
104
|
+
onStartShouldSetResponderCapture?: IElementProps['onStartShouldSetResponderCapture'];
|
|
105
|
+
@Input() onMoveShouldSetResponder?: IElementProps['onMoveShouldSetResponder'];
|
|
106
|
+
@Input()
|
|
107
|
+
onMoveShouldSetResponderCapture?: IElementProps['onMoveShouldSetResponderCapture'];
|
|
108
|
+
@Input() onResponderGrant?: IElementProps['onResponderGrant'];
|
|
109
|
+
@Input() onResponderReject?: IElementProps['onResponderReject'];
|
|
110
|
+
@Input() onResponderStart?: IElementProps['onResponderStart'];
|
|
111
|
+
@Input() onResponderMove?: IElementProps['onResponderMove'];
|
|
112
|
+
@Input() onResponderEnd?: IElementProps['onResponderEnd'];
|
|
113
|
+
@Input() onResponderRelease?: IElementProps['onResponderRelease'];
|
|
114
|
+
@Input() onResponderTerminate?: IElementProps['onResponderTerminate'];
|
|
115
|
+
@Input()
|
|
116
|
+
onResponderTerminationRequest?: IElementProps['onResponderTerminationRequest'];
|
|
117
|
+
|
|
118
|
+
@Input() pointerEvents?: IElementProps['pointerEvents'];
|
|
119
|
+
@Input() hitSlop?: IElementProps['hitSlop'];
|
|
120
|
+
@Input() focusable?: IElementProps['focusable'];
|
|
121
|
+
@Input() collapsable?: IElementProps['collapsable'];
|
|
122
|
+
@Input() removeClippedSubviews?: IElementProps['removeClippedSubviews'];
|
|
123
|
+
@Input()
|
|
124
|
+
renderToHardwareTextureAndroid?: IElementProps['renderToHardwareTextureAndroid'];
|
|
125
|
+
@Input() shouldRasterizeIOS?: IElementProps['shouldRasterizeIOS'];
|
|
126
|
+
@Input()
|
|
127
|
+
needsOffscreenAlphaCompositing?: IElementProps['needsOffscreenAlphaCompositing'];
|
|
128
|
+
// `[style]` and `[class]` are declared for the TYPE CHECK only. Withheld from run-time matching, no
|
|
129
|
+
// input claims them, so Angular's own styling engine decomposes them into `setStyle`/`addClass`
|
|
130
|
+
// exactly as on a DOM element - which is why `style` is typed as the object/string that engine can
|
|
131
|
+
// hold. An RN style ARRAY or press-state FUNCTION throws in there ("indexOf is not a function",
|
|
132
|
+
// "Unsupported styling type: function"), so it is `[styleProp]`: an ordinary property binding the
|
|
133
|
+
// renderer routes to `style` whole. A claim would cost a directive instance per element.
|
|
134
|
+
//
|
|
135
|
+
// The press-state callback rides the BASE type rather than `PressableElement` alone: a subclass
|
|
136
|
+
// cannot widen an inherited property, and only the pressables have a `pressed` to read — so on
|
|
137
|
+
// any other tag the engine resolves it at `pressed: false`.
|
|
138
|
+
@Input() style?: IElementProps['style'];
|
|
139
|
+
@Input() styleProp?: IElementProps['styleProp'];
|
|
140
|
+
|
|
141
|
+
// `ɵɵclassMap` hands over a string after joining any static `class=` prefix; `[class.foo]` and
|
|
142
|
+
// `[ngClass]` arrive as `addClass`. The renderer unions both sources (`classStringFor`).
|
|
143
|
+
@Input() class?: string;
|
|
144
|
+
|
|
145
|
+
// The flat-bag spelling of the events below. `(press)` and `[onPress]` are both supported and
|
|
146
|
+
// land in the same place; an app that already holds a handler bag binds the props.
|
|
147
|
+
@Input() onPress?: IElementProps['onPress'];
|
|
148
|
+
@Input() onPressIn?: IElementProps['onPressIn'];
|
|
149
|
+
@Input() onPressOut?: IElementProps['onPressOut'];
|
|
150
|
+
@Input() onPressMove?: IElementProps['onPressMove'];
|
|
151
|
+
@Input() onLongPress?: IElementProps['onLongPress'];
|
|
152
|
+
@Input() onLayout?: IElementProps['onLayout'];
|
|
153
|
+
@Input() onFocus?: IElementProps['onFocus'];
|
|
154
|
+
@Input() onBlur?: IElementProps['onBlur'];
|
|
155
|
+
|
|
156
|
+
ngOnChanges(changes: SimpleChanges): void {
|
|
157
|
+
for (const name of Object.keys(changes)) {
|
|
158
|
+
this.renderer.setProperty(
|
|
159
|
+
this.host.nativeElement,
|
|
160
|
+
name,
|
|
161
|
+
// Unwrapped on purpose: `SymbioteRenderer.setProperty` is where an `on*` value is wrapped
|
|
162
|
+
// now, and it is the call this line makes.
|
|
163
|
+
changes[name]?.currentValue,
|
|
164
|
+
);
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
/**
|
|
170
|
+
* The base for a tag whose app callback an engine behavior READS BACK inside the same microtask
|
|
171
|
+
* turn — `<text-input>`, `<switch>`, `<refresh-control>`. Zoneless change detection is a macrotask,
|
|
172
|
+
* so without this the behavior sees the PRE-event value and undoes the user; the full mechanism,
|
|
173
|
+
* and why this is `detectChanges()` on one view rather than `ApplicationRef.tick()`, is in
|
|
174
|
+
* `./change-detection-flush`.
|
|
175
|
+
*
|
|
176
|
+
* The directive is the only thing in the adapter that owns a `ChangeDetectorRef` for the view
|
|
177
|
+
* holding the binding, so it hands one to the renderer keyed on its own node.
|
|
178
|
+
*/
|
|
179
|
+
@Directive()
|
|
180
|
+
export abstract class ReadBackElement
|
|
181
|
+
extends SymbioteElement
|
|
182
|
+
implements OnDestroy
|
|
183
|
+
{
|
|
184
|
+
// ITS OWN, now that the base has none. Three tags reach this class, so the injection is paid where
|
|
185
|
+
// it is read instead of on every element of a screen.
|
|
186
|
+
private readonly detector = inject(ChangeDetectorRef);
|
|
187
|
+
private readonly errorHandler = inject(ErrorHandler);
|
|
188
|
+
|
|
189
|
+
constructor() {
|
|
190
|
+
super();
|
|
191
|
+
const node: unknown = this.host.nativeElement;
|
|
192
|
+
if (typeof node === 'object' && node !== null) {
|
|
193
|
+
registerViewFlush(node, () => this.flush());
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
// REPORTED, NOT RETHROWN — Angular's own contract. Every other change detection runs inside
|
|
198
|
+
// `ApplicationRef.tick()`, caught by `ErrorHandler` (`SymbioteErrorHandler`); this flush instead
|
|
199
|
+
// runs from a native event dispatch, where an uncaught throw has nowhere to go but `RCTFatal`.
|
|
200
|
+
private flush(): void {
|
|
201
|
+
try {
|
|
202
|
+
this.detector.detectChanges();
|
|
203
|
+
} catch (error: unknown) {
|
|
204
|
+
this.errorHandler.handleError(error);
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
ngOnDestroy(): void {
|
|
209
|
+
const node: unknown = this.host.nativeElement;
|
|
210
|
+
if (typeof node === 'object' && node !== null) unregisterViewFlush(node);
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
/**
|
|
215
|
+
* The `[(value)]` half of a controlled tag — `<switch>` and `<text-input>`.
|
|
216
|
+
*
|
|
217
|
+
* The one `@Output` in this file, and it is FORCED rather than chosen. `[(value)]` desugars to
|
|
218
|
+
* `[value]` + `(valueChange)`, and ngtsc requires both halves to resolve to the SAME target: a
|
|
219
|
+
* declared `value` input beside an event no directive claims is NG8007, "the property and event
|
|
220
|
+
* halves are not bound to the same target". So the sugar this adapter documents cannot work without
|
|
221
|
+
* the output existing, whatever the file header says about events in general.
|
|
222
|
+
*
|
|
223
|
+
* The bridge below is NOT what makes the binding work today, and the comment says so because the
|
|
224
|
+
* obvious reading is wrong: the file header's "an `@Output` CONSUMES the binding" holds for a
|
|
225
|
+
* COMPONENT, and an element is the other case — Angular attaches the renderer listener for the
|
|
226
|
+
* event as well, so `Renderer2.listen` still runs and the engine still hears the change. Measured
|
|
227
|
+
* under JIT by deleting this whole hook: every case in `renderer/two-way-value.test.ts` stayed
|
|
228
|
+
* green, delivery included, and exactly ONCE (nothing double-fires when both paths exist).
|
|
229
|
+
*
|
|
230
|
+
* It is kept because the measurement is JIT-only and this adapter has a recorded case of JIT and
|
|
231
|
+
* AOT resolving a binding differently (`test-harness-false-greens.md` §21). If AOT routes the event
|
|
232
|
+
* exclusively to the output, this hook is the only thing keeping `[(value)]` alive; if it routes to
|
|
233
|
+
* both, it is one extra listener on a control an app explicitly bound. Delete it once something
|
|
234
|
+
* executes the LINKED artifact and shows the renderer listener is attached there too.
|
|
235
|
+
*
|
|
236
|
+
* Opened only when something is SUBSCRIBED: the prop's PRESENCE is what a behavior reads to decide
|
|
237
|
+
* it is controlled, so a `<switch>` given a handler nobody asked for changes how it snaps back.
|
|
238
|
+
* `.observed` is readable from `ngOnInit` because Angular subscribes outputs in the creation pass,
|
|
239
|
+
* before the update pass runs the hook — observed directly (true for the two bound tags, false for
|
|
240
|
+
* an unbound one), not assumed.
|
|
241
|
+
*/
|
|
242
|
+
@Directive()
|
|
243
|
+
export abstract class ValueChangeElement
|
|
244
|
+
extends ReadBackElement
|
|
245
|
+
implements OnInit, OnDestroy
|
|
246
|
+
{
|
|
247
|
+
private readonly valueRenderer = inject(Renderer2);
|
|
248
|
+
private readonly valueHost = inject(ElementRef);
|
|
249
|
+
private unlistenValue?: () => void;
|
|
250
|
+
|
|
251
|
+
/** `this.valueChange.observed` — the subclass owns the emitter so its payload type stays exact. */
|
|
252
|
+
protected abstract hasValueSubscriber(): boolean;
|
|
253
|
+
|
|
254
|
+
/** Narrows the engine's unwrapped value to the type THIS tag emits, then emits it. */
|
|
255
|
+
protected abstract emitValue(value: unknown): void;
|
|
256
|
+
|
|
257
|
+
ngOnInit(): void {
|
|
258
|
+
if (!this.hasValueSubscriber()) return;
|
|
259
|
+
this.unlistenValue = this.valueRenderer.listen(
|
|
260
|
+
this.valueHost.nativeElement,
|
|
261
|
+
VALUE_CHANGE_EVENT,
|
|
262
|
+
(value: unknown) => {
|
|
263
|
+
this.emitValue(value);
|
|
264
|
+
},
|
|
265
|
+
);
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
override ngOnDestroy(): void {
|
|
269
|
+
super.ngOnDestroy();
|
|
270
|
+
this.unlistenValue?.();
|
|
271
|
+
}
|
|
272
|
+
}
|
|
@@ -0,0 +1,282 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Directive,
|
|
3
|
+
ElementRef,
|
|
4
|
+
EventEmitter,
|
|
5
|
+
Input,
|
|
6
|
+
Output,
|
|
7
|
+
Renderer2,
|
|
8
|
+
forwardRef,
|
|
9
|
+
inject,
|
|
10
|
+
} from '@angular/core';
|
|
11
|
+
import type { OnDestroy } from '@angular/core';
|
|
12
|
+
import { NG_VALUE_ACCESSOR, type ControlValueAccessor } from '@angular/forms';
|
|
13
|
+
import { VALUE_CHANGE_EVENT } from './renderer/value-change';
|
|
14
|
+
import type {
|
|
15
|
+
IActivityIndicatorProps,
|
|
16
|
+
IInputAccessoryViewViewProps,
|
|
17
|
+
IModalViewProps,
|
|
18
|
+
ISwitchProps,
|
|
19
|
+
ITextInputProps,
|
|
20
|
+
} from '@symbiote-native/components';
|
|
21
|
+
import type { IStickyHeaderElementProps } from './element-props';
|
|
22
|
+
import type { IAngularRefreshControlProps } from './components/refresh-control-props';
|
|
23
|
+
import {
|
|
24
|
+
ReadBackElement,
|
|
25
|
+
SymbioteElement,
|
|
26
|
+
ValueChangeElement,
|
|
27
|
+
} from './element-base';
|
|
28
|
+
|
|
29
|
+
@Directive({ selector: 'text-input', standalone: true })
|
|
30
|
+
export class TextInputElement extends ValueChangeElement {
|
|
31
|
+
@Input() value?: ITextInputProps['value'];
|
|
32
|
+
@Input() defaultValue?: ITextInputProps['defaultValue'];
|
|
33
|
+
@Input() placeholder?: ITextInputProps['placeholder'];
|
|
34
|
+
@Input() placeholderTextColor?: ITextInputProps['placeholderTextColor'];
|
|
35
|
+
@Input() multiline?: ITextInputProps['multiline'];
|
|
36
|
+
@Input() numberOfLines?: ITextInputProps['numberOfLines'];
|
|
37
|
+
@Input() maxLength?: ITextInputProps['maxLength'];
|
|
38
|
+
@Input() editable?: ITextInputProps['editable'];
|
|
39
|
+
@Input() readOnly?: ITextInputProps['readOnly'];
|
|
40
|
+
@Input() autoFocus?: ITextInputProps['autoFocus'];
|
|
41
|
+
@Input() autoCapitalize?: ITextInputProps['autoCapitalize'];
|
|
42
|
+
@Input() autoComplete?: ITextInputProps['autoComplete'];
|
|
43
|
+
@Input() autoCorrect?: ITextInputProps['autoCorrect'];
|
|
44
|
+
@Input() blurOnSubmit?: ITextInputProps['blurOnSubmit'];
|
|
45
|
+
@Input() submitBehavior?: ITextInputProps['submitBehavior'];
|
|
46
|
+
@Input() cursorColor?: ITextInputProps['cursorColor'];
|
|
47
|
+
@Input() enterKeyHint?: ITextInputProps['enterKeyHint'];
|
|
48
|
+
@Input() returnKeyType?: ITextInputProps['returnKeyType'];
|
|
49
|
+
@Input() inputMode?: ITextInputProps['inputMode'];
|
|
50
|
+
@Input() keyboardType?: ITextInputProps['keyboardType'];
|
|
51
|
+
@Input() inputAccessoryViewID?: ITextInputProps['inputAccessoryViewID'];
|
|
52
|
+
@Input() scrollEnabled?: ITextInputProps['scrollEnabled'];
|
|
53
|
+
@Input() secureTextEntry?: ITextInputProps['secureTextEntry'];
|
|
54
|
+
@Input() selectTextOnFocus?: ITextInputProps['selectTextOnFocus'];
|
|
55
|
+
@Input() selection?: ITextInputProps['selection'];
|
|
56
|
+
@Input() selectionColor?: ITextInputProps['selectionColor'];
|
|
57
|
+
@Input() selectionHandleColor?: ITextInputProps['selectionHandleColor'];
|
|
58
|
+
@Input() showSoftInputOnFocus?: ITextInputProps['showSoftInputOnFocus'];
|
|
59
|
+
@Input() textAlign?: ITextInputProps['textAlign'];
|
|
60
|
+
@Input() textContentType?: ITextInputProps['textContentType'];
|
|
61
|
+
@Input() underlineColorAndroid?: ITextInputProps['underlineColorAndroid'];
|
|
62
|
+
@Input() onValueChange?: ITextInputProps['onValueChange'];
|
|
63
|
+
@Input() onChangeText?: ITextInputProps['onChangeText'];
|
|
64
|
+
@Input() onContentSizeChange?: ITextInputProps['onContentSizeChange'];
|
|
65
|
+
@Input() onEndEditing?: ITextInputProps['onEndEditing'];
|
|
66
|
+
@Input() onKeyPress?: ITextInputProps['onKeyPress'];
|
|
67
|
+
@Input() onSelectionChange?: ITextInputProps['onSelectionChange'];
|
|
68
|
+
@Input() onSubmitEditing?: ITextInputProps['onSubmitEditing'];
|
|
69
|
+
|
|
70
|
+
// NonNullable, not the prop type: `[(value)]="name"` binds a `string`, and an emitter that can
|
|
71
|
+
// also emit `undefined` fails the two-way assignability check ngtsc runs on the event half.
|
|
72
|
+
@Output() readonly valueChange = new EventEmitter<
|
|
73
|
+
NonNullable<ITextInputProps['value']>
|
|
74
|
+
>();
|
|
75
|
+
|
|
76
|
+
protected hasValueSubscriber(): boolean {
|
|
77
|
+
return this.valueChange.observed;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
protected emitValue(value: unknown): void {
|
|
81
|
+
if (typeof value === 'string') this.valueChange.emit(value);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
@Directive({ selector: 'text-input-multiline', standalone: true })
|
|
86
|
+
export class MultilineTextInputElement extends TextInputElement {}
|
|
87
|
+
|
|
88
|
+
@Directive({ selector: 'switch, symbiote-switch', standalone: true })
|
|
89
|
+
export class SwitchElement extends ValueChangeElement {
|
|
90
|
+
@Input() value?: ISwitchProps['value'];
|
|
91
|
+
@Input() disabled?: ISwitchProps['disabled'];
|
|
92
|
+
@Input() trackColor?: ISwitchProps['trackColor'];
|
|
93
|
+
@Input() thumbColor?: ISwitchProps['thumbColor'];
|
|
94
|
+
@Input() ios_backgroundColor?: ISwitchProps['ios_backgroundColor'];
|
|
95
|
+
@Input() onValueChange?: ISwitchProps['onValueChange'];
|
|
96
|
+
|
|
97
|
+
@Output() readonly valueChange = new EventEmitter<
|
|
98
|
+
NonNullable<ISwitchProps['value']>
|
|
99
|
+
>();
|
|
100
|
+
|
|
101
|
+
protected hasValueSubscriber(): boolean {
|
|
102
|
+
return this.valueChange.observed;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
protected emitValue(value: unknown): void {
|
|
106
|
+
if (typeof value === 'boolean') this.valueChange.emit(value);
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
/**
|
|
111
|
+
* `[(ngModel)]` / `formControlName` on a `<text-input>` or a `<switch>`.
|
|
112
|
+
*
|
|
113
|
+
* The wrappers provided `NG_VALUE_ACCESSOR` themselves; a tag has no class for @angular/forms to
|
|
114
|
+
* call into, so the accessor moves onto a directive of its own rather than being dropped — the
|
|
115
|
+
* shape Angular's own `DefaultValueAccessor` takes for `<input>`. Providing it unconditionally is
|
|
116
|
+
* safe: @angular/forms looks the accessor up only when an `ngModel` / `formControl*` directive sits
|
|
117
|
+
* on the SAME element, so a plain `<switch [(value)]>` never reaches it.
|
|
118
|
+
*
|
|
119
|
+
* Everything below goes through `Renderer2`, which is the adapter's own — `setProperty` lands in
|
|
120
|
+
* `routeProp` and `listen('valueChange')` is already unwrapped to a bare value there, so this
|
|
121
|
+
* directive holds no fold of its own.
|
|
122
|
+
*/
|
|
123
|
+
@Directive()
|
|
124
|
+
abstract class SymbioteValueAccessor
|
|
125
|
+
implements ControlValueAccessor, OnDestroy
|
|
126
|
+
{
|
|
127
|
+
private readonly renderer = inject(Renderer2);
|
|
128
|
+
private readonly host = inject(ElementRef);
|
|
129
|
+
private unlisten?: () => void;
|
|
130
|
+
|
|
131
|
+
// The prop that spells "not editable" for this tag: RN's TextInput has no `disabled`, it has
|
|
132
|
+
// `editable` (inverted), while Switch takes `disabled` straight.
|
|
133
|
+
protected abstract writeDisabled(isDisabled: boolean): void;
|
|
134
|
+
|
|
135
|
+
protected setProp(name: string, value: unknown): void {
|
|
136
|
+
this.renderer.setProperty(this.host.nativeElement, name, value);
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
writeValue(value: unknown): void {
|
|
140
|
+
this.setProp('value', value ?? undefined);
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
registerOnChange(fn: (value: unknown) => void): void {
|
|
144
|
+
this.unlisten?.();
|
|
145
|
+
this.unlisten = this.renderer.listen(
|
|
146
|
+
this.host.nativeElement,
|
|
147
|
+
VALUE_CHANGE_EVENT,
|
|
148
|
+
(value: unknown) => {
|
|
149
|
+
// THE HALF THE DOM DOES FOR FREE, and without it a controlled input undoes every
|
|
150
|
+
// keystroke. `<text-input>`'s behavior re-commands the native text whenever `props.value`
|
|
151
|
+
// disagrees with what native last reported — that is what makes it controlled — and the
|
|
152
|
+
// read-back flush exists so the app's new value is on the node by the time the commit runs.
|
|
153
|
+
// @angular/forms does not reach the node in that window: `NgModel.ngOnChanges` defers
|
|
154
|
+
// `_updateValue` through `resolvedPromise.then`, so `writeValue` lands a MICROTASK after
|
|
155
|
+
// the flush, and the commit in between still reads the value from before the keystroke.
|
|
156
|
+
//
|
|
157
|
+
// In a browser there is nothing to do here: `input.value` already holds what the user
|
|
158
|
+
// typed. `node.props.value` is the same slot, and nothing else writes it — so the accessor
|
|
159
|
+
// mirrors it, which is the shape rather than a workaround. A later `writeValue` still wins,
|
|
160
|
+
// so an app that transforms or refuses the value keeps doing so, one microtask on.
|
|
161
|
+
//
|
|
162
|
+
// Without this, every character snaps the field back to its mounted text.
|
|
163
|
+
this.setProp('value', value);
|
|
164
|
+
fn(value);
|
|
165
|
+
},
|
|
166
|
+
);
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
// Native has no blur-driven "touched" signal distinct from `blur`, and RN's own onBlur is what an
|
|
170
|
+
// app binds — so touched is driven off the same event rather than a second channel.
|
|
171
|
+
registerOnTouched(fn: () => void): void {
|
|
172
|
+
this.setProp('onBlur', () => fn());
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
setDisabledState(isDisabled: boolean): void {
|
|
176
|
+
this.writeDisabled(isDisabled);
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
ngOnDestroy(): void {
|
|
180
|
+
this.unlisten?.();
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
@Directive({
|
|
185
|
+
selector:
|
|
186
|
+
'text-input[ngModel], text-input[formControl], text-input[formControlName], text-input-multiline[ngModel], text-input-multiline[formControl], text-input-multiline[formControlName]',
|
|
187
|
+
standalone: true,
|
|
188
|
+
providers: [
|
|
189
|
+
{
|
|
190
|
+
provide: NG_VALUE_ACCESSOR,
|
|
191
|
+
useExisting: forwardRef(() => TextInputValueAccessor),
|
|
192
|
+
multi: true,
|
|
193
|
+
},
|
|
194
|
+
],
|
|
195
|
+
})
|
|
196
|
+
export class TextInputValueAccessor extends SymbioteValueAccessor {
|
|
197
|
+
protected override writeDisabled(isDisabled: boolean): void {
|
|
198
|
+
this.setProp('editable', !isDisabled);
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
@Directive({
|
|
203
|
+
selector: 'switch[ngModel], switch[formControl], switch[formControlName]',
|
|
204
|
+
standalone: true,
|
|
205
|
+
providers: [
|
|
206
|
+
{
|
|
207
|
+
provide: NG_VALUE_ACCESSOR,
|
|
208
|
+
useExisting: forwardRef(() => SwitchValueAccessor),
|
|
209
|
+
multi: true,
|
|
210
|
+
},
|
|
211
|
+
],
|
|
212
|
+
})
|
|
213
|
+
export class SwitchValueAccessor extends SymbioteValueAccessor {
|
|
214
|
+
protected override writeDisabled(isDisabled: boolean): void {
|
|
215
|
+
this.setProp('disabled', isDisabled);
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
// The HOST — RN's centering RCTView (ActivityIndicator.js:112), which is the tag an app writes.
|
|
220
|
+
// The four spinner props are declared here because that is where the app writes them; the engine's
|
|
221
|
+
// behavior redirects them onto the spinner it builds underneath (`slotProps`).
|
|
222
|
+
@Directive({ selector: 'activity-indicator', standalone: true })
|
|
223
|
+
export class ActivityIndicatorElement extends SymbioteElement {
|
|
224
|
+
@Input() animating?: IActivityIndicatorProps['animating'];
|
|
225
|
+
@Input() color?: IActivityIndicatorProps['color'];
|
|
226
|
+
@Input() size?: IActivityIndicatorProps['size'];
|
|
227
|
+
@Input() hidesWhenStopped?: IActivityIndicatorProps['hidesWhenStopped'];
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
// The native spinner. Built by the behavior's `buildStructure` and by the wrapper's render fn, never
|
|
231
|
+
// written in an app template — declared only so the tag alphabet stays covered, the same as
|
|
232
|
+
// `scroll-content`.
|
|
233
|
+
@Directive({ selector: 'activity-indicator-spinner', standalone: true })
|
|
234
|
+
export class ActivityIndicatorSpinnerElement extends ActivityIndicatorElement {}
|
|
235
|
+
|
|
236
|
+
@Directive({ selector: 'safe-area-view', standalone: true })
|
|
237
|
+
export class SafeAreaViewElement extends SymbioteElement {}
|
|
238
|
+
|
|
239
|
+
@Directive({ selector: 'modal, symbiote-modal', standalone: true })
|
|
240
|
+
export class ModalElement extends SymbioteElement {
|
|
241
|
+
@Input() visible?: IModalViewProps['visible'];
|
|
242
|
+
@Input() transparent?: IModalViewProps['transparent'];
|
|
243
|
+
@Input() animationType?: IModalViewProps['animationType'];
|
|
244
|
+
@Input() presentationStyle?: IModalViewProps['presentationStyle'];
|
|
245
|
+
@Input() supportedOrientations?: IModalViewProps['supportedOrientations'];
|
|
246
|
+
@Input() hardwareAccelerated?: IModalViewProps['hardwareAccelerated'];
|
|
247
|
+
@Input() statusBarTranslucent?: IModalViewProps['statusBarTranslucent'];
|
|
248
|
+
@Input()
|
|
249
|
+
navigationBarTranslucent?: IModalViewProps['navigationBarTranslucent'];
|
|
250
|
+
@Input() allowSwipeDismissal?: IModalViewProps['allowSwipeDismissal'];
|
|
251
|
+
@Input() backdropColor?: IModalViewProps['backdropColor'];
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
@Directive({ selector: 'refresh-control', standalone: true })
|
|
255
|
+
export class RefreshControlElement extends ReadBackElement {
|
|
256
|
+
@Input() refreshing?: IAngularRefreshControlProps['refreshing'];
|
|
257
|
+
@Input() enabled?: IAngularRefreshControlProps['enabled'];
|
|
258
|
+
@Input() colors?: IAngularRefreshControlProps['colors'];
|
|
259
|
+
@Input() tintColor?: IAngularRefreshControlProps['tintColor'];
|
|
260
|
+
@Input() title?: IAngularRefreshControlProps['title'];
|
|
261
|
+
@Input() titleColor?: IAngularRefreshControlProps['titleColor'];
|
|
262
|
+
@Input() size?: IAngularRefreshControlProps['size'];
|
|
263
|
+
@Input()
|
|
264
|
+
progressBackgroundColor?: IAngularRefreshControlProps['progressBackgroundColor'];
|
|
265
|
+
@Input()
|
|
266
|
+
progressViewOffset?: IAngularRefreshControlProps['progressViewOffset'];
|
|
267
|
+
@Input() onRefresh?: IAngularRefreshControlProps['onRefresh'];
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
@Directive({ selector: 'sticky-header', standalone: true })
|
|
271
|
+
export class StickyHeaderElement extends SymbioteElement {
|
|
272
|
+
@Input() inverted?: IStickyHeaderElementProps['inverted'];
|
|
273
|
+
@Input() nextHeaderLayoutY?: IStickyHeaderElementProps['nextHeaderLayoutY'];
|
|
274
|
+
@Input()
|
|
275
|
+
scrollAnimatedValue?: IStickyHeaderElementProps['scrollAnimatedValue'];
|
|
276
|
+
@Input() scrollViewHeight?: IStickyHeaderElementProps['scrollViewHeight'];
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
@Directive({ selector: 'input-accessory-view', standalone: true })
|
|
280
|
+
export class InputAccessoryViewElement extends SymbioteElement {
|
|
281
|
+
@Input() backgroundColor?: IInputAccessoryViewViewProps['backgroundColor'];
|
|
282
|
+
}
|