@sesionario/blocks 1.10.0 → 1.11.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 +350 -233
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +24 -1
- package/dist/index.d.ts +24 -1
- package/dist/index.js +216 -100
- 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);
|
|
@@ -3134,17 +3134,17 @@ function EmojiPickerPopover({
|
|
|
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);
|
|
@@ -3177,8 +3177,10 @@ function insertAtCaret(element, value, text) {
|
|
|
3177
3177
|
caret: start + text.length
|
|
3178
3178
|
};
|
|
3179
3179
|
}
|
|
3180
|
-
|
|
3181
|
-
|
|
3180
|
+
|
|
3181
|
+
// src/components/emoji/emoji-field-shared.ts
|
|
3182
|
+
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";
|
|
3183
|
+
var emojiFieldResetClassName = "border-0 bg-transparent shadow-none focus-visible:border-transparent focus-visible:ring-0 dark:bg-transparent";
|
|
3182
3184
|
function mergeRefs(...refs) {
|
|
3183
3185
|
return (node) => {
|
|
3184
3186
|
for (const ref of refs) {
|
|
@@ -3202,7 +3204,7 @@ function emitChange(element, nextValue, onChange) {
|
|
|
3202
3204
|
});
|
|
3203
3205
|
}
|
|
3204
3206
|
function useEmojiInsert(fieldRef, value, onChange) {
|
|
3205
|
-
return
|
|
3207
|
+
return React7__namespace.useCallback(
|
|
3206
3208
|
(emoji) => {
|
|
3207
3209
|
const el = fieldRef.current;
|
|
3208
3210
|
const current = value !== void 0 && value !== null ? String(value) : el?.value ?? "";
|
|
@@ -3223,7 +3225,7 @@ function useEmojiInsert(fieldRef, value, onChange) {
|
|
|
3223
3225
|
[fieldRef, value, onChange]
|
|
3224
3226
|
);
|
|
3225
3227
|
}
|
|
3226
|
-
var EmojiTextarea =
|
|
3228
|
+
var EmojiTextarea = React7__namespace.forwardRef(
|
|
3227
3229
|
function EmojiTextarea2({
|
|
3228
3230
|
className,
|
|
3229
3231
|
locale = "en",
|
|
@@ -3243,10 +3245,10 @@ var EmojiTextarea = React6__namespace.forwardRef(
|
|
|
3243
3245
|
emojiTriggerClassName,
|
|
3244
3246
|
...props
|
|
3245
3247
|
}, ref) {
|
|
3246
|
-
const fieldRef =
|
|
3248
|
+
const fieldRef = React7__namespace.useRef(null);
|
|
3247
3249
|
const handleEmojiSelect = useEmojiInsert(fieldRef, value, onChange);
|
|
3248
3250
|
const pickerDisabled = Boolean(disabled || readOnly);
|
|
3249
|
-
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: cn(
|
|
3251
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: cn(emojiFieldWrapperClassName, className), children: [
|
|
3250
3252
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
3251
3253
|
"textarea",
|
|
3252
3254
|
{
|
|
@@ -3258,7 +3260,7 @@ var EmojiTextarea = React6__namespace.forwardRef(
|
|
|
3258
3260
|
onChange,
|
|
3259
3261
|
className: cn(
|
|
3260
3262
|
"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
|
-
|
|
3263
|
+
emojiFieldResetClassName,
|
|
3262
3264
|
className
|
|
3263
3265
|
),
|
|
3264
3266
|
...props
|
|
@@ -3289,7 +3291,7 @@ var EmojiTextarea = React6__namespace.forwardRef(
|
|
|
3289
3291
|
}
|
|
3290
3292
|
);
|
|
3291
3293
|
EmojiTextarea.displayName = "EmojiTextarea";
|
|
3292
|
-
var EmojiInput =
|
|
3294
|
+
var EmojiInput = React7__namespace.forwardRef(
|
|
3293
3295
|
function EmojiInput2({
|
|
3294
3296
|
className,
|
|
3295
3297
|
locale = "en",
|
|
@@ -3310,10 +3312,10 @@ var EmojiInput = React6__namespace.forwardRef(
|
|
|
3310
3312
|
emojiTriggerClassName,
|
|
3311
3313
|
...props
|
|
3312
3314
|
}, ref) {
|
|
3313
|
-
const fieldRef =
|
|
3315
|
+
const fieldRef = React7__namespace.useRef(null);
|
|
3314
3316
|
const handleEmojiSelect = useEmojiInsert(fieldRef, value, onChange);
|
|
3315
3317
|
const pickerDisabled = Boolean(disabled || readOnly);
|
|
3316
|
-
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: cn(
|
|
3318
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: cn(emojiFieldWrapperClassName, className), children: [
|
|
3317
3319
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
3318
3320
|
"input",
|
|
3319
3321
|
{
|
|
@@ -3326,7 +3328,7 @@ var EmojiInput = React6__namespace.forwardRef(
|
|
|
3326
3328
|
onChange,
|
|
3327
3329
|
className: cn(
|
|
3328
3330
|
"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
|
-
|
|
3331
|
+
emojiFieldResetClassName,
|
|
3330
3332
|
className
|
|
3331
3333
|
),
|
|
3332
3334
|
...props
|
|
@@ -3518,27 +3520,27 @@ function useHlsPlayback({
|
|
|
3518
3520
|
onError,
|
|
3519
3521
|
onPlayingChange
|
|
3520
3522
|
}) {
|
|
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
|
-
|
|
3523
|
+
const videoRef = React7__namespace.useRef(null);
|
|
3524
|
+
const hlsRef = React7__namespace.useRef(null);
|
|
3525
|
+
const [state, setState] = React7__namespace.useState("idle");
|
|
3526
|
+
const [qualities, setQualities] = React7__namespace.useState([]);
|
|
3527
|
+
const [activeLevel, setActiveLevel] = React7__namespace.useState(-1);
|
|
3528
|
+
const [autoplayState, setAutoplayState] = React7__namespace.useState("none");
|
|
3529
|
+
const [error, setError] = React7__namespace.useState(null);
|
|
3530
|
+
const [reloadKey, setReloadKey] = React7__namespace.useState(0);
|
|
3531
|
+
const onErrorRef = React7__namespace.useRef(onError);
|
|
3532
|
+
const onPlayingChangeRef = React7__namespace.useRef(onPlayingChange);
|
|
3533
|
+
React7__namespace.useEffect(() => {
|
|
3532
3534
|
onErrorRef.current = onError;
|
|
3533
3535
|
onPlayingChangeRef.current = onPlayingChange;
|
|
3534
3536
|
}, [onError, onPlayingChange]);
|
|
3535
|
-
const retry =
|
|
3537
|
+
const retry = React7__namespace.useCallback(() => {
|
|
3536
3538
|
setError(null);
|
|
3537
3539
|
setState("loading");
|
|
3538
3540
|
setAutoplayState("none");
|
|
3539
3541
|
setReloadKey((k) => k + 1);
|
|
3540
3542
|
}, []);
|
|
3541
|
-
|
|
3543
|
+
React7__namespace.useEffect(() => {
|
|
3542
3544
|
const media = videoRef.current;
|
|
3543
3545
|
if (!media || !src || !active) {
|
|
3544
3546
|
setState("idle");
|
|
@@ -3750,7 +3752,7 @@ function useHlsPlayback({
|
|
|
3750
3752
|
destroyHls();
|
|
3751
3753
|
};
|
|
3752
3754
|
}, [src, mode, active, autoPlay, muted, reloadKey]);
|
|
3753
|
-
const setLevel =
|
|
3755
|
+
const setLevel = React7__namespace.useCallback((index) => {
|
|
3754
3756
|
const hls = hlsRef.current;
|
|
3755
3757
|
if (!hls) return;
|
|
3756
3758
|
hls.nextLevel = index;
|
|
@@ -3833,12 +3835,12 @@ function VideoPlayer({
|
|
|
3833
3835
|
className
|
|
3834
3836
|
}) {
|
|
3835
3837
|
const t = { ...DEFAULT_LABELS2, ...labels };
|
|
3836
|
-
const containerRef =
|
|
3837
|
-
const firstPlayFiredRef =
|
|
3838
|
-
const [userStarted, setUserStarted] =
|
|
3838
|
+
const containerRef = React7__namespace.useRef(null);
|
|
3839
|
+
const firstPlayFiredRef = React7__namespace.useRef(false);
|
|
3840
|
+
const [userStarted, setUserStarted] = React7__namespace.useState(false);
|
|
3839
3841
|
const active = autoPlay || !poster || userStarted;
|
|
3840
3842
|
const autoplayActive = autoPlay || userStarted;
|
|
3841
|
-
const handlePlayingChange =
|
|
3843
|
+
const handlePlayingChange = React7__namespace.useCallback(
|
|
3842
3844
|
(playing) => {
|
|
3843
3845
|
setIsPlaying(playing);
|
|
3844
3846
|
if (playing && !firstPlayFiredRef.current) {
|
|
@@ -3867,25 +3869,25 @@ function VideoPlayer({
|
|
|
3867
3869
|
onError,
|
|
3868
3870
|
onPlayingChange: handlePlayingChange
|
|
3869
3871
|
});
|
|
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] =
|
|
3872
|
+
const [isPlaying, setIsPlaying] = React7__namespace.useState(false);
|
|
3873
|
+
const [isMuted, setIsMuted] = React7__namespace.useState(muted);
|
|
3874
|
+
const [volume, setVolume] = React7__namespace.useState(1);
|
|
3875
|
+
const [currentTime, setCurrentTime] = React7__namespace.useState(0);
|
|
3876
|
+
const [duration, setDuration] = React7__namespace.useState(0);
|
|
3877
|
+
const [buffered, setBuffered] = React7__namespace.useState(0);
|
|
3878
|
+
const [isFullscreen, setIsFullscreen] = React7__namespace.useState(false);
|
|
3879
|
+
const [pipActive, setPipActive] = React7__namespace.useState(false);
|
|
3880
|
+
const [controlsVisible, setControlsVisible] = React7__namespace.useState(true);
|
|
3881
|
+
const [playbackRate, setPlaybackRate] = React7__namespace.useState(1);
|
|
3882
|
+
const [openMenu, setOpenMenu] = React7__namespace.useState(
|
|
3881
3883
|
null
|
|
3882
3884
|
);
|
|
3883
|
-
const [behindLive, setBehindLive] =
|
|
3884
|
-
const [webkitFullscreenSupported, setWebkitFullscreenSupported] =
|
|
3885
|
-
const hideTimerRef =
|
|
3885
|
+
const [behindLive, setBehindLive] = React7__namespace.useState(false);
|
|
3886
|
+
const [webkitFullscreenSupported, setWebkitFullscreenSupported] = React7__namespace.useState(false);
|
|
3887
|
+
const hideTimerRef = React7__namespace.useRef(null);
|
|
3886
3888
|
const pipSupported = typeof document !== "undefined" && "pictureInPictureEnabled" in document && document.pictureInPictureEnabled;
|
|
3887
3889
|
const fullscreenSupported = hasStandardFullscreen() || webkitFullscreenSupported;
|
|
3888
|
-
|
|
3890
|
+
React7__namespace.useEffect(() => {
|
|
3889
3891
|
const video = videoRef.current;
|
|
3890
3892
|
if (!video || !active) return;
|
|
3891
3893
|
const onTimeUpdate = () => {
|
|
@@ -3918,15 +3920,15 @@ function VideoPlayer({
|
|
|
3918
3920
|
video.removeEventListener("ratechange", onRate);
|
|
3919
3921
|
};
|
|
3920
3922
|
}, [videoRef, active, mode]);
|
|
3921
|
-
|
|
3923
|
+
React7__namespace.useEffect(() => {
|
|
3922
3924
|
setWebkitFullscreenSupported(hasWebkitVideoFullscreen(videoRef.current));
|
|
3923
3925
|
}, [videoRef, active]);
|
|
3924
|
-
|
|
3926
|
+
React7__namespace.useEffect(() => {
|
|
3925
3927
|
const onFsChange = () => setIsFullscreen(document.fullscreenElement === containerRef.current);
|
|
3926
3928
|
document.addEventListener("fullscreenchange", onFsChange);
|
|
3927
3929
|
return () => document.removeEventListener("fullscreenchange", onFsChange);
|
|
3928
3930
|
}, []);
|
|
3929
|
-
|
|
3931
|
+
React7__namespace.useEffect(() => {
|
|
3930
3932
|
const video = asWebkitVideo(videoRef.current);
|
|
3931
3933
|
if (!video) return;
|
|
3932
3934
|
const onBegin = () => setIsFullscreen(true);
|
|
@@ -3938,7 +3940,7 @@ function VideoPlayer({
|
|
|
3938
3940
|
video.removeEventListener("webkitendfullscreen", onEnd);
|
|
3939
3941
|
};
|
|
3940
3942
|
}, [videoRef, active]);
|
|
3941
|
-
|
|
3943
|
+
React7__namespace.useEffect(() => {
|
|
3942
3944
|
const video = videoRef.current;
|
|
3943
3945
|
if (!video) return;
|
|
3944
3946
|
const onEnter = () => setPipActive(true);
|
|
@@ -3950,18 +3952,18 @@ function VideoPlayer({
|
|
|
3950
3952
|
video.removeEventListener("leavepictureinpicture", onLeave);
|
|
3951
3953
|
};
|
|
3952
3954
|
}, [videoRef]);
|
|
3953
|
-
const scheduleHide =
|
|
3955
|
+
const scheduleHide = React7__namespace.useCallback(() => {
|
|
3954
3956
|
if (hideTimerRef.current) clearTimeout(hideTimerRef.current);
|
|
3955
3957
|
hideTimerRef.current = setTimeout(() => {
|
|
3956
3958
|
setControlsVisible(false);
|
|
3957
3959
|
setOpenMenu(null);
|
|
3958
3960
|
}, CONTROLS_HIDE_MS);
|
|
3959
3961
|
}, []);
|
|
3960
|
-
const revealControls =
|
|
3962
|
+
const revealControls = React7__namespace.useCallback(() => {
|
|
3961
3963
|
setControlsVisible(true);
|
|
3962
3964
|
scheduleHide();
|
|
3963
3965
|
}, [scheduleHide]);
|
|
3964
|
-
|
|
3966
|
+
React7__namespace.useEffect(() => {
|
|
3965
3967
|
return () => {
|
|
3966
3968
|
if (hideTimerRef.current) clearTimeout(hideTimerRef.current);
|
|
3967
3969
|
};
|
|
@@ -4424,8 +4426,8 @@ function MenuItem({
|
|
|
4424
4426
|
);
|
|
4425
4427
|
}
|
|
4426
4428
|
function usePlaybackStats(statsUrl, { intervalMs = 15e3, enabled = true } = {}) {
|
|
4427
|
-
const [stats, setStats] =
|
|
4428
|
-
|
|
4429
|
+
const [stats, setStats] = React7__namespace.useState({});
|
|
4430
|
+
React7__namespace.useEffect(() => {
|
|
4429
4431
|
if (!statsUrl || !enabled) return;
|
|
4430
4432
|
let cancelled = false;
|
|
4431
4433
|
const controller = new AbortController();
|
|
@@ -4455,16 +4457,16 @@ function usePlaybackStats(statsUrl, { intervalMs = 15e3, enabled = true } = {})
|
|
|
4455
4457
|
return stats;
|
|
4456
4458
|
}
|
|
4457
4459
|
function useDebouncedValue(value, delayMs) {
|
|
4458
|
-
const [debounced, setDebounced] =
|
|
4459
|
-
|
|
4460
|
+
const [debounced, setDebounced] = React7.useState(value);
|
|
4461
|
+
React7.useEffect(() => {
|
|
4460
4462
|
const id = window.setTimeout(() => setDebounced(value), delayMs);
|
|
4461
4463
|
return () => window.clearTimeout(id);
|
|
4462
4464
|
}, [value, delayMs]);
|
|
4463
4465
|
return debounced;
|
|
4464
4466
|
}
|
|
4465
4467
|
function useDebouncedValueStrict(value, delayMs) {
|
|
4466
|
-
const [debounced, setDebounced] =
|
|
4467
|
-
|
|
4468
|
+
const [debounced, setDebounced] = React7.useState(void 0);
|
|
4469
|
+
React7.useEffect(() => {
|
|
4468
4470
|
setDebounced(void 0);
|
|
4469
4471
|
const id = window.setTimeout(() => setDebounced(value), delayMs);
|
|
4470
4472
|
return () => window.clearTimeout(id);
|
|
@@ -4472,8 +4474,8 @@ function useDebouncedValueStrict(value, delayMs) {
|
|
|
4472
4474
|
return debounced;
|
|
4473
4475
|
}
|
|
4474
4476
|
function useMediaQuery2(query) {
|
|
4475
|
-
const [matches, setMatches] =
|
|
4476
|
-
|
|
4477
|
+
const [matches, setMatches] = React7.useState(false);
|
|
4478
|
+
React7.useEffect(() => {
|
|
4477
4479
|
if (typeof window === "undefined" || !window.matchMedia) return;
|
|
4478
4480
|
const mql = window.matchMedia(query);
|
|
4479
4481
|
const onChange = () => setMatches(mql.matches);
|
|
@@ -4485,9 +4487,9 @@ function useMediaQuery2(query) {
|
|
|
4485
4487
|
}
|
|
4486
4488
|
function useSearchHotkey(options = {}) {
|
|
4487
4489
|
const { defaultOpen = false, disabled = false } = options;
|
|
4488
|
-
const [open, setOpen] =
|
|
4489
|
-
const toggle =
|
|
4490
|
-
|
|
4490
|
+
const [open, setOpen] = React7.useState(defaultOpen);
|
|
4491
|
+
const toggle = React7.useCallback(() => setOpen((prev) => !prev), []);
|
|
4492
|
+
React7.useEffect(() => {
|
|
4491
4493
|
if (disabled) return;
|
|
4492
4494
|
function handleKeyDown(event) {
|
|
4493
4495
|
if (event.key.toLowerCase() !== "k") return;
|
|
@@ -4902,26 +4904,26 @@ function SearchablePicker(props) {
|
|
|
4902
4904
|
const labels = { ...defaultLabels3, ...userLabels };
|
|
4903
4905
|
const resolvedEmptyLabel = emptyLabel ?? labels.emptyOption;
|
|
4904
4906
|
const isMobile = useMediaQuery2("(max-width: 767px)");
|
|
4905
|
-
const generatedId =
|
|
4907
|
+
const generatedId = React7.useId();
|
|
4906
4908
|
const triggerId = id ?? generatedId;
|
|
4907
|
-
const [uncontrolledOpen, setUncontrolledOpen] =
|
|
4909
|
+
const [uncontrolledOpen, setUncontrolledOpen] = React7.useState(false);
|
|
4908
4910
|
const open = openProp ?? uncontrolledOpen;
|
|
4909
|
-
const setOpen =
|
|
4911
|
+
const setOpen = React7.useCallback(
|
|
4910
4912
|
(next) => {
|
|
4911
4913
|
onOpenChange?.(next);
|
|
4912
4914
|
if (openProp === void 0) setUncontrolledOpen(next);
|
|
4913
4915
|
},
|
|
4914
4916
|
[onOpenChange, openProp]
|
|
4915
4917
|
);
|
|
4916
|
-
const [query, setQuery] =
|
|
4917
|
-
const [remoteItems, setRemoteItems] =
|
|
4918
|
-
const [isLoading, setIsLoading] =
|
|
4919
|
-
const [hasError, setHasError] =
|
|
4920
|
-
const [isLoadingMore, setIsLoadingMore] =
|
|
4918
|
+
const [query, setQuery] = React7.useState("");
|
|
4919
|
+
const [remoteItems, setRemoteItems] = React7.useState([]);
|
|
4920
|
+
const [isLoading, setIsLoading] = React7.useState(false);
|
|
4921
|
+
const [hasError, setHasError] = React7.useState(false);
|
|
4922
|
+
const [isLoadingMore, setIsLoadingMore] = React7.useState(false);
|
|
4921
4923
|
const debouncedQuery = useDebouncedValue(query, debounceMs);
|
|
4922
|
-
const requestIdRef =
|
|
4923
|
-
const knownItemsRef =
|
|
4924
|
-
const rememberItems =
|
|
4924
|
+
const requestIdRef = React7.useRef(0);
|
|
4925
|
+
const knownItemsRef = React7.useRef(/* @__PURE__ */ new Map());
|
|
4926
|
+
const rememberItems = React7.useCallback(
|
|
4925
4927
|
(items) => {
|
|
4926
4928
|
for (const item of items) {
|
|
4927
4929
|
knownItemsRef.current.set(getOptionValue(item), item);
|
|
@@ -4929,12 +4931,12 @@ function SearchablePicker(props) {
|
|
|
4929
4931
|
},
|
|
4930
4932
|
[getOptionValue]
|
|
4931
4933
|
);
|
|
4932
|
-
|
|
4934
|
+
React7.useEffect(() => {
|
|
4933
4935
|
if (options) rememberItems(options);
|
|
4934
4936
|
if (pinned?.recommended) rememberItems(pinned.recommended);
|
|
4935
4937
|
if (pinned?.recent) rememberItems(pinned.recent);
|
|
4936
4938
|
}, [options, pinned, rememberItems]);
|
|
4937
|
-
|
|
4939
|
+
React7.useEffect(() => {
|
|
4938
4940
|
if (!open) {
|
|
4939
4941
|
setQuery("");
|
|
4940
4942
|
setRemoteItems([]);
|
|
@@ -4944,7 +4946,7 @@ function SearchablePicker(props) {
|
|
|
4944
4946
|
}, [open]);
|
|
4945
4947
|
const trimmedDebounced = debouncedQuery.trim();
|
|
4946
4948
|
const shouldFetch = Boolean(fetchOptions) && open && trimmedDebounced.length >= minQueryLength && (trimmedDebounced.length > 0 || !options);
|
|
4947
|
-
|
|
4949
|
+
React7.useEffect(() => {
|
|
4948
4950
|
if (!shouldFetch || !fetchOptions) {
|
|
4949
4951
|
if (!trimmedDebounced) {
|
|
4950
4952
|
setRemoteItems([]);
|
|
@@ -4969,7 +4971,7 @@ function SearchablePicker(props) {
|
|
|
4969
4971
|
setIsLoading(false);
|
|
4970
4972
|
});
|
|
4971
4973
|
}, [shouldFetch, fetchOptions, trimmedDebounced, rememberItems]);
|
|
4972
|
-
const selectedValues =
|
|
4974
|
+
const selectedValues = React7.useMemo(() => {
|
|
4973
4975
|
if (mode === "multiple") {
|
|
4974
4976
|
const multiValue = props.value ?? [];
|
|
4975
4977
|
return new Set(multiValue);
|
|
@@ -4978,12 +4980,12 @@ function SearchablePicker(props) {
|
|
|
4978
4980
|
return singleValue ? /* @__PURE__ */ new Set([singleValue]) : /* @__PURE__ */ new Set();
|
|
4979
4981
|
}, [mode, props]);
|
|
4980
4982
|
const selectedValueKey = mode === "multiple" ? (props.value ?? []).join("\0") : props.value ?? "";
|
|
4981
|
-
const selectedItems =
|
|
4983
|
+
const selectedItems = React7.useMemo(() => {
|
|
4982
4984
|
const values = mode === "multiple" ? selectedValueKey ? selectedValueKey.split("\0") : [] : selectedValueKey ? [selectedValueKey] : [];
|
|
4983
4985
|
return values.map((value) => knownItemsRef.current.get(value)).filter((item) => item !== void 0);
|
|
4984
4986
|
}, [mode, selectedValueKey, options, pinned, remoteItems]);
|
|
4985
4987
|
const queryForFilter = query.trim();
|
|
4986
|
-
const recommended =
|
|
4988
|
+
const recommended = React7.useMemo(() => {
|
|
4987
4989
|
if (queryForFilter) return [];
|
|
4988
4990
|
const pinnedValues = /* @__PURE__ */ new Set();
|
|
4989
4991
|
const items = dedupeByValue(
|
|
@@ -4992,7 +4994,7 @@ function SearchablePicker(props) {
|
|
|
4992
4994
|
for (const entry of items) pinnedValues.add(entry.value);
|
|
4993
4995
|
return items;
|
|
4994
4996
|
}, [queryForFilter, pinned?.recommended, getOptionValue, getOptionLabel]);
|
|
4995
|
-
const recent =
|
|
4997
|
+
const recent = React7.useMemo(() => {
|
|
4996
4998
|
if (queryForFilter) return [];
|
|
4997
4999
|
const exclude = new Set(recommended.map((e) => e.value));
|
|
4998
5000
|
return dedupeByValue(
|
|
@@ -5006,13 +5008,13 @@ function SearchablePicker(props) {
|
|
|
5006
5008
|
getOptionValue,
|
|
5007
5009
|
getOptionLabel
|
|
5008
5010
|
]);
|
|
5009
|
-
const pinnedValueSet =
|
|
5011
|
+
const pinnedValueSet = React7.useMemo(() => {
|
|
5010
5012
|
const set = /* @__PURE__ */ new Set();
|
|
5011
5013
|
for (const entry of recommended) set.add(entry.value);
|
|
5012
5014
|
for (const entry of recent) set.add(entry.value);
|
|
5013
5015
|
return set;
|
|
5014
5016
|
}, [recommended, recent]);
|
|
5015
|
-
const results =
|
|
5017
|
+
const results = React7.useMemo(() => {
|
|
5016
5018
|
const usingRemote = Boolean(fetchOptions) && trimmedDebounced.length >= minQueryLength && (trimmedDebounced.length > 0 || !options);
|
|
5017
5019
|
if (usingRemote) {
|
|
5018
5020
|
return dedupeByValue(
|
|
@@ -5038,7 +5040,7 @@ function SearchablePicker(props) {
|
|
|
5038
5040
|
pinnedValueSet
|
|
5039
5041
|
]);
|
|
5040
5042
|
const closeOnSelect = keepOpenOnSelect !== void 0 ? !keepOpenOnSelect : mode === "single";
|
|
5041
|
-
const handleSelectEmpty =
|
|
5043
|
+
const handleSelectEmpty = React7.useCallback(() => {
|
|
5042
5044
|
if (mode === "single") {
|
|
5043
5045
|
props.onValueChange?.(
|
|
5044
5046
|
null
|
|
@@ -5046,7 +5048,7 @@ function SearchablePicker(props) {
|
|
|
5046
5048
|
}
|
|
5047
5049
|
if (closeOnSelect) setOpen(false);
|
|
5048
5050
|
}, [mode, props, closeOnSelect, setOpen]);
|
|
5049
|
-
const handleSelectItem =
|
|
5051
|
+
const handleSelectItem = React7.useCallback(
|
|
5050
5052
|
(value) => {
|
|
5051
5053
|
if (mode === "multiple") {
|
|
5052
5054
|
const current = props.value ?? [];
|
|
@@ -5069,7 +5071,7 @@ function SearchablePicker(props) {
|
|
|
5069
5071
|
},
|
|
5070
5072
|
[mode, props, maxSelected, closeOnSelect, setOpen]
|
|
5071
5073
|
);
|
|
5072
|
-
const handleClear =
|
|
5074
|
+
const handleClear = React7.useCallback(
|
|
5073
5075
|
(event) => {
|
|
5074
5076
|
event.preventDefault();
|
|
5075
5077
|
event.stopPropagation();
|
|
@@ -5083,7 +5085,7 @@ function SearchablePicker(props) {
|
|
|
5083
5085
|
},
|
|
5084
5086
|
[mode, props]
|
|
5085
5087
|
);
|
|
5086
|
-
const handleLoadMore =
|
|
5088
|
+
const handleLoadMore = React7.useCallback(async () => {
|
|
5087
5089
|
if (!onLoadMore || isLoadingMore) return;
|
|
5088
5090
|
setIsLoadingMore(true);
|
|
5089
5091
|
try {
|
|
@@ -5092,7 +5094,7 @@ function SearchablePicker(props) {
|
|
|
5092
5094
|
setIsLoadingMore(false);
|
|
5093
5095
|
}
|
|
5094
5096
|
}, [onLoadMore, isLoadingMore]);
|
|
5095
|
-
const triggerLabel =
|
|
5097
|
+
const triggerLabel = React7.useMemo(() => {
|
|
5096
5098
|
if (renderValue) {
|
|
5097
5099
|
if (mode === "multiple") {
|
|
5098
5100
|
return renderValue(selectedItems);
|
|
@@ -5274,20 +5276,20 @@ function SearchCommand({
|
|
|
5274
5276
|
className
|
|
5275
5277
|
}) {
|
|
5276
5278
|
const labels = { ...defaultLabels4, ...userLabels };
|
|
5277
|
-
const [query, setQuery] =
|
|
5278
|
-
const [hits, setHits] =
|
|
5279
|
-
const [isLoading, setIsLoading] =
|
|
5280
|
-
const [hasError, setHasError] =
|
|
5279
|
+
const [query, setQuery] = React7.useState("");
|
|
5280
|
+
const [hits, setHits] = React7.useState([]);
|
|
5281
|
+
const [isLoading, setIsLoading] = React7.useState(false);
|
|
5282
|
+
const [hasError, setHasError] = React7.useState(false);
|
|
5281
5283
|
const debouncedQuery = useDebouncedValue(query, debounceMs);
|
|
5282
|
-
const requestIdRef =
|
|
5283
|
-
|
|
5284
|
+
const requestIdRef = React7.useRef(0);
|
|
5285
|
+
React7.useEffect(() => {
|
|
5284
5286
|
if (!open) {
|
|
5285
5287
|
setQuery("");
|
|
5286
5288
|
setHits([]);
|
|
5287
5289
|
setHasError(false);
|
|
5288
5290
|
}
|
|
5289
5291
|
}, [open]);
|
|
5290
|
-
|
|
5292
|
+
React7.useEffect(() => {
|
|
5291
5293
|
const trimmed = debouncedQuery.trim();
|
|
5292
5294
|
if (trimmed.length < minQueryLength) {
|
|
5293
5295
|
setHits([]);
|
|
@@ -5310,13 +5312,13 @@ function SearchCommand({
|
|
|
5310
5312
|
setIsLoading(false);
|
|
5311
5313
|
});
|
|
5312
5314
|
}, [debouncedQuery, minQueryLength, fetchResults]);
|
|
5313
|
-
const filteredFeatures =
|
|
5315
|
+
const filteredFeatures = React7.useMemo(() => {
|
|
5314
5316
|
if (!query.trim()) return features;
|
|
5315
5317
|
return features.filter(
|
|
5316
5318
|
(feature) => fuzzyMatch(query, feature.label) || feature.keywords?.some((keyword) => fuzzyMatch(query, keyword))
|
|
5317
5319
|
);
|
|
5318
5320
|
}, [features, query]);
|
|
5319
|
-
const groupedHits =
|
|
5321
|
+
const groupedHits = React7.useMemo(() => groupHitsByType(hits), [hits]);
|
|
5320
5322
|
function handleSelect(selection) {
|
|
5321
5323
|
onSelect(selection);
|
|
5322
5324
|
onOpenChange(false);
|
|
@@ -5450,7 +5452,7 @@ function ScrollBar({
|
|
|
5450
5452
|
);
|
|
5451
5453
|
}
|
|
5452
5454
|
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 =
|
|
5455
|
+
var PhoneInput = React7__namespace.forwardRef(
|
|
5454
5456
|
({ className, onChange, value, defaultCountry = "MX", ...props }, ref) => {
|
|
5455
5457
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
5456
5458
|
RPNInput__namespace.default,
|
|
@@ -5470,7 +5472,7 @@ var PhoneInput = React6__namespace.forwardRef(
|
|
|
5470
5472
|
}
|
|
5471
5473
|
);
|
|
5472
5474
|
PhoneInput.displayName = "PhoneInput";
|
|
5473
|
-
var InputComponent =
|
|
5475
|
+
var InputComponent = React7__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
5474
5476
|
Input,
|
|
5475
5477
|
{
|
|
5476
5478
|
className: cn(
|
|
@@ -5488,9 +5490,9 @@ var CountrySelect = ({
|
|
|
5488
5490
|
options: countryList,
|
|
5489
5491
|
onChange
|
|
5490
5492
|
}) => {
|
|
5491
|
-
const scrollAreaRef =
|
|
5492
|
-
const [searchValue, setSearchValue] =
|
|
5493
|
-
const [isOpen, setIsOpen] =
|
|
5493
|
+
const scrollAreaRef = React7__namespace.useRef(null);
|
|
5494
|
+
const [searchValue, setSearchValue] = React7__namespace.useState("");
|
|
5495
|
+
const [isOpen, setIsOpen] = React7__namespace.useState(false);
|
|
5494
5496
|
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
5495
5497
|
Popover,
|
|
5496
5498
|
{
|
|
@@ -5671,8 +5673,8 @@ var MEXICO_STATE_PATHS = {
|
|
|
5671
5673
|
};
|
|
5672
5674
|
function MexicoMap({ selected, onToggle, className }) {
|
|
5673
5675
|
const isInteractive = typeof onToggle === "function";
|
|
5674
|
-
const selectedSet =
|
|
5675
|
-
const handleKeyDown =
|
|
5676
|
+
const selectedSet = React7__namespace.useMemo(() => new Set(selected), [selected]);
|
|
5677
|
+
const handleKeyDown = React7__namespace.useCallback(
|
|
5676
5678
|
(event, id) => {
|
|
5677
5679
|
if (!onToggle) return;
|
|
5678
5680
|
if (event.key === "Enter" || event.key === " ") {
|
|
@@ -6154,6 +6156,121 @@ function ChatMessageList({
|
|
|
6154
6156
|
/* @__PURE__ */ jsxRuntime.jsx(MessageScrollerButton, {})
|
|
6155
6157
|
] }) });
|
|
6156
6158
|
}
|
|
6159
|
+
var MessageComposer = React7__namespace.forwardRef(function MessageComposer2({
|
|
6160
|
+
className,
|
|
6161
|
+
locale = "en",
|
|
6162
|
+
disabled,
|
|
6163
|
+
readOnly,
|
|
6164
|
+
value,
|
|
6165
|
+
onChange,
|
|
6166
|
+
onSubmit,
|
|
6167
|
+
onKeyDown,
|
|
6168
|
+
sendLabel,
|
|
6169
|
+
sendDisabled = false,
|
|
6170
|
+
sendButtonClassName,
|
|
6171
|
+
sendButtonSize = "sm",
|
|
6172
|
+
triggerLabel,
|
|
6173
|
+
keepOpenOnSelect,
|
|
6174
|
+
open,
|
|
6175
|
+
onOpenChange,
|
|
6176
|
+
side = "top",
|
|
6177
|
+
align = "end",
|
|
6178
|
+
labels,
|
|
6179
|
+
recentLimit,
|
|
6180
|
+
storageKey,
|
|
6181
|
+
emojiTriggerClassName,
|
|
6182
|
+
rows = 2,
|
|
6183
|
+
...props
|
|
6184
|
+
}, ref) {
|
|
6185
|
+
const formRef = React7__namespace.useRef(null);
|
|
6186
|
+
const fieldRef = React7__namespace.useRef(null);
|
|
6187
|
+
const handleEmojiSelect = useEmojiInsert(fieldRef, value, onChange);
|
|
6188
|
+
const pickerDisabled = Boolean(disabled || readOnly);
|
|
6189
|
+
const draft = value !== void 0 && value !== null ? String(value) : "";
|
|
6190
|
+
const canSubmit = Boolean(draft.trim()) && !sendDisabled && !disabled && !readOnly;
|
|
6191
|
+
const handleSubmit = React7__namespace.useCallback(
|
|
6192
|
+
(event) => {
|
|
6193
|
+
event.preventDefault();
|
|
6194
|
+
if (!canSubmit) return;
|
|
6195
|
+
onSubmit(event);
|
|
6196
|
+
},
|
|
6197
|
+
[canSubmit, onSubmit]
|
|
6198
|
+
);
|
|
6199
|
+
const handleKeyDown = React7__namespace.useCallback(
|
|
6200
|
+
(event) => {
|
|
6201
|
+
onKeyDown?.(event);
|
|
6202
|
+
if (event.defaultPrevented) return;
|
|
6203
|
+
if (event.key !== "Enter" || event.shiftKey) return;
|
|
6204
|
+
if (event.nativeEvent.isComposing || event.keyCode === 229) return;
|
|
6205
|
+
event.preventDefault();
|
|
6206
|
+
if (!canSubmit) return;
|
|
6207
|
+
formRef.current?.requestSubmit();
|
|
6208
|
+
},
|
|
6209
|
+
[canSubmit, onKeyDown]
|
|
6210
|
+
);
|
|
6211
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
6212
|
+
"form",
|
|
6213
|
+
{
|
|
6214
|
+
ref: formRef,
|
|
6215
|
+
className: cn(emojiFieldWrapperClassName, "flex flex-col", className),
|
|
6216
|
+
onSubmit: handleSubmit,
|
|
6217
|
+
children: [
|
|
6218
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
6219
|
+
"textarea",
|
|
6220
|
+
{
|
|
6221
|
+
"data-slot": "textarea",
|
|
6222
|
+
ref: mergeRefs(fieldRef, ref),
|
|
6223
|
+
disabled,
|
|
6224
|
+
readOnly,
|
|
6225
|
+
value,
|
|
6226
|
+
onChange,
|
|
6227
|
+
onKeyDown: handleKeyDown,
|
|
6228
|
+
rows,
|
|
6229
|
+
className: cn(
|
|
6230
|
+
"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",
|
|
6231
|
+
emojiFieldResetClassName
|
|
6232
|
+
),
|
|
6233
|
+
...props
|
|
6234
|
+
}
|
|
6235
|
+
),
|
|
6236
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-between gap-2 px-1.5 pb-1.5", children: [
|
|
6237
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
6238
|
+
EmojiPickerPopover,
|
|
6239
|
+
{
|
|
6240
|
+
locale,
|
|
6241
|
+
onSelect: handleEmojiSelect,
|
|
6242
|
+
disabled: pickerDisabled,
|
|
6243
|
+
triggerLabel,
|
|
6244
|
+
keepOpenOnSelect,
|
|
6245
|
+
open,
|
|
6246
|
+
onOpenChange,
|
|
6247
|
+
side,
|
|
6248
|
+
align,
|
|
6249
|
+
labels,
|
|
6250
|
+
recentLimit,
|
|
6251
|
+
storageKey,
|
|
6252
|
+
triggerClassName: cn(
|
|
6253
|
+
"size-7 text-muted-foreground",
|
|
6254
|
+
emojiTriggerClassName
|
|
6255
|
+
)
|
|
6256
|
+
}
|
|
6257
|
+
),
|
|
6258
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
6259
|
+
Button,
|
|
6260
|
+
{
|
|
6261
|
+
type: "submit",
|
|
6262
|
+
size: sendButtonSize,
|
|
6263
|
+
disabled: !canSubmit,
|
|
6264
|
+
className: sendButtonClassName,
|
|
6265
|
+
children: sendLabel
|
|
6266
|
+
}
|
|
6267
|
+
)
|
|
6268
|
+
] })
|
|
6269
|
+
]
|
|
6270
|
+
}
|
|
6271
|
+
);
|
|
6272
|
+
});
|
|
6273
|
+
MessageComposer.displayName = "MessageComposer";
|
|
6157
6274
|
var RECONNECT_DELAY_MS = 2e3;
|
|
6158
6275
|
function useSupportConversation({
|
|
6159
6276
|
client,
|
|
@@ -6164,21 +6281,21 @@ function useSupportConversation({
|
|
|
6164
6281
|
onConversationReady,
|
|
6165
6282
|
onIncomingMessage
|
|
6166
6283
|
}) {
|
|
6167
|
-
const [conversationId, setConversationId] =
|
|
6284
|
+
const [conversationId, setConversationId] = React7.useState(
|
|
6168
6285
|
conversationIdProp
|
|
6169
6286
|
);
|
|
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 =
|
|
6287
|
+
const [messages, setMessages] = React7.useState([]);
|
|
6288
|
+
const [loading, setLoading] = React7.useState(false);
|
|
6289
|
+
const [sending, setSending] = React7.useState(false);
|
|
6290
|
+
const [error, setError] = React7.useState(null);
|
|
6291
|
+
const socketRef = React7.useRef(null);
|
|
6292
|
+
const reconnectRef = React7.useRef(null);
|
|
6293
|
+
const closedByUser = React7.useRef(false);
|
|
6294
|
+
const onReadyRef = React7.useRef(onConversationReady);
|
|
6295
|
+
const onIncomingRef = React7.useRef(onIncomingMessage);
|
|
6179
6296
|
onReadyRef.current = onConversationReady;
|
|
6180
6297
|
onIncomingRef.current = onIncomingMessage;
|
|
6181
|
-
const load =
|
|
6298
|
+
const load = React7.useCallback(async () => {
|
|
6182
6299
|
if (!enabled) return;
|
|
6183
6300
|
setLoading(true);
|
|
6184
6301
|
setError(null);
|
|
@@ -6204,10 +6321,10 @@ function useSupportConversation({
|
|
|
6204
6321
|
setLoading(false);
|
|
6205
6322
|
}
|
|
6206
6323
|
}, [client, conversationIdProp, enabled, open]);
|
|
6207
|
-
|
|
6324
|
+
React7.useEffect(() => {
|
|
6208
6325
|
void load();
|
|
6209
6326
|
}, [load]);
|
|
6210
|
-
|
|
6327
|
+
React7.useEffect(() => {
|
|
6211
6328
|
closedByUser.current = false;
|
|
6212
6329
|
if (!enabled || !conversationId) return;
|
|
6213
6330
|
let cancelled = false;
|
|
@@ -6253,7 +6370,7 @@ function useSupportConversation({
|
|
|
6253
6370
|
socketRef.current = null;
|
|
6254
6371
|
};
|
|
6255
6372
|
}, [conversationId, enabled, getWsUrl]);
|
|
6256
|
-
const send =
|
|
6373
|
+
const send = React7.useCallback(
|
|
6257
6374
|
async (text) => {
|
|
6258
6375
|
const trimmed = text.trim();
|
|
6259
6376
|
if (!conversationId || !trimmed || sending) return;
|
|
@@ -6285,9 +6402,9 @@ function useSupportConversation({
|
|
|
6285
6402
|
reload: load
|
|
6286
6403
|
};
|
|
6287
6404
|
}
|
|
6288
|
-
var SupportMessengerContext =
|
|
6405
|
+
var SupportMessengerContext = React7.createContext(null);
|
|
6289
6406
|
function useSupportMessenger() {
|
|
6290
|
-
const ctx =
|
|
6407
|
+
const ctx = React7.useContext(SupportMessengerContext);
|
|
6291
6408
|
if (!ctx) {
|
|
6292
6409
|
throw new Error(
|
|
6293
6410
|
"useSupportMessenger must be used within SupportMessengerProvider"
|
|
@@ -6296,7 +6413,7 @@ function useSupportMessenger() {
|
|
|
6296
6413
|
return ctx;
|
|
6297
6414
|
}
|
|
6298
6415
|
function useSupportMessengerOptional() {
|
|
6299
|
-
return
|
|
6416
|
+
return React7.useContext(SupportMessengerContext);
|
|
6300
6417
|
}
|
|
6301
6418
|
function ThreadPanel({
|
|
6302
6419
|
thread,
|
|
@@ -6311,7 +6428,7 @@ function ThreadPanel({
|
|
|
6311
6428
|
onConversationReady,
|
|
6312
6429
|
className
|
|
6313
6430
|
}) {
|
|
6314
|
-
const [draft, setDraft] =
|
|
6431
|
+
const [draft, setDraft] = React7.useState("");
|
|
6315
6432
|
const { messages, loading, sending, error, send } = useSupportConversation({
|
|
6316
6433
|
client,
|
|
6317
6434
|
getWsUrl,
|
|
@@ -6374,23 +6491,22 @@ function ThreadPanel({
|
|
|
6374
6491
|
emptyDescription: labels.emptyThread
|
|
6375
6492
|
}
|
|
6376
6493
|
) }),
|
|
6377
|
-
/* @__PURE__ */ jsxRuntime.
|
|
6378
|
-
|
|
6379
|
-
|
|
6380
|
-
|
|
6381
|
-
|
|
6382
|
-
|
|
6383
|
-
|
|
6384
|
-
|
|
6385
|
-
|
|
6386
|
-
|
|
6387
|
-
|
|
6388
|
-
|
|
6389
|
-
|
|
6390
|
-
|
|
6391
|
-
|
|
6392
|
-
|
|
6393
|
-
] })
|
|
6494
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "border-t p-3", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
6495
|
+
MessageComposer,
|
|
6496
|
+
{
|
|
6497
|
+
locale: emojiLocale,
|
|
6498
|
+
value: draft,
|
|
6499
|
+
onChange: (e) => setDraft(e.target.value.slice(0, 2e3)),
|
|
6500
|
+
onSubmit,
|
|
6501
|
+
sendLabel: labels.send,
|
|
6502
|
+
placeholder: labels.placeholder,
|
|
6503
|
+
"aria-label": labels.placeholder,
|
|
6504
|
+
disabled: loading || sending,
|
|
6505
|
+
sendDisabled: loading || sending,
|
|
6506
|
+
maxLength: 2e3,
|
|
6507
|
+
rows: 2
|
|
6508
|
+
}
|
|
6509
|
+
) })
|
|
6394
6510
|
]
|
|
6395
6511
|
}
|
|
6396
6512
|
);
|
|
@@ -6406,9 +6522,9 @@ function ListPanel({
|
|
|
6406
6522
|
searchThreshold,
|
|
6407
6523
|
className
|
|
6408
6524
|
}) {
|
|
6409
|
-
const [query, setQuery] =
|
|
6525
|
+
const [query, setQuery] = React7.useState("");
|
|
6410
6526
|
const showSearch = items.length >= searchThreshold;
|
|
6411
|
-
const filtered =
|
|
6527
|
+
const filtered = React7.useMemo(() => {
|
|
6412
6528
|
const q = query.trim().toLowerCase();
|
|
6413
6529
|
if (!q) return items;
|
|
6414
6530
|
return items.filter(
|
|
@@ -6512,32 +6628,32 @@ function SupportMessengerProvider({
|
|
|
6512
6628
|
className
|
|
6513
6629
|
}) {
|
|
6514
6630
|
const isMobile = useMediaQuery2("(max-width: 767px)");
|
|
6515
|
-
const [listOpen, setListOpen] =
|
|
6516
|
-
const [threads, setThreads] =
|
|
6517
|
-
const [mobileThreadKey, setMobileThreadKey] =
|
|
6518
|
-
const totalUnread =
|
|
6631
|
+
const [listOpen, setListOpen] = React7.useState(false);
|
|
6632
|
+
const [threads, setThreads] = React7.useState([]);
|
|
6633
|
+
const [mobileThreadKey, setMobileThreadKey] = React7.useState(null);
|
|
6634
|
+
const totalUnread = React7.useMemo(
|
|
6519
6635
|
() => items.reduce((sum, item) => sum + (item.unreadCount ?? 0), 0),
|
|
6520
6636
|
[items]
|
|
6521
6637
|
);
|
|
6522
|
-
|
|
6638
|
+
React7.useEffect(() => {
|
|
6523
6639
|
if (!forceMinimized) return;
|
|
6524
6640
|
setListOpen(false);
|
|
6525
6641
|
setThreads([]);
|
|
6526
6642
|
setMobileThreadKey(null);
|
|
6527
6643
|
}, [forceMinimized]);
|
|
6528
|
-
const openList =
|
|
6644
|
+
const openList = React7.useCallback(() => {
|
|
6529
6645
|
setListOpen(true);
|
|
6530
6646
|
void onRefreshItems?.();
|
|
6531
6647
|
}, [onRefreshItems]);
|
|
6532
|
-
const closeList =
|
|
6533
|
-
const toggleList =
|
|
6648
|
+
const closeList = React7.useCallback(() => setListOpen(false), []);
|
|
6649
|
+
const toggleList = React7.useCallback(() => {
|
|
6534
6650
|
setListOpen((prev) => {
|
|
6535
6651
|
const next = !prev;
|
|
6536
6652
|
if (next) void onRefreshItems?.();
|
|
6537
6653
|
return next;
|
|
6538
6654
|
});
|
|
6539
6655
|
}, [onRefreshItems]);
|
|
6540
|
-
const openThread =
|
|
6656
|
+
const openThread = React7.useCallback((req) => {
|
|
6541
6657
|
setListOpen(false);
|
|
6542
6658
|
setThreads((prev) => {
|
|
6543
6659
|
const existing = prev.find((t) => t.key === req.key);
|
|
@@ -6552,16 +6668,16 @@ function SupportMessengerProvider({
|
|
|
6552
6668
|
});
|
|
6553
6669
|
setMobileThreadKey(req.key);
|
|
6554
6670
|
}, []);
|
|
6555
|
-
const closeThread =
|
|
6671
|
+
const closeThread = React7.useCallback((key) => {
|
|
6556
6672
|
setThreads((prev) => prev.filter((t) => t.key !== key));
|
|
6557
6673
|
setMobileThreadKey((prev) => prev === key ? null : prev);
|
|
6558
6674
|
}, []);
|
|
6559
|
-
const closeAll =
|
|
6675
|
+
const closeAll = React7.useCallback(() => {
|
|
6560
6676
|
setListOpen(false);
|
|
6561
6677
|
setThreads([]);
|
|
6562
6678
|
setMobileThreadKey(null);
|
|
6563
6679
|
}, []);
|
|
6564
|
-
const ctx =
|
|
6680
|
+
const ctx = React7.useMemo(
|
|
6565
6681
|
() => ({
|
|
6566
6682
|
listOpen,
|
|
6567
6683
|
openList,
|
|
@@ -6586,7 +6702,7 @@ function SupportMessengerProvider({
|
|
|
6586
6702
|
totalUnread
|
|
6587
6703
|
]
|
|
6588
6704
|
);
|
|
6589
|
-
const handleSelectItem =
|
|
6705
|
+
const handleSelectItem = React7.useCallback(
|
|
6590
6706
|
(item) => {
|
|
6591
6707
|
openThread({
|
|
6592
6708
|
key: item.key,
|
|
@@ -6816,6 +6932,7 @@ exports.MarkerContent = MarkerContent;
|
|
|
6816
6932
|
exports.MarkerIcon = MarkerIcon;
|
|
6817
6933
|
exports.Message = Message;
|
|
6818
6934
|
exports.MessageAvatar = MessageAvatar;
|
|
6935
|
+
exports.MessageComposer = MessageComposer;
|
|
6819
6936
|
exports.MessageContent = MessageContent;
|
|
6820
6937
|
exports.MessageFooter = MessageFooter;
|
|
6821
6938
|
exports.MessageGroup = MessageGroup;
|