@sia.soul/sia-react-ui 0.1.76 → 0.1.78
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/chart.js +2 -3
- package/dist/{chunk-Q4FDV6KP.js → chunk-BDS42FR3.js} +2 -4
- package/dist/{chunk-JNZXYBGM.js → chunk-GODBVCIQ.js} +2 -2
- package/dist/chunk-JZWTTSOZ.js +131 -0
- package/dist/{chunk-QDZXP2UO.js → chunk-NK2FZWKM.js} +8 -10
- package/dist/{chunk-TKCXP6RZ.js → chunk-WXERMWTW.js} +113 -436
- package/dist/{chunk-YMOOL62S.js → chunk-XHLIIDD2.js} +407 -21
- package/dist/{chunk-TG7ZYXA7.js → chunk-Y4Y2NVBM.js} +35 -12
- package/dist/{core-CBLT4Vfl.d.ts → core-0ml74Q-C.d.ts} +7 -0
- package/dist/{core-Bx07vzrr.d.cts → core-vGTHkzIa.d.cts} +7 -0
- package/dist/core.cjs +336 -275
- package/dist/core.css +19 -0
- package/dist/core.d.cts +1 -1
- package/dist/core.d.ts +1 -1
- package/dist/core.js +5 -6
- package/dist/index.cjs +1038 -952
- package/dist/index.css +19 -0
- package/dist/index.d.cts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.js +13 -15
- package/dist/rich-text-editor.cjs +522 -74
- package/dist/rich-text-editor.js +3 -3
- package/dist/{select-date-range-DN4eBuVx.d.cts → select-date-range-CRWxqHFp.d.cts} +2 -2
- package/dist/{select-date-range-YrK9kuKW.d.ts → select-date-range-rtYL9egr.d.ts} +2 -2
- package/dist/select-date-range.cjs +338 -188
- package/dist/select-date-range.d.cts +1 -1
- package/dist/select-date-range.d.ts +1 -1
- package/dist/select-date-range.js +4 -4
- package/package.json +1 -1
- package/dist/chunk-IKAMZNCK.js +0 -65
- package/dist/chunk-SMCYEPBL.js +0 -73
|
@@ -324,7 +324,7 @@ function useFloatingPlaceholder({ mode, placeholder, filled, active = false }) {
|
|
|
324
324
|
}
|
|
325
325
|
|
|
326
326
|
// src/components/RichTextEditor.tsx
|
|
327
|
-
var
|
|
327
|
+
var import_react12 = require("react");
|
|
328
328
|
var import_dompurify = __toESM(require("dompurify"), 1);
|
|
329
329
|
var import_core = require("@tiptap/core");
|
|
330
330
|
var import_starter_kit = __toESM(require("@tiptap/starter-kit"), 1);
|
|
@@ -1693,9 +1693,396 @@ var Dropdown = Object.assign(DropdownRoot, {
|
|
|
1693
1693
|
});
|
|
1694
1694
|
|
|
1695
1695
|
// src/components/Input.tsx
|
|
1696
|
+
var import_react11 = require("react");
|
|
1697
|
+
|
|
1698
|
+
// src/components/Modal.tsx
|
|
1699
|
+
var import_react9 = require("react");
|
|
1700
|
+
var import_client2 = require("react-dom/client");
|
|
1701
|
+
|
|
1702
|
+
// src/components/Overlay.tsx
|
|
1696
1703
|
var import_react8 = require("react");
|
|
1704
|
+
var import_react_dom2 = require("react-dom");
|
|
1705
|
+
var bodyLockCount = 0;
|
|
1706
|
+
var previousBodyOverflow = "";
|
|
1707
|
+
var overlayStack = [];
|
|
1708
|
+
function lockBodyScroll() {
|
|
1709
|
+
if (bodyLockCount === 0) {
|
|
1710
|
+
previousBodyOverflow = document.body.style.overflow;
|
|
1711
|
+
document.body.style.overflow = "hidden";
|
|
1712
|
+
}
|
|
1713
|
+
bodyLockCount += 1;
|
|
1714
|
+
return () => {
|
|
1715
|
+
bodyLockCount = Math.max(0, bodyLockCount - 1);
|
|
1716
|
+
if (bodyLockCount === 0) document.body.style.overflow = previousBodyOverflow;
|
|
1717
|
+
};
|
|
1718
|
+
}
|
|
1719
|
+
function focusableElements(container) {
|
|
1720
|
+
return [...container.querySelectorAll(
|
|
1721
|
+
'a[href], button:not([disabled]), input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])'
|
|
1722
|
+
)].filter((element) => !element.hidden && element.getAttribute("aria-hidden") !== "true");
|
|
1723
|
+
}
|
|
1724
|
+
function useOverlayLifecycle(open, panelRef, onRequestClose, keyboard = true) {
|
|
1725
|
+
const overlayIdRef = (0, import_react8.useRef)(/* @__PURE__ */ Symbol("sia-overlay"));
|
|
1726
|
+
const closeRef = (0, import_react8.useRef)(onRequestClose);
|
|
1727
|
+
closeRef.current = onRequestClose;
|
|
1728
|
+
(0, import_react8.useEffect)(() => {
|
|
1729
|
+
if (!open || typeof document === "undefined") return void 0;
|
|
1730
|
+
const overlayId = overlayIdRef.current;
|
|
1731
|
+
const previouslyFocused = document.activeElement instanceof HTMLElement ? document.activeElement : null;
|
|
1732
|
+
overlayStack.push(overlayId);
|
|
1733
|
+
const unlockBody = lockBodyScroll();
|
|
1734
|
+
const focusTimer = window.setTimeout(() => {
|
|
1735
|
+
const panel = panelRef.current;
|
|
1736
|
+
if (!panel) return;
|
|
1737
|
+
const [firstFocusable] = focusableElements(panel);
|
|
1738
|
+
(firstFocusable ?? panel).focus({ preventScroll: true });
|
|
1739
|
+
}, 0);
|
|
1740
|
+
function handleKeyDown(event) {
|
|
1741
|
+
if (overlayStack.at(-1) !== overlayId) return;
|
|
1742
|
+
if (event.key === "Escape" && keyboard) {
|
|
1743
|
+
event.preventDefault();
|
|
1744
|
+
closeRef.current();
|
|
1745
|
+
return;
|
|
1746
|
+
}
|
|
1747
|
+
if (event.key !== "Tab" || !panelRef.current) return;
|
|
1748
|
+
const focusable = focusableElements(panelRef.current);
|
|
1749
|
+
if (focusable.length === 0) {
|
|
1750
|
+
event.preventDefault();
|
|
1751
|
+
panelRef.current.focus();
|
|
1752
|
+
return;
|
|
1753
|
+
}
|
|
1754
|
+
const first = focusable[0];
|
|
1755
|
+
const last = focusable.at(-1);
|
|
1756
|
+
if (event.shiftKey && document.activeElement === first) {
|
|
1757
|
+
event.preventDefault();
|
|
1758
|
+
last.focus();
|
|
1759
|
+
} else if (!event.shiftKey && document.activeElement === last) {
|
|
1760
|
+
event.preventDefault();
|
|
1761
|
+
first.focus();
|
|
1762
|
+
}
|
|
1763
|
+
}
|
|
1764
|
+
document.addEventListener("keydown", handleKeyDown);
|
|
1765
|
+
return () => {
|
|
1766
|
+
window.clearTimeout(focusTimer);
|
|
1767
|
+
document.removeEventListener("keydown", handleKeyDown);
|
|
1768
|
+
const index = overlayStack.lastIndexOf(overlayId);
|
|
1769
|
+
if (index >= 0) overlayStack.splice(index, 1);
|
|
1770
|
+
unlockBody();
|
|
1771
|
+
previouslyFocused?.focus({ preventScroll: true });
|
|
1772
|
+
};
|
|
1773
|
+
}, [keyboard, open, panelRef]);
|
|
1774
|
+
}
|
|
1775
|
+
function OverlayPortal({ children, container }) {
|
|
1776
|
+
if (typeof document === "undefined") return null;
|
|
1777
|
+
const target = typeof container === "function" ? container() : container ?? document.body;
|
|
1778
|
+
return (0, import_react_dom2.createPortal)(children, target);
|
|
1779
|
+
}
|
|
1780
|
+
|
|
1781
|
+
// src/components/Modal.tsx
|
|
1697
1782
|
var import_jsx_runtime9 = require("react/jsx-runtime");
|
|
1698
|
-
var
|
|
1783
|
+
var modalHandles = /* @__PURE__ */ new Set();
|
|
1784
|
+
var MODAL_MOTION_DURATION = 220;
|
|
1785
|
+
var typeIcons = {
|
|
1786
|
+
info: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(Icon, { name: "info", size: 23 }),
|
|
1787
|
+
success: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(Icon, { name: "circle-check", size: 23 }),
|
|
1788
|
+
warning: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(Icon, { name: "warning", size: 23 }),
|
|
1789
|
+
error: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(Icon, { name: "circle-close", size: 23 }),
|
|
1790
|
+
confirm: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(Icon, { name: "question", size: 23 })
|
|
1791
|
+
};
|
|
1792
|
+
var ModalRoot = (0, import_react9.forwardRef)(function Modal({
|
|
1793
|
+
open,
|
|
1794
|
+
title,
|
|
1795
|
+
children,
|
|
1796
|
+
footer,
|
|
1797
|
+
footerExtra,
|
|
1798
|
+
type = "default",
|
|
1799
|
+
okText = "\u786E\u5B9A",
|
|
1800
|
+
cancelText = "\u53D6\u6D88",
|
|
1801
|
+
showCancel = type === "default" || type === "confirm",
|
|
1802
|
+
confirmLoading = false,
|
|
1803
|
+
okButtonProps,
|
|
1804
|
+
cancelButtonProps,
|
|
1805
|
+
closable = true,
|
|
1806
|
+
maskClosable = true,
|
|
1807
|
+
keyboard = true,
|
|
1808
|
+
centered = false,
|
|
1809
|
+
width = 520,
|
|
1810
|
+
height,
|
|
1811
|
+
zIndex = 1e3,
|
|
1812
|
+
getContainer,
|
|
1813
|
+
onOk,
|
|
1814
|
+
onCancel,
|
|
1815
|
+
onOpenChange,
|
|
1816
|
+
afterOpenChange,
|
|
1817
|
+
className = "",
|
|
1818
|
+
style,
|
|
1819
|
+
...props
|
|
1820
|
+
}, forwardedRef) {
|
|
1821
|
+
const localRef = (0, import_react9.useRef)(null);
|
|
1822
|
+
const titleId = (0, import_react9.useId)();
|
|
1823
|
+
const [submitting, setSubmitting] = (0, import_react9.useState)(false);
|
|
1824
|
+
const [rendered, setRendered] = (0, import_react9.useState)(open);
|
|
1825
|
+
const [closing, setClosing] = (0, import_react9.useState)(false);
|
|
1826
|
+
const afterOpenChangeRef = (0, import_react9.useRef)(afterOpenChange);
|
|
1827
|
+
afterOpenChangeRef.current = afterOpenChange;
|
|
1828
|
+
const submitLock = (0, import_react9.useRef)(false);
|
|
1829
|
+
(0, import_react9.useEffect)(() => {
|
|
1830
|
+
if (!open || !rendered) return void 0;
|
|
1831
|
+
const timer = window.setTimeout(() => afterOpenChangeRef.current?.(true), MODAL_MOTION_DURATION);
|
|
1832
|
+
return () => window.clearTimeout(timer);
|
|
1833
|
+
}, [open, rendered]);
|
|
1834
|
+
(0, import_react9.useEffect)(() => {
|
|
1835
|
+
if (open) {
|
|
1836
|
+
setRendered(true);
|
|
1837
|
+
setClosing(false);
|
|
1838
|
+
return void 0;
|
|
1839
|
+
}
|
|
1840
|
+
if (!rendered) return void 0;
|
|
1841
|
+
setClosing(true);
|
|
1842
|
+
const timer = window.setTimeout(() => {
|
|
1843
|
+
setRendered(false);
|
|
1844
|
+
setClosing(false);
|
|
1845
|
+
afterOpenChangeRef.current?.(false);
|
|
1846
|
+
}, MODAL_MOTION_DURATION);
|
|
1847
|
+
return () => window.clearTimeout(timer);
|
|
1848
|
+
}, [open, rendered]);
|
|
1849
|
+
function setRef(node) {
|
|
1850
|
+
localRef.current = node;
|
|
1851
|
+
if (typeof forwardedRef === "function") forwardedRef(node);
|
|
1852
|
+
else if (forwardedRef) forwardedRef.current = node;
|
|
1853
|
+
}
|
|
1854
|
+
function requestClose() {
|
|
1855
|
+
if (submitting || confirmLoading) return;
|
|
1856
|
+
onCancel?.();
|
|
1857
|
+
onOpenChange?.(false);
|
|
1858
|
+
}
|
|
1859
|
+
async function handleOk() {
|
|
1860
|
+
if (submitLock.current || confirmLoading) return;
|
|
1861
|
+
submitLock.current = true;
|
|
1862
|
+
if (!onOk) {
|
|
1863
|
+
onOpenChange?.(false);
|
|
1864
|
+
submitLock.current = false;
|
|
1865
|
+
return;
|
|
1866
|
+
}
|
|
1867
|
+
try {
|
|
1868
|
+
const result = onOk();
|
|
1869
|
+
if (result instanceof Promise) {
|
|
1870
|
+
setSubmitting(true);
|
|
1871
|
+
const resolved = await result;
|
|
1872
|
+
if (resolved !== false) onOpenChange?.(false);
|
|
1873
|
+
} else if (result !== false) {
|
|
1874
|
+
onOpenChange?.(false);
|
|
1875
|
+
}
|
|
1876
|
+
} catch {
|
|
1877
|
+
return;
|
|
1878
|
+
} finally {
|
|
1879
|
+
submitLock.current = false;
|
|
1880
|
+
setSubmitting(false);
|
|
1881
|
+
}
|
|
1882
|
+
}
|
|
1883
|
+
useOverlayLifecycle(rendered, localRef, requestClose, keyboard);
|
|
1884
|
+
if (!rendered) return null;
|
|
1885
|
+
const mergedStyle = {
|
|
1886
|
+
...height !== void 0 ? { display: "flex", flexDirection: "column", height, maxHeight: "calc(100dvh - 48px)" } : {},
|
|
1887
|
+
...style,
|
|
1888
|
+
"--sia-modal-width": typeof width === "number" ? `${width}px` : width
|
|
1889
|
+
};
|
|
1890
|
+
const loading = submitting || confirmLoading;
|
|
1891
|
+
const defaultFooter = /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(import_jsx_runtime9.Fragment, { children: [
|
|
1892
|
+
showCancel ? /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(Button, { ...cancelButtonProps, onClick: requestClose, disabled: loading || cancelButtonProps?.disabled, children: cancelText }) : null,
|
|
1893
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)(Button, { variant: "primary", ...okButtonProps, onClick: handleOk, loading, children: okText })
|
|
1894
|
+
] });
|
|
1895
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(OverlayPortal, { container: getContainer, children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
1896
|
+
"div",
|
|
1897
|
+
{
|
|
1898
|
+
className: `sia-modal-root${centered ? " sia-modal-root--centered" : ""}`,
|
|
1899
|
+
"data-state": closing ? "closing" : "open",
|
|
1900
|
+
style: { zIndex },
|
|
1901
|
+
onMouseDown: (event) => {
|
|
1902
|
+
if (event.target === event.currentTarget && maskClosable) requestClose();
|
|
1903
|
+
},
|
|
1904
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(
|
|
1905
|
+
"div",
|
|
1906
|
+
{
|
|
1907
|
+
ref: setRef,
|
|
1908
|
+
className: `sia-modal sia-modal--${type} ${className}`.trim(),
|
|
1909
|
+
style: mergedStyle,
|
|
1910
|
+
role: "dialog",
|
|
1911
|
+
"aria-modal": "true",
|
|
1912
|
+
"aria-labelledby": title ? titleId : void 0,
|
|
1913
|
+
tabIndex: -1,
|
|
1914
|
+
...withTitleTooltip(props),
|
|
1915
|
+
children: [
|
|
1916
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "sia-modal__header", style: height !== void 0 ? { flexShrink: 0 } : void 0, children: [
|
|
1917
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "sia-modal__heading", children: [
|
|
1918
|
+
typeIcons[type] ? /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("span", { className: "sia-modal__type-icon", "aria-hidden": "true", children: typeIcons[type] }) : null,
|
|
1919
|
+
title ? /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("strong", { id: titleId, children: title }) : null
|
|
1920
|
+
] }),
|
|
1921
|
+
closable ? /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("button", { type: "button", className: "sia-modal__close", "aria-label": "\u5173\u95ED\u5BF9\u8BDD\u6846", onClick: requestClose, children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(Icon, { name: "close", size: 17 }) }) : null
|
|
1922
|
+
] }),
|
|
1923
|
+
children !== void 0 ? /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: "sia-modal__body", style: height !== void 0 ? { flex: 1, minHeight: 0, overflow: "auto" } : void 0, children }) : null,
|
|
1924
|
+
footer !== null ? /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "sia-modal__footer", style: height !== void 0 ? { flexShrink: 0 } : void 0, children: [
|
|
1925
|
+
footer === void 0 && footerExtra != null ? /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { style: { marginRight: "auto" }, children: footerExtra }) : null,
|
|
1926
|
+
footer ?? defaultFooter
|
|
1927
|
+
] }) : null
|
|
1928
|
+
]
|
|
1929
|
+
}
|
|
1930
|
+
)
|
|
1931
|
+
}
|
|
1932
|
+
) });
|
|
1933
|
+
});
|
|
1934
|
+
function openModal(config) {
|
|
1935
|
+
if (typeof document === "undefined") return { destroy() {
|
|
1936
|
+
}, update() {
|
|
1937
|
+
} };
|
|
1938
|
+
const container = document.createElement("div");
|
|
1939
|
+
container.className = "sia-modal-api-host";
|
|
1940
|
+
document.body.appendChild(container);
|
|
1941
|
+
const root = (0, import_client2.createRoot)(container);
|
|
1942
|
+
let currentConfig = config;
|
|
1943
|
+
let currentOpen = true;
|
|
1944
|
+
let destroyed = false;
|
|
1945
|
+
let mounted = false;
|
|
1946
|
+
function cleanup() {
|
|
1947
|
+
if (destroyed) return;
|
|
1948
|
+
destroyed = true;
|
|
1949
|
+
root.unmount();
|
|
1950
|
+
container.remove();
|
|
1951
|
+
modalHandles.delete(handle);
|
|
1952
|
+
}
|
|
1953
|
+
function closeWithMotion() {
|
|
1954
|
+
if (destroyed || !currentOpen) return;
|
|
1955
|
+
currentOpen = false;
|
|
1956
|
+
render();
|
|
1957
|
+
}
|
|
1958
|
+
function ModalInstance() {
|
|
1959
|
+
(0, import_react9.useEffect)(() => {
|
|
1960
|
+
mounted = true;
|
|
1961
|
+
if (!currentOpen) render();
|
|
1962
|
+
}, []);
|
|
1963
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(ModalRoot, { ...currentConfig, open: !mounted || currentOpen, onOpenChange: (nextOpen) => {
|
|
1964
|
+
currentConfig.onOpenChange?.(nextOpen);
|
|
1965
|
+
if (!nextOpen) closeWithMotion();
|
|
1966
|
+
}, afterOpenChange: (nextOpen) => {
|
|
1967
|
+
try {
|
|
1968
|
+
currentConfig.afterOpenChange?.(nextOpen);
|
|
1969
|
+
} finally {
|
|
1970
|
+
if (!nextOpen) queueMicrotask(cleanup);
|
|
1971
|
+
}
|
|
1972
|
+
} });
|
|
1973
|
+
}
|
|
1974
|
+
function render() {
|
|
1975
|
+
root.render(/* @__PURE__ */ (0, import_jsx_runtime9.jsx)(ModalInstance, {}));
|
|
1976
|
+
}
|
|
1977
|
+
const handle = {
|
|
1978
|
+
destroy: closeWithMotion,
|
|
1979
|
+
update(next) {
|
|
1980
|
+
if (destroyed) return;
|
|
1981
|
+
currentConfig = { ...currentConfig, ...next };
|
|
1982
|
+
render();
|
|
1983
|
+
}
|
|
1984
|
+
};
|
|
1985
|
+
modalHandles.add(handle);
|
|
1986
|
+
render();
|
|
1987
|
+
return handle;
|
|
1988
|
+
}
|
|
1989
|
+
function preset(type, defaults = {}) {
|
|
1990
|
+
return (config) => openModal({
|
|
1991
|
+
okText: type === "confirm" ? "\u786E\u5B9A" : "\u77E5\u9053\u4E86",
|
|
1992
|
+
showCancel: type === "confirm",
|
|
1993
|
+
closable: type !== "confirm",
|
|
1994
|
+
maskClosable: type !== "confirm",
|
|
1995
|
+
...defaults,
|
|
1996
|
+
...config,
|
|
1997
|
+
type
|
|
1998
|
+
});
|
|
1999
|
+
}
|
|
2000
|
+
var Modal2 = Object.assign(ModalRoot, {
|
|
2001
|
+
/** 直接打开实例,返回更新和关闭句柄;关闭动画完成后先调用 afterOpenChange(false),再卸载实例。 */
|
|
2002
|
+
open: openModal,
|
|
2003
|
+
/** 显示普通信息提示。 */
|
|
2004
|
+
info: preset("info", { title: "\u63D0\u793A" }),
|
|
2005
|
+
/** 显示成功提示。 */
|
|
2006
|
+
success: preset("success", { title: "\u64CD\u4F5C\u6210\u529F" }),
|
|
2007
|
+
/** 显示警告提示。 */
|
|
2008
|
+
warning: preset("warning", { title: "\u8BF7\u6CE8\u610F" }),
|
|
2009
|
+
/** 显示错误提示。 */
|
|
2010
|
+
error: preset("error", { title: "\u64CD\u4F5C\u5931\u8D25" }),
|
|
2011
|
+
/** 打开确认弹框,支持异步确认;返回 false 可阻止关闭。 */
|
|
2012
|
+
confirm: preset("confirm", { title: "\u786E\u8BA4\u64CD\u4F5C" }),
|
|
2013
|
+
/** 关闭由此 API 打开的所有弹层。 */
|
|
2014
|
+
destroyAll() {
|
|
2015
|
+
[...modalHandles].forEach((handle) => handle.destroy());
|
|
2016
|
+
}
|
|
2017
|
+
});
|
|
2018
|
+
|
|
2019
|
+
// src/components/TextArea.tsx
|
|
2020
|
+
var import_react10 = require("react");
|
|
2021
|
+
var import_jsx_runtime10 = require("react/jsx-runtime");
|
|
2022
|
+
var TextArea = (0, import_react10.forwardRef)(function TextArea2({
|
|
2023
|
+
label,
|
|
2024
|
+
hint,
|
|
2025
|
+
status = "default",
|
|
2026
|
+
size: sizeProp,
|
|
2027
|
+
showCount = false,
|
|
2028
|
+
placeholder,
|
|
2029
|
+
placeholderMode,
|
|
2030
|
+
className = "",
|
|
2031
|
+
id,
|
|
2032
|
+
disabled,
|
|
2033
|
+
value,
|
|
2034
|
+
defaultValue,
|
|
2035
|
+
maxLength,
|
|
2036
|
+
onChange,
|
|
2037
|
+
...props
|
|
2038
|
+
}, ref) {
|
|
2039
|
+
const size = useControlSize(sizeProp);
|
|
2040
|
+
const fallbackId = (0, import_react10.useId)();
|
|
2041
|
+
const textAreaId = id ?? fallbackId;
|
|
2042
|
+
const [uncontrolledValue, setUncontrolledValue] = (0, import_react10.useState)(() => defaultValue === void 0 ? "" : String(defaultValue));
|
|
2043
|
+
const currentText = value !== void 0 ? String(value) : uncontrolledValue;
|
|
2044
|
+
const floating = useFloatingPlaceholder({ mode: placeholderMode, placeholder, filled: currentText.length > 0 });
|
|
2045
|
+
const hintId = `${textAreaId}-hint`;
|
|
2046
|
+
const describedBy = [props["aria-describedby"], hint ? hintId : null].filter(Boolean).join(" ") || void 0;
|
|
2047
|
+
function handleChange(event) {
|
|
2048
|
+
setUncontrolledValue(event.target.value);
|
|
2049
|
+
onChange?.(event);
|
|
2050
|
+
}
|
|
2051
|
+
const control = /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("span", { className: `sia-textarea-control sia-textarea-control--${size} sia-textarea-control--${status}${floating.className}${disabled ? " is-disabled" : ""}`, children: [
|
|
2052
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
2053
|
+
"textarea",
|
|
2054
|
+
{
|
|
2055
|
+
...withTitleTooltip(props),
|
|
2056
|
+
ref,
|
|
2057
|
+
id: textAreaId,
|
|
2058
|
+
className: "sia-textarea",
|
|
2059
|
+
disabled,
|
|
2060
|
+
value,
|
|
2061
|
+
defaultValue,
|
|
2062
|
+
maxLength,
|
|
2063
|
+
placeholder,
|
|
2064
|
+
"aria-describedby": describedBy,
|
|
2065
|
+
"aria-invalid": status === "error" || void 0,
|
|
2066
|
+
onChange: handleChange
|
|
2067
|
+
}
|
|
2068
|
+
),
|
|
2069
|
+
floating.label,
|
|
2070
|
+
showCount ? /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("span", { className: `sia-textarea-control__count${maxLength !== void 0 && currentText.length >= maxLength ? " is-limit" : ""}`, "aria-live": "polite", children: [
|
|
2071
|
+
currentText.length,
|
|
2072
|
+
maxLength !== void 0 ? `/${maxLength}` : null
|
|
2073
|
+
] }) : null
|
|
2074
|
+
] });
|
|
2075
|
+
if (!label && !hint) return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("span", { className: `sia-field ${className}`.trim(), children: control });
|
|
2076
|
+
return /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("span", { className: `sia-field ${className}`.trim(), children: [
|
|
2077
|
+
label ? /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("label", { className: "sia-field__label", htmlFor: textAreaId, children: label }) : null,
|
|
2078
|
+
control,
|
|
2079
|
+
hint ? /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("span", { id: hintId, className: `sia-field__hint sia-field__hint--${status}`, children: hint }) : null
|
|
2080
|
+
] });
|
|
2081
|
+
});
|
|
2082
|
+
|
|
2083
|
+
// src/components/Input.tsx
|
|
2084
|
+
var import_jsx_runtime11 = require("react/jsx-runtime");
|
|
2085
|
+
var Input = (0, import_react11.forwardRef)(function Input2({
|
|
1699
2086
|
label,
|
|
1700
2087
|
hint,
|
|
1701
2088
|
status = "default",
|
|
@@ -1714,15 +2101,18 @@ var Input = (0, import_react8.forwardRef)(function Input2({
|
|
|
1714
2101
|
defaultValue,
|
|
1715
2102
|
maxLength,
|
|
1716
2103
|
onChange,
|
|
2104
|
+
expandable = false,
|
|
1717
2105
|
...props
|
|
1718
2106
|
}, forwardedRef) {
|
|
1719
2107
|
const size = useControlSize(sizeProp);
|
|
1720
|
-
const fallbackId = (0,
|
|
2108
|
+
const fallbackId = (0, import_react11.useId)();
|
|
1721
2109
|
const inputId = id ?? fallbackId;
|
|
1722
|
-
const localRef = (0,
|
|
1723
|
-
const [uncontrolledValue, setUncontrolledValue] = (0,
|
|
2110
|
+
const localRef = (0, import_react11.useRef)(null);
|
|
2111
|
+
const [uncontrolledValue, setUncontrolledValue] = (0, import_react11.useState)(() => defaultValue === void 0 ? "" : String(defaultValue));
|
|
1724
2112
|
const currentText = value !== void 0 ? String(value) : uncontrolledValue;
|
|
1725
2113
|
const hasValue = currentText.length > 0;
|
|
2114
|
+
const [expanded, setExpanded] = (0, import_react11.useState)(false);
|
|
2115
|
+
const [expandedDraft, setExpandedDraft] = (0, import_react11.useState)("");
|
|
1726
2116
|
const floatingPlaceholder = usePlaceholderMode(placeholderMode) === "floating" && Boolean(placeholder);
|
|
1727
2117
|
const hintId = `${inputId}-hint`;
|
|
1728
2118
|
const describedBy = [props["aria-describedby"], hint ? hintId : null].filter(Boolean).join(" ") || void 0;
|
|
@@ -1758,7 +2148,7 @@ var Input = (0, import_react8.forwardRef)(function Input2({
|
|
|
1758
2148
|
event.preventDefault();
|
|
1759
2149
|
localRef.current?.focus({ preventScroll: true });
|
|
1760
2150
|
}
|
|
1761
|
-
const input = /* @__PURE__ */ (0,
|
|
2151
|
+
const input = /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
|
|
1762
2152
|
"input",
|
|
1763
2153
|
{
|
|
1764
2154
|
...withTitleTooltip(props),
|
|
@@ -1775,29 +2165,87 @@ var Input = (0, import_react8.forwardRef)(function Input2({
|
|
|
1775
2165
|
onChange: handleChange
|
|
1776
2166
|
}
|
|
1777
2167
|
);
|
|
1778
|
-
const control = /* @__PURE__ */ (0,
|
|
1779
|
-
prefix ? /* @__PURE__ */ (0,
|
|
1780
|
-
floatingPlaceholder ? /* @__PURE__ */ (0,
|
|
2168
|
+
const control = /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("span", { onMouseDown: handleControlMouseDown, className: `sia-input-control sia-input-control--${size} sia-input-control--${status}${floatingPlaceholder ? " sia-input-control--floating" : ""}${floatingPlaceholder && hasValue ? " is-filled" : ""}${disabled ? " is-disabled" : ""}`, children: [
|
|
2169
|
+
prefix ? /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("span", { className: "sia-input-control__affix", children: prefix }) : null,
|
|
2170
|
+
floatingPlaceholder ? /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("span", { className: "sia-input-control__input-wrap", children: [
|
|
1781
2171
|
input,
|
|
1782
|
-
/* @__PURE__ */ (0,
|
|
2172
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)("span", { className: "sia-input-control__floating-placeholder", "aria-hidden": "true", children: placeholder })
|
|
1783
2173
|
] }) : input,
|
|
1784
|
-
allowClear && hasValue && !disabled ? /* @__PURE__ */ (0,
|
|
1785
|
-
suffix ? /* @__PURE__ */ (0,
|
|
1786
|
-
|
|
2174
|
+
allowClear && hasValue && !disabled ? /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("button", { className: "sia-input-control__clear", type: "button", "aria-label": "\u6E05\u7A7A\u8F93\u5165", onClick: clearValue, children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(Icon, { name: "circle-close", variant: "filled", size: 15 }) }) : null,
|
|
2175
|
+
suffix ? /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("span", { className: "sia-input-control__affix", children: suffix }) : null,
|
|
2176
|
+
expandable && !disabled && !props.readOnly && (!props.type || props.type === "text") ? /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
|
|
2177
|
+
"button",
|
|
2178
|
+
{
|
|
2179
|
+
type: "button",
|
|
2180
|
+
className: "sia-input-control__expand",
|
|
2181
|
+
"aria-label": "\u5C55\u5F00\u7F16\u8F91",
|
|
2182
|
+
title: "\u5C55\u5F00\u7F16\u8F91",
|
|
2183
|
+
onClick: () => {
|
|
2184
|
+
if (localRef.current?.matches(":disabled")) return;
|
|
2185
|
+
setExpandedDraft(currentText);
|
|
2186
|
+
setExpanded(true);
|
|
2187
|
+
},
|
|
2188
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(Icon, { name: "expand", size: 15 })
|
|
2189
|
+
}
|
|
2190
|
+
) : null,
|
|
2191
|
+
showCount ? /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("span", { className: `sia-input-control__count${maxLength !== void 0 && currentText.length >= maxLength ? " is-limit" : ""}`, "aria-live": "polite", children: [
|
|
1787
2192
|
currentText.length,
|
|
1788
2193
|
maxLength !== void 0 ? `/${maxLength}` : null
|
|
1789
2194
|
] }) : null
|
|
1790
2195
|
] });
|
|
1791
|
-
|
|
1792
|
-
|
|
1793
|
-
|
|
1794
|
-
|
|
1795
|
-
|
|
2196
|
+
const editor = expandable ? /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
|
|
2197
|
+
Modal2,
|
|
2198
|
+
{
|
|
2199
|
+
open: expanded,
|
|
2200
|
+
title: "\u5C55\u5F00\u7F16\u8F91",
|
|
2201
|
+
okText: "\u786E\u5B9A",
|
|
2202
|
+
cancelText: "\u53D6\u6D88",
|
|
2203
|
+
onCancel: () => setExpanded(false),
|
|
2204
|
+
afterOpenChange: (open) => {
|
|
2205
|
+
if (!open) setExpandedDraft("");
|
|
2206
|
+
},
|
|
2207
|
+
onOk: () => {
|
|
2208
|
+
const target = localRef.current;
|
|
2209
|
+
if (!target || target.matches(":disabled") || props.readOnly) return false;
|
|
2210
|
+
const normalized = expandedDraft.replace(/\r\n|[\r\n]/g, " ");
|
|
2211
|
+
const next = maxLength !== void 0 && maxLength >= 0 ? normalized.slice(0, maxLength) : normalized;
|
|
2212
|
+
Object.getOwnPropertyDescriptor(HTMLInputElement.prototype, "value")?.set?.call(target, next);
|
|
2213
|
+
target.dispatchEvent(new Event("input", { bubbles: true }));
|
|
2214
|
+
setUncontrolledValue(next);
|
|
2215
|
+
setExpanded(false);
|
|
2216
|
+
},
|
|
2217
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
|
|
2218
|
+
TextArea,
|
|
2219
|
+
{
|
|
2220
|
+
"aria-label": "\u5C55\u5F00\u7F16\u8F91\u5185\u5BB9",
|
|
2221
|
+
value: expandedDraft,
|
|
2222
|
+
onChange: (event) => setExpandedDraft(event.target.value),
|
|
2223
|
+
maxLength,
|
|
2224
|
+
showCount,
|
|
2225
|
+
placeholder,
|
|
2226
|
+
rows: 8,
|
|
2227
|
+
disabled,
|
|
2228
|
+
readOnly: props.readOnly
|
|
2229
|
+
}
|
|
2230
|
+
)
|
|
2231
|
+
}
|
|
2232
|
+
) : null;
|
|
2233
|
+
if (!label && !hint) return /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(import_jsx_runtime11.Fragment, { children: [
|
|
2234
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)("span", { className: `sia-field ${className}`.trim(), children: control }),
|
|
2235
|
+
editor
|
|
2236
|
+
] });
|
|
2237
|
+
return /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(import_jsx_runtime11.Fragment, { children: [
|
|
2238
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("span", { className: `sia-field ${className}`.trim(), children: [
|
|
2239
|
+
label ? /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("label", { className: "sia-field__label", htmlFor: inputId, children: label }) : null,
|
|
2240
|
+
control,
|
|
2241
|
+
hint ? /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("span", { id: hintId, className: `sia-field__hint sia-field__hint--${status}`, children: hint }) : null
|
|
2242
|
+
] }),
|
|
2243
|
+
editor
|
|
1796
2244
|
] });
|
|
1797
2245
|
});
|
|
1798
2246
|
|
|
1799
2247
|
// src/components/RichTextEditor.tsx
|
|
1800
|
-
var
|
|
2248
|
+
var import_jsx_runtime12 = require("react/jsx-runtime");
|
|
1801
2249
|
function escapeHtml(value) {
|
|
1802
2250
|
return value.replaceAll("&", "&").replaceAll("<", "<").replaceAll(">", ">").replaceAll('"', """).replaceAll("'", "'");
|
|
1803
2251
|
}
|
|
@@ -1813,9 +2261,9 @@ function sanitizeContent(value) {
|
|
|
1813
2261
|
}).replace(/<img\b/giu, '<img loading="lazy" decoding="async"');
|
|
1814
2262
|
}
|
|
1815
2263
|
function RichTextContent({ content, emptyText = "\u6682\u65E0\u5185\u5BB9", className = "", ...props }) {
|
|
1816
|
-
const html = (0,
|
|
1817
|
-
if (!html.trim()) return /* @__PURE__ */ (0,
|
|
1818
|
-
return /* @__PURE__ */ (0,
|
|
2264
|
+
const html = (0, import_react12.useMemo)(() => sanitizeContent(content), [content]);
|
|
2265
|
+
if (!html.trim()) return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { className: `sia-rich-text-content sia-rich-text-content--empty ${className}`.trim(), children: emptyText });
|
|
2266
|
+
return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("article", { className: `sia-rich-text-content ${className}`.trim(), dangerouslySetInnerHTML: { __html: html }, ...withTitleTooltip(props) });
|
|
1819
2267
|
}
|
|
1820
2268
|
function RichTextEditor({
|
|
1821
2269
|
value,
|
|
@@ -1836,31 +2284,31 @@ function RichTextEditor({
|
|
|
1836
2284
|
"aria-label": ariaLabel,
|
|
1837
2285
|
...props
|
|
1838
2286
|
}) {
|
|
1839
|
-
const initialValueRef = (0,
|
|
1840
|
-
const lastEmittedValueRef = (0,
|
|
1841
|
-
const onChangeRef = (0,
|
|
1842
|
-
const onPasteImageRef = (0,
|
|
1843
|
-
const saveShortcutRef = (0,
|
|
1844
|
-
const contentFormatRef = (0,
|
|
1845
|
-
const editorElementRef = (0,
|
|
1846
|
-
const editorRef = (0,
|
|
1847
|
-
const [editor, setEditor] = (0,
|
|
1848
|
-
const [linkEditorOpen, setLinkEditorOpen] = (0,
|
|
1849
|
-
const [linkHref, setLinkHref] = (0,
|
|
1850
|
-
const [, setEditorRevision] = (0,
|
|
1851
|
-
(0,
|
|
2287
|
+
const initialValueRef = (0, import_react12.useRef)(value ?? defaultValue);
|
|
2288
|
+
const lastEmittedValueRef = (0, import_react12.useRef)(value ?? defaultValue);
|
|
2289
|
+
const onChangeRef = (0, import_react12.useRef)(onChange);
|
|
2290
|
+
const onPasteImageRef = (0, import_react12.useRef)(onPasteImage);
|
|
2291
|
+
const saveShortcutRef = (0, import_react12.useRef)(saveShortcut);
|
|
2292
|
+
const contentFormatRef = (0, import_react12.useRef)(contentFormat);
|
|
2293
|
+
const editorElementRef = (0, import_react12.useRef)(null);
|
|
2294
|
+
const editorRef = (0, import_react12.useRef)(null);
|
|
2295
|
+
const [editor, setEditor] = (0, import_react12.useState)(null);
|
|
2296
|
+
const [linkEditorOpen, setLinkEditorOpen] = (0, import_react12.useState)(false);
|
|
2297
|
+
const [linkHref, setLinkHref] = (0, import_react12.useState)("");
|
|
2298
|
+
const [, setEditorRevision] = (0, import_react12.useState)(0);
|
|
2299
|
+
(0, import_react12.useEffect)(() => {
|
|
1852
2300
|
onChangeRef.current = onChange;
|
|
1853
2301
|
}, [onChange]);
|
|
1854
|
-
(0,
|
|
2302
|
+
(0, import_react12.useEffect)(() => {
|
|
1855
2303
|
onPasteImageRef.current = onPasteImage;
|
|
1856
2304
|
}, [onPasteImage]);
|
|
1857
|
-
(0,
|
|
2305
|
+
(0, import_react12.useEffect)(() => {
|
|
1858
2306
|
saveShortcutRef.current = saveShortcut;
|
|
1859
2307
|
}, [saveShortcut]);
|
|
1860
|
-
(0,
|
|
2308
|
+
(0, import_react12.useEffect)(() => {
|
|
1861
2309
|
contentFormatRef.current = contentFormat;
|
|
1862
2310
|
}, [contentFormat]);
|
|
1863
|
-
const extensions = (0,
|
|
2311
|
+
const extensions = (0, import_react12.useMemo)(() => [
|
|
1864
2312
|
import_starter_kit.default.configure({
|
|
1865
2313
|
heading: { levels: [1, 2, 3, 4, 5, 6] },
|
|
1866
2314
|
link: { openOnClick: false, autolink: true, linkOnPaste: true },
|
|
@@ -1876,7 +2324,7 @@ function RichTextEditor({
|
|
|
1876
2324
|
import_extension_task_item.default.configure({ nested: true }),
|
|
1877
2325
|
import_markdown.Markdown.configure({ markedOptions: { gfm: true } })
|
|
1878
2326
|
], [placeholder]);
|
|
1879
|
-
(0,
|
|
2327
|
+
(0, import_react12.useEffect)(() => {
|
|
1880
2328
|
const element = editorElementRef.current;
|
|
1881
2329
|
if (!element) return;
|
|
1882
2330
|
const nextEditor = new import_core.Editor({
|
|
@@ -1933,10 +2381,10 @@ function RichTextEditor({
|
|
|
1933
2381
|
nextEditor.destroy();
|
|
1934
2382
|
};
|
|
1935
2383
|
}, [ariaLabel, extensions]);
|
|
1936
|
-
(0,
|
|
2384
|
+
(0, import_react12.useEffect)(() => {
|
|
1937
2385
|
editor?.setEditable(!disabled);
|
|
1938
2386
|
}, [disabled, editor]);
|
|
1939
|
-
(0,
|
|
2387
|
+
(0, import_react12.useEffect)(() => {
|
|
1940
2388
|
if (!editor || value === void 0 || value === lastEmittedValueRef.current) return;
|
|
1941
2389
|
editor.commands.setContent(value, { emitUpdate: false, contentType: contentFormat });
|
|
1942
2390
|
lastEmittedValueRef.current = value;
|
|
@@ -1957,7 +2405,7 @@ function RichTextEditor({
|
|
|
1957
2405
|
setLinkEditorOpen(false);
|
|
1958
2406
|
}
|
|
1959
2407
|
function formatButton(label, action, active = false, disabledByState = false, content) {
|
|
1960
|
-
return /* @__PURE__ */ (0,
|
|
2408
|
+
return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
1961
2409
|
Button,
|
|
1962
2410
|
{
|
|
1963
2411
|
type: "button",
|
|
@@ -1995,27 +2443,27 @@ function RichTextEditor({
|
|
|
1995
2443
|
}
|
|
1996
2444
|
};
|
|
1997
2445
|
const floating = useFloatingPlaceholder({ mode: placeholderMode, placeholder, filled: editor ? !editor.isEmpty : Boolean(value ?? defaultValue) });
|
|
1998
|
-
return /* @__PURE__ */ (0,
|
|
2446
|
+
return /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("div", { ...withTitleTooltip(props), id, style: mergedStyle, className: `sia-rich-text-editor${floating.className}${disabled ? " is-disabled" : ""} sia-rich-text-editor--${toolbar} ${className}`.trim(), children: [
|
|
1999
2447
|
floating.label,
|
|
2000
|
-
/* @__PURE__ */ (0,
|
|
2001
|
-
/* @__PURE__ */ (0,
|
|
2002
|
-
toolbar === "full" ? /* @__PURE__ */ (0,
|
|
2003
|
-
formatButton("\u64A4\u9500", () => editor?.chain().focus().undo().run(), false, !editor?.can().undo(), /* @__PURE__ */ (0,
|
|
2004
|
-
formatButton("\u91CD\u505A", () => editor?.chain().focus().redo().run(), false, !editor?.can().redo(), /* @__PURE__ */ (0,
|
|
2005
|
-
/* @__PURE__ */ (0,
|
|
2006
|
-
/* @__PURE__ */ (0,
|
|
2448
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("div", { className: "sia-rich-text-editor__toolbar", "aria-label": "\u6587\u672C\u683C\u5F0F\u5DE5\u5177\u680F", children: [
|
|
2449
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("div", { className: "sia-rich-text-editor__toolbar-main", children: [
|
|
2450
|
+
toolbar === "full" ? /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(import_jsx_runtime12.Fragment, { children: [
|
|
2451
|
+
formatButton("\u64A4\u9500", () => editor?.chain().focus().undo().run(), false, !editor?.can().undo(), /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(Icon, { name: "undo" })),
|
|
2452
|
+
formatButton("\u91CD\u505A", () => editor?.chain().focus().redo().run(), false, !editor?.can().redo(), /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(Icon, { name: "redo" })),
|
|
2453
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("span", { className: "sia-rich-text-editor__divider" }),
|
|
2454
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)(Dropdown, { menu: blockTypeMenu, trigger: ["click"], placement: "bottomLeft", disabled: disabled || !editor, children: /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(Button, { type: "button", variant: "text", size: "small", className: "sia-rich-text-editor__block-type", disabled: disabled || !editor, "aria-label": "\u6BB5\u843D\u683C\u5F0F", title: "\u6BB5\u843D\u683C\u5F0F", onMouseDown: (event) => event.preventDefault(), children: [
|
|
2007
2455
|
currentBlockLabel,
|
|
2008
|
-
/* @__PURE__ */ (0,
|
|
2456
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)(Icon, { name: "chevron-down", size: 13 })
|
|
2009
2457
|
] }) }),
|
|
2010
|
-
/* @__PURE__ */ (0,
|
|
2458
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("span", { className: "sia-rich-text-editor__divider" })
|
|
2011
2459
|
] }) : null,
|
|
2012
|
-
formatButton("\u52A0\u7C97", () => editor?.chain().focus().toggleBold().run(), Boolean(editor?.isActive("bold")), false, /* @__PURE__ */ (0,
|
|
2013
|
-
formatButton("\u659C\u4F53", () => editor?.chain().focus().toggleItalic().run(), Boolean(editor?.isActive("italic")), false, /* @__PURE__ */ (0,
|
|
2014
|
-
toolbar === "full" ? /* @__PURE__ */ (0,
|
|
2015
|
-
formatButton("\u4E0B\u5212\u7EBF", () => editor?.chain().focus().toggleUnderline().run(), Boolean(editor?.isActive("underline")), false, /* @__PURE__ */ (0,
|
|
2016
|
-
formatButton("\u5220\u9664\u7EBF", () => editor?.chain().focus().toggleStrike().run(), Boolean(editor?.isActive("strike")), false, /* @__PURE__ */ (0,
|
|
2460
|
+
formatButton("\u52A0\u7C97", () => editor?.chain().focus().toggleBold().run(), Boolean(editor?.isActive("bold")), false, /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("strong", { children: "B" })),
|
|
2461
|
+
formatButton("\u659C\u4F53", () => editor?.chain().focus().toggleItalic().run(), Boolean(editor?.isActive("italic")), false, /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("em", { children: "I" })),
|
|
2462
|
+
toolbar === "full" ? /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(import_jsx_runtime12.Fragment, { children: [
|
|
2463
|
+
formatButton("\u4E0B\u5212\u7EBF", () => editor?.chain().focus().toggleUnderline().run(), Boolean(editor?.isActive("underline")), false, /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("u", { children: "U" })),
|
|
2464
|
+
formatButton("\u5220\u9664\u7EBF", () => editor?.chain().focus().toggleStrike().run(), Boolean(editor?.isActive("strike")), false, /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("s", { children: "S" })),
|
|
2017
2465
|
formatButton("\u884C\u5185\u4EE3\u7801", () => editor?.chain().focus().toggleCode().run(), Boolean(editor?.isActive("code")), false, "</>"),
|
|
2018
|
-
/* @__PURE__ */ (0,
|
|
2466
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
2019
2467
|
Dropdown,
|
|
2020
2468
|
{
|
|
2021
2469
|
menu: { items: [] },
|
|
@@ -2025,48 +2473,48 @@ function RichTextEditor({
|
|
|
2025
2473
|
disabled: disabled || !editor,
|
|
2026
2474
|
onOpenChange: openLinkEditor,
|
|
2027
2475
|
popupClassName: "sia-rich-text-editor__link-popup",
|
|
2028
|
-
popupRender: () => /* @__PURE__ */ (0,
|
|
2029
|
-
/* @__PURE__ */ (0,
|
|
2030
|
-
/* @__PURE__ */ (0,
|
|
2031
|
-
editor?.isActive("link") ? /* @__PURE__ */ (0,
|
|
2476
|
+
popupRender: () => /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("form", { className: "sia-rich-text-editor__link-form", onSubmit: submitLink, children: [
|
|
2477
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)(Input, { autoFocus: true, "aria-label": "\u94FE\u63A5\u5730\u5740", value: linkHref, onChange: (event) => setLinkHref(event.target.value), placeholder: "https://example.com" }),
|
|
2478
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)(Button, { type: "submit", variant: "primary", size: "small", children: "\u5E94\u7528" }),
|
|
2479
|
+
editor?.isActive("link") ? /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(Button, { type: "button", size: "small", onClick: () => {
|
|
2032
2480
|
setLinkHref("");
|
|
2033
2481
|
editor.chain().focus().extendMarkRange("link").unsetLink().run();
|
|
2034
2482
|
setLinkEditorOpen(false);
|
|
2035
2483
|
}, children: "\u79FB\u9664" }) : null
|
|
2036
2484
|
] }),
|
|
2037
|
-
children: /* @__PURE__ */ (0,
|
|
2485
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(Button, { type: "button", variant: "text", size: "small", className: `sia-rich-text-editor__tool${editor?.isActive("link") ? " is-active" : ""}`, disabled: disabled || !editor, "aria-label": "\u94FE\u63A5", "aria-pressed": editor?.isActive("link") || void 0, title: "\u94FE\u63A5", onMouseDown: (event) => event.preventDefault(), children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(Icon, { name: "link" }) })
|
|
2038
2486
|
}
|
|
2039
2487
|
),
|
|
2040
|
-
/* @__PURE__ */ (0,
|
|
2488
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("span", { className: "sia-rich-text-editor__divider" })
|
|
2041
2489
|
] }) : null,
|
|
2042
2490
|
formatButton("\u65E0\u5E8F\u5217\u8868", () => editor?.chain().focus().toggleBulletList().run(), Boolean(editor?.isActive("bulletList")), false, "\u2022 \u5217\u8868"),
|
|
2043
2491
|
formatButton("\u6709\u5E8F\u5217\u8868", () => editor?.chain().focus().toggleOrderedList().run(), Boolean(editor?.isActive("orderedList")), false, "1. \u5217\u8868"),
|
|
2044
|
-
toolbar === "full" ? /* @__PURE__ */ (0,
|
|
2492
|
+
toolbar === "full" ? /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(import_jsx_runtime12.Fragment, { children: [
|
|
2045
2493
|
formatButton("\u4EFB\u52A1\u5217\u8868", () => editor?.chain().focus().toggleTaskList().run(), Boolean(editor?.isActive("taskList")), false, "\u2611 \u4EFB\u52A1"),
|
|
2046
2494
|
formatButton("\u5F15\u7528", () => editor?.chain().focus().toggleBlockquote().run(), Boolean(editor?.isActive("blockquote")), false, "\u275D \u5F15\u7528"),
|
|
2047
2495
|
formatButton("\u4EE3\u7801\u5757", () => editor?.chain().focus().toggleCodeBlock().run(), Boolean(editor?.isActive("codeBlock")), false, "\u4EE3\u7801\u5757"),
|
|
2048
2496
|
formatButton("\u63D2\u5165\u8868\u683C", () => editor?.chain().focus().insertTable({ rows: 3, cols: 3, withHeaderRow: true }).run(), Boolean(editor?.isActive("table")), false, "\u8868\u683C"),
|
|
2049
|
-
formatButton("\u5206\u5272\u7EBF", () => editor?.chain().focus().setHorizontalRule().run(), false, false, /* @__PURE__ */ (0,
|
|
2497
|
+
formatButton("\u5206\u5272\u7EBF", () => editor?.chain().focus().setHorizontalRule().run(), false, false, /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(Icon, { name: "minus" }))
|
|
2050
2498
|
] }) : null
|
|
2051
2499
|
] }),
|
|
2052
|
-
onPasteImage ? /* @__PURE__ */ (0,
|
|
2053
|
-
/* @__PURE__ */ (0,
|
|
2500
|
+
onPasteImage ? /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("small", { children: [
|
|
2501
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)(Icon, { name: "image", size: 14 }),
|
|
2054
2502
|
pasteImageHint
|
|
2055
2503
|
] }) : null
|
|
2056
2504
|
] }),
|
|
2057
|
-
toolbar === "full" && editor?.isActive("table") ? /* @__PURE__ */ (0,
|
|
2058
|
-
/* @__PURE__ */ (0,
|
|
2505
|
+
toolbar === "full" && editor?.isActive("table") ? /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("div", { className: "sia-rich-text-editor__table-toolbar", "aria-label": "\u8868\u683C\u5DE5\u5177\u680F", children: [
|
|
2506
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("span", { children: "\u8868\u683C" }),
|
|
2059
2507
|
formatButton("\u524D\u65B9\u63D2\u5165\u5217", () => editor.chain().focus().addColumnBefore().run(), false, !editor.can().addColumnBefore(), "\u524D\u63D2\u5217"),
|
|
2060
2508
|
formatButton("\u540E\u65B9\u63D2\u5165\u5217", () => editor.chain().focus().addColumnAfter().run(), false, !editor.can().addColumnAfter(), "\u540E\u63D2\u5217"),
|
|
2061
2509
|
formatButton("\u5220\u9664\u5F53\u524D\u5217", () => editor.chain().focus().deleteColumn().run(), false, !editor.can().deleteColumn(), "\u5220\u5217"),
|
|
2062
|
-
/* @__PURE__ */ (0,
|
|
2510
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("span", { className: "sia-rich-text-editor__divider" }),
|
|
2063
2511
|
formatButton("\u4E0A\u65B9\u63D2\u5165\u884C", () => editor.chain().focus().addRowBefore().run(), false, !editor.can().addRowBefore(), "\u4E0A\u63D2\u884C"),
|
|
2064
2512
|
formatButton("\u4E0B\u65B9\u63D2\u5165\u884C", () => editor.chain().focus().addRowAfter().run(), false, !editor.can().addRowAfter(), "\u4E0B\u63D2\u884C"),
|
|
2065
2513
|
formatButton("\u5220\u9664\u5F53\u524D\u884C", () => editor.chain().focus().deleteRow().run(), false, !editor.can().deleteRow(), "\u5220\u884C"),
|
|
2066
|
-
/* @__PURE__ */ (0,
|
|
2514
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("span", { className: "sia-rich-text-editor__divider" }),
|
|
2067
2515
|
formatButton("\u5220\u9664\u8868\u683C", () => editor.chain().focus().deleteTable().run(), false, !editor.can().deleteTable(), "\u5220\u9664\u8868\u683C")
|
|
2068
2516
|
] }) : null,
|
|
2069
|
-
/* @__PURE__ */ (0,
|
|
2517
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { ref: editorElementRef, className: "sia-rich-text-editor__content" })
|
|
2070
2518
|
] });
|
|
2071
2519
|
}
|
|
2072
2520
|
// Annotate the CommonJS export names for ESM import in node:
|