@spaced-out/ui-design-system 0.1.29 → 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 (55) 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/main.js +1 -1
  7. package/.storybook/preview-head.html +8 -3
  8. package/CHANGELOG.md +33 -0
  9. package/design-tokens/color/app-color.json +3 -0
  10. package/design-tokens/color/base-color.json +3 -0
  11. package/design-tokens/index.js +5 -3
  12. package/design-tokens/size/base-size.json +15 -0
  13. package/lib/components/Dialog/Dialog.module.css +1 -1
  14. package/lib/components/FileUpload/FileUpload.js +195 -0
  15. package/lib/components/FileUpload/FileUpload.js.flow +301 -0
  16. package/lib/components/FileUpload/FileUpload.module.css +185 -0
  17. package/lib/components/FileUpload/index.js +16 -0
  18. package/lib/components/FileUpload/index.js.flow +3 -0
  19. package/lib/components/Input/Input.js +2 -2
  20. package/lib/components/Input/Input.js.flow +11 -7
  21. package/lib/components/Input/Input.module.css +16 -5
  22. package/lib/components/LinearLoader/LinearLoader.js +10 -3
  23. package/lib/components/LinearLoader/LinearLoader.js.flow +15 -2
  24. package/lib/components/LinearLoader/LinearLoader.module.css +34 -1
  25. package/lib/components/Modal/Modal.js +3 -2
  26. package/lib/components/Modal/Modal.js.flow +10 -4
  27. package/lib/components/Modal/Modal.module.css +13 -1
  28. package/lib/components/Modal/index.js.flow +1 -0
  29. package/lib/components/Textarea/Textarea.js +2 -2
  30. package/lib/components/Textarea/Textarea.js.flow +10 -6
  31. package/lib/components/Textarea/Textarea.module.css +19 -5
  32. package/lib/components/index.js +11 -0
  33. package/lib/components/index.js.flow +1 -0
  34. package/lib/hooks/index.js +11 -0
  35. package/lib/hooks/index.js.flow +1 -0
  36. package/lib/hooks/useFileUpload/index.js +16 -0
  37. package/lib/hooks/useFileUpload/index.js.flow +3 -0
  38. package/lib/hooks/useFileUpload/useFileUpload.js +279 -0
  39. package/lib/hooks/useFileUpload/useFileUpload.js.flow +304 -0
  40. package/lib/styles/index.css +12 -0
  41. package/lib/styles/index.js +15 -3
  42. package/lib/styles/index.js.flow +12 -0
  43. package/lib/styles/variables/_color.css +2 -0
  44. package/lib/styles/variables/_color.js +3 -1
  45. package/lib/styles/variables/_color.js.flow +2 -0
  46. package/lib/styles/variables/_size.css +10 -0
  47. package/lib/styles/variables/_size.js +11 -1
  48. package/lib/styles/variables/_size.js.flow +10 -0
  49. package/lib/utils/helpers/helpers.js +39 -2
  50. package/lib/utils/helpers/helpers.js.flow +37 -0
  51. package/lib/utils/makeClassNameComponent/makeClassNameComponent.js.flow +0 -1
  52. package/lib/utils/tokens/tokens.js +15 -2
  53. package/lib/utils/tokens/tokens.js.flow +16 -0
  54. package/package.json +3 -2
  55. /package/design-tokens/motion/{app.motion.json → app-motion.json} +0 -0
@@ -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
+ };
@@ -1,5 +1,4 @@
1
1
  // @flow strict
2
-
3
2
  import * as React from 'react';
4
3
 
5
4
  import classify from '../classify';
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.getSortedTokenNames = exports.getRandomDataVariation = exports.filterTableDataBySearchText = exports.dataVariations = void 0;
6
+ exports.handleDownload = exports.getSortedTokenNames = exports.getRandomDataVariation = exports.filterTableDataBySearchText = exports.dataVariations = void 0;
7
7
 
8
8
  const dataVariations = [{
9
9
  title: 'The Great HTML Escape 🎩🌐',
@@ -151,4 +151,17 @@ const getRandomDataVariation = () => {
151
151
  const randomIndex = Math.floor(Math.random() * dataVariations.length);
152
152
  return dataVariations[randomIndex];
153
153
  };
154
- exports.getRandomDataVariation = getRandomDataVariation;
154
+ exports.getRandomDataVariation = getRandomDataVariation;
155
+ const handleDownload = (filePath, fileName) => {
156
+ fetch(filePath).then(response => response.blob()).then(blob => {
157
+ const url = URL.createObjectURL(blob);
158
+ const link = document.createElement('a');
159
+ link.href = url;
160
+ link.download = fileName;
161
+ link.click();
162
+ URL.revokeObjectURL(url);
163
+ }).catch(error => {
164
+ console.error('Error downloading the JSON file:', error);
165
+ });
166
+ };
167
+ exports.handleDownload = handleDownload;
@@ -226,3 +226,19 @@ export const getRandomDataVariation = (): DataVariation => {
226
226
  const randomIndex: number = Math.floor(Math.random() * dataVariations.length);
227
227
  return dataVariations[randomIndex];
228
228
  };
229
+
230
+ export const handleDownload = (filePath: string, fileName: string) => {
231
+ fetch(filePath)
232
+ .then((response) => response.blob())
233
+ .then((blob) => {
234
+ const url = URL.createObjectURL(blob);
235
+ const link = document.createElement('a');
236
+ link.href = url;
237
+ link.download = fileName;
238
+ link.click();
239
+ URL.revokeObjectURL(url);
240
+ })
241
+ .catch((error) => {
242
+ console.error('Error downloading the JSON file:', error);
243
+ });
244
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@spaced-out/ui-design-system",
3
- "version": "0.1.29",
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",