@rxap/directives 16.0.0-dev.2 → 16.0.0-dev.20

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 (44) hide show
  1. package/CHANGELOG.md +369 -0
  2. package/LICENSE +621 -21
  3. package/LICENSE.md +621 -0
  4. package/README.md +8 -22
  5. package/esm2022/index.mjs +13 -10
  6. package/esm2022/lib/avatar-background-image.directive.mjs +17 -19
  7. package/esm2022/lib/background-image.directive.mjs +12 -13
  8. package/esm2022/lib/confirm-click.mjs +6 -7
  9. package/esm2022/lib/contenteditable.directive.mjs +8 -9
  10. package/esm2022/lib/full-width.directive.mjs +7 -8
  11. package/esm2022/lib/if-truthy.directive.mjs +12 -13
  12. package/esm2022/lib/is-dev-mode.directive.mjs +27 -0
  13. package/esm2022/lib/method-template.directive.mjs +22 -20
  14. package/esm2022/lib/method.directive.mjs +16 -17
  15. package/esm2022/lib/movable-divider.directive.mjs +15 -23
  16. package/esm2022/lib/prevent-default.directive.mjs +7 -8
  17. package/esm2022/lib/share-button.directive.mjs +19 -21
  18. package/esm2022/lib/stop-immediate-propagation.directive.mjs +7 -8
  19. package/esm2022/lib/stop-propagation.directive.mjs +7 -8
  20. package/esm2022/rxap-directives.mjs +1 -1
  21. package/fesm2022/rxap-directives.mjs +422 -395
  22. package/fesm2022/rxap-directives.mjs.map +1 -1
  23. package/index.d.ts +10 -9
  24. package/lib/avatar-background-image.directive.d.ts +3 -3
  25. package/lib/background-image.directive.d.ts +1 -1
  26. package/lib/confirm-click.d.ts +1 -1
  27. package/lib/contenteditable.directive.d.ts +2 -2
  28. package/lib/if-truthy.directive.d.ts +6 -6
  29. package/lib/is-dev-mode.directive.d.ts +12 -0
  30. package/lib/method-template.directive.d.ts +5 -4
  31. package/lib/method.directive.d.ts +5 -5
  32. package/lib/movable-divider.directive.d.ts +1 -1
  33. package/lib/share-button.directive.d.ts +1 -1
  34. package/package.json +56 -42
  35. package/theme.css +1 -0
  36. package/collection.json +0 -10
  37. package/migration.json +0 -10
  38. package/src/migrations/v11-2-0/index.d.ts +0 -2
  39. package/src/migrations/v11-2-0/index.js +0 -29
  40. package/src/migrations/v11-2-0/index.js.map +0 -1
  41. package/src/schematics/ng-add/index.d.ts +0 -2
  42. package/src/schematics/ng-add/index.js +0 -8
  43. package/src/schematics/ng-add/index.js.map +0 -1
  44. package/src/schematics/ng-add/schema.json +0 -7
@@ -1,10 +1,10 @@
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
- import { ToggleSubject } from '@rxap/utilities/rxjs';
7
+ import { ToggleSubject } from '@rxap/rxjs';
8
8
  import { Subscription, fromEvent } from 'rxjs';
9
9
  import { tap } from 'rxjs/operators';
10
10
 
@@ -57,18 +57,18 @@ class BackgroundImageDirective {
57
57
  for (const propertyKey of Object.keys(changes)) {
58
58
  switch (propertyKey) {
59
59
  case 'imageUrl':
60
- if (changes.imageUrl.currentValue) {
61
- this.imageUrlChange(changes.imageUrl.currentValue);
60
+ if (changes['imageUrl'].currentValue) {
61
+ this.imageUrlChange(changes['imageUrl'].currentValue);
62
62
  }
63
63
  break;
64
64
  case 'size':
65
- this.sizeChange(changes.size.currentValue);
65
+ this.sizeChange(changes['size'].currentValue);
66
66
  break;
67
67
  case 'repeat':
68
- this.repeatChange(changes.repeat.currentValue);
68
+ this.repeatChange(changes['repeat'].currentValue);
69
69
  break;
70
70
  case 'position':
71
- this.positionChange(changes.position.currentValue);
71
+ this.positionChange(changes['position'].currentValue);
72
72
  break;
73
73
  }
74
74
  }
@@ -96,14 +96,14 @@ class BackgroundImageDirective {
96
96
  }
97
97
  }
98
98
  }
99
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.0.2", ngImport: i0, type: BackgroundImageDirective, deps: [{ token: ElementRef }, { token: Renderer2 }, { token: ImageLoaderService }], target: i0.ɵɵFactoryTarget.Directive }); }
100
- static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "16.0.2", type: BackgroundImageDirective, isStandalone: true, selector: "[rxapBackgroundImage]", inputs: { imageUrl: ["rxapBackgroundImage", "imageUrl"], placeholderImageUrl: "placeholderImageUrl", size: "size", repeat: "repeat", position: "position" }, usesOnChanges: true, ngImport: i0 }); }
99
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.1.4", ngImport: i0, type: BackgroundImageDirective, deps: [{ token: ElementRef }, { token: Renderer2 }, { token: ImageLoaderService }], target: i0.ɵɵFactoryTarget.Directive }); }
100
+ static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "16.1.4", type: BackgroundImageDirective, isStandalone: true, selector: "[rxapBackgroundImage]", inputs: { imageUrl: ["rxapBackgroundImage", "imageUrl"], placeholderImageUrl: "placeholderImageUrl", size: "size", repeat: "repeat", position: "position" }, usesOnChanges: true, ngImport: i0 }); }
101
101
  }
