Skip to content

Commit 24ad6e4

Browse files
authored
docs(core): fix types & improve jsdoc comments (NativeScript#10620)
1 parent 3dec0a5 commit 24ad6e4

File tree

55 files changed

+1056
-38
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

55 files changed

+1056
-38
lines changed

packages/core/data/observable/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ const _globalEventHandlers: {
9797
export class Observable {
9898
/**
9999
* String value used when hooking to propertyChange event.
100+
* @nsEvent {PropertyChangeData} propertyChange
100101
*/
101102
public static propertyChangeEvent = 'propertyChange';
102103

packages/core/index.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ export { CSSUtils } from './css/system-classes';
3131
export { ObservableArray, ChangeType } from './data/observable-array';
3232
export type { ChangedData } from './data/observable-array';
3333
export { Observable, WrappedValue, fromObject, fromObjectRecursive } from './data/observable';
34-
export type { PropertyChangeData, EventData } from './data/observable';
34+
export type { PropertyChangeData, EventData, EventDataValue } from './data/observable';
3535
export { VirtualArray } from './data/virtual-array';
3636
export type { ItemsLoading } from './data/virtual-array';
3737
export { File, FileSystemEntity, Folder, knownFolders, path, getFileAccess, AndroidDirectory } from './file-system';

packages/core/ui/action-bar/index.d.ts

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,36 +4,49 @@ import { EventData } from '../../data/observable';
44

55
/**
66
* Provides an abstraction over the ActionBar (android) and NavigationBar (iOS).
7+
*
8+
* @nsView ActionBar
79
*/
810
export class ActionBar extends View {
911
/**
1012
* Gets or sets the action bar title.
13+
*
14+
* @nsProperty
1115
*/
1216
title: string;
1317

1418
/**
1519
* Gets or sets the title view. When set - replaces the title with a custom view.
20+
*
21+
* @nsProperty
1622
*/
1723
titleView: View;
1824

1925
/**
2026
* Gets or sets the navigation button (a.k.a. the back button).
27+
*
28+
* @nsProperty
2129
*/
2230
navigationButton: NavigationButton;
2331

2432
/**
2533
* Removes the shadow/border at the bottom of the ActionBar and removes translucency on iOS.
2634
* Default false.
35+
*
36+
* @nsProperty
2737
*/
2838
flat: boolean;
2939

3040
/**
3141
* Gets the collection of action items.
42+
*
43+
* @nsProperty
3244
*/
3345
actionItems: ActionItems;
3446

3547
/**
3648
* Gets the android specific options of the action bar.
49+
*
3750
*/
3851
android: AndroidActionBarSettings;
3952

@@ -48,6 +61,8 @@ export class ActionBar extends View {
4861
* - automatic
4962
* - alwaysOriginal
5063
* - alwaysTemplate
64+
*
65+
* @nsProperty
5166
*/
5267
iosIconRenderingMode: 'automatic' | 'alwaysOriginal' | 'alwaysTemplate';
5368

@@ -73,6 +88,7 @@ export class ActionBar extends View {
7388

7489
/**
7590
* Represents a collection of ActionItems.
91+
*
7692
*/
7793
export class ActionItems {
7894
/**
@@ -101,25 +117,42 @@ export class ActionItems {
101117

102118
/**
103119
* Represents an action item in the action bar.
120+
*
121+
* @nsView ActionItem
104122
*/
105123
export class ActionItem extends ViewBase {
124+
/**
125+
* String value used when hooking to layoutChanged event.
126+
*
127+
* @nsEvent {EventData} tap
128+
*/
129+
public static tapEvent: string;
130+
106131
/**
107132
* Gets or sets the text of the action item.
133+
*
134+
* @nsProperty
108135
*/
109136
text: string;
110137

111138
/**
112139
* Gets or sets the icon of the action item.
140+
*
141+
* @nsProperty
113142
*/
114143
icon: string;
115144

116145
/**
117146
* Gets or sets the custom action view of the action item.
147+
*
148+
* @nsProperty
118149
*/
119150
actionView: View;
120151

121152
/**
122153
* Gets or sets the visibility of the action item.
154+
*
155+
* @nsProperty
123156
*/
124157
visibility: string;
125158

packages/core/ui/activity-indicator/index.d.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
/**
44
* Represents a UI widget which displays a progress indicator hinting the user for some background operation running.
5+
*
6+
* @nsView ActivityIndicator
57
*/
68
export class ActivityIndicator extends View {
79
/**
@@ -16,6 +18,8 @@ export class ActivityIndicator extends View {
1618

1719
/**
1820
* Gets or sets a value indicating whether the widget is currently displaying progress.
21+
*
22+
* @nsProperty
1923
*/
2024
busy: boolean;
2125
}

packages/core/ui/button/index.d.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,14 @@ import { EventData } from '../../data/observable';
33

44
/**
55
* Represents a standard Button widget.
6+
*
7+
* @nsView Button
68
*/
79
export class Button extends TextBase {
810
/**
911
* String value used when hooking to tap event.
12+
*
13+
* @nsEvent {EventData} string;
1014
*/
1115
public static tapEvent: string;
1216

@@ -22,6 +26,8 @@ export class Button extends TextBase {
2226

2327
/**
2428
* Gets or sets whether the Button wraps text or not.
29+
*
30+
* @nsProperty
2531
*/
2632
textWrap: boolean;
2733

packages/core/ui/content-view/index.d.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,15 @@
11
import { View, CustomLayoutView, AddChildFromBuilder } from '../core/view';
22

3+
/**
4+
*
5+
* @nsView ContentView
6+
*/
37
export declare class ContentView extends CustomLayoutView implements AddChildFromBuilder {
8+
/**
9+
* Gets or sets the single child of the view.
10+
*
11+
* @nsProperty
12+
*/
413
content: View;
514
layoutView(): View;
615
_addChildFromBuilder(name: string, value: any): void;

packages/core/ui/core/view-base/index.ts

Lines changed: 96 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { AlignSelf, FlexGrow, FlexShrink, FlexWrapBefore, Order } from '../../layouts/flexbox-layout';
1+
import { AlignSelf, Flex, FlexFlow, FlexGrow, FlexShrink, FlexWrapBefore, Order } from '../../layouts/flexbox-layout';
22
import { Page } from '../../page';
33
import { CoreTypes } from '../../../core-types';
44
import { Property, CssProperty, CssAnimationProperty, InheritedProperty, clearInheritedProperties, propagateInheritableProperties, propagateInheritableCssProperties, initNativeView } from '../properties';
@@ -10,7 +10,6 @@ import { Observable, PropertyChangeData, WrappedValue } from '../../../data/obse
1010
import { Style } from '../../styling/style';
1111
import { paddingTopProperty, paddingRightProperty, paddingBottomProperty, paddingLeftProperty } from '../../styling/style-properties';
1212
import type { ModalTransition } from '../../transition/modal-transition';
13-
import type { GestureEventData } from '../../gestures';
1413

1514
// TODO: Remove this import!
1615
import { getClass } from '../../../utils/types';
@@ -310,21 +309,33 @@ namespace SuspendType {
310309

311310
const DEFAULT_VIEW_PADDINGS: Map<string, any> = new Map();
312311

312+
/**
313+
*
314+
* @nsView ViewBase
315+
*/
313316
export abstract class ViewBase extends Observable implements ViewBaseDefinition {
314317
/**
315318
* String value used when hooking to loaded event.
319+
*
320+
* @nsEvent loaded
316321
*/
317322
public static loadedEvent = 'loaded';
318323
/**
319324
* String value used when hooking to unloaded event.
325+
*
326+
* @nsEvent unloaded
320327
*/
321328
public static unloadedEvent = 'unloaded';
322329
/**
323330
* String value used when hooking to creation event
331+
*
332+
* @nsEvent created
324333
*/
325334
public static createdEvent = 'created';
326335
/**
327336
* String value used when hooking to disposeNativeView event
337+
*
338+
* @nsEvent disposeNativeView
328339
*/
329340
public static disposeNativeViewEvent = 'disposeNativeView';
330341

@@ -346,6 +357,9 @@ export abstract class ViewBase extends Observable implements ViewBaseDefinition
346357
* returns the native UIViewController.
347358
*/
348359
public viewController: any;
360+
/**
361+
* @nsProperty
362+
*/
349363
public bindingContext: any;
350364
/**
351365
* read-only. If you want to set out-of-band the nativeView use the setNativeView method.
@@ -364,23 +378,39 @@ export abstract class ViewBase extends Observable implements ViewBaseDefinition
364378

365379
/**
366380
* Gets or sets the id for this view.
381+
*
382+
* @nsProperty
367383
*/
368384
public id: string;
369385
/**
370386
* Gets or sets the CSS class name for this view.
387+
*
388+
* @nsProperty
371389
*/
372390
public className: string;
391+
392+
/**
393+
* Gets or sets the visual state of the view.
394+
* @nsProperty
395+
*/
396+
public hidden: boolean;
373397
/**
374398
* Gets or sets the shared transition tag for animated view transitions
399+
*
400+
* @nsProperty
375401
*/
376402
public sharedTransitionTag: string;
377403
/**
378404
* Opt out of shared transition under different binding conditions
405+
*
406+
* @nsProperty
379407
*/
380408
public sharedTransitionIgnore: boolean;
381409

382410
/**
383411
* Default visual state, defaults to 'normal'
412+
*
413+
* @nsProperty
384414
*/
385415
public defaultVisualState: string = 'normal';
386416

@@ -412,22 +442,77 @@ export abstract class ViewBase extends Observable implements ViewBaseDefinition
412442
public _automaticallyAdjustsScrollViewInsets: boolean;
413443

414444
// Dynamic properties.
445+
/**
446+
* Gets or sets the distance, in pixels, between the left edge of the child and the left edge of its parent.
447+
* @nsProperty
448+
*/
415449
left: CoreTypes.LengthType;
450+
/**
451+
* Gets or sets the distance, in pixels, between the top edge of the child and the top edge of its parent.
452+
* @nsProperty
453+
*/
416454
top: CoreTypes.LengthType;
417455
effectiveLeft: number;
418456
effectiveTop: number;
457+
/**
458+
* Dock position of the view within its parent.
459+
* @nsProperty
460+
*/
419461
dock: 'left' | 'top' | 'right' | 'bottom';
462+
/**
463+
* The row for the element. The rows are 0-indexed, so the first row is indicated by 0.
464+
*
465+
* @nsProperty
466+
*/
420467
row: number;
468+
/**
469+
* The column for the element. The columns are 0-indexed, so the first column is indicated by 0.
470+
* @nsProperty
471+
*/
421472
col: number;
473+
/**
474+
* The column for the element. The columns are 0-indexed, so the first column is indicated by 0.
475+
* @nsProperty
476+
*/
422477
column: number; // synonym for "col"
478+
/**
479+
* The number of rows for the element to span across.
480+
* @nsProperty
481+
*/
423482
rowSpan: number;
483+
/**
484+
* The number of columns for the element to span across.
485+
* @nsProperty
486+
*/
424487
colSpan: number;
488+
/**
489+
* @nsProperty
490+
*/
425491
columnSpan: number; // synonym for "columnSpan"
426-
492+
/**
493+
* Sets the order in which child elements inside a Flex appear in relation to one another.
494+
* @nsProperty
495+
*/
427496
order: Order;
497+
/**
498+
* Indicates that the child should grow in size, if necessary. Sets how much the child will grow in proportion to the rest of the child elements in the flex container.
499+
* @nsProperty
500+
*/
428501
flexGrow: FlexGrow;
502+
/**
503+
* Indicates that the child should shrink when the row runs out of space. Sets how much the flex item will shrink in proportion to the rest of the child elements in the flex container. When not specified, its value is set to 1.
504+
* @nsProperty
505+
*/
429506
flexShrink: FlexShrink;
507+
/**
508+
* When true, forces the item to wrap onto a new line.
509+
* @nsProperty
510+
*/
430511
flexWrapBefore: FlexWrapBefore;
512+
/**
513+
* (Android-only) Overrides the alignItems value for the child.
514+
* @nsProperty
515+
*/
431516
alignSelf: AlignSelf;
432517

433518
_oldLeft: number;
@@ -466,8 +551,9 @@ export abstract class ViewBase extends Observable implements ViewBaseDefinition
466551
public _moduleName: string;
467552

468553
/**
469-
* Gets or sets if the view is reusable.
470-
* Reusable views are not automatically destroyed when removed from the View tree.
554+
* Gets or sets if the view is reusable. Reusable views are not automatically destroyed when removed from the View tree.
555+
*
556+
* @nsProperty
471557
*/
472558
public reusable: boolean;
473559

@@ -511,6 +597,11 @@ export abstract class ViewBase extends Observable implements ViewBaseDefinition
511597
get style(): Style {
512598
return this._style;
513599
}
600+
601+
/**
602+
*
603+
* @nsProperty
604+
*/
514605
set style(inlineStyle: Style /* | string */) {
515606
if (typeof inlineStyle === 'string') {
516607
this.setInlineStyle(inlineStyle);

0 commit comments

Comments
 (0)