gbs-fwk-buildingblock 1.3.21 → 1.3.23-script-block
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/index.es.js +1 -1
- package/dist/index.js +1 -1
- package/package.json +3 -3
- package/src/blocks/file-viewer/index.tsx +2 -2
- package/src/blocks/modal/index.tsx +19 -15
- package/src/blocks/text-area/index.tsx +63 -18
- package/src/blocks/text-box/index.tsx +63 -37
- package/src/blocks/uploader/index.tsx +1 -1
- package/types/blocks/modal/index.d.ts +3 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "gbs-fwk-buildingblock",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.23-script-block",
|
|
4
4
|
"description": "building blocks",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.es.js",
|
|
@@ -46,9 +46,9 @@
|
|
|
46
46
|
"acorn-walk": "8.2.0",
|
|
47
47
|
"axios": "^1.6.7",
|
|
48
48
|
"commander": "10.0.1",
|
|
49
|
-
"gbs-fwk-core": "
|
|
49
|
+
"gbs-fwk-core": "^1.0.70-beta",
|
|
50
50
|
"react-bootstrap": "2.8.0",
|
|
51
|
-
"react-pdf": "^
|
|
51
|
+
"react-pdf": "^10.0.1",
|
|
52
52
|
"react-slick": "^0.30.2",
|
|
53
53
|
"rollup-plugin-peer-deps-external": "2.2.4",
|
|
54
54
|
"rollup-plugin-typescript2": "0.35.0",
|
|
@@ -6,7 +6,7 @@ import DocumentViewer from "./docx-viewer/document-viewer";
|
|
|
6
6
|
|
|
7
7
|
export const Viewer = () => {
|
|
8
8
|
|
|
9
|
-
const [state, setState] = useState({ documentId: "", showEditor: false, documentAPI: "", documentName: "", documentType: "", actualPath: "", downloadPdfFile
|
|
9
|
+
const [state, setState] = useState({ documentId: "", showEditor: false, documentAPI: "", documentName: "", documentType: "", actualPath: "", downloadPdfFile: false, downloadImageFile: false });
|
|
10
10
|
|
|
11
11
|
useEffect(() => {
|
|
12
12
|
window.addEventListener('message', crossCommunication)
|
|
@@ -17,7 +17,7 @@ export const Viewer = () => {
|
|
|
17
17
|
let data: any = tryJSONParse(message.data);
|
|
18
18
|
if (data.message) {
|
|
19
19
|
switch (data.message) {
|
|
20
|
-
case "
|
|
20
|
+
case "_viewDocumentEditor":
|
|
21
21
|
if (data.entity) {
|
|
22
22
|
setState({
|
|
23
23
|
documentId: data.entity?.documentId || "",
|
|
@@ -8,6 +8,8 @@ interface ModalProps {
|
|
|
8
8
|
title?: string;
|
|
9
9
|
confirmBtn?: string;
|
|
10
10
|
deletBtn?: string;
|
|
11
|
+
showConfirmBtn?: boolean;
|
|
12
|
+
showDeleteBtn?: boolean
|
|
11
13
|
}
|
|
12
14
|
|
|
13
15
|
export const Modal = ({
|
|
@@ -18,6 +20,8 @@ export const Modal = ({
|
|
|
18
20
|
title,
|
|
19
21
|
confirmBtn = 'Yes',
|
|
20
22
|
deletBtn = 'No',
|
|
23
|
+
showConfirmBtn = true,
|
|
24
|
+
showDeleteBtn = true
|
|
21
25
|
}: ModalProps) => {
|
|
22
26
|
const handleClick = (button: any) => {
|
|
23
27
|
onButtonClick(button);
|
|
@@ -55,21 +59,21 @@ export const Modal = ({
|
|
|
55
59
|
<div className="bb-modal-container">
|
|
56
60
|
<div className="bb-modal-content">
|
|
57
61
|
<p className="bb-modal-title">{title}</p>
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
62
|
+
<div className="bb-modal-children">{children}</div>
|
|
63
|
+
<div className="bb-modal-buttons">
|
|
64
|
+
{showConfirmBtn && <Button
|
|
65
|
+
onClick={() => handleClick('Action_1')}
|
|
66
|
+
className={'bb-modal-buttons-action1'}
|
|
67
|
+
>
|
|
68
|
+
{confirmBtn}
|
|
69
|
+
</Button>}
|
|
70
|
+
{showDeleteBtn && <Button
|
|
71
|
+
onClick={() => handleClick('Action_2')}
|
|
72
|
+
className={'bb-modal-buttons-action2'}
|
|
73
|
+
>
|
|
74
|
+
{deletBtn}
|
|
75
|
+
</Button>}
|
|
76
|
+
</div>
|
|
73
77
|
</div>
|
|
74
78
|
</div>
|
|
75
79
|
)
|
|
@@ -1,4 +1,11 @@
|
|
|
1
|
-
import React, {
|
|
1
|
+
import React, {
|
|
2
|
+
ChangeEvent,
|
|
3
|
+
FocusEvent,
|
|
4
|
+
KeyboardEvent,
|
|
5
|
+
useState,
|
|
6
|
+
useRef,
|
|
7
|
+
useEffect,
|
|
8
|
+
} from "react";
|
|
2
9
|
import { TooltipComponent } from "@syncfusion/ej2-react-popups";
|
|
3
10
|
|
|
4
11
|
interface TextAreaprops {
|
|
@@ -14,7 +21,7 @@ interface TextAreaprops {
|
|
|
14
21
|
required?: boolean;
|
|
15
22
|
className?: string;
|
|
16
23
|
placeholder?: string;
|
|
17
|
-
maxLength?: any
|
|
24
|
+
maxLength?: any;
|
|
18
25
|
disabled?: boolean;
|
|
19
26
|
defaultValue?: any;
|
|
20
27
|
enableTooltip?: boolean;
|
|
@@ -38,41 +45,76 @@ export const TextArea: React.FC<TextAreaprops> = ({
|
|
|
38
45
|
onBlur,
|
|
39
46
|
defaultValue,
|
|
40
47
|
enableTooltip,
|
|
41
|
-
maxWords
|
|
48
|
+
maxWords,
|
|
42
49
|
}) => {
|
|
43
|
-
const [toolTipValue, setToolTipValue] = useState("")
|
|
50
|
+
const [toolTipValue, setToolTipValue] = useState("");
|
|
44
51
|
|
|
45
52
|
const textAreaRef: any = useRef(null);
|
|
46
53
|
|
|
47
54
|
useEffect(() => {
|
|
48
|
-
setToolTipValue(textAreaRef.current?.value)
|
|
49
|
-
}, [defaultValue, value])
|
|
55
|
+
setToolTipValue(textAreaRef.current?.value);
|
|
56
|
+
}, [defaultValue, value]);
|
|
50
57
|
|
|
51
58
|
const tooltipBeforeOpen = (event: any, tooltipValue: any) => {
|
|
52
|
-
if (!tooltipValue || !enableTooltip)
|
|
53
|
-
|
|
54
|
-
|
|
59
|
+
if (!tooltipValue || !enableTooltip) event.cancel = true;
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
const sanitizeInput = (value: string): string => {
|
|
63
|
+
return value
|
|
64
|
+
.replace(/[<>`;]/g, "") // strip common XSS/script vectors
|
|
65
|
+
};
|
|
55
66
|
|
|
56
67
|
const onHandleChange = (event: ChangeEvent<HTMLTextAreaElement>) => {
|
|
57
68
|
const inputValue = event.target.value;
|
|
69
|
+
const sanitizedValue = sanitizeInput(inputValue);
|
|
70
|
+
|
|
71
|
+
const clonedEvent = Object.assign(Object.create(Object.getPrototypeOf(event)), event, {
|
|
72
|
+
target: {
|
|
73
|
+
...event.target,
|
|
74
|
+
value: sanitizedValue,
|
|
75
|
+
name: event.target.name,
|
|
76
|
+
}
|
|
77
|
+
});
|
|
78
|
+
|
|
58
79
|
const words = inputValue.trim().split(/\s+/);
|
|
59
80
|
if (maxWords && words.length > maxWords) {
|
|
60
81
|
return;
|
|
61
82
|
}
|
|
62
83
|
setToolTipValue(inputValue);
|
|
63
|
-
onChange?.(
|
|
84
|
+
onChange?.(clonedEvent as any, {});
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
const onBlurEvent = (event: FocusEvent<HTMLTextAreaElement>) => {
|
|
88
|
+
const inputValue = event.target.value;
|
|
89
|
+
const sanitizedValue = sanitizeInput(inputValue);
|
|
90
|
+
const clonedEvent = {
|
|
91
|
+
...event,
|
|
92
|
+
target: {
|
|
93
|
+
...event.target,
|
|
94
|
+
value: sanitizedValue,
|
|
95
|
+
},
|
|
96
|
+
};
|
|
97
|
+
setToolTipValue(event.target.value);
|
|
98
|
+
onBlur?.(clonedEvent as any, {});
|
|
64
99
|
};
|
|
65
100
|
|
|
66
101
|
const onKeyDown = (e: any) => {
|
|
67
|
-
e.stopPropagation()
|
|
68
|
-
onKeypress?.(e)
|
|
69
|
-
}
|
|
102
|
+
e.stopPropagation();
|
|
103
|
+
onKeypress?.(e);
|
|
104
|
+
};
|
|
70
105
|
|
|
71
106
|
return (
|
|
72
107
|
<>
|
|
73
|
-
{label &&
|
|
108
|
+
{label && (
|
|
109
|
+
<label htmlFor={id} className="form-label">
|
|
110
|
+
{label} {required ? <i className="req-lbl">*</i> : <></>}
|
|
111
|
+
</label>
|
|
112
|
+
)}
|
|
74
113
|
{value != undefined ? (
|
|
75
|
-
<TooltipComponent
|
|
114
|
+
<TooltipComponent
|
|
115
|
+
beforeOpen={(event: any) => tooltipBeforeOpen(event, toolTipValue)}
|
|
116
|
+
content={enableTooltip ? toolTipValue : ""}
|
|
117
|
+
>
|
|
76
118
|
<textarea
|
|
77
119
|
id={id}
|
|
78
120
|
name={name}
|
|
@@ -90,7 +132,10 @@ export const TextArea: React.FC<TextAreaprops> = ({
|
|
|
90
132
|
/>
|
|
91
133
|
</TooltipComponent>
|
|
92
134
|
) : (
|
|
93
|
-
<TooltipComponent
|
|
135
|
+
<TooltipComponent
|
|
136
|
+
beforeOpen={(event: any) => tooltipBeforeOpen(event, toolTipValue)}
|
|
137
|
+
content={enableTooltip ? toolTipValue : ""}
|
|
138
|
+
>
|
|
94
139
|
<textarea
|
|
95
140
|
id={id}
|
|
96
141
|
name={name}
|
|
@@ -103,7 +148,7 @@ export const TextArea: React.FC<TextAreaprops> = ({
|
|
|
103
148
|
disabled={disabled}
|
|
104
149
|
onKeyDown={onKeyDown}
|
|
105
150
|
defaultValue={defaultValue}
|
|
106
|
-
onBlur={
|
|
151
|
+
onBlur={onBlurEvent}
|
|
107
152
|
maxLength={maxLength}
|
|
108
153
|
ref={textAreaRef}
|
|
109
154
|
/>
|
|
@@ -111,4 +156,4 @@ export const TextArea: React.FC<TextAreaprops> = ({
|
|
|
111
156
|
)}
|
|
112
157
|
</>
|
|
113
158
|
);
|
|
114
|
-
};
|
|
159
|
+
};
|
|
@@ -1,4 +1,10 @@
|
|
|
1
|
-
import React, {
|
|
1
|
+
import React, {
|
|
2
|
+
ChangeEvent,
|
|
3
|
+
FocusEvent,
|
|
4
|
+
useState,
|
|
5
|
+
useRef,
|
|
6
|
+
useEffect,
|
|
7
|
+
} from "react";
|
|
2
8
|
import { TooltipComponent } from "@syncfusion/ej2-react-popups";
|
|
3
9
|
|
|
4
10
|
interface TextInputProps {
|
|
@@ -24,7 +30,7 @@ interface TextInputProps {
|
|
|
24
30
|
enableTooltip?: boolean;
|
|
25
31
|
disablePasting?: boolean;
|
|
26
32
|
autoComplete?: string;
|
|
27
|
-
inputRef?: any
|
|
33
|
+
inputRef?: any;
|
|
28
34
|
}
|
|
29
35
|
|
|
30
36
|
export const Textbox: React.FC<TextInputProps> = ({
|
|
@@ -50,11 +56,11 @@ export const Textbox: React.FC<TextInputProps> = ({
|
|
|
50
56
|
enableTooltip,
|
|
51
57
|
disablePasting = false,
|
|
52
58
|
autoComplete = "",
|
|
53
|
-
inputRef
|
|
59
|
+
inputRef,
|
|
54
60
|
}) => {
|
|
55
61
|
const [patternError, setPatternError] = useState(false);
|
|
56
62
|
const [oldValue, setOldValue] = useState(value ? value : defaultValue);
|
|
57
|
-
const [tooltipValue, setTooltipValue] = useState()
|
|
63
|
+
const [tooltipValue, setTooltipValue] = useState();
|
|
58
64
|
|
|
59
65
|
const isValidPattern = (value: string): boolean => {
|
|
60
66
|
switch (pattern) {
|
|
@@ -87,6 +93,11 @@ export const Textbox: React.FC<TextInputProps> = ({
|
|
|
87
93
|
return "Invalid Input";
|
|
88
94
|
};
|
|
89
95
|
|
|
96
|
+
const sanitizeInput = (value: string): string => {
|
|
97
|
+
return value
|
|
98
|
+
.replace(/[<>`;]/g, "")
|
|
99
|
+
};
|
|
100
|
+
|
|
90
101
|
const onBlurEvent = (event: any) => {
|
|
91
102
|
if (pattern && event.target.value && !isValidPattern(event.target.value)) {
|
|
92
103
|
setPatternError(true);
|
|
@@ -94,64 +105,73 @@ export const Textbox: React.FC<TextInputProps> = ({
|
|
|
94
105
|
onBlur?.(event, {});
|
|
95
106
|
};
|
|
96
107
|
|
|
97
|
-
const onChangeEvent = (event:
|
|
98
|
-
|
|
99
|
-
|
|
108
|
+
const onChangeEvent = (event: React.ChangeEvent<HTMLInputElement>) => {
|
|
109
|
+
const rawValue = event.target.value;
|
|
110
|
+
const sanitizedValue: any = sanitizeInput(rawValue);
|
|
111
|
+
setTooltipValue(texboxTooltip.current?.value);
|
|
100
112
|
setPatternError(false);
|
|
101
113
|
|
|
114
|
+
const clonedEvent = Object.assign(Object.create(Object.getPrototypeOf(event)), event, {
|
|
115
|
+
target: {
|
|
116
|
+
...event.target,
|
|
117
|
+
value: sanitizedValue,
|
|
118
|
+
name: event.target.name
|
|
119
|
+
}
|
|
120
|
+
});
|
|
121
|
+
|
|
102
122
|
if (pattern === "number") {
|
|
103
123
|
if (
|
|
104
|
-
(
|
|
105
|
-
!isNaN(
|
|
124
|
+
(sanitizedValue.length === 1 && sanitizedValue === "-") ||
|
|
125
|
+
!isNaN(sanitizedValue)
|
|
106
126
|
) {
|
|
107
|
-
onChange?.(
|
|
108
|
-
setOldValue(
|
|
127
|
+
onChange?.(clonedEvent as any, {});
|
|
128
|
+
setOldValue(sanitizedValue);
|
|
109
129
|
} else {
|
|
110
130
|
event.target.value = oldValue;
|
|
111
131
|
}
|
|
112
|
-
} else if (
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
132
|
+
} else if (
|
|
133
|
+
pattern === "negativenumber" ||
|
|
134
|
+
pattern === "preventnegativenumber"
|
|
135
|
+
) {
|
|
136
|
+
if (!sanitizedValue.includes("-") && !isNaN(sanitizedValue)) {
|
|
137
|
+
onChange?.(clonedEvent as any, {});
|
|
138
|
+
setOldValue(sanitizedValue);
|
|
116
139
|
} else {
|
|
117
140
|
event.target.value = oldValue;
|
|
118
141
|
}
|
|
119
|
-
}
|
|
120
|
-
else if (pattern === "lettersOnly") {
|
|
142
|
+
} else if (pattern === "lettersOnly") {
|
|
121
143
|
const textRegex = /^[a-zA-Z]*$/;
|
|
122
|
-
if (textRegex.test(
|
|
123
|
-
setOldValue(
|
|
124
|
-
onChange?.(
|
|
144
|
+
if (textRegex.test(sanitizedValue) || sanitizedValue === "") {
|
|
145
|
+
setOldValue(sanitizedValue);
|
|
146
|
+
onChange?.(clonedEvent as any, {});
|
|
125
147
|
} else {
|
|
126
148
|
event.target.value = oldValue;
|
|
127
149
|
}
|
|
128
150
|
} else {
|
|
129
|
-
setOldValue(
|
|
130
|
-
onChange?.(
|
|
151
|
+
setOldValue(sanitizedValue);
|
|
152
|
+
onChange?.(clonedEvent as any, {});
|
|
131
153
|
}
|
|
132
154
|
};
|
|
133
155
|
|
|
134
156
|
//tooltip settings
|
|
135
157
|
const texboxTooltip: any = useRef(null);
|
|
136
158
|
useEffect(() => {
|
|
137
|
-
setTooltipValue(texboxTooltip.current?.value)
|
|
138
|
-
}, [defaultValue, value])
|
|
159
|
+
setTooltipValue(texboxTooltip.current?.value);
|
|
160
|
+
}, [defaultValue, value]);
|
|
139
161
|
|
|
140
162
|
useEffect(() => {
|
|
141
163
|
if (inputRef) {
|
|
142
|
-
inputRef(texboxTooltip)
|
|
164
|
+
inputRef(texboxTooltip);
|
|
143
165
|
}
|
|
144
|
-
}, [texboxTooltip, inputRef])
|
|
166
|
+
}, [texboxTooltip, inputRef]);
|
|
145
167
|
|
|
146
168
|
const tooltipBeforeOpen = (event: any, tooltipValue: any) => {
|
|
147
|
-
if (!tooltipValue || !enableTooltip)
|
|
148
|
-
|
|
149
|
-
}
|
|
169
|
+
if (!tooltipValue || !enableTooltip) event.cancel = true;
|
|
170
|
+
};
|
|
150
171
|
const handleonKeyDown = (e: any) => {
|
|
151
|
-
onKeyDown?.(e)
|
|
152
|
-
e.stopPropagation()
|
|
153
|
-
|
|
154
|
-
}
|
|
172
|
+
onKeyDown?.(e);
|
|
173
|
+
e.stopPropagation();
|
|
174
|
+
};
|
|
155
175
|
return (
|
|
156
176
|
<>
|
|
157
177
|
{label && (
|
|
@@ -161,7 +181,10 @@ export const Textbox: React.FC<TextInputProps> = ({
|
|
|
161
181
|
)}
|
|
162
182
|
<>
|
|
163
183
|
{value != undefined ? (
|
|
164
|
-
<TooltipComponent
|
|
184
|
+
<TooltipComponent
|
|
185
|
+
beforeOpen={(event: any) => tooltipBeforeOpen(event, tooltipValue)}
|
|
186
|
+
content={enableTooltip ? tooltipValue : ""}
|
|
187
|
+
>
|
|
165
188
|
<input
|
|
166
189
|
id={id}
|
|
167
190
|
type={type}
|
|
@@ -183,12 +206,15 @@ export const Textbox: React.FC<TextInputProps> = ({
|
|
|
183
206
|
defaultValue={defaultValue}
|
|
184
207
|
checked={checked}
|
|
185
208
|
ref={texboxTooltip}
|
|
186
|
-
onPaste={disablePasting ? e => e.preventDefault() : undefined}
|
|
209
|
+
onPaste={disablePasting ? (e) => e.preventDefault() : undefined}
|
|
187
210
|
autoComplete={autoComplete}
|
|
188
211
|
/>
|
|
189
212
|
</TooltipComponent>
|
|
190
213
|
) : (
|
|
191
|
-
<TooltipComponent
|
|
214
|
+
<TooltipComponent
|
|
215
|
+
beforeOpen={(event: any) => tooltipBeforeOpen(event, tooltipValue)}
|
|
216
|
+
content={enableTooltip ? tooltipValue : ""}
|
|
217
|
+
>
|
|
192
218
|
<input
|
|
193
219
|
id={id}
|
|
194
220
|
type={type}
|
|
@@ -209,7 +235,7 @@ export const Textbox: React.FC<TextInputProps> = ({
|
|
|
209
235
|
defaultValue={defaultValue}
|
|
210
236
|
checked={checked}
|
|
211
237
|
ref={texboxTooltip}
|
|
212
|
-
onPaste={disablePasting ? e => e.preventDefault() : undefined}
|
|
238
|
+
onPaste={disablePasting ? (e) => e.preventDefault() : undefined}
|
|
213
239
|
autoComplete={autoComplete}
|
|
214
240
|
/>
|
|
215
241
|
</TooltipComponent>
|
|
@@ -607,7 +607,7 @@ export const Uploader: React.FC<UploaderProps> = ({
|
|
|
607
607
|
if (utilService.isValidGUID(file.documentId)) {
|
|
608
608
|
var fileType: any = file.fileName?.split(".").pop();
|
|
609
609
|
const message = JSON.stringify({
|
|
610
|
-
message: "
|
|
610
|
+
message: "_viewDocumentEditor",
|
|
611
611
|
entity: {
|
|
612
612
|
documentId: file.documentId,
|
|
613
613
|
documentName: file.fileName,
|
|
@@ -7,6 +7,8 @@ interface ModalProps {
|
|
|
7
7
|
title?: string;
|
|
8
8
|
confirmBtn?: string;
|
|
9
9
|
deletBtn?: string;
|
|
10
|
+
showConfirmBtn?: boolean;
|
|
11
|
+
showDeleteBtn?: boolean;
|
|
10
12
|
}
|
|
11
|
-
export declare const Modal: ({ isOpen, setIsOpen, onButtonClick, children, title, confirmBtn, deletBtn, }: ModalProps) => JSX.Element;
|
|
13
|
+
export declare const Modal: ({ isOpen, setIsOpen, onButtonClick, children, title, confirmBtn, deletBtn, showConfirmBtn, showDeleteBtn }: ModalProps) => JSX.Element;
|
|
12
14
|
export {};
|