102
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.0.2", ngImport: i0, type: BackgroundImageDirective, decorators: [{
102
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.1.4", ngImport: i0, type: BackgroundImageDirective, decorators: [{
103
103
  type: Directive,
104
104
  args: [{
105
105
  selector: '[rxapBackgroundImage]',
106
- standalone: true
106
+ standalone: true,
107
107
  }]
108
108
  }], ctorParameters: function () { return [{ type: i0.ElementRef, decorators: [{
109
109
  type: Inject,
@@ -127,144 +127,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.0.2", 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.0.2", ngImport: i0, type: PreventDefaultDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
135
- static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "16.0.2", type: PreventDefaultDirective, isStandalone: true, selector: "[rxapPreventDefault]", host: { listeners: { "click": "onClick($event)" } }, ngImport: i0 }); }
136
- }
137
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.0.2", 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.0.2", ngImport: i0, type: StopImmediatePropagationDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
153
- static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "16.0.2", type: StopImmediatePropagationDirective, isStandalone: true, selector: "[rxapStopImmediatePropagation]", host: { listeners: { "click": "onClick($event)" } }, ngImport: i0 }); }
154
- }
155
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.0.2", 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.0.2", ngImport: i0, type: StopPropagationDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
171
- static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "16.0.2", type: StopPropagationDirective, isStandalone: true, selector: "[rxapStopPropagation]", host: { listeners: { "click": "onClick($event)" } }, ngImport: i0 }); }
172
- }
173
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.0.2", 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.0.2", ngImport: i0, type: ShareService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
203
- static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "16.0.2", ngImport: i0, type: ShareService, providedIn: 'root' }); }
204
- }
205
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.0.2", 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({ url: this.url, text: this.text, files: this.files, title: this.title })
215
- .then(() => console.log('share successfully'))
216
- .catch(err => console.error('share failed', err.message));
217
- }
218
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.0.2", ngImport: i0, type: ShareButtonDirective, deps: [{ token: ShareService }], target: i0.ɵɵFactoryTarget.Directive }); }
219
- static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "16.0.2", type: ShareButtonDirective, isStandalone: true, selector: "[rxapShareButton]", inputs: { url: "url", text: "text", title: "title", files: "files" }, host: { listeners: { "click": "share()" } }, ngImport: i0 }); }
220
- }
221
- __decorate([
222
- Required,
223
- __metadata("design:type", String)
224
- ], ShareButtonDirective.prototype, "title", void 0);
225
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.0.2", ngImport: i0, type: ShareButtonDirective, decorators: [{
226
- type: Directive,
227
- args: [{
228
- selector: '[rxapShareButton]',
229
- standalone: true
230
- }]
231
- }], ctorParameters: function () { return [{ type: ShareService }]; }, propDecorators: { url: [{
232
- type: Input
233
- }], text: [{
234
- type: Input
235
- }], title: [{
236
- type: Input
237
- }], files: [{
238
- type: Input
239
- }], share: [{
240
- type: HostListener,
241
- args: ['click']
242
- }] } });
243
-
244
- class FullWidthDirective {
245
- constructor() {
246
- this.width = '100%';
247
- }
248
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.0.2", ngImport: i0, type: FullWidthDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
249
- static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "16.0.2", type: FullWidthDirective, isStandalone: true, selector: "[rxapFullWidth]", host: { properties: { "style.width": "this.width" } }, ngImport: i0 }); }
250
- }
251
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.0.2", ngImport: i0, type: FullWidthDirective, decorators: [{
252
- type: Directive,
253
- args: [{
254
- selector: '[rxapFullWidth]',
255
- standalone: true
256
- }]
257
- }], propDecorators: { width: [{
258
- type: HostBinding,
259
- args: ['style.width']
260
- }] } });
261
-
262
130
  class AvatarBackgroundImageDirective extends BackgroundImageDirective {
263
- set name(name) {
264
- if (!this.placeholderImageUrl) {
265
- this.placeholderImageUrl = this.avatarImage.get({ name });
266
- }
267
- }
268
131
  constructor(host, renderer, imageLoader, avatarImage) {
269
132
  super(host, renderer, imageLoader);
270
133
  this.avatarImage = avatarImage;
@@ -272,15 +135,19 @@ class AvatarBackgroundImageDirective extends BackgroundImageDirective {
272
135
  this.size = BackgroundSizeOptions.COVER;
273
136
  this.repeat = BackgroundRepeatOptions.NO_REPEAT;
274
137
  }
275
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.0.2", ngImport: i0, type: AvatarBackgroundImageDirective, deps: [{ token: ElementRef }, { token: Renderer2 }, { token: ImageLoaderService }, { token: AvatarImageService }], target: i0.ɵɵFactoryTarget.Directive }); }
276
- static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "16.0.2", type: AvatarBackgroundImageDirective, isStandalone: true, selector: "[rxapAvatarBackgroundImage]", inputs: { name: "name", imageUrl: ["rxapAvatarBackgroundImage", "imageUrl"] }, usesInheritance: true, ngImport: i0 }); }
138
+ set name(name) {
139
+ if (!this.placeholderImageUrl) {
140
+ this.placeholderImageUrl = this.avatarImage.get({ name });
141
+ }
142
+ }
143
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.1.4", ngImport: i0, type: AvatarBackgroundImageDirective, deps: [{ token: ElementRef }, { token: Renderer2 }, { token: ImageLoaderService }, { token: AvatarImageService }], target: i0.ɵɵFactoryTarget.Directive }); }
144
+ static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "16.1.4", type: AvatarBackgroundImageDirective, isStandalone: true, selector: "[rxapAvatarBackgroundImage]", inputs: { imageUrl: ["rxapAvatarBackgroundImage", "imageUrl"], name: "name" }, usesInheritance: true, ngImport: i0 }); }
277
145
  }
