@rxap/directives 16.0.0-dev.8 → 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 { Required, 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,143 +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
- __decorate([
227
- Required,
228
- __metadata("design:type", String)
229
- ], ShareButtonDirective.prototype, "title", void 0);
230
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.1.4", ngImport: i0, type: ShareButtonDirective, decorators: [{
231
- type: Directive,
232
- args: [{
233
- selector: '[rxapShareButton]',
234
- standalone: true,
235
- }]
236
- }], ctorParameters: function () { return [{ type: ShareService }]; }, propDecorators: { url: [{
237
- type: Input
238
- }], text: [{
239
- type: Input
240
- }], title: [{
241
- type: Input
242
- }], files: [{
243
- type: Input
244
- }], share: [{
245
- type: HostListener,
246
- args: ['click']
247
- }] } });
248
-
249
- class FullWidthDirective {
250
- constructor() {
251
- this.width = '100%';
252
- }
253
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.1.4", ngImport: i0, type: FullWidthDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
254
- 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 }); }
255
- }
256
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.1.4", ngImport: i0, type: FullWidthDirective, decorators: [{
257
- type: Directive,
258
- args: [{
259
- selector: '[rxapFullWidth]',
260
- standalone: true,
261
- }]
262
- }], propDecorators: { width: [{
263
- type: HostBinding,
264
- args: ['style.width']
265
- }] } });
266
-
267
130
  class AvatarBackgroundImageDirective extends BackgroundImageDirective {
268
131
  constructor(host, renderer, imageLoader, avatarImage) {
269
132
  super(host, renderer, imageLoader);
@@ -305,6 +168,37 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.1.4", ngImpor
305
168
  type: Input
306
169
  }] } });
307
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
+
308
202
  class ContenteditableDirective {
309
203
  constructor(elementRef) {
310
204
  this.elementRef = elementRef;
@@ -371,257 +265,54 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.1.4", ngImpor
371
265
  args: ['input', ['$event']]
372
266
  }] } });
373
267
 
374
- class ConfirmClick {
268
+ class FullWidthDirective {
375
269
  constructor() {
376
- this._hasConfirmDirective = false;
377
- }
378
- set hasConfirmDirective(value) {
379
- this._hasConfirmDirective = coerceBoolean(value);
380
- }
381
- onClick() {
382
- if (!this._hasConfirmDirective) {
383
- this.execute();
384
- }
385
- }
386
- onConfirm() {
387
- this.execute();
270
+ this.width = '100%';
388
271
  }
389
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.1.4", ngImport: i0, type: ConfirmClick, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
390
- 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 }); }
391
274
  }
392
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.1.4", ngImport: i0, type: ConfirmClick, decorators: [{
393
- type: Injectable
394
- }], propDecorators: { hasConfirmDirective: [{
395
- type: Input,
396
- args: ['rxapConfirm']
397
- }], onClick: [{
398
- type: HostListener,
399
- args: ['click']
400
- }], onConfirm: [{
401
- type: HostListener,
402
- 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']
403
284
  }] } });
404
285
 
