@rxap/directives 16.0.0-dev.9 → 16.0.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.
@@ -1,9 +1,9 @@
1
1
  import * as i0 from '@angular/core';
2
- import { isDevMode, ElementRef, Renderer2, Directive, Inject, Input, HostListener, Injectable, HostBinding, EventEmitter, Output, TemplateRef, ViewContainerRef, ChangeDetectorRef } from '@angular/core';
2
+ import { isDevMode, ElementRef, Renderer2, Directive, Inject, Input, Injectable, HostListener, EventEmitter, HostBinding, Output, TemplateRef, ViewContainerRef, ChangeDetectorRef } from '@angular/core';
3
3
  import * as i1 from '@rxap/services';
4
4
  import { ImageLoaderService, AvatarImageService } from '@rxap/services';
5
+ import { coerceBoolean, DebounceCall } from '@rxap/utilities';
5
6
  import { __decorate, __metadata } from 'tslib';
6
- import { DebounceCall, coerceBoolean } from '@rxap/utilities';
7
7
  import { ToggleSubject } from '@rxap/rxjs';
8
8
  import { Subscription, fromEvent } from 'rxjs';
9
9
  import { tap } from 'rxjs/operators';
@@ -127,140 +127,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.1.4", ngImpor
127
127
  type: Input
128
128
  }] } });
129
129
 
130
- class PreventDefaultDirective {
131
- onClick($event) {
132
- $event.preventDefault();
133
- }
134
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.1.4", ngImport: i0, type: PreventDefaultDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
135
- static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "16.1.4", type: PreventDefaultDirective, isStandalone: true, selector: "[rxapPreventDefault]", host: { listeners: { "click": "onClick($event)" } }, ngImport: i0 }); }
136
- }
137
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.1.4", ngImport: i0, type: PreventDefaultDirective, decorators: [{
138
- type: Directive,
139
- args: [{
140
- selector: '[rxapPreventDefault]',
141
- standalone: true,
142
- }]
143
- }], propDecorators: { onClick: [{
144
- type: HostListener,
145
- args: ['click', ['$event']]
146
- }] } });
147
-
148
- class StopImmediatePropagationDirective {
149
- onClick($event) {
150
- $event.stopImmediatePropagation();
151
- }
152
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.1.4", ngImport: i0, type: StopImmediatePropagationDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
153
- static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "16.1.4", type: StopImmediatePropagationDirective, isStandalone: true, selector: "[rxapStopImmediatePropagation]", host: { listeners: { "click": "onClick($event)" } }, ngImport: i0 }); }
154
- }
155
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.1.4", ngImport: i0, type: StopImmediatePropagationDirective, decorators: [{
156
- type: Directive,
157
- args: [{
158
- selector: '[rxapStopImmediatePropagation]',
159
- standalone: true,
160
- }]
161
- }], propDecorators: { onClick: [{
162
- type: HostListener,
163
- args: ['click', ['$event']]
164
- }] } });
165
-
166
- class StopPropagationDirective {
167
- onClick($event) {
168
- $event.stopPropagation();
169
- }
170
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.1.4", ngImport: i0, type: StopPropagationDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
171
- static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "16.1.4", type: StopPropagationDirective, isStandalone: true, selector: "[rxapStopPropagation]", host: { listeners: { "click": "onClick($event)" } }, ngImport: i0 }); }
172
- }
173
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.1.4", ngImport: i0, type: StopPropagationDirective, decorators: [{
174
- type: Directive,
175
- args: [{
176
- selector: '[rxapStopPropagation]',
177
- standalone: true,
178
- }]
179
- }], propDecorators: { onClick: [{
180
- type: HostListener,
181
- args: ['click', ['$event']]
182
- }] } });
183
-
184
- class ShareService {
185
- async share(data) {
186
- if (this.isShareSupported()) {
187
- if (navigator.canShare(data)) {
188
- await navigator.share(data);
189
- }
190
- else {
191
- console.debug('share data:', data);
192
- throw new Error('Can not share data. Data is invalid!');
193
- }
194
- }
195
- else {
196
- alert('Native share is not supported!');
197
- }
198
- }
199
- isShareSupported() {
200
- return !!navigator.share;
201
- }
202
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.1.4", ngImport: i0, type: ShareService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
203
- static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "16.1.4", ngImport: i0, type: ShareService, providedIn: 'root' }); }
204
- }
205
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.1.4", ngImport: i0, type: ShareService, decorators: [{
206
- type: Injectable,
207
- args: [{ providedIn: 'root' }]
208
- }] });
209
- class ShareButtonDirective {
210
- constructor(shareService) {
211
- this.shareService = shareService;
212
- }
213
- share() {
214
- this.shareService.share({
215
- url: this.url,
216
- text: this.text,
217
- files: this.files,
218
- title: this.title,
219
- })
220
- .then(() => console.log('share successfully'))
221
- .catch(err => console.error('share failed', err.message));
222
- }
223
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.1.4", ngImport: i0, type: ShareButtonDirective, deps: [{ token: ShareService }], target: i0.ɵɵFactoryTarget.Directive }); }
224
- static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "16.1.4", type: ShareButtonDirective, isStandalone: true, selector: "[rxapShareButton]", inputs: { url: "url", text: "text", title: "title", files: "files" }, host: { listeners: { "click": "share()" } }, ngImport: i0 }); }
225
- }
226
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.1.4", ngImport: i0, type: ShareButtonDirective, decorators: [{
227
- type: Directive,
228
- args: [{
229
- selector: '[rxapShareButton]',
230
- standalone: true,
231
- }]
232
- }], ctorParameters: function () { return [{ type: ShareService }]; }, propDecorators: { url: [{
233
- type: Input
234
- }], text: [{
235
- type: Input
236
- }], title: [{
237
- type: Input,
238
- args: [{ required: true }]
239
- }], files: [{
240
- type: Input
241
- }], share: [{
242
- type: HostListener,
243
- args: ['click']
244
- }] } });
245
-
246
- class FullWidthDirective {
247
- constructor() {
248
- this.width = '100%';
249
- }
250
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.1.4", ngImport: i0, type: FullWidthDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
251
- static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "16.1.4", type: FullWidthDirective, isStandalone: true, selector: "[rxapFullWidth]", host: { properties: { "style.width": "this.width" } }, ngImport: i0 }); }
252
- }
253
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.1.4", ngImport: i0, type: FullWidthDirective, decorators: [{
254
- type: Directive,
255
- args: [{
256
- selector: '[rxapFullWidth]',
257
- standalone: true,
258
- }]
259
- }], propDecorators: { width: [{
260
- type: HostBinding,
261
- args: ['style.width']
262
- }] } });
263
-
264
130
  class AvatarBackgroundImageDirective extends BackgroundImageDirective {
265
131
  constructor(host, renderer, imageLoader, avatarImage) {
266
132
  super(host, renderer, imageLoader);
@@ -302,6 +168,37 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.1.4", ngImpor
302
168
  type: Input
303
169
  }] } });
