@rxap/directives 19.0.4 → 19.1.0-dev.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.
Files changed (106) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/compodoc/changelog.html +5 -0
  3. package/compodoc/dependencies.html +4 -4
  4. package/compodoc/directives/ShareButtonDirective.html +234 -140
  5. package/compodoc/injectables/ShareService.html +109 -40
  6. package/compodoc/interfaces/ShareData.html +500 -0
  7. package/compodoc/js/menu-wc.js +3 -0
  8. package/compodoc/js/menu-wc_es5.js +1 -1
  9. package/compodoc/js/search/search_index.js +2 -2
  10. package/compodoc/overview.html +1 -1
  11. package/compodoc/properties.html +1 -1
  12. package/docs/documentation.json +645 -478
  13. package/docs/html/assets/navigation.js +1 -1
  14. package/docs/html/assets/search.js +1 -1
  15. package/docs/html/classes/AvatarBackgroundImageDirective.html +4 -4
  16. package/docs/html/classes/BackgroundImageDirective.html +4 -4
  17. package/docs/html/classes/ConfirmClick.html +2 -2
  18. package/docs/html/classes/ContenteditableDirective.html +2 -2
  19. package/docs/html/classes/FullWidthDirective.html +2 -2
  20. package/docs/html/classes/IfTruthyDirective.html +4 -4
  21. package/docs/html/classes/IsDevModeDirective.html +4 -4
  22. package/docs/html/classes/MethodDirective.html +4 -4
  23. package/docs/html/classes/MethodTemplateDirective.html +5 -5
  24. package/docs/html/classes/MovableDividerDirective.html +4 -4
  25. package/docs/html/classes/PreventDefaultDirective.html +2 -2
  26. package/docs/html/classes/ShareButtonDirective.html +5 -3
  27. package/docs/html/classes/ShareService.html +3 -2
  28. package/docs/html/classes/StopImmediatePropagationDirective.html +2 -2
  29. package/docs/html/classes/StopPropagationDirective.html +2 -2
  30. package/docs/html/enums/BackgroundPositionOptions.html +2 -2
  31. package/docs/html/enums/BackgroundRepeatOptions.html +2 -2
  32. package/docs/html/enums/BackgroundSizeOptions.html +2 -2
  33. package/docs/html/enums/GlobalStyleOptions.html +2 -2
  34. package/docs/html/hierarchy.html +1 -1
  35. package/docs/html/index.html +2 -2
  36. package/docs/html/interfaces/ContenteditableEvent.html +2 -2
  37. package/docs/html/interfaces/IfTruthyDirectiveTemplateContext.html +2 -2
  38. package/docs/html/interfaces/MethodTemplateDirectiveContext.html +2 -2
  39. package/docs/html/interfaces/MethodTemplateDirectiveErrorContext.html +2 -2
  40. package/docs/html/interfaces/ShareData.html +5 -0
  41. package/docs/html/modules.html +1 -1
  42. package/docs/html/types/BackgroundPosition.html +1 -1
  43. package/docs/html/types/BackgroundRepeat.html +1 -1
  44. package/docs/html/types/BackgroundSize.html +1 -1
  45. package/docs/markdown/README.md +1 -1
  46. package/docs/markdown/classes/AvatarBackgroundImageDirective.md +11 -11
  47. package/docs/markdown/classes/BackgroundImageDirective.md +10 -10
  48. package/docs/markdown/classes/ConfirmClick.md +6 -6
  49. package/docs/markdown/classes/ContenteditableDirective.md +11 -11
  50. package/docs/markdown/classes/FullWidthDirective.md +3 -3
  51. package/docs/markdown/classes/IfTruthyDirective.md +10 -10
  52. package/docs/markdown/classes/IsDevModeDirective.md +5 -5
  53. package/docs/markdown/classes/MethodDirective.md +19 -19
  54. package/docs/markdown/classes/MethodTemplateDirective.md +27 -27
  55. package/docs/markdown/classes/MovableDividerDirective.md +10 -10
  56. package/docs/markdown/classes/PreventDefaultDirective.md +3 -3
  57. package/docs/markdown/classes/ShareButtonDirective.md +30 -22
  58. package/docs/markdown/classes/ShareService.md +15 -17
  59. package/docs/markdown/classes/StopImmediatePropagationDirective.md +3 -3
  60. package/docs/markdown/classes/StopPropagationDirective.md +3 -3
  61. package/docs/markdown/enumerations/BackgroundPositionOptions.md +4 -4
  62. package/docs/markdown/enumerations/BackgroundRepeatOptions.md +3 -3
  63. package/docs/markdown/enumerations/BackgroundSizeOptions.md +5 -5
  64. package/docs/markdown/enumerations/GlobalStyleOptions.md +4 -4
  65. package/docs/markdown/globals.md +3 -2
  66. package/docs/markdown/interfaces/ContenteditableEvent.md +4 -4
  67. package/docs/markdown/interfaces/IfTruthyDirectiveTemplateContext.md +3 -3
  68. package/docs/markdown/interfaces/MethodTemplateDirectiveContext.md +3 -3
  69. package/docs/markdown/interfaces/MethodTemplateDirectiveErrorContext.md +4 -4
  70. package/docs/markdown/interfaces/ShareData.md +41 -0
  71. package/docs/markdown/type-aliases/BackgroundPosition.md +2 -2
  72. package/docs/markdown/type-aliases/BackgroundRepeat.md +2 -2
  73. package/docs/markdown/type-aliases/BackgroundSize.md +2 -2
  74. package/docs/wiki/Class.AvatarBackgroundImageDirective.md +10 -10
  75. package/docs/wiki/Class.BackgroundImageDirective.md +9 -9
  76. package/docs/wiki/Class.ConfirmClick.md +5 -5
  77. package/docs/wiki/Class.ContenteditableDirective.md +10 -10
  78. package/docs/wiki/Class.FullWidthDirective.md +2 -2
  79. package/docs/wiki/Class.IfTruthyDirective.md +9 -9
  80. package/docs/wiki/Class.IsDevModeDirective.md +4 -4
  81. package/docs/wiki/Class.MethodDirective.md +18 -18
  82. package/docs/wiki/Class.MethodTemplateDirective.md +26 -26
  83. package/docs/wiki/Class.MovableDividerDirective.md +9 -9
  84. package/docs/wiki/Class.PreventDefaultDirective.md +2 -2
  85. package/docs/wiki/Class.ShareButtonDirective.md +29 -21
  86. package/docs/wiki/Class.ShareService.md +14 -16
  87. package/docs/wiki/Class.StopImmediatePropagationDirective.md +2 -2
  88. package/docs/wiki/Class.StopPropagationDirective.md +2 -2
  89. package/docs/wiki/Enumeration.BackgroundPositionOptions.md +3 -3
  90. package/docs/wiki/Enumeration.BackgroundRepeatOptions.md +2 -2
  91. package/docs/wiki/Enumeration.BackgroundSizeOptions.md +4 -4
  92. package/docs/wiki/Enumeration.GlobalStyleOptions.md +3 -3
  93. package/docs/wiki/Interface.ContenteditableEvent.md +3 -3
  94. package/docs/wiki/Interface.IfTruthyDirectiveTemplateContext.md +2 -2
  95. package/docs/wiki/Interface.MethodTemplateDirectiveContext.md +2 -2
  96. package/docs/wiki/Interface.MethodTemplateDirectiveErrorContext.md +3 -3
  97. package/docs/wiki/Interface.ShareData.md +37 -0
  98. package/docs/wiki/TypeAlias.BackgroundPosition.md +1 -1
  99. package/docs/wiki/TypeAlias.BackgroundRepeat.md +1 -1
  100. package/docs/wiki/TypeAlias.BackgroundSize.md +1 -1
  101. package/docs/wiki/_Sidebar.md +1 -0
  102. package/docs/wiki/globals.md +2 -1
  103. package/fesm2022/rxap-directives.mjs +39 -34
  104. package/fesm2022/rxap-directives.mjs.map +1 -1
  105. package/lib/share-button.directive.d.ts +16 -14
  106. package/package.json +10 -10
