@onewelcome/react-lib-components 1.6.0 → 1.7.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.
Files changed (34) hide show
  1. package/README.md +4 -4
  2. package/dist/Form/FileUpload/FileItem/FileItem.d.ts +17 -0
  3. package/dist/Form/FileUpload/FileUpload.d.ts +26 -0
  4. package/dist/Icon/Icon.d.ts +4 -1
  5. package/dist/ProgressBar/ProgressBar.d.ts +2 -1
  6. package/dist/_BaseStyling_/BaseStyling.d.ts +3 -0
  7. package/dist/hooks/useUploadFile.d.ts +22 -0
  8. package/dist/react-lib-components.cjs.development.js +60 -53
  9. package/dist/react-lib-components.cjs.development.js.map +1 -1
  10. package/dist/react-lib-components.cjs.production.min.js +1 -1
  11. package/dist/react-lib-components.cjs.production.min.js.map +1 -1
  12. package/dist/react-lib-components.esm.js +60 -53
  13. package/dist/react-lib-components.esm.js.map +1 -1
  14. package/dist/util/helper.d.ts +5 -0
  15. package/package.json +24 -21
  16. package/src/Form/FileUpload/FileItem/FileItem.modules.scss +75 -0
  17. package/src/Form/FileUpload/FileItem/FileItem.test.tsx +103 -0
  18. package/src/Form/FileUpload/FileItem/FileItem.tsx +141 -0
  19. package/src/Form/FileUpload/FileUpload.module.scss +106 -0
  20. package/src/Form/FileUpload/FileUpload.test.tsx +374 -0
  21. package/src/Form/FileUpload/FileUpload.tsx +251 -0
  22. package/src/Form/Input/Input.module.scss +0 -1
  23. package/src/Icon/Icon.module.scss +12 -0
  24. package/src/Icon/Icon.tsx +4 -1
  25. package/src/ProgressBar/ProgressBar.module.scss +11 -9
  26. package/src/ProgressBar/ProgressBar.test.tsx +21 -0
  27. package/src/ProgressBar/ProgressBar.tsx +7 -2
  28. package/src/Typography/Typography.module.scss +2 -2
  29. package/src/_BaseStyling_/BaseStyling.tsx +9 -3
  30. package/src/hooks/useUploadFile.test.ts +211 -0
  31. package/src/hooks/useUploadFile.tsx +136 -0
  32. package/src/mixins.module.scss +24 -5
  33. package/src/util/helper.test.tsx +156 -1
  34. package/src/util/helper.tsx +33 -0
@@ -143,3 +143,36 @@ export const throttle = (fn: (...args: unknown[]) => unknown, delay: number) =>
143
143
  }
144
144
  };
145
145
  };
146
+
147
+ export const isEqual = (x: any, y: any): boolean => {
148
+ const typesCoincide = x && y && typeof x === "object" && typeof y === "object";
149
+ return typesCoincide
150
+ ? Object.keys(x).length === Object.keys(y).length &&
151
+ Object.keys(x).every(key => isEqual(x[key], y[key]))
152
+ : x === y;
153
+ };
154
+
155
+ export const areArraysDifferent = (
156
+ arr1: Record<string, any>[],
157
+ arr2: Record<string, any>[],
158
+ key: string
159
+ ) => {
160
+ if (arr1.length !== arr2.length) {
161
+ return true;
162
+ } else {
163
+ const firstFilteredArray = arr1.filter(arr1Item =>
164
+ arr2.some((arr2Item: { [x: string]: any }) => !isEqual(arr1Item[key], arr2Item[key]))
165
+ );
166
+ const secondFilteredArray = arr2.filter(arr2Item =>
167
+ arr1.some((arr1Item: { [x: string]: any }) => !isEqual(arr1Item[key], arr2Item[key]))
168
+ );
169
+
170
+ return !!firstFilteredArray.length || !!secondFilteredArray.length;
171
+ }
172
+ };
173
+
174
+ export const getValueByPath = (obj: { [key: string]: any }, path: string): any => {
175
+ return path.split(".").reduce((res, prop) => {
176
+ return res[prop];
177
+ }, obj);
178
+ };