@snapdragonsnursery/react-components 1.19.2 → 1.19.4
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/ChildSearchModal.jsx +111 -34
package/package.json
CHANGED
package/src/ChildSearchModal.jsx
CHANGED
|
@@ -107,8 +107,8 @@ const ChildSearchModal = ({
|
|
|
107
107
|
const viewportHeight = window.innerHeight;
|
|
108
108
|
const expectedHeight = viewportHeight * 0.9;
|
|
109
109
|
const expectedContentHeight = expectedHeight - 300;
|
|
110
|
-
|
|
111
|
-
console.log(
|
|
110
|
+
|
|
111
|
+
console.log("🔍 Modal Debug:", {
|
|
112
112
|
modalHeight: rect.height,
|
|
113
113
|
modalTop: rect.top,
|
|
114
114
|
modalBottom: rect.bottom,
|
|
@@ -119,15 +119,15 @@ const ChildSearchModal = ({
|
|
|
119
119
|
loading,
|
|
120
120
|
error,
|
|
121
121
|
modalStyle: modal.style,
|
|
122
|
-
modalComputedStyle: window.getComputedStyle(modal)
|
|
122
|
+
modalComputedStyle: window.getComputedStyle(modal),
|
|
123
123
|
});
|
|
124
|
-
|
|
124
|
+
|
|
125
125
|
// Check if modal is overflowing
|
|
126
126
|
if (rect.bottom > window.innerHeight) {
|
|
127
|
-
console.warn(
|
|
127
|
+
console.warn("⚠️ Modal is overflowing bottom of viewport!");
|
|
128
128
|
}
|
|
129
129
|
if (rect.top < 0) {
|
|
130
|
-
console.warn(
|
|
130
|
+
console.warn("⚠️ Modal is overflowing top of viewport!");
|
|
131
131
|
}
|
|
132
132
|
}
|
|
133
133
|
}, [isOpen, children.length, loading, error]);
|
|
@@ -363,14 +363,87 @@ const ChildSearchModal = ({
|
|
|
363
363
|
};
|
|
364
364
|
|
|
365
365
|
const formatAge = (years, months) => {
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
366
|
+
const numericYears =
|
|
367
|
+
typeof years === "number" && Number.isFinite(years)
|
|
368
|
+
? years
|
|
369
|
+
: typeof years === "string" && years.trim() !== ""
|
|
370
|
+
? Number.parseInt(years, 10)
|
|
371
|
+
: null;
|
|
372
|
+
const numericMonths =
|
|
373
|
+
typeof months === "number" && Number.isFinite(months)
|
|
374
|
+
? months
|
|
375
|
+
: typeof months === "string" && months.trim() !== ""
|
|
376
|
+
? Number.parseInt(months, 10)
|
|
377
|
+
: null;
|
|
378
|
+
|
|
379
|
+
let displayYears = numericYears;
|
|
380
|
+
let displayMonths = numericMonths;
|
|
381
|
+
|
|
382
|
+
const normaliseMonths = (yearsValue, monthsValue) => {
|
|
383
|
+
if (monthsValue === null || Number.isNaN(monthsValue)) return null;
|
|
384
|
+
if (yearsValue === null || Number.isNaN(yearsValue)) {
|
|
385
|
+
return {
|
|
386
|
+
years: Math.floor(monthsValue / 12),
|
|
387
|
+
months: monthsValue % 12,
|
|
388
|
+
};
|
|
389
|
+
}
|
|
390
|
+
|
|
391
|
+
const expectedMonthsTotal = yearsValue * 12;
|
|
392
|
+
let remainder = monthsValue;
|
|
393
|
+
|
|
394
|
+
if (remainder >= expectedMonthsTotal) {
|
|
395
|
+
remainder = remainder - expectedMonthsTotal;
|
|
396
|
+
}
|
|
397
|
+
|
|
398
|
+
if (remainder >= 12) {
|
|
399
|
+
remainder = remainder % 12;
|
|
400
|
+
}
|
|
401
|
+
|
|
402
|
+
if (remainder < 0) {
|
|
403
|
+
remainder = 0;
|
|
404
|
+
}
|
|
405
|
+
|
|
406
|
+
return {
|
|
407
|
+
years: yearsValue,
|
|
408
|
+
months: remainder,
|
|
409
|
+
};
|
|
410
|
+
};
|
|
411
|
+
|
|
412
|
+
if (displayMonths !== null && !Number.isNaN(displayMonths)) {
|
|
413
|
+
const normalised = normaliseMonths(
|
|
414
|
+
displayYears ?? null,
|
|
415
|
+
displayMonths ?? null
|
|
416
|
+
);
|
|
417
|
+
|
|
418
|
+
if (normalised) {
|
|
419
|
+
displayYears =
|
|
420
|
+
normalised.years !== undefined ? normalised.years : displayYears;
|
|
421
|
+
displayMonths = normalised.months ?? null;
|
|
422
|
+
}
|
|
372
423
|
}
|
|
373
|
-
|
|
424
|
+
|
|
425
|
+
if (
|
|
426
|
+
(displayYears === null || Number.isNaN(displayYears)) &&
|
|
427
|
+
displayMonths !== null &&
|
|
428
|
+
displayMonths >= 12
|
|
429
|
+
) {
|
|
430
|
+
displayYears = Math.floor(displayMonths / 12);
|
|
431
|
+
displayMonths = displayMonths % 12;
|
|
432
|
+
}
|
|
433
|
+
|
|
434
|
+
const parts = [];
|
|
435
|
+
if (displayYears !== null && !Number.isNaN(displayYears)) {
|
|
436
|
+
parts.push(`${displayYears}y`);
|
|
437
|
+
}
|
|
438
|
+
if (
|
|
439
|
+
displayMonths !== null &&
|
|
440
|
+
!Number.isNaN(displayMonths) &&
|
|
441
|
+
displayMonths > 0
|
|
442
|
+
) {
|
|
443
|
+
parts.push(`${displayMonths}m`);
|
|
444
|
+
}
|
|
445
|
+
|
|
446
|
+
return parts.join(" ");
|
|
374
447
|
};
|
|
375
448
|
|
|
376
449
|
const formatDate = (dateString) => {
|
|
@@ -381,16 +454,19 @@ const ChildSearchModal = ({
|
|
|
381
454
|
if (!isOpen) return null;
|
|
382
455
|
|
|
383
456
|
return (
|
|
384
|
-
<div
|
|
457
|
+
<div
|
|
458
|
+
className="fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center p-4 overflow-hidden"
|
|
459
|
+
style={{ zIndex }}
|
|
460
|
+
>
|
|
385
461
|
<div
|
|
386
462
|
ref={modalRef}
|
|
387
463
|
className={`bg-white dark:bg-gray-800 rounded-lg shadow-xl max-w-4xl w-full flex flex-col overflow-hidden ${className}`}
|
|
388
464
|
style={{
|
|
389
465
|
maxHeight: `${maxHeightVh}vh`,
|
|
390
466
|
height: `${maxHeightVh}vh`,
|
|
391
|
-
display:
|
|
392
|
-
flexDirection:
|
|
393
|
-
position:
|
|
467
|
+
display: "flex",
|
|
468
|
+
flexDirection: "column",
|
|
469
|
+
position: "relative",
|
|
394
470
|
}}
|
|
395
471
|
>
|
|
396
472
|
{/* Header */}
|
|
@@ -688,20 +764,20 @@ const ChildSearchModal = ({
|
|
|
688
764
|
</div>
|
|
689
765
|
|
|
690
766
|
{/* Content */}
|
|
691
|
-
<div
|
|
767
|
+
<div
|
|
692
768
|
className="overflow-hidden"
|
|
693
|
-
style={{
|
|
694
|
-
height:
|
|
695
|
-
maxHeight:
|
|
696
|
-
overflow:
|
|
697
|
-
flex:
|
|
698
|
-
position:
|
|
769
|
+
style={{
|
|
770
|
+
height: "calc(90vh - 300px)",
|
|
771
|
+
maxHeight: "calc(90vh - 300px)",
|
|
772
|
+
overflow: "hidden",
|
|
773
|
+
flex: "none",
|
|
774
|
+
position: "relative",
|
|
699
775
|
}}
|
|
700
776
|
ref={(el) => {
|
|
701
777
|
if (el) {
|
|
702
778
|
const rect = el.getBoundingClientRect();
|
|
703
779
|
const computedStyle = window.getComputedStyle(el);
|
|
704
|
-
console.log(
|
|
780
|
+
console.log("📦 Content Area Debug:", {
|
|
705
781
|
contentHeight: rect.height,
|
|
706
782
|
contentTop: rect.top,
|
|
707
783
|
contentBottom: rect.bottom,
|
|
@@ -712,7 +788,7 @@ const ChildSearchModal = ({
|
|
|
712
788
|
height: computedStyle.height,
|
|
713
789
|
overflow: computedStyle.overflow,
|
|
714
790
|
styleMaxHeight: el.style.maxHeight,
|
|
715
|
-
styleHeight: el.style.height
|
|
791
|
+
styleHeight: el.style.height,
|
|
716
792
|
});
|
|
717
793
|
}
|
|
718
794
|
}}
|
|
@@ -732,18 +808,18 @@ const ChildSearchModal = ({
|
|
|
732
808
|
)}
|
|
733
809
|
|
|
734
810
|
{!loading && !error && (
|
|
735
|
-
<div
|
|
811
|
+
<div
|
|
736
812
|
className="overflow-y-auto h-full max-h-full"
|
|
737
|
-
style={{
|
|
738
|
-
maxHeight:
|
|
739
|
-
height:
|
|
740
|
-
overflowY:
|
|
813
|
+
style={{
|
|
814
|
+
maxHeight: "100% !important",
|
|
815
|
+
height: "100% !important",
|
|
816
|
+
overflowY: "auto !important",
|
|
741
817
|
}}
|
|
742
818
|
ref={(el) => {
|
|
743
819
|
if (el) {
|
|
744
820
|
const rect = el.getBoundingClientRect();
|
|
745
821
|
const computedStyle = window.getComputedStyle(el);
|
|
746
|
-
console.log(
|
|
822
|
+
console.log("📜 Scrollable Content Debug:", {
|
|
747
823
|
scrollHeight: el.scrollHeight,
|
|
748
824
|
clientHeight: el.clientHeight,
|
|
749
825
|
scrollTop: el.scrollTop,
|
|
@@ -754,7 +830,7 @@ const ChildSearchModal = ({
|
|
|
754
830
|
height: computedStyle.height,
|
|
755
831
|
overflowY: computedStyle.overflowY,
|
|
756
832
|
styleMaxHeight: el.style.maxHeight,
|
|
757
|
-
styleHeight: el.style.height
|
|
833
|
+
styleHeight: el.style.height,
|
|
758
834
|
});
|
|
759
835
|
}
|
|
760
836
|
}}
|
|
@@ -909,7 +985,8 @@ const ChildSearchModal = ({
|
|
|
909
985
|
{multiSelect && (
|
|
910
986
|
<div className="p-6 border-t border-gray-200 dark:border-gray-700 flex items-center justify-between">
|
|
911
987
|
<div className="text-sm text-gray-600 dark:text-gray-300">
|
|
912
|
-
{selectedChildrenState.length} selected
|
|
988
|
+
{selectedChildrenState.length} selected
|
|
989
|
+
{maxSelections ? ` / ${maxSelections}` : ""}
|
|
913
990
|
</div>
|
|
914
991
|
<div className="flex items-center gap-2">
|
|
915
992
|
<button
|