278
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.0.2", ngImport: i0, type: AvatarBackgroundImageDirective, decorators: [{
146
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.1.4", ngImport: i0, type: AvatarBackgroundImageDirective, decorators: [{
279
147
  type: Directive,
280
148
  args: [{
281
- // tslint:disable-next-line:directive-selector
282
149
  selector: '[rxapAvatarBackgroundImage]',
283
- standalone: true
150
+ standalone: true,
284
151
  }]
285
152
  }], ctorParameters: function () { return [{ type: i0.ElementRef, decorators: [{
286
153
  type: Inject,
@@ -294,11 +161,42 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.0.2", ngImpor
294
161
  }] }, { type: i1.AvatarImageService, decorators: [{
295
162
  type: Inject,
296
163
  args: [AvatarImageService]
297
- }] }]; }, propDecorators: { name: [{
298
- type: Input
299
- }], imageUrl: [{
164
+ }] }]; }, propDecorators: { imageUrl: [{
300
165
  type: Input,
301
166
  args: ['rxapAvatarBackgroundImage']
167
+ }], name: [{
168
+ type: Input
169
+ }] } });
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']
302
200
  }] } });
303
201
 
304
202
  class ContenteditableDirective {
@@ -316,7 +214,7 @@ class ContenteditableDirective {
316
214
  if (value && value.length >= 2) {
317
215
  const event = {
318
216
  value,
319
- parameters: this.parameters
217
+ parameters: this.parameters,
320
218
  };
321
219
  this.change.emit(event);
322
220
  const result = await this.method?.call(event);
@@ -328,8 +226,8 @@ class ContenteditableDirective {
328
226
  }
329
227
  }
330
228
  }
331
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.0.2", ngImport: i0, type: ContenteditableDirective, deps: [{ token: i0.ElementRef }], target: i0.ɵɵFactoryTarget.Directive }); }
332
- static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "16.0.2", type: ContenteditableDirective, isStandalone: true, selector: "[rxapContenteditable]", inputs: { method: ["rxapContenteditable", "method"], parameters: "parameters", initial: "initial" }, outputs: { change: "rxapContenteditable" }, host: { listeners: { "click": "onClick($event)", "input": "onInput($event)" }, properties: { "attr.contenteditable": "this.contenteditable", "attr.spellcheck": "this.spellcheck" } }, ngImport: i0 }); }
229
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.1.4", ngImport: i0, type: ContenteditableDirective, deps: [{ token: i0.ElementRef }], target: i0.ɵɵFactoryTarget.Directive }); }
230
+ static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "16.1.4", type: ContenteditableDirective, isStandalone: true, selector: "[rxapContenteditable]", inputs: { method: ["rxapContenteditable", "method"], parameters: "parameters", initial: "initial" }, outputs: { change: "rxapContenteditable" }, host: { listeners: { "click": "onClick($event)", "input": "onInput($event)" }, properties: { "attr.contenteditable": "this.contenteditable", "attr.spellcheck": "this.spellcheck" } }, ngImport: i0 }); }
333
231
  }
334
232
  __decorate([
335
233
  DebounceCall(1000),
@@ -337,11 +235,11 @@ __decorate([
337
235
  __metadata("design:paramtypes", [Object]),
338
236
  __metadata("design:returntype", Promise)
339
237
  ], ContenteditableDirective.prototype, "onInput", null);
340
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.0.2", ngImport: i0, type: ContenteditableDirective, decorators: [{
238
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.1.4", ngImport: i0, type: ContenteditableDirective, decorators: [{
341
239
  type: Directive,
342
240
  args: [{
343
241
  selector: '[rxapContenteditable]',
344
- standalone: true
242
+ standalone: true,
345
243
  }]
346
244
  }], ctorParameters: function () { return [{ type: i0.ElementRef }]; }, propDecorators: { contenteditable: [{
347
245
  type: HostBinding,
@@ -367,43 +265,263 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.0.2", ngImpor
367
265
  args: ['input', ['$event']]
368
266
  }] } });
