@activecollab/components 2.0.460 → 2.0.461
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/cjs/presentation/shared/SourceCodeSection.js +204 -24
- package/dist/cjs/presentation/shared/SourceCodeSection.js.map +1 -1
- package/dist/esm/presentation/shared/SourceCodeSection.d.ts.map +1 -1
- package/dist/esm/presentation/shared/SourceCodeSection.js +173 -26
- package/dist/esm/presentation/shared/SourceCodeSection.js.map +1 -1
- package/package.json +1 -1
|
@@ -13,10 +13,12 @@ var _tokens = require("./tokens");
|
|
|
13
13
|
var _AvatarGroup = require("../../components/AvatarGroup");
|
|
14
14
|
var _Button = require("../../components/Button");
|
|
15
15
|
var _AddToListButton = require("../../components/Button/AddToListButton");
|
|
16
|
+
var _Checkbox = require("../../components/Checkbox");
|
|
16
17
|
var _Chip = require("../../components/Chip");
|
|
17
18
|
var _Dialog = require("../../components/Dialog");
|
|
18
19
|
var _IconButton = require("../../components/IconButton");
|
|
19
20
|
var _Icons = require("../../components/Icons");
|
|
21
|
+
var _Label = require("../../components/Label");
|
|
20
22
|
var _StepSequence = require("../../components/StepSequence");
|
|
21
23
|
var _Tooltip = require("../../components/Tooltip");
|
|
22
24
|
var _Typography = require("../../components/Typography");
|
|
@@ -980,7 +982,7 @@ var HistoryDialog = exports.HistoryDialog = function HistoryDialog(_ref4) {
|
|
|
980
982
|
var StyledSourceCode = _styledComponents.default.div.withConfig({
|
|
981
983
|
displayName: "SourceCodeSection__StyledSourceCode",
|
|
982
984
|
componentId: "sc-rvqbh5-2"
|
|
983
|
-
})(["font-family:", ";margin:0 0 16px;padding-bottom:16px;border-bottom:1px solid var(--border-primary);", " .sc-header{display:flex;align-items:center;justify-content:space-between;gap:12px;margin-bottom:4px;}.sc-completed-row{display:flex;align-items:center;margin-top:8px;padding-top:8px;border-top:1px solid var(--border-primary);}.sc-add{margin-top:8px;padding-top:12px;border-top:1px solid var(--border-primary);}.sc-add .c--add-to-list-btn svg{box-sizing:content-box;}.sc-item{padding:12px 0;}.sc-item + .sc-item{border-top:1px solid var(--border-primary);}.sc-row{display:flex;align-items:flex-start;justify-content:space-between;gap:16px;}.sc-main{flex:1 1 0%;min-width:0;}.sc-name{display:flex;align-items:center;gap:8px;flex-wrap:nowrap;min-width:0;}.sc-lead{flex-shrink:0;display:inline-flex;color:var(--color-theme-600);}.sc-title{flex:0 1 auto;min-width:0;display:block;overflow:hidden;white-space:nowrap;text-overflow:ellipsis;}.sc-title.strike{text-decoration:line-through;}.sc-title.strike-link{text-decoration:line-through;}.sc-title.strike-link:hover{text-decoration:none;}.sc-sigs{display:flex;align-items:center;gap:12px;flex-wrap:wrap;margin-top:10px;font-size:12px;color:var(--color-theme-600);}.sc-sig{display:inline-flex;align-items:center;gap:4px;}.sc-closing{display:inline-flex;align-items:center;flex-shrink:0;cursor:default;}.sc-sha{font-family:ui-monospace,SFMono-Regular,Menlo,Consolas,monospace;}.sc-muted{color:var(--color-theme-600);}.sc-refs{display:inline-flex;align-items:center;gap:6px;}.sc-refs .ref-link{color:var(--color-primary);font-weight:500;}"], SANS, function (p) {
|
|
985
|
+
})(["font-family:", ";margin:0 0 16px;padding-bottom:16px;border-bottom:1px solid var(--border-primary);", " .sc-header{display:flex;align-items:center;justify-content:space-between;gap:12px;margin-bottom:4px;}.sc-header-actions{display:flex;align-items:center;gap:8px;flex-shrink:0;}.sc-completed-row{display:flex;align-items:center;margin-top:8px;padding-top:8px;border-top:1px solid var(--border-primary);}.sc-add{display:flex;align-items:center;justify-content:space-between;gap:12px;margin-top:8px;padding-top:12px;border-top:1px solid var(--border-primary);}.sc-add .c--add-to-list-btn svg{box-sizing:content-box;}.sc-item{padding:12px 0;}.sc-item + .sc-item{border-top:1px solid var(--border-primary);}.sc-row{display:flex;align-items:flex-start;justify-content:space-between;gap:16px;}.sc-main{flex:1 1 0%;min-width:0;}.sc-name{display:flex;align-items:center;gap:8px;flex-wrap:nowrap;min-width:0;}.sc-lead{flex-shrink:0;display:inline-flex;color:var(--color-theme-600);}.sc-title{flex:0 1 auto;min-width:0;display:block;overflow:hidden;white-space:nowrap;text-overflow:ellipsis;}.sc-title.strike{text-decoration:line-through;}.sc-title.strike-link{text-decoration:line-through;}.sc-title.strike-link:hover{text-decoration:none;}.sc-sigs{display:flex;align-items:center;gap:12px;flex-wrap:wrap;margin-top:10px;font-size:12px;color:var(--color-theme-600);}.sc-sig{display:inline-flex;align-items:center;gap:4px;}.sc-closing{display:inline-flex;align-items:center;flex-shrink:0;cursor:default;}.sc-sha{font-family:ui-monospace,SFMono-Regular,Menlo,Consolas,monospace;}.sc-muted{color:var(--color-theme-600);}.sc-refs{display:inline-flex;align-items:center;gap:6px;}.sc-refs .ref-link{color:var(--color-primary);font-weight:500;}"], SANS, function (p) {
|
|
984
986
|
return p.$flush && (0, _styledComponents.css)(["margin:0;padding-bottom:0;border-bottom:none;"]);
|
|
985
987
|
});
|
|
986
988
|
|
|
@@ -1269,31 +1271,164 @@ var CompletedHeader = exports.CompletedHeader = function CompletedHeader(_ref1)
|
|
|
1269
1271
|
}
|
|
1270
1272
|
}, expanded ? "Hide completed elements" : "Show ".concat(count, " more completed elements")));
|
|
1271
1273
|
};
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
|
|
1274
|
+
|
|
1275
|
+
/* ---- Unlink ---------------------------------------------------------- */
|
|
1276
|
+
|
|
1277
|
+
/** Stable per-element keys, shared by the Unlink dialog list and the section's
|
|
1278
|
+
removal set so a checked element maps back to the row it hides. */
|
|
1279
|
+
var issueElementKey = function issueElementKey(i) {
|
|
1280
|
+
return "issue:".concat(i.ref);
|
|
1281
|
+
};
|
|
1282
|
+
var codeElementKey = function codeElementKey(e) {
|
|
1283
|
+
return "code:".concat(e.repo, "-").concat(e.title);
|
|
1284
|
+
};
|
|
1285
|
+
/* Squared secondary button — the DS secondary/small button is a pill by
|
|
1286
|
+
default; a 6px radius matches the Linking and Commands trigger beside it. */
|
|
1287
|
+
var UnlinkTriggerButton = (0, _styledComponents.default)(_Button.Button).withConfig({
|
|
1288
|
+
displayName: "SourceCodeSection__UnlinkTriggerButton",
|
|
1289
|
+
componentId: "sc-rvqbh5-5"
|
|
1290
|
+
})(["&&{border-radius:var(--ac-br-6);}"]);
|
|
1291
|
+
var StyledUnlink = _styledComponents.default.div.withConfig({
|
|
1292
|
+
displayName: "SourceCodeSection__StyledUnlink",
|
|
1293
|
+
componentId: "sc-rvqbh5-6"
|
|
1294
|
+
})([".unlink-error{display:block;margin-bottom:12px;}.unlink-list{list-style:none;margin:0;padding:0;}.unlink-item{display:flex;align-items:center;gap:8px;padding:8px 0;}.unlink-label{min-width:0;cursor:pointer;}"]);
|
|
1295
|
+
|
|
1296
|
+
/** Stands in for the unlink request. Production replaces it with the real call
|
|
1297
|
+
and rejects on failure, which surfaces the error message in the dialog. */
|
|
1298
|
+
var mockUnlinkRequest = function mockUnlinkRequest() {
|
|
1299
|
+
return new Promise(function (resolve) {
|
|
1300
|
+
return setTimeout(resolve, 700);
|
|
1301
|
+
});
|
|
1302
|
+
};
|
|
1303
|
+
|
|
1304
|
+
/**
|
|
1305
|
+
* Unlink dialog — an action dialog with an explicit footer that also closes on
|
|
1306
|
+
* Esc or a click outside. Lists every
|
|
1307
|
+
* linked element with a checkbox, all unchecked by default; the user selects any
|
|
1308
|
+
* number and the primary action is always enabled. While the request is in
|
|
1309
|
+
* flight the buttons are disabled; on success the parent removes the selected
|
|
1310
|
+
* elements and closes the dialog with no toast; on failure the dialog shows
|
|
1311
|
+
* "Unable to unlink selected items" and re-enables the buttons.
|
|
1312
|
+
*/
|
|
1313
|
+
var UnlinkDialog = function UnlinkDialog(_ref10) {
|
|
1314
|
+
var open = _ref10.open,
|
|
1315
|
+
elements = _ref10.elements,
|
|
1316
|
+
onClose = _ref10.onClose,
|
|
1317
|
+
onConfirm = _ref10.onConfirm;
|
|
1318
|
+
var _useState = (0, _react.useState)(new Set()),
|
|
1284
1319
|
_useState2 = _slicedToArray(_useState, 2),
|
|
1285
|
-
|
|
1286
|
-
|
|
1320
|
+
selected = _useState2[0],
|
|
1321
|
+
setSelected = _useState2[1];
|
|
1287
1322
|
var _useState3 = (0, _react.useState)(false),
|
|
1288
1323
|
_useState4 = _slicedToArray(_useState3, 2),
|
|
1289
|
-
|
|
1290
|
-
|
|
1324
|
+
submitting = _useState4[0],
|
|
1325
|
+
setSubmitting = _useState4[1];
|
|
1291
1326
|
var _useState5 = (0, _react.useState)(false),
|
|
1292
1327
|
_useState6 = _slicedToArray(_useState5, 2),
|
|
1293
|
-
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
|
|
1328
|
+
error = _useState6[0],
|
|
1329
|
+
setError = _useState6[1];
|
|
1330
|
+
(0, _react.useEffect)(function () {
|
|
1331
|
+
if (open) {
|
|
1332
|
+
setSelected(new Set());
|
|
1333
|
+
setSubmitting(false);
|
|
1334
|
+
setError(false);
|
|
1335
|
+
}
|
|
1336
|
+
}, [open]);
|
|
1337
|
+
var toggle = function toggle(key) {
|
|
1338
|
+
return setSelected(function (prev) {
|
|
1339
|
+
var next = new Set(Array.from(prev));
|
|
1340
|
+
if (next.has(key)) {
|
|
1341
|
+
next.delete(key);
|
|
1342
|
+
} else {
|
|
1343
|
+
next.add(key);
|
|
1344
|
+
}
|
|
1345
|
+
return next;
|
|
1346
|
+
});
|
|
1347
|
+
};
|
|
1348
|
+
var handleUnlink = async function handleUnlink() {
|
|
1349
|
+
setSubmitting(true);
|
|
1350
|
+
setError(false);
|
|
1351
|
+
try {
|
|
1352
|
+
await onConfirm(Array.from(selected));
|
|
1353
|
+
} catch (_unused) {
|
|
1354
|
+
setError(true);
|
|
1355
|
+
setSubmitting(false);
|
|
1356
|
+
}
|
|
1357
|
+
};
|
|
1358
|
+
return /*#__PURE__*/_react.default.createElement(_Dialog.Dialog, {
|
|
1359
|
+
open: open,
|
|
1360
|
+
onClose: onClose,
|
|
1361
|
+
enableBackgroundClick: true
|
|
1362
|
+
}, /*#__PURE__*/_react.default.createElement(_Dialog.Dialog.Title, null, "Unlink"), /*#__PURE__*/_react.default.createElement(_Dialog.Dialog.ContentDivider, null), /*#__PURE__*/_react.default.createElement(_Dialog.Dialog.Content, null, /*#__PURE__*/_react.default.createElement(StyledUnlink, null, error && /*#__PURE__*/_react.default.createElement(_Typography.Body2, {
|
|
1363
|
+
color: "alert",
|
|
1364
|
+
className: "unlink-error"
|
|
1365
|
+
}, "Unable to unlink selected items"), /*#__PURE__*/_react.default.createElement("ul", {
|
|
1366
|
+
className: "unlink-list"
|
|
1367
|
+
}, elements.map(function (el, i) {
|
|
1368
|
+
var id = "source-unlink-".concat(i);
|
|
1369
|
+
return /*#__PURE__*/_react.default.createElement("li", {
|
|
1370
|
+
className: "unlink-item",
|
|
1371
|
+
key: el.key
|
|
1372
|
+
}, /*#__PURE__*/_react.default.createElement(_Checkbox.Checkbox, {
|
|
1373
|
+
id: id,
|
|
1374
|
+
checked: selected.has(el.key),
|
|
1375
|
+
onChange: function onChange() {
|
|
1376
|
+
return toggle(el.key);
|
|
1377
|
+
}
|
|
1378
|
+
}), /*#__PURE__*/_react.default.createElement(_Label.Label, {
|
|
1379
|
+
htmlFor: id,
|
|
1380
|
+
weight: "regular",
|
|
1381
|
+
className: "unlink-label"
|
|
1382
|
+
}, el.label));
|
|
1383
|
+
})))), /*#__PURE__*/_react.default.createElement(_Dialog.Dialog.ContentDivider, null), /*#__PURE__*/_react.default.createElement(_Dialog.Dialog.Actions, null, /*#__PURE__*/_react.default.createElement(_Button.Button, {
|
|
1384
|
+
type: "button",
|
|
1385
|
+
variant: "primary",
|
|
1386
|
+
disabled: submitting,
|
|
1387
|
+
onClick: handleUnlink
|
|
1388
|
+
}, "Unlink"), /*#__PURE__*/_react.default.createElement(_Button.Button, {
|
|
1389
|
+
type: "button",
|
|
1390
|
+
variant: "secondary",
|
|
1391
|
+
disabled: submitting,
|
|
1392
|
+
onClick: onClose
|
|
1393
|
+
}, "Cancel")));
|
|
1394
|
+
};
|
|
1395
|
+
var SourceCodeSection = exports.SourceCodeSection = function SourceCodeSection(_ref11) {
|
|
1396
|
+
var _ref11$variant = _ref11.variant,
|
|
1397
|
+
variant = _ref11$variant === void 0 ? "mix" : _ref11$variant,
|
|
1398
|
+
issues = _ref11.issues,
|
|
1399
|
+
code = _ref11.code,
|
|
1400
|
+
_ref11$showHeader = _ref11.showHeader,
|
|
1401
|
+
showHeader = _ref11$showHeader === void 0 ? true : _ref11$showHeader,
|
|
1402
|
+
_ref11$showLink = _ref11.showLink,
|
|
1403
|
+
showLink = _ref11$showLink === void 0 ? true : _ref11$showLink,
|
|
1404
|
+
_ref11$flush = _ref11.flush,
|
|
1405
|
+
flush = _ref11$flush === void 0 ? false : _ref11$flush;
|
|
1406
|
+
var _useState7 = (0, _react.useState)(null),
|
|
1407
|
+
_useState8 = _slicedToArray(_useState7, 2),
|
|
1408
|
+
openEntry = _useState8[0],
|
|
1409
|
+
setOpenEntry = _useState8[1];
|
|
1410
|
+
var _useState9 = (0, _react.useState)(false),
|
|
1411
|
+
_useState0 = _slicedToArray(_useState9, 2),
|
|
1412
|
+
completedExpanded = _useState0[0],
|
|
1413
|
+
setCompletedExpanded = _useState0[1];
|
|
1414
|
+
var _useState1 = (0, _react.useState)(false),
|
|
1415
|
+
_useState10 = _slicedToArray(_useState1, 2),
|
|
1416
|
+
linkOpen = _useState10[0],
|
|
1417
|
+
setLinkOpen = _useState10[1];
|
|
1418
|
+
var _useState11 = (0, _react.useState)(false),
|
|
1419
|
+
_useState12 = _slicedToArray(_useState11, 2),
|
|
1420
|
+
unlinkOpen = _useState12[0],
|
|
1421
|
+
setUnlinkOpen = _useState12[1];
|
|
1422
|
+
var _useState13 = (0, _react.useState)(new Set()),
|
|
1423
|
+
_useState14 = _slicedToArray(_useState13, 2),
|
|
1424
|
+
removed = _useState14[0],
|
|
1425
|
+
setRemoved = _useState14[1];
|
|
1426
|
+
var issuesData = (issues !== null && issues !== void 0 ? issues : ISSUES).filter(function (i) {
|
|
1427
|
+
return !removed.has(issueElementKey(i));
|
|
1428
|
+
});
|
|
1429
|
+
var codeData = (code !== null && code !== void 0 ? code : CODE_ENTRIES).filter(function (e) {
|
|
1430
|
+
return !removed.has(codeElementKey(e));
|
|
1431
|
+
});
|
|
1297
1432
|
var openIssues = issuesData.filter(function (i) {
|
|
1298
1433
|
return !issueCompleted(i);
|
|
1299
1434
|
}).sort(byRecency);
|
|
@@ -1325,13 +1460,51 @@ var SourceCodeSection = exports.SourceCodeSection = function SourceCodeSection(_
|
|
|
1325
1460
|
// In the "completed" variant there is no collapsible header and everything is
|
|
1326
1461
|
// shown; in "mix" the section is collapsed by default.
|
|
1327
1462
|
var completedVisible = variant === "completed" ? true : completedExpanded;
|
|
1463
|
+
var hasRows = openIssues.length > 0 || openCode.length > 0 || completed.length > 0;
|
|
1464
|
+
|
|
1465
|
+
// Every linked element, sorted by name, for the Unlink dialog.
|
|
1466
|
+
var unlinkElements = [...issuesData.map(function (i) {
|
|
1467
|
+
return {
|
|
1468
|
+
key: issueElementKey(i),
|
|
1469
|
+
label: i.title
|
|
1470
|
+
};
|
|
1471
|
+
}), ...codeData.map(function (e) {
|
|
1472
|
+
return {
|
|
1473
|
+
key: codeElementKey(e),
|
|
1474
|
+
label: e.title
|
|
1475
|
+
};
|
|
1476
|
+
})].sort(function (a, b) {
|
|
1477
|
+
return a.label.localeCompare(b.label);
|
|
1478
|
+
});
|
|
1479
|
+
var handleUnlinkConfirm = async function handleUnlinkConfirm(keys) {
|
|
1480
|
+
await mockUnlinkRequest();
|
|
1481
|
+
if (keys.length > 0) {
|
|
1482
|
+
setRemoved(function (prev) {
|
|
1483
|
+
var next = new Set(Array.from(prev));
|
|
1484
|
+
keys.forEach(function (key) {
|
|
1485
|
+
return next.add(key);
|
|
1486
|
+
});
|
|
1487
|
+
return next;
|
|
1488
|
+
});
|
|
1489
|
+
}
|
|
1490
|
+
setUnlinkOpen(false);
|
|
1491
|
+
};
|
|
1328
1492
|
return /*#__PURE__*/_react.default.createElement(StyledSourceCode, {
|
|
1329
1493
|
$flush: flush
|
|
1330
|
-
}, showHeader && /*#__PURE__*/_react.default.createElement("div", {
|
|
1494
|
+
}, showHeader && hasRows && /*#__PURE__*/_react.default.createElement("div", {
|
|
1331
1495
|
className: "sc-header"
|
|
1332
1496
|
}, /*#__PURE__*/_react.default.createElement(_Typography.Body1, {
|
|
1333
1497
|
weight: "bold"
|
|
1334
|
-
}, "Source Code"), /*#__PURE__*/_react.default.createElement(
|
|
1498
|
+
}, "Source Code"), /*#__PURE__*/_react.default.createElement("div", {
|
|
1499
|
+
className: "sc-header-actions"
|
|
1500
|
+
}, /*#__PURE__*/_react.default.createElement(_LinkingCommandsButton.LinkingCommandsButton, null), showLink && /*#__PURE__*/_react.default.createElement(UnlinkTriggerButton, {
|
|
1501
|
+
type: "button",
|
|
1502
|
+
variant: "secondary",
|
|
1503
|
+
size: "small",
|
|
1504
|
+
onClick: function onClick() {
|
|
1505
|
+
return setUnlinkOpen(true);
|
|
1506
|
+
}
|
|
1507
|
+
}, "Unlink"))), showOpen && openIssues.map(function (issue) {
|
|
1335
1508
|
return /*#__PURE__*/_react.default.createElement("div", {
|
|
1336
1509
|
className: "sc-item",
|
|
1337
1510
|
key: issue.ref
|
|
@@ -1371,7 +1544,7 @@ var SourceCodeSection = exports.SourceCodeSection = function SourceCodeSection(_
|
|
|
1371
1544
|
onClick: function onClick() {
|
|
1372
1545
|
return setLinkOpen(true);
|
|
1373
1546
|
}
|
|
1374
|
-
})), /*#__PURE__*/_react.default.createElement(HistoryDialog, {
|
|
1547
|
+
}), showHeader && !hasRows && /*#__PURE__*/_react.default.createElement(_LinkingCommandsButton.LinkingCommandsButton, null)), /*#__PURE__*/_react.default.createElement(HistoryDialog, {
|
|
1375
1548
|
entry: openEntry,
|
|
1376
1549
|
onClose: function onClose() {
|
|
1377
1550
|
return setOpenEntry(null);
|
|
@@ -1381,6 +1554,13 @@ var SourceCodeSection = exports.SourceCodeSection = function SourceCodeSection(_
|
|
|
1381
1554
|
onClose: function onClose() {
|
|
1382
1555
|
return setLinkOpen(false);
|
|
1383
1556
|
}
|
|
1557
|
+
}), /*#__PURE__*/_react.default.createElement(UnlinkDialog, {
|
|
1558
|
+
open: unlinkOpen,
|
|
1559
|
+
elements: unlinkElements,
|
|
1560
|
+
onClose: function onClose() {
|
|
1561
|
+
return setUnlinkOpen(false);
|
|
1562
|
+
},
|
|
1563
|
+
onConfirm: handleUnlinkConfirm
|
|
1384
1564
|
}));
|
|
1385
1565
|
};
|
|
1386
1566
|
//# sourceMappingURL=SourceCodeSection.js.map
|