@rxap/form-system 18.1.3 → 18.2.0-dev.1

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 (29) hide show
  1. package/CHANGELOG.md +13 -0
  2. package/compodoc/changelog.html +25 -0
  3. package/compodoc/dependencies.html +18 -14
  4. package/compodoc/directives/AutocompleteOptionsFromMethodDirective.html +1367 -0
  5. package/compodoc/directives/FormArrayItemButton.html +58 -19
  6. package/compodoc/directives/FormArrayItemRemoveButtonDirective.html +113 -10
  7. package/compodoc/directives/FormArrayItemRestoreButtonDirective.html +43 -5
  8. package/compodoc/directives/FormArrayRemovableDirective.html +25 -20
  9. package/compodoc/directives/OptionsFromMethodDirective.html +71 -66
  10. package/compodoc/interfaces/AutocompleteOptionsFromMethodDirectiveParameters.html +512 -0
  11. package/compodoc/interfaces/AutocompleteOptionsFromMethodDirectiveSettings.html +518 -0
  12. package/compodoc/interfaces/AutocompleteOptionsFromRemoteMethodTemplateContext.html +506 -0
  13. package/compodoc/interfaces/OptionsFromMethodDirectiveSettings.html +26 -14
  14. package/compodoc/interfaces/OptionsFromMethodTemplateContext.html +26 -14
  15. package/compodoc/js/menu-wc.js +12 -0
  16. package/compodoc/js/menu-wc_es5.js +1 -1
  17. package/compodoc/js/search/search_index.js +2 -2
  18. package/compodoc/miscellaneous/functions.html +356 -0
  19. package/compodoc/overview.html +2 -2
  20. package/compodoc/properties.html +1 -1
  21. package/esm2022/index.mjs +2 -1
  22. package/esm2022/lib/directives/autocomplete-options-from-method.directive.mjs +168 -0
  23. package/esm2022/lib/directives/options-from-method.directive.mjs +17 -7
  24. package/fesm2022/rxap-form-system.mjs +250 -83
  25. package/fesm2022/rxap-form-system.mjs.map +1 -1
  26. package/index.d.ts +1 -0
  27. package/lib/directives/autocomplete-options-from-method.directive.d.ts +71 -0
  28. package/lib/directives/options-from-method.directive.d.ts +6 -6
  29. package/package.json +29 -27
