@onehat/ui 0.4.72 → 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 +7 -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/Date.js +9 -8
- 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 +8 -4
- package/src/Components/Grid/GridHeaderRow.js +3 -2
- package/src/Components/Grid/GridRow.js +1 -1
- package/src/Components/Hoc/withAlert.js +18 -10
- package/src/Components/Hoc/withDnd.js +36 -32
- package/src/Components/Messages/GlobalModals.js +46 -23
- 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/Viewer/TextWithLinks.js +2 -1
- package/src/Constants/Dates.js +5 -2
- package/src/Functions/downloadInBackground.js +47 -7
- package/src/Functions/getReport.js +5 -2
- package/src/Functions/trackEngagementHit.js +2 -1
|
@@ -41,6 +41,7 @@ function Report(props) {
|
|
|
41
41
|
disableExcel = false,
|
|
42
42
|
showReportHeaders = true,
|
|
43
43
|
isQuickReport = false,
|
|
44
|
+
additionalData = {},
|
|
44
45
|
quickReportData = {},
|
|
45
46
|
alert,
|
|
46
47
|
} = props,
|
|
@@ -50,7 +51,10 @@ function Report(props) {
|
|
|
50
51
|
reportId,
|
|
51
52
|
reportType: REPORT_TYPES__EXCEL,
|
|
52
53
|
showReportHeaders,
|
|
53
|
-
data:
|
|
54
|
+
data: {
|
|
55
|
+
...additionalData,
|
|
56
|
+
...quickReportData,
|
|
57
|
+
},
|
|
54
58
|
});
|
|
55
59
|
},
|
|
56
60
|
downloadReport = (args) => {
|
|
@@ -74,8 +78,8 @@ function Report(props) {
|
|
|
74
78
|
|
|
75
79
|
if (isQuickReport) {
|
|
76
80
|
let className = clsx(
|
|
77
|
-
'
|
|
78
|
-
'
|
|
81
|
+
'QuickReport',
|
|
82
|
+
'flex-1',
|
|
79
83
|
'm-2',
|
|
80
84
|
);
|
|
81
85
|
if (props.className) {
|
|
@@ -122,7 +126,10 @@ function Report(props) {
|
|
|
122
126
|
icon: Excel,
|
|
123
127
|
onPress: (data) => downloadReport({
|
|
124
128
|
reportId,
|
|
125
|
-
data
|
|
129
|
+
data: {
|
|
130
|
+
...data,
|
|
131
|
+
...additionalData,
|
|
132
|
+
},
|
|
126
133
|
reportType: REPORT_TYPES__EXCEL,
|
|
127
134
|
showReportHeaders,
|
|
128
135
|
}),
|
|
@@ -137,7 +144,10 @@ function Report(props) {
|
|
|
137
144
|
icon: Pdf,
|
|
138
145
|
onPress: (data) => downloadReport({
|
|
139
146
|
reportId,
|
|
140
|
-
data
|
|
147
|
+
data: {
|
|
148
|
+
...data,
|
|
149
|
+
...additionalData,
|
|
150
|
+
},
|
|
141
151
|
reportType: REPORT_TYPES__PDF,
|
|
142
152
|
showReportHeaders,
|
|
143
153
|
}),
|
|
@@ -1,7 +1,12 @@
|
|
|
1
1
|
import {
|
|
2
2
|
HStackNative,
|
|
3
|
+
ScrollView,
|
|
3
4
|
} from '@project-components/Gluestack';
|
|
4
5
|
import clsx from 'clsx';
|
|
6
|
+
import {
|
|
7
|
+
CURRENT_MODE,
|
|
8
|
+
UI_MODE_NATIVE,
|
|
9
|
+
} from '../../Constants/UiModes.js';
|
|
5
10
|
import UiGlobals from '../../UiGlobals.js';
|
|
6
11
|
|
|
7
12
|
export default function Toolbar(props) {
|
|
@@ -20,13 +25,28 @@ export default function Toolbar(props) {
|
|
|
20
25
|
'border-b-grey-400',
|
|
21
26
|
styles.TOOLBAR_CLASSNAME,
|
|
22
27
|
);
|
|
28
|
+
if (CURRENT_MODE === UI_MODE_NATIVE) {
|
|
29
|
+
className += ' min-w-[100%]';
|
|
30
|
+
}
|
|
23
31
|
if (props.className) {
|
|
24
32
|
className += ' ' + props.className
|
|
25
33
|
}
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
34
|
+
let toolbar = <HStackNative
|
|
35
|
+
className={className}
|
|
36
|
+
style={props.style || {}}
|
|
37
|
+
>
|
|
38
|
+
{props.children}
|
|
39
|
+
</HStackNative>;
|
|
40
|
+
|
|
41
|
+
if (CURRENT_MODE === UI_MODE_NATIVE) {
|
|
42
|
+
toolbar = <ScrollView
|
|
43
|
+
horizontal={true}
|
|
44
|
+
className={clsx(
|
|
45
|
+
'min-w-[100%]',
|
|
46
|
+
'max-h-[50px]',
|
|
47
|
+
)}
|
|
48
|
+
>{toolbar}</ScrollView>;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
return toolbar;
|
|
32
52
|
};
|
|
@@ -8,6 +8,7 @@ import {
|
|
|
8
8
|
} from '@project-components/Gluestack';
|
|
9
9
|
import clsx from 'clsx';
|
|
10
10
|
import {
|
|
11
|
+
CURRENT_MODE,
|
|
11
12
|
UI_MODE_WEB,
|
|
12
13
|
} from '../../Constants/UiModes.js';
|
|
13
14
|
import UiGlobals from '../../UiGlobals.js';
|
|
@@ -78,7 +79,7 @@ function TextWithLinksElement(props) {
|
|
|
78
79
|
};
|
|
79
80
|
|
|
80
81
|
const elementProps = {};
|
|
81
|
-
if (
|
|
82
|
+
if (CURRENT_MODE === UI_MODE_WEB) {
|
|
82
83
|
elementProps.textOverflow = 'ellipsis';
|
|
83
84
|
}
|
|
84
85
|
let className = clsx(
|
package/src/Constants/Dates.js
CHANGED
|
@@ -10,8 +10,11 @@ export const ONE_MONTH_AGO = moment().add(-1, 'months');
|
|
|
10
10
|
export const TWO_MONTHS_AGO = moment().add(-2, 'months');
|
|
11
11
|
export const SIX_MONTHS_AGO = moment().add(-6, 'months');
|
|
12
12
|
export const ONE_MONTH_FROM_NOW = moment().add(1, 'months');
|
|
13
|
+
export const START_OF_THIS_MONTH = moment().startOf('months');
|
|
14
|
+
export const END_OF_LAST_MONTH = moment().subtract(1, 'months').endOf('month');
|
|
13
15
|
export const ONE_YEAR_AGO = moment().add(-1, 'years');
|
|
14
16
|
export const MOMENT_DATE_FORMAT_1 = 'YYYY-MM-DD HH:mm:ss';
|
|
15
|
-
export const MOMENT_DATE_FORMAT_2 = 'MMMM Do YYYY, h:mm:ss a';
|
|
16
|
-
export const MOMENT_DATE_FORMAT_3 = 'h:mm A';
|
|
17
|
+
export const MOMENT_DATE_FORMAT_2 = 'MMMM Do YYYY, h:mm:ss a'; // pretty datetime
|
|
18
|
+
export const MOMENT_DATE_FORMAT_3 = 'h:mm A'; // pretty time
|
|
17
19
|
export const MOMENT_DATE_FORMAT_4 = 'YYYY-MM-DD';
|
|
20
|
+
export const MOMENT_DATE_FORMAT_5 = 'HH:mm:ss';
|
|
@@ -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
|
};
|