@zcomponent/core 1.14.3 → 1.16.0-beta

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.
Files changed (141) hide show
  1. package/README.md +0 -6
  2. package/lib/actionbehavior.d.ts +12 -3
  3. package/lib/actionbehavior.js +12 -3
  4. package/lib/animation/animation.d.ts +96 -4
  5. package/lib/animation/animation.js +93 -0
  6. package/lib/animation/animationstate.d.ts +52 -2
  7. package/lib/animation/bezier.d.ts +12 -1
  8. package/lib/animation/bezier.js +15 -12
  9. package/lib/animation/clips/clip.d.ts +71 -0
  10. package/lib/animation/clips/clip.js +68 -0
  11. package/lib/animation/interpolate.d.ts +17 -0
  12. package/lib/animation/interpolate.js +71 -0
  13. package/lib/animation/keyframe.d.ts +24 -1
  14. package/lib/animation/layer.d.ts +73 -1
  15. package/lib/animation/layer.js +69 -0
  16. package/lib/animation/layerclip.d.ts +75 -0
  17. package/lib/animation/layerclip.js +69 -0
  18. package/lib/animation/stream.d.ts +49 -7
  19. package/lib/animation/stream.js +3 -0
  20. package/lib/animation/tracks/cliptrack.d.ts +64 -0
  21. package/lib/animation/tracks/cliptrack.js +65 -1
  22. package/lib/animation/tracks/functiontrack.d.ts +60 -0
  23. package/lib/animation/tracks/functiontrack.js +62 -3
  24. package/lib/animation/tracks/propertytrack.d.ts +84 -0
  25. package/lib/animation/tracks/propertytrack.js +75 -0
  26. package/lib/animation/tracks/streamtrack.d.ts +51 -0
  27. package/lib/animation/tracks/streamtrack.js +54 -3
  28. package/lib/animation/tracks/track.d.ts +56 -0
  29. package/lib/animation/tracks/track.js +40 -0
  30. package/lib/behavior.d.ts +37 -0
  31. package/lib/behavior.js +21 -0
  32. package/lib/behaviors/ActivateState.d.ts +10 -3
  33. package/lib/behaviors/ActivateState.js +8 -4
  34. package/lib/behaviors/CallFunction.d.ts +1 -1
  35. package/lib/behaviors/CallFunction.js +2 -2
  36. package/lib/behaviors/ConsoleLog.d.ts +1 -1
  37. package/lib/behaviors/ConsoleLog.js +2 -2
  38. package/lib/behaviors/DownloadSnapshot.d.ts +5 -2
  39. package/lib/behaviors/DownloadSnapshot.js +5 -2
  40. package/lib/behaviors/LaunchURL.d.ts +1 -1
  41. package/lib/behaviors/LaunchURL.js +1 -1
  42. package/lib/behaviors/LogAnalyticsEvent.d.ts +1 -1
  43. package/lib/behaviors/LogAnalyticsEvent.js +2 -2
  44. package/lib/behaviors/PauseLayerClip.d.ts +5 -3
  45. package/lib/behaviors/PauseLayerClip.js +3 -2
  46. package/lib/behaviors/PlayLayerClip.d.ts +10 -4
  47. package/lib/behaviors/PlayLayerClip.js +7 -5
  48. package/lib/behaviors/PlaySound.d.ts +4 -4
  49. package/lib/behaviors/PlaySound.js +4 -4
  50. package/lib/behaviors/SetLayerOff.d.ts +4 -3
  51. package/lib/behaviors/SetLayerOff.js +3 -2
  52. package/lib/behaviors/ShowTextAlert.d.ts +2 -2
  53. package/lib/behaviors/ShowTextAlert.js +5 -5
  54. package/lib/behaviors/ToggleLayerClips.d.ts +4 -3
  55. package/lib/behaviors/ToggleLayerClips.js +5 -4
  56. package/lib/behaviors/stream/PauseStream.d.ts +15 -3
  57. package/lib/behaviors/stream/PauseStream.js +13 -2
  58. package/lib/behaviors/stream/PlayStream.d.ts +14 -4
  59. package/lib/behaviors/stream/PlayStream.js +10 -3
  60. package/lib/behaviors/stream/SeekStream.d.ts +12 -3
  61. package/lib/behaviors/stream/SeekStream.js +10 -2
  62. package/lib/behaviors/stream/StopStream.d.ts +11 -3
  63. package/lib/behaviors/stream/StopStream.js +9 -2
  64. package/lib/component.d.ts +85 -5
  65. package/lib/component.js +49 -1
  66. package/lib/components/Audio.d.ts +14 -5
  67. package/lib/components/Audio.js +19 -10
  68. package/lib/components/AudioLayerSettings.d.ts +9 -3
  69. package/lib/components/AudioLayerSettings.js +9 -3
  70. package/lib/components/Children.d.ts +7 -2
  71. package/lib/components/Children.js +6 -1
  72. package/lib/components/DefaultCookieConsent.d.ts +13 -3
  73. package/lib/components/DefaultCookieConsent.js +62 -38
  74. package/lib/components/DefaultLoader.d.ts +14 -9
  75. package/lib/components/DefaultLoader.js +25 -20
  76. package/lib/components/Gamepad.d.ts +12 -4
  77. package/lib/components/Gamepad.js +16 -8
  78. package/lib/components/LongLoad.d.ts +7 -1
  79. package/lib/components/LongLoad.js +7 -1
  80. package/lib/components/SnapshotUI.d.ts +10 -0
  81. package/lib/components/SnapshotUI.js +24 -0
  82. package/lib/context.d.ts +117 -0
  83. package/lib/context.js +50 -71
  84. package/lib/contexts/analyticscontext.d.ts +6 -0
  85. package/lib/contexts/analyticscontext.js +6 -0
  86. package/lib/contexts/audiocontextcontext.d.ts +26 -1
  87. package/lib/contexts/audiocontextcontext.js +26 -1
  88. package/lib/contexts/canvascontext.d.ts +59 -1
  89. package/lib/contexts/canvascontext.js +54 -1
  90. package/lib/contexts/cookieconsentcontext.d.ts +84 -10
  91. package/lib/contexts/cookieconsentcontext.js +71 -0
  92. package/lib/contexts/environmentcontext.d.ts +40 -5
  93. package/lib/contexts/environmentcontext.js +40 -5
  94. package/lib/contexts/gamepadcontext.d.ts +38 -0
  95. package/lib/contexts/gamepadcontext.js +38 -0
  96. package/lib/contexts/gesturecontext.d.ts +31 -4
  97. package/lib/contexts/gesturecontext.js +28 -4
  98. package/lib/contexts/globaltagcontext.d.ts +14 -2
  99. package/lib/contexts/globaltagcontext.js +13 -1
  100. package/lib/contexts/loadcontext.d.ts +92 -5
  101. package/lib/contexts/loadcontext.js +98 -11
  102. package/lib/contexts/orientationcontext.d.ts +58 -1
  103. package/lib/contexts/orientationcontext.js +51 -1
  104. package/lib/contexts/snapshotContext.d.ts +97 -4
  105. package/lib/contexts/snapshotContext.js +115 -4
  106. package/lib/contexts/tagcontext.d.ts +56 -2
  107. package/lib/contexts/tagcontext.js +77 -7
  108. package/lib/contexts/textalertcontext.d.ts +35 -2
  109. package/lib/contexts/textalertcontext.js +20 -2
  110. package/lib/contexts/usereventcontext.d.ts +29 -0
  111. package/lib/contexts/usereventcontext.js +30 -1
  112. package/lib/data/animation.d.ts +163 -0
  113. package/lib/data/animation.js +9 -0
  114. package/lib/data/change.d.ts +199 -0
  115. package/lib/data/change.js +190 -0
  116. package/lib/emitter.d.ts +8 -1
  117. package/lib/emitter.js +7 -0
  118. package/lib/entity.d.ts +30 -5
  119. package/lib/entity.js +23 -7
  120. package/lib/event.d.ts +19 -2
  121. package/lib/event.js +19 -2
  122. package/lib/fractionalindexing.js +38 -42
  123. package/lib/inflate.d.ts +68 -0
  124. package/lib/inflate.js +76 -0
  125. package/lib/observable.d.ts +3 -3
  126. package/lib/observable.js +4 -4
  127. package/lib/profile.d.ts +27 -0
  128. package/lib/profile.js +26 -0
  129. package/lib/selectors.d.ts +114 -0
  130. package/lib/selectors.js +159 -7
  131. package/lib/types.d.ts +215 -0
  132. package/lib/types.js +110 -1
  133. package/lib/validators.d.ts +27 -0
  134. package/lib/validators.js +27 -0
  135. package/lib/values/values.d.ts +5 -0
  136. package/lib/values/values.js +5 -0
  137. package/lib/zcomponent.d.ts +72 -0
  138. package/lib/zcomponent.js +81 -0
  139. package/lib/zcomponentconstruction.d.ts +11 -1
  140. package/lib/zcomponentconstruction.js +10 -0
  141. package/package.json +7 -2