304
170
 
171
+ class ConfirmClick {
172
+ constructor() {
173
+ this._hasConfirmDirective = false;
174
+ }
175
+ set hasConfirmDirective(value) {
176
+ this._hasConfirmDirective = coerceBoolean(value);
177
+ }
178
+ onClick() {
179
+ if (!this._hasConfirmDirective) {
180
+ this.execute();
181
+ }
182
+ }
183
+ onConfirm() {
184
+ this.execute();
185
+ }
186
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.1.4", ngImport: i0, type: ConfirmClick, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
187
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "16.1.4", ngImport: i0, type: ConfirmClick }); }
188
+ }
189
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.1.4", ngImport: i0, type: ConfirmClick, decorators: [{
190
+ type: Injectable
191
+ }], propDecorators: { hasConfirmDirective: [{
192
+ type: Input,
193
+ args: ['rxapConfirm']
194
+ }], onClick: [{
195
+ type: HostListener,
196
+ args: ['click']
197
+ }], onConfirm: [{
198
+ type: HostListener,
199
+ args: ['confirmed']
200
+ }] } });
201
+
305
202
  class ContenteditableDirective {
306
203
  constructor(elementRef) {
307
204
  this.elementRef = elementRef;
@@ -368,251 +265,54 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.1.4", ngImpor
368
265
  args: ['input', ['$event']]
369
266
  }] } });
370
267
 
