1 | import { AlignSelf, FlexGrow, FlexShrink, FlexWrapBefore, Order } from '../../layouts/flexbox-layout';
|
2 | import { Page } from '../../page';
|
3 | import { CoreTypes } from '../../../core-types';
|
4 | import { Property, CssProperty, CssAnimationProperty, InheritedProperty } from '../properties';
|
5 | import { BindingOptions } from '../bindable';
|
6 | import { Observable } from '../../../data/observable';
|
7 | import { Style } from '../../styling/style';
|
8 | import type { ModalTransition } from '../../transition/modal-transition';
|
9 | import * as dnm from '../../../debugger/dom-node';
|
10 | import * as ssm from '../../styling/style-scope';
|
11 | import { ViewBase as ViewBaseDefinition } from '.';
|
12 | export interface ModalTransitionType {
|
13 | name?: string;
|
14 | instance?: ModalTransition;
|
15 | duration?: number;
|
16 | curve?: any;
|
17 | }
|
18 | export interface ShowModalOptions {
|
19 | |
20 |
|
21 |
|
22 | context: any;
|
23 | |
24 |
|
25 |
|
26 | closeCallback: (...args: any[]) => void;
|
27 | |
28 |
|
29 |
|
30 | fullscreen?: boolean;
|
31 | |
32 |
|
33 |
|
34 | animated?: boolean;
|
35 | |
36 |
|
37 |
|
38 | stretched?: boolean;
|
39 | |
40 |
|
41 |
|
42 | transition?: ModalTransitionType;
|
43 | |
44 |
|
45 |
|
46 | ios?: {
|
47 | |
48 |
|
49 |
|
50 | presentationStyle?: any;
|
51 | |
52 |
|
53 |
|
54 | width?: number;
|
55 | |
56 |
|
57 |
|
58 | height?: number;
|
59 | };
|
60 | android?: {
|
61 | |
62 |
|
63 |
|
64 |
|
65 | cancelable?: boolean;
|
66 | |
67 |
|
68 |
|
69 |
|
70 | windowSoftInputMode?: number;
|
71 | };
|
72 | |
73 |
|
74 |
|
75 | cancelable?: boolean;
|
76 | }
|
77 |
|
78 |
|
79 |
|
80 |
|
81 |
|
82 |
|
83 | export declare function getAncestor(view: ViewBaseDefinition, criterion: string | {
|
84 | new (): any;
|
85 | }): ViewBaseDefinition;
|
86 |
|
87 |
|
88 |
|
89 |
|
90 |
|
91 |
|
92 | export declare function getViewById(view: ViewBaseDefinition, id: string): ViewBaseDefinition;
|
93 |
|
94 |
|
95 |
|
96 |
|
97 |
|
98 |
|
99 | export declare function getViewByDomId(view: ViewBaseDefinition, domId: number): ViewBaseDefinition;
|
100 |
|
101 |
|
102 |
|
103 |
|
104 |
|
105 |
|
106 | export declare function querySelectorAll(view: ViewBaseDefinition, selector: string): Array<ViewBaseDefinition>;
|
107 |
|
108 |
|
109 |
|
110 |
|
111 |
|
112 | export declare function eachDescendant(view: ViewBaseDefinition, callback: (child: ViewBaseDefinition) => boolean): void;
|
113 | declare enum SuspendType {
|
114 | Incremental = 0,
|
115 | Loaded = 1048576,
|
116 | NativeView = 2097152,
|
117 | UISetup = 4194304,
|
118 | IncrementalCountMask = -7340033
|
119 | }
|
120 | declare namespace SuspendType {
|
121 | function toString(type: SuspendType): string;
|
122 | }
|
123 | export declare abstract class ViewBase extends Observable implements ViewBaseDefinition {
|
124 | |
125 |
|
126 |
|
127 | static loadedEvent: string;
|
128 | |
129 |
|
130 |
|
131 | static unloadedEvent: string;
|
132 | |
133 |
|
134 |
|
135 | static createdEvent: string;
|
136 | |
137 |
|
138 |
|
139 | static disposeNativeViewEvent: string;
|
140 | private _onLoadedCalled;
|
141 | private _onUnloadedCalled;
|
142 | private _iosView;
|
143 | private _androidView;
|
144 | private _style;
|
145 | private _isLoaded;
|
146 | private _visualState;
|
147 | private _templateParent;
|
148 | private __nativeView;
|
149 | domNode: dnm.DOMNode;
|
150 | recycleNativeView: 'always' | 'never' | 'auto';
|
151 | |
152 |
|
153 |
|
154 | viewController: any;
|
155 | bindingContext: any;
|
156 | |
157 |
|
158 |
|
159 | nativeViewProtected: any;
|
160 | |
161 |
|
162 |
|
163 | parent: ViewBase;
|
164 | |
165 |
|
166 |
|
167 |
|
168 |
|
169 | isCollapsed: any;
|
170 | |
171 |
|
172 |
|
173 | id: string;
|
174 | |
175 |
|
176 |
|
177 | className: string;
|
178 | |
179 |
|
180 |
|
181 | sharedTransitionTag: string;
|
182 | |
183 |
|
184 |
|
185 | sharedTransitionIgnore: boolean;
|
186 | |
187 |
|
188 |
|
189 | defaultVisualState: string;
|
190 | _domId: number;
|
191 | _context: any;
|
192 | _isAddedToNativeVisualTree: boolean;
|
193 | _cssState: ssm.CssState;
|
194 | _styleScope: ssm.StyleScope;
|
195 | |
196 |
|
197 |
|
198 |
|
199 |
|
200 |
|
201 |
|
202 | _suspendedUpdates: {
|
203 | [propertyName: string]: Property<ViewBase, any> | CssProperty<Style, any> | CssAnimationProperty<Style, any>;
|
204 | };
|
205 | |
206 |
|
207 |
|
208 |
|
209 |
|
210 |
|
211 |
|
212 | _suspendNativeUpdatesCount: number;
|
213 | _isStyleScopeHost: boolean;
|
214 | _automaticallyAdjustsScrollViewInsets: boolean;
|
215 | left: CoreTypes.LengthType;
|
216 | top: CoreTypes.LengthType;
|
217 | effectiveLeft: number;
|
218 | effectiveTop: number;
|
219 | dock: 'left' | 'top' | 'right' | 'bottom';
|
220 | row: number;
|
221 | col: number;
|
222 | column: number;
|
223 | rowSpan: number;
|
224 | colSpan: number;
|
225 | columnSpan: number;
|
226 | order: Order;
|
227 | flexGrow: FlexGrow;
|
228 | flexShrink: FlexShrink;
|
229 | flexWrapBefore: FlexWrapBefore;
|
230 | alignSelf: AlignSelf;
|
231 | _oldLeft: number;
|
232 | _oldTop: number;
|
233 | _oldRight: number;
|
234 | _oldBottom: number;
|
235 | _ignoreFlexMinWidthHeightReset: boolean;
|
236 | effectiveMinWidth: number;
|
237 | effectiveMinHeight: number;
|
238 | effectiveWidth: number;
|
239 | effectiveHeight: number;
|
240 | effectiveMarginTop: number;
|
241 | effectiveMarginRight: number;
|
242 | effectiveMarginBottom: number;
|
243 | effectiveMarginLeft: number;
|
244 | effectivePaddingTop: number;
|
245 | effectivePaddingRight: number;
|
246 | effectivePaddingBottom: number;
|
247 | effectivePaddingLeft: number;
|
248 | effectiveBorderTopWidth: number;
|
249 | effectiveBorderRightWidth: number;
|
250 | effectiveBorderBottomWidth: number;
|
251 | effectiveBorderLeftWidth: number;
|
252 | _defaultPaddingTop: number;
|
253 | _defaultPaddingRight: number;
|
254 | _defaultPaddingBottom: number;
|
255 | _defaultPaddingLeft: number;
|
256 | _isPaddingRelative: boolean;
|
257 | |
258 |
|
259 |
|
260 |
|
261 | _moduleName: string;
|
262 | |
263 |
|
264 |
|
265 |
|
266 | reusable: boolean;
|
267 | constructor();
|
268 | /**
|
269 | * Gets the template parent or the native parent. Sets the template parent.
|
270 | */
|
271 | get parentNode(): ViewBase;
|
272 | set parentNode(node: ViewBase);
|
273 | get nativeView(): any;
|
274 | set nativeView(value: any);
|
275 | /**
|
276 | * Gets the name of the constructor function for this instance. E.g. for a Button class this will return "Button".
|
277 | */
|
278 | get typeName(): string;
|
279 | /**
|
280 | * Gets the style object associated to this view.
|
281 | */
|
282 | get style(): Style;
|
283 | set style(inlineStyle: Style);
|
284 | get android(): any;
|
285 | get ios(): any;
|
286 | get isLoaded(): boolean;
|
287 | get ['class'](): string;
|
288 | set ['class'](v: string);
|
289 | /**
|
290 | * Returns the child view with the specified id.
|
291 | */
|
292 | getViewById<T extends ViewBaseDefinition>(id: string): T;
|
293 | /**
|
294 | * Returns the child view with the specified domId.
|
295 | */
|
296 | getViewByDomId<T extends ViewBaseDefinition>(domId: number): T;
|
297 | /**
|
298 | * Gets owner page. This is a read-only property.
|
299 | */
|
300 | get page(): Page;
|
301 | /**
|
302 | * @unstable
|
303 | * Ensures a dom-node for this view.
|
304 | */
|
305 | ensureDomNode(): void;
|
306 | set(name: string, value: any): void;
|
307 | onLoaded(): void;
|
308 | onUnloaded(): void;
|
309 | _layoutParent(): void;
|
310 | _suspendNativeUpdates(type: SuspendType): void;
|
311 | _resumeNativeUpdates(type: SuspendType): void;
|
312 | /**
|
313 | * Allow multiple updates to be performed on the instance at once.
|
314 | */
|
315 | _batchUpdate<T>(callback: () => T): T;
|
316 | private setFlag;
|
317 | private isFlagSet;
|
318 | private callFunctionWithSuper;
|
319 | callLoaded(): void;
|
320 | callUnloaded(): void;
|
321 | private notifyPseudoClassChanged;
|
322 | private pseudoClassAliases;
|
323 | cssClasses: Set<string>;
|
324 | cssPseudoClasses: Set<string>;
|
325 | private getAllAliasedStates;
|
326 | /**
|
327 | * @protected
|
328 | * @unstable
|
329 | * A widget can call this method to add a matching css pseudo class.
|
330 | */
|
331 | addPseudoClass(name: string): void;
|
332 | /**
|
333 | * @protected
|
334 | * @unstable
|
335 | * A widget can call this method to discard matching css pseudo class.
|
336 | */
|
337 | deletePseudoClass(name: string): void;
|
338 | private bindingContextChanged;
|
339 | private bindings;
|
340 | private shouldAddHandlerToParentBindingContextChanged;
|
341 | private bindingContextBoundToParentBindingContextChanged;
|
342 | bind(options: BindingOptions, source?: Object): void;
|
343 | unbind(property: string): void;
|
344 | private performLayout;
|
345 | /**
|
346 | * Invalidates the layout of the view and triggers a new layout pass.
|
347 | */
|
348 | requestLayout(): void;
|
349 | /**
|
350 | * Iterates over children of type ViewBase.
|
351 | * @param callback Called for each child of type ViewBase. Iteration stops if this method returns falsy value.
|
352 | */
|
353 | eachChild(callback: (child: ViewBase) => boolean): void;
|
354 | _inheritStyles(view: ViewBase): void;
|
355 | _addView(view: ViewBase, atIndex?: number): void;
|
356 | /**
|
357 | * Method is intended to be overridden by inheritors and used as "protected"
|
358 | */
|
359 | _addViewCore(view: ViewBase, atIndex?: number): void;
|
360 | /**
|
361 | * Load view.
|
362 | * @param view to load.
|
363 | */
|
364 | loadView(view: ViewBase): void;
|
365 | /**
|
366 | * When returning true the callLoaded method will be run in setTimeout
|
367 | * Method is intended to be overridden by inheritors and used as "protected"
|
368 | */
|
369 | _shouldDelayLayout(): boolean;
|
370 | /**
|
371 | * Unload view.
|
372 | * @param view to unload.
|
373 | */
|
374 | unloadView(view: ViewBase): void;
|
375 | /**
|
376 | * Core logic for removing a child view from this instance. Used by the framework to handle lifecycle events more centralized. Do not use outside the UI Stack implementation.
|
377 | */
|
378 | _removeView(view: ViewBase): void;
|
379 | /**
|
380 | * Method is intended to be overridden by inheritors and used as "protected"
|
381 | */
|
382 | _removeViewCore(view: ViewBase): void;
|
383 | /**
|
384 | * Creates a native view.
|
385 | * Returns either android.view.View or UIView.
|
386 | */
|
387 | createNativeView(): Object;
|
388 | /**
|
389 | * Clean up references to the native view.
|
390 | */
|
391 | disposeNativeView(): void;
|
392 | /**
|
393 | * Initializes properties/listeners of the native view.
|
394 | */
|
395 | initNativeView(): void;
|
396 | /**
|
397 | * Resets properties/listeners set to the native view.
|
398 | */
|
399 | resetNativeView(): void;
|
400 | private resetNativeViewInternal;
|
401 | /**
|
402 | * if _setupAsRootView is called it means it is not supposed to be
|
403 | * added to a parent. However parent can be set before for the purpose
|
404 | * of CSS variables/classes. That variable ensures that _addViewToNativeVisualTree
|
405 | * is not called in _setupAsRootView
|
406 | */
|
407 | mIsRootView: boolean;
|
408 | _setupAsRootView(context: any): void;
|
409 | /**
|
410 | * Setups the UI for ViewBase and all its children recursively.
|
411 | * This method should *not* be overridden by derived views.
|
412 | */
|
413 | _setupUI(context: any, atIndex?: number, parentIsLoaded?: boolean): void;
|
414 | /**
|
415 | * Set the nativeView field performing extra checks and updates to the native properties on the new view.
|
416 | * Use in cases where the createNativeView is not suitable.
|
417 | * As an example use in item controls where the native parent view will create the native views for child items.
|
418 | */
|
419 | setNativeView(value: any): void;
|
420 | /**
|
421 | * Tears down the UI of a reusable node by making it no longer reusable.
|
422 | * @see _tearDownUI
|
423 | * @param forceDestroyChildren Force destroy the children (even if they are reusable)
|
424 | */
|
425 | destroyNode(forceDestroyChildren?: boolean): void;
|
426 | /**
|
427 | * Tears down the UI for ViewBase and all its children recursively.
|
428 | * This method should *not* be overridden by derived views.
|
429 | */
|
430 | _tearDownUI(force?: boolean): void;
|
431 | _childIndexToNativeChildIndex(index?: number): number;
|
432 | /**
|
433 | * Performs the core logic of adding a child view to the native visual tree. Returns true if the view's native representation has been successfully added, false otherwise.
|
434 | * Method is intended to be overridden by inheritors and used as "protected".
|
435 | */
|
436 | _addViewToNativeVisualTree(view: ViewBase, atIndex?: number): boolean;
|
437 | /**
|
438 | * Method is intended to be overridden by inheritors and used as "protected"
|
439 | */
|
440 | _removeViewFromNativeVisualTree(view: ViewBase): void;
|
441 | get visualState(): string;
|
442 | _goToVisualState(state: string): void;
|
443 | /**
|
444 | * @deprecated
|
445 | *
|
446 | * This used to be the way to set attribute values in early {N} versions.
|
447 | * Now attributes are expected to be set as plain properties on the view instances.
|
448 | */
|
449 | _applyXmlAttribute(attribute: string, value: string): boolean;
|
450 | setInlineStyle(style: string): void;
|
451 | _parentChanged(oldParent: ViewBase): void;
|
452 | onResumeNativeUpdates(): void;
|
453 | toString(): string;
|
454 | /**
|
455 | * @private
|
456 | * Notifies each child's css state for change, recursively.
|
457 | * Either the style scope, className or id properties were changed.
|
458 | */
|
459 | _onCssStateChange(): void;
|
460 | _inheritStyleScope(styleScope: ssm.StyleScope): void;
|
461 | /**
|
462 | * Shows the view passed as parameter as a modal view.
|
463 | * @param view - View instance to be shown modally.
|
464 | * @param modalOptions - A ShowModalOptions instance
|
465 | */
|
466 | showModal(view: ViewBase, modalOptions?: ShowModalOptions): ViewBase;
|
467 | /**
|
468 | * Shows the View contained in moduleName as a modal view.
|
469 | * @param moduleName - The name of the module to load starting from the application root.
|
470 | * @param modalOptions - A ShowModalOptions instance
|
471 | */
|
472 | showModal(moduleName: string, modalOptions?: ShowModalOptions): ViewBase;
|
473 | /**
|
474 | * Closes the current modal view that this page is showing.
|
475 | * @param context - Any context you want to pass back to the host when closing the modal view.
|
476 | */
|
477 | closeModal(...args: any[]): void;
|
478 | /**
|
479 | * Method is intended to be overridden by inheritors and used as "protected"
|
480 | */
|
481 | _dialogClosed(): void;
|
482 | /**
|
483 | * Method is intended to be overridden by inheritors and used as "protected"
|
484 | */
|
485 | _onRootViewReset(): void;
|
486 | }
|
487 | export declare const bindingContextProperty: InheritedProperty<ViewBaseDefinition, any>;
|
488 | export declare const hiddenProperty: Property<ViewBaseDefinition, boolean>;
|
489 | export declare const classNameProperty: Property<ViewBaseDefinition, string>;
|
490 | export declare const idProperty: Property<ViewBaseDefinition, string>;
|
491 | export declare function booleanConverter(v: string | boolean): boolean;
|
492 | export {};
|