@@ -126,6 +126,21 @@
126
126
  <h3 id="index">Index</h3>
127
127
  <table class="table table-sm table-bordered index-table">
128
128
  <tbody>
129
+ <tr>
130
+ <td class="col-md-4">
131
+ <h6><b>Properties</b></h6>
132
+ </td>
133
+ </tr>
134
+ <tr>
135
+ <td class="col-md-4">
136
+ <ul class="index-list">
137
+ <li>
138
+ <span class="modifier">Readonly</span>
139
+ <a href="#isSupported" >isSupported</a>
140
+ </li>
141
+ </ul>
142
+ </td>
143
+ </tr>
129
144
 
130
145
  <tr>
131
146
  <td class="col-md-4">
@@ -136,7 +151,6 @@
136
151
  <td class="col-md-4">
137
152
  <ul class="index-list">
138
153
  <li>
139
- <span class="modifier">Public</span>
140
154
  <span class="modifier">Async</span>
141
155
  <a href="#share" >share</a>
142
156
  </li>
@@ -164,7 +178,6 @@
164
178
  <td class="col-md-4">
165
179
  <a name="share"></a>
166
180
  <span class="name">
167
- <span class="modifier">Public</span>
168
181
  <span class="modifier">Async</span>
169
182
  <span ><b>share</b></span>