369
267
 
370
- class ConfirmClick {
268
+ class FullWidthDirective {
371
269
  constructor() {
372
- this._hasConfirmDirective = false;
270
+ this.width = '100%';
373
271
  }
374
- set hasConfirmDirective(value) {
375
- this._hasConfirmDirective = coerceBoolean(value);
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 }); }
274
+ }
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']
284
+ }] } });
285
+
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;
376
292
  }
377
- onClick() {
378
- if (!this._hasConfirmDirective) {
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;
301
+ }
302
+ ngOnChanges(changes) {
303
+ if (this.method && this.parameters) {
379
304
  this.execute();
380
305
  }
381
306
  }
382
- onConfirm() {
383
- this.execute();
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 });
313
+ }
314
+ }
315
+ this.cdr.detectChanges();
316
+ }
317
+ hasChanged(current) {
318
+ if (this._last !== undefined) {
319
+ const currentTrackBy = this.trackBy ? this.trackBy(current) : current;
320
+ const lastTrackBy = this.trackBy ? this.trackBy(this._last) : this._last;
321
+ return currentTrackBy !== lastTrackBy;
322
+ }
323
+ return true;
384
324
  }
385
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.0.2", ngImport: i0, type: ConfirmClick, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
386
- static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "16.0.2", ngImport: i0, type: ConfirmClick }); }
325
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.1.4", ngImport: i0, type: IfTruthyDirective, deps: [{ token: i0.TemplateRef }, { token: i0.ViewContainerRef }, { token: i0.ChangeDetectorRef }], target: i0.ɵɵFactoryTarget.Directive }); }
326
+ static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "16.1.4", type: IfTruthyDirective, isStandalone: true, selector: "[rxapIfTruthy]", inputs: { method: ["rxapIfTruthy", "method"], parameters: ["rxapIfTruthyParameters", "parameters"], trackBy: ["rxapIfTruthyTrackBy", "trackBy"] }, usesOnChanges: true, ngImport: i0 }); }
387
327
  }
