@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.
@@ -1,7 +1,7 @@
1
1
  import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
2
2
  import _extends from "@babel/runtime/helpers/esm/extends";
3
3
  const _excluded = ["size", "bg", "initials", "alt"];
4
- import React, { useState } from "react";
4
+ import React, { useEffect, useState } from "react";
5
5
  import styled, { css } from "styled-components";
6
6
  import { LinkBranchOrPullRequestDialog } from "./LinkBranchOrPullRequestDialog";
7
7
  import { LinkingCommandsButton } from "./LinkingCommandsButton";
@@ -10,13 +10,15 @@ import { AVATAR_COLORS } from "./tokens";
10
10
  import { AvatarGroup } from "../../components/AvatarGroup";
11
11
  import { Button } from "../../components/Button";
12
12
  import { AddToListButton } from "../../components/Button/AddToListButton";
13
+ import { Checkbox } from "../../components/Checkbox";
13
14
  import { Chip } from "../../components/Chip";
14
15
  import { Dialog } from "../../components/Dialog";
15
16
  import { IconButton } from "../../components/IconButton";
16
17
  import { ArrowRightIcon, CancelCrossIcon, CheckboxBlankTogglerIcon, CheckIcon, CircleDotIcon, CloseIcon, CloudDeployFailedIcon, CloudDeployIcon, EyeIcon, GearFailedIcon, GearIcon, GitBranchIcon, GitCommitIcon, GitMergeIcon, GitPullRequestClosedIcon, GitPullRequestDraftIcon, GitPullRequestIcon, GitRepositoryIcon, InfoSmallIcon, MessageIcon, MessageSmallIcon, TrashIcon } from "../../components/Icons";
18
+ import { Label } from "../../components/Label";
17
19
  import { StepSequence } from "../../components/StepSequence";
18
20
  import { Tooltip } from "../../components/Tooltip";
19
- import { Body1, Caption1, Header3 } from "../../components/Typography";
21
+ import { Body1, Body2, Caption1, Header3 } from "../../components/Typography";
20
22
  import { colors } from "../../utils";
21
23
 
22
24
  /**
@@ -938,7 +940,7 @@ const HistoryDialog = _ref4 => {
938
940
  const StyledSourceCode = styled.div.withConfig({
939
941
  displayName: "SourceCodeSection__StyledSourceCode",
940
942
  componentId: "sc-rvqbh5-2"
941
- })(["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, p => p.$flush && css(["margin:0;padding-bottom:0;border-bottom:none;"]));
943
+ })(["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, p => p.$flush && css(["margin:0;padding-bottom:0;border-bottom:none;"]));
942
944
 
943
945
  /* Element name — a link that opens the object in a new tab. Keeps the row's
944
946
  typography (inherits color + weight), turns primary on hover, link cursor. */
@@ -1225,28 +1227,140 @@ const CompletedHeader = _ref1 => {
1225
1227
  }
1226
1228
  }, expanded ? "Hide completed elements" : "Show " + count + " more completed elements"));
1227
1229
  };
