@spaced-out/ui-design-system 0.1.30 → 0.1.31

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.
Files changed (51) hide show
  1. package/.cspell/custom-words.txt +5 -0
  2. package/.github/workflows/pages.yml +3 -0
  3. package/.github/workflows/publish_to_npm.yml +1 -1
  4. package/.github/workflows/pull_request_checks.yml +44 -0
  5. package/.github/workflows/pull_request_semantics_checker.yml +1 -0
  6. package/.storybook/preview-head.html +2 -2
  7. package/CHANGELOG.md +18 -0
  8. package/design-tokens/color/app-color.json +3 -0
  9. package/design-tokens/color/base-color.json +3 -0
  10. package/design-tokens/size/base-size.json +15 -0
  11. package/lib/components/Dialog/Dialog.module.css +1 -1
  12. package/lib/components/FileUpload/FileUpload.js +195 -0
  13. package/lib/components/FileUpload/FileUpload.js.flow +301 -0
  14. package/lib/components/FileUpload/FileUpload.module.css +185 -0
  15. package/lib/components/FileUpload/index.js +16 -0
  16. package/lib/components/FileUpload/index.js.flow +3 -0
  17. package/lib/components/Input/Input.js +2 -2
  18. package/lib/components/Input/Input.js.flow +11 -7
  19. package/lib/components/Input/Input.module.css +16 -5
  20. package/lib/components/LinearLoader/LinearLoader.js +10 -3
  21. package/lib/components/LinearLoader/LinearLoader.js.flow +15 -2
  22. package/lib/components/LinearLoader/LinearLoader.module.css +34 -1
  23. package/lib/components/Modal/Modal.js +3 -2
  24. package/lib/components/Modal/Modal.js.flow +10 -4
  25. package/lib/components/Modal/Modal.module.css +13 -1
  26. package/lib/components/Modal/index.js.flow +1 -0
  27. package/lib/components/Textarea/Textarea.js +2 -2
  28. package/lib/components/Textarea/Textarea.js.flow +10 -6
  29. package/lib/components/Textarea/Textarea.module.css +16 -6
  30. package/lib/components/index.js +11 -0
  31. package/lib/components/index.js.flow +1 -0
  32. package/lib/hooks/index.js +11 -0
  33. package/lib/hooks/index.js.flow +1 -0
  34. package/lib/hooks/useFileUpload/index.js +16 -0
  35. package/lib/hooks/useFileUpload/index.js.flow +3 -0
  36. package/lib/hooks/useFileUpload/useFileUpload.js +279 -0
  37. package/lib/hooks/useFileUpload/useFileUpload.js.flow +304 -0
  38. package/lib/styles/index.css +12 -0
  39. package/lib/styles/index.js +15 -3
  40. package/lib/styles/index.js.flow +12 -0
  41. package/lib/styles/variables/_color.css +2 -0
  42. package/lib/styles/variables/_color.js +3 -1
  43. package/lib/styles/variables/_color.js.flow +2 -0
  44. package/lib/styles/variables/_size.css +10 -0
  45. package/lib/styles/variables/_size.js +11 -1
  46. package/lib/styles/variables/_size.js.flow +10 -0
  47. package/lib/utils/helpers/helpers.js +39 -2
  48. package/lib/utils/helpers/helpers.js.flow +37 -0
  49. package/lib/utils/tokens/tokens.js +1 -2
  50. package/lib/utils/tokens/tokens.js.flow +1 -3
  51. package/package.json +3 -2
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.uuid = exports.range = void 0;
6
+ exports.uuid = exports.range = exports.convertFileSize = void 0;
7
7
 
8
8
  const uuid = () => {
9
9
  let dt = new Date().getTime();
@@ -20,4 +20,41 @@ const range = (start, end) => {
20
20
  length
21
21
  }, (_, i) => start + i);
22
22
  };
