@onehat/ui 0.4.71 → 0.4.73
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 +2 -1
- package/src/Components/Buttons/Button.js +20 -6
- package/src/Components/Container/ScreenContainer.js +1 -0
- package/src/Components/Editor/InlineEditor.js +2 -1
- package/src/Components/Form/Field/Color.js +2 -1
- package/src/Components/Form/Field/Combo/Combo.js +55 -37
- package/src/Components/Form/Field/Combo/MeterTypesCombo.js +4 -2
- package/src/Components/Form/Field/Date.js +9 -8
- package/src/Components/Form/Field/Input.js +5 -4
- package/src/Components/Form/Field/Json.js +3 -2
- package/src/Components/Form/Field/TextArea.js +1 -1
- package/src/Components/Form/FieldSet.js +1 -1
- package/src/Components/Form/Form.js +4 -1
- package/src/Components/Gluestack/accordion/index.tsx +5 -1
- package/src/Components/Gluestack/actionsheet/index.tsx +5 -1
- package/src/Components/Gluestack/alert/index.tsx +5 -1
- package/src/Components/Gluestack/badge/index.tsx +5 -1
- package/src/Components/Gluestack/button/index.tsx +5 -1
- package/src/Components/Gluestack/checkbox/index.tsx +5 -1
- package/src/Components/Gluestack/fab/index.tsx +5 -1
- package/src/Components/Gluestack/form-control/index.tsx +5 -1
- package/src/Components/Gluestack/icon/createIcon.js +74 -0
- package/src/Components/Gluestack/icon/index.tsx +46 -88
- package/src/Components/Gluestack/input/index.tsx +5 -1
- package/src/Components/Gluestack/select/index.tsx +5 -1
- package/src/Components/Grid/Grid.js +24 -11
- package/src/Components/Grid/GridHeaderRow.js +4 -3
- package/src/Components/Grid/GridRow.js +35 -34
- package/src/Components/Grid/RowDragHandle.js +25 -10
- package/src/Components/Grid/RowHandle.js +55 -0
- package/src/{Hooks → Components/Grid}/useAsyncRenderers.js +1 -1
- package/src/Components/Hoc/Secondary/withSecondaryData.js +2 -1
- package/src/Components/Hoc/Secondary/withSecondaryEditor.js +3 -2
- package/src/Components/Hoc/Secondary/withSecondarySelection.js +3 -2
- package/src/Components/Hoc/Secondary/withSecondaryValue.js +2 -1
- package/src/Components/Hoc/withAlert.js +21 -11
- package/src/Components/Hoc/withCollapsible.js +9 -4
- package/src/Components/Hoc/withComponent.js +6 -0
- package/src/Components/Hoc/withContextMenu.js +6 -0
- package/src/Components/Hoc/withData.js +3 -2
- package/src/Components/Hoc/withDnd.js +52 -40
- package/src/Components/Hoc/withDraggable.js +21 -5
- package/src/Components/Hoc/withEditor.js +2 -1
- package/src/Components/Hoc/withEvents.js +11 -1
- package/src/Components/Hoc/withFilters.js +7 -2
- package/src/Components/Hoc/withModal.js +3 -2
- package/src/Components/Hoc/withPdfButtons.js +3 -2
- package/src/Components/Hoc/withPermissions.js +3 -2
- package/src/Components/Hoc/withPresetButtons.js +3 -2
- package/src/Components/Hoc/withSelection.js +2 -8
- package/src/Components/Hoc/withToast.js +4 -2
- package/src/Components/Hoc/withTooltip.js +10 -1
- package/src/Components/Hoc/withValue.js +3 -9
- package/src/Components/Messages/GlobalModals.js +70 -0
- package/src/Components/Messages/Loading.js +2 -2
- package/src/Components/Messages/ProgressModal.js +63 -0
- package/src/Components/Messages/WaitMessage.js +7 -2
- package/src/Components/Report/Report.js +15 -5
- package/src/Components/Toolbar/Pagination.js +1 -1
- package/src/Components/Toolbar/Toolbar.js +26 -6
- package/src/Components/Tree/Tree.js +22 -6
- package/src/Components/Tree/TreeNode.js +11 -11
- package/src/Components/Tree/TreeNodeDragHandle.js +8 -4
- package/src/Components/Viewer/MeterTypeText.js +21 -1
- package/src/Components/Viewer/TextWithLinks.js +2 -1
- package/src/Constants/Dates.js +5 -2
- package/src/Constants/MeterTypes.js +2 -0
- package/src/Functions/addIconProps.js +46 -0
- package/src/Functions/downloadInBackground.js +47 -7
- package/src/Functions/getReport.js +5 -2
- package/src/Functions/testProps.js +1 -1
- package/src/Functions/trackEngagementHit.js +2 -1
- package/src/Hooks/useWhyDidYouUpdate.js +33 -0
- package/src/PlatformImports/Web/Attachments.js +1 -1
- package/src/Components/Hoc/withBlank.js +0 -10
|
@@ -1,11 +1,51 @@
|
|
|
1
1
|
import qs from 'qs';
|
|
2
2
|
|
|
3
|
-
const downloadInBackground = (url, data) => {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
3
|
+
const downloadInBackground = async (url, data, authHeaders = {}) => {
|
|
4
|
+
try {
|
|
5
|
+
// Use fetch to make the request with headers
|
|
6
|
+
const response = await fetch(url, {
|
|
7
|
+
method: 'POST',
|
|
8
|
+
headers: {
|
|
9
|
+
'Content-Type': 'application/x-www-form-urlencoded',
|
|
10
|
+
...authHeaders,
|
|
11
|
+
},
|
|
12
|
+
body: qs.stringify(data),
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
if (!response.ok) {
|
|
16
|
+
throw new Error(`HTTP error! status: ${response.status}`);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
// Get the blob from the response
|
|
20
|
+
const blob = await response.blob();
|
|
21
|
+
|
|
22
|
+
// Create a download link
|
|
23
|
+
const downloadUrl = window.URL.createObjectURL(blob);
|
|
24
|
+
const a = document.createElement('A');
|
|
25
|
+
a.href = downloadUrl;
|
|
26
|
+
|
|
27
|
+
// Try to get filename from response headers
|
|
28
|
+
const contentDisposition = response.headers.get('Content-Disposition');
|
|
29
|
+
let filename = 'download';
|
|
30
|
+
if (contentDisposition) {
|
|
31
|
+
const matches = /filename[^;=\n]*=((['"]).*?\2|[^;\n]*)/.exec(contentDisposition);
|
|
32
|
+
if (matches != null && matches[1]) {
|
|
33
|
+
filename = matches[1].replace(/['"]/g, '');
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
a.download = filename;
|
|
38
|
+
document.body.appendChild(a);
|
|
39
|
+
a.click();
|
|
40
|
+
document.body.removeChild(a);
|
|
41
|
+
|
|
42
|
+
// Clean up the object URL
|
|
43
|
+
window.URL.revokeObjectURL(downloadUrl);
|
|
44
|
+
|
|
45
|
+
} catch (error) {
|
|
46
|
+
console.error('Download failed:', error);
|
|
47
|
+
throw error;
|
|
48
|
+
}
|
|
10
49
|
};
|
|
50
|
+
|
|
11
51
|
export default downloadInBackground;
|
|
@@ -4,6 +4,7 @@ import {
|
|
|
4
4
|
} from '../Constants/ReportTypes.js';
|
|
5
5
|
import downloadInBackground from './downloadInBackground.js';
|
|
6
6
|
import downloadWithFetch from './downloadWithFetch.js';
|
|
7
|
+
import getTokenHeaders from './getTokenHeaders.js';
|
|
7
8
|
import UiGlobals from '../UiGlobals.js';
|
|
8
9
|
|
|
9
10
|
export default function getReport(args) {
|
|
@@ -25,15 +26,17 @@ export default function getReport(args) {
|
|
|
25
26
|
outputFileType: reportType,
|
|
26
27
|
showReportHeaders,
|
|
27
28
|
...data,
|
|
28
|
-
}
|
|
29
|
+
},
|
|
30
|
+
authHeaders = getTokenHeaders();
|
|
29
31
|
|
|
30
32
|
if (reportType === REPORT_TYPES__EXCEL) {
|
|
31
|
-
downloadInBackground(url, params);
|
|
33
|
+
downloadInBackground(url, params, authHeaders);
|
|
32
34
|
} else {
|
|
33
35
|
const options = {
|
|
34
36
|
method: 'POST',
|
|
35
37
|
headers: {
|
|
36
38
|
'Content-Type': 'application/json',
|
|
39
|
+
...authHeaders,
|
|
37
40
|
},
|
|
38
41
|
body: JSON.stringify(params),
|
|
39
42
|
};
|
|
@@ -22,7 +22,7 @@ export default function testProps(id, suffix) {
|
|
|
22
22
|
if (suffix) {
|
|
23
23
|
id += suffix; // this is used in conjunction with 'self' object
|
|
24
24
|
}
|
|
25
|
-
if (
|
|
25
|
+
if (typeof window === 'undefined' && Platform.OS === 'android') {
|
|
26
26
|
return {
|
|
27
27
|
accessibilityLabel: id,
|
|
28
28
|
accessible: true,
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { useRef, useEffect } from 'react';
|
|
2
|
+
|
|
3
|
+
// This custom hook logs changes in props for debugging purposes.
|
|
4
|
+
// It can be used to track why a component re-renders by comparing current props with previous props
|
|
5
|
+
|
|
6
|
+
// Usage in your component:
|
|
7
|
+
// useWhyDidYouUpdate('withMhTree', { enterpriseId, getEquipment, showInactiveEquipment });
|
|
8
|
+
|
|
9
|
+
export default function useWhyDidYouUpdate(name, props) {
|
|
10
|
+
const previous = useRef();
|
|
11
|
+
|
|
12
|
+
useEffect(() => {
|
|
13
|
+
if (previous.current) {
|
|
14
|
+
const allKeys = Object.keys({ ...previous.current, ...props });
|
|
15
|
+
const changedProps = {};
|
|
16
|
+
|
|
17
|
+
allKeys.forEach(key => {
|
|
18
|
+
if (previous.current[key] !== props[key]) {
|
|
19
|
+
changedProps[key] = {
|
|
20
|
+
from: previous.current[key],
|
|
21
|
+
to: props[key]
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
if (Object.keys(changedProps).length) {
|
|
27
|
+
console.log('[why-did-you-update]', name, changedProps);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
previous.current = props;
|
|
32
|
+
});
|
|
33
|
+
}
|