388
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.0.2", ngImport: i0, type: ConfirmClick, decorators: [{
389
- type: Injectable
390
- }], propDecorators: { hasConfirmDirective: [{
328
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.1.4", ngImport: i0, type: IfTruthyDirective, decorators: [{
329
+ type: Directive,
330
+ args: [{
331
+ selector: '[rxapIfTruthy]',
332
+ standalone: true,
333
+ }]
334
+ }], ctorParameters: function () { return [{ type: i0.TemplateRef }, { type: i0.ViewContainerRef }, { type: i0.ChangeDetectorRef }]; }, propDecorators: { method: [{
391
335
  type: Input,
392
- args: ['rxapConfirm']
393
- }], onClick: [{
394
- type: HostListener,
395
- args: ['click']
396
- }], onConfirm: [{
336
+ args: ['rxapIfTruthy']
337
+ }], parameters: [{
338
+ type: Input,
339
+ args: ['rxapIfTruthyParameters']
340
+ }], trackBy: [{
341
+ type: Input,
342
+ args: ['rxapIfTruthyTrackBy']
343
+ }] } });
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
+
370
+ class MethodTemplateDirective {
371
+ constructor(template, viewContainerRef, cdr) {
372
+ this.template = template;
373
+ this.viewContainerRef = viewContainerRef;
374
+ this.cdr = cdr;
375
+ this.withoutParameters = false;
376
+ this.immediately = false;
377
+ this.executed$ = new EventEmitter();
378
+ this.failure$ = new EventEmitter();
379
+ this.successful$ = new EventEmitter();
380
+ /**
381
+ * true - a remote method call is in progress
382
+ */
383
+ this.executing$ = new ToggleSubject();
384
+ this.embedded = new EventEmitter();
385
+ }
386
+ static ngTemplateContextGuard(dir, ctx) {
387
+ return true;
388
+ }
389
+ ngOnChanges(changes) {
390
+ const parametersChanges = changes['parameters'];
391
+ if (parametersChanges) {
392
+ this.execute(parametersChanges.currentValue);
393
+ }
394
+ }
395
+ ngOnInit() {
396
+ this.renderLoadingTemplate();
397
+ if (this.withoutParameters) {
398
+ this.execute();
399
+ }
400
+ }
401
+ onConfirmed() {
402
+ return this.execute();
403
+ }
404
+ async execute(parameters = this.parameters) {
405
+ this.executing$.enable();
406
+ try {
407
+ const result = await this.method.call(parameters);
408
+ this.executed(result);
409
+ this.renderTemplate(result);
410
+ this.successful(result);
411
+ }
412
+ catch (error) {
413
+ if (isDevMode()) {
414
+ console.error(`Method directive execution failed:`, error.message);
415
+ }
416
+ this.renderErrorTemplate(error);
417
+ this.failure(error);
418
+ }
419
+ finally {
420
+ this.executing$.disable();
421
+ }
422
+ }
423
+ setParameter(parameterKey, value) {
424
+ this.updateParameters({ [parameterKey]: value });
425
+ }
426
+ updateParameters(parameters) {
427
+ this.parameters = { ...(this.parameters ?? {}), ...parameters };
428
+ }
429
+ executed(result) {
430
+ this.executed$.emit(result);
431
+ }
432
+ failure(error) {
433
+ this.failure$.emit(error);
434
+ }
435
+ successful(result) {
436
+ this.successful$.emit(result);
437
+ }
438
+ renderErrorTemplate(error) {
439
+ if (this.errorTemplate) {
440
+ this.viewContainerRef.clear();
441
+ if (this.errorTemplate) {
442
+ this.viewContainerRef.createEmbeddedView(this.errorTemplate, {
443
+ $implicit: error,
444
+ message: error.message,
445
+ });
446
+ }
447
+ }
448
+ }
449
+ renderTemplate(result) {
450
+ this.viewContainerRef.clear();
451
+ try {
452
+ this.viewContainerRef.createEmbeddedView(this.template, { $implicit: result });
453
+ }
454
+ catch (error) {
455
+ this.renderErrorTemplate(error);
456
+ console.error(error.message);
457
+ throw error;
458
+ }
459
+ this.embedded.emit();
460
+ this.cdr.detectChanges();
461
+ }
462
+ renderLoadingTemplate() {
463
+ if (this.loadingTemplate) {
464
+ this.viewContainerRef.clear();
465
+ this.viewContainerRef.createEmbeddedView(this.loadingTemplate);
466
+ }
467
+ }
468
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.1.4", ngImport: i0, type: MethodTemplateDirective, deps: [{ token: TemplateRef }, { token: ViewContainerRef }, { token: ChangeDetectorRef }], target: i0.ɵɵFactoryTarget.Directive }); }
469
+ static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "16.1.4", type: MethodTemplateDirective, isStandalone: true, selector: "[rxapMethod]", inputs: { method: ["rxapMethodCall", "method"], parameters: ["rxapMethodParameters", "parameters"], errorTemplate: ["rxapMethodError", "errorTemplate"], loadingTemplate: ["rxapMethodLoading", "loadingTemplate"], withoutParameters: ["rxapMethodWithoutParameters", "withoutParameters"], immediately: "immediately" }, outputs: { executed$: "executed", failure$: "failure", successful$: "successful", executing$: "executing", embedded: "embedded" }, host: { listeners: { "confirmed": "onConfirmed()" } }, exportAs: ["rxapMethod"], usesOnChanges: true, ngImport: i0 }); }
470
+ }
471
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.1.4", ngImport: i0, type: MethodTemplateDirective, decorators: [{
472
+ type: Directive,
473
+ args: [{
474
+ selector: '[rxapMethod]',
475
+ exportAs: 'rxapMethod',
476
+ standalone: true,
477
+ }]
478
+ }], ctorParameters: function () { return [{ type: i0.TemplateRef, decorators: [{
479
+ type: Inject,
480
+ args: [TemplateRef]
481
+ }] }, { type: i0.ViewContainerRef, decorators: [{
482
+ type: Inject,
483
+ args: [ViewContainerRef]
484
+ }] }, { type: i0.ChangeDetectorRef, decorators: [{
485
+ type: Inject,
486
+ args: [ChangeDetectorRef]
487
+ }] }]; }, propDecorators: { method: [{
488
+ type: Input,
489
+ args: ['rxapMethodCall']
490
+ }], parameters: [{
491
+ type: Input,
492
+ args: ['rxapMethodParameters']
493
+ }], errorTemplate: [{
494
+ type: Input,
495
+ args: ['rxapMethodError']
496
+ }], loadingTemplate: [{
497
+ type: Input,
498
+ args: ['rxapMethodLoading']
499
+ }], withoutParameters: [{
500
+ type: Input,
501
+ args: ['rxapMethodWithoutParameters']
502
+ }], immediately: [{
503
+ type: Input
504
+ }], executed$: [{
505
+ type: Output,
506
+ args: ['executed']
507
+ }], failure$: [{
508
+ type: Output,
509
+ args: ['failure']
510
+ }], successful$: [{
511
+ type: Output,
512
+ args: ['successful']
513
+ }], executing$: [{
514
+ type: Output,
515
+ args: ['executing']
516
+ }], embedded: [{
517
+ type: Output
518
+ }], onConfirmed: [{
397
519
  type: HostListener,
398
520
  args: ['confirmed']
399
521
  }] } });
400
522
 
