@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.
Files changed (75) hide show
  1. package/package.json +2 -1
  2. package/src/Components/Buttons/Button.js +20 -6
  3. package/src/Components/Container/ScreenContainer.js +1 -0
  4. package/src/Components/Editor/InlineEditor.js +2 -1
  5. package/src/Components/Form/Field/Color.js +2 -1
  6. package/src/Components/Form/Field/Combo/Combo.js +55 -37
  7. package/src/Components/Form/Field/Combo/MeterTypesCombo.js +4 -2
  8. package/src/Components/Form/Field/Date.js +9 -8
  9. package/src/Components/Form/Field/Input.js +5 -4
  10. package/src/Components/Form/Field/Json.js +3 -2
  11. package/src/Components/Form/Field/TextArea.js +1 -1
  12. package/src/Components/Form/FieldSet.js +1 -1
  13. package/src/Components/Form/Form.js +4 -1
  14. package/src/Components/Gluestack/accordion/index.tsx +5 -1
  15. package/src/Components/Gluestack/actionsheet/index.tsx +5 -1
  16. package/src/Components/Gluestack/alert/index.tsx +5 -1
  17. package/src/Components/Gluestack/badge/index.tsx +5 -1
  18. package/src/Components/Gluestack/button/index.tsx +5 -1
  19. package/src/Components/Gluestack/checkbox/index.tsx +5 -1
  20. package/src/Components/Gluestack/fab/index.tsx +5 -1
  21. package/src/Components/Gluestack/form-control/index.tsx +5 -1
  22. package/src/Components/Gluestack/icon/createIcon.js +74 -0
  23. package/src/Components/Gluestack/icon/index.tsx +46 -88
  24. package/src/Components/Gluestack/input/index.tsx +5 -1
  25. package/src/Components/Gluestack/select/index.tsx +5 -1
  26. package/src/Components/Grid/Grid.js +24 -11
  27. package/src/Components/Grid/GridHeaderRow.js +4 -3
  28. package/src/Components/Grid/GridRow.js +35 -34
  29. package/src/Components/Grid/RowDragHandle.js +25 -10
  30. package/src/Components/Grid/RowHandle.js +55 -0
  31. package/src/{Hooks → Components/Grid}/useAsyncRenderers.js +1 -1
  32. package/src/Components/Hoc/Secondary/withSecondaryData.js +2 -1
  33. package/src/Components/Hoc/Secondary/withSecondaryEditor.js +3 -2
  34. package/src/Components/Hoc/Secondary/withSecondarySelection.js +3 -2
  35. package/src/Components/Hoc/Secondary/withSecondaryValue.js +2 -1
  36. package/src/Components/Hoc/withAlert.js +21 -11
  37. package/src/Components/Hoc/withCollapsible.js +9 -4
  38. package/src/Components/Hoc/withComponent.js +6 -0
  39. package/src/Components/Hoc/withContextMenu.js +6 -0
  40. package/src/Components/Hoc/withData.js +3 -2
  41. package/src/Components/Hoc/withDnd.js +52 -40
  42. package/src/Components/Hoc/withDraggable.js +21 -5
  43. package/src/Components/Hoc/withEditor.js +2 -1
  44. package/src/Components/Hoc/withEvents.js +11 -1
  45. package/src/Components/Hoc/withFilters.js +7 -2
  46. package/src/Components/Hoc/withModal.js +3 -2
  47. package/src/Components/Hoc/withPdfButtons.js +3 -2
  48. package/src/Components/Hoc/withPermissions.js +3 -2
  49. package/src/Components/Hoc/withPresetButtons.js +3 -2
  50. package/src/Components/Hoc/withSelection.js +2 -8
  51. package/src/Components/Hoc/withToast.js +4 -2
  52. package/src/Components/Hoc/withTooltip.js +10 -1
  53. package/src/Components/Hoc/withValue.js +3 -9
  54. package/src/Components/Messages/GlobalModals.js +70 -0
  55. package/src/Components/Messages/Loading.js +2 -2
  56. package/src/Components/Messages/ProgressModal.js +63 -0
  57. package/src/Components/Messages/WaitMessage.js +7 -2
  58. package/src/Components/Report/Report.js +15 -5
  59. package/src/Components/Toolbar/Pagination.js +1 -1
  60. package/src/Components/Toolbar/Toolbar.js +26 -6
  61. package/src/Components/Tree/Tree.js +22 -6
  62. package/src/Components/Tree/TreeNode.js +11 -11
  63. package/src/Components/Tree/TreeNodeDragHandle.js +8 -4
  64. package/src/Components/Viewer/MeterTypeText.js +21 -1
  65. package/src/Components/Viewer/TextWithLinks.js +2 -1
  66. package/src/Constants/Dates.js +5 -2
  67. package/src/Constants/MeterTypes.js +2 -0
  68. package/src/Functions/addIconProps.js +46 -0
  69. package/src/Functions/downloadInBackground.js +47 -7
  70. package/src/Functions/getReport.js +5 -2
  71. package/src/Functions/testProps.js +1 -1
  72. package/src/Functions/trackEngagementHit.js +2 -1
  73. package/src/Hooks/useWhyDidYouUpdate.js +33 -0
  74. package/src/PlatformImports/Web/Attachments.js +1 -1
  75. 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
- const a = document.createElement('A');
5
- a.href = url + '?' + qs.stringify(data);
6
- a.download = true;
7
- document.body.appendChild(a);
8
- a.click();
9
- document.body.removeChild(a);
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 (!window && Platform.OS === 'android') {
25
+ if (typeof window === 'undefined' && Platform.OS === 'android') {
26
26
  return {
27
27
  accessibilityLabel: id,
28
28
  accessible: true,
@@ -1,5 +1,6 @@
1
1
  export default function trackEngagementHit(repository, data) {
2
- const method = 'POST',
2
+ const
3
+ method = 'POST',
3
4
  url = 'Engagements/trackEngagementHit';
4
5
 
5
6
  return repository._send(method, url, data)
@@ -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
+ }
@@ -37,7 +37,7 @@ import _ from 'lodash';
37
37
  const
38
38
  EXPANDED_MAX = 100,
39
39
  COLLAPSED_MAX = 4,
40
- isPwa = !!window?.navigator?.standalone;
40
+ isPwa = typeof window !== 'undefined' && !!window?.navigator?.standalone;
41
41
 
42
42
  function FileCardCustom(props) {
43
43
  const {
@@ -1,10 +0,0 @@
1
- import { forwardRef } from 'react';
2
-
3
- export default function withBlank(WrappedComponent) {
4
- return forwardRef((props, ref) => {
5
- const {
6
-
7
- } = props;
8
- return <WrappedComponent {...props} ref={ref} />;
9
- });
10
- }