371
- class ConfirmClick {
268
+ class FullWidthDirective {
372
269
  constructor() {
373
- this._hasConfirmDirective = false;
374
- }
375
- set hasConfirmDirective(value) {
376
- this._hasConfirmDirective = coerceBoolean(value);
377
- }
378
- onClick() {
379
- if (!this._hasConfirmDirective) {
380
- this.execute();
381
- }
382
- }
383
- onConfirm() {
384
- this.execute();
270
+ this.width = '100%';
385
271
  }
386
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.1.4", ngImport: i0, type: ConfirmClick, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
387
- static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "16.1.4", ngImport: i0, type: ConfirmClick }); }
272
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.1.4", ngImport: i0, type: FullWidthDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
273
+ static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "16.1.4", type: FullWidthDirective, isStandalone: true, selector: "[rxapFullWidth]", host: { properties: { "style.width": "this.width" } }, ngImport: i0 }); }
388
274
  }
389
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.1.4", ngImport: i0, type: ConfirmClick, decorators: [{
390
- type: Injectable
391
- }], propDecorators: { hasConfirmDirective: [{
392
- type: Input,
393
- args: ['rxapConfirm']
394
- }], onClick: [{
395
- type: HostListener,
396
- args: ['click']
397
- }], onConfirm: [{
398
- type: HostListener,
399
- args: ['confirmed']
275
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.1.4", ngImport: i0, type: FullWidthDirective, decorators: [{
276
+ type: Directive,
277
+ args: [{
278
+ selector: '[rxapFullWidth]',
279
+ standalone: true,
280
+ }]
281
+ }], propDecorators: { width: [{
282
+ type: HostBinding,
283
+ args: ['style.width']
400
284
  }] } });
401
285
 
