@underverse-ui/underverse 1.0.88 → 1.0.90
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/api-reference.json +1 -1
- package/dist/index.cjs +48 -22
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +145 -119
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -543,7 +543,7 @@ var Checkbox = React3.forwardRef(
|
|
|
543
543
|
Checkbox.displayName = "Checkbox";
|
|
544
544
|
|
|
545
545
|
// src/components/Input.tsx
|
|
546
|
-
import React8, { forwardRef as forwardRef3, useCallback as useCallback4, useId, useRef as useRef2, useState as
|
|
546
|
+
import React8, { forwardRef as forwardRef3, useCallback as useCallback4, useId, useRef as useRef2, useState as useState4 } from "react";
|
|
547
547
|
|
|
548
548
|
// src/hooks/useSmartTranslations.tsx
|
|
549
549
|
import * as React6 from "react";
|
|
@@ -1796,40 +1796,48 @@ function getEnvironmentLocale(fallback) {
|
|
|
1796
1796
|
}
|
|
1797
1797
|
return fallback;
|
|
1798
1798
|
}
|
|
1799
|
-
function getExternalLocaleFallback(internalLocale) {
|
|
1800
|
-
if (internalLocale !== "en") {
|
|
1801
|
-
return internalLocale;
|
|
1802
|
-
}
|
|
1803
|
-
return getEnvironmentLocale(internalLocale);
|
|
1804
|
-
}
|
|
1805
1799
|
function useSmartTranslations(namespace) {
|
|
1806
1800
|
const forceInternal = React6.useContext(ForceInternalContext);
|
|
1807
1801
|
const nextIntlBridge = useNextIntlBridge();
|
|
1808
1802
|
const internalT = useUnderverseTranslations(namespace);
|
|
1809
1803
|
const internalLocale = useUnderverseLocale();
|
|
1804
|
+
const [environmentLocale, setEnvironmentLocale] = React6.useState(null);
|
|
1805
|
+
React6.useEffect(() => {
|
|
1806
|
+
if (forceInternal) return;
|
|
1807
|
+
if (nextIntlBridge) return;
|
|
1808
|
+
if (internalLocale !== "en") return;
|
|
1809
|
+
const detected = getEnvironmentLocale(internalLocale);
|
|
1810
|
+
if (detected !== internalLocale) {
|
|
1811
|
+
setEnvironmentLocale(detected);
|
|
1812
|
+
}
|
|
1813
|
+
}, [forceInternal, internalLocale, nextIntlBridge]);
|
|
1810
1814
|
if (forceInternal) {
|
|
1811
1815
|
return internalT;
|
|
1812
1816
|
}
|
|
1813
|
-
const resolvedLocale = nextIntlBridge?.locale ?? getExternalLocaleFallback(internalLocale);
|
|
1814
1817
|
return (key) => {
|
|
1818
|
+
const primaryLocale = nextIntlBridge?.locale ?? internalLocale;
|
|
1819
|
+
const fallbackLocale = environmentLocale && environmentLocale !== primaryLocale ? environmentLocale : null;
|
|
1815
1820
|
let translated = null;
|
|
1816
1821
|
if (nextIntlBridge) {
|
|
1817
1822
|
const nextIntlResult = nextIntlBridge.translate(namespace, key);
|
|
1818
1823
|
translated = nextIntlResult.translated;
|
|
1819
1824
|
}
|
|
1820
|
-
const
|
|
1821
|
-
const
|
|
1825
|
+
const localizedDefault = getUnderverseDefaultTranslation(primaryLocale, namespace, key);
|
|
1826
|
+
const fallbackLocalizedDefault = fallbackLocale ? getUnderverseDefaultTranslation(fallbackLocale, namespace, key) : key;
|
|
1822
1827
|
const englishDefault = getUnderverseDefaultTranslation("en", namespace, key);
|
|
1823
1828
|
const internalValue = internalT(key);
|
|
1824
|
-
if (translated && !isUnresolvedTranslation(translated, namespace, key) && !(
|
|
1829
|
+
if (translated && !isUnresolvedTranslation(translated, namespace, key) && !(primaryLocale !== "en" && localizedDefault !== englishDefault && translated === englishDefault)) {
|
|
1825
1830
|
return translated;
|
|
1826
1831
|
}
|
|
1827
|
-
if (internalLocale ===
|
|
1832
|
+
if (internalLocale === primaryLocale && internalValue !== key) {
|
|
1828
1833
|
return internalValue;
|
|
1829
1834
|
}
|
|
1830
1835
|
if (localizedDefault !== key) {
|
|
1831
1836
|
return localizedDefault;
|
|
1832
1837
|
}
|
|
1838
|
+
if (fallbackLocalizedDefault !== key) {
|
|
1839
|
+
return fallbackLocalizedDefault;
|
|
1840
|
+
}
|
|
1833
1841
|
if (internalValue !== key) {
|
|
1834
1842
|
return internalValue;
|
|
1835
1843
|
}
|
|
@@ -1843,14 +1851,14 @@ function useSmartLocale() {
|
|
|
1843
1851
|
if (forceInternal) {
|
|
1844
1852
|
return internalLocale;
|
|
1845
1853
|
}
|
|
1846
|
-
return nextIntlBridge?.locale ??
|
|
1854
|
+
return nextIntlBridge?.locale ?? internalLocale;
|
|
1847
1855
|
}
|
|
1848
1856
|
|
|
1849
1857
|
// src/components/Input.tsx
|
|
1850
1858
|
import { Eye, EyeOff, Search, X, AlertCircle, CheckCircle, Loader2 } from "lucide-react";
|
|
1851
1859
|
|
|
1852
1860
|
// src/components/OverlayScrollbarProvider.tsx
|
|
1853
|
-
import { createContext as createContext4, useContext as useContext4, useEffect, useMemo as useMemo2 } from "react";
|
|
1861
|
+
import { createContext as createContext4, useContext as useContext4, useEffect as useEffect2, useMemo as useMemo2 } from "react";
|
|
1854
1862
|
import { OverlayScrollbars } from "overlayscrollbars";
|
|
1855
1863
|
|
|
1856
1864
|
// src/utils/overlay-scrollbar-controller.ts
|
|
@@ -2068,7 +2076,7 @@ function useOverlayScrollbarTarget(targetRef, options = {}) {
|
|
|
2068
2076
|
}),
|
|
2069
2077
|
[enabled, theme, visibility, autoHide, autoHideDelay, dragScroll, clickScroll, exclude]
|
|
2070
2078
|
);
|
|
2071
|
-
|
|
2079
|
+
useEffect2(() => {
|
|
2072
2080
|
if (typeof window === "undefined") return;
|
|
2073
2081
|
const target = targetRef.current;
|
|
2074
2082
|
if (!target) return;
|
|
@@ -2122,9 +2130,9 @@ var Input = forwardRef3(
|
|
|
2122
2130
|
rightAddon,
|
|
2123
2131
|
...rest
|
|
2124
2132
|
}, ref) => {
|
|
2125
|
-
const [localError, setLocalError] =
|
|
2126
|
-
const [showPassword, setShowPassword] =
|
|
2127
|
-
const [isFocused, setIsFocused] =
|
|
2133
|
+
const [localError, setLocalError] = useState4(error);
|
|
2134
|
+
const [showPassword, setShowPassword] = useState4(false);
|
|
2135
|
+
const [isFocused, setIsFocused] = useState4(false);
|
|
2128
2136
|
const tv = useSmartTranslations("ValidationInput");
|
|
2129
2137
|
const autoId = useId();
|
|
2130
2138
|
const needsId = !!(label || description || hint || error);
|
|
@@ -2388,7 +2396,7 @@ var Input = forwardRef3(
|
|
|
2388
2396
|
Input.displayName = "Input";
|
|
2389
2397
|
var SearchInput = forwardRef3(
|
|
2390
2398
|
({ onSearch, searchDelay = 300, placeholder = "Search\u2026", ...props }, ref) => {
|
|
2391
|
-
const [searchValue, setSearchValue] =
|
|
2399
|
+
const [searchValue, setSearchValue] = useState4(props.value || "");
|
|
2392
2400
|
React8.useEffect(() => {
|
|
2393
2401
|
if (!onSearch) return;
|
|
2394
2402
|
const timer = setTimeout(() => {
|
|
@@ -2601,7 +2609,7 @@ var Textarea = forwardRef3(
|
|
|
2601
2609
|
maxLength,
|
|
2602
2610
|
...props
|
|
2603
2611
|
}, ref) => {
|
|
2604
|
-
const [isFocused, setIsFocused] =
|
|
2612
|
+
const [isFocused, setIsFocused] = useState4(false);
|
|
2605
2613
|
const textareaRef = useRef2(null);
|
|
2606
2614
|
const charCount = typeof value === "string" ? value.length : 0;
|
|
2607
2615
|
useOverlayScrollbarTarget(textareaRef, { enabled: useOverlayScrollbar });
|
|
@@ -2704,7 +2712,7 @@ Textarea.displayName = "Textarea";
|
|
|
2704
2712
|
var Input_default = Input;
|
|
2705
2713
|
|
|
2706
2714
|
// src/components/EmojiPicker.tsx
|
|
2707
|
-
import { useEffect as
|
|
2715
|
+
import { useEffect as useEffect4, useMemo as useMemo3, useRef as useRef4, useState as useState6 } from "react";
|
|
2708
2716
|
import { Search as Search2, X as X2, Smile, Leaf, Utensils, Dumbbell, Lightbulb, Hash, Flag } from "lucide-react";
|
|
2709
2717
|
|
|
2710
2718
|
// src/components/Tooltip.tsx
|
|
@@ -3788,8 +3796,8 @@ var EmojiPicker = ({
|
|
|
3788
3796
|
chrome = "standalone"
|
|
3789
3797
|
}) => {
|
|
3790
3798
|
const t = useSmartTranslations("UEditor");
|
|
3791
|
-
const [search, setSearch] =
|
|
3792
|
-
const [activeCategory, setActiveCategory] =
|
|
3799
|
+
const [search, setSearch] = useState6("");
|
|
3800
|
+
const [activeCategory, setActiveCategory] = useState6(EMOJI_LIST[0]?.id || "");
|
|
3793
3801
|
const scrollContainerRef = useRef4(null);
|
|
3794
3802
|
const categoryRefs = useRef4({});
|
|
3795
3803
|
const isUserScrolling = useRef4(false);
|
|
@@ -3809,7 +3817,7 @@ var EmojiPicker = ({
|
|
|
3809
3817
|
emojis: category.emojis.filter((emoji) => emoji.name.toLowerCase().includes(query) || emoji.emoji.includes(search))
|
|
3810
3818
|
})).filter((category) => category.emojis.length > 0);
|
|
3811
3819
|
}, [search]);
|
|
3812
|
-
|
|
3820
|
+
useEffect4(() => {
|
|
3813
3821
|
if (search) return;
|
|
3814
3822
|
const container = scrollContainerRef.current;
|
|
3815
3823
|
if (!container) return;
|
|
@@ -3837,7 +3845,7 @@ var EmojiPicker = ({
|
|
|
3837
3845
|
container.addEventListener("scroll", handleScroll);
|
|
3838
3846
|
return () => container.removeEventListener("scroll", handleScroll);
|
|
3839
3847
|
}, [activeCategory, search]);
|
|
3840
|
-
|
|
3848
|
+
useEffect4(() => {
|
|
3841
3849
|
isUserScrolling.current = true;
|
|
3842
3850
|
}, []);
|
|
3843
3851
|
const renderEmojiCategory = (category, assignRef2 = false) => /* @__PURE__ */ jsxs7(
|
|
@@ -3939,7 +3947,7 @@ var EmojiPicker = ({
|
|
|
3939
3947
|
var EmojiPicker_default = EmojiPicker;
|
|
3940
3948
|
|
|
3941
3949
|
// src/components/TagInput.tsx
|
|
3942
|
-
import { forwardRef as forwardRef4, useState as
|
|
3950
|
+
import { forwardRef as forwardRef4, useState as useState7, useRef as useRef5, useId as useId3 } from "react";
|
|
3943
3951
|
import { X as X3, Search as Search3, Loader2 as Loader22 } from "lucide-react";
|
|
3944
3952
|
import { jsx as jsx13, jsxs as jsxs8 } from "react/jsx-runtime";
|
|
3945
3953
|
var TagInput = forwardRef4(
|
|
@@ -3962,8 +3970,8 @@ var TagInput = forwardRef4(
|
|
|
3962
3970
|
maxVisibleTags,
|
|
3963
3971
|
labels
|
|
3964
3972
|
}, ref) => {
|
|
3965
|
-
const [inputValue, setInputValue] =
|
|
3966
|
-
const [isFocused, setIsFocused] =
|
|
3973
|
+
const [inputValue, setInputValue] = useState7("");
|
|
3974
|
+
const [isFocused, setIsFocused] = useState7(false);
|
|
3967
3975
|
const inputRef = useRef5(null);
|
|
3968
3976
|
const autoId = useId3();
|
|
3969
3977
|
const inputId = `tag-input-${autoId}`;
|
|
@@ -3972,7 +3980,7 @@ var TagInput = forwardRef4(
|
|
|
3972
3980
|
const searchLabel = labels?.search ?? "Search";
|
|
3973
3981
|
const clearAllLabel = labels?.clearAll ?? "Clear all";
|
|
3974
3982
|
const isMaxReached = maxTags !== void 0 && value.length >= maxTags;
|
|
3975
|
-
const [isExpanded, setIsExpanded] =
|
|
3983
|
+
const [isExpanded, setIsExpanded] = useState7(false);
|
|
3976
3984
|
const hiddenCount = maxVisibleTags !== void 0 && !isExpanded ? Math.max(0, value.length - maxVisibleTags) : 0;
|
|
3977
3985
|
const visibleTags = hiddenCount > 0 ? value.slice(0, maxVisibleTags) : value;
|
|
3978
3986
|
const moreLabel = labels?.moreCount?.replace("{count}", String(hiddenCount)) ?? `+${hiddenCount} more`;
|
|
@@ -5231,7 +5239,7 @@ var Modal = ({
|
|
|
5231
5239
|
var Modal_default = Modal;
|
|
5232
5240
|
|
|
5233
5241
|
// src/components/Toast.tsx
|
|
5234
|
-
import { createContext as createContext5, useContext as useContext5, useState as
|
|
5242
|
+
import { createContext as createContext5, useContext as useContext5, useState as useState10, useCallback as useCallback6, useEffect as useEffect6, useRef as useRef7 } from "react";
|
|
5235
5243
|
import { X as X6, CheckCircle as CheckCircle2, AlertCircle as AlertCircle2, Info, AlertTriangle as AlertTriangle2 } from "lucide-react";
|
|
5236
5244
|
import { jsx as jsx21, jsxs as jsxs14 } from "react/jsx-runtime";
|
|
5237
5245
|
var ToastContext = createContext5(void 0);
|
|
@@ -5243,7 +5251,7 @@ var useToast = () => {
|
|
|
5243
5251
|
return context;
|
|
5244
5252
|
};
|
|
5245
5253
|
var ToastProvider = ({ children, position = "top-right", maxToasts = 5 }) => {
|
|
5246
|
-
const [toasts, setToasts] =
|
|
5254
|
+
const [toasts, setToasts] = useState10([]);
|
|
5247
5255
|
const idRef = useRef7(0);
|
|
5248
5256
|
const removeToast = useCallback6((id) => {
|
|
5249
5257
|
setToasts((prev) => prev.filter((toast) => toast.id !== id));
|
|
@@ -5273,9 +5281,9 @@ var ToastProvider = ({ children, position = "top-right", maxToasts = 5 }) => {
|
|
|
5273
5281
|
] });
|
|
5274
5282
|
};
|
|
5275
5283
|
var ToastComponent = ({ toast, onRemove }) => {
|
|
5276
|
-
const [isVisible, setIsVisible] =
|
|
5277
|
-
const [progress, setProgress] =
|
|
5278
|
-
const [paused, setPaused] =
|
|
5284
|
+
const [isVisible, setIsVisible] = useState10(true);
|
|
5285
|
+
const [progress, setProgress] = useState10(100);
|
|
5286
|
+
const [paused, setPaused] = useState10(false);
|
|
5279
5287
|
const total = toast.duration && toast.duration > 0 ? toast.duration : 5e3;
|
|
5280
5288
|
const endTsRef = useRef7(0);
|
|
5281
5289
|
const remainingRef = useRef7(total);
|
|
@@ -5284,7 +5292,7 @@ var ToastComponent = ({ toast, onRemove }) => {
|
|
|
5284
5292
|
setIsVisible(false);
|
|
5285
5293
|
setTimeout(() => onRemove(toast.id), 150);
|
|
5286
5294
|
}, [onRemove, toast.id]);
|
|
5287
|
-
|
|
5295
|
+
useEffect6(() => {
|
|
5288
5296
|
if (toast.duration === 0) return;
|
|
5289
5297
|
remainingRef.current = total;
|
|
5290
5298
|
endTsRef.current = Date.now() + total;
|
|
@@ -5408,7 +5416,7 @@ import * as React18 from "react";
|
|
|
5408
5416
|
import { createPortal as createPortal3 } from "react-dom";
|
|
5409
5417
|
|
|
5410
5418
|
// src/utils/animations.ts
|
|
5411
|
-
import { useEffect as
|
|
5419
|
+
import { useEffect as useEffect7 } from "react";
|
|
5412
5420
|
var shadcnAnimationStyles = `
|
|
5413
5421
|
/* ============================================
|
|
5414
5422
|
* DROPDOWN / POPOVER ANIMATIONS
|
|
@@ -5586,7 +5594,7 @@ function ensureAnimationStylesInjected() {
|
|
|
5586
5594
|
}
|
|
5587
5595
|
}
|
|
5588
5596
|
function useShadCNAnimations() {
|
|
5589
|
-
|
|
5597
|
+
useEffect7(() => {
|
|
5590
5598
|
ensureAnimationStylesInjected();
|
|
5591
5599
|
}, []);
|
|
5592
5600
|
}
|
|
@@ -6141,7 +6149,7 @@ var SidebarSheet = ({ navigation, children, ...props }) => {
|
|
|
6141
6149
|
};
|
|
6142
6150
|
|
|
6143
6151
|
// src/components/Alert.tsx
|
|
6144
|
-
import { useState as
|
|
6152
|
+
import { useState as useState13 } from "react";
|
|
6145
6153
|
import { Info as Info2, AlertTriangle as AlertTriangle3, CheckCircle as CheckCircle3, XCircle, X as X8 } from "lucide-react";
|
|
6146
6154
|
import { jsx as jsx24, jsxs as jsxs17 } from "react/jsx-runtime";
|
|
6147
6155
|
var variantConfig = {
|
|
@@ -6193,7 +6201,7 @@ var Alert = ({
|
|
|
6193
6201
|
closeAriaLabel,
|
|
6194
6202
|
overflowHidden = true
|
|
6195
6203
|
}) => {
|
|
6196
|
-
const [open, setOpen] =
|
|
6204
|
+
const [open, setOpen] = useState13(true);
|
|
6197
6205
|
const t = useSmartTranslations("Common");
|
|
6198
6206
|
if (!open) return null;
|
|
6199
6207
|
const handleClose = () => {
|
|
@@ -6239,7 +6247,7 @@ var Alert = ({
|
|
|
6239
6247
|
var Alert_default = Alert;
|
|
6240
6248
|
|
|
6241
6249
|
// src/components/GlobalLoading.tsx
|
|
6242
|
-
import React20, { useEffect as
|
|
6250
|
+
import React20, { useEffect as useEffect10, useState as useState14 } from "react";
|
|
6243
6251
|
import { Activity as Activity2 } from "lucide-react";
|
|
6244
6252
|
|
|
6245
6253
|
// src/utils/loading.ts
|
|
@@ -6286,8 +6294,8 @@ var loading = new LoadingManager();
|
|
|
6286
6294
|
// src/components/GlobalLoading.tsx
|
|
6287
6295
|
import { jsx as jsx25, jsxs as jsxs18 } from "react/jsx-runtime";
|
|
6288
6296
|
var GlobalLoading = ({ className, backdrop = true, position = "fixed", size = "lg" }) => {
|
|
6289
|
-
const [state, setState] =
|
|
6290
|
-
|
|
6297
|
+
const [state, setState] = useState14(() => loading.getState());
|
|
6298
|
+
useEffect10(() => {
|
|
6291
6299
|
const unsubscribe = loading.subscribe(setState);
|
|
6292
6300
|
return unsubscribe;
|
|
6293
6301
|
}, []);
|
|
@@ -6694,7 +6702,7 @@ var VerticalTabs = ({ sidebarWidth = "w-48", className, ...props }) => {
|
|
|
6694
6702
|
};
|
|
6695
6703
|
|
|
6696
6704
|
// src/components/DropdownMenu.tsx
|
|
6697
|
-
import React23, { useState as
|
|
6705
|
+
import React23, { useState as useState17 } from "react";
|
|
6698
6706
|
import { jsx as jsx28, jsxs as jsxs21 } from "react/jsx-runtime";
|
|
6699
6707
|
function useResettingIndex(resetToken) {
|
|
6700
6708
|
const [state, setState] = React23.useState({ resetToken, index: -1 });
|
|
@@ -6722,7 +6730,7 @@ var DropdownMenu = ({
|
|
|
6722
6730
|
onOpenChange,
|
|
6723
6731
|
items
|
|
6724
6732
|
}) => {
|
|
6725
|
-
const [internalOpen, setInternalOpen] =
|
|
6733
|
+
const [internalOpen, setInternalOpen] = useState17(false);
|
|
6726
6734
|
const open = isOpen !== void 0 ? isOpen : internalOpen;
|
|
6727
6735
|
const setOpen = onOpenChange || setInternalOpen;
|
|
6728
6736
|
const triggerRef = React23.useRef(null);
|
|
@@ -16661,7 +16669,7 @@ function OverlayControls({
|
|
|
16661
16669
|
}
|
|
16662
16670
|
|
|
16663
16671
|
// src/components/CategoryTreeSelect.tsx
|
|
16664
|
-
import { useEffect as
|
|
16672
|
+
import { useEffect as useEffect25, useId as useId9, useMemo as useMemo19, useRef as useRef19, useState as useState31 } from "react";
|
|
16665
16673
|
import { ChevronRight as ChevronRight6, ChevronDown as ChevronDown5, FolderTree, Layers, Search as Search6, SearchX as SearchX3, X as X14 } from "lucide-react";
|
|
16666
16674
|
import { jsx as jsx49, jsxs as jsxs39 } from "react/jsx-runtime";
|
|
16667
16675
|
var defaultLabels = {
|
|
@@ -16670,6 +16678,11 @@ var defaultLabels = {
|
|
|
16670
16678
|
searchPlaceholder: "Search...",
|
|
16671
16679
|
noResultsText: "No results found"
|
|
16672
16680
|
};
|
|
16681
|
+
var TREE_NODE_BASE_PADDING_REM = 0.75;
|
|
16682
|
+
var TREE_NODE_INDENT_REM = 1;
|
|
16683
|
+
var TREE_BRANCH_OFFSET_CLASS = "ml-1.5 pl-1.5";
|
|
16684
|
+
var TREE_NODE_GAP_CLASS = "gap-1.5";
|
|
16685
|
+
var TREE_EXPANDER_PLACEHOLDER_CLASS = "w-5";
|
|
16673
16686
|
function getInitialExpandedNodes(categories, defaultExpanded, viewOnly, inline) {
|
|
16674
16687
|
if (!(viewOnly || inline) || !defaultExpanded) return /* @__PURE__ */ new Set();
|
|
16675
16688
|
const parentIds = /* @__PURE__ */ new Set();
|
|
@@ -16706,10 +16719,10 @@ function CategoryTreeSelect(props) {
|
|
|
16706
16719
|
leafOnlySelect = false,
|
|
16707
16720
|
singleSelect = false
|
|
16708
16721
|
} = props;
|
|
16709
|
-
const [isOpen, setIsOpen] =
|
|
16710
|
-
const [expandedNodes, setExpandedNodes] =
|
|
16711
|
-
const [query, setQuery] =
|
|
16712
|
-
const [localRequiredError, setLocalRequiredError] =
|
|
16722
|
+
const [isOpen, setIsOpen] = useState31(false);
|
|
16723
|
+
const [expandedNodes, setExpandedNodes] = useState31(() => getInitialExpandedNodes(categories, defaultExpanded, viewOnly, inline));
|
|
16724
|
+
const [query, setQuery] = useState31("");
|
|
16725
|
+
const [localRequiredError, setLocalRequiredError] = useState31();
|
|
16713
16726
|
const searchInputRef = useRef19(null);
|
|
16714
16727
|
const dropdownViewportRef = useRef19(null);
|
|
16715
16728
|
useOverlayScrollbarTarget(dropdownViewportRef, { enabled: useOverlayScrollbar });
|
|
@@ -16783,13 +16796,13 @@ function CategoryTreeSelect(props) {
|
|
|
16783
16796
|
}
|
|
16784
16797
|
return visible;
|
|
16785
16798
|
}, [byId, categories, childrenMap, isSearchMode, normalizedQuery]);
|
|
16786
|
-
|
|
16799
|
+
useEffect25(() => {
|
|
16787
16800
|
if (!isOpen) return;
|
|
16788
16801
|
if (!isSearchEnabled) return;
|
|
16789
16802
|
const t = setTimeout(() => searchInputRef.current?.focus(), 50);
|
|
16790
16803
|
return () => clearTimeout(t);
|
|
16791
16804
|
}, [isOpen, isSearchEnabled]);
|
|
16792
|
-
|
|
16805
|
+
useEffect25(() => {
|
|
16793
16806
|
if (disabled || !required || valueArray.length > 0) {
|
|
16794
16807
|
setLocalRequiredError(void 0);
|
|
16795
16808
|
}
|
|
@@ -16858,13 +16871,14 @@ function CategoryTreeSelect(props) {
|
|
|
16858
16871
|
{
|
|
16859
16872
|
onClick: () => !viewOnly && handleSelect(category.id, category),
|
|
16860
16873
|
className: cn(
|
|
16861
|
-
"relative flex min-w-0 items-center
|
|
16874
|
+
"relative flex min-w-0 items-center px-3 py-2.5 min-h-11 transition-all duration-200 rounded-3xl",
|
|
16875
|
+
TREE_NODE_GAP_CLASS,
|
|
16862
16876
|
!viewOnly && (isSelectable ? "cursor-pointer" : "cursor-default"),
|
|
16863
16877
|
isSelectable && !isSelected && "hover:bg-accent/50",
|
|
16864
16878
|
// Selected state - đồng bộ cho tất cả
|
|
16865
16879
|
!viewOnly && isSelected && "bg-accent/40"
|
|
16866
16880
|
),
|
|
16867
|
-
style: { paddingLeft: `${level *
|
|
16881
|
+
style: { paddingLeft: `${level * TREE_NODE_INDENT_REM + TREE_NODE_BASE_PADDING_REM}rem` },
|
|
16868
16882
|
children: [
|
|
16869
16883
|
hasChildren ? /* @__PURE__ */ jsx49(
|
|
16870
16884
|
"button",
|
|
@@ -16875,7 +16889,7 @@ function CategoryTreeSelect(props) {
|
|
|
16875
16889
|
toggleExpand(category.id);
|
|
16876
16890
|
},
|
|
16877
16891
|
className: cn(
|
|
16878
|
-
"p-
|
|
16892
|
+
"p-0.5 rounded-lg transition-all duration-200",
|
|
16879
16893
|
"hover:scale-110 active:scale-95",
|
|
16880
16894
|
"focus:outline-none focus-visible:ring-2 focus-visible:ring-primary/50",
|
|
16881
16895
|
isExpanded && "text-primary",
|
|
@@ -16884,16 +16898,16 @@ function CategoryTreeSelect(props) {
|
|
|
16884
16898
|
disabled: isSearchMode,
|
|
16885
16899
|
children: /* @__PURE__ */ jsx49("div", { className: cn("transition-transform duration-200", isExpanded && "rotate-90"), children: /* @__PURE__ */ jsx49(ChevronRight6, { className: "w-4 h-4" }) })
|
|
16886
16900
|
}
|
|
16887
|
-
) : /* @__PURE__ */ jsx49("span", { className:
|
|
16901
|
+
) : /* @__PURE__ */ jsx49("span", { className: TREE_EXPANDER_PLACEHOLDER_CLASS }),
|
|
16888
16902
|
viewOnly ? (
|
|
16889
16903
|
// View-only mode: just display the name with folder icon
|
|
16890
|
-
/* @__PURE__ */ jsxs39("div", { className: "flex min-w-0 items-center
|
|
16904
|
+
/* @__PURE__ */ jsxs39("div", { className: cn("flex min-w-0 items-center", TREE_NODE_GAP_CLASS), children: [
|
|
16891
16905
|
category.icon ? /* @__PURE__ */ jsx49("div", { className: "h-4 w-4 shrink-0 flex items-center justify-center text-muted-foreground/60", children: category.icon }) : hasChildren ? /* @__PURE__ */ jsx49(FolderTree, { className: "h-4 w-4 shrink-0 text-muted-foreground/60" }) : /* @__PURE__ */ jsx49("div", { className: "h-1.5 w-1.5 shrink-0 rounded-full bg-muted-foreground/40" }),
|
|
16892
16906
|
/* @__PURE__ */ jsx49("span", { className: "min-w-0 text-sm font-medium leading-snug break-words [overflow-wrap:anywhere]", children: category.name })
|
|
16893
16907
|
] })
|
|
16894
16908
|
) : (
|
|
16895
16909
|
// Single/Multi select mode: icon + text + badge
|
|
16896
|
-
/* @__PURE__ */ jsxs39("div", { className: "flex min-w-0 flex-1 items-center
|
|
16910
|
+
/* @__PURE__ */ jsxs39("div", { className: cn("flex min-w-0 flex-1 items-center overflow-hidden", TREE_NODE_GAP_CLASS), children: [
|
|
16897
16911
|
category.icon && /* @__PURE__ */ jsx49("div", { className: "h-4 w-4 shrink-0 flex items-center justify-center text-current", children: category.icon }),
|
|
16898
16912
|
/* @__PURE__ */ jsx49(
|
|
16899
16913
|
"span",
|
|
@@ -16912,7 +16926,17 @@ function CategoryTreeSelect(props) {
|
|
|
16912
16926
|
]
|
|
16913
16927
|
}
|
|
16914
16928
|
),
|
|
16915
|
-
hasChildren && isExpanded && /* @__PURE__ */ jsx49(
|
|
16929
|
+
hasChildren && isExpanded && /* @__PURE__ */ jsx49(
|
|
16930
|
+
"div",
|
|
16931
|
+
{
|
|
16932
|
+
className: cn(
|
|
16933
|
+
TREE_BRANCH_OFFSET_CLASS,
|
|
16934
|
+
"border-l-2 border-dashed border-border/50",
|
|
16935
|
+
"animate-in slide-in-from-top-2 fade-in-50 duration-200"
|
|
16936
|
+
),
|
|
16937
|
+
children: children.map((child) => renderCategory(child, level + 1))
|
|
16938
|
+
}
|
|
16939
|
+
)
|
|
16916
16940
|
]
|
|
16917
16941
|
},
|
|
16918
16942
|
category.id
|
|
@@ -17261,7 +17285,7 @@ function CategoryTreeSelect(props) {
|
|
|
17261
17285
|
}
|
|
17262
17286
|
|
|
17263
17287
|
// src/components/ImageUpload.tsx
|
|
17264
|
-
import { useState as
|
|
17288
|
+
import { useState as useState32, useRef as useRef20, useCallback as useCallback15 } from "react";
|
|
17265
17289
|
import { Upload, X as X15, Image as ImageIcon, Loader2 as Loader25, Check as Check7 } from "lucide-react";
|
|
17266
17290
|
import { jsx as jsx50, jsxs as jsxs40 } from "react/jsx-runtime";
|
|
17267
17291
|
function ImageUpload({
|
|
@@ -17279,9 +17303,9 @@ function ImageUpload({
|
|
|
17279
17303
|
browseText,
|
|
17280
17304
|
supportedFormatsText
|
|
17281
17305
|
}) {
|
|
17282
|
-
const [isDragging, setIsDragging] =
|
|
17283
|
-
const [uploading, setUploading] =
|
|
17284
|
-
const [uploadedImages, setUploadedImages] =
|
|
17306
|
+
const [isDragging, setIsDragging] = useState32(false);
|
|
17307
|
+
const [uploading, setUploading] = useState32(false);
|
|
17308
|
+
const [uploadedImages, setUploadedImages] = useState32([]);
|
|
17285
17309
|
const fileInputRef = useRef20(null);
|
|
17286
17310
|
const { addToast } = useToast();
|
|
17287
17311
|
const t = useSmartTranslations("OCR.imageUpload");
|
|
@@ -17500,7 +17524,7 @@ import {
|
|
|
17500
17524
|
Trash2,
|
|
17501
17525
|
Upload as Upload2
|
|
17502
17526
|
} from "lucide-react";
|
|
17503
|
-
import { useCallback as useCallback16, useMemo as useMemo20, useRef as useRef21, useState as
|
|
17527
|
+
import { useCallback as useCallback16, useMemo as useMemo20, useRef as useRef21, useState as useState33 } from "react";
|
|
17504
17528
|
import { Fragment as Fragment16, jsx as jsx51, jsxs as jsxs41 } from "react/jsx-runtime";
|
|
17505
17529
|
var formatFileSize = (bytes) => {
|
|
17506
17530
|
if (bytes === 0) return "0 Bytes";
|
|
@@ -17607,8 +17631,8 @@ function FileUpload({
|
|
|
17607
17631
|
allowPreview = true,
|
|
17608
17632
|
initialFiles = []
|
|
17609
17633
|
}) {
|
|
17610
|
-
const [isDragging, setIsDragging] =
|
|
17611
|
-
const [files, setFiles] =
|
|
17634
|
+
const [isDragging, setIsDragging] = useState33(false);
|
|
17635
|
+
const [files, setFiles] = useState33(initialFiles);
|
|
17612
17636
|
const fileInputRef = useRef21(null);
|
|
17613
17637
|
const { addToast } = useToast();
|
|
17614
17638
|
const t = useSmartTranslations("FileUpload");
|
|
@@ -20100,7 +20124,7 @@ function ColorPicker({
|
|
|
20100
20124
|
}
|
|
20101
20125
|
|
|
20102
20126
|
// src/components/MusicPlayer.tsx
|
|
20103
|
-
import { useState as
|
|
20127
|
+
import { useState as useState39, useRef as useRef23, useEffect as useEffect29 } from "react";
|
|
20104
20128
|
import { Play as Play2, Pause as Pause2, SkipForward, SkipBack, Volume2 as Volume22, VolumeX as VolumeX2, List as List2, X as X17 } from "lucide-react";
|
|
20105
20129
|
import { jsx as jsx58, jsxs as jsxs48 } from "react/jsx-runtime";
|
|
20106
20130
|
var DEFAULT_PLAYLIST = [
|
|
@@ -20222,21 +20246,21 @@ var MusicPlayer = ({
|
|
|
20222
20246
|
className = "",
|
|
20223
20247
|
overflowHidden = true
|
|
20224
20248
|
}) => {
|
|
20225
|
-
const [currentSongIndex, setCurrentSongIndex] =
|
|
20226
|
-
const [isPlaying, setIsPlaying] =
|
|
20227
|
-
const [currentTime, setCurrentTime] =
|
|
20228
|
-
const [duration, setDuration] =
|
|
20229
|
-
const [volume, setVolume] =
|
|
20230
|
-
const [isMuted, setIsMuted] =
|
|
20231
|
-
const [showPlaylist, setShowPlaylist] =
|
|
20249
|
+
const [currentSongIndex, setCurrentSongIndex] = useState39(0);
|
|
20250
|
+
const [isPlaying, setIsPlaying] = useState39(false);
|
|
20251
|
+
const [currentTime, setCurrentTime] = useState39(0);
|
|
20252
|
+
const [duration, setDuration] = useState39(0);
|
|
20253
|
+
const [volume, setVolume] = useState39(1);
|
|
20254
|
+
const [isMuted, setIsMuted] = useState39(false);
|
|
20255
|
+
const [showPlaylist, setShowPlaylist] = useState39(initialShowPlaylist);
|
|
20232
20256
|
const audioRef = useRef23(null);
|
|
20233
20257
|
const currentSong = playlist[currentSongIndex];
|
|
20234
|
-
|
|
20258
|
+
useEffect29(() => {
|
|
20235
20259
|
if (audioRef.current) {
|
|
20236
20260
|
audioRef.current.volume = volume;
|
|
20237
20261
|
}
|
|
20238
20262
|
}, [volume]);
|
|
20239
|
-
|
|
20263
|
+
useEffect29(() => {
|
|
20240
20264
|
if (autoPlay && audioRef.current) {
|
|
20241
20265
|
audioRef.current.play().catch(() => {
|
|
20242
20266
|
setIsPlaying(false);
|
|
@@ -20312,7 +20336,7 @@ var MusicPlayer = ({
|
|
|
20312
20336
|
setCurrentSongIndex(index);
|
|
20313
20337
|
setIsPlaying(true);
|
|
20314
20338
|
};
|
|
20315
|
-
|
|
20339
|
+
useEffect29(() => {
|
|
20316
20340
|
if (audioRef.current) {
|
|
20317
20341
|
if (currentSong.startTime !== void 0) {
|
|
20318
20342
|
audioRef.current.currentTime = currentSong.startTime;
|
|
@@ -20900,7 +20924,8 @@ function DataTableBodyRows({
|
|
|
20900
20924
|
getRowKey,
|
|
20901
20925
|
getStickyColumnStyle,
|
|
20902
20926
|
getStickyCellClass,
|
|
20903
|
-
t
|
|
20927
|
+
t,
|
|
20928
|
+
labels
|
|
20904
20929
|
}) {
|
|
20905
20930
|
return /* @__PURE__ */ jsx63(TableBody, { children: loading2 ? /* @__PURE__ */ jsx63(TableRow, { children: /* @__PURE__ */ jsx63(TableCell, { colSpan: leafColumns.length, className: "text-center py-8", children: /* @__PURE__ */ jsxs52("div", { className: "flex items-center justify-center gap-2 text-muted-foreground", children: [
|
|
20906
20931
|
/* @__PURE__ */ jsxs52("svg", { className: "animate-spin h-4 w-4", xmlns: "http://www.w3.org/2000/svg", fill: "none", viewBox: "0 0 24 24", children: [
|
|
@@ -20918,7 +20943,7 @@ function DataTableBodyRows({
|
|
|
20918
20943
|
t("loading"),
|
|
20919
20944
|
"\u2026"
|
|
20920
20945
|
] })
|
|
20921
|
-
] }) }) }) : displayedData.length === 0 ? /* @__PURE__ */ jsx63(TableRow, { children: /* @__PURE__ */ jsx63(TableCell, { colSpan: leafColumns.length, className: "text-center py-6 text-muted-foreground", children: t("noData") }) }) : displayedData.map((row, idx) => {
|
|
20946
|
+
] }) }) }) : displayedData.length === 0 ? /* @__PURE__ */ jsx63(TableRow, { children: /* @__PURE__ */ jsx63(TableCell, { colSpan: leafColumns.length, className: "text-center py-6 text-muted-foreground", children: labels?.noData || t("noData") }) }) : displayedData.map((row, idx) => {
|
|
20922
20947
|
const isStripedRow = striped && idx % 2 === 0;
|
|
20923
20948
|
return /* @__PURE__ */ jsx63(
|
|
20924
20949
|
TableRow,
|
|
@@ -22185,7 +22210,8 @@ function DataTable({
|
|
|
22185
22210
|
getRowKey,
|
|
22186
22211
|
getStickyColumnStyle,
|
|
22187
22212
|
getStickyCellClass,
|
|
22188
|
-
t
|
|
22213
|
+
t,
|
|
22214
|
+
labels
|
|
22189
22215
|
}
|
|
22190
22216
|
)
|
|
22191
22217
|
]
|
|
@@ -22434,7 +22460,7 @@ function AccessDenied({
|
|
|
22434
22460
|
|
|
22435
22461
|
// src/components/ThemeToggleHeadless.tsx
|
|
22436
22462
|
import { Moon as Moon2, Sun as Sun2, Monitor } from "lucide-react";
|
|
22437
|
-
import { useRef as useRef24, useState as
|
|
22463
|
+
import { useRef as useRef24, useState as useState40 } from "react";
|
|
22438
22464
|
import { createPortal as createPortal6 } from "react-dom";
|
|
22439
22465
|
import { Fragment as Fragment23, jsx as jsx71, jsxs as jsxs60 } from "react/jsx-runtime";
|
|
22440
22466
|
function ThemeToggleHeadless({
|
|
@@ -22443,10 +22469,10 @@ function ThemeToggleHeadless({
|
|
|
22443
22469
|
labels,
|
|
22444
22470
|
className
|
|
22445
22471
|
}) {
|
|
22446
|
-
const [isOpen, setIsOpen] =
|
|
22472
|
+
const [isOpen, setIsOpen] = useState40(false);
|
|
22447
22473
|
const isHydrated = useHydrated();
|
|
22448
22474
|
const triggerRef = useRef24(null);
|
|
22449
|
-
const [dropdownPosition, setDropdownPosition] =
|
|
22475
|
+
const [dropdownPosition, setDropdownPosition] = useState40(null);
|
|
22450
22476
|
const themes = [
|
|
22451
22477
|
{ value: "light", label: labels?.light ?? "Light", icon: Sun2 },
|
|
22452
22478
|
{ value: "dark", label: labels?.dark ?? "Dark", icon: Moon2 },
|
|
@@ -22535,7 +22561,7 @@ function ThemeToggleHeadless({
|
|
|
22535
22561
|
}
|
|
22536
22562
|
|
|
22537
22563
|
// src/components/LanguageSwitcherHeadless.tsx
|
|
22538
|
-
import { useRef as useRef25, useState as
|
|
22564
|
+
import { useRef as useRef25, useState as useState41 } from "react";
|
|
22539
22565
|
import { createPortal as createPortal7 } from "react-dom";
|
|
22540
22566
|
import { Globe } from "lucide-react";
|
|
22541
22567
|
import { Fragment as Fragment24, jsx as jsx72, jsxs as jsxs61 } from "react/jsx-runtime";
|
|
@@ -22546,8 +22572,8 @@ function LanguageSwitcherHeadless({
|
|
|
22546
22572
|
labels,
|
|
22547
22573
|
className
|
|
22548
22574
|
}) {
|
|
22549
|
-
const [isOpen, setIsOpen] =
|
|
22550
|
-
const [dropdownPosition, setDropdownPosition] =
|
|
22575
|
+
const [isOpen, setIsOpen] = useState41(false);
|
|
22576
|
+
const [dropdownPosition, setDropdownPosition] = useState41(null);
|
|
22551
22577
|
const triggerButtonRef = useRef25(null);
|
|
22552
22578
|
const currentLanguage = locales.find((l) => l.code === currentLocale) || locales[0];
|
|
22553
22579
|
const calculatePosition = () => {
|
|
@@ -22692,7 +22718,7 @@ function useLocale2() {
|
|
|
22692
22718
|
}
|
|
22693
22719
|
|
|
22694
22720
|
// src/components/UEditor/UEditor.tsx
|
|
22695
|
-
import React74, { useEffect as
|
|
22721
|
+
import React74, { useEffect as useEffect35, useImperativeHandle as useImperativeHandle3, useMemo as useMemo24, useRef as useRef31 } from "react";
|
|
22696
22722
|
import { useEditor, EditorContent } from "@tiptap/react";
|
|
22697
22723
|
|
|
22698
22724
|
// src/components/UEditor/extensions.ts
|
|
@@ -22731,7 +22757,7 @@ import { common, createLowlight } from "lowlight";
|
|
|
22731
22757
|
import { Extension } from "@tiptap/core";
|
|
22732
22758
|
import Suggestion from "@tiptap/suggestion";
|
|
22733
22759
|
import { ReactRenderer } from "@tiptap/react";
|
|
22734
|
-
import React66, { forwardRef as forwardRef13, useEffect as
|
|
22760
|
+
import React66, { forwardRef as forwardRef13, useEffect as useEffect31, useImperativeHandle, useRef as useRef26 } from "react";
|
|
22735
22761
|
import {
|
|
22736
22762
|
FileCode as FileCode2,
|
|
22737
22763
|
Heading1,
|
|
@@ -22938,7 +22964,7 @@ function buildSlashCommandItems({
|
|
|
22938
22964
|
var SlashCommandList = forwardRef13((props, ref) => {
|
|
22939
22965
|
const [selectedIndex, setSelectedIndex] = useResettingIndex2(props.items);
|
|
22940
22966
|
const listRef = useRef26(null);
|
|
22941
|
-
|
|
22967
|
+
useEffect31(() => {
|
|
22942
22968
|
const selectedElement = listRef.current?.querySelector(`[data-index="${selectedIndex}"]`);
|
|
22943
22969
|
selectedElement?.scrollIntoView({ block: "nearest" });
|
|
22944
22970
|
}, [selectedIndex, props.items]);
|
|
@@ -23396,7 +23422,7 @@ var UEditorPlaceholder = Extension4.create({
|
|
|
23396
23422
|
});
|
|
23397
23423
|
|
|
23398
23424
|
// src/components/UEditor/resizable-image.tsx
|
|
23399
|
-
import { useEffect as
|
|
23425
|
+
import { useEffect as useEffect32, useRef as useRef27, useState as useState42 } from "react";
|
|
23400
23426
|
import Image3 from "@tiptap/extension-image";
|
|
23401
23427
|
import { mergeAttributes } from "@tiptap/core";
|
|
23402
23428
|
import { NodeViewWrapper, ReactNodeViewRenderer } from "@tiptap/react";
|
|
@@ -23447,15 +23473,15 @@ function ResizableImageNodeView(props) {
|
|
|
23447
23473
|
const { node, selected, updateAttributes, editor, getPos } = props;
|
|
23448
23474
|
const wrapperRef = useRef27(null);
|
|
23449
23475
|
const imgRef = useRef27(null);
|
|
23450
|
-
const [isHovered, setIsHovered] =
|
|
23451
|
-
const [isResizing, setIsResizing] =
|
|
23476
|
+
const [isHovered, setIsHovered] = useState42(false);
|
|
23477
|
+
const [isResizing, setIsResizing] = useState42(false);
|
|
23452
23478
|
const widthAttr = toNullableNumber(node.attrs["width"]);
|
|
23453
23479
|
const heightAttr = toNullableNumber(node.attrs["height"]);
|
|
23454
23480
|
const textAlign = String(node.attrs["textAlign"] ?? "");
|
|
23455
23481
|
const imageLayout = parseImageLayout(node.attrs["imageLayout"]);
|
|
23456
23482
|
const preserveAspectByDefault = imageLayout === "left" || imageLayout === "right";
|
|
23457
23483
|
const dragStateRef = useRef27(null);
|
|
23458
|
-
|
|
23484
|
+
useEffect32(() => {
|
|
23459
23485
|
const img = imgRef.current;
|
|
23460
23486
|
if (!img) return;
|
|
23461
23487
|
img.style.width = widthAttr ? `${widthAttr}px` : "";
|
|
@@ -24100,7 +24126,7 @@ function buildUEditorExtensions({
|
|
|
24100
24126
|
}
|
|
24101
24127
|
|
|
24102
24128
|
// src/components/UEditor/toolbar.tsx
|
|
24103
|
-
import React71, { useRef as useRef29, useState as
|
|
24129
|
+
import React71, { useRef as useRef29, useState as useState44 } from "react";
|
|
24104
24130
|
import {
|
|
24105
24131
|
AlignCenter,
|
|
24106
24132
|
AlignJustify,
|
|
@@ -24292,7 +24318,7 @@ function deleteSelectedImage(editor) {
|
|
|
24292
24318
|
}
|
|
24293
24319
|
|
|
24294
24320
|
// src/components/UEditor/inputs.tsx
|
|
24295
|
-
import { useEffect as
|
|
24321
|
+
import { useEffect as useEffect33, useRef as useRef28, useState as useState43 } from "react";
|
|
24296
24322
|
import { Check as Check10, X as X19 } from "lucide-react";
|
|
24297
24323
|
import { jsx as jsx78, jsxs as jsxs66 } from "react/jsx-runtime";
|
|
24298
24324
|
function normalizeUrl(raw) {
|
|
@@ -24308,9 +24334,9 @@ var LinkInput = ({
|
|
|
24308
24334
|
initialUrl = ""
|
|
24309
24335
|
}) => {
|
|
24310
24336
|
const t = useSmartTranslations("UEditor");
|
|
24311
|
-
const [url, setUrl] =
|
|
24337
|
+
const [url, setUrl] = useState43(initialUrl);
|
|
24312
24338
|
const inputRef = useRef28(null);
|
|
24313
|
-
|
|
24339
|
+
useEffect33(() => {
|
|
24314
24340
|
inputRef.current?.focus();
|
|
24315
24341
|
inputRef.current?.select();
|
|
24316
24342
|
}, []);
|
|
@@ -24337,10 +24363,10 @@ var LinkInput = ({
|
|
|
24337
24363
|
};
|
|
24338
24364
|
var ImageInput = ({ onSubmit, onCancel }) => {
|
|
24339
24365
|
const t = useSmartTranslations("UEditor");
|
|
24340
|
-
const [url, setUrl] =
|
|
24341
|
-
const [alt, setAlt] =
|
|
24366
|
+
const [url, setUrl] = useState43("");
|
|
24367
|
+
const [alt, setAlt] = useState43("");
|
|
24342
24368
|
const inputRef = useRef28(null);
|
|
24343
|
-
|
|
24369
|
+
useEffect33(() => {
|
|
24344
24370
|
inputRef.current?.focus();
|
|
24345
24371
|
}, []);
|
|
24346
24372
|
const handleSubmit = (e) => {
|
|
@@ -24539,13 +24565,13 @@ var EditorToolbar = ({
|
|
|
24539
24565
|
}) => {
|
|
24540
24566
|
const t = useSmartTranslations("UEditor");
|
|
24541
24567
|
const { textColors, highlightColors } = useEditorColors();
|
|
24542
|
-
const [showImageInput, setShowImageInput] =
|
|
24543
|
-
const [isTableMenuOpen, setIsTableMenuOpen] =
|
|
24568
|
+
const [showImageInput, setShowImageInput] = useState44(false);
|
|
24569
|
+
const [isTableMenuOpen, setIsTableMenuOpen] = useState44(false);
|
|
24544
24570
|
const tableCommandAnchorPosRef = useRef29(null);
|
|
24545
24571
|
const fileInputRef = useRef29(null);
|
|
24546
|
-
const [isUploadingImage, setIsUploadingImage] =
|
|
24547
|
-
const [imageUploadError, setImageUploadError] =
|
|
24548
|
-
const [fontSizeDraft, setFontSizeDraft] =
|
|
24572
|
+
const [isUploadingImage, setIsUploadingImage] = useState44(false);
|
|
24573
|
+
const [imageUploadError, setImageUploadError] = useState44(null);
|
|
24574
|
+
const [fontSizeDraft, setFontSizeDraft] = useState44("");
|
|
24549
24575
|
const isImageSelected = editor.isActive("image");
|
|
24550
24576
|
const imageAttrs = editor.getAttributes("image");
|
|
24551
24577
|
const tableAttrs = editor.getAttributes("table");
|
|
@@ -25357,7 +25383,7 @@ var EditorToolbar = ({
|
|
|
25357
25383
|
};
|
|
25358
25384
|
|
|
25359
25385
|
// src/components/UEditor/menus.tsx
|
|
25360
|
-
import { useCallback as useCallback19, useEffect as
|
|
25386
|
+
import { useCallback as useCallback19, useEffect as useEffect34, useMemo as useMemo23, useRef as useRef30, useState as useState45 } from "react";
|
|
25361
25387
|
import { createPortal as createPortal8 } from "react-dom";
|
|
25362
25388
|
import {
|
|
25363
25389
|
AlignCenter as AlignCenter2,
|
|
@@ -25382,7 +25408,7 @@ var FloatingSlashCommandMenu = ({ editor, onClose }) => {
|
|
|
25382
25408
|
const messages = useMemo23(() => buildSlashCommandMessages(t), [t]);
|
|
25383
25409
|
const items = useMemo23(() => buildSlashCommandItems({ query: "", messages }), [messages]);
|
|
25384
25410
|
const listRef = useRef30(null);
|
|
25385
|
-
|
|
25411
|
+
useEffect34(() => {
|
|
25386
25412
|
const handleKeyDown2 = (event) => {
|
|
25387
25413
|
if (event.key === "Escape") {
|
|
25388
25414
|
event.preventDefault();
|
|
@@ -25412,7 +25438,7 @@ var FloatingSlashCommandMenu = ({ editor, onClose }) => {
|
|
|
25412
25438
|
};
|
|
25413
25439
|
var FloatingMenuContent = ({ editor }) => {
|
|
25414
25440
|
const t = useSmartTranslations("UEditor");
|
|
25415
|
-
const [showCommands, setShowCommands] =
|
|
25441
|
+
const [showCommands, setShowCommands] = useState45(false);
|
|
25416
25442
|
if (showCommands) {
|
|
25417
25443
|
return /* @__PURE__ */ jsx81(FloatingSlashCommandMenu, { editor, onClose: () => setShowCommands(false) });
|
|
25418
25444
|
}
|
|
@@ -25437,8 +25463,8 @@ var BubbleMenuContent = ({
|
|
|
25437
25463
|
}) => {
|
|
25438
25464
|
const t = useSmartTranslations("UEditor");
|
|
25439
25465
|
const { textColors, highlightColors } = useEditorColors();
|
|
25440
|
-
const [showLinkInput, setShowLinkInput] =
|
|
25441
|
-
const [showEditorColorPalette, setShowEditorColorPalette] =
|
|
25466
|
+
const [showLinkInput, setShowLinkInput] = useState45(false);
|
|
25467
|
+
const [showEditorColorPalette, setShowEditorColorPalette] = useState45(false);
|
|
25442
25468
|
const isImageSelected = editor.isActive("image");
|
|
25443
25469
|
const imageAttrs = editor.getAttributes("image");
|
|
25444
25470
|
const imageLayout = imageAttrs.imageLayout === "left" || imageAttrs.imageLayout === "right" ? imageAttrs.imageLayout : "block";
|
|
@@ -25454,10 +25480,10 @@ var BubbleMenuContent = ({
|
|
|
25454
25480
|
() => (lineHeights ?? getDefaultLineHeights()).filter((option) => ["1.2", "1.5", "1.75"].includes(option.value)),
|
|
25455
25481
|
[lineHeights]
|
|
25456
25482
|
);
|
|
25457
|
-
|
|
25483
|
+
useEffect34(() => {
|
|
25458
25484
|
onKeepOpenChange?.(showLinkInput);
|
|
25459
25485
|
}, [onKeepOpenChange, showLinkInput]);
|
|
25460
|
-
|
|
25486
|
+
useEffect34(() => {
|
|
25461
25487
|
if (!showLinkInput) return;
|
|
25462
25488
|
const close2 = () => setShowLinkInput(false);
|
|
25463
25489
|
editor.on("selectionUpdate", close2);
|
|
@@ -25644,8 +25670,8 @@ var CustomBubbleMenu = ({
|
|
|
25644
25670
|
}) => {
|
|
25645
25671
|
const SHOW_DELAY_MS = 180;
|
|
25646
25672
|
const BUBBLE_MENU_OFFSET = 16;
|
|
25647
|
-
const [isVisible, setIsVisible] =
|
|
25648
|
-
const [position, setPosition] =
|
|
25673
|
+
const [isVisible, setIsVisible] = useState45(false);
|
|
25674
|
+
const [position, setPosition] = useState45({ top: 0, left: 0 });
|
|
25649
25675
|
const menuRef = useRef30(null);
|
|
25650
25676
|
const keepOpenRef = useRef30(false);
|
|
25651
25677
|
const showTimeoutRef = useRef30(null);
|
|
@@ -25653,7 +25679,7 @@ var CustomBubbleMenu = ({
|
|
|
25653
25679
|
keepOpenRef.current = next;
|
|
25654
25680
|
if (next) setIsVisible(true);
|
|
25655
25681
|
}, []);
|
|
25656
|
-
|
|
25682
|
+
useEffect34(() => {
|
|
25657
25683
|
const clearShowTimeout = () => {
|
|
25658
25684
|
if (showTimeoutRef.current) {
|
|
25659
25685
|
clearTimeout(showTimeoutRef.current);
|
|
@@ -25729,9 +25755,9 @@ var CustomBubbleMenu = ({
|
|
|
25729
25755
|
};
|
|
25730
25756
|
var CustomFloatingMenu = ({ editor }) => {
|
|
25731
25757
|
const FLOATING_MENU_OFFSET = 16;
|
|
25732
|
-
const [isVisible, setIsVisible] =
|
|
25733
|
-
const [position, setPosition] =
|
|
25734
|
-
|
|
25758
|
+
const [isVisible, setIsVisible] = useState45(false);
|
|
25759
|
+
const [position, setPosition] = useState45({ top: 0, left: 0 });
|
|
25760
|
+
useEffect34(() => {
|
|
25735
25761
|
const updatePosition = () => {
|
|
25736
25762
|
const { state, view } = editor;
|
|
25737
25763
|
const { $from, empty } = state.selection;
|
|
@@ -31669,14 +31695,14 @@ var UEditor = React74.forwardRef(({
|
|
|
31669
31695
|
}),
|
|
31670
31696
|
[content, editor, uploadImageForSave]
|
|
31671
31697
|
);
|
|
31672
|
-
|
|
31698
|
+
useEffect35(() => {
|
|
31673
31699
|
if (editor && content !== editor.getHTML()) {
|
|
31674
31700
|
if (editor.isEmpty && content) {
|
|
31675
31701
|
editor.commands.setContent(content);
|
|
31676
31702
|
}
|
|
31677
31703
|
}
|
|
31678
31704
|
}, [content, editor]);
|
|
31679
|
-
|
|
31705
|
+
useEffect35(() => {
|
|
31680
31706
|
if (!editor) return void 0;
|
|
31681
31707
|
const proseMirror = editor.view.dom;
|
|
31682
31708
|
const surface = editorContentRef.current;
|