@uxf/ui 11.45.1 → 11.46.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@uxf/ui",
3
- "version": "11.45.1",
3
+ "version": "11.46.0",
4
4
  "description": "",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -23,10 +23,10 @@
23
23
  "dependencies": {
24
24
  "@floating-ui/react": "0.26.28",
25
25
  "@headlessui/react": "1.7.19",
26
- "@uxf/core": "11.45.0",
27
- "@uxf/core-react": "11.45.0",
26
+ "@uxf/core": "11.46.0",
27
+ "@uxf/core-react": "11.46.0",
28
28
  "@uxf/datepicker": "11.45.0",
29
- "@uxf/styles": "11.45.0",
29
+ "@uxf/styles": "11.46.0",
30
30
  "color2k": "2.0.3",
31
31
  "dayjs": "1.11.13",
32
32
  "jump.js": "1.0.2",
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const get_file_icon_1 = require("./get-file-icon");
4
+ describe("getIconNameFromFileExtension", () => {
5
+ it("should return 'imageFile' for image extensions", () => {
6
+ expect((0, get_file_icon_1.getIconNameFromFileExtension)("jpg")).toBe("imageFile");
7
+ expect((0, get_file_icon_1.getIconNameFromFileExtension)("jpeg")).toBe("imageFile");
8
+ expect((0, get_file_icon_1.getIconNameFromFileExtension)("png")).toBe("imageFile");
9
+ expect((0, get_file_icon_1.getIconNameFromFileExtension)("gif")).toBe("imageFile");
10
+ });
11
+ it("should return 'videoFile' for video extensions", () => {
12
+ expect((0, get_file_icon_1.getIconNameFromFileExtension)("mp4")).toBe("videoFile");
13
+ expect((0, get_file_icon_1.getIconNameFromFileExtension)("avi")).toBe("videoFile");
14
+ expect((0, get_file_icon_1.getIconNameFromFileExtension)("mov")).toBe("videoFile");
15
+ });
16
+ it("should return 'file' for unknown extensions", () => {
17
+ expect((0, get_file_icon_1.getIconNameFromFileExtension)("pdf")).toBe("file");
18
+ expect((0, get_file_icon_1.getIconNameFromFileExtension)("docx")).toBe("file");
19
+ expect((0, get_file_icon_1.getIconNameFromFileExtension)("txt")).toBe("file");
20
+ expect((0, get_file_icon_1.getIconNameFromFileExtension)("exe")).toBe("file");
21
+ });
22
+ });
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,44 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const get_file_url_1 = require("./get-file-url");
4
+ describe("getFileUrl", () => {
5
+ it("should generate a correct file URL with default namespace", () => {
6
+ const domain = "https://example.com";
7
+ const file = {
8
+ id: 1,
9
+ name: "test",
10
+ namespace: null,
11
+ uuid: "123-456-789",
12
+ extension: "jpg",
13
+ type: "image/jpeg",
14
+ };
15
+ const result = (0, get_file_url_1.getFileUrl)(domain, file);
16
+ expect(result).toBe("https://example.com/upload/default/1/2/123-456-789.jpg");
17
+ });
18
+ it("should generate a correct file URL with specified namespace", () => {
19
+ const domain = "https://example.com";
20
+ const file = {
21
+ id: 2,
22
+ name: "anotherTest",
23
+ namespace: "customNamespace",
24
+ uuid: "123-456-789",
25
+ extension: "png",
26
+ type: "image/png",
27
+ };
28
+ const result = (0, get_file_url_1.getFileUrl)(domain, file);
29
+ expect(result).toBe("https://example.com/upload/customNamespace/1/2/123-456-789.png");
30
+ });
31
+ it("should generate a correct file URL with default namespace and different extension", () => {
32
+ const domain = "https://example.com";
33
+ const file = {
34
+ id: 3,
35
+ name: "document",
36
+ namespace: null,
37
+ uuid: "111-222-333",
38
+ extension: "pdf",
39
+ type: "application/pdf",
40
+ };
41
+ const result = (0, get_file_url_1.getFileUrl)(domain, file);
42
+ expect(result).toBe("https://example.com/upload/default/1/1/111-222-333.pdf");
43
+ });
44
+ });
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,88 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const get_dropzone_state_1 = require("./get-dropzone-state");
4
+ describe("getDropzoneState", () => {
5
+ it("should return OK state when there are no files", () => {
6
+ const files = [];
7
+ const result = (0, get_dropzone_state_1.getDropzoneState)(files);
8
+ expect(result).toEqual({ status: "OK" });
9
+ });
10
+ it("should return UPLOADING state when there are files with negative IDs", () => {
11
+ const files = [
12
+ {
13
+ id: -1,
14
+ name: "file1.txt",
15
+ uuid: "uuid1",
16
+ extension: "txt",
17
+ error: null,
18
+ progress: null,
19
+ namespace: null,
20
+ },
21
+ { id: 1, name: "file2.txt", uuid: "uuid2", extension: "txt", error: null, progress: null, namespace: null },
22
+ ];
23
+ const result = (0, get_dropzone_state_1.getDropzoneState)(files);
24
+ expect(result).toEqual({ status: "UPLOADING" });
25
+ });
26
+ it("should return ERROR state with error messages when files have errors", () => {
27
+ const files = [
28
+ {
29
+ id: 1,
30
+ name: "file1.txt",
31
+ uuid: "uuid1",
32
+ extension: "txt",
33
+ error: "File too large",
34
+ progress: null,
35
+ namespace: null,
36
+ },
37
+ {
38
+ id: 2,
39
+ name: "file2.txt",
40
+ uuid: "uuid2",
41
+ extension: "txt",
42
+ error: "Unsupported format",
43
+ progress: null,
44
+ namespace: null,
45
+ },
46
+ ];
47
+ const result = (0, get_dropzone_state_1.getDropzoneState)(files);
48
+ expect(result).toEqual({
49
+ errorMessage: "File too large; Unsupported format",
50
+ status: "ERROR",
51
+ });
52
+ });
53
+ it("should return OK state when files are uploaded successfully", () => {
54
+ const files = [
55
+ { id: 1, name: "file1.txt", uuid: "uuid1", extension: "txt", error: null, progress: null, namespace: null },
56
+ { id: 2, name: "file2.txt", uuid: "uuid2", extension: "txt", error: null, progress: null, namespace: null },
57
+ ];
58
+ const result = (0, get_dropzone_state_1.getDropzoneState)(files);
59
+ expect(result).toEqual({ status: "OK" });
60
+ });
61
+ it("should return OK state when some files are uploading but no errors", () => {
62
+ const files = [
63
+ { id: 1, name: "file1.txt", uuid: "uuid1", extension: "txt", error: null, progress: 50, namespace: null },
64
+ { id: 2, name: "file2.txt", uuid: "uuid2", extension: "txt", error: null, progress: 75, namespace: null },
65
+ ];
66
+ const result = (0, get_dropzone_state_1.getDropzoneState)(files);
67
+ expect(result).toEqual({ status: "OK" });
68
+ });
69
+ it("should return ERROR state when there is a file with an error and uploading files", () => {
70
+ const files = [
71
+ {
72
+ id: -1,
73
+ name: "file1.txt",
74
+ uuid: "uuid1",
75
+ extension: "txt",
76
+ error: "File too large",
77
+ progress: null,
78
+ namespace: null,
79
+ },
80
+ { id: -2, name: "file2.txt", uuid: "uuid2", extension: "txt", error: null, progress: 50, namespace: null },
81
+ ];
82
+ const result = (0, get_dropzone_state_1.getDropzoneState)(files);
83
+ expect(result).toEqual({
84
+ errorMessage: "File too large",
85
+ status: "ERROR",
86
+ });
87
+ });
88
+ });
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,34 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const upload_file_mock_1 = require("./upload-file.mock");
4
+ describe("uploadFile", () => {
5
+ const mockFile = new File(["file content"], "test.txt", { type: "text/plain" });
6
+ it("should resolve with a FileResponse object after upload", async () => {
7
+ const mockOnUploadProgress = jest.fn();
8
+ const mockAbortController = new AbortController();
9
+ const response = await (0, upload_file_mock_1.uploadFile)(mockFile, {
10
+ onUploadProgress: mockOnUploadProgress,
11
+ abortController: mockAbortController,
12
+ });
13
+ expect(response).toEqual({
14
+ id: expect.any(Number),
15
+ uuid: expect.any(String),
16
+ name: "test.txt",
17
+ namespace: null,
18
+ extension: "txt",
19
+ });
20
+ });
21
+ it("should call onUploadProgress with correct values", async () => {
22
+ const mockOnUploadProgress = jest.fn();
23
+ const mockAbortController = new AbortController();
24
+ await (0, upload_file_mock_1.uploadFile)(mockFile, {
25
+ onUploadProgress: mockOnUploadProgress,
26
+ abortController: mockAbortController,
27
+ });
28
+ expect(mockOnUploadProgress).toHaveBeenCalledWith(expect.objectContaining({
29
+ lengthComputable: true,
30
+ loaded: expect.any(Number),
31
+ total: mockFile.size,
32
+ }));
33
+ });
34
+ });