402
- class MethodDirective {
403
- constructor() {
404
- this.immediately = false;
405
- this.executed$ = new EventEmitter();
406
- this.failure$ = new EventEmitter();
407
- this.successful$ = new EventEmitter();
408
- /**
409
- * true - a remote method call is in progress
410
- */
411
- this.executing$ = new ToggleSubject();
412
- this._hasConfirmDirective = false;
286
+ // TODO : mv to rxap package
287
+ class IfTruthyDirective {
288
+ constructor(templateRef, viewContainerRef, cdr) {
289
+ this.templateRef = templateRef;
290
+ this.viewContainerRef = viewContainerRef;
291
+ this.cdr = cdr;
413
292
  }
414
- set hasConfirmDirective(value) {
415
- this._hasConfirmDirective = coerceBoolean(value);
293
+ /**
294
+ * Asserts the correct type of the context for the template that `NgForOf` will render.
295
+ *
296
+ * The presence of this method is a signal to the Ivy template type-check compiler that the
297
+ * `NgForOf` structural directive renders its template with a specific context type.
298
+ */
299
+ static ngTemplateContextGuard(dir, ctx) {
300
+ return true;
416
301
  }
417
- ngOnInit() {
418
- if (this.immediately) {
302
+ ngOnChanges(changes) {
303
+ if (this.method && this.parameters) {
419
304
  this.execute();
420
305
  }
421
306
  }
422
- onConfirmed() {
423
- return this.execute();
424
- }
425
- onClick() {
426
- if (!this._hasConfirmDirective) {
427
- return this.execute();
428
- }
429
- else {
430
- if (isDevMode()) {
431
- console.debug('Skip method call. Wait for confirmation.');
307
+ async execute() {
308
+ const result = await this.method.call(this.parameters);
309
+ if (this.hasChanged(result)) {
310
+ this.viewContainerRef.clear();
311
+ if (result) {
312
+ this.viewContainerRef.createEmbeddedView(this.templateRef, { $implicit: result });
432
313
  }
433
314
  }
434
- return Promise.resolve();
435
- }
436
- async execute() {
437
- this.executing$.enable();
438
- try {
439
- const result = await this.method.call(this.parameters);
440
- this.executed(result);
441
- this.successful(result);
442
- }
443
- catch (error) {
444
- if (isDevMode()) {
445
- console.error(`Method directive execution failed:`, error.message);
446
- }
447
- this.failure(error);
448
- }
449
- finally {
450
- this.executing$.disable();
451
- }
452
- }
453
- setParameter(parameterKey, value) {
454
- this.updateParameters({ [parameterKey]: value });
455
- }
456
- updateParameters(parameters) {
457
- this.parameters = { ...(this.parameters ?? {}), ...parameters };
458
- }
459
- executed(result) {
460
- this.executed$.emit(result);
461
- }
462
- failure(error) {
463
- this.failure$.emit(error);
464
- }
465
- successful(result) {
466
- this.successful$.emit(result);
467
- }
468
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.1.4", ngImport: i0, type: MethodDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
469
- static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "16.1.4", type: MethodDirective, isStandalone: true, selector: "[rxapMethod]", inputs: { method: ["rxapMethod", "method"], parameters: "parameters", immediately: "immediately", hasConfirmDirective: ["rxapConfirm", "hasConfirmDirective"] }, outputs: { executed$: "executed", failure$: "failure", successful$: "successful" }, host: { listeners: { "confirmed": "onConfirmed()", "click": "onClick()" } }, exportAs: ["rxapMethod"], ngImport: i0 }); }
470
- }
471
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.1.4", ngImport: i0, type: MethodDirective, decorators: [{
472
- type: Directive,
473
- args: [{
474
- selector: '[rxapMethod]',
475
- exportAs: 'rxapMethod',
476
- standalone: true,
477
- }]
478
- }], propDecorators: { method: [{
479
- type: Input,
480
- args: ['rxapMethod']
481
- }], parameters: [{
482
- type: Input
483
- }], immediately: [{
484
- type: Input
485
- }], executed$: [{
486
- type: Output,
487
- args: ['executed']
488
- }], failure$: [{
489
- type: Output,
490
- args: ['failure']
491
- }], successful$: [{
492
- type: Output,
493
- args: ['successful']
494
- }], hasConfirmDirective: [{
495
- type: Input,
496
- args: ['rxapConfirm']
497
- }], onConfirmed: [{
498
- type: HostListener,
499
- args: ['confirmed']
500
- }], onClick: [{
501
- type: HostListener,
502
- args: ['click']
503
- }] } });
504
-
505
- class MovableDividerDirective {
506
- constructor(renderer) {
507
- this.renderer = renderer;
508
- this.origin = 'right';
509
- this.cursor = 'ew-resize';
510
- this._subscription = new Subscription();
511
- /**
512
- * Indicates that the divider is moved with mouse down
513
- * @private
514
- */
515
- this._moveDivider = false;
516
- /**
517
- * Holds the current fixed element width.
518
- * If null the move divider feature was not yet used and the initial
519
- * fixed element width is not calculated
520
- * @private
521
- */
522
- this._fixedElementWidth = null;
523
- }
524
- ngOnDestroy() {
525
- this._subscription?.unsubscribe();
526
- }
527
- ngOnInit() {
528
- this._subscription.add(fromEvent(this.containerElement, 'mousemove').pipe(tap(($event) => {
529
- if (this._moveDivider) {
530
- if (!this._fixedElementWidth) {
531
- this._fixedElementWidth = this.fixedElement.clientWidth;
532
- }
533
- if (this.origin === 'right') {
534
- this._fixedElementWidth = $event.clientX - this.containerElement.getBoundingClientRect().left;
535
- }
536
- else if (this.origin === 'left') {
537
- if (isDevMode()) {
538
- console.log({
539
- clientWidth: this.containerElement.clientWidth,
540
- clientX: $event.clientX,
541
- clientLeft: this.containerElement.getBoundingClientRect().left,
542
- });
543
- }
544
- this._fixedElementWidth =
545
- this.containerElement.clientWidth - $event.clientX + this.containerElement.getBoundingClientRect().left;
546
- }
547
- else {
548
- throw new Error(`The origin '${this.origin}' is not supported.`);
549
- }
550
- const width = this._fixedElementWidth + 'px';
551
- this.renderer.setStyle(this.fixedElement, 'max-width', width);
552
- this.renderer.setStyle(this.fixedElement, 'min-width', width);
553
- this.renderer.setStyle(this.fixedElement, 'flex-basis', width);
554
- }
555
- })).subscribe());
556
- this._subscription.add(fromEvent(this.containerElement, 'mouseup').pipe(tap(() => this._moveDivider = false)).subscribe());
557
- }
558
- onMousedown() {
559
- this._moveDivider = true;
560
- }
561
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.1.4", ngImport: i0, type: MovableDividerDirective, deps: [{ token: i0.Renderer2 }], target: i0.ɵɵFactoryTarget.Directive }); }
562
- static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "16.1.4", type: MovableDividerDirective, isStandalone: true, selector: "[rxapMovableDivider]", inputs: { containerElement: "containerElement", fixedElement: "fixedElement", origin: "origin" }, host: { listeners: { "mousedown": "onMousedown()" }, properties: { "style.cursor": "this.cursor" } }, ngImport: i0 }); }
563
- }
564
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.1.4", ngImport: i0, type: MovableDividerDirective, decorators: [{
565
- type: Directive,
566
- args: [{
567
- selector: '[rxapMovableDivider]',
568
- standalone: true,
569
- }]
570
- }], ctorParameters: function () { return [{ type: i0.Renderer2 }]; }, propDecorators: { containerElement: [{
571
- type: Input,
572
- args: [{ required: true }]
573
- }], fixedElement: [{
574
- type: Input,
575
- args: [{ required: true }]
576
- }], origin: [{
577
- type: Input
578
- }], cursor: [{
579
- type: HostBinding,
580
- args: ['style.cursor']
581
- }], onMousedown: [{
582
- type: HostListener,
583
- args: ['mousedown']
584
- }] } });
585
-
586
- // TODO : mv to rxap package
587
- class IfTruthyDirective {
588
- constructor(templateRef, viewContainerRef, cdr) {
589
- this.templateRef = templateRef;
590
- this.viewContainerRef = viewContainerRef;
591
- this.cdr = cdr;
592
- }
593
- /**
594
- * Asserts the correct type of the context for the template that `NgForOf` will render.
595
- *
596
- * The presence of this method is a signal to the Ivy template type-check compiler that the
597
- * `NgForOf` structural directive renders its template with a specific context type.
598
- */
599
- static ngTemplateContextGuard(dir, ctx) {
600
- return true;
601
- }
602
- ngOnChanges(changes) {
603
- if (this.method && this.parameters) {
604
- this.execute();
605
- }
606
- }
607
- async execute() {
608
- const result = await this.method.call(this.parameters);
609
- if (this.hasChanged(result)) {
610
- this.viewContainerRef.clear();
611
- if (result) {
612
- this.viewContainerRef.createEmbeddedView(this.templateRef, { $implicit: result });
613
- }
614
- }
615
- this.cdr.detectChanges();
315
+ this.cdr.detectChanges();
616
316
  }
617
317
  hasChanged(current) {
618
318
  if (this._last !== undefined) {
@@ -642,6 +342,31 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.1.4", ngImpor
642
342
  args: ['rxapIfTruthyTrackBy']
643
343
  }] } });
