dsh-workbench-storage 1.5.5 → 1.5.8
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/lib/client.js +683 -296
- package/lib/index.js +1 -1
- package/package.json +4 -4
package/lib/client.js
CHANGED
|
@@ -705,6 +705,10 @@ var require_filter_checklist_styles = __commonJS({
|
|
|
705
705
|
".wbck-opt:hover{background:color-mix(in srgb, currentColor 7%, transparent)}",
|
|
706
706
|
".wbck-opt.is-on{background:color-mix(in srgb, var(--wb-accent) 10%, transparent)}",
|
|
707
707
|
".wbck-opt input{margin:0;flex:none;accent-color:var(--wb-accent)}",
|
|
708
|
+
// 单选变体用 button 渲染(role="radio"),这里把浏览器默认按钮样式清掉,视觉与多选行一致。
|
|
709
|
+
'.wbck-opt[role="radio"]{appearance:none;width:100%;box-sizing:border-box;border:0;background:transparent;color:inherit;font:inherit;text-align:left}',
|
|
710
|
+
'.wbck-opt[role="radio"]:disabled{opacity:.55;cursor:not-allowed}',
|
|
711
|
+
'.wbck-opt[role="radio"]:focus-visible{outline:2px solid var(--wb-accent);outline-offset:-2px}',
|
|
708
712
|
".wbck-nm{min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}",
|
|
709
713
|
".wbck-meta{margin-left:auto;flex:none;font-size:11.5px;color:var(--wb-muted)}",
|
|
710
714
|
".wbck-note{font-size:12px;color:var(--wb-muted);padding:8px 6px}",
|
|
@@ -750,6 +754,42 @@ var require_styles = __commonJS({
|
|
|
750
754
|
}
|
|
751
755
|
});
|
|
752
756
|
|
|
757
|
+
// packages/addons/lib/icons.cjs
|
|
758
|
+
var require_icons = __commonJS({
|
|
759
|
+
"packages/addons/lib/icons.cjs"(exports2, module2) {
|
|
760
|
+
"use strict";
|
|
761
|
+
var h2 = require("react").createElement;
|
|
762
|
+
function create(prefix, glyphs, options) {
|
|
763
|
+
var opts = options || {};
|
|
764
|
+
var ICONS = Object.assign({}, glyphs);
|
|
765
|
+
function Icon3(props) {
|
|
766
|
+
var C = ICONS[props.name] || (opts.fallback ? ICONS[opts.fallback] : null);
|
|
767
|
+
if (!C) return null;
|
|
768
|
+
var size = typeof opts.sizeOf === "function" ? opts.sizeOf(props) : props.size || 14;
|
|
769
|
+
var cls = prefix + "-svg" + (opts.classNameAppend && props.className ? " " + props.className : "");
|
|
770
|
+
var attrs = {
|
|
771
|
+
size,
|
|
772
|
+
strokeWidth: props.strokeWidth || 2,
|
|
773
|
+
"aria-hidden": "true",
|
|
774
|
+
className: cls
|
|
775
|
+
};
|
|
776
|
+
if (opts.focusable) attrs.focusable = false;
|
|
777
|
+
return h2(C, attrs);
|
|
778
|
+
}
|
|
779
|
+
var set = { ICONS, Icon: Icon3 };
|
|
780
|
+
if (opts.tabIcon) {
|
|
781
|
+
set.tabIcon = function(name) {
|
|
782
|
+
return function TabIcon() {
|
|
783
|
+
return h2(Icon3, { name, size: 14 });
|
|
784
|
+
};
|
|
785
|
+
};
|
|
786
|
+
}
|
|
787
|
+
return set;
|
|
788
|
+
}
|
|
789
|
+
module2.exports = { create };
|
|
790
|
+
}
|
|
791
|
+
});
|
|
792
|
+
|
|
753
793
|
// node_modules/.pnpm/lucide-react@1.70.0_react@19.2.0/node_modules/lucide-react/dist/esm/icons/box.mjs
|
|
754
794
|
var box_exports = {};
|
|
755
795
|
__export(box_exports, {
|
|
@@ -1415,10 +1455,15 @@ var init_rotate_ccw = __esm({
|
|
|
1415
1455
|
});
|
|
1416
1456
|
|
|
1417
1457
|
// packages/addons/storage/client/ui/icons.cjs
|
|
1418
|
-
var
|
|
1458
|
+
var require_icons2 = __commonJS({
|
|
1419
1459
|
"packages/addons/storage/client/ui/icons.cjs"(exports2, module2) {
|
|
1420
|
-
|
|
1421
|
-
var
|
|
1460
|
+
"use strict";
|
|
1461
|
+
var icons2 = require_icons();
|
|
1462
|
+
function sizeOf(props) {
|
|
1463
|
+
if (props.name === "empty" && props.size === 48) return 48;
|
|
1464
|
+
return [11, 14, 16].indexOf(props.size) >= 0 ? props.size : 14;
|
|
1465
|
+
}
|
|
1466
|
+
var set = icons2.create("wbi", {
|
|
1422
1467
|
box: (init_box(), __toCommonJS(box_exports)).default,
|
|
1423
1468
|
plus: (init_plus(), __toCommonJS(plus_exports)).default,
|
|
1424
1469
|
search: (init_search(), __toCommonJS(search_exports)).default,
|
|
@@ -1444,18 +1489,172 @@ var require_icons = __commonJS({
|
|
|
1444
1489
|
close: (init_x(), __toCommonJS(x_exports)).default,
|
|
1445
1490
|
table: (init_table(), __toCommonJS(table_exports)).default,
|
|
1446
1491
|
reset: (init_rotate_ccw(), __toCommonJS(rotate_ccw_exports)).default
|
|
1492
|
+
}, { fallback: "box", focusable: true, sizeOf });
|
|
1493
|
+
module2.exports = { ICONS: set.ICONS, Icon: set.Icon };
|
|
1494
|
+
}
|
|
1495
|
+
});
|
|
1496
|
+
|
|
1497
|
+
// packages/addons/lib/button.cjs
|
|
1498
|
+
var require_button = __commonJS({
|
|
1499
|
+
"packages/addons/lib/button.cjs"(exports2, module2) {
|
|
1500
|
+
"use strict";
|
|
1501
|
+
var React = require("react");
|
|
1502
|
+
var h2 = React.createElement;
|
|
1503
|
+
module2.exports = function createButton(options) {
|
|
1504
|
+
var opts = options || {};
|
|
1505
|
+
var prefix = opts.prefix;
|
|
1506
|
+
var Icon3 = opts.Icon;
|
|
1507
|
+
function Button(props) {
|
|
1508
|
+
var attrs = Object.assign({ type: "button", className: prefix + "-btn" }, props);
|
|
1509
|
+
delete attrs.icon;
|
|
1510
|
+
delete attrs.iconOnly;
|
|
1511
|
+
if (props.icon) {
|
|
1512
|
+
attrs["aria-label"] = props["aria-label"] || props.children;
|
|
1513
|
+
attrs.title = props.title || attrs["aria-label"];
|
|
1514
|
+
attrs.className += props.iconOnly ? " " + prefix + "-icon-only" : " " + prefix + "-icon-text";
|
|
1515
|
+
}
|
|
1516
|
+
return h2(
|
|
1517
|
+
"button",
|
|
1518
|
+
attrs,
|
|
1519
|
+
props.icon ? h2(Icon3, { name: props.icon }) : null,
|
|
1520
|
+
props.iconOnly ? null : props.icon ? h2("span", { className: prefix + "-btn-label" }, props.children) : props.children
|
|
1521
|
+
);
|
|
1522
|
+
}
|
|
1523
|
+
return Button;
|
|
1524
|
+
};
|
|
1525
|
+
}
|
|
1526
|
+
});
|
|
1527
|
+
|
|
1528
|
+
// packages/addons/lib/skeleton.cjs
|
|
1529
|
+
var require_skeleton = __commonJS({
|
|
1530
|
+
"packages/addons/lib/skeleton.cjs"(exports2, module2) {
|
|
1531
|
+
"use strict";
|
|
1532
|
+
var React = require("react");
|
|
1533
|
+
var h2 = React.createElement;
|
|
1534
|
+
module2.exports = function createSkeleton(options) {
|
|
1535
|
+
var opts = options || {};
|
|
1536
|
+
var prefix = opts.prefix;
|
|
1537
|
+
var text = opts.text || function(lang) {
|
|
1538
|
+
return lang === "en" ? "Loading\u2026" : "\u8BFB\u53D6\u4E2D\u2026";
|
|
1539
|
+
};
|
|
1540
|
+
return function Skeleton(props) {
|
|
1541
|
+
var label = props.label || text(props.lang);
|
|
1542
|
+
return h2(
|
|
1543
|
+
"div",
|
|
1544
|
+
{ className: prefix + "-root " + prefix + "-grid " + prefix + "-skeleton", role: "status", "aria-label": label, "aria-busy": true },
|
|
1545
|
+
h2("span", { className: prefix + "-sr" }, label),
|
|
1546
|
+
[0, 1, 2].map(function(i) {
|
|
1547
|
+
return h2(
|
|
1548
|
+
"div",
|
|
1549
|
+
{ key: i, className: prefix + "-card " + prefix + "-skeleton-card", "aria-hidden": true },
|
|
1550
|
+
h2("div", { className: prefix + "-sk" }),
|
|
1551
|
+
h2("div", { className: prefix + "-sk" }),
|
|
1552
|
+
h2("div", { className: prefix + "-sk" })
|
|
1553
|
+
);
|
|
1554
|
+
})
|
|
1555
|
+
);
|
|
1556
|
+
};
|
|
1557
|
+
};
|
|
1558
|
+
}
|
|
1559
|
+
});
|
|
1560
|
+
|
|
1561
|
+
// packages/addons/lib/overlay.cjs
|
|
1562
|
+
var require_overlay = __commonJS({
|
|
1563
|
+
"packages/addons/lib/overlay.cjs"(exports2, module2) {
|
|
1564
|
+
"use strict";
|
|
1565
|
+
var defaultReact = require("react");
|
|
1566
|
+
var FOCUSABLE = "button:not(:disabled),input:not(:disabled),textarea:not(:disabled),select:not(:disabled),a[href]";
|
|
1567
|
+
module2.exports = function createOverlay(options) {
|
|
1568
|
+
var opts = options || {};
|
|
1569
|
+
var React = opts.React || defaultReact;
|
|
1570
|
+
var h2 = React.createElement;
|
|
1571
|
+
var tag = opts.tag || "section";
|
|
1572
|
+
var maskClass = opts.maskClass;
|
|
1573
|
+
var dialogClass = opts.dialogClass;
|
|
1574
|
+
var dialogClassOf = opts.dialogClassOf || function() {
|
|
1575
|
+
return "";
|
|
1576
|
+
};
|
|
1577
|
+
var ariaLabelOf = opts.ariaLabelOf || function(props) {
|
|
1578
|
+
return props["aria-label"] || props.title;
|
|
1579
|
+
};
|
|
1580
|
+
var ariaLabelledByOf = opts.ariaLabelledByOf || function() {
|
|
1581
|
+
return null;
|
|
1582
|
+
};
|
|
1583
|
+
var header = opts.header || null;
|
|
1584
|
+
var closeOnEscape = opts.closeOnEscape || function() {
|
|
1585
|
+
return true;
|
|
1586
|
+
};
|
|
1587
|
+
var closeOnMask = opts.closeOnMask || function() {
|
|
1588
|
+
return true;
|
|
1589
|
+
};
|
|
1590
|
+
var extraKeyDown = opts.onKeyDown || null;
|
|
1591
|
+
var autoFocusDialog = opts.autoFocusDialog !== false;
|
|
1592
|
+
var focusableSelector = opts.focusableSelector || FOCUSABLE;
|
|
1593
|
+
function Modal(props) {
|
|
1594
|
+
var ref = React.useRef(null);
|
|
1595
|
+
React.useEffect(function() {
|
|
1596
|
+
var previous = typeof document !== "undefined" ? document.activeElement : null;
|
|
1597
|
+
var focusIt = props.autoFocus !== void 0 ? props.autoFocus : autoFocusDialog;
|
|
1598
|
+
if (focusIt && ref.current) ref.current.focus();
|
|
1599
|
+
return function() {
|
|
1600
|
+
if (previous && previous.isConnected) previous.focus();
|
|
1601
|
+
};
|
|
1602
|
+
}, []);
|
|
1603
|
+
function onKeyDown(e) {
|
|
1604
|
+
if (extraKeyDown && extraKeyDown(e, props, ref)) return;
|
|
1605
|
+
if (e.key === "Escape") {
|
|
1606
|
+
if (!(props.closeOnEscape !== void 0 ? props.closeOnEscape : closeOnEscape(props))) return;
|
|
1607
|
+
e.preventDefault();
|
|
1608
|
+
e.stopPropagation();
|
|
1609
|
+
if (props.onClose) props.onClose();
|
|
1610
|
+
return;
|
|
1611
|
+
}
|
|
1612
|
+
if (e.key !== "Tab" || !ref.current) return;
|
|
1613
|
+
var els = ref.current.querySelectorAll(focusableSelector);
|
|
1614
|
+
if (!els.length) {
|
|
1615
|
+
e.preventDefault();
|
|
1616
|
+
return;
|
|
1617
|
+
}
|
|
1618
|
+
var first = els[0];
|
|
1619
|
+
var last = els[els.length - 1];
|
|
1620
|
+
if (e.shiftKey && (document.activeElement === first || document.activeElement === ref.current)) {
|
|
1621
|
+
e.preventDefault();
|
|
1622
|
+
last.focus();
|
|
1623
|
+
}
|
|
1624
|
+
if (!e.shiftKey && document.activeElement === last) {
|
|
1625
|
+
e.preventDefault();
|
|
1626
|
+
first.focus();
|
|
1627
|
+
}
|
|
1628
|
+
}
|
|
1629
|
+
var labelledBy = ariaLabelledByOf(props);
|
|
1630
|
+
return h2(
|
|
1631
|
+
"div",
|
|
1632
|
+
{
|
|
1633
|
+
className: maskClass,
|
|
1634
|
+
onMouseDown: function(e) {
|
|
1635
|
+
var allowed = props.closeOnMask !== void 0 ? props.closeOnMask : closeOnMask(props);
|
|
1636
|
+
if (e.target === e.currentTarget && props.onClose && allowed) props.onClose();
|
|
1637
|
+
}
|
|
1638
|
+
},
|
|
1639
|
+
h2(
|
|
1640
|
+
tag,
|
|
1641
|
+
{
|
|
1642
|
+
className: dialogClass + dialogClassOf(props),
|
|
1643
|
+
role: "dialog",
|
|
1644
|
+
"aria-modal": true,
|
|
1645
|
+
"aria-label": labelledBy ? null : ariaLabelOf(props),
|
|
1646
|
+
"aria-labelledby": labelledBy || null,
|
|
1647
|
+
ref,
|
|
1648
|
+
tabIndex: -1,
|
|
1649
|
+
onKeyDown
|
|
1650
|
+
},
|
|
1651
|
+
header ? header(props) : null,
|
|
1652
|
+
props.children
|
|
1653
|
+
)
|
|
1654
|
+
);
|
|
1655
|
+
}
|
|
1656
|
+
return Modal;
|
|
1447
1657
|
};
|
|
1448
|
-
function Icon3(props) {
|
|
1449
|
-
var size = props.name === "empty" && props.size === 48 ? 48 : [11, 14, 16].includes(props.size) ? props.size : 14;
|
|
1450
|
-
return React.createElement(ICONS[props.name] || ICONS.box, {
|
|
1451
|
-
size,
|
|
1452
|
-
strokeWidth: 2,
|
|
1453
|
-
"aria-hidden": true,
|
|
1454
|
-
focusable: false,
|
|
1455
|
-
className: "wbi-svg"
|
|
1456
|
-
});
|
|
1457
|
-
}
|
|
1458
|
-
module2.exports = { ICONS, Icon: Icon3 };
|
|
1459
1658
|
}
|
|
1460
1659
|
});
|
|
1461
1660
|
|
|
@@ -1464,7 +1663,7 @@ var require_ui = __commonJS({
|
|
|
1464
1663
|
"packages/addons/storage/client/ui/ui.cjs"(exports2, module2) {
|
|
1465
1664
|
var React = require("react");
|
|
1466
1665
|
var h2 = React.createElement;
|
|
1467
|
-
var Icon3 =
|
|
1666
|
+
var Icon3 = require_icons2().Icon;
|
|
1468
1667
|
function call(api, name, args) {
|
|
1469
1668
|
return api.call(name, args || {}).then(function(r) {
|
|
1470
1669
|
if (!r || r.ok !== true) throw new Error(r && r.error || "\u8BF7\u6C42\u5931\u8D25");
|
|
@@ -1474,39 +1673,16 @@ var require_ui = __commonJS({
|
|
|
1474
1673
|
function tr(lang, zh, en) {
|
|
1475
1674
|
return lang === "en" ? en : zh;
|
|
1476
1675
|
}
|
|
1477
|
-
|
|
1478
|
-
|
|
1479
|
-
|
|
1480
|
-
|
|
1481
|
-
|
|
1482
|
-
|
|
1483
|
-
|
|
1484
|
-
|
|
1676
|
+
var createButton = require_button();
|
|
1677
|
+
var createSkeleton = require_skeleton();
|
|
1678
|
+
var createOverlay = require_overlay();
|
|
1679
|
+
var Button = createButton({ prefix: "wbi", Icon: Icon3 });
|
|
1680
|
+
var Skeleton = createSkeleton({
|
|
1681
|
+
prefix: "wbi",
|
|
1682
|
+
text: function(lang) {
|
|
1683
|
+
return tr(lang, "\u8BFB\u53D6\u4E2D\u2026", "Loading\u2026");
|
|
1485
1684
|
}
|
|
1486
|
-
|
|
1487
|
-
"button",
|
|
1488
|
-
attrs,
|
|
1489
|
-
props.icon ? h2(Icon3, { name: props.icon }) : null,
|
|
1490
|
-
props.iconOnly ? null : props.icon ? h2("span", { className: "wbi-btn-label" }, props.children) : props.children
|
|
1491
|
-
);
|
|
1492
|
-
}
|
|
1493
|
-
function Skeleton(props) {
|
|
1494
|
-
var label = props.label || tr(props.lang, "\u8BFB\u53D6\u4E2D\u2026", "Loading\u2026");
|
|
1495
|
-
return h2(
|
|
1496
|
-
"div",
|
|
1497
|
-
{ className: "wbi-root wbi-grid wbi-skeleton", role: "status", "aria-label": label, "aria-busy": true },
|
|
1498
|
-
h2("span", { className: "wbi-sr" }, label),
|
|
1499
|
-
[0, 1, 2].map(function(i) {
|
|
1500
|
-
return h2(
|
|
1501
|
-
"div",
|
|
1502
|
-
{ key: i, className: "wbi-card wbi-skeleton-card", "aria-hidden": true },
|
|
1503
|
-
h2("div", { className: "wbi-sk" }),
|
|
1504
|
-
h2("div", { className: "wbi-sk" }),
|
|
1505
|
-
h2("div", { className: "wbi-sk" })
|
|
1506
|
-
);
|
|
1507
|
-
})
|
|
1508
|
-
);
|
|
1509
|
-
}
|
|
1685
|
+
});
|
|
1510
1686
|
function ErrorBox(props) {
|
|
1511
1687
|
return props.error ? h2("div", { className: "wbi-error", role: "alert" }, String(props.error.message || props.error)) : null;
|
|
1512
1688
|
}
|
|
@@ -1518,70 +1694,23 @@ var require_ui = __commonJS({
|
|
|
1518
1694
|
return "";
|
|
1519
1695
|
}
|
|
1520
1696
|
}
|
|
1521
|
-
|
|
1522
|
-
|
|
1523
|
-
|
|
1524
|
-
|
|
1525
|
-
|
|
1526
|
-
return
|
|
1527
|
-
|
|
1528
|
-
|
|
1529
|
-
|
|
1530
|
-
|
|
1531
|
-
|
|
1532
|
-
|
|
1533
|
-
|
|
1534
|
-
|
|
1535
|
-
return;
|
|
1536
|
-
}
|
|
1537
|
-
if (e.key !== "Tab") return;
|
|
1538
|
-
var els = ref.current.querySelectorAll(
|
|
1539
|
-
"button:not(:disabled),input:not(:disabled),textarea:not(:disabled),select:not(:disabled),a[href]"
|
|
1697
|
+
var Modal = createOverlay({
|
|
1698
|
+
tag: "section",
|
|
1699
|
+
maskClass: "wbi-mask",
|
|
1700
|
+
dialogClass: "wbi-modal",
|
|
1701
|
+
ariaLabelOf: function(props) {
|
|
1702
|
+
return props.title;
|
|
1703
|
+
},
|
|
1704
|
+
header: function(props) {
|
|
1705
|
+
return h2(
|
|
1706
|
+
"header",
|
|
1707
|
+
{ className: "wbi-row" },
|
|
1708
|
+
h2("h2", null, props.title),
|
|
1709
|
+
h2("span", { className: "wbi-grow" }),
|
|
1710
|
+
h2(Button, { icon: "close", iconOnly: true, onClick: props.onClose, disabled: !props.onClose, "aria-label": "\u5173\u95ED / Close" }, "\xD7")
|
|
1540
1711
|
);
|
|
1541
|
-
if (!els.length) {
|
|
1542
|
-
e.preventDefault();
|
|
1543
|
-
return;
|
|
1544
|
-
}
|
|
1545
|
-
var first = els[0], last = els[els.length - 1];
|
|
1546
|
-
if (e.shiftKey && (document.activeElement === first || document.activeElement === ref.current)) {
|
|
1547
|
-
e.preventDefault();
|
|
1548
|
-
last.focus();
|
|
1549
|
-
}
|
|
1550
|
-
if (!e.shiftKey && document.activeElement === last) {
|
|
1551
|
-
e.preventDefault();
|
|
1552
|
-
first.focus();
|
|
1553
|
-
}
|
|
1554
1712
|
}
|
|
1555
|
-
|
|
1556
|
-
"div",
|
|
1557
|
-
{
|
|
1558
|
-
className: "wbi-mask",
|
|
1559
|
-
onMouseDown: function(e) {
|
|
1560
|
-
if (e.target === e.currentTarget && props.onClose) props.onClose();
|
|
1561
|
-
}
|
|
1562
|
-
},
|
|
1563
|
-
h2(
|
|
1564
|
-
"section",
|
|
1565
|
-
{
|
|
1566
|
-
className: "wbi-modal",
|
|
1567
|
-
role: "dialog",
|
|
1568
|
-
"aria-modal": true,
|
|
1569
|
-
"aria-label": props.title,
|
|
1570
|
-
ref,
|
|
1571
|
-
tabIndex: -1,
|
|
1572
|
-
onKeyDown: key
|
|
1573
|
-
},
|
|
1574
|
-
h2(
|
|
1575
|
-
"header",
|
|
1576
|
-
{ className: "wbi-row" },
|
|
1577
|
-
h2("h2", null, props.title),
|
|
1578
|
-
h2("span", { className: "wbi-grow" }),
|
|
1579
|
-
h2(Button, { icon: "close", iconOnly: true, onClick: props.onClose, disabled: !props.onClose, "aria-label": "\u5173\u95ED / Close" }, "\xD7")
|
|
1580
|
-
),
|
|
1581
|
-
props.children
|
|
1582
|
-
)
|
|
1583
|
-
);
|
|
1584
|
-
}
|
|
1713
|
+
});
|
|
1585
1714
|
module2.exports = { Icon: Icon3, Skeleton, h: h2, call, tr, Button, ErrorBox, Modal, safeImage };
|
|
1586
1715
|
}
|
|
1587
1716
|
});
|
|
@@ -2193,6 +2322,8 @@ var require_filter_checklist = __commonJS({
|
|
|
2193
2322
|
var onLoadMore = props.onLoadMore;
|
|
2194
2323
|
var onClear = props.onClear || function() {
|
|
2195
2324
|
};
|
|
2325
|
+
var single = props.mode === "single";
|
|
2326
|
+
var onPick = typeof props.onPick === "function" ? props.onPick : onToggle;
|
|
2196
2327
|
function toggle(id) {
|
|
2197
2328
|
if (disabled) return;
|
|
2198
2329
|
onToggle(id);
|
|
@@ -2205,8 +2336,8 @@ var require_filter_checklist = __commonJS({
|
|
|
2205
2336
|
"div",
|
|
2206
2337
|
{ className: "wbck-head" },
|
|
2207
2338
|
h2("span", { className: "wbck-grow" }, title + (total ? " \xB7 " + total : "")),
|
|
2208
|
-
selected.length ? h2("span", { className: "wbck-sel" }, selectedText + " " + selected.length) : null,
|
|
2209
|
-
selected.length || query ? h2("button", {
|
|
2339
|
+
!single && selected.length ? h2("span", { className: "wbck-sel" }, selectedText + " " + selected.length) : null,
|
|
2340
|
+
!single && (selected.length || query) ? h2("button", {
|
|
2210
2341
|
type: "button",
|
|
2211
2342
|
className: "wbck-clear",
|
|
2212
2343
|
title: clearText,
|
|
@@ -2223,6 +2354,25 @@ var require_filter_checklist = __commonJS({
|
|
|
2223
2354
|
} else {
|
|
2224
2355
|
body = items.map(function(x) {
|
|
2225
2356
|
var on = selected.indexOf(String(x.id)) >= 0;
|
|
2357
|
+
if (single) {
|
|
2358
|
+
return h2(
|
|
2359
|
+
"button",
|
|
2360
|
+
{
|
|
2361
|
+
key: x.id,
|
|
2362
|
+
type: "button",
|
|
2363
|
+
role: "radio",
|
|
2364
|
+
"aria-checked": on ? "true" : "false",
|
|
2365
|
+
className: "wbck-opt" + (on ? " is-on" : ""),
|
|
2366
|
+
disabled,
|
|
2367
|
+
onClick: function() {
|
|
2368
|
+
if (disabled) return;
|
|
2369
|
+
onPick(x.id);
|
|
2370
|
+
}
|
|
2371
|
+
},
|
|
2372
|
+
h2("span", { className: "wbck-nm", title: x.name }, x.name),
|
|
2373
|
+
x.meta ? h2("span", { className: "wbck-meta" }, x.meta) : null
|
|
2374
|
+
);
|
|
2375
|
+
}
|
|
2226
2376
|
return h2(
|
|
2227
2377
|
"label",
|
|
2228
2378
|
{ key: x.id, className: "wbck-opt" + (on ? " is-on" : "") },
|
|
@@ -2265,6 +2415,8 @@ var require_filter_checklist = __commonJS({
|
|
|
2265
2415
|
h2("div", {
|
|
2266
2416
|
className: "wbck-list",
|
|
2267
2417
|
onScroll: scroll,
|
|
2418
|
+
role: single ? "radiogroup" : void 0,
|
|
2419
|
+
"aria-label": single ? props.groupLabel || searchPlaceholder : void 0,
|
|
2268
2420
|
"aria-busy": loading ? "true" : "false"
|
|
2269
2421
|
}, body)
|
|
2270
2422
|
);
|
|
@@ -2274,193 +2426,323 @@ var require_filter_checklist = __commonJS({
|
|
|
2274
2426
|
}
|
|
2275
2427
|
});
|
|
2276
2428
|
|
|
2277
|
-
// packages/addons/
|
|
2278
|
-
var
|
|
2279
|
-
"packages/addons/
|
|
2429
|
+
// packages/addons/lib/tag-filter.cjs
|
|
2430
|
+
var require_tag_filter = __commonJS({
|
|
2431
|
+
"packages/addons/lib/tag-filter.cjs"(exports2, module2) {
|
|
2432
|
+
"use strict";
|
|
2280
2433
|
var React = require("react");
|
|
2281
|
-
var ui = require_ui();
|
|
2282
|
-
var FilterChecklist = require_filter_checklist();
|
|
2283
2434
|
var h2 = React.createElement;
|
|
2284
|
-
var
|
|
2285
|
-
module2.exports = function
|
|
2286
|
-
var
|
|
2287
|
-
var
|
|
2288
|
-
var
|
|
2289
|
-
var
|
|
2290
|
-
var
|
|
2291
|
-
var
|
|
2292
|
-
|
|
2293
|
-
|
|
2294
|
-
|
|
2295
|
-
|
|
2296
|
-
|
|
2297
|
-
|
|
2298
|
-
|
|
2299
|
-
|
|
2300
|
-
|
|
2301
|
-
|
|
2302
|
-
|
|
2303
|
-
|
|
2304
|
-
|
|
2305
|
-
|
|
2306
|
-
|
|
2435
|
+
var FilterChecklist = require_filter_checklist();
|
|
2436
|
+
module2.exports = function createTagFilter(options) {
|
|
2437
|
+
var conf = options || {};
|
|
2438
|
+
var classes = conf.classes || {};
|
|
2439
|
+
var pageSize = conf.pageSize || 20;
|
|
2440
|
+
var debounce = conf.debounce === void 0 ? 200 : conf.debounce;
|
|
2441
|
+
var dedupe = conf.dedupe !== false;
|
|
2442
|
+
var mapPage = conf.mapPage || function(out, pageNumber) {
|
|
2443
|
+
return {
|
|
2444
|
+
rows: out.records || [],
|
|
2445
|
+
total: out.total || 0,
|
|
2446
|
+
page: out.current || pageNumber,
|
|
2447
|
+
hasMore: !!out.hasNext
|
|
2448
|
+
};
|
|
2449
|
+
};
|
|
2450
|
+
var items = conf.items || function(rows) {
|
|
2451
|
+
return rows.map(function(x) {
|
|
2452
|
+
return { id: x.id, name: x.name };
|
|
2453
|
+
});
|
|
2454
|
+
};
|
|
2455
|
+
var text = conf.text || function() {
|
|
2456
|
+
return {};
|
|
2457
|
+
};
|
|
2458
|
+
var icon = conf.icon || function() {
|
|
2459
|
+
return null;
|
|
2460
|
+
};
|
|
2461
|
+
var caret = conf.caret === void 0 ? "\u25BE" : conf.caret;
|
|
2462
|
+
var enabled = conf.enabled || function() {
|
|
2463
|
+
return true;
|
|
2464
|
+
};
|
|
2465
|
+
var renderSelected = conf.renderSelected || null;
|
|
2466
|
+
return function TagFilter(props) {
|
|
2467
|
+
var api = props.api;
|
|
2468
|
+
var ids = props.ids || [];
|
|
2469
|
+
var onChange = props.onChange || function() {
|
|
2470
|
+
};
|
|
2471
|
+
var t = text(props);
|
|
2472
|
+
var availS = React.useState(true);
|
|
2473
|
+
var openS = React.useState(false);
|
|
2474
|
+
var open = openS[0];
|
|
2475
|
+
var setOpen = openS[1];
|
|
2476
|
+
var queryS = React.useState("");
|
|
2477
|
+
var query = queryS[0];
|
|
2478
|
+
var setQuery = queryS[1];
|
|
2479
|
+
var rowsS = React.useState([]);
|
|
2480
|
+
var rows = rowsS[0];
|
|
2481
|
+
var setRows = rowsS[1];
|
|
2482
|
+
var totalS = React.useState(0);
|
|
2483
|
+
var total = totalS[0];
|
|
2484
|
+
var setTotal = totalS[1];
|
|
2485
|
+
var pageS = React.useState(0);
|
|
2486
|
+
var page = pageS[0];
|
|
2487
|
+
var setPage = pageS[1];
|
|
2488
|
+
var hasMoreS = React.useState(false);
|
|
2489
|
+
var hasMore = hasMoreS[0];
|
|
2490
|
+
var setHasMore = hasMoreS[1];
|
|
2491
|
+
var loadingS = React.useState(false);
|
|
2492
|
+
var loading = loadingS[0];
|
|
2493
|
+
var setLoading = loadingS[1];
|
|
2494
|
+
var namesS = React.useState({});
|
|
2495
|
+
var names = namesS[0];
|
|
2496
|
+
var setNames = namesS[1];
|
|
2497
|
+
var seq = React.useRef(0);
|
|
2498
|
+
var load = React.useCallback(
|
|
2499
|
+
function(q, pageNumber, append) {
|
|
2500
|
+
var mine = ++seq.current;
|
|
2501
|
+
setLoading(true);
|
|
2502
|
+
return api.call(conf.action, { text: q || "", pageNumber, pageSize }).then(function(r) {
|
|
2503
|
+
if (mine !== seq.current) return;
|
|
2504
|
+
setLoading(false);
|
|
2505
|
+
if (!r || !r.ok) return;
|
|
2506
|
+
var next = mapPage(r.result || {}, pageNumber);
|
|
2507
|
+
setRows(function(prev) {
|
|
2508
|
+
if (!append) return next.rows;
|
|
2509
|
+
if (!dedupe) return prev.concat(next.rows);
|
|
2510
|
+
var seen = {};
|
|
2511
|
+
var out = [];
|
|
2512
|
+
prev.concat(next.rows).forEach(function(x) {
|
|
2513
|
+
var key = String(x.id);
|
|
2514
|
+
if (seen[key]) return;
|
|
2515
|
+
seen[key] = true;
|
|
2516
|
+
out.push(x);
|
|
2517
|
+
});
|
|
2518
|
+
return out;
|
|
2307
2519
|
});
|
|
2308
|
-
|
|
2309
|
-
|
|
2520
|
+
setTotal(next.total);
|
|
2521
|
+
setPage(next.page);
|
|
2522
|
+
setHasMore(next.hasMore);
|
|
2523
|
+
setNames(function(prev) {
|
|
2524
|
+
var map = Object.assign({}, prev);
|
|
2525
|
+
next.rows.forEach(function(x) {
|
|
2526
|
+
map[String(x.id)] = x.name;
|
|
2527
|
+
});
|
|
2528
|
+
return map;
|
|
2310
2529
|
});
|
|
2311
|
-
|
|
2530
|
+
}).catch(function() {
|
|
2531
|
+
if (mine === seq.current) setLoading(false);
|
|
2312
2532
|
});
|
|
2313
|
-
|
|
2314
|
-
|
|
2315
|
-
|
|
2316
|
-
|
|
2317
|
-
|
|
2318
|
-
|
|
2533
|
+
},
|
|
2534
|
+
[api]
|
|
2535
|
+
);
|
|
2536
|
+
React.useEffect(
|
|
2537
|
+
function() {
|
|
2538
|
+
if (!open) return void 0;
|
|
2539
|
+
var timer = setTimeout(
|
|
2540
|
+
function() {
|
|
2541
|
+
load(query, 1, false);
|
|
2542
|
+
},
|
|
2543
|
+
query ? debounce : 0
|
|
2544
|
+
);
|
|
2545
|
+
return function() {
|
|
2546
|
+
clearTimeout(timer);
|
|
2547
|
+
};
|
|
2548
|
+
},
|
|
2549
|
+
[open, query, load, props.reloadKey]
|
|
2550
|
+
);
|
|
2551
|
+
React.useEffect(
|
|
2552
|
+
function() {
|
|
2553
|
+
if (!conf.probe) return;
|
|
2554
|
+
api.call(conf.probe.action || conf.action, conf.probe.args || {}).then(function(r) {
|
|
2555
|
+
if (r && r.ok) availS[1](!!(conf.probe.available && conf.probe.available(r.result)));
|
|
2556
|
+
}).catch(function() {
|
|
2319
2557
|
});
|
|
2320
|
-
}
|
|
2321
|
-
|
|
2322
|
-
|
|
2323
|
-
|
|
2324
|
-
|
|
2325
|
-
|
|
2326
|
-
|
|
2327
|
-
|
|
2328
|
-
if (!open) return void 0;
|
|
2329
|
-
var timer = setTimeout(
|
|
2330
|
-
function() {
|
|
2331
|
-
load(query, 1, false);
|
|
2332
|
-
},
|
|
2333
|
-
query ? 200 : 0
|
|
2334
|
-
);
|
|
2335
|
-
return function() {
|
|
2336
|
-
clearTimeout(timer);
|
|
2337
|
-
};
|
|
2338
|
-
},
|
|
2339
|
-
[open, query, load, props.reloadKey]
|
|
2340
|
-
);
|
|
2341
|
-
React.useEffect(
|
|
2342
|
-
function() {
|
|
2343
|
-
if (!open || !ids.length) return;
|
|
2344
|
-
var wanted = ids.filter(function(id) {
|
|
2345
|
-
return !names[String(id)];
|
|
2346
|
-
});
|
|
2347
|
-
if (!wanted.length) return;
|
|
2348
|
-
api.call("storageTags.byIds", { ids: wanted }).then(function(r) {
|
|
2349
|
-
if (!r || !r.ok) return;
|
|
2350
|
-
var next = {};
|
|
2351
|
-
(r.result && r.result.records || []).forEach(function(x) {
|
|
2352
|
-
next[String(x.id)] = x.name;
|
|
2558
|
+
},
|
|
2559
|
+
[api]
|
|
2560
|
+
);
|
|
2561
|
+
React.useEffect(
|
|
2562
|
+
function() {
|
|
2563
|
+
if (!open || !ids.length || !conf.names) return;
|
|
2564
|
+
var wanted = ids.filter(function(id) {
|
|
2565
|
+
return !names[String(id)];
|
|
2353
2566
|
});
|
|
2354
|
-
if (!
|
|
2355
|
-
|
|
2356
|
-
|
|
2567
|
+
if (!wanted.length) return;
|
|
2568
|
+
var args = conf.names.args ? conf.names.args(wanted) : { ids: wanted };
|
|
2569
|
+
api.call(conf.names.action, args).then(function(r) {
|
|
2570
|
+
if (!r || !r.ok) return;
|
|
2571
|
+
var map = {};
|
|
2572
|
+
(r.result && r.result.records || []).forEach(function(x) {
|
|
2573
|
+
map[String(x.id)] = x.name;
|
|
2574
|
+
});
|
|
2575
|
+
if (!Object.keys(map).length) return;
|
|
2576
|
+
setNames(function(prev) {
|
|
2577
|
+
return Object.assign({}, prev, map);
|
|
2578
|
+
});
|
|
2579
|
+
}).catch(function() {
|
|
2357
2580
|
});
|
|
2358
|
-
}
|
|
2359
|
-
|
|
2360
|
-
|
|
2361
|
-
|
|
2362
|
-
|
|
2363
|
-
|
|
2364
|
-
|
|
2365
|
-
|
|
2366
|
-
function onKey(e) {
|
|
2367
|
-
if (e.key === "Escape") setOpen(false);
|
|
2368
|
-
}
|
|
2369
|
-
document.addEventListener("keydown", onKey);
|
|
2370
|
-
return function() {
|
|
2371
|
-
document.removeEventListener("keydown", onKey);
|
|
2372
|
-
};
|
|
2373
|
-
},
|
|
2374
|
-
[open]
|
|
2375
|
-
);
|
|
2376
|
-
function toggle(id) {
|
|
2377
|
-
var key = String(id), next = ids.slice(), i = next.indexOf(key);
|
|
2378
|
-
if (i >= 0) next.splice(i, 1);
|
|
2379
|
-
else next.push(key);
|
|
2380
|
-
onChange(next);
|
|
2381
|
-
}
|
|
2382
|
-
if (!enabled) return null;
|
|
2383
|
-
return h2(
|
|
2384
|
-
"div",
|
|
2385
|
-
{ className: "wbi-tagfilter" },
|
|
2386
|
-
h2(
|
|
2387
|
-
"button",
|
|
2388
|
-
{
|
|
2389
|
-
type: "button",
|
|
2390
|
-
className: "wbi-btn" + (ids.length ? " wbi-tagon" : ""),
|
|
2391
|
-
"aria-expanded": open ? "true" : "false",
|
|
2392
|
-
onClick: function(e) {
|
|
2393
|
-
e.stopPropagation();
|
|
2394
|
-
setOpen(!open);
|
|
2581
|
+
},
|
|
2582
|
+
[open, ids.join(",")]
|
|
2583
|
+
);
|
|
2584
|
+
React.useEffect(
|
|
2585
|
+
function() {
|
|
2586
|
+
if (!open) return void 0;
|
|
2587
|
+
function onKey(e) {
|
|
2588
|
+
if (e.key === "Escape") setOpen(false);
|
|
2395
2589
|
}
|
|
2590
|
+
document.addEventListener("keydown", onKey);
|
|
2591
|
+
return function() {
|
|
2592
|
+
document.removeEventListener("keydown", onKey);
|
|
2593
|
+
};
|
|
2396
2594
|
},
|
|
2397
|
-
|
|
2398
|
-
|
|
2399
|
-
|
|
2400
|
-
|
|
2401
|
-
|
|
2595
|
+
[open]
|
|
2596
|
+
);
|
|
2597
|
+
function toggle(id) {
|
|
2598
|
+
var key = String(id);
|
|
2599
|
+
var next = ids.slice();
|
|
2600
|
+
var i = next.indexOf(key);
|
|
2601
|
+
if (i >= 0) next.splice(i, 1);
|
|
2602
|
+
else next.push(key);
|
|
2603
|
+
onChange(next);
|
|
2604
|
+
}
|
|
2605
|
+
if (!enabled(props)) return null;
|
|
2606
|
+
var caretNode = typeof caret === "function" ? caret(props, t) : caret;
|
|
2607
|
+
var selectedNode = renderSelected ? renderSelected({ ids, names, toggle, text: t, classes, h: h2 }) : null;
|
|
2608
|
+
return h2(
|
|
2402
2609
|
"div",
|
|
2403
|
-
{ className:
|
|
2404
|
-
|
|
2405
|
-
|
|
2406
|
-
|
|
2407
|
-
|
|
2408
|
-
"
|
|
2409
|
-
|
|
2410
|
-
|
|
2411
|
-
|
|
2412
|
-
|
|
2413
|
-
|
|
2414
|
-
ids.map(function(id) {
|
|
2415
|
-
return h2(
|
|
2416
|
-
"button",
|
|
2417
|
-
{
|
|
2418
|
-
key: id,
|
|
2419
|
-
type: "button",
|
|
2420
|
-
className: "wbi-tagselitem",
|
|
2421
|
-
title: tr(lang, "\u79FB\u9664", "Remove"),
|
|
2422
|
-
onClick: function() {
|
|
2423
|
-
toggle(id);
|
|
2424
|
-
}
|
|
2425
|
-
},
|
|
2426
|
-
h2("span", { className: "wbi-tagnm" }, names[String(id)] || "#" + id),
|
|
2427
|
-
h2("span", { className: "wbi-tagx" }, "\xD7")
|
|
2428
|
-
);
|
|
2429
|
-
})
|
|
2430
|
-
)
|
|
2431
|
-
) : null,
|
|
2432
|
-
items: opts.tags.map(function(x) {
|
|
2433
|
-
return { id: x.id, name: x.name };
|
|
2434
|
-
}),
|
|
2435
|
-
selected: ids,
|
|
2436
|
-
onToggle: toggle,
|
|
2437
|
-
query,
|
|
2438
|
-
onQuery: setQuery,
|
|
2439
|
-
title: tr(lang, "\u5168\u90E8\u6807\u7B7E", "All tags"),
|
|
2440
|
-
total: opts.total,
|
|
2441
|
-
selectedText: tr(lang, "\u5DF2\u9009", "Selected"),
|
|
2442
|
-
clearText: tr(lang, "\u6E05\u7A7A", "Clear"),
|
|
2443
|
-
onClear: function() {
|
|
2444
|
-
onChange([]);
|
|
2445
|
-
setQuery("");
|
|
2610
|
+
{ className: classes.root },
|
|
2611
|
+
h2(
|
|
2612
|
+
"button",
|
|
2613
|
+
{
|
|
2614
|
+
type: "button",
|
|
2615
|
+
className: classes.btn + (ids.length ? " " + (classes.btnOn || "on") : ""),
|
|
2616
|
+
"aria-expanded": open ? "true" : "false",
|
|
2617
|
+
onClick: function(e) {
|
|
2618
|
+
if (conf.stopPropagation) e.stopPropagation();
|
|
2619
|
+
setOpen(!open);
|
|
2620
|
+
}
|
|
2446
2621
|
},
|
|
2447
|
-
|
|
2448
|
-
|
|
2449
|
-
|
|
2450
|
-
|
|
2451
|
-
|
|
2622
|
+
icon(props, "tag", 13),
|
|
2623
|
+
t.label + (ids.length ? " \xB7 " + ids.length : ""),
|
|
2624
|
+
caretNode
|
|
2625
|
+
),
|
|
2626
|
+
open ? h2(
|
|
2627
|
+
"div",
|
|
2628
|
+
{
|
|
2629
|
+
className: classes.menu,
|
|
2630
|
+
role: conf.menuRole,
|
|
2631
|
+
style: conf.menuStyle,
|
|
2632
|
+
onClick: conf.stopPropagation ? function(e) {
|
|
2633
|
+
e.stopPropagation();
|
|
2634
|
+
} : void 0
|
|
2452
2635
|
},
|
|
2453
|
-
|
|
2454
|
-
|
|
2455
|
-
|
|
2456
|
-
|
|
2457
|
-
|
|
2458
|
-
|
|
2459
|
-
|
|
2636
|
+
h2(FilterChecklist, {
|
|
2637
|
+
beforeHead: selectedNode,
|
|
2638
|
+
items: items(rows),
|
|
2639
|
+
selected: ids,
|
|
2640
|
+
onToggle: toggle,
|
|
2641
|
+
query,
|
|
2642
|
+
onQuery: setQuery,
|
|
2643
|
+
title: t.all,
|
|
2644
|
+
total,
|
|
2645
|
+
selectedText: t.selected,
|
|
2646
|
+
clearText: t.clear,
|
|
2647
|
+
onClear: function() {
|
|
2648
|
+
onChange([]);
|
|
2649
|
+
setQuery("");
|
|
2650
|
+
},
|
|
2651
|
+
searchPlaceholder: t.searchPlaceholder,
|
|
2652
|
+
loading,
|
|
2653
|
+
hasMore,
|
|
2654
|
+
onLoadMore: function() {
|
|
2655
|
+
load(query, (page || 1) + 1, true);
|
|
2656
|
+
},
|
|
2657
|
+
emptyText: t.empty,
|
|
2658
|
+
noMatchText: t.noMatch,
|
|
2659
|
+
loadingText: t.loading,
|
|
2660
|
+
noMoreText: t.noMore
|
|
2661
|
+
})
|
|
2662
|
+
) : null
|
|
2663
|
+
);
|
|
2664
|
+
};
|
|
2460
2665
|
};
|
|
2461
2666
|
}
|
|
2462
2667
|
});
|
|
2463
2668
|
|
|
2669
|
+
// packages/addons/storage/client/ui/tagfilter.cjs
|
|
2670
|
+
var require_tagfilter = __commonJS({
|
|
2671
|
+
"packages/addons/storage/client/ui/tagfilter.cjs"(exports2, module2) {
|
|
2672
|
+
var React = require("react");
|
|
2673
|
+
var h2 = React.createElement;
|
|
2674
|
+
var ui = require_ui();
|
|
2675
|
+
var createTagFilter = require_tag_filter();
|
|
2676
|
+
module2.exports = createTagFilter({
|
|
2677
|
+
action: "storageTags.search",
|
|
2678
|
+
stopPropagation: true,
|
|
2679
|
+
classes: { root: "wbi-tagfilter", btn: "wbi-btn", btnOn: "wbi-tagon", menu: "wbi-tagmenu" },
|
|
2680
|
+
menuRole: "menu",
|
|
2681
|
+
enabled: function(props) {
|
|
2682
|
+
return props.enabled !== false;
|
|
2683
|
+
},
|
|
2684
|
+
// 已选标签可能不在当前页甚至不在当前搜索词里,按 id 补名字。
|
|
2685
|
+
names: { action: "storageTags.byIds" },
|
|
2686
|
+
text: function(props) {
|
|
2687
|
+
var lang = props.lang;
|
|
2688
|
+
return {
|
|
2689
|
+
label: ui.tr(lang, "\u6807\u7B7E\u7B5B\u9009", "Tag filter"),
|
|
2690
|
+
selected: ui.tr(lang, "\u5DF2\u9009", "Selected"),
|
|
2691
|
+
all: ui.tr(lang, "\u5168\u90E8\u6807\u7B7E", "All tags"),
|
|
2692
|
+
clear: ui.tr(lang, "\u6E05\u7A7A", "Clear"),
|
|
2693
|
+
searchPlaceholder: ui.tr(lang, "\u641C\u7D22\u6807\u7B7E\u540D\u79F0", "Search tag names"),
|
|
2694
|
+
empty: ui.tr(lang, "\u6682\u65E0\u6807\u7B7E", "No tags yet"),
|
|
2695
|
+
noMatch: ui.tr(lang, "\u6CA1\u6709\u5339\u914D\u7684\u6807\u7B7E", "No matching tags"),
|
|
2696
|
+
loading: ui.tr(lang, "\u52A0\u8F7D\u4E2D\u2026", "Loading\u2026"),
|
|
2697
|
+
noMore: ui.tr(lang, "\u6CA1\u6709\u66F4\u591A", "No more"),
|
|
2698
|
+
remove: ui.tr(lang, "\u79FB\u9664", "Remove")
|
|
2699
|
+
};
|
|
2700
|
+
},
|
|
2701
|
+
icon: function(props, name, size) {
|
|
2702
|
+
return h2(ui.Icon, { name, size });
|
|
2703
|
+
},
|
|
2704
|
+
caret: "\u25BE",
|
|
2705
|
+
mapPage: function(out, pageNumber) {
|
|
2706
|
+
var pages = out.pages || 0;
|
|
2707
|
+
var current = out.current || pageNumber;
|
|
2708
|
+
return { rows: out.records || [], total: out.total || 0, page: current, hasMore: current < pages };
|
|
2709
|
+
},
|
|
2710
|
+
renderSelected: function(ctx) {
|
|
2711
|
+
if (!ctx.ids.length) return null;
|
|
2712
|
+
return h2(
|
|
2713
|
+
"div",
|
|
2714
|
+
{ className: "wbi-tagsel" },
|
|
2715
|
+
h2(
|
|
2716
|
+
"div",
|
|
2717
|
+
{ className: "wbi-tagmenu-head" },
|
|
2718
|
+
h2("span", null, ctx.text.selected + " " + ctx.ids.length)
|
|
2719
|
+
),
|
|
2720
|
+
h2(
|
|
2721
|
+
"div",
|
|
2722
|
+
{ className: "wbi-tagsel-list" },
|
|
2723
|
+
ctx.ids.map(function(id) {
|
|
2724
|
+
return h2(
|
|
2725
|
+
"button",
|
|
2726
|
+
{
|
|
2727
|
+
key: id,
|
|
2728
|
+
type: "button",
|
|
2729
|
+
className: "wbi-tagselitem",
|
|
2730
|
+
title: ctx.text.remove,
|
|
2731
|
+
onClick: function() {
|
|
2732
|
+
ctx.toggle(id);
|
|
2733
|
+
}
|
|
2734
|
+
},
|
|
2735
|
+
h2("span", { className: "wbi-tagnm" }, ctx.names[String(id)] || "#" + id),
|
|
2736
|
+
h2("span", { className: "wbi-tagx" }, "\xD7")
|
|
2737
|
+
);
|
|
2738
|
+
})
|
|
2739
|
+
)
|
|
2740
|
+
);
|
|
2741
|
+
}
|
|
2742
|
+
});
|
|
2743
|
+
}
|
|
2744
|
+
});
|
|
2745
|
+
|
|
2464
2746
|
// packages/addons/storage/client/ui/selection.cjs
|
|
2465
2747
|
var require_selection = __commonJS({
|
|
2466
2748
|
"packages/addons/storage/client/ui/selection.cjs"(exports2, module2) {
|
|
@@ -4626,7 +4908,7 @@ var require_data = __commonJS({
|
|
|
4626
4908
|
"use strict";
|
|
4627
4909
|
module2.exports = require_data_view()({
|
|
4628
4910
|
domain: "storage",
|
|
4629
|
-
Icon:
|
|
4911
|
+
Icon: require_icons2().Icon,
|
|
4630
4912
|
Skeleton: require_ui().Skeleton,
|
|
4631
4913
|
prefix: "wbi",
|
|
4632
4914
|
tables: ["storage"],
|
|
@@ -4657,8 +4939,21 @@ var require_action_schema_style = __commonJS({
|
|
|
4657
4939
|
"." + P + " select:focus-visible{outline:2px solid var(--dsw-alias-brand-primary,#4f6ef7);outline-offset:1px}",
|
|
4658
4940
|
"." + P + "-list{display:flex;flex-direction:column;gap:8px}",
|
|
4659
4941
|
"." + P + "-card{border:1px solid var(--wb-border,#e3e5e9);border-radius:10px;padding:10px 12px;background:var(--wb-surface,var(--dsw-alias-bg-layer-1,transparent));display:flex;flex-direction:column;gap:8px;min-width:0}",
|
|
4660
|
-
"." + P + "-cardhead{display:
|
|
4661
|
-
"." + P + "-
|
|
4942
|
+
"." + P + "-cardhead{display:grid;grid-template-columns:minmax(0,1fr) auto;align-items:start;gap:8px}",
|
|
4943
|
+
"." + P + "-cardmeta{display:flex;align-items:center;flex-wrap:wrap;gap:8px;min-width:0;min-height:24px}",
|
|
4944
|
+
"." + P + "-cardhead code{font-weight:640;overflow-wrap:anywhere;min-width:0}",
|
|
4945
|
+
"." + P + "-hintline{margin:0;color:var(--dsw-alias-label-tertiary,inherit);font-size:11.5px;line-height:1.5}",
|
|
4946
|
+
"." + P + "-toggle{display:inline-flex;align-items:center;gap:6px;min-height:24px;padding:0 2px;border:0;background:transparent;font:inherit;font-size:11.5px;color:var(--wb-muted);cursor:pointer}",
|
|
4947
|
+
"." + P + "-track{display:inline-flex;align-items:center;box-sizing:border-box;width:30px;height:18px;padding:2px;border:1px solid var(--wb-muted);border-radius:999px;background:var(--wb-surface);color:var(--wb-muted)}",
|
|
4948
|
+
"." + P + "-track::before{content:'';width:12px;height:12px;border-radius:50%;background:currentColor;transition:transform .15s ease}",
|
|
4949
|
+
"." + P + "-toggle[aria-checked=true] ." + P + "-track{background:var(--wb-accent);border-color:var(--wb-accent);color:var(--wb-card)}",
|
|
4950
|
+
"." + P + "-toggle[aria-checked=true] ." + P + "-track::before{transform:translateX(12px)}",
|
|
4951
|
+
"." + P + "-toggle:hover:not(:disabled) ." + P + "-track{outline:1px solid var(--wb-accent)}",
|
|
4952
|
+
"." + P + "-toggle:focus-visible{outline:2px solid var(--wb-accent);outline-offset:2px}",
|
|
4953
|
+
"." + P + "-toggle:disabled{opacity:.6;cursor:progress}",
|
|
4954
|
+
"@media(prefers-reduced-motion:reduce){." + P + "-track::before{transition:none}}",
|
|
4955
|
+
// 安全约束(不可放开):用警示色描边,和可切换的开关区分开。
|
|
4956
|
+
"." + P + "-locked{border-color:var(--wb-warn,#b7791f);color:var(--wb-warn,#b7791f)}",
|
|
4662
4957
|
"." + P + "-desc{margin:0;color:var(--dsw-alias-label-secondary,inherit);line-height:1.55;font-size:12.5px}",
|
|
4663
4958
|
// 搜索命中:用品牌色透明度叠加而不是写死浅色,深浅主题都可读;继承文字颜色、不覆盖 ::selection。
|
|
4664
4959
|
"." + P + " mark." + P + "-hit{background:color-mix(in oklab,var(--dsw-alias-brand-primary,#4f6ef7) 22%,transparent);color:inherit;border-radius:2px;padding:0;font:inherit;box-decoration-break:clone;-webkit-box-decoration-break:clone}",
|
|
@@ -4710,6 +5005,15 @@ var require_action_schema_view = __commonJS({
|
|
|
4710
5005
|
zh: {
|
|
4711
5006
|
title: "Action",
|
|
4712
5007
|
hint: "\u8FD0\u884C\u65F6\u6CE8\u518C \xB7 \u53EA\u8BFB",
|
|
5008
|
+
switchHint: "agent \u5F00\u5173\u843D\u672C\u673A\u3001\u5373\u6539\u5373\u751F\u6548\uFF1B\u754C\u9762\u64CD\u4F5C\u4E0D\u53D7\u5F71\u54CD\u3002",
|
|
5009
|
+
hostHint: "\u5BBF\u4E3B action \u7684 agent \u5F00\u5173\uFF1B\u6807\u300C\u4EC5\u754C\u9762 \xB7 \u5B89\u5168\u7EA6\u675F\u300D\u7684\u4E0D\u53EF\u653E\u5F00\u3002",
|
|
5010
|
+
agentSwitch: "agent \u53EF\u7528",
|
|
5011
|
+
agentLocked: "\u4EC5\u754C\u9762 \xB7 \u5B89\u5168\u7EA6\u675F",
|
|
5012
|
+
agentLockedHint: "\u8BE5 action \u53EA\u80FD\u5728\u754C\u9762\u6267\u884C\uFF08\u5B89\u5168\u7EA6\u675F\uFF09\uFF0Cagent \u5F00\u5173\u4E0D\u53EF\u653E\u5F00",
|
|
5013
|
+
agentSaving: "\u4FDD\u5B58\u4E2D\u2026",
|
|
5014
|
+
agentOnToast: "\u5DF2\u5141\u8BB8 agent \u8C03\u7528",
|
|
5015
|
+
agentOffToast: "\u5DF2\u7981\u6B62 agent \u8C03\u7528",
|
|
5016
|
+
agentFail: "\u5207\u6362 agent \u5F00\u5173\u5931\u8D25",
|
|
4713
5017
|
domain: "\u57DF",
|
|
4714
5018
|
versionLabel: "\u7248\u672C",
|
|
4715
5019
|
shell: "\u5BBF\u4E3B",
|
|
@@ -4755,6 +5059,15 @@ var require_action_schema_view = __commonJS({
|
|
|
4755
5059
|
en: {
|
|
4756
5060
|
title: "Actions",
|
|
4757
5061
|
hint: "runtime registry \xB7 read-only",
|
|
5062
|
+
switchHint: "The agent switch is stored locally and applies immediately; UI actions are unaffected.",
|
|
5063
|
+
hostHint: "Agent switch for host actions; items marked UI-only (security) cannot be opened up.",
|
|
5064
|
+
agentSwitch: "Agent callable",
|
|
5065
|
+
agentLocked: "UI only \xB7 security",
|
|
5066
|
+
agentLockedHint: "This action can only run from the UI (security constraint); the agent switch cannot be opened",
|
|
5067
|
+
agentSaving: "Saving\u2026",
|
|
5068
|
+
agentOnToast: "Agent calls allowed",
|
|
5069
|
+
agentOffToast: "Agent calls blocked",
|
|
5070
|
+
agentFail: "Failed to change the agent switch",
|
|
4758
5071
|
domain: "Domain",
|
|
4759
5072
|
versionLabel: "Version",
|
|
4760
5073
|
shell: "Host",
|
|
@@ -4867,7 +5180,9 @@ var require_action_schema_view = __commonJS({
|
|
|
4867
5180
|
}
|
|
4868
5181
|
module2.exports = function createActionSchemaView(options) {
|
|
4869
5182
|
var raw = String(options.domain || "");
|
|
4870
|
-
var
|
|
5183
|
+
var SOURCE = options.source === "actions.list" ? "actions.list" : "actionSchema";
|
|
5184
|
+
var DOMAIN = SOURCE === "actions.list" ? raw : raw.indexOf("wb-addon-") === 0 ? raw : "wb-addon-" + raw;
|
|
5185
|
+
var LIST_DOMAIN = options.listDomain ? String(options.listDomain) : DOMAIN;
|
|
4871
5186
|
var prefix = options.prefix;
|
|
4872
5187
|
var P = prefix + "-as";
|
|
4873
5188
|
var Icon3 = options.Icon || null;
|
|
@@ -4911,6 +5226,8 @@ var require_action_schema_view = __commonJS({
|
|
|
4911
5226
|
var typePick = typeState[0], setTypePick = typeState[1];
|
|
4912
5227
|
var toastState = React.useState("");
|
|
4913
5228
|
var toast = toastState[0], setToast = toastState[1];
|
|
5229
|
+
var savingState = React.useState("");
|
|
5230
|
+
var saving = savingState[0], setSaving = savingState[1];
|
|
4914
5231
|
React.useEffect(function() {
|
|
4915
5232
|
injectCss();
|
|
4916
5233
|
}, []);
|
|
@@ -4919,9 +5236,10 @@ var require_action_schema_view = __commonJS({
|
|
|
4919
5236
|
setLoading(true);
|
|
4920
5237
|
setErr("");
|
|
4921
5238
|
var pending;
|
|
4922
|
-
var actionName = DOMAIN.replace(/^wb-addon-/, "") + ".actionSchema";
|
|
5239
|
+
var actionName = SOURCE === "actions.list" ? "actions.list" : DOMAIN.replace(/^wb-addon-/, "") + ".actionSchema";
|
|
5240
|
+
var callArgs = SOURCE === "actions.list" ? { detail: true, domain: LIST_DOMAIN } : void 0;
|
|
4923
5241
|
if (api && typeof api.call === "function") {
|
|
4924
|
-
pending = Promise.resolve(api.call(actionName)).then(function(r) {
|
|
5242
|
+
pending = Promise.resolve(api.call(actionName, callArgs)).then(function(r) {
|
|
4925
5243
|
if (r && r.ok === false) return r;
|
|
4926
5244
|
return r && r.result || r;
|
|
4927
5245
|
});
|
|
@@ -4961,6 +5279,39 @@ var require_action_schema_view = __commonJS({
|
|
|
4961
5279
|
plainCopy(text);
|
|
4962
5280
|
done();
|
|
4963
5281
|
}
|
|
5282
|
+
function setAgent(action, next) {
|
|
5283
|
+
var name = action.name;
|
|
5284
|
+
setSaving(name);
|
|
5285
|
+
setToast("");
|
|
5286
|
+
var fail = function(e) {
|
|
5287
|
+
setSaving("");
|
|
5288
|
+
setToast(t.agentFail + "\uFF1A" + String(e && e.message || e || ""));
|
|
5289
|
+
};
|
|
5290
|
+
var done = function(r) {
|
|
5291
|
+
setSaving("");
|
|
5292
|
+
var payload = r && typeof r === "object" && Object.prototype.hasOwnProperty.call(r, "result") ? r.result : r;
|
|
5293
|
+
if (r && r.ok === false) {
|
|
5294
|
+
setToast(t.agentFail + "\uFF1A" + String(r.error || r.text || ""));
|
|
5295
|
+
return;
|
|
5296
|
+
}
|
|
5297
|
+
var value = payload && typeof payload.agentEnabled === "boolean" ? payload.agentEnabled : next;
|
|
5298
|
+
setSnap(function(prev) {
|
|
5299
|
+
if (!prev || !Array.isArray(prev.actions)) return prev;
|
|
5300
|
+
return Object.assign({}, prev, {
|
|
5301
|
+
actions: prev.actions.map(function(a) {
|
|
5302
|
+
if (!a || a.name !== name) return a;
|
|
5303
|
+
return Object.assign({}, a, { agentEnabled: value });
|
|
5304
|
+
})
|
|
5305
|
+
});
|
|
5306
|
+
});
|
|
5307
|
+
setToast(value ? t.agentOnToast : t.agentOffToast);
|
|
5308
|
+
};
|
|
5309
|
+
if (!api || typeof api.call !== "function") {
|
|
5310
|
+
fail(new Error("no call api"));
|
|
5311
|
+
return;
|
|
5312
|
+
}
|
|
5313
|
+
Promise.resolve(api.call("actions.setAgentAccess", { action: name, agentEnabled: next })).then(done, fail);
|
|
5314
|
+
}
|
|
4964
5315
|
var all = snap && Array.isArray(snap.actions) ? snap.actions.filter(function(a) {
|
|
4965
5316
|
return a && a.domain === DOMAIN;
|
|
4966
5317
|
}) : [];
|
|
@@ -5009,6 +5360,35 @@ var require_action_schema_view = __commonJS({
|
|
|
5009
5360
|
h2("td", null, Highlight.hit(row.description, kw))
|
|
5010
5361
|
);
|
|
5011
5362
|
}
|
|
5363
|
+
function agentSwitch(action) {
|
|
5364
|
+
if (action.agentLocked === true) {
|
|
5365
|
+
return h2("span", {
|
|
5366
|
+
className: P + "-badge " + P + "-locked",
|
|
5367
|
+
title: t.agentLockedHint,
|
|
5368
|
+
"data-agent-locked": action.name
|
|
5369
|
+
}, t.agentLocked);
|
|
5370
|
+
}
|
|
5371
|
+
if (typeof action.agentEnabled !== "boolean") return null;
|
|
5372
|
+
var busy = saving === action.name;
|
|
5373
|
+
return h2(
|
|
5374
|
+
"button",
|
|
5375
|
+
{
|
|
5376
|
+
className: P + "-toggle",
|
|
5377
|
+
"data-agent-row": action.name,
|
|
5378
|
+
type: "button",
|
|
5379
|
+
role: "switch",
|
|
5380
|
+
"aria-checked": action.agentEnabled,
|
|
5381
|
+
disabled: busy,
|
|
5382
|
+
"data-agent-toggle": action.name,
|
|
5383
|
+
"aria-label": t.agentSwitch + " \xB7 " + action.name,
|
|
5384
|
+
onClick: function() {
|
|
5385
|
+
setAgent(action, !action.agentEnabled);
|
|
5386
|
+
}
|
|
5387
|
+
},
|
|
5388
|
+
h2("span", { className: P + "-track", "aria-hidden": true }),
|
|
5389
|
+
h2("span", null, busy ? t.agentSaving : t.agentSwitch)
|
|
5390
|
+
);
|
|
5391
|
+
}
|
|
5012
5392
|
function card(action) {
|
|
5013
5393
|
var rows = paramRows(action);
|
|
5014
5394
|
var examples = Array.isArray(action.examples) ? action.examples : [];
|
|
@@ -5018,12 +5398,16 @@ var require_action_schema_view = __commonJS({
|
|
|
5018
5398
|
h2(
|
|
5019
5399
|
"div",
|
|
5020
5400
|
{ className: P + "-cardhead" },
|
|
5021
|
-
h2(
|
|
5022
|
-
|
|
5023
|
-
|
|
5024
|
-
|
|
5025
|
-
|
|
5026
|
-
|
|
5401
|
+
h2(
|
|
5402
|
+
"div",
|
|
5403
|
+
{ className: P + "-cardmeta" },
|
|
5404
|
+
h2("code", { className: P + "-mono" }, Highlight.hit(action.name, kw)),
|
|
5405
|
+
h2("span", { className: P + "-badge" }, rows.length ? t.paramCount(rows.length) : t.noParams),
|
|
5406
|
+
rows.some(function(row) {
|
|
5407
|
+
return row.required;
|
|
5408
|
+
}) ? h2("span", { className: P + "-badge " + P + "-req" }, t.required) : null
|
|
5409
|
+
),
|
|
5410
|
+
agentSwitch(action)
|
|
5027
5411
|
),
|
|
5028
5412
|
action.description ? h2("p", { className: P + "-desc" }, Highlight.hit(action.description, kw)) : null,
|
|
5029
5413
|
rows.length ? h2(
|
|
@@ -5100,6 +5484,7 @@ var require_action_schema_view = __commonJS({
|
|
|
5100
5484
|
h2("span", { className: P + "-badge" }, t.count(visible.length, all.length)),
|
|
5101
5485
|
h2("span", { className: P + "-none" }, t.hint)
|
|
5102
5486
|
),
|
|
5487
|
+
h2("p", { className: P + "-hintline" }, SOURCE === "actions.list" ? t.hostHint : t.switchHint),
|
|
5103
5488
|
snap ? h2(
|
|
5104
5489
|
"div",
|
|
5105
5490
|
{ className: P + "-toolbar" },
|
|
@@ -5183,11 +5568,11 @@ if (host) {
|
|
|
5183
5568
|
style.textContent = require_styles();
|
|
5184
5569
|
document.head.appendChild(style);
|
|
5185
5570
|
}
|
|
5186
|
-
h = require("react").createElement,
|
|
5571
|
+
h = require("react").createElement, icons = require_icons2(), Icon2 = icons.Icon, GLYPHS = icons.ICONS;
|
|
5187
5572
|
host.registerAddon({
|
|
5188
5573
|
id: "wb-addon-storage",
|
|
5189
|
-
version: "1.5.
|
|
5190
|
-
icon:
|
|
5574
|
+
version: "1.5.8",
|
|
5575
|
+
icon: GLYPHS["package"],
|
|
5191
5576
|
views: [
|
|
5192
5577
|
{ id: "stats", icon: tabIcon2("chart"), title: { zh: "\u7EDF\u8BA1", en: "Statistics" }, component: require_stats().Stats },
|
|
5193
5578
|
{ id: "storage", icon: tabIcon2("list"), title: { zh: "\u8BB0\u5F55", en: "Records" }, component: require_records().Records },
|
|
@@ -5200,7 +5585,9 @@ if (host) {
|
|
|
5200
5585
|
var styleId;
|
|
5201
5586
|
var style;
|
|
5202
5587
|
var h;
|
|
5588
|
+
var icons;
|
|
5203
5589
|
var Icon2;
|
|
5590
|
+
var GLYPHS;
|
|
5204
5591
|
var tabIcon;
|
|
5205
5592
|
module.exports = { name: "dsh-workbench-storage", inject: [], apply: function() {
|
|
5206
5593
|
} };
|
package/lib/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-workbench-storage",
|
|
3
|
-
"version": "1.5.
|
|
3
|
+
"version": "1.5.8",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "个人工作台储物插件:名称、品牌、位置、单位、库存文本与标签",
|
|
6
6
|
"main": "lib/index.js",
|
|
@@ -9,8 +9,8 @@
|
|
|
9
9
|
"id": "wb-addon-storage",
|
|
10
10
|
"title": "储物",
|
|
11
11
|
"description": "储物:统计/记录/配置/数据四个视图",
|
|
12
|
-
"version": "1.5.
|
|
13
|
-
"minShell": "0.
|
|
12
|
+
"version": "1.5.8",
|
|
13
|
+
"minShell": "0.8.0",
|
|
14
14
|
"tables": [
|
|
15
15
|
"storage"
|
|
16
16
|
],
|
|
@@ -47,7 +47,7 @@
|
|
|
47
47
|
"./package.json": "./package.json"
|
|
48
48
|
},
|
|
49
49
|
"dependencies": {
|
|
50
|
-
"dsh-workbench-host": "^0.
|
|
50
|
+
"dsh-workbench-host": "^0.8.1"
|
|
51
51
|
},
|
|
52
52
|
"dsh": {
|
|
53
53
|
"bundle": {
|