@ldw-framework/material-media 0.2.0 → 0.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  import { CommonModule } from '@angular/common';
2
2
  import * as i0 from '@angular/core';
3
- import { inject, ChangeDetectorRef, Component, InjectionToken, Injectable } from '@angular/core';
3
+ import { inject, ChangeDetectorRef, Component, InjectionToken, Injectable, Input, NgModule } from '@angular/core';
4
4
  import * as i1 from '@angular/material/button';
5
5
  import { MatButtonModule } from '@angular/material/button';
6
6
  import * as i3 from '@angular/material/dialog';
@@ -8,6 +8,13 @@ import { MatDialogRef, MAT_DIALOG_DATA, MatDialogModule, MatDialog } from '@angu
8
8
  import * as i2 from '@angular/material/icon';
9
9
  import { MatIconModule } from '@angular/material/icon';
10
10
  import { LDuAnguBootTranslationPipe } from '@ldu-anguboot/i18n';
11
+ import { coerceBooleanProperty } from '@angular/cdk/coercion';
12
+ import * as i1$1 from '@angular/forms';
13
+ import { FormGroup, FormControl, FormsModule, ReactiveFormsModule } from '@angular/forms';
14
+ import * as i3$1 from '@angular/material/form-field';
15
+ import { MatFormFieldModule } from '@angular/material/form-field';
16
+ import * as i4 from '@angular/material/input';
17
+ import { MatInputModule } from '@angular/material/input';
11
18
  import { LDuAnguBootApiService } from '@ldu-anguboot/http';
12
19
  import { firstValueFrom } from 'rxjs';
13
20
 
@@ -65,7 +72,7 @@ class LDwMaterialImageUploadDialogComponent {
65
72
  [style.display]="'none'"
66
73
  (change)="onChange($event)"
67
74
  />
68
- <div class="ldw-mat-image-uploader"
75
+ <div class="ldw-mat-image-uploader--instance"
69
76
  [style.backgroundImage]="$backgroundImage"
70
77
  (keypress)="uploader.click()"
71
78
  (click)="uploader.click()"
@@ -105,7 +112,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.0", ngImpor
105
112
  [style.display]="'none'"
106
113
  (change)="onChange($event)"
107
114
  />
108
- <div class="ldw-mat-image-uploader"
115
+ <div class="ldw-mat-image-uploader--instance"
109
116
  [style.backgroundImage]="$backgroundImage"
110
117
  (keypress)="uploader.click()"
111
118
  (click)="uploader.click()"
@@ -148,6 +155,9 @@ class LDwMaterialMediaService {
148
155
  }
149
156
  return null;
150
157
  }
158
+ async clearImage(api) {
159
+ return firstValueFrom(this.lduApiService.DELETE(`${api}`));
160
+ }
151
161
  get ENV() { return this.MEDIA_API$; }
152
162
  static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.0", ngImport: i0, type: LDwMaterialMediaService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
153
163
  static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.2.0", ngImport: i0, type: LDwMaterialMediaService, providedIn: 'root' });
@@ -157,9 +167,187 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.0", ngImpor
157
167
  args: [{ providedIn: 'root' }]
158
168
  }] });
159
169
 
