@sia.soul/sia-react-ui 0.1.106 → 0.1.108
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/Button-BiL3Wjsd.d.ts +44 -0
- package/dist/Button-O_pNB3SQ.d.cts +44 -0
- package/dist/{Select-DmT9pFRW.d.ts → Select-BddM4uXC.d.ts} +4 -42
- package/dist/{Select-DQpfyK7I.d.cts → Select-Cf0xz1Tg.d.cts} +4 -42
- package/dist/chart.js +5 -3
- package/dist/chunk-4TTHKFJ7.js +706 -0
- package/dist/chunk-CZ2ITBRW.js +65 -0
- package/dist/{chunk-EYB55TC5.js → chunk-D3HXXEEZ.js} +9 -5
- package/dist/{chunk-X4OLHWC3.js → chunk-GPCUD6FA.js} +23 -13
- package/dist/chunk-KY6A5IJH.js +18 -0
- package/dist/{chunk-NURPAO7G.js → chunk-MMSYWDTR.js} +9 -5
- package/dist/{chunk-PUZWLIIJ.js → chunk-NZMUW5XI.js} +1 -13
- package/dist/{chunk-D456SSL3.js → chunk-OJ2WDC66.js} +6 -4
- package/dist/{chunk-V6CRVCSB.js → chunk-QV3AP6A2.js} +40 -729
- package/dist/chunk-RX242MUO.js +0 -0
- package/dist/chunk-SCEHVGKV.js +75 -0
- package/dist/{chunk-TUXNOSCT.js → chunk-SO7IJZIR.js} +4 -2
- package/dist/{chunk-T3EGAN7O.js → chunk-WD56MJO2.js} +5 -3
- package/dist/{core-DF7gei-P.d.cts → core-KJBvQlUc.d.cts} +12 -3
- package/dist/{core-_1K1jLyH.d.ts → core-OuydQbFN.d.ts} +12 -3
- package/dist/core.cjs +15 -7
- package/dist/core.css +42 -0
- package/dist/core.d.cts +3 -2
- package/dist/core.d.ts +3 -2
- package/dist/core.js +12 -7
- package/dist/game.cjs +2815 -0
- package/dist/game.css +8929 -0
- package/dist/game.d.cts +439 -0
- package/dist/game.d.ts +439 -0
- package/dist/game.js +1034 -0
- package/dist/index.cjs +5528 -5464
- package/dist/index.css +82 -0
- package/dist/index.d.cts +45 -10
- package/dist/index.d.ts +45 -10
- package/dist/index.js +718 -656
- package/dist/markdown-editor.js +3 -2
- package/dist/rich-text-editor.cjs +3 -1
- package/dist/rich-text-editor.js +7 -4
- package/dist/{select-date-range-BT71tp7y.d.cts → select-date-range-Cm5o2xPp.d.cts} +1 -1
- package/dist/{select-date-range-CFGzoyLs.d.ts → select-date-range-yGDEA1RP.d.ts} +1 -1
- package/dist/select-date-range.d.cts +3 -2
- package/dist/select-date-range.d.ts +3 -2
- package/dist/select-date-range.js +8 -5
- package/package.json +9 -3
- package/dist/chunk-SJFT5OSX.js +0 -131
|
@@ -1,14 +1,9 @@
|
|
|
1
1
|
import {
|
|
2
|
-
Button
|
|
3
|
-
|
|
4
|
-
} from "./chunk-SJFT5OSX.js";
|
|
2
|
+
Button
|
|
3
|
+
} from "./chunk-CZ2ITBRW.js";
|
|
5
4
|
import {
|
|
6
|
-
PopupPortal,
|
|
7
|
-
useControlSize,
|
|
8
|
-
useControllableState,
|
|
9
|
-
usePlaceholderMode,
|
|
10
5
|
withTitleTooltip
|
|
11
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-NZMUW5XI.js";
|
|
12
7
|
|
|
13
8
|
// src/components/Icon.tsx
|
|
14
9
|
import { forwardRef } from "react";
|
|
@@ -1108,526 +1103,12 @@ var Icon = forwardRef(function Icon2({ name, size = "1em", strokeWidth = 1.8, ro
|
|
|
1108
1103
|
);
|
|
1109
1104
|
});
|
|
1110
1105
|
|
|
1111
|
-
// src/components/Navigation.tsx
|
|
1112
|
-
import { useEffect, useId, useLayoutEffect, useMemo, useRef, useState } from "react";
|
|
1113
|
-
import { Fragment as Fragment3, jsx as jsx4, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
1114
|
-
import { createElement } from "react";
|
|
1115
|
-
function MenuPopup({
|
|
1116
|
-
anchorRef,
|
|
1117
|
-
open,
|
|
1118
|
-
placement,
|
|
1119
|
-
menuId,
|
|
1120
|
-
theme,
|
|
1121
|
-
children,
|
|
1122
|
-
onMouseEnter,
|
|
1123
|
-
onMouseLeave
|
|
1124
|
-
}) {
|
|
1125
|
-
const [mounted, setMounted] = useState(open);
|
|
1126
|
-
const [fontSize, setFontSize] = useState();
|
|
1127
|
-
useLayoutEffect(() => {
|
|
1128
|
-
const anchor = anchorRef.current;
|
|
1129
|
-
if (!mounted || !anchor) return;
|
|
1130
|
-
const syncFontSize = () => setFontSize(getComputedStyle(anchor).fontSize);
|
|
1131
|
-
syncFontSize();
|
|
1132
|
-
const observer = new ResizeObserver(syncFontSize);
|
|
1133
|
-
observer.observe(anchor);
|
|
1134
|
-
return () => observer.disconnect();
|
|
1135
|
-
});
|
|
1136
|
-
useEffect(() => {
|
|
1137
|
-
if (open) {
|
|
1138
|
-
setMounted(true);
|
|
1139
|
-
return void 0;
|
|
1140
|
-
}
|
|
1141
|
-
const timer = window.setTimeout(() => setMounted(false), 160);
|
|
1142
|
-
return () => window.clearTimeout(timer);
|
|
1143
|
-
}, [open]);
|
|
1144
|
-
return /* @__PURE__ */ jsx4(
|
|
1145
|
-
PopupPortal,
|
|
1146
|
-
{
|
|
1147
|
-
anchorRef,
|
|
1148
|
-
open: mounted,
|
|
1149
|
-
placement,
|
|
1150
|
-
offset: 4,
|
|
1151
|
-
className: `sia-menu__popup sia-menu--${theme}${open ? " is-open" : " is-closing"}`,
|
|
1152
|
-
style: { fontSize },
|
|
1153
|
-
"data-sia-menu-owner": menuId,
|
|
1154
|
-
onMouseEnter,
|
|
1155
|
-
onMouseLeave,
|
|
1156
|
-
children: /* @__PURE__ */ jsx4("ul", { className: "sia-menu__popup-list", role: "menu", children })
|
|
1157
|
-
}
|
|
1158
|
-
);
|
|
1159
|
-
}
|
|
1160
|
-
function MenuEntry({
|
|
1161
|
-
item,
|
|
1162
|
-
level,
|
|
1163
|
-
parents,
|
|
1164
|
-
props,
|
|
1165
|
-
reserveIcon
|
|
1166
|
-
}) {
|
|
1167
|
-
const anchorRef = useRef(null);
|
|
1168
|
-
const closeTimerRef = useRef(void 0);
|
|
1169
|
-
const hasChildren = Boolean(item.children?.length);
|
|
1170
|
-
const isOpen = props.open.includes(item.key);
|
|
1171
|
-
const isSelected = props.selected.includes(item.key);
|
|
1172
|
-
const path = [item.key, ...parents];
|
|
1173
|
-
const collapsed = props.inlineCollapsed && level === 0;
|
|
1174
|
-
const inlineSubmenu = props.mode === "inline" && !collapsed;
|
|
1175
|
-
useEffect(() => () => {
|
|
1176
|
-
if (closeTimerRef.current !== void 0) window.clearTimeout(closeTimerRef.current);
|
|
1177
|
-
}, []);
|
|
1178
|
-
function cancelClose() {
|
|
1179
|
-
if (closeTimerRef.current !== void 0) {
|
|
1180
|
-
window.clearTimeout(closeTimerRef.current);
|
|
1181
|
-
closeTimerRef.current = void 0;
|
|
1182
|
-
}
|
|
1183
|
-
}
|
|
1184
|
-
function scheduleClose() {
|
|
1185
|
-
cancelClose();
|
|
1186
|
-
closeTimerRef.current = window.setTimeout(() => props.toggle(item.key, false), 100);
|
|
1187
|
-
}
|
|
1188
|
-
const hover = props.triggerSubMenuAction === "hover" && hasChildren && !inlineSubmenu;
|
|
1189
|
-
const submenu = hasChildren ? /* @__PURE__ */ jsx4(MenuLevel, { items: item.children ?? [], level: level + 1, parents: [item.key, ...parents], props }) : null;
|
|
1190
|
-
const popupPlacement = props.mode === "horizontal" && level === 0 ? "bottom-start" : "right-start";
|
|
1191
|
-
return /* @__PURE__ */ jsxs3(
|
|
1192
|
-
"li",
|
|
1193
|
-
{
|
|
1194
|
-
className: `sia-menu__entry${isOpen ? " is-open" : ""}${isSelected ? " is-selected" : ""}${item.disabled ? " is-disabled" : ""}${item.danger ? " is-danger" : ""}`,
|
|
1195
|
-
onMouseEnter: hover ? () => {
|
|
1196
|
-
cancelClose();
|
|
1197
|
-
props.toggle(item.key, true);
|
|
1198
|
-
} : void 0,
|
|
1199
|
-
onMouseLeave: hover ? scheduleClose : void 0,
|
|
1200
|
-
children: [
|
|
1201
|
-
/* @__PURE__ */ jsxs3(
|
|
1202
|
-
"button",
|
|
1203
|
-
{
|
|
1204
|
-
ref: anchorRef,
|
|
1205
|
-
type: "button",
|
|
1206
|
-
className: "sia-menu__item",
|
|
1207
|
-
style: { paddingInlineStart: props.mode === "inline" && !props.inlineCollapsed ? 12 + level * props.inlineIndent : void 0 },
|
|
1208
|
-
...withTitleTooltip({ title: collapsed ? item.title ?? (typeof item.label === "string" ? item.label : void 0) : item.title }),
|
|
1209
|
-
disabled: item.disabled,
|
|
1210
|
-
"aria-current": isSelected ? "page" : void 0,
|
|
1211
|
-
"aria-expanded": hasChildren ? isOpen : void 0,
|
|
1212
|
-
onClick: (event) => hasChildren ? props.toggle(item.key) : props.select(item, path, event),
|
|
1213
|
-
children: [
|
|
1214
|
-
reserveIcon ? /* @__PURE__ */ jsx4("span", { className: "sia-menu__icon", "aria-hidden": !item.icon || void 0, children: item.icon }) : null,
|
|
1215
|
-
!collapsed ? /* @__PURE__ */ jsx4("span", { className: "sia-menu__label", children: item.label }) : null,
|
|
1216
|
-
!collapsed && item.extra ? /* @__PURE__ */ jsx4("span", { className: "sia-menu__extra", children: item.extra }) : null,
|
|
1217
|
-
!collapsed && hasChildren ? /* @__PURE__ */ jsx4(Icon, { className: "sia-menu__expand-icon", name: "chevron-down", size: 13 }) : null
|
|
1218
|
-
]
|
|
1219
|
-
}
|
|
1220
|
-
),
|
|
1221
|
-
hasChildren ? inlineSubmenu ? /* @__PURE__ */ jsx4("ul", { className: "sia-menu__submenu", role: "menu", "aria-hidden": !isOpen, children: submenu }) : /* @__PURE__ */ jsx4(
|
|
1222
|
-
MenuPopup,
|
|
1223
|
-
{
|
|
1224
|
-
anchorRef,
|
|
1225
|
-
open: isOpen,
|
|
1226
|
-
placement: popupPlacement,
|
|
1227
|
-
menuId: props.menuId,
|
|
1228
|
-
theme: props.theme,
|
|
1229
|
-
onMouseEnter: hover ? cancelClose : void 0,
|
|
1230
|
-
onMouseLeave: hover ? scheduleClose : void 0,
|
|
1231
|
-
children: submenu
|
|
1232
|
-
}
|
|
1233
|
-
) : null
|
|
1234
|
-
]
|
|
1235
|
-
}
|
|
1236
|
-
);
|
|
1237
|
-
}
|
|
1238
|
-
function hasMenuIcon(items) {
|
|
1239
|
-
return items.some((item) => item.type === "group" ? hasMenuIcon(item.children ?? []) : item.type !== "divider" && Boolean(item.icon));
|
|
1240
|
-
}
|
|
1241
|
-
function MenuLevel({
|
|
1242
|
-
items,
|
|
1243
|
-
level,
|
|
1244
|
-
parents,
|
|
1245
|
-
props,
|
|
1246
|
-
reserveIcon = hasMenuIcon(items)
|
|
1247
|
-
}) {
|
|
1248
|
-
return /* @__PURE__ */ jsx4(Fragment3, { children: items.map((item, index) => {
|
|
1249
|
-
if (item.type === "divider") return /* @__PURE__ */ jsx4("li", { className: "sia-menu__divider", role: "separator" }, item.key || `divider-${index}`);
|
|
1250
|
-
if (item.type === "group") return /* @__PURE__ */ jsxs3("li", { className: "sia-menu__group", children: [
|
|
1251
|
-
/* @__PURE__ */ jsx4("div", { className: "sia-menu__group-title", children: item.label }),
|
|
1252
|
-
/* @__PURE__ */ jsx4("ul", { role: "group", children: /* @__PURE__ */ jsx4(MenuLevel, { items: item.children ?? [], level: level + 1, parents: [...parents, item.key], props, reserveIcon }) })
|
|
1253
|
-
] }, item.key);
|
|
1254
|
-
return /* @__PURE__ */ jsx4(MenuEntry, { item, level, parents, props, reserveIcon }, item.key);
|
|
1255
|
-
}) });
|
|
1256
|
-
}
|
|
1257
|
-
function Menu({
|
|
1258
|
-
items,
|
|
1259
|
-
mode = "vertical",
|
|
1260
|
-
theme = "light",
|
|
1261
|
-
selectedKeys,
|
|
1262
|
-
defaultSelectedKeys = [],
|
|
1263
|
-
openKeys,
|
|
1264
|
-
defaultOpenKeys = [],
|
|
1265
|
-
multiple = false,
|
|
1266
|
-
selectable = true,
|
|
1267
|
-
inlineCollapsed = false,
|
|
1268
|
-
inlineIndent = 20,
|
|
1269
|
-
triggerSubMenuAction = "click",
|
|
1270
|
-
onClick,
|
|
1271
|
-
onSelect,
|
|
1272
|
-
onDeselect,
|
|
1273
|
-
onOpenChange,
|
|
1274
|
-
className = "",
|
|
1275
|
-
...rest
|
|
1276
|
-
}) {
|
|
1277
|
-
const menuId = useId();
|
|
1278
|
-
const rootRef = useRef(null);
|
|
1279
|
-
const [selected, setSelected] = useControllableState({ value: selectedKeys, defaultValue: defaultSelectedKeys });
|
|
1280
|
-
const [open, setOpen] = useControllableState({ value: openKeys, defaultValue: defaultOpenKeys, onChange: (next) => onOpenChange?.([...next]) });
|
|
1281
|
-
useEffect(() => {
|
|
1282
|
-
if (mode === "inline" || !open.length) return void 0;
|
|
1283
|
-
const closeOutside = (event) => {
|
|
1284
|
-
const target = event.target;
|
|
1285
|
-
if (rootRef.current?.contains(target)) return;
|
|
1286
|
-
const owner = target instanceof Element ? target.closest("[data-sia-menu-owner]")?.getAttribute("data-sia-menu-owner") : null;
|
|
1287
|
-
if (owner !== menuId) setOpen([]);
|
|
1288
|
-
};
|
|
1289
|
-
document.addEventListener("pointerdown", closeOutside);
|
|
1290
|
-
return () => document.removeEventListener("pointerdown", closeOutside);
|
|
1291
|
-
}, [menuId, mode, open.length, setOpen]);
|
|
1292
|
-
function toggle(key, force) {
|
|
1293
|
-
const shouldOpen = force ?? !open.includes(key);
|
|
1294
|
-
setOpen(shouldOpen ? open.includes(key) ? open : [...open, key] : open.filter((item) => item !== key));
|
|
1295
|
-
}
|
|
1296
|
-
function select(item, keyPath, domEvent) {
|
|
1297
|
-
const info = { key: item.key, keyPath, domEvent, item };
|
|
1298
|
-
onClick?.(info);
|
|
1299
|
-
if (!selectable) return;
|
|
1300
|
-
const exists = selected.includes(item.key);
|
|
1301
|
-
const next = multiple ? exists ? selected.filter((key) => key !== item.key) : [...selected, item.key] : [item.key];
|
|
1302
|
-
setSelected(next);
|
|
1303
|
-
if (exists && multiple) onDeselect?.({ ...info, selectedKeys: [...next] });
|
|
1304
|
-
else onSelect?.({ ...info, selectedKeys: [...next] });
|
|
1305
|
-
if (mode !== "inline") setOpen([]);
|
|
1306
|
-
}
|
|
1307
|
-
return /* @__PURE__ */ jsx4("ul", { ref: rootRef, className: `sia-menu sia-menu--${mode} sia-menu--${theme}${inlineCollapsed ? " sia-menu--collapsed" : ""} ${className}`.trim(), role: "menu", ...withTitleTooltip(rest), "data-sia-menu-owner": menuId, children: /* @__PURE__ */ jsx4(MenuLevel, { items, level: 0, parents: [], props: { menuId, mode, theme, multiple, selectable, inlineCollapsed, inlineIndent, triggerSubMenuAction, selected, open, select, toggle } }) });
|
|
1308
|
-
}
|
|
1309
|
-
function Steps({ items, current = 0, initial = 0, direction = "horizontal", type = "default", size = "default", status = "process", progressDot = false, onChange, className = "", ...props }) {
|
|
1310
|
-
return /* @__PURE__ */ jsx4("div", { className: `sia-steps sia-steps--${direction} sia-steps--${type} sia-steps--${size} ${className}`.trim(), ...withTitleTooltip(props), children: items.map((item, rawIndex) => {
|
|
1311
|
-
const index = rawIndex + initial;
|
|
1312
|
-
const itemStatus = item.status ?? (index < current ? "finish" : index === current ? status : "wait");
|
|
1313
|
-
const dot = /* @__PURE__ */ jsx4("span", { className: "sia-steps__dot" });
|
|
1314
|
-
const icon = progressDot ? typeof progressDot === "function" ? progressDot(dot, { index, status: itemStatus, title: item.title, description: item.description }) : dot : item.icon ?? (itemStatus === "finish" ? /* @__PURE__ */ jsx4(Icon, { name: "check", size: 15 }) : itemStatus === "error" ? /* @__PURE__ */ jsx4(Icon, { name: "close", size: 14 }) : index + 1);
|
|
1315
|
-
return /* @__PURE__ */ jsxs3("button", { type: "button", className: `sia-steps__item sia-steps__item--${itemStatus}`, disabled: item.disabled || !onChange, onClick: () => onChange?.(index), children: [
|
|
1316
|
-
/* @__PURE__ */ jsxs3("span", { className: "sia-steps__head", children: [
|
|
1317
|
-
/* @__PURE__ */ jsx4("span", { className: "sia-steps__icon", children: icon }),
|
|
1318
|
-
/* @__PURE__ */ jsx4("span", { className: "sia-steps__tail" })
|
|
1319
|
-
] }),
|
|
1320
|
-
/* @__PURE__ */ jsxs3("span", { className: "sia-steps__content", children: [
|
|
1321
|
-
/* @__PURE__ */ jsxs3("span", { className: "sia-steps__title", children: [
|
|
1322
|
-
item.title,
|
|
1323
|
-
item.subTitle ? /* @__PURE__ */ jsx4("small", { children: item.subTitle }) : null
|
|
1324
|
-
] }),
|
|
1325
|
-
item.description ? /* @__PURE__ */ jsx4("span", { className: "sia-steps__description", children: item.description }) : null
|
|
1326
|
-
] })
|
|
1327
|
-
] }, index);
|
|
1328
|
-
}) });
|
|
1329
|
-
}
|
|
1330
|
-
function Segmented({ options, value, defaultValue, variant = "default", shape = "capsule", size: sizeProp, block = false, vertical = false, disabled = false, onChange, className = "", onKeyDown, ...props }) {
|
|
1331
|
-
const size = useControlSize(sizeProp);
|
|
1332
|
-
const normalized = useMemo(() => options.map((option) => typeof option === "object" ? option : { label: option, value: option }), [options]);
|
|
1333
|
-
const [current, setCurrent] = useControllableState({ value, defaultValue: defaultValue ?? normalized[0]?.value, onChange: (next) => next !== void 0 && onChange?.(next) });
|
|
1334
|
-
function keyboard(event) {
|
|
1335
|
-
onKeyDown?.(event);
|
|
1336
|
-
if (!["ArrowLeft", "ArrowRight", "ArrowUp", "ArrowDown"].includes(event.key)) return;
|
|
1337
|
-
event.preventDefault();
|
|
1338
|
-
const enabled = normalized.filter((option) => !option.disabled);
|
|
1339
|
-
const index = enabled.findIndex((option) => option.value === current);
|
|
1340
|
-
const next = event.key === "ArrowRight" || event.key === "ArrowDown" ? enabled[(index + 1) % enabled.length] : enabled[(index - 1 + enabled.length) % enabled.length];
|
|
1341
|
-
if (next) setCurrent(next.value);
|
|
1342
|
-
}
|
|
1343
|
-
return /* @__PURE__ */ jsx4("div", { className: `sia-segmented sia-segmented--${size}${variant === "zigzag" && !vertical && normalized.length === 2 ? ` sia-segmented--zigzag sia-segmented--shape-${shape}` : ""}${block ? " sia-segmented--block" : ""}${vertical ? " sia-segmented--vertical" : ""}${disabled ? " is-disabled" : ""} ${className}`.trim(), role: "radiogroup", onKeyDown: keyboard, ...withTitleTooltip(props), children: normalized.map((option) => /* @__PURE__ */ createElement("button", { type: "button", role: "radio", "aria-checked": option.value === current, ...withTitleTooltip({ title: option.title }), className: option.value === current ? "is-selected" : "", disabled: disabled || option.disabled, key: option.value, onClick: () => setCurrent(option.value) }, option.icon, /* @__PURE__ */ jsx4("span", { children: option.label ?? option.value }))) });
|
|
1344
|
-
}
|
|
1345
|
-
|
|
1346
|
-
// src/components/Dropdown.tsx
|
|
1347
|
-
import { cloneElement as cloneElement2, isValidElement as isValidElement2, useEffect as useEffect2, useLayoutEffect as useLayoutEffect2, useRef as useRef2, useState as useState2 } from "react";
|
|
1348
|
-
import { jsx as jsx5, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
1349
|
-
var placementMap = {
|
|
1350
|
-
bottomLeft: "bottom-start",
|
|
1351
|
-
bottomRight: "bottom-end",
|
|
1352
|
-
topLeft: "top-start",
|
|
1353
|
-
topRight: "top-end"
|
|
1354
|
-
};
|
|
1355
|
-
function DropdownInternal({
|
|
1356
|
-
popupAnchorRef,
|
|
1357
|
-
menu,
|
|
1358
|
-
children,
|
|
1359
|
-
trigger = ["hover"],
|
|
1360
|
-
placement = "bottomLeft",
|
|
1361
|
-
open,
|
|
1362
|
-
defaultOpen = false,
|
|
1363
|
-
disabled = false,
|
|
1364
|
-
showTriggerIcon = true,
|
|
1365
|
-
arrow = false,
|
|
1366
|
-
autoFocus = false,
|
|
1367
|
-
openDelay = 80,
|
|
1368
|
-
closeDelay = 120,
|
|
1369
|
-
popupClassName = "",
|
|
1370
|
-
popupStyle,
|
|
1371
|
-
popupRender,
|
|
1372
|
-
onOpenChange,
|
|
1373
|
-
className = "",
|
|
1374
|
-
onClick,
|
|
1375
|
-
onMouseEnter,
|
|
1376
|
-
onMouseLeave,
|
|
1377
|
-
onContextMenu,
|
|
1378
|
-
onKeyDown,
|
|
1379
|
-
...props
|
|
1380
|
-
}) {
|
|
1381
|
-
const rootRef = useRef2(null);
|
|
1382
|
-
const contextAnchorRef = useRef2(null);
|
|
1383
|
-
const popupRef = useRef2(null);
|
|
1384
|
-
const openTimerRef = useRef2(void 0);
|
|
1385
|
-
const closeTimerRef = useRef2(void 0);
|
|
1386
|
-
const [internalOpen, setInternalOpen] = useState2(defaultOpen);
|
|
1387
|
-
const [mounted, setMounted] = useState2(open ?? defaultOpen);
|
|
1388
|
-
const [contextPoint, setContextPoint] = useState2();
|
|
1389
|
-
const visible = open ?? internalOpen;
|
|
1390
|
-
const triggerSet = new Set(trigger);
|
|
1391
|
-
const pointAtCenter = typeof arrow === "object" && arrow.pointAtCenter;
|
|
1392
|
-
const [triggerFontSize, setTriggerFontSize] = useState2();
|
|
1393
|
-
useLayoutEffect2(() => {
|
|
1394
|
-
if (!visible || !rootRef.current) return;
|
|
1395
|
-
const root = rootRef.current;
|
|
1396
|
-
const target = root.querySelector("button, [role='button'], a") ?? (root.firstElementChild !== contextAnchorRef.current ? root.firstElementChild : null) ?? root;
|
|
1397
|
-
const syncFontSize = () => setTriggerFontSize(getComputedStyle(target).fontSize);
|
|
1398
|
-
syncFontSize();
|
|
1399
|
-
const observer = new ResizeObserver(syncFontSize);
|
|
1400
|
-
observer.observe(target);
|
|
1401
|
-
return () => observer.disconnect();
|
|
1402
|
-
});
|
|
1403
|
-
function clearTimer(ref) {
|
|
1404
|
-
if (ref.current === void 0) return;
|
|
1405
|
-
window.clearTimeout(ref.current);
|
|
1406
|
-
ref.current = void 0;
|
|
1407
|
-
}
|
|
1408
|
-
function clearTimers() {
|
|
1409
|
-
clearTimer(openTimerRef);
|
|
1410
|
-
clearTimer(closeTimerRef);
|
|
1411
|
-
}
|
|
1412
|
-
function updateOpen(next, source) {
|
|
1413
|
-
clearTimers();
|
|
1414
|
-
if (next === visible) return;
|
|
1415
|
-
if (open === void 0) setInternalOpen(next);
|
|
1416
|
-
onOpenChange?.(next, { source });
|
|
1417
|
-
}
|
|
1418
|
-
function scheduleOpen() {
|
|
1419
|
-
clearTimer(closeTimerRef);
|
|
1420
|
-
clearTimer(openTimerRef);
|
|
1421
|
-
openTimerRef.current = window.setTimeout(() => updateOpen(true, "trigger"), Math.max(0, openDelay));
|
|
1422
|
-
}
|
|
1423
|
-
function scheduleClose() {
|
|
1424
|
-
clearTimer(openTimerRef);
|
|
1425
|
-
clearTimer(closeTimerRef);
|
|
1426
|
-
closeTimerRef.current = window.setTimeout(() => updateOpen(false, "trigger"), Math.max(0, closeDelay));
|
|
1427
|
-
}
|
|
1428
|
-
useEffect2(() => {
|
|
1429
|
-
if (visible) {
|
|
1430
|
-
setMounted(true);
|
|
1431
|
-
return void 0;
|
|
1432
|
-
}
|
|
1433
|
-
const timer = window.setTimeout(() => setMounted(false), 160);
|
|
1434
|
-
return () => window.clearTimeout(timer);
|
|
1435
|
-
}, [visible]);
|
|
1436
|
-
useEffect2(() => {
|
|
1437
|
-
if (!visible && !mounted) setContextPoint(void 0);
|
|
1438
|
-
}, [mounted, visible]);
|
|
1439
|
-
useEffect2(() => () => clearTimers(), []);
|
|
1440
|
-
useEffect2(() => {
|
|
1441
|
-
if (!visible) return void 0;
|
|
1442
|
-
const contextMenuTrigger = triggerSet.has("contextMenu");
|
|
1443
|
-
const closeOutside = (event) => {
|
|
1444
|
-
const target = event.target;
|
|
1445
|
-
if (popupRef.current?.contains(target)) return;
|
|
1446
|
-
if (!contextMenuTrigger && rootRef.current?.contains(target)) return;
|
|
1447
|
-
const targetOwner = target instanceof Element ? target.closest("[data-sia-menu-owner]")?.getAttribute("data-sia-menu-owner") : null;
|
|
1448
|
-
const menuOwner = popupRef.current?.querySelector("[data-sia-menu-owner]")?.getAttribute("data-sia-menu-owner");
|
|
1449
|
-
if (menuOwner && targetOwner === menuOwner) return;
|
|
1450
|
-
updateOpen(false, "trigger");
|
|
1451
|
-
};
|
|
1452
|
-
const closeWithEscape = (event) => {
|
|
1453
|
-
if (event.key !== "Escape") return;
|
|
1454
|
-
updateOpen(false, "trigger");
|
|
1455
|
-
rootRef.current?.querySelector("button, a, [tabindex]:not([tabindex='-1'])")?.focus();
|
|
1456
|
-
};
|
|
1457
|
-
const keepOpenOverNestedMenu = (event) => {
|
|
1458
|
-
const target = event.target;
|
|
1459
|
-
if (target instanceof Element && target.closest(".sia-menu__popup")) clearTimer(closeTimerRef);
|
|
1460
|
-
};
|
|
1461
|
-
document.addEventListener("pointerdown", closeOutside);
|
|
1462
|
-
document.addEventListener("keydown", closeWithEscape);
|
|
1463
|
-
document.addEventListener("pointerover", keepOpenOverNestedMenu);
|
|
1464
|
-
return () => {
|
|
1465
|
-
document.removeEventListener("pointerdown", closeOutside);
|
|
1466
|
-
document.removeEventListener("keydown", closeWithEscape);
|
|
1467
|
-
document.removeEventListener("pointerover", keepOpenOverNestedMenu);
|
|
1468
|
-
};
|
|
1469
|
-
}, [visible]);
|
|
1470
|
-
useEffect2(() => {
|
|
1471
|
-
if (!visible || !mounted || !autoFocus) return void 0;
|
|
1472
|
-
const frame = window.requestAnimationFrame(() => {
|
|
1473
|
-
popupRef.current?.querySelector(
|
|
1474
|
-
"[data-sia-dropdown-autofocus], input:not(:disabled), textarea:not(:disabled), .sia-menu__item:not(:disabled)"
|
|
1475
|
-
)?.focus();
|
|
1476
|
-
});
|
|
1477
|
-
return () => window.cancelAnimationFrame(frame);
|
|
1478
|
-
}, [autoFocus, mounted, visible]);
|
|
1479
|
-
function handleMenuClick(info) {
|
|
1480
|
-
info.domEvent.stopPropagation();
|
|
1481
|
-
menu.onClick?.(info);
|
|
1482
|
-
updateOpen(false, "menu");
|
|
1483
|
-
}
|
|
1484
|
-
function handleClick(event) {
|
|
1485
|
-
onClick?.(event);
|
|
1486
|
-
if (disabled || !triggerSet.has("click") || event.defaultPrevented) return;
|
|
1487
|
-
setContextPoint(void 0);
|
|
1488
|
-
updateOpen(!visible, "trigger");
|
|
1489
|
-
}
|
|
1490
|
-
function handleMouseEnter(event) {
|
|
1491
|
-
onMouseEnter?.(event);
|
|
1492
|
-
if (!disabled && triggerSet.has("hover")) scheduleOpen();
|
|
1493
|
-
}
|
|
1494
|
-
function handleMouseLeave(event) {
|
|
1495
|
-
onMouseLeave?.(event);
|
|
1496
|
-
if (!disabled && triggerSet.has("hover")) scheduleClose();
|
|
1497
|
-
}
|
|
1498
|
-
function handleContextMenu(event) {
|
|
1499
|
-
onContextMenu?.(event);
|
|
1500
|
-
if (disabled || !triggerSet.has("contextMenu") || event.defaultPrevented) return;
|
|
1501
|
-
event.preventDefault();
|
|
1502
|
-
event.stopPropagation();
|
|
1503
|
-
setContextPoint({ x: event.clientX, y: event.clientY });
|
|
1504
|
-
updateOpen(true, "trigger");
|
|
1505
|
-
}
|
|
1506
|
-
function handleKeyDown(event) {
|
|
1507
|
-
onKeyDown?.(event);
|
|
1508
|
-
if (disabled || event.defaultPrevented) return;
|
|
1509
|
-
if (event.key === "ArrowDown" && (triggerSet.has("click") || triggerSet.has("hover"))) {
|
|
1510
|
-
event.preventDefault();
|
|
1511
|
-
setContextPoint(void 0);
|
|
1512
|
-
updateOpen(true, "trigger");
|
|
1513
|
-
} else if (triggerSet.has("contextMenu") && (event.key === "ContextMenu" || event.shiftKey && event.key === "F10")) {
|
|
1514
|
-
event.preventDefault();
|
|
1515
|
-
setContextPoint(void 0);
|
|
1516
|
-
updateOpen(true, "trigger");
|
|
1517
|
-
}
|
|
1518
|
-
}
|
|
1519
|
-
const menuNode = /* @__PURE__ */ jsx5(
|
|
1520
|
-
Menu,
|
|
1521
|
-
{
|
|
1522
|
-
mode: "vertical",
|
|
1523
|
-
theme: menu.theme,
|
|
1524
|
-
items: menu.items,
|
|
1525
|
-
multiple: menu.multiple,
|
|
1526
|
-
selectable: menu.selectable,
|
|
1527
|
-
selectedKeys: menu.selectedKeys,
|
|
1528
|
-
defaultSelectedKeys: menu.defaultSelectedKeys,
|
|
1529
|
-
triggerSubMenuAction: "hover",
|
|
1530
|
-
onClick: handleMenuClick,
|
|
1531
|
-
onSelect: menu.onSelect,
|
|
1532
|
-
onDeselect: menu.onDeselect,
|
|
1533
|
-
className: "sia-dropdown__menu"
|
|
1534
|
-
}
|
|
1535
|
-
);
|
|
1536
|
-
const triggerNode = showTriggerIcon && isValidElement2(children) && children.type === Button && children.props.children !== void 0 && children.props.children !== null ? cloneElement2(children, {}, /* @__PURE__ */ jsxs4("span", { className: "sia-dropdown__trigger-content", children: [
|
|
1537
|
-
children.props.children,
|
|
1538
|
-
/* @__PURE__ */ jsx5(Icon, { name: "chevron-down", size: 14, className: "sia-dropdown__trigger-icon" })
|
|
1539
|
-
] })) : children;
|
|
1540
|
-
return /* @__PURE__ */ jsxs4(
|
|
1541
|
-
"span",
|
|
1542
|
-
{
|
|
1543
|
-
ref: rootRef,
|
|
1544
|
-
className: `sia-dropdown${visible ? " is-open" : ""}${disabled ? " is-disabled" : ""} ${className}`.trim(),
|
|
1545
|
-
"aria-expanded": visible,
|
|
1546
|
-
"aria-haspopup": "menu",
|
|
1547
|
-
tabIndex: triggerSet.has("contextMenu") ? 0 : void 0,
|
|
1548
|
-
onClick: handleClick,
|
|
1549
|
-
onMouseEnter: handleMouseEnter,
|
|
1550
|
-
onMouseLeave: handleMouseLeave,
|
|
1551
|
-
onContextMenu: handleContextMenu,
|
|
1552
|
-
onKeyDown: handleKeyDown,
|
|
1553
|
-
...withTitleTooltip(props),
|
|
1554
|
-
children: [
|
|
1555
|
-
triggerNode,
|
|
1556
|
-
/* @__PURE__ */ jsx5(
|
|
1557
|
-
"span",
|
|
1558
|
-
{
|
|
1559
|
-
ref: contextAnchorRef,
|
|
1560
|
-
className: "sia-dropdown__context-anchor",
|
|
1561
|
-
style: contextPoint ? { left: contextPoint.x, top: contextPoint.y } : void 0,
|
|
1562
|
-
"aria-hidden": "true"
|
|
1563
|
-
}
|
|
1564
|
-
),
|
|
1565
|
-
/* @__PURE__ */ jsx5(
|
|
1566
|
-
PopupPortal,
|
|
1567
|
-
{
|
|
1568
|
-
ref: popupRef,
|
|
1569
|
-
anchorRef: contextPoint ? contextAnchorRef : popupAnchorRef ?? rootRef,
|
|
1570
|
-
open: mounted,
|
|
1571
|
-
placement: contextPoint ? "bottom-start" : placementMap[placement],
|
|
1572
|
-
offset: contextPoint ? 2 : 6,
|
|
1573
|
-
className: `sia-dropdown__popup${visible ? " is-open" : " is-closing"}${arrow ? " sia-dropdown__popup--arrow" : ""}${pointAtCenter ? " sia-dropdown__popup--arrow-center" : ""} ${popupClassName}`.trim(),
|
|
1574
|
-
style: { fontSize: triggerFontSize, ...popupStyle },
|
|
1575
|
-
onMouseEnter: () => {
|
|
1576
|
-
clearTimer(closeTimerRef);
|
|
1577
|
-
if (!disabled && triggerSet.has("hover")) clearTimer(openTimerRef);
|
|
1578
|
-
},
|
|
1579
|
-
onMouseLeave: () => {
|
|
1580
|
-
if (!disabled && triggerSet.has("hover")) scheduleClose();
|
|
1581
|
-
},
|
|
1582
|
-
onClick: (event) => event.stopPropagation(),
|
|
1583
|
-
children: popupRender ? popupRender(menuNode) : menuNode
|
|
1584
|
-
},
|
|
1585
|
-
contextPoint ? `context-${contextPoint.x}-${contextPoint.y}` : "trigger"
|
|
1586
|
-
)
|
|
1587
|
-
]
|
|
1588
|
-
}
|
|
1589
|
-
);
|
|
1590
|
-
}
|
|
1591
|
-
function DropdownRoot(props) {
|
|
1592
|
-
return /* @__PURE__ */ jsx5(DropdownInternal, { ...props });
|
|
1593
|
-
}
|
|
1594
|
-
function DropdownButton({
|
|
1595
|
-
children,
|
|
1596
|
-
className = "",
|
|
1597
|
-
buttonProps,
|
|
1598
|
-
onClick,
|
|
1599
|
-
disabled,
|
|
1600
|
-
buttonDisabled,
|
|
1601
|
-
dropdownDisabled,
|
|
1602
|
-
trigger = ["click"],
|
|
1603
|
-
...dropdownProps
|
|
1604
|
-
}) {
|
|
1605
|
-
const groupRef = useRef2(null);
|
|
1606
|
-
return /* @__PURE__ */ jsxs4("span", { ref: groupRef, className: `sia-dropdown-button ${className}`.trim(), children: [
|
|
1607
|
-
/* @__PURE__ */ jsx5(Button, { ...buttonProps, disabled: disabled || buttonDisabled, onClick, children }),
|
|
1608
|
-
/* @__PURE__ */ jsx5(DropdownInternal, { ...dropdownProps, popupAnchorRef: groupRef, disabled: disabled || dropdownDisabled, trigger, showTriggerIcon: false, children: /* @__PURE__ */ jsx5(
|
|
1609
|
-
Button,
|
|
1610
|
-
{
|
|
1611
|
-
...buttonProps,
|
|
1612
|
-
className: `sia-dropdown-button__arrow ${buttonProps?.className ?? ""}`.trim(),
|
|
1613
|
-
disabled: disabled || dropdownDisabled,
|
|
1614
|
-
icon: /* @__PURE__ */ jsx5(Icon, { name: "chevron-down", size: 14 }),
|
|
1615
|
-
"aria-label": "\u5C55\u5F00\u4E0B\u62C9\u83DC\u5355"
|
|
1616
|
-
}
|
|
1617
|
-
) })
|
|
1618
|
-
] });
|
|
1619
|
-
}
|
|
1620
|
-
var Dropdown = Object.assign(DropdownRoot, {
|
|
1621
|
-
/** 组合主操作按钮与下拉菜单的按钮组件。 */
|
|
1622
|
-
Button: DropdownButton
|
|
1623
|
-
});
|
|
1624
|
-
|
|
1625
1106
|
// src/components/Modal.tsx
|
|
1626
|
-
import { forwardRef as forwardRef2, useEffect as
|
|
1107
|
+
import { forwardRef as forwardRef2, useEffect as useEffect2, useId, useRef as useRef2, useState } from "react";
|
|
1627
1108
|
import { createRoot } from "react-dom/client";
|
|
1628
1109
|
|
|
1629
1110
|
// src/components/Overlay.tsx
|
|
1630
|
-
import { useEffect
|
|
1111
|
+
import { useEffect, useRef } from "react";
|
|
1631
1112
|
import { createPortal } from "react-dom";
|
|
1632
1113
|
var bodyLockCount = 0;
|
|
1633
1114
|
var previousBodyOverflow = "";
|
|
@@ -1649,10 +1130,10 @@ function focusableElements(container) {
|
|
|
1649
1130
|
)].filter((element) => !element.hidden && element.getAttribute("aria-hidden") !== "true");
|
|
1650
1131
|
}
|
|
1651
1132
|
function useOverlayLifecycle(open, panelRef, onRequestClose, keyboard = true) {
|
|
1652
|
-
const overlayIdRef =
|
|
1653
|
-
const closeRef =
|
|
1133
|
+
const overlayIdRef = useRef(/* @__PURE__ */ Symbol("sia-overlay"));
|
|
1134
|
+
const closeRef = useRef(onRequestClose);
|
|
1654
1135
|
closeRef.current = onRequestClose;
|
|
1655
|
-
|
|
1136
|
+
useEffect(() => {
|
|
1656
1137
|
if (!open || typeof document === "undefined") return void 0;
|
|
1657
1138
|
const overlayId = overlayIdRef.current;
|
|
1658
1139
|
const previouslyFocused = document.activeElement instanceof HTMLElement ? document.activeElement : null;
|
|
@@ -1706,15 +1187,15 @@ function OverlayPortal({ children, container }) {
|
|
|
1706
1187
|
}
|
|
1707
1188
|
|
|
1708
1189
|
// src/components/Modal.tsx
|
|
1709
|
-
import { Fragment as
|
|
1190
|
+
import { Fragment as Fragment3, jsx as jsx4, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
1710
1191
|
var modalHandles = /* @__PURE__ */ new Set();
|
|
1711
1192
|
var MODAL_MOTION_DURATION = 220;
|
|
1712
1193
|
var typeIcons = {
|
|
1713
|
-
info: /* @__PURE__ */
|
|
1714
|
-
success: /* @__PURE__ */
|
|
1715
|
-
warning: /* @__PURE__ */
|
|
1716
|
-
error: /* @__PURE__ */
|
|
1717
|
-
confirm: /* @__PURE__ */
|
|
1194
|
+
info: /* @__PURE__ */ jsx4(Icon, { name: "info", size: 23 }),
|
|
1195
|
+
success: /* @__PURE__ */ jsx4(Icon, { name: "circle-check", size: 23 }),
|
|
1196
|
+
warning: /* @__PURE__ */ jsx4(Icon, { name: "warning", size: 23 }),
|
|
1197
|
+
error: /* @__PURE__ */ jsx4(Icon, { name: "circle-close", size: 23 }),
|
|
1198
|
+
confirm: /* @__PURE__ */ jsx4(Icon, { name: "question", size: 23 })
|
|
1718
1199
|
};
|
|
1719
1200
|
var ModalRoot = forwardRef2(function Modal({
|
|
1720
1201
|
open,
|
|
@@ -1745,20 +1226,20 @@ var ModalRoot = forwardRef2(function Modal({
|
|
|
1745
1226
|
style,
|
|
1746
1227
|
...props
|
|
1747
1228
|
}, forwardedRef) {
|
|
1748
|
-
const localRef =
|
|
1749
|
-
const titleId =
|
|
1750
|
-
const [submitting, setSubmitting] =
|
|
1751
|
-
const [rendered, setRendered] =
|
|
1752
|
-
const [closing, setClosing] =
|
|
1753
|
-
const afterOpenChangeRef =
|
|
1229
|
+
const localRef = useRef2(null);
|
|
1230
|
+
const titleId = useId();
|
|
1231
|
+
const [submitting, setSubmitting] = useState(false);
|
|
1232
|
+
const [rendered, setRendered] = useState(open);
|
|
1233
|
+
const [closing, setClosing] = useState(false);
|
|
1234
|
+
const afterOpenChangeRef = useRef2(afterOpenChange);
|
|
1754
1235
|
afterOpenChangeRef.current = afterOpenChange;
|
|
1755
|
-
const submitLock =
|
|
1756
|
-
|
|
1236
|
+
const submitLock = useRef2(false);
|
|
1237
|
+
useEffect2(() => {
|
|
1757
1238
|
if (!open || !rendered) return void 0;
|
|
1758
1239
|
const timer = window.setTimeout(() => afterOpenChangeRef.current?.(true), MODAL_MOTION_DURATION);
|
|
1759
1240
|
return () => window.clearTimeout(timer);
|
|
1760
1241
|
}, [open, rendered]);
|
|
1761
|
-
|
|
1242
|
+
useEffect2(() => {
|
|
1762
1243
|
if (open) {
|
|
1763
1244
|
setRendered(true);
|
|
1764
1245
|
setClosing(false);
|
|
@@ -1815,11 +1296,11 @@ var ModalRoot = forwardRef2(function Modal({
|
|
|
1815
1296
|
"--sia-modal-width": typeof width === "number" ? `${width}px` : width
|
|
1816
1297
|
};
|
|
1817
1298
|
const loading = submitting || confirmLoading;
|
|
1818
|
-
const defaultFooter = /* @__PURE__ */
|
|
1819
|
-
showCancel ? /* @__PURE__ */
|
|
1820
|
-
/* @__PURE__ */
|
|
1299
|
+
const defaultFooter = /* @__PURE__ */ jsxs3(Fragment3, { children: [
|
|
1300
|
+
showCancel ? /* @__PURE__ */ jsx4(Button, { ...cancelButtonProps, onClick: requestClose, disabled: loading || cancelButtonProps?.disabled, children: cancelText }) : null,
|
|
1301
|
+
/* @__PURE__ */ jsx4(Button, { variant: "primary", ...okButtonProps, onClick: handleOk, loading, children: okText })
|
|
1821
1302
|
] });
|
|
1822
|
-
return /* @__PURE__ */
|
|
1303
|
+
return /* @__PURE__ */ jsx4(OverlayPortal, { container: getContainer, children: /* @__PURE__ */ jsx4(
|
|
1823
1304
|
"div",
|
|
1824
1305
|
{
|
|
1825
1306
|
className: `sia-modal-root${centered ? " sia-modal-root--centered" : ""}`,
|
|
@@ -1828,7 +1309,7 @@ var ModalRoot = forwardRef2(function Modal({
|
|
|
1828
1309
|
onMouseDown: (event) => {
|
|
1829
1310
|
if (event.target === event.currentTarget && maskClosable) requestClose();
|
|
1830
1311
|
},
|
|
1831
|
-
children: /* @__PURE__ */
|
|
1312
|
+
children: /* @__PURE__ */ jsxs3(
|
|
1832
1313
|
"div",
|
|
1833
1314
|
{
|
|
1834
1315
|
ref: setRef,
|
|
@@ -1840,16 +1321,16 @@ var ModalRoot = forwardRef2(function Modal({
|
|
|
1840
1321
|
tabIndex: -1,
|
|
1841
1322
|
...withTitleTooltip(props),
|
|
1842
1323
|
children: [
|
|
1843
|
-
/* @__PURE__ */
|
|
1844
|
-
/* @__PURE__ */
|
|
1845
|
-
typeIcons[type] ? /* @__PURE__ */
|
|
1846
|
-
title ? /* @__PURE__ */
|
|
1324
|
+
/* @__PURE__ */ jsxs3("div", { className: "sia-modal__header", style: height !== void 0 ? { flexShrink: 0 } : void 0, children: [
|
|
1325
|
+
/* @__PURE__ */ jsxs3("div", { className: "sia-modal__heading", children: [
|
|
1326
|
+
typeIcons[type] ? /* @__PURE__ */ jsx4("span", { className: "sia-modal__type-icon", "aria-hidden": "true", children: typeIcons[type] }) : null,
|
|
1327
|
+
title ? /* @__PURE__ */ jsx4("strong", { id: titleId, children: title }) : null
|
|
1847
1328
|
] }),
|
|
1848
|
-
closable ? /* @__PURE__ */
|
|
1329
|
+
closable ? /* @__PURE__ */ jsx4("button", { type: "button", className: "sia-modal__close", "aria-label": "\u5173\u95ED\u5BF9\u8BDD\u6846", onClick: requestClose, children: /* @__PURE__ */ jsx4(Icon, { name: "close", size: 17 }) }) : null
|
|
1849
1330
|
] }),
|
|
1850
|
-
children !== void 0 ? /* @__PURE__ */
|
|
1851
|
-
footer !== null ? /* @__PURE__ */
|
|
1852
|
-
footer === void 0 && footerExtra != null ? /* @__PURE__ */
|
|
1331
|
+
children !== void 0 ? /* @__PURE__ */ jsx4("div", { className: "sia-modal__body", style: height !== void 0 ? { flex: 1, minHeight: 0, overflow: "auto" } : void 0, children }) : null,
|
|
1332
|
+
footer !== null ? /* @__PURE__ */ jsxs3("div", { className: "sia-modal__footer", style: height !== void 0 ? { flexShrink: 0 } : void 0, children: [
|
|
1333
|
+
footer === void 0 && footerExtra != null ? /* @__PURE__ */ jsx4("div", { style: { marginRight: "auto" }, children: footerExtra }) : null,
|
|
1853
1334
|
footer ?? defaultFooter
|
|
1854
1335
|
] }) : null
|
|
1855
1336
|
]
|
|
@@ -1883,11 +1364,11 @@ function openModal(config) {
|
|
|
1883
1364
|
render();
|
|
1884
1365
|
}
|
|
1885
1366
|
function ModalInstance() {
|
|
1886
|
-
|
|
1367
|
+
useEffect2(() => {
|
|
1887
1368
|
mounted = true;
|
|
1888
1369
|
if (!currentOpen) render();
|
|
1889
1370
|
}, []);
|
|
1890
|
-
return /* @__PURE__ */
|
|
1371
|
+
return /* @__PURE__ */ jsx4(ModalRoot, { ...currentConfig, open: !mounted || currentOpen, onOpenChange: (nextOpen) => {
|
|
1891
1372
|
currentConfig.onOpenChange?.(nextOpen);
|
|
1892
1373
|
if (!nextOpen) closeWithMotion();
|
|
1893
1374
|
}, afterOpenChange: (nextOpen) => {
|
|
@@ -1899,7 +1380,7 @@ function openModal(config) {
|
|
|
1899
1380
|
} });
|
|
1900
1381
|
}
|
|
1901
1382
|
function render() {
|
|
1902
|
-
root.render(/* @__PURE__ */
|
|
1383
|
+
root.render(/* @__PURE__ */ jsx4(ModalInstance, {}));
|
|
1903
1384
|
}
|
|
1904
1385
|
const handle = {
|
|
1905
1386
|
destroy: closeWithMotion,
|
|
@@ -1943,181 +1424,11 @@ var Modal2 = Object.assign(ModalRoot, {
|
|
|
1943
1424
|
}
|
|
1944
1425
|
});
|
|
1945
1426
|
|
|
1946
|
-
// src/components/Input.tsx
|
|
1947
|
-
import { forwardRef as forwardRef3, useId as useId3, useRef as useRef5, useState as useState4 } from "react";
|
|
1948
|
-
import { Fragment as Fragment5, jsx as jsx7, jsxs as jsxs6 } from "react/jsx-runtime";
|
|
1949
|
-
var Input = forwardRef3(function Input2({
|
|
1950
|
-
label,
|
|
1951
|
-
hint,
|
|
1952
|
-
status = "default",
|
|
1953
|
-
size: sizeProp,
|
|
1954
|
-
prefix,
|
|
1955
|
-
suffix,
|
|
1956
|
-
allowClear = true,
|
|
1957
|
-
onClear,
|
|
1958
|
-
showCount = false,
|
|
1959
|
-
placeholderMode,
|
|
1960
|
-
placeholder,
|
|
1961
|
-
className = "",
|
|
1962
|
-
id,
|
|
1963
|
-
disabled,
|
|
1964
|
-
value,
|
|
1965
|
-
defaultValue,
|
|
1966
|
-
maxLength,
|
|
1967
|
-
onChange,
|
|
1968
|
-
expandable = false,
|
|
1969
|
-
...props
|
|
1970
|
-
}, forwardedRef) {
|
|
1971
|
-
const size = useControlSize(sizeProp);
|
|
1972
|
-
const fallbackId = useId3();
|
|
1973
|
-
const inputId = id ?? fallbackId;
|
|
1974
|
-
const localRef = useRef5(null);
|
|
1975
|
-
const [uncontrolledValue, setUncontrolledValue] = useState4(() => defaultValue === void 0 ? "" : String(defaultValue));
|
|
1976
|
-
const currentText = value !== void 0 ? String(value) : uncontrolledValue;
|
|
1977
|
-
const hasValue = currentText.length > 0;
|
|
1978
|
-
const [expanded, setExpanded] = useState4(false);
|
|
1979
|
-
const [expandedDraft, setExpandedDraft] = useState4("");
|
|
1980
|
-
const floatingPlaceholder = usePlaceholderMode(placeholderMode) === "floating" && Boolean(placeholder);
|
|
1981
|
-
const hintId = `${inputId}-hint`;
|
|
1982
|
-
const describedBy = [props["aria-describedby"], hint ? hintId : null].filter(Boolean).join(" ") || void 0;
|
|
1983
|
-
function setRef(node) {
|
|
1984
|
-
localRef.current = node;
|
|
1985
|
-
if (typeof forwardedRef === "function") forwardedRef(node);
|
|
1986
|
-
else if (forwardedRef) forwardedRef.current = node;
|
|
1987
|
-
}
|
|
1988
|
-
function handleChange(event) {
|
|
1989
|
-
if (maxLength !== void 0 && maxLength >= 0 && event.target.value.length > maxLength) {
|
|
1990
|
-
const valueSetter = Object.getOwnPropertyDescriptor(HTMLInputElement.prototype, "value")?.set;
|
|
1991
|
-
valueSetter?.call(event.target, event.target.value.slice(0, maxLength));
|
|
1992
|
-
}
|
|
1993
|
-
setUncontrolledValue(event.target.value);
|
|
1994
|
-
onChange?.(event);
|
|
1995
|
-
}
|
|
1996
|
-
function clearValue() {
|
|
1997
|
-
const input2 = localRef.current;
|
|
1998
|
-
if (!input2 || disabled) return;
|
|
1999
|
-
const valueSetter = Object.getOwnPropertyDescriptor(HTMLInputElement.prototype, "value")?.set;
|
|
2000
|
-
valueSetter?.call(input2, "");
|
|
2001
|
-
input2.dispatchEvent(new Event("input", { bubbles: true }));
|
|
2002
|
-
setUncontrolledValue("");
|
|
2003
|
-
input2.focus();
|
|
2004
|
-
onClear?.();
|
|
2005
|
-
}
|
|
2006
|
-
function handleControlMouseDown(event) {
|
|
2007
|
-
if (disabled || event.defaultPrevented || event.button !== 0) return;
|
|
2008
|
-
const target = event.target;
|
|
2009
|
-
if (!(target instanceof Element)) return;
|
|
2010
|
-
const interactive = target.closest("input, textarea, select, button, a[href], [tabindex], [contenteditable]:not([contenteditable='false']), [role='button'], [role='link']");
|
|
2011
|
-
if (interactive && event.currentTarget.contains(interactive) && !interactive.classList.contains("sia-input-control__clear")) return;
|
|
2012
|
-
event.preventDefault();
|
|
2013
|
-
localRef.current?.focus({ preventScroll: true });
|
|
2014
|
-
}
|
|
2015
|
-
const input = /* @__PURE__ */ jsx7(
|
|
2016
|
-
"input",
|
|
2017
|
-
{
|
|
2018
|
-
...withTitleTooltip(props),
|
|
2019
|
-
ref: setRef,
|
|
2020
|
-
id: inputId,
|
|
2021
|
-
className: "sia-input",
|
|
2022
|
-
disabled,
|
|
2023
|
-
value,
|
|
2024
|
-
defaultValue,
|
|
2025
|
-
maxLength,
|
|
2026
|
-
placeholder,
|
|
2027
|
-
"aria-describedby": describedBy,
|
|
2028
|
-
"aria-invalid": status === "error" || void 0,
|
|
2029
|
-
onChange: handleChange
|
|
2030
|
-
}
|
|
2031
|
-
);
|
|
2032
|
-
const control = /* @__PURE__ */ jsxs6("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: [
|
|
2033
|
-
prefix ? /* @__PURE__ */ jsx7("span", { className: "sia-input-control__affix", children: prefix }) : null,
|
|
2034
|
-
floatingPlaceholder ? /* @__PURE__ */ jsxs6("span", { className: "sia-input-control__input-wrap", children: [
|
|
2035
|
-
input,
|
|
2036
|
-
/* @__PURE__ */ jsx7("span", { className: "sia-input-control__floating-placeholder", "aria-hidden": "true", children: placeholder })
|
|
2037
|
-
] }) : input,
|
|
2038
|
-
allowClear && hasValue && !disabled ? /* @__PURE__ */ jsx7("button", { className: "sia-input-control__clear", type: "button", "aria-label": "\u6E05\u7A7A\u8F93\u5165", onClick: clearValue, children: /* @__PURE__ */ jsx7(Icon, { name: "circle-close", variant: "filled", size: 15 }) }) : null,
|
|
2039
|
-
suffix ? /* @__PURE__ */ jsx7("span", { className: "sia-input-control__affix", children: suffix }) : null,
|
|
2040
|
-
expandable && !disabled && !props.readOnly && (!props.type || props.type === "text") ? /* @__PURE__ */ jsx7(
|
|
2041
|
-
"button",
|
|
2042
|
-
{
|
|
2043
|
-
type: "button",
|
|
2044
|
-
className: "sia-input-control__expand",
|
|
2045
|
-
"aria-label": "\u5C55\u5F00\u7F16\u8F91",
|
|
2046
|
-
title: "\u5C55\u5F00\u7F16\u8F91",
|
|
2047
|
-
onClick: () => {
|
|
2048
|
-
if (localRef.current?.matches(":disabled")) return;
|
|
2049
|
-
setExpandedDraft(currentText);
|
|
2050
|
-
setExpanded(true);
|
|
2051
|
-
},
|
|
2052
|
-
children: /* @__PURE__ */ jsx7(Icon, { name: "expand", size: 15 })
|
|
2053
|
-
}
|
|
2054
|
-
) : null,
|
|
2055
|
-
showCount ? /* @__PURE__ */ jsxs6("span", { className: `sia-input-control__count${maxLength !== void 0 && currentText.length >= maxLength ? " is-limit" : ""}`, "aria-live": "polite", children: [
|
|
2056
|
-
currentText.length,
|
|
2057
|
-
maxLength !== void 0 ? `/${maxLength}` : null
|
|
2058
|
-
] }) : null
|
|
2059
|
-
] });
|
|
2060
|
-
const editor = expandable ? /* @__PURE__ */ jsx7(
|
|
2061
|
-
Modal2,
|
|
2062
|
-
{
|
|
2063
|
-
open: expanded,
|
|
2064
|
-
title: "\u5C55\u5F00\u7F16\u8F91",
|
|
2065
|
-
okText: "\u786E\u5B9A",
|
|
2066
|
-
cancelText: "\u53D6\u6D88",
|
|
2067
|
-
onCancel: () => setExpanded(false),
|
|
2068
|
-
afterOpenChange: (open) => {
|
|
2069
|
-
if (!open) setExpandedDraft("");
|
|
2070
|
-
},
|
|
2071
|
-
onOk: () => {
|
|
2072
|
-
const target = localRef.current;
|
|
2073
|
-
if (!target || target.matches(":disabled") || props.readOnly) return false;
|
|
2074
|
-
const normalized = expandedDraft.replace(/\r\n|[\r\n]/g, " ");
|
|
2075
|
-
const next = maxLength !== void 0 && maxLength >= 0 ? normalized.slice(0, maxLength) : normalized;
|
|
2076
|
-
Object.getOwnPropertyDescriptor(HTMLInputElement.prototype, "value")?.set?.call(target, next);
|
|
2077
|
-
target.dispatchEvent(new Event("input", { bubbles: true }));
|
|
2078
|
-
setUncontrolledValue(next);
|
|
2079
|
-
setExpanded(false);
|
|
2080
|
-
},
|
|
2081
|
-
children: /* @__PURE__ */ jsx7(
|
|
2082
|
-
TextArea,
|
|
2083
|
-
{
|
|
2084
|
-
"aria-label": "\u5C55\u5F00\u7F16\u8F91\u5185\u5BB9",
|
|
2085
|
-
value: expandedDraft,
|
|
2086
|
-
onChange: (event) => setExpandedDraft(event.target.value),
|
|
2087
|
-
maxLength,
|
|
2088
|
-
showCount,
|
|
2089
|
-
placeholder,
|
|
2090
|
-
rows: 8,
|
|
2091
|
-
disabled,
|
|
2092
|
-
readOnly: props.readOnly
|
|
2093
|
-
}
|
|
2094
|
-
)
|
|
2095
|
-
}
|
|
2096
|
-
) : null;
|
|
2097
|
-
if (!label && !hint) return /* @__PURE__ */ jsxs6(Fragment5, { children: [
|
|
2098
|
-
/* @__PURE__ */ jsx7("span", { className: `sia-field ${className}`.trim(), children: control }),
|
|
2099
|
-
editor
|
|
2100
|
-
] });
|
|
2101
|
-
return /* @__PURE__ */ jsxs6(Fragment5, { children: [
|
|
2102
|
-
/* @__PURE__ */ jsxs6("span", { className: `sia-field ${className}`.trim(), children: [
|
|
2103
|
-
label ? /* @__PURE__ */ jsx7("label", { className: "sia-field__label", htmlFor: inputId, children: label }) : null,
|
|
2104
|
-
control,
|
|
2105
|
-
hint ? /* @__PURE__ */ jsx7("span", { id: hintId, className: `sia-field__hint sia-field__hint--${status}`, children: hint }) : null
|
|
2106
|
-
] }),
|
|
2107
|
-
editor
|
|
2108
|
-
] });
|
|
2109
|
-
});
|
|
2110
|
-
|
|
2111
1427
|
export {
|
|
2112
1428
|
ICON_NAMES,
|
|
2113
1429
|
FILLED_ICON_NAMES,
|
|
2114
1430
|
Icon,
|
|
2115
|
-
Menu,
|
|
2116
|
-
Steps,
|
|
2117
|
-
Segmented,
|
|
2118
|
-
Dropdown,
|
|
2119
1431
|
useOverlayLifecycle,
|
|
2120
1432
|
OverlayPortal,
|
|
2121
|
-
Modal2 as Modal
|
|
2122
|
-
Input
|
|
1433
|
+
Modal2 as Modal
|
|
2123
1434
|
};
|