dsh-plugin-core-demo 0.5.1 → 0.6.0
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/client.js +304 -262
- package/package.json +1 -1
package/dist/client.js
CHANGED
|
@@ -141,7 +141,7 @@ var MARQUEE_CSS = "/* \u8DD1\u9A6C\u706F\uFF08MarqueeText\uFF09\uFF1A\u53CC\u5C4
|
|
|
141
141
|
|
|
142
142
|
// dist/ui/picker-css.generated.js
|
|
143
143
|
var PICKER_CSS = `
|
|
144
|
-
.dshpc-picker{position:relative;display:inline-block;font-size:13px;line-height:20px}
|
|
144
|
+
.dshpc-picker{position:relative;display:inline-block;max-width:100%;font-size:13px;line-height:20px}
|
|
145
145
|
.dshpc-picker__trigger{
|
|
146
146
|
display:inline-flex;align-items:center;justify-content:space-between;gap:6px;
|
|
147
147
|
min-width:120px;max-width:100%;height:28px;padding:0 8px;
|
|
@@ -297,9 +297,22 @@ function groupOf(groups, value) {
|
|
|
297
297
|
return void 0;
|
|
298
298
|
return groups.find((g) => g.options.some((o) => o.value === value));
|
|
299
299
|
}
|
|
300
|
+
function resolveTriggerSizing(opts) {
|
|
301
|
+
const px = (v) => typeof v === "number" ? `${v}px` : v;
|
|
302
|
+
if (opts.width !== void 0) {
|
|
303
|
+
const w = px(opts.width);
|
|
304
|
+
return { width: w, minWidth: w, maxWidth: w };
|
|
305
|
+
}
|
|
306
|
+
const style2 = {};
|
|
307
|
+
if (opts.minWidth !== void 0)
|
|
308
|
+
style2.minWidth = px(opts.minWidth);
|
|
309
|
+
if (opts.maxWidth !== void 0)
|
|
310
|
+
style2.maxWidth = px(opts.maxWidth);
|
|
311
|
+
return style2;
|
|
312
|
+
}
|
|
300
313
|
|
|
301
314
|
// dist/ui/Picker.js
|
|
302
|
-
var
|
|
315
|
+
var import_react6 = require("react");
|
|
303
316
|
|
|
304
317
|
// node_modules/.pnpm/@floating-ui+react@0.27.20_react-dom@18.3.1_react@18.3.1__react@18.3.1/node_modules/@floating-ui/react/dist/floating-ui.react.mjs
|
|
305
318
|
var React3 = __toESM(require("react"), 1);
|
|
@@ -3371,6 +3384,50 @@ function FieldHint(props) {
|
|
|
3371
3384
|
});
|
|
3372
3385
|
}
|
|
3373
3386
|
|
|
3387
|
+
// dist/ui/MarqueeText.js
|
|
3388
|
+
var import_react5 = require("react");
|
|
3389
|
+
function MarqueeText(props) {
|
|
3390
|
+
const outerRef = (0, import_react5.useRef)(null);
|
|
3391
|
+
const innerRef = (0, import_react5.useRef)(null);
|
|
3392
|
+
const [dist2, setDist] = (0, import_react5.useState)(0);
|
|
3393
|
+
const measure = (0, import_react5.useCallback)(() => {
|
|
3394
|
+
const outer = outerRef.current;
|
|
3395
|
+
const inner = innerRef.current;
|
|
3396
|
+
if (outer === null || inner === null)
|
|
3397
|
+
return;
|
|
3398
|
+
setDist(Math.max(0, Math.ceil(inner.scrollWidth - outer.clientWidth)));
|
|
3399
|
+
}, []);
|
|
3400
|
+
(0, import_react5.useLayoutEffect)(() => {
|
|
3401
|
+
const outer = outerRef.current;
|
|
3402
|
+
const inner = innerRef.current;
|
|
3403
|
+
if (outer === null || inner === null)
|
|
3404
|
+
return;
|
|
3405
|
+
measure();
|
|
3406
|
+
const ro = new ResizeObserver(measure);
|
|
3407
|
+
ro.observe(outer);
|
|
3408
|
+
ro.observe(inner);
|
|
3409
|
+
return () => {
|
|
3410
|
+
ro.disconnect();
|
|
3411
|
+
};
|
|
3412
|
+
}, [measure]);
|
|
3413
|
+
(0, import_react5.useEffect)(() => {
|
|
3414
|
+
measure();
|
|
3415
|
+
}, [props.text, measure]);
|
|
3416
|
+
const run = dist2 > 0;
|
|
3417
|
+
return (0, import_react5.createElement)("span", {
|
|
3418
|
+
ref: outerRef,
|
|
3419
|
+
className: (run ? "dshpc-mq dshpc-mq-run" : "dshpc-mq") + (props.className === void 0 ? "" : ` ${props.className}`),
|
|
3420
|
+
title: props.title,
|
|
3421
|
+
style: props.style
|
|
3422
|
+
}, (0, import_react5.createElement)("span", {
|
|
3423
|
+
ref: innerRef,
|
|
3424
|
+
className: "dshpc-mq-in",
|
|
3425
|
+
style: {
|
|
3426
|
+
...run ? { "--dshpc-mq-dist": `${-dist2}px`, "--dshpc-mq-dur": `${Math.max(3, Math.round(dist2 / 30))}s` } : null
|
|
3427
|
+
}
|
|
3428
|
+
}, props.text));
|
|
3429
|
+
}
|
|
3430
|
+
|
|
3374
3431
|
// dist/ui/Picker.js
|
|
3375
3432
|
function Picker(props) {
|
|
3376
3433
|
ensureControls();
|
|
@@ -3380,20 +3437,21 @@ function Picker(props) {
|
|
|
3380
3437
|
const placement = props.placement ?? "down";
|
|
3381
3438
|
const clearable = props.clearable === true;
|
|
3382
3439
|
const showLabels = props.showLabels !== false;
|
|
3383
|
-
const
|
|
3440
|
+
const triggerStyle = resolveTriggerSizing(props);
|
|
3441
|
+
const groups = (0, import_react6.useMemo)(() => toGroups(props.groups, props.options), [props.groups, props.options]);
|
|
3384
3442
|
const controlled = props.value !== void 0;
|
|
3385
|
-
const [inner, setInner] = (0,
|
|
3443
|
+
const [inner, setInner] = (0, import_react6.useState)(() => toArray(props.defaultValue));
|
|
3386
3444
|
const selected = controlled ? toArray(props.value) : inner;
|
|
3387
3445
|
const emit = (next) => {
|
|
3388
3446
|
if (!controlled)
|
|
3389
3447
|
setInner(next);
|
|
3390
3448
|
props.onChange?.(mode === "single" ? next[0] ?? "" : next);
|
|
3391
3449
|
};
|
|
3392
|
-
const [open, setOpen] = (0,
|
|
3393
|
-
const [query, setQuery] = (0,
|
|
3394
|
-
const [active, setActive2] = (0,
|
|
3395
|
-
const rootRef = (0,
|
|
3396
|
-
const searchRef = (0,
|
|
3450
|
+
const [open, setOpen] = (0, import_react6.useState)(false);
|
|
3451
|
+
const [query, setQuery] = (0, import_react6.useState)("");
|
|
3452
|
+
const [active, setActive2] = (0, import_react6.useState)(-1);
|
|
3453
|
+
const rootRef = (0, import_react6.useRef)(null);
|
|
3454
|
+
const searchRef = (0, import_react6.useRef)(null);
|
|
3397
3455
|
const { refs, floatingStyles } = useFloating2({
|
|
3398
3456
|
open,
|
|
3399
3457
|
onOpenChange: setOpen,
|
|
@@ -3416,12 +3474,12 @@ function Picker(props) {
|
|
|
3416
3474
|
whileElementsMounted: autoUpdate,
|
|
3417
3475
|
strategy: "fixed"
|
|
3418
3476
|
});
|
|
3419
|
-
const setSearchRef = (0,
|
|
3477
|
+
const setSearchRef = (0, import_react6.useCallback)((el) => {
|
|
3420
3478
|
searchRef.current = el;
|
|
3421
3479
|
if (el !== null && open)
|
|
3422
3480
|
el.focus();
|
|
3423
3481
|
}, [open]);
|
|
3424
|
-
(0,
|
|
3482
|
+
(0, import_react6.useEffect)(() => {
|
|
3425
3483
|
if (!open)
|
|
3426
3484
|
return;
|
|
3427
3485
|
const onDown = (e) => {
|
|
@@ -3436,7 +3494,7 @@ function Picker(props) {
|
|
|
3436
3494
|
document.addEventListener("mousedown", onDown);
|
|
3437
3495
|
return () => document.removeEventListener("mousedown", onDown);
|
|
3438
3496
|
}, [open]);
|
|
3439
|
-
(0,
|
|
3497
|
+
(0, import_react6.useEffect)(() => {
|
|
3440
3498
|
if (open)
|
|
3441
3499
|
return;
|
|
3442
3500
|
setQuery("");
|
|
@@ -3482,7 +3540,7 @@ function Picker(props) {
|
|
|
3482
3540
|
pick2(hit.value);
|
|
3483
3541
|
}
|
|
3484
3542
|
};
|
|
3485
|
-
const trigger = (0,
|
|
3543
|
+
const trigger = (0, import_react6.createElement)(
|
|
3486
3544
|
"button",
|
|
3487
3545
|
{
|
|
3488
3546
|
type: "button",
|
|
@@ -3490,39 +3548,40 @@ function Picker(props) {
|
|
|
3490
3548
|
"aria-expanded": open,
|
|
3491
3549
|
ref: refs.setReference,
|
|
3492
3550
|
className: `dshpc-picker__trigger dshpc-picker__trigger--${size4}${props.align === "center" ? " dshpc-picker__trigger--center" : ""}`,
|
|
3551
|
+
style: triggerStyle,
|
|
3493
3552
|
disabled: props.disabled === true,
|
|
3494
3553
|
onClick: () => {
|
|
3495
3554
|
if (props.disabled !== true)
|
|
3496
3555
|
setOpen(!open);
|
|
3497
3556
|
}
|
|
3498
3557
|
},
|
|
3499
|
-
props.icon !== void 0 && props.icon !== null ? (0,
|
|
3500
|
-
//
|
|
3501
|
-
(0,
|
|
3502
|
-
(0,
|
|
3558
|
+
props.icon !== void 0 && props.icon !== null ? (0, import_react6.createElement)("span", { className: "dshpc-picker__icon" }, props.icon) : null,
|
|
3559
|
+
// 文字吃掉剩余宽度并靠左(默认);超长时外层省略号、hover 跑马灯(MarqueeText 自带)。
|
|
3560
|
+
(0, import_react6.createElement)(MarqueeText, { text: summary, className: "dshpc-picker__label" }),
|
|
3561
|
+
(0, import_react6.createElement)(Chevron, { size: 12, className: "dshpc-picker__caret" })
|
|
3503
3562
|
);
|
|
3504
|
-
const triggerRow = props.hint === void 0 ? trigger : (0,
|
|
3505
|
-
return (0,
|
|
3563
|
+
const triggerRow = props.hint === void 0 ? trigger : (0, import_react6.createElement)("span", { className: "dshpc-fieldwrap dshpc-fieldwrap--inline" }, trigger, (0, import_react6.createElement)(FieldHint, { text: props.hint }));
|
|
3564
|
+
return (0, import_react6.createElement)("div", {
|
|
3506
3565
|
className: `dshpc-picker${props.className === void 0 ? "" : ` ${props.className}`}`,
|
|
3507
3566
|
ref: rootRef,
|
|
3508
3567
|
onKeyDown
|
|
3509
|
-
}, triggerRow, open ? (0,
|
|
3568
|
+
}, triggerRow, open ? (0, import_react6.createElement)(FloatingPortal, null, (0, import_react6.createElement)("div", {
|
|
3510
3569
|
className: "dshpc-picker__menu",
|
|
3511
3570
|
ref: refs.setFloating,
|
|
3512
3571
|
style: floatingStyles
|
|
3513
|
-
}, props.degraded === true ? (0,
|
|
3572
|
+
}, props.degraded === true ? (0, import_react6.createElement)("div", { className: "dshpc-picker__degraded" }, tt("pickerDegraded")) : null, atMax ? (0, import_react6.createElement)("div", { className: "dshpc-picker__degraded" }, tt("pickerMaxReached", { n: props.max ?? 0 })) : null, props.searchable === true ? (0, import_react6.createElement)("input", {
|
|
3514
3573
|
ref: setSearchRef,
|
|
3515
3574
|
className: "dshpc-picker__search",
|
|
3516
3575
|
placeholder: tt("pickerSearch"),
|
|
3517
3576
|
value: query,
|
|
3518
3577
|
onChange: (e) => setQuery(e.target.value)
|
|
3519
|
-
}) : null, flat.length === 0 && groups.length === 0 ? (0,
|
|
3520
|
-
clearable && mode === "single" && selected.length > 0 ? (0,
|
|
3578
|
+
}) : null, flat.length === 0 && groups.length === 0 ? (0, import_react6.createElement)("div", { className: "dshpc-picker__empty" }, tt("pickerEmpty")) : flat.length === 0 ? (0, import_react6.createElement)("div", { className: "dshpc-picker__empty" }, tt("pickerNoMatch")) : [
|
|
3579
|
+
clearable && mode === "single" && selected.length > 0 ? (0, import_react6.createElement)("div", {
|
|
3521
3580
|
key: "__clear__",
|
|
3522
3581
|
className: "dshpc-picker__option dshpc-picker__option--clear",
|
|
3523
3582
|
onClick: clear
|
|
3524
3583
|
}, tt("pickerClear")) : null,
|
|
3525
|
-
...shown.map((g) => (0,
|
|
3584
|
+
...shown.map((g) => (0, import_react6.createElement)("div", { key: g.value || "_" }, g.label === "" ? null : (0, import_react6.createElement)("div", { className: "dshpc-picker__group-label" }, g.label), g.options.map((o) => {
|
|
3526
3585
|
const blocked = o.disabled === true || atMax && !selected.includes(o.value);
|
|
3527
3586
|
const activeCls = [
|
|
3528
3587
|
"dshpc-picker__option",
|
|
@@ -3530,7 +3589,7 @@ function Picker(props) {
|
|
|
3530
3589
|
blocked ? "dshpc-picker__option--disabled" : ""
|
|
3531
3590
|
].filter((s) => s !== "").join(" ");
|
|
3532
3591
|
const idx = flat.indexOf(o);
|
|
3533
|
-
return (0,
|
|
3592
|
+
return (0, import_react6.createElement)("div", {
|
|
3534
3593
|
key: o.value,
|
|
3535
3594
|
className: activeCls,
|
|
3536
3595
|
"data-active": idx === active ? "true" : void 0,
|
|
@@ -3538,7 +3597,7 @@ function Picker(props) {
|
|
|
3538
3597
|
if (!blocked)
|
|
3539
3598
|
pick2(o.value);
|
|
3540
3599
|
}
|
|
3541
|
-
}, mode === "multiple" ? (0,
|
|
3600
|
+
}, mode === "multiple" ? (0, import_react6.createElement)("span", { className: "dshpc-picker__tick" }, selected.includes(o.value) ? "\u2713" : "") : null, o.icon !== void 0 && o.icon !== null ? (0, import_react6.createElement)("span", { className: "dshpc-picker__option-icon" }, o.icon) : null, (0, import_react6.createElement)("span", null, o.label));
|
|
3542
3601
|
})))
|
|
3543
3602
|
])) : null);
|
|
3544
3603
|
}
|
|
@@ -3549,10 +3608,10 @@ function toArray(v) {
|
|
|
3549
3608
|
}
|
|
3550
3609
|
|
|
3551
3610
|
// dist/ui/DateTimePicker.js
|
|
3552
|
-
var
|
|
3611
|
+
var import_react9 = require("react");
|
|
3553
3612
|
|
|
3554
3613
|
// dist/ui/Button.js
|
|
3555
|
-
var
|
|
3614
|
+
var import_react8 = require("react");
|
|
3556
3615
|
var SOLID_VARIANTS = ["primary", "secondary", "danger", "success", "warning", "info"];
|
|
3557
3616
|
function colorVars(variant, color) {
|
|
3558
3617
|
if (color === void 0 || color === "")
|
|
@@ -3586,13 +3645,13 @@ function Button(props) {
|
|
|
3586
3645
|
className: buttonClass(variant, size4, block2, icon2 !== void 0 && icon2 !== null && !loading, className2),
|
|
3587
3646
|
style: { ...colorVars(variant, color), ...style2 }
|
|
3588
3647
|
};
|
|
3589
|
-
return (0,
|
|
3648
|
+
return (0, import_react8.createElement)("button", attrs2, loading ? (0, import_react8.createElement)("svg", {
|
|
3590
3649
|
className: "dshpc-btn__spinner",
|
|
3591
3650
|
viewBox: "0 0 12 12",
|
|
3592
3651
|
width: 12,
|
|
3593
3652
|
height: 12,
|
|
3594
3653
|
"aria-hidden": true
|
|
3595
|
-
}, (0,
|
|
3654
|
+
}, (0, import_react8.createElement)("circle", {
|
|
3596
3655
|
cx: 6,
|
|
3597
3656
|
cy: 6,
|
|
3598
3657
|
r: 4.75,
|
|
@@ -3602,7 +3661,7 @@ function Button(props) {
|
|
|
3602
3661
|
strokeLinecap: "round",
|
|
3603
3662
|
// 周长 ≈ 29.85,画 22 的弧 + 足够长的空缺 ⇒ 一个约 270° 的开口环
|
|
3604
3663
|
strokeDasharray: "22 30"
|
|
3605
|
-
})) : icon2 !== void 0 && icon2 !== null ? (0,
|
|
3664
|
+
})) : icon2 !== void 0 && icon2 !== null ? (0, import_react8.createElement)("span", { className: "dshpc-btn__icon" }, icon2) : null, children, iconRight !== void 0 && iconRight !== null ? (0, import_react8.createElement)("span", { className: "dshpc-btn__icon-end" }, iconRight) : null);
|
|
3606
3665
|
}
|
|
3607
3666
|
function IconButton(props) {
|
|
3608
3667
|
ensureControls();
|
|
@@ -3615,7 +3674,7 @@ function IconButton(props) {
|
|
|
3615
3674
|
className: `dshpc-iconbtn dshpc-iconbtn--${variant} dshpc-iconbtn--${size4}${className2 !== void 0 && className2 !== "" ? ` ${className2}` : ""}`,
|
|
3616
3675
|
style: style2
|
|
3617
3676
|
};
|
|
3618
|
-
return (0,
|
|
3677
|
+
return (0, import_react8.createElement)("button", attrs2, icon2);
|
|
3619
3678
|
}
|
|
3620
3679
|
|
|
3621
3680
|
// dist/utils/date.js
|
|
@@ -3921,7 +3980,7 @@ function fmtParts(p, precision) {
|
|
|
3921
3980
|
return formatDateTimePrecision(formatDateTimeIso(p), precision);
|
|
3922
3981
|
}
|
|
3923
3982
|
function icon(paths, size4) {
|
|
3924
|
-
return (0,
|
|
3983
|
+
return (0, import_react9.createElement)("svg", { width: size4, height: size4, viewBox: "0 0 16 16", fill: "none", "aria-hidden": true }, ...paths.map((d2) => (0, import_react9.createElement)("path", {
|
|
3925
3984
|
d: d2,
|
|
3926
3985
|
stroke: "currentColor",
|
|
3927
3986
|
"stroke-width": 1.5,
|
|
@@ -3939,8 +3998,8 @@ var ICON_PREV_YEAR = icon(["M9 5L5.5 8 9 11", "M12.5 5L9 8l3.5 3"], 14);
|
|
|
3939
3998
|
var ICON_PREV_MONTH = icon(["M9.5 5L6 8l3.5 3"], 14);
|
|
3940
3999
|
var ICON_NEXT_MONTH = icon(["M6.5 5L10 8l-3.5 3"], 14);
|
|
3941
4000
|
var ICON_NEXT_YEAR = icon(["M7 5l3.5 3L7 11", "M3.5 5L7 8l-3.5 3"], 14);
|
|
3942
|
-
var ICON_UP = (0,
|
|
3943
|
-
var ICON_DOWN = (0,
|
|
4001
|
+
var ICON_UP = (0, import_react9.createElement)(Chevron, { dir: "up", size: 12 });
|
|
4002
|
+
var ICON_DOWN = (0, import_react9.createElement)(Chevron, { size: 12 });
|
|
3944
4003
|
function DateTimePicker(props) {
|
|
3945
4004
|
ensureControls();
|
|
3946
4005
|
const tt = props.translate ?? t;
|
|
@@ -3951,21 +4010,21 @@ function DateTimePicker(props) {
|
|
|
3951
4010
|
const locale2 = getLocale();
|
|
3952
4011
|
const placeholder2 = props.placeholder ?? tt("dtPlaceholder");
|
|
3953
4012
|
const controlled = props.value !== void 0;
|
|
3954
|
-
const [inner, setInner] = (0,
|
|
4013
|
+
const [inner, setInner] = (0, import_react9.useState)(() => props.defaultValue ?? null);
|
|
3955
4014
|
const current3 = controlled ? props.value ?? null : inner;
|
|
3956
|
-
const [open, setOpen] = (0,
|
|
3957
|
-
const [draft, setDraft] = (0,
|
|
3958
|
-
const [views, setViews] = (0,
|
|
4015
|
+
const [open, setOpen] = (0, import_react9.useState)(false);
|
|
4016
|
+
const [draft, setDraft] = (0, import_react9.useState)(() => draftOf(current3));
|
|
4017
|
+
const [views, setViews] = (0, import_react9.useState)(() => {
|
|
3959
4018
|
const d2 = draftOf(current3);
|
|
3960
4019
|
const n = nowParts();
|
|
3961
4020
|
const monthOf = (e) => e.day === null ? { year: n.year, month: n.month } : { year: e.day.year, month: e.day.month };
|
|
3962
4021
|
return { start: monthOf(d2.start), end: monthOf(d2.end) };
|
|
3963
4022
|
});
|
|
3964
|
-
const [active, setActive2] = (0,
|
|
3965
|
-
const [focus, setFocus] = (0,
|
|
3966
|
-
const [typing, setTyping] = (0,
|
|
3967
|
-
const rootRef = (0,
|
|
3968
|
-
const gridRefs = (0,
|
|
4023
|
+
const [active, setActive2] = (0, import_react9.useState)("start");
|
|
4024
|
+
const [focus, setFocus] = (0, import_react9.useState)({ start: null, end: null });
|
|
4025
|
+
const [typing, setTyping] = (0, import_react9.useState)(null);
|
|
4026
|
+
const rootRef = (0, import_react9.useRef)(null);
|
|
4027
|
+
const gridRefs = (0, import_react9.useRef)({ start: null, end: null });
|
|
3969
4028
|
const { refs, floatingStyles } = useFloating2({
|
|
3970
4029
|
open,
|
|
3971
4030
|
onOpenChange: setOpen,
|
|
@@ -3986,12 +4045,12 @@ function DateTimePicker(props) {
|
|
|
3986
4045
|
whileElementsMounted: autoUpdate,
|
|
3987
4046
|
strategy: "fixed"
|
|
3988
4047
|
});
|
|
3989
|
-
const emit = (0,
|
|
4048
|
+
const emit = (0, import_react9.useCallback)((value) => {
|
|
3990
4049
|
if (!controlled)
|
|
3991
4050
|
setInner(value);
|
|
3992
4051
|
props.onChange?.(value);
|
|
3993
4052
|
}, [controlled, props.onChange]);
|
|
3994
|
-
const openPop = (0,
|
|
4053
|
+
const openPop = (0, import_react9.useCallback)(() => {
|
|
3995
4054
|
if (props.disabled === true)
|
|
3996
4055
|
return;
|
|
3997
4056
|
const d2 = draftOf(current3);
|
|
@@ -4004,7 +4063,7 @@ function DateTimePicker(props) {
|
|
|
4004
4063
|
setTyping(null);
|
|
4005
4064
|
setOpen(true);
|
|
4006
4065
|
}, [current3, props.disabled]);
|
|
4007
|
-
(0,
|
|
4066
|
+
(0, import_react9.useEffect)(() => {
|
|
4008
4067
|
if (!open)
|
|
4009
4068
|
return;
|
|
4010
4069
|
const onDown = (e) => {
|
|
@@ -4019,7 +4078,7 @@ function DateTimePicker(props) {
|
|
|
4019
4078
|
document.addEventListener("mousedown", onDown);
|
|
4020
4079
|
return () => document.removeEventListener("mousedown", onDown);
|
|
4021
4080
|
}, [open, refs.floating]);
|
|
4022
|
-
(0,
|
|
4081
|
+
(0, import_react9.useEffect)(() => {
|
|
4023
4082
|
if (!open)
|
|
4024
4083
|
return;
|
|
4025
4084
|
const sides2 = ["start", "end"];
|
|
@@ -4160,9 +4219,9 @@ function DateTimePicker(props) {
|
|
|
4160
4219
|
const currentDraft = draftOf(current3);
|
|
4161
4220
|
const startValue = partsOf(currentDraft.start);
|
|
4162
4221
|
const endValue = rangeMode ? partsOf(currentDraft.end) : null;
|
|
4163
|
-
const dateZone = (key, value) => (0,
|
|
4164
|
-
const calIcon = (0,
|
|
4165
|
-
const trigger = (0,
|
|
4222
|
+
const dateZone = (key, value) => (0, import_react9.createElement)("span", { key, className: `dshpc-dt__pair-date${value === null ? " dshpc-dt__pair-date--empty" : ""}` }, value === null ? placeholder2 : fmtParts(value, precision));
|
|
4223
|
+
const calIcon = (0, import_react9.createElement)("span", { className: "dshpc-dt__cal" }, ICON_CAL);
|
|
4224
|
+
const trigger = (0, import_react9.createElement)("button", {
|
|
4166
4225
|
type: "button",
|
|
4167
4226
|
"aria-label": props.ariaLabel,
|
|
4168
4227
|
"aria-expanded": open,
|
|
@@ -4170,20 +4229,20 @@ function DateTimePicker(props) {
|
|
|
4170
4229
|
disabled: props.disabled === true,
|
|
4171
4230
|
className: `dshpc-dt__trigger ${SIZE_CLASS[size4]} ${WIDTH_CLASS(rangeMode, precision)}`.trim(),
|
|
4172
4231
|
onClick: openPop
|
|
4173
|
-
}, rangeMode ? (0,
|
|
4232
|
+
}, rangeMode ? (0, import_react9.createElement)("span", { key: "group", className: "dshpc-dt__pair-group" }, dateZone("start", startValue), (0, import_react9.createElement)("span", { key: "sep", className: "dshpc-dt__pair-sep", "aria-hidden": true }, "-"), dateZone("end", endValue)) : (0, import_react9.createElement)("span", {
|
|
4174
4233
|
key: "label",
|
|
4175
4234
|
className: `dshpc-dt__trigger-label${startValue === null ? " dshpc-dt__trigger-label--empty" : ""}`
|
|
4176
4235
|
}, startValue === null ? placeholder2 : fmtParts(startValue, precision)), calIcon);
|
|
4177
|
-
const triggerRow = props.hint === void 0 ? trigger : (0,
|
|
4236
|
+
const triggerRow = props.hint === void 0 ? trigger : (0, import_react9.createElement)("span", { className: "dshpc-fieldwrap dshpc-fieldwrap--inline" }, trigger, (0, import_react9.createElement)(FieldHint, { text: props.hint }));
|
|
4178
4237
|
const endBox = (side, label) => {
|
|
4179
4238
|
const p = partsOf(draft[side]);
|
|
4180
|
-
return (0,
|
|
4239
|
+
return (0, import_react9.createElement)("button", {
|
|
4181
4240
|
key: side,
|
|
4182
4241
|
type: "button",
|
|
4183
4242
|
className: `dshpc-dt__end${active === side ? " dshpc-dt__end--active" : ""}`,
|
|
4184
4243
|
"aria-pressed": active === side,
|
|
4185
4244
|
onClick: () => setActive2(side)
|
|
4186
|
-
}, (0,
|
|
4245
|
+
}, (0, import_react9.createElement)("span", { className: "dshpc-dt__end-label" }, `${label}\uFF1A`), (0, import_react9.createElement)("span", { className: `dshpc-dt__end-value${p === null ? " dshpc-dt__end-value--empty" : ""}` }, p === null ? placeholder2 : fmtParts(p, precision)));
|
|
4187
4246
|
};
|
|
4188
4247
|
const panel = (side) => {
|
|
4189
4248
|
const view = views[side];
|
|
@@ -4191,7 +4250,7 @@ function DateTimePicker(props) {
|
|
|
4191
4250
|
const selIso = end.day === null ? null : dayIso(end.day);
|
|
4192
4251
|
const cells = buildMonthCells(view.year, view.month);
|
|
4193
4252
|
const today = nowParts();
|
|
4194
|
-
return (0,
|
|
4253
|
+
return (0, import_react9.createElement)("div", { className: "dshpc-dt__panel", key: side }, (0, import_react9.createElement)("div", { className: "dshpc-dt__nav" }, (0, import_react9.createElement)("div", { className: "dshpc-dt__nav-group" }, (0, import_react9.createElement)("button", { type: "button", className: "dshpc-dt__nav-btn", "aria-label": tt("dtPrevYear"), onClick: () => shiftMonth(side, -12) }, ICON_PREV_YEAR), (0, import_react9.createElement)("button", { type: "button", className: "dshpc-dt__nav-btn", "aria-label": tt("dtPrevMonth"), onClick: () => shiftMonth(side, -1) }, ICON_PREV_MONTH)), (0, import_react9.createElement)("span", { className: "dshpc-dt__caption" }, monthCaption(view.year, view.month, locale2)), (0, import_react9.createElement)("div", { className: "dshpc-dt__nav-group" }, (0, import_react9.createElement)("button", { type: "button", className: "dshpc-dt__nav-btn", "aria-label": tt("dtNextMonth"), onClick: () => shiftMonth(side, 1) }, ICON_NEXT_MONTH), (0, import_react9.createElement)("button", { type: "button", className: "dshpc-dt__nav-btn", "aria-label": tt("dtNextYear"), onClick: () => shiftMonth(side, 12) }, ICON_NEXT_YEAR))), (0, import_react9.createElement)("div", {
|
|
4195
4254
|
className: "dshpc-dt__grid",
|
|
4196
4255
|
role: "grid",
|
|
4197
4256
|
"aria-label": monthCaption(view.year, view.month, locale2),
|
|
@@ -4199,7 +4258,7 @@ function DateTimePicker(props) {
|
|
|
4199
4258
|
gridRefs.current[side] = el;
|
|
4200
4259
|
},
|
|
4201
4260
|
onKeyDown: (e) => onGridKeyDown(side, e)
|
|
4202
|
-
}, ...weekdayLabels(locale2).map((w) => (0,
|
|
4261
|
+
}, ...weekdayLabels(locale2).map((w) => (0, import_react9.createElement)("span", { key: `wd-${w}`, className: "dshpc-dt__wd", role: "columnheader" }, w)), ...cells.map((c2) => (0, import_react9.createElement)("button", {
|
|
4203
4262
|
key: c2.iso,
|
|
4204
4263
|
type: "button",
|
|
4205
4264
|
role: "gridcell",
|
|
@@ -4209,18 +4268,18 @@ function DateTimePicker(props) {
|
|
|
4209
4268
|
"aria-label": locale2 === "zh" ? `${String(c2.year)}\u5E74${String(c2.month)}\u6708${String(c2.day)}\u65E5` : `${weekdayLabels("en")[c2.weekday]}, ${String(c2.year)}-${String(c2.month).padStart(2, "0")}-${String(c2.day).padStart(2, "0")}`,
|
|
4210
4269
|
"aria-selected": selIso !== null && c2.iso === selIso,
|
|
4211
4270
|
onClick: () => pickDay(side, c2)
|
|
4212
|
-
}, String(c2.day)))), units.length === 0 ? null : (0,
|
|
4271
|
+
}, String(c2.day)))), units.length === 0 ? null : (0, import_react9.createElement)("div", { className: "dshpc-dt__time" }, ...units.flatMap((unit, i2) => {
|
|
4213
4272
|
const labelKey = UNIT_LABEL[unit];
|
|
4214
4273
|
const value = end.time[unit];
|
|
4215
4274
|
const shown = typing !== null && typing.side === side && typing.unit === unit ? typing.text : String(value).padStart(2, "0");
|
|
4216
4275
|
return [
|
|
4217
|
-
i2 > 0 ? (0,
|
|
4218
|
-
(0,
|
|
4276
|
+
i2 > 0 ? (0, import_react9.createElement)("span", { key: `sep-${unit}`, className: "dshpc-dt__sep" }, ":") : null,
|
|
4277
|
+
(0, import_react9.createElement)("div", { key: unit, className: "dshpc-dt__unit" }, (0, import_react9.createElement)("span", { className: "dshpc-dt__unit-label" }, tt(labelKey)), (0, import_react9.createElement)("button", {
|
|
4219
4278
|
type: "button",
|
|
4220
4279
|
className: "dshpc-dt__step-btn",
|
|
4221
4280
|
"aria-label": `${tt(labelKey)} +1`,
|
|
4222
4281
|
onClick: () => shiftUnit(side, unit, 1)
|
|
4223
|
-
}, ICON_UP), (0,
|
|
4282
|
+
}, ICON_UP), (0, import_react9.createElement)("input", {
|
|
4224
4283
|
className: "dshpc-dt__step-val",
|
|
4225
4284
|
inputMode: "numeric",
|
|
4226
4285
|
maxLength: 2,
|
|
@@ -4239,7 +4298,7 @@ function DateTimePicker(props) {
|
|
|
4239
4298
|
commitTyping(side, unit, shown);
|
|
4240
4299
|
}
|
|
4241
4300
|
}
|
|
4242
|
-
}), (0,
|
|
4301
|
+
}), (0, import_react9.createElement)("button", {
|
|
4243
4302
|
type: "button",
|
|
4244
4303
|
className: "dshpc-dt__step-btn",
|
|
4245
4304
|
"aria-label": `${tt(labelKey)} -1`,
|
|
@@ -4250,15 +4309,15 @@ function DateTimePicker(props) {
|
|
|
4250
4309
|
};
|
|
4251
4310
|
const invalidRange = rangeMode && partsOf(draft.start) !== null && partsOf(draft.end) !== null && !rangeIsValid(formatDateTimeIso(partsOf(draft.start)), formatDateTimeIso(partsOf(draft.end)));
|
|
4252
4311
|
const canCommit = rangeMode ? partsOf(draft.start) !== null && partsOf(draft.end) !== null && !invalidRange : partsOf(draft.start) !== null;
|
|
4253
|
-
const pop2 = (0,
|
|
4254
|
-
return (0,
|
|
4312
|
+
const pop2 = (0, import_react9.createElement)("div", { className: "dshpc-dt__pop", ref: refs.setFloating, style: floatingStyles, onKeyDown: onPopKeyDown }, rangeMode ? (0, import_react9.createElement)("div", { className: "dshpc-dt__ends" }, endBox("start", tt("dtStart")), endBox("end", tt("dtEnd"))) : null, (0, import_react9.createElement)("div", { className: "dshpc-dt__panels" }, panel("start"), rangeMode ? panel("end") : null), (0, import_react9.createElement)("div", { className: "dshpc-dt__foot" }, (0, import_react9.createElement)("div", { className: "dshpc-dt__foot-side" }, (0, import_react9.createElement)(Button, { variant: "ghost", size: "sm", onClick: applyNow }, precision === "day" ? tt("dtToday") : tt("dtNow")), (0, import_react9.createElement)(Button, { variant: "ghost", size: "sm", onClick: clear }, tt("dtClear"))), (0, import_react9.createElement)("div", { className: "dshpc-dt__foot-side" }, invalidRange ? (0, import_react9.createElement)("span", { className: "dshpc-dt__warn" }, tt("dtInvalidRange")) : null, (0, import_react9.createElement)(Button, { variant: "outline", size: "sm", onClick: () => setOpen(false) }, tt("cancel")), (0, import_react9.createElement)(Button, { variant: "primary", size: "sm", disabled: !canCommit, onClick: commit }, tt("confirm")))));
|
|
4313
|
+
return (0, import_react9.createElement)("div", {
|
|
4255
4314
|
className: `dshpc-dt${props.className === void 0 ? "" : ` ${props.className}`}`,
|
|
4256
4315
|
ref: rootRef
|
|
4257
|
-
}, triggerRow, open ? (0,
|
|
4316
|
+
}, triggerRow, open ? (0, import_react9.createElement)(FloatingPortal, null, pop2) : null);
|
|
4258
4317
|
}
|
|
4259
4318
|
|
|
4260
4319
|
// dist/ui/ModelPicker.js
|
|
4261
|
-
var
|
|
4320
|
+
var import_react12 = require("react");
|
|
4262
4321
|
|
|
4263
4322
|
// dist/ui/host-data.js
|
|
4264
4323
|
var ModelCatalogStore = class {
|
|
@@ -4337,12 +4396,12 @@ function connectHost(ctx, options = {}) {
|
|
|
4337
4396
|
}
|
|
4338
4397
|
|
|
4339
4398
|
// dist/ui/picker-icons.js
|
|
4340
|
-
var
|
|
4399
|
+
var import_react11 = require("react");
|
|
4341
4400
|
function glyph(path) {
|
|
4342
|
-
return (0,
|
|
4401
|
+
return (0, import_react11.createElement)("svg", { width: 14, height: 14, viewBox: "0 0 16 16", fill: "none", "aria-hidden": true }, path);
|
|
4343
4402
|
}
|
|
4344
4403
|
function folderIcon() {
|
|
4345
|
-
return glyph((0,
|
|
4404
|
+
return glyph((0, import_react11.createElement)("path", {
|
|
4346
4405
|
d: "M2 4.5A1.5 1.5 0 0 1 3.5 3h2.6l1.2 1.5h5.2A1.5 1.5 0 0 1 14 6v5.5A1.5 1.5 0 0 1 12.5 13h-9A1.5 1.5 0 0 1 2 11.5z",
|
|
4347
4406
|
stroke: "currentColor",
|
|
4348
4407
|
"stroke-width": 1.3,
|
|
@@ -4350,7 +4409,7 @@ function folderIcon() {
|
|
|
4350
4409
|
}));
|
|
4351
4410
|
}
|
|
4352
4411
|
function sparkleIcon() {
|
|
4353
|
-
return glyph((0,
|
|
4412
|
+
return glyph((0, import_react11.createElement)("path", {
|
|
4354
4413
|
d: "M8 1.8l1.6 4.1 4.1 1.6-4.1 1.6L8 13.2 6.4 9.1 2.3 7.5l4.1-1.6z",
|
|
4355
4414
|
stroke: "currentColor",
|
|
4356
4415
|
"stroke-width": 1.2,
|
|
@@ -4366,7 +4425,7 @@ function ModelPicker(props) {
|
|
|
4366
4425
|
const variant = props.variant ?? "grouped";
|
|
4367
4426
|
const searchable = props.searchable ?? true;
|
|
4368
4427
|
const defaultOption = props.allowDefault === false ? void 0 : { value: "", label: props.defaultLabel ?? tt("modelDefault") };
|
|
4369
|
-
const catalog = (0,
|
|
4428
|
+
const catalog = (0, import_react12.useSyncExternalStore)(modelCatalog.subscribe, modelCatalog.getSnapshot);
|
|
4370
4429
|
const groups = props.groups ?? (catalog.status === "ready" ? catalog.routes.map((route) => ({
|
|
4371
4430
|
value: route.provider,
|
|
4372
4431
|
label: route.displayName,
|
|
@@ -4380,15 +4439,15 @@ function ModelPicker(props) {
|
|
|
4380
4439
|
const emitModel = (v) => {
|
|
4381
4440
|
props.onChange?.(typeof v === "string" ? v : v[0] ?? "");
|
|
4382
4441
|
};
|
|
4383
|
-
const [pickedProvider, setPickedProvider] = (0,
|
|
4442
|
+
const [pickedProvider, setPickedProvider] = (0, import_react12.useState)("");
|
|
4384
4443
|
const curGroup = groupOf(groups, value ?? "");
|
|
4385
4444
|
const provider = pickedProvider !== "" && groups.some((g) => g.value === pickedProvider) ? pickedProvider : curGroup?.value ?? "";
|
|
4386
|
-
(0,
|
|
4445
|
+
(0, import_react12.useEffect)(() => {
|
|
4387
4446
|
if (value !== void 0 && value !== "")
|
|
4388
4447
|
setPickedProvider("");
|
|
4389
4448
|
}, [value]);
|
|
4390
4449
|
if (variant === "grouped") {
|
|
4391
|
-
return (0,
|
|
4450
|
+
return (0, import_react12.createElement)(Picker, {
|
|
4392
4451
|
// 「默认模型」放最上面:空 label 的组,Picker 只渲染选项不渲染组头
|
|
4393
4452
|
groups: defaultOption === void 0 ? groups : [{ value: "", label: "", options: [defaultOption] }, ...groups],
|
|
4394
4453
|
value,
|
|
@@ -4408,7 +4467,7 @@ function ModelPicker(props) {
|
|
|
4408
4467
|
}
|
|
4409
4468
|
const group = groups.find((g) => g.value === provider);
|
|
4410
4469
|
const options = group === void 0 ? [] : flattenOptions([group]);
|
|
4411
|
-
return (0,
|
|
4470
|
+
return (0, import_react12.createElement)("div", { className: "dshpc-picker__row" }, (0, import_react12.createElement)(Picker, {
|
|
4412
4471
|
options: groups.map((g) => ({ value: g.value, label: g.label })),
|
|
4413
4472
|
value: provider === "" ? void 0 : provider,
|
|
4414
4473
|
placeholder: tt("modelProvider"),
|
|
@@ -4419,7 +4478,7 @@ function ModelPicker(props) {
|
|
|
4419
4478
|
setPickedProvider(typeof v === "string" ? v : v[0] ?? "");
|
|
4420
4479
|
props.onChange?.("");
|
|
4421
4480
|
}
|
|
4422
|
-
}), (0,
|
|
4481
|
+
}), (0, import_react12.createElement)(Picker, {
|
|
4423
4482
|
options: defaultOption === void 0 ? options : [defaultOption, ...options],
|
|
4424
4483
|
value,
|
|
4425
4484
|
defaultValue: props.defaultValue,
|
|
@@ -4438,14 +4497,14 @@ function ModelPicker(props) {
|
|
|
4438
4497
|
}
|
|
4439
4498
|
|
|
4440
4499
|
// dist/ui/WorkspacePicker.js
|
|
4441
|
-
var
|
|
4500
|
+
var import_react13 = require("react");
|
|
4442
4501
|
function WorkspacePicker(props) {
|
|
4443
4502
|
ensureControls();
|
|
4444
4503
|
const tt = props.translate ?? t;
|
|
4445
|
-
const items = (0,
|
|
4504
|
+
const items = (0, import_react13.useSyncExternalStore)(workspaceList.subscribe, workspaceList.getSnapshot);
|
|
4446
4505
|
const options = items.map((w) => ({ value: w.workspaceId, label: w.title }));
|
|
4447
4506
|
const allOption = props.allowDefault !== false && props.mode !== "multiple" ? { value: "", label: props.defaultLabel ?? tt("workspaceAll") } : void 0;
|
|
4448
|
-
return (0,
|
|
4507
|
+
return (0, import_react13.createElement)(Picker, {
|
|
4449
4508
|
options: allOption === void 0 ? options : [allOption, ...options],
|
|
4450
4509
|
value: props.value,
|
|
4451
4510
|
defaultValue: props.defaultValue,
|
|
@@ -4465,13 +4524,13 @@ function WorkspacePicker(props) {
|
|
|
4465
4524
|
}
|
|
4466
4525
|
|
|
4467
4526
|
// dist/ui/Modal.js
|
|
4468
|
-
var
|
|
4527
|
+
var import_react14 = require("react");
|
|
4469
4528
|
function Modal(props) {
|
|
4470
4529
|
ensureControls();
|
|
4471
4530
|
const tt = props.translate ?? t;
|
|
4472
4531
|
const closeOnMask = props.closeOnMask !== false;
|
|
4473
4532
|
const escClose = props.escClose !== false;
|
|
4474
|
-
(0,
|
|
4533
|
+
(0, import_react14.useEffect)(() => {
|
|
4475
4534
|
if (!escClose || props.onClose === void 0)
|
|
4476
4535
|
return;
|
|
4477
4536
|
const onKey = (e) => {
|
|
@@ -4489,13 +4548,13 @@ function Modal(props) {
|
|
|
4489
4548
|
const s = sizeStyle[props.size ?? "md"];
|
|
4490
4549
|
const showClose = props.closable !== false && props.onClose !== void 0;
|
|
4491
4550
|
const showHeader = props.hideHeader !== true && (props.icon !== void 0 || props.title !== void 0 || props.subtitle !== void 0 || props.headerExtra !== void 0 || props.headerActions !== void 0 || showClose);
|
|
4492
|
-
return (0,
|
|
4551
|
+
return (0, import_react14.createElement)("div", {
|
|
4493
4552
|
className: "dshpc-modal-mask",
|
|
4494
4553
|
onClick: () => {
|
|
4495
4554
|
if (closeOnMask)
|
|
4496
4555
|
props.onClose?.();
|
|
4497
4556
|
}
|
|
4498
|
-
}, (0,
|
|
4557
|
+
}, (0, import_react14.createElement)(
|
|
4499
4558
|
"div",
|
|
4500
4559
|
{
|
|
4501
4560
|
className: `dshpc-modal${props.size ? ` dshpc-modal--${props.size}` : ""}`,
|
|
@@ -4507,14 +4566,14 @@ function Modal(props) {
|
|
|
4507
4566
|
},
|
|
4508
4567
|
onClick: (e) => e.stopPropagation()
|
|
4509
4568
|
},
|
|
4510
|
-
showHeader ? (0,
|
|
4569
|
+
showHeader ? (0, import_react14.createElement)("div", { className: "dshpc-modal__head" }, (0, import_react14.createElement)(
|
|
4511
4570
|
"div",
|
|
4512
4571
|
{ className: "dshpc-modal__heading" },
|
|
4513
|
-
props.icon === void 0 ? null : (0,
|
|
4572
|
+
props.icon === void 0 ? null : (0, import_react14.createElement)("span", { className: "dshpc-modal__lead" }, props.icon),
|
|
4514
4573
|
// 标题组:第一行 = 标题 + 右侧小块(徽标**紧跟标题**,不跨两行居中),
|
|
4515
4574
|
// 第二行 = 副标题(会话 id 这类标识)。
|
|
4516
|
-
(0,
|
|
4517
|
-
), (0,
|
|
4575
|
+
(0, import_react14.createElement)("div", { className: "dshpc-modal__titlegroup" }, (0, import_react14.createElement)("div", { className: "dshpc-modal__titlerow" }, (0, import_react14.createElement)("div", { className: "dshpc-modal__title" }, props.title ?? ""), props.headerExtra === void 0 ? null : (0, import_react14.createElement)("div", { className: "dshpc-modal__extra" }, props.headerExtra)), props.subtitle === void 0 ? null : (0, import_react14.createElement)("div", { className: "dshpc-modal__sid" }, props.subtitle))
|
|
4576
|
+
), (0, import_react14.createElement)("div", { className: "dshpc-modal__spacer" }), props.headerActions === void 0 ? null : (0, import_react14.createElement)("div", { className: "dshpc-modal__actions" }, props.headerActions), showClose ? (0, import_react14.createElement)("button", {
|
|
4518
4577
|
type: "button",
|
|
4519
4578
|
className: "dshpc-modal__close",
|
|
4520
4579
|
"aria-label": tt("modalClose"),
|
|
@@ -4522,13 +4581,13 @@ function Modal(props) {
|
|
|
4522
4581
|
}, "\u2715") : null) : null,
|
|
4523
4582
|
// body 是**唯一滚动容器**:内距归它、滚动条归它、滚动条贴面板右缘;
|
|
4524
4583
|
// 内容只管按流排,不许自己定高、不许自己再开滚动条(用户 2026-10-22 定的口径)。
|
|
4525
|
-
(0,
|
|
4526
|
-
props.footer === void 0 ? null : (0,
|
|
4584
|
+
(0, import_react14.createElement)("div", { className: "dshpc-modal__body" }, props.children ?? null),
|
|
4585
|
+
props.footer === void 0 ? null : (0, import_react14.createElement)("div", { className: "dshpc-modal__foot" }, props.footer)
|
|
4527
4586
|
));
|
|
4528
4587
|
}
|
|
4529
4588
|
|
|
4530
4589
|
// dist/ui/AlertModal.js
|
|
4531
|
-
var
|
|
4590
|
+
var import_react15 = require("react");
|
|
4532
4591
|
var SEVERITY_GLYPH = {
|
|
4533
4592
|
info: "\u24D8",
|
|
4534
4593
|
success: "\u2713",
|
|
@@ -4538,37 +4597,37 @@ var SEVERITY_GLYPH = {
|
|
|
4538
4597
|
function AlertModal(props) {
|
|
4539
4598
|
const tt = props.translate ?? t;
|
|
4540
4599
|
const severity = props.severity ?? "info";
|
|
4541
|
-
return (0,
|
|
4542
|
-
icon: (0,
|
|
4600
|
+
return (0, import_react15.createElement)(Modal, {
|
|
4601
|
+
icon: (0, import_react15.createElement)("span", { className: `dshpc-alert-sev dshpc-alert-sev--${severity}` }, SEVERITY_GLYPH[severity]),
|
|
4543
4602
|
title: props.title,
|
|
4544
4603
|
size: props.size ?? "sm",
|
|
4545
4604
|
hideHeader: props.title === void 0,
|
|
4546
4605
|
closable: false,
|
|
4547
4606
|
closeOnMask: props.closeOnMask,
|
|
4548
4607
|
onClose: props.onConfirm,
|
|
4549
|
-
footer: (0,
|
|
4608
|
+
footer: (0, import_react15.createElement)(Button, { variant: "primary", onClick: () => props.onConfirm?.() }, props.confirmText ?? tt("dialogOk"))
|
|
4550
4609
|
}, props.message ?? null);
|
|
4551
4610
|
}
|
|
4552
4611
|
|
|
4553
4612
|
// dist/ui/ConfirmModal.js
|
|
4554
|
-
var
|
|
4613
|
+
var import_react16 = require("react");
|
|
4555
4614
|
function ConfirmModal(props) {
|
|
4556
4615
|
const tt = props.translate ?? t;
|
|
4557
4616
|
const tone = props.tone ?? "primary";
|
|
4558
4617
|
const confirmVariant = tone === "danger" ? "danger" : tone === "warning" ? "warning" : "primary";
|
|
4559
|
-
return (0,
|
|
4618
|
+
return (0, import_react16.createElement)(Modal, {
|
|
4560
4619
|
title: props.title,
|
|
4561
4620
|
size: props.size ?? "sm",
|
|
4562
4621
|
hideHeader: props.title === void 0,
|
|
4563
4622
|
closable: false,
|
|
4564
4623
|
closeOnMask: props.closeOnMask,
|
|
4565
4624
|
onClose: props.onCancel,
|
|
4566
|
-
footer: (0,
|
|
4625
|
+
footer: (0, import_react16.createElement)("div", { style: { display: "flex", gap: "8px", justifyContent: "flex-end" } }, (0, import_react16.createElement)(Button, { variant: "outline", onClick: () => props.onCancel?.() }, props.cancelText ?? tt("cancel")), (0, import_react16.createElement)(Button, { variant: confirmVariant, onClick: () => props.onConfirm?.() }, props.confirmText ?? tt("confirm")))
|
|
4567
4626
|
}, props.message ?? null);
|
|
4568
4627
|
}
|
|
4569
4628
|
|
|
4570
4629
|
// dist/ui/modal-host.js
|
|
4571
|
-
var
|
|
4630
|
+
var import_react17 = require("react");
|
|
4572
4631
|
var import_client = require("react-dom/client");
|
|
4573
4632
|
var hostRoot = null;
|
|
4574
4633
|
var hostContainer = null;
|
|
@@ -4597,7 +4656,7 @@ function flush() {
|
|
|
4597
4656
|
hostContainer = null;
|
|
4598
4657
|
return;
|
|
4599
4658
|
}
|
|
4600
|
-
root.render((0,
|
|
4659
|
+
root.render((0, import_react17.createElement)(import_react17.Fragment, null, entries.map((e) => e.node)));
|
|
4601
4660
|
}
|
|
4602
4661
|
function dismiss(id3) {
|
|
4603
4662
|
entries = entries.filter((e) => e.id !== id3);
|
|
@@ -4630,7 +4689,7 @@ function confirmModal(opts) {
|
|
|
4630
4689
|
};
|
|
4631
4690
|
entries.push({
|
|
4632
4691
|
id: id3,
|
|
4633
|
-
node: (0,
|
|
4692
|
+
node: (0, import_react17.createElement)(ConfirmModal, { ...core, onConfirm: () => close(true), onCancel: () => close(false) })
|
|
4634
4693
|
});
|
|
4635
4694
|
flush();
|
|
4636
4695
|
});
|
|
@@ -4654,13 +4713,13 @@ function alertModal(opts) {
|
|
|
4654
4713
|
dismiss(id3);
|
|
4655
4714
|
resolve();
|
|
4656
4715
|
};
|
|
4657
|
-
entries.push({ id: id3, node: (0,
|
|
4716
|
+
entries.push({ id: id3, node: (0, import_react17.createElement)(AlertModal, { ...core, onConfirm: close }) });
|
|
4658
4717
|
flush();
|
|
4659
4718
|
});
|
|
4660
4719
|
}
|
|
4661
4720
|
|
|
4662
4721
|
// dist/ui/Card.js
|
|
4663
|
-
var
|
|
4722
|
+
var import_react18 = require("react");
|
|
4664
4723
|
var CARD_ACCENTS = ["business", "success", "warning", "danger", "neutral"];
|
|
4665
4724
|
function CardShell(kind, props) {
|
|
4666
4725
|
ensureControls();
|
|
@@ -4674,13 +4733,13 @@ function CardShell(kind, props) {
|
|
|
4674
4733
|
props.className ?? ""
|
|
4675
4734
|
].filter((s) => s !== "").join(" ");
|
|
4676
4735
|
const style2 = isPreset ? props.style : { ...props.style, ["--card-accent"]: accent };
|
|
4677
|
-
return (0,
|
|
4736
|
+
return (0, import_react18.createElement)("div", { className: classes, style: style2 }, (0, import_react18.createElement)(
|
|
4678
4737
|
"div",
|
|
4679
4738
|
{ className: "dshpc-card__head" },
|
|
4680
4739
|
// 色条是头部第一个子元素:strip 外观 = 绝对定位 4px 通高贴左缘;bordered 外观 = 行内 6px 圆角短条(高度跟随内容,最小一行,左移 3px)。
|
|
4681
|
-
(0,
|
|
4682
|
-
(0,
|
|
4683
|
-
props.action === void 0 && props.onToggle === void 0 ? null : (0,
|
|
4740
|
+
(0, import_react18.createElement)("span", { className: "dshpc-card__bar", "aria-hidden": true }),
|
|
4741
|
+
(0, import_react18.createElement)("div", { className: "dshpc-card__main" }, props.children ?? null),
|
|
4742
|
+
props.action === void 0 && props.onToggle === void 0 ? null : (0, import_react18.createElement)("div", { className: "dshpc-card__side" }, props.action ?? null, props.onToggle === void 0 ? null : (0, import_react18.createElement)(
|
|
4684
4743
|
"button",
|
|
4685
4744
|
{
|
|
4686
4745
|
type: "button",
|
|
@@ -4690,9 +4749,9 @@ function CardShell(kind, props) {
|
|
|
4690
4749
|
onClick: props.onToggle
|
|
4691
4750
|
},
|
|
4692
4751
|
// 箭头走全站唯一的 Chevron(不再写 ▾ 字形);旋转由外层 .is-open 承担,动画不变。
|
|
4693
|
-
(0,
|
|
4752
|
+
(0, import_react18.createElement)("span", { className: props.expanded === true ? "dshpc-card__caret is-open" : "dshpc-card__caret" }, (0, import_react18.createElement)(Chevron, { size: 12 }))
|
|
4694
4753
|
))
|
|
4695
|
-
), props.panel === void 0 || props.expanded !== true ? null : (0,
|
|
4754
|
+
), props.panel === void 0 || props.expanded !== true ? null : (0, import_react18.createElement)("div", { className: "dshpc-card__panel" }, props.panel));
|
|
4696
4755
|
}
|
|
4697
4756
|
function Card(props) {
|
|
4698
4757
|
return CardShell("bordered", props);
|
|
@@ -4702,13 +4761,13 @@ function StripCard(props) {
|
|
|
4702
4761
|
}
|
|
4703
4762
|
|
|
4704
4763
|
// dist/ui/Chip.js
|
|
4705
|
-
var
|
|
4764
|
+
var import_react19 = require("react");
|
|
4706
4765
|
function Chip(props) {
|
|
4707
4766
|
ensureControls();
|
|
4708
4767
|
const clickable = props.onClick !== void 0;
|
|
4709
4768
|
const tone = props.tone ?? "neutral";
|
|
4710
4769
|
const size4 = props.size ?? "sm";
|
|
4711
|
-
return (0,
|
|
4770
|
+
return (0, import_react19.createElement)(clickable ? "button" : "span", {
|
|
4712
4771
|
type: clickable ? "button" : void 0,
|
|
4713
4772
|
className: `dshpc-chip${tone !== "neutral" ? ` dshpc-chip--${tone}` : ""}${size4 !== "sm" ? ` dshpc-chip--${size4}` : ""}${clickable ? " dshpc-chip--clickable" : ""}${props.className === void 0 ? "" : ` ${props.className}`}`,
|
|
4714
4773
|
onClick: props.onClick
|
|
@@ -4716,11 +4775,11 @@ function Chip(props) {
|
|
|
4716
4775
|
}
|
|
4717
4776
|
|
|
4718
4777
|
// dist/ui/Toast.js
|
|
4719
|
-
var
|
|
4778
|
+
var import_react21 = require("react");
|
|
4720
4779
|
var import_client2 = require("react-dom/client");
|
|
4721
4780
|
|
|
4722
4781
|
// node_modules/.pnpm/sonner@2.0.8_@types+react@18.3.31_react-dom@18.3.1_react@18.3.1__react@18.3.1/node_modules/sonner/dist/index.mjs
|
|
4723
|
-
var
|
|
4782
|
+
var import_react20 = __toESM(require("react"), 1);
|
|
4724
4783
|
var import_react_dom3 = __toESM(require("react-dom"), 1);
|
|
4725
4784
|
function __insertCSS(code3) {
|
|
4726
4785
|
if (!code3 || typeof document == "undefined") return;
|
|
@@ -4746,68 +4805,68 @@ var getAsset = (type3) => {
|
|
|
4746
4805
|
};
|
|
4747
4806
|
var bars = Array(12).fill(0);
|
|
4748
4807
|
var Loader = ({ visible, className: className2 }) => {
|
|
4749
|
-
return /* @__PURE__ */
|
|
4808
|
+
return /* @__PURE__ */ import_react20.default.createElement("div", {
|
|
4750
4809
|
className: [
|
|
4751
4810
|
"sonner-loading-wrapper",
|
|
4752
4811
|
className2
|
|
4753
4812
|
].filter(Boolean).join(" "),
|
|
4754
4813
|
"data-visible": visible
|
|
4755
|
-
}, /* @__PURE__ */
|
|
4814
|
+
}, /* @__PURE__ */ import_react20.default.createElement("div", {
|
|
4756
4815
|
className: "sonner-spinner"
|
|
4757
|
-
}, bars.map((_, i2) => /* @__PURE__ */
|
|
4816
|
+
}, bars.map((_, i2) => /* @__PURE__ */ import_react20.default.createElement("div", {
|
|
4758
4817
|
className: "sonner-loading-bar",
|
|
4759
4818
|
key: `spinner-bar-${i2}`
|
|
4760
4819
|
}))));
|
|
4761
4820
|
};
|
|
4762
|
-
var SuccessIcon = /* @__PURE__ */
|
|
4821
|
+
var SuccessIcon = /* @__PURE__ */ import_react20.default.createElement("svg", {
|
|
4763
4822
|
xmlns: "http://www.w3.org/2000/svg",
|
|
4764
4823
|
viewBox: "0 0 20 20",
|
|
4765
4824
|
fill: "currentColor",
|
|
4766
4825
|
height: "20",
|
|
4767
4826
|
width: "20",
|
|
4768
4827
|
"aria-hidden": "true"
|
|
4769
|
-
}, /* @__PURE__ */
|
|
4828
|
+
}, /* @__PURE__ */ import_react20.default.createElement("path", {
|
|
4770
4829
|
fillRule: "evenodd",
|
|
4771
4830
|
d: "M10 18a8 8 0 100-16 8 8 0 000 16zm3.857-9.809a.75.75 0 00-1.214-.882l-3.483 4.79-1.88-1.88a.75.75 0 10-1.06 1.061l2.5 2.5a.75.75 0 001.137-.089l4-5.5z",
|
|
4772
4831
|
clipRule: "evenodd"
|
|
4773
4832
|
}));
|
|
4774
|
-
var WarningIcon = /* @__PURE__ */
|
|
4833
|
+
var WarningIcon = /* @__PURE__ */ import_react20.default.createElement("svg", {
|
|
4775
4834
|
xmlns: "http://www.w3.org/2000/svg",
|
|
4776
4835
|
viewBox: "0 0 24 24",
|
|
4777
4836
|
fill: "currentColor",
|
|
4778
4837
|
height: "20",
|
|
4779
4838
|
width: "20",
|
|
4780
4839
|
"aria-hidden": "true"
|
|
4781
|
-
}, /* @__PURE__ */
|
|
4840
|
+
}, /* @__PURE__ */ import_react20.default.createElement("path", {
|
|
4782
4841
|
fillRule: "evenodd",
|
|
4783
4842
|
d: "M9.401 3.003c1.155-2 4.043-2 5.197 0l7.355 12.748c1.154 2-.29 4.5-2.599 4.5H4.645c-2.309 0-3.752-2.5-2.598-4.5L9.4 3.003zM12 8.25a.75.75 0 01.75.75v3.75a.75.75 0 01-1.5 0V9a.75.75 0 01.75-.75zm0 8.25a.75.75 0 100-1.5.75.75 0 000 1.5z",
|
|
4784
4843
|
clipRule: "evenodd"
|
|
4785
4844
|
}));
|
|
4786
|
-
var InfoIcon = /* @__PURE__ */
|
|
4845
|
+
var InfoIcon = /* @__PURE__ */ import_react20.default.createElement("svg", {
|
|
4787
4846
|
xmlns: "http://www.w3.org/2000/svg",
|
|
4788
4847
|
viewBox: "0 0 20 20",
|
|
4789
4848
|
fill: "currentColor",
|
|
4790
4849
|
height: "20",
|
|
4791
4850
|
width: "20",
|
|
4792
4851
|
"aria-hidden": "true"
|
|
4793
|
-
}, /* @__PURE__ */
|
|
4852
|
+
}, /* @__PURE__ */ import_react20.default.createElement("path", {
|
|
4794
4853
|
fillRule: "evenodd",
|
|
4795
4854
|
d: "M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-7-4a1 1 0 11-2 0 1 1 0 012 0zM9 9a.75.75 0 000 1.5h.253a.25.25 0 01.244.304l-.459 2.066A1.75 1.75 0 0010.747 15H11a.75.75 0 000-1.5h-.253a.25.25 0 01-.244-.304l.459-2.066A1.75 1.75 0 009.253 9H9z",
|
|
4796
4855
|
clipRule: "evenodd"
|
|
4797
4856
|
}));
|
|
4798
|
-
var ErrorIcon = /* @__PURE__ */
|
|
4857
|
+
var ErrorIcon = /* @__PURE__ */ import_react20.default.createElement("svg", {
|
|
4799
4858
|
xmlns: "http://www.w3.org/2000/svg",
|
|
4800
4859
|
viewBox: "0 0 20 20",
|
|
4801
4860
|
fill: "currentColor",
|
|
4802
4861
|
height: "20",
|
|
4803
4862
|
width: "20",
|
|
4804
4863
|
"aria-hidden": "true"
|
|
4805
|
-
}, /* @__PURE__ */
|
|
4864
|
+
}, /* @__PURE__ */ import_react20.default.createElement("path", {
|
|
4806
4865
|
fillRule: "evenodd",
|
|
4807
4866
|
d: "M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-8-5a.75.75 0 01.75.75v4.5a.75.75 0 01-1.5 0v-4.5A.75.75 0 0110 5zm0 10a1 1 0 100-2 1 1 0 000 2z",
|
|
4808
4867
|
clipRule: "evenodd"
|
|
4809
4868
|
}));
|
|
4810
|
-
var CloseIcon = /* @__PURE__ */
|
|
4869
|
+
var CloseIcon = /* @__PURE__ */ import_react20.default.createElement("svg", {
|
|
4811
4870
|
xmlns: "http://www.w3.org/2000/svg",
|
|
4812
4871
|
width: "12",
|
|
4813
4872
|
height: "12",
|
|
@@ -4818,20 +4877,20 @@ var CloseIcon = /* @__PURE__ */ import_react19.default.createElement("svg", {
|
|
|
4818
4877
|
strokeLinecap: "round",
|
|
4819
4878
|
strokeLinejoin: "round",
|
|
4820
4879
|
"aria-hidden": "true"
|
|
4821
|
-
}, /* @__PURE__ */
|
|
4880
|
+
}, /* @__PURE__ */ import_react20.default.createElement("line", {
|
|
4822
4881
|
x1: "18",
|
|
4823
4882
|
y1: "6",
|
|
4824
4883
|
x2: "6",
|
|
4825
4884
|
y2: "18"
|
|
4826
|
-
}), /* @__PURE__ */
|
|
4885
|
+
}), /* @__PURE__ */ import_react20.default.createElement("line", {
|
|
4827
4886
|
x1: "6",
|
|
4828
4887
|
y1: "6",
|
|
4829
4888
|
x2: "18",
|
|
4830
4889
|
y2: "18"
|
|
4831
4890
|
}));
|
|
4832
4891
|
var useIsDocumentHidden = () => {
|
|
4833
|
-
const [isDocumentHidden, setIsDocumentHidden] =
|
|
4834
|
-
|
|
4892
|
+
const [isDocumentHidden, setIsDocumentHidden] = import_react20.default.useState(document.hidden);
|
|
4893
|
+
import_react20.default.useEffect(() => {
|
|
4835
4894
|
const callback = () => {
|
|
4836
4895
|
setIsDocumentHidden(document.hidden);
|
|
4837
4896
|
};
|
|
@@ -5015,7 +5074,7 @@ var Observer = class {
|
|
|
5015
5074
|
"resolve",
|
|
5016
5075
|
response
|
|
5017
5076
|
];
|
|
5018
|
-
const isReactElementResponse =
|
|
5077
|
+
const isReactElementResponse = import_react20.default.isValidElement(response);
|
|
5019
5078
|
if (isReactElementResponse) {
|
|
5020
5079
|
shouldDismiss = false;
|
|
5021
5080
|
this.create({
|
|
@@ -5027,7 +5086,7 @@ var Observer = class {
|
|
|
5027
5086
|
shouldDismiss = false;
|
|
5028
5087
|
const promiseData = typeof data2.error === "function" ? await data2.error(`HTTP error! status: ${response.status}`) : data2.error;
|
|
5029
5088
|
const description = typeof data2.description === "function" ? await data2.description(`HTTP error! status: ${response.status}`) : data2.description;
|
|
5030
|
-
const isExtendedResult = typeof promiseData === "object" && !
|
|
5089
|
+
const isExtendedResult = typeof promiseData === "object" && !import_react20.default.isValidElement(promiseData);
|
|
5031
5090
|
const toastSettings = isExtendedResult ? promiseData : {
|
|
5032
5091
|
message: promiseData
|
|
5033
5092
|
};
|
|
@@ -5041,7 +5100,7 @@ var Observer = class {
|
|
|
5041
5100
|
shouldDismiss = false;
|
|
5042
5101
|
const promiseData = typeof data2.error === "function" ? await data2.error(response) : data2.error;
|
|
5043
5102
|
const description = typeof data2.description === "function" ? await data2.description(response) : data2.description;
|
|
5044
|
-
const isExtendedResult = typeof promiseData === "object" && !
|
|
5103
|
+
const isExtendedResult = typeof promiseData === "object" && !import_react20.default.isValidElement(promiseData);
|
|
5045
5104
|
const toastSettings = isExtendedResult ? promiseData : {
|
|
5046
5105
|
message: promiseData
|
|
5047
5106
|
};
|
|
@@ -5055,7 +5114,7 @@ var Observer = class {
|
|
|
5055
5114
|
shouldDismiss = false;
|
|
5056
5115
|
const promiseData = typeof data2.success === "function" ? await data2.success(response) : data2.success;
|
|
5057
5116
|
const description = typeof data2.description === "function" ? await data2.description(response) : data2.description;
|
|
5058
|
-
const isExtendedResult = typeof promiseData === "object" && !
|
|
5117
|
+
const isExtendedResult = typeof promiseData === "object" && !import_react20.default.isValidElement(promiseData);
|
|
5059
5118
|
const toastSettings = isExtendedResult ? promiseData : {
|
|
5060
5119
|
message: promiseData
|
|
5061
5120
|
};
|
|
@@ -5075,7 +5134,7 @@ var Observer = class {
|
|
|
5075
5134
|
shouldDismiss = false;
|
|
5076
5135
|
const promiseData = typeof data2.error === "function" ? await data2.error(error) : data2.error;
|
|
5077
5136
|
const description = typeof data2.description === "function" ? await data2.description(error) : data2.description;
|
|
5078
|
-
const isExtendedResult = typeof promiseData === "object" && !
|
|
5137
|
+
const isExtendedResult = typeof promiseData === "object" && !import_react20.default.isValidElement(promiseData);
|
|
5079
5138
|
const toastSettings = isExtendedResult ? promiseData : {
|
|
5080
5139
|
message: promiseData
|
|
5081
5140
|
};
|
|
@@ -5176,18 +5235,18 @@ function getDefaultSwipeDirections(position) {
|
|
|
5176
5235
|
var Toast = (props) => {
|
|
5177
5236
|
var _toast_classNames, _toast_classNames1, _toast_classNames2, _toast_classNames3, _toast_classNames4, _toast_classNames5, _toast_classNames6, _toast_classNames7, _toast_classNames8;
|
|
5178
5237
|
const { invert: ToasterInvert, toast: toast2, unstyled, interacting, setHeights, visibleToasts, heights, index: index3, toasts, expanded, removeToast, defaultRichColors, closeButton: closeButtonFromToaster, style: style2, cancelButtonStyle, actionButtonStyle, className: className2 = "", descriptionClassName = "", duration: durationFromToaster, position, gap, expandByDefault, classNames, icons, closeButtonAriaLabel = "Close toast" } = props;
|
|
5179
|
-
const [swipeDirection, setSwipeDirection] =
|
|
5180
|
-
const [swipeOutDirection, setSwipeOutDirection] =
|
|
5181
|
-
const [mounted, setMounted] =
|
|
5182
|
-
const [removed, setRemoved] =
|
|
5183
|
-
const [swiping, setSwiping] =
|
|
5184
|
-
const [swipeOut, setSwipeOut] =
|
|
5185
|
-
const [isSwiped, setIsSwiped] =
|
|
5186
|
-
const [offsetBeforeRemove, setOffsetBeforeRemove] =
|
|
5187
|
-
const [initialHeight, setInitialHeight] =
|
|
5188
|
-
const remainingTime =
|
|
5189
|
-
const dragStartTime =
|
|
5190
|
-
const toastRef =
|
|
5238
|
+
const [swipeDirection, setSwipeDirection] = import_react20.default.useState(null);
|
|
5239
|
+
const [swipeOutDirection, setSwipeOutDirection] = import_react20.default.useState(null);
|
|
5240
|
+
const [mounted, setMounted] = import_react20.default.useState(false);
|
|
5241
|
+
const [removed, setRemoved] = import_react20.default.useState(false);
|
|
5242
|
+
const [swiping, setSwiping] = import_react20.default.useState(false);
|
|
5243
|
+
const [swipeOut, setSwipeOut] = import_react20.default.useState(false);
|
|
5244
|
+
const [isSwiped, setIsSwiped] = import_react20.default.useState(false);
|
|
5245
|
+
const [offsetBeforeRemove, setOffsetBeforeRemove] = import_react20.default.useState(0);
|
|
5246
|
+
const [initialHeight, setInitialHeight] = import_react20.default.useState(0);
|
|
5247
|
+
const remainingTime = import_react20.default.useRef(toast2.duration || durationFromToaster || TOAST_LIFETIME);
|
|
5248
|
+
const dragStartTime = import_react20.default.useRef(null);
|
|
5249
|
+
const toastRef = import_react20.default.useRef(null);
|
|
5191
5250
|
const isFront = index3 === 0;
|
|
5192
5251
|
const isVisible = index3 + 1 <= visibleToasts;
|
|
5193
5252
|
const toastType = toast2.type;
|
|
@@ -5195,27 +5254,27 @@ var Toast = (props) => {
|
|
|
5195
5254
|
const dismissible = toast2.dismissible !== false;
|
|
5196
5255
|
const toastClassname = toast2.className || "";
|
|
5197
5256
|
const toastDescriptionClassname = toast2.descriptionClassName || "";
|
|
5198
|
-
const heightIndex =
|
|
5257
|
+
const heightIndex = import_react20.default.useMemo(() => heights.findIndex((height) => height.toastId === toast2.id) || 0, [
|
|
5199
5258
|
heights,
|
|
5200
5259
|
toast2.id
|
|
5201
5260
|
]);
|
|
5202
|
-
const closeButton =
|
|
5261
|
+
const closeButton = import_react20.default.useMemo(() => {
|
|
5203
5262
|
var _toast_closeButton;
|
|
5204
5263
|
return (_toast_closeButton = toast2.closeButton) != null ? _toast_closeButton : closeButtonFromToaster;
|
|
5205
5264
|
}, [
|
|
5206
5265
|
toast2.closeButton,
|
|
5207
5266
|
closeButtonFromToaster
|
|
5208
5267
|
]);
|
|
5209
|
-
const duration =
|
|
5268
|
+
const duration = import_react20.default.useMemo(() => toast2.duration || durationFromToaster || TOAST_LIFETIME, [
|
|
5210
5269
|
toast2.duration,
|
|
5211
5270
|
durationFromToaster
|
|
5212
5271
|
]);
|
|
5213
|
-
const closeTimerStartTimeRef =
|
|
5214
|
-
const offset4 =
|
|
5215
|
-
const lastCloseTimerStartTimeRef =
|
|
5216
|
-
const pointerStartRef =
|
|
5272
|
+
const closeTimerStartTimeRef = import_react20.default.useRef(0);
|
|
5273
|
+
const offset4 = import_react20.default.useRef(0);
|
|
5274
|
+
const lastCloseTimerStartTimeRef = import_react20.default.useRef(0);
|
|
5275
|
+
const pointerStartRef = import_react20.default.useRef(null);
|
|
5217
5276
|
const [y, x] = position.split("-");
|
|
5218
|
-
const toastsHeightBefore =
|
|
5277
|
+
const toastsHeightBefore = import_react20.default.useMemo(() => {
|
|
5219
5278
|
return heights.reduce((prev, curr, reducerIndex) => {
|
|
5220
5279
|
if (reducerIndex >= heightIndex) {
|
|
5221
5280
|
return prev;
|
|
@@ -5227,7 +5286,7 @@ var Toast = (props) => {
|
|
|
5227
5286
|
heightIndex
|
|
5228
5287
|
]);
|
|
5229
5288
|
const isDocumentHidden = useIsDocumentHidden();
|
|
5230
|
-
const swipeDirections =
|
|
5289
|
+
const swipeDirections = import_react20.default.useMemo(() => {
|
|
5231
5290
|
var _props_swipeDirections;
|
|
5232
5291
|
return (_props_swipeDirections = props.swipeDirections) != null ? _props_swipeDirections : getDefaultSwipeDirections(position);
|
|
5233
5292
|
}, [
|
|
@@ -5236,19 +5295,19 @@ var Toast = (props) => {
|
|
|
5236
5295
|
]);
|
|
5237
5296
|
const invert = toast2.invert || ToasterInvert;
|
|
5238
5297
|
const disabled = toastType === "loading";
|
|
5239
|
-
offset4.current =
|
|
5298
|
+
offset4.current = import_react20.default.useMemo(() => heightIndex * gap + toastsHeightBefore, [
|
|
5240
5299
|
heightIndex,
|
|
5241
5300
|
toastsHeightBefore
|
|
5242
5301
|
]);
|
|
5243
|
-
|
|
5302
|
+
import_react20.default.useEffect(() => {
|
|
5244
5303
|
remainingTime.current = duration;
|
|
5245
5304
|
}, [
|
|
5246
5305
|
duration
|
|
5247
5306
|
]);
|
|
5248
|
-
|
|
5307
|
+
import_react20.default.useEffect(() => {
|
|
5249
5308
|
setMounted(true);
|
|
5250
5309
|
}, []);
|
|
5251
|
-
|
|
5310
|
+
import_react20.default.useEffect(() => {
|
|
5252
5311
|
const toastNode = toastRef.current;
|
|
5253
5312
|
if (toastNode) {
|
|
5254
5313
|
const height = toastNode.getBoundingClientRect().height;
|
|
@@ -5267,7 +5326,7 @@ var Toast = (props) => {
|
|
|
5267
5326
|
setHeights,
|
|
5268
5327
|
toast2.id
|
|
5269
5328
|
]);
|
|
5270
|
-
|
|
5329
|
+
import_react20.default.useLayoutEffect(() => {
|
|
5271
5330
|
if (!mounted) return;
|
|
5272
5331
|
const toastNode = toastRef.current;
|
|
5273
5332
|
const originalHeight = toastNode.style.height;
|
|
@@ -5303,7 +5362,7 @@ var Toast = (props) => {
|
|
|
5303
5362
|
toast2.action,
|
|
5304
5363
|
toast2.cancel
|
|
5305
5364
|
]);
|
|
5306
|
-
const deleteToast =
|
|
5365
|
+
const deleteToast = import_react20.default.useCallback(() => {
|
|
5307
5366
|
setRemoved(true);
|
|
5308
5367
|
setOffsetBeforeRemove(offset4.current);
|
|
5309
5368
|
setHeights((h60) => h60.filter((height) => height.toastId !== toast2.id));
|
|
@@ -5316,7 +5375,7 @@ var Toast = (props) => {
|
|
|
5316
5375
|
setHeights,
|
|
5317
5376
|
offset4
|
|
5318
5377
|
]);
|
|
5319
|
-
|
|
5378
|
+
import_react20.default.useEffect(() => {
|
|
5320
5379
|
if (toast2.promise && toastType === "loading" || toast2.duration === Infinity || toast2.type === "loading") return;
|
|
5321
5380
|
let timeoutId;
|
|
5322
5381
|
const pauseTimer = () => {
|
|
@@ -5348,7 +5407,7 @@ var Toast = (props) => {
|
|
|
5348
5407
|
isDocumentHidden,
|
|
5349
5408
|
deleteToast
|
|
5350
5409
|
]);
|
|
5351
|
-
|
|
5410
|
+
import_react20.default.useEffect(() => {
|
|
5352
5411
|
if (toast2.delete) {
|
|
5353
5412
|
deleteToast();
|
|
5354
5413
|
toast2.onDismiss == null ? void 0 : toast2.onDismiss.call(toast2, toast2);
|
|
@@ -5361,19 +5420,19 @@ var Toast = (props) => {
|
|
|
5361
5420
|
var _toast_classNames9;
|
|
5362
5421
|
if (icons == null ? void 0 : icons.loading) {
|
|
5363
5422
|
var _toast_classNames12;
|
|
5364
|
-
return /* @__PURE__ */
|
|
5423
|
+
return /* @__PURE__ */ import_react20.default.createElement("div", {
|
|
5365
5424
|
className: cn(classNames == null ? void 0 : classNames.loader, toast2 == null ? void 0 : (_toast_classNames12 = toast2.classNames) == null ? void 0 : _toast_classNames12.loader, "sonner-loader"),
|
|
5366
5425
|
"data-visible": toastType === "loading"
|
|
5367
5426
|
}, icons.loading);
|
|
5368
5427
|
}
|
|
5369
|
-
return /* @__PURE__ */
|
|
5428
|
+
return /* @__PURE__ */ import_react20.default.createElement(Loader, {
|
|
5370
5429
|
className: cn(classNames == null ? void 0 : classNames.loader, toast2 == null ? void 0 : (_toast_classNames9 = toast2.classNames) == null ? void 0 : _toast_classNames9.loader),
|
|
5371
5430
|
visible: toastType === "loading"
|
|
5372
5431
|
});
|
|
5373
5432
|
}
|
|
5374
5433
|
const icon2 = toast2.icon || (icons == null ? void 0 : icons[toastType]) || getAsset(toastType);
|
|
5375
5434
|
var _toast_richColors, _icons_close;
|
|
5376
|
-
return /* @__PURE__ */
|
|
5435
|
+
return /* @__PURE__ */ import_react20.default.createElement("li", {
|
|
5377
5436
|
tabIndex: 0,
|
|
5378
5437
|
ref: toastRef,
|
|
5379
5438
|
className: cn(className2, toastClassname, classNames == null ? void 0 : classNames.toast, toast2 == null ? void 0 : (_toast_classNames = toast2.classNames) == null ? void 0 : _toast_classNames.toast, classNames == null ? void 0 : classNames[toastTypeKey], toast2 == null ? void 0 : (_toast_classNames1 = toast2.classNames) == null ? void 0 : _toast_classNames1[toastTypeKey]),
|
|
@@ -5497,7 +5556,7 @@ var Toast = (props) => {
|
|
|
5497
5556
|
(_toastRef_current = toastRef.current) == null ? void 0 : _toastRef_current.style.setProperty("--swipe-amount-x", `${swipeAmount.x}px`);
|
|
5498
5557
|
(_toastRef_current1 = toastRef.current) == null ? void 0 : _toastRef_current1.style.setProperty("--swipe-amount-y", `${swipeAmount.y}px`);
|
|
5499
5558
|
}
|
|
5500
|
-
}, closeButton && !toast2.jsx && toastType !== "loading" ? /* @__PURE__ */
|
|
5559
|
+
}, closeButton && !toast2.jsx && toastType !== "loading" ? /* @__PURE__ */ import_react20.default.createElement("button", {
|
|
5501
5560
|
"aria-label": closeButtonAriaLabel,
|
|
5502
5561
|
"data-disabled": disabled,
|
|
5503
5562
|
"data-close-button": true,
|
|
@@ -5507,19 +5566,19 @@ var Toast = (props) => {
|
|
|
5507
5566
|
toast2.onDismiss == null ? void 0 : toast2.onDismiss.call(toast2, toast2);
|
|
5508
5567
|
},
|
|
5509
5568
|
className: cn(classNames == null ? void 0 : classNames.closeButton, toast2 == null ? void 0 : (_toast_classNames2 = toast2.classNames) == null ? void 0 : _toast_classNames2.closeButton)
|
|
5510
|
-
}, (_icons_close = icons == null ? void 0 : icons.close) != null ? _icons_close : CloseIcon) : null, (toastType || toast2.icon || toast2.promise) && toast2.icon !== null && ((icons == null ? void 0 : icons[toastType]) !== null || toast2.icon) ? /* @__PURE__ */
|
|
5569
|
+
}, (_icons_close = icons == null ? void 0 : icons.close) != null ? _icons_close : CloseIcon) : null, (toastType || toast2.icon || toast2.promise) && toast2.icon !== null && ((icons == null ? void 0 : icons[toastType]) !== null || toast2.icon) ? /* @__PURE__ */ import_react20.default.createElement("div", {
|
|
5511
5570
|
"data-icon": "",
|
|
5512
5571
|
className: cn(classNames == null ? void 0 : classNames.icon, toast2 == null ? void 0 : (_toast_classNames3 = toast2.classNames) == null ? void 0 : _toast_classNames3.icon)
|
|
5513
|
-
}, toastType === "loading" ? toast2.icon || getLoadingIcon() : toast2.promise ? getLoadingIcon() : null, toastType !== "loading" ? icon2 : null) : null, /* @__PURE__ */
|
|
5572
|
+
}, toastType === "loading" ? toast2.icon || getLoadingIcon() : toast2.promise ? getLoadingIcon() : null, toastType !== "loading" ? icon2 : null) : null, /* @__PURE__ */ import_react20.default.createElement("div", {
|
|
5514
5573
|
"data-content": "",
|
|
5515
5574
|
className: cn(classNames == null ? void 0 : classNames.content, toast2 == null ? void 0 : (_toast_classNames4 = toast2.classNames) == null ? void 0 : _toast_classNames4.content)
|
|
5516
|
-
}, /* @__PURE__ */
|
|
5575
|
+
}, /* @__PURE__ */ import_react20.default.createElement("div", {
|
|
5517
5576
|
"data-title": "",
|
|
5518
5577
|
className: cn(classNames == null ? void 0 : classNames.title, toast2 == null ? void 0 : (_toast_classNames5 = toast2.classNames) == null ? void 0 : _toast_classNames5.title)
|
|
5519
|
-
}, toast2.jsx ? toast2.jsx : typeof toast2.title === "function" ? toast2.title() : toast2.title), toast2.description ? /* @__PURE__ */
|
|
5578
|
+
}, toast2.jsx ? toast2.jsx : typeof toast2.title === "function" ? toast2.title() : toast2.title), toast2.description ? /* @__PURE__ */ import_react20.default.createElement("div", {
|
|
5520
5579
|
"data-description": "",
|
|
5521
5580
|
className: cn(descriptionClassName, toastDescriptionClassname, classNames == null ? void 0 : classNames.description, toast2 == null ? void 0 : (_toast_classNames6 = toast2.classNames) == null ? void 0 : _toast_classNames6.description)
|
|
5522
|
-
}, typeof toast2.description === "function" ? toast2.description() : toast2.description) : null), /* @__PURE__ */
|
|
5581
|
+
}, typeof toast2.description === "function" ? toast2.description() : toast2.description) : null), /* @__PURE__ */ import_react20.default.isValidElement(toast2.cancel) ? toast2.cancel : toast2.cancel && isAction(toast2.cancel) ? /* @__PURE__ */ import_react20.default.createElement("button", {
|
|
5523
5582
|
"data-button": true,
|
|
5524
5583
|
"data-cancel": true,
|
|
5525
5584
|
style: toast2.cancelButtonStyle || cancelButtonStyle,
|
|
@@ -5530,7 +5589,7 @@ var Toast = (props) => {
|
|
|
5530
5589
|
deleteToast();
|
|
5531
5590
|
},
|
|
5532
5591
|
className: cn(classNames == null ? void 0 : classNames.cancelButton, toast2 == null ? void 0 : (_toast_classNames7 = toast2.classNames) == null ? void 0 : _toast_classNames7.cancelButton)
|
|
5533
|
-
}, toast2.cancel.label) : null, /* @__PURE__ */
|
|
5592
|
+
}, toast2.cancel.label) : null, /* @__PURE__ */ import_react20.default.isValidElement(toast2.action) ? toast2.action : toast2.action && isAction(toast2.action) ? /* @__PURE__ */ import_react20.default.createElement("button", {
|
|
5534
5593
|
"data-button": true,
|
|
5535
5594
|
"data-action": true,
|
|
5536
5595
|
style: toast2.actionButtonStyle || actionButtonStyle,
|
|
@@ -5592,13 +5651,13 @@ function assignOffset(defaultOffset, mobileOffset) {
|
|
|
5592
5651
|
});
|
|
5593
5652
|
return styles;
|
|
5594
5653
|
}
|
|
5595
|
-
var Toaster = /* @__PURE__ */
|
|
5654
|
+
var Toaster = /* @__PURE__ */ import_react20.default.forwardRef(function Toaster2(props, ref) {
|
|
5596
5655
|
const { id: id3, invert, position = "bottom-right", hotkey = [
|
|
5597
5656
|
"altKey",
|
|
5598
5657
|
"KeyT"
|
|
5599
5658
|
], expand, closeButton, className: className2, offset: offset4, mobileOffset, theme: theme2 = "light", richColors, duration, style: style2, visibleToasts = VISIBLE_TOASTS_AMOUNT, toastOptions, dir = getDocumentDirection(), gap = GAP, icons, customAriaLabel, containerAriaLabel = "Notifications" } = props;
|
|
5600
|
-
const [toasts, setToasts] =
|
|
5601
|
-
const filteredToasts =
|
|
5659
|
+
const [toasts, setToasts] = import_react20.default.useState([]);
|
|
5660
|
+
const filteredToasts = import_react20.default.useMemo(() => {
|
|
5602
5661
|
if (id3) {
|
|
5603
5662
|
return toasts.filter((toast2) => toast2.toasterId === id3);
|
|
5604
5663
|
}
|
|
@@ -5607,7 +5666,7 @@ var Toaster = /* @__PURE__ */ import_react19.default.forwardRef(function Toaster
|
|
|
5607
5666
|
toasts,
|
|
5608
5667
|
id3
|
|
5609
5668
|
]);
|
|
5610
|
-
const possiblePositions =
|
|
5669
|
+
const possiblePositions = import_react20.default.useMemo(() => {
|
|
5611
5670
|
return Array.from(new Set([
|
|
5612
5671
|
position
|
|
5613
5672
|
].concat(filteredToasts.filter((toast2) => toast2.position).map((toast2) => toast2.position))));
|
|
@@ -5615,15 +5674,15 @@ var Toaster = /* @__PURE__ */ import_react19.default.forwardRef(function Toaster
|
|
|
5615
5674
|
filteredToasts,
|
|
5616
5675
|
position
|
|
5617
5676
|
]);
|
|
5618
|
-
const [heights, setHeights] =
|
|
5619
|
-
const [expanded, setExpanded] =
|
|
5620
|
-
const [interacting, setInteracting] =
|
|
5621
|
-
const [actualTheme, setActualTheme] =
|
|
5622
|
-
const listRef =
|
|
5677
|
+
const [heights, setHeights] = import_react20.default.useState([]);
|
|
5678
|
+
const [expanded, setExpanded] = import_react20.default.useState(false);
|
|
5679
|
+
const [interacting, setInteracting] = import_react20.default.useState(false);
|
|
5680
|
+
const [actualTheme, setActualTheme] = import_react20.default.useState(theme2 !== "system" ? theme2 : typeof window !== "undefined" ? window.matchMedia && window.matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "light" : "light");
|
|
5681
|
+
const listRef = import_react20.default.useRef(null);
|
|
5623
5682
|
const hotkeyLabel = hotkey.join("+").replace(/Key/g, "").replace(/Digit/g, "");
|
|
5624
|
-
const lastFocusedElementRef =
|
|
5625
|
-
const isFocusWithinRef =
|
|
5626
|
-
const removeToast =
|
|
5683
|
+
const lastFocusedElementRef = import_react20.default.useRef(null);
|
|
5684
|
+
const isFocusWithinRef = import_react20.default.useRef(false);
|
|
5685
|
+
const removeToast = import_react20.default.useCallback((toastToRemove) => {
|
|
5627
5686
|
setToasts((toasts2) => {
|
|
5628
5687
|
var _toasts_find;
|
|
5629
5688
|
if (!((_toasts_find = toasts2.find((toast2) => toast2.id === toastToRemove.id)) == null ? void 0 : _toasts_find.delete)) {
|
|
@@ -5632,7 +5691,7 @@ var Toaster = /* @__PURE__ */ import_react19.default.forwardRef(function Toaster
|
|
|
5632
5691
|
return toasts2.filter(({ id: id4 }) => id4 !== toastToRemove.id);
|
|
5633
5692
|
});
|
|
5634
5693
|
}, []);
|
|
5635
|
-
|
|
5694
|
+
import_react20.default.useEffect(() => {
|
|
5636
5695
|
return ToastState.subscribe((toast2) => {
|
|
5637
5696
|
if (toast2.dismiss) {
|
|
5638
5697
|
requestAnimationFrame(() => {
|
|
@@ -5666,7 +5725,7 @@ var Toaster = /* @__PURE__ */ import_react19.default.forwardRef(function Toaster
|
|
|
5666
5725
|
});
|
|
5667
5726
|
});
|
|
5668
5727
|
}, []);
|
|
5669
|
-
|
|
5728
|
+
import_react20.default.useEffect(() => {
|
|
5670
5729
|
if (theme2 !== "system") {
|
|
5671
5730
|
setActualTheme(theme2);
|
|
5672
5731
|
return;
|
|
@@ -5704,14 +5763,14 @@ var Toaster = /* @__PURE__ */ import_react19.default.forwardRef(function Toaster
|
|
|
5704
5763
|
}, [
|
|
5705
5764
|
theme2
|
|
5706
5765
|
]);
|
|
5707
|
-
|
|
5766
|
+
import_react20.default.useEffect(() => {
|
|
5708
5767
|
if (toasts.length <= 1) {
|
|
5709
5768
|
setExpanded(false);
|
|
5710
5769
|
}
|
|
5711
5770
|
}, [
|
|
5712
5771
|
toasts
|
|
5713
5772
|
]);
|
|
5714
|
-
|
|
5773
|
+
import_react20.default.useEffect(() => {
|
|
5715
5774
|
const handleKeyDown = (event) => {
|
|
5716
5775
|
var _listRef_current;
|
|
5717
5776
|
const isHotkeyPressed = hotkey.length > 0 && hotkey.every((key) => event[key] || event.code === key);
|
|
@@ -5729,7 +5788,7 @@ var Toaster = /* @__PURE__ */ import_react19.default.forwardRef(function Toaster
|
|
|
5729
5788
|
}, [
|
|
5730
5789
|
hotkey
|
|
5731
5790
|
]);
|
|
5732
|
-
|
|
5791
|
+
import_react20.default.useEffect(() => {
|
|
5733
5792
|
if (listRef.current) {
|
|
5734
5793
|
return () => {
|
|
5735
5794
|
if (lastFocusedElementRef.current) {
|
|
@@ -5746,7 +5805,7 @@ var Toaster = /* @__PURE__ */ import_react19.default.forwardRef(function Toaster
|
|
|
5746
5805
|
]);
|
|
5747
5806
|
return (
|
|
5748
5807
|
// Remove item from normal navigation flow, only available via hotkey
|
|
5749
|
-
/* @__PURE__ */
|
|
5808
|
+
/* @__PURE__ */ import_react20.default.createElement("section", {
|
|
5750
5809
|
ref,
|
|
5751
5810
|
"aria-label": customAriaLabel != null ? customAriaLabel : `${containerAriaLabel} ${hotkeyLabel}`,
|
|
5752
5811
|
tabIndex: -1,
|
|
@@ -5759,7 +5818,7 @@ var Toaster = /* @__PURE__ */ import_react19.default.forwardRef(function Toaster
|
|
|
5759
5818
|
var _heights_;
|
|
5760
5819
|
const [y, x] = position2.split("-");
|
|
5761
5820
|
if (!filteredToasts.length) return null;
|
|
5762
|
-
return /* @__PURE__ */
|
|
5821
|
+
return /* @__PURE__ */ import_react20.default.createElement("ol", {
|
|
5763
5822
|
key: position2,
|
|
5764
5823
|
dir: dir === "auto" ? getDocumentDirection() : dir,
|
|
5765
5824
|
tabIndex: -1,
|
|
@@ -5811,7 +5870,7 @@ var Toaster = /* @__PURE__ */ import_react19.default.forwardRef(function Toaster
|
|
|
5811
5870
|
onPointerUp: () => setInteracting(false)
|
|
5812
5871
|
}, filteredToasts.filter((toast2) => !toast2.position && index3 === 0 || toast2.position === position2).map((toast2, index4) => {
|
|
5813
5872
|
var _toastOptions_duration, _toastOptions_closeButton;
|
|
5814
|
-
return /* @__PURE__ */
|
|
5873
|
+
return /* @__PURE__ */ import_react20.default.createElement(Toast, {
|
|
5815
5874
|
key: toast2.id,
|
|
5816
5875
|
icons,
|
|
5817
5876
|
index: index4,
|
|
@@ -5879,7 +5938,7 @@ function createToasterHost() {
|
|
|
5879
5938
|
function renderToaster() {
|
|
5880
5939
|
if (root === null)
|
|
5881
5940
|
return;
|
|
5882
|
-
root.render((0,
|
|
5941
|
+
root.render((0, import_react21.createElement)(Toaster, {
|
|
5883
5942
|
theme: currentTheme(),
|
|
5884
5943
|
position,
|
|
5885
5944
|
// richColors:success=绿整条 / error=红整条 / warning=黄整条(Sonner 自带);
|
|
@@ -5945,7 +6004,7 @@ function createToasterHost() {
|
|
|
5945
6004
|
const palette = notifyPalette(payload.variant, currentTheme());
|
|
5946
6005
|
const duration = payload.durationMs;
|
|
5947
6006
|
const actions = payload.actions;
|
|
5948
|
-
const id3 = toast.custom(() => (0,
|
|
6007
|
+
const id3 = toast.custom(() => (0, import_react21.createElement)("div", {
|
|
5949
6008
|
style: {
|
|
5950
6009
|
display: "flex",
|
|
5951
6010
|
alignItems: "center",
|
|
@@ -5961,7 +6020,7 @@ function createToasterHost() {
|
|
|
5961
6020
|
fontSize: "14px",
|
|
5962
6021
|
lineHeight: "20px"
|
|
5963
6022
|
}
|
|
5964
|
-
}, (0,
|
|
6023
|
+
}, (0, import_react21.createElement)("span", {
|
|
5965
6024
|
style: {
|
|
5966
6025
|
flexShrink: 0,
|
|
5967
6026
|
width: "20px",
|
|
@@ -5974,7 +6033,7 @@ function createToasterHost() {
|
|
|
5974
6033
|
fontSize: "13px",
|
|
5975
6034
|
fontWeight: 700
|
|
5976
6035
|
}
|
|
5977
|
-
}, palette.glyph), (0,
|
|
6036
|
+
}, palette.glyph), (0, import_react21.createElement)("div", { style: { flex: 1, minWidth: 0 } }, (0, import_react21.createElement)("div", { style: { fontWeight: 600 } }, payload.message), payload.description !== void 0 ? (0, import_react21.createElement)("div", { style: { opacity: 0.9, fontSize: "13px", marginTop: "2px" } }, payload.description) : null), actions !== void 0 && actions.length > 0 ? (0, import_react21.createElement)("div", { style: { display: "flex", gap: "8px", flexShrink: 0 } }, ...actions.slice(0, 2).map((a) => (0, import_react21.createElement)(Button, {
|
|
5978
6037
|
variant: a.variant ?? "outline",
|
|
5979
6038
|
size: "md",
|
|
5980
6039
|
onClick: () => {
|
|
@@ -6048,7 +6107,7 @@ function notify(message, opts) {
|
|
|
6048
6107
|
}
|
|
6049
6108
|
|
|
6050
6109
|
// dist/ui/Segmented.js
|
|
6051
|
-
var
|
|
6110
|
+
var import_react22 = require("react");
|
|
6052
6111
|
function Segmented(props) {
|
|
6053
6112
|
ensureControls();
|
|
6054
6113
|
ensureControls();
|
|
@@ -6057,9 +6116,9 @@ function Segmented(props) {
|
|
|
6057
6116
|
const value = props.value;
|
|
6058
6117
|
const onChange = props.onChange;
|
|
6059
6118
|
const sliding = !multiple && props.items.length > 1;
|
|
6060
|
-
const rootRef = (0,
|
|
6061
|
-
const [thumb, setThumb] = (0,
|
|
6062
|
-
const measure = (0,
|
|
6119
|
+
const rootRef = (0, import_react22.useRef)(null);
|
|
6120
|
+
const [thumb, setThumb] = (0, import_react22.useState)(null);
|
|
6121
|
+
const measure = (0, import_react22.useCallback)(() => {
|
|
6063
6122
|
const sel = rootRef.current?.querySelector('.dshpc-seg__item[aria-pressed="true"]');
|
|
6064
6123
|
if (sel === void 0 || sel === null) {
|
|
6065
6124
|
setThumb(null);
|
|
@@ -6068,7 +6127,7 @@ function Segmented(props) {
|
|
|
6068
6127
|
const next = { left: sel.offsetLeft, top: sel.offsetTop, width: sel.offsetWidth, height: sel.offsetHeight };
|
|
6069
6128
|
setThumb((cur2) => cur2 !== null && cur2.left === next.left && cur2.top === next.top && cur2.width === next.width && cur2.height === next.height ? cur2 : next);
|
|
6070
6129
|
}, []);
|
|
6071
|
-
(0,
|
|
6130
|
+
(0, import_react22.useLayoutEffect)(() => {
|
|
6072
6131
|
if (!sliding) {
|
|
6073
6132
|
setThumb(null);
|
|
6074
6133
|
return;
|
|
@@ -6082,7 +6141,7 @@ function Segmented(props) {
|
|
|
6082
6141
|
return () => ro.disconnect();
|
|
6083
6142
|
}, [sliding, measure, value, size4, props.items, props.bordered, props.block]);
|
|
6084
6143
|
const renderer2 = getTooltipRenderer();
|
|
6085
|
-
return (0,
|
|
6144
|
+
return (0, import_react22.createElement)("div", {
|
|
6086
6145
|
role: "group",
|
|
6087
6146
|
"aria-label": props.label,
|
|
6088
6147
|
id: props.id,
|
|
@@ -6091,7 +6150,7 @@ function Segmented(props) {
|
|
|
6091
6150
|
className: `dshpc-seg dshpc-seg--${size4}${sliding ? " dshpc-seg--slide" : ""}${props.block === true ? " dshpc-seg--block" : ""}${props.bordered === true ? " dshpc-seg--bordered" : ""}${props.className !== void 0 ? ` ${props.className}` : ""}`,
|
|
6092
6151
|
style: props.style
|
|
6093
6152
|
}, [
|
|
6094
|
-
sliding && thumb !== null ? (0,
|
|
6153
|
+
sliding && thumb !== null ? (0, import_react22.createElement)("span", {
|
|
6095
6154
|
key: "__thumb__",
|
|
6096
6155
|
className: "dshpc-seg__thumb",
|
|
6097
6156
|
"aria-hidden": true,
|
|
@@ -6117,7 +6176,7 @@ function Segmented(props) {
|
|
|
6117
6176
|
onChange(item.value);
|
|
6118
6177
|
}
|
|
6119
6178
|
};
|
|
6120
|
-
const itemButton = (0,
|
|
6179
|
+
const itemButton = (0, import_react22.createElement)("button", {
|
|
6121
6180
|
key: item.value,
|
|
6122
6181
|
type: "button",
|
|
6123
6182
|
className: "dshpc-seg__item",
|
|
@@ -6125,7 +6184,7 @@ function Segmented(props) {
|
|
|
6125
6184
|
"aria-pressed": on,
|
|
6126
6185
|
disabled,
|
|
6127
6186
|
onClick: handle
|
|
6128
|
-
}, item.label, item.count !== void 0 && item.count > 0 ? (0,
|
|
6187
|
+
}, item.label, item.count !== void 0 && item.count > 0 ? (0, import_react22.createElement)("span", { className: "dshpc-seg__count" }, String(item.count)) : null, item.badge !== void 0 && item.badge > 0 ? (0, import_react22.createElement)("span", { className: "dshpc-seg__badge" }, String(item.badge)) : null);
|
|
6129
6188
|
if (item.tooltip !== void 0 && renderer2 !== void 0) {
|
|
6130
6189
|
return renderer2({ label: item.tooltip, side: "top", children: itemButton });
|
|
6131
6190
|
}
|
|
@@ -6135,11 +6194,11 @@ function Segmented(props) {
|
|
|
6135
6194
|
}
|
|
6136
6195
|
|
|
6137
6196
|
// dist/ui/Textarea.js
|
|
6138
|
-
var
|
|
6197
|
+
var import_react23 = require("react");
|
|
6139
6198
|
function Textarea(props) {
|
|
6140
6199
|
ensureControls();
|
|
6141
6200
|
const { value, onChange, placeholder: placeholder2, error, disabled, id: id3, rows, spellCheck, className: className2, style: style2 } = props;
|
|
6142
|
-
const box = (0,
|
|
6201
|
+
const box = (0, import_react23.createElement)("textarea", {
|
|
6143
6202
|
id: id3,
|
|
6144
6203
|
rows,
|
|
6145
6204
|
value,
|
|
@@ -6155,14 +6214,14 @@ function Textarea(props) {
|
|
|
6155
6214
|
});
|
|
6156
6215
|
if (props.hint === void 0)
|
|
6157
6216
|
return box;
|
|
6158
|
-
return (0,
|
|
6217
|
+
return (0, import_react23.createElement)("span", { className: "dshpc-fieldwrap dshpc-fieldwrap--block" }, box, (0, import_react23.createElement)(FieldHint, { text: props.hint }));
|
|
6159
6218
|
}
|
|
6160
6219
|
|
|
6161
6220
|
// dist/ui/Checkbox.js
|
|
6162
|
-
var
|
|
6221
|
+
var import_react24 = require("react");
|
|
6163
6222
|
function Checkbox(props) {
|
|
6164
6223
|
const { checked, onChange, label, accentColor, disabled, className: className2 } = props;
|
|
6165
|
-
return (0,
|
|
6224
|
+
return (0, import_react24.createElement)("label", {
|
|
6166
6225
|
className: `dshpc-checkbox${className2 !== void 0 && className2 !== "" ? ` ${className2}` : ""}`,
|
|
6167
6226
|
style: {
|
|
6168
6227
|
display: "flex",
|
|
@@ -6172,7 +6231,7 @@ function Checkbox(props) {
|
|
|
6172
6231
|
lineHeight: "var(--dshpc-line-md)",
|
|
6173
6232
|
cursor: disabled === true ? "default" : "pointer"
|
|
6174
6233
|
}
|
|
6175
|
-
}, (0,
|
|
6234
|
+
}, (0, import_react24.createElement)("input", {
|
|
6176
6235
|
type: "checkbox",
|
|
6177
6236
|
checked,
|
|
6178
6237
|
disabled,
|
|
@@ -6187,51 +6246,7 @@ function Checkbox(props) {
|
|
|
6187
6246
|
onChange: (event) => {
|
|
6188
6247
|
onChange(event.target.checked);
|
|
6189
6248
|
}
|
|
6190
|
-
}), label !== void 0 ? (0,
|
|
6191
|
-
}
|
|
6192
|
-
|
|
6193
|
-
// dist/ui/MarqueeText.js
|
|
6194
|
-
var import_react24 = require("react");
|
|
6195
|
-
function MarqueeText(props) {
|
|
6196
|
-
const outerRef = (0, import_react24.useRef)(null);
|
|
6197
|
-
const innerRef = (0, import_react24.useRef)(null);
|
|
6198
|
-
const [dist2, setDist] = (0, import_react24.useState)(0);
|
|
6199
|
-
const measure = (0, import_react24.useCallback)(() => {
|
|
6200
|
-
const outer = outerRef.current;
|
|
6201
|
-
const inner = innerRef.current;
|
|
6202
|
-
if (outer === null || inner === null)
|
|
6203
|
-
return;
|
|
6204
|
-
setDist(Math.max(0, Math.ceil(inner.scrollWidth - outer.clientWidth)));
|
|
6205
|
-
}, []);
|
|
6206
|
-
(0, import_react24.useLayoutEffect)(() => {
|
|
6207
|
-
const outer = outerRef.current;
|
|
6208
|
-
const inner = innerRef.current;
|
|
6209
|
-
if (outer === null || inner === null)
|
|
6210
|
-
return;
|
|
6211
|
-
measure();
|
|
6212
|
-
const ro = new ResizeObserver(measure);
|
|
6213
|
-
ro.observe(outer);
|
|
6214
|
-
ro.observe(inner);
|
|
6215
|
-
return () => {
|
|
6216
|
-
ro.disconnect();
|
|
6217
|
-
};
|
|
6218
|
-
}, [measure]);
|
|
6219
|
-
(0, import_react24.useEffect)(() => {
|
|
6220
|
-
measure();
|
|
6221
|
-
}, [props.text, measure]);
|
|
6222
|
-
const run = dist2 > 0;
|
|
6223
|
-
return (0, import_react24.createElement)("span", {
|
|
6224
|
-
ref: outerRef,
|
|
6225
|
-
className: (run ? "dshpc-mq dshpc-mq-run" : "dshpc-mq") + (props.className === void 0 ? "" : ` ${props.className}`),
|
|
6226
|
-
title: props.title,
|
|
6227
|
-
style: props.style
|
|
6228
|
-
}, (0, import_react24.createElement)("span", {
|
|
6229
|
-
ref: innerRef,
|
|
6230
|
-
className: "dshpc-mq-in",
|
|
6231
|
-
style: {
|
|
6232
|
-
...run ? { "--dshpc-mq-dist": `${-dist2}px`, "--dshpc-mq-dur": `${Math.max(3, Math.round(dist2 / 30))}s` } : null
|
|
6233
|
-
}
|
|
6234
|
-
}, props.text));
|
|
6249
|
+
}), label !== void 0 ? (0, import_react24.createElement)("span", null, label) : null);
|
|
6235
6250
|
}
|
|
6236
6251
|
|
|
6237
6252
|
// dist/ui/SectionHead.js
|
|
@@ -56847,7 +56862,7 @@ var docData = {
|
|
|
56847
56862
|
},
|
|
56848
56863
|
"prose": [
|
|
56849
56864
|
{
|
|
56850
|
-
"zh": "Picker\uFF1A\u5355 / \u591A\u9009\u3001\u4E0A\u9650\u3001\u641C\u7D22\u3001\u5206\u7EC4\u3001\u7A7A\u6001\uFF0C\u81EA\u7ED8\u3002\u952E\u76D8\uFF1AEsc \u5173\u3001\u2191\u2193 \u79FB\u6E38\u6807\u3001Enter \u9009\u3002\u7EAF\u903B\u8F91\u53EF\u5355\u7528\uFF1A`toGroups` / `filterGroups` / `toggleValue`\u3002",
|
|
56865
|
+
"zh": "Picker\uFF1A\u5355 / \u591A\u9009\u3001\u4E0A\u9650\u3001\u641C\u7D22\u3001\u5206\u7EC4\u3001\u7A7A\u6001\uFF0C\u81EA\u7ED8\u3002\u952E\u76D8\uFF1AEsc \u5173\u3001\u2191\u2193 \u79FB\u6E38\u6807\u3001Enter \u9009\u3002\u7EAF\u903B\u8F91\u53EF\u5355\u7528\uFF1A`toGroups` / `filterGroups` / `toggleValue`\u3002\u89E6\u53D1\u5668\u652F\u6301 width / minWidth / maxWidth \u7EA6\u675F\u5BBD\u5EA6\uFF1A\u5B9A\u5BBD\u5FFD\u7565\u53E6\u4E24\u8005\uFF1B\u5185\u5BB9\u8D85\u957F\u5219\u7701\u7565\u53F7 + hover \u8DD1\u9A6C\u706F\u3002",
|
|
56851
56866
|
"en": "Picker: single/multiple selection, cap, search, grouping, empty state \u2014 self-drawn. Keyboard: Esc closes, \u2191\u2193 move the cursor, Enter selects. Logic reusable standalone: `toGroups` / `filterGroups` / `toggleValue`."
|
|
56852
56867
|
},
|
|
56853
56868
|
{
|
|
@@ -57016,6 +57031,33 @@ var docData = {
|
|
|
57016
57031
|
"en": "Custom width / margin"
|
|
57017
57032
|
}
|
|
57018
57033
|
},
|
|
57034
|
+
{
|
|
57035
|
+
"name": "width",
|
|
57036
|
+
"type": "number | string",
|
|
57037
|
+
"def": "\u2014",
|
|
57038
|
+
"desc": {
|
|
57039
|
+
"zh": "\u5B9A\u5BBD\uFF08px \u6216\u4EFB\u610F CSS \u957F\u5EA6\uFF09\uFF1B\u7ED9\u4E86\u5373\u5FFD\u7565 minWidth / maxWidth\uFF0C\u89E6\u53D1\u5668\u9501\u5B9A\u6B64\u5BBD\uFF1B\u5185\u5BB9\u8D85\u957F\u5219\u7701\u7565 + hover \u8DD1\u9A6C\u706F",
|
|
57040
|
+
"en": "Fixed width (px or any CSS length); overrides minWidth/maxWidth and locks the trigger; overflow elides + hover marquee"
|
|
57041
|
+
}
|
|
57042
|
+
},
|
|
57043
|
+
{
|
|
57044
|
+
"name": "minWidth",
|
|
57045
|
+
"type": "number | string",
|
|
57046
|
+
"def": "120px\uFF08CSS \u9ED8\u8BA4\uFF09",
|
|
57047
|
+
"desc": {
|
|
57048
|
+
"zh": "\u6700\u5C0F\u5BBD\uFF1B\u5185\u5BB9\u4E0D\u5230\u6B64\u5BBD\u89E6\u53D1\u5668\u4E5F\u4E0D\u66F4\u7A84",
|
|
57049
|
+
"en": "Minimum width; trigger never narrower than this"
|
|
57050
|
+
}
|
|
57051
|
+
},
|
|
57052
|
+
{
|
|
57053
|
+
"name": "maxWidth",
|
|
57054
|
+
"type": "number | string",
|
|
57055
|
+
"def": "100%\uFF08CSS \u9ED8\u8BA4\uFF09",
|
|
57056
|
+
"desc": {
|
|
57057
|
+
"zh": "\u6700\u5927\u5BBD\uFF1B\u5185\u5BB9\u8D85\u8FC7\u6B64\u5BBD\u5219\u7701\u7565 + hover \u8DD1\u9A6C\u706F",
|
|
57058
|
+
"en": "Maximum width; overflow elides + hover marquee"
|
|
57059
|
+
}
|
|
57060
|
+
},
|
|
57019
57061
|
{
|
|
57020
57062
|
"name": "ariaLabel",
|
|
57021
57063
|
"type": "string",
|
|
@@ -61467,9 +61509,9 @@ function ReferencePage() {
|
|
|
61467
61509
|
"tbody",
|
|
61468
61510
|
null,
|
|
61469
61511
|
[
|
|
61470
|
-
[t3("buildCore"), `v${"0.
|
|
61471
|
-
[t3("buildDemo"), `v${"0.
|
|
61472
|
-
[t3("buildStamp"), "
|
|
61512
|
+
[t3("buildCore"), `v${"0.6.0"}`],
|
|
61513
|
+
[t3("buildDemo"), `v${"0.6.0"}`],
|
|
61514
|
+
[t3("buildStamp"), "261028-034237-929"]
|
|
61473
61515
|
].map(
|
|
61474
61516
|
([label, value]) => (0, import_react67.createElement)(
|
|
61475
61517
|
"tr",
|
|
@@ -61791,9 +61833,9 @@ function DemoPage() {
|
|
|
61791
61833
|
lineHeight: "14px"
|
|
61792
61834
|
}
|
|
61793
61835
|
},
|
|
61794
|
-
(0, import_react69.createElement)("span", null, `core v${"0.
|
|
61795
|
-
(0, import_react69.createElement)("span", null, `demo v${"0.
|
|
61796
|
-
(0, import_react69.createElement)("span", { style: { marginTop: "4px", fontSize: "9px" } }, "
|
|
61836
|
+
(0, import_react69.createElement)("span", null, `core v${"0.6.0"}`),
|
|
61837
|
+
(0, import_react69.createElement)("span", null, `demo v${"0.6.0"}`),
|
|
61838
|
+
(0, import_react69.createElement)("span", { style: { marginTop: "4px", fontSize: "9px" } }, "261028-034237-929")
|
|
61797
61839
|
)
|
|
61798
61840
|
)
|
|
61799
61841
|
),
|