@praxisui/files-upload 1.0.0-beta.8 → 3.0.0-beta.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.
package/README.md CHANGED
@@ -1,7 +1,62 @@
1
+ ---
2
+ title: "Files Upload"
3
+ slug: "files-upload-overview"
4
+ description: "Visao geral do @praxisui/files-upload com upload direto ou presign, validacoes, i18n, persistencia de configuracao e integracao com backend Praxis."
5
+ doc_type: "reference"
6
+ document_kind: "component-overview"
7
+ component: "files-upload"
8
+ category: "components"
9
+ audience:
10
+ - "frontend"
11
+ - "host"
12
+ - "architect"
13
+ level: "intermediate"
14
+ status: "active"
15
+ owner: "praxis-ui"
16
+ tags:
17
+ - "files-upload"
18
+ - "upload"
19
+ - "presign"
20
+ - "validation"
21
+ - "i18n"
22
+ order: 37
23
+ icon: "upload"
24
+ toc: true
25
+ sidebar: true
26
+ search_boost: 0.95
27
+ reading_time: 11
28
+ estimated_setup_time: 20
29
+ version: "1.0"
30
+ related_docs:
31
+ - "host-files-upload-integration"
32
+ - "consumer-integration-quickstart"
33
+ - "host-integration-guide"
34
+ keywords:
35
+ - "praxis files upload"
36
+ - "presigned upload"
37
+ - "upload config"
38
+ - "bulk upload"
39
+ last_updated: "2026-03-07"
40
+ ---
41
+
1
42
  # Praxis Files Upload
2
43
 
3
44
  Components and services for integrating file uploads with the Praxis backend. Configuration is provided as JSON and can be edited at runtime through the Settings Panel.
4
45
 
46
+ `enableCustomization` is opt-in. Hosts that want runtime settings/configuration must declare `[enableCustomization]="true"` explicitly.
47
+
48
+ ## Documentation
49
+
50
+ - Official documentation: https://praxisui.dev
51
+ - Quickstart reference app: https://github.com/codexrodrigues/praxis-ui-quickstart
52
+ - Recommended for: enterprise upload flows with direct upload, presigned URLs, quotas and operational feedback
53
+
54
+ ## When to use
55
+
56
+ - Implement file upload with operational feedback and quota-aware UX
57
+ - Support direct and presigned upload strategies from the same component set
58
+ - Keep upload configuration editable at runtime in Praxis-based hosts
59
+
5
60
  ## Component Overview
6
61
 
7
62
  Main component selector: `praxis-files-upload`
@@ -9,18 +64,110 @@ Main component selector: `praxis-files-upload`
9
64
  Inputs
10
65
  - `config: FilesUploadConfig | null` UI/limits/options for the upload flow.
11
66
  - `baseUrl?: string` Required to enable uploads (backend base URL for files API).
12
- - `componentId: string` Persistence key suffix for local config (default: `default`).
67
+ - `filesUploadId: string` Required identifier for config persistence.
68
+ - `componentInstanceId?: string` Optional instance key when rendering multiple uploads in the same route.
13
69
  - `displayMode: 'full' | 'compact'` Controls UI density and overlays (default: `full`).
70
+ - `enableCustomization: boolean` Enables runtime customization/settings affordances (default: `false`).
14
71
 
15
72
  Outputs
16
- - `uploadSuccess: { file: FileMetadata }` Emitted per successful single upload.
17
- - `bulkComplete: BulkUploadResponse` Summary for batch uploads.
73
+ - `uploadSuccess: FileMetadata` Emitted per successful single upload.
74
+ - `bulkComplete: BulkUploadResponseData` Summary payload for batch uploads.
18
75
  - `error: ErrorResponse` Error information for failed requests.
19
76
  - `rateLimited: RateLimitInfo` Emits when 429 is detected (with reset hints).
20
77
  - `retry | download | copyLink | detailsOpened | detailsClosed: BulkUploadFileResult` Advanced list actions.
21
- - `pendingFilesChange: File[]` Current selected (pending) files.
78
+ - `pendingStateChange: PendingFilesState` Current manual-selection state (`files`, `count`, `hasPending`).
22
79
  - `proximityChange: boolean` Proximity overlay visibility toggles.
23
80
 