@@ -0,0 +1,506 @@
1
+ <!doctype html>
2
+ <html class="no-js" lang="">
3
+ <head>
4
+ <meta charset="utf-8">
5
+ <meta http-equiv="x-ua-compatible" content="ie=edge">
6
+ <title>angular-form-system</title>
7
+ <meta name="description" content="">
8
+ <meta name="viewport" content="width=device-width, initial-scale=1">
9
+
10
+ <link rel="icon" type="image/x-icon" href="../images/favicon.ico">
11
+ <link rel="stylesheet" href="../styles/style.css">
12
+ <link rel="stylesheet" href="../styles/dark.css">
13
+ </head>
14
+ <body>
15
+ <script>
16
+ // Blocking script to avoid flickering dark mode
17
+ // Dark mode toggle button
18
+ var useDark = window.matchMedia('(prefers-color-scheme: dark)');
19
+ var darkModeState = useDark.matches;
20
+ var $darkModeToggleSwitchers = document.querySelectorAll('.dark-mode-switch input');
21
+ var $darkModeToggles = document.querySelectorAll('.dark-mode-switch');
22
+ var darkModeStateLocal = localStorage.getItem('compodoc_darkmode-state');
23
+
24
+ function checkToggle(check) {
25
+ for (var i = 0; i < $darkModeToggleSwitchers.length; i++) {
26
+ $darkModeToggleSwitchers[i].checked = check;
27
+ }
28
+ }
29
+
30
+ function toggleDarkMode(state) {
31
+ if (window.localStorage) {
32
+ localStorage.setItem('compodoc_darkmode-state', state);
33
+ }
34
+
35
+ checkToggle(state);
36
+
37
+ const hasClass = document.body.classList.contains('dark');
38
+
39
+ if (state) {
40
+ for (var i = 0; i < $darkModeToggles.length; i++) {
41
+ $darkModeToggles[i].classList.add('dark');
42
+ }
43
+ if (!hasClass) {
44
+ document.body.classList.add('dark');
45
+ }
46
+ } else {
47
+ for (var i = 0; i < $darkModeToggles.length; i++) {
48
+ $darkModeToggles[i].classList.remove('dark');
49
+ }
50
+ if (hasClass) {
51
+ document.body.classList.remove('dark');
52
+ }
53
+ }
54
+ }
55
+
56
+ useDark.addEventListener('change', function (evt) {
57
+ toggleDarkMode(evt.matches);
58
+ });
59
+ if (darkModeStateLocal) {
60
+ darkModeState = darkModeStateLocal === 'true';
61
+ }
62
+ toggleDarkMode(darkModeState);
63
+ </script>
64
+
65
+ <div class="navbar navbar-default navbar-fixed-top d-md-none p-0">
66
+ <div class="d-flex">
67
+ <a href="../" class="navbar-brand">angular-form-system</a>
68
+ <button type="button" class="btn btn-default btn-menu ion-ios-menu" id="btn-menu"></button>
69
+ </div>
70
+ </div>
71
+
72
+ <div class="xs-menu menu" id="mobile-menu">
73
+ <div id="book-search-input" role="search"><input type="text" placeholder="Type to search"></div> <compodoc-menu></compodoc-menu>
74
+ </div>
75
+
76
+ <div class="container-fluid main">
77
+ <div class="row main">
78
+ <div class="d-none d-md-block menu">
79
+ <compodoc-menu mode="normal"></compodoc-menu>
80
+ </div>
81
+ <!-- START CONTENT -->
82
+ <div class="content interface">
83
+ <div class="content-data">
84
+
85
+
86
+
87
+
88
+
89
+
90
+
91
+
92
+
93
+
94
+
95
+
96
+
97
+ <ol class="breadcrumb">
98
+ <li class="breadcrumb-item">Interfaces</li>
99
+ <li class="breadcrumb-item"
100
+ >
101
+ AutocompleteOptionsFromRemoteMethodTemplateContext</li>
102
+ </ol>
103
+
104
+ <ul class="nav nav-tabs" role="tablist">
105
+ <li class="nav-item">
106
+ <a href="#info"
107
+ class="nav-link"
108
+ class="nav-link active"
109
+ role="tab" id="info-tab" data-bs-toggle="tab" data-link="info">Info</a>
110
+ </li>
111
+ <li class="nav-item">
112
+ <a href="#readme"
113
+ class="nav-link"
114
+
115
+ role="tab" id="readme-tab" data-bs-toggle="tab" data-link="readme">README</a>
116
+ </li>
117
+ <li class="nav-item">
118
+ <a href="#source"
119
+ class="nav-link"
120
+
121
+ role="tab" id="source-tab" data-bs-toggle="tab" data-link="source">Source</a>
122
+ </li>
123
+ </ul>
124
+
125
+ <div class="tab-content">
126
+ <div class="tab-pane fade active in" id="info">
127
+ <p class="comment">
128
+ <h3>File</h3>
129
+ </p>
130
+ <p class="comment">
131
+ <code>src/lib/directives/autocomplete-options-from-method.directive.ts</code>
132
+ </p>
133
+
134
+
135
+
136
+
137
+ <section data-compodoc="block-index">
138
+ <h3 id="index">Index</h3>
139
+ <table class="table table-sm table-bordered index-table">
140
+ <tbody>
141
+ <tr>
142
+ <td class="col-md-4">
143
+ <h6><b>Properties</b></h6>
144
+ </td>
145
+ </tr>
146
+ <tr>
147
+ <td class="col-md-4">
148
+ <ul class="index-list">
149
+ <li>
150
+ <a href="#$implicit"
151
+ >
152
+ $implicit
153
+ </a>
154
+ </li>
155
+ </ul>
156
+ </td>
157
+ </tr>
158
+ </tbody>
159
+ </table>
160
+ </section>
161
+
162
+
163
+
164
+ <section data-compodoc="block-properties">
165
+ <h3 id="inputs">Properties</h3>
166
+ <table class="table table-sm table-bordered">
167
+ <tbody>
168
+ <tr>
169
+ <td class="col-md-4">
170
+ <a name="$implicit"></a>
171
+ <span class="name "><b>$implicit</b>
172
+ <a href="#$implicit">
173
+ <span class="icon ion-ios-link"></span>
174
+ </a>
175
+ </span>
176
+ </td>
177
+ </tr>
178
+ <tr>
179
+ <td class="col-md-4">
180
+ <code>$implicit: <code>ControlOption</code>
181
+ </code>
182
+ </td>
183
+ </tr>
184
+
185
+
186
+ <tr>
187
+ <td class="col-md-4">
188
+ <i>Type : </i> <code>ControlOption</code>
189
+
190
+ </td>
191
+ </tr>
192
+
193
+
194
+
195
+
196
+
197
+ </tbody>
198
+ </table>
199
+ </section>
200
+ </div>
201
+
202
+ <div class="tab-pane fade " id="readme">
203
+ <p><h1>Test</h1>
204
+ </p>
205
+ </div>
206
+
207
+ <div class="tab-pane fade tab-source-code" id="source">
208
+ <pre class="line-numbers compodoc-sourcecode"><code class="language-typescript">import {
209
+ AfterViewInit,
210
+ Directive,
211
+ inject,
212
+ Injector,
213
+ INJECTOR,
214
+ Input,
215
+ isDevMode,
216
+ OnDestroy,
217
+ ProviderToken,
218
+ } from &#x27;@angular/core&#x27;;
219
+ import { MatAutocomplete } from &#x27;@angular/material/autocomplete&#x27;;
220
+ import { ControlOption, ControlOptions } from &#x27;@rxap/utilities&#x27;;
221
+ import { distinctUntilChanged, Subscription, tap } from &#x27;rxjs&#x27;;
222
+ import { isUUID } from &#x27;@rxap/validator&#x27;;
223
+ import { Method, MethodWithParameters } from &#x27;@rxap/pattern&#x27;;
224
+ import { Mixin } from &#x27;@rxap/mixin&#x27;;
225
+ import { NgControl } from &#x27;@angular/forms&#x27;;
226
+ import { MatFormField } from &#x27;@angular/material/form-field&#x27;;
227
+ import { isDefined } from &#x27;@rxap/rxjs&#x27;;
228
+ import { UseMethodConfig } from &#x27;../mixins/extract-methods.mixin&#x27;;
229
+ import { UseOptionsMethod } from &#x27;../mixins/extract-options-method.mixin&#x27;;
230
+ import {
231
+ ExtractResolveMethodMixin,
232
+ UseResolveMethod,
233
+ } from &#x27;../mixins/extract-resolve-method.mixin&#x27;;
234
+ import { OptionsFromMethodDirective, OptionsFromMethodDirectiveSettings } from &#x27;./options-from-method.directive&#x27;;
235
+ import { OpenApiRemoteMethodParameter } from &#x27;@rxap/open-api/remote-method&#x27;;
236
+ import { controlValueChanges$ } from &#x27;@rxap/forms&#x27;;
237
+
238
+ export function UseAutocompleteOptionsMethod(
239
+ method: ProviderToken&lt;MethodWithParameters&lt;ControlOptions, AutocompleteOptionsFromMethodDirectiveParameters&gt;&gt;,
240
+ ): any;
241
+ export function UseAutocompleteOptionsMethod(
242
+ method: ProviderToken&lt;MethodWithParameters&lt;ControlOptions, OpenApiRemoteMethodParameter&lt;AutocompleteOptionsFromMethodDirectiveParameters&gt;&gt;&gt;,
243
+ ): any;
244
+ export function UseAutocompleteOptionsMethod(
245
+ method: ProviderToken&lt;MethodWithParameters&gt;,
246
+ config: UseMethodConfig&lt;ControlOptions, AutocompleteOptionsFromMethodDirectiveParameters&gt;,
247
+ ): any;
248
+ export function UseAutocompleteOptionsMethod(
249
+ method: ProviderToken&lt;MethodWithParameters&lt;ControlOptions, AutocompleteOptionsFromMethodDirectiveParameters | OpenApiRemoteMethodParameter&lt;AutocompleteOptionsFromMethodDirectiveParameters&gt;&gt;&gt;,
250
+ config: UseMethodConfig &#x3D; {},
251
+ ) {
252
+ config.adapter ??&#x3D; {};
253
+ config.adapter.parameter ??&#x3D; (parameters) &#x3D;&gt; ({parameters});
254
+ return UseOptionsMethod(method as any, config);
255
+ }
256
+
257
+ export function UseAutocompleteResolveMethod&lt;Value &#x3D; unknown&gt;(
258
+ method: ProviderToken&lt;MethodWithParameters&lt;ControlOption&lt;Value&gt;, OpenApiRemoteMethodParameter&lt;{ value: string }&gt;&gt;&gt;,
259
+ config: UseMethodConfig &#x3D; {},
260
+ ) {
261
+ config.adapter ??&#x3D; {};
262
+ config.adapter.parameter ??&#x3D; (parameters) &#x3D;&gt; ({parameters});
263
+ return UseResolveMethod(method, config);
264
+ }
265
+
266
+ export interface AutocompleteOptionsFromRemoteMethodTemplateContext {
267
+ $implicit: ControlOption;
268
+ }
269
+
270
+ export interface AutocompleteOptionsFromMethodDirectiveSettings extends OptionsFromMethodDirectiveSettings {
271
+ filteredOptions?: boolean;
272
+ }
273
+
274
+ export interface AutocompleteOptionsFromMethodDirectiveParameters&lt;Value &#x3D; any&gt; {
275
+ search?: Value | null;
276
+ }
277
+
278
+ // eslint-disable-next-line @typescript-eslint/no-empty-interface
279
+ export interface AutocompleteOptionsFromMethodDirective&lt;Value &#x3D; any, Parameters extends AutocompleteOptionsFromMethodDirectiveParameters&lt;Value&gt; &#x3D; AutocompleteOptionsFromMethodDirectiveParameters&lt;Value&gt;&gt;
280
+ extends ExtractResolveMethodMixin, AfterViewInit, OnDestroy {
281
+ }
282
+
283
+ @Mixin(ExtractResolveMethodMixin)
284
+ @Directive({
285
+ // eslint-disable-next-line @angular-eslint/directive-selector
286
+ selector: &#x27;[rxapAutocompleteOptionsFromMethod]&#x27;,
287
+ standalone: true,
288
+ })
289
+ export class AutocompleteOptionsFromMethodDirective&lt;Value &#x3D; any, Parameters extends AutocompleteOptionsFromMethodDirectiveParameters&lt;Value&gt; &#x3D; AutocompleteOptionsFromMethodDirectiveParameters&lt;Value&gt;&gt;
290
+ extends OptionsFromMethodDirective&lt;Value, Parameters&gt;
291
+ implements AfterViewInit, OnDestroy {
292
+
293
+ static override ngTemplateContextGuard(
294
+ dir: OptionsFromMethodDirective,
295
+ ctx: any,
296
+ ): ctx is AutocompleteOptionsFromRemoteMethodTemplateContext {
297
+ return true;
298
+ }
299
+
300
+ @Input(&#x27;rxapAutocompleteOptionsFromMethodParameters&#x27;)
301
+ public declare parameters?: Parameters;
302
+ @Input(&#x27;rxapAutocompleteOptionsFromMethodResetOnChange&#x27;)
303
+ public declare resetOnChange?: Value;
304
+ @Input(&#x27;rxapAutocompleteOptionsFromMethodMatAutocomplete&#x27;)
305
+ public matAutocomplete?: MatAutocomplete;
306
+ // eslint-disable-next-line @angular-eslint/no-input-rename
307
+ @Input(&#x27;rxapAutocompleteOptionsFromMethodCall&#x27;)
308
+ public declare method: Method&lt;ControlOptions, Parameters&gt;;
309
+ // eslint-disable-next-line @angular-eslint/no-input-rename
310
+ @Input(&#x27;rxapAutocompleteOptionsFromMethodResolve&#x27;)
311
+ public resolveMethod?: MethodWithParameters&lt;ControlOption, { value: Value } &amp; Parameters&gt;;
312
+ protected override ngControl: NgControl | null &#x3D; null;
313
+ protected override matFormField: MatFormField | null &#x3D; null;
314
+ protected override injector: Injector &#x3D; inject(INJECTOR);
315
+ protected override settings: AutocompleteOptionsFromMethodDirectiveSettings &#x3D; {};
316
+ /**
317
+ * This flag is used to prevent the setValue is called for each refresh
318
+ * of the options list. This is needed because the setValue method will
319
+ * trigger a new refresh of the options list. This results in an endless
320
+ * call stack. This flag is set to true if the setValue method is called
321
+ * once.
322
+ */
323
+ private isAutocompleteToDisplayTriggered &#x3D; false;
324
+
325
+ private _subscription?: Subscription;
326
+
327
+ public ngOnDestroy() {
328
+ this._subscription?.unsubscribe();
329
+ }
330
+
331
+ public override async ngAfterViewInit() {
332
+ if (this.matAutocomplete) {
333
+ this.matAutocomplete.displayWith &#x3D; this.toDisplay.bind(this);
334
+ this.settings ??&#x3D; {};
335
+ this.settings.filteredOptions ??&#x3D; true;
336
+ }
337
+ await super.ngAfterViewInit();
338
+ this.resolveMethod ??&#x3D; this.extractResolveMethod();
339
+ if (!this.control) {
340
+ throw new Error(&#x27;The control is not yet defined&#x27;);
341
+ }
342
+ const value$ &#x3D; controlValueChanges$(this.control);
343
+ this._subscription &#x3D; value$.pipe(
344
+ isDefined(),
345
+ // only trigger the load options or resolve value if the value is changed
346
+ // this is required because in the resolveValue method the control value is set
347
+ // to trigger the toDisplay function in the mat-autocomplete
348
+ distinctUntilChanged(),
349
+ tap(async value &#x3D;&gt; {
350
+ this.setOptions(await this.loadOptions(this.parameters));
351
+ if (this.isValue(value)) {
352
+ this.triggerAutocompleteToDisplay();
353
+ }
354
+ }),
355
+ ).subscribe();
356
+ }
357
+
358
+ public toDisplay(value: any): string {
359
+ if (!value) {
360
+ return &#x27;&#x27;;
361
+ }
362
+ const option &#x3D; this.findOptionByValue(value);
363
+ return option?.display ?? (isDevMode() ? &#x27;to display error&#x27; : &#x27;...&#x27;);
364
+ }
365
+
366
+ public isValue(value: any): boolean {
367
+ return typeof value &#x3D;&#x3D;&#x3D; &#x27;string&#x27; &amp;&amp; isUUID(value);
368
+ }
369
+
370
+ protected override loadOptions(parameters: Parameters &#x3D; {} as Parameters): Promise&lt;ControlOptions | null&gt; {
371
+ if (!this.control) {
372
+ throw new Error(&#x27;The control is not yet defined&#x27;);
373
+ }
374
+ const value &#x3D; this.control?.value;
375
+ const c_parameters &#x3D; {...parameters};
376
+ if (this.isValue(value)) {
377
+ return this.resolveValue(value, c_parameters);
378
+ } else {
379
+ c_parameters.search ??&#x3D; value;
380
+ if (!c_parameters.search) {
381
+ return Promise.resolve([]);
382
+ }
383
+ return super.loadOptions(c_parameters);
384
+ }
385
+ }
386
+
387
+ protected override renderTemplate() {
388
+ super.renderTemplate();
389
+ if (this.matAutocomplete &amp;&amp; !this.isAutocompleteToDisplayTriggered) {
390
+ this.isAutocompleteToDisplayTriggered &#x3D; true;
391
+ this.triggerAutocompleteToDisplay();
392
+ }
393
+ }
394
+
395
+ protected async resolveValue(value: Value, parameters: Parameters &#x3D; {} as Parameters) {
396
+ if (!this.resolveMethod) {
397
+ if (isDevMode()) {
398
+ console.warn(&#x27;The resolve method is not yet defined&#x27;);
399
+ }
400
+ return null;
401
+ }
402
+ // only resolve the value if the option is not already loaded
403
+ if (!this.findOptionByValue(value)) {
404
+ const option &#x3D; await this.resolveMethod!.call({...parameters, value});
405
+ if (option.value !&#x3D;&#x3D; value) {
406
+ throw new Error(&#x27;The resolved value is not the same as the input value&#x27;);
407
+ }
408
+ return [ option ];
409
+ }
410
+ return this.options;
411
+ }
412
+
413
+ private triggerAutocompleteToDisplay() {
414
+ // trigger a change detection after the options are rendered
415
+ // this is needed to trigger the mat-autocomplete options to display function
416
+ this.ngControl?.control?.setValue(this.ngControl?.control?.value);
417
+ }
418
+
419
+ private findOptionByValue(value: Value): ControlOption | null {
420
+ return this.options?.find((option: ControlOption) &#x3D;&gt; option.value &#x3D;&#x3D;&#x3D; value) ?? null;
421
+ }
422
+
423
+ }
424
+ </code></pre>
425
+ </div>
426
+ </div>
427
+
428
+
429
+
430
+
431
+
432
+
433
+
434
+
435
+ </div><div class="search-results">
436
+ <div class="has-results">
437
+ <h1 class="search-results-title"><span class='search-results-count'></span> results matching "<span class='search-query'></span>"</h1>
438
+ <ul class="search-results-list"></ul>
439
+ </div>
440
+ <div class="no-results">
441
+ <h1 class="search-results-title">No results matching "<span class='search-query'></span>"</h1>
442
+ </div>
443
+ </div>
444
+ </div>
445
+ <!-- END CONTENT -->
446
+ </div>
447
+ </div>
448
+
449
+ <label class="dark-mode-switch">
450
+ <input type="checkbox">
451
+ <span class="slider">
452
+ <svg class="slider-icon" viewBox="0 0 24 24" fill="none" height="20" stroke="#000" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" width="20" xmlns="http://www.w3.org/2000/svg">
453
+ <path d="M21 12.79A9 9 0 1111.21 3 7 7 0 0021 12.79z"></path>
454
+ </svg>
455
+ </span>
456
+ </label>
457
+
458
+ <script>
459
+ var COMPODOC_CURRENT_PAGE_DEPTH = 1;
460
+ var COMPODOC_CURRENT_PAGE_CONTEXT = 'interface';
461
+ var COMPODOC_CURRENT_PAGE_URL = 'AutocompleteOptionsFromRemoteMethodTemplateContext.html';
462
+ var MAX_SEARCH_RESULTS = 15;
463
+ </script>
464
+
465
+ <script>
466
+ $darkModeToggleSwitchers = document.querySelectorAll('.dark-mode-switch input');
467
+ checkToggle(darkModeState);
468
+ if ($darkModeToggleSwitchers.length > 0) {
469
+ for (var i = 0; i < $darkModeToggleSwitchers.length; i++) {
470
+ $darkModeToggleSwitchers[i].addEventListener('change', function (event) {
471
+ darkModeState = !darkModeState;
472
+ toggleDarkMode(darkModeState);
473
+ });
474
+ }
475
+ }
476
+ </script>
477
+
478
+ <script src="../js/libs/custom-elements.min.js"></script>
479
+ <script src="../js/libs/lit-html.js"></script>
480
+
481
+ <script src="../js/menu-wc.js" defer></script>
482
+ <script nomodule src="../js/menu-wc_es5.js" defer></script>
483
+
484
+ <script src="../js/libs/bootstrap-native.js"></script>
485
+
486
+ <script src="../js/libs/es6-shim.min.js"></script>
487
+ <script src="../js/libs/EventDispatcher.js"></script>
488
+ <script src="../js/libs/promise.min.js"></script>
489
+ <script src="../js/libs/zepto.min.js"></script>
490
+
491
+ <script src="../js/compodoc.js"></script>
492
+
493
+ <script src="../js/tabs.js"></script>
494
+ <script src="../js/menu.js"></script>
495
+ <script src="../js/libs/clipboard.min.js"></script>
496
+ <script src="../js/libs/prism.js"></script>
497
+ <script src="../js/sourceCode.js"></script>
498
+ <script src="../js/search/search.js"></script>
499
+ <script src="../js/search/lunr.min.js"></script>
500
+ <script src="../js/search/search-lunr.js"></script>
501
+ <script src="../js/search/search_index.js"></script>
502
+ <script src="../js/lazy-load-graphs.js"></script>
503
+
504
+
505
+ </body>
506
+ </html>
@@ -148,8 +148,12 @@
148
148
  TemplateRef,
149
149
  ViewContainerRef,
150
150
  } from &#x27;@angular/core&#x27;;
151
- import { NgControl } from &#x27;@angular/forms&#x27;;
151
+ import {
152
+ AbstractControlDirective,
153
+ NgControl,
154
+ } from &#x27;@angular/forms&#x27;;
152
155
  import { MatFormField } from &#x27;@angular/material/form-field&#x27;;
156
+ import { RxapFormControl } from &#x27;@rxap/forms&#x27;;
153
157
  import { Mixin } from &#x27;@rxap/mixin&#x27;;
154
158
  import { Method } from &#x27;@rxap/pattern&#x27;;
155
159
  import {
@@ -193,20 +197,23 @@ export class OptionsFromMethodDirective&lt;Value &#x3D; any, Parameters &#x3D; a
193
197
  @Input(&#x27;rxapOptionsFromMethodResetOnChange&#x27;)
194
198
  public resetOnChange?: Value;
195
199
 
196
- public options: ControlOptions | null &#x3D; null;
197
- protected ngControl: NgControl | null &#x3D; null;
198
- protected matFormField: MatFormField | null &#x3D; null;
199
- protected settings: OptionsFromMethodDirectiveSettings &#x3D; {};
200
- protected method!: Method&lt;ControlOptions, Parameters&gt;;
201
- protected readonly viewContainerRef: ViewContainerRef &#x3D; inject(ViewContainerRef);
202
- protected readonly injector: Injector &#x3D; inject(INJECTOR);
200
+ public options: ControlOptions | null &#x3D; null;
201
+ // eslint-disable-next-line @angular-eslint/no-input-rename
202
+ @Input(&#x27;rxapOptionsFromMethodCall&#x27;)
203
+ public method!: Method&lt;ControlOptions, Parameters&gt;;
204
+ protected ngControl: NgControl | AbstractControlDirective | null &#x3D; null;
205
+ protected matFormField: MatFormField | null &#x3D; null;
206
+ protected settings: OptionsFromMethodDirectiveSettings &#x3D; {};
207
+ protected readonly viewContainerRef: ViewContainerRef &#x3D; inject(ViewContainerRef);
208
+ protected readonly injector: Injector &#x3D; inject(INJECTOR);
203
209
  protected readonly cdr: ChangeDetectorRef &#x3D; inject(ChangeDetectorRef);
204
210
  private readonly template: TemplateRef&lt;OptionsFromMethodTemplateContext&gt; &#x3D; inject(TemplateRef);
205
211
 
206
212
  public async ngAfterViewInit() {
207
- this.ngControl &#x3D; this.injector.get(NgControl, null);
208
213
  this.matFormField &#x3D; this.injector.get(MatFormField, null);
209
- this.method &#x3D; this.extractOptionsMethod();
214
+ this.ngControl &#x3D; this.injector.get(NgControl, this.matFormField?._control.ngControl);
215
+ this.control &#x3D; (this.ngControl?.control as RxapFormControl) ?? undefined;
216
+ this.method ??&#x3D; this.extractOptionsMethod();
210
217
  // ensure that the options are loaded. It is possible that the ngOnChange is triggered before the ngAfterViewInit
211
218
  // then the options are not loaded.
212
219
  if (!this.options) {
@@ -227,7 +234,7 @@ export class OptionsFromMethodDirective&lt;Value &#x3D; any, Parameters &#x3D; a
227
234
  }
228
235
  }
229
236
 
230
- protected async loadOptions(parameters?: Parameters): Promise&lt;ControlOptions&gt; {
237
+ protected async loadOptions(parameters?: Parameters): Promise&lt;ControlOptions | null&gt; {
231
238
  return this.method.call(parameters);
232
239
  }
233
240
 
@@ -251,9 +258,14 @@ export class OptionsFromMethodDirective&lt;Value &#x3D; any, Parameters &#x3D; a
251
258
 
252
259
  }
253
260
 
254
- protected setOptions(options: ControlOptions) {
255
- this.options &#x3D; options.slice();
256
- this.renderTemplate();
261
+ protected setOptions(options: ControlOptions | null) {
262
+ if (!options) {
263
+ this.options &#x3D; null;
264
+ this.viewContainerRef.clear();
265
+ } else {
266
+ this.options &#x3D; options.slice();
267
+ this.renderTemplate();
268
+ }
257
269
  }
258
270
 
259
271
  }
@@ -208,8 +208,12 @@
208
208
  TemplateRef,
209
209
  ViewContainerRef,
210
210
  } from &#x27;@angular/core&#x27;;
211
- import { NgControl } from &#x27;@angular/forms&#x27;;
211
+ import {
212
+ AbstractControlDirective,
213
+ NgControl,
214
+ } from &#x27;@angular/forms&#x27;;
212
215
  import { MatFormField } from &#x27;@angular/material/form-field&#x27;;
216
+ import { RxapFormControl } from &#x27;@rxap/forms&#x27;;
213
217
  import { Mixin } from &#x27;@rxap/mixin&#x27;;
214
218
  import { Method } from &#x27;@rxap/pattern&#x27;;
215
219
  import {
@@ -253,20 +257,23 @@ export class OptionsFromMethodDirective&lt;Value &#x3D; any, Parameters &#x3D; a
253
257
  @Input(&#x27;rxapOptionsFromMethodResetOnChange&#x27;)
254
258
  public resetOnChange?: Value;
255
259
 
256
- public options: ControlOptions | null &#x3D; null;
257
- protected ngControl: NgControl | null &#x3D; null;
258
- protected matFormField: MatFormField | null &#x3D; null;
259
- protected settings: OptionsFromMethodDirectiveSettings &#x3D; {};
260
- protected method!: Method&lt;ControlOptions, Parameters&gt;;
261
- protected readonly viewContainerRef: ViewContainerRef &#x3D; inject(ViewContainerRef);
262
- protected readonly injector: Injector &#x3D; inject(INJECTOR);
260
+ public options: ControlOptions | null &#x3D; null;
261
+ // eslint-disable-next-line @angular-eslint/no-input-rename
262
+ @Input(&#x27;rxapOptionsFromMethodCall&#x27;)
263
+ public method!: Method&lt;ControlOptions, Parameters&gt;;
264
+ protected ngControl: NgControl | AbstractControlDirective | null &#x3D; null;
265
+ protected matFormField: MatFormField | null &#x3D; null;
266
+ protected settings: OptionsFromMethodDirectiveSettings &#x3D; {};
267
+ protected readonly viewContainerRef: ViewContainerRef &#x3D; inject(ViewContainerRef);
268
+ protected readonly injector: Injector &#x3D; inject(INJECTOR);
263
269
  protected readonly cdr: ChangeDetectorRef &#x3D; inject(ChangeDetectorRef);
264
270
  private readonly template: TemplateRef&lt;OptionsFromMethodTemplateContext&gt; &#x3D; inject(TemplateRef);
265
271
 
266
272
  public async ngAfterViewInit() {
267
- this.ngControl &#x3D; this.injector.get(NgControl, null);
268
273
  this.matFormField &#x3D; this.injector.get(MatFormField, null);
269
- this.method &#x3D; this.extractOptionsMethod();
274
+ this.ngControl &#x3D; this.injector.get(NgControl, this.matFormField?._control.ngControl);
275
+ this.control &#x3D; (this.ngControl?.control as RxapFormControl) ?? undefined;
276
+ this.method ??&#x3D; this.extractOptionsMethod();
270
277
  // ensure that the options are loaded. It is possible that the ngOnChange is triggered before the ngAfterViewInit
271
278
  // then the options are not loaded.
272
279
  if (!this.options) {
@@ -287,7 +294,7 @@ export class OptionsFromMethodDirective&lt;Value &#x3D; any, Parameters &#x3D; a
287
294
  }
288
295
  }
289
296
 
290
- protected async loadOptions(parameters?: Parameters): Promise&lt;ControlOptions&gt; {
297
+ protected async loadOptions(parameters?: Parameters): Promise&lt;ControlOptions | null&gt; {
291
298
  return this.method.call(parameters);
292
299
  }
293
300
 
@@ -311,9 +318,14 @@ export class OptionsFromMethodDirective&lt;Value &#x3D; any, Parameters &#x3D; a
311
318
 
312
319
  }
313
320
 
314
- protected setOptions(options: ControlOptions) {
315
- this.options &#x3D; options.slice();
316
- this.renderTemplate();
321
+ protected setOptions(options: ControlOptions | null) {
322
+ if (!options) {
323
+ this.options &#x3D; null;
324
+ this.viewContainerRef.clear();
325
+ } else {
326
+ this.options &#x3D; options.slice();
327
+ this.renderTemplate();
328
+ }
317
329
  }
318
330
 
319
331
  }