170
183
  <a href="#share"><span class="icon ion-ios-link"></span></a>
@@ -174,15 +187,15 @@
174
187
  <tr>
175
188
  <td class="col-md-4">
176
189
  <span class="modifier-icon icon ion-ios-reset"></span>
177
- <code>share(data: literal type)</code>
190
+ <code>share(data: <a href="../interfaces/ShareData.html" target="_self">ShareData</a>, softFail)</code>
178
191
  </td>
179
192
  </tr>
180
193
 
181
194
 
182
195
  <tr>
183
196
  <td class="col-md-4">
184
- <div class="io-line">Defined in <a href="" data-line="12"
185
- class="link-to-prism">src/lib/share-button.directive.ts:12</a></div>
197
+ <div class="io-line">Defined in <a href="" data-line="22"
198
+ class="link-to-prism">src/lib/share-button.directive.ts:22</a></div>
186
199
  </td>
187
200
  </tr>
188
201
 
@@ -199,19 +212,36 @@
199
212
  <td>Name</td>
200
213
  <td>Type</td>
201
214
  <td>Optional</td>
215
+ <td>Default value</td>
202
216
  </tr>
203
217
  </thead>
204
218
  <tbody>
205
219
  <tr>
206
220
  <td>data</td>
207
221
  <td>
208
- <code>literal type</code>
222
+ <code><a href="../interfaces/ShareData.html" target="_self" >ShareData</a></code>
209
223
  </td>
210
224
 
211
225
  <td>
212
226
  No
213
227
  </td>
214
228
 
229
+ <td>
230
+ </td>
231
+
232
+ </tr>
233
+ <tr>
234
+ <td>softFail</td>
235
+ <td>
236
+ </td>
237
+
238
+ <td>
239
+ No
240
+ </td>
241
+
242
+ <td>
243
+ <code>true</code>
244
+ </td>
215
245
 
216
246
  </tr>
217
247
  </tbody>
@@ -226,6 +256,38 @@
226
256
  </div>
227
257
  </td>
228
258
  </tr>
259
+ </tbody>
260
+ </table>
261
+ </section>
262
+ <section data-compodoc="block-properties">
263
+
264
+ <h3 id="inputs">
265
+ Properties
266
+ </h3>
267
+ <table class="table table-sm table-bordered">
268
+ <tbody>
269
+ <tr>
270
+ <td class="col-md-4">
271
+ <a name="isSupported"></a>
272
+ <span class="name">
273
+ <span class="modifier">Readonly</span>
274
+ <span ><b>isSupported</b></span>
275
+ <a href="#isSupported"><span class="icon ion-ios-link"></span></a>
276
+ </span>
277
+ </td>
278
+ </tr>
279
+ <tr>
280
+ <td class="col-md-4">
281
+ <i>Default value : </i><code>&#x27;share&#x27; in navigator &amp;&amp; &#x27;canShare&#x27; in navigator &amp;&amp; typeof navigator.canShare &#x3D;&#x3D;&#x3D; &#x27;function&#x27; &amp;&amp; typeof navigator.share &#x3D;&#x3D;&#x3D; &#x27;function&#x27;</code>
282
+ </td>
283
+ </tr>
284
+ <tr>
285
+ <td class="col-md-4">
286
+ <div class="io-line">Defined in <a href="" data-line="20" class="link-to-prism">src/lib/share-button.directive.ts:20</a></div>
287
+ </td>
288
+ </tr>
289
+
290
+
229
291
  </tbody>
230
292
  </table>
231
293
  </section>