81
+ ## Backend Contract
82
+
83
+ `@praxisui/files-upload` consome o contrato final do backend Praxis sem camadas de compatibilidade.
84
+
85
+ Success envelope:
86
+
87
+ ```json
88
+ {
89
+ "status": "success",
90
+ "message": "Upload realizado com sucesso",
91
+ "timestamp": "2026-03-15T11:00:00Z",
92
+ "data": {
93
+ "originalFilename": "contract.pdf",
94
+ "serverFilename": "stored-contract.pdf",
95
+ "fileId": "f-123",
96
+ "fileSize": 1024,
97
+ "mimeType": "application/pdf",
98
+ "uploadTimestamp": "2026-03-15T11:00:00Z"
99
+ }
100
+ }
101
+ ```
102
+
103
+ Bulk success and partial success:
104
+
105
+ ```json
106
+ {
107
+ "status": "partial_success",
108
+ "message": "Upload em lote processado com sucesso parcial",
109
+ "timestamp": "2026-03-15T11:00:00Z",
110
+ "data": {
111
+ "totalProcessed": 2,
112
+ "totalSuccess": 1,
113
+ "totalFailed": 1,
114
+ "overallSuccess": false,
115
+ "results": [
116
+ {
117
+ "fileName": "ok.pdf",
118
+ "status": "SUCCESS",
119
+ "file": {
120
+ "id": "f-123",
121
+ "fileName": "ok.pdf",
122
+ "contentType": "application/pdf",
123
+ "fileSize": 1024,
124
+ "uploadedAt": "2026-03-15T11:00:00Z",
125
+ "tenantId": "tenant-a",
126
+ "scanStatus": "PENDING"
127
+ }
128
+ },
129
+ {
130
+ "fileName": "bad.exe",
131
+ "status": "FAILED",
132
+ "error": {
133
+ "status": "failure",
134
+ "message": "Falha de validacao",
135
+ "errors": [
136
+ {
137
+ "code": "TIPO_ARQUIVO_INVALIDO",
138
+ "message": "Tipo de arquivo invalido."
139
+ }
140
+ ],
141
+ "traceId": "trace-1"
142
+ }
143
+ }
144
+ ]
145
+ }
146
+ }
147
+ ```
148
+
149
+ Error envelope:
150
+
151
+ ```json
152
+ {
153
+ "status": "failure",
154
+ "message": "Falha de validacao",
155
+ "errors": [
156
+ {
157
+ "code": "QUOTA_EXCEEDED",
158
+ "message": "Quota reached."
159
+ }
160
+ ],
161
+ "timestamp": "2026-03-15T11:00:00Z",
162
+ "traceId": "trace-1"
163
+ }
164
+ ```
165
+
166
+ Leituras feitas pelo componente:
167
+ - upload simples: `data`
168
+ - upload em lote: `data.results`
169
+ - erro: `errors[0]`
170
+
24
171
  ## Components
25
172
 
26
173
  ### `PraxisFilesUpload`
@@ -32,7 +179,7 @@ import { PraxisFilesUpload, FilesUploadConfig, FileMetadata } from "@praxisui/fi
32
179
  @Component({
33
180
  standalone: true,
34
181
  imports: [PraxisFilesUpload],
35
- template: `<praxis-files-upload [config]="config" (uploadSuccess)="onSuccess($event)"></praxis-files-upload>`,
182
+ template: `<praxis-files-upload filesUploadId="docs-upload" [config]="config" (uploadSuccess)="onSuccess($event)"></praxis-files-upload>`,
36
183
  })
