@sesionario/blocks 1.10.0 → 1.12.0
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.cjs +374 -239
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +43 -3
- package/dist/index.d.ts +43 -3
- package/dist/index.js +240 -106
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
'use strict';
|
|
3
3
|
|
|
4
|
-
var
|
|
4
|
+
var React7 = require('react');
|
|
5
5
|
var lucideReact = require('lucide-react');
|
|
6
6
|
var clsx = require('clsx');
|
|
7
7
|
var tailwindMerge = require('tailwind-merge');
|
|
@@ -44,7 +44,7 @@ function _interopNamespace(e) {
|
|
|
44
44
|
return Object.freeze(n);
|
|
45
45
|
}
|
|
46
46
|
|
|
47
|
-
var
|
|
47
|
+
var React7__namespace = /*#__PURE__*/_interopNamespace(React7);
|
|
48
48
|
var AlertDialogPrimitive__namespace = /*#__PURE__*/_interopNamespace(AlertDialogPrimitive);
|
|
49
49
|
var DropdownMenuPrimitive__namespace = /*#__PURE__*/_interopNamespace(DropdownMenuPrimitive);
|
|
50
50
|
var SliderPrimitive__namespace = /*#__PURE__*/_interopNamespace(SliderPrimitive);
|
|
@@ -55,9 +55,9 @@ var RPNInput__namespace = /*#__PURE__*/_interopNamespace(RPNInput);
|
|
|
55
55
|
var flags__default = /*#__PURE__*/_interopDefault(flags);
|
|
56
56
|
var ScrollAreaPrimitive__namespace = /*#__PURE__*/_interopNamespace(ScrollAreaPrimitive);
|
|
57
57
|
|
|
58
|
-
var LanguageContext =
|
|
58
|
+
var LanguageContext = React7.createContext(null);
|
|
59
59
|
function useLanguageContext() {
|
|
60
|
-
return
|
|
60
|
+
return React7.useContext(LanguageContext);
|
|
61
61
|
}
|
|
62
62
|
function cn(...inputs) {
|
|
63
63
|
return tailwindMerge.twMerge(clsx.clsx(inputs));
|
|
@@ -464,13 +464,13 @@ function ExpandableText({
|
|
|
464
464
|
className,
|
|
465
465
|
textClassName
|
|
466
466
|
}) {
|
|
467
|
-
const [expanded, setExpanded] =
|
|
468
|
-
const [overflowing, setOverflowing] =
|
|
469
|
-
const contentRef =
|
|
470
|
-
|
|
467
|
+
const [expanded, setExpanded] = React7.useState(false);
|
|
468
|
+
const [overflowing, setOverflowing] = React7.useState(false);
|
|
469
|
+
const contentRef = React7.useRef(null);
|
|
470
|
+
React7.useEffect(() => {
|
|
471
471
|
setExpanded(false);
|
|
472
472
|
}, [children]);
|
|
473
|
-
|
|
473
|
+
React7.useLayoutEffect(() => {
|
|
474
474
|
const el = contentRef.current;
|
|
475
475
|
if (!el) return;
|
|
476
476
|
const measure = () => {
|
|
@@ -557,29 +557,29 @@ function ImageLightbox({
|
|
|
557
557
|
const previousLabel = labels?.previous ?? "Anterior";
|
|
558
558
|
const nextLabel = labels?.next ?? "Siguiente";
|
|
559
559
|
const hasMultiple = images.length > 1;
|
|
560
|
-
const [transform, setTransform] =
|
|
561
|
-
const transformRef =
|
|
560
|
+
const [transform, setTransform] = React7.useState(IDENTITY);
|
|
561
|
+
const transformRef = React7.useRef(transform);
|
|
562
562
|
transformRef.current = transform;
|
|
563
|
-
const [isSwipeDragging, setIsSwipeDragging] =
|
|
564
|
-
const [snapBack, setSnapBack] =
|
|
565
|
-
const stageRef =
|
|
566
|
-
const pointersRef =
|
|
567
|
-
const pinchStartRef =
|
|
568
|
-
const panRef =
|
|
569
|
-
const swipeRef =
|
|
570
|
-
const lastTapRef =
|
|
563
|
+
const [isSwipeDragging, setIsSwipeDragging] = React7.useState(false);
|
|
564
|
+
const [snapBack, setSnapBack] = React7.useState(false);
|
|
565
|
+
const stageRef = React7.useRef(null);
|
|
566
|
+
const pointersRef = React7.useRef(/* @__PURE__ */ new Map());
|
|
567
|
+
const pinchStartRef = React7.useRef(null);
|
|
568
|
+
const panRef = React7.useRef(null);
|
|
569
|
+
const swipeRef = React7.useRef(null);
|
|
570
|
+
const lastTapRef = React7.useRef(
|
|
571
571
|
null
|
|
572
572
|
);
|
|
573
|
-
const indexRef =
|
|
573
|
+
const indexRef = React7.useRef(index);
|
|
574
574
|
indexRef.current = index;
|
|
575
|
-
const imagesLengthRef =
|
|
575
|
+
const imagesLengthRef = React7.useRef(images.length);
|
|
576
576
|
imagesLengthRef.current = images.length;
|
|
577
|
-
const resetZoom =
|
|
577
|
+
const resetZoom = React7.useCallback(() => {
|
|
578
578
|
setTransform(IDENTITY);
|
|
579
579
|
setIsSwipeDragging(false);
|
|
580
580
|
setSnapBack(false);
|
|
581
581
|
}, []);
|
|
582
|
-
|
|
582
|
+
React7.useEffect(() => {
|
|
583
583
|
resetZoom();
|
|
584
584
|
}, [index, images[index], resetZoom]);
|
|
585
585
|
function goPrev() {
|
|
@@ -588,7 +588,7 @@ function ImageLightbox({
|
|
|
588
588
|
function goNext() {
|
|
589
589
|
onIndexChange((index + 1) % images.length);
|
|
590
590
|
}
|
|
591
|
-
|
|
591
|
+
React7.useEffect(() => {
|
|
592
592
|
function handleKeyDown(e) {
|
|
593
593
|
if (e.key === "Escape") {
|
|
594
594
|
onClose();
|
|
@@ -604,14 +604,14 @@ function ImageLightbox({
|
|
|
604
604
|
window.addEventListener("keydown", handleKeyDown);
|
|
605
605
|
return () => window.removeEventListener("keydown", handleKeyDown);
|
|
606
606
|
}, [index, images.length, hasMultiple, onClose, onIndexChange]);
|
|
607
|
-
|
|
607
|
+
React7.useEffect(() => {
|
|
608
608
|
const previousOverflow = document.body.style.overflow;
|
|
609
609
|
document.body.style.overflow = "hidden";
|
|
610
610
|
return () => {
|
|
611
611
|
document.body.style.overflow = previousOverflow;
|
|
612
612
|
};
|
|
613
613
|
}, []);
|
|
614
|
-
const stageOrigin =
|
|
614
|
+
const stageOrigin = React7.useCallback((clientX, clientY) => {
|
|
615
615
|
const stage = stageRef.current;
|
|
616
616
|
if (!stage) return { x: 0, y: 0 };
|
|
617
617
|
const rect = stage.getBoundingClientRect();
|
|
@@ -620,7 +620,7 @@ function ImageLightbox({
|
|
|
620
620
|
y: clientY - rect.top - rect.height / 2
|
|
621
621
|
};
|
|
622
622
|
}, []);
|
|
623
|
-
|
|
623
|
+
React7.useEffect(() => {
|
|
624
624
|
const stage = stageRef.current;
|
|
625
625
|
if (!stage) return;
|
|
626
626
|
const handleWheel = (e) => {
|
|
@@ -1052,18 +1052,18 @@ function ThemeSwitcher({
|
|
|
1052
1052
|
labels: userLabels
|
|
1053
1053
|
}) {
|
|
1054
1054
|
const { theme, setTheme } = nextThemes.useTheme();
|
|
1055
|
-
const [mounted, setMounted] =
|
|
1055
|
+
const [mounted, setMounted] = React7.useState(false);
|
|
1056
1056
|
const reduceMotion = framerMotion.useReducedMotion();
|
|
1057
1057
|
const sizes = sizeClasses[size];
|
|
1058
1058
|
const shapeClass = shapeClasses[shape];
|
|
1059
1059
|
const labels = { ...defaultLabels, ...userLabels };
|
|
1060
|
-
const handleThemeClick =
|
|
1060
|
+
const handleThemeClick = React7.useCallback(
|
|
1061
1061
|
(themeKey) => {
|
|
1062
1062
|
setTheme(themeKey);
|
|
1063
1063
|
},
|
|
1064
1064
|
[setTheme]
|
|
1065
1065
|
);
|
|
1066
|
-
|
|
1066
|
+
React7.useEffect(() => {
|
|
1067
1067
|
setMounted(true);
|
|
1068
1068
|
}, []);
|
|
1069
1069
|
if (!mounted) {
|
|
@@ -1605,7 +1605,7 @@ function Slider({
|
|
|
1605
1605
|
max = 100,
|
|
1606
1606
|
...props
|
|
1607
1607
|
}) {
|
|
1608
|
-
const _values =
|
|
1608
|
+
const _values = React7__namespace.useMemo(
|
|
1609
1609
|
() => Array.isArray(value) ? value : Array.isArray(defaultValue) ? defaultValue : [min, max],
|
|
1610
1610
|
[value, defaultValue, min, max]
|
|
1611
1611
|
);
|
|
@@ -1699,18 +1699,18 @@ function AvatarEditor({
|
|
|
1699
1699
|
className,
|
|
1700
1700
|
controlSize = "default"
|
|
1701
1701
|
}) {
|
|
1702
|
-
const canvasRef =
|
|
1703
|
-
const fileInputRef =
|
|
1704
|
-
const containerRef =
|
|
1705
|
-
const [image, setImage] =
|
|
1706
|
-
const [imageLoaded, setImageLoaded] =
|
|
1707
|
-
const [zoom, setZoom] =
|
|
1708
|
-
const [rotation, setRotation] =
|
|
1709
|
-
const [position, setPosition] =
|
|
1710
|
-
const [isDragging, setIsDragging] =
|
|
1711
|
-
const [dragStart, setDragStart] =
|
|
1712
|
-
const [showGrid, setShowGrid] =
|
|
1713
|
-
const generateOutput =
|
|
1702
|
+
const canvasRef = React7.useRef(null);
|
|
1703
|
+
const fileInputRef = React7.useRef(null);
|
|
1704
|
+
const containerRef = React7.useRef(null);
|
|
1705
|
+
const [image, setImage] = React7.useState(null);
|
|
1706
|
+
const [imageLoaded, setImageLoaded] = React7.useState(false);
|
|
1707
|
+
const [zoom, setZoom] = React7.useState(1);
|
|
1708
|
+
const [rotation, setRotation] = React7.useState(0);
|
|
1709
|
+
const [position, setPosition] = React7.useState({ x: 0, y: 0 });
|
|
1710
|
+
const [isDragging, setIsDragging] = React7.useState(false);
|
|
1711
|
+
const [dragStart, setDragStart] = React7.useState({ x: 0, y: 0 });
|
|
1712
|
+
const [showGrid, setShowGrid] = React7.useState(initialShowGrid);
|
|
1713
|
+
const generateOutput = React7.useCallback(() => {
|
|
1714
1714
|
if (!canvasRef.current || !image) return null;
|
|
1715
1715
|
const outputCanvas = document.createElement("canvas");
|
|
1716
1716
|
outputCanvas.width = outputSize;
|
|
@@ -1721,7 +1721,7 @@ function AvatarEditor({
|
|
|
1721
1721
|
const mimeType = `image/${outputFormat}`;
|
|
1722
1722
|
return outputCanvas.toDataURL(mimeType, outputQuality);
|
|
1723
1723
|
}, [image, outputSize, outputFormat, outputQuality]);
|
|
1724
|
-
|
|
1724
|
+
React7.useEffect(() => {
|
|
1725
1725
|
if (!canvasRef.current || !image || !imageLoaded) return;
|
|
1726
1726
|
const canvas = canvasRef.current;
|
|
1727
1727
|
const ctx = canvas.getContext("2d");
|
|
@@ -1789,12 +1789,12 @@ function AvatarEditor({
|
|
|
1789
1789
|
generateOutput,
|
|
1790
1790
|
onChange
|
|
1791
1791
|
]);
|
|
1792
|
-
const resetTransforms =
|
|
1792
|
+
const resetTransforms = React7.useCallback(() => {
|
|
1793
1793
|
setZoom(1);
|
|
1794
1794
|
setRotation(0);
|
|
1795
1795
|
setPosition({ x: 0, y: 0 });
|
|
1796
1796
|
}, []);
|
|
1797
|
-
const handleFileSelect =
|
|
1797
|
+
const handleFileSelect = React7.useCallback(
|
|
1798
1798
|
(e) => {
|
|
1799
1799
|
const file = e.target.files?.[0];
|
|
1800
1800
|
if (!file) return;
|
|
@@ -1813,7 +1813,7 @@ function AvatarEditor({
|
|
|
1813
1813
|
},
|
|
1814
1814
|
[resetTransforms]
|
|
1815
1815
|
);
|
|
1816
|
-
const handleMouseDown =
|
|
1816
|
+
const handleMouseDown = React7.useCallback(
|
|
1817
1817
|
(e) => {
|
|
1818
1818
|
if (!imageLoaded) return;
|
|
1819
1819
|
setIsDragging(true);
|
|
@@ -1821,7 +1821,7 @@ function AvatarEditor({
|
|
|
1821
1821
|
},
|
|
1822
1822
|
[imageLoaded, position]
|
|
1823
1823
|
);
|
|
1824
|
-
const handleMouseMove =
|
|
1824
|
+
const handleMouseMove = React7.useCallback(
|
|
1825
1825
|
(e) => {
|
|
1826
1826
|
if (!isDragging) return;
|
|
1827
1827
|
setPosition({
|
|
@@ -1831,10 +1831,10 @@ function AvatarEditor({
|
|
|
1831
1831
|
},
|
|
1832
1832
|
[isDragging, dragStart]
|
|
1833
1833
|
);
|
|
1834
|
-
const handleMouseUp =
|
|
1834
|
+
const handleMouseUp = React7.useCallback(() => {
|
|
1835
1835
|
setIsDragging(false);
|
|
1836
1836
|
}, []);
|
|
1837
|
-
const handleTouchStart =
|
|
1837
|
+
const handleTouchStart = React7.useCallback(
|
|
1838
1838
|
(e) => {
|
|
1839
1839
|
if (!imageLoaded) return;
|
|
1840
1840
|
const touch = e.touches[0];
|
|
@@ -1846,7 +1846,7 @@ function AvatarEditor({
|
|
|
1846
1846
|
},
|
|
1847
1847
|
[imageLoaded, position]
|
|
1848
1848
|
);
|
|
1849
|
-
const handleTouchMove =
|
|
1849
|
+
const handleTouchMove = React7.useCallback(
|
|
1850
1850
|
(e) => {
|
|
1851
1851
|
if (!isDragging) return;
|
|
1852
1852
|
const touch = e.touches[0];
|
|
@@ -1857,7 +1857,7 @@ function AvatarEditor({
|
|
|
1857
1857
|
},
|
|
1858
1858
|
[isDragging, dragStart]
|
|
1859
1859
|
);
|
|
1860
|
-
const handleDiscard =
|
|
1860
|
+
const handleDiscard = React7.useCallback(() => {
|
|
1861
1861
|
setImage(null);
|
|
1862
1862
|
setImageLoaded(false);
|
|
1863
1863
|
resetTransforms();
|
|
@@ -2406,8 +2406,8 @@ function DrawerTitle({
|
|
|
2406
2406
|
);
|
|
2407
2407
|
}
|
|
2408
2408
|
function useMediaQuery(query) {
|
|
2409
|
-
const [matches, setMatches] =
|
|
2410
|
-
|
|
2409
|
+
const [matches, setMatches] = React7.useState(false);
|
|
2410
|
+
React7.useEffect(() => {
|
|
2411
2411
|
const media = window.matchMedia(query);
|
|
2412
2412
|
if (media.matches !== matches) {
|
|
2413
2413
|
setMatches(media.matches);
|
|
@@ -2436,13 +2436,13 @@ function AvatarEditorDialog({
|
|
|
2436
2436
|
errorMessage = "Failed to save avatar. Please try again.",
|
|
2437
2437
|
className
|
|
2438
2438
|
}) {
|
|
2439
|
-
const [isOpen, setIsOpen] =
|
|
2440
|
-
const [editedValue, setEditedValue] =
|
|
2441
|
-
const [isSaving, setIsSaving] =
|
|
2442
|
-
const [feedback, setFeedback] =
|
|
2439
|
+
const [isOpen, setIsOpen] = React7.useState(false);
|
|
2440
|
+
const [editedValue, setEditedValue] = React7.useState(value ?? null);
|
|
2441
|
+
const [isSaving, setIsSaving] = React7.useState(false);
|
|
2442
|
+
const [feedback, setFeedback] = React7.useState(null);
|
|
2443
2443
|
const isMobile = useMediaQuery("(max-width: 640px)");
|
|
2444
2444
|
const caption = (placeholder ?? "").trim();
|
|
2445
|
-
const handleOpenChange =
|
|
2445
|
+
const handleOpenChange = React7.useCallback(
|
|
2446
2446
|
(open) => {
|
|
2447
2447
|
if (open) {
|
|
2448
2448
|
setEditedValue(value ?? null);
|
|
@@ -2452,7 +2452,7 @@ function AvatarEditorDialog({
|
|
|
2452
2452
|
},
|
|
2453
2453
|
[value]
|
|
2454
2454
|
);
|
|
2455
|
-
const handleAccept =
|
|
2455
|
+
const handleAccept = React7.useCallback(async () => {
|
|
2456
2456
|
if (!editedValue) return;
|
|
2457
2457
|
setIsSaving(true);
|
|
2458
2458
|
setFeedback(null);
|
|
@@ -2734,22 +2734,22 @@ function EmojiPicker({
|
|
|
2734
2734
|
recentLimit = 24,
|
|
2735
2735
|
storageKey = "blocks-emoji"
|
|
2736
2736
|
}) {
|
|
2737
|
-
const strings =
|
|
2737
|
+
const strings = React7__namespace.useMemo(
|
|
2738
2738
|
() => ({ ...DEFAULT_LABELS[locale], ...labels }),
|
|
2739
2739
|
[locale, labels]
|
|
2740
2740
|
);
|
|
2741
|
-
const titles =
|
|
2741
|
+
const titles = React7__namespace.useMemo(
|
|
2742
2742
|
() => ({ ...DEFAULT_TITLES[locale], ...labels?.categoryTitles }),
|
|
2743
2743
|
[locale, labels]
|
|
2744
2744
|
);
|
|
2745
|
-
const [query, setQuery] =
|
|
2746
|
-
const [skinTone, setSkinTone] =
|
|
2745
|
+
const [query, setQuery] = React7__namespace.useState("");
|
|
2746
|
+
const [skinTone, setSkinTone] = React7__namespace.useState(() => {
|
|
2747
2747
|
const raw = readStored(storageKey, "tone");
|
|
2748
2748
|
const parsed = raw != null ? Number.parseInt(raw, 10) : 0;
|
|
2749
2749
|
return parsed >= 0 && parsed <= 5 ? parsed : 0;
|
|
2750
2750
|
});
|
|
2751
|
-
const [toneOpen, setToneOpen] =
|
|
2752
|
-
const [recents, setRecents] =
|
|
2751
|
+
const [toneOpen, setToneOpen] = React7__namespace.useState(false);
|
|
2752
|
+
const [recents, setRecents] = React7__namespace.useState(() => {
|
|
2753
2753
|
const raw = readStored(storageKey, "recent");
|
|
2754
2754
|
if (!raw) return [];
|
|
2755
2755
|
try {
|
|
@@ -2759,13 +2759,13 @@ function EmojiPicker({
|
|
|
2759
2759
|
return [];
|
|
2760
2760
|
}
|
|
2761
2761
|
});
|
|
2762
|
-
const [focusIndex, setFocusIndex] =
|
|
2763
|
-
const scrollRef =
|
|
2764
|
-
const sectionRefs =
|
|
2762
|
+
const [focusIndex, setFocusIndex] = React7__namespace.useState(-1);
|
|
2763
|
+
const scrollRef = React7__namespace.useRef(null);
|
|
2764
|
+
const sectionRefs = React7__namespace.useRef(
|
|
2765
2765
|
/* @__PURE__ */ new Map()
|
|
2766
2766
|
);
|
|
2767
2767
|
const normalizedQuery = normalizeEmojiQuery(query);
|
|
2768
|
-
const sections =
|
|
2768
|
+
const sections = React7__namespace.useMemo(() => {
|
|
2769
2769
|
if (normalizedQuery) return [];
|
|
2770
2770
|
const result = [];
|
|
2771
2771
|
if (recents.length > 0) {
|
|
@@ -2784,7 +2784,7 @@ function EmojiPicker({
|
|
|
2784
2784
|
}
|
|
2785
2785
|
return result;
|
|
2786
2786
|
}, [normalizedQuery, recents, titles]);
|
|
2787
|
-
const searchResults =
|
|
2787
|
+
const searchResults = React7__namespace.useMemo(() => {
|
|
2788
2788
|
if (!normalizedQuery) return [];
|
|
2789
2789
|
const out = [];
|
|
2790
2790
|
for (const category of EMOJI_CATEGORIES) {
|
|
@@ -2794,21 +2794,21 @@ function EmojiPicker({
|
|
|
2794
2794
|
}
|
|
2795
2795
|
return out;
|
|
2796
2796
|
}, [normalizedQuery]);
|
|
2797
|
-
const flatList =
|
|
2797
|
+
const flatList = React7__namespace.useMemo(() => {
|
|
2798
2798
|
if (normalizedQuery) return searchResults;
|
|
2799
2799
|
return sections.flatMap((s) => s.emojis);
|
|
2800
2800
|
}, [normalizedQuery, searchResults, sections]);
|
|
2801
|
-
|
|
2801
|
+
React7__namespace.useEffect(() => {
|
|
2802
2802
|
setFocusIndex(-1);
|
|
2803
2803
|
}, [normalizedQuery]);
|
|
2804
|
-
|
|
2804
|
+
React7__namespace.useEffect(() => {
|
|
2805
2805
|
if (focusIndex < 0) return;
|
|
2806
2806
|
const el = scrollRef.current?.querySelector(
|
|
2807
2807
|
`[data-emoji-index="${focusIndex}"]`
|
|
2808
2808
|
);
|
|
2809
2809
|
el?.focus();
|
|
2810
2810
|
}, [focusIndex]);
|
|
2811
|
-
const commitRecent =
|
|
2811
|
+
const commitRecent = React7__namespace.useCallback(
|
|
2812
2812
|
(glyph) => {
|
|
2813
2813
|
setRecents((prev) => {
|
|
2814
2814
|
const next = [glyph, ...prev.filter((e) => e !== glyph)].slice(
|
|
@@ -2821,14 +2821,14 @@ function EmojiPicker({
|
|
|
2821
2821
|
},
|
|
2822
2822
|
[recentLimit, storageKey]
|
|
2823
2823
|
);
|
|
2824
|
-
const handleSelect =
|
|
2824
|
+
const handleSelect = React7__namespace.useCallback(
|
|
2825
2825
|
(glyph) => {
|
|
2826
2826
|
commitRecent(glyph);
|
|
2827
2827
|
onSelect(glyph);
|
|
2828
2828
|
},
|
|
2829
2829
|
[commitRecent, onSelect]
|
|
2830
2830
|
);
|
|
2831
|
-
const chooseTone =
|
|
2831
|
+
const chooseTone = React7__namespace.useCallback(
|
|
2832
2832
|
(tone) => {
|
|
2833
2833
|
setSkinTone(tone);
|
|
2834
2834
|
setToneOpen(false);
|
|
@@ -2988,8 +2988,8 @@ function EmojiPicker({
|
|
|
2988
2988
|
{
|
|
2989
2989
|
ref: scrollRef,
|
|
2990
2990
|
onKeyDown: handleGridKeyDown,
|
|
2991
|
-
className: "h-64 overflow-x-hidden overflow-y-auto
|
|
2992
|
-
children: normalizedQuery ? searchResults.length === 0 ? /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-muted-foreground py-8 text-center text-sm", children: strings.noResults }) : /* @__PURE__ */ jsxRuntime.jsx(
|
|
2991
|
+
className: "h-64 overflow-x-hidden overflow-y-auto px-2 pb-2",
|
|
2992
|
+
children: normalizedQuery ? searchResults.length === 0 ? /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-muted-foreground py-8 text-center text-sm", children: strings.noResults }) : /* @__PURE__ */ jsxRuntime.jsx("div", { className: "pt-2", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
2993
2993
|
EmojiGrid,
|
|
2994
2994
|
{
|
|
2995
2995
|
emojis: searchResults,
|
|
@@ -2998,7 +2998,7 @@ function EmojiPicker({
|
|
|
2998
2998
|
skinTone,
|
|
2999
2999
|
onSelect: handleSelect
|
|
3000
3000
|
}
|
|
3001
|
-
) : sections.map((section) => {
|
|
3001
|
+
) }) : sections.map((section) => {
|
|
3002
3002
|
const startIndex = flatOffset;
|
|
3003
3003
|
flatOffset += section.emojis.length;
|
|
3004
3004
|
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
@@ -3009,7 +3009,7 @@ function EmojiPicker({
|
|
|
3009
3009
|
},
|
|
3010
3010
|
className: "mb-2",
|
|
3011
3011
|
children: [
|
|
3012
|
-
/* @__PURE__ */ jsxRuntime.jsx("h3", { className: "text-muted-foreground bg-popover sticky top-0 z-[1] px-
|
|
3012
|
+
/* @__PURE__ */ jsxRuntime.jsx("h3", { className: "text-muted-foreground bg-popover sticky top-0 z-[1] -mx-2 px-3 pt-2 pb-1 text-xs font-medium", children: section.title }),
|
|
3013
3013
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
3014
3014
|
"div",
|
|
3015
3015
|
{
|
|
@@ -3130,21 +3130,21 @@ function EmojiPickerPopover({
|
|
|
3130
3130
|
align = "end",
|
|
3131
3131
|
open,
|
|
3132
3132
|
onOpenChange,
|
|
3133
|
-
keepOpenOnSelect =
|
|
3133
|
+
keepOpenOnSelect = true,
|
|
3134
3134
|
locale = "en",
|
|
3135
3135
|
...pickerProps
|
|
3136
3136
|
}) {
|
|
3137
|
-
const [internalOpen, setInternalOpen] =
|
|
3137
|
+
const [internalOpen, setInternalOpen] = React7__namespace.useState(false);
|
|
3138
3138
|
const isControlled = open !== void 0;
|
|
3139
3139
|
const isOpen = isControlled ? open : internalOpen;
|
|
3140
|
-
const setOpen =
|
|
3140
|
+
const setOpen = React7__namespace.useCallback(
|
|
3141
3141
|
(next) => {
|
|
3142
3142
|
if (!isControlled) setInternalOpen(next);
|
|
3143
3143
|
onOpenChange?.(next);
|
|
3144
3144
|
},
|
|
3145
3145
|
[isControlled, onOpenChange]
|
|
3146
3146
|
);
|
|
3147
|
-
const handleSelect =
|
|
3147
|
+
const handleSelect = React7__namespace.useCallback(
|
|
3148
3148
|
(emoji) => {
|
|
3149
3149
|
onSelect(emoji);
|
|
3150
3150
|
if (!keepOpenOnSelect) setOpen(false);
|
|
@@ -3164,7 +3164,16 @@ function EmojiPickerPopover({
|
|
|
3164
3164
|
children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Smile, { className: "size-5" })
|
|
3165
3165
|
}
|
|
3166
3166
|
) }),
|
|
3167
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
3167
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
3168
|
+
PopoverContent,
|
|
3169
|
+
{
|
|
3170
|
+
side,
|
|
3171
|
+
align,
|
|
3172
|
+
className: "w-auto p-0",
|
|
3173
|
+
onFocusOutside: (e) => e.preventDefault(),
|
|
3174
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(EmojiPicker, { onSelect: handleSelect, locale, ...pickerProps })
|
|
3175
|
+
}
|
|
3176
|
+
)
|
|
3168
3177
|
] });
|
|
3169
3178
|
}
|
|
3170
3179
|
|
|
@@ -3177,8 +3186,10 @@ function insertAtCaret(element, value, text) {
|
|
|
3177
3186
|
caret: start + text.length
|
|
3178
3187
|
};
|
|
3179
3188
|
}
|
|
3180
|
-
|
|
3181
|
-
|
|
3189
|
+
|
|
3190
|
+
// src/components/emoji/emoji-field-shared.ts
|
|
3191
|
+
var emojiFieldWrapperClassName = "relative w-full rounded-md border border-input bg-transparent shadow-xs transition-[color,box-shadow] focus-within:border-ring focus-within:ring-[3px] focus-within:ring-ring/50 has-[[aria-invalid=true]]:border-destructive has-[[aria-invalid=true]]:ring-destructive/20 has-[:disabled]:opacity-50 dark:bg-input/30 dark:has-[[aria-invalid=true]]:ring-destructive/40";
|
|
3192
|
+
var emojiFieldResetClassName = "border-0 bg-transparent shadow-none focus-visible:border-transparent focus-visible:ring-0 dark:bg-transparent";
|
|
3182
3193
|
function mergeRefs(...refs) {
|
|
3183
3194
|
return (node) => {
|
|
3184
3195
|
for (const ref of refs) {
|
|
@@ -3202,7 +3213,7 @@ function emitChange(element, nextValue, onChange) {
|
|
|
3202
3213
|
});
|
|
3203
3214
|
}
|
|
3204
3215
|
function useEmojiInsert(fieldRef, value, onChange) {
|
|
3205
|
-
return
|
|
3216
|
+
return React7__namespace.useCallback(
|
|
3206
3217
|
(emoji) => {
|
|
3207
3218
|
const el = fieldRef.current;
|
|
3208
3219
|
const current = value !== void 0 && value !== null ? String(value) : el?.value ?? "";
|
|
@@ -3223,7 +3234,7 @@ function useEmojiInsert(fieldRef, value, onChange) {
|
|
|
3223
3234
|
[fieldRef, value, onChange]
|
|
3224
3235
|
);
|
|
3225
3236
|
}
|
|
3226
|
-
var EmojiTextarea =
|
|
3237
|
+
var EmojiTextarea = React7__namespace.forwardRef(
|
|
3227
3238
|
function EmojiTextarea2({
|
|
3228
3239
|
className,
|
|
3229
3240
|
locale = "en",
|
|
@@ -3243,10 +3254,10 @@ var EmojiTextarea = React6__namespace.forwardRef(
|
|
|
3243
3254
|
emojiTriggerClassName,
|
|
3244
3255
|
...props
|
|
3245
3256
|
}, ref) {
|
|
3246
|
-
const fieldRef =
|
|
3257
|
+
const fieldRef = React7__namespace.useRef(null);
|
|
3247
3258
|
const handleEmojiSelect = useEmojiInsert(fieldRef, value, onChange);
|
|
3248
3259
|
const pickerDisabled = Boolean(disabled || readOnly);
|
|
3249
|
-
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: cn(
|
|
3260
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: cn(emojiFieldWrapperClassName, className), children: [
|
|
3250
3261
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
3251
3262
|
"textarea",
|
|
3252
3263
|
{
|
|
@@ -3258,7 +3269,7 @@ var EmojiTextarea = React6__namespace.forwardRef(
|
|
|
3258
3269
|
onChange,
|
|
3259
3270
|
className: cn(
|
|
3260
3271
|
"placeholder:text-muted-foreground flex min-h-20 w-full rounded-md px-3 py-2 pb-9 pr-10 text-base outline-none transition-[color,box-shadow] disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",
|
|
3261
|
-
|
|
3272
|
+
emojiFieldResetClassName,
|
|
3262
3273
|
className
|
|
3263
3274
|
),
|
|
3264
3275
|
...props
|
|
@@ -3289,7 +3300,7 @@ var EmojiTextarea = React6__namespace.forwardRef(
|
|
|
3289
3300
|
}
|
|
3290
3301
|
);
|
|
3291
3302
|
EmojiTextarea.displayName = "EmojiTextarea";
|
|
3292
|
-
var EmojiInput =
|
|
3303
|
+
var EmojiInput = React7__namespace.forwardRef(
|
|
3293
3304
|
function EmojiInput2({
|
|
3294
3305
|
className,
|
|
3295
3306
|
locale = "en",
|
|
@@ -3310,10 +3321,10 @@ var EmojiInput = React6__namespace.forwardRef(
|
|
|
3310
3321
|
emojiTriggerClassName,
|
|
3311
3322
|
...props
|
|
3312
3323
|
}, ref) {
|
|
3313
|
-
const fieldRef =
|
|
3324
|
+
const fieldRef = React7__namespace.useRef(null);
|
|
3314
3325
|
const handleEmojiSelect = useEmojiInsert(fieldRef, value, onChange);
|
|
3315
3326
|
const pickerDisabled = Boolean(disabled || readOnly);
|
|
3316
|
-
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: cn(
|
|
3327
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: cn(emojiFieldWrapperClassName, className), children: [
|
|
3317
3328
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
3318
3329
|
"input",
|
|
3319
3330
|
{
|
|
@@ -3326,7 +3337,7 @@ var EmojiInput = React6__namespace.forwardRef(
|
|
|
3326
3337
|
onChange,
|
|
3327
3338
|
className: cn(
|
|
3328
3339
|
"placeholder:text-muted-foreground flex h-9 w-full min-w-0 rounded-md px-3 py-1 pr-10 text-base outline-none transition-[color,box-shadow] selection:bg-primary selection:text-primary-foreground disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",
|
|
3329
|
-
|
|
3340
|
+
emojiFieldResetClassName,
|
|
3330
3341
|
className
|
|
3331
3342
|
),
|
|
3332
3343
|
...props
|
|
@@ -3518,27 +3529,27 @@ function useHlsPlayback({
|
|
|
3518
3529
|
onError,
|
|
3519
3530
|
onPlayingChange
|
|
3520
3531
|
}) {
|
|
3521
|
-
const videoRef =
|
|
3522
|
-
const hlsRef =
|
|
3523
|
-
const [state, setState] =
|
|
3524
|
-
const [qualities, setQualities] =
|
|
3525
|
-
const [activeLevel, setActiveLevel] =
|
|
3526
|
-
const [autoplayState, setAutoplayState] =
|
|
3527
|
-
const [error, setError] =
|
|
3528
|
-
const [reloadKey, setReloadKey] =
|
|
3529
|
-
const onErrorRef =
|
|
3530
|
-
const onPlayingChangeRef =
|
|
3531
|
-
|
|
3532
|
+
const videoRef = React7__namespace.useRef(null);
|
|
3533
|
+
const hlsRef = React7__namespace.useRef(null);
|
|
3534
|
+
const [state, setState] = React7__namespace.useState("idle");
|
|
3535
|
+
const [qualities, setQualities] = React7__namespace.useState([]);
|
|
3536
|
+
const [activeLevel, setActiveLevel] = React7__namespace.useState(-1);
|
|
3537
|
+
const [autoplayState, setAutoplayState] = React7__namespace.useState("none");
|
|
3538
|
+
const [error, setError] = React7__namespace.useState(null);
|
|
3539
|
+
const [reloadKey, setReloadKey] = React7__namespace.useState(0);
|
|
3540
|
+
const onErrorRef = React7__namespace.useRef(onError);
|
|
3541
|
+
const onPlayingChangeRef = React7__namespace.useRef(onPlayingChange);
|
|
3542
|
+
React7__namespace.useEffect(() => {
|
|
3532
3543
|
onErrorRef.current = onError;
|
|
3533
3544
|
onPlayingChangeRef.current = onPlayingChange;
|
|
3534
3545
|
}, [onError, onPlayingChange]);
|
|
3535
|
-
const retry =
|
|
3546
|
+
const retry = React7__namespace.useCallback(() => {
|
|
3536
3547
|
setError(null);
|
|
3537
3548
|
setState("loading");
|
|
3538
3549
|
setAutoplayState("none");
|
|
3539
3550
|
setReloadKey((k) => k + 1);
|
|
3540
3551
|
}, []);
|
|
3541
|
-
|
|
3552
|
+
React7__namespace.useEffect(() => {
|
|
3542
3553
|
const media = videoRef.current;
|
|
3543
3554
|
if (!media || !src || !active) {
|
|
3544
3555
|
setState("idle");
|
|
@@ -3750,7 +3761,7 @@ function useHlsPlayback({
|
|
|
3750
3761
|
destroyHls();
|
|
3751
3762
|
};
|
|
3752
3763
|
}, [src, mode, active, autoPlay, muted, reloadKey]);
|
|
3753
|
-
const setLevel =
|
|
3764
|
+
const setLevel = React7__namespace.useCallback((index) => {
|
|
3754
3765
|
const hls = hlsRef.current;
|
|
3755
3766
|
if (!hls) return;
|
|
3756
3767
|
hls.nextLevel = index;
|
|
@@ -3833,12 +3844,12 @@ function VideoPlayer({
|
|
|
3833
3844
|
className
|
|
3834
3845
|
}) {
|
|
3835
3846
|
const t = { ...DEFAULT_LABELS2, ...labels };
|
|
3836
|
-
const containerRef =
|
|
3837
|
-
const firstPlayFiredRef =
|
|
3838
|
-
const [userStarted, setUserStarted] =
|
|
3847
|
+
const containerRef = React7__namespace.useRef(null);
|
|
3848
|
+
const firstPlayFiredRef = React7__namespace.useRef(false);
|
|
3849
|
+
const [userStarted, setUserStarted] = React7__namespace.useState(false);
|
|
3839
3850
|
const active = autoPlay || !poster || userStarted;
|
|
3840
3851
|
const autoplayActive = autoPlay || userStarted;
|
|
3841
|
-
const handlePlayingChange =
|
|
3852
|
+
const handlePlayingChange = React7__namespace.useCallback(
|
|
3842
3853
|
(playing) => {
|
|
3843
3854
|
setIsPlaying(playing);
|
|
3844
3855
|
if (playing && !firstPlayFiredRef.current) {
|
|
@@ -3867,25 +3878,25 @@ function VideoPlayer({
|
|
|
3867
3878
|
onError,
|
|
3868
3879
|
onPlayingChange: handlePlayingChange
|
|
3869
3880
|
});
|
|
3870
|
-
const [isPlaying, setIsPlaying] =
|
|
3871
|
-
const [isMuted, setIsMuted] =
|
|
3872
|
-
const [volume, setVolume] =
|
|
3873
|
-
const [currentTime, setCurrentTime] =
|
|
3874
|
-
const [duration, setDuration] =
|
|
3875
|
-
const [buffered, setBuffered] =
|
|
3876
|
-
const [isFullscreen, setIsFullscreen] =
|
|
3877
|
-
const [pipActive, setPipActive] =
|
|
3878
|
-
const [controlsVisible, setControlsVisible] =
|
|
3879
|
-
const [playbackRate, setPlaybackRate] =
|
|
3880
|
-
const [openMenu, setOpenMenu] =
|
|
3881
|
+
const [isPlaying, setIsPlaying] = React7__namespace.useState(false);
|
|
3882
|
+
const [isMuted, setIsMuted] = React7__namespace.useState(muted);
|
|
3883
|
+
const [volume, setVolume] = React7__namespace.useState(1);
|
|
3884
|
+
const [currentTime, setCurrentTime] = React7__namespace.useState(0);
|
|
3885
|
+
const [duration, setDuration] = React7__namespace.useState(0);
|
|
3886
|
+
const [buffered, setBuffered] = React7__namespace.useState(0);
|
|
3887
|
+
const [isFullscreen, setIsFullscreen] = React7__namespace.useState(false);
|
|
3888
|
+
const [pipActive, setPipActive] = React7__namespace.useState(false);
|
|
3889
|
+
const [controlsVisible, setControlsVisible] = React7__namespace.useState(true);
|
|
3890
|
+
const [playbackRate, setPlaybackRate] = React7__namespace.useState(1);
|
|
3891
|
+
const [openMenu, setOpenMenu] = React7__namespace.useState(
|
|
3881
3892
|
null
|
|
3882
3893
|
);
|
|
3883
|
-
const [behindLive, setBehindLive] =
|
|
3884
|
-
const [webkitFullscreenSupported, setWebkitFullscreenSupported] =
|
|
3885
|
-
const hideTimerRef =
|
|
3894
|
+
const [behindLive, setBehindLive] = React7__namespace.useState(false);
|
|
3895
|
+
const [webkitFullscreenSupported, setWebkitFullscreenSupported] = React7__namespace.useState(false);
|
|
3896
|
+
const hideTimerRef = React7__namespace.useRef(null);
|
|
3886
3897
|
const pipSupported = typeof document !== "undefined" && "pictureInPictureEnabled" in document && document.pictureInPictureEnabled;
|
|
3887
3898
|
const fullscreenSupported = hasStandardFullscreen() || webkitFullscreenSupported;
|
|
3888
|
-
|
|
3899
|
+
React7__namespace.useEffect(() => {
|
|
3889
3900
|
const video = videoRef.current;
|
|
3890
3901
|
if (!video || !active) return;
|
|
3891
3902
|
const onTimeUpdate = () => {
|
|
@@ -3918,15 +3929,15 @@ function VideoPlayer({
|
|
|
3918
3929
|
video.removeEventListener("ratechange", onRate);
|
|
3919
3930
|
};
|
|
3920
3931
|
}, [videoRef, active, mode]);
|
|
3921
|
-
|
|
3932
|
+
React7__namespace.useEffect(() => {
|
|
3922
3933
|
setWebkitFullscreenSupported(hasWebkitVideoFullscreen(videoRef.current));
|
|
3923
3934
|
}, [videoRef, active]);
|
|
3924
|
-
|
|
3935
|
+
React7__namespace.useEffect(() => {
|
|
3925
3936
|
const onFsChange = () => setIsFullscreen(document.fullscreenElement === containerRef.current);
|
|
3926
3937
|
document.addEventListener("fullscreenchange", onFsChange);
|
|
3927
3938
|
return () => document.removeEventListener("fullscreenchange", onFsChange);
|
|
3928
3939
|
}, []);
|
|
3929
|
-
|
|
3940
|
+
React7__namespace.useEffect(() => {
|
|
3930
3941
|
const video = asWebkitVideo(videoRef.current);
|
|
3931
3942
|
if (!video) return;
|
|
3932
3943
|
const onBegin = () => setIsFullscreen(true);
|
|
@@ -3938,7 +3949,7 @@ function VideoPlayer({
|
|
|
3938
3949
|
video.removeEventListener("webkitendfullscreen", onEnd);
|
|
3939
3950
|
};
|
|
3940
3951
|
}, [videoRef, active]);
|
|
3941
|
-
|
|
3952
|
+
React7__namespace.useEffect(() => {
|
|
3942
3953
|
const video = videoRef.current;
|
|
3943
3954
|
if (!video) return;
|
|
3944
3955
|
const onEnter = () => setPipActive(true);
|
|
@@ -3950,18 +3961,18 @@ function VideoPlayer({
|
|
|
3950
3961
|
video.removeEventListener("leavepictureinpicture", onLeave);
|
|
3951
3962
|
};
|
|
3952
3963
|
}, [videoRef]);
|
|
3953
|
-
const scheduleHide =
|
|
3964
|
+
const scheduleHide = React7__namespace.useCallback(() => {
|
|
3954
3965
|
if (hideTimerRef.current) clearTimeout(hideTimerRef.current);
|
|
3955
3966
|
hideTimerRef.current = setTimeout(() => {
|
|
3956
3967
|
setControlsVisible(false);
|
|
3957
3968
|
setOpenMenu(null);
|
|
3958
3969
|
}, CONTROLS_HIDE_MS);
|
|
3959
3970
|
}, []);
|
|
3960
|
-
const revealControls =
|
|
3971
|
+
const revealControls = React7__namespace.useCallback(() => {
|
|
3961
3972
|
setControlsVisible(true);
|
|
3962
3973
|
scheduleHide();
|
|
3963
3974
|
}, [scheduleHide]);
|
|
3964
|
-
|
|
3975
|
+
React7__namespace.useEffect(() => {
|
|
3965
3976
|
return () => {
|
|
3966
3977
|
if (hideTimerRef.current) clearTimeout(hideTimerRef.current);
|
|
3967
3978
|
};
|
|
@@ -4424,8 +4435,8 @@ function MenuItem({
|
|
|
4424
4435
|
);
|
|
4425
4436
|
}
|
|
4426
4437
|
function usePlaybackStats(statsUrl, { intervalMs = 15e3, enabled = true } = {}) {
|
|
4427
|
-
const [stats, setStats] =
|
|
4428
|
-
|
|
4438
|
+
const [stats, setStats] = React7__namespace.useState({});
|
|
4439
|
+
React7__namespace.useEffect(() => {
|
|
4429
4440
|
if (!statsUrl || !enabled) return;
|
|
4430
4441
|
let cancelled = false;
|
|
4431
4442
|
const controller = new AbortController();
|
|
@@ -4455,16 +4466,16 @@ function usePlaybackStats(statsUrl, { intervalMs = 15e3, enabled = true } = {})
|
|
|
4455
4466
|
return stats;
|
|
4456
4467
|
}
|
|
4457
4468
|
function useDebouncedValue(value, delayMs) {
|
|
4458
|
-
const [debounced, setDebounced] =
|
|
4459
|
-
|
|
4469
|
+
const [debounced, setDebounced] = React7.useState(value);
|
|
4470
|
+
React7.useEffect(() => {
|
|
4460
4471
|
const id = window.setTimeout(() => setDebounced(value), delayMs);
|
|
4461
4472
|
return () => window.clearTimeout(id);
|
|
4462
4473
|
}, [value, delayMs]);
|
|
4463
4474
|
return debounced;
|
|
4464
4475
|
}
|
|
4465
4476
|
function useDebouncedValueStrict(value, delayMs) {
|
|
4466
|
-
const [debounced, setDebounced] =
|
|
4467
|
-
|
|
4477
|
+
const [debounced, setDebounced] = React7.useState(void 0);
|
|
4478
|
+
React7.useEffect(() => {
|
|
4468
4479
|
setDebounced(void 0);
|
|
4469
4480
|
const id = window.setTimeout(() => setDebounced(value), delayMs);
|
|
4470
4481
|
return () => window.clearTimeout(id);
|
|
@@ -4472,8 +4483,8 @@ function useDebouncedValueStrict(value, delayMs) {
|
|
|
4472
4483
|
return debounced;
|
|
4473
4484
|
}
|
|
4474
4485
|
function useMediaQuery2(query) {
|
|
4475
|
-
const [matches, setMatches] =
|
|
4476
|
-
|
|
4486
|
+
const [matches, setMatches] = React7.useState(false);
|
|
4487
|
+
React7.useEffect(() => {
|
|
4477
4488
|
if (typeof window === "undefined" || !window.matchMedia) return;
|
|
4478
4489
|
const mql = window.matchMedia(query);
|
|
4479
4490
|
const onChange = () => setMatches(mql.matches);
|
|
@@ -4485,9 +4496,9 @@ function useMediaQuery2(query) {
|
|
|
4485
4496
|
}
|
|
4486
4497
|
function useSearchHotkey(options = {}) {
|
|
4487
4498
|
const { defaultOpen = false, disabled = false } = options;
|
|
4488
|
-
const [open, setOpen] =
|
|
4489
|
-
const toggle =
|
|
4490
|
-
|
|
4499
|
+
const [open, setOpen] = React7.useState(defaultOpen);
|
|
4500
|
+
const toggle = React7.useCallback(() => setOpen((prev) => !prev), []);
|
|
4501
|
+
React7.useEffect(() => {
|
|
4491
4502
|
if (disabled) return;
|
|
4492
4503
|
function handleKeyDown(event) {
|
|
4493
4504
|
if (event.key.toLowerCase() !== "k") return;
|
|
@@ -4902,26 +4913,26 @@ function SearchablePicker(props) {
|
|
|
4902
4913
|
const labels = { ...defaultLabels3, ...userLabels };
|
|
4903
4914
|
const resolvedEmptyLabel = emptyLabel ?? labels.emptyOption;
|
|
4904
4915
|
const isMobile = useMediaQuery2("(max-width: 767px)");
|
|
4905
|
-
const generatedId =
|
|
4916
|
+
const generatedId = React7.useId();
|
|
4906
4917
|
const triggerId = id ?? generatedId;
|
|
4907
|
-
const [uncontrolledOpen, setUncontrolledOpen] =
|
|
4918
|
+
const [uncontrolledOpen, setUncontrolledOpen] = React7.useState(false);
|
|
4908
4919
|
const open = openProp ?? uncontrolledOpen;
|
|
4909
|
-
const setOpen =
|
|
4920
|
+
const setOpen = React7.useCallback(
|
|
4910
4921
|
(next) => {
|
|
4911
4922
|
onOpenChange?.(next);
|
|
4912
4923
|
if (openProp === void 0) setUncontrolledOpen(next);
|
|
4913
4924
|
},
|
|
4914
4925
|
[onOpenChange, openProp]
|
|
4915
4926
|
);
|
|
4916
|
-
const [query, setQuery] =
|
|
4917
|
-
const [remoteItems, setRemoteItems] =
|
|
4918
|
-
const [isLoading, setIsLoading] =
|
|
4919
|
-
const [hasError, setHasError] =
|
|
4920
|
-
const [isLoadingMore, setIsLoadingMore] =
|
|
4927
|
+
const [query, setQuery] = React7.useState("");
|
|
4928
|
+
const [remoteItems, setRemoteItems] = React7.useState([]);
|
|
4929
|
+
const [isLoading, setIsLoading] = React7.useState(false);
|
|
4930
|
+
const [hasError, setHasError] = React7.useState(false);
|
|
4931
|
+
const [isLoadingMore, setIsLoadingMore] = React7.useState(false);
|
|
4921
4932
|
const debouncedQuery = useDebouncedValue(query, debounceMs);
|
|
4922
|
-
const requestIdRef =
|
|
4923
|
-
const knownItemsRef =
|
|
4924
|
-
const rememberItems =
|
|
4933
|
+
const requestIdRef = React7.useRef(0);
|
|
4934
|
+
const knownItemsRef = React7.useRef(/* @__PURE__ */ new Map());
|
|
4935
|
+
const rememberItems = React7.useCallback(
|
|
4925
4936
|
(items) => {
|
|
4926
4937
|
for (const item of items) {
|
|
4927
4938
|
knownItemsRef.current.set(getOptionValue(item), item);
|
|
@@ -4929,12 +4940,12 @@ function SearchablePicker(props) {
|
|
|
4929
4940
|
},
|
|
4930
4941
|
[getOptionValue]
|
|
4931
4942
|
);
|
|
4932
|
-
|
|
4943
|
+
React7.useEffect(() => {
|
|
4933
4944
|
if (options) rememberItems(options);
|
|
4934
4945
|
if (pinned?.recommended) rememberItems(pinned.recommended);
|
|
4935
4946
|
if (pinned?.recent) rememberItems(pinned.recent);
|
|
4936
4947
|
}, [options, pinned, rememberItems]);
|
|
4937
|
-
|
|
4948
|
+
React7.useEffect(() => {
|
|
4938
4949
|
if (!open) {
|
|
4939
4950
|
setQuery("");
|
|
4940
4951
|
setRemoteItems([]);
|
|
@@ -4944,7 +4955,7 @@ function SearchablePicker(props) {
|
|
|
4944
4955
|
}, [open]);
|
|
4945
4956
|
const trimmedDebounced = debouncedQuery.trim();
|
|
4946
4957
|
const shouldFetch = Boolean(fetchOptions) && open && trimmedDebounced.length >= minQueryLength && (trimmedDebounced.length > 0 || !options);
|
|
4947
|
-
|
|
4958
|
+
React7.useEffect(() => {
|
|
4948
4959
|
if (!shouldFetch || !fetchOptions) {
|
|
4949
4960
|
if (!trimmedDebounced) {
|
|
4950
4961
|
setRemoteItems([]);
|
|
@@ -4969,7 +4980,7 @@ function SearchablePicker(props) {
|
|
|
4969
4980
|
setIsLoading(false);
|
|
4970
4981
|
});
|
|
4971
4982
|
}, [shouldFetch, fetchOptions, trimmedDebounced, rememberItems]);
|
|
4972
|
-
const selectedValues =
|
|
4983
|
+
const selectedValues = React7.useMemo(() => {
|
|
4973
4984
|
if (mode === "multiple") {
|
|
4974
4985
|
const multiValue = props.value ?? [];
|
|
4975
4986
|
return new Set(multiValue);
|
|
@@ -4978,12 +4989,12 @@ function SearchablePicker(props) {
|
|
|
4978
4989
|
return singleValue ? /* @__PURE__ */ new Set([singleValue]) : /* @__PURE__ */ new Set();
|
|
4979
4990
|
}, [mode, props]);
|
|
4980
4991
|
const selectedValueKey = mode === "multiple" ? (props.value ?? []).join("\0") : props.value ?? "";
|
|
4981
|
-
const selectedItems =
|
|
4992
|
+
const selectedItems = React7.useMemo(() => {
|
|
4982
4993
|
const values = mode === "multiple" ? selectedValueKey ? selectedValueKey.split("\0") : [] : selectedValueKey ? [selectedValueKey] : [];
|
|
4983
4994
|
return values.map((value) => knownItemsRef.current.get(value)).filter((item) => item !== void 0);
|
|
4984
4995
|
}, [mode, selectedValueKey, options, pinned, remoteItems]);
|
|
4985
4996
|
const queryForFilter = query.trim();
|
|
4986
|
-
const recommended =
|
|
4997
|
+
const recommended = React7.useMemo(() => {
|
|
4987
4998
|
if (queryForFilter) return [];
|
|
4988
4999
|
const pinnedValues = /* @__PURE__ */ new Set();
|
|
4989
5000
|
const items = dedupeByValue(
|
|
@@ -4992,7 +5003,7 @@ function SearchablePicker(props) {
|
|
|
4992
5003
|
for (const entry of items) pinnedValues.add(entry.value);
|
|
4993
5004
|
return items;
|
|
4994
5005
|
}, [queryForFilter, pinned?.recommended, getOptionValue, getOptionLabel]);
|
|
4995
|
-
const recent =
|
|
5006
|
+
const recent = React7.useMemo(() => {
|
|
4996
5007
|
if (queryForFilter) return [];
|
|
4997
5008
|
const exclude = new Set(recommended.map((e) => e.value));
|
|
4998
5009
|
return dedupeByValue(
|
|
@@ -5006,13 +5017,13 @@ function SearchablePicker(props) {
|
|
|
5006
5017
|
getOptionValue,
|
|
5007
5018
|
getOptionLabel
|
|
5008
5019
|
]);
|
|
5009
|
-
const pinnedValueSet =
|
|
5020
|
+
const pinnedValueSet = React7.useMemo(() => {
|
|
5010
5021
|
const set = /* @__PURE__ */ new Set();
|
|
5011
5022
|
for (const entry of recommended) set.add(entry.value);
|
|
5012
5023
|
for (const entry of recent) set.add(entry.value);
|
|
5013
5024
|
return set;
|
|
5014
5025
|
}, [recommended, recent]);
|
|
5015
|
-
const results =
|
|
5026
|
+
const results = React7.useMemo(() => {
|
|
5016
5027
|
const usingRemote = Boolean(fetchOptions) && trimmedDebounced.length >= minQueryLength && (trimmedDebounced.length > 0 || !options);
|
|
5017
5028
|
if (usingRemote) {
|
|
5018
5029
|
return dedupeByValue(
|
|
@@ -5038,7 +5049,7 @@ function SearchablePicker(props) {
|
|
|
5038
5049
|
pinnedValueSet
|
|
5039
5050
|
]);
|
|
5040
5051
|
const closeOnSelect = keepOpenOnSelect !== void 0 ? !keepOpenOnSelect : mode === "single";
|
|
5041
|
-
const handleSelectEmpty =
|
|
5052
|
+
const handleSelectEmpty = React7.useCallback(() => {
|
|
5042
5053
|
if (mode === "single") {
|
|
5043
5054
|
props.onValueChange?.(
|
|
5044
5055
|
null
|
|
@@ -5046,7 +5057,7 @@ function SearchablePicker(props) {
|
|
|
5046
5057
|
}
|
|
5047
5058
|
if (closeOnSelect) setOpen(false);
|
|
5048
5059
|
}, [mode, props, closeOnSelect, setOpen]);
|
|
5049
|
-
const handleSelectItem =
|
|
5060
|
+
const handleSelectItem = React7.useCallback(
|
|
5050
5061
|
(value) => {
|
|
5051
5062
|
if (mode === "multiple") {
|
|
5052
5063
|
const current = props.value ?? [];
|
|
@@ -5069,7 +5080,7 @@ function SearchablePicker(props) {
|
|
|
5069
5080
|
},
|
|
5070
5081
|
[mode, props, maxSelected, closeOnSelect, setOpen]
|
|
5071
5082
|
);
|
|
5072
|
-
const handleClear =
|
|
5083
|
+
const handleClear = React7.useCallback(
|
|
5073
5084
|
(event) => {
|
|
5074
5085
|
event.preventDefault();
|
|
5075
5086
|
event.stopPropagation();
|
|
@@ -5083,7 +5094,7 @@ function SearchablePicker(props) {
|
|
|
5083
5094
|
},
|
|
5084
5095
|
[mode, props]
|
|
5085
5096
|
);
|
|
5086
|
-
const handleLoadMore =
|
|
5097
|
+
const handleLoadMore = React7.useCallback(async () => {
|
|
5087
5098
|
if (!onLoadMore || isLoadingMore) return;
|
|
5088
5099
|
setIsLoadingMore(true);
|
|
5089
5100
|
try {
|
|
@@ -5092,7 +5103,7 @@ function SearchablePicker(props) {
|
|
|
5092
5103
|
setIsLoadingMore(false);
|
|
5093
5104
|
}
|
|
5094
5105
|
}, [onLoadMore, isLoadingMore]);
|
|
5095
|
-
const triggerLabel =
|
|
5106
|
+
const triggerLabel = React7.useMemo(() => {
|
|
5096
5107
|
if (renderValue) {
|
|
5097
5108
|
if (mode === "multiple") {
|
|
5098
5109
|
return renderValue(selectedItems);
|
|
@@ -5274,20 +5285,20 @@ function SearchCommand({
|
|
|
5274
5285
|
className
|
|
5275
5286
|
}) {
|
|
5276
5287
|
const labels = { ...defaultLabels4, ...userLabels };
|
|
5277
|
-
const [query, setQuery] =
|
|
5278
|
-
const [hits, setHits] =
|
|
5279
|
-
const [isLoading, setIsLoading] =
|
|
5280
|
-
const [hasError, setHasError] =
|
|
5288
|
+
const [query, setQuery] = React7.useState("");
|
|
5289
|
+
const [hits, setHits] = React7.useState([]);
|
|
5290
|
+
const [isLoading, setIsLoading] = React7.useState(false);
|
|
5291
|
+
const [hasError, setHasError] = React7.useState(false);
|
|
5281
5292
|
const debouncedQuery = useDebouncedValue(query, debounceMs);
|
|
5282
|
-
const requestIdRef =
|
|
5283
|
-
|
|
5293
|
+
const requestIdRef = React7.useRef(0);
|
|
5294
|
+
React7.useEffect(() => {
|
|
5284
5295
|
if (!open) {
|
|
5285
5296
|
setQuery("");
|
|
5286
5297
|
setHits([]);
|
|
5287
5298
|
setHasError(false);
|
|
5288
5299
|
}
|
|
5289
5300
|
}, [open]);
|
|
5290
|
-
|
|
5301
|
+
React7.useEffect(() => {
|
|
5291
5302
|
const trimmed = debouncedQuery.trim();
|
|
5292
5303
|
if (trimmed.length < minQueryLength) {
|
|
5293
5304
|
setHits([]);
|
|
@@ -5310,13 +5321,13 @@ function SearchCommand({
|
|
|
5310
5321
|
setIsLoading(false);
|
|
5311
5322
|
});
|
|
5312
5323
|
}, [debouncedQuery, minQueryLength, fetchResults]);
|
|
5313
|
-
const filteredFeatures =
|
|
5324
|
+
const filteredFeatures = React7.useMemo(() => {
|
|
5314
5325
|
if (!query.trim()) return features;
|
|
5315
5326
|
return features.filter(
|
|
5316
5327
|
(feature) => fuzzyMatch(query, feature.label) || feature.keywords?.some((keyword) => fuzzyMatch(query, keyword))
|
|
5317
5328
|
);
|
|
5318
5329
|
}, [features, query]);
|
|
5319
|
-
const groupedHits =
|
|
5330
|
+
const groupedHits = React7.useMemo(() => groupHitsByType(hits), [hits]);
|
|
5320
5331
|
function handleSelect(selection) {
|
|
5321
5332
|
onSelect(selection);
|
|
5322
5333
|
onOpenChange(false);
|
|
@@ -5450,7 +5461,7 @@ function ScrollBar({
|
|
|
5450
5461
|
);
|
|
5451
5462
|
}
|
|
5452
5463
|
var phoneInputGroupClass = "flex h-9 w-full gap-0 overflow-hidden rounded-md border border-input bg-transparent shadow-xs transition-[color,box-shadow] [--PhoneInputCountrySelect-marginRight:0] focus-within:border-ring focus-within:ring-[3px] focus-within:ring-ring/50 dark:bg-input/30 [&_.PhoneInputCountry]:mr-0";
|
|
5453
|
-
var PhoneInput =
|
|
5464
|
+
var PhoneInput = React7__namespace.forwardRef(
|
|
5454
5465
|
({ className, onChange, value, defaultCountry = "MX", ...props }, ref) => {
|
|
5455
5466
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
5456
5467
|
RPNInput__namespace.default,
|
|
@@ -5470,7 +5481,7 @@ var PhoneInput = React6__namespace.forwardRef(
|
|
|
5470
5481
|
}
|
|
5471
5482
|
);
|
|
5472
5483
|
PhoneInput.displayName = "PhoneInput";
|
|
5473
|
-
var InputComponent =
|
|
5484
|
+
var InputComponent = React7__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
5474
5485
|
Input,
|
|
5475
5486
|
{
|
|
5476
5487
|
className: cn(
|
|
@@ -5488,9 +5499,9 @@ var CountrySelect = ({
|
|
|
5488
5499
|
options: countryList,
|
|
5489
5500
|
onChange
|
|
5490
5501
|
}) => {
|
|
5491
|
-
const scrollAreaRef =
|
|
5492
|
-
const [searchValue, setSearchValue] =
|
|
5493
|
-
const [isOpen, setIsOpen] =
|
|
5502
|
+
const scrollAreaRef = React7__namespace.useRef(null);
|
|
5503
|
+
const [searchValue, setSearchValue] = React7__namespace.useState("");
|
|
5504
|
+
const [isOpen, setIsOpen] = React7__namespace.useState(false);
|
|
5494
5505
|
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
5495
5506
|
Popover,
|
|
5496
5507
|
{
|
|
@@ -5671,8 +5682,8 @@ var MEXICO_STATE_PATHS = {
|
|
|
5671
5682
|
};
|
|
5672
5683
|
function MexicoMap({ selected, onToggle, className }) {
|
|
5673
5684
|
const isInteractive = typeof onToggle === "function";
|
|
5674
|
-
const selectedSet =
|
|
5675
|
-
const handleKeyDown =
|
|
5685
|
+
const selectedSet = React7__namespace.useMemo(() => new Set(selected), [selected]);
|
|
5686
|
+
const handleKeyDown = React7__namespace.useCallback(
|
|
5676
5687
|
(event, id) => {
|
|
5677
5688
|
if (!onToggle) return;
|
|
5678
5689
|
if (event.key === "Enter" || event.key === " ") {
|
|
@@ -6154,6 +6165,130 @@ function ChatMessageList({
|
|
|
6154
6165
|
/* @__PURE__ */ jsxRuntime.jsx(MessageScrollerButton, {})
|
|
6155
6166
|
] }) });
|
|
6156
6167
|
}
|
|
6168
|
+
var MessageComposer = React7__namespace.forwardRef(function MessageComposer2({
|
|
6169
|
+
className,
|
|
6170
|
+
locale = "en",
|
|
6171
|
+
disabled,
|
|
6172
|
+
readOnly,
|
|
6173
|
+
value,
|
|
6174
|
+
onChange,
|
|
6175
|
+
onSubmit,
|
|
6176
|
+
onKeyDown,
|
|
6177
|
+
sendLabel,
|
|
6178
|
+
sendDisabled = false,
|
|
6179
|
+
allowEmptySubmit = false,
|
|
6180
|
+
sendButtonClassName,
|
|
6181
|
+
sendButtonSize = "sm",
|
|
6182
|
+
submitOnEnter = true,
|
|
6183
|
+
tools,
|
|
6184
|
+
attachments,
|
|
6185
|
+
triggerLabel,
|
|
6186
|
+
keepOpenOnSelect,
|
|
6187
|
+
open,
|
|
6188
|
+
onOpenChange,
|
|
6189
|
+
side = "top",
|
|
6190
|
+
align = "end",
|
|
6191
|
+
labels,
|
|
6192
|
+
recentLimit,
|
|
6193
|
+
storageKey,
|
|
6194
|
+
emojiTriggerClassName,
|
|
6195
|
+
rows = 2,
|
|
6196
|
+
...props
|
|
6197
|
+
}, ref) {
|
|
6198
|
+
const formRef = React7__namespace.useRef(null);
|
|
6199
|
+
const fieldRef = React7__namespace.useRef(null);
|
|
6200
|
+
const handleEmojiSelect = useEmojiInsert(fieldRef, value, onChange);
|
|
6201
|
+
const pickerDisabled = Boolean(disabled || readOnly);
|
|
6202
|
+
const draft = value !== void 0 && value !== null ? String(value) : "";
|
|
6203
|
+
const canSubmit = (allowEmptySubmit || Boolean(draft.trim())) && !sendDisabled && !disabled && !readOnly;
|
|
6204
|
+
const handleSubmit = React7__namespace.useCallback(
|
|
6205
|
+
(event) => {
|
|
6206
|
+
event.preventDefault();
|
|
6207
|
+
if (!canSubmit) return;
|
|
6208
|
+
onSubmit(event);
|
|
6209
|
+
},
|
|
6210
|
+
[canSubmit, onSubmit]
|
|
6211
|
+
);
|
|
6212
|
+
const handleKeyDown = React7__namespace.useCallback(
|
|
6213
|
+
(event) => {
|
|
6214
|
+
onKeyDown?.(event);
|
|
6215
|
+
if (event.defaultPrevented) return;
|
|
6216
|
+
if (!submitOnEnter) return;
|
|
6217
|
+
if (event.key !== "Enter" || event.shiftKey) return;
|
|
6218
|
+
if (event.nativeEvent.isComposing || event.keyCode === 229) return;
|
|
6219
|
+
event.preventDefault();
|
|
6220
|
+
if (!canSubmit) return;
|
|
6221
|
+
formRef.current?.requestSubmit();
|
|
6222
|
+
},
|
|
6223
|
+
[canSubmit, onKeyDown, submitOnEnter]
|
|
6224
|
+
);
|
|
6225
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
6226
|
+
"form",
|
|
6227
|
+
{
|
|
6228
|
+
ref: formRef,
|
|
6229
|
+
className: cn(emojiFieldWrapperClassName, "flex flex-col", className),
|
|
6230
|
+
onSubmit: handleSubmit,
|
|
6231
|
+
children: [
|
|
6232
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
6233
|
+
"textarea",
|
|
6234
|
+
{
|
|
6235
|
+
"data-slot": "textarea",
|
|
6236
|
+
ref: mergeRefs(fieldRef, ref),
|
|
6237
|
+
disabled,
|
|
6238
|
+
readOnly,
|
|
6239
|
+
value,
|
|
6240
|
+
onChange,
|
|
6241
|
+
onKeyDown: handleKeyDown,
|
|
6242
|
+
rows,
|
|
6243
|
+
className: cn(
|
|
6244
|
+
"placeholder:text-muted-foreground flex min-h-10 w-full resize-none rounded-md px-3 pt-2 pb-1 text-base outline-none transition-[color,box-shadow] disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",
|
|
6245
|
+
emojiFieldResetClassName
|
|
6246
|
+
),
|
|
6247
|
+
...props
|
|
6248
|
+
}
|
|
6249
|
+
),
|
|
6250
|
+
attachments ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "border-t px-2 py-2", children: attachments }) : null,
|
|
6251
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-between gap-2 px-1.5 pb-1.5", children: [
|
|
6252
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex min-w-0 flex-1 items-center gap-0.5", children: [
|
|
6253
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
6254
|
+
EmojiPickerPopover,
|
|
6255
|
+
{
|
|
6256
|
+
locale,
|
|
6257
|
+
onSelect: handleEmojiSelect,
|
|
6258
|
+
disabled: pickerDisabled,
|
|
6259
|
+
triggerLabel,
|
|
6260
|
+
keepOpenOnSelect,
|
|
6261
|
+
open,
|
|
6262
|
+
onOpenChange,
|
|
6263
|
+
side,
|
|
6264
|
+
align,
|
|
6265
|
+
labels,
|
|
6266
|
+
recentLimit,
|
|
6267
|
+
storageKey,
|
|
6268
|
+
triggerClassName: cn(
|
|
6269
|
+
"size-7 text-muted-foreground",
|
|
6270
|
+
emojiTriggerClassName
|
|
6271
|
+
)
|
|
6272
|
+
}
|
|
6273
|
+
),
|
|
6274
|
+
tools
|
|
6275
|
+
] }),
|
|
6276
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
6277
|
+
Button,
|
|
6278
|
+
{
|
|
6279
|
+
type: "submit",
|
|
6280
|
+
size: sendButtonSize,
|
|
6281
|
+
disabled: !canSubmit,
|
|
6282
|
+
className: sendButtonClassName,
|
|
6283
|
+
children: sendLabel
|
|
6284
|
+
}
|
|
6285
|
+
)
|
|
6286
|
+
] })
|
|
6287
|
+
]
|
|
6288
|
+
}
|
|
6289
|
+
);
|
|
6290
|
+
});
|
|
6291
|
+
MessageComposer.displayName = "MessageComposer";
|
|
6157
6292
|
var RECONNECT_DELAY_MS = 2e3;
|
|
6158
6293
|
function useSupportConversation({
|
|
6159
6294
|
client,
|
|
@@ -6164,21 +6299,21 @@ function useSupportConversation({
|
|
|
6164
6299
|
onConversationReady,
|
|
6165
6300
|
onIncomingMessage
|
|
6166
6301
|
}) {
|
|
6167
|
-
const [conversationId, setConversationId] =
|
|
6302
|
+
const [conversationId, setConversationId] = React7.useState(
|
|
6168
6303
|
conversationIdProp
|
|
6169
6304
|
);
|
|
6170
|
-
const [messages, setMessages] =
|
|
6171
|
-
const [loading, setLoading] =
|
|
6172
|
-
const [sending, setSending] =
|
|
6173
|
-
const [error, setError] =
|
|
6174
|
-
const socketRef =
|
|
6175
|
-
const reconnectRef =
|
|
6176
|
-
const closedByUser =
|
|
6177
|
-
const onReadyRef =
|
|
6178
|
-
const onIncomingRef =
|
|
6305
|
+
const [messages, setMessages] = React7.useState([]);
|
|
6306
|
+
const [loading, setLoading] = React7.useState(false);
|
|
6307
|
+
const [sending, setSending] = React7.useState(false);
|
|
6308
|
+
const [error, setError] = React7.useState(null);
|
|
6309
|
+
const socketRef = React7.useRef(null);
|
|
6310
|
+
const reconnectRef = React7.useRef(null);
|
|
6311
|
+
const closedByUser = React7.useRef(false);
|
|
6312
|
+
const onReadyRef = React7.useRef(onConversationReady);
|
|
6313
|
+
const onIncomingRef = React7.useRef(onIncomingMessage);
|
|
6179
6314
|
onReadyRef.current = onConversationReady;
|
|
6180
6315
|
onIncomingRef.current = onIncomingMessage;
|
|
6181
|
-
const load =
|
|
6316
|
+
const load = React7.useCallback(async () => {
|
|
6182
6317
|
if (!enabled) return;
|
|
6183
6318
|
setLoading(true);
|
|
6184
6319
|
setError(null);
|
|
@@ -6204,10 +6339,10 @@ function useSupportConversation({
|
|
|
6204
6339
|
setLoading(false);
|
|
6205
6340
|
}
|
|
6206
6341
|
}, [client, conversationIdProp, enabled, open]);
|
|
6207
|
-
|
|
6342
|
+
React7.useEffect(() => {
|
|
6208
6343
|
void load();
|
|
6209
6344
|
}, [load]);
|
|
6210
|
-
|
|
6345
|
+
React7.useEffect(() => {
|
|
6211
6346
|
closedByUser.current = false;
|
|
6212
6347
|
if (!enabled || !conversationId) return;
|
|
6213
6348
|
let cancelled = false;
|
|
@@ -6253,7 +6388,7 @@ function useSupportConversation({
|
|
|
6253
6388
|
socketRef.current = null;
|
|
6254
6389
|
};
|
|
6255
6390
|
}, [conversationId, enabled, getWsUrl]);
|
|
6256
|
-
const send =
|
|
6391
|
+
const send = React7.useCallback(
|
|
6257
6392
|
async (text) => {
|
|
6258
6393
|
const trimmed = text.trim();
|
|
6259
6394
|
if (!conversationId || !trimmed || sending) return;
|
|
@@ -6285,9 +6420,9 @@ function useSupportConversation({
|
|
|
6285
6420
|
reload: load
|
|
6286
6421
|
};
|
|
6287
6422
|
}
|
|
6288
|
-
var SupportMessengerContext =
|
|
6423
|
+
var SupportMessengerContext = React7.createContext(null);
|
|
6289
6424
|
function useSupportMessenger() {
|
|
6290
|
-
const ctx =
|
|
6425
|
+
const ctx = React7.useContext(SupportMessengerContext);
|
|
6291
6426
|
if (!ctx) {
|
|
6292
6427
|
throw new Error(
|
|
6293
6428
|
"useSupportMessenger must be used within SupportMessengerProvider"
|
|
@@ -6296,7 +6431,7 @@ function useSupportMessenger() {
|
|
|
6296
6431
|
return ctx;
|
|
6297
6432
|
}
|
|
6298
6433
|
function useSupportMessengerOptional() {
|
|
6299
|
-
return
|
|
6434
|
+
return React7.useContext(SupportMessengerContext);
|
|
6300
6435
|
}
|
|
6301
6436
|
function ThreadPanel({
|
|
6302
6437
|
thread,
|
|
@@ -6311,7 +6446,7 @@ function ThreadPanel({
|
|
|
6311
6446
|
onConversationReady,
|
|
6312
6447
|
className
|
|
6313
6448
|
}) {
|
|
6314
|
-
const [draft, setDraft] =
|
|
6449
|
+
const [draft, setDraft] = React7.useState("");
|
|
6315
6450
|
const { messages, loading, sending, error, send } = useSupportConversation({
|
|
6316
6451
|
client,
|
|
6317
6452
|
getWsUrl,
|
|
@@ -6374,23 +6509,22 @@ function ThreadPanel({
|
|
|
6374
6509
|
emptyDescription: labels.emptyThread
|
|
6375
6510
|
}
|
|
6376
6511
|
) }),
|
|
6377
|
-
/* @__PURE__ */ jsxRuntime.
|
|
6378
|
-
|
|
6379
|
-
|
|
6380
|
-
|
|
6381
|
-
|
|
6382
|
-
|
|
6383
|
-
|
|
6384
|
-
|
|
6385
|
-
|
|
6386
|
-
|
|
6387
|
-
|
|
6388
|
-
|
|
6389
|
-
|
|
6390
|
-
|
|
6391
|
-
|
|
6392
|
-
|
|
6393
|
-
] })
|
|
6512
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "border-t p-3", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
6513
|
+
MessageComposer,
|
|
6514
|
+
{
|
|
6515
|
+
locale: emojiLocale,
|
|
6516
|
+
value: draft,
|
|
6517
|
+
onChange: (e) => setDraft(e.target.value.slice(0, 2e3)),
|
|
6518
|
+
onSubmit,
|
|
6519
|
+
sendLabel: labels.send,
|
|
6520
|
+
placeholder: labels.placeholder,
|
|
6521
|
+
"aria-label": labels.placeholder,
|
|
6522
|
+
disabled: loading || sending,
|
|
6523
|
+
sendDisabled: loading || sending,
|
|
6524
|
+
maxLength: 2e3,
|
|
6525
|
+
rows: 2
|
|
6526
|
+
}
|
|
6527
|
+
) })
|
|
6394
6528
|
]
|
|
6395
6529
|
}
|
|
6396
6530
|
);
|
|
@@ -6406,9 +6540,9 @@ function ListPanel({
|
|
|
6406
6540
|
searchThreshold,
|
|
6407
6541
|
className
|
|
6408
6542
|
}) {
|
|
6409
|
-
const [query, setQuery] =
|
|
6543
|
+
const [query, setQuery] = React7.useState("");
|
|
6410
6544
|
const showSearch = items.length >= searchThreshold;
|
|
6411
|
-
const filtered =
|
|
6545
|
+
const filtered = React7.useMemo(() => {
|
|
6412
6546
|
const q = query.trim().toLowerCase();
|
|
6413
6547
|
if (!q) return items;
|
|
6414
6548
|
return items.filter(
|
|
@@ -6512,32 +6646,32 @@ function SupportMessengerProvider({
|
|
|
6512
6646
|
className
|
|
6513
6647
|
}) {
|
|
6514
6648
|
const isMobile = useMediaQuery2("(max-width: 767px)");
|
|
6515
|
-
const [listOpen, setListOpen] =
|
|
6516
|
-
const [threads, setThreads] =
|
|
6517
|
-
const [mobileThreadKey, setMobileThreadKey] =
|
|
6518
|
-
const totalUnread =
|
|
6649
|
+
const [listOpen, setListOpen] = React7.useState(false);
|
|
6650
|
+
const [threads, setThreads] = React7.useState([]);
|
|
6651
|
+
const [mobileThreadKey, setMobileThreadKey] = React7.useState(null);
|
|
6652
|
+
const totalUnread = React7.useMemo(
|
|
6519
6653
|
() => items.reduce((sum, item) => sum + (item.unreadCount ?? 0), 0),
|
|
6520
6654
|
[items]
|
|
6521
6655
|
);
|
|
6522
|
-
|
|
6656
|
+
React7.useEffect(() => {
|
|
6523
6657
|
if (!forceMinimized) return;
|
|
6524
6658
|
setListOpen(false);
|
|
6525
6659
|
setThreads([]);
|
|
6526
6660
|
setMobileThreadKey(null);
|
|
6527
6661
|
}, [forceMinimized]);
|
|
6528
|
-
const openList =
|
|
6662
|
+
const openList = React7.useCallback(() => {
|
|
6529
6663
|
setListOpen(true);
|
|
6530
6664
|
void onRefreshItems?.();
|
|
6531
6665
|
}, [onRefreshItems]);
|
|
6532
|
-
const closeList =
|
|
6533
|
-
const toggleList =
|
|
6666
|
+
const closeList = React7.useCallback(() => setListOpen(false), []);
|
|
6667
|
+
const toggleList = React7.useCallback(() => {
|
|
6534
6668
|
setListOpen((prev) => {
|
|
6535
6669
|
const next = !prev;
|
|
6536
6670
|
if (next) void onRefreshItems?.();
|
|
6537
6671
|
return next;
|
|
6538
6672
|
});
|
|
6539
6673
|
}, [onRefreshItems]);
|
|
6540
|
-
const openThread =
|
|
6674
|
+
const openThread = React7.useCallback((req) => {
|
|
6541
6675
|
setListOpen(false);
|
|
6542
6676
|
setThreads((prev) => {
|
|
6543
6677
|
const existing = prev.find((t) => t.key === req.key);
|
|
@@ -6552,16 +6686,16 @@ function SupportMessengerProvider({
|
|
|
6552
6686
|
});
|
|
6553
6687
|
setMobileThreadKey(req.key);
|
|
6554
6688
|
}, []);
|
|
6555
|
-
const closeThread =
|
|
6689
|
+
const closeThread = React7.useCallback((key) => {
|
|
6556
6690
|
setThreads((prev) => prev.filter((t) => t.key !== key));
|
|
6557
6691
|
setMobileThreadKey((prev) => prev === key ? null : prev);
|
|
6558
6692
|
}, []);
|
|
6559
|
-
const closeAll =
|
|
6693
|
+
const closeAll = React7.useCallback(() => {
|
|
6560
6694
|
setListOpen(false);
|
|
6561
6695
|
setThreads([]);
|
|
6562
6696
|
setMobileThreadKey(null);
|
|
6563
6697
|
}, []);
|
|
6564
|
-
const ctx =
|
|
6698
|
+
const ctx = React7.useMemo(
|
|
6565
6699
|
() => ({
|
|
6566
6700
|
listOpen,
|
|
6567
6701
|
openList,
|
|
@@ -6586,7 +6720,7 @@ function SupportMessengerProvider({
|
|
|
6586
6720
|
totalUnread
|
|
6587
6721
|
]
|
|
6588
6722
|
);
|
|
6589
|
-
const handleSelectItem =
|
|
6723
|
+
const handleSelectItem = React7.useCallback(
|
|
6590
6724
|
(item) => {
|
|
6591
6725
|
openThread({
|
|
6592
6726
|
key: item.key,
|
|
@@ -6816,6 +6950,7 @@ exports.MarkerContent = MarkerContent;
|
|
|
6816
6950
|
exports.MarkerIcon = MarkerIcon;
|
|
6817
6951
|
exports.Message = Message;
|
|
6818
6952
|
exports.MessageAvatar = MessageAvatar;
|
|
6953
|
+
exports.MessageComposer = MessageComposer;
|
|
6819
6954
|
exports.MessageContent = MessageContent;
|
|
6820
6955
|
exports.MessageFooter = MessageFooter;
|
|
6821
6956
|
exports.MessageGroup = MessageGroup;
|