644
344
 
345
+ class IsDevModeDirective {
346
+ constructor(template, vcr) {
347
+ this.template = template;
348
+ this.vcr = vcr;
349
+ }
350
+ ngOnInit() {
351
+ if (isDevMode()) {
352
+ this.embeddedViewRef = this.vcr.createEmbeddedView(this.template);
353
+ }
354
+ }
355
+ ngOnDestroy() {
356
+ this.embeddedViewRef?.destroy();
357
+ this.vcr.clear();
358
+ }
359
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.1.4", ngImport: i0, type: IsDevModeDirective, deps: [{ token: i0.TemplateRef }, { token: i0.ViewContainerRef }], target: i0.ɵɵFactoryTarget.Directive }); }
360
+ static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "16.1.4", type: IsDevModeDirective, isStandalone: true, selector: "[rxapIsDevMode]", ngImport: i0 }); }
361
+ }
362
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.1.4", ngImport: i0, type: IsDevModeDirective, decorators: [{
363
+ type: Directive,
364
+ args: [{
365
+ selector: '[rxapIsDevMode]',
366
+ standalone: true,
367
+ }]
368
+ }], ctorParameters: function () { return [{ type: i0.TemplateRef }, { type: i0.ViewContainerRef }]; } });
369
+
645
370
  class MethodTemplateDirective {
646
371
  constructor(template, viewContainerRef, cdr) {
647
372
  this.template = template;
@@ -795,9 +520,312 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.1.4", ngImpor
795
520
  args: ['confirmed']
796
521
  }] } });
797
522
 