401
523
  class MethodDirective {
402
- set hasConfirmDirective(value) {
403
- this._hasConfirmDirective = coerceBoolean(value);
404
- }
405
524
  constructor() {
406
- this._hasConfirmDirective = false;
407
525
  this.immediately = false;
408
526
  this.executed$ = new EventEmitter();
409
527
  this.failure$ = new EventEmitter();
@@ -412,6 +530,10 @@ class MethodDirective {
412
530
  * true - a remote method call is in progress
413
531
  */
414
532
  this.executing$ = new ToggleSubject();
533
+ this._hasConfirmDirective = false;
534
+ }
535
+ set hasConfirmDirective(value) {
536
+ this._hasConfirmDirective = coerceBoolean(value);
415
537
  }
416
538
  ngOnInit() {
417
539
  if (this.immediately) {
@@ -464,20 +586,17 @@ class MethodDirective {
464
586
  successful(result) {
465
587
  this.successful$.emit(result);
466
588
  }
467
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.0.2", ngImport: i0, type: MethodDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
468
- static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "16.0.2", type: MethodDirective, isStandalone: true, selector: "[rxapMethod]", inputs: { hasConfirmDirective: ["rxapConfirm", "hasConfirmDirective"], method: ["rxapMethod", "method"], parameters: "parameters", immediately: "immediately" }, outputs: { executed$: "executed", failure$: "failure", successful$: "successful" }, host: { listeners: { "confirmed": "onConfirmed()", "click": "onClick()" } }, exportAs: ["rxapMethod"], ngImport: i0 }); }
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 }); }
469
591
  }
470
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.0.2", ngImport: i0, type: MethodDirective, decorators: [{
592
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.1.4", ngImport: i0, type: MethodDirective, decorators: [{
471
593
  type: Directive,
472
594
  args: [{
473
595
  selector: '[rxapMethod]',
474
596
  exportAs: 'rxapMethod',
475
- standalone: true
597
+ standalone: true,
476
598
  }]
477
- }], ctorParameters: function () { return []; }, propDecorators: { hasConfirmDirective: [{
478
- type: Input,
479
- args: ['rxapConfirm']
480
- }], method: [{
599
+ }], propDecorators: { method: [{
481
600
  type: Input,
482
601
  args: ['rxapMethod']
483
602
  }], parameters: [{
@@ -493,6 +612,9 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.0.2", ngImpor
493
612
  }], successful$: [{
494
613
  type: Output,
495
614
  args: ['successful']
615
+ }], hasConfirmDirective: [{
616
+ type: Input,
617
+ args: ['rxapConfirm']
496
618
  }], onConfirmed: [{
497
619
  type: HostListener,
498
620
  args: ['confirmed']
@@ -537,10 +659,11 @@ class MovableDividerDirective {
537
659
  console.log({
538
660
  clientWidth: this.containerElement.clientWidth,
539
661
  clientX: $event.clientX,
540
- clientLeft: this.containerElement.getBoundingClientRect().left
662
+ clientLeft: this.containerElement.getBoundingClientRect().left,
541
663
  });
542
664
  }
543
- this._fixedElementWidth = this.containerElement.clientWidth - $event.clientX + this.containerElement.getBoundingClientRect().left;
665
+ this._fixedElementWidth =
666
+ this.containerElement.clientWidth - $event.clientX + this.containerElement.getBoundingClientRect().left;
544
667
  }
545
668
  else {
546
669
  throw new Error(`The origin '${this.origin}' is not supported.`);
@@ -556,27 +679,21 @@ class MovableDividerDirective {
556
679
  onMousedown() {
557
680
  this._moveDivider = true;
558
681
  }
559
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.0.2", ngImport: i0, type: MovableDividerDirective, deps: [{ token: i0.Renderer2 }], target: i0.ɵɵFactoryTarget.Directive }); }
560
- static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "16.0.2", type: MovableDividerDirective, isStandalone: true, selector: "[rxapMovableDivider]", inputs: { containerElement: "containerElement", fixedElement: "fixedElement", origin: "origin" }, host: { listeners: { "mousedown": "onMousedown()" }, properties: { "style.cursor": "this.cursor" } }, ngImport: i0 }); }
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 }); }
561
684
  }
562
- __decorate([
563
- Required,
564
- __metadata("design:type", HTMLDivElement)
565
- ], MovableDividerDirective.prototype, "containerElement", void 0);
566
- __decorate([
567
- Required,
568
- __metadata("design:type", HTMLDivElement)
569
- ], MovableDividerDirective.prototype, "fixedElement", void 0);
570
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.0.2", ngImport: i0, type: MovableDividerDirective, decorators: [{
685
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.1.4", ngImport: i0, type: MovableDividerDirective, decorators: [{
571
686
  type: Directive,
572
687
  args: [{
573
688
  selector: '[rxapMovableDivider]',
574
- standalone: true
689
+ standalone: true,
575
690
  }]
576
691
  }], ctorParameters: function () { return [{ type: i0.Renderer2 }]; }, propDecorators: { containerElement: [{
577
- type: Input
692
+ type: Input,
693
+ args: [{ required: true }]
578
694
  }], fixedElement: [{
579
- type: Input
695
+ type: Input,
696
+ args: [{ required: true }]
580
697
  }], origin: [{
581
698
  type: Input
582
699
  }], cursor: [{
@@ -587,218 +704,128 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.0.2", ngImpor
587
704
  args: ['mousedown']
588
705
  }] } });
589
706
 