@@ -1,5 +1,17 @@
1
- import { Component } from "../component";
2
- import { Context } from "../context";
1
+ import { Component } from '../component';
2
+ import { Context } from '../context';
3
+ import { Event } from '../event';
4
+ /**
5
+ * Manages the association between global tags and components.
6
+ * @zcontext
7
+ */
3
8
  export declare class GlobalTagContext extends Context {
9
+ /**
10
+ * A map storing the relationship between global tags and sets of components.
11
+ */
4
12
  readonly componentsByGlobalTag: Map<string, Set<Component<any, import("../component").ConstructorProps>>>;
13
+ /**
14
+ * An event that's emitted when the set of components that constitute a tag changes.
15
+ */
16
+ readonly onTagChange: Event<[string]>;
5
17
  }
@@ -1,7 +1,19 @@
1
- import { Context } from "../context";
1
+ import { Context } from '../context';
2
+ import { Event } from '../event';
3
+ /**
4
+ * Manages the association between global tags and components.
5
+ * @zcontext
6
+ */
2
7
  export class GlobalTagContext extends Context {
3
8
  constructor() {
4
9
  super(...arguments);
10
+ /**
11
+ * A map storing the relationship between global tags and sets of components.
12
+ */
5
13
  this.componentsByGlobalTag = new Map();
14
+ /**
15
+ * An event that's emitted when the set of components that constitute a tag changes.
16
+ */
17
+ this.onTagChange = new Event();
6
18
  }
7
19
  }