523
+ class MethodDirective {
524
+ constructor() {
525
+ this.immediately = false;
526
+ this.executed$ = new EventEmitter();
527
+ this.failure$ = new EventEmitter();
528
+ this.successful$ = new EventEmitter();
529
+ /**
530
+ * true - a remote method call is in progress
531
+ */
532
+ this.executing$ = new ToggleSubject();
533
+ this._hasConfirmDirective = false;
534
+ }
535
+ set hasConfirmDirective(value) {
536
+ this._hasConfirmDirective = coerceBoolean(value);
537
+ }
538
+ ngOnInit() {
539
+ if (this.immediately) {
540
+ this.execute();
541
+ }
542
+ }
543
+ onConfirmed() {
544
+ return this.execute();
545
+ }
546
+ onClick() {
547
+ if (!this._hasConfirmDirective) {
548
+ return this.execute();
549
+ }
550
+ else {
551
+ if (isDevMode()) {
552
+ console.debug('Skip method call. Wait for confirmation.');
553
+ }
554
+ }
555
+ return Promise.resolve();
556
+ }
557
+ async execute() {
558
+ this.executing$.enable();
559
+ try {
560
+ const result = await this.method.call(this.parameters);
561
+ this.executed(result);
562
+ this.successful(result);
563
+ }
564
+ catch (error) {
565
+ if (isDevMode()) {
566
+ console.error(`Method directive execution failed:`, error.message);
567
+ }
568
+ this.failure(error);
569
+ }
570
+ finally {
571
+ this.executing$.disable();
572
+ }
573
+ }
574
+ setParameter(parameterKey, value) {
575
+ this.updateParameters({ [parameterKey]: value });
576
+ }
577
+ updateParameters(parameters) {
578
+ this.parameters = { ...(this.parameters ?? {}), ...parameters };
579
+ }
580
+ executed(result) {
581
+ this.executed$.emit(result);
582
+ }
583
+ failure(error) {
584
+ this.failure$.emit(error);
585
+ }
586
+ successful(result) {
587
+ this.successful$.emit(result);
588
+ }
589
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.1.4", ngImport: i0, type: MethodDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
590
+ static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "16.1.4", type: MethodDirective, isStandalone: true, selector: "[rxapMethod]", inputs: { method: ["rxapMethod", "method"], parameters: "parameters", immediately: "immediately", hasConfirmDirective: ["rxapConfirm", "hasConfirmDirective"] }, outputs: { executed$: "executed", failure$: "failure", successful$: "successful" }, host: { listeners: { "confirmed": "onConfirmed()", "click": "onClick()" } }, exportAs: ["rxapMethod"], ngImport: i0 }); }
591
+ }
592
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.1.4", ngImport: i0, type: MethodDirective, decorators: [{
593
+ type: Directive,
594
+ args: [{
595
+ selector: '[rxapMethod]',
596
+ exportAs: 'rxapMethod',
597
+ standalone: true,
598
+ }]
599
+ }], propDecorators: { method: [{
600
+ type: Input,
601
+ args: ['rxapMethod']
602
+ }], parameters: [{
603
+ type: Input
604
+ }], immediately: [{
605
+ type: Input
606
+ }], executed$: [{
607
+ type: Output,
608
+ args: ['executed']
609
+ }], failure$: [{
610
+ type: Output,
611
+ args: ['failure']
612
+ }], successful$: [{
613
+ type: Output,
614
+ args: ['successful']
615
+ }], hasConfirmDirective: [{
616
+ type: Input,
617
+ args: ['rxapConfirm']
618
+ }], onConfirmed: [{
619
+ type: HostListener,
620
+ args: ['confirmed']
621
+ }], onClick: [{
622
+ type: HostListener,
623
+ args: ['click']
624
+ }] } });
625
+
626
+ class MovableDividerDirective {
627
+ constructor(renderer) {
628
+ this.renderer = renderer;
629
+ this.origin = 'right';
630
+ this.cursor = 'ew-resize';
631
+ this._subscription = new Subscription();
632
+ /**
633
+ * Indicates that the divider is moved with mouse down
634
+ * @private
635
+ */
636
+ this._moveDivider = false;
637
+ /**
638
+ * Holds the current fixed element width.
639
+ * If null the move divider feature was not yet used and the initial
640
+ * fixed element width is not calculated
641
+ * @private
642
+ */
643
+ this._fixedElementWidth = null;
644
+ }
645
+ ngOnDestroy() {
646
+ this._subscription?.unsubscribe();
647
+ }
648
+ ngOnInit() {
649
+ this._subscription.add(fromEvent(this.containerElement, 'mousemove').pipe(tap(($event) => {
650
+ if (this._moveDivider) {
651
+ if (!this._fixedElementWidth) {
652
+ this._fixedElementWidth = this.fixedElement.clientWidth;
653
+ }
654
+ if (this.origin === 'right') {
655
+ this._fixedElementWidth = $event.clientX - this.containerElement.getBoundingClientRect().left;
656
+ }
657
+ else if (this.origin === 'left') {
658
+ if (isDevMode()) {
659
+ console.log({
660
+ clientWidth: this.containerElement.clientWidth,
661
+ clientX: $event.clientX,
662
+ clientLeft: this.containerElement.getBoundingClientRect().left,
663
+ });
664
+ }
665
+ this._fixedElementWidth =
666
+ this.containerElement.clientWidth - $event.clientX + this.containerElement.getBoundingClientRect().left;
667
+ }
668
+ else {
669
+ throw new Error(`The origin '${this.origin}' is not supported.`);
670
+ }
671
+ const width = this._fixedElementWidth + 'px';
672
+ this.renderer.setStyle(this.fixedElement, 'max-width', width);
673
+ this.renderer.setStyle(this.fixedElement, 'min-width', width);
674
+ this.renderer.setStyle(this.fixedElement, 'flex-basis', width);
675
+ }
676
+ })).subscribe());
677
+ this._subscription.add(fromEvent(this.containerElement, 'mouseup').pipe(tap(() => this._moveDivider = false)).subscribe());
678
+ }
679
+ onMousedown() {
680
+ this._moveDivider = true;
681
+ }
682
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.1.4", ngImport: i0, type: MovableDividerDirective, deps: [{ token: i0.Renderer2 }], target: i0.ɵɵFactoryTarget.Directive }); }
683
+ static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "16.1.4", type: MovableDividerDirective, isStandalone: true, selector: "[rxapMovableDivider]", inputs: { containerElement: "containerElement", fixedElement: "fixedElement", origin: "origin" }, host: { listeners: { "mousedown": "onMousedown()" }, properties: { "style.cursor": "this.cursor" } }, ngImport: i0 }); }
684
+ }
685
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.1.4", ngImport: i0, type: MovableDividerDirective, decorators: [{
686
+ type: Directive,
687
+ args: [{
688
+ selector: '[rxapMovableDivider]',
689
+ standalone: true,
690
+ }]
691
+ }], ctorParameters: function () { return [{ type: i0.Renderer2 }]; }, propDecorators: { containerElement: [{
692
+ type: Input,
693
+ args: [{ required: true }]
694
+ }], fixedElement: [{
695
+ type: Input,
696
+ args: [{ required: true }]
697
+ }], origin: [{
698
+ type: Input
699
+ }], cursor: [{
700
+ type: HostBinding,
701
+ args: ['style.cursor']
702
+ }], onMousedown: [{
703
+ type: HostListener,
704
+ args: ['mousedown']
705
+ }] } });
706
+
707
+ class PreventDefaultDirective {
708
+ onClick($event) {
709
+ $event.preventDefault();
710
+ }
711
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.1.4", ngImport: i0, type: PreventDefaultDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
712
+ static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "16.1.4", type: PreventDefaultDirective, isStandalone: true, selector: "[rxapPreventDefault]", host: { listeners: { "click": "onClick($event)" } }, ngImport: i0 }); }
713
+ }
714
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.1.4", ngImport: i0, type: PreventDefaultDirective, decorators: [{
715
+ type: Directive,
716
+ args: [{
717
+ selector: '[rxapPreventDefault]',
718
+ standalone: true,
719
+ }]
720
+ }], propDecorators: { onClick: [{
721
+ type: HostListener,
722
+ args: ['click', ['$event']]
723
+ }] } });
724
+
725
+ class ShareService {
726
+ async share(data) {
727
+ if (this.isShareSupported()) {
728
+ if (navigator.canShare(data)) {
729
+ await navigator.share(data);
730
+ }
731
+ else {
732
+ console.debug('share data:', data);
733
+ throw new Error('Can not share data. Data is invalid!');
734
+ }
735
+ }
736
+ else {
737
+ alert('Native share is not supported!');
738
+ }
739
+ }
740
+ isShareSupported() {
741
+ return !!navigator.share;
742
+ }
743
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.1.4", ngImport: i0, type: ShareService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
744
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "16.1.4", ngImport: i0, type: ShareService, providedIn: 'root' }); }
745
+ }
746
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.1.4", ngImport: i0, type: ShareService, decorators: [{
747
+ type: Injectable,
748
+ args: [{ providedIn: 'root' }]
749
+ }] });
750
+ class ShareButtonDirective {
751
+ constructor(shareService) {
752
+ this.shareService = shareService;
753
+ }
754
+ share() {
755
+ this.shareService.share({
756
+ url: this.url,
757
+ text: this.text,
758
+ files: this.files,
759
+ title: this.title,
760
+ })
761
+ .then(() => console.log('share successfully'))
762
+ .catch(err => console.error('share failed', err.message));
763
+ }
764
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.1.4", ngImport: i0, type: ShareButtonDirective, deps: [{ token: ShareService }], target: i0.ɵɵFactoryTarget.Directive }); }
765
+ static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "16.1.4", type: ShareButtonDirective, isStandalone: true, selector: "[rxapShareButton]", inputs: { url: "url", text: "text", title: "title", files: "files" }, host: { listeners: { "click": "share()" } }, ngImport: i0 }); }
766
+ }
767
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.1.4", ngImport: i0, type: ShareButtonDirective, decorators: [{
768
+ type: Directive,
769
+ args: [{
770
+ selector: '[rxapShareButton]',
771
+ standalone: true,
772
+ }]
773
+ }], ctorParameters: function () { return [{ type: ShareService }]; }, propDecorators: { url: [{
774
+ type: Input
775
+ }], text: [{
776
+ type: Input
777
+ }], title: [{
778
+ type: Input,
779
+ args: [{ required: true }]
780
+ }], files: [{
781
+ type: Input
782
+ }], share: [{
783
+ type: HostListener,
784
+ args: ['click']
785
+ }] } });
786
+
787
+ class StopImmediatePropagationDirective {
788
+ onClick($event) {
789
+ $event.stopImmediatePropagation();
790
+ }
791
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.1.4", ngImport: i0, type: StopImmediatePropagationDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
792
+ static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "16.1.4", type: StopImmediatePropagationDirective, isStandalone: true, selector: "[rxapStopImmediatePropagation]", host: { listeners: { "click": "onClick($event)" } }, ngImport: i0 }); }
793
+ }
794
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.1.4", ngImport: i0, type: StopImmediatePropagationDirective, decorators: [{
795
+ type: Directive,
796
+ args: [{
797
+ selector: '[rxapStopImmediatePropagation]',
798
+ standalone: true,
799
+ }]
800
+ }], propDecorators: { onClick: [{
801
+ type: HostListener,
802
+ args: ['click', ['$event']]
803
+ }] } });
804
+
805
+ class StopPropagationDirective {
806
+ onClick($event) {
807
+ $event.stopPropagation();
808
+ }
809
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.1.4", ngImport: i0, type: StopPropagationDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
810
+ static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "16.1.4", type: StopPropagationDirective, isStandalone: true, selector: "[rxapStopPropagation]", host: { listeners: { "click": "onClick($event)" } }, ngImport: i0 }); }
811
+ }
812
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.1.4", ngImport: i0, type: StopPropagationDirective, decorators: [{
813
+ type: Directive,
814
+ args: [{
815
+ selector: '[rxapStopPropagation]',
816
+ standalone: true,
817
+ }]
818
+ }], propDecorators: { onClick: [{
819
+ type: HostListener,
820
+ args: ['click', ['$event']]
821
+ }] } });
822
+
823
+ // region
824
+ // endregion
825
+
798
826
  /**
799
827
  * Generated bundle index. Do not edit.
800
828
  */
801
829
 
802
- export { AvatarBackgroundImageDirective, BackgroundImageDirective, BackgroundPositionOptions, BackgroundRepeatOptions, BackgroundSizeOptions, ConfirmClick, ContenteditableDirective, FullWidthDirective, GlobalStyleOptions, IfTruthyDirective, MethodDirective, MethodTemplateDirective, MovableDividerDirective, PreventDefaultDirective, ShareButtonDirective, ShareService, StopImmediatePropagationDirective, StopPropagationDirective };
830
+ export { AvatarBackgroundImageDirective, BackgroundImageDirective, BackgroundPositionOptions, BackgroundRepeatOptions, BackgroundSizeOptions, ConfirmClick, ContenteditableDirective, FullWidthDirective, GlobalStyleOptions, IfTruthyDirective, IsDevModeDirective, MethodDirective, MethodTemplateDirective, MovableDividerDirective, PreventDefaultDirective, ShareButtonDirective, ShareService, StopImmediatePropagationDirective, StopPropagationDirective };
803
831
  //# sourceMappingURL=rxap-directives.mjs.map