@@ -237,70 +299,77 @@
237
299
  <pre class="line-numbers compodoc-sourcecode"><code class="language-typescript">import {
238
300
  Directive,
239
301
  HostListener,
302
+ inject,
240
303
  Injectable,
241
- Input,
304
+ input,
305
+ output,
242
306
  } from &#x27;@angular/core&#x27;;
243
- import { Required } from &#x27;@rxap/utilities&#x27;;
307
+
308
+ export interface ShareData {
309
+ files?: File[];
310
+ text?: string;
311
+ title?: string;
312
+ url?: string;
313
+ }
244
314
 
245
315
  @Injectable({ providedIn: &#x27;root&#x27; })
246
316
  export class ShareService {
247
317
 
248
- public async share(data: { url?: string, text?: string, title?: string, files?: ReadonlyArray&lt;File&gt; }) {
318
+ readonly isSupported &#x3D; &#x27;share&#x27; in navigator &amp;&amp; &#x27;canShare&#x27; in navigator &amp;&amp; typeof navigator.canShare &#x3D;&#x3D;&#x3D; &#x27;function&#x27; &amp;&amp; typeof navigator.share &#x3D;&#x3D;&#x3D; &#x27;function&#x27;;
249
319
 
250
- if (this.isShareSupported()) {
320
+ async share(data: ShareData, softFail &#x3D; true) {
251
321
 
252
- if ((navigator as any).canShare(data)) {
322
+ if (this.isSupported) {
253
323
 
254
- await (navigator as any).share(data);
324
+ if (navigator.canShare(data)) {
325
+
326
+ await navigator.share(data);
255
327
 
256
328
  } else {
257
- console.debug(&#x27;share data:&#x27;, data);
258
- throw new Error(&#x27;Can not share data. Data is invalid!&#x27;);
329
+ console.warn(&#x27;Can not share data&#x27;, data);
330
+ throw new Error(&#x27;Can not share data&#x27;);
259
331
  }
260
332
 
333
+ } else if (softFail) {
334
+ console.warn(&#x60;Native share is not supported!&#x60;);
261
335
  } else {
262
336
  alert(&#x27;Native share is not supported!&#x27;);
263
337
  }
264
338
 
265
339
  }
266
340
 
267
- private isShareSupported(): boolean {
268
- return !!(navigator as any).share;
269
- }
270
-
271
341
  }
272
342
 
273
343
  @Directive({
274
- selector: &#x27;[rxapShareButton]&#x27;,
344
+ selector: &#x27;[rxapShareButton],[rxapShare]&#x27;,
275
345
  standalone: true,
276
346
  })
277
347
  export class ShareButtonDirective {
278
348
 
279
- @Input()
280
- public url!: string;
281
-
282
- @Input()
283
- public text!: string;
349
+ readonly url &#x3D; input&lt;string&gt;();
350
+ readonly text &#x3D; input&lt;string&gt;();
351
+ readonly title &#x3D; input&lt;string&gt;();
352
+ readonly files &#x3D; input&lt;File[] | undefined&gt;();
284
353
 
285
- @Input({ required: true })
286
- public title!: string;
354
+ readonly failed &#x3D; output&lt;any&gt;();
355
+ readonly success &#x3D; output&lt;void&gt;();
287
356
 
288
- @Input()
289
- public files?: ReadonlyArray&lt;File&gt;;
290
-
291
- constructor(private readonly shareService: ShareService) {
292
- }
357
+ private readonly shareService &#x3D; inject(ShareService);
293
358
 
294
359
  @HostListener(&#x27;click&#x27;)
295
- public share() {
296
- this.shareService.share({
297
- url: this.url,
298
- text: this.text,
299
- files: this.files,
300
- title: this.title,
301
- })
302
- .then(() &#x3D;&gt; console.log(&#x27;share successfully&#x27;))
303
- .catch(err &#x3D;&gt; console.error(&#x27;share failed&#x27;, err.message));
360
+ async share() {
361
+ try {
362
+ await this.shareService.share({
363
+ url: this.url(),
364
+ text: this.text(),
365
+ files: this.files(),
366
+ title: this.title(),
367
+ });
368
+ this.success.emit();
369
+ } catch (err: any) {
370
+ console.error(&#x60;share failed: ${ err.message }&#x60;);
371
+ this.failed.emit(err);
372
+ }
304
373
  }
305
374
 
306
375
  }