@cityway/basic-ui 1.1.0-beta002 → 1.1.0-beta004
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.
- package/cityway-basic-ui-1.1.0-beta004.tgz +0 -0
- package/docs/00-overview.md +3 -3
- package/docs/components/file-drop.md +181 -0
- package/fesm2022/cityway-basic-ui.mjs +290 -3
- package/fesm2022/cityway-basic-ui.mjs.map +1 -1
- package/index.d.ts +130 -3
- package/lib/assets/i18n/common.en.json +14 -0
- package/lib/assets/i18n/common.fr.json +14 -0
- package/package.json +2 -2
- package/styles/basic-ui.styles.bo.min.css +1 -1
- package/styles/basic-ui.styles.bo.min.css.map +1 -1
- package/cityway-basic-ui-1.1.0-beta001.tgz +0 -0
- package/cityway-basic-ui-1.1.0-beta002.tgz +0 -0
|
Binary file
|
package/docs/00-overview.md
CHANGED
|
@@ -20,9 +20,9 @@ Installer `bo-ui` tire transitivement `basic-ui` et `design-tokens`. Installer `
|
|
|
20
20
|
|
|
21
21
|
**Versions de référence (à la rédaction) :**
|
|
22
22
|
|
|
23
|
-
- `@cityway/design-tokens` : `1.1.0-
|
|
24
|
-
- `@cityway/basic-ui` : `1.1.0-
|
|
25
|
-
- `@cityway/bo-ui` : `1.1.0-
|
|
23
|
+
- `@cityway/design-tokens` : `1.1.0-beta004`
|
|
24
|
+
- `@cityway/basic-ui` : `1.1.0-beta004`
|
|
25
|
+
- `@cityway/bo-ui` : `1.1.0-beta004`
|
|
26
26
|
|
|
27
27
|
> Les `peerDependencies` Angular sont en `^20.3.0` (Angular 20). `@angular/cdk` en `^20.2.2`.
|
|
28
28
|
|
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
# `cw-file-drop` — File drop (zone de dépôt)
|
|
2
|
+
|
|
3
|
+
> Lib : `@cityway/basic-ui` · Sélecteur : `cw-file-drop` · Standalone : oui
|
|
4
|
+
> Import : `import { FileDropComponent } from '@cityway/basic-ui';`
|
|
5
|
+
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
## 1. Rôle & quand l'utiliser
|
|
9
|
+
|
|
10
|
+
Zone de dépôt de fichiers **maison** (drag & drop + bouton « Parcourir »), **sans librairie externe**. Implémente `ControlValueAccessor` : se branche directement sur `formControlName` / `[(ngModel)]`.
|
|
11
|
+
|
|
12
|
+
Couvre :
|
|
13
|
+
|
|
14
|
+
- le **drag & drop** natif (HTML5) **et** la sélection via l'explorateur ;
|
|
15
|
+
- deux **modes** : `file` (liste de fichiers) et `picture` (miniature de prévisualisation + placeholder illustré) ;
|
|
16
|
+
- la **validation locale** : format (`accept`) et taille (`maxSizeMb`), avec affichage des fichiers rejetés en erreur ;
|
|
17
|
+
- un mode **mono** ou **multi-fichiers** (`multiple`) ;
|
|
18
|
+
- les **textes d'aide** : formats acceptés, taille max, dimensions recommandées ;
|
|
19
|
+
- un **état d'erreur global** (ex. échec d'upload serveur) via `errorMessage` + sortie `retry`.
|
|
20
|
+
|
|
21
|
+
À ne PAS utiliser pour : un simple champ fichier inline dans un formulaire dense → `cw-form-field` (`type=file`) suffit. La dropzone est faite pour un dépôt mis en avant (import de documents, photo de profil…).
|
|
22
|
+
|
|
23
|
+
> Remplace l'ancien usage de `ngx-file-drop` (lib externe) : ce composant est 100 % maison.
|
|
24
|
+
|
|
25
|
+
---
|
|
26
|
+
|
|
27
|
+
## 2. API
|
|
28
|
+
|
|
29
|
+
### Inputs
|
|
30
|
+
|
|
31
|
+
| Input | Type | Défaut | Description |
|
|
32
|
+
|-------|------|--------|-------------|
|
|
33
|
+
| `mode` | `FileDropModeEnum` | `file` | `file` = liste de fichiers ; `picture` = miniatures + placeholder illustré. |
|
|
34
|
+
| `multiple` | `boolean` | `false` | Autorise plusieurs fichiers. Détermine le **type de la valeur** (voir §3). |
|
|
35
|
+
| `accept` | `string` | `''` | Filtre natif + validation. Ex. `'.pdf,.png'` ou `'image/*'`. Défaut `image/*` en mode `picture`. |
|
|
36
|
+
| `acceptLabel` | `string` | `undefined` | Libellé lisible des formats (texte d'aide). Ex. `'PDF, PNG, JPG'`. |
|
|
37
|
+
| `maxSizeMb` | `number` | `undefined` | Taille maximale **par fichier**, en Mo. Au-delà → rejet (raison `size`). |
|
|
38
|
+
| `recommendedDimensions` | `string` | `undefined` | Dimensions recommandées (mode `picture`), texte d'aide. Ex. `'200 x 200 px'`. |
|
|
39
|
+
| `label` | `string` | `undefined` | Libellé accessible de la zone (`aria-label`). |
|
|
40
|
+
| `isDisabled` | `boolean` | `false` | Désactive le composant (en plus du `setDisabledState` du formulaire). |
|
|
41
|
+
| `errorMessage` | `string` | `undefined` | Si renseigné, bascule la zone en état d'erreur global + bouton Réessayer. |
|
|
42
|
+
| `dataTest` | `string` | `undefined` | Pose l'attribut `data-test-ctw`. |
|
|
43
|
+
|
|
44
|
+
### Outputs
|
|
45
|
+
|
|
46
|
+
| Output | Payload | Description |
|
|
47
|
+
|--------|---------|-------------|
|
|
48
|
+
| `filesChange` | `CwFileDropItem[]` | Liste complète (valides **et** en erreur) à chaque changement. |
|
|
49
|
+
| `rejected` | `CwFileDropRejection[]` | Fichiers refusés par la validation locale (format / taille). |
|
|
50
|
+
| `retry` | `void` | Clic sur « Réessayer » (état d'erreur global). |
|
|
51
|
+
|
|
52
|
+
> La **valeur du formulaire** (via CVA) ne contient que les fichiers **valides** ; les fichiers en erreur sont affichés mais exclus.
|
|
53
|
+
|
|
54
|
+
### Comportement
|
|
55
|
+
|
|
56
|
+
- **Drag-over** : la zone passe en surbrillance (bordure/surface primaire).
|
|
57
|
+
- **Mono-fichier** : un nouveau dépôt **remplace** le précédent. **Multi** : les fichiers s'**empilent**.
|
|
58
|
+
- **Validation** : chaque fichier est testé contre `accept` puis `maxSizeMb`. Un fichier rejeté apparaît en rouge avec la raison, et est émis via `rejected`.
|
|
59
|
+
- **Preview** (mode `picture`) : pour les images, une miniature (data URL) est générée localement (aucun upload).
|
|
60
|
+
- **Accessibilité** : zone `role="button"` focusable (Entrée/Espace ouvrent l'explorateur), input fichier masqué, boutons de suppression avec `aria-label`.
|
|
61
|
+
|
|
62
|
+
---
|
|
63
|
+
|
|
64
|
+
## 3. Types
|
|
65
|
+
|
|
66
|
+
```ts
|
|
67
|
+
enum FileDropModeEnum { file = 'file', picture = 'picture' }
|
|
68
|
+
enum FileDropFileStatusEnum { success = 'success', error = 'error' }
|
|
69
|
+
enum FileDropRejectReasonEnum { format = 'format', size = 'size' }
|
|
70
|
+
|
|
71
|
+
interface CwFileDropItem {
|
|
72
|
+
file: File;
|
|
73
|
+
status: FileDropFileStatusEnum;
|
|
74
|
+
reason?: FileDropRejectReasonEnum; // si status === error
|
|
75
|
+
previewUrl?: string; // mode picture, images
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
interface CwFileDropRejection {
|
|
79
|
+
file: File;
|
|
80
|
+
reason: FileDropRejectReasonEnum;
|
|
81
|
+
}
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
**Type de la valeur (CVA)** :
|
|
85
|
+
- `multiple = false` → `File | null`
|
|
86
|
+
- `multiple = true` → `File[]`
|
|
87
|
+
|
|
88
|
+
---
|
|
89
|
+
|
|
90
|
+
## 4. Exemples
|
|
91
|
+
|
|
92
|
+
### Mono-fichier piloté par un FormControl
|
|
93
|
+
|
|
94
|
+
```ts
|
|
95
|
+
import { FileDropComponent } from '@cityway/basic-ui';
|
|
96
|
+
import { ReactiveFormsModule, FormControl } from '@angular/forms';
|
|
97
|
+
|
|
98
|
+
@Component({
|
|
99
|
+
selector: 'app-import',
|
|
100
|
+
standalone: true,
|
|
101
|
+
imports: [FileDropComponent, ReactiveFormsModule],
|
|
102
|
+
template: `
|
|
103
|
+
<cw-file-drop
|
|
104
|
+
[formControl]="doc"
|
|
105
|
+
accept=".pdf,.csv"
|
|
106
|
+
acceptLabel="PDF, CSV"
|
|
107
|
+
[maxSizeMb]="10"
|
|
108
|
+
label="Document à importer">
|
|
109
|
+
</cw-file-drop>
|
|
110
|
+
`,
|
|
111
|
+
})
|
|
112
|
+
export class ImportComponent {
|
|
113
|
+
doc = new FormControl<File | null>(null);
|
|
114
|
+
}
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
### Multi-fichiers + gestion des rejets
|
|
118
|
+
|
|
119
|
+
```html
|
|
120
|
+
<cw-file-drop
|
|
121
|
+
[multiple]="true"
|
|
122
|
+
accept=".pdf,.png,.jpg"
|
|
123
|
+
acceptLabel="PDF, PNG, JPG"
|
|
124
|
+
[maxSizeMb]="5"
|
|
125
|
+
(filesChange)="onFiles($event)"
|
|
126
|
+
(rejected)="onRejected($event)">
|
|
127
|
+
</cw-file-drop>
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
### Image (avatar) avec preview
|
|
131
|
+
|
|
132
|
+
```html
|
|
133
|
+
<cw-file-drop
|
|
134
|
+
[formControl]="avatar"
|
|
135
|
+
mode="picture"
|
|
136
|
+
accept="image/*"
|
|
137
|
+
acceptLabel="PNG, JPG"
|
|
138
|
+
[maxSizeMb]="2"
|
|
139
|
+
recommendedDimensions="200 x 200 px"
|
|
140
|
+
label="Photo de profil">
|
|
141
|
+
</cw-file-drop>
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
### État d'erreur après échec d'upload
|
|
145
|
+
|
|
146
|
+
```html
|
|
147
|
+
<cw-file-drop
|
|
148
|
+
[formControl]="doc"
|
|
149
|
+
[errorMessage]="uploadError()"
|
|
150
|
+
(retry)="upload()">
|
|
151
|
+
</cw-file-drop>
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
---
|
|
155
|
+
|
|
156
|
+
## 5. Notes d'intégration
|
|
157
|
+
|
|
158
|
+
- **ControlValueAccessor** : préférer `formControlName` / `[formControl]` / `[(ngModel)]` au câblage manuel des outputs. La valeur est un `File` (ou `File[]`) — c'est à l'hôte de gérer l'**upload** (le composant ne fait aucun appel réseau).
|
|
159
|
+
- **Validation locale ≠ sécurité** : `accept` / `maxSizeMb` filtrent côté client pour l'UX. Toujours revalider côté serveur.
|
|
160
|
+
- **Required** : poser `Validators.required` sur le `FormControl` ; le composant marque `touched` au premier dépôt/interaction.
|
|
161
|
+
- **Erreur serveur** : après un échec d'upload, alimenter `errorMessage` et relancer l'envoi dans le handler `(retry)`.
|
|
162
|
+
- **Pas de fuite mémoire** : les previews utilisent des data URLs (pas de `createObjectURL`), aucun `revoke` nécessaire.
|
|
163
|
+
- **i18n** : libellés sous `_COMMON._FILE_DROP.*` (DROP_FILE, OR, BROWSE, ACCEPTED_FORMATS, MAX_SIZE, RECOMMENDED_DIMENSIONS, REMOVE, ERROR_FORMAT, ERROR_SIZE, RETRY) — présents dans les bundles fr/en de la lib.
|
|
164
|
+
- **Dark mode** : aucune action requise (couleurs issues des tokens DS globaux, dark-aware).
|
|
165
|
+
|
|
166
|
+
---
|
|
167
|
+
|
|
168
|
+
## 6. Prompts-types (génération assistée)
|
|
169
|
+
|
|
170
|
+
> Exemples de formulation pour demander à Claude de générer du code consommant ce composant.
|
|
171
|
+
|
|
172
|
+
- « Ajoute une `cw-file-drop` mono-fichier branchée sur un `FormControl` `doc`, formats PDF/CSV, max 10 Mo. »
|
|
173
|
+
- « Mets une `cw-file-drop` en mode `picture` pour l'avatar, `image/*`, max 2 Mo, dimensions recommandées 200x200. »
|
|
174
|
+
- « Gère l'upload : à chaque `filesChange`, envoie le fichier au service ; en cas d'échec, affiche `errorMessage` et réessaie au `(retry)`. »
|
|
175
|
+
|
|
176
|
+
**Rappels pour Claude :**
|
|
177
|
+
- Importer `FileDropComponent` (standalone) + `ReactiveFormsModule` si usage `formControlName`.
|
|
178
|
+
- La valeur est `File | null` (mono) ou `File[]` (multi) — **pas** une string.
|
|
179
|
+
- Le composant ne fait **aucun upload** : c'est l'hôte qui envoie le(s) `File`.
|
|
180
|
+
- `accept` / `maxSizeMb` = validation UX uniquement ; revalider côté serveur.
|
|
181
|
+
- Pour un champ fichier simple inline, utiliser `cw-form-field` (`type=file`) plutôt que la dropzone.
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as i1 from '@angular/common';
|
|
2
2
|
import { CommonModule, NgClass, NgTemplateOutlet } from '@angular/common';
|
|
3
3
|
import * as i0 from '@angular/core';
|
|
4
|
-
import { inject, ElementRef, signal, EventEmitter, effect, Output, Input, Directive, input, HostBinding, Component, ChangeDetectorRef, model, output, viewChild, contentChildren, Injectable, NgZone, HostListener, ChangeDetectionStrategy, Renderer2, ViewContainerRef, DestroyRef, ViewChild, computed, TemplateRef, ContentChild, ApplicationRef, Injector, createComponent, viewChildren, Pipe } from '@angular/core';
|
|
4
|
+
import { inject, ElementRef, signal, EventEmitter, effect, Output, Input, Directive, input, HostBinding, Component, ChangeDetectorRef, model, output, viewChild, contentChildren, Injectable, NgZone, HostListener, ChangeDetectionStrategy, Renderer2, ViewContainerRef, DestroyRef, ViewChild, computed, TemplateRef, ContentChild, ApplicationRef, Injector, createComponent, viewChildren, Pipe, forwardRef } from '@angular/core';
|
|
5
5
|
import * as i2 from '@ngx-translate/core';
|
|
6
6
|
import { TranslatePipe, TranslateModule, TranslateService } from '@ngx-translate/core';
|
|
7
7
|
import { RouterLink, Router, ActivatedRoute } from '@angular/router';
|
|
@@ -13,7 +13,7 @@ import * as i4 from '@angular-slider/ngx-slider';
|
|
|
13
13
|
import { NgxSliderModule } from '@angular-slider/ngx-slider';
|
|
14
14
|
export { Options } from '@angular-slider/ngx-slider';
|
|
15
15
|
import * as i2$1 from '@angular/forms';
|
|
16
|
-
import { FormControl, ReactiveFormsModule, FormGroup, Validators, FormsModule } from '@angular/forms';
|
|
16
|
+
import { FormControl, ReactiveFormsModule, FormGroup, Validators, FormsModule, NG_VALUE_ACCESSOR } from '@angular/forms';
|
|
17
17
|
import intlTelInput from 'intl-tel-input';
|
|
18
18
|
import itiEn from 'intl-tel-input/dist/js/i18n/en.js';
|
|
19
19
|
import itiFr from 'intl-tel-input/dist/js/i18n/fr.js';
|
|
@@ -4373,6 +4373,293 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.20", ngImpo
|
|
|
4373
4373
|
], template: "@if (items().length > 0) {\n <nav class=\"breadcrumb\" [attr.aria-label]=\"ariaLabel() | translate\">\n <ol class=\"breadcrumb-list list-unstyled d-flex-h mb-0\">\n @for (item of items(); track $index; let first = $first) {\n <li\n class=\"breadcrumb-item\"\n [class.breadcrumb-item-home]=\"first\"\n [class.active]=\"item.isCurrent === true\"\n >\n @if (!first) {\n <cw-icon\n class=\"breadcrumb-separator\"\n [icon]=\"separatorIcon\"\n [iconSize]=\"iconSizeEnum['2xs']\"\n [type]=\"iconType.default\"\n aria-hidden=\"true\"\n ></cw-icon>\n }\n @if (isClickable(item)) {\n <a class=\"breadcrumb-link\" [routerLink]=\"item.link\">{{ item.label | translate }}</a>\n } @else {\n <span\n class=\"breadcrumb-text\"\n [attr.aria-current]=\"item.isCurrent === true ? 'page' : null\"\n >{{ item.label | translate }}</span>\n }\n </li>\n }\n </ol>\n </nav>\n}\n" }]
|
|
4374
4374
|
}], propDecorators: { items: [{ type: i0.Input, args: [{ isSignal: true, alias: "items", required: false }] }], ariaLabel: [{ type: i0.Input, args: [{ isSignal: true, alias: "ariaLabel", required: false }] }] } });
|
|
4375
4375
|
|
|
4376
|
+
// Types du composant `cw-file-drop` — alignes sur le DS (BOU) page Form
|
|
4377
|
+
// `File Upload / Dropzone / *`.
|
|
4378
|
+
/** Presentation de la dropzone. */
|
|
4379
|
+
var FileDropModeEnum;
|
|
4380
|
+
(function (FileDropModeEnum) {
|
|
4381
|
+
/** Liste de fichiers (icone + nom + taille). */
|
|
4382
|
+
FileDropModeEnum["file"] = "file";
|
|
4383
|
+
/** Image(s) avec miniature de preview et placeholder illustre. */
|
|
4384
|
+
FileDropModeEnum["picture"] = "picture";
|
|
4385
|
+
})(FileDropModeEnum || (FileDropModeEnum = {}));
|
|
4386
|
+
/** Etat d'un fichier dans la liste. */
|
|
4387
|
+
var FileDropFileStatusEnum;
|
|
4388
|
+
(function (FileDropFileStatusEnum) {
|
|
4389
|
+
/** Accepte (validation locale OK). */
|
|
4390
|
+
FileDropFileStatusEnum["success"] = "success";
|
|
4391
|
+
/** Rejete (format / taille). `error` porte le message. */
|
|
4392
|
+
FileDropFileStatusEnum["error"] = "error";
|
|
4393
|
+
})(FileDropFileStatusEnum || (FileDropFileStatusEnum = {}));
|
|
4394
|
+
/** Raison de rejet d'un fichier (cle i18n resolue par le composant). */
|
|
4395
|
+
var FileDropRejectReasonEnum;
|
|
4396
|
+
(function (FileDropRejectReasonEnum) {
|
|
4397
|
+
FileDropRejectReasonEnum["format"] = "format";
|
|
4398
|
+
FileDropRejectReasonEnum["size"] = "size";
|
|
4399
|
+
})(FileDropRejectReasonEnum || (FileDropRejectReasonEnum = {}));
|
|
4400
|
+
|
|
4401
|
+
/**
|
|
4402
|
+
* Zone de depot de fichiers « tout maison » (drag & drop + parcourir), sans lib externe.
|
|
4403
|
+
* Implemente `ControlValueAccessor` : utilisable avec `formControlName` / `[(ngModel)]`.
|
|
4404
|
+
*
|
|
4405
|
+
* - `multiple=false` (defaut) : valeur du formulaire = `File | null`.
|
|
4406
|
+
* - `multiple=true` : valeur du formulaire = `File[]`.
|
|
4407
|
+
*
|
|
4408
|
+
* Style base sur les tokens DS (BOU) `File Upload / Dropzone / *` (tokens globaux
|
|
4409
|
+
* `--cw-border-*`, `--cw-surface-*`, `--cw-status-*`, `--cw-text/icon-*`).
|
|
4410
|
+
*/
|
|
4411
|
+
class FileDropComponent {
|
|
4412
|
+
constructor() {
|
|
4413
|
+
// --- Configuration (inputs) ---------------------------------------------
|
|
4414
|
+
/** Presentation : liste de fichiers (`file`) ou images avec preview (`picture`). */
|
|
4415
|
+
this.mode = input(FileDropModeEnum.file, ...(ngDevMode ? [{ debugName: "mode" }] : []));
|
|
4416
|
+
/** Autorise plusieurs fichiers. */
|
|
4417
|
+
this.multiple = input(false, ...(ngDevMode ? [{ debugName: "multiple" }] : []));
|
|
4418
|
+
/** Filtre natif + validation. Ex. `'.pdf,.png'` ou `'image/*'`. Defaut `image/*` en mode picture. */
|
|
4419
|
+
this.accept = input('', ...(ngDevMode ? [{ debugName: "accept" }] : []));
|
|
4420
|
+
/** Libelle lisible des formats acceptes (texte d'aide). Ex. `'PDF, PNG, JPG'`. */
|
|
4421
|
+
this.acceptLabel = input(...(ngDevMode ? [undefined, { debugName: "acceptLabel" }] : []));
|
|
4422
|
+
/** Taille maximale par fichier, en Mo. */
|
|
4423
|
+
this.maxSizeMb = input(...(ngDevMode ? [undefined, { debugName: "maxSizeMb" }] : []));
|
|
4424
|
+
/** Dimensions recommandees (mode picture), texte d'aide. Ex. `'200 x 200 px'`. */
|
|
4425
|
+
this.recommendedDimensions = input(...(ngDevMode ? [undefined, { debugName: "recommendedDimensions" }] : []));
|
|
4426
|
+
/** Libelle accessible de la zone (aria-label). */
|
|
4427
|
+
this.label = input(...(ngDevMode ? [undefined, { debugName: "label" }] : []));
|
|
4428
|
+
/** Desactive le composant (en plus de `setDisabledState` du formulaire). */
|
|
4429
|
+
this.isDisabled = input(false, ...(ngDevMode ? [{ debugName: "isDisabled" }] : []));
|
|
4430
|
+
/**
|
|
4431
|
+
* Message d'erreur global (ex. echec d'upload cote serveur) : bascule la zone en
|
|
4432
|
+
* etat « erreur de connexion » avec un bouton Reessayer (output `retry`).
|
|
4433
|
+
*/
|
|
4434
|
+
this.errorMessage = input(...(ngDevMode ? [undefined, { debugName: "errorMessage" }] : []));
|
|
4435
|
+
/** Attribut `data-test-ctw`. */
|
|
4436
|
+
this.dataTest = input(...(ngDevMode ? [undefined, { debugName: "dataTest" }] : []));
|
|
4437
|
+
// --- Outputs ------------------------------------------------------------
|
|
4438
|
+
/** Emis a chaque changement : liste complete des fichiers (valides + en erreur). */
|
|
4439
|
+
this.filesChange = output();
|
|
4440
|
+
/** Emis avec les fichiers rejetes par la validation locale (format / taille). */
|
|
4441
|
+
this.rejected = output();
|
|
4442
|
+
/** Emis au clic sur Reessayer (etat d'erreur global). */
|
|
4443
|
+
this.retry = output();
|
|
4444
|
+
// --- Etat interne -------------------------------------------------------
|
|
4445
|
+
this.fileInput = viewChild('fileInput', ...(ngDevMode ? [{ debugName: "fileInput" }] : []));
|
|
4446
|
+
this.items = signal([], ...(ngDevMode ? [{ debugName: "items" }] : []));
|
|
4447
|
+
this.isDragging = signal(false, ...(ngDevMode ? [{ debugName: "isDragging" }] : []));
|
|
4448
|
+
this.disabledByForm = signal(false, ...(ngDevMode ? [{ debugName: "disabledByForm" }] : []));
|
|
4449
|
+
this.dragDepth = 0;
|
|
4450
|
+
// --- Enums / consts exposes au template ---------------------------------
|
|
4451
|
+
this.modeEnum = FileDropModeEnum;
|
|
4452
|
+
this.statusEnum = FileDropFileStatusEnum;
|
|
4453
|
+
this.reasonEnum = FileDropRejectReasonEnum;
|
|
4454
|
+
this.spriteIcon = SpriteIconEnum;
|
|
4455
|
+
this.iconSize = IconSizeEnum;
|
|
4456
|
+
this.iconUiType = IconUiTypeEnum;
|
|
4457
|
+
this.buttonType = BoButtonTypeEnum;
|
|
4458
|
+
this.buttonIconSize = ButtonIconSizeEnum;
|
|
4459
|
+
// --- Derives ------------------------------------------------------------
|
|
4460
|
+
this.disabled = computed(() => this.disabledByForm() || this.isDisabled(), ...(ngDevMode ? [{ debugName: "disabled" }] : []));
|
|
4461
|
+
this.isPicture = computed(() => this.mode() === FileDropModeEnum.picture, ...(ngDevMode ? [{ debugName: "isPicture" }] : []));
|
|
4462
|
+
/** `accept` effectif (defaut `image/*` en mode picture). */
|
|
4463
|
+
this.effectiveAccept = computed(() => {
|
|
4464
|
+
const a = this.accept();
|
|
4465
|
+
if (a)
|
|
4466
|
+
return a;
|
|
4467
|
+
return this.isPicture() ? 'image/*' : '';
|
|
4468
|
+
}, ...(ngDevMode ? [{ debugName: "effectiveAccept" }] : []));
|
|
4469
|
+
// --- ControlValueAccessor ----------------------------------------------
|
|
4470
|
+
this.onChange = () => { };
|
|
4471
|
+
this.onTouched = () => { };
|
|
4472
|
+
}
|
|
4473
|
+
writeValue(value) {
|
|
4474
|
+
const files = Array.isArray(value) ? value : value ? [value] : [];
|
|
4475
|
+
const items = files.map((file) => ({
|
|
4476
|
+
file,
|
|
4477
|
+
status: FileDropFileStatusEnum.success,
|
|
4478
|
+
}));
|
|
4479
|
+
this.items.set(items);
|
|
4480
|
+
items.forEach((item) => this.attachPreview(item));
|
|
4481
|
+
}
|
|
4482
|
+
registerOnChange(fn) {
|
|
4483
|
+
this.onChange = fn;
|
|
4484
|
+
}
|
|
4485
|
+
registerOnTouched(fn) {
|
|
4486
|
+
this.onTouched = fn;
|
|
4487
|
+
}
|
|
4488
|
+
setDisabledState(isDisabled) {
|
|
4489
|
+
this.disabledByForm.set(isDisabled);
|
|
4490
|
+
}
|
|
4491
|
+
// --- Interaction ---------------------------------------------------------
|
|
4492
|
+
openPicker() {
|
|
4493
|
+
if (this.disabled())
|
|
4494
|
+
return;
|
|
4495
|
+
this.fileInput()?.nativeElement.click();
|
|
4496
|
+
}
|
|
4497
|
+
/** Clic sur le bouton « Parcourir » : empeche le double-declenchement via le clic de la zone. */
|
|
4498
|
+
onBrowse(event) {
|
|
4499
|
+
event.stopPropagation();
|
|
4500
|
+
this.openPicker();
|
|
4501
|
+
}
|
|
4502
|
+
/** Cle i18n du message d'erreur d'un fichier rejete. */
|
|
4503
|
+
reasonKey(item) {
|
|
4504
|
+
return item.reason === FileDropRejectReasonEnum.size
|
|
4505
|
+
? '_COMMON._FILE_DROP.ERROR_SIZE'
|
|
4506
|
+
: '_COMMON._FILE_DROP.ERROR_FORMAT';
|
|
4507
|
+
}
|
|
4508
|
+
onKeydown(event) {
|
|
4509
|
+
if (event.key === 'Enter' || event.key === ' ') {
|
|
4510
|
+
event.preventDefault();
|
|
4511
|
+
this.openPicker();
|
|
4512
|
+
}
|
|
4513
|
+
}
|
|
4514
|
+
onInputChange(event) {
|
|
4515
|
+
const input = event.target;
|
|
4516
|
+
this.handleFiles(input.files);
|
|
4517
|
+
// Permet de re-selectionner le meme fichier juste apres une suppression.
|
|
4518
|
+
input.value = '';
|
|
4519
|
+
}
|
|
4520
|
+
onDragOver(event) {
|
|
4521
|
+
if (this.disabled())
|
|
4522
|
+
return;
|
|
4523
|
+
event.preventDefault();
|
|
4524
|
+
this.isDragging.set(true);
|
|
4525
|
+
}
|
|
4526
|
+
onDragEnter(event) {
|
|
4527
|
+
if (this.disabled())
|
|
4528
|
+
return;
|
|
4529
|
+
event.preventDefault();
|
|
4530
|
+
this.dragDepth++;
|
|
4531
|
+
this.isDragging.set(true);
|
|
4532
|
+
}
|
|
4533
|
+
onDragLeave(event) {
|
|
4534
|
+
if (this.disabled())
|
|
4535
|
+
return;
|
|
4536
|
+
event.preventDefault();
|
|
4537
|
+
this.dragDepth = Math.max(0, this.dragDepth - 1);
|
|
4538
|
+
if (this.dragDepth === 0)
|
|
4539
|
+
this.isDragging.set(false);
|
|
4540
|
+
}
|
|
4541
|
+
onDrop(event) {
|
|
4542
|
+
if (this.disabled())
|
|
4543
|
+
return;
|
|
4544
|
+
event.preventDefault();
|
|
4545
|
+
this.dragDepth = 0;
|
|
4546
|
+
this.isDragging.set(false);
|
|
4547
|
+
this.handleFiles(event.dataTransfer?.files ?? null);
|
|
4548
|
+
}
|
|
4549
|
+
remove(target) {
|
|
4550
|
+
if (this.disabled())
|
|
4551
|
+
return;
|
|
4552
|
+
this.items.update((list) => list.filter((i) => i !== target));
|
|
4553
|
+
this.propagate();
|
|
4554
|
+
}
|
|
4555
|
+
onRetry() {
|
|
4556
|
+
this.onTouched();
|
|
4557
|
+
this.retry.emit();
|
|
4558
|
+
}
|
|
4559
|
+
// --- Coeur : validation + ajout -----------------------------------------
|
|
4560
|
+
handleFiles(fileList) {
|
|
4561
|
+
if (!fileList || fileList.length === 0)
|
|
4562
|
+
return;
|
|
4563
|
+
this.onTouched();
|
|
4564
|
+
const incoming = this.multiple() ? Array.from(fileList) : [fileList[0]];
|
|
4565
|
+
const accepted = [];
|
|
4566
|
+
const errored = [];
|
|
4567
|
+
const rejections = [];
|
|
4568
|
+
for (const file of incoming) {
|
|
4569
|
+
const reason = this.validate(file);
|
|
4570
|
+
if (reason) {
|
|
4571
|
+
errored.push({ file, status: FileDropFileStatusEnum.error, reason });
|
|
4572
|
+
rejections.push({ file, reason });
|
|
4573
|
+
}
|
|
4574
|
+
else {
|
|
4575
|
+
accepted.push({ file, status: FileDropFileStatusEnum.success });
|
|
4576
|
+
}
|
|
4577
|
+
}
|
|
4578
|
+
this.items.update((list) => {
|
|
4579
|
+
const base = this.multiple() ? list : [];
|
|
4580
|
+
return [...base, ...accepted, ...errored];
|
|
4581
|
+
});
|
|
4582
|
+
accepted.forEach((item) => this.attachPreview(item));
|
|
4583
|
+
if (rejections.length)
|
|
4584
|
+
this.rejected.emit(rejections);
|
|
4585
|
+
this.propagate();
|
|
4586
|
+
}
|
|
4587
|
+
/** Retourne la raison de rejet, ou `undefined` si le fichier est valide. */
|
|
4588
|
+
validate(file) {
|
|
4589
|
+
if (!this.acceptsType(file))
|
|
4590
|
+
return FileDropRejectReasonEnum.format;
|
|
4591
|
+
const max = this.maxSizeMb();
|
|
4592
|
+
if (max != null && file.size > max * 1024 * 1024)
|
|
4593
|
+
return FileDropRejectReasonEnum.size;
|
|
4594
|
+
return undefined;
|
|
4595
|
+
}
|
|
4596
|
+
/** Match d'un fichier contre l'attribut `accept` (extensions et types MIME). */
|
|
4597
|
+
acceptsType(file) {
|
|
4598
|
+
const accept = this.effectiveAccept().trim();
|
|
4599
|
+
if (!accept)
|
|
4600
|
+
return true;
|
|
4601
|
+
const tokens = accept.split(',').map((t) => t.trim().toLowerCase()).filter(Boolean);
|
|
4602
|
+
const name = file.name.toLowerCase();
|
|
4603
|
+
const type = file.type.toLowerCase();
|
|
4604
|
+
return tokens.some((token) => {
|
|
4605
|
+
if (token.startsWith('.'))
|
|
4606
|
+
return name.endsWith(token);
|
|
4607
|
+
if (token.endsWith('/*'))
|
|
4608
|
+
return type.startsWith(token.slice(0, -1));
|
|
4609
|
+
return type === token;
|
|
4610
|
+
});
|
|
4611
|
+
}
|
|
4612
|
+
/** Genere la data URL de preview (mode picture + image) et la rattache a l'item. */
|
|
4613
|
+
attachPreview(item) {
|
|
4614
|
+
if (!this.isPicture() || !item.file.type.startsWith('image/'))
|
|
4615
|
+
return;
|
|
4616
|
+
const reader = new FileReader();
|
|
4617
|
+
reader.onload = () => {
|
|
4618
|
+
const url = reader.result;
|
|
4619
|
+
this.items.update((list) => list.map((i) => (i.file === item.file ? { ...i, previewUrl: url } : i)));
|
|
4620
|
+
};
|
|
4621
|
+
reader.readAsDataURL(item.file);
|
|
4622
|
+
}
|
|
4623
|
+
propagate() {
|
|
4624
|
+
const files = this.items()
|
|
4625
|
+
.filter((i) => i.status === FileDropFileStatusEnum.success)
|
|
4626
|
+
.map((i) => i.file);
|
|
4627
|
+
this.onChange(this.multiple() ? files : files[0] ?? null);
|
|
4628
|
+
this.filesChange.emit(this.items());
|
|
4629
|
+
}
|
|
4630
|
+
// --- Affichage taille ----------------------------------------------------
|
|
4631
|
+
/** Formate une taille en octets en libelle court (ex. `1,2 Mo`). */
|
|
4632
|
+
humanSize(bytes) {
|
|
4633
|
+
if (bytes < 1024)
|
|
4634
|
+
return `${bytes} o`;
|
|
4635
|
+
const kb = bytes / 1024;
|
|
4636
|
+
if (kb < 1024)
|
|
4637
|
+
return `${this.round(kb)} Ko`;
|
|
4638
|
+
return `${this.round(kb / 1024)} Mo`;
|
|
4639
|
+
}
|
|
4640
|
+
round(n) {
|
|
4641
|
+
return (Math.round(n * 10) / 10).toLocaleString('fr-FR');
|
|
4642
|
+
}
|
|
4643
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.20", ngImport: i0, type: FileDropComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
|
|
4644
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "20.3.20", type: FileDropComponent, isStandalone: true, selector: "cw-file-drop", inputs: { mode: { classPropertyName: "mode", publicName: "mode", isSignal: true, isRequired: false, transformFunction: null }, multiple: { classPropertyName: "multiple", publicName: "multiple", isSignal: true, isRequired: false, transformFunction: null }, accept: { classPropertyName: "accept", publicName: "accept", isSignal: true, isRequired: false, transformFunction: null }, acceptLabel: { classPropertyName: "acceptLabel", publicName: "acceptLabel", isSignal: true, isRequired: false, transformFunction: null }, maxSizeMb: { classPropertyName: "maxSizeMb", publicName: "maxSizeMb", isSignal: true, isRequired: false, transformFunction: null }, recommendedDimensions: { classPropertyName: "recommendedDimensions", publicName: "recommendedDimensions", isSignal: true, isRequired: false, transformFunction: null }, label: { classPropertyName: "label", publicName: "label", isSignal: true, isRequired: false, transformFunction: null }, isDisabled: { classPropertyName: "isDisabled", publicName: "isDisabled", isSignal: true, isRequired: false, transformFunction: null }, errorMessage: { classPropertyName: "errorMessage", publicName: "errorMessage", isSignal: true, isRequired: false, transformFunction: null }, dataTest: { classPropertyName: "dataTest", publicName: "dataTest", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { filesChange: "filesChange", rejected: "rejected", retry: "retry" }, providers: [
|
|
4645
|
+
{
|
|
4646
|
+
provide: NG_VALUE_ACCESSOR,
|
|
4647
|
+
useExisting: forwardRef(() => FileDropComponent),
|
|
4648
|
+
multi: true,
|
|
4649
|
+
},
|
|
4650
|
+
], viewQueries: [{ propertyName: "fileInput", first: true, predicate: ["fileInput"], descendants: true, isSignal: true }], ngImport: i0, template: "<input\n #fileInput\n type=\"file\"\n hidden\n [accept]=\"effectiveAccept()\"\n [multiple]=\"multiple()\"\n [disabled]=\"disabled()\"\n (change)=\"onInputChange($event)\" />\n\n@if (errorMessage()) {\n <!-- Etat erreur global (DS : Dropzone / Connexion Error) -->\n <div class=\"file-drop file-drop-error\" [attr.data-test-ctw]=\"dataTest() || null\">\n <cw-icon class=\"file-drop-icon file-drop-icon-danger\" [icon]=\"spriteIcon.error\" [iconSize]=\"iconSize.xl\"></cw-icon>\n <p class=\"file-drop-title\">{{ errorMessage() }}</p>\n <cw-button\n [type]=\"buttonType.secondary\"\n [label]=\"'_COMMON._FILE_DROP.RETRY' | translate\"\n [withIcon]=\"spriteIcon.toolbarUpload\"\n (click)=\"onRetry()\"></cw-button>\n </div>\n} @else {\n <!-- Zone de depot -->\n <div\n class=\"file-drop\"\n [class.file-drop-dragging]=\"isDragging()\"\n [class.file-drop-disabled]=\"disabled()\"\n [class.file-drop-picture]=\"isPicture()\"\n role=\"button\"\n [attr.tabindex]=\"disabled() ? -1 : 0\"\n [attr.aria-label]=\"label() || null\"\n [attr.aria-disabled]=\"disabled() || null\"\n [attr.data-test-ctw]=\"dataTest() || null\"\n (click)=\"openPicker()\"\n (keydown)=\"onKeydown($event)\"\n (dragenter)=\"onDragEnter($event)\"\n (dragover)=\"onDragOver($event)\"\n (dragleave)=\"onDragLeave($event)\"\n (drop)=\"onDrop($event)\">\n\n @if (isPicture()) {\n <span class=\"file-drop-illustration\" aria-hidden=\"true\">\n <svg width=\"64\" height=\"64\" viewBox=\"0 0 64 64\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\">\n <defs>\n <clipPath id=\"cw-file-drop-illu\"><rect width=\"64\" height=\"64\" rx=\"8\" /></clipPath>\n </defs>\n <g clip-path=\"url(#cw-file-drop-illu)\">\n <rect width=\"64\" height=\"64\" fill=\"#dde8f5\" />\n <circle cx=\"45\" cy=\"19\" r=\"7\" fill=\"#ffd166\" />\n <path d=\"M0 64 L22 36 L38 58 L50 28 L64 50 L64 64 Z\" fill=\"#8bbd5a\" />\n <path d=\"M0 64 L16 44 L32 64 Z\" fill=\"#a8c97a\" />\n </g>\n <rect x=\"0.5\" y=\"0.5\" width=\"63\" height=\"63\" rx=\"7.5\" fill=\"none\" stroke=\"#c8d6df\" />\n </svg>\n </span>\n } @else {\n <cw-icon class=\"file-drop-icon\" [icon]=\"spriteIcon.toolbarUpload\" [iconSize]=\"iconSize.xl\"></cw-icon>\n }\n\n <p class=\"file-drop-title\">\n {{ (isPicture() ? '_COMMON._FILE_DROP.DROP_PICTURE' : '_COMMON._FILE_DROP.DROP_FILE') | translate }}\n </p>\n <span class=\"file-drop-or\">{{ '_COMMON._FILE_DROP.OR' | translate }}</span>\n <cw-button\n class=\"file-drop-browse\"\n [type]=\"buttonType.secondary\"\n [label]=\"(isPicture() ? '_COMMON._FILE_DROP.BROWSE_PICTURE' : '_COMMON._FILE_DROP.BROWSE') | translate\"\n [withIcon]=\"spriteIcon.toolbarUpload\"\n [isDisabled]=\"disabled()\"\n (click)=\"onBrowse($event)\"></cw-button>\n </div>\n\n <!-- Textes d'aide -->\n @if (acceptLabel() || maxSizeMb() != null || (isPicture() && recommendedDimensions())) {\n <ul class=\"file-drop-hints\">\n @if (acceptLabel()) {\n <li>{{ '_COMMON._FILE_DROP.ACCEPTED_FORMATS' | translate: { formats: acceptLabel() } }}</li>\n }\n @if (maxSizeMb() != null) {\n <li>{{ '_COMMON._FILE_DROP.MAX_SIZE' | translate: { size: maxSizeMb() + ' Mo' } }}</li>\n }\n @if (isPicture() && recommendedDimensions()) {\n <li>{{ '_COMMON._FILE_DROP.RECOMMENDED_DIMENSIONS' | translate: { dimensions: recommendedDimensions() } }}</li>\n }\n </ul>\n }\n\n <!-- Liste des fichiers / miniatures -->\n @if (items().length) {\n @if (isPicture()) {\n <ul class=\"file-drop-previews\">\n @for (item of items(); track item.file) {\n <li class=\"file-drop-preview\" [class.file-drop-preview-error]=\"item.status === statusEnum.error\">\n @if (item.previewUrl) {\n <img class=\"file-drop-preview-img\" [src]=\"item.previewUrl\" [alt]=\"item.file.name\" />\n } @else {\n <cw-icon [icon]=\"spriteIcon.poiPhoto\" [iconSize]=\"iconSize.lg\"></cw-icon>\n }\n <button\n type=\"button\"\n class=\"file-drop-remove\"\n [disabled]=\"disabled()\"\n [attr.aria-label]=\"'_COMMON._FILE_DROP.REMOVE' | translate: { name: item.file.name }\"\n (click)=\"remove(item)\">\n <cw-icon [icon]=\"spriteIcon.close\" [iconSize]=\"iconSize.xs\"></cw-icon>\n </button>\n @if (item.status === statusEnum.error) {\n <span class=\"file-drop-preview-reason\">{{ reasonKey(item) | translate }}</span>\n }\n </li>\n }\n </ul>\n } @else {\n <ul class=\"file-drop-list\">\n @for (item of items(); track item.file) {\n <li\n class=\"file-drop-file\"\n [class.file-drop-file-success]=\"item.status === statusEnum.success\"\n [class.file-drop-file-error]=\"item.status === statusEnum.error\">\n <cw-icon\n class=\"file-drop-file-icon\"\n [icon]=\"item.status === statusEnum.error ? spriteIcon.error : spriteIcon.file\"\n [iconSize]=\"iconSize.sm\"></cw-icon>\n <span class=\"file-drop-file-name\">{{ item.file.name }}</span>\n @if (item.status === statusEnum.error) {\n <span class=\"file-drop-file-reason\">{{ reasonKey(item) | translate }}</span>\n } @else {\n <span class=\"file-drop-file-size\">{{ humanSize(item.file.size) }}</span>\n }\n <button\n type=\"button\"\n class=\"file-drop-remove\"\n [disabled]=\"disabled()\"\n [attr.aria-label]=\"'_COMMON._FILE_DROP.REMOVE' | translate: { name: item.file.name }\"\n (click)=\"remove(item)\">\n <cw-icon [icon]=\"spriteIcon.trash\" [iconSize]=\"iconSize.sm\"></cw-icon>\n </button>\n </li>\n }\n </ul>\n }\n }\n}\n", dependencies: [{ kind: "ngmodule", type: CommonModule }, { kind: "component", type: IconComponent, selector: "cw-icon", inputs: ["icon", "label", "type", "iconSize", "iconCssClass", "iconUiType", "iconColorCustom", "spritePath"] }, { kind: "component", type: ButtonComponent, selector: "cw-button", inputs: ["type", "label", "id", "link", "isDropdown", "hideCaret", "withIcon", "withOnlyIcon", "iconSize", "iconPosition", "dropdownPosition", "isMinWidth", "isDisabled", "isLoading", "cssClass", "dataTest", "skeletonMode", "withTooltip", "tooltipText", "tooltipTitle", "tooltipTrigger", "tooltipPosition", "tooltipType"], outputs: ["btnAction", "dropDownClicked"] }, { kind: "pipe", type: TranslatePipe, name: "translate" }] }); }
|
|
4651
|
+
}
|
|
4652
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.20", ngImport: i0, type: FileDropComponent, decorators: [{
|
|
4653
|
+
type: Component,
|
|
4654
|
+
args: [{ selector: 'cw-file-drop', standalone: true, imports: [CommonModule, TranslatePipe, IconComponent, ButtonComponent], providers: [
|
|
4655
|
+
{
|
|
4656
|
+
provide: NG_VALUE_ACCESSOR,
|
|
4657
|
+
useExisting: forwardRef(() => FileDropComponent),
|
|
4658
|
+
multi: true,
|
|
4659
|
+
},
|
|
4660
|
+
], template: "<input\n #fileInput\n type=\"file\"\n hidden\n [accept]=\"effectiveAccept()\"\n [multiple]=\"multiple()\"\n [disabled]=\"disabled()\"\n (change)=\"onInputChange($event)\" />\n\n@if (errorMessage()) {\n <!-- Etat erreur global (DS : Dropzone / Connexion Error) -->\n <div class=\"file-drop file-drop-error\" [attr.data-test-ctw]=\"dataTest() || null\">\n <cw-icon class=\"file-drop-icon file-drop-icon-danger\" [icon]=\"spriteIcon.error\" [iconSize]=\"iconSize.xl\"></cw-icon>\n <p class=\"file-drop-title\">{{ errorMessage() }}</p>\n <cw-button\n [type]=\"buttonType.secondary\"\n [label]=\"'_COMMON._FILE_DROP.RETRY' | translate\"\n [withIcon]=\"spriteIcon.toolbarUpload\"\n (click)=\"onRetry()\"></cw-button>\n </div>\n} @else {\n <!-- Zone de depot -->\n <div\n class=\"file-drop\"\n [class.file-drop-dragging]=\"isDragging()\"\n [class.file-drop-disabled]=\"disabled()\"\n [class.file-drop-picture]=\"isPicture()\"\n role=\"button\"\n [attr.tabindex]=\"disabled() ? -1 : 0\"\n [attr.aria-label]=\"label() || null\"\n [attr.aria-disabled]=\"disabled() || null\"\n [attr.data-test-ctw]=\"dataTest() || null\"\n (click)=\"openPicker()\"\n (keydown)=\"onKeydown($event)\"\n (dragenter)=\"onDragEnter($event)\"\n (dragover)=\"onDragOver($event)\"\n (dragleave)=\"onDragLeave($event)\"\n (drop)=\"onDrop($event)\">\n\n @if (isPicture()) {\n <span class=\"file-drop-illustration\" aria-hidden=\"true\">\n <svg width=\"64\" height=\"64\" viewBox=\"0 0 64 64\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\">\n <defs>\n <clipPath id=\"cw-file-drop-illu\"><rect width=\"64\" height=\"64\" rx=\"8\" /></clipPath>\n </defs>\n <g clip-path=\"url(#cw-file-drop-illu)\">\n <rect width=\"64\" height=\"64\" fill=\"#dde8f5\" />\n <circle cx=\"45\" cy=\"19\" r=\"7\" fill=\"#ffd166\" />\n <path d=\"M0 64 L22 36 L38 58 L50 28 L64 50 L64 64 Z\" fill=\"#8bbd5a\" />\n <path d=\"M0 64 L16 44 L32 64 Z\" fill=\"#a8c97a\" />\n </g>\n <rect x=\"0.5\" y=\"0.5\" width=\"63\" height=\"63\" rx=\"7.5\" fill=\"none\" stroke=\"#c8d6df\" />\n </svg>\n </span>\n } @else {\n <cw-icon class=\"file-drop-icon\" [icon]=\"spriteIcon.toolbarUpload\" [iconSize]=\"iconSize.xl\"></cw-icon>\n }\n\n <p class=\"file-drop-title\">\n {{ (isPicture() ? '_COMMON._FILE_DROP.DROP_PICTURE' : '_COMMON._FILE_DROP.DROP_FILE') | translate }}\n </p>\n <span class=\"file-drop-or\">{{ '_COMMON._FILE_DROP.OR' | translate }}</span>\n <cw-button\n class=\"file-drop-browse\"\n [type]=\"buttonType.secondary\"\n [label]=\"(isPicture() ? '_COMMON._FILE_DROP.BROWSE_PICTURE' : '_COMMON._FILE_DROP.BROWSE') | translate\"\n [withIcon]=\"spriteIcon.toolbarUpload\"\n [isDisabled]=\"disabled()\"\n (click)=\"onBrowse($event)\"></cw-button>\n </div>\n\n <!-- Textes d'aide -->\n @if (acceptLabel() || maxSizeMb() != null || (isPicture() && recommendedDimensions())) {\n <ul class=\"file-drop-hints\">\n @if (acceptLabel()) {\n <li>{{ '_COMMON._FILE_DROP.ACCEPTED_FORMATS' | translate: { formats: acceptLabel() } }}</li>\n }\n @if (maxSizeMb() != null) {\n <li>{{ '_COMMON._FILE_DROP.MAX_SIZE' | translate: { size: maxSizeMb() + ' Mo' } }}</li>\n }\n @if (isPicture() && recommendedDimensions()) {\n <li>{{ '_COMMON._FILE_DROP.RECOMMENDED_DIMENSIONS' | translate: { dimensions: recommendedDimensions() } }}</li>\n }\n </ul>\n }\n\n <!-- Liste des fichiers / miniatures -->\n @if (items().length) {\n @if (isPicture()) {\n <ul class=\"file-drop-previews\">\n @for (item of items(); track item.file) {\n <li class=\"file-drop-preview\" [class.file-drop-preview-error]=\"item.status === statusEnum.error\">\n @if (item.previewUrl) {\n <img class=\"file-drop-preview-img\" [src]=\"item.previewUrl\" [alt]=\"item.file.name\" />\n } @else {\n <cw-icon [icon]=\"spriteIcon.poiPhoto\" [iconSize]=\"iconSize.lg\"></cw-icon>\n }\n <button\n type=\"button\"\n class=\"file-drop-remove\"\n [disabled]=\"disabled()\"\n [attr.aria-label]=\"'_COMMON._FILE_DROP.REMOVE' | translate: { name: item.file.name }\"\n (click)=\"remove(item)\">\n <cw-icon [icon]=\"spriteIcon.close\" [iconSize]=\"iconSize.xs\"></cw-icon>\n </button>\n @if (item.status === statusEnum.error) {\n <span class=\"file-drop-preview-reason\">{{ reasonKey(item) | translate }}</span>\n }\n </li>\n }\n </ul>\n } @else {\n <ul class=\"file-drop-list\">\n @for (item of items(); track item.file) {\n <li\n class=\"file-drop-file\"\n [class.file-drop-file-success]=\"item.status === statusEnum.success\"\n [class.file-drop-file-error]=\"item.status === statusEnum.error\">\n <cw-icon\n class=\"file-drop-file-icon\"\n [icon]=\"item.status === statusEnum.error ? spriteIcon.error : spriteIcon.file\"\n [iconSize]=\"iconSize.sm\"></cw-icon>\n <span class=\"file-drop-file-name\">{{ item.file.name }}</span>\n @if (item.status === statusEnum.error) {\n <span class=\"file-drop-file-reason\">{{ reasonKey(item) | translate }}</span>\n } @else {\n <span class=\"file-drop-file-size\">{{ humanSize(item.file.size) }}</span>\n }\n <button\n type=\"button\"\n class=\"file-drop-remove\"\n [disabled]=\"disabled()\"\n [attr.aria-label]=\"'_COMMON._FILE_DROP.REMOVE' | translate: { name: item.file.name }\"\n (click)=\"remove(item)\">\n <cw-icon [icon]=\"spriteIcon.trash\" [iconSize]=\"iconSize.sm\"></cw-icon>\n </button>\n </li>\n }\n </ul>\n }\n }\n}\n" }]
|
|
4661
|
+
}], propDecorators: { mode: [{ type: i0.Input, args: [{ isSignal: true, alias: "mode", required: false }] }], multiple: [{ type: i0.Input, args: [{ isSignal: true, alias: "multiple", required: false }] }], accept: [{ type: i0.Input, args: [{ isSignal: true, alias: "accept", required: false }] }], acceptLabel: [{ type: i0.Input, args: [{ isSignal: true, alias: "acceptLabel", required: false }] }], maxSizeMb: [{ type: i0.Input, args: [{ isSignal: true, alias: "maxSizeMb", required: false }] }], recommendedDimensions: [{ type: i0.Input, args: [{ isSignal: true, alias: "recommendedDimensions", required: false }] }], label: [{ type: i0.Input, args: [{ isSignal: true, alias: "label", required: false }] }], isDisabled: [{ type: i0.Input, args: [{ isSignal: true, alias: "isDisabled", required: false }] }], errorMessage: [{ type: i0.Input, args: [{ isSignal: true, alias: "errorMessage", required: false }] }], dataTest: [{ type: i0.Input, args: [{ isSignal: true, alias: "dataTest", required: false }] }], filesChange: [{ type: i0.Output, args: ["filesChange"] }], rejected: [{ type: i0.Output, args: ["rejected"] }], retry: [{ type: i0.Output, args: ["retry"] }], fileInput: [{ type: i0.ViewChild, args: ['fileInput', { isSignal: true }] }] } });
|
|
4662
|
+
|
|
4376
4663
|
/**
|
|
4377
4664
|
* Sélecteur de langue présentational.
|
|
4378
4665
|
*
|
|
@@ -4633,5 +4920,5 @@ const CW_DEFAULT_THEME_OPTIONS = [
|
|
|
4633
4920
|
* Generated bundle index. Do not edit.
|
|
4634
4921
|
*/
|
|
4635
4922
|
|
|
4636
|
-
export { AccordionComponent, AlertComponent, AlertTypeEnum, BadgeComponent, BadgePositionEnum, BadgeTypeEnum, BoButtonTypeEnum, BoTabTypeEnum, BreadcrumbComponent, ButtonComponent, ButtonIconSizeEnum, ButtonPositionEnum, CW_DEFAULT_THEME_OPTIONS, CardComponent, CardTitleRankEnum, CardTypeEnum, ClickOutsideDirective, CollapseDirective, CwThemeKeyEnum, CwTooltipDirective, DropdownComponent, DropdownItemDirective, DropdownPositionEnum, FileToDownloadComponent, FoButtonTypeEnum, FoTabTypeEnum, FocusTrackerService, FormFieldComponent, FormFieldTypeEnum, IconComponent, IconNotifSizeEnum, IconNotifTypeEnum, IconNotificationComponent, IconSizeEnum, IconTypeEnum, IconUiTypeEnum, ImageComponent, LanguageSelectorComponent, LegendComponent, LegendTypeEnum, LoaderComponent, LoaderSizeEnum, ModalsComponent, ModalsService, ModalsSize, ModalsState, ModalsTextType, ModalsType, NumericalRangeComponent, NumericalRangeLabelPositionEnum, NumericalRangeTypeEnum, PlacementEnum, RequiredInfoComponent, ResponsiveService, SkipLinksComponent, SpriteIconEnum, StepperComponent, TOAST_AUTOHIDE_DELAY_MS, TabComponent, TabContentComponent, ThemeSelectorComponent, ThemeService, TitleComponent, TitleContextEnum, TitleTagEnum, ToastComponent, ToastItemComponent, ToastService, TooltipPositionEnum, TriggerTooltipEnum, TypeTooltipEnum, rangeValidator, resolveArrowPos };
|
|
4923
|
+
export { AccordionComponent, AlertComponent, AlertTypeEnum, BadgeComponent, BadgePositionEnum, BadgeTypeEnum, BoButtonTypeEnum, BoTabTypeEnum, BreadcrumbComponent, ButtonComponent, ButtonIconSizeEnum, ButtonPositionEnum, CW_DEFAULT_THEME_OPTIONS, CardComponent, CardTitleRankEnum, CardTypeEnum, ClickOutsideDirective, CollapseDirective, CwThemeKeyEnum, CwTooltipDirective, DropdownComponent, DropdownItemDirective, DropdownPositionEnum, FileDropComponent, FileDropFileStatusEnum, FileDropModeEnum, FileDropRejectReasonEnum, FileToDownloadComponent, FoButtonTypeEnum, FoTabTypeEnum, FocusTrackerService, FormFieldComponent, FormFieldTypeEnum, IconComponent, IconNotifSizeEnum, IconNotifTypeEnum, IconNotificationComponent, IconSizeEnum, IconTypeEnum, IconUiTypeEnum, ImageComponent, LanguageSelectorComponent, LegendComponent, LegendTypeEnum, LoaderComponent, LoaderSizeEnum, ModalsComponent, ModalsService, ModalsSize, ModalsState, ModalsTextType, ModalsType, NumericalRangeComponent, NumericalRangeLabelPositionEnum, NumericalRangeTypeEnum, PlacementEnum, RequiredInfoComponent, ResponsiveService, SkipLinksComponent, SpriteIconEnum, StepperComponent, TOAST_AUTOHIDE_DELAY_MS, TabComponent, TabContentComponent, ThemeSelectorComponent, ThemeService, TitleComponent, TitleContextEnum, TitleTagEnum, ToastComponent, ToastItemComponent, ToastService, TooltipPositionEnum, TriggerTooltipEnum, TypeTooltipEnum, rangeValidator, resolveArrowPos };
|
|
4637
4924
|
//# sourceMappingURL=cityway-basic-ui.mjs.map
|