@churchapps/apphelper 0.4.50 → 0.5.1
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/FormCardPayment.d.ts +1 -1
- package/dist/components/FormCardPayment.d.ts.map +1 -1
- package/dist/components/FormCardPayment.js +27 -10
- package/dist/components/FormCardPayment.js.map +1 -1
- package/dist/components/Loading.js +36 -36
- package/dist/components/notes/Notes.js +27 -27
- package/dist/helpers/UserHelper.d.ts.map +1 -1
- package/dist/helpers/UserHelper.js +4 -1
- package/dist/helpers/UserHelper.js.map +1 -1
- package/dist/helpers/index.d.ts +1 -1
- package/dist/helpers/index.d.ts.map +1 -1
- package/dist/helpers/index.js +1 -1
- package/dist/helpers/index.js.map +1 -1
- package/dist/public/css/cropper.css +309 -309
- package/dist/public/css/styles.css +111 -111
- package/package.json +72 -73
- 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 -169
- 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 +77 -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 +32 -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 -104
- package/src/helpers/createEmotionCache.ts +17 -17
- package/src/helpers/index.ts +58 -50
- 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 +12 -0
- package/tsconfig.json +31 -31
- package/dist/public/locales/de.json +0 -270
- package/dist/public/locales/en.json +0 -277
- package/dist/public/locales/es.json +0 -272
- package/dist/public/locales/fr.json +0 -270
- package/dist/public/locales/hi.json +0 -270
- package/dist/public/locales/it.json +0 -270
- package/dist/public/locales/ko.json +0 -270
- package/dist/public/locales/no.json +0 -270
- package/dist/public/locales/pt.json +0 -270
- package/dist/public/locales/ru.json +0 -270
- package/dist/public/locales/tl.json +0 -270
- package/dist/public/locales/zh.json +0 -270
|
@@ -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
|
+
}
|