ssovee-os-web-ui 0.1.101 → 0.1.102
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 +116 -97
- package/dist/index.cjs.map +1 -1
- package/dist/index.css +4 -8
- package/dist/index.js +45 -26
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var React24 = require('react');
|
|
4
4
|
var jsxRuntime = require('react/jsx-runtime');
|
|
5
5
|
var react = require('@phosphor-icons/react');
|
|
6
6
|
var Editor = require('@monaco-editor/react');
|
|
@@ -28,7 +28,7 @@ function _interopNamespace(e) {
|
|
|
28
28
|
return Object.freeze(n);
|
|
29
29
|
}
|
|
30
30
|
|
|
31
|
-
var
|
|
31
|
+
var React24__namespace = /*#__PURE__*/_interopNamespace(React24);
|
|
32
32
|
var Editor__default = /*#__PURE__*/_interopDefault(Editor);
|
|
33
33
|
var StarterKit__default = /*#__PURE__*/_interopDefault(StarterKit);
|
|
34
34
|
|
|
@@ -38,7 +38,7 @@ var StarterKit__default = /*#__PURE__*/_interopDefault(StarterKit);
|
|
|
38
38
|
function cn(...inputs) {
|
|
39
39
|
return inputs.filter(Boolean).join(" ");
|
|
40
40
|
}
|
|
41
|
-
var Button =
|
|
41
|
+
var Button = React24__namespace.default.forwardRef(
|
|
42
42
|
({
|
|
43
43
|
className,
|
|
44
44
|
variant = "primary",
|
|
@@ -174,7 +174,7 @@ var Typography = ({
|
|
|
174
174
|
return /* @__PURE__ */ jsxRuntime.jsx(Component, { className: classes, children });
|
|
175
175
|
};
|
|
176
176
|
var Typography_default = Typography;
|
|
177
|
-
var Input =
|
|
177
|
+
var Input = React24__namespace.default.forwardRef(
|
|
178
178
|
({
|
|
179
179
|
className,
|
|
180
180
|
variant = "default",
|
|
@@ -252,7 +252,7 @@ var Input = React23__namespace.default.forwardRef(
|
|
|
252
252
|
);
|
|
253
253
|
Input.displayName = "Input";
|
|
254
254
|
var Input_default = Input;
|
|
255
|
-
var TextArea =
|
|
255
|
+
var TextArea = React24__namespace.default.forwardRef(
|
|
256
256
|
({
|
|
257
257
|
className,
|
|
258
258
|
variant = "default",
|
|
@@ -318,7 +318,7 @@ var CodeEditor = ({
|
|
|
318
318
|
className,
|
|
319
319
|
isDarkTheme
|
|
320
320
|
}) => {
|
|
321
|
-
const editorTheme =
|
|
321
|
+
const editorTheme = React24.useMemo(() => {
|
|
322
322
|
if (typeof isDarkTheme === "undefined") return "light";
|
|
323
323
|
const isDark = Boolean(isDarkTheme);
|
|
324
324
|
return isDark ? "vs-dark" : "light";
|
|
@@ -337,7 +337,7 @@ var CodeEditor = ({
|
|
|
337
337
|
};
|
|
338
338
|
var CodeEditor_default = CodeEditor;
|
|
339
339
|
var RichEditor = ({ content, onChange, isDarkTheme }) => {
|
|
340
|
-
const onChangeRef =
|
|
340
|
+
const onChangeRef = React24.useRef(onChange);
|
|
341
341
|
onChangeRef.current = onChange;
|
|
342
342
|
const editorTheme = isDarkTheme ? "vs-dark" : "light";
|
|
343
343
|
const editor = react$1.useEditor({
|
|
@@ -348,7 +348,7 @@ var RichEditor = ({ content, onChange, isDarkTheme }) => {
|
|
|
348
348
|
onChangeRef.current(updatedEditor.getHTML());
|
|
349
349
|
}
|
|
350
350
|
}, []);
|
|
351
|
-
|
|
351
|
+
React24.useEffect(() => {
|
|
352
352
|
if (editor && content !== editor.getHTML()) {
|
|
353
353
|
editor.commands.setContent(content, { emitUpdate: false });
|
|
354
354
|
}
|
|
@@ -385,13 +385,13 @@ var RichEditor = ({ content, onChange, isDarkTheme }) => {
|
|
|
385
385
|
react$1.EditorContent,
|
|
386
386
|
{
|
|
387
387
|
editor,
|
|
388
|
-
className: `mt-4 min-h-52 rounded-md border border-
|
|
388
|
+
className: `mt-4 min-h-52 rounded-md border border-surface-1 p-3 text-sm leading-6 text-neutral-500 outline-none transition-colors focus-within:border-surface-1 [&_.ProseMirror]:min-h-44 [&_.ProseMirror]:outline-none [&_.ProseMirror_p]:my-2 [&_.ProseMirror_h1]:my-3 [&_.ProseMirror_h1]:text-2xl [&_.ProseMirror_h1]:font-bold [&_.ProseMirror_h2]:my-3 [&_.ProseMirror_h2]:text-xl [&_.ProseMirror_h2]:font-bold [&_.ProseMirror_h3]:my-3 [&_.ProseMirror_h3]:text-lg [&_.ProseMirror_h3]:font-bold [&_.ProseMirror_ul]:my-2 [&_.ProseMirror_ul]:list-disc [&_.ProseMirror_ul]:pl-6 [&_.ProseMirror_ol]:my-2 [&_.ProseMirror_ol]:list-decimal [&_.ProseMirror_ol]:pl-6 [&_.ProseMirror_blockquote]:my-3 [&_.ProseMirror_blockquote]:border-l-4 [&_.ProseMirror_blockquote]:border-surface-1 [&_.ProseMirror_blockquote]:pl-4 [&_.ProseMirror_pre]:my-3 [&_.ProseMirror_pre]:overflow-x-auto [&_.ProseMirror_pre]:rounded [&_.ProseMirror_pre]:bg-surface-3 [&_.ProseMirror_pre]:p-3 ${editorTheme === "vs-dark" ? "bg-primary" : "bg-secondary"}`
|
|
389
389
|
}
|
|
390
390
|
)
|
|
391
391
|
] });
|
|
392
392
|
};
|
|
393
393
|
var RichEditor_default = RichEditor;
|
|
394
|
-
var Select =
|
|
394
|
+
var Select = React24__namespace.default.forwardRef(
|
|
395
395
|
({
|
|
396
396
|
className,
|
|
397
397
|
options,
|
|
@@ -471,7 +471,7 @@ var Select = React23__namespace.default.forwardRef(
|
|
|
471
471
|
);
|
|
472
472
|
Select.displayName = "Select";
|
|
473
473
|
var Select_default = Select;
|
|
474
|
-
var Checkbox =
|
|
474
|
+
var Checkbox = React24__namespace.default.forwardRef(
|
|
475
475
|
({
|
|
476
476
|
className,
|
|
477
477
|
variant = "default",
|
|
@@ -546,7 +546,7 @@ var Checkbox = React23__namespace.default.forwardRef(
|
|
|
546
546
|
);
|
|
547
547
|
Checkbox.displayName = "Checkbox";
|
|
548
548
|
var Checkbox_default = Checkbox;
|
|
549
|
-
var Toggle =
|
|
549
|
+
var Toggle = React24__namespace.default.forwardRef(
|
|
550
550
|
({
|
|
551
551
|
checked,
|
|
552
552
|
onChange,
|
|
@@ -652,10 +652,10 @@ var Dropdown = ({
|
|
|
652
652
|
className,
|
|
653
653
|
trigger
|
|
654
654
|
}) => {
|
|
655
|
-
const [isOpen, setIsOpen] =
|
|
656
|
-
const dropdownRef =
|
|
655
|
+
const [isOpen, setIsOpen] = React24.useState(false);
|
|
656
|
+
const dropdownRef = React24.useRef(null);
|
|
657
657
|
const selectedOption = options.find((option) => option.value === value);
|
|
658
|
-
|
|
658
|
+
React24.useEffect(() => {
|
|
659
659
|
const handleClickOutside = (event) => {
|
|
660
660
|
if (dropdownRef.current && !dropdownRef.current.contains(event.target)) {
|
|
661
661
|
setIsOpen(false);
|
|
@@ -782,9 +782,9 @@ var ImageWithPlaceholder = ({
|
|
|
782
782
|
};
|
|
783
783
|
const resolvedSrc = resolveSrc(src);
|
|
784
784
|
const initialSrc = isValidSrc(resolvedSrc) ? resolvedSrc : fallbackSrc;
|
|
785
|
-
const [imgSrc, setImgSrc] =
|
|
786
|
-
const [hasError, setHasError] =
|
|
787
|
-
|
|
785
|
+
const [imgSrc, setImgSrc] = React24.useState(initialSrc);
|
|
786
|
+
const [hasError, setHasError] = React24.useState(!isValidSrc(resolvedSrc));
|
|
787
|
+
React24.useEffect(() => {
|
|
788
788
|
const nextResolvedSrc = resolveSrc(src);
|
|
789
789
|
if (isValidSrc(nextResolvedSrc)) {
|
|
790
790
|
setImgSrc(nextResolvedSrc);
|
|
@@ -993,8 +993,8 @@ var Toast = ({
|
|
|
993
993
|
showCloseButton = true,
|
|
994
994
|
className
|
|
995
995
|
}) => {
|
|
996
|
-
const [isShowing, setIsShowing] =
|
|
997
|
-
|
|
996
|
+
const [isShowing, setIsShowing] = React24.useState(false);
|
|
997
|
+
React24.useEffect(() => {
|
|
998
998
|
if (isVisible) {
|
|
999
999
|
setIsShowing(true);
|
|
1000
1000
|
let timer = null;
|
|
@@ -1218,7 +1218,7 @@ var Modal = ({
|
|
|
1218
1218
|
closeOnEscape = true,
|
|
1219
1219
|
className
|
|
1220
1220
|
}) => {
|
|
1221
|
-
|
|
1221
|
+
React24.useEffect(() => {
|
|
1222
1222
|
if (!isOpen) return;
|
|
1223
1223
|
const handleEscape = (e) => {
|
|
1224
1224
|
if (e.key === "Escape" && closeOnEscape) {
|
|
@@ -1285,7 +1285,7 @@ var Modal = ({
|
|
|
1285
1285
|
);
|
|
1286
1286
|
};
|
|
1287
1287
|
var Modal_default = Modal;
|
|
1288
|
-
var Card =
|
|
1288
|
+
var Card = React24__namespace.default.forwardRef(
|
|
1289
1289
|
({
|
|
1290
1290
|
className,
|
|
1291
1291
|
variant = "default",
|
|
@@ -1323,7 +1323,7 @@ var Card = React23__namespace.default.forwardRef(
|
|
|
1323
1323
|
);
|
|
1324
1324
|
Card.displayName = "Card";
|
|
1325
1325
|
var Card_default = Card;
|
|
1326
|
-
var Badge =
|
|
1326
|
+
var Badge = React24__namespace.default.forwardRef(
|
|
1327
1327
|
({
|
|
1328
1328
|
className,
|
|
1329
1329
|
variant = "default",
|
|
@@ -1378,7 +1378,7 @@ var Avatar = ({
|
|
|
1378
1378
|
className,
|
|
1379
1379
|
onClick
|
|
1380
1380
|
}) => {
|
|
1381
|
-
const [imgError, setImgError] =
|
|
1381
|
+
const [imgError, setImgError] = React24.useState(false);
|
|
1382
1382
|
const sizeClasses = {
|
|
1383
1383
|
sm: "w-8 h-8 text-xs",
|
|
1384
1384
|
md: "w-10 h-10 text-sm",
|
|
@@ -1401,7 +1401,7 @@ var Avatar = ({
|
|
|
1401
1401
|
}
|
|
1402
1402
|
) }) });
|
|
1403
1403
|
};
|
|
1404
|
-
const handleImgError =
|
|
1404
|
+
const handleImgError = React24.useCallback(() => {
|
|
1405
1405
|
setImgError(true);
|
|
1406
1406
|
}, []);
|
|
1407
1407
|
const isSrcAvailable = typeof src === "string" && src.trim() !== "";
|
|
@@ -1473,8 +1473,8 @@ var Tooltip = ({
|
|
|
1473
1473
|
delay = 200,
|
|
1474
1474
|
className
|
|
1475
1475
|
}) => {
|
|
1476
|
-
const [isVisible, setIsVisible] =
|
|
1477
|
-
const [timeoutId, setTimeoutId] =
|
|
1476
|
+
const [isVisible, setIsVisible] = React24.useState(false);
|
|
1477
|
+
const [timeoutId, setTimeoutId] = React24.useState(null);
|
|
1478
1478
|
const showTooltip = () => {
|
|
1479
1479
|
const id = setTimeout(() => setIsVisible(true), delay);
|
|
1480
1480
|
setTimeoutId(id);
|
|
@@ -1604,14 +1604,14 @@ var matchShortcut = (event, shortcut, os) => {
|
|
|
1604
1604
|
var useShortcutFormatter = ({
|
|
1605
1605
|
globalKeyboardShortcuts: globalKeyboardShortcuts2 = []
|
|
1606
1606
|
} = {}) => {
|
|
1607
|
-
const [os, setOS] =
|
|
1608
|
-
const listenersRef =
|
|
1607
|
+
const [os, setOS] = React24.useState("windows");
|
|
1608
|
+
const listenersRef = React24.useRef(
|
|
1609
1609
|
/* @__PURE__ */ new Map()
|
|
1610
1610
|
);
|
|
1611
|
-
|
|
1611
|
+
React24.useEffect(() => {
|
|
1612
1612
|
setOS(detectOS());
|
|
1613
1613
|
}, []);
|
|
1614
|
-
|
|
1614
|
+
React24.useEffect(() => {
|
|
1615
1615
|
if (!globalKeyboardShortcuts2.length) return;
|
|
1616
1616
|
const handleKeyDown = (event) => {
|
|
1617
1617
|
for (const shortcut of globalKeyboardShortcuts2) {
|
|
@@ -1629,21 +1629,21 @@ var useShortcutFormatter = ({
|
|
|
1629
1629
|
window.removeEventListener("keydown", handleKeyDown);
|
|
1630
1630
|
};
|
|
1631
1631
|
}, [os, globalKeyboardShortcuts2]);
|
|
1632
|
-
const formatKeys =
|
|
1632
|
+
const formatKeys = React24.useCallback(
|
|
1633
1633
|
(keys = []) => {
|
|
1634
1634
|
const separator = os === "mac" ? "" : " + ";
|
|
1635
1635
|
return keys.map((key) => keyMap[os][key.toLowerCase()] || key.toUpperCase()).join(separator);
|
|
1636
1636
|
},
|
|
1637
1637
|
[os]
|
|
1638
1638
|
);
|
|
1639
|
-
const getShortcutByCommand =
|
|
1639
|
+
const getShortcutByCommand = React24.useCallback(
|
|
1640
1640
|
(command) => {
|
|
1641
1641
|
const found = globalKeyboardShortcuts2.find((s) => s.command === command);
|
|
1642
1642
|
return found ? found.shortcut : [];
|
|
1643
1643
|
},
|
|
1644
1644
|
[globalKeyboardShortcuts2]
|
|
1645
1645
|
);
|
|
1646
|
-
const addShortcutListener =
|
|
1646
|
+
const addShortcutListener = React24.useCallback(
|
|
1647
1647
|
(command, listener) => {
|
|
1648
1648
|
if (!listenersRef.current.has(command)) {
|
|
1649
1649
|
listenersRef.current.set(command, /* @__PURE__ */ new Set());
|
|
@@ -1652,7 +1652,7 @@ var useShortcutFormatter = ({
|
|
|
1652
1652
|
},
|
|
1653
1653
|
[]
|
|
1654
1654
|
);
|
|
1655
|
-
const removeShortcutListener =
|
|
1655
|
+
const removeShortcutListener = React24.useCallback(
|
|
1656
1656
|
(command, listener) => {
|
|
1657
1657
|
if (listenersRef.current.has(command)) {
|
|
1658
1658
|
listenersRef.current.get(command).delete(listener);
|
|
@@ -1692,7 +1692,7 @@ var globalKeyboardShortcuts = [
|
|
|
1692
1692
|
usage: "Focus on current app search"
|
|
1693
1693
|
}
|
|
1694
1694
|
];
|
|
1695
|
-
var SearchInput =
|
|
1695
|
+
var SearchInput = React24__namespace.default.forwardRef(
|
|
1696
1696
|
({
|
|
1697
1697
|
onSearch,
|
|
1698
1698
|
placeholder = "Search...",
|
|
@@ -1707,16 +1707,16 @@ var SearchInput = React23__namespace.default.forwardRef(
|
|
|
1707
1707
|
isActive = true,
|
|
1708
1708
|
...props
|
|
1709
1709
|
}, ref) => {
|
|
1710
|
-
const [searchValue, setSearchValue] =
|
|
1711
|
-
const inputRef =
|
|
1712
|
-
|
|
1710
|
+
const [searchValue, setSearchValue] = React24__namespace.default.useState(value || "");
|
|
1711
|
+
const inputRef = React24.useRef(null);
|
|
1712
|
+
React24.useImperativeHandle(ref, () => inputRef.current);
|
|
1713
1713
|
const {
|
|
1714
1714
|
addShortcutListener,
|
|
1715
1715
|
removeShortcutListener,
|
|
1716
1716
|
formatKeys,
|
|
1717
1717
|
getShortcutByCommand
|
|
1718
1718
|
} = useShortcutFormatter_default({ globalKeyboardShortcuts });
|
|
1719
|
-
|
|
1719
|
+
React24.useEffect(() => {
|
|
1720
1720
|
setSearchValue(value ?? "");
|
|
1721
1721
|
}, [value]);
|
|
1722
1722
|
const handleChange = (e) => {
|
|
@@ -1725,7 +1725,7 @@ var SearchInput = React23__namespace.default.forwardRef(
|
|
|
1725
1725
|
onChange?.(e);
|
|
1726
1726
|
onSearch?.(newValue);
|
|
1727
1727
|
};
|
|
1728
|
-
const handleClear =
|
|
1728
|
+
const handleClear = React24.useCallback(() => {
|
|
1729
1729
|
setSearchValue("");
|
|
1730
1730
|
onSearch?.("");
|
|
1731
1731
|
const syntheticEvent = {
|
|
@@ -1733,7 +1733,7 @@ var SearchInput = React23__namespace.default.forwardRef(
|
|
|
1733
1733
|
};
|
|
1734
1734
|
onChange?.(syntheticEvent);
|
|
1735
1735
|
}, [onChange, onSearch]);
|
|
1736
|
-
|
|
1736
|
+
React24.useEffect(() => {
|
|
1737
1737
|
if (!enableKeyboardShortcuts || !isActive) return;
|
|
1738
1738
|
const handleFocusSearch = (e) => {
|
|
1739
1739
|
e?.preventDefault();
|
|
@@ -1886,8 +1886,8 @@ var FileUpload = ({
|
|
|
1886
1886
|
children,
|
|
1887
1887
|
dragAndDrop = false
|
|
1888
1888
|
}) => {
|
|
1889
|
-
const fileInputRef =
|
|
1890
|
-
const [isDragOver, setIsDragOver] =
|
|
1889
|
+
const fileInputRef = React24.useRef(null);
|
|
1890
|
+
const [isDragOver, setIsDragOver] = React24__namespace.default.useState(false);
|
|
1891
1891
|
const handleFileSelect = (files) => {
|
|
1892
1892
|
if (!files) return;
|
|
1893
1893
|
const fileArray = Array.from(files);
|
|
@@ -2185,7 +2185,7 @@ var Pagination = ({
|
|
|
2185
2185
|
] });
|
|
2186
2186
|
};
|
|
2187
2187
|
var Pagination_default = Pagination;
|
|
2188
|
-
var Radio =
|
|
2188
|
+
var Radio = React24__namespace.default.forwardRef(
|
|
2189
2189
|
({
|
|
2190
2190
|
className,
|
|
2191
2191
|
label,
|
|
@@ -2250,7 +2250,7 @@ var Radio = React23__namespace.default.forwardRef(
|
|
|
2250
2250
|
Radio.displayName = "Radio";
|
|
2251
2251
|
var Radio_default = Radio;
|
|
2252
2252
|
var Accordion = ({ items, active = -1 }) => {
|
|
2253
|
-
const [activeIndex, setActiveIndex] =
|
|
2253
|
+
const [activeIndex, setActiveIndex] = React24.useState(active);
|
|
2254
2254
|
const toggleAccordion = (index) => {
|
|
2255
2255
|
setActiveIndex(activeIndex === index ? null : index);
|
|
2256
2256
|
};
|
|
@@ -2291,8 +2291,8 @@ var Tabs = ({
|
|
|
2291
2291
|
buttonClassName = "flex items-center gap-1 px-[8px] py-[2px] text-[13px] cursor-pointer transition-all duration-300 text-neutral-300 rounded-[6px] m-[8px]",
|
|
2292
2292
|
activeButtonClassName = "bg-surface-3 text-neutral-400"
|
|
2293
2293
|
}) => {
|
|
2294
|
-
const [activeTab, setActiveTab] =
|
|
2295
|
-
|
|
2294
|
+
const [activeTab, setActiveTab] = React24.useState(defaultActiveTab);
|
|
2295
|
+
React24.useEffect(() => {
|
|
2296
2296
|
setActiveTab(defaultActiveTab);
|
|
2297
2297
|
}, [defaultActiveTab]);
|
|
2298
2298
|
const handleTabClick = (index) => {
|
|
@@ -2351,14 +2351,33 @@ var decodeBase64 = (base64) => {
|
|
|
2351
2351
|
const bytes = Uint8Array.from(atob(value), (character) => character.charCodeAt(0));
|
|
2352
2352
|
return new TextDecoder().decode(bytes);
|
|
2353
2353
|
};
|
|
2354
|
+
var toPdfBlob = (base64) => {
|
|
2355
|
+
const value = base64.includes(",") ? base64.slice(base64.indexOf(",") + 1) : base64;
|
|
2356
|
+
const bytes = Uint8Array.from(atob(value), (character) => character.charCodeAt(0));
|
|
2357
|
+
return new Blob([bytes], { type: "application/pdf" });
|
|
2358
|
+
};
|
|
2354
2359
|
var PreviewComponent = ({ fileName, base64, className }) => {
|
|
2355
2360
|
const previewType = getPreviewType(fileName);
|
|
2356
2361
|
const dataUrl = toDataUrl(base64, fileName);
|
|
2362
|
+
const [pdfUrl, setPdfUrl] = React24.useState(dataUrl);
|
|
2363
|
+
React24.useEffect(() => {
|
|
2364
|
+
if (previewType !== "pdf" || typeof URL.createObjectURL !== "function") return;
|
|
2365
|
+
try {
|
|
2366
|
+
const objectUrl = URL.createObjectURL(toPdfBlob(base64));
|
|
2367
|
+
setPdfUrl(objectUrl);
|
|
2368
|
+
return () => URL.revokeObjectURL(objectUrl);
|
|
2369
|
+
} catch {
|
|
2370
|
+
setPdfUrl(dataUrl);
|
|
2371
|
+
}
|
|
2372
|
+
}, [base64, dataUrl, previewType]);
|
|
2357
2373
|
if (previewType === "image") {
|
|
2358
2374
|
return /* @__PURE__ */ jsxRuntime.jsx("div", { className: cn("flex h-full min-h-48 w-full items-center justify-center overflow-auto", className), children: /* @__PURE__ */ jsxRuntime.jsx("img", { src: dataUrl, alt: fileName, className: "max-h-full max-w-full object-contain" }) });
|
|
2359
2375
|
}
|
|
2360
2376
|
if (previewType === "pdf") {
|
|
2361
|
-
return /* @__PURE__ */ jsxRuntime.jsx("
|
|
2377
|
+
return /* @__PURE__ */ jsxRuntime.jsx("object", { data: pdfUrl, type: "application/pdf", "aria-label": fileName, className: cn("h-full min-h-96 w-full", className), children: /* @__PURE__ */ jsxRuntime.jsxs("a", { href: pdfUrl, download: fileName, children: [
|
|
2378
|
+
"Download ",
|
|
2379
|
+
fileName
|
|
2380
|
+
] }) });
|
|
2362
2381
|
}
|
|
2363
2382
|
if (previewType === "text" || previewType === "json") {
|
|
2364
2383
|
let content;
|
|
@@ -2392,11 +2411,11 @@ function renderPluginChild(child, app, api, reloadKey) {
|
|
|
2392
2411
|
const renderFn = child;
|
|
2393
2412
|
return renderFn({ app, api });
|
|
2394
2413
|
}
|
|
2395
|
-
return
|
|
2396
|
-
if (!
|
|
2414
|
+
return React24.Children.map(child, (node, index) => {
|
|
2415
|
+
if (!React24.isValidElement(node)) {
|
|
2397
2416
|
return node;
|
|
2398
2417
|
}
|
|
2399
|
-
return
|
|
2418
|
+
return React24.cloneElement(
|
|
2400
2419
|
node,
|
|
2401
2420
|
{
|
|
2402
2421
|
key: `${reloadKey}-${index}`,
|
|
@@ -2426,13 +2445,13 @@ function PluginPlayground({
|
|
|
2426
2445
|
metadata,
|
|
2427
2446
|
backgroundImage
|
|
2428
2447
|
}) {
|
|
2429
|
-
const [mockUser] =
|
|
2430
|
-
const [mockToken] =
|
|
2431
|
-
const [isMinimized, setIsMinimized] =
|
|
2432
|
-
const [isClosed, setIsClosed] =
|
|
2433
|
-
const [isActive, setIsActive] =
|
|
2434
|
-
const [isNightMode, setIsNightMode] =
|
|
2435
|
-
|
|
2448
|
+
const [mockUser] = React24.useState(DEFAULT_MOCK_USER);
|
|
2449
|
+
const [mockToken] = React24.useState(DEFAULT_TOKEN);
|
|
2450
|
+
const [isMinimized, setIsMinimized] = React24.useState(false);
|
|
2451
|
+
const [isClosed, setIsClosed] = React24.useState(false);
|
|
2452
|
+
const [isActive, setIsActive] = React24.useState(true);
|
|
2453
|
+
const [isNightMode, setIsNightMode] = React24.useState(true);
|
|
2454
|
+
React24.useEffect(() => {
|
|
2436
2455
|
if (typeof window === "undefined") return;
|
|
2437
2456
|
const storedTheme = window.localStorage.getItem("plugin-playground-theme");
|
|
2438
2457
|
const prefersDark = window.matchMedia(
|
|
@@ -2441,7 +2460,7 @@ function PluginPlayground({
|
|
|
2441
2460
|
const shouldUseDark = storedTheme ? storedTheme === "dark" : prefersDark;
|
|
2442
2461
|
setIsNightMode(shouldUseDark);
|
|
2443
2462
|
}, []);
|
|
2444
|
-
|
|
2463
|
+
React24.useEffect(() => {
|
|
2445
2464
|
if (typeof document === "undefined") return;
|
|
2446
2465
|
document.documentElement.classList.toggle("dark", isNightMode);
|
|
2447
2466
|
window.localStorage.setItem(
|
|
@@ -2451,25 +2470,25 @@ function PluginPlayground({
|
|
|
2451
2470
|
}, [isNightMode]);
|
|
2452
2471
|
const title = metadata.title ?? metadata.name ?? "Plugin Playground";
|
|
2453
2472
|
const slug = metadata.slug ?? "local-plugin";
|
|
2454
|
-
const defaultSize =
|
|
2473
|
+
const defaultSize = React24.useMemo(() => getDefaultSize(metadata), [metadata]);
|
|
2455
2474
|
const canvasBackground = backgroundImage ?? metadata.backgroundImage ?? DEFAULT_BACKGROUND;
|
|
2456
2475
|
const isWindowResizable = metadata.windowSize?.isAppWindowResizing ?? metadata.isResizing ?? true;
|
|
2457
|
-
const minimizeWindow =
|
|
2476
|
+
const minimizeWindow = React24.useCallback(() => {
|
|
2458
2477
|
setIsActive(false);
|
|
2459
2478
|
setIsMinimized(true);
|
|
2460
2479
|
setIsClosed(false);
|
|
2461
2480
|
}, []);
|
|
2462
|
-
const closeWindow =
|
|
2481
|
+
const closeWindow = React24.useCallback(() => {
|
|
2463
2482
|
setIsActive(false);
|
|
2464
2483
|
setIsClosed(true);
|
|
2465
2484
|
setIsMinimized(false);
|
|
2466
2485
|
}, []);
|
|
2467
|
-
const restoreWindow =
|
|
2486
|
+
const restoreWindow = React24.useCallback(() => {
|
|
2468
2487
|
setIsActive(true);
|
|
2469
2488
|
setIsClosed(false);
|
|
2470
2489
|
setIsMinimized(false);
|
|
2471
2490
|
}, []);
|
|
2472
|
-
const mockApi =
|
|
2491
|
+
const mockApi = React24.useMemo(() => {
|
|
2473
2492
|
return {
|
|
2474
2493
|
showToast: (message, type) => {
|
|
2475
2494
|
console.info(`[playground:${type}] ${message}`);
|
|
@@ -2486,7 +2505,7 @@ function PluginPlayground({
|
|
|
2486
2505
|
isDarkTheme: isNightMode
|
|
2487
2506
|
};
|
|
2488
2507
|
}, [mockToken, mockUser, isNightMode]);
|
|
2489
|
-
const appProps =
|
|
2508
|
+
const appProps = React24.useMemo(
|
|
2490
2509
|
() => ({
|
|
2491
2510
|
name: title,
|
|
2492
2511
|
slug,
|
|
@@ -2656,13 +2675,13 @@ var WindowWithSideMenu = ({
|
|
|
2656
2675
|
removeShortcutListener,
|
|
2657
2676
|
getShortcutByCommand
|
|
2658
2677
|
} = useShortcutFormatter_default({ globalKeyboardShortcuts });
|
|
2659
|
-
const [state, dispatch] =
|
|
2678
|
+
const [state, dispatch] = React24.useReducer(reducer, {
|
|
2660
2679
|
...initialState,
|
|
2661
2680
|
windowSize: app.windowSize.windowSize ?? defaultSize,
|
|
2662
2681
|
defaultSize: app.windowSize.windowSize ?? defaultSize
|
|
2663
2682
|
});
|
|
2664
|
-
const windowRef =
|
|
2665
|
-
|
|
2683
|
+
const windowRef = React24.useRef(null);
|
|
2684
|
+
React24.useEffect(() => {
|
|
2666
2685
|
if (app.isMinimize !== state.isMinimized) {
|
|
2667
2686
|
dispatch({ type: "SYNC_MINIMIZE_STATE", payload: app.isMinimize });
|
|
2668
2687
|
}
|
|
@@ -2723,7 +2742,7 @@ var WindowWithSideMenu = ({
|
|
|
2723
2742
|
document.body.style.userSelect = "none";
|
|
2724
2743
|
dispatch({ type: "START_RESIZE", payload: { x: e.clientX, y: e.clientY } });
|
|
2725
2744
|
};
|
|
2726
|
-
|
|
2745
|
+
React24.useEffect(() => {
|
|
2727
2746
|
if (state.isDragging || state.resizeStart) {
|
|
2728
2747
|
window.addEventListener("mousemove", handleMouseMove);
|
|
2729
2748
|
window.addEventListener("mouseup", handleMouseUp);
|
|
@@ -2734,7 +2753,7 @@ var WindowWithSideMenu = ({
|
|
|
2734
2753
|
document.body.style.userSelect = "";
|
|
2735
2754
|
};
|
|
2736
2755
|
}, [state.isDragging, state.resizeStart]);
|
|
2737
|
-
|
|
2756
|
+
React24.useEffect(() => {
|
|
2738
2757
|
if (windowRef.current) {
|
|
2739
2758
|
windowRef.current.addEventListener("click", () => {
|
|
2740
2759
|
if (app?.callback) {
|
|
@@ -2743,7 +2762,7 @@ var WindowWithSideMenu = ({
|
|
|
2743
2762
|
});
|
|
2744
2763
|
}
|
|
2745
2764
|
}, [app?.slug, windowRef]);
|
|
2746
|
-
|
|
2765
|
+
React24.useEffect(() => {
|
|
2747
2766
|
const handleExitApp = () => {
|
|
2748
2767
|
if (app?.callback) {
|
|
2749
2768
|
app?.callback("CLOSE_APP");
|
|
@@ -2754,7 +2773,7 @@ var WindowWithSideMenu = ({
|
|
|
2754
2773
|
removeShortcutListener("exit_app", handleExitApp);
|
|
2755
2774
|
};
|
|
2756
2775
|
}, [app?.slug, app.isActive]);
|
|
2757
|
-
|
|
2776
|
+
React24.useEffect(() => {
|
|
2758
2777
|
const handleMinimize = () => {
|
|
2759
2778
|
if (app?.slug && app.isActive) {
|
|
2760
2779
|
dispatch({
|
|
@@ -2771,7 +2790,7 @@ var WindowWithSideMenu = ({
|
|
|
2771
2790
|
removeShortcutListener("minimize_app", handleMinimize);
|
|
2772
2791
|
};
|
|
2773
2792
|
}, [app?.slug, app.isActive, state.isMinimized, state.windowSize]);
|
|
2774
|
-
|
|
2793
|
+
React24.useEffect(() => {
|
|
2775
2794
|
const handleMaximize = () => {
|
|
2776
2795
|
if (app?.slug && app.isActive) {
|
|
2777
2796
|
dispatch({
|
|
@@ -2942,7 +2961,7 @@ var WindowWithSideMenu = ({
|
|
|
2942
2961
|
style: {
|
|
2943
2962
|
maxHeight: `${state.windowSize.height - 37}px`
|
|
2944
2963
|
},
|
|
2945
|
-
children:
|
|
2964
|
+
children: React24.isValidElement(children) && typeof children.type !== "string" ? React24__namespace.default.cloneElement(children, {
|
|
2946
2965
|
windowSize: state.windowSize,
|
|
2947
2966
|
isAppWindowResizing: state.resizeStart !== null
|
|
2948
2967
|
}) : children
|
|
@@ -3048,13 +3067,13 @@ var WindowWithoutSideMenu = ({
|
|
|
3048
3067
|
removeShortcutListener,
|
|
3049
3068
|
getShortcutByCommand
|
|
3050
3069
|
} = useShortcutFormatter_default({ globalKeyboardShortcuts });
|
|
3051
|
-
const [state, dispatch] =
|
|
3070
|
+
const [state, dispatch] = React24.useReducer(reducer2, {
|
|
3052
3071
|
...initialState2,
|
|
3053
3072
|
windowSize: app.windowSize.windowSize ?? defaultSize,
|
|
3054
3073
|
defaultSize: app.windowSize.windowSize ?? defaultSize
|
|
3055
3074
|
});
|
|
3056
|
-
const windowRef =
|
|
3057
|
-
|
|
3075
|
+
const windowRef = React24.useRef(null);
|
|
3076
|
+
React24.useEffect(() => {
|
|
3058
3077
|
if (app.isMinimize !== state.isMinimized) {
|
|
3059
3078
|
dispatch({ type: "SYNC_MINIMIZE_STATE", payload: app.isMinimize });
|
|
3060
3079
|
}
|
|
@@ -3111,7 +3130,7 @@ var WindowWithoutSideMenu = ({
|
|
|
3111
3130
|
document.body.style.userSelect = "none";
|
|
3112
3131
|
dispatch({ type: "START_RESIZE", payload: { x: e.clientX, y: e.clientY } });
|
|
3113
3132
|
};
|
|
3114
|
-
|
|
3133
|
+
React24.useEffect(() => {
|
|
3115
3134
|
if (state.isDragging || state.resizeStart) {
|
|
3116
3135
|
window.addEventListener("mousemove", handleMouseMove);
|
|
3117
3136
|
window.addEventListener("mouseup", handleMouseUp);
|
|
@@ -3122,7 +3141,7 @@ var WindowWithoutSideMenu = ({
|
|
|
3122
3141
|
document.body.style.userSelect = "";
|
|
3123
3142
|
};
|
|
3124
3143
|
}, [state.isDragging, state.resizeStart]);
|
|
3125
|
-
|
|
3144
|
+
React24.useEffect(() => {
|
|
3126
3145
|
if (windowRef.current) {
|
|
3127
3146
|
windowRef.current.addEventListener("click", () => {
|
|
3128
3147
|
if (app?.callback) {
|
|
@@ -3131,7 +3150,7 @@ var WindowWithoutSideMenu = ({
|
|
|
3131
3150
|
});
|
|
3132
3151
|
}
|
|
3133
3152
|
}, [app?.slug, windowRef]);
|
|
3134
|
-
|
|
3153
|
+
React24.useEffect(() => {
|
|
3135
3154
|
const handleExitApp = () => {
|
|
3136
3155
|
if (app?.callback) {
|
|
3137
3156
|
app?.callback("CLOSE_APP");
|
|
@@ -3142,7 +3161,7 @@ var WindowWithoutSideMenu = ({
|
|
|
3142
3161
|
removeShortcutListener("exit_app", handleExitApp);
|
|
3143
3162
|
};
|
|
3144
3163
|
}, [app?.slug, app.isActive]);
|
|
3145
|
-
|
|
3164
|
+
React24.useEffect(() => {
|
|
3146
3165
|
const handleMinimize = () => {
|
|
3147
3166
|
if (app?.slug && app.isActive) {
|
|
3148
3167
|
dispatch({
|
|
@@ -3159,7 +3178,7 @@ var WindowWithoutSideMenu = ({
|
|
|
3159
3178
|
removeShortcutListener("minimize_app", handleMinimize);
|
|
3160
3179
|
};
|
|
3161
3180
|
}, [app?.slug, app.isActive, state.isMinimized, state.windowSize]);
|
|
3162
|
-
|
|
3181
|
+
React24.useEffect(() => {
|
|
3163
3182
|
const handleMaximize = () => {
|
|
3164
3183
|
if (app?.slug && app.isActive) {
|
|
3165
3184
|
dispatch({
|
|
@@ -3275,7 +3294,7 @@ var WindowWithoutSideMenu = ({
|
|
|
3275
3294
|
style: {
|
|
3276
3295
|
maxHeight: `${state.windowSize.height - 37}px`
|
|
3277
3296
|
},
|
|
3278
|
-
children:
|
|
3297
|
+
children: React24.isValidElement(children) && typeof children.type !== "string" ? React24__namespace.default.cloneElement(children, {
|
|
3279
3298
|
windowSize: state.windowSize,
|
|
3280
3299
|
isAppWindowResizing: state.resizeStart !== null
|
|
3281
3300
|
}) : children
|
|
@@ -3298,7 +3317,7 @@ var WindowWithoutSideMenu = ({
|
|
|
3298
3317
|
);
|
|
3299
3318
|
};
|
|
3300
3319
|
var WindowWithoutSideMenu_default = WindowWithoutSideMenu;
|
|
3301
|
-
var Table =
|
|
3320
|
+
var Table = React24__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx("div", { className: "relative w-full overflow-auto", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
3302
3321
|
"table",
|
|
3303
3322
|
{
|
|
3304
3323
|
ref,
|
|
@@ -3307,9 +3326,9 @@ var Table = React23__namespace.forwardRef(({ className, ...props }, ref) => /* @
|
|
|
3307
3326
|
}
|
|
3308
3327
|
) }));
|
|
3309
3328
|
Table.displayName = "Table";
|
|
3310
|
-
var TableHeader =
|
|
3329
|
+
var TableHeader = React24__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx("thead", { ref, className: cn("[&_tr]:border-b text-neutral-400 bg-surface-2", className), ...props }));
|
|
3311
3330
|
TableHeader.displayName = "TableHeader";
|
|
3312
|
-
var TableBody =
|
|
3331
|
+
var TableBody = React24__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
3313
3332
|
"tbody",
|
|
3314
3333
|
{
|
|
3315
3334
|
ref,
|
|
@@ -3318,7 +3337,7 @@ var TableBody = React23__namespace.forwardRef(({ className, ...props }, ref) =>
|
|
|
3318
3337
|
}
|
|
3319
3338
|
));
|
|
3320
3339
|
TableBody.displayName = "TableBody";
|
|
3321
|
-
var TableFooter =
|
|
3340
|
+
var TableFooter = React24__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
3322
3341
|
"tfoot",
|
|
3323
3342
|
{
|
|
3324
3343
|
ref,
|
|
@@ -3330,7 +3349,7 @@ var TableFooter = React23__namespace.forwardRef(({ className, ...props }, ref) =
|
|
|
3330
3349
|
}
|
|
3331
3350
|
));
|
|
3332
3351
|
TableFooter.displayName = "TableFooter";
|
|
3333
|
-
var TableRow =
|
|
3352
|
+
var TableRow = React24__namespace.forwardRef(({ className, onClick, ...props }, ref) => {
|
|
3334
3353
|
const isInteractive = typeof onClick === "function";
|
|
3335
3354
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
3336
3355
|
"tr",
|
|
@@ -3347,7 +3366,7 @@ var TableRow = React23__namespace.forwardRef(({ className, onClick, ...props },
|
|
|
3347
3366
|
);
|
|
3348
3367
|
});
|
|
3349
3368
|
TableRow.displayName = "TableRow";
|
|
3350
|
-
var TableHead =
|
|
3369
|
+
var TableHead = React24__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
3351
3370
|
"th",
|
|
3352
3371
|
{
|
|
3353
3372
|
ref,
|
|
@@ -3359,7 +3378,7 @@ var TableHead = React23__namespace.forwardRef(({ className, ...props }, ref) =>
|
|
|
3359
3378
|
}
|
|
3360
3379
|
));
|
|
3361
3380
|
TableHead.displayName = "TableHead";
|
|
3362
|
-
var TableCell =
|
|
3381
|
+
var TableCell = React24__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
3363
3382
|
"td",
|
|
3364
3383
|
{
|
|
3365
3384
|
ref,
|
|
@@ -3368,7 +3387,7 @@ var TableCell = React23__namespace.forwardRef(({ className, ...props }, ref) =>
|
|
|
3368
3387
|
}
|
|
3369
3388
|
));
|
|
3370
3389
|
TableCell.displayName = "TableCell";
|
|
3371
|
-
var TableCaption =
|
|
3390
|
+
var TableCaption = React24__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
3372
3391
|
"caption",
|
|
3373
3392
|
{
|
|
3374
3393
|
ref,
|
|
@@ -3378,12 +3397,12 @@ var TableCaption = React23__namespace.forwardRef(({ className, ...props }, ref)
|
|
|
3378
3397
|
));
|
|
3379
3398
|
TableCaption.displayName = "TableCaption";
|
|
3380
3399
|
var useGridClasses = (windowSize, gridRules) => {
|
|
3381
|
-
const deviceType =
|
|
3400
|
+
const deviceType = React24.useMemo(() => {
|
|
3382
3401
|
if (windowSize.width <= 640) return "mobile";
|
|
3383
3402
|
if (windowSize.width <= 1024) return "tablet";
|
|
3384
3403
|
return "desktop";
|
|
3385
3404
|
}, [windowSize]);
|
|
3386
|
-
const gridClasses =
|
|
3405
|
+
const gridClasses = React24.useMemo(() => {
|
|
3387
3406
|
const classes = {};
|
|
3388
3407
|
for (const element in gridRules) {
|
|
3389
3408
|
const classRules = gridRules[element] ?? {};
|
|
@@ -3396,8 +3415,8 @@ var useGridClasses = (windowSize, gridRules) => {
|
|
|
3396
3415
|
};
|
|
3397
3416
|
var useGridClasses_default = useGridClasses;
|
|
3398
3417
|
var useDeviceSupport = () => {
|
|
3399
|
-
const [isSupported, setIsSupported] =
|
|
3400
|
-
|
|
3418
|
+
const [isSupported, setIsSupported] = React24.useState(true);
|
|
3419
|
+
React24.useEffect(() => {
|
|
3401
3420
|
function checkSupport() {
|
|
3402
3421
|
const ua = typeof window !== "undefined" ? window.navigator.userAgent : "";
|
|
3403
3422
|
const width = typeof window !== "undefined" ? window.innerWidth : 1920;
|
|
@@ -3523,7 +3542,7 @@ var useSound = () => {
|
|
|
3523
3542
|
audio.currentTime = 0;
|
|
3524
3543
|
await audio.play();
|
|
3525
3544
|
};
|
|
3526
|
-
const playSound =
|
|
3545
|
+
const playSound = React24.useCallback((type) => {
|
|
3527
3546
|
if (typeof window === "undefined") {
|
|
3528
3547
|
return;
|
|
3529
3548
|
}
|