1228
- const SourceCodeSection = _ref10 => {
1229
- let _ref10$variant = _ref10.variant,
1230
- variant = _ref10$variant === void 0 ? "mix" : _ref10$variant,
1231
- issues = _ref10.issues,
1232
- code = _ref10.code,
1233
- _ref10$showHeader = _ref10.showHeader,
1234
- showHeader = _ref10$showHeader === void 0 ? true : _ref10$showHeader,
1235
- _ref10$showLink = _ref10.showLink,
1236
- showLink = _ref10$showLink === void 0 ? true : _ref10$showLink,
1237
- _ref10$flush = _ref10.flush,
1238
- flush = _ref10$flush === void 0 ? false : _ref10$flush;
1239
- const _useState = useState(null),
1240
- openEntry = _useState[0],
1241
- setOpenEntry = _useState[1];
1230
+
1231
+ /* ---- Unlink ---------------------------------------------------------- */
1232
+
1233
+ /** Stable per-element keys, shared by the Unlink dialog list and the section's
1234
+ removal set so a checked element maps back to the row it hides. */
1235
+ const issueElementKey = i => "issue:" + i.ref;
1236
+ const codeElementKey = e => "code:" + e.repo + "-" + e.title;
1237
+ /* Squared secondary button — the DS secondary/small button is a pill by
1238
+ default; a 6px radius matches the Linking and Commands trigger beside it. */
1239
+ const UnlinkTriggerButton = styled(Button).withConfig({
1240
+ displayName: "SourceCodeSection__UnlinkTriggerButton",
1241
+ componentId: "sc-rvqbh5-5"
1242
+ })(["&&{border-radius:var(--ac-br-6);}"]);
1243
+ const StyledUnlink = styled.div.withConfig({
1244
+ displayName: "SourceCodeSection__StyledUnlink",
1245
+ componentId: "sc-rvqbh5-6"
1246
+ })([".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;}"]);
1247
+
1248
+ /** Stands in for the unlink request. Production replaces it with the real call
1249
+ and rejects on failure, which surfaces the error message in the dialog. */
1250
+ const mockUnlinkRequest = () => new Promise(resolve => setTimeout(resolve, 700));
1251
+
1252
+ /**
1253
+ * Unlink dialog — an action dialog with an explicit footer that also closes on
1254
+ * Esc or a click outside. Lists every
1255
+ * linked element with a checkbox, all unchecked by default; the user selects any
1256
+ * number and the primary action is always enabled. While the request is in
1257
+ * flight the buttons are disabled; on success the parent removes the selected
1258
+ * elements and closes the dialog with no toast; on failure the dialog shows
1259
+ * "Unable to unlink selected items" and re-enables the buttons.
1260
+ */
1261
+ const UnlinkDialog = _ref10 => {
1262
+ let open = _ref10.open,
1263
+ elements = _ref10.elements,
1264
+ onClose = _ref10.onClose,
1265
+ onConfirm = _ref10.onConfirm;
1266
+ const _useState = useState(new Set()),
1267
+ selected = _useState[0],
1268
+ setSelected = _useState[1];
1242
1269
  const _useState2 = useState(false),
1243
- completedExpanded = _useState2[0],
1244
- setCompletedExpanded = _useState2[1];
1270
+ submitting = _useState2[0],
1271
+ setSubmitting = _useState2[1];
1245
1272
  const _useState3 = useState(false),
1246
- linkOpen = _useState3[0],
1247
- setLinkOpen = _useState3[1];
1248
- const issuesData = issues != null ? issues : ISSUES;
1249
- const codeData = code != null ? code : CODE_ENTRIES;
1273
+ error = _useState3[0],
1274
+ setError = _useState3[1];
1275
+ useEffect(() => {
1276
+ if (open) {
1277
+ setSelected(new Set());
1278
+ setSubmitting(false);
1279
+ setError(false);
1280
+ }
1281
+ }, [open]);
1282
+ const toggle = key => setSelected(prev => {
1283
+ const next = new Set(Array.from(prev));
1284
+ if (next.has(key)) {
1285
+ next.delete(key);
1286
+ } else {
1287
+ next.add(key);
1288
+ }
1289
+ return next;
1290
+ });
1291
+ const handleUnlink = async () => {
1292
+ setSubmitting(true);
1293
+ setError(false);
1294
+ try {
1295
+ await onConfirm(Array.from(selected));
1296
+ } catch (_unused) {
1297
+ setError(true);
1298
+ setSubmitting(false);
1299
+ }
1300
+ };
1301
+ return /*#__PURE__*/React.createElement(Dialog, {
1302
+ open: open,
1303
+ onClose: onClose,
1304
+ enableBackgroundClick: true
1305
+ }, /*#__PURE__*/React.createElement(Dialog.Title, null, "Unlink"), /*#__PURE__*/React.createElement(Dialog.ContentDivider, null), /*#__PURE__*/React.createElement(Dialog.Content, null, /*#__PURE__*/React.createElement(StyledUnlink, null, error && /*#__PURE__*/React.createElement(Body2, {
1306
+ color: "alert",
1307
+ className: "unlink-error"
1308
+ }, "Unable to unlink selected items"), /*#__PURE__*/React.createElement("ul", {
1309
+ className: "unlink-list"
1310
+ }, elements.map((el, i) => {
1311
+ const id = "source-unlink-" + i;
1312
+ return /*#__PURE__*/React.createElement("li", {
1313
+ className: "unlink-item",
1314
+ key: el.key
1315
+ }, /*#__PURE__*/React.createElement(Checkbox, {
1316
+ id: id,
1317
+ checked: selected.has(el.key),
1318
+ onChange: () => toggle(el.key)
1319
+ }), /*#__PURE__*/React.createElement(Label, {
1320
+ htmlFor: id,
1321
+ weight: "regular",
1322
+ className: "unlink-label"
1323
+ }, el.label));
1324
+ })))), /*#__PURE__*/React.createElement(Dialog.ContentDivider, null), /*#__PURE__*/React.createElement(Dialog.Actions, null, /*#__PURE__*/React.createElement(Button, {
1325
+ type: "button",
1326
+ variant: "primary",
1327
+ disabled: submitting,
1328
+ onClick: handleUnlink
1329
+ }, "Unlink"), /*#__PURE__*/React.createElement(Button, {
1330
+ type: "button",
1331
+ variant: "secondary",
1332
+ disabled: submitting,
1333
+ onClick: onClose
1334
+ }, "Cancel")));
1335
+ };
1336
+ const SourceCodeSection = _ref11 => {
1337
+ let _ref11$variant = _ref11.variant,
1338
+ variant = _ref11$variant === void 0 ? "mix" : _ref11$variant,
1339
+ issues = _ref11.issues,
1340
+ code = _ref11.code,
1341
+ _ref11$showHeader = _ref11.showHeader,
1342
+ showHeader = _ref11$showHeader === void 0 ? true : _ref11$showHeader,
1343
+ _ref11$showLink = _ref11.showLink,
1344
+ showLink = _ref11$showLink === void 0 ? true : _ref11$showLink,
1345
+ _ref11$flush = _ref11.flush,
1346
+ flush = _ref11$flush === void 0 ? false : _ref11$flush;
1347
+ const _useState4 = useState(null),
1348
+ openEntry = _useState4[0],
1349
+ setOpenEntry = _useState4[1];
1350
+ const _useState5 = useState(false),
1351
+ completedExpanded = _useState5[0],
1352
+ setCompletedExpanded = _useState5[1];
1353
+ const _useState6 = useState(false),
1354
+ linkOpen = _useState6[0],
1355
+ setLinkOpen = _useState6[1];
1356
+ const _useState7 = useState(false),
1357
+ unlinkOpen = _useState7[0],
1358
+ setUnlinkOpen = _useState7[1];
1359
+ const _useState8 = useState(new Set()),
1360
+ removed = _useState8[0],
1361
+ setRemoved = _useState8[1];
1362
+ const issuesData = (issues != null ? issues : ISSUES).filter(i => !removed.has(issueElementKey(i)));
1363
+ const codeData = (code != null ? code : CODE_ENTRIES).filter(e => !removed.has(codeElementKey(e)));
1250
1364
  const openIssues = issuesData.filter(i => !issueCompleted(i)).sort(byRecency);
1251
1365
  const openCode = codeData.filter(e => !codeCompleted(e)).sort(byRecency);
1252
1366
  const completed = [...issuesData.filter(issueCompleted).map(issue => ({
@@ -1268,13 +1382,41 @@ const SourceCodeSection = _ref10 => {
1268
1382
  // In the "completed" variant there is no collapsible header and everything is
1269
1383
  // shown; in "mix" the section is collapsed by default.
1270
1384
  const completedVisible = variant === "completed" ? true : completedExpanded;
1385
+ const hasRows = openIssues.length > 0 || openCode.length > 0 || completed.length > 0;
1386
+
1387
+ // Every linked element, sorted by name, for the Unlink dialog.
1388
+ const unlinkElements = [...issuesData.map(i => ({
1389
+ key: issueElementKey(i),
1390
+ label: i.title
1391
+ })), ...codeData.map(e => ({
1392
+ key: codeElementKey(e),
1393
+ label: e.title
1394
+ }))].sort((a, b) => a.label.localeCompare(b.label));
1395
+ const handleUnlinkConfirm = async keys => {
1396
+ await mockUnlinkRequest();
1397
+ if (keys.length > 0) {
1398
+ setRemoved(prev => {
1399
+ const next = new Set(Array.from(prev));
1400
+ keys.forEach(key => next.add(key));
1401
+ return next;
1402
+ });
1403
+ }
1404
+ setUnlinkOpen(false);
1405
+ };
1271
1406
  return /*#__PURE__*/React.createElement(StyledSourceCode, {
1272
1407
  $flush: flush
1273
- }, showHeader && /*#__PURE__*/React.createElement("div", {
1408
+ }, showHeader && hasRows && /*#__PURE__*/React.createElement("div", {
1274
1409
  className: "sc-header"
1275
1410
  }, /*#__PURE__*/React.createElement(Body1, {
1276
1411
  weight: "bold"
1277
- }, "Source Code"), /*#__PURE__*/React.createElement(LinkingCommandsButton, null)), showOpen && openIssues.map(issue => /*#__PURE__*/React.createElement("div", {
1412
+ }, "Source Code"), /*#__PURE__*/React.createElement("div", {
1413
+ className: "sc-header-actions"
1414
+ }, /*#__PURE__*/React.createElement(LinkingCommandsButton, null), showLink && /*#__PURE__*/React.createElement(UnlinkTriggerButton, {
1415
+ type: "button",
1416
+ variant: "secondary",
1417
+ size: "small",
1418
+ onClick: () => setUnlinkOpen(true)
1419
+ }, "Unlink"))), showOpen && openIssues.map(issue => /*#__PURE__*/React.createElement("div", {
1278
1420
  className: "sc-item",
1279
1421
  key: issue.ref
1280
1422
  }, /*#__PURE__*/React.createElement(IssueRow, {
@@ -1300,12 +1442,17 @@ const SourceCodeSection = _ref10 => {
1300
1442
  marginLeft: -4
1301
1443
  },
1302
1444
  onClick: () => setLinkOpen(true)
1303
- })), /*#__PURE__*/React.createElement(HistoryDialog, {
1445
+ }), showHeader && !hasRows && /*#__PURE__*/React.createElement(LinkingCommandsButton, null)), /*#__PURE__*/React.createElement(HistoryDialog, {
1304
1446
  entry: openEntry,
1305
1447
  onClose: () => setOpenEntry(null)
1306
1448
  }), /*#__PURE__*/React.createElement(LinkBranchOrPullRequestDialog, {
1307
1449
  open: linkOpen,
1308
1450
  onClose: () => setLinkOpen(false)
1451
+ }), /*#__PURE__*/React.createElement(UnlinkDialog, {
1452
+ open: unlinkOpen,
1453
+ elements: unlinkElements,
1454
+ onClose: () => setUnlinkOpen(false),
1455
+ onConfirm: handleUnlinkConfirm
1309
1456
  }));
1310
1457
  };
1311
1458
  export { Spine, HistoryDialog, IssueRow, CodeRow, CompletedHeader, SourceCodeSection };