170
+ class LDwMaterialImageUploaderComponent {
171
+ service = inject(LDwMaterialMediaService);
172
+ readonly$ = false;
173
+ required$ = false;
174
+ formParent = new FormGroup({
175
+ value: new FormControl(null, [])
176
+ });
177
+ formParentControlName = 'value';
178
+ label = 'Value';
179
+ appearance = 'outline';
180
+ name = 'value';
181
+ type = 'jpg';
182
+ dimensions;
183
+ api;
184
+ set readonly(v) { this.readonly$ = coerceBooleanProperty(v); }
185
+ set required(v) { this.required$ = coerceBooleanProperty(v); }
186
+ async onUploadClick() {
187
+ if (this.api) {
188
+ const mediaUrl = await this.service.uploadImage(`${this.api}`);
189
+ if (mediaUrl) {
190
+ this.control.setValue(mediaUrl);
191
+ }
192
+ }
193
+ }
194
+ async onDeleteClick() {
195
+ if (this.api) {
196
+ await this.service.clearImage(this.api);
197
+ }
198
+ this.control.setValue(null);
199
+ }
200
+ get readonly() { return this.readonly$; }
201
+ ;
202
+ get required() { return this.required$; }
203
+ ;
204
+ get control() {
205
+ return this.formParent?.get(this.formParentControlName);
206
+ }
207
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.0", ngImport: i0, type: LDwMaterialImageUploaderComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
208
+ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.2.0", type: LDwMaterialImageUploaderComponent, isStandalone: true, selector: "ldw-mat-image-uploader", inputs: { formParent: "formParent", formParentControlName: "formParentControlName", label: "label", appearance: "appearance", name: "name", type: "type", dimensions: "dimensions", api: "api", readonly: "readonly", required: "required" }, host: { classAttribute: "ldw-mat-image-uploader" }, ngImport: i0, template: `
209
+ <form
210
+ [formGroup]="formParent"
211
+ novalidate
212
+ ><mat-form-field
213
+ [appearance]="appearance"
214
+ ><mat-label
215
+ [innerHTML]="label" />
216
+ <input matInput
217
+ [name]="name"
218
+ [formControlName]="formParentControlName"
219
+ [readonly]="readonly"
220
+ [required]="required"
221
+ />
222
+ @if (dimensions)
223
+ {
224
+ <mat-hint>{{ dimensions }}.{{ type }}</mat-hint>
225
+ }
226
+ <div matSuffix>
227
+ @if (control.value)
228
+ {
229
+ <a matIconButton
230
+ [href]="control.value"
231
+ target="_blank"
232
+ ><mat-icon>visibility</mat-icon>
233
+ </a>
234
+ }
235
+ <button matIconButton
236
+ (click)="onUploadClick()"
237
+ ><mat-icon>add_photo_alternate</mat-icon>
238
+ </button>
239
+ <button matIconButton
240
+ (click)="onDeleteClick()"
241
+ ><mat-icon>delete</mat-icon>
242
+ </button>
243
+ </div>
244
+ <ng-content/>
245
+ </mat-form-field>
246
+ </form>
247
+ `, isInline: true, dependencies: [{ kind: "ngmodule", type: CommonModule }, { kind: "ngmodule", type: FormsModule }, { kind: "directive", type: i1$1.ɵNgNoValidate, selector: "form:not([ngNoForm]):not([ngNativeValidate])" }, { kind: "directive", type: i1$1.DefaultValueAccessor, selector: "input:not([type=checkbox])[formControlName],textarea[formControlName],input:not([type=checkbox])[formControl],textarea[formControl],input:not([type=checkbox])[ngModel],textarea[ngModel],[ngDefaultControl]" }, { kind: "directive", type: i1$1.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i1$1.NgControlStatusGroup, selector: "[formGroupName],[formArrayName],[ngModelGroup],[formGroup],[formArray],form:not([ngNoForm]),[ngForm]" }, { kind: "directive", type: i1$1.RequiredValidator, selector: ":not([type=checkbox])[required][formControlName],:not([type=checkbox])[required][formControl],:not([type=checkbox])[required][ngModel]", inputs: ["required"] }, { kind: "ngmodule", type: ReactiveFormsModule }, { kind: "directive", type: i1$1.FormGroupDirective, selector: "[formGroup]", inputs: ["formGroup"], outputs: ["ngSubmit"], exportAs: ["ngForm"] }, { kind: "directive", type: i1$1.FormControlName, selector: "[formControlName]", inputs: ["formControlName", "disabled", "ngModel"], outputs: ["ngModelChange"] }, { kind: "ngmodule", type: MatButtonModule }, { kind: "component", type: i1.MatIconButton, selector: "button[mat-icon-button], a[mat-icon-button], button[matIconButton], a[matIconButton]", exportAs: ["matButton", "matAnchor"] }, { kind: "ngmodule", type: MatFormFieldModule }, { kind: "component", type: i3$1.MatFormField, selector: "mat-form-field", inputs: ["hideRequiredMarker", "color", "floatLabel", "appearance", "subscriptSizing", "hintLabel"], exportAs: ["matFormField"] }, { kind: "directive", type: i3$1.MatLabel, selector: "mat-label" }, { kind: "directive", type: i3$1.MatHint, selector: "mat-hint", inputs: ["align", "id"] }, { kind: "directive", type: i3$1.MatSuffix, selector: "[matSuffix], [matIconSuffix], [matTextSuffix]", inputs: ["matTextSuffix"] }, { kind: "ngmodule", type: MatInputModule }, { kind: "directive", type: i4.MatInput, selector: "input[matInput], textarea[matInput], select[matNativeControl], input[matNativeControl], textarea[matNativeControl]", inputs: ["disabled", "id", "placeholder", "name", "required", "type", "errorStateMatcher", "aria-describedby", "value", "readonly", "disabledInteractive"], exportAs: ["matInput"] }, { kind: "ngmodule", type: MatIconModule }, { kind: "component", type: i2.MatIcon, selector: "mat-icon", inputs: ["color", "inline", "svgIcon", "fontSet", "fontIcon"], exportAs: ["matIcon"] }] });
248
+ }
249
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.0", ngImport: i0, type: LDwMaterialImageUploaderComponent, decorators: [{
250
+ type: Component,
251
+ args: [{
252
+ selector: 'ldw-mat-image-uploader',
253
+ host: { class: 'ldw-mat-image-uploader' },
254
+ imports: [
255
+ CommonModule,
256
+ FormsModule,
257
+ ReactiveFormsModule,
258
+ MatButtonModule,
259
+ MatFormFieldModule,
260
+ MatInputModule,
261
+ MatIconModule,
262
+ ],
263
+ template: `
264
+ <form
265
+ [formGroup]="formParent"
266
+ novalidate
267
+ ><mat-form-field
268
+ [appearance]="appearance"
269
+ ><mat-label
270
+ [innerHTML]="label" />
271
+ <input matInput
272
+ [name]="name"
273
+ [formControlName]="formParentControlName"
274
+ [readonly]="readonly"
275
+ [required]="required"
276
+ />
277
+ @if (dimensions)
278
+ {
279
+ <mat-hint>{{ dimensions }}.{{ type }}</mat-hint>
280
+ }
281
+ <div matSuffix>
282
+ @if (control.value)
283
+ {
284
+ <a matIconButton
285
+ [href]="control.value"
286
+ target="_blank"
287
+ ><mat-icon>visibility</mat-icon>
288
+ </a>
289
+ }
290
+ <button matIconButton
291
+ (click)="onUploadClick()"
292
+ ><mat-icon>add_photo_alternate</mat-icon>
293
+ </button>
294
+ <button matIconButton
295
+ (click)="onDeleteClick()"
296
+ ><mat-icon>delete</mat-icon>
297
+ </button>
298
+ </div>
299
+ <ng-content/>
300
+ </mat-form-field>
301
+ </form>
302
+ `
303
+ }]
304
+ }], propDecorators: { formParent: [{
305
+ type: Input,
306
+ args: [{ required: true }]
307
+ }], formParentControlName: [{
308
+ type: Input,
309
+ args: [{ required: true }]
310
+ }], label: [{
311
+ type: Input,
312
+ args: [{ required: true }]
313
+ }], appearance: [{
314
+ type: Input
315
+ }], name: [{
316
+ type: Input
317
+ }], type: [{
318
+ type: Input
319
+ }], dimensions: [{
320
+ type: Input
321
+ }], api: [{
322
+ type: Input
323
+ }], readonly: [{
324
+ type: Input
325
+ }], required: [{
326
+ type: Input
327
+ }] } });
328
+
329
+ const components = [
330
+ LDwMaterialImageUploadDialogComponent,
331
+ LDwMaterialImageUploaderComponent,
332
+ ];
333
+ class LDwMaterialImageUploaderModule {
334
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.0", ngImport: i0, type: LDwMaterialImageUploaderModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
335
+ static ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "21.2.0", ngImport: i0, type: LDwMaterialImageUploaderModule, imports: [LDwMaterialImageUploadDialogComponent,
336
+ LDwMaterialImageUploaderComponent], exports: [LDwMaterialImageUploadDialogComponent,
337
+ LDwMaterialImageUploaderComponent] });
338
+ static ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "21.2.0", ngImport: i0, type: LDwMaterialImageUploaderModule, imports: [components] });
339
+ }
340
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.0", ngImport: i0, type: LDwMaterialImageUploaderModule, decorators: [{
341
+ type: NgModule,
342
+ args: [{
343
+ imports: [...components],
344
+ exports: [...components]
345
+ }]
346
+ }] });
347
+
160
348
  /**
161
349
  * Generated bundle index. Do not edit.
162
350
  */
163
351
 
164
- export { LDW_MAT_MEDIA_API, LDwMaterialImageUploadDialogComponent, LDwMaterialMediaService };
352
+ export { LDW_MAT_MEDIA_API, LDwMaterialImageUploadDialogComponent, LDwMaterialImageUploaderComponent, LDwMaterialImageUploaderModule, LDwMaterialMediaService };
165
353
  //# sourceMappingURL=ldw-framework-material-media.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"ldw-framework-material-media.mjs","sources":["../../../lib/src/components/ldw-mat-image-upload-dialog.component.ts","../../../lib/src/config/ldw-mat-media.config.ts","../../../lib/src/services/ldw-mat-media.service.ts","../../../lib/src/ldw-framework-material-media.ts"],"sourcesContent":["import { CommonModule } from '@angular/common';\nimport { ChangeDetectorRef, Component, inject } from '@angular/core';\nimport { MatButtonModule } from '@angular/material/button';\nimport { MAT_DIALOG_DATA, MatDialogModule, MatDialogRef } from '@angular/material/dialog';\nimport { MatIconModule } from '@angular/material/icon';\nimport { LDuAnguBootTranslationPipe } from '@ldu-anguboot/i18n';\nimport { LDwMaterialMediaModel } from '../models/ldw-mat-media.model';\n\n@Component({\n selector: 'ldw-mat-image-upload-dialog',\n host: { class: 'ldw-mat-image-upload-dialog' },\n imports: [\n CommonModule,\n MatButtonModule,\n MatIconModule,\n MatDialogModule,\n LDuAnguBootTranslationPipe,\n ],\n template: `\n <mat-dialog-actions>\n <h2>{{ 'LDU_ANGUBOOT_IMG_UPLOAD_DIALOG.title' | i18n }}</h2>\n <button class=\"ldw-mat-image-uploader-save\"\n matButton\n cdkFocusInitial\n (click)=\"onSaveClick()\"\n >{{ 'LDU_ANGUBOOT_IMG_UPLOAD_DIALOG.btnSave' | i18n }}</button>\n <button class=\"ldw-mat-image-uploader-cancel\"\n matButton\n (click)=\"onCancelClick()\"\n >{{ 'LDU_ANGUBOOT_IMG_UPLOAD_DIALOG.btnCancel' | i18n }}</button>\n </mat-dialog-actions>\n <mat-dialog-content>\n <input class=\"ldw-mat-image-uploader-hidden-input\"\n #uploader type=\"file\"\n [style.display]=\"'none'\"\n (change)=\"onChange($event)\"\n />\n <div class=\"ldw-mat-image-uploader\"\n [style.backgroundImage]=\"$backgroundImage\"\n (keypress)=\"uploader.click()\"\n (click)=\"uploader.click()\"\n >@if ($noData) { <mat-icon>image</mat-icon> }\n </div>\n </mat-dialog-content>\n`})\nexport class LDwMaterialImageUploadDialogComponent {\n\n readonly dialogRef = inject(MatDialogRef<LDwMaterialImageUploadDialogComponent>);\n\n readonly data = inject<LDwMaterialMediaModel>(MAT_DIALOG_DATA);\n\n readonly cdr = inject(ChangeDetectorRef);\n\n onSaveClick() {\n this.dialogRef.close(this.data);\n }\n\n onCancelClick() {\n this.dialogRef.close(false);\n }\n\n onChange($event: any) {\n const files = $event?.target?.files;\n if (files?.[0]) {\n const picture = files[0];\n const reader = new FileReader();\n reader.readAsDataURL(picture);\n reader.onload = () => {\n this.data.imgBase64 = (reader.result as string).toString();\n this.cdr.detectChanges();\n };\n }\n }\n\n get $backgroundImage() {\n if (this.data.imgBase64) {\n return 'url(' + this.data.imgBase64 + ')';\n }\n if (this.data.imgSrc) {\n return 'url(' + this.data.imgSrc + ')';\n }\n return '';\n }\n\n get $noData() {\n return !this.data?.imgBase64 && !this.data?.imgSrc;\n }\n}\n","import { InjectionToken } from '@angular/core';\n\nexport const LDW_MAT_MEDIA_API = new InjectionToken<{\n url: string;\n}>('LDW_MAT_MEDIA_API');\n","import { inject, Injectable } from '@angular/core';\nimport { MatDialog } from '@angular/material/dialog';\nimport { LDuAnguBootApiService } from '@ldu-anguboot/http';\nimport { firstValueFrom } from 'rxjs';\nimport { LDwMaterialImageUploadDialogComponent } from '../components/ldw-mat-image-upload-dialog.component';\nimport { LDW_MAT_MEDIA_API } from '../config/ldw-mat-media.config';\nimport { LDwMaterialMediaModel } from '../models/ldw-mat-media.model';\n\n@Injectable({ providedIn: 'root' })\nexport class LDwMaterialMediaService {\n\n private readonly MEDIA_API$ = inject(LDW_MAT_MEDIA_API);\n\n private readonly lduApiService = inject(LDuAnguBootApiService);\n\n private readonly matDialog = inject(MatDialog);\n\n async uploadImage(uploadUrl: string, type: 'jpg' | 'png' = 'jpg', data?: LDwMaterialMediaModel) {\n const media = await firstValueFrom(this.matDialog.open(LDwMaterialImageUploadDialogComponent, {\n height: 'calc(100% - 1rem)',\n width: 'calc(100% - 1rem)',\n maxHeight: '100%',\n maxWidth: '100%',\n data: {\n imgSrc: data?.imgSrc,\n imgBase64: data?.imgBase64,\n },\n }).afterClosed());\n if (media?.imgBase64) {\n const response = await firstValueFrom(this.lduApiService.PUT<LDwMaterialMediaModel>(uploadUrl, media));\n if (response?.id) {\n switch (type) {\n case 'jpg':\n return this.lduApiService.url(`${this.ENV.url}/${response.id}.jpg?t=${Date.now()}`);\n case 'png':\n return this.lduApiService.url(`${this.ENV.url}/${response.id}.png?t=${Date.now()}`);\n default:\n break;\n }\n }\n }\n return null;\n }\n\n get ENV() { return this.MEDIA_API$; }\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;;;;;;;;;;;;MA6Ca,qCAAqC,CAAA;AAErC,IAAA,SAAS,GAAG,MAAM,EAAC,YAAmD,EAAC;AAEvE,IAAA,IAAI,GAAG,MAAM,CAAwB,eAAe,CAAC;AAErD,IAAA,GAAG,GAAG,MAAM,CAAC,iBAAiB,CAAC;IAExC,WAAW,GAAA;QACP,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC;IACnC;IAEA,aAAa,GAAA;AACT,QAAA,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,KAAK,CAAC;IAC/B;AAEA,IAAA,QAAQ,CAAC,MAAW,EAAA;AAChB,QAAA,MAAM,KAAK,GAAG,MAAM,EAAE,MAAM,EAAE,KAAK;AACnC,QAAA,IAAI,KAAK,GAAG,CAAC,CAAC,EAAE;AACZ,YAAA,MAAM,OAAO,GAAG,KAAK,CAAC,CAAC,CAAC;AACxB,YAAA,MAAM,MAAM,GAAG,IAAI,UAAU,EAAE;AAC/B,YAAA,MAAM,CAAC,aAAa,CAAC,OAAO,CAAC;AAC7B,YAAA,MAAM,CAAC,MAAM,GAAG,MAAK;gBACjB,IAAI,CAAC,IAAI,CAAC,SAAS,GAAI,MAAM,CAAC,MAAiB,CAAC,QAAQ,EAAE;AAC1D,gBAAA,IAAI,CAAC,GAAG,CAAC,aAAa,EAAE;AAC5B,YAAA,CAAC;QACL;IACJ;AAEA,IAAA,IAAI,gBAAgB,GAAA;AAChB,QAAA,IAAI,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE;YACrB,OAAO,MAAM,GAAG,IAAI,CAAC,IAA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dialog.component.ts","../../../lib/src/config/ldw-mat-media.config.ts","../../../lib/src/services/ldw-mat-media.service.ts","../../../lib/src/components/ldw-mat-image-uploader.component.ts","../../../lib/src/modules/ldw-mat-image-uploader.module.ts","../../../lib/src/ldw-framework-material-media.ts"],"sourcesContent":["import { CommonModule } from '@angular/common';\nimport { ChangeDetectorRef, Component, inject } from '@angular/core';\nimport { MatButtonModule } from '@angular/material/button';\nimport { MAT_DIALOG_DATA, MatDialogModule, MatDialogRef } from '@angular/material/dialog';\nimport { MatIconModule } from '@angular/material/icon';\nimport { LDuAnguBootTranslationPipe } from '@ldu-anguboot/i18n';\nimport { LDwMaterialMediaModel } from '../models/ldw-mat-media.model';\n\n@Component({\n selector: 'ldw-mat-image-upload-dialog',\n host: { class: 'ldw-mat-image-upload-dialog' },\n imports: [\n CommonModule,\n MatButtonModule,\n MatIconModule,\n MatDialogModule,\n LDuAnguBootTranslationPipe,\n ],\n template: `\n <mat-dialog-actions>\n <h2>{{ 'LDU_ANGUBOOT_IMG_UPLOAD_DIALOG.title' | i18n }}</h2>\n <button class=\"ldw-mat-image-uploader-save\"\n matButton\n cdkFocusInitial\n (click)=\"onSaveClick()\"\n >{{ 'LDU_ANGUBOOT_IMG_UPLOAD_DIALOG.btnSave' | i18n }}</button>\n <button class=\"ldw-mat-image-uploader-cancel\"\n matButton\n (click)=\"onCancelClick()\"\n >{{ 'LDU_ANGUBOOT_IMG_UPLOAD_DIALOG.btnCancel' | i18n }}</button>\n </mat-dialog-actions>\n <mat-dialog-content>\n <input class=\"ldw-mat-image-uploader-hidden-input\"\n #uploader type=\"file\"\n [style.display]=\"'none'\"\n (change)=\"onChange($event)\"\n />\n <div class=\"ldw-mat-image-uploader--instance\"\n [style.backgroundImage]=\"$backgroundImage\"\n (keypress)=\"uploader.click()\"\n (click)=\"uploader.click()\"\n >@if ($noData) { <mat-icon>image</mat-icon> }\n </div>\n </mat-dialog-content>\n`})\nexport class LDwMaterialImageUploadDialogComponent {\n\n readonly dialogRef = inject(MatDialogRef<LDwMaterialImageUploadDialogComponent>);\n\n readonly data = inject<LDwMaterialMediaModel>(MAT_DIALOG_DATA);\n\n readonly cdr = inject(ChangeDetectorRef);\n\n onSaveClick() {\n this.dialogRef.close(this.data);\n }\n\n onCancelClick() {\n this.dialogRef.close(false);\n }\n\n onChange($event: any) {\n const files = $event?.target?.files;\n if (files?.[0]) {\n const picture = files[0];\n const reader = new FileReader();\n reader.readAsDataURL(picture);\n reader.onload = () => {\n this.data.imgBase64 = (reader.result as string).toString();\n this.cdr.detectChanges();\n };\n }\n }\n\n get $backgroundImage() {\n if (this.data.imgBase64) {\n return 'url(' + this.data.imgBase64 + ')';\n }\n if (this.data.imgSrc) {\n return 'url(' + this.data.imgSrc + ')';\n }\n return '';\n }\n\n get $noData() {\n return !this.data?.imgBase64 && !this.data?.imgSrc;\n }\n}\n","import { InjectionToken } from '@angular/core';\n\nexport const LDW_MAT_MEDIA_API = new InjectionToken<{\n url: string;\n}>('LDW_MAT_MEDIA_API');\n","import { inject, Injectable } from '@angular/core';\nimport { MatDialog } from '@angular/material/dialog';\nimport { LDuAnguBootApiService } from '@ldu-anguboot/http';\nimport { firstValueFrom } from 'rxjs';\nimport { LDwMaterialImageUploadDialogComponent } from '../components/ldw-mat-image-upload-dialog.component';\nimport { LDW_MAT_MEDIA_API } from '../config/ldw-mat-media.config';\nimport { LDwMaterialMediaModel } from '../models/ldw-mat-media.model';\n\n@Injectable({ providedIn: 'root' })\nexport class LDwMaterialMediaService {\n\n private readonly MEDIA_API$ = inject(LDW_MAT_MEDIA_API);\n\n private readonly lduApiService = inject(LDuAnguBootApiService);\n\n private readonly matDialog = inject(MatDialog);\n\n async uploadImage(uploadUrl: string, type: 'jpg' | 'png' = 'jpg', data?: LDwMaterialMediaModel) {\n const media = await firstValueFrom(this.matDialog.open(LDwMaterialImageUploadDialogComponent, {\n height: 'calc(100% - 1rem)',\n width: 'calc(100% - 1rem)',\n maxHeight: '100%',\n maxWidth: '100%',\n data: {\n imgSrc: data?.imgSrc,\n imgBase64: data?.imgBase64,\n },\n }).afterClosed());\n if (media?.imgBase64) {\n const response = await firstValueFrom(this.lduApiService.PUT<LDwMaterialMediaModel>(uploadUrl, media));\n if (response?.id) {\n switch (type) {\n case 'jpg':\n return this.lduApiService.url(`${this.ENV.url}/${response.id}.jpg?t=${Date.now()}`);\n case 'png':\n return this.lduApiService.url(`${this.ENV.url}/${response.id}.png?t=${Date.now()}`);\n default:\n break;\n }\n }\n }\n return null;\n }\n\n async clearImage(api: string) {\n return firstValueFrom(this.lduApiService.DELETE(`${api}`));\n }\n\n get ENV() { return this.MEDIA_API$; }\n}\n","import { coerceBooleanProperty } from '@angular/cdk/coercion';\nimport { CommonModule } from '@angular/common';\nimport { Component, inject, Input } from '@angular/core';\nimport { FormControl, FormGroup, FormsModule, ReactiveFormsModule } from '@angular/forms';\nimport { MatButtonModule } from '@angular/material/button';\nimport { MatFormFieldModule } from '@angular/material/form-field';\nimport { MatIconModule } from '@angular/material/icon';\nimport { MatInputModule } from '@angular/material/input';\nimport { LDwMaterialMediaService } from '../services/ldw-mat-media.service';\n\n@Component({\n selector: 'ldw-mat-image-uploader',\n host: { class: 'ldw-mat-image-uploader' },\n imports: [\n CommonModule,\n FormsModule,\n ReactiveFormsModule,\n MatButtonModule,\n MatFormFieldModule,\n MatInputModule,\n MatIconModule,\n ],\n template: `\n <form\n [formGroup]=\"formParent\"\n novalidate\n ><mat-form-field\n [appearance]=\"appearance\"\n ><mat-label\n [innerHTML]=\"label\" />\n <input matInput\n [name]=\"name\"\n [formControlName]=\"formParentControlName\"\n [readonly]=\"readonly\"\n [required]=\"required\"\n />\n @if (dimensions)\n {\n <mat-hint>{{ dimensions }}.{{ type }}</mat-hint>\n }\n <div matSuffix>\n @if (control.value)\n {\n <a matIconButton\n [href]=\"control.value\"\n target=\"_blank\"\n ><mat-icon>visibility</mat-icon>\n </a>\n }\n <button matIconButton\n (click)=\"onUploadClick()\"\n ><mat-icon>add_photo_alternate</mat-icon>\n </button>\n <button matIconButton\n (click)=\"onDeleteClick()\"\n ><mat-icon>delete</mat-icon>\n </button>\n </div>\n <ng-content/>\n </mat-form-field>\n </form>\n`})\nexport class LDwMaterialImageUploaderComponent {\n\n private readonly service = inject(LDwMaterialMediaService);\n\n private readonly$: string | boolean = false;\n\n private required$: string | boolean = false;\n\n @Input({ required: true })\n formParent: FormGroup = new FormGroup({\n value: new FormControl<string | null | undefined>(null, [])\n });\n\n @Input({ required: true })\n formParentControlName = 'value';\n\n @Input({ required: true })\n label = 'Value';\n\n @Input()\n appearance: 'fill' | 'outline' = 'outline';\n\n @Input()\n name = 'value';\n\n @Input()\n type: 'jpg' | 'png' = 'jpg';\n\n @Input()\n dimensions: string | null | undefined;\n\n @Input()\n api: string | null | undefined;\n\n @Input()\n set readonly(v) { this.readonly$ = coerceBooleanProperty(v); }\n\n @Input()\n set required(v) { this.required$ = coerceBooleanProperty(v); }\n\n async onUploadClick() {\n if (this.api) {\n const mediaUrl = await this.service.uploadImage(`${this.api}`);\n if (mediaUrl) {\n this.control.setValue(mediaUrl);\n }\n }\n }\n\n async onDeleteClick() {\n if (this.api) {\n await this.service.clearImage(this.api);\n }\n this.control.setValue(null);\n }\n\n get readonly() { return this.readonly$; };\n\n get required() { return this.required$; };\n\n get control() {\n return this.formParent?.get(this.formParentControlName) as FormControl<string | null | undefined>;\n }\n}\n","import { NgModule } from '@angular/core';\nimport { LDwMaterialImageUploadDialogComponent } from '../components/ldw-mat-image-upload-dialog.component';\nimport { LDwMaterialImageUploaderComponent } from '../components/ldw-mat-image-uploader.component';\n\nconst components = [\n LDwMaterialImageUploadDialogComponent,\n LDwMaterialImageUploaderComponent,\n];\n\n@NgModule({\n imports: [...components],\n exports: [...components]\n})\nexport class LDwMaterialImageUploaderModule { }\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":["i1","i2","i3","i5"],"mappings":";;;;;;;;;;;;;;;;;;;;MA6Ca,qCAAqC,CAAA;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;;;AAuCb;AAAC,iBAAA;;sBASG,KAAK;uBAAC,EAAE,QAAQ,EAAE,IAAI,EAAE;;sBAKxB,KAAK;uBAAC,EAAE,QAAQ,EAAE,IAAI,EAAE;;sBAGxB,KAAK;uBAAC,EAAE,QAAQ,EAAE,IAAI,EAAE;;sBAGxB;;sBAGA;;sBAGA;;sBAGA;;sBAGA;;sBAGA;;sBAGA;;;AC/FL,MAAM,UAAU,GAAG;IACf,qCAAqC;IACrC,iCAAiC;CACpC;MAMY,8BAA8B,CAAA;uGAA9B,8BAA8B,EAAA,IAAA,EAAA,EAAA,EAAA,MAAA,EAAA,EAAA,CAAA,eAAA,CAAA,QAAA,EAAA,CAAA;AAA9B,IAAA,OAAA,IAAA,GAAA,EAAA,CAAA,mBAAA,CAAA,EAAA,UAAA,EAAA,QAAA,EAAA,OAAA,EAAA,QAAA,EAAA,QAAA,EAAA,EAAA,EAAA,IAAA,EAAA,8BAA8B,YARvC,qCAAqC;AACrC,YAAA,iCAAiC,aADjC,qCAAqC;YACrC,iCAAiC,CAAA,EAAA,CAAA;AAOxB,IAAA,OAAA,IAAA,GAAA,EAAA,CAAA,mBAAA,CAAA,EAAA,UAAA,EAAA,QAAA,EAAA,OAAA,EAAA,QAAA,EAAA,QAAA,EAAA,EAAA,EAAA,IAAA,EAAA,8BAA8B,YAH1B,UAAU,CAAA,EAAA,CAAA;;2FAGd,8BAA8B,EAAA,UAAA,EAAA,CAAA;kBAJ1C,QAAQ;AAAC,YAAA,IAAA,EAAA,CAAA;AACN,oBAAA,OAAO,EAAE,CAAC,GAAG,UAAU,CAAC;AACxB,oBAAA,OAAO,EAAE,CAAC,GAAG,UAAU;AAC1B,iBAAA;;;ACZD;;AAEG;;;;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ldw-framework/material-media",
3
- "version": "0.2.0",
3
+ "version": "0.3.1",
4
4
  "peerDependencies": {
5
5
  "@angular/common": "^21.0.0",
6
6
  "@angular/core": "^21.0.0",
@@ -1,32 +1,32 @@
1
- .ldw-mat-image-uploader {
2
- background-color: #eaeaea;
3
- background-position: center;
4
- background-repeat: no-repeat;
5
- background-size: contain;
6
- border-width: 1px;
7
- border-style: dotted;
8
- border-color: inherit;
9
- height: calc(100% - 2px);
10
- width: calc(100% - 2px);
11
- position: relative;
1
+ .ldw-mat-image-upload-dialog {
12
2
 
13
- .mat-icon {
14
- top: 50%;
15
- left: 50%;
16
- transform: translate(-50%, -50%);
17
- position: absolute;
18
- font-size: 48px;
19
- height: 48px;
20
- width: 48px;
21
- }
3
+ .ldw-mat-image-uploader--instance {
4
+ background-color: #eaeaea;
5
+ background-position: center;
6
+ background-repeat: no-repeat;
7
+ background-size: contain;
8
+ border-width: 1px;
9
+ border-style: dotted;
10
+ border-color: inherit;
11
+ height: calc(100% - 2px);
12
+ width: calc(100% - 2px);
13
+ position: relative;
22
14
 
23
- &:hover {
24
- cursor: pointer;
25
- opacity: 0.925;
26
- }
27
- }
15
+ .mat-icon {
16
+ top: 50%;
17
+ left: 50%;
18
+ transform: translate(-50%, -50%);
19
+ position: absolute;
20
+ font-size: 48px;
21
+ height: 48px;
22
+ width: 48px;
23
+ }
28
24
 
29
- .ldw-mat-image-upload-dialog {
25
+ &:hover {
26
+ cursor: pointer;
27
+ opacity: 0.925;
28
+ }
29
+ }
30
30
 
31
31
  .mat-mdc-dialog-actions {
32
32
  h2 {
@@ -1,6 +1,7 @@
1
1
  import * as i0 from '@angular/core';
2
2
  import { ChangeDetectorRef, InjectionToken } from '@angular/core';
3
3
  import { MatDialogRef } from '@angular/material/dialog';
4
+ import { FormGroup, FormControl } from '@angular/forms';
4
5
 
5
6
  interface LDwMaterialMediaModel {
6
7
  id?: number;
@@ -21,15 +22,45 @@ declare class LDwMaterialImageUploadDialogComponent {
21
22
  static ɵcmp: i0.ɵɵComponentDeclaration<LDwMaterialImageUploadDialogComponent, "ldw-mat-image-upload-dialog", never, {}, {}, never, never, true, never>;
22
23
  }
23
24
 
25
+ declare class LDwMaterialImageUploaderComponent {
26
+ private readonly service;
27
+ private readonly$;
28
+ private required$;
29
+ formParent: FormGroup;
30
+ formParentControlName: string;
31
+ label: string;
32
+ appearance: 'fill' | 'outline';
33
+ name: string;
34
+ type: 'jpg' | 'png';
35
+ dimensions: string | null | undefined;
36
+ api: string | null | undefined;
37
+ set readonly(v: string | boolean);
38
+ set required(v: string | boolean);
39
+ onUploadClick(): Promise<void>;
40
+ onDeleteClick(): Promise<void>;
41
+ get readonly(): string | boolean;
42
+ get required(): string | boolean;
43
+ get control(): FormControl<string | null | undefined>;
44
+ static ɵfac: i0.ɵɵFactoryDeclaration<LDwMaterialImageUploaderComponent, never>;
45
+ static ɵcmp: i0.ɵɵComponentDeclaration<LDwMaterialImageUploaderComponent, "ldw-mat-image-uploader", never, { "formParent": { "alias": "formParent"; "required": true; }; "formParentControlName": { "alias": "formParentControlName"; "required": true; }; "label": { "alias": "label"; "required": true; }; "appearance": { "alias": "appearance"; "required": false; }; "name": { "alias": "name"; "required": false; }; "type": { "alias": "type"; "required": false; }; "dimensions": { "alias": "dimensions"; "required": false; }; "api": { "alias": "api"; "required": false; }; "readonly": { "alias": "readonly"; "required": false; }; "required": { "alias": "required"; "required": false; }; }, {}, never, ["*"], true, never>;
46
+ }
47
+
24
48
  declare const LDW_MAT_MEDIA_API: InjectionToken<{
25
49
  url: string;
26
50
  }>;
27
51
 
52
+ declare class LDwMaterialImageUploaderModule {
53
+ static ɵfac: i0.ɵɵFactoryDeclaration<LDwMaterialImageUploaderModule, never>;
54
+ static ɵmod: i0.ɵɵNgModuleDeclaration<LDwMaterialImageUploaderModule, never, [typeof LDwMaterialImageUploadDialogComponent, typeof LDwMaterialImageUploaderComponent], [typeof LDwMaterialImageUploadDialogComponent, typeof LDwMaterialImageUploaderComponent]>;
55
+ static ɵinj: i0.ɵɵInjectorDeclaration<LDwMaterialImageUploaderModule>;
56
+ }
57
+
28
58
  declare class LDwMaterialMediaService {
29
59
  private readonly MEDIA_API$;
30
60
  private readonly lduApiService;
31
61
  private readonly matDialog;
32
62
  uploadImage(uploadUrl: string, type?: 'jpg' | 'png', data?: LDwMaterialMediaModel): Promise<string | null>;
63
+ clearImage(api: string): Promise<unknown>;
33
64
  get ENV(): {
34
65
  url: string;
35
66
  };
@@ -37,5 +68,5 @@ declare class LDwMaterialMediaService {
37
68
  static ɵprov: i0.ɵɵInjectableDeclaration<LDwMaterialMediaService>;
38
69
  }
39
70
 
40
- export { LDW_MAT_MEDIA_API, LDwMaterialImageUploadDialogComponent, LDwMaterialMediaService };
71
+ export { LDW_MAT_MEDIA_API, LDwMaterialImageUploadDialogComponent, LDwMaterialImageUploaderComponent, LDwMaterialImageUploaderModule, LDwMaterialMediaService };
41
72
  export type { LDwMaterialMediaModel };