@onewelcome/react-lib-components 8.3.0 → 8.4.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 (156) hide show
  1. package/dist/cjs/DataGrid/DataGridBody/DataGridCell/DataGridCell.module.scss.cjs.js +1 -1
  2. package/dist/cjs/DataGrid/DataGridBody/DataGridRow/DataGridRow.module.scss.cjs.js +1 -1
  3. package/dist/cjs/DataGrid/DataGridFilters/DataGridFilters.interfaces.cjs.js.map +1 -1
  4. package/dist/cjs/DataGrid/DataGridFilters/DataGridSearchbar.cjs.js.map +1 -1
  5. package/dist/cjs/DataGrid/DataGridFilters/FilterKeyMapper.cjs.js +2 -0
  6. package/dist/cjs/DataGrid/DataGridFilters/FilterKeyMapper.cjs.js.map +1 -0
  7. package/dist/cjs/DataGrid/DataGridHeader/DataGridHeader.module.scss.cjs.js +1 -1
  8. package/dist/cjs/Form/FileUpload/FileItem/FileItem.cjs.js +1 -1
  9. package/dist/cjs/Form/FileUpload/FileItem/FileItem.cjs.js.map +1 -1
  10. package/dist/cjs/Form/FileUpload/FileItem/FileItem.module.scss.cjs.js +1 -1
  11. package/dist/cjs/Form/FileUpload/FileUpload.cjs.js +1 -1
  12. package/dist/cjs/Form/FileUpload/FileUpload.cjs.js.map +1 -1
  13. package/dist/cjs/Form/FileUpload/FileUpload.module.scss.cjs.js +1 -1
  14. package/dist/cjs/Icon/Icon.cjs.js +1 -1
  15. package/dist/cjs/Icon/Icon.cjs.js.map +1 -1
  16. package/dist/cjs/Icon/Icon.module.scss.cjs.js +1 -1
  17. package/dist/cjs/Notifications/BaseModal/BaseModal.cjs.js +1 -1
  18. package/dist/cjs/Notifications/BaseModal/BaseModal.cjs.js.map +1 -1
  19. package/dist/cjs/Notifications/BaseModal/BaseModalHeader/BaseModalHeader.cjs.js +1 -1
  20. package/dist/cjs/Notifications/BaseModal/BaseModalHeader/BaseModalHeader.cjs.js.map +1 -1
  21. package/dist/cjs/Notifications/SideSheet/SideSheet.cjs.js +2 -0
  22. package/dist/cjs/Notifications/SideSheet/SideSheet.cjs.js.map +1 -0
  23. package/dist/cjs/Notifications/SideSheet/SideSheet.module.scss.cjs.js +2 -0
  24. package/dist/cjs/Notifications/SideSheet/SideSheet.module.scss.cjs.js.map +1 -0
  25. package/dist/cjs/Notifications/SideSheet/SideSheetContent/SideSheetContent.cjs.js +2 -0
  26. package/dist/cjs/Notifications/SideSheet/SideSheetContent/SideSheetContent.cjs.js.map +1 -0
  27. package/dist/cjs/Notifications/SideSheet/SideSheetContent/SideSheetContent.module.scss.cjs.js +2 -0
  28. package/dist/cjs/Notifications/SideSheet/SideSheetContent/SideSheetContent.module.scss.cjs.js.map +1 -0
  29. package/dist/cjs/Notifications/SideSheet/SideSheetHeader/SideSheetHeader.cjs.js +2 -0
  30. package/dist/cjs/Notifications/SideSheet/SideSheetHeader/SideSheetHeader.cjs.js.map +1 -0
  31. package/dist/cjs/Notifications/SideSheet/SideSheetHeader/SideSheetHeader.module.scss.cjs.js +2 -0
  32. package/dist/cjs/Notifications/SideSheet/SideSheetHeader/SideSheetHeader.module.scss.cjs.js.map +1 -0
  33. package/dist/cjs/Notifications/SlideInModal/SlideInModal.cjs.js.map +1 -1
  34. package/dist/cjs/_BaseStyling_/BaseStyling.cjs.js +1 -1
  35. package/dist/cjs/_BaseStyling_/BaseStyling.cjs.js.map +1 -1
  36. package/dist/cjs/src/components/DataGrid/DataGridFilters/DataGridFilters.interfaces.d.ts +4 -0
  37. package/dist/cjs/src/components/DataGrid/DataGridFilters/DataGridSearchbar.d.ts +1 -1
  38. package/dist/cjs/src/components/DataGrid/DataGridFilters/FilterKeyMapper.d.ts +14 -0
  39. package/dist/cjs/src/components/DataGrid/DataGridFilters/FilterKeyMapper.test.d.ts +1 -0
  40. package/dist/cjs/src/components/DataGrid/testUtils.d.ts +3 -1
  41. package/dist/cjs/src/components/Form/Select/MultiSelect/MultiSelect.test.d.ts +1 -2
  42. package/dist/cjs/src/components/Form/Select/SingleSelect/Select.test.d.ts +1 -2
  43. package/dist/cjs/src/components/Icon/Icon.d.ts +2 -1
  44. package/dist/cjs/src/components/Notifications/BaseModal/BaseModal.d.ts +1 -0
  45. package/dist/cjs/src/components/Notifications/BaseModal/BaseModalHeader/BaseModalHeader.d.ts +1 -0
  46. package/dist/cjs/src/components/Notifications/SideSheet/SideSheet.d.ts +10 -0
  47. package/dist/cjs/src/components/Notifications/SideSheet/SideSheet.test.d.ts +1 -0
  48. package/dist/cjs/src/components/Notifications/SideSheet/SideSheetActions/SideSheetActions.d.ts +2 -0
  49. package/dist/cjs/src/components/Notifications/SideSheet/SideSheetContent/SideSheetContent.d.ts +4 -0
  50. package/dist/cjs/src/components/Notifications/SideSheet/SideSheetHeader/SideSheetHeader.d.ts +4 -0
  51. package/dist/cjs/src/components/Typography/Typography.d.ts +1 -1
  52. package/dist/cjs/src/components/_BaseStyling_/BaseStyling.d.ts +2 -0
  53. package/dist/cjs/src/hooks/useUploadFile.cjs.js +2 -0
  54. package/dist/cjs/src/hooks/useUploadFile.cjs.js.map +1 -0
  55. package/dist/cjs/src/hooks/useUploadFile.d.ts +10 -4
  56. package/dist/cjs/src/index.cjs.js +1 -1
  57. package/dist/cjs/src/index.d.ts +17 -2
  58. package/dist/cjs/src/util/helper.cjs.js +1 -1
  59. package/dist/cjs/src/util/helper.cjs.js.map +1 -1
  60. package/dist/cjs/src/util/helper.d.ts +0 -3
  61. package/dist/esm/DataGrid/DataGridBody/DataGridCell/DataGridCell.module.scss.esm.js +1 -1
  62. package/dist/esm/DataGrid/DataGridBody/DataGridRow/DataGridRow.module.scss.esm.js +1 -1
  63. package/dist/esm/DataGrid/DataGridFilters/DataGridFilters.interfaces.esm.js.map +1 -1
  64. package/dist/esm/DataGrid/DataGridFilters/DataGridSearchbar.esm.js.map +1 -1
  65. package/dist/esm/DataGrid/DataGridFilters/FilterKeyMapper.esm.js +46 -0
  66. package/dist/esm/DataGrid/DataGridFilters/FilterKeyMapper.esm.js.map +1 -0
  67. package/dist/esm/DataGrid/DataGridHeader/DataGridHeader.module.scss.esm.js +2 -2
  68. package/dist/esm/Form/FileUpload/FileItem/FileItem.esm.js +4 -3
  69. package/dist/esm/Form/FileUpload/FileItem/FileItem.esm.js.map +1 -1
  70. package/dist/esm/Form/FileUpload/FileItem/FileItem.module.scss.esm.js +1 -1
  71. package/dist/esm/Form/FileUpload/FileUpload.esm.js +8 -7
  72. package/dist/esm/Form/FileUpload/FileUpload.esm.js.map +1 -1
  73. package/dist/esm/Form/FileUpload/FileUpload.module.scss.esm.js +2 -2
  74. package/dist/esm/Icon/Icon.esm.js +1 -0
  75. package/dist/esm/Icon/Icon.esm.js.map +1 -1
  76. package/dist/esm/Icon/Icon.module.scss.esm.js +2 -2
  77. package/dist/esm/Notifications/BaseModal/BaseModal.esm.js +2 -2
  78. package/dist/esm/Notifications/BaseModal/BaseModal.esm.js.map +1 -1
  79. package/dist/esm/Notifications/BaseModal/BaseModalHeader/BaseModalHeader.esm.js +4 -3
  80. package/dist/esm/Notifications/BaseModal/BaseModalHeader/BaseModalHeader.esm.js.map +1 -1
  81. package/dist/esm/Notifications/SideSheet/SideSheet.esm.js +59 -0
  82. package/dist/esm/Notifications/SideSheet/SideSheet.esm.js.map +1 -0
  83. package/dist/esm/Notifications/SideSheet/SideSheet.module.scss.esm.js +8 -0
  84. package/dist/esm/Notifications/SideSheet/SideSheet.module.scss.esm.js.map +1 -0
  85. package/dist/esm/Notifications/SideSheet/SideSheetContent/SideSheetContent.esm.js +23 -0
  86. package/dist/esm/Notifications/SideSheet/SideSheetContent/SideSheetContent.esm.js.map +1 -0
  87. package/dist/esm/Notifications/SideSheet/SideSheetContent/SideSheetContent.module.scss.esm.js +8 -0
  88. package/dist/esm/Notifications/SideSheet/SideSheetContent/SideSheetContent.module.scss.esm.js.map +1 -0
  89. package/dist/esm/Notifications/SideSheet/SideSheetHeader/SideSheetHeader.esm.js +23 -0
  90. package/dist/esm/Notifications/SideSheet/SideSheetHeader/SideSheetHeader.esm.js.map +1 -0
  91. package/dist/esm/Notifications/SideSheet/SideSheetHeader/SideSheetHeader.module.scss.esm.js +8 -0
  92. package/dist/esm/Notifications/SideSheet/SideSheetHeader/SideSheetHeader.module.scss.esm.js.map +1 -0
  93. package/dist/esm/Notifications/SlideInModal/SlideInModal.esm.js +3 -0
  94. package/dist/esm/Notifications/SlideInModal/SlideInModal.esm.js.map +1 -1
  95. package/dist/esm/_BaseStyling_/BaseStyling.esm.js +2 -0
  96. package/dist/esm/_BaseStyling_/BaseStyling.esm.js.map +1 -1
  97. package/dist/esm/src/components/DataGrid/DataGridFilters/DataGridFilters.interfaces.d.ts +4 -0
  98. package/dist/esm/src/components/DataGrid/DataGridFilters/DataGridSearchbar.d.ts +1 -1
  99. package/dist/esm/src/components/DataGrid/DataGridFilters/FilterKeyMapper.d.ts +14 -0
  100. package/dist/esm/src/components/DataGrid/DataGridFilters/FilterKeyMapper.test.d.ts +1 -0
  101. package/dist/esm/src/components/DataGrid/testUtils.d.ts +3 -1
  102. package/dist/esm/src/components/Form/Select/MultiSelect/MultiSelect.test.d.ts +1 -2
  103. package/dist/esm/src/components/Form/Select/SingleSelect/Select.test.d.ts +1 -2
  104. package/dist/esm/src/components/Icon/Icon.d.ts +2 -1
  105. package/dist/esm/src/components/Notifications/BaseModal/BaseModal.d.ts +1 -0
  106. package/dist/esm/src/components/Notifications/BaseModal/BaseModalHeader/BaseModalHeader.d.ts +1 -0
  107. package/dist/esm/src/components/Notifications/SideSheet/SideSheet.d.ts +10 -0
  108. package/dist/esm/src/components/Notifications/SideSheet/SideSheet.test.d.ts +1 -0
  109. package/dist/esm/src/components/Notifications/SideSheet/SideSheetActions/SideSheetActions.d.ts +2 -0
  110. package/dist/esm/src/components/Notifications/SideSheet/SideSheetContent/SideSheetContent.d.ts +4 -0
  111. package/dist/esm/src/components/Notifications/SideSheet/SideSheetHeader/SideSheetHeader.d.ts +4 -0
  112. package/dist/esm/src/components/Typography/Typography.d.ts +1 -1
  113. package/dist/esm/src/components/_BaseStyling_/BaseStyling.d.ts +2 -0
  114. package/dist/esm/src/hooks/useUploadFile.d.ts +10 -4
  115. package/dist/esm/src/hooks/useUploadFile.esm.js +101 -0
  116. package/dist/esm/src/hooks/useUploadFile.esm.js.map +1 -0
  117. package/dist/esm/src/index.d.ts +17 -2
  118. package/dist/esm/src/index.esm.js +7 -1
  119. package/dist/esm/src/index.esm.js.map +1 -1
  120. package/dist/esm/src/util/helper.d.ts +0 -3
  121. package/dist/esm/src/util/helper.esm.js +10 -1
  122. package/dist/esm/src/util/helper.esm.js.map +1 -1
  123. package/package.json +22 -22
  124. package/src/components/DataGrid/DataGridBody/DataGridCell/DataGridCell.module.scss +1 -1
  125. package/src/components/DataGrid/DataGridBody/DataGridRow/DataGridRow.module.scss +8 -24
  126. package/src/components/DataGrid/DataGridFilters/DataGridFilters.interfaces.ts +5 -0
  127. package/src/components/DataGrid/DataGridFilters/DataGridSearchbar.tsx +5 -2
  128. package/src/components/DataGrid/DataGridFilters/FilterKeyMapper.ts +48 -0
  129. package/src/components/DataGrid/DataGridHeader/DataGridHeader.module.scss +9 -8
  130. package/src/components/DataGrid/dataGridMixins.module.scss +33 -0
  131. package/src/components/DataGrid/testUtils.ts +39 -32
  132. package/src/components/Form/FileUpload/FileItem/FileItem.module.scss +6 -3
  133. package/src/components/Form/FileUpload/FileItem/FileItem.tsx +3 -1
  134. package/src/components/Form/FileUpload/FileUpload.module.scss +12 -5
  135. package/src/components/Form/FileUpload/FileUpload.tsx +10 -7
  136. package/src/components/Icon/Icon.module.scss +5 -0
  137. package/src/components/Icon/Icon.tsx +2 -1
  138. package/src/components/Notifications/BaseModal/BaseModal.tsx +10 -6
  139. package/src/components/Notifications/BaseModal/BaseModalHeader/BaseModalHeader.tsx +14 -2
  140. package/src/components/Notifications/SideSheet/SideSheet.module.scss +96 -0
  141. package/src/components/Notifications/SideSheet/SideSheet.tsx +114 -0
  142. package/src/components/Notifications/SideSheet/SideSheetActions/SideSheetActions.tsx +18 -0
  143. package/src/components/Notifications/SideSheet/SideSheetContent/SideSheetContent.module.scss +19 -0
  144. package/src/components/Notifications/SideSheet/SideSheetContent/SideSheetContent.tsx +25 -0
  145. package/src/components/Notifications/SideSheet/SideSheetHeader/SideSheetHeader.module.scss +19 -0
  146. package/src/components/Notifications/SideSheet/SideSheetHeader/SideSheetHeader.tsx +25 -0
  147. package/src/components/Notifications/SlideInModal/SlideInModal.tsx +3 -0
  148. package/src/components/_BaseStyling_/BaseStyling.tsx +4 -0
  149. package/src/font/icomoon.eot +0 -0
  150. package/src/font/icomoon.svg +1 -0
  151. package/src/font/icomoon.ttf +0 -0
  152. package/src/font/icomoon.woff +0 -0
  153. package/src/font/selection.json +1 -1
  154. package/src/hooks/useUploadFile.tsx +27 -25
  155. package/src/index.ts +27 -2
  156. package/src/util/helper.tsx +0 -6
