dsh-tree-task-flow 0.3.10 → 0.3.11
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/client.js +49 -18
- package/package.json +1 -1
package/client.js
CHANGED
|
@@ -61,10 +61,27 @@ window.__ModuleLoader__.load({
|
|
|
61
61
|
primitives = {};
|
|
62
62
|
}
|
|
63
63
|
|
|
64
|
+
/**
|
|
65
|
+
* 内置图标名有两套写法,这里两套都认。
|
|
66
|
+
*
|
|
67
|
+
* 旧外壳把尺寸写进名字:`IconCheckOutline16`、`IconChevronDownOutline14`;
|
|
68
|
+
* 升级后的外壳把名字里的尺寸换成笔画粗细:`IconCheckOutlineRegular`、
|
|
69
|
+
* `IconCheckOutlineMedium`,尺寸改由 `size` 属性给。按「尺寸后缀 → 粗细后缀
|
|
70
|
+
* → 裸名」的顺序找,两套外壳都取得回图标,不会平白降级成文字。
|
|
71
|
+
*/
|
|
72
|
+
function findIcon(base, size) {
|
|
73
|
+
const candidates = [base + size, base + "14", base + "16", base + "Regular", base + "Medium", base];
|
|
74
|
+
for (const candidate of candidates) {
|
|
75
|
+
const component = primitives[candidate];
|
|
76
|
+
if (typeof component === "function") return component;
|
|
77
|
+
}
|
|
78
|
+
return null;
|
|
79
|
+
}
|
|
80
|
+
|
|
64
81
|
/** 取一个内置图标;这版外壳没有就返回 null,由调用方决定怎么退。 */
|
|
65
|
-
function icon(
|
|
66
|
-
const component =
|
|
67
|
-
if (
|
|
82
|
+
function icon(base, size) {
|
|
83
|
+
const component = findIcon(base, size);
|
|
84
|
+
if (component === null) return null;
|
|
68
85
|
return h(component, { size });
|
|
69
86
|
}
|
|
70
87
|
|
|
@@ -75,16 +92,21 @@ window.__ModuleLoader__.load({
|
|
|
75
92
|
return h(Tooltip, { label, side: "bottom", delayMs: 500 }, node);
|
|
76
93
|
}
|
|
77
94
|
|
|
78
|
-
/**
|
|
79
|
-
|
|
80
|
-
|
|
95
|
+
/**
|
|
96
|
+
* 图标按钮:有图标用图标,没图标退回短文字,保证永远点得到。
|
|
97
|
+
*
|
|
98
|
+
* 退回文字时换成 `dsh-ttf-iconBtnText`:按钮按文字宽度自己撑开、文字长了
|
|
99
|
+
* 用省略号收住,所以并排的几个按钮不会挤成一团互相压。
|
|
100
|
+
*/
|
|
101
|
+
function IconButton({ iconBase, label, size, disabled, onClick }) {
|
|
102
|
+
const glyph = icon(iconBase, typeof size === "number" ? size : 16);
|
|
81
103
|
return withTooltip(
|
|
82
104
|
label,
|
|
83
105
|
h(
|
|
84
106
|
"button",
|
|
85
107
|
{
|
|
86
108
|
type: "button",
|
|
87
|
-
className: "dsh-ttf-iconBtn",
|
|
109
|
+
className: glyph === null ? "dsh-ttf-iconBtn dsh-ttf-iconBtnText" : "dsh-ttf-iconBtn",
|
|
88
110
|
disabled: disabled === true,
|
|
89
111
|
"aria-label": label,
|
|
90
112
|
onClick,
|
|
@@ -307,16 +329,21 @@ window.__ModuleLoader__.load({
|
|
|
307
329
|
'.dsh-ttf-panel:after{border:.5px solid var(--dsw-alias-border-l1);border-radius:inherit;content:"";pointer-events:none;position:absolute;inset:0}',
|
|
308
330
|
".dsh-ttf-bar{box-sizing:border-box;width:100%;height:36px;display:flex;align-items:center;gap:10px;padding:4px 5px 4px 12px}",
|
|
309
331
|
".dsh-ttf-glyph{color:var(--dsw-alias-label-tertiary);flex:none;display:inline-flex;align-items:center}",
|
|
332
|
+
".dsh-ttf-glyphFallback{font-size:13px;line-height:16px}",
|
|
310
333
|
".dsh-ttf-label{color:var(--dsw-alias-label-primary);flex:none;font-size:13px;font-weight:500;line-height:24px;white-space:nowrap}",
|
|
311
334
|
".dsh-ttf-labelHeld{color:var(--dsw-alias-state-warning-primary,#a06800)}",
|
|
312
335
|
".dsh-ttf-title{min-width:0;flex:1;color:var(--dsw-alias-label-primary-dimmed);font-size:13px;line-height:20px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}",
|
|
313
336
|
".dsh-ttf-progress{flex:none;max-width:45%;min-width:0;color:var(--dsw-alias-label-tertiary);font-size:12px;line-height:20px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}",
|
|
314
337
|
".dsh-ttf-actions{flex:none;display:flex;align-items:center;gap:2px}",
|
|
315
|
-
".dsh-ttf-iconBtn{corner-shape:round;width:28px;height:28px;border:none;background:0 0;border-radius:999px;color:var(--dsw-alias-label-tertiary);cursor:pointer;display:inline-flex;align-items:center;justify-content:center;padding:0;font:inherit}",
|
|
338
|
+
".dsh-ttf-iconBtn{corner-shape:round;width:28px;height:28px;border:none;background:0 0;border-radius:999px;color:var(--dsw-alias-label-tertiary);cursor:pointer;display:inline-flex;align-items:center;justify-content:center;padding:0;font:inherit;flex:none}",
|
|
316
339
|
".dsh-ttf-iconBtn:hover{background:var(--dsw-alias-interactive-bg-hover);color:var(--dsw-alias-label-secondary)}",
|
|
317
340
|
".dsh-ttf-iconBtn:disabled{opacity:.4;cursor:default}",
|
|
318
341
|
".dsh-ttf-iconBtn:disabled:hover{background:0 0;color:var(--dsw-alias-label-tertiary)}",
|
|
319
|
-
|
|
342
|
+
// 取不到内置图标时退回文字:固定 28px 宽装不下几个字,文字会溢出到相邻
|
|
343
|
+
// 按钮上,看着就是几个按钮叠在一起。这里按文字宽度撑开、留出边距,
|
|
344
|
+
// 并给一个上限,长了用省略号收住——几个按钮始终各占各的位置。
|
|
345
|
+
".dsh-ttf-iconBtnText{width:auto;min-width:28px;max-width:112px;height:24px;padding:0 8px}",
|
|
346
|
+
".dsh-ttf-iconText{min-width:0;max-width:100%;overflow:hidden;text-overflow:ellipsis;font-size:12px;line-height:16px;white-space:nowrap}",
|
|
320
347
|
// 展开体:限高滚动——这是输入框旁边的位置,不能让它把会话挤没了。
|
|
321
348
|
".dsh-ttf-body{max-height:264px;overflow-y:auto;padding:2px 8px 8px}",
|
|
322
349
|
".dsh-ttf-note{margin:4px 4px 6px;padding:6px 8px;border-radius:8px;font-size:12px;line-height:18px;color:var(--dsw-alias-label-secondary);background:var(--dsw-alias-bg-module-platform)}",
|
|
@@ -388,11 +415,11 @@ window.__ModuleLoader__.load({
|
|
|
388
415
|
*/
|
|
389
416
|
function StatusMark({ node, isCurrent }) {
|
|
390
417
|
if (node.status === "done") {
|
|
391
|
-
const check = icon("
|
|
418
|
+
const check = icon("IconCheckOutline", 14);
|
|
392
419
|
return h("span", { className: "dsh-ttf-markDone" }, check === null ? "✓" : check);
|
|
393
420
|
}
|
|
394
421
|
if (node.status === "dropped") {
|
|
395
|
-
const close = icon("
|
|
422
|
+
const close = icon("IconCloseOutline", 14);
|
|
396
423
|
return h("span", { className: "dsh-ttf-markMuted" }, close === null ? "×" : close);
|
|
397
424
|
}
|
|
398
425
|
const circle = { cx: 7, cy: 7, r: 5.2, stroke: "currentColor", strokeWidth: 1.2 };
|
|
@@ -536,7 +563,7 @@ window.__ModuleLoader__.load({
|
|
|
536
563
|
{ className: "dsh-ttf-rowActions" },
|
|
537
564
|
canAct
|
|
538
565
|
? h(IconButton, {
|
|
539
|
-
|
|
566
|
+
iconBase: "IconCheckOutline",
|
|
540
567
|
label: t("action.done"),
|
|
541
568
|
disabled: busy,
|
|
542
569
|
onClick: () => {
|
|
@@ -547,7 +574,7 @@ window.__ModuleLoader__.load({
|
|
|
547
574
|
: null,
|
|
548
575
|
canAct && canDrop
|
|
549
576
|
? h(IconButton, {
|
|
550
|
-
|
|
577
|
+
iconBase: "IconTrashOutline",
|
|
551
578
|
label: t("action.drop"),
|
|
552
579
|
disabled: busy,
|
|
553
580
|
onClick: () => {
|
|
@@ -559,7 +586,7 @@ window.__ModuleLoader__.load({
|
|
|
559
586
|
: null,
|
|
560
587
|
expandable
|
|
561
588
|
? h(IconButton, {
|
|
562
|
-
|
|
589
|
+
iconBase: open ? "IconChevronDownOutline" : "IconChevronRightOutline",
|
|
563
590
|
label: open ? t("action.collapse") : t("action.expand"),
|
|
564
591
|
onClick: () => setOpen(!open),
|
|
565
592
|
})
|
|
@@ -718,6 +745,10 @@ window.__ModuleLoader__.load({
|
|
|
718
745
|
: data.active === null
|
|
719
746
|
? t("state.done")
|
|
720
747
|
: t("state.running");
|
|
748
|
+
// 条首的清单图标;外壳连这个图标都没有时退回一个同类字符,别留空白。
|
|
749
|
+
const listIcon = icon("IconChecklistOutline", 14);
|
|
750
|
+
const listGlyph =
|
|
751
|
+
listIcon === null ? h("span", { className: "dsh-ttf-glyphFallback" }, "☰") : listIcon;
|
|
721
752
|
|
|
722
753
|
return h(
|
|
723
754
|
"div",
|
|
@@ -728,7 +759,7 @@ window.__ModuleLoader__.load({
|
|
|
728
759
|
h(
|
|
729
760
|
"div",
|
|
730
761
|
{ className: "dsh-ttf-bar" },
|
|
731
|
-
h("span", { className: "dsh-ttf-glyph", "aria-hidden": true },
|
|
762
|
+
h("span", { className: "dsh-ttf-glyph", "aria-hidden": true }, listGlyph),
|
|
732
763
|
h("span", { className: "dsh-ttf-label" + (held ? " dsh-ttf-labelHeld" : "") }, stateLabel),
|
|
733
764
|
h("span", { className: "dsh-ttf-title", title: heading }, heading),
|
|
734
765
|
h(
|
|
@@ -740,13 +771,13 @@ window.__ModuleLoader__.load({
|
|
|
740
771
|
"div",
|
|
741
772
|
{ className: "dsh-ttf-actions" },
|
|
742
773
|
h(IconButton, {
|
|
743
|
-
|
|
774
|
+
iconBase: held ? "IconPlayOutline" : "IconPauseOutline",
|
|
744
775
|
label: held ? t("action.resume") : t("action.pause"),
|
|
745
776
|
disabled: busy,
|
|
746
777
|
onClick: () => act({ action: held ? "resume" : "pause" }),
|
|
747
778
|
}),
|
|
748
779
|
h(IconButton, {
|
|
749
|
-
|
|
780
|
+
iconBase: "IconTrashOutline",
|
|
750
781
|
label: t("action.reset"),
|
|
751
782
|
disabled: busy,
|
|
752
783
|
onClick: () => {
|
|
@@ -754,7 +785,7 @@ window.__ModuleLoader__.load({
|
|
|
754
785
|
},
|
|
755
786
|
}),
|
|
756
787
|
h(IconButton, {
|
|
757
|
-
|
|
788
|
+
iconBase: open ? "IconChevronDownOutline" : "IconChevronUpOutline",
|
|
758
789
|
label: open ? t("action.collapse") : t("action.expand"),
|
|
759
790
|
onClick: () => setOpen(!open),
|
|
760
791
|
}),
|