590
- // TODO : mv to rxap package
591
- class IfTruthyDirective {
592
- /**
593
- * Asserts the correct type of the context for the template that `NgForOf` will render.
594
- *
595
- * The presence of this method is a signal to the Ivy template type-check compiler that the
596
- * `NgForOf` structural directive renders its template with a specific context type.
597
- */
598
- static ngTemplateContextGuard(dir, ctx) {
599
- return true;
600
- }
601
- constructor(templateRef, viewContainerRef, cdr) {
602
- this.templateRef = templateRef;
603
- this.viewContainerRef = viewContainerRef;
604
- this.cdr = cdr;
605
- }
606
- ngOnChanges(changes) {
607
- if (this.method && this.parameters) {
608
- this.execute();
609
- }
610
- }
611
- async execute() {
612
- const result = await this.method.call(this.parameters);
613
- if (this.hasChanged(result)) {
614
- this.viewContainerRef.clear();
615
- if (result) {
616
- this.viewContainerRef.createEmbeddedView(this.templateRef, { $implicit: result });
617
- }
618
- }
619
- this.cdr.detectChanges();
620
- }
621
- hasChanged(current) {
622
- if (this._last !== undefined) {
623
- const currentTrackBy = this.trackBy ? this.trackBy(current) : current;
624
- const lastTrackBy = this.trackBy ? this.trackBy(this._last) : this._last;
625
- return currentTrackBy !== lastTrackBy;
626
- }
627
- return true;
707
+ class PreventDefaultDirective {
708
+ onClick($event) {
709
+ $event.preventDefault();
628
710
  }
629
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.0.2", ngImport: i0, type: IfTruthyDirective, deps: [{ token: i0.TemplateRef }, { token: i0.ViewContainerRef }, { token: i0.ChangeDetectorRef }], target: i0.ɵɵFactoryTarget.Directive }); }
630
- static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "16.0.2", type: IfTruthyDirective, isStandalone: true, selector: "[rxapIfTruthy]", inputs: { method: ["rxapIfTruthy", "method"], parameters: ["rxapIfTruthyParameters", "parameters"], trackBy: ["rxapIfTruthyTrackBy", "trackBy"] }, usesOnChanges: true, ngImport: i0 }); }
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 }); }
631
713
  }
632
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.0.2", ngImport: i0, type: IfTruthyDirective, decorators: [{
714
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.1.4", ngImport: i0, type: PreventDefaultDirective, decorators: [{
633
715
  type: Directive,
634
716
  args: [{
635
- selector: '[rxapIfTruthy]',
636
- standalone: true
717
+ selector: '[rxapPreventDefault]',
718
+ standalone: true,
637
719
  }]
638
- }], ctorParameters: function () { return [{ type: i0.TemplateRef }, { type: i0.ViewContainerRef }, { type: i0.ChangeDetectorRef }]; }, propDecorators: { method: [{
639
- type: Input,
640
- args: ['rxapIfTruthy']
641
- }], parameters: [{
642
- type: Input,
643
- args: ['rxapIfTruthyParameters']
644
- }], trackBy: [{
645
- type: Input,
646
- args: ['rxapIfTruthyTrackBy']
720
+ }], propDecorators: { onClick: [{
721
+ type: HostListener,
722
+ args: ['click', ['$event']]
647
723
  }] } });
648
724
 