@@ -28,15 +28,35 @@ import { Observable } from '../observable';
28
28
  *
29
29
  * @zcontext */
30
30
  export declare class LoadContext extends Context {
31
- /** @zui */
31
+ /**
32
+ * Observable indicating whether the root component's construction is complete.
33
+ * This is typically set to true immediately after the root component and its children are constructed.
34
+ * @zui
35
+ */
32
36
  readonly isConstructed: Observable<boolean, never>;
33
- /** @zui */
37
+ /**
38
+ * Observable indicating whether all loadable processes have completed.
39
+ * This is true when all assets and dependencies required for the experience are fully loaded.
40
+ * @zui
41
+ */
34
42
  readonly isLoaded: Observable<boolean, never>;
35
- /** @zui */
43
+ /**
44
+ * Observable indicating whether the experience has started.
45
+ * This becomes true at the point where the experience transitions from loading to active interaction.
46
+ * @zui
47
+ */
36
48
  readonly isStarted: Observable<boolean, never>;
37
- /** @zui */
49
+ /**
50
+ * Observable indicating whether the experience has been launched.
51
+ * This is set to true typically when the user interacts with a splash screen or an initial launch button.
52
+ * @zui
53
+ */
38
54
  readonly isLaunched: Observable<boolean, never>;
39
- /** @zui */
55
+ /**
56
+ * Observable representing the progress percentage of loadable processes.
57
+ * This provides a numerical value representing the completion percentage of all loading operations.
58
+ * @zui
59
+ */
40
60
  readonly progressPercent: Observable<number, never>;
41
61
  private _startedResolved;
42
62
  readonly started: Promise<void>;
@@ -48,27 +68,94 @@ export declare class LoadContext extends Context {
48
68
  private _startWhenLoaded;
49
69
  private _totalLoadables;
50
70
  private _loadedCount;
71
+ /**
72
+ * Start the experience.
73
+ */
51
74
  start(): void;
75
+ /**
76
+ * Called when the root component's constructor (and thus any recursive children) has finished.
77
+ */
52
78
  constructionComplete(): void;
79
+ /**
80
+ * Called when the user taps on a splash screen's 'launch' button or, in the case that there's no launch
81
+ */
53
82
  launch(): void;
54
83
  private _update;
84
+ /**
85
+ * Start the experience when all loadables have completed.
86
+ */
55
87
  startWhenLoaded(): void;
88
+ /**
89
+ * Register a loadable process.
90
+ */
56
91
  registerLoadable(p: Promise<any>): void;
57
92
  }
93
+ /**
94
+ * Returns an observable that indicates whether the experience is loaded.
95
+ */
58
96
  export declare function useIsLoaded(mgr: ContextManager): Observable<boolean, never>;
97
+ /**
98
+ * Returns a value that indicates whether the experience is loaded.
99
+ */
59
100
  export declare function isLoaded(mgr: ContextManager): boolean;
101
+ /**
102
+ * Returns an observable that indicates whether the experience is started.
103
+ */
60
104
  export declare function useIsStarted(mgr: ContextManager): Observable<boolean, never>;
105
+ /**
106
+ * Returns a value that indicates whether the experience is started.
107
+ */
61
108
  export declare function isStarted(mgr: ContextManager): boolean;
109
+ /**
110
+ * Returns an observable that indicates whether the experience is constructed.
111
+ */
62
112
  export declare function useIsConstructed(mgr: ContextManager): Observable<boolean, never>;
113
+ /**
114
+ * Returns a value that indicates whether the experience is constructed.
115
+ */
63
116
  export declare function isConstructed(mgr: ContextManager): boolean;
117
+ /**
118
+ * Returns an observable that indicates whether the experience is launched.
119
+ */
64
120
  export declare function useIsLaunched(mgr: ContextManager): Observable<boolean, never>;
121
+ /**
122
+ * Returns a value that indicates whether the experience is launched.
123
+ */
65
124
  export declare function isLaunched(mgr: ContextManager): boolean;
125
+ /**
126
+ * Returns an observable that indicates the percentage of loadables that have completed.
127
+ */
66
128
  export declare function useLoadPercent(mgr: ContextManager): Observable<number, never>;
129
+ /**
130
+ * Register a loadable process.
131
+ */
67
132
  export declare function registerLoadable(mgr: ContextManager, p: Promise<any>): void;
133
+ /**
134
+ * Starts the experience.
135
+ */
68
136
  export declare function start(mgr: ContextManager): void;
137
+ /**
138
+ * Launches the experience.
139
+ */
69
140
  export declare function launch(mgr: ContextManager): void;
141
+ /**
142
+ * Starts the experience when all loadables have completed.
143
+ */
70
144
  export declare function startWhenLoaded(mgr: ContextManager): void;
145
+ /**
146
+ * Returns a promise that resolves when the experience has started.
147
+ */
71
148
  export declare function started(mgr: ContextManager): Promise<void>;
149
+ /**
150
+ * Returns a promise that resolves when the root component's constructor (and thus any recursive children) has finished.
151
+ */
72
152
  export declare function constructed(mgr: ContextManager): Promise<void>;
153
+ /**
154
+ * Returns a promise that resolves when the user taps on a splash screen's 'launch' button or, in the case that there's no launch
155
+ * button, after construction.
156
+ */
73
157
  export declare function launched(mgr: ContextManager): Promise<void>;
158
+ /**
159
+ * Marks the root component's constructor (and thus any recursive children) as finished.
160
+ */
74
161
  export declare function constructionComplete(mgr: ContextManager): void;
@@ -30,24 +30,47 @@ import { Observable } from '../observable';
30
30
  export class LoadContext extends Context {
31
31
  constructor() {
32
32
  super(...arguments);
33
- /** @zui */
33
+ /**
34
+ * Observable indicating whether the root component's construction is complete.
35
+ * This is typically set to true immediately after the root component and its children are constructed.
36
+ * @zui
37
+ */
34
38
  this.isConstructed = new Observable(false);
35
- /** @zui */
39
+ /**
40
+ * Observable indicating whether all loadable processes have completed.
41
+ * This is true when all assets and dependencies required for the experience are fully loaded.
42
+ * @zui
43
+ */
36
44
  this.isLoaded = new Observable(false);
37
- /** @zui */
45
+ /**
46
+ * Observable indicating whether the experience has started.
47
+ * This becomes true at the point where the experience transitions from loading to active interaction.
48
+ * @zui
49
+ */
38
50
  this.isStarted = new Observable(false);
39
- /** @zui */
51
+ /**
52
+ * Observable indicating whether the experience has been launched.
53
+ * This is set to true typically when the user interacts with a splash screen or an initial launch button.
54
+ * @zui
55
+ */
40
56
  this.isLaunched = new Observable(false);
41
- /** @zui */
57
+ /**
58
+ * Observable representing the progress percentage of loadable processes.
59
+ * This provides a numerical value representing the completion percentage of all loading operations.
60
+ * @zui
61
+ */
42
62
  this.progressPercent = new Observable(0);
43
- this.started = new Promise(resolve => this._startedResolved = resolve);
44
- this.constructed = new Promise(resolve => this._constructedResolved = resolve);
45
- this.launched = new Promise(resolve => this._launchedResolved = resolve);
63
+ this.started = new Promise(resolve => (this._startedResolved = resolve));
64
+ this.constructed = new Promise(resolve => (this._constructedResolved = resolve));
65
+ this.launched = new Promise(resolve => (this._launchedResolved = resolve));
46
66
  this._loadables = new Set();
47
67
  this._startWhenLoaded = false;
48
68
  this._totalLoadables = 0;
49
69
  this._loadedCount = 0;
50
70
  }
71
+ /**
72
+ * Start the experience.
73
+ */
51
74
  start() {
52
75
  if (this.isStarted.value)
53
76
  return;
@@ -56,17 +79,23 @@ export class LoadContext extends Context {
56
79
  this.isStarted.value = true;
57
80
  this._startedResolved?.();
58
81
  }
82
+ /**
83
+ * Called when the root component's constructor (and thus any recursive children) has finished.
84
+ */
59
85
  constructionComplete() {
60
86
  if (this.isConstructed.value)
61
87
  return;
62
88
  this.isConstructed.value = true;
63
89
  this._constructedResolved();
64
90
  }
91
+ /**
92
+ * Called when the user taps on a splash screen's 'launch' button or, in the case that there's no launch
93
+ */
65
94
  launch() {
66
95
  if (this.isLaunched.value)
67
96
  return;
68
97
  if (document.body)
69
- document.body.classList.add("zcomponent-launched");
98
+ document.body.classList.add('zcomponent-launched');
70
99
  this.isLaunched.value = true;
71
100
  this._launchedResolved();
72
101
  }
@@ -79,17 +108,23 @@ export class LoadContext extends Context {
79
108
  if (this._loadables.size === 0 && this.isLoaded.value === false) {
80
109
  this.isLoaded.value = true;
81
110
  if (document.body)
82
- document.body.classList.add("zcomponent-loaded");
111
+ document.body.classList.add('zcomponent-loaded');
83
112
  }
84
- this.progressPercent.value = this.isLoaded.value ? 100 : (100 * this._loadedCount / this._totalLoadables);
113
+ this.progressPercent.value = this.isLoaded.value ? 100 : (100 * this._loadedCount) / this._totalLoadables;
85
114
  if (this._startWhenLoaded && this.isLoaded.value && !this.isStarted.value) {
86
115
  this.start();
87
116
  }
88
117
  }
118
+ /**
119
+ * Start the experience when all loadables have completed.
120
+ */
89
121
  startWhenLoaded() {
90
122
  this._startWhenLoaded = true;
91
123
  this._update();
92
124
  }
125
+ /**
126
+ * Register a loadable process.
127
+ */
93
128
  registerLoadable(p) {
94
129
  if (this.disposed)
95
130
  return;
@@ -105,54 +140,106 @@ export class LoadContext extends Context {
105
140
  this._update();
106
141
  }
107
142
  }
143
+ /**
144
+ * Returns an observable that indicates whether the experience is loaded.
145
+ */
108
146
  export function useIsLoaded(mgr) {
109
147
  return mgr.get(LoadContext).isLoaded;
110
148
  }
149
+ /**
150
+ * Returns a value that indicates whether the experience is loaded.
151
+ */
111
152
  export function isLoaded(mgr) {
112
153
  return mgr.get(LoadContext).isLoaded.value;
113
154
  }
155
+ /**
156
+ * Returns an observable that indicates whether the experience is started.
157
+ */
114
158
  export function useIsStarted(mgr) {
115
159
  return mgr.get(LoadContext).isStarted;
116
160
  }
161
+ /**
162
+ * Returns a value that indicates whether the experience is started.
163
+ */
117
164
  export function isStarted(mgr) {
118
165
  return mgr.get(LoadContext).isStarted.value;
119
166
  }
167
+ /**
168
+ * Returns an observable that indicates whether the experience is constructed.
169
+ */
120
170
  export function useIsConstructed(mgr) {
121
171
  return mgr.get(LoadContext).isConstructed;
122
172
  }
173
+ /**
174
+ * Returns a value that indicates whether the experience is constructed.
175
+ */
123
176
  export function isConstructed(mgr) {
124
177
  return mgr.get(LoadContext).isConstructed.value;
125
178
  }
179
+ /**
180
+ * Returns an observable that indicates whether the experience is launched.
181
+ */
126
182
  export function useIsLaunched(mgr) {
127
183
  return mgr.get(LoadContext).isLaunched;
128
184
  }
185
+ /**
186
+ * Returns a value that indicates whether the experience is launched.
187
+ */
129
188
  export function isLaunched(mgr) {
130
189
  return mgr.get(LoadContext).isLaunched.value;
131
190
  }
191
+ /**
192
+ * Returns an observable that indicates the percentage of loadables that have completed.
193
+ */
132
194
  export function useLoadPercent(mgr) {
133
195
  return mgr.get(LoadContext).progressPercent;
134
196
  }
197
+ /**
198
+ * Register a loadable process.
199
+ */
135
200
  export function registerLoadable(mgr, p) {
136
201
  return mgr.get(LoadContext).registerLoadable(p);
137
202
  }
203
+ /**
204
+ * Starts the experience.
205
+ */
138
206
  export function start(mgr) {
139
207
  return mgr.get(LoadContext).start();
140
208
  }
209
+ /**
210
+ * Launches the experience.
211
+ */
141
212
  export function launch(mgr) {
142
213
  return mgr.get(LoadContext).launch();
143
214
  }
215
+ /**
216
+ * Starts the experience when all loadables have completed.
217
+ */
144
218
  export function startWhenLoaded(mgr) {
145
219
  return mgr.get(LoadContext).startWhenLoaded();
146
220
  }
221
+ /**
222
+ * Returns a promise that resolves when the experience has started.
223
+ */
147
224
  export function started(mgr) {
148
225
  return mgr.get(LoadContext).started;
149
226
  }
227
+ /**
228
+ * Returns a promise that resolves when the root component's constructor (and thus any recursive children) has finished.
229
+ */
150
230
  export function constructed(mgr) {
151
231
  return mgr.get(LoadContext).constructed;
152
232
  }
233
+ /**
234
+ * Returns a promise that resolves when the user taps on a splash screen's 'launch' button or, in the case that there's no launch
235
+ * button, after construction.
236
+ */
153
237
  export function launched(mgr) {
154
238
  return mgr.get(LoadContext).launched;
155
239
  }
240
+ /**
241
+ * Marks the root component's constructor (and thus any recursive children) as finished.
242
+ */
156
243
  export function constructionComplete(mgr) {
157
244
  return mgr.get(LoadContext).constructionComplete();
158
245
  }
@@ -8,31 +8,58 @@ export declare enum Orientation {
8
8
  LandscapeSecondary = "landscape-secondary"
9
9
  }
10
10
  /**
11
+ * Manages and tracks orientation changes in the application context.
11
12
  * @zcontext
12
13
  */
13
14
  export declare class OrientationContext extends Context {
14
15
  /**
16
+ * Observable indicating whether the current orientation is portrait.
15
17
  * @zui
16
18
  */
17
19
  readonly isPortrait: Observable<boolean>;
18
20
  /**
21
+ * Observable indicating whether the current orientation is landscape.
19
22
  * @zui
20
23
  */
21
24
  readonly isLandscape: Observable<boolean>;
22
25
  /**
26
+ * Observable indicating whether the current orientation is secondary portrait.
23
27
  * @zui
24
28
  */
25
29
  readonly isPortraitSecondary: Observable<boolean>;
26
30
  /**
31
+ * Observable indicating whether the current orientation is secondary landscape.
27
32
  * @zui
28
33
  */
29
34
  readonly isLandscapeSecondary: Observable<boolean>;
30
- readonly onOrientationChange: Event<[Orientation]>;
35
+ /**
36
+ * Observable representing the current orientation.
37
+ */
31
38
  readonly orientation: Observable<Orientation>;
39
+ /**
40
+ * Event triggered when the orientation changes to portrait.
41
+ */
32
42
  readonly onPortrait: Event<[void]>;
43
+ /**
44
+ * Event triggered when the orientation changes to landscape.
45
+ */
33
46
  readonly onLandscape: Event<[void]>;
47
+ /**
48
+ * Event triggered when the orientation changes to secondary portrait.
49
+ */
34
50
  readonly onPortraitSecondary: Event<[void]>;
51
+ /**
52
+ * Event triggered when the orientation changes to secondary landscape.
53
+ */
35
54
  readonly onLandscapeSecondary: Event<[void]>;
55
+ /**
56
+ * Event triggered when there is any orientation change.
57
+ */
58
+ readonly onOrientationChange: Event<[Orientation]>;
59
+ /**
60
+ * Creates an instance of OrientationContext.
61
+ * @param contextManager - The current ContextManager
62
+ */
36
63
  constructor(contextManager: ContextManager);
37
64
  private attachListeners;
38
65
  private _onOrientationChange;
@@ -43,9 +70,39 @@ export declare class OrientationContext extends Context {
43
70
  private getOrientationFromDimensions;
44
71
  dispose: () => never;
45
72
  }
73
+ /**
74
+ * Returns an observable that notifies when the orientation changes.
75
+ * @param mgr The ContextManager instance to access the OrientationContext.
76
+ * @returns Observable for orientation change events.
77
+ */
46
78
  export declare function useOnOrientationChange(mgr: ContextManager): Event<[Orientation]>;
79
+ /**
80
+ * Retrieves the current orientation value.
81
+ * @param mgr The ContextManager instance to access the OrientationContext.
82
+ * @returns The current orientation as an Orientation enum value.
83
+ */
47
84
  export declare function getOrientation(mgr: ContextManager): Orientation;
85
+ /**
86
+ * Determines if the current orientation is portrait.
87
+ * @param mgr The ContextManager instance to access the OrientationContext.
88
+ * @returns True if the orientation is portrait, false otherwise.
89
+ */
48
90
  export declare function isPortrait(mgr: ContextManager): boolean;
91
+ /**
92
+ * Determines if the current orientation is landscape.
93
+ * @param mgr The ContextManager instance to access the OrientationContext.
94
+ * @returns True if the orientation is landscape, false otherwise.
95
+ */
49
96
  export declare function isLandscape(mgr: ContextManager): boolean;
97
+ /**
98
+ * Determines if the current orientation is secondary portrait.
99
+ * @param mgr The ContextManager instance to access the OrientationContext.
100
+ * @returns True if the orientation is secondary portrait, false otherwise.
101
+ */
50
102
  export declare function isPortraitSecondary(mgr: ContextManager): boolean;
103
+ /**
104
+ * Determines if the current orientation is secondary landscape.
105
+ * @param mgr The ContextManager instance to access the OrientationContext.
106
+ * @returns True if the orientation is secondary landscape, false otherwise.
107
+ */
51
108
  export declare function isLandscapeSecondary(mgr: ContextManager): boolean;
@@ -9,16 +9,36 @@ export var Orientation;
9
9
  Orientation["LandscapeSecondary"] = "landscape-secondary";
10
10
  })(Orientation || (Orientation = {}));
11
11
  /**
12
+ * Manages and tracks orientation changes in the application context.
12
13
  * @zcontext
13
14
  */
14
15
  export class OrientationContext extends Context {
16
+ /**
17
+ * Creates an instance of OrientationContext.
18
+ * @param contextManager - The current ContextManager
19
+ */
15
20
  constructor(contextManager) {
16
21
  super(contextManager, {});
17
- this.onOrientationChange = new Event();
22
+ /**
23
+ * Event triggered when the orientation changes to portrait.
24
+ */
18
25
  this.onPortrait = new Event();
26
+ /**
27
+ * Event triggered when the orientation changes to landscape.
28
+ */
19
29
  this.onLandscape = new Event();
30
+ /**
31
+ * Event triggered when the orientation changes to secondary portrait.
32
+ */
20
33
  this.onPortraitSecondary = new Event();
34
+ /**
35
+ * Event triggered when the orientation changes to secondary landscape.
36
+ */
21
37
  this.onLandscapeSecondary = new Event();
38
+ /**
39
+ * Event triggered when there is any orientation change.
40
+ */
41
+ this.onOrientationChange = new Event();
22
42
  this.attachListeners = () => {
23
43
  this.orientation.addListener(this._onOrientationChange);
24
44
  window.addEventListener('resize', this.orientationChangeHandler);
@@ -104,21 +124,51 @@ export class OrientationContext extends Context {
104
124
  return window.innerWidth > window.innerHeight ? Orientation.Landscape : Orientation.Portrait;
105
125
  }
106
126
  }
127
+ /**
128
+ * Returns an observable that notifies when the orientation changes.
129
+ * @param mgr The ContextManager instance to access the OrientationContext.
130
+ * @returns Observable for orientation change events.
131
+ */
107
132
  export function useOnOrientationChange(mgr) {
108
133
  return mgr.get(OrientationContext).onOrientationChange;
109
134
  }
135
+ /**
136
+ * Retrieves the current orientation value.
137
+ * @param mgr The ContextManager instance to access the OrientationContext.
138
+ * @returns The current orientation as an Orientation enum value.
139
+ */
110
140
  export function getOrientation(mgr) {
111
141
  return mgr.get(OrientationContext).orientation.value;
112
142
  }
143
+ /**
144
+ * Determines if the current orientation is portrait.
145
+ * @param mgr The ContextManager instance to access the OrientationContext.
146
+ * @returns True if the orientation is portrait, false otherwise.
147
+ */
113
148
  export function isPortrait(mgr) {
114
149
  return mgr.get(OrientationContext).isPortrait.value;
115
150
  }
151
+ /**
152
+ * Determines if the current orientation is landscape.
153
+ * @param mgr The ContextManager instance to access the OrientationContext.
154
+ * @returns True if the orientation is landscape, false otherwise.
155
+ */
116
156
  export function isLandscape(mgr) {
117
157
  return mgr.get(OrientationContext).isLandscape.value;
118
158
  }
159
+ /**
160
+ * Determines if the current orientation is secondary portrait.
161
+ * @param mgr The ContextManager instance to access the OrientationContext.
162
+ * @returns True if the orientation is secondary portrait, false otherwise.
163
+ */
119
164
  export function isPortraitSecondary(mgr) {
120
165
  return mgr.get(OrientationContext).isPortraitSecondary.value;
121
166
  }
167
+ /**
168
+ * Determines if the current orientation is secondary landscape.
169
+ * @param mgr The ContextManager instance to access the OrientationContext.
170
+ * @returns True if the orientation is secondary landscape, false otherwise.
171
+ */
122
172
  export function isLandscapeSecondary(mgr) {
123
173
  return mgr.get(OrientationContext).isLandscapeSecondary.value;
124
174
  }