catchup-library-web 1.11.4 → 1.11.5
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 +1 -1
- package/src/components/groups/InputGroup.tsx +125 -21
package/package.json
CHANGED
|
@@ -65,6 +65,7 @@ const InputGroup = ({
|
|
|
65
65
|
const textAreaRef = useRef<HTMLTextAreaElement>(null);
|
|
66
66
|
const mathFieldRef = useRef<MathfieldElement>(null);
|
|
67
67
|
const [isMathMode, setIsMathMode] = useState<boolean>(false);
|
|
68
|
+
const [showMathOverlay, setShowMathOverlay] = useState<boolean>(false);
|
|
68
69
|
|
|
69
70
|
useEffect(() => {
|
|
70
71
|
if (!textAreaRef) return;
|
|
@@ -85,6 +86,24 @@ const InputGroup = ({
|
|
|
85
86
|
});
|
|
86
87
|
}, [useMath, type, placeholder, title]);
|
|
87
88
|
|
|
89
|
+
// Close overlay when clicking outside
|
|
90
|
+
useEffect(() => {
|
|
91
|
+
const handleClickOutside = (event: MouseEvent) => {
|
|
92
|
+
if (
|
|
93
|
+
showMathOverlay &&
|
|
94
|
+
event.target instanceof Element &&
|
|
95
|
+
!event.target.closest(".math-overlay")
|
|
96
|
+
) {
|
|
97
|
+
setShowMathOverlay(false);
|
|
98
|
+
}
|
|
99
|
+
};
|
|
100
|
+
|
|
101
|
+
document.addEventListener("mousedown", handleClickOutside);
|
|
102
|
+
return () => {
|
|
103
|
+
document.removeEventListener("mousedown", handleClickOutside);
|
|
104
|
+
};
|
|
105
|
+
}, [showMathOverlay]);
|
|
106
|
+
|
|
88
107
|
const retrieveNullableOptionList = () => {
|
|
89
108
|
if (!optionList) return [];
|
|
90
109
|
const currentOptionList = {
|
|
@@ -133,6 +152,83 @@ const InputGroup = ({
|
|
|
133
152
|
onFocus && onFocus(syntheticEvent);
|
|
134
153
|
};
|
|
135
154
|
|
|
155
|
+
const handleMathModeToggle = (mode: boolean) => {
|
|
156
|
+
setIsMathMode(mode);
|
|
157
|
+
setShowMathOverlay(false);
|
|
158
|
+
};
|
|
159
|
+
|
|
160
|
+
const MathModeOverlay = () => {
|
|
161
|
+
if (!showMathOverlay) return null;
|
|
162
|
+
|
|
163
|
+
return (
|
|
164
|
+
<div className="fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50">
|
|
165
|
+
<div className="math-overlay bg-white rounded-lg p-6 shadow-xl max-w-sm w-full mx-4">
|
|
166
|
+
<h3 className="text-lg font-semibold mb-4 text-catchup-gray-400">
|
|
167
|
+
{i18n.t("select_input_mode")}
|
|
168
|
+
</h3>
|
|
169
|
+
<div className="space-y-3">
|
|
170
|
+
<button
|
|
171
|
+
className={`w-full p-3 rounded-lg border-2 transition-all duration-200 ${
|
|
172
|
+
!isMathMode
|
|
173
|
+
? "border-catchup-blue-400 bg-catchup-blue-50"
|
|
174
|
+
: "border-catchup-gray-100 hover:border-catchup-gray-200"
|
|
175
|
+
}`}
|
|
176
|
+
onClick={() => handleMathModeToggle(false)}
|
|
177
|
+
>
|
|
178
|
+
<div className="flex items-center space-x-3">
|
|
179
|
+
<div className="w-4 h-4 rounded-full border-2 border-catchup-blue-400 flex items-center justify-center">
|
|
180
|
+
{!isMathMode && (
|
|
181
|
+
<div className="w-2 h-2 rounded-full bg-catchup-blue-400"></div>
|
|
182
|
+
)}
|
|
183
|
+
</div>
|
|
184
|
+
<div className="text-left">
|
|
185
|
+
<p className="font-medium text-catchup-gray-400">
|
|
186
|
+
{i18n.t("text_mode")}
|
|
187
|
+
</p>
|
|
188
|
+
<p className="text-sm text-catchup-gray-300">
|
|
189
|
+
Regular text input
|
|
190
|
+
</p>
|
|
191
|
+
</div>
|
|
192
|
+
</div>
|
|
193
|
+
</button>
|
|
194
|
+
<button
|
|
195
|
+
className={`w-full p-3 rounded-lg border-2 transition-all duration-200 ${
|
|
196
|
+
isMathMode
|
|
197
|
+
? "border-catchup-blue-400 bg-catchup-blue-50"
|
|
198
|
+
: "border-catchup-gray-100 hover:border-catchup-gray-200"
|
|
199
|
+
}`}
|
|
200
|
+
onClick={() => handleMathModeToggle(true)}
|
|
201
|
+
>
|
|
202
|
+
<div className="flex items-center space-x-3">
|
|
203
|
+
<div className="w-4 h-4 rounded-full border-2 border-catchup-blue-400 flex items-center justify-center">
|
|
204
|
+
{isMathMode && (
|
|
205
|
+
<div className="w-2 h-2 rounded-full bg-catchup-blue-400"></div>
|
|
206
|
+
)}
|
|
207
|
+
</div>
|
|
208
|
+
<div className="text-left">
|
|
209
|
+
<p className="font-medium text-catchup-gray-400">
|
|
210
|
+
{i18n.t("math_mode")}
|
|
211
|
+
</p>
|
|
212
|
+
<p className="text-sm text-catchup-gray-300">
|
|
213
|
+
Mathematical expressions
|
|
214
|
+
</p>
|
|
215
|
+
</div>
|
|
216
|
+
</div>
|
|
217
|
+
</button>
|
|
218
|
+
</div>
|
|
219
|
+
<div className="mt-6 flex justify-end">
|
|
220
|
+
<button
|
|
221
|
+
className="px-4 py-2 text-catchup-gray-300 hover:text-catchup-gray-400 transition-colors"
|
|
222
|
+
onClick={() => setShowMathOverlay(false)}
|
|
223
|
+
>
|
|
224
|
+
{i18n.t("cancel")}
|
|
225
|
+
</button>
|
|
226
|
+
</div>
|
|
227
|
+
</div>
|
|
228
|
+
</div>
|
|
229
|
+
);
|
|
230
|
+
};
|
|
231
|
+
|
|
136
232
|
const CheckboxInputGroup = () => {
|
|
137
233
|
return (
|
|
138
234
|
<div
|
|
@@ -325,13 +421,6 @@ const InputGroup = ({
|
|
|
325
421
|
onFocus={onFocus}
|
|
326
422
|
onKeyDown={onKeyDown}
|
|
327
423
|
/>
|
|
328
|
-
{/* <div
|
|
329
|
-
className={`${
|
|
330
|
-
title ? "absolute top-0 right-0" : "absolute top-3 left-5"
|
|
331
|
-
}`}
|
|
332
|
-
>
|
|
333
|
-
<p className="italic text-catchup-red opacity-70">{errorText}</p>
|
|
334
|
-
</div> */}
|
|
335
424
|
</div>
|
|
336
425
|
);
|
|
337
426
|
};
|
|
@@ -401,20 +490,30 @@ const InputGroup = ({
|
|
|
401
490
|
</div>
|
|
402
491
|
|
|
403
492
|
{useMath && (
|
|
404
|
-
<
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
493
|
+
<button
|
|
494
|
+
className="absolute right-2 top-1/2 transform -translate-y-1/2 bg-catchup-white border border-catchup-gray-100 rounded-md px-3 py-1 shadow-sm hover:shadow-md transition-shadow duration-200"
|
|
495
|
+
onClick={() => setShowMathOverlay(true)}
|
|
496
|
+
type="button"
|
|
497
|
+
>
|
|
498
|
+
<div className="flex items-center gap-x-1">
|
|
499
|
+
<span className="text-sm font-medium text-catchup-gray-400">
|
|
500
|
+
{isMathMode ? "𝑓(x)" : "Aa"}
|
|
501
|
+
</span>
|
|
502
|
+
<svg
|
|
503
|
+
className="w-3 h-3 text-catchup-gray-300"
|
|
504
|
+
fill="none"
|
|
505
|
+
stroke="currentColor"
|
|
506
|
+
viewBox="0 0 24 24"
|
|
507
|
+
>
|
|
508
|
+
<path
|
|
509
|
+
strokeLinecap="round"
|
|
510
|
+
strokeLinejoin="round"
|
|
511
|
+
strokeWidth={2}
|
|
512
|
+
d="M19 9l-7 7-7-7"
|
|
513
|
+
/>
|
|
514
|
+
</svg>
|
|
416
515
|
</div>
|
|
417
|
-
</
|
|
516
|
+
</button>
|
|
418
517
|
)}
|
|
419
518
|
</div>
|
|
420
519
|
);
|
|
@@ -438,7 +537,12 @@ const InputGroup = ({
|
|
|
438
537
|
}
|
|
439
538
|
};
|
|
440
539
|
|
|
441
|
-
return
|
|
540
|
+
return (
|
|
541
|
+
<>
|
|
542
|
+
{RenderMainContent()}
|
|
543
|
+
<MathModeOverlay />
|
|
544
|
+
</>
|
|
545
|
+
);
|
|
442
546
|
};
|
|
443
547
|
|
|
444
548
|
export default InputGroup;
|