@churchapps/apphelper 0.5.1 → 0.5.3
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/dist/components/Loading.d.ts +1 -0
- package/dist/components/Loading.d.ts.map +1 -1
- package/dist/components/Loading.js +1 -45
- package/dist/components/Loading.js.map +1 -1
- package/dist/components/notes/Notes.js +27 -27
- package/dist/helpers/AnalyticsHelper.d.ts.map +1 -1
- package/dist/helpers/AnalyticsHelper.js +21 -6
- package/dist/helpers/AnalyticsHelper.js.map +1 -1
- package/dist/public/css/cropper.css +309 -309
- package/dist/public/css/styles.css +111 -111
- package/dist/public/locales/de.json +270 -0
- package/dist/public/locales/en.json +277 -0
- package/dist/public/locales/es.json +272 -0
- package/dist/public/locales/fr.json +270 -0
- package/dist/public/locales/hi.json +270 -0
- package/dist/public/locales/it.json +270 -0
- package/dist/public/locales/ko.json +270 -0
- package/dist/public/locales/no.json +270 -0
- package/dist/public/locales/pt.json +270 -0
- package/dist/public/locales/ru.json +270 -0
- package/dist/public/locales/tl.json +270 -0
- package/dist/public/locales/zh.json +270 -0
- package/package.json +72 -72
- package/public/css/cropper.css +309 -309
- package/public/css/styles.css +111 -111
- package/public/locales/de.json +269 -269
- package/public/locales/en.json +276 -276
- package/public/locales/es.json +272 -272
- package/public/locales/fr.json +269 -269
- package/public/locales/hi.json +269 -269
- package/public/locales/it.json +269 -269
- package/public/locales/ko.json +269 -269
- package/public/locales/no.json +269 -269
- package/public/locales/pt.json +269 -269
- package/public/locales/ru.json +269 -269
- package/public/locales/tl.json +269 -269
- package/public/locales/zh.json +269 -269
- package/src/components/DisplayBox.tsx +83 -83
- package/src/components/ErrorMessages.tsx +28 -28
- package/src/components/ExportLink.tsx +81 -81
- package/src/components/FloatingSupport.tsx +18 -18
- package/src/components/FormCardPayment.tsx +184 -184
- package/src/components/FormSubmissionEdit.tsx +168 -168
- package/src/components/HelpIcon.tsx +12 -12
- package/src/components/ImageEditor.tsx +161 -161
- package/src/components/InputBox.tsx +96 -96
- package/src/components/Loading.tsx +31 -77
- package/src/components/PageHeader.tsx +110 -110
- package/src/components/PersonAvatar.tsx +77 -77
- package/src/components/QuestionEdit.tsx +99 -99
- package/src/components/SmallButton.tsx +42 -42
- package/src/components/SupportModal.tsx +32 -32
- package/src/components/TabPanel.tsx +28 -28
- package/src/components/gallery/GalleryModal.tsx +173 -173
- package/src/components/gallery/StockPhotos.tsx +95 -95
- package/src/components/gallery/index.ts +1 -1
- package/src/components/header/Banner.tsx +11 -11
- package/src/components/header/PrimaryMenu.tsx +100 -100
- package/src/components/header/SecondaryMenu.tsx +23 -23
- package/src/components/header/SecondaryMenuAlt.tsx +40 -40
- package/src/components/header/SiteHeader.tsx +207 -207
- package/src/components/header/SupportDrawer.tsx +111 -111
- package/src/components/header/index.tsx +2 -2
- package/src/components/index.tsx +20 -20
- package/src/components/notes/AddNote.tsx +180 -180
- package/src/components/notes/Note.tsx +68 -68
- package/src/components/notes/Notes.tsx +208 -208
- package/src/components/notes/index.ts +3 -3
- package/src/components/wrapper/AppList.tsx +19 -19
- package/src/components/wrapper/ChurchList.tsx +154 -154
- package/src/components/wrapper/NavItem.tsx +47 -47
- package/src/components/wrapper/NewPrivateMessage.tsx +253 -253
- package/src/components/wrapper/Notifications.tsx +223 -223
- package/src/components/wrapper/PrivateMessageDetails.tsx +112 -112
- package/src/components/wrapper/PrivateMessages.tsx +576 -576
- package/src/components/wrapper/UserMenu.tsx +383 -383
- package/src/components/wrapper/index.tsx +8 -8
- package/src/helpers/AnalyticsHelper.ts +44 -32
- package/src/helpers/AppearanceHelper.ts +73 -73
- package/src/helpers/ArrayHelper.ts +87 -87
- package/src/helpers/CurrencyHelper.ts +10 -10
- package/src/helpers/DateHelper.ts +104 -104
- package/src/helpers/ErrorHelper.ts +43 -43
- package/src/helpers/EventHelper.ts +49 -49
- package/src/helpers/FileHelper.ts +31 -31
- package/src/helpers/Locale.ts +457 -457
- package/src/helpers/NotificationService.ts +296 -296
- package/src/helpers/PersonHelper.ts +62 -62
- package/src/helpers/SlugHelper.ts +37 -37
- package/src/helpers/SocketHelper.ts +296 -296
- package/src/helpers/UniqueIdHelper.ts +36 -36
- package/src/helpers/UserHelper.ts +107 -107
- package/src/helpers/createEmotionCache.ts +17 -17
- package/src/helpers/index.ts +58 -58
- package/src/hooks/index.ts +3 -3
- package/src/hooks/useMountedState.ts +16 -16
- package/src/hooks/useNotifications.ts +93 -93
- package/src/index.ts +2 -2
- package/src/types/interface-extensions.d.ts +11 -11
- package/tsconfig.json +31 -31
|
@@ -1,161 +1,161 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
|
|
3
|
-
import React, { useState, useEffect, useRef, Suspense, lazy } from "react";
|
|
4
|
-
import { InputBox, SmallButton, Loading } from ".";
|
|
5
|
-
import { Locale } from "../helpers";
|
|
6
|
-
import "../../public/css/cropper.css";
|
|
7
|
-
|
|
8
|
-
// Lazy load the Cropper component
|
|
9
|
-
const Cropper = lazy(() => import("react-cropper").then(module => ({ default: module.default })));
|
|
10
|
-
|
|
11
|
-
interface Props {
|
|
12
|
-
title?: string;
|
|
13
|
-
photoUrl: string;
|
|
14
|
-
aspectRatio: number;
|
|
15
|
-
onUpdate: (dataUrl?: string) => void;
|
|
16
|
-
onCancel?: () => void;
|
|
17
|
-
outputWidth?: number;
|
|
18
|
-
outputHeight?: number;
|
|
19
|
-
hideDelete?: boolean;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
export function ImageEditor(props: Props) {
|
|
23
|
-
const [photoSrc, setPhotoSrc] = useState<string>("");
|
|
24
|
-
const [croppedImageDataUrl, setCroppedImageDataUrl] = useState<string>("");
|
|
25
|
-
const cropperRef = useRef<HTMLImageElement>(null);
|
|
26
|
-
let timeout: number | null = null;
|
|
27
|
-
|
|
28
|
-
const handleSave = () => {
|
|
29
|
-
console.log('ImageEditor handleSave called, croppedImageDataUrl:', croppedImageDataUrl ? 'Data URL available' : 'No data URL');
|
|
30
|
-
props.onUpdate(croppedImageDataUrl);
|
|
31
|
-
};
|
|
32
|
-
|
|
33
|
-
const handleDelete = () => props.onUpdate("");
|
|
34
|
-
|
|
35
|
-
const handleUpload = (e: React.ChangeEvent<HTMLInputElement>) => {
|
|
36
|
-
e.preventDefault();
|
|
37
|
-
let files;
|
|
38
|
-
if (e.target) {
|
|
39
|
-
files = e.target.files;
|
|
40
|
-
}
|
|
41
|
-
if (!files || files.length === 0) return;
|
|
42
|
-
|
|
43
|
-
const reader = new FileReader();
|
|
44
|
-
reader.onload = () => {
|
|
45
|
-
const url = reader.result.toString();
|
|
46
|
-
console.log('ImageEditor file uploaded, setting photoSrc');
|
|
47
|
-
setPhotoSrc(url);
|
|
48
|
-
setCroppedImageDataUrl("");
|
|
49
|
-
};
|
|
50
|
-
reader.readAsDataURL(files[0]);
|
|
51
|
-
|
|
52
|
-
// Clear the input value to allow re-uploading the same file
|
|
53
|
-
e.target.value = "";
|
|
54
|
-
};
|
|
55
|
-
|
|
56
|
-
const selectDefaultCropZone = () => {
|
|
57
|
-
const imageElement: any = cropperRef?.current;
|
|
58
|
-
let cropper: any = imageElement?.cropper;
|
|
59
|
-
if (props.aspectRatio===0)
|
|
60
|
-
{
|
|
61
|
-
let containerData = cropper.getContainerData();
|
|
62
|
-
const imgWidth = cropper.getImageData().width;
|
|
63
|
-
const imgHeight = cropper.getImageData().height;
|
|
64
|
-
const effectiveWidth = (containerData.width > imgWidth) ? imgWidth : containerData.width;
|
|
65
|
-
const effectiveHeight = (containerData.height > imgHeight) ? imgHeight : containerData.height;
|
|
66
|
-
cropper.setCropBoxData({ width: effectiveWidth, height: effectiveHeight, left: (containerData.width - effectiveWidth) / 2.0 , top: (containerData.height - effectiveHeight) / 2.0 });
|
|
67
|
-
} else {
|
|
68
|
-
let desiredAspect = props.aspectRatio;
|
|
69
|
-
let containerData = cropper.getContainerData();
|
|
70
|
-
let imgAspect = cropper.getImageData().aspectRatio;
|
|
71
|
-
let scale = imgAspect / desiredAspect;
|
|
72
|
-
if (scale < 1) {
|
|
73
|
-
const imgWidth = cropper.getImageData().width;
|
|
74
|
-
let l = (containerData.width - imgWidth) / 2.0;
|
|
75
|
-
let t = (containerData.height - (containerData.height * scale)) / 2.0;
|
|
76
|
-
cropper.setCropBoxData({ width: imgWidth, height: imgWidth / desiredAspect, left: l, top: t });
|
|
77
|
-
} else {
|
|
78
|
-
const imgHeight = cropper.getImageData().height;
|
|
79
|
-
let l = (containerData.width - (imgHeight * desiredAspect)) / 2.0;
|
|
80
|
-
let t = cropper.canvasData.top;
|
|
81
|
-
cropper.setCropBoxData({ width: imgHeight * desiredAspect, height: imgHeight, left: l, top: t });
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
const handleCrop = () => {
|
|
88
|
-
if (timeout !== null) {
|
|
89
|
-
window.clearTimeout(timeout);
|
|
90
|
-
timeout = null;
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
timeout = window.setTimeout(() => {
|
|
94
|
-
if (cropperRef.current !== null) {
|
|
95
|
-
const imageElement: any = cropperRef?.current;
|
|
96
|
-
const cropper: any = imageElement?.cropper;
|
|
97
|
-
|
|
98
|
-
//Do not enlarge if less
|
|
99
|
-
const imageData = cropper.getImageData();
|
|
100
|
-
let width = props.outputWidth || 400;
|
|
101
|
-
let height = props.outputHeight || 300;
|
|
102
|
-
if (imageData.naturalWidth < width && imageData.naturalHeight < height) {
|
|
103
|
-
width = imageData.naturalWidth;
|
|
104
|
-
height = imageData.naturalHeight;
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
const url = cropper.getCroppedCanvas({ width, height }).toDataURL("image/png", 0.4);
|
|
108
|
-
console.log('ImageEditor handleCrop setting croppedImageDataUrl');
|
|
109
|
-
setCroppedImageDataUrl(url);
|
|
110
|
-
}
|
|
111
|
-
}, 200);
|
|
112
|
-
};
|
|
113
|
-
|
|
114
|
-
useEffect(() => { setPhotoSrc(props.photoUrl); }, [props.photoUrl]);
|
|
115
|
-
|
|
116
|
-
return (
|
|
117
|
-
<InputBox
|
|
118
|
-
id="cropperBox"
|
|
119
|
-
headerIcon=""
|
|
120
|
-
headerText={props.title}
|
|
121
|
-
ariaLabelDelete="deletePhoto"
|
|
122
|
-
saveText={Locale.label("common.update")}
|
|
123
|
-
saveFunction={handleSave}
|
|
124
|
-
cancelFunction={props.onCancel}
|
|
125
|
-
deleteFunction={(!props.hideDelete) && handleDelete}
|
|
126
|
-
headerActionContent={
|
|
127
|
-
<div>
|
|
128
|
-
<input type="file" onChange={handleUpload} id="fileUpload" accept="image/*" style={{ display: "none" }} />
|
|
129
|
-
<SmallButton
|
|
130
|
-
icon="upload"
|
|
131
|
-
text="Upload"
|
|
132
|
-
onClick={() => {
|
|
133
|
-
document.getElementById("fileUpload").click();
|
|
134
|
-
}}
|
|
135
|
-
/>
|
|
136
|
-
</div>
|
|
137
|
-
}
|
|
138
|
-
>
|
|
139
|
-
<Suspense fallback={<Loading />}>
|
|
140
|
-
<Cropper
|
|
141
|
-
ref={cropperRef}
|
|
142
|
-
src={photoSrc}
|
|
143
|
-
key={photoSrc}
|
|
144
|
-
style={{ height: 240, width: "100%" }}
|
|
145
|
-
aspectRatio={props.aspectRatio}
|
|
146
|
-
guides={false}
|
|
147
|
-
crop={handleCrop}
|
|
148
|
-
autoCropArea={1}
|
|
149
|
-
viewMode={0}
|
|
150
|
-
responsive={true}
|
|
151
|
-
restore={false}
|
|
152
|
-
checkOrientation={false}
|
|
153
|
-
background={false}
|
|
154
|
-
ready={() => {
|
|
155
|
-
setTimeout(selectDefaultCropZone, 100);
|
|
156
|
-
}}
|
|
157
|
-
/>
|
|
158
|
-
</Suspense>
|
|
159
|
-
</InputBox>
|
|
160
|
-
);
|
|
161
|
-
}
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import React, { useState, useEffect, useRef, Suspense, lazy } from "react";
|
|
4
|
+
import { InputBox, SmallButton, Loading } from ".";
|
|
5
|
+
import { Locale } from "../helpers";
|
|
6
|
+
import "../../public/css/cropper.css";
|
|
7
|
+
|
|
8
|
+
// Lazy load the Cropper component
|
|
9
|
+
const Cropper = lazy(() => import("react-cropper").then(module => ({ default: module.default })));
|
|
10
|
+
|
|
11
|
+
interface Props {
|
|
12
|
+
title?: string;
|
|
13
|
+
photoUrl: string;
|
|
14
|
+
aspectRatio: number;
|
|
15
|
+
onUpdate: (dataUrl?: string) => void;
|
|
16
|
+
onCancel?: () => void;
|
|
17
|
+
outputWidth?: number;
|
|
18
|
+
outputHeight?: number;
|
|
19
|
+
hideDelete?: boolean;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export function ImageEditor(props: Props) {
|
|
23
|
+
const [photoSrc, setPhotoSrc] = useState<string>("");
|
|
24
|
+
const [croppedImageDataUrl, setCroppedImageDataUrl] = useState<string>("");
|
|
25
|
+
const cropperRef = useRef<HTMLImageElement>(null);
|
|
26
|
+
let timeout: number | null = null;
|
|
27
|
+
|
|
28
|
+
const handleSave = () => {
|
|
29
|
+
console.log('ImageEditor handleSave called, croppedImageDataUrl:', croppedImageDataUrl ? 'Data URL available' : 'No data URL');
|
|
30
|
+
props.onUpdate(croppedImageDataUrl);
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
const handleDelete = () => props.onUpdate("");
|
|
34
|
+
|
|
35
|
+
const handleUpload = (e: React.ChangeEvent<HTMLInputElement>) => {
|
|
36
|
+
e.preventDefault();
|
|
37
|
+
let files;
|
|
38
|
+
if (e.target) {
|
|
39
|
+
files = e.target.files;
|
|
40
|
+
}
|
|
41
|
+
if (!files || files.length === 0) return;
|
|
42
|
+
|
|
43
|
+
const reader = new FileReader();
|
|
44
|
+
reader.onload = () => {
|
|
45
|
+
const url = reader.result.toString();
|
|
46
|
+
console.log('ImageEditor file uploaded, setting photoSrc');
|
|
47
|
+
setPhotoSrc(url);
|
|
48
|
+
setCroppedImageDataUrl("");
|
|
49
|
+
};
|
|
50
|
+
reader.readAsDataURL(files[0]);
|
|
51
|
+
|
|
52
|
+
// Clear the input value to allow re-uploading the same file
|
|
53
|
+
e.target.value = "";
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
const selectDefaultCropZone = () => {
|
|
57
|
+
const imageElement: any = cropperRef?.current;
|
|
58
|
+
let cropper: any = imageElement?.cropper;
|
|
59
|
+
if (props.aspectRatio===0)
|
|
60
|
+
{
|
|
61
|
+
let containerData = cropper.getContainerData();
|
|
62
|
+
const imgWidth = cropper.getImageData().width;
|
|
63
|
+
const imgHeight = cropper.getImageData().height;
|
|
64
|
+
const effectiveWidth = (containerData.width > imgWidth) ? imgWidth : containerData.width;
|
|
65
|
+
const effectiveHeight = (containerData.height > imgHeight) ? imgHeight : containerData.height;
|
|
66
|
+
cropper.setCropBoxData({ width: effectiveWidth, height: effectiveHeight, left: (containerData.width - effectiveWidth) / 2.0 , top: (containerData.height - effectiveHeight) / 2.0 });
|
|
67
|
+
} else {
|
|
68
|
+
let desiredAspect = props.aspectRatio;
|
|
69
|
+
let containerData = cropper.getContainerData();
|
|
70
|
+
let imgAspect = cropper.getImageData().aspectRatio;
|
|
71
|
+
let scale = imgAspect / desiredAspect;
|
|
72
|
+
if (scale < 1) {
|
|
73
|
+
const imgWidth = cropper.getImageData().width;
|
|
74
|
+
let l = (containerData.width - imgWidth) / 2.0;
|
|
75
|
+
let t = (containerData.height - (containerData.height * scale)) / 2.0;
|
|
76
|
+
cropper.setCropBoxData({ width: imgWidth, height: imgWidth / desiredAspect, left: l, top: t });
|
|
77
|
+
} else {
|
|
78
|
+
const imgHeight = cropper.getImageData().height;
|
|
79
|
+
let l = (containerData.width - (imgHeight * desiredAspect)) / 2.0;
|
|
80
|
+
let t = cropper.canvasData.top;
|
|
81
|
+
cropper.setCropBoxData({ width: imgHeight * desiredAspect, height: imgHeight, left: l, top: t });
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
const handleCrop = () => {
|
|
88
|
+
if (timeout !== null) {
|
|
89
|
+
window.clearTimeout(timeout);
|
|
90
|
+
timeout = null;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
timeout = window.setTimeout(() => {
|
|
94
|
+
if (cropperRef.current !== null) {
|
|
95
|
+
const imageElement: any = cropperRef?.current;
|
|
96
|
+
const cropper: any = imageElement?.cropper;
|
|
97
|
+
|
|
98
|
+
//Do not enlarge if less
|
|
99
|
+
const imageData = cropper.getImageData();
|
|
100
|
+
let width = props.outputWidth || 400;
|
|
101
|
+
let height = props.outputHeight || 300;
|
|
102
|
+
if (imageData.naturalWidth < width && imageData.naturalHeight < height) {
|
|
103
|
+
width = imageData.naturalWidth;
|
|
104
|
+
height = imageData.naturalHeight;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
const url = cropper.getCroppedCanvas({ width, height }).toDataURL("image/png", 0.4);
|
|
108
|
+
console.log('ImageEditor handleCrop setting croppedImageDataUrl');
|
|
109
|
+
setCroppedImageDataUrl(url);
|
|
110
|
+
}
|
|
111
|
+
}, 200);
|
|
112
|
+
};
|
|
113
|
+
|
|
114
|
+
useEffect(() => { setPhotoSrc(props.photoUrl); }, [props.photoUrl]);
|
|
115
|
+
|
|
116
|
+
return (
|
|
117
|
+
<InputBox
|
|
118
|
+
id="cropperBox"
|
|
119
|
+
headerIcon=""
|
|
120
|
+
headerText={props.title}
|
|
121
|
+
ariaLabelDelete="deletePhoto"
|
|
122
|
+
saveText={Locale.label("common.update")}
|
|
123
|
+
saveFunction={handleSave}
|
|
124
|
+
cancelFunction={props.onCancel}
|
|
125
|
+
deleteFunction={(!props.hideDelete) && handleDelete}
|
|
126
|
+
headerActionContent={
|
|
127
|
+
<div>
|
|
128
|
+
<input type="file" onChange={handleUpload} id="fileUpload" accept="image/*" style={{ display: "none" }} />
|
|
129
|
+
<SmallButton
|
|
130
|
+
icon="upload"
|
|
131
|
+
text="Upload"
|
|
132
|
+
onClick={() => {
|
|
133
|
+
document.getElementById("fileUpload").click();
|
|
134
|
+
}}
|
|
135
|
+
/>
|
|
136
|
+
</div>
|
|
137
|
+
}
|
|
138
|
+
>
|
|
139
|
+
<Suspense fallback={<Loading />}>
|
|
140
|
+
<Cropper
|
|
141
|
+
ref={cropperRef}
|
|
142
|
+
src={photoSrc}
|
|
143
|
+
key={photoSrc}
|
|
144
|
+
style={{ height: 240, width: "100%" }}
|
|
145
|
+
aspectRatio={props.aspectRatio}
|
|
146
|
+
guides={false}
|
|
147
|
+
crop={handleCrop}
|
|
148
|
+
autoCropArea={1}
|
|
149
|
+
viewMode={0}
|
|
150
|
+
responsive={true}
|
|
151
|
+
restore={false}
|
|
152
|
+
checkOrientation={false}
|
|
153
|
+
background={false}
|
|
154
|
+
ready={() => {
|
|
155
|
+
setTimeout(selectDefaultCropZone, 100);
|
|
156
|
+
}}
|
|
157
|
+
/>
|
|
158
|
+
</Suspense>
|
|
159
|
+
</InputBox>
|
|
160
|
+
);
|
|
161
|
+
}
|
|
@@ -1,96 +1,96 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
|
|
3
|
-
import React from "react";
|
|
4
|
-
import { Paper, Box, Typography, Stack, Button, PaperProps } from "@mui/material";
|
|
5
|
-
import { Icon } from "@mui/material";
|
|
6
|
-
import { HelpIcon } from "./HelpIcon";
|
|
7
|
-
import { Locale } from "../helpers";
|
|
8
|
-
import { styled, useTheme } from '@mui/material/styles';
|
|
9
|
-
|
|
10
|
-
declare module '@mui/material/styles' {
|
|
11
|
-
interface Palette {
|
|
12
|
-
InputBox: { headerText: string; };
|
|
13
|
-
}
|
|
14
|
-
interface PaletteOptions {
|
|
15
|
-
InputBox?: { headerText?: string; };
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
interface Props {
|
|
21
|
-
id?: string;
|
|
22
|
-
children?: React.ReactNode;
|
|
23
|
-
headerIcon?: string;
|
|
24
|
-
headerText?: string;
|
|
25
|
-
help?: string;
|
|
26
|
-
saveText?: string;
|
|
27
|
-
deleteText?: string;
|
|
28
|
-
cancelText?: string;
|
|
29
|
-
headerActionContent?: React.ReactNode;
|
|
30
|
-
cancelFunction?: () => void;
|
|
31
|
-
deleteFunction?: () => void;
|
|
32
|
-
saveFunction?: () => void;
|
|
33
|
-
"data-testid"?: string;
|
|
34
|
-
className?: string;
|
|
35
|
-
isSubmitting?: boolean;
|
|
36
|
-
ariaLabelDelete?: string;
|
|
37
|
-
ariaLabelSave?: string;
|
|
38
|
-
saveButtonType?: "submit" | "button";
|
|
39
|
-
mainContainerCssProps?: PaperProps;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
const CustomContextBox = styled(Box)({
|
|
43
|
-
name: "InputBox",
|
|
44
|
-
slot: "root",
|
|
45
|
-
marginTop: 10,
|
|
46
|
-
overflowX: "hidden",
|
|
47
|
-
"& p": { color: "#666" },
|
|
48
|
-
"& label": { color: "#999" },
|
|
49
|
-
"& ul": { paddingLeft: 15 },
|
|
50
|
-
"& li": {
|
|
51
|
-
marginBottom: 10,
|
|
52
|
-
"& i": { marginRight: 5 }
|
|
53
|
-
},
|
|
54
|
-
"& td": {
|
|
55
|
-
"& i": { marginRight: 5 }
|
|
56
|
-
}
|
|
57
|
-
})
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
export function InputBox({ mainContainerCssProps = {}, ...props }: Props) {
|
|
61
|
-
const theme = useTheme();
|
|
62
|
-
const headerText = theme?.palette?.InputBox?.headerText ? theme?.palette?.InputBox?.headerText : "primary";
|
|
63
|
-
|
|
64
|
-
let buttons = [];
|
|
65
|
-
if (props.cancelFunction) buttons.push(<Button key="cancel" onClick={props.cancelFunction} color="warning" sx={{ "&:focus": { outline: "none" } }}>{props.cancelText || Locale.label("common.cancel")}</Button>);
|
|
66
|
-
if (props.deleteFunction) buttons.push(<Button key="delete" id="delete" variant="outlined" aria-label={props.ariaLabelDelete} onClick={props.deleteFunction} color="error" sx={{ "&:focus": { outline: "none" } }}>{props.deleteText || Locale.label("common.delete")}</Button>);
|
|
67
|
-
if (props.saveFunction) buttons.push(<Button key="save" type={props.saveButtonType || "button"} variant="contained" disableElevation aria-label={props.ariaLabelSave} onClick={props.saveFunction} disabled={props.isSubmitting} sx={{ "&:focus": { outline: "none" } }}>{props.saveText || Locale.label("common.save")}</Button>);
|
|
68
|
-
|
|
69
|
-
let classNames = ["inputBox"];
|
|
70
|
-
if (props.className) {
|
|
71
|
-
classNames.push(props.className);
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
return (
|
|
75
|
-
<Paper id={props.id || "input-box"} sx={{ padding: 2, marginBottom: 4 }} data-testid={props["data-testid"]} {...mainContainerCssProps}>
|
|
76
|
-
{props.help && <HelpIcon article={props.help} />}
|
|
77
|
-
<Box id="input-box-header" sx={{ display: "flex", justifyContent: "space-between", alignItems: "center", position: "relative" }} data-testid="input-box-header">
|
|
78
|
-
<Box id="input-box-title-section" display="flex" alignItems="center">
|
|
79
|
-
{props.headerIcon && <Icon id="input-box-icon" sx={{ color: headerText }}>{props.headerIcon}</Icon>}
|
|
80
|
-
{props.headerText && (
|
|
81
|
-
<Typography id="input-box-title" component="h2" sx={{ display: "inline-block", marginLeft: props.headerIcon ? 1 : 0 }} variant="h6" color={headerText}>
|
|
82
|
-
{props.headerText}
|
|
83
|
-
</Typography>
|
|
84
|
-
)}
|
|
85
|
-
</Box>
|
|
86
|
-
<Box id="input-box-actions">
|
|
87
|
-
{props.headerActionContent}
|
|
88
|
-
</Box>
|
|
89
|
-
</Box>
|
|
90
|
-
<CustomContextBox id="input-box-content">{props.children}</CustomContextBox>
|
|
91
|
-
<Stack id="input-box-buttons" direction="row" sx={{ marginTop: 1 }} spacing={1} justifyContent="end">
|
|
92
|
-
{buttons}
|
|
93
|
-
</Stack>
|
|
94
|
-
</Paper>
|
|
95
|
-
);
|
|
96
|
-
}
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import React from "react";
|
|
4
|
+
import { Paper, Box, Typography, Stack, Button, PaperProps } from "@mui/material";
|
|
5
|
+
import { Icon } from "@mui/material";
|
|
6
|
+
import { HelpIcon } from "./HelpIcon";
|
|
7
|
+
import { Locale } from "../helpers";
|
|
8
|
+
import { styled, useTheme } from '@mui/material/styles';
|
|
9
|
+
|
|
10
|
+
declare module '@mui/material/styles' {
|
|
11
|
+
interface Palette {
|
|
12
|
+
InputBox: { headerText: string; };
|
|
13
|
+
}
|
|
14
|
+
interface PaletteOptions {
|
|
15
|
+
InputBox?: { headerText?: string; };
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
interface Props {
|
|
21
|
+
id?: string;
|
|
22
|
+
children?: React.ReactNode;
|
|
23
|
+
headerIcon?: string;
|
|
24
|
+
headerText?: string;
|
|
25
|
+
help?: string;
|
|
26
|
+
saveText?: string;
|
|
27
|
+
deleteText?: string;
|
|
28
|
+
cancelText?: string;
|
|
29
|
+
headerActionContent?: React.ReactNode;
|
|
30
|
+
cancelFunction?: () => void;
|
|
31
|
+
deleteFunction?: () => void;
|
|
32
|
+
saveFunction?: () => void;
|
|
33
|
+
"data-testid"?: string;
|
|
34
|
+
className?: string;
|
|
35
|
+
isSubmitting?: boolean;
|
|
36
|
+
ariaLabelDelete?: string;
|
|
37
|
+
ariaLabelSave?: string;
|
|
38
|
+
saveButtonType?: "submit" | "button";
|
|
39
|
+
mainContainerCssProps?: PaperProps;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
const CustomContextBox = styled(Box)({
|
|
43
|
+
name: "InputBox",
|
|
44
|
+
slot: "root",
|
|
45
|
+
marginTop: 10,
|
|
46
|
+
overflowX: "hidden",
|
|
47
|
+
"& p": { color: "#666" },
|
|
48
|
+
"& label": { color: "#999" },
|
|
49
|
+
"& ul": { paddingLeft: 15 },
|
|
50
|
+
"& li": {
|
|
51
|
+
marginBottom: 10,
|
|
52
|
+
"& i": { marginRight: 5 }
|
|
53
|
+
},
|
|
54
|
+
"& td": {
|
|
55
|
+
"& i": { marginRight: 5 }
|
|
56
|
+
}
|
|
57
|
+
})
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
export function InputBox({ mainContainerCssProps = {}, ...props }: Props) {
|
|
61
|
+
const theme = useTheme();
|
|
62
|
+
const headerText = theme?.palette?.InputBox?.headerText ? theme?.palette?.InputBox?.headerText : "primary";
|
|
63
|
+
|
|
64
|
+
let buttons = [];
|
|
65
|
+
if (props.cancelFunction) buttons.push(<Button key="cancel" onClick={props.cancelFunction} color="warning" sx={{ "&:focus": { outline: "none" } }}>{props.cancelText || Locale.label("common.cancel")}</Button>);
|
|
66
|
+
if (props.deleteFunction) buttons.push(<Button key="delete" id="delete" variant="outlined" aria-label={props.ariaLabelDelete} onClick={props.deleteFunction} color="error" sx={{ "&:focus": { outline: "none" } }}>{props.deleteText || Locale.label("common.delete")}</Button>);
|
|
67
|
+
if (props.saveFunction) buttons.push(<Button key="save" type={props.saveButtonType || "button"} variant="contained" disableElevation aria-label={props.ariaLabelSave} onClick={props.saveFunction} disabled={props.isSubmitting} sx={{ "&:focus": { outline: "none" } }}>{props.saveText || Locale.label("common.save")}</Button>);
|
|
68
|
+
|
|
69
|
+
let classNames = ["inputBox"];
|
|
70
|
+
if (props.className) {
|
|
71
|
+
classNames.push(props.className);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
return (
|
|
75
|
+
<Paper id={props.id || "input-box"} sx={{ padding: 2, marginBottom: 4 }} data-testid={props["data-testid"]} {...mainContainerCssProps}>
|
|
76
|
+
{props.help && <HelpIcon article={props.help} />}
|
|
77
|
+
<Box id="input-box-header" sx={{ display: "flex", justifyContent: "space-between", alignItems: "center", position: "relative" }} data-testid="input-box-header">
|
|
78
|
+
<Box id="input-box-title-section" display="flex" alignItems="center">
|
|
79
|
+
{props.headerIcon && <Icon id="input-box-icon" sx={{ color: headerText }}>{props.headerIcon}</Icon>}
|
|
80
|
+
{props.headerText && (
|
|
81
|
+
<Typography id="input-box-title" component="h2" sx={{ display: "inline-block", marginLeft: props.headerIcon ? 1 : 0 }} variant="h6" color={headerText}>
|
|
82
|
+
{props.headerText}
|
|
83
|
+
</Typography>
|
|
84
|
+
)}
|
|
85
|
+
</Box>
|
|
86
|
+
<Box id="input-box-actions">
|
|
87
|
+
{props.headerActionContent}
|
|
88
|
+
</Box>
|
|
89
|
+
</Box>
|
|
90
|
+
<CustomContextBox id="input-box-content">{props.children}</CustomContextBox>
|
|
91
|
+
<Stack id="input-box-buttons" direction="row" sx={{ marginTop: 1 }} spacing={1} justifyContent="end">
|
|
92
|
+
{buttons}
|
|
93
|
+
</Stack>
|
|
94
|
+
</Paper>
|
|
95
|
+
);
|
|
96
|
+
}
|
|
@@ -1,77 +1,31 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
|
|
3
|
-
import React from "react";
|
|
4
|
-
import { Dots } from "react-activity";
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
.activity-dots > div:nth-child(11) { animation-delay: -0.1s; }
|
|
33
|
-
.activity-dots > div:nth-child(12) { animation-delay: 0s; }
|
|
34
|
-
|
|
35
|
-
@keyframes activity-dots {
|
|
36
|
-
0%, 80%, 100% {
|
|
37
|
-
transform: scale(0);
|
|
38
|
-
}
|
|
39
|
-
40% {
|
|
40
|
-
transform: scale(1);
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
`;
|
|
44
|
-
|
|
45
|
-
// Add styles to document head if not already present
|
|
46
|
-
if (typeof document !== 'undefined' && !document.getElementById('activity-styles')) {
|
|
47
|
-
const style = document.createElement('style');
|
|
48
|
-
style.id = 'activity-styles';
|
|
49
|
-
style.textContent = activityStyles;
|
|
50
|
-
document.head.appendChild(style);
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
interface Props { size?: "sm" | "md" | "lg", loadingText?: string, color?: string }
|
|
54
|
-
|
|
55
|
-
export const Loading: React.FC<Props> = (props) => {
|
|
56
|
-
|
|
57
|
-
const getContents = () => {
|
|
58
|
-
const text = (props.loadingText) ? props.loadingText : "Loading"
|
|
59
|
-
const color = (props.color) ? props.color : "#222"
|
|
60
|
-
let result = <><Dots speed={0.8} animating={true} size={32} color={color} /><p style={{ color: color }}>{text}</p></>
|
|
61
|
-
switch (props.size) {
|
|
62
|
-
case "sm":
|
|
63
|
-
result = <><Dots speed={0.8} animating={true} size={20} color={color} /><p style={{ fontSize: 12, color: color }}>{text}</p></>
|
|
64
|
-
break;
|
|
65
|
-
case "lg":
|
|
66
|
-
result = <><Dots speed={0.8} animating={true} size={48} color={color} /><p style={{ fontSize: 30, color: color }}>{text}</p></>
|
|
67
|
-
break;
|
|
68
|
-
}
|
|
69
|
-
return result;
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
return (
|
|
73
|
-
<div id="loading-component" style={{ textAlign: "center", fontFamily: "Roboto" }}>
|
|
74
|
-
{getContents()}
|
|
75
|
-
</div>
|
|
76
|
-
)
|
|
77
|
-
}
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import React from "react";
|
|
4
|
+
import { Dots } from "react-activity";
|
|
5
|
+
import "react-activity/dist/Dots.css";
|
|
6
|
+
|
|
7
|
+
interface Props { size?: "sm" | "md" | "lg", loadingText?: string, color?: string }
|
|
8
|
+
|
|
9
|
+
export const Loading: React.FC<Props> = (props) => {
|
|
10
|
+
|
|
11
|
+
const getContents = () => {
|
|
12
|
+
const text = (props.loadingText) ? props.loadingText : "Loading"
|
|
13
|
+
const color = (props.color) ? props.color : "#222"
|
|
14
|
+
let result = <><Dots speed={0.8} animating={true} size={32} color={color} /><p style={{ color: color }}>{text}</p></>
|
|
15
|
+
switch (props.size) {
|
|
16
|
+
case "sm":
|
|
17
|
+
result = <><Dots speed={0.8} animating={true} size={20} color={color} /><p style={{ fontSize: 12, color: color }}>{text}</p></>
|
|
18
|
+
break;
|
|
19
|
+
case "lg":
|
|
20
|
+
result = <><Dots speed={0.8} animating={true} size={48} color={color} /><p style={{ fontSize: 30, color: color }}>{text}</p></>
|
|
21
|
+
break;
|
|
22
|
+
}
|
|
23
|
+
return result;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
return (
|
|
27
|
+
<div id="loading-component" style={{ textAlign: "center", fontFamily: "Roboto" }}>
|
|
28
|
+
{getContents()}
|
|
29
|
+
</div>
|
|
30
|
+
)
|
|
31
|
+
}
|