649
- class MethodTemplateDirective {
650
- static ngTemplateContextGuard(dir, ctx) {
651
- return true;
652
- }
653
- constructor(template, viewContainerRef, cdr) {
654
- this.template = template;
655
- this.viewContainerRef = viewContainerRef;
656
- this.cdr = cdr;
657
- this.withoutParameters = false;
658
- this.immediately = false;
659
- this.executed$ = new EventEmitter();
660
- this.failure$ = new EventEmitter();
661
- this.successful$ = new EventEmitter();
662
- /**
663
- * true - a remote method call is in progress
664
- */
665
- this.executing$ = new ToggleSubject();
666
- this.embedded = new EventEmitter();
667
- }
668
- ngOnChanges(changes) {
669
- const parametersChanges = changes.parameters;
670
- if (parametersChanges) {
671
- this.execute(parametersChanges.currentValue);
672
- }
673
- }
674
- ngOnInit() {
675
- this.renderLoadingTemplate();
676
- if (this.withoutParameters) {
677
- this.execute();
678
- }
679
- }
680
- onConfirmed() {
681
- return this.execute();
682
- }
683
- async execute(parameters = this.parameters) {
684
- this.executing$.enable();
685
- try {
686
- const result = await this.method.call(parameters);
687
- this.executed(result);
688
- this.renderTemplate(result);
689
- this.successful(result);
690
- }
691
- catch (error) {
692
- if (isDevMode()) {
693
- console.error(`Method directive execution failed:`, error.message);
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!');
694
734
  }
695
- this.renderErrorTemplate(error);
696
- this.failure(error);
697
- }
698
- finally {
699
- this.executing$.disable();
700
735
  }
701
- }
702
- setParameter(parameterKey, value) {
703
- this.updateParameters({ [parameterKey]: value });
704
- }
705
- updateParameters(parameters) {
706
- this.parameters = { ...(this.parameters ?? {}), ...parameters };
707
- }
708
- renderLoadingTemplate() {
709
- if (this.loadingTemplate) {
710
- this.viewContainerRef.clear();
711
- this.viewContainerRef.createEmbeddedView(this.loadingTemplate);
736
+ else {
737
+ alert('Native share is not supported!');
712
738
  }
713
739
  }
714
- executed(result) {
715
- this.executed$.emit(result);
716
- }
717
- failure(error) {
718
- this.failure$.emit(error);
719
- }
720
- successful(result) {
721
- this.successful$.emit(result);
740
+ isShareSupported() {
741
+ return !!navigator.share;
722
742
  }
723
- renderErrorTemplate(error) {
724
- if (this.errorTemplate) {
725
- this.viewContainerRef.clear();
726
- if (this.errorTemplate) {
727
- this.viewContainerRef.createEmbeddedView(this.errorTemplate, { $implicit: error, message: error.message });
728
- }
729
- }
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;
730
753
  }
731
- renderTemplate(result) {
732
- this.viewContainerRef.clear();
733
- try {
734
- this.viewContainerRef.createEmbeddedView(this.template, { $implicit: result });
735
- }
736
- catch (error) {
737
- this.renderErrorTemplate(error);
738
- console.error(error.message);
739
- throw error;
740
- }
741
- this.embedded.emit();
742
- this.cdr.detectChanges();
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));
743
763
  }
744
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.0.2", ngImport: i0, type: MethodTemplateDirective, deps: [{ token: TemplateRef }, { token: ViewContainerRef }, { token: ChangeDetectorRef }], target: i0.ɵɵFactoryTarget.Directive }); }
745
- static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "16.0.2", type: MethodTemplateDirective, isStandalone: true, selector: "[rxapMethod]", inputs: { method: ["rxapMethodCall", "method"], parameters: ["rxapMethodParameters", "parameters"], errorTemplate: ["rxapMethodError", "errorTemplate"], loadingTemplate: ["rxapMethodLoading", "loadingTemplate"], withoutParameters: ["rxapMethodWithoutParameters", "withoutParameters"], immediately: "immediately" }, outputs: { executed$: "executed", failure$: "failure", successful$: "successful", executing$: "executing", embedded: "embedded" }, host: { listeners: { "confirmed": "onConfirmed()" } }, exportAs: ["rxapMethod"], usesOnChanges: true, ngImport: i0 }); }
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 }); }
746
766
  }
747
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.0.2", ngImport: i0, type: MethodTemplateDirective, decorators: [{
767
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.1.4", ngImport: i0, type: ShareButtonDirective, decorators: [{
748
768
  type: Directive,
749
769
  args: [{
750
- selector: '[rxapMethod]',
751
- exportAs: 'rxapMethod',
752
- standalone: true
770
+ selector: '[rxapShareButton]',
771
+ standalone: true,
753
772
  }]
754
- }], ctorParameters: function () { return [{ type: i0.TemplateRef, decorators: [{
755
- type: Inject,
756
- args: [TemplateRef]
757
- }] }, { type: i0.ViewContainerRef, decorators: [{
758
- type: Inject,
759
- args: [ViewContainerRef]
760
- }] }, { type: i0.ChangeDetectorRef, decorators: [{
761
- type: Inject,
762
- args: [ChangeDetectorRef]
763
- }] }]; }, propDecorators: { method: [{
764
- type: Input,
765
- args: ['rxapMethodCall']
766
- }], parameters: [{
767
- type: Input,
768
- args: ['rxapMethodParameters']
769
- }], errorTemplate: [{
770
- type: Input,
771
- args: ['rxapMethodError']
772
- }], loadingTemplate: [{
773
- type: Input,
774
- args: ['rxapMethodLoading']
775
- }], withoutParameters: [{
773
+ }], ctorParameters: function () { return [{ type: ShareService }]; }, propDecorators: { url: [{
774
+ type: Input
775
+ }], text: [{
776
+ type: Input
777
+ }], title: [{
776
778
  type: Input,
777
- args: ['rxapMethodWithoutParameters']
778
- }], immediately: [{
779
+ args: [{ required: true }]
780
+ }], files: [{
779
781
  type: Input
780
- }], executed$: [{
781
- type: Output,
782
- args: ['executed']
783
- }], failure$: [{
784
- type: Output,
785
- args: ['failure']
786
- }], successful$: [{
787
- type: Output,
788
- args: ['successful']
789
- }], executing$: [{
790
- type: Output,
791
- args: ['executing']
792
- }], embedded: [{
793
- type: Output
794
- }], onConfirmed: [{
782
+ }], share: [{
795
783
  type: HostListener,
796
- args: ['confirmed']
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']]
797
821
  }] } });
798
822
 
823
+ // region
824
+ // endregion
825
+
799
826
  /**
800
827
  * Generated bundle index. Do not edit.
801
828
  */
802
829
 
803
- 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 };
804
831
  //# sourceMappingURL=rxap-directives.mjs.map