@xsolla/xui-uploader 0.174.3 → 0.175.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 +68 -0
- package/package.json +5 -5
package/README.md
CHANGED
|
@@ -1,6 +1,74 @@
|
|
|
1
1
|
# Uploader
|
|
2
2
|
|
|
3
3
|
A cross-platform React file uploader component that provides a button to select files, displays selected files, and allows removing them.
|
|
4
|
+
<!-- BEGIN:xui-mcp-instructions:uploader -->
|
|
5
|
+
A compact button-style control that triggers a file selection dialog and optionally displays a list of uploaded or selected files below the trigger. Supports five sizes, six states including an upload-in-progress loading state, and a toggleable file list. Used wherever a user must attach, replace, or upload a file — profile photos, document uploads, asset imports.
|
|
6
|
+
|
|
7
|
+
### When to use
|
|
8
|
+
- When the user must select and upload a file from their device — profile picture, document, CSV import, media asset
|
|
9
|
+
- When the file selection happens inline in a form alongside other fields
|
|
10
|
+
- When the number of accepted files is small (one or a few) and a full drag-and-drop zone would occupy too much space
|
|
11
|
+
- When the upload state and error feedback must be communicated within the field itself, without a separate Toast or modal
|
|
12
|
+
|
|
13
|
+
### When not to use
|
|
14
|
+
|
|
15
|
+
When batch uploading many files at once with drag-and-drop is the primary interaction — use a dedicated Drag&dropUploader component
|
|
16
|
+
|
|
17
|
+
When the upload triggers a complex multi-step flow — open a dedicated upload modal instead
|
|
18
|
+
|
|
19
|
+
When only a URL or link is needed, not an actual file — use a standard Input
|
|
20
|
+
|
|
21
|
+
### Content guidelines
|
|
22
|
+
|
|
23
|
+
Trigger label — use a short imperative phrase: *"Upload file"*, *"Choose file"*, *"Add document"*, *"Upload photo"*. For replace scenarios, switch to *"Replace file"* or *"Change photo"*.
|
|
24
|
+
|
|
25
|
+
Loading label — show *"Uploading…"* or *"Processing…"* while in State=Loading. If the upload has measurable progress, include the percentage: *"Uploading… 64%"*.
|
|
26
|
+
Error messages — be specific and actionable:
|
|
27
|
+
- *"File type not supported. Please upload a PDF or DOCX file."*
|
|
28
|
+
- *"File is too large. Maximum allowed size is 10 MB."*
|
|
29
|
+
- *"Upload failed. Check your connection and try again."*
|
|
30
|
+
- *"Please upload a file to continue."* (required field, empty on submit)
|
|
31
|
+
- File type guidance — add helper text below the component (outside FileUploader) specifying accepted formats and size limits: *"Accepted formats: PDF, DOCX. Max size: 10 MB."* Do not put this information inside the trigger label.
|
|
32
|
+
- Field label — always provide a visible label above the component: *"Profile photo"*, *"Company logo"*, *"Import file"*. Do not rely on the trigger label alone.
|
|
33
|
+
|
|
34
|
+
Behaviour guidelines (from industry practice)
|
|
35
|
+
|
|
36
|
+
Click to select — clicking the trigger opens the native OS file selection dialog. After the user selects a file, the component transitions based on the product's flow: either immediately begins uploading (State=Loading) or adds the file to the list (if deferred upload is used).
|
|
37
|
+
|
|
38
|
+
Loading state — switch to State=Loading immediately when the upload begins. The trigger is non-interactive during upload. Show a progress indicator if the file is large and upload duration is meaningful (e.g. a progress bar inside or below the trigger, outside the component itself).
|
|
39
|
+
|
|
40
|
+
Upload complete — after a successful upload, return the trigger to State=Default (or a custom *"Replace"* state). If Uploader list=true, add the uploaded file to the list.
|
|
41
|
+
Error handling — switch to State=Error when:
|
|
42
|
+
- The file type is not accepted (e.g. a PNG was uploaded but only PDF is allowed)
|
|
43
|
+
- The file size exceeds the maximum allowed
|
|
44
|
+
- The upload request fails on the server
|
|
45
|
+
- Required file was not provided on form submission Show a specific error message below the trigger.
|
|
46
|
+
- Remove file — clicking the ✕ button in an uploader list item removes that file from the selection. If the product uses immediate upload, also cancel or delete the server-side upload. After removal, if the list is empty, keep Uploader list=true visible (empty state) or revert to Uploader list=false depending on the product logic.
|
|
47
|
+
- Replace file — for single-file contexts, clicking the trigger again while a file is already selected or uploaded should replace the previous selection. Provide a clear label change (e.g. *"Replace file"*) to signal this behaviour.
|
|
48
|
+
- File validation — validate the file type and size client-side before uploading and before switching to State=Loading. Do not start an upload for an invalid file — switch directly to State=Error with a specific message.
|
|
49
|
+
- Disabled state — State=Disable prevents opening the file dialog. Show a tooltip or nearby explanation for why the upload is unavailable.
|
|
50
|
+
- Multiple files — if the product allows multiple file selection, set multiple on the underlying <input type=*"file"*> and enable Uploader list=true to show all selected files. Define a clear max file count and enforce it client-side.
|
|
51
|
+
|
|
52
|
+
### Accessibility
|
|
53
|
+
|
|
54
|
+
The trigger must be implemented as a <button> or <label> element associated with a visually hidden <input type=*"file"*>. The <input> must not be the visible trigger.
|
|
55
|
+
|
|
56
|
+
The trigger must have aria-label if the visible label text is not descriptive enough — e.g. aria-label=*"Upload profile photo"*.
|
|
57
|
+
|
|
58
|
+
When State=Loading, set aria-busy=*"true"* on the trigger and update aria-label to reflect the in-progress state: aria-label=*"Uploading profile photo…"*.
|
|
59
|
+
|
|
60
|
+
When State=Error, the error message must be associated via aria-describedby so screen readers announce it when the trigger receives focus.
|
|
61
|
+
|
|
62
|
+
When State=Disable, the trigger must have aria-disabled=*"true"*. Keep it focusable so screen readers can discover and announce it.
|
|
63
|
+
|
|
64
|
+
The file list (when Uploader list=true) must be in a region with aria-label=*"Selected files"* or equivalent. Each file item must be announced with its name and size. The remove button for each item must have aria-label=*"Remove [file name]"* — not just aria-label=*"Remove"*.
|
|
65
|
+
|
|
66
|
+
When a file is removed from the list, announce the removal to screen readers using aria-live=*"polite"*: e.g. *"document.pdf removed"*.
|
|
67
|
+
|
|
68
|
+
When a file is successfully uploaded or added to the list, use aria-live=*"polite"* to announce: *"document.pdf added"*.
|
|
69
|
+
|
|
70
|
+
The accepted file types and size limits (shown in helper text) should be linked to the trigger via aria-describedby so screen readers surface the constraints when the trigger is focused.
|
|
71
|
+
<!-- END:xui-mcp-instructions:uploader -->
|
|
4
72
|
|
|
5
73
|
## Installation
|
|
6
74
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xsolla/xui-uploader",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.175.0",
|
|
4
4
|
"main": "./web/index.js",
|
|
5
5
|
"module": "./web/index.mjs",
|
|
6
6
|
"types": "./web/index.d.ts",
|
|
@@ -13,10 +13,10 @@
|
|
|
13
13
|
"test:coverage": "vitest run --coverage"
|
|
14
14
|
},
|
|
15
15
|
"dependencies": {
|
|
16
|
-
"@xsolla/xui-button": "0.
|
|
17
|
-
"@xsolla/xui-core": "0.
|
|
18
|
-
"@xsolla/xui-icons": "0.
|
|
19
|
-
"@xsolla/xui-primitives-core": "0.
|
|
16
|
+
"@xsolla/xui-button": "0.175.0",
|
|
17
|
+
"@xsolla/xui-core": "0.175.0",
|
|
18
|
+
"@xsolla/xui-icons": "0.175.0",
|
|
19
|
+
"@xsolla/xui-primitives-core": "0.175.0"
|
|
20
20
|
},
|
|
21
21
|
"peerDependencies": {
|
|
22
22
|
"react": ">=16.8.0"
|