@@ -0,0 +1,10 @@
1
+ import React from "react";
2
+ import { Props as ModalProps } from "../Modal/Modal";
3
+ export interface Props extends Omit<ModalProps, "hideBackdrop" | "disableBackdrop"> {
4
+ handleButtonProps?: {
5
+ onOpen: () => void;
6
+ onClose: () => void;
7
+ title?: string;
8
+ };
9
+ }
10
+ export declare const SideSheet: React.ForwardRefExoticComponent<Omit<Props, "ref"> & React.RefAttributes<HTMLDivElement>>;
@@ -0,0 +1,2 @@
1
+ export { BaseModalActions as SideSheetActions } from "../../BaseModal/BaseModalActions/BaseModalActions";
2
+ export type { Props } from "../../BaseModal/BaseModalActions/BaseModalActions";
@@ -0,0 +1,4 @@
1
+ import React from "react";
2
+ import { Props } from "../../BaseModal/BaseModalContent/BaseModalContent";
3
+ export declare const SideSheetContent: React.FC<Props>;
4
+ export { Props } from "../../BaseModal/BaseModalContent/BaseModalContent";
@@ -0,0 +1,4 @@
1
+ import React from "react";
2
+ import { Props } from "../../BaseModal/BaseModalHeader/BaseModalHeader";
3
+ export declare const SideSheetHeader: React.FC<Props>;
4
+ export { Props } from "../../BaseModal/BaseModalHeader/BaseModalHeader";
@@ -10,5 +10,5 @@ export interface Props extends ComponentPropsWithRef<any> {
10
10
  spacing?: Spacing;
11
11
  align?: "left" | "center" | "right";
12
12
  }