23
- exports.range = range;
23
+ exports.range = range;
24
+ const convertFileSize = fileSize => {
25
+ let sizeInBytes = fileSize;
26
+ // Check if the file size is less than 1024
27
+ if (sizeInBytes < 0) {
28
+ sizeInBytes = Math.abs(sizeInBytes);
29
+ }
30
+
31
+ // Handle the case where the file size is 0 or negative
32
+ if (sizeInBytes <= 0) {
33
+ return '0 B';
34
+ }
35
+
36
+ // Check if the file size is less than 1024
37
+ if (sizeInBytes < 1024) {
38
+ // Return the file size in bytes
39
+ return sizeInBytes.toString() + ' B';
40
+ }
41
+
42
+ // Check if the file size is less than 1048576
43
+ else if (sizeInBytes < 1048576) {
44
+ // Return the file size in KB
45
+ return (sizeInBytes / 1024).toFixed(1) + ' KB';
46
+ }
47
+
48
+ // Check if the file size is less than 1073741824
49
+ else if (sizeInBytes < 1073741824) {
50
+ // Return the file size in MB
51
+ return (sizeInBytes / 1048576).toFixed(1) + ' MB';
52
+ }
53
+
54
+ // Otherwise, the file size is greater than or equal to 1073741824
55
+ else {
56
+ // Return the file size in GB
57
+ return (sizeInBytes / 1073741824).toFixed(1) + ' GB';
58
+ }
59
+ };
60
+ exports.convertFileSize = convertFileSize;
@@ -14,3 +14,40 @@ export const range = (start: number, end: number): Array<number> => {
14
14
  const length = end - start + 1;
15
15
  return Array.from({length}, (_, i) => start + i);
16
16
  };
17
+
18
+ export const convertFileSize = (fileSize: number): string => {
19
+ let sizeInBytes = fileSize;
20
+ // Check if the file size is less than 1024
21
+ if (sizeInBytes < 0) {
22
+ sizeInBytes = Math.abs(sizeInBytes);
23
+ }
24
+
25
+ // Handle the case where the file size is 0 or negative
26
+ if (sizeInBytes <= 0) {
27
+ return '0 B';
28
+ }
29
+
30
+ // Check if the file size is less than 1024
31
+ if (sizeInBytes < 1024) {
32
+ // Return the file size in bytes
33
+ return sizeInBytes.toString() + ' B';
34
+ }
35
+
36
+ // Check if the file size is less than 1048576
37
+ else if (sizeInBytes < 1048576) {
38
+ // Return the file size in KB
39
+ return (sizeInBytes / 1024).toFixed(1) + ' KB';
40
+ }
41
+
42
+ // Check if the file size is less than 1073741824
43
+ else if (sizeInBytes < 1073741824) {
44
+ // Return the file size in MB
45
+ return (sizeInBytes / 1048576).toFixed(1) + ' MB';
46
+ }
47
+
48
+ // Otherwise, the file size is greater than or equal to 1073741824
49
+ else {
50
+ // Return the file size in GB
51
+ return (sizeInBytes / 1073741824).toFixed(1) + ' GB';
52
+ }
53
+ };
@@ -152,8 +152,7 @@ const getRandomDataVariation = () => {
152
152
  return dataVariations[randomIndex];
153
153
  };
154
154
  exports.getRandomDataVariation = getRandomDataVariation;
155
- const handleDownload = (path, fileName) => {
156
- const filePath = `../../../${path}`;
155
+ const handleDownload = (filePath, fileName) => {
157
156
  fetch(filePath).then(response => response.blob()).then(blob => {
158
157
  const url = URL.createObjectURL(blob);
159
158
  const link = document.createElement('a');
@@ -227,9 +227,7 @@ export const getRandomDataVariation = (): DataVariation => {
227
227
  return dataVariations[randomIndex];
228
228
  };
229
229
 
230
- export const handleDownload = (path: string, fileName: string) => {
231
- const filePath = `../../../${path}`;
232
-
230
+ export const handleDownload = (filePath: string, fileName: string) => {
233
231
  fetch(filePath)
234
232
  .then((response) => response.blob())
235
233
  .then((blob) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@spaced-out/ui-design-system",
3
- "version": "0.1.30",
3
+ "version": "0.1.31",
4
4
  "main": "index.js",
5
5
  "description": "Sense UI components library",
6
6
  "author": {
@@ -46,7 +46,8 @@
46
46
  "dependencies": {
47
47
  "@floating-ui/react": "^0.24.0",
48
48
  "date-fns": "^2.29.3",
49
- "lodash": "^4.17.21"
49
+ "lodash": "^4.17.21",
50
+ "react-dropzone": "^14.2.3"
50
51
  },
51
52
  "devDependencies": {
52
53
  "@babel/cli": "^7.18.10",