@sia.soul/sia-react-ui 0.1.77 → 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-K5OU5NOT.js → chunk-Y4Y2NVBM.js} +2 -2
- 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 +1006 -943
- package/dist/index.css +19 -0
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- 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.cjs +305 -178
- 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
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import {
|
|
2
2
|
Dropdown,
|
|
3
3
|
Icon,
|
|
4
|
-
Input
|
|
5
|
-
|
|
4
|
+
Input,
|
|
5
|
+
Modal
|
|
6
|
+
} from "./chunk-XHLIIDD2.js";
|
|
6
7
|
import {
|
|
7
8
|
Button
|
|
8
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-JZWTTSOZ.js";
|
|
9
10
|
import {
|
|
10
11
|
ControlSizeContext,
|
|
11
12
|
PopupPortal,
|
|
@@ -1147,330 +1148,9 @@ function Tree({
|
|
|
1147
1148
|
] });
|
|
1148
1149
|
}
|
|
1149
1150
|
|
|
1150
|
-
// src/components/Modal.tsx
|
|
1151
|
-
import { forwardRef as forwardRef2, useEffect as useEffect6, useId as useId3, useRef as useRef4, useState as useState2 } from "react";
|
|
1152
|
-
import { createRoot } from "react-dom/client";
|
|
1153
|
-
|
|
1154
|
-
// src/components/Overlay.tsx
|
|
1155
|
-
import { useEffect as useEffect5, useRef as useRef3 } from "react";
|
|
1156
|
-
import { createPortal as createPortal2 } from "react-dom";
|
|
1157
|
-
var bodyLockCount = 0;
|
|
1158
|
-
var previousBodyOverflow = "";
|
|
1159
|
-
var overlayStack = [];
|
|
1160
|
-
function lockBodyScroll() {
|
|
1161
|
-
if (bodyLockCount === 0) {
|
|
1162
|
-
previousBodyOverflow = document.body.style.overflow;
|
|
1163
|
-
document.body.style.overflow = "hidden";
|
|
1164
|
-
}
|
|
1165
|
-
bodyLockCount += 1;
|
|
1166
|
-
return () => {
|
|
1167
|
-
bodyLockCount = Math.max(0, bodyLockCount - 1);
|
|
1168
|
-
if (bodyLockCount === 0) document.body.style.overflow = previousBodyOverflow;
|
|
1169
|
-
};
|
|
1170
|
-
}
|
|
1171
|
-
function focusableElements(container) {
|
|
1172
|
-
return [...container.querySelectorAll(
|
|
1173
|
-
'a[href], button:not([disabled]), input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])'
|
|
1174
|
-
)].filter((element) => !element.hidden && element.getAttribute("aria-hidden") !== "true");
|
|
1175
|
-
}
|
|
1176
|
-
function useOverlayLifecycle(open, panelRef, onRequestClose, keyboard = true) {
|
|
1177
|
-
const overlayIdRef = useRef3(/* @__PURE__ */ Symbol("sia-overlay"));
|
|
1178
|
-
const closeRef = useRef3(onRequestClose);
|
|
1179
|
-
closeRef.current = onRequestClose;
|
|
1180
|
-
useEffect5(() => {
|
|
1181
|
-
if (!open || typeof document === "undefined") return void 0;
|
|
1182
|
-
const overlayId = overlayIdRef.current;
|
|
1183
|
-
const previouslyFocused = document.activeElement instanceof HTMLElement ? document.activeElement : null;
|
|
1184
|
-
overlayStack.push(overlayId);
|
|
1185
|
-
const unlockBody = lockBodyScroll();
|
|
1186
|
-
const focusTimer = window.setTimeout(() => {
|
|
1187
|
-
const panel = panelRef.current;
|
|
1188
|
-
if (!panel) return;
|
|
1189
|
-
const [firstFocusable] = focusableElements(panel);
|
|
1190
|
-
(firstFocusable ?? panel).focus({ preventScroll: true });
|
|
1191
|
-
}, 0);
|
|
1192
|
-
function handleKeyDown(event) {
|
|
1193
|
-
if (overlayStack.at(-1) !== overlayId) return;
|
|
1194
|
-
if (event.key === "Escape" && keyboard) {
|
|
1195
|
-
event.preventDefault();
|
|
1196
|
-
closeRef.current();
|
|
1197
|
-
return;
|
|
1198
|
-
}
|
|
1199
|
-
if (event.key !== "Tab" || !panelRef.current) return;
|
|
1200
|
-
const focusable = focusableElements(panelRef.current);
|
|
1201
|
-
if (focusable.length === 0) {
|
|
1202
|
-
event.preventDefault();
|
|
1203
|
-
panelRef.current.focus();
|
|
1204
|
-
return;
|
|
1205
|
-
}
|
|
1206
|
-
const first = focusable[0];
|
|
1207
|
-
const last = focusable.at(-1);
|
|
1208
|
-
if (event.shiftKey && document.activeElement === first) {
|
|
1209
|
-
event.preventDefault();
|
|
1210
|
-
last.focus();
|
|
1211
|
-
} else if (!event.shiftKey && document.activeElement === last) {
|
|
1212
|
-
event.preventDefault();
|
|
1213
|
-
first.focus();
|
|
1214
|
-
}
|
|
1215
|
-
}
|
|
1216
|
-
document.addEventListener("keydown", handleKeyDown);
|
|
1217
|
-
return () => {
|
|
1218
|
-
window.clearTimeout(focusTimer);
|
|
1219
|
-
document.removeEventListener("keydown", handleKeyDown);
|
|
1220
|
-
const index = overlayStack.lastIndexOf(overlayId);
|
|
1221
|
-
if (index >= 0) overlayStack.splice(index, 1);
|
|
1222
|
-
unlockBody();
|
|
1223
|
-
previouslyFocused?.focus({ preventScroll: true });
|
|
1224
|
-
};
|
|
1225
|
-
}, [keyboard, open, panelRef]);
|
|
1226
|
-
}
|
|
1227
|
-
function OverlayPortal({ children, container }) {
|
|
1228
|
-
if (typeof document === "undefined") return null;
|
|
1229
|
-
const target = typeof container === "function" ? container() : container ?? document.body;
|
|
1230
|
-
return createPortal2(children, target);
|
|
1231
|
-
}
|
|
1232
|
-
|
|
1233
|
-
// src/components/Modal.tsx
|
|
1234
|
-
import { Fragment as Fragment2, jsx as jsx3, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
1235
|
-
var modalHandles = /* @__PURE__ */ new Set();
|
|
1236
|
-
var MODAL_MOTION_DURATION = 220;
|
|
1237
|
-
var typeIcons = {
|
|
1238
|
-
info: /* @__PURE__ */ jsx3(Icon, { name: "info", size: 23 }),
|
|
1239
|
-
success: /* @__PURE__ */ jsx3(Icon, { name: "circle-check", size: 23 }),
|
|
1240
|
-
warning: /* @__PURE__ */ jsx3(Icon, { name: "warning", size: 23 }),
|
|
1241
|
-
error: /* @__PURE__ */ jsx3(Icon, { name: "circle-close", size: 23 }),
|
|
1242
|
-
confirm: /* @__PURE__ */ jsx3(Icon, { name: "question", size: 23 })
|
|
1243
|
-
};
|
|
1244
|
-
var ModalRoot = forwardRef2(function Modal({
|
|
1245
|
-
open,
|
|
1246
|
-
title,
|
|
1247
|
-
children,
|
|
1248
|
-
footer,
|
|
1249
|
-
footerExtra,
|
|
1250
|
-
type = "default",
|
|
1251
|
-
okText = "\u786E\u5B9A",
|
|
1252
|
-
cancelText = "\u53D6\u6D88",
|
|
1253
|
-
showCancel = type === "default" || type === "confirm",
|
|
1254
|
-
confirmLoading = false,
|
|
1255
|
-
okButtonProps,
|
|
1256
|
-
cancelButtonProps,
|
|
1257
|
-
closable = true,
|
|
1258
|
-
maskClosable = true,
|
|
1259
|
-
keyboard = true,
|
|
1260
|
-
centered = false,
|
|
1261
|
-
width = 520,
|
|
1262
|
-
height,
|
|
1263
|
-
zIndex = 1e3,
|
|
1264
|
-
getContainer,
|
|
1265
|
-
onOk,
|
|
1266
|
-
onCancel,
|
|
1267
|
-
onOpenChange,
|
|
1268
|
-
afterOpenChange,
|
|
1269
|
-
className = "",
|
|
1270
|
-
style,
|
|
1271
|
-
...props
|
|
1272
|
-
}, forwardedRef) {
|
|
1273
|
-
const localRef = useRef4(null);
|
|
1274
|
-
const titleId = useId3();
|
|
1275
|
-
const [submitting, setSubmitting] = useState2(false);
|
|
1276
|
-
const [rendered, setRendered] = useState2(open);
|
|
1277
|
-
const [closing, setClosing] = useState2(false);
|
|
1278
|
-
const afterOpenChangeRef = useRef4(afterOpenChange);
|
|
1279
|
-
afterOpenChangeRef.current = afterOpenChange;
|
|
1280
|
-
const submitLock = useRef4(false);
|
|
1281
|
-
useEffect6(() => {
|
|
1282
|
-
if (!open || !rendered) return void 0;
|
|
1283
|
-
const timer = window.setTimeout(() => afterOpenChangeRef.current?.(true), MODAL_MOTION_DURATION);
|
|
1284
|
-
return () => window.clearTimeout(timer);
|
|
1285
|
-
}, [open, rendered]);
|
|
1286
|
-
useEffect6(() => {
|
|
1287
|
-
if (open) {
|
|
1288
|
-
setRendered(true);
|
|
1289
|
-
setClosing(false);
|
|
1290
|
-
return void 0;
|
|
1291
|
-
}
|
|
1292
|
-
if (!rendered) return void 0;
|
|
1293
|
-
setClosing(true);
|
|
1294
|
-
const timer = window.setTimeout(() => {
|
|
1295
|
-
setRendered(false);
|
|
1296
|
-
setClosing(false);
|
|
1297
|
-
afterOpenChangeRef.current?.(false);
|
|
1298
|
-
}, MODAL_MOTION_DURATION);
|
|
1299
|
-
return () => window.clearTimeout(timer);
|
|
1300
|
-
}, [open, rendered]);
|
|
1301
|
-
function setRef(node) {
|
|
1302
|
-
localRef.current = node;
|
|
1303
|
-
if (typeof forwardedRef === "function") forwardedRef(node);
|
|
1304
|
-
else if (forwardedRef) forwardedRef.current = node;
|
|
1305
|
-
}
|
|
1306
|
-
function requestClose() {
|
|
1307
|
-
if (submitting || confirmLoading) return;
|
|
1308
|
-
onCancel?.();
|
|
1309
|
-
onOpenChange?.(false);
|
|
1310
|
-
}
|
|
1311
|
-
async function handleOk() {
|
|
1312
|
-
if (submitLock.current || confirmLoading) return;
|
|
1313
|
-
submitLock.current = true;
|
|
1314
|
-
if (!onOk) {
|
|
1315
|
-
onOpenChange?.(false);
|
|
1316
|
-
submitLock.current = false;
|
|
1317
|
-
return;
|
|
1318
|
-
}
|
|
1319
|
-
try {
|
|
1320
|
-
const result = onOk();
|
|
1321
|
-
if (result instanceof Promise) {
|
|
1322
|
-
setSubmitting(true);
|
|
1323
|
-
const resolved = await result;
|
|
1324
|
-
if (resolved !== false) onOpenChange?.(false);
|
|
1325
|
-
} else if (result !== false) {
|
|
1326
|
-
onOpenChange?.(false);
|
|
1327
|
-
}
|
|
1328
|
-
} catch {
|
|
1329
|
-
return;
|
|
1330
|
-
} finally {
|
|
1331
|
-
submitLock.current = false;
|
|
1332
|
-
setSubmitting(false);
|
|
1333
|
-
}
|
|
1334
|
-
}
|
|
1335
|
-
useOverlayLifecycle(rendered, localRef, requestClose, keyboard);
|
|
1336
|
-
if (!rendered) return null;
|
|
1337
|
-
const mergedStyle = {
|
|
1338
|
-
...height !== void 0 ? { display: "flex", flexDirection: "column", height, maxHeight: "calc(100dvh - 48px)" } : {},
|
|
1339
|
-
...style,
|
|
1340
|
-
"--sia-modal-width": typeof width === "number" ? `${width}px` : width
|
|
1341
|
-
};
|
|
1342
|
-
const loading = submitting || confirmLoading;
|
|
1343
|
-
const defaultFooter = /* @__PURE__ */ jsxs3(Fragment2, { children: [
|
|
1344
|
-
showCancel ? /* @__PURE__ */ jsx3(Button, { ...cancelButtonProps, onClick: requestClose, disabled: loading || cancelButtonProps?.disabled, children: cancelText }) : null,
|
|
1345
|
-
/* @__PURE__ */ jsx3(Button, { variant: "primary", ...okButtonProps, onClick: handleOk, loading, children: okText })
|
|
1346
|
-
] });
|
|
1347
|
-
return /* @__PURE__ */ jsx3(OverlayPortal, { container: getContainer, children: /* @__PURE__ */ jsx3(
|
|
1348
|
-
"div",
|
|
1349
|
-
{
|
|
1350
|
-
className: `sia-modal-root${centered ? " sia-modal-root--centered" : ""}`,
|
|
1351
|
-
"data-state": closing ? "closing" : "open",
|
|
1352
|
-
style: { zIndex },
|
|
1353
|
-
onMouseDown: (event) => {
|
|
1354
|
-
if (event.target === event.currentTarget && maskClosable) requestClose();
|
|
1355
|
-
},
|
|
1356
|
-
children: /* @__PURE__ */ jsxs3(
|
|
1357
|
-
"div",
|
|
1358
|
-
{
|
|
1359
|
-
ref: setRef,
|
|
1360
|
-
className: `sia-modal sia-modal--${type} ${className}`.trim(),
|
|
1361
|
-
style: mergedStyle,
|
|
1362
|
-
role: "dialog",
|
|
1363
|
-
"aria-modal": "true",
|
|
1364
|
-
"aria-labelledby": title ? titleId : void 0,
|
|
1365
|
-
tabIndex: -1,
|
|
1366
|
-
...withTitleTooltip(props),
|
|
1367
|
-
children: [
|
|
1368
|
-
/* @__PURE__ */ jsxs3("div", { className: "sia-modal__header", style: height !== void 0 ? { flexShrink: 0 } : void 0, children: [
|
|
1369
|
-
/* @__PURE__ */ jsxs3("div", { className: "sia-modal__heading", children: [
|
|
1370
|
-
typeIcons[type] ? /* @__PURE__ */ jsx3("span", { className: "sia-modal__type-icon", "aria-hidden": "true", children: typeIcons[type] }) : null,
|
|
1371
|
-
title ? /* @__PURE__ */ jsx3("strong", { id: titleId, children: title }) : null
|
|
1372
|
-
] }),
|
|
1373
|
-
closable ? /* @__PURE__ */ jsx3("button", { type: "button", className: "sia-modal__close", "aria-label": "\u5173\u95ED\u5BF9\u8BDD\u6846", onClick: requestClose, children: /* @__PURE__ */ jsx3(Icon, { name: "close", size: 17 }) }) : null
|
|
1374
|
-
] }),
|
|
1375
|
-
children !== void 0 ? /* @__PURE__ */ jsx3("div", { className: "sia-modal__body", style: height !== void 0 ? { flex: 1, minHeight: 0, overflow: "auto" } : void 0, children }) : null,
|
|
1376
|
-
footer !== null ? /* @__PURE__ */ jsxs3("div", { className: "sia-modal__footer", style: height !== void 0 ? { flexShrink: 0 } : void 0, children: [
|
|
1377
|
-
footer === void 0 && footerExtra != null ? /* @__PURE__ */ jsx3("div", { style: { marginRight: "auto" }, children: footerExtra }) : null,
|
|
1378
|
-
footer ?? defaultFooter
|
|
1379
|
-
] }) : null
|
|
1380
|
-
]
|
|
1381
|
-
}
|
|
1382
|
-
)
|
|
1383
|
-
}
|
|
1384
|
-
) });
|
|
1385
|
-
});
|
|
1386
|
-
function openModal(config) {
|
|
1387
|
-
if (typeof document === "undefined") return { destroy() {
|
|
1388
|
-
}, update() {
|
|
1389
|
-
} };
|
|
1390
|
-
const container = document.createElement("div");
|
|
1391
|
-
container.className = "sia-modal-api-host";
|
|
1392
|
-
document.body.appendChild(container);
|
|
1393
|
-
const root = createRoot(container);
|
|
1394
|
-
let currentConfig = config;
|
|
1395
|
-
let currentOpen = true;
|
|
1396
|
-
let destroyed = false;
|
|
1397
|
-
let mounted = false;
|
|
1398
|
-
function cleanup2() {
|
|
1399
|
-
if (destroyed) return;
|
|
1400
|
-
destroyed = true;
|
|
1401
|
-
root.unmount();
|
|
1402
|
-
container.remove();
|
|
1403
|
-
modalHandles.delete(handle);
|
|
1404
|
-
}
|
|
1405
|
-
function closeWithMotion() {
|
|
1406
|
-
if (destroyed || !currentOpen) return;
|
|
1407
|
-
currentOpen = false;
|
|
1408
|
-
render();
|
|
1409
|
-
}
|
|
1410
|
-
function ModalInstance() {
|
|
1411
|
-
useEffect6(() => {
|
|
1412
|
-
mounted = true;
|
|
1413
|
-
if (!currentOpen) render();
|
|
1414
|
-
}, []);
|
|
1415
|
-
return /* @__PURE__ */ jsx3(ModalRoot, { ...currentConfig, open: !mounted || currentOpen, onOpenChange: (nextOpen) => {
|
|
1416
|
-
currentConfig.onOpenChange?.(nextOpen);
|
|
1417
|
-
if (!nextOpen) closeWithMotion();
|
|
1418
|
-
}, afterOpenChange: (nextOpen) => {
|
|
1419
|
-
try {
|
|
1420
|
-
currentConfig.afterOpenChange?.(nextOpen);
|
|
1421
|
-
} finally {
|
|
1422
|
-
if (!nextOpen) queueMicrotask(cleanup2);
|
|
1423
|
-
}
|
|
1424
|
-
} });
|
|
1425
|
-
}
|
|
1426
|
-
function render() {
|
|
1427
|
-
root.render(/* @__PURE__ */ jsx3(ModalInstance, {}));
|
|
1428
|
-
}
|
|
1429
|
-
const handle = {
|
|
1430
|
-
destroy: closeWithMotion,
|
|
1431
|
-
update(next) {
|
|
1432
|
-
if (destroyed) return;
|
|
1433
|
-
currentConfig = { ...currentConfig, ...next };
|
|
1434
|
-
render();
|
|
1435
|
-
}
|
|
1436
|
-
};
|
|
1437
|
-
modalHandles.add(handle);
|
|
1438
|
-
render();
|
|
1439
|
-
return handle;
|
|
1440
|
-
}
|
|
1441
|
-
function preset(type, defaults = {}) {
|
|
1442
|
-
return (config) => openModal({
|
|
1443
|
-
okText: type === "confirm" ? "\u786E\u5B9A" : "\u77E5\u9053\u4E86",
|
|
1444
|
-
showCancel: type === "confirm",
|
|
1445
|
-
closable: type !== "confirm",
|
|
1446
|
-
maskClosable: type !== "confirm",
|
|
1447
|
-
...defaults,
|
|
1448
|
-
...config,
|
|
1449
|
-
type
|
|
1450
|
-
});
|
|
1451
|
-
}
|
|
1452
|
-
var Modal2 = Object.assign(ModalRoot, {
|
|
1453
|
-
/** 直接打开实例,返回更新和关闭句柄;关闭动画完成后先调用 afterOpenChange(false),再卸载实例。 */
|
|
1454
|
-
open: openModal,
|
|
1455
|
-
/** 显示普通信息提示。 */
|
|
1456
|
-
info: preset("info", { title: "\u63D0\u793A" }),
|
|
1457
|
-
/** 显示成功提示。 */
|
|
1458
|
-
success: preset("success", { title: "\u64CD\u4F5C\u6210\u529F" }),
|
|
1459
|
-
/** 显示警告提示。 */
|
|
1460
|
-
warning: preset("warning", { title: "\u8BF7\u6CE8\u610F" }),
|
|
1461
|
-
/** 显示错误提示。 */
|
|
1462
|
-
error: preset("error", { title: "\u64CD\u4F5C\u5931\u8D25" }),
|
|
1463
|
-
/** 打开确认弹框,支持异步确认;返回 false 可阻止关闭。 */
|
|
1464
|
-
confirm: preset("confirm", { title: "\u786E\u8BA4\u64CD\u4F5C" }),
|
|
1465
|
-
/** 关闭由此 API 打开的所有弹层。 */
|
|
1466
|
-
destroyAll() {
|
|
1467
|
-
[...modalHandles].forEach((handle) => handle.destroy());
|
|
1468
|
-
}
|
|
1469
|
-
});
|
|
1470
|
-
|
|
1471
1151
|
// src/components/SelectionPanel.tsx
|
|
1472
|
-
import { useEffect as
|
|
1473
|
-
import { jsx as
|
|
1152
|
+
import { useEffect as useEffect5, useId as useId3, useMemo as useMemo3, useRef as useRef3, useState as useState2 } from "react";
|
|
1153
|
+
import { jsx as jsx3, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
1474
1154
|
function SelectionPanel({
|
|
1475
1155
|
options,
|
|
1476
1156
|
value,
|
|
@@ -1491,14 +1171,14 @@ function SelectionPanel({
|
|
|
1491
1171
|
maxHeight = 250,
|
|
1492
1172
|
autoFocusSearch = false
|
|
1493
1173
|
}) {
|
|
1494
|
-
const [localSearch, setLocalSearch] =
|
|
1174
|
+
const [localSearch, setLocalSearch] = useState2("");
|
|
1495
1175
|
const search = searchValue ?? localSearch;
|
|
1496
|
-
const [scrollTop, setScrollTop] =
|
|
1497
|
-
const [active, setActive] =
|
|
1498
|
-
const [keyboardActive, setKeyboardActive] =
|
|
1499
|
-
const [deselectedHover, setDeselectedHover] =
|
|
1500
|
-
const listRef =
|
|
1501
|
-
const id =
|
|
1176
|
+
const [scrollTop, setScrollTop] = useState2(0);
|
|
1177
|
+
const [active, setActive] = useState2();
|
|
1178
|
+
const [keyboardActive, setKeyboardActive] = useState2(false);
|
|
1179
|
+
const [deselectedHover, setDeselectedHover] = useState2();
|
|
1180
|
+
const listRef = useRef3(null);
|
|
1181
|
+
const id = useId3();
|
|
1502
1182
|
const selected = useMemo3(() => new Set(value), [value]);
|
|
1503
1183
|
const count = Math.max(1, Math.floor(columns));
|
|
1504
1184
|
const allOptions = useMemo3(() => {
|
|
@@ -1536,7 +1216,7 @@ function SelectionPanel({
|
|
|
1536
1216
|
const virtual = filtered.length > 100;
|
|
1537
1217
|
const renderedRows = virtual ? rows.filter((row) => row.top + row.height >= scrollTop - 100 && row.top <= scrollTop + maxHeight + 100) : rows;
|
|
1538
1218
|
const enabled = filtered.filter((option) => !option.disabled && option.optionType !== "divider");
|
|
1539
|
-
|
|
1219
|
+
useEffect5(() => {
|
|
1540
1220
|
setScrollTop(0);
|
|
1541
1221
|
if (listRef.current) listRef.current.scrollTop = 0;
|
|
1542
1222
|
setActive(void 0);
|
|
@@ -1559,9 +1239,9 @@ function SelectionPanel({
|
|
|
1559
1239
|
const add = enabled.filter((option) => operation === "all" || !selected.has(option.value)).map((option) => option.value);
|
|
1560
1240
|
onChange([...retained, ...add]);
|
|
1561
1241
|
}
|
|
1562
|
-
return /* @__PURE__ */
|
|
1563
|
-
/* @__PURE__ */
|
|
1564
|
-
showSearch && /* @__PURE__ */
|
|
1242
|
+
return /* @__PURE__ */ jsxs3("div", { className: "sia-selection-panel", children: [
|
|
1243
|
+
/* @__PURE__ */ jsx3(FloatingScrollbarProvider, { targetRef: listRef }),
|
|
1244
|
+
showSearch && /* @__PURE__ */ jsx3(
|
|
1565
1245
|
Input,
|
|
1566
1246
|
{
|
|
1567
1247
|
"aria-label": "\u641C\u7D22\u9009\u9879",
|
|
@@ -1575,17 +1255,17 @@ function SelectionPanel({
|
|
|
1575
1255
|
}
|
|
1576
1256
|
}
|
|
1577
1257
|
),
|
|
1578
|
-
multiple && showActions && /* @__PURE__ */
|
|
1579
|
-
/* @__PURE__ */
|
|
1580
|
-
/* @__PURE__ */
|
|
1581
|
-
/* @__PURE__ */
|
|
1582
|
-
/* @__PURE__ */
|
|
1258
|
+
multiple && showActions && /* @__PURE__ */ jsxs3("div", { className: "sia-selection-panel__actions", children: [
|
|
1259
|
+
/* @__PURE__ */ jsx3(Button, { variant: "link", size: "small", disabled: disabled || loading || !enabled.length, onClick: () => batch("all"), children: "\u5168\u9009" }),
|
|
1260
|
+
/* @__PURE__ */ jsx3(Button, { variant: "link", size: "small", disabled: disabled || loading || !enabled.length, onClick: () => batch("invert"), children: "\u53CD\u9009" }),
|
|
1261
|
+
/* @__PURE__ */ jsx3(Button, { variant: "link", size: "small", disabled: disabled || loading || !value.length, onClick: () => batch("clear"), children: "\u6E05\u7A7A" }),
|
|
1262
|
+
/* @__PURE__ */ jsxs3("span", { children: [
|
|
1583
1263
|
"\u5DF2\u9009 ",
|
|
1584
1264
|
value.length,
|
|
1585
1265
|
" \u9879"
|
|
1586
1266
|
] })
|
|
1587
1267
|
] }),
|
|
1588
|
-
/* @__PURE__ */
|
|
1268
|
+
/* @__PURE__ */ jsx3(
|
|
1589
1269
|
"div",
|
|
1590
1270
|
{
|
|
1591
1271
|
ref: listRef,
|
|
@@ -1622,12 +1302,12 @@ function SelectionPanel({
|
|
|
1622
1302
|
toggle(enabled[index], true);
|
|
1623
1303
|
}
|
|
1624
1304
|
},
|
|
1625
|
-
children: loading ? /* @__PURE__ */
|
|
1305
|
+
children: loading ? /* @__PURE__ */ jsx3("div", { role: "status", children: "\u52A0\u8F7D\u4E2D\u2026" }) : !rows.length ? /* @__PURE__ */ jsx3("div", { className: "sia-selection-panel__empty", children: "\u6682\u65E0\u5339\u914D\u9009\u9879" }) : /* @__PURE__ */ jsx3("div", { style: { height: totalHeight, position: "relative" }, children: renderedRows.map((row) => /* @__PURE__ */ jsx3(
|
|
1626
1306
|
"div",
|
|
1627
1307
|
{
|
|
1628
1308
|
className: row.title !== void 0 ? "sia-selection-panel__group" : "sia-selection-panel__row",
|
|
1629
1309
|
style: { position: "absolute", top: row.top, height: row.height, width: "100%", gridTemplateColumns: `repeat(${count}, minmax(0, 1fr))` },
|
|
1630
|
-
children: row.title ?? row.items?.map((option, index) => option.optionType === "divider" ? /* @__PURE__ */
|
|
1310
|
+
children: row.title ?? row.items?.map((option, index) => option.optionType === "divider" ? /* @__PURE__ */ jsx3("div", { role: "separator", className: "sia-selection-panel__divider" }, `divider-${index}`) : /* @__PURE__ */ jsx3(Tooltip, { title: option.disabled ? option.disabledTip : void 0, placement: "right", children: /* @__PURE__ */ jsx3(
|
|
1631
1311
|
"div",
|
|
1632
1312
|
{
|
|
1633
1313
|
role: "option",
|
|
@@ -1643,12 +1323,12 @@ function SelectionPanel({
|
|
|
1643
1323
|
onClick: (event) => {
|
|
1644
1324
|
if (!event.target.closest(".sia-checkbox")) toggle(option);
|
|
1645
1325
|
},
|
|
1646
|
-
children: multiple ? /* @__PURE__ */
|
|
1647
|
-
/* @__PURE__ */
|
|
1648
|
-
showValue && /* @__PURE__ */
|
|
1649
|
-
] }) }) : /* @__PURE__ */
|
|
1650
|
-
/* @__PURE__ */
|
|
1651
|
-
showValue && /* @__PURE__ */
|
|
1326
|
+
children: multiple ? /* @__PURE__ */ jsx3(Checkbox2, { checked: selected.has(option.value), disabled: disabled || loading || option.disabled, tabIndex: -1, onChange: () => toggle(option), children: /* @__PURE__ */ jsxs3("span", { className: "sia-selection-panel__text", children: [
|
|
1327
|
+
/* @__PURE__ */ jsx3("span", { className: "sia-selection-panel__label", children: showValue || displayField === "label" ? option.label : String(option.value) }),
|
|
1328
|
+
showValue && /* @__PURE__ */ jsx3("small", { children: String(option.value) })
|
|
1329
|
+
] }) }) : /* @__PURE__ */ jsxs3("span", { className: "sia-selection-panel__text", children: [
|
|
1330
|
+
/* @__PURE__ */ jsx3("span", { className: "sia-selection-panel__label", children: showValue || displayField === "label" ? option.label : String(option.value) }),
|
|
1331
|
+
showValue && /* @__PURE__ */ jsx3("small", { children: String(option.value) })
|
|
1652
1332
|
] })
|
|
1653
1333
|
}
|
|
1654
1334
|
) }, `${typeof option.value}-${option.value}`))
|
|
@@ -1661,16 +1341,16 @@ function SelectionPanel({
|
|
|
1661
1341
|
}
|
|
1662
1342
|
|
|
1663
1343
|
// src/components/Select.tsx
|
|
1664
|
-
import { forwardRef as
|
|
1344
|
+
import { forwardRef as forwardRef2, useDeferredValue, useEffect as useEffect6, useId as useId4, useLayoutEffect as useLayoutEffect3, useMemo as useMemo4, useRef as useRef5, useState as useState4 } from "react";
|
|
1665
1345
|
|
|
1666
1346
|
// src/components/OverflowTags.tsx
|
|
1667
|
-
import { useLayoutEffect as useLayoutEffect2, useRef as
|
|
1668
|
-
import { jsx as
|
|
1347
|
+
import { useLayoutEffect as useLayoutEffect2, useRef as useRef4, useState as useState3 } from "react";
|
|
1348
|
+
import { jsx as jsx4, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
1669
1349
|
function OverflowTags({ items, maxCount, className = "", tagClassName, restClassName = "" }) {
|
|
1670
|
-
const rootRef =
|
|
1671
|
-
const measureRef =
|
|
1350
|
+
const rootRef = useRef4(null);
|
|
1351
|
+
const measureRef = useRef4(null);
|
|
1672
1352
|
const limit = Math.min(items.length, Math.max(0, Math.floor(maxCount) || 0));
|
|
1673
|
-
const [visibleCount, setVisibleCount] =
|
|
1353
|
+
const [visibleCount, setVisibleCount] = useState3(0);
|
|
1674
1354
|
useLayoutEffect2(() => {
|
|
1675
1355
|
const root = rootRef.current;
|
|
1676
1356
|
const measure = measureRef.current;
|
|
@@ -1694,15 +1374,15 @@ function OverflowTags({ items, maxCount, className = "", tagClassName, restClass
|
|
|
1694
1374
|
return () => observer.disconnect();
|
|
1695
1375
|
}, [items, limit]);
|
|
1696
1376
|
const count = Math.min(visibleCount, limit);
|
|
1697
|
-
return /* @__PURE__ */
|
|
1698
|
-
items.slice(0, count).map((item) => /* @__PURE__ */
|
|
1699
|
-
items.length > count ? /* @__PURE__ */
|
|
1377
|
+
return /* @__PURE__ */ jsxs4("span", { ref: rootRef, className: `sia-overflow-tags ${className}`.trim(), children: [
|
|
1378
|
+
items.slice(0, count).map((item) => /* @__PURE__ */ jsx4("span", { className: tagClassName, children: item.label }, item.key)),
|
|
1379
|
+
items.length > count ? /* @__PURE__ */ jsxs4("span", { className: `${tagClassName} sia-overflow-tags__rest ${restClassName}`.trim(), children: [
|
|
1700
1380
|
"+",
|
|
1701
1381
|
items.length - count
|
|
1702
1382
|
] }) : null,
|
|
1703
|
-
/* @__PURE__ */
|
|
1704
|
-
items.slice(0, limit).map((item) => /* @__PURE__ */
|
|
1705
|
-
Array.from({ length: limit + 1 }, (_, index) => /* @__PURE__ */
|
|
1383
|
+
/* @__PURE__ */ jsxs4("span", { ref: measureRef, className: "sia-overflow-tags__measure", "aria-hidden": "true", children: [
|
|
1384
|
+
items.slice(0, limit).map((item) => /* @__PURE__ */ jsx4("span", { className: tagClassName, children: item.label }, item.key)),
|
|
1385
|
+
Array.from({ length: limit + 1 }, (_, index) => /* @__PURE__ */ jsxs4("span", { className: `${tagClassName} ${restClassName}`.trim(), children: [
|
|
1706
1386
|
"+",
|
|
1707
1387
|
items.length - index
|
|
1708
1388
|
] }, `rest-${index}`))
|
|
@@ -1711,12 +1391,12 @@ function OverflowTags({ items, maxCount, className = "", tagClassName, restClass
|
|
|
1711
1391
|
}
|
|
1712
1392
|
|
|
1713
1393
|
// src/components/Select.tsx
|
|
1714
|
-
import { Fragment as
|
|
1394
|
+
import { Fragment as Fragment2, jsx as jsx5, jsxs as jsxs5 } from "react/jsx-runtime";
|
|
1715
1395
|
function defaultFilterOption(query, option) {
|
|
1716
1396
|
const keyword = query.toLowerCase();
|
|
1717
1397
|
return [option.label, option.value].some((value) => String(value).toLowerCase().includes(keyword));
|
|
1718
1398
|
}
|
|
1719
|
-
var Select =
|
|
1399
|
+
var Select = forwardRef2(function Select2({
|
|
1720
1400
|
options,
|
|
1721
1401
|
mode = "single",
|
|
1722
1402
|
popupMode: popupModeProp,
|
|
@@ -1755,26 +1435,26 @@ var Select = forwardRef3(function Select2({
|
|
|
1755
1435
|
}, forwardedRef) {
|
|
1756
1436
|
const showSearch = showSearchProp ?? options.length > 15;
|
|
1757
1437
|
const size = useControlSize(sizeProp);
|
|
1758
|
-
const fallbackId =
|
|
1438
|
+
const fallbackId = useId4();
|
|
1759
1439
|
const selectId = id ?? fallbackId;
|
|
1760
1440
|
const listboxId = `${selectId}-listbox`;
|
|
1761
|
-
const rootRef =
|
|
1762
|
-
const popupRef =
|
|
1763
|
-
const searchRef =
|
|
1764
|
-
const listRef =
|
|
1765
|
-
const [open, setOpen] =
|
|
1441
|
+
const rootRef = useRef5(null);
|
|
1442
|
+
const popupRef = useRef5(null);
|
|
1443
|
+
const searchRef = useRef5(null);
|
|
1444
|
+
const listRef = useRef5(null);
|
|
1445
|
+
const [open, setOpen] = useState4(false);
|
|
1766
1446
|
const automaticMode = popupModeProp ?? (options.length > modalThreshold ? "modal" : "dropdown");
|
|
1767
|
-
const [openedMode, setOpenedMode] =
|
|
1447
|
+
const [openedMode, setOpenedMode] = useState4(automaticMode);
|
|
1768
1448
|
const popupMode = open ? openedMode : automaticMode;
|
|
1769
|
-
const [modalValues, setModalValues] =
|
|
1770
|
-
const [modalSubmitting, setModalSubmitting] =
|
|
1771
|
-
const modalSubmitLock =
|
|
1772
|
-
const [selectedOnly, setSelectedOnly] =
|
|
1773
|
-
const [query, setQuery] =
|
|
1774
|
-
const [activeIndex, setActiveIndex] =
|
|
1775
|
-
const [scrollTop, setScrollTop] =
|
|
1776
|
-
const [dropdownFontSize, setDropdownFontSize] =
|
|
1777
|
-
const pendingSelectedScroll =
|
|
1449
|
+
const [modalValues, setModalValues] = useState4([]);
|
|
1450
|
+
const [modalSubmitting, setModalSubmitting] = useState4(false);
|
|
1451
|
+
const modalSubmitLock = useRef5(false);
|
|
1452
|
+
const [selectedOnly, setSelectedOnly] = useState4(false);
|
|
1453
|
+
const [query, setQuery] = useState4("");
|
|
1454
|
+
const [activeIndex, setActiveIndex] = useState4(-1);
|
|
1455
|
+
const [scrollTop, setScrollTop] = useState4(0);
|
|
1456
|
+
const [dropdownFontSize, setDropdownFontSize] = useState4();
|
|
1457
|
+
const pendingSelectedScroll = useRef5(false);
|
|
1778
1458
|
const deferredQuery = useDeferredValue(query.trim());
|
|
1779
1459
|
const initialValue = defaultValue === void 0 ? mode === "multiple" ? [] : null : defaultValue;
|
|
1780
1460
|
const [currentValue, setCurrentValue] = useControllableState({
|
|
@@ -1817,7 +1497,7 @@ var Select = forwardRef3(function Select2({
|
|
|
1817
1497
|
const renderedOptions = virtualEnabled ? filteredOptions.slice(virtualStart, virtualEnd) : filteredOptions;
|
|
1818
1498
|
const enabledFilteredOptions = filteredOptions.filter((option) => !option.disabled);
|
|
1819
1499
|
const allFilteredSelected = enabledFilteredOptions.length > 0 && enabledFilteredOptions.every((option) => selectedValueSet.has(option.value));
|
|
1820
|
-
|
|
1500
|
+
useEffect6(() => {
|
|
1821
1501
|
if (!open || popupMode === "modal") return void 0;
|
|
1822
1502
|
function closeFromOutside(event) {
|
|
1823
1503
|
const target = event.target;
|
|
@@ -1826,13 +1506,13 @@ var Select = forwardRef3(function Select2({
|
|
|
1826
1506
|
document.addEventListener("mousedown", closeFromOutside);
|
|
1827
1507
|
return () => document.removeEventListener("mousedown", closeFromOutside);
|
|
1828
1508
|
}, [open, popupMode]);
|
|
1829
|
-
|
|
1509
|
+
useEffect6(() => {
|
|
1830
1510
|
if (open && (showSearch || allowInput)) searchRef.current?.focus();
|
|
1831
1511
|
}, [allowInput, open, showSearch]);
|
|
1832
|
-
|
|
1512
|
+
useEffect6(() => {
|
|
1833
1513
|
if (disabled || loading) closeDropdown();
|
|
1834
1514
|
}, [disabled, loading]);
|
|
1835
|
-
|
|
1515
|
+
useEffect6(() => {
|
|
1836
1516
|
if (!open || popupMode !== "dropdown" || !pendingSelectedScroll.current || query) return;
|
|
1837
1517
|
const index = filteredOptions.findIndex((option) => selectedValueSet.has(option.value));
|
|
1838
1518
|
if (index < 0) return;
|
|
@@ -1998,7 +1678,7 @@ var Select = forwardRef3(function Select2({
|
|
|
1998
1678
|
function renderOption(option, renderedIndex) {
|
|
1999
1679
|
const optionIndex = virtualEnabled ? virtualStart + renderedIndex : renderedIndex;
|
|
2000
1680
|
const selected = selectedValueSet.has(option.value);
|
|
2001
|
-
return /* @__PURE__ */
|
|
1681
|
+
return /* @__PURE__ */ jsxs5(
|
|
2002
1682
|
"div",
|
|
2003
1683
|
{
|
|
2004
1684
|
id: `${listboxId}-${optionIndex}`,
|
|
@@ -2011,11 +1691,11 @@ var Select = forwardRef3(function Select2({
|
|
|
2011
1691
|
onMouseDown: (event) => event.preventDefault(),
|
|
2012
1692
|
onClick: () => selectOption(option),
|
|
2013
1693
|
children: [
|
|
2014
|
-
/* @__PURE__ */
|
|
2015
|
-
/* @__PURE__ */
|
|
2016
|
-
showValue ? /* @__PURE__ */
|
|
1694
|
+
/* @__PURE__ */ jsxs5("span", { className: "sia-select__option-content", children: [
|
|
1695
|
+
/* @__PURE__ */ jsx5("span", { className: "sia-select__option-label", children: option.label }),
|
|
1696
|
+
showValue ? /* @__PURE__ */ jsx5("small", { className: "sia-select__option-value", children: String(option.value) }) : null
|
|
2017
1697
|
] }),
|
|
2018
|
-
selected ? /* @__PURE__ */
|
|
1698
|
+
selected ? /* @__PURE__ */ jsx5(Icon, { name: "check", size: 15 }) : null
|
|
2019
1699
|
]
|
|
2020
1700
|
},
|
|
2021
1701
|
`${typeof option.value}-${option.value}`
|
|
@@ -2029,8 +1709,8 @@ var Select = forwardRef3(function Select2({
|
|
|
2029
1709
|
setModalValues([...modalValues.filter((value2) => !editable.has(value2)), ...modalEnabled.filter((option) => operation === "all" || operation === "invert" && !modalValues.includes(option.value)).map((option) => option.value)]);
|
|
2030
1710
|
}
|
|
2031
1711
|
const floating = useFloatingPlaceholder({ mode: placeholderMode, placeholder, filled: hasValue, active: open });
|
|
2032
|
-
return /* @__PURE__ */
|
|
2033
|
-
/* @__PURE__ */
|
|
1712
|
+
return /* @__PURE__ */ jsxs5("div", { ref: rootRef, className: `sia-select sia-select--${size} sia-select--${status}${open ? " is-open" : ""}${disabled ? " is-disabled" : ""}${multiple ? " sia-select--multiple" : ""} ${className}`.trim(), style, children: [
|
|
1713
|
+
/* @__PURE__ */ jsxs5(
|
|
2034
1714
|
"button",
|
|
2035
1715
|
{
|
|
2036
1716
|
...withTitleTooltip(props),
|
|
@@ -2048,29 +1728,29 @@ var Select = forwardRef3(function Select2({
|
|
|
2048
1728
|
onClick: () => open ? closeDropdown() : openDropdown(),
|
|
2049
1729
|
onKeyDown: handleTriggerKeyDown,
|
|
2050
1730
|
children: [
|
|
2051
|
-
multiple && hasValue ? /* @__PURE__ */
|
|
2052
|
-
loading ? /* @__PURE__ */
|
|
1731
|
+
multiple && hasValue ? /* @__PURE__ */ jsx5(OverflowTags, { className: "sia-select__tags", tagClassName: "sia-select__tag", restClassName: "sia-select__tag--rest", maxCount: maxTagCount, items: selectedOptions.map((option) => ({ key: `${typeof option.value}-${option.value}`, label: option.label })) }) : /* @__PURE__ */ jsx5("span", { className: `sia-select__value${hasValue ? "" : " is-placeholder"}`, children: selectedOptions[0]?.label ?? placeholder }),
|
|
1732
|
+
loading ? /* @__PURE__ */ jsx5("span", { className: "sia-select__spinner", "aria-hidden": "true" }) : null,
|
|
2053
1733
|
floating.label,
|
|
2054
|
-
/* @__PURE__ */
|
|
1734
|
+
/* @__PURE__ */ jsx5(Icon, { className: "sia-select__arrow", name: "chevron-down", size: 15 })
|
|
2055
1735
|
]
|
|
2056
1736
|
}
|
|
2057
1737
|
),
|
|
2058
|
-
allowClear && hasValue && !disabled && !loading ? /* @__PURE__ */
|
|
2059
|
-
/* @__PURE__ */
|
|
2060
|
-
/* @__PURE__ */
|
|
2061
|
-
showSearch || allowInput ? /* @__PURE__ */
|
|
2062
|
-
/* @__PURE__ */
|
|
2063
|
-
/* @__PURE__ */
|
|
1738
|
+
allowClear && hasValue && !disabled && !loading ? /* @__PURE__ */ jsx5("button", { className: "sia-select__clear", type: "button", "aria-label": "\u6E05\u7A7A\u9009\u62E9", onClick: clearValue, children: /* @__PURE__ */ jsx5(Icon, { name: "circle-close", variant: "filled", size: 15 }) }) : null,
|
|
1739
|
+
/* @__PURE__ */ jsxs5(PopupPortal, { ref: popupRef, anchorRef: rootRef, open: open && popupMode === "dropdown", style: { fontSize: dropdownFontSize }, className: `sia-select__dropdown${filteredOptions.length === 0 && !canSubmitInput ? " sia-select__dropdown--empty" : ""}`, children: [
|
|
1740
|
+
/* @__PURE__ */ jsx5(FloatingScrollbarProvider, { targetRef: listRef }),
|
|
1741
|
+
showSearch || allowInput ? /* @__PURE__ */ jsxs5("label", { className: "sia-select__search", children: [
|
|
1742
|
+
/* @__PURE__ */ jsx5(Icon, { name: "search", size: 15 }),
|
|
1743
|
+
/* @__PURE__ */ jsx5("input", { ref: searchRef, value: query, maxLength: inputMaxLength, onChange: handleSearchChange, onKeyDown: (event) => handleInteractionKeyDown(event, true), placeholder: searchPlaceholder, "aria-label": searchPlaceholder })
|
|
2064
1744
|
] }) : null,
|
|
2065
|
-
canSubmitInput ? /* @__PURE__ */
|
|
2066
|
-
/* @__PURE__ */
|
|
2067
|
-
/* @__PURE__ */
|
|
1745
|
+
canSubmitInput ? /* @__PURE__ */ jsxs5("button", { type: "button", className: "sia-select__input-option", onMouseDown: (event) => event.preventDefault(), onClick: submitInputValue, children: [
|
|
1746
|
+
/* @__PURE__ */ jsx5(Icon, { name: "plus", size: 14 }),
|
|
1747
|
+
/* @__PURE__ */ jsxs5("span", { children: [
|
|
2068
1748
|
"\u4F7F\u7528\u201C",
|
|
2069
1749
|
inputValue,
|
|
2070
1750
|
"\u201D"
|
|
2071
1751
|
] })
|
|
2072
1752
|
] }) : null,
|
|
2073
|
-
/* @__PURE__ */
|
|
1753
|
+
/* @__PURE__ */ jsx5(
|
|
2074
1754
|
"div",
|
|
2075
1755
|
{
|
|
2076
1756
|
ref: listRef,
|
|
@@ -2081,24 +1761,24 @@ var Select = forwardRef3(function Select2({
|
|
|
2081
1761
|
"aria-multiselectable": multiple || void 0,
|
|
2082
1762
|
style: { maxHeight: listHeight },
|
|
2083
1763
|
onScroll: handleListScroll,
|
|
2084
|
-
children: filteredOptions.length > 0 ? virtualEnabled ? /* @__PURE__ */
|
|
1764
|
+
children: filteredOptions.length > 0 ? virtualEnabled ? /* @__PURE__ */ jsx5("div", { className: "sia-select__virtual-space", style: { height: filteredOptions.length * optionHeight }, children: renderedOptions.map(renderOption) }) : renderedOptions.map(renderOption) : canSubmitInput ? null : /* @__PURE__ */ jsx5("div", { className: "sia-select__empty", children: notFoundContent })
|
|
2085
1765
|
}
|
|
2086
1766
|
),
|
|
2087
|
-
showActions ? /* @__PURE__ */
|
|
2088
|
-
/* @__PURE__ */
|
|
1767
|
+
showActions ? /* @__PURE__ */ jsxs5("div", { className: "sia-select__actions", children: [
|
|
1768
|
+
/* @__PURE__ */ jsxs5("span", { children: [
|
|
2089
1769
|
"\u5171 ",
|
|
2090
1770
|
filteredOptions.length,
|
|
2091
1771
|
" \u6761"
|
|
2092
1772
|
] }),
|
|
2093
|
-
multiple && showSelectAll ? /* @__PURE__ */
|
|
2094
|
-
/* @__PURE__ */
|
|
2095
|
-
/* @__PURE__ */
|
|
1773
|
+
multiple && showSelectAll ? /* @__PURE__ */ jsxs5(Fragment2, { children: [
|
|
1774
|
+
/* @__PURE__ */ jsx5(Button, { variant: "link", size: "small", disabled: allFilteredSelected || !enabledFilteredOptions.length, onClick: selectAllFiltered, children: "\u5168\u9009" }),
|
|
1775
|
+
/* @__PURE__ */ jsx5(Button, { variant: "link", size: "small", disabled: !enabledFilteredOptions.length, onClick: invertFiltered, children: "\u53CD\u9009" })
|
|
2096
1776
|
] }) : null,
|
|
2097
|
-
multiple || allowClear ? /* @__PURE__ */
|
|
1777
|
+
multiple || allowClear ? /* @__PURE__ */ jsx5(Button, { variant: "link", size: "small", danger: true, disabled: !hasValue, onClick: clearSelection, children: "\u6E05\u7A7A" }) : null
|
|
2098
1778
|
] }) : null
|
|
2099
1779
|
] }),
|
|
2100
|
-
popupMode === "modal" ? /* @__PURE__ */
|
|
2101
|
-
|
|
1780
|
+
popupMode === "modal" ? /* @__PURE__ */ jsx5(
|
|
1781
|
+
Modal,
|
|
2102
1782
|
{
|
|
2103
1783
|
className: "sia-select-modal",
|
|
2104
1784
|
open,
|
|
@@ -2109,30 +1789,30 @@ var Select = forwardRef3(function Select2({
|
|
|
2109
1789
|
if (!next) closeDropdown();
|
|
2110
1790
|
},
|
|
2111
1791
|
onCancel: closeDropdown,
|
|
2112
|
-
footer: /* @__PURE__ */
|
|
2113
|
-
/* @__PURE__ */
|
|
2114
|
-
/* @__PURE__ */
|
|
2115
|
-
/* @__PURE__ */
|
|
2116
|
-
/* @__PURE__ */
|
|
1792
|
+
footer: /* @__PURE__ */ jsxs5("div", { className: "sia-select-modal__footer", children: [
|
|
1793
|
+
/* @__PURE__ */ jsx5("div", { children: modalConfig?.footerExtra }),
|
|
1794
|
+
/* @__PURE__ */ jsxs5("div", { children: [
|
|
1795
|
+
/* @__PURE__ */ jsx5(Button, { disabled: modalSubmitting, onClick: closeDropdown, children: "\u53D6\u6D88" }),
|
|
1796
|
+
/* @__PURE__ */ jsx5(Button, { variant: "primary", loading: modalSubmitting, disabled: disabled || loading, onClick: confirmModalSelection, children: "\u786E\u5B9A" })
|
|
2117
1797
|
] })
|
|
2118
1798
|
] }),
|
|
2119
|
-
children: open ? /* @__PURE__ */
|
|
2120
|
-
modalConfig?.headerExtra != null && modalConfig.headerExtra !== false ? /* @__PURE__ */
|
|
2121
|
-
/* @__PURE__ */
|
|
2122
|
-
/* @__PURE__ */
|
|
2123
|
-
/* @__PURE__ */
|
|
2124
|
-
/* @__PURE__ */
|
|
1799
|
+
children: open ? /* @__PURE__ */ jsxs5(Fragment2, { children: [
|
|
1800
|
+
modalConfig?.headerExtra != null && modalConfig.headerExtra !== false ? /* @__PURE__ */ jsx5("div", { className: "sia-select-modal__header-extra", children: modalConfig.headerExtra }) : null,
|
|
1801
|
+
/* @__PURE__ */ jsxs5("div", { className: "sia-select-modal__heading", children: [
|
|
1802
|
+
/* @__PURE__ */ jsxs5("div", { role: "tablist", "aria-label": "\u9009\u9879\u8303\u56F4", children: [
|
|
1803
|
+
/* @__PURE__ */ jsx5(Button, { role: "tab", "aria-selected": !selectedOnly, variant: "link", onClick: () => setSelectedOnly(false), children: "\u5168\u90E8" }),
|
|
1804
|
+
/* @__PURE__ */ jsxs5(Button, { role: "tab", "aria-selected": selectedOnly, variant: "link", onClick: () => setSelectedOnly(true), children: [
|
|
2125
1805
|
"\u5DF2\u9009\u9879(",
|
|
2126
1806
|
modalValues.length,
|
|
2127
1807
|
")"
|
|
2128
1808
|
] })
|
|
2129
1809
|
] }),
|
|
2130
|
-
/* @__PURE__ */
|
|
1810
|
+
/* @__PURE__ */ jsx5(
|
|
2131
1811
|
Input,
|
|
2132
1812
|
{
|
|
2133
1813
|
"aria-label": searchPlaceholder,
|
|
2134
1814
|
placeholder: searchPlaceholder,
|
|
2135
|
-
prefix: /* @__PURE__ */
|
|
1815
|
+
prefix: /* @__PURE__ */ jsx5(Icon, { name: "search", size: 14 }),
|
|
2136
1816
|
value: query,
|
|
2137
1817
|
allowClear: true,
|
|
2138
1818
|
onChange: (event) => {
|
|
@@ -2142,8 +1822,8 @@ var Select = forwardRef3(function Select2({
|
|
|
2142
1822
|
}
|
|
2143
1823
|
)
|
|
2144
1824
|
] }),
|
|
2145
|
-
multiple && showSelectAll ? /* @__PURE__ */
|
|
2146
|
-
/* @__PURE__ */
|
|
1825
|
+
multiple && showSelectAll ? /* @__PURE__ */ jsxs5("div", { className: "sia-select-modal__actions", children: [
|
|
1826
|
+
/* @__PURE__ */ jsx5(
|
|
2147
1827
|
Checkbox2,
|
|
2148
1828
|
{
|
|
2149
1829
|
checked: modalEnabled.length > 0 && modalEnabled.every((option) => modalValues.includes(option.value)),
|
|
@@ -2153,10 +1833,10 @@ var Select = forwardRef3(function Select2({
|
|
|
2153
1833
|
children: "\u5168\u9009"
|
|
2154
1834
|
}
|
|
2155
1835
|
),
|
|
2156
|
-
/* @__PURE__ */
|
|
2157
|
-
/* @__PURE__ */
|
|
1836
|
+
/* @__PURE__ */ jsx5(Button, { variant: "link", size: "small", disabled: !modalEnabled.length, onClick: () => modalBatch("invert"), children: "\u53CD\u9009" }),
|
|
1837
|
+
/* @__PURE__ */ jsx5(Button, { variant: "link", size: "small", danger: true, disabled: !modalValues.length, onClick: () => setModalValues([]), children: "\u6E05\u7A7A" })
|
|
2158
1838
|
] }) : null,
|
|
2159
|
-
allowInput && canSubmitInput ? /* @__PURE__ */
|
|
1839
|
+
allowInput && canSubmitInput ? /* @__PURE__ */ jsxs5(Button, { variant: "link", onClick: () => {
|
|
2160
1840
|
setModalValues(multiple ? [.../* @__PURE__ */ new Set([...modalValues, inputValue])] : [inputValue]);
|
|
2161
1841
|
setQuery("");
|
|
2162
1842
|
}, children: [
|
|
@@ -2164,7 +1844,7 @@ var Select = forwardRef3(function Select2({
|
|
|
2164
1844
|
inputValue,
|
|
2165
1845
|
"\u201D"
|
|
2166
1846
|
] }) : null,
|
|
2167
|
-
/* @__PURE__ */
|
|
1847
|
+
/* @__PURE__ */ jsx5(
|
|
2168
1848
|
SelectionPanel,
|
|
2169
1849
|
{
|
|
2170
1850
|
options: modalFiltered,
|
|
@@ -2195,9 +1875,6 @@ export {
|
|
|
2195
1875
|
Popover,
|
|
2196
1876
|
Timeline,
|
|
2197
1877
|
Tree,
|
|
2198
|
-
useOverlayLifecycle,
|
|
2199
|
-
OverlayPortal,
|
|
2200
|
-
Modal2 as Modal,
|
|
2201
1878
|
SelectionPanel,
|
|
2202
1879
|
OverflowTags,
|
|
2203
1880
|
Select
|