13
- export declare const Typography: React.ForwardRefExoticComponent<Omit<Props, "ref"> & React.RefAttributes<any>>;
13
+ export declare const Typography: React.ForwardRefExoticComponent<Omit<Omit<Props, "ref">, "ref"> & React.RefAttributes<any>>;
14
14
  export {};
@@ -98,6 +98,8 @@ interface CSSProperties {
98
98
  modalShadowColor?: string;
99
99
  modalBackgroundColor?: string;
100
100
  modalBackdropColor?: string;
101
+ sideSheetShadowColorOne?: string;
102
+ sideSheetShadowColorTwo?: string;
101
103
  skeletonBackgroundColor?: string;
102
104
  skeletonAnimationColorRgb?: string;
103
105
  alertTextColor?: string;
@@ -1,17 +1,23 @@
1
1
  import { FileType } from "../components/Form/FileUpload/FileUpload";
2
+ export type UploadResponseStatus = XMLHttpRequest["status"];
3
+ export type UploadResponseJson = Record<string, unknown>;
2
4
  export interface UploadResponseType {
3
5
  fileList: FileType[];
4
- status: XMLHttpRequest["status"];
6
+ status: UploadResponseStatus;
7
+ responseJson: UploadResponseJson;
8
+ }
9
+ export interface OnErrorMessageMapperType {
10
+ responseStatus: UploadResponseStatus;
11
+ responseJson: UploadResponseJson;
5
12
  }
6
13
  export interface UseUploadFileCallback {
7
14
  onComplete?: (response: UploadResponseType) => void;
8
- onProgress?: Function;
15
+ onProgress?: (fileName: string, progress: number) => void;
16
+ onErrorMessageMapper?: (args: OnErrorMessageMapperType) => string | undefined;
9
17
  }
10
18
  export interface UploadFileRequestParams {
11
19
  url: string;
12
20
  headers?: Headers;
13
- responseErrorPath?: string;
14
- networkErrorText?: string;
15
21
  withCredentials?: boolean;
16
22
  }
17
23
  export declare const useUploadFile: (files: FileType[], request: UploadFileRequestParams, callbacks?: UseUploadFileCallback) => {
@@ -0,0 +1,101 @@
1
+ import { useState, useEffect } from 'react';
2
+ import { isJsonString } from '../util/helper.esm.js';
3
+
4
+ /*
5
+ * Copyright 2022 OneWelcome B.V.
6
+ *
7
+ * Licensed under the Apache License, Version 2.0 (the "License");
8
+ * you may not use this file except in compliance with the License.
9
+ * You may obtain a copy of the License at
10
+ *
11
+ * http://www.apache.org/licenses/LICENSE-2.0
12
+ *
13
+ * Unless required by applicable law or agreed to in writing, software
14
+ * distributed under the License is distributed on an "AS IS" BASIS,
15
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
+ * See the License for the specific language governing permissions and
17
+ * limitations under the License.
18
+ */
19
+ const useUploadFile = (files, request, callbacks) => {
20
+ const { url, headers, withCredentials } = request;
21
+ const { onComplete, onProgress, onErrorMessageMapper } = callbacks !== null && callbacks !== void 0 ? callbacks : {};
22
+ const [uploadingFiles, setUploadingFiles] = useState([]);
23
+ const [updatedFiles, setUpdatedFiles] = useState([...files]);
24
+ const getUpdatedList = (fileName, fileStatus, progress, error) => {
25
+ return files.map(file => {
26
+ if (file.name === fileName) {
27
+ file.progress = progress;
28
+ file.error = error;
29
+ file.status = fileStatus;
30
+ }
31
+ return { ...file };
32
+ });
33
+ };
34
+ const recordProgress = (e, fileName) => {
35
+ const progress = (e.loaded / e.total) * 100;
36
+ const updatedData = getUpdatedList(fileName, "uploading", progress);
37
+ setUpdatedFiles(updatedData);
38
+ onProgress === null || onProgress === void 0 ? void 0 : onProgress(fileName, progress);
39
+ };
40
+ const getFileStatus = (responseStatus, responseJson) => {
41
+ var _a, _b, _c;
42
+ let fileStatus = undefined;
43
+ let error = "";
44
+ if (responseStatus >= 200 && responseStatus < 400) {
45
+ fileStatus = "completed";
46
+ }
47
+ else if (responseStatus === 0) {
48
+ fileStatus = "retry";
49
+ error =
50
+ (_a = onErrorMessageMapper === null || onErrorMessageMapper === void 0 ? void 0 : onErrorMessageMapper({ responseStatus, responseJson })) !== null && _a !== void 0 ? _a : "Network error. Check internet connection and retry uploading the file";
51
+ }
52
+ else if (responseStatus >= 400 && responseStatus < 500) {
53
+ fileStatus = "error";
54
+ error = (_b = onErrorMessageMapper === null || onErrorMessageMapper === void 0 ? void 0 : onErrorMessageMapper({ responseStatus, responseJson })) !== null && _b !== void 0 ? _b : "Bad request";
55
+ }
56
+ else if (responseStatus >= 500) {
57
+ fileStatus = "error";
58
+ error = (_c = onErrorMessageMapper === null || onErrorMessageMapper === void 0 ? void 0 : onErrorMessageMapper({ responseStatus, responseJson })) !== null && _c !== void 0 ? _c : "Server Error";
59
+ }
60
+ return { fileStatus, error };
61
+ };
62
+ const handleOnComplete = (xhr, fileName) => {
63
+ const { status, readyState, responseText } = xhr;
64
+ if (readyState === xhr.DONE) {
65
+ const responseJson = responseText && isJsonString(responseText) && JSON.parse(responseText);
66
+ const { fileStatus, error } = getFileStatus(status, responseJson);
67
+ const updatedList = getUpdatedList(fileName, fileStatus, undefined, error);
68
+ setUpdatedFiles(updatedList);
69
+ const response = { fileList: updatedList, status, responseJson };
70
+ setUploadingFiles(prevState => prevState.filter(selected => selected.name === fileName));
71
+ onComplete === null || onComplete === void 0 ? void 0 : onComplete(response);
72
+ }
73
+ };
74
+ const uploadFile = (file) => {
75
+ const xhr = new XMLHttpRequest();
76
+ xhr.upload.addEventListener("progress", e => recordProgress(e, file.name));
77
+ xhr.addEventListener("readystatechange", () => handleOnComplete(xhr, file.name));
78
+ withCredentials && (xhr.withCredentials = true);
79
+ xhr.open("POST", url, true);
80
+ headers === null || headers === void 0 ? void 0 : headers.forEach((value, key) => xhr.setRequestHeader(key, value));
81
+ const formData = new FormData();
82
+ formData.append("file", file.data);
83
+ formData.append("name", file.name);
84
+ xhr.send(formData);
85
+ };
86
+ useEffect(() => {
87
+ if (!url || !files.length) {
88
+ return;
89
+ }
90
+ files.forEach(file => {
91
+ if (!file.status && !uploadingFiles.find(selected => selected.name === file.name)) {
92
+ setUploadingFiles(prevState => [...prevState, file]);
93
+ uploadFile(file);
94
+ }
95
+ });
96
+ }, [url, files]);
97
+ return { updatedFiles, setUpdatedFiles, uploadingFiles };
98
+ };
99
+
100
+ export { useUploadFile };
101
+ //# sourceMappingURL=useUploadFile.esm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useUploadFile.esm.js","sources":["../../../../../../src/hooks/useUploadFile.tsx"],"sourcesContent":["/*\n * Copyright 2022 OneWelcome B.V.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { FileType } from \"../components/Form/FileUpload/FileUpload\";\nimport { useEffect, useState } from \"react\";\nimport { isJsonString } from \"../util/helper\";\n\nexport type UploadResponseStatus = XMLHttpRequest[\"status\"];\nexport type UploadResponseJson = Record<string, unknown>;\nexport interface UploadResponseType {\n fileList: FileType[];\n status: UploadResponseStatus;\n responseJson: UploadResponseJson;\n}\nexport interface OnErrorMessageMapperType {\n responseStatus: UploadResponseStatus;\n responseJson: UploadResponseJson;\n}\nexport interface UseUploadFileCallback {\n onComplete?: (response: UploadResponseType) => void;\n onProgress?: (fileName: string, progress: number) => void;\n onErrorMessageMapper?: (args: OnErrorMessageMapperType) => string | undefined;\n}\nexport interface UploadFileRequestParams {\n url: string;\n headers?: Headers;\n withCredentials?: boolean;\n}\n\nexport const useUploadFile = (\n files: FileType[],\n request: UploadFileRequestParams,\n callbacks?: UseUploadFileCallback\n) => {\n const { url, headers, withCredentials } = request;\n\n const { onComplete, onProgress, onErrorMessageMapper } = callbacks ?? {};\n\n const [uploadingFiles, setUploadingFiles] = useState<FileType[]>([]);\n const [updatedFiles, setUpdatedFiles] = useState<FileType[]>([...files]);\n\n const getUpdatedList = (\n fileName: string,\n fileStatus: FileType[\"status\"],\n progress?: number,\n error?: string\n ) => {\n return files.map(file => {\n if (file.name === fileName) {\n file.progress = progress;\n file.error = error;\n file.status = fileStatus;\n }\n return { ...file };\n });\n };\n\n const recordProgress = (e: ProgressEvent<XMLHttpRequestEventTarget>, fileName: string) => {\n const progress = (e.loaded / e.total) * 100;\n const updatedData = getUpdatedList(fileName, \"uploading\", progress);\n setUpdatedFiles(updatedData);\n onProgress?.(fileName, progress);\n };\n\n const getFileStatus = (\n responseStatus: UploadResponseStatus,\n responseJson: UploadResponseJson\n ) => {\n let fileStatus: FileType[\"status\"] = undefined;\n let error = \"\";\n if (responseStatus >= 200 && responseStatus < 400) {\n fileStatus = \"completed\";\n } else if (responseStatus === 0) {\n fileStatus = \"retry\";\n error =\n onErrorMessageMapper?.({ responseStatus, responseJson }) ??\n \"Network error. Check internet connection and retry uploading the file\";\n } else if (responseStatus >= 400 && responseStatus < 500) {\n fileStatus = \"error\";\n error = onErrorMessageMapper?.({ responseStatus, responseJson }) ?? \"Bad request\";\n } else if (responseStatus >= 500) {\n fileStatus = \"error\";\n error = onErrorMessageMapper?.({ responseStatus, responseJson }) ?? \"Server Error\";\n }\n return { fileStatus, error };\n };\n\n const handleOnComplete = (xhr: XMLHttpRequest, fileName: string) => {\n const { status, readyState, responseText } = xhr;\n if (readyState === xhr.DONE) {\n const responseJson = responseText && isJsonString(responseText) && JSON.parse(responseText);\n const { fileStatus, error } = getFileStatus(status, responseJson);\n const updatedList = getUpdatedList(fileName, fileStatus, undefined, error);\n setUpdatedFiles(updatedList);\n const response = { fileList: updatedList, status, responseJson };\n setUploadingFiles(prevState => prevState.filter(selected => selected.name === fileName));\n onComplete?.(response);\n }\n };\n\n const uploadFile = (file: FileType) => {\n const xhr = new XMLHttpRequest();\n xhr.upload.addEventListener(\"progress\", e => recordProgress(e, file.name));\n xhr.addEventListener(\"readystatechange\", () => handleOnComplete(xhr, file.name));\n withCredentials && (xhr.withCredentials = true);\n xhr.open(\"POST\", url, true);\n headers?.forEach((value, key) => xhr.setRequestHeader(key, value));\n const formData = new FormData();\n formData.append(\"file\", file.data as File);\n formData.append(\"name\", file.name);\n xhr.send(formData);\n };\n\n useEffect(() => {\n if (!url || !files.length) {\n return;\n }\n\n files.forEach(file => {\n if (!file.status && !uploadingFiles.find(selected => selected.name === file.name)) {\n setUploadingFiles(prevState => [...prevState, file]);\n uploadFile(file);\n }\n });\n }, [url, files]);\n\n return { updatedFiles, setUpdatedFiles, uploadingFiles };\n};\n"],"names":[],"mappings":";;;AAAA;;;;;;;;;;;;;;AAcG;AA4BU,MAAA,aAAa,GAAG,CAC3B,KAAiB,EACjB,OAAgC,EAChC,SAAiC,KAC/B;IACF,MAAM,EAAE,GAAG,EAAE,OAAO,EAAE,eAAe,EAAE,GAAG,OAAO,CAAC;AAElD,IAAA,MAAM,EAAE,UAAU,EAAE,UAAU,EAAE,oBAAoB,EAAE,GAAG,SAAS,aAAT,SAAS,KAAA,KAAA,CAAA,GAAT,SAAS,GAAI,EAAE,CAAC;IAEzE,MAAM,CAAC,cAAc,EAAE,iBAAiB,CAAC,GAAG,QAAQ,CAAa,EAAE,CAAC,CAAC;AACrE,IAAA,MAAM,CAAC,YAAY,EAAE,eAAe,CAAC,GAAG,QAAQ,CAAa,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC;IAEzE,MAAM,cAAc,GAAG,CACrB,QAAgB,EAChB,UAA8B,EAC9B,QAAiB,EACjB,KAAc,KACZ;AACF,QAAA,OAAO,KAAK,CAAC,GAAG,CAAC,IAAI,IAAG;AACtB,YAAA,IAAI,IAAI,CAAC,IAAI,KAAK,QAAQ,EAAE;AAC1B,gBAAA,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;AACzB,gBAAA,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;AACnB,gBAAA,IAAI,CAAC,MAAM,GAAG,UAAU,CAAC;aAC1B;AACD,YAAA,OAAO,EAAE,GAAG,IAAI,EAAE,CAAC;AACrB,SAAC,CAAC,CAAC;AACL,KAAC,CAAC;AAEF,IAAA,MAAM,cAAc,GAAG,CAAC,CAA2C,EAAE,QAAgB,KAA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AAE;AACjF,gBAAA,iBAAiB,CAAC,SAAS,IAAI,CAAC,GAAG,SAAS,EAAE,IAAI,CAAC,CAAC,CAAC;gBACrD,UAAU,CAAC,IAAI,CAAC,CAAC;aAClB;AACH,SAAC,CAAC,CAAC;AACL,KAAC,EAAE,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC,CAAC;AAEjB,IAAA,OAAO,EAAE,YAAY,EAAE,eAAe,EAAE,cAAc,EAAE,CAAC;AAC3D;;;;"}
@@ -41,8 +41,11 @@ export { Pagination } from "./components/Pagination/Pagination";
41
41
  export type { Props as PaginationProps, PageChangeLabels, PaginationTranslations, PageSize } from "./components/Pagination/Pagination";
42
42
  export { useRepeater } from "./hooks/useRepeater";
43
43
  export { useFullHeightCollapse } from "./hooks/useFullHeightCollapse";
44
- export { usePosition, Placement } from "./hooks/usePosition";
44
+ export { usePosition } from "./hooks/usePosition";
45
+ export type { Placement } from "./hooks/usePosition";
45
46
  export { useDebouncedCallback } from "./hooks/useDebouncedCallback";
47
+ export { useUploadFile } from "./hooks/useUploadFile";
48
+ export type { UploadResponseStatus, UploadResponseJson, UploadResponseType, UseUploadFileCallback, UploadFileRequestParams } from "./hooks/useUploadFile";
46
49
  export { generateID, debounce, throttle } from "./util/helper";
47
50
  export { Modal } from "./components/Notifications/Modal/Modal";
48
51
  export type { Props as ModalProps } from "./components/Notifications/Modal/Modal";
@@ -65,6 +68,15 @@ export type { Props as NotificationProviderProps } from "./components/Notificati
65
68
  export type { AddNotification, RemoveNotification, Translations } from "./components/Notifications/NotificationProvider/notification.interfaces";
66
69
  export { SlideInModal } from "./components/Notifications/SlideInModal/SlideInModal";
67
70
  export type { Props as SlideInModalProps } from "./components/Notifications/SlideInModal/SlideInModal";
71
+ /** SideSheet */
72
+ export { SideSheet } from "./components/Notifications/SideSheet/SideSheet";
73
+ export type { Props as SideSheetProps } from "./components/Notifications/SideSheet/SideSheet";
74
+ export { SideSheetActions } from "./components/Notifications/SideSheet/SideSheetActions/SideSheetActions";
75
+ export type { Props as SideSheetActionsProps } from "./components/Notifications/SideSheet/SideSheetActions/SideSheetActions";
76
+ export { SideSheetContent } from "./components/Notifications/SideSheet/SideSheetContent/SideSheetContent";
77
+ export type { Props as SideSheetContentProps } from "./components/Notifications/SideSheet/SideSheetContent/SideSheetContent";
78
+ export { SideSheetHeader } from "./components/Notifications/SideSheet/SideSheetHeader/SideSheetHeader";
79
+ export type { Props as SideSheetHeaderProps } from "./components/Notifications/SideSheet/SideSheetHeader/SideSheetHeader";
68
80
  /** Form components */
69
81
  export { Checkbox } from "./components/Form/Checkbox/Checkbox";
70
82
  export type { Props as CheckboxProps } from "./components/Form/Checkbox/Checkbox";
@@ -106,7 +118,8 @@ export type { Props as TextareaWrapperProps } from "./components/Form/Wrapper/Te
106
118
  export { SelectWrapper } from "./components/Form/Wrapper/SelectWrapper/SelectWrapper";
107
119
  export type { Props as SelectWrapperProps } from "./components/Form/Wrapper/SelectWrapper/SelectWrapper";
108
120
  export { FileUpload } from "./components/Form/FileUpload/FileUpload";
109
- export type { Props as FileUploadProps } from "./components/Form/FileUpload/FileUpload";
121
+ export type { Props as FileUploadProps, FileType } from "./components/Form/FileUpload/FileUpload";
122
+ export { FILE_ACTION, ACTION_STATUS } from "./components/Form/FileUpload/FileItem/FileItem";
110
123
  export { MultiSelectWrapper } from "./components/Form/Wrapper/MultiSelectWrapper/MultiSelectWrapper";
111
124
  export type { Props as MultiSelectWrapperProps } from "./components/Form/Wrapper/MultiSelectWrapper/MultiSelectWrapper";
112
125
  export { ContentHeader } from "./components/Layout/ContentHeader/ContentHeader";
@@ -127,6 +140,8 @@ export { DataGridDrawerItem } from "./components/DataGrid/DataGridBody/DataGridD
127
140
  export type { Props as DataGridDrawerItemProps } from "./components/DataGrid/DataGridBody/DataGridDrawer/DataGridDrawerItem";
128
141
  export { DataGridCell } from "./components/DataGrid/DataGridBody/DataGridCell/DataGridCell";
129
142
  export type { Props as DataGridCellProps } from "./components/DataGrid/DataGridBody/DataGridCell/DataGridCell";
143
+ export { Filter } from "./components/DataGrid/DataGridFilters/DataGridFilters.interfaces";
144
+ export { FilterKeyMapper } from "./components/DataGrid/DataGridFilters/FilterKeyMapper";
130
145
  export { useFiltersReducer } from "./components/DataGrid/DataGridFilters/useFiltersReducer";
131
146
  /** Banner */
132
147
  export { Banner } from "./components/Notifications/Banner/Banner";
@@ -22,6 +22,7 @@ export { useRepeater } from './hooks/useRepeater.esm.js';
22
22
  export { useFullHeightCollapse } from './hooks/useFullHeightCollapse.esm.js';
23
23
  export { usePosition } from './hooks/usePosition.esm.js';
24
24
  export { useDebouncedCallback } from './hooks/useDebouncedCallback.esm.js';
25
+ export { useUploadFile } from './hooks/useUploadFile.esm.js';
25
26
  export { debounce, generateID, throttle } from './util/helper.esm.js';
26
27
  export { BaseModal as Modal } from '../Notifications/BaseModal/BaseModal.esm.js';
27
28
  export { useAlert } from '../Notifications/Alert/useAlert.esm.js';
@@ -29,11 +30,14 @@ export { AlertProvider } from '../Notifications/Alert/AlertProvider/AlertProvide
29
30
  export { AlertItem } from '../Notifications/Alert/AlertItem/AlertItem.esm.js';
30
31
  export { Dialog } from '../Notifications/Dialog/Dialog.esm.js';
31
32
  export { DiscardChangesModal } from '../Notifications/DiscardChangesModal/DiscardChangesModal.esm.js';
32
- export { BaseModalActions as ModalActions } from '../Notifications/BaseModal/BaseModalActions/BaseModalActions.esm.js';
33
+ export { BaseModalActions as ModalActions, BaseModalActions as SideSheetActions } from '../Notifications/BaseModal/BaseModalActions/BaseModalActions.esm.js';
33
34
  export { BaseModalContent as ModalContent } from '../Notifications/BaseModal/BaseModalContent/BaseModalContent.esm.js';
34
35
  export { BaseModalHeader as ModalHeader } from '../Notifications/BaseModal/BaseModalHeader/BaseModalHeader.esm.js';
35
36
  export { NotificationProvider, useNotificationContext } from '../Notifications/NotificationProvider/NotificationContext.esm.js';
36
37
  export { SlideInModal } from '../Notifications/SlideInModal/SlideInModal.esm.js';
38
+ export { SideSheet } from '../Notifications/SideSheet/SideSheet.esm.js';
39
+ export { SideSheetContent } from '../Notifications/SideSheet/SideSheetContent/SideSheetContent.esm.js';
40
+ export { SideSheetHeader } from '../Notifications/SideSheet/SideSheetHeader/SideSheetHeader.esm.js';
37
41
  export { Checkbox } from '../Form/Checkbox/Checkbox.esm.js';
38
42
  export { Fieldset } from '../Form/Fieldset/Fieldset.esm.js';
39
43
  export { Form } from '../Form/Form.esm.js';
@@ -55,6 +59,7 @@ export { CheckboxWrapper } from '../Form/Wrapper/CheckboxWrapper/CheckboxWrapper
55
59
  export { TextareaWrapper } from '../Form/Wrapper/TextareaWrapper/TextareaWrapper.esm.js';
56
60
  export { SelectWrapper } from '../Form/Wrapper/SelectWrapper/SelectWrapper.esm.js';
57
61
  export { FileUpload } from '../Form/FileUpload/FileUpload.esm.js';
62
+ export { ACTION_STATUS, FILE_ACTION } from '../Form/FileUpload/FileItem/FileItem.esm.js';
58
63
  export { MultiSelectWrapper } from '../Form/Wrapper/MultiSelectWrapper/MultiSelectWrapper.esm.js';
59
64
  export { ContentHeader } from '../Layout/ContentHeader/ContentHeader.esm.js';
60
65
  export { FormStepper } from '../Layout/FormPage/FormWithStepper/FormStepper/FormStepper.esm.js';
@@ -64,6 +69,7 @@ export { DataGrid } from '../DataGrid/DataGrid.esm.js';
64
69
  export { DataGridRow } from '../DataGrid/DataGridBody/DataGridRow/DataGridRow.esm.js';
65
70
  export { DataGridDrawerItem } from '../DataGrid/DataGridBody/DataGridDrawer/DataGridDrawerItem.esm.js';
66
71
  export { DataGridCell } from '../DataGrid/DataGridBody/DataGridCell/DataGridCell.esm.js';
72
+ export { FilterKeyMapper } from '../DataGrid/DataGridFilters/FilterKeyMapper.esm.js';
67
73
  export { useFiltersReducer } from '../DataGrid/DataGridFilters/useFiltersReducer.esm.js';
68
74
  export { Banner } from '../Notifications/Banner/Banner.esm.js';
69
75
  export { DatePicker } from '../DatePicker/DatePicker.esm.js';
@@ -1 +1 @@
1
- {"version":3,"file":"index.esm.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"index.esm.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -4,9 +4,6 @@ export declare const debounce: (fn: (...args: unknown[]) => unknown, delay: numb
4
4
  export declare const throttle: (fn: (...args: unknown[]) => unknown, delay: number) => () => void;
5
5
  export declare const isEqual: (x: any, y: any) => boolean;
6
6
  export declare const areArraysDifferent: (arr1: Record<string, any>[], arr2: Record<string, any>[], key: string) => boolean;
7
- export declare const getValueByPath: (obj: {
8
- [key: string]: any;
9
- }, path: string) => any;
10
7
  /** Source: https://stackoverflow.com/a/42769683/5084110 */
11
8
  export declare const remToPx: (rem: number) => number;
12
9
  export declare const isJsonString: (str: any) => boolean;
@@ -131,6 +131,15 @@ const throttle = (fn, delay) => {
131
131
  const remToPx = (rem) => {
132
132
  return rem * parseFloat(getComputedStyle(document.documentElement).fontSize);
133
133
  };
134
+ const isJsonString = (str) => {
135
+ try {
136
+ JSON.parse(str);
137
+ }
138
+ catch (e) {
139
+ return false;
140
+ }
141
+ return true;
142
+ };
134
143
  const deepMerge = (obj1, obj2) => {
135
144
  if (!obj2)
136
145
  return obj1;
@@ -152,5 +161,5 @@ const deepMerge = (obj1, obj2) => {
152
161
  };
153
162
  const escapeRegExp = (str) => str.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
154
163
 
155
- export { debounce, deepMerge, escapeRegExp, filterProps, generateID, remToPx, throttle };
164
+ export { debounce, deepMerge, escapeRegExp, filterProps, generateID, isJsonString, remToPx, throttle };
156
165
  //# sourceMappingURL=helper.esm.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"helper.esm.js","sources":["../../../../../../src/util/helper.tsx"],"sourcesContent":["/*\n * Copyright 2022 OneWelcome B.V.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\ntype KeyValuePair = { [key: string]: unknown };\n\nexport const generateID = (length = 15, stringToWeaveIn?: string) => {\n /** We will make sure to mesh the generate id and name property together to basically create a unique ID */\n let hashCharacters = [\n \"1\",\n \"2\",\n \"3\",\n \"4\",\n \"5\",\n \"6\",\n \"7\",\n \"8\",\n \"9\",\n \"0\",\n \"A\",\n \"B\",\n \"C\",\n \"D\",\n \"E\",\n \"F\",\n \"G\",\n \"H\",\n \"I\",\n \"J\",\n \"K\",\n \"L\",\n \"M\",\n \"N\",\n \"O\",\n \"P\",\n \"Q\",\n \"R\",\n \"S\",\n \"T\",\n \"U\",\n \"V\",\n \"W\",\n \"X\",\n \"Y\",\n \"Z\",\n \"a\",\n \"b\",\n \"c\",\n \"d\",\n \"e\",\n \"f\",\n \"g\",\n \"h\",\n \"i\",\n \"j\",\n \"k\",\n \"l\",\n \"m\",\n \"n\",\n \"o\",\n \"p\",\n \"q\",\n \"r\",\n \"s\",\n \"t\",\n \"u\",\n \"v\",\n \"w\",\n \"x\",\n \"y\",\n \"z\"\n ];\n\n let id = \"\";\n\n /** Generate an id of x characters in length */\n for (let i = 0; i < length && id.length < length; i++) {\n let stringCharacter =\n typeof stringToWeaveIn === \"string\" &&\n stringToWeaveIn?.[i] !== undefined &&\n !/\\s/.test(stringToWeaveIn[i])\n ? stringToWeaveIn[i]\n : \"\";\n id = id + stringCharacter + hashCharacters[Math.floor(Math.random() * hashCharacters.length)];\n }\n\n return id.slice(0, length);\n};\n\nexport const filterProps = (props: any, regexPattern: RegExp, returnFiltered: boolean = true) => {\n if (returnFiltered) {\n return Object.keys(props).reduce((acc: KeyValuePair, key) => {\n if (regexPattern.test(key)) {\n acc[key] = props[key];\n }\n\n return acc;\n }, {});\n } else {\n return Object.entries(props)\n .filter(([key]) => !regexPattern.test(key))\n .reduce(\n (prevObj, currKeyValPair) => ({ ...prevObj, [currKeyValPair[0]]: currKeyValPair[1] }),\n {}\n );\n }\n};\n\nexport const debounce = (fn: (...args: unknown[]) => unknown, delay: number) => {\n let timeout: undefined | ReturnType<typeof setTimeout>;\n\n return function executedFunction(...args: unknown[]) {\n const later = () => {\n clearTimeout(timeout);\n fn(...args);\n };\n\n clearTimeout(timeout);\n\n timeout = setTimeout(later, delay);\n };\n};\n\nexport const throttle = (fn: (...args: unknown[]) => unknown, delay: number) => {\n let lastTime = 0;\n\n return function () {\n let now = Date.now();\n\n if (now - lastTime >= delay) {\n fn();\n lastTime = now;\n }\n };\n};\n\nexport const isEqual = (x: any, y: any): boolean => {\n const typesCoincide = x && y && typeof x === \"object\" && typeof y === \"object\";\n return typesCoincide\n ? Object.keys(x).length === Object.keys(y).length &&\n Object.keys(x).every(key => isEqual(x[key], y[key]))\n : x === y;\n};\n\nexport const areArraysDifferent = (\n arr1: Record<string, any>[],\n arr2: Record<string, any>[],\n key: string\n) => {\n if (arr1.length !== arr2.length) {\n return true;\n } else {\n const firstFilteredArray = arr1.filter(arr1Item =>\n arr2.some((arr2Item: { [x: string]: any }) => !isEqual(arr1Item[key], arr2Item[key]))\n );\n const secondFilteredArray = arr2.filter(arr2Item =>\n arr1.some((arr1Item: { [x: string]: any }) => !isEqual(arr1Item[key], arr2Item[key]))\n );\n\n return !!firstFilteredArray.length || !!secondFilteredArray.length;\n }\n};\n\nexport const getValueByPath = (obj: { [key: string]: any }, path: string): any => {\n return path.split(\".\").reduce((res, prop) => {\n return res[prop];\n }, obj);\n};\n\n/** Source: https://stackoverflow.com/a/42769683/5084110 */\nexport const remToPx = (rem: number): number => {\n return rem * parseFloat(getComputedStyle(document.documentElement).fontSize);\n};\n\nexport const isJsonString = (str: any) => {\n try {\n JSON.parse(str);\n } catch (e) {\n return false;\n }\n return true;\n};\n\ntype ObjectType = { [key: string]: any };\n\nexport const deepMerge = <T extends {}>(obj1: ObjectType, obj2: ObjectType | false): T => {\n if (!obj2) return obj1 as T;\n\n let result: ObjectType = { ...obj1 };\n\n for (let key in obj2) {\n if (Object.prototype.hasOwnProperty.call(obj2, key)) {\n if (\n typeof obj2[key] === \"object\" &&\n obj2[key] !== null &&\n Object.prototype.hasOwnProperty.call(obj1, key) &&\n !Array.isArray(obj2[key])\n ) {\n result[key] = deepMerge(obj1[key], obj2[key]);\n } else {\n result[key] = obj2[key];\n }\n }\n }\n\n return result as T;\n};\n\nexport const escapeRegExp = (str: string) => str.replace(/[.*+?^${}()|[\\]\\\\]/g, \"\\\\$&\");\n"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;AAcG;AAIU,MAAA,UAAU,GAAG,CAAC,MAAM,GAAG,EAAE,EAAE,eAAwB,KAAI;;AAElE,IAAA,IAAI,cAAc,GAAG;QACnB,GAAG;QACH,GAAG;QACH,GAAG;QACH,GAAG;QACH,GAAG;QACH,GAAG;QACH,GAAG;QACH,GAAG;QACH,GAAG;QACH,GAAG;QACH,GAAG;QACH,GAAG;QACH,GAAG;QACH,GAAG;QACH,GAAG;QACH,GAAG;QACH,GAAG;QACH,GAAG;QACH,GAAG;QACH,GAAG;QACH,GAAG;QACH,GAAG;QACH,GAAG;QACH,GAAG;QACH,GAAG;QACH,GAAG;QACH,GAAG;QACH,GAAG;QACH,GAAG;QACH,GAAG;QACH,GAAG;QACH,GAAG;QACH,GAAG;QACH,GAAG;QACH,GAAG;QACH,GAAG;QACH,GAAG;QACH,GAAG;QACH,GAAG;QACH,GAAG;QACH,GAAG;QACH,GAAG;QACH,GAAG;QACH,GAAG;QACH,GAAG;QACH,GAAG;QACH,GAAG;QACH,GAAG;QACH,GAAG;QACH,GAAG;QACH,GAAG;QACH,GAAG;QAC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AG,CAAe,IAAgB,EAAE,IAAwB,KAAO;AACvF,IAAA,IAAI,CAAC,IAAI;AAAE,QAAA,OAAO,IAAS,CAAC;AAE5B,IAAA,IAAI,MAAM,GAAe,EAAE,GAAG,IAAI,EAAE,CAAC;AAErC,IAAA,KAAK,IAAI,GAAG,IAAI,IAAI,EAAE;AACpB,QAAA,IAAI,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC,IAAI,CAAC,IAAI,EAAE,GAAG,CAAC,EAAE;AACnD,YAAA,IACE,OAAO,IAAI,CAAC,GAAG,CAAC,KAAK,QAAQ;AAC7B,gBAAA,IAAI,CAAC,GAAG,CAAC,KAAK,IAAI;gBAClB,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC,IAAI,CAAC,IAAI,EAAE,GAAG,CAAC;gBAC/C,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,EACzB;AACA,gBAAA,MAAM,CAAC,GAAG,CAAC,GAAG,SAAS,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;aAC/C;iBAAM;gBACL,MAAM,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC;aACzB;SACF;KACF;AAED,IAAA,OAAO,MAAW,CAAC;AACrB,EAAE;AAEW,MAAA,YAAY,GAAG,CAAC,GAAW,KAAK,GAAG,CAAC,OAAO,CAAC,qBAAqB,EAAE,MAAM;;;;"}
1
+ {"version":3,"file":"helper.esm.js","sources":["../../../../../../src/util/helper.tsx"],"sourcesContent":["/*\n * Copyright 2022 OneWelcome B.V.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\ntype KeyValuePair = { [key: string]: unknown };\n\nexport const generateID = (length = 15, stringToWeaveIn?: string) => {\n /** We will make sure to mesh the generate id and name property together to basically create a unique ID */\n let hashCharacters = [\n \"1\",\n \"2\",\n \"3\",\n \"4\",\n \"5\",\n \"6\",\n \"7\",\n \"8\",\n \"9\",\n \"0\",\n \"A\",\n \"B\",\n \"C\",\n \"D\",\n \"E\",\n \"F\",\n \"G\",\n \"H\",\n \"I\",\n \"J\",\n \"K\",\n \"L\",\n \"M\",\n \"N\",\n \"O\",\n \"P\",\n \"Q\",\n \"R\",\n \"S\",\n \"T\",\n \"U\",\n \"V\",\n \"W\",\n \"X\",\n \"Y\",\n \"Z\",\n \"a\",\n \"b\",\n \"c\",\n \"d\",\n \"e\",\n \"f\",\n \"g\",\n \"h\",\n \"i\",\n \"j\",\n \"k\",\n \"l\",\n \"m\",\n \"n\",\n \"o\",\n \"p\",\n \"q\",\n \"r\",\n \"s\",\n \"t\",\n \"u\",\n \"v\",\n \"w\",\n \"x\",\n \"y\",\n \"z\"\n ];\n\n let id = \"\";\n\n /** Generate an id of x characters in length */\n for (let i = 0; i < length && id.length < length; i++) {\n let stringCharacter =\n typeof stringToWeaveIn === \"string\" &&\n stringToWeaveIn?.[i] !== undefined &&\n !/\\s/.test(stringToWeaveIn[i])\n ? stringToWeaveIn[i]\n : \"\";\n id = id + stringCharacter + hashCharacters[Math.floor(Math.random() * hashCharacters.length)];\n }\n\n return id.slice(0, length);\n};\n\nexport const filterProps = (props: any, regexPattern: RegExp, returnFiltered: boolean = true) => {\n if (returnFiltered) {\n return Object.keys(props).reduce((acc: KeyValuePair, key) => {\n if (regexPattern.test(key)) {\n acc[key] = props[key];\n }\n\n return acc;\n }, {});\n } else {\n return Object.entries(props)\n .filter(([key]) => !regexPattern.test(key))\n .reduce(\n (prevObj, currKeyValPair) => ({ ...prevObj, [currKeyValPair[0]]: currKeyValPair[1] }),\n {}\n );\n }\n};\n\nexport const debounce = (fn: (...args: unknown[]) => unknown, delay: number) => {\n let timeout: undefined | ReturnType<typeof setTimeout>;\n\n return function executedFunction(...args: unknown[]) {\n const later = () => {\n clearTimeout(timeout);\n fn(...args);\n };\n\n clearTimeout(timeout);\n\n timeout = setTimeout(later, delay);\n };\n};\n\nexport const throttle = (fn: (...args: unknown[]) => unknown, delay: number) => {\n let lastTime = 0;\n\n return function () {\n let now = Date.now();\n\n if (now - lastTime >= delay) {\n fn();\n lastTime = now;\n }\n };\n};\n\nexport const isEqual = (x: any, y: any): boolean => {\n const typesCoincide = x && y && typeof x === \"object\" && typeof y === \"object\";\n return typesCoincide\n ? Object.keys(x).length === Object.keys(y).length &&\n Object.keys(x).every(key => isEqual(x[key], y[key]))\n : x === y;\n};\n\nexport const areArraysDifferent = (\n arr1: Record<string, any>[],\n arr2: Record<string, any>[],\n key: string\n) => {\n if (arr1.length !== arr2.length) {\n return true;\n } else {\n const firstFilteredArray = arr1.filter(arr1Item =>\n arr2.some((arr2Item: { [x: string]: any }) => !isEqual(arr1Item[key], arr2Item[key]))\n );\n const secondFilteredArray = arr2.filter(arr2Item =>\n arr1.some((arr1Item: { [x: string]: any }) => !isEqual(arr1Item[key], arr2Item[key]))\n );\n\n return !!firstFilteredArray.length || !!secondFilteredArray.length;\n }\n};\n\n/** Source: https://stackoverflow.com/a/42769683/5084110 */\nexport const remToPx = (rem: number): number => {\n return rem * parseFloat(getComputedStyle(document.documentElement).fontSize);\n};\n\nexport const isJsonString = (str: any) => {\n try {\n JSON.parse(str);\n } catch (e) {\n return false;\n }\n return true;\n};\n\ntype ObjectType = { [key: string]: any };\n\nexport const deepMerge = <T extends {}>(obj1: ObjectType, obj2: ObjectType | false): T => {\n if (!obj2) return obj1 as T;\n\n let result: ObjectType = { ...obj1 };\n\n for (let key in obj2) {\n if (Object.prototype.hasOwnProperty.call(obj2, key)) {\n if (\n typeof obj2[key] === \"object\" &&\n obj2[key] !== null &&\n Object.prototype.hasOwnProperty.call(obj1, key) &&\n !Array.isArray(obj2[key])\n ) {\n result[key] = deepMerge(obj1[key], obj2[key]);\n } else {\n result[key] = obj2[key];\n }\n }\n }\n\n return result as T;\n};\n\nexport const escapeRegExp = (str: string) => str.replace(/[.*+?^${}()|[\\]\\\\]/g, \"\\\\$&\");\n"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;AAcG;AAIU,MAAA,UAAU,GAAG,CAAC,MAAM,GAAG,EAAE,EAAE,eAAwB,KAAI;;AAElE,IAAA,IAAI,cAAc,GAAG;QACnB,GAAG;QACH,GAAG;QACH,GAAG;QACH,GAAG;QACH,GAAG;QACH,GAAG;QACH,GAAG;QACH,GAAG;QACH,GAAG;QACH,GAAG;QACH,GAAG;QACH,GAAG;QACH,GAAG;QACH,GAAG;QACH,GAAG;QACH,GAAG;QACH,GAAG;QACH,GAAG;QACH,GAAG;QACH,GAAG;QACH,GAAG;QACH,GAAG;QACH,GAAG;QACH,GAAG;QACH,GAAG;QACH,GAAG;QACH,GAAG;QACH,GAAG;QACH,GAAG;QACH,GAAG;QACH,GAAG;QACH,GAAG;QACH,GAAG;QACH,GAAG;QACH,GAAG;QACH,GAAG;QACH,GAAG;QACH,GAAG;QACH,GAAG;QACH,GAAG;QACH,GAAG;QACH,GAAG;QACH,GAAG;QACH,GAAG;QACH,GAAG;QACH,GAAG;QACH,GAAG;QACH,GAAG;QACH,GAAG;QACH,GAAG;QACH,GAAG;QACH,GAAG;QACH,GAAG;QACH,GAAG;QACH,GAAG;QACH,GAAG;QACH,GAAG;QACH,GAAG;QACH,GAAG;QACH,GAAG;QACH,GAAG;QACH,GAAG;KACJ,CAAC;IAEF,IAAI,EAAE,GAAG,EAAE,CAAC;;AAGZ,IAAA,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,MAAM,IAAI,EAAE,CAAC,MAAM,GAAG,MAAM,EAAE,CAAC,EAAE,EAAE;AACrD,QAAA,IAAI,eAAe,GACjB,OAAO,eAAe,KAAK,QAA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AAM,GAAe,EAAE,GAAG,IAAI,EAAE,CAAC;AAErC,IAAA,KAAK,IAAI,GAAG,IAAI,IAAI,EAAE;AACpB,QAAA,IAAI,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC,IAAI,CAAC,IAAI,EAAE,GAAG,CAAC,EAAE;AACnD,YAAA,IACE,OAAO,IAAI,CAAC,GAAG,CAAC,KAAK,QAAQ;AAC7B,gBAAA,IAAI,CAAC,GAAG,CAAC,KAAK,IAAI;gBAClB,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC,IAAI,CAAC,IAAI,EAAE,GAAG,CAAC;gBAC/C,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,EACzB;AACA,gBAAA,MAAM,CAAC,GAAG,CAAC,GAAG,SAAS,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;aAC/C;iBAAM;gBACL,MAAM,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC;aACzB;SACF;KACF;AAED,IAAA,OAAO,MAAW,CAAC;AACrB,EAAE;AAEW,MAAA,YAAY,GAAG,CAAC,GAAW,KAAK,GAAG,CAAC,OAAO,CAAC,qBAAqB,EAAE,MAAM;;;;"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "homepage": "http://onewelcome.github.io/react-lib-components",
3
3
  "name": "@onewelcome/react-lib-components",
4
- "version": "8.3.0",
4
+ "version": "8.4.0",
5
5
  "license": "Apache-2.0",
6
6
  "author": "OneWelcome B.V.",
7
7
  "main": "dist/cjs/src/index.cjs.js",
@@ -53,16 +53,16 @@
53
53
  "node": ">=16"
54
54
  },
55
55
  "devDependencies": {
56
- "@babel/core": "^7.24.9",
57
- "@babel/preset-env": "^7.24.8",
56
+ "@babel/core": "^7.24.7",
57
+ "@babel/preset-env": "^7.24.7",
58
58
  "@babel/preset-react": "^7.24.7",
59
59
  "@babel/preset-typescript": "^7.24.7",
60
- "@chromatic-com/storybook": "^1.6.1",
60
+ "@chromatic-com/storybook": "^1.6.0",
61
61
  "@mdx-js/react": "^3.0.1",
62
62
  "@onewelcome/eslint-config-shared-codestyle": "^9.2.3",
63
63
  "@onewelcome/storybook-addon-basestyling": "^2.0.0",
64
- "@rollup/plugin-commonjs": "^26.0.3",
65
- "@rollup/plugin-node-resolve": "^15.2.4",
64
+ "@rollup/plugin-commonjs": "^26.0.1",
65
+ "@rollup/plugin-node-resolve": "^15.2.3",
66
66
  "@rollup/plugin-terser": "^0.4.4",
67
67
  "@rollup/plugin-typescript": "^11.1.6",
68
68
  "@storybook/addon-a11y": "^8.1.11",
@@ -78,29 +78,29 @@
78
78
  "@storybook/react": "^8.1.11",
79
79
  "@storybook/react-webpack5": "^8.1.11",
80
80
  "@storybook/theming": "^8.1.11",
81
- "@testing-library/dom": "^10.3.2",
82
- "@testing-library/jest-dom": "^6.4.8",
83
- "@testing-library/react": "^16.0.1",
81
+ "@testing-library/dom": "^10.3.0",
82
+ "@testing-library/jest-dom": "^6.4.6",
83
+ "@testing-library/react": "^16.0.0",
84
84
  "@testing-library/user-event": "^14.5.2",
85
- "@types/jest": "^29.5.13",
85
+ "@types/jest": "^29.5.12",
86
86
  "@types/mdx": "^2.0.13",
87
- "@types/react": "^18.3.11",
87
+ "@types/react": "^18.3.3",
88
88
  "@types/react-dom": "^18.3.0",
89
89
  "@types/react-router": "^5.1.20",
90
90
  "@types/react-router-dom": "^5.3.3",
91
91
  "@typescript-eslint/eslint-plugin": "^7.15.0",
92
92
  "@typescript-eslint/parser": "^7.15.0",
93
93
  "babel-loader": "^9.1.3",
94
- "chromatic": "^11.5.6",
94
+ "chromatic": "^11.5.4",
95
95
  "css-loader": "^7.1.2",
96
- "eslint": "^8.57.1",
96
+ "eslint": "^8.57.0",
97
97
  "eslint-config-prettier": "^9.1.0",
98
98
  "eslint-plugin-cypress": "^3.3.0",
99
99
  "eslint-plugin-export-scope": "^2.4.0",
100
100
  "eslint-plugin-jest": "^28.6.0",
101
101
  "eslint-plugin-license-header": "^0.6.1",
102
102
  "eslint-plugin-prettier": "^5.1.3",
103
- "eslint-plugin-react": "^7.34.4",
103
+ "eslint-plugin-react": "^7.34.3",
104
104
  "eslint-plugin-react-hooks": "^4.6.2",
105
105
  "eslint-plugin-storybook": "^0.8.0",
106
106
  "husky": "^9.1.6",
@@ -109,30 +109,30 @@
109
109
  "jest-environment-jsdom": "^29.7.0",
110
110
  "jest-junit": "^16.0.0",
111
111
  "jest-sonar-reporter": "^2.0.0",
112
- "lint-staged": "^15.2.10",
113
- "mini-css-extract-plugin": "^2.9.1",
112
+ "lint-staged": "^15.2.7",
113
+ "mini-css-extract-plugin": "^2.9.0",
114
114
  "npm-run-all": "^4.1.5",
115
- "postcss": "^8.4.47",
115
+ "postcss": "^8.4.39",
116
116
  "postcss-modules": "^6.0.0",
117
117
  "postcss-url": "^10.1.3",
118
- "prettier": "^3.3.3",
118
+ "prettier": "^3.3.2",
119
119
  "react": "^18.3.1",
120
120
  "react-dom": "^18.3.1",
121
121
  "react-is": "^18.3.1",
122
122
  "react-router-dom": "^6.24.1",
123
123
  "remark-gfm": "^4.0.0",
124
124
  "rimraf": "^6.0.1",
125
- "rollup": "^4.18.1",
125
+ "rollup": "^4.18.0",
126
126
  "rollup-plugin-postcss": "^4.0.2",
127
- "sass": "1.77.8",
127
+ "sass": "1.77.6",
128
128
  "sass-loader": "^14.2.1",
129
- "size-limit": "^11.1.6",
129
+ "size-limit": "^11.1.4",
130
130
  "storybook": "^8.1.11",
131
131
  "storybook-addon-mock": "^5.0.0",
132
132
  "storybook-addon-pseudo-states": "^3.1.1",
133
133
  "style-loader": "^4.0.0",
134
134
  "ts-jest": "^29.1.5",
135
135
  "tslib": "^2.6.3",
136
- "typescript": "^5.5.4"
136
+ "typescript": "^5.5.3"
137
137
  }
138
138
  }
@@ -17,7 +17,7 @@
17
17
  @use "../../../../mixins.module.scss";
18
18
 
19
19
  .cell {
20
- height: 2.75rem;
20
+ height: 2.625rem;
21
21
  padding: 0.25rem 1rem;
22
22
 
23
23
  &:first-child {
@@ -13,6 +13,8 @@
13
13
  * See the License for the specific language governing permissions and
14
14
  * limitations under the License.
15
15
  */
16
+ @use "../../dataGridMixins.module";
17
+
16
18
  $nesting-limit: 6;
17
19
 
18
20
  .row {
@@ -23,29 +25,11 @@ $nesting-limit: 6;
23
25
  background-color: var(--data-grid-row-hover-background-color);
24
26
  }
25
27
 
26
- @mixin borderAfter($i, $no-offset: false) {
27
- content: "";
28
- position: absolute;
29
-
30
- @if $no-offset {
31
- width: 100%;
32
- left: 0;
33
- } @else if $i > 0 {
34
- width: calc(100% - calc(3.0625rem + $i * 4.125rem));
35
- left: calc(3.0625rem + $i * 4.125rem);
36
- } @else {
37
- width: calc(100% - 3.0625rem);
38
- left: 3.0625rem;
39
- }
40
- bottom: 0;
41
- border-bottom: 1px solid var(--light-grey-border);
42
- }
43
-
44
28
  @mixin border-x {
45
29
  @for $i from 0 through $nesting-limit {
46
30
  &.border-#{$i} {
47
- &:not(:last-child)::after {
48
- @include borderAfter($i);
31
+ &::after {
32
+ @include dataGridMixins.borderAfter($i);
49
33
  }
50
34
  }
51
35
  }
@@ -54,14 +38,14 @@ $nesting-limit: 6;
54
38
  @include border-x();
55
39
 
56
40
  &.border {
57
- &:not(:last-child)::after {
58
- @include borderAfter(0, true);
41
+ &::after {
42
+ @include dataGridMixins.borderAfter(0, true);
59
43
  }
60
44
  }
61
45
 
62
46
  &.border-drawer {
63
- &:not(:last-child):not(:nth-last-child(2))::after {
64
- @include borderAfter(0, true);
47
+ &:not(:nth-last-child(2))::after {
48
+ @include dataGridMixins.borderAfter(0, true);
65
49
  }
66
50
  }
67
51
  }
@@ -83,3 +83,8 @@ export interface FiltersTranslations {
83
83
  tag?: TagTranslations;
84
84
  popover?: PopoverTranslations;
85
85
  }
86
+
87
+ export interface KeyValuePair<TKey = string, TValue = string> {
88
+ key: TKey;
89
+ value: TValue;
90
+ }
@@ -15,10 +15,13 @@
15
15
  */
16
16
 
17
17
  import React, { useState, useEffect } from "react";
18
- import { InputWrapper } from "../../Form/Wrapper/InputWrapper/InputWrapper";
18
+ import {
19
+ InputWrapper,
20
+ Props as InputWrapperProps
21
+ } from "../../Form/Wrapper/InputWrapper/InputWrapper";
19
22
  import { Icon, Icons } from "../../Icon/Icon";
20
23
  import classes from "./DataGridToolbar.module.scss";
21
- import { InputWrapperProps, useDebouncedCallback } from "../../..";
24
+ import { useDebouncedCallback } from "../../../hooks/useDebouncedCallback";
22
25
 
23
26
  export interface DataGridSearchbarProps {
24
27
  onSearch: (value: string) => void;