37
184
  export class DemoComponent {
38
185
  config: FilesUploadConfig = {
@@ -40,25 +187,39 @@ export class DemoComponent {
40
187
  ui: { showDropzone: true },
41
188
  };
42
189
 
43
- onSuccess(event: { file: FileMetadata }) {
44
- console.log("uploaded", event.file);
190
+ onSuccess(file: FileMetadata) {
191
+ console.log("uploaded", file);
45
192
  }
46
193
  }
47
194
  ```
48
195
 
49
196
  ### `PdxFilesUploadFieldComponent`
50
197
 
51
- Wrapper for dynamic forms that implements `ControlValueAccessor` and emits either file metadata or the uploaded id according to the configured `valueMode`.
198
+ Wrapper for dynamic forms that implements `ControlValueAccessor` and resolves the field value according to the configured `valueMode`.
52
199
 
53
200
  ```ts
54
201
  <form [formGroup]="form">
55
- <pdx-material-files-upload formControlName="attachment" />
202
+ <pdx-material-files-upload
203
+ formControlName="attachment"
204
+ valueMode="metadata[]"
205
+ />
56
206
  </form>
57
207
  ```
58
208
 
209
+ Array modes keep a stable shape in both single and bulk uploads:
210
+ - `metadata[]` always resolves to `FileMetadata[]`
211
+ - `id[]` always resolves to `string[]`
212
+
59
213
  ## Configuration options
60
214
 
61
- The editor allows adjusting UI behavior, bulk parameters, limits, quotas, rate limit handling, headers and messages for individual error codes.
215
+ The editor allows adjusting the config in separated responsibility groups:
216
+
217
+ - `ui`: visual presentation and interaction only
218
+ - `limits`: client-side validation and local flow guards
219
+ - `options`: backend-facing upload options serialized into the request
220
+ - `bulk`: execution policy such as retries and parallelism
221
+ - `quotas`, `rateLimit`, `messages`: feedback and UX behavior
222
+ - `headers`: host-specific contextual header naming
62
223
 
63
224
  - `strategy`: `direct` | `presign` | `auto` — `auto` tenta upload pré-assinado e recorre ao modo direto se a etapa de presign falhar.
64
225
 
@@ -83,7 +244,7 @@ Client-side constraints can be enforced via `config` and validated by built-in v
83
244
 
84
245
  - Types: `ui.accept: string[]` (e.g., `['image/png','application/pdf']`)
85
246
  - Extensions/MIME: `options.allowedExtensions`, `options.acceptMimeTypes`
86
- - Size per file: `limits.maxFileSizeBytes` (bytes) or `limits.maxUploadSizeMb`
247
+ - Size per file: `limits.maxFileSizeBytes` (bytes) or `options.maxUploadSizeMb`
87
248
  - Count per batch: `limits.maxFilesPerBulk`
88
249
  - Total size per batch: `limits.maxBulkSizeBytes`
89
250
 
@@ -112,7 +273,7 @@ const cfg: FilesUploadConfig = {
112
273
 
113
274
  ## Error handling
114
275
 
115
- `ErrorMapperService` translates backend `ErrorCode` values into user-facing messages and exposes rate limit information.
276
+ `ErrorMapperService` translates backend error codes from `errors[0]` into user-facing messages and exposes rate limit information.
116
277
 
117
278
  Default messages are provided in Portuguese but can be overridden globally by
118
279
  providing the `FILES_UPLOAD_ERROR_MESSAGES` injection token:
@@ -123,40 +284,30 @@ providing the `FILES_UPLOAD_ERROR_MESSAGES` injection token:
123
284
 
124
285
  ## Configuration persistence
125
286
 
126
- The configuration editor stores settings in `CONFIG_STORAGE` with fallback to `localStorage`, using the key `files-upload-config:<componentId>`.
287
+ The configuration editor stores settings in `ASYNC_CONFIG_STORAGE`, using the key `files-upload-config:<component_id>`. Provide an async storage implementation (for example, `LocalStorageAsyncAdapter` for local persistence or `ApiConfigStorage` for remote persistence).
127
288
 
128
289
  ## Internationalização
129
290
 
130
- Todas as mensagens do componente são fornecidas em Português Brasileiro. Para cenários multilíngues, o componente integra-se opcionalmente ao `@ngx-translate/core` e expõe um conjunto de chaves `praxis.filesUpload.*`.
291
+ `@praxisui/files-upload` usa a infraestrutura oficial de i18n do `@praxisui/core`.
131
292
 
132
- As traduções padrão podem ser registradas com o objeto `FILES_UPLOAD_PT_BR`:
293
+ As chaves internas da lib vivem no namespace `praxis.filesUpload.*` e podem ser registradas com `providePraxisFilesUploadI18n(...)`:
133
294
 
134
295
  ```ts
135
- import { TranslateService } from '@ngx-translate/core';
136
- import { FILES_UPLOAD_PT_BR } from '@praxisui/files-upload';
137
-
138
- constructor(private translate: TranslateService) {
139
- translate.setTranslation('pt-BR', FILES_UPLOAD_PT_BR, true);
140
- }
141
- ```
142
-
143
- Se nenhuma tradução estiver disponível, o componente utiliza o token `FILES_UPLOAD_TEXTS` como fallback. Para sobrescrever os textos manualmente:
144
-
145
- ```ts
146
- import { FILES_UPLOAD_TEXTS } from "@praxisui/files-upload";
296
+ import { providePraxisFilesUploadI18n } from '@praxisui/files-upload';
147
297
 
148
298
  providers: [
149
- {
150
- provide: FILES_UPLOAD_TEXTS,
151
- useValue: {
152
- settingsAriaLabel: "Open settings",
153
- dropzoneLabel: "Drag files here or",
154
- dropzoneButton: "select",
155
- conflictPolicyLabel: "Conflict policy",
156
- metadataLabel: "Metadata (JSON)",
157
- progressAriaLabel: "Upload progress",
158
- rateLimitBanner: "Rate limit exceeded. Try again at",
299
+ providePraxisFilesUploadI18n({
300
+ locale: 'en-US',
301
+ fallbackLocale: 'pt-BR',
302
+ dictionaries: {
303
+ 'en-US': {
304
+ 'praxis.filesUpload.dropzoneLabel': 'Drag files or',
305
+ },
159
306
  },
160
- },
307
+ }),
161
308
  ];
162
309
  ```
310
+
311
+ O caminho recomendado para hosts e libs consumidoras e usar esse provider ou a infraestrutura compartilhada do `PraxisI18nService`.
312
+
313
+ `FILES_UPLOAD_TEXTS` e `TRANSLATE_LIKE` permanecem exportados apenas como camada transitoria de compatibilidade. Quando usados, eles funcionam como fallback para chaves planas da lib, inclusive chaves novas como `fieldPendingSummary` e overrides legados baseados em `instant(...)` ou `t(...)`. Novo codigo nao deve depender desses tokens, e eles devem ser tratados como legado/deprecado.