405
- class MethodDirective {
406
- constructor() {
407
- this.immediately = false;
408
- this.executed$ = new EventEmitter();
409
- this.failure$ = new EventEmitter();
410
- this.successful$ = new EventEmitter();
411
- /**
412
- * true - a remote method call is in progress
413
- */
414
- this.executing$ = new ToggleSubject();
415
- 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;
416
292
  }
417
- set hasConfirmDirective(value) {
418
- 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;
419
301
  }
420
- ngOnInit() {
421
- if (this.immediately) {
302
+ ngOnChanges(changes) {
303
+ if (this.method && this.parameters) {
422
304
  this.execute();
423
305
  }
424
306
  }
425
- onConfirmed() {
426
- return this.execute();
427
- }
428
- onClick() {
429
- if (!this._hasConfirmDirective) {
430
- return this.execute();
431
- }
432
- else {
433
- if (isDevMode()) {
434
- 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 });
435
313
  }
436
314
  }
437
- return Promise.resolve();
438
- }
439
- async execute() {
440
- this.executing$.enable();
441
- try {
442
- const result = await this.method.call(this.parameters);
443
- this.executed(result);
444
- this.successful(result);
445
- }
446
- catch (error) {
447
- if (isDevMode()) {
448
- console.error(`Method directive execution failed:`, error.message);
449
- }
450
- this.failure(error);
451
- }
452
- finally {
453
- this.executing$.disable();
454
- }
455
- }
456
- setParameter(parameterKey, value) {
457
- this.updateParameters({ [parameterKey]: value });
458
- }
459
- updateParameters(parameters) {
460
- this.parameters = { ...(this.parameters ?? {}), ...parameters };
461
- }
462
- executed(result) {
463
- this.executed$.emit(result);
464
- }
465
- failure(error) {
466
- this.failure$.emit(error);
467
- }
468
- successful(result) {
469
- this.successful$.emit(result);
470
- }
471
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.1.4", ngImport: i0, type: MethodDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
472
- 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 }); }
473
- }
474
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.1.4", ngImport: i0, type: MethodDirective, decorators: [{
475
- type: Directive,
476
- args: [{
477
- selector: '[rxapMethod]',
478
- exportAs: 'rxapMethod',
479
- standalone: true,
480
- }]
481
- }], propDecorators: { method: [{
482
- type: Input,
483
- args: ['rxapMethod']
484
- }], parameters: [{
485
- type: Input
486
- }], immediately: [{
487
- type: Input
488
- }], executed$: [{
489
- type: Output,
490
- args: ['executed']
491
- }], failure$: [{
492
- type: Output,
493
- args: ['failure']
494
- }], successful$: [{
495
- type: Output,
496
- args: ['successful']
497
- }], hasConfirmDirective: [{
498
- type: Input,
499
- args: ['rxapConfirm']
500
- }], onConfirmed: [{
501
- type: HostListener,
502
- args: ['confirmed']
503
- }], onClick: [{
504
- type: HostListener,
505
- args: ['click']
506
- }] } });
507
-
508
- class MovableDividerDirective {
509
- constructor(renderer) {
510
- this.renderer = renderer;
511
- this.origin = 'right';
512
- this.cursor = 'ew-resize';
513
- this._subscription = new Subscription();
514
- /**
515
- * Indicates that the divider is moved with mouse down
516
- * @private
517
- */
518
- this._moveDivider = false;
519
- /**
520
- * Holds the current fixed element width.
521
- * If null the move divider feature was not yet used and the initial
522
- * fixed element width is not calculated
523
- * @private
524
- */
525
- this._fixedElementWidth = null;
526
- }
527
- ngOnDestroy() {
528
- this._subscription?.unsubscribe();
529
- }
530
- ngOnInit() {
531
- this._subscription.add(fromEvent(this.containerElement, 'mousemove').pipe(tap(($event) => {
532
- if (this._moveDivider) {
533
- if (!this._fixedElementWidth) {
534
- this._fixedElementWidth = this.fixedElement.clientWidth;
535
- }
536
- if (this.origin === 'right') {
537
- this._fixedElementWidth = $event.clientX - this.containerElement.getBoundingClientRect().left;
538
- }
539
- else if (this.origin === 'left') {
540
- if (isDevMode()) {
541
- console.log({
542
- clientWidth: this.containerElement.clientWidth,
543
- clientX: $event.clientX,
544
- clientLeft: this.containerElement.getBoundingClientRect().left,
545
- });
546
- }
547
- this._fixedElementWidth =
548
- this.containerElement.clientWidth - $event.clientX + this.containerElement.getBoundingClientRect().left;
549
- }
550
- else {
551
- throw new Error(`The origin '${this.origin}' is not supported.`);
552
- }
553
- const width = this._fixedElementWidth + 'px';
554
- this.renderer.setStyle(this.fixedElement, 'max-width', width);
555
- this.renderer.setStyle(this.fixedElement, 'min-width', width);
556
- this.renderer.setStyle(this.fixedElement, 'flex-basis', width);
557
- }
558
- })).subscribe());
559
- this._subscription.add(fromEvent(this.containerElement, 'mouseup').pipe(tap(() => this._moveDivider = false)).subscribe());
560
- }
561
- onMousedown() {
562
- this._moveDivider = true;
563
- }
564
- 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 }); }
565
- 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 }); }
566
- }
567
- __decorate([
568
- Required,
569
- __metadata("design:type", HTMLDivElement)
570
- ], MovableDividerDirective.prototype, "containerElement", void 0);
571
- __decorate([
572
- Required,
573
- __metadata("design:type", HTMLDivElement)
574
- ], MovableDividerDirective.prototype, "fixedElement", void 0);
575
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.1.4", ngImport: i0, type: MovableDividerDirective, decorators: [{
576
- type: Directive,
577
- args: [{
578
- selector: '[rxapMovableDivider]',
579
- standalone: true,
580
- }]
581
- }], ctorParameters: function () { return [{ type: i0.Renderer2 }]; }, propDecorators: { containerElement: [{
582
- type: Input
583
- }], fixedElement: [{
584
- type: Input
585
- }], origin: [{
586
- type: Input
587
- }], cursor: [{
588
- type: HostBinding,
589
- args: ['style.cursor']
590
- }], onMousedown: [{
591
- type: HostListener,
592
- args: ['mousedown']
593
- }] } });
594
-
595
- // TODO : mv to rxap package
596
- class IfTruthyDirective {
597
- constructor(templateRef, viewContainerRef, cdr) {
598
- this.templateRef = templateRef;
599
- this.viewContainerRef = viewContainerRef;
600
- this.cdr = cdr;
601
- }
602
- /**
603
- * Asserts the correct type of the context for the template that `NgForOf` will render.
604
- *
605
- * The presence of this method is a signal to the Ivy template type-check compiler that the
606
- * `NgForOf` structural directive renders its template with a specific context type.
607
- */
608
- static ngTemplateContextGuard(dir, ctx) {
609
- return true;
610
- }
611
- ngOnChanges(changes) {
612
- if (this.method && this.parameters) {
613
- this.execute();
614
- }
615
- }
616
- async execute() {
617
- const result = await this.method.call(this.parameters);
618
- if (this.hasChanged(result)) {
619
- this.viewContainerRef.clear();
620
- if (result) {
621
- this.viewContainerRef.createEmbeddedView(this.templateRef, { $implicit: result });
622
- }
623
- }
624
- this.cdr.detectChanges();
315
+ this.cdr.detectChanges();
625
316
  }
626
317
  hasChanged(current) {
627
318
  if (this._last !== undefined) {
@@ -651,6 +342,31 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.1.4", ngImpor
651
342
  args: ['rxapIfTruthyTrackBy']
652
343
  }] } });
653
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
+
654
370
  class MethodTemplateDirective {
655
371
  constructor(template, viewContainerRef, cdr) {
656
372
  this.template = template;
@@ -804,9 +520,312 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.1.4", ngImpor
804
520
  args: ['confirmed']
805
521
  }] } });
806
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
+
807
826
  /**
808
827
  * Generated bundle index. Do not edit.
809
828
  */
810
829
 
811
- 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 };
812
831
  //# sourceMappingURL=rxap-directives.mjs.map