@ordinatio/ui 1.8.0 → 1.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +15 -0
- package/README.md +54 -0
- package/dist/board-dnd.d.mts +111 -0
- package/dist/board-dnd.mjs +208 -0
- package/dist/board-types-D8JR0lN4.d.mts +182 -0
- package/dist/index.d.mts +185 -1
- package/dist/index.mjs +733 -78
- package/package.json +19 -2
package/dist/index.mjs
CHANGED
|
@@ -1005,6 +1005,48 @@ function TrashedBanner({ since, by, restore, formatDate: formatDate2 = formatTra
|
|
|
1005
1005
|
] });
|
|
1006
1006
|
}
|
|
1007
1007
|
|
|
1008
|
+
// src/components/pager.tsx
|
|
1009
|
+
import { jsx as jsx10, jsxs as jsxs9 } from "react/jsx-runtime";
|
|
1010
|
+
var defaults6 = {
|
|
1011
|
+
root: { display: "flex", alignItems: "center", justifyContent: "space-between", marginTop: "16px", fontSize: "14px" },
|
|
1012
|
+
links: { display: "flex", gap: "12px" }
|
|
1013
|
+
};
|
|
1014
|
+
var DEFAULT_SHOWING = "Showing {start} to {end} of {total}";
|
|
1015
|
+
var whole = (value, fallback) => Number.isFinite(value) ? Math.floor(value) : fallback;
|
|
1016
|
+
var PlainLink = ({ href, className, children }) => /* @__PURE__ */ jsx10("a", { href, className, children });
|
|
1017
|
+
function Pager({
|
|
1018
|
+
total: rawTotal,
|
|
1019
|
+
page: rawPage,
|
|
1020
|
+
pageSize: rawSize,
|
|
1021
|
+
hrefs,
|
|
1022
|
+
LinkComponent = PlainLink,
|
|
1023
|
+
classNames,
|
|
1024
|
+
labels,
|
|
1025
|
+
hideWhenSinglePage = true
|
|
1026
|
+
}) {
|
|
1027
|
+
const total = Math.max(0, whole(rawTotal, 0));
|
|
1028
|
+
const size = Math.max(1, whole(rawSize, 1));
|
|
1029
|
+
if (total === 0) return null;
|
|
1030
|
+
if (hideWhenSinglePage && total <= size) return null;
|
|
1031
|
+
const lastPage = Math.max(1, Math.ceil(total / size));
|
|
1032
|
+
const page = Math.min(lastPage, Math.max(1, whole(rawPage, 1)));
|
|
1033
|
+
const trusted = rawPage === page;
|
|
1034
|
+
const rangeStart = (page - 1) * size + 1;
|
|
1035
|
+
const rangeEnd = Math.min(page * size, total);
|
|
1036
|
+
const hasPrev = trusted && page > 1;
|
|
1037
|
+
const hasNext = trusted && rangeEnd < total;
|
|
1038
|
+
const text = (labels?.showing ?? DEFAULT_SHOWING).replace(/\{start\}/g, String(rangeStart)).replace(/\{end\}/g, String(rangeEnd)).replace(/\{total\}/g, String(total));
|
|
1039
|
+
const rootProps = classNames?.root ? { className: classNames.root } : { style: defaults6.root };
|
|
1040
|
+
const linksProps = classNames?.links ? { className: classNames.links } : { style: defaults6.links };
|
|
1041
|
+
return /* @__PURE__ */ jsxs9("div", { ...rootProps, children: [
|
|
1042
|
+
/* @__PURE__ */ jsx10("span", { className: classNames?.summary, children: text }),
|
|
1043
|
+
/* @__PURE__ */ jsxs9("div", { ...linksProps, children: [
|
|
1044
|
+
hasPrev ? /* @__PURE__ */ jsx10(LinkComponent, { href: hrefs.previous, className: classNames?.link, children: labels?.previous ?? "\u2190 Previous" }) : null,
|
|
1045
|
+
hasNext ? /* @__PURE__ */ jsx10(LinkComponent, { href: hrefs.next, className: classNames?.link, children: labels?.next ?? "Next \u2192" }) : null
|
|
1046
|
+
] })
|
|
1047
|
+
] });
|
|
1048
|
+
}
|
|
1049
|
+
|
|
1008
1050
|
// src/components/show-once-secret.tsx
|
|
1009
1051
|
import { useEffect as useEffect5 } from "react";
|
|
1010
1052
|
|
|
@@ -1058,8 +1100,8 @@ function useCopyToClipboard(options = {}) {
|
|
|
1058
1100
|
}
|
|
1059
1101
|
|
|
1060
1102
|
// src/components/show-once-secret.tsx
|
|
1061
|
-
import { jsx as
|
|
1062
|
-
var
|
|
1103
|
+
import { jsx as jsx11, jsxs as jsxs10 } from "react/jsx-runtime";
|
|
1104
|
+
var defaults7 = {
|
|
1063
1105
|
root: { display: "flex", flexDirection: "column", gap: "8px", padding: "12px 16px", border: "1px solid #fcd34d", borderRadius: "6px", backgroundColor: "#fffbeb" },
|
|
1064
1106
|
title: { margin: 0, fontSize: "14px", fontWeight: 500, color: "#78350f" },
|
|
1065
1107
|
warning: { fontWeight: 400 },
|
|
@@ -1076,18 +1118,18 @@ function ShowOnceSecret({ secret, title, onDone, display = "text", secretTestId,
|
|
|
1076
1118
|
}, [secret, reset]);
|
|
1077
1119
|
const part = (key) => {
|
|
1078
1120
|
const className = classNames?.[key];
|
|
1079
|
-
return className ? { className } : { style:
|
|
1121
|
+
return className ? { className } : { style: defaults7[key] };
|
|
1080
1122
|
};
|
|
1081
|
-
return /* @__PURE__ */
|
|
1082
|
-
/* @__PURE__ */
|
|
1123
|
+
return /* @__PURE__ */ jsxs10("div", { ...part("root"), children: [
|
|
1124
|
+
/* @__PURE__ */ jsxs10("p", { ...part("title"), children: [
|
|
1083
1125
|
title,
|
|
1084
1126
|
" ",
|
|
1085
|
-
/* @__PURE__ */
|
|
1127
|
+
/* @__PURE__ */ jsx11("span", { ...part("warning"), children: labels?.warning ?? "Copy it now: you will not see it again." })
|
|
1086
1128
|
] }),
|
|
1087
|
-
display === "field" ? /* @__PURE__ */
|
|
1088
|
-
/* @__PURE__ */
|
|
1089
|
-
/* @__PURE__ */
|
|
1090
|
-
/* @__PURE__ */
|
|
1129
|
+
display === "field" ? /* @__PURE__ */ jsx11("input", { readOnly: true, value: secret, "aria-label": labels?.secret ?? "Secret", "data-testid": secretTestId, onFocus: (event) => event.currentTarget.select(), ...part("secret") }) : /* @__PURE__ */ jsx11("code", { "data-testid": secretTestId, ...part("secret"), children: secret }),
|
|
1130
|
+
/* @__PURE__ */ jsxs10("div", { ...part("actions"), children: [
|
|
1131
|
+
/* @__PURE__ */ jsx11("button", { type: "button", onClick: () => void copy(secret), ...part("copy"), children: labels?.copy ?? "Copy" }),
|
|
1132
|
+
/* @__PURE__ */ jsx11(
|
|
1091
1133
|
"button",
|
|
1092
1134
|
{
|
|
1093
1135
|
type: "button",
|
|
@@ -1099,7 +1141,7 @@ function ShowOnceSecret({ secret, title, onDone, display = "text", secretTestId,
|
|
|
1099
1141
|
children: labels?.done ?? "Done"
|
|
1100
1142
|
}
|
|
1101
1143
|
),
|
|
1102
|
-
/* @__PURE__ */
|
|
1144
|
+
/* @__PURE__ */ jsx11("span", { role: "status", "data-status": status ?? void 0, ...part("note"), children: note })
|
|
1103
1145
|
] }),
|
|
1104
1146
|
children
|
|
1105
1147
|
] });
|
|
@@ -1107,8 +1149,8 @@ function ShowOnceSecret({ secret, title, onDone, display = "text", secretTestId,
|
|
|
1107
1149
|
|
|
1108
1150
|
// src/components/entity-picker.tsx
|
|
1109
1151
|
import { useCallback as useCallback4, useEffect as useEffect6, useId as useId2, useRef as useRef5, useState as useState7 } from "react";
|
|
1110
|
-
import { jsx as
|
|
1111
|
-
var
|
|
1152
|
+
import { jsx as jsx12, jsxs as jsxs11 } from "react/jsx-runtime";
|
|
1153
|
+
var defaults8 = {
|
|
1112
1154
|
root: { position: "relative", display: "inline-flex", alignItems: "center", gap: "4px", width: "100%" },
|
|
1113
1155
|
input: { flex: 1, minWidth: 0, padding: "8px 10px", fontSize: "14px", border: "1px solid #d4d4d4", borderRadius: "6px", backgroundColor: "#ffffff", color: "#171717" },
|
|
1114
1156
|
clear: { padding: "4px 8px", fontSize: "14px", border: "1px solid transparent", borderRadius: "6px", backgroundColor: "transparent", color: "#525252", cursor: "pointer" },
|
|
@@ -1255,7 +1297,7 @@ function EntityPicker({
|
|
|
1255
1297
|
const partProps = (key) => {
|
|
1256
1298
|
const className = classNames?.[key];
|
|
1257
1299
|
if (className) return { className, style: key === "root" ? style : void 0 };
|
|
1258
|
-
return { style: key === "root" ? { ...
|
|
1300
|
+
return { style: key === "root" ? { ...defaults8.root, ...style } : defaults8[key] };
|
|
1259
1301
|
};
|
|
1260
1302
|
const optionProps = (active) => {
|
|
1261
1303
|
const optionClass = classNames?.option;
|
|
@@ -1264,8 +1306,8 @@ function EntityPicker({
|
|
|
1264
1306
|
return { className, style: optionClass ? void 0 : { ...optionDefaults.base, ...active && !activeClass ? optionDefaults.active : {} } };
|
|
1265
1307
|
};
|
|
1266
1308
|
const shown = editing ? text : value ? getLabel(value) : "";
|
|
1267
|
-
return /* @__PURE__ */
|
|
1268
|
-
/* @__PURE__ */
|
|
1309
|
+
return /* @__PURE__ */ jsxs11("div", { ...partProps("root"), children: [
|
|
1310
|
+
/* @__PURE__ */ jsx12(
|
|
1269
1311
|
"input",
|
|
1270
1312
|
{
|
|
1271
1313
|
...partProps("input"),
|
|
@@ -1297,19 +1339,19 @@ function EntityPicker({
|
|
|
1297
1339
|
}
|
|
1298
1340
|
}
|
|
1299
1341
|
),
|
|
1300
|
-
name !== void 0 ? /* @__PURE__ */
|
|
1301
|
-
clearable && value && !disabled ? /* @__PURE__ */
|
|
1342
|
+
name !== void 0 ? /* @__PURE__ */ jsx12("input", { type: "hidden", name, value: value ? getKey(value) : "", disabled }) : null,
|
|
1343
|
+
clearable && value && !disabled ? /* @__PURE__ */ jsx12("button", { type: "button", "aria-label": clearLabel, ...partProps("clear"), onClick: () => {
|
|
1302
1344
|
onChange(null);
|
|
1303
1345
|
inputRef.current?.focus();
|
|
1304
1346
|
}, children: "\xD7" }) : null,
|
|
1305
|
-
/* @__PURE__ */
|
|
1347
|
+
/* @__PURE__ */ jsx12("div", { role: "status", "aria-live": "polite", style: visuallyHidden2, children: announcement }),
|
|
1306
1348
|
showPopup ? (
|
|
1307
1349
|
// mousedown anywhere in the popup (an option, the scrollbar, a message) must not move focus out of the input, or its
|
|
1308
1350
|
// blur would close the list before the click lands (and make a long list impossible to scroll by dragging)
|
|
1309
|
-
/* @__PURE__ */
|
|
1310
|
-
showListbox ? /* @__PURE__ */
|
|
1351
|
+
/* @__PURE__ */ jsxs11("div", { ...partProps("list"), onMouseDown: (event) => event.preventDefault(), children: [
|
|
1352
|
+
showListbox ? /* @__PURE__ */ jsx12("ul", { ref: listRef, id: listId, role: "listbox", "aria-label": ariaLabel, style: { listStyle: "none", margin: 0, padding: 0 }, children: results.map((item, index) => {
|
|
1311
1353
|
const active = index === activeIndex;
|
|
1312
|
-
return /* @__PURE__ */
|
|
1354
|
+
return /* @__PURE__ */ jsx12(
|
|
1313
1355
|
"li",
|
|
1314
1356
|
{
|
|
1315
1357
|
id: `${listId}-opt-${index}`,
|
|
@@ -1325,9 +1367,9 @@ function EntityPicker({
|
|
|
1325
1367
|
getKey(item)
|
|
1326
1368
|
);
|
|
1327
1369
|
}) }) : null,
|
|
1328
|
-
status === "loading" ? /* @__PURE__ */
|
|
1329
|
-
status === "error" ? /* @__PURE__ */
|
|
1330
|
-
status === "idle" && searched && results.length === 0 ? /* @__PURE__ */
|
|
1370
|
+
status === "loading" ? /* @__PURE__ */ jsx12("div", { "aria-hidden": "true", "data-entity-picker-message": "loading", ...partProps("message"), children: loadingText }) : null,
|
|
1371
|
+
status === "error" ? /* @__PURE__ */ jsx12("div", { "aria-hidden": "true", "data-entity-picker-message": "error", ...partProps("message"), children: errorText }) : null,
|
|
1372
|
+
status === "idle" && searched && results.length === 0 ? /* @__PURE__ */ jsx12("div", { "aria-hidden": "true", "data-entity-picker-message": "empty", ...partProps("message"), children: emptyText }) : null
|
|
1331
1373
|
] })
|
|
1332
1374
|
) : null
|
|
1333
1375
|
] });
|
|
@@ -1387,7 +1429,7 @@ var editableStyle = {
|
|
|
1387
1429
|
};
|
|
1388
1430
|
|
|
1389
1431
|
// src/components/rich-text-editor.tsx
|
|
1390
|
-
import { jsx as
|
|
1432
|
+
import { jsx as jsx13, jsxs as jsxs12 } from "react/jsx-runtime";
|
|
1391
1433
|
var TOOLBAR_BUTTONS = [
|
|
1392
1434
|
{ command: "bold", label: "B", ariaLabel: "Bold" },
|
|
1393
1435
|
{ command: "italic", label: "I", ariaLabel: "Italic" },
|
|
@@ -1457,7 +1499,7 @@ function RichTextEditor({
|
|
|
1457
1499
|
runCommand("createLink", url);
|
|
1458
1500
|
}, [runCommand]);
|
|
1459
1501
|
if (!editable) {
|
|
1460
|
-
return /* @__PURE__ */
|
|
1502
|
+
return /* @__PURE__ */ jsx13(
|
|
1461
1503
|
"div",
|
|
1462
1504
|
{
|
|
1463
1505
|
className: [className, "ordinatio-rte", "ordinatio-rte-readonly"].filter(Boolean).join(" "),
|
|
@@ -1466,9 +1508,9 @@ function RichTextEditor({
|
|
|
1466
1508
|
}
|
|
1467
1509
|
);
|
|
1468
1510
|
}
|
|
1469
|
-
return /* @__PURE__ */
|
|
1470
|
-
/* @__PURE__ */
|
|
1471
|
-
TOOLBAR_BUTTONS.map((btn) => /* @__PURE__ */
|
|
1511
|
+
return /* @__PURE__ */ jsxs12("div", { className: [className, "ordinatio-rte"].filter(Boolean).join(" "), style: className ? style : { ...containerStyle, ...style }, children: [
|
|
1512
|
+
/* @__PURE__ */ jsxs12("div", { className: "ordinatio-rte-toolbar", style: toolbarStyle, children: [
|
|
1513
|
+
TOOLBAR_BUTTONS.map((btn) => /* @__PURE__ */ jsx13(
|
|
1472
1514
|
"button",
|
|
1473
1515
|
{
|
|
1474
1516
|
type: "button",
|
|
@@ -1482,7 +1524,7 @@ function RichTextEditor({
|
|
|
1482
1524
|
},
|
|
1483
1525
|
btn.command
|
|
1484
1526
|
)),
|
|
1485
|
-
/* @__PURE__ */
|
|
1527
|
+
/* @__PURE__ */ jsx13(
|
|
1486
1528
|
"button",
|
|
1487
1529
|
{
|
|
1488
1530
|
type: "button",
|
|
@@ -1495,10 +1537,10 @@ function RichTextEditor({
|
|
|
1495
1537
|
children: "\u{1F517}"
|
|
1496
1538
|
}
|
|
1497
1539
|
),
|
|
1498
|
-
toolbarRight ? /* @__PURE__ */
|
|
1540
|
+
toolbarRight ? /* @__PURE__ */ jsx13("div", { className: "ordinatio-rte-toolbar-right", style: toolbarRightStyle, children: toolbarRight }) : null
|
|
1499
1541
|
] }),
|
|
1500
|
-
linkError ? /* @__PURE__ */
|
|
1501
|
-
/* @__PURE__ */
|
|
1542
|
+
linkError ? /* @__PURE__ */ jsx13("div", { className: "ordinatio-rte-link-error", role: "alert", style: linkErrorStyle, children: linkError }) : null,
|
|
1543
|
+
/* @__PURE__ */ jsxs12("div", { className: "ordinatio-rte-editable-wrap", style: { position: "relative" }, children: [
|
|
1502
1544
|
isEmpty ? (
|
|
1503
1545
|
// Shown while empty REGARDLESS of focus — WorldClass cycle 1:
|
|
1504
1546
|
// the prior `isEmpty && !isFocused` condition hid the
|
|
@@ -1507,7 +1549,7 @@ function RichTextEditor({
|
|
|
1507
1549
|
// the click landed. Matches native `<textarea placeholder>`
|
|
1508
1550
|
// behavior (visible while focused-and-empty, removed only once
|
|
1509
1551
|
// the user types).
|
|
1510
|
-
/* @__PURE__ */
|
|
1552
|
+
/* @__PURE__ */ jsx13(
|
|
1511
1553
|
"div",
|
|
1512
1554
|
{
|
|
1513
1555
|
"aria-hidden": "true",
|
|
@@ -1517,7 +1559,7 @@ function RichTextEditor({
|
|
|
1517
1559
|
}
|
|
1518
1560
|
)
|
|
1519
1561
|
) : null,
|
|
1520
|
-
/* @__PURE__ */
|
|
1562
|
+
/* @__PURE__ */ jsx13(
|
|
1521
1563
|
"div",
|
|
1522
1564
|
{
|
|
1523
1565
|
ref: editorRef,
|
|
@@ -1629,7 +1671,7 @@ var disabledButtonStyle = {
|
|
|
1629
1671
|
};
|
|
1630
1672
|
|
|
1631
1673
|
// src/components/reply-panel.tsx
|
|
1632
|
-
import { Fragment as Fragment3, jsx as
|
|
1674
|
+
import { Fragment as Fragment3, jsx as jsx14, jsxs as jsxs13 } from "react/jsx-runtime";
|
|
1633
1675
|
function ReplyPanel({
|
|
1634
1676
|
mode = "reply",
|
|
1635
1677
|
subject,
|
|
@@ -1708,16 +1750,16 @@ function ReplyPanel({
|
|
|
1708
1750
|
if (isMountedRef.current) setSending(false);
|
|
1709
1751
|
}
|
|
1710
1752
|
};
|
|
1711
|
-
return /* @__PURE__ */
|
|
1753
|
+
return /* @__PURE__ */ jsxs13(
|
|
1712
1754
|
"div",
|
|
1713
1755
|
{
|
|
1714
1756
|
className: [className, "ordinatio-reply-panel"].filter(Boolean).join(" "),
|
|
1715
1757
|
style: className ? style : { display: "flex", flexDirection: "column", gap: "8px", ...style },
|
|
1716
1758
|
children: [
|
|
1717
|
-
/* @__PURE__ */
|
|
1718
|
-
/* @__PURE__ */
|
|
1719
|
-
/* @__PURE__ */
|
|
1720
|
-
/* @__PURE__ */
|
|
1759
|
+
/* @__PURE__ */ jsxs13("div", { className: "ordinatio-reply-fields", style: { display: "flex", flexDirection: "column", gap: "6px" }, children: [
|
|
1760
|
+
/* @__PURE__ */ jsxs13("div", { className: "ordinatio-reply-field-row", style: fieldRowStyle, children: [
|
|
1761
|
+
/* @__PURE__ */ jsx14("label", { htmlFor: toId, className: "ordinatio-reply-field-label", style: fieldLabelStyle, children: "To" }),
|
|
1762
|
+
/* @__PURE__ */ jsx14(
|
|
1721
1763
|
"input",
|
|
1722
1764
|
{
|
|
1723
1765
|
id: toId,
|
|
@@ -1745,7 +1787,7 @@ function ReplyPanel({
|
|
|
1745
1787
|
// and aria-controls referenced ids (ccId/bccId) that don't
|
|
1746
1788
|
// exist in the DOM until AFTER this button has already
|
|
1747
1789
|
// unmounted. A one-directional reveal, not a toggle.
|
|
1748
|
-
/* @__PURE__ */
|
|
1790
|
+
/* @__PURE__ */ jsx14(
|
|
1749
1791
|
"button",
|
|
1750
1792
|
{
|
|
1751
1793
|
type: "button",
|
|
@@ -1758,10 +1800,10 @@ function ReplyPanel({
|
|
|
1758
1800
|
)
|
|
1759
1801
|
) : null
|
|
1760
1802
|
] }),
|
|
1761
|
-
showCcBcc ? /* @__PURE__ */
|
|
1762
|
-
/* @__PURE__ */
|
|
1763
|
-
/* @__PURE__ */
|
|
1764
|
-
/* @__PURE__ */
|
|
1803
|
+
showCcBcc ? /* @__PURE__ */ jsxs13(Fragment3, { children: [
|
|
1804
|
+
/* @__PURE__ */ jsxs13("div", { className: "ordinatio-reply-field-row", style: fieldRowStyle, children: [
|
|
1805
|
+
/* @__PURE__ */ jsx14("label", { htmlFor: ccId, className: "ordinatio-reply-field-label", style: fieldLabelStyle, children: "Cc" }),
|
|
1806
|
+
/* @__PURE__ */ jsx14(
|
|
1765
1807
|
"input",
|
|
1766
1808
|
{
|
|
1767
1809
|
id: ccId,
|
|
@@ -1779,9 +1821,9 @@ function ReplyPanel({
|
|
|
1779
1821
|
}
|
|
1780
1822
|
)
|
|
1781
1823
|
] }),
|
|
1782
|
-
/* @__PURE__ */
|
|
1783
|
-
/* @__PURE__ */
|
|
1784
|
-
/* @__PURE__ */
|
|
1824
|
+
/* @__PURE__ */ jsxs13("div", { className: "ordinatio-reply-field-row", style: fieldRowStyle, children: [
|
|
1825
|
+
/* @__PURE__ */ jsx14("label", { htmlFor: bccId, className: "ordinatio-reply-field-label", style: fieldLabelStyle, children: "Bcc" }),
|
|
1826
|
+
/* @__PURE__ */ jsx14(
|
|
1785
1827
|
"input",
|
|
1786
1828
|
{
|
|
1787
1829
|
id: bccId,
|
|
@@ -1800,9 +1842,9 @@ function ReplyPanel({
|
|
|
1800
1842
|
)
|
|
1801
1843
|
] })
|
|
1802
1844
|
] }) : null,
|
|
1803
|
-
/* @__PURE__ */
|
|
1804
|
-
/* @__PURE__ */
|
|
1805
|
-
/* @__PURE__ */
|
|
1845
|
+
/* @__PURE__ */ jsxs13("div", { className: "ordinatio-reply-field-row", style: fieldRowStyle, children: [
|
|
1846
|
+
/* @__PURE__ */ jsx14("label", { htmlFor: subjectId, className: "ordinatio-reply-field-label", style: fieldLabelStyle, children: "Subject" }),
|
|
1847
|
+
/* @__PURE__ */ jsx14(
|
|
1806
1848
|
"input",
|
|
1807
1849
|
{
|
|
1808
1850
|
id: subjectId,
|
|
@@ -1821,9 +1863,9 @@ function ReplyPanel({
|
|
|
1821
1863
|
)
|
|
1822
1864
|
] })
|
|
1823
1865
|
] }),
|
|
1824
|
-
error ? /* @__PURE__ */
|
|
1825
|
-
sent && resolvedSuccessMessage ? /* @__PURE__ */
|
|
1826
|
-
/* @__PURE__ */
|
|
1866
|
+
error ? /* @__PURE__ */ jsx14("div", { className: "ordinatio-reply-error", role: "alert", style: errorStyle, children: error }) : null,
|
|
1867
|
+
sent && resolvedSuccessMessage ? /* @__PURE__ */ jsx14("div", { className: "ordinatio-reply-success", role: "status", style: successStyle, children: resolvedSuccessMessage }) : null,
|
|
1868
|
+
/* @__PURE__ */ jsx14(
|
|
1827
1869
|
RichTextEditor,
|
|
1828
1870
|
{
|
|
1829
1871
|
content: body,
|
|
@@ -1837,8 +1879,8 @@ function ReplyPanel({
|
|
|
1837
1879
|
locked: sending
|
|
1838
1880
|
}
|
|
1839
1881
|
),
|
|
1840
|
-
/* @__PURE__ */
|
|
1841
|
-
showCancel && onCancel ? /* @__PURE__ */
|
|
1882
|
+
/* @__PURE__ */ jsxs13("div", { className: "ordinatio-reply-actions", style: actionsRowStyle, children: [
|
|
1883
|
+
showCancel && onCancel ? /* @__PURE__ */ jsx14(
|
|
1842
1884
|
"button",
|
|
1843
1885
|
{
|
|
1844
1886
|
type: "button",
|
|
@@ -1849,7 +1891,7 @@ function ReplyPanel({
|
|
|
1849
1891
|
children: "Cancel"
|
|
1850
1892
|
}
|
|
1851
1893
|
) : null,
|
|
1852
|
-
/* @__PURE__ */
|
|
1894
|
+
/* @__PURE__ */ jsx14(
|
|
1853
1895
|
"button",
|
|
1854
1896
|
{
|
|
1855
1897
|
type: "button",
|
|
@@ -2098,7 +2140,7 @@ function getShortcut(context, action) {
|
|
|
2098
2140
|
|
|
2099
2141
|
// src/components/keyboard-shortcuts-panel.tsx
|
|
2100
2142
|
import { useEffect as useEffect10, useState as useState10 } from "react";
|
|
2101
|
-
import { Fragment as Fragment4, jsx as
|
|
2143
|
+
import { Fragment as Fragment4, jsx as jsx15, jsxs as jsxs14 } from "react/jsx-runtime";
|
|
2102
2144
|
function KeyboardShortcutsPanel({
|
|
2103
2145
|
contexts = ALL_SHORTCUT_CONTEXTS
|
|
2104
2146
|
}) {
|
|
@@ -2120,33 +2162,33 @@ function KeyboardShortcutsPanel({
|
|
|
2120
2162
|
return () => window.removeEventListener("keydown", handleKey);
|
|
2121
2163
|
}, [open]);
|
|
2122
2164
|
if (!open) return null;
|
|
2123
|
-
return /* @__PURE__ */
|
|
2124
|
-
/* @__PURE__ */
|
|
2165
|
+
return /* @__PURE__ */ jsxs14(Fragment4, { children: [
|
|
2166
|
+
/* @__PURE__ */ jsx15(
|
|
2125
2167
|
"div",
|
|
2126
2168
|
{
|
|
2127
2169
|
className: "fixed inset-0 z-50 bg-black/50 backdrop-blur-sm",
|
|
2128
2170
|
onClick: () => setOpen(false)
|
|
2129
2171
|
}
|
|
2130
2172
|
),
|
|
2131
|
-
/* @__PURE__ */
|
|
2132
|
-
/* @__PURE__ */
|
|
2133
|
-
/* @__PURE__ */
|
|
2134
|
-
/* @__PURE__ */
|
|
2173
|
+
/* @__PURE__ */ jsx15("div", { className: "fixed inset-x-0 top-[10%] z-50 mx-auto w-full max-w-lg", children: /* @__PURE__ */ jsxs14("div", { className: "rounded-xl border bg-background shadow-2xl overflow-hidden", children: [
|
|
2174
|
+
/* @__PURE__ */ jsxs14("div", { className: "px-6 py-4 border-b", children: [
|
|
2175
|
+
/* @__PURE__ */ jsx15("h2", { className: "text-lg font-semibold", children: "Keyboard Shortcuts" }),
|
|
2176
|
+
/* @__PURE__ */ jsxs14("p", { className: "text-sm text-muted-foreground mt-0.5", children: [
|
|
2135
2177
|
"Press ",
|
|
2136
|
-
/* @__PURE__ */
|
|
2178
|
+
/* @__PURE__ */ jsx15("kbd", { className: "px-1.5 py-0.5 bg-muted rounded text-xs font-mono", children: "?" }),
|
|
2137
2179
|
" to toggle this panel"
|
|
2138
2180
|
] })
|
|
2139
2181
|
] }),
|
|
2140
|
-
/* @__PURE__ */
|
|
2141
|
-
/* @__PURE__ */
|
|
2142
|
-
/* @__PURE__ */
|
|
2143
|
-
/* @__PURE__ */
|
|
2144
|
-
/* @__PURE__ */
|
|
2182
|
+
/* @__PURE__ */ jsx15("div", { className: "px-6 py-4 max-h-[60vh] overflow-y-auto space-y-6", children: contexts.map((ctx) => /* @__PURE__ */ jsxs14("div", { children: [
|
|
2183
|
+
/* @__PURE__ */ jsx15("h3", { className: "text-xs font-semibold text-muted-foreground uppercase tracking-wide mb-2", children: ctx.label }),
|
|
2184
|
+
/* @__PURE__ */ jsx15("div", { className: "space-y-1", children: Object.entries(ctx.shortcuts).map(([key, def]) => /* @__PURE__ */ jsxs14("div", { className: "flex items-center justify-between py-1", children: [
|
|
2185
|
+
/* @__PURE__ */ jsx15("span", { className: "text-sm", children: def.description }),
|
|
2186
|
+
/* @__PURE__ */ jsx15("kbd", { className: "px-2 py-0.5 bg-muted rounded text-xs font-mono min-w-[2rem] text-center", children: def.display })
|
|
2145
2187
|
] }, key)) })
|
|
2146
2188
|
] }, ctx.name)) }),
|
|
2147
|
-
/* @__PURE__ */
|
|
2189
|
+
/* @__PURE__ */ jsxs14("div", { className: "px-6 py-3 border-t bg-muted/30 text-xs text-muted-foreground text-center", children: [
|
|
2148
2190
|
"Press ",
|
|
2149
|
-
/* @__PURE__ */
|
|
2191
|
+
/* @__PURE__ */ jsx15("kbd", { className: "px-1 py-0.5 bg-muted rounded", children: "Esc" }),
|
|
2150
2192
|
" to close"
|
|
2151
2193
|
] })
|
|
2152
2194
|
] }) })
|
|
@@ -2633,9 +2675,9 @@ function clearCache() {
|
|
|
2633
2675
|
import { useState as useState19, useEffect as useEffect18, useCallback as useCallback11 } from "react";
|
|
2634
2676
|
function usePreferences({
|
|
2635
2677
|
endpoint,
|
|
2636
|
-
defaults:
|
|
2678
|
+
defaults: defaults9
|
|
2637
2679
|
}) {
|
|
2638
|
-
const [preferences, setPreferences] = useState19(
|
|
2680
|
+
const [preferences, setPreferences] = useState19(defaults9 ?? null);
|
|
2639
2681
|
const [loading, setLoading] = useState19(true);
|
|
2640
2682
|
const [error, setError] = useState19(null);
|
|
2641
2683
|
const fetchPreferences = useCallback11(async () => {
|
|
@@ -2644,7 +2686,7 @@ function usePreferences({
|
|
|
2644
2686
|
const res = await fetch(endpoint);
|
|
2645
2687
|
if (!res.ok) {
|
|
2646
2688
|
if (res.status === 401) {
|
|
2647
|
-
setPreferences(
|
|
2689
|
+
setPreferences(defaults9 ?? null);
|
|
2648
2690
|
return;
|
|
2649
2691
|
}
|
|
2650
2692
|
throw new Error("Failed to fetch preferences");
|
|
@@ -2656,7 +2698,7 @@ function usePreferences({
|
|
|
2656
2698
|
} finally {
|
|
2657
2699
|
setLoading(false);
|
|
2658
2700
|
}
|
|
2659
|
-
}, [endpoint,
|
|
2701
|
+
}, [endpoint, defaults9]);
|
|
2660
2702
|
useEffect18(() => {
|
|
2661
2703
|
fetchPreferences();
|
|
2662
2704
|
}, [fetchPreferences]);
|
|
@@ -3011,16 +3053,623 @@ var ACTIVITY_ICONS = {
|
|
|
3011
3053
|
function resolveActivityIcon(name) {
|
|
3012
3054
|
return ACTIVITY_ICONS[name] ?? Activity;
|
|
3013
3055
|
}
|
|
3056
|
+
|
|
3057
|
+
// src/components/pipeline-board.tsx
|
|
3058
|
+
import { useEffect as useEffect22, useMemo as useMemo2, useRef as useRef19, useState as useState24 } from "react";
|
|
3059
|
+
|
|
3060
|
+
// src/lib/board-scroll.ts
|
|
3061
|
+
function nearestColumnIndex(scrollLeft, offsets) {
|
|
3062
|
+
if (offsets.length === 0) return 0;
|
|
3063
|
+
const at = Number.isFinite(scrollLeft) && scrollLeft > 0 ? scrollLeft : 0;
|
|
3064
|
+
let best = 0;
|
|
3065
|
+
let bestDistance = Math.abs((offsets[0] ?? 0) - at);
|
|
3066
|
+
for (let i = 1; i < offsets.length; i++) {
|
|
3067
|
+
const distance = Math.abs((offsets[i] ?? 0) - at);
|
|
3068
|
+
if (distance < bestDistance) {
|
|
3069
|
+
best = i;
|
|
3070
|
+
bestDistance = distance;
|
|
3071
|
+
}
|
|
3072
|
+
}
|
|
3073
|
+
return best;
|
|
3074
|
+
}
|
|
3075
|
+
|
|
3076
|
+
// src/components/board-column.tsx
|
|
3077
|
+
import { useId as useId5 } from "react";
|
|
3078
|
+
|
|
3079
|
+
// src/components/add-card-box.tsx
|
|
3080
|
+
import { useEffect as useEffect19, useId as useId4, useRef as useRef16, useState as useState20 } from "react";
|
|
3081
|
+
|
|
3082
|
+
// src/components/board-styles.ts
|
|
3083
|
+
var STRUCTURE = {
|
|
3084
|
+
root: { maxWidth: "100%", minWidth: 0, overflow: "hidden" },
|
|
3085
|
+
row: { display: "flex", alignItems: "flex-start", gap: "12px", overflowX: "auto", overflowY: "hidden", scrollSnapType: "x mandatory", overscrollBehaviorX: "contain", maxWidth: "100%", boxSizing: "border-box" },
|
|
3086
|
+
// About 85% of the screen on a phone (so the next column peeks in), at most 22rem on a wide screen.
|
|
3087
|
+
column: { flex: "0 0 min(85vw, 22rem)", scrollSnapAlign: "start", minWidth: 0, boxSizing: "border-box" },
|
|
3088
|
+
cardList: { listStyle: "none", margin: 0, padding: 0, display: "flex", flexDirection: "column", gap: "8px" },
|
|
3089
|
+
card: { minWidth: 0, overflowWrap: "anywhere" }
|
|
3090
|
+
};
|
|
3091
|
+
var LOOK = {
|
|
3092
|
+
root: { fontSize: "16px", color: "#171717" },
|
|
3093
|
+
position: { margin: "0 0 8px", fontSize: "16px", color: "#525252" },
|
|
3094
|
+
column: { background: "#f4f4f5", borderRadius: "12px", padding: "12px" },
|
|
3095
|
+
columnDropOver: { background: "#e0e7ff" },
|
|
3096
|
+
columnHeader: { display: "flex", flexWrap: "wrap", alignItems: "baseline", gap: "4px 8px", marginBottom: "8px" },
|
|
3097
|
+
columnName: { margin: 0, fontSize: "18px", fontWeight: 700 },
|
|
3098
|
+
columnCount: { fontSize: "16px", color: "#525252" },
|
|
3099
|
+
columnTotals: { width: "100%", margin: 0, fontSize: "16px", color: "#404040" },
|
|
3100
|
+
empty: { margin: "8px 0", fontSize: "16px", color: "#525252" },
|
|
3101
|
+
card: { background: "#ffffff", borderRadius: "8px", padding: "12px", boxShadow: "0 1px 3px rgba(0,0,0,0.2)", fontSize: "16px" },
|
|
3102
|
+
cardPending: { opacity: 0.55 },
|
|
3103
|
+
cardDragging: { opacity: 0.4 },
|
|
3104
|
+
cardTitle: { margin: 0, fontSize: "16px", fontWeight: 600 },
|
|
3105
|
+
cardMeta: { margin: "4px 0 0", fontSize: "16px", color: "#404040" },
|
|
3106
|
+
overdue: { color: "#b91c1c", fontWeight: 700 },
|
|
3107
|
+
ownerMark: { display: "inline-flex", alignItems: "center", justifyContent: "center", minWidth: "28px", height: "28px", borderRadius: "14px", background: "#e5e5e5", fontSize: "14px", fontWeight: 700 },
|
|
3108
|
+
tagChip: { display: "inline-block", padding: "2px 8px", borderRadius: "999px", background: "#e5e7eb", fontSize: "14px" },
|
|
3109
|
+
badgeWon: { display: "inline-block", padding: "2px 8px", borderRadius: "6px", background: "#dcfce7", color: "#166534", fontSize: "14px", fontWeight: 700 },
|
|
3110
|
+
badgeLost: { display: "inline-block", padding: "2px 8px", borderRadius: "6px", background: "#fee2e2", color: "#991b1b", fontSize: "14px", fontWeight: 700 },
|
|
3111
|
+
cardError: { margin: "8px 0 0", fontSize: "16px", color: "#b91c1c" },
|
|
3112
|
+
showMore: { marginTop: "8px", minHeight: "44px", padding: "8px 12px", fontSize: "16px", border: "1px solid #d4d4d4", borderRadius: "8px", background: "#ffffff", cursor: "pointer" },
|
|
3113
|
+
addButton: { marginTop: "8px", minHeight: "44px", width: "100%", textAlign: "left", padding: "8px 12px", fontSize: "16px", border: "1px dashed #a3a3a3", borderRadius: "8px", background: "transparent", color: "#404040", cursor: "pointer" },
|
|
3114
|
+
addForm: { marginTop: "8px", display: "flex", flexDirection: "column", gap: "8px" },
|
|
3115
|
+
input: { minHeight: "44px", padding: "8px 12px", fontSize: "16px", border: "1px solid #a3a3a3", borderRadius: "8px", boxSizing: "border-box", width: "100%" },
|
|
3116
|
+
select: { minHeight: "44px", padding: "8px 12px", fontSize: "16px", border: "1px solid #a3a3a3", borderRadius: "8px", background: "#ffffff" },
|
|
3117
|
+
primaryButton: { minHeight: "44px", padding: "8px 16px", fontSize: "16px", border: "1px solid #1d4ed8", borderRadius: "8px", background: "#1d4ed8", color: "#ffffff", cursor: "pointer" },
|
|
3118
|
+
secondaryButton: { minHeight: "44px", padding: "8px 16px", fontSize: "16px", border: "1px solid #a3a3a3", borderRadius: "8px", background: "#ffffff", color: "#171717", cursor: "pointer" },
|
|
3119
|
+
error: { margin: 0, fontSize: "16px", color: "#b91c1c" },
|
|
3120
|
+
panel: { display: "flex", flexDirection: "column", gap: "8px", marginTop: "8px", padding: "12px", border: "1px solid #a3a3a3", borderRadius: "8px", background: "#ffffff" },
|
|
3121
|
+
panelTitle: { margin: 0, fontSize: "16px", fontWeight: 700 },
|
|
3122
|
+
choice: { minHeight: "44px", padding: "8px 12px", fontSize: "16px", border: "1px solid #a3a3a3", borderRadius: "8px", background: "#ffffff", cursor: "pointer" },
|
|
3123
|
+
choiceActive: { background: "#dbeafe", border: "1px solid #1d4ed8" },
|
|
3124
|
+
note: { margin: "8px 0 0", fontSize: "16px", color: "#525252" }
|
|
3125
|
+
};
|
|
3126
|
+
var DISABLED = { opacity: 0.6, cursor: "not-allowed" };
|
|
3127
|
+
function boardPart(classNames, key, options = {}) {
|
|
3128
|
+
const structure = Object.hasOwn(STRUCTURE, key) ? STRUCTURE[key] : void 0;
|
|
3129
|
+
const injected = classNames?.[key];
|
|
3130
|
+
const stateClasses = [];
|
|
3131
|
+
let stateLook = {};
|
|
3132
|
+
for (const state of options.states ?? []) {
|
|
3133
|
+
const name = classNames?.[state];
|
|
3134
|
+
if (name) stateClasses.push(name);
|
|
3135
|
+
else if (Object.hasOwn(LOOK, state)) stateLook = { ...stateLook, ...LOOK[state] };
|
|
3136
|
+
}
|
|
3137
|
+
const className = [injected, ...stateClasses].filter(Boolean).join(" ");
|
|
3138
|
+
const style = {
|
|
3139
|
+
...injected ? {} : Object.hasOwn(LOOK, key) ? LOOK[key] : {},
|
|
3140
|
+
...stateLook,
|
|
3141
|
+
...structure ?? {},
|
|
3142
|
+
...options.disabled ? DISABLED : {}
|
|
3143
|
+
};
|
|
3144
|
+
const result = {};
|
|
3145
|
+
if (className) result.className = className;
|
|
3146
|
+
if (Object.keys(style).length > 0) result.style = style;
|
|
3147
|
+
return result;
|
|
3148
|
+
}
|
|
3149
|
+
|
|
3150
|
+
// src/components/add-card-box.tsx
|
|
3151
|
+
import { Fragment as Fragment5, jsx as jsx16, jsxs as jsxs15 } from "react/jsx-runtime";
|
|
3152
|
+
function AddCardBox({ columnName, texts, classNames, currencies = [], defaultCurrency = "", onAdd }) {
|
|
3153
|
+
const initialCurrency = currencies.includes(defaultCurrency) ? defaultCurrency : "";
|
|
3154
|
+
const [open, setOpen] = useState20(false);
|
|
3155
|
+
const [title, setTitle] = useState20("");
|
|
3156
|
+
const [amount, setAmount] = useState20("");
|
|
3157
|
+
const [currency, setCurrency] = useState20(initialCurrency);
|
|
3158
|
+
const [error, setError] = useState20();
|
|
3159
|
+
const [pending, setPending] = useState20(false);
|
|
3160
|
+
const buttonRef = useRef16(null);
|
|
3161
|
+
const titleRef = useRef16(null);
|
|
3162
|
+
const inFlight = useRef16(false);
|
|
3163
|
+
const restore = useRef16(false);
|
|
3164
|
+
const ids = { title: useId4(), amount: useId4(), currency: useId4() };
|
|
3165
|
+
useEffect19(() => {
|
|
3166
|
+
if (open) titleRef.current?.focus();
|
|
3167
|
+
else if (restore.current) {
|
|
3168
|
+
restore.current = false;
|
|
3169
|
+
buttonRef.current?.focus();
|
|
3170
|
+
}
|
|
3171
|
+
}, [open]);
|
|
3172
|
+
const cancel = () => {
|
|
3173
|
+
restore.current = true;
|
|
3174
|
+
setOpen(false);
|
|
3175
|
+
setTitle("");
|
|
3176
|
+
setAmount("");
|
|
3177
|
+
setCurrency(initialCurrency);
|
|
3178
|
+
setError(void 0);
|
|
3179
|
+
};
|
|
3180
|
+
const submit = async (event) => {
|
|
3181
|
+
event.preventDefault();
|
|
3182
|
+
if (inFlight.current) return;
|
|
3183
|
+
if (title.trim() === "") {
|
|
3184
|
+
setError(texts.addTitleRequired);
|
|
3185
|
+
titleRef.current?.focus();
|
|
3186
|
+
return;
|
|
3187
|
+
}
|
|
3188
|
+
inFlight.current = true;
|
|
3189
|
+
setPending(true);
|
|
3190
|
+
setError(void 0);
|
|
3191
|
+
try {
|
|
3192
|
+
const result = await onAdd({ title: title.trim(), amount: amount.trim(), currency });
|
|
3193
|
+
if (result && typeof result.error === "string" && result.error !== "") {
|
|
3194
|
+
setError(result.error);
|
|
3195
|
+
} else {
|
|
3196
|
+
setTitle("");
|
|
3197
|
+
setAmount("");
|
|
3198
|
+
titleRef.current?.focus();
|
|
3199
|
+
}
|
|
3200
|
+
} catch {
|
|
3201
|
+
setError(texts.unexpectedError);
|
|
3202
|
+
} finally {
|
|
3203
|
+
inFlight.current = false;
|
|
3204
|
+
setPending(false);
|
|
3205
|
+
}
|
|
3206
|
+
};
|
|
3207
|
+
const onKeyDown = (event) => {
|
|
3208
|
+
if (event.key !== "Escape") return;
|
|
3209
|
+
event.stopPropagation();
|
|
3210
|
+
cancel();
|
|
3211
|
+
};
|
|
3212
|
+
if (!open) {
|
|
3213
|
+
return /* @__PURE__ */ jsx16("button", { type: "button", ref: buttonRef, onClick: () => setOpen(true), "aria-label": `${texts.addCard} (${columnName})`, ...boardPart(classNames, "addButton"), children: texts.addCard });
|
|
3214
|
+
}
|
|
3215
|
+
return /* @__PURE__ */ jsxs15("form", { onSubmit: submit, onKeyDown, "aria-label": `${texts.addCard} (${columnName})`, ...boardPart(classNames, "addForm"), children: [
|
|
3216
|
+
/* @__PURE__ */ jsx16("label", { htmlFor: ids.title, ...boardPart(classNames, "note"), children: texts.addTitleLabel }),
|
|
3217
|
+
/* @__PURE__ */ jsx16("input", { id: ids.title, ref: titleRef, type: "text", value: title, disabled: pending, onChange: (e) => setTitle(e.target.value), autoComplete: "off", ...boardPart(classNames, "input") }),
|
|
3218
|
+
/* @__PURE__ */ jsx16("label", { htmlFor: ids.amount, ...boardPart(classNames, "note"), children: texts.addAmountLabel }),
|
|
3219
|
+
/* @__PURE__ */ jsx16("input", { id: ids.amount, type: "text", inputMode: "decimal", value: amount, disabled: pending, onChange: (e) => setAmount(e.target.value), autoComplete: "off", ...boardPart(classNames, "input") }),
|
|
3220
|
+
currencies.length > 0 ? /* @__PURE__ */ jsxs15(Fragment5, { children: [
|
|
3221
|
+
/* @__PURE__ */ jsx16("label", { htmlFor: ids.currency, ...boardPart(classNames, "note"), children: texts.addCurrencyLabel }),
|
|
3222
|
+
/* @__PURE__ */ jsxs15("select", { id: ids.currency, value: currency, disabled: pending, onChange: (e) => setCurrency(e.target.value), ...boardPart(classNames, "select"), children: [
|
|
3223
|
+
/* @__PURE__ */ jsx16("option", { value: "", children: " " }),
|
|
3224
|
+
currencies.map((code) => /* @__PURE__ */ jsx16("option", { value: code, children: code }, code))
|
|
3225
|
+
] })
|
|
3226
|
+
] }) : null,
|
|
3227
|
+
error ? /* @__PURE__ */ jsx16("p", { ...boardPart(classNames, "error"), role: "alert", children: error }) : null,
|
|
3228
|
+
/* @__PURE__ */ jsxs15("div", { style: { display: "flex", flexWrap: "wrap", gap: "8px" }, children: [
|
|
3229
|
+
/* @__PURE__ */ jsx16("button", { type: "submit", disabled: pending, ...boardPart(classNames, "primaryButton", { disabled: pending }), children: pending ? texts.addPending : texts.addSubmit }),
|
|
3230
|
+
/* @__PURE__ */ jsx16("button", { type: "button", onClick: cancel, disabled: pending, ...boardPart(classNames, "secondaryButton", { disabled: pending }), children: texts.addCancel })
|
|
3231
|
+
] })
|
|
3232
|
+
] });
|
|
3233
|
+
}
|
|
3234
|
+
|
|
3235
|
+
// src/components/board-column.tsx
|
|
3236
|
+
import { jsx as jsx17, jsxs as jsxs16 } from "react/jsx-runtime";
|
|
3237
|
+
function BoardColumn({ column, texts, classNames, renderCard, onAddCard, currencies, defaultCurrency, onShowMore, dnd }) {
|
|
3238
|
+
const headingId = useId5();
|
|
3239
|
+
const body = (shell, over) => /* @__PURE__ */ jsxs16("section", { "aria-labelledby": headingId, "data-column-id": column.id, "data-kind": column.kind, ...shell, ...boardPart(classNames, "column", { states: over ? ["columnDropOver"] : [] }), children: [
|
|
3240
|
+
/* @__PURE__ */ jsxs16("div", { ...boardPart(classNames, "columnHeader"), children: [
|
|
3241
|
+
/* @__PURE__ */ jsx17("h3", { id: headingId, ...boardPart(classNames, "columnName"), children: column.name }),
|
|
3242
|
+
/* @__PURE__ */ jsx17("span", { ...boardPart(classNames, "columnCount"), children: texts.columnCount(column.count) }),
|
|
3243
|
+
column.totals.length > 0 ? /* @__PURE__ */ jsx17("p", { ...boardPart(classNames, "columnTotals"), children: column.totals.join(" \xB7 ") }) : null
|
|
3244
|
+
] }),
|
|
3245
|
+
column.cards.length === 0 ? /* @__PURE__ */ jsx17("p", { ...boardPart(classNames, "empty"), children: texts.emptyColumn }) : /* @__PURE__ */ jsx17("ul", { ...boardPart(classNames, "cardList"), children: column.cards.map((card) => renderCard(card)) }),
|
|
3246
|
+
column.hasMore && onShowMore ? /* @__PURE__ */ jsx17("button", { type: "button", onClick: () => onShowMore(column.id), ...boardPart(classNames, "showMore"), children: texts.showMore }) : null,
|
|
3247
|
+
column.kind === "open" && onAddCard ? /* @__PURE__ */ jsx17(AddCardBox, { columnName: column.name, texts, classNames, currencies, defaultCurrency, onAdd: (input) => onAddCard(column.id, input) }) : null
|
|
3248
|
+
] });
|
|
3249
|
+
if (!dnd) return body({}, false);
|
|
3250
|
+
const Shell = dnd.Column;
|
|
3251
|
+
return /* @__PURE__ */ jsx17(Shell, { column, children: (shellProps, over) => body(shellProps, over) });
|
|
3252
|
+
}
|
|
3253
|
+
|
|
3254
|
+
// src/components/deal-card.tsx
|
|
3255
|
+
import { Fragment as Fragment6, jsx as jsx18, jsxs as jsxs17 } from "react/jsx-runtime";
|
|
3256
|
+
function DealCard({ card, texts, classNames, pending = false, dragging = false, error, renderTitle, controls, shellProps }) {
|
|
3257
|
+
const tags = (card.tags ?? []).slice(0, 2);
|
|
3258
|
+
const states = [...pending ? ["cardPending"] : [], ...dragging ? ["cardDragging"] : []];
|
|
3259
|
+
const title = /* @__PURE__ */ jsx18("span", { children: card.title });
|
|
3260
|
+
const badge = card.badge === "won" ? texts.won : card.badge === "lost" ? texts.lost : null;
|
|
3261
|
+
return /* @__PURE__ */ jsxs17("li", { tabIndex: -1, ...shellProps, ...boardPart(classNames, "card", { states }), "aria-busy": pending || void 0, "data-card-id": card.id, "data-pending": pending || void 0, children: [
|
|
3262
|
+
/* @__PURE__ */ jsx18("p", { ...boardPart(classNames, "cardTitle"), children: renderTitle ? renderTitle(card, title) : title }),
|
|
3263
|
+
card.amountLine ? /* @__PURE__ */ jsx18("p", { ...boardPart(classNames, "cardMeta"), children: card.amountLine }) : null,
|
|
3264
|
+
card.closeDateLine ? /* @__PURE__ */ jsxs17("p", { ...boardPart(classNames, "cardMeta"), children: [
|
|
3265
|
+
card.closeDateLine,
|
|
3266
|
+
card.overdue ? /* @__PURE__ */ jsxs17(Fragment6, { children: [
|
|
3267
|
+
" ",
|
|
3268
|
+
/* @__PURE__ */ jsx18("strong", { ...boardPart(classNames, "overdue"), children: texts.overdue })
|
|
3269
|
+
] }) : null
|
|
3270
|
+
] }) : null,
|
|
3271
|
+
card.ownerInitials || tags.length > 0 || badge ? /* @__PURE__ */ jsxs17("p", { ...boardPart(classNames, "cardMeta"), style: { ...boardPart(classNames, "cardMeta").style, display: "flex", flexWrap: "wrap", alignItems: "center", gap: "6px" }, children: [
|
|
3272
|
+
card.ownerInitials ? /* @__PURE__ */ jsx18("span", { ...boardPart(classNames, "ownerMark"), "aria-label": `${texts.owner} ${card.ownerInitials}`, role: "img", children: card.ownerInitials }) : null,
|
|
3273
|
+
tags.map((tag) => /* @__PURE__ */ jsx18("span", { ...boardPart(classNames, "tagChip"), children: tag.label }, tag.id)),
|
|
3274
|
+
badge ? /* @__PURE__ */ jsx18("span", { ...boardPart(classNames, card.badge === "won" ? "badgeWon" : "badgeLost"), children: badge }) : null
|
|
3275
|
+
] }) : null,
|
|
3276
|
+
pending ? /* @__PURE__ */ jsx18("p", { ...boardPart(classNames, "note"), role: "status", children: texts.moving }) : controls,
|
|
3277
|
+
error ? /* @__PURE__ */ jsx18("p", { ...boardPart(classNames, "cardError"), role: "alert", children: error }) : null
|
|
3278
|
+
] });
|
|
3279
|
+
}
|
|
3280
|
+
|
|
3281
|
+
// src/components/lost-step.tsx
|
|
3282
|
+
import { useEffect as useEffect20, useId as useId6, useRef as useRef17, useState as useState21 } from "react";
|
|
3283
|
+
import { jsx as jsx19, jsxs as jsxs18 } from "react/jsx-runtime";
|
|
3284
|
+
function LostStep({ suggestions, used, validateReason, humanize, texts, classNames, error, busy = false, onConfirm, onCancel }) {
|
|
3285
|
+
const [picked, setPicked] = useState21(null);
|
|
3286
|
+
const [own, setOwn] = useState21("");
|
|
3287
|
+
const [missing, setMissing] = useState21(false);
|
|
3288
|
+
const firstRef = useRef17(null);
|
|
3289
|
+
const ownRef = useRef17(null);
|
|
3290
|
+
const sent = useRef17(false);
|
|
3291
|
+
const titleId = useId6();
|
|
3292
|
+
const ownId = useId6();
|
|
3293
|
+
useEffect20(() => {
|
|
3294
|
+
if (firstRef.current) firstRef.current.focus();
|
|
3295
|
+
else ownRef.current?.focus();
|
|
3296
|
+
}, []);
|
|
3297
|
+
const known = new Set(suggestions.map((s) => s.code));
|
|
3298
|
+
const usedOnly = used.filter((u) => !known.has(u.code));
|
|
3299
|
+
const code = own.trim() !== "" ? validateReason(own) : picked;
|
|
3300
|
+
const confirm = () => {
|
|
3301
|
+
if (busy || sent.current) return;
|
|
3302
|
+
if (code === null || code === "") {
|
|
3303
|
+
setMissing(true);
|
|
3304
|
+
return;
|
|
3305
|
+
}
|
|
3306
|
+
sent.current = true;
|
|
3307
|
+
onConfirm(code);
|
|
3308
|
+
queueMicrotask(() => {
|
|
3309
|
+
sent.current = false;
|
|
3310
|
+
});
|
|
3311
|
+
};
|
|
3312
|
+
const onKeyDown = (event) => {
|
|
3313
|
+
if (event.key !== "Escape") return;
|
|
3314
|
+
event.stopPropagation();
|
|
3315
|
+
onCancel();
|
|
3316
|
+
};
|
|
3317
|
+
const choice = (item, index) => {
|
|
3318
|
+
const active = own.trim() === "" && picked === item.code;
|
|
3319
|
+
return /* @__PURE__ */ jsx19(
|
|
3320
|
+
"button",
|
|
3321
|
+
{
|
|
3322
|
+
type: "button",
|
|
3323
|
+
ref: index === 0 ? firstRef : void 0,
|
|
3324
|
+
"aria-pressed": active,
|
|
3325
|
+
disabled: busy,
|
|
3326
|
+
onClick: () => {
|
|
3327
|
+
setPicked(item.code);
|
|
3328
|
+
setOwn("");
|
|
3329
|
+
setMissing(false);
|
|
3330
|
+
},
|
|
3331
|
+
...boardPart(classNames, "choice", { states: active ? ["choiceActive"] : [], disabled: busy }),
|
|
3332
|
+
children: item.label ?? humanize(item.code)
|
|
3333
|
+
},
|
|
3334
|
+
item.code
|
|
3335
|
+
);
|
|
3336
|
+
};
|
|
3337
|
+
return (
|
|
3338
|
+
// eslint-disable-next-line jsx-a11y/no-noninteractive-element-interactions
|
|
3339
|
+
/* @__PURE__ */ jsxs18("div", { role: "group", "aria-labelledby": titleId, onKeyDown, ...boardPart(classNames, "panel"), children: [
|
|
3340
|
+
/* @__PURE__ */ jsx19("p", { id: titleId, ...boardPart(classNames, "panelTitle"), children: texts.lostTitle }),
|
|
3341
|
+
suggestions.length > 0 ? /* @__PURE__ */ jsx19("div", { role: "group", "aria-label": texts.lostSuggested, style: { display: "flex", flexWrap: "wrap", gap: "8px" }, children: suggestions.map((s, i) => choice(s, i)) }) : null,
|
|
3342
|
+
usedOnly.length > 0 ? /* @__PURE__ */ jsx19("div", { role: "group", "aria-label": texts.lostUsed, style: { display: "flex", flexWrap: "wrap", gap: "8px" }, children: usedOnly.map((u, i) => choice(u, suggestions.length + i)) }) : null,
|
|
3343
|
+
/* @__PURE__ */ jsx19("label", { htmlFor: ownId, ...boardPart(classNames, "note"), children: texts.lostOwnLabel }),
|
|
3344
|
+
/* @__PURE__ */ jsx19(
|
|
3345
|
+
"input",
|
|
3346
|
+
{
|
|
3347
|
+
id: ownId,
|
|
3348
|
+
ref: ownRef,
|
|
3349
|
+
type: "text",
|
|
3350
|
+
value: own,
|
|
3351
|
+
disabled: busy,
|
|
3352
|
+
onChange: (e) => {
|
|
3353
|
+
setOwn(e.target.value);
|
|
3354
|
+
setMissing(false);
|
|
3355
|
+
},
|
|
3356
|
+
onKeyDown: (e) => {
|
|
3357
|
+
if (e.key === "Enter") {
|
|
3358
|
+
e.preventDefault();
|
|
3359
|
+
confirm();
|
|
3360
|
+
}
|
|
3361
|
+
},
|
|
3362
|
+
...boardPart(classNames, "input")
|
|
3363
|
+
}
|
|
3364
|
+
),
|
|
3365
|
+
missing || error ? /* @__PURE__ */ jsx19("p", { ...boardPart(classNames, "error"), role: "alert", children: error ?? texts.lostRequired }) : null,
|
|
3366
|
+
/* @__PURE__ */ jsxs18("div", { style: { display: "flex", flexWrap: "wrap", gap: "8px" }, children: [
|
|
3367
|
+
/* @__PURE__ */ jsx19("button", { type: "button", onClick: confirm, disabled: busy, ...boardPart(classNames, "primaryButton", { disabled: busy }), children: busy ? texts.movePending : texts.lostConfirm }),
|
|
3368
|
+
/* @__PURE__ */ jsx19("button", { type: "button", onClick: onCancel, disabled: busy, ...boardPart(classNames, "secondaryButton", { disabled: busy }), children: texts.lostCancel })
|
|
3369
|
+
] })
|
|
3370
|
+
] })
|
|
3371
|
+
);
|
|
3372
|
+
}
|
|
3373
|
+
|
|
3374
|
+
// src/components/move-menu.tsx
|
|
3375
|
+
import { useId as useId7, useState as useState22 } from "react";
|
|
3376
|
+
import { jsx as jsx20, jsxs as jsxs19 } from "react/jsx-runtime";
|
|
3377
|
+
function MoveMenu({ cardTitle, targets, texts, classNames, busy = false, onChoose }) {
|
|
3378
|
+
const [value, setValue] = useState22("");
|
|
3379
|
+
const id = useId7();
|
|
3380
|
+
if (targets.length === 0) return null;
|
|
3381
|
+
const chosen = targets.some((t) => t.stageId === value) ? value : "";
|
|
3382
|
+
return /* @__PURE__ */ jsxs19("div", { style: { display: "flex", flexWrap: "wrap", gap: "8px", marginTop: "8px" }, children: [
|
|
3383
|
+
/* @__PURE__ */ jsx20("label", { htmlFor: id, style: { position: "absolute", width: "1px", height: "1px", overflow: "hidden", clip: "rect(0 0 0 0)" }, children: `${texts.moveLabel} ${cardTitle}` }),
|
|
3384
|
+
/* @__PURE__ */ jsxs19("select", { id, value: chosen, onChange: (e) => setValue(e.target.value), disabled: busy, ...boardPart(classNames, "select", { disabled: busy }), children: [
|
|
3385
|
+
/* @__PURE__ */ jsx20("option", { value: "", children: texts.moveChoose }),
|
|
3386
|
+
targets.map((t) => /* @__PURE__ */ jsx20("option", { value: t.stageId, children: t.label }, t.stageId))
|
|
3387
|
+
] }),
|
|
3388
|
+
/* @__PURE__ */ jsx20(
|
|
3389
|
+
"button",
|
|
3390
|
+
{
|
|
3391
|
+
type: "button",
|
|
3392
|
+
disabled: busy || chosen === "",
|
|
3393
|
+
onClick: () => {
|
|
3394
|
+
if (chosen === "") return;
|
|
3395
|
+
onChoose(chosen);
|
|
3396
|
+
setValue("");
|
|
3397
|
+
},
|
|
3398
|
+
...boardPart(classNames, "secondaryButton", { disabled: busy || chosen === "" }),
|
|
3399
|
+
children: busy ? texts.movePending : texts.moveSubmit
|
|
3400
|
+
}
|
|
3401
|
+
)
|
|
3402
|
+
] });
|
|
3403
|
+
}
|
|
3404
|
+
|
|
3405
|
+
// src/components/reopen-step.tsx
|
|
3406
|
+
import { useEffect as useEffect21, useId as useId8, useRef as useRef18, useState as useState23 } from "react";
|
|
3407
|
+
import { Fragment as Fragment7, jsx as jsx21, jsxs as jsxs20 } from "react/jsx-runtime";
|
|
3408
|
+
function ReopenStep({ needsStage, stages, texts, classNames, error, busy = false, onConfirm, onCancel }) {
|
|
3409
|
+
const [stage, setStage] = useState23("");
|
|
3410
|
+
const confirmRef = useRef18(null);
|
|
3411
|
+
const selectRef = useRef18(null);
|
|
3412
|
+
const titleId = useId8();
|
|
3413
|
+
const selectId = useId8();
|
|
3414
|
+
const chosen = stages.some((s) => s.stageId === stage) ? stage : "";
|
|
3415
|
+
useEffect21(() => {
|
|
3416
|
+
if (needsStage) selectRef.current?.focus();
|
|
3417
|
+
else confirmRef.current?.focus();
|
|
3418
|
+
}, [needsStage]);
|
|
3419
|
+
const blocked = busy || needsStage && chosen === "";
|
|
3420
|
+
const onKeyDown = (event) => {
|
|
3421
|
+
if (event.key !== "Escape") return;
|
|
3422
|
+
event.stopPropagation();
|
|
3423
|
+
onCancel();
|
|
3424
|
+
};
|
|
3425
|
+
return (
|
|
3426
|
+
// eslint-disable-next-line jsx-a11y/no-noninteractive-element-interactions
|
|
3427
|
+
/* @__PURE__ */ jsxs20("div", { role: "group", "aria-labelledby": titleId, onKeyDown, ...boardPart(classNames, "panel"), children: [
|
|
3428
|
+
/* @__PURE__ */ jsx21("p", { id: titleId, ...boardPart(classNames, "panelTitle"), children: texts.reopenTitle }),
|
|
3429
|
+
needsStage ? /* @__PURE__ */ jsxs20(Fragment7, { children: [
|
|
3430
|
+
/* @__PURE__ */ jsx21("label", { htmlFor: selectId, ...boardPart(classNames, "note"), children: texts.reopenStageLabel }),
|
|
3431
|
+
/* @__PURE__ */ jsxs20("select", { id: selectId, ref: selectRef, value: chosen, disabled: busy, onChange: (e) => setStage(e.target.value), ...boardPart(classNames, "select", { disabled: busy }), children: [
|
|
3432
|
+
/* @__PURE__ */ jsx21("option", { value: "", children: texts.moveChoose }),
|
|
3433
|
+
stages.map((s) => /* @__PURE__ */ jsx21("option", { value: s.stageId, children: s.label }, s.stageId))
|
|
3434
|
+
] })
|
|
3435
|
+
] }) : null,
|
|
3436
|
+
error ? /* @__PURE__ */ jsx21("p", { ...boardPart(classNames, "error"), role: "alert", children: error }) : null,
|
|
3437
|
+
/* @__PURE__ */ jsxs20("div", { style: { display: "flex", flexWrap: "wrap", gap: "8px" }, children: [
|
|
3438
|
+
/* @__PURE__ */ jsx21(
|
|
3439
|
+
"button",
|
|
3440
|
+
{
|
|
3441
|
+
type: "button",
|
|
3442
|
+
ref: confirmRef,
|
|
3443
|
+
disabled: blocked,
|
|
3444
|
+
onClick: () => {
|
|
3445
|
+
if (blocked) return;
|
|
3446
|
+
if (needsStage) onConfirm(chosen);
|
|
3447
|
+
else onConfirm();
|
|
3448
|
+
},
|
|
3449
|
+
...boardPart(classNames, "primaryButton", { disabled: blocked }),
|
|
3450
|
+
children: busy ? texts.movePending : texts.reopenConfirm
|
|
3451
|
+
}
|
|
3452
|
+
),
|
|
3453
|
+
/* @__PURE__ */ jsx21("button", { type: "button", onClick: onCancel, disabled: busy, ...boardPart(classNames, "secondaryButton", { disabled: busy }), children: texts.reopenCancel })
|
|
3454
|
+
] })
|
|
3455
|
+
] })
|
|
3456
|
+
);
|
|
3457
|
+
}
|
|
3458
|
+
|
|
3459
|
+
// src/components/pipeline-board.tsx
|
|
3460
|
+
import { Fragment as Fragment8, jsx as jsx22, jsxs as jsxs21 } from "react/jsx-runtime";
|
|
3461
|
+
var errorOf2 = (result) => {
|
|
3462
|
+
if (result && typeof result === "object" && "error" in result) {
|
|
3463
|
+
const e = result.error;
|
|
3464
|
+
if (typeof e === "string" && e !== "") return e;
|
|
3465
|
+
}
|
|
3466
|
+
return void 0;
|
|
3467
|
+
};
|
|
3468
|
+
function PipelineBoard(props) {
|
|
3469
|
+
const { columns, texts, classNames, pendingDealIds = [], cardErrors, onMove, legalTargets, reopenFor, onReopen, lost, onAddCard, currencies, defaultCurrency, onShowMore, renderCardTitle, endSlot, dnd } = props;
|
|
3470
|
+
const [placed, setPlaced] = useState24({});
|
|
3471
|
+
const [errors, setErrors] = useState24({});
|
|
3472
|
+
const [step, setStep] = useState24(null);
|
|
3473
|
+
const [stepError, setStepError] = useState24();
|
|
3474
|
+
const [position, setPosition] = useState24(0);
|
|
3475
|
+
const rowRef = useRef19(null);
|
|
3476
|
+
const running = useRef19(/* @__PURE__ */ new Set());
|
|
3477
|
+
const focusAfter = useRef19(null);
|
|
3478
|
+
useEffect22(() => {
|
|
3479
|
+
const id = focusAfter.current;
|
|
3480
|
+
if (id === null || placed[id]?.running) return;
|
|
3481
|
+
for (const el of Array.from(rowRef.current?.querySelectorAll("[data-card-id]") ?? [])) {
|
|
3482
|
+
if (el.getAttribute("data-card-id") === id) {
|
|
3483
|
+
focusAfter.current = null;
|
|
3484
|
+
el.focus();
|
|
3485
|
+
return;
|
|
3486
|
+
}
|
|
3487
|
+
}
|
|
3488
|
+
});
|
|
3489
|
+
useEffect22(() => {
|
|
3490
|
+
setPlaced((prev) => {
|
|
3491
|
+
const keep = {};
|
|
3492
|
+
for (const [id, value] of Object.entries(prev)) if (value.running) keep[id] = value;
|
|
3493
|
+
return Object.keys(keep).length === Object.keys(prev).length ? prev : keep;
|
|
3494
|
+
});
|
|
3495
|
+
}, [columns]);
|
|
3496
|
+
const view = useMemo2(() => {
|
|
3497
|
+
const moved = Object.entries(placed);
|
|
3498
|
+
if (moved.length === 0) return columns;
|
|
3499
|
+
const byId = /* @__PURE__ */ new Map();
|
|
3500
|
+
for (const column of columns) for (const card of column.cards) byId.set(card.id, card);
|
|
3501
|
+
return columns.map((column) => {
|
|
3502
|
+
const stay = column.cards.filter((card) => !Object.hasOwn(placed, card.id) || placed[card.id]?.toStageId === column.id);
|
|
3503
|
+
const arriving = moved.filter(([, value]) => value.toStageId === column.id).map(([id]) => byId.get(id)).filter((card) => card !== void 0 && !column.cards.some((c) => c.id === card.id));
|
|
3504
|
+
return arriving.length === 0 && stay.length === column.cards.length ? column : { ...column, cards: [...arriving, ...stay] };
|
|
3505
|
+
});
|
|
3506
|
+
}, [columns, placed]);
|
|
3507
|
+
const cardOf = (id) => {
|
|
3508
|
+
for (const column of columns) for (const card of column.cards) if (card.id === id) return card;
|
|
3509
|
+
return void 0;
|
|
3510
|
+
};
|
|
3511
|
+
const send = async (card, toStageId, reason) => {
|
|
3512
|
+
if (!onMove || running.current.has(card.id)) return void 0;
|
|
3513
|
+
running.current.add(card.id);
|
|
3514
|
+
setErrors((prev) => withoutKey(prev, card.id));
|
|
3515
|
+
setPlaced((prev) => ({ ...prev, [card.id]: { toStageId, running: true } }));
|
|
3516
|
+
const request = { dealId: card.id, toStageId, expectedVersion: card.version, ...reason !== void 0 ? { reason } : {} };
|
|
3517
|
+
let message;
|
|
3518
|
+
try {
|
|
3519
|
+
message = errorOf2(await onMove(request));
|
|
3520
|
+
} catch {
|
|
3521
|
+
message = texts.unexpectedError;
|
|
3522
|
+
}
|
|
3523
|
+
running.current.delete(card.id);
|
|
3524
|
+
if (message) {
|
|
3525
|
+
setPlaced((prev) => withoutKey(prev, card.id));
|
|
3526
|
+
setErrors((prev) => ({ ...prev, [card.id]: message }));
|
|
3527
|
+
} else {
|
|
3528
|
+
focusAfter.current = card.id;
|
|
3529
|
+
setPlaced((prev) => ({ ...prev, [card.id]: { toStageId, running: false } }));
|
|
3530
|
+
}
|
|
3531
|
+
return message;
|
|
3532
|
+
};
|
|
3533
|
+
const requestMove = (card, toStageId) => {
|
|
3534
|
+
const target = columns.find((c) => c.id === toStageId);
|
|
3535
|
+
if (!target || card.stageId === toStageId) return;
|
|
3536
|
+
if (target.kind === "lost" && !lost) return;
|
|
3537
|
+
if (target.kind === "lost" && lost) {
|
|
3538
|
+
setStepError(void 0);
|
|
3539
|
+
setStep({ kind: "lost", card, toStageId });
|
|
3540
|
+
return;
|
|
3541
|
+
}
|
|
3542
|
+
void send(card, toStageId);
|
|
3543
|
+
};
|
|
3544
|
+
const pendingIds = new Set(pendingDealIds);
|
|
3545
|
+
const isPending = (id) => pendingIds.has(id) || placed[id]?.running === true;
|
|
3546
|
+
const controlsFor = (card) => {
|
|
3547
|
+
if (step && step.card.id === card.id) {
|
|
3548
|
+
if (step.kind === "lost" && lost) {
|
|
3549
|
+
return /* @__PURE__ */ jsx22(
|
|
3550
|
+
LostStep,
|
|
3551
|
+
{
|
|
3552
|
+
suggestions: lost.suggestions,
|
|
3553
|
+
used: lost.used,
|
|
3554
|
+
validateReason: lost.validateReason,
|
|
3555
|
+
humanize: lost.humanize,
|
|
3556
|
+
texts,
|
|
3557
|
+
classNames,
|
|
3558
|
+
error: stepError,
|
|
3559
|
+
onCancel: () => setStep(null),
|
|
3560
|
+
onConfirm: (reason) => {
|
|
3561
|
+
const target = step.toStageId;
|
|
3562
|
+
setStep(null);
|
|
3563
|
+
void send(card, target, reason);
|
|
3564
|
+
}
|
|
3565
|
+
}
|
|
3566
|
+
);
|
|
3567
|
+
}
|
|
3568
|
+
const options = reopenFor?.(card);
|
|
3569
|
+
if (step.kind === "reopen" && options) {
|
|
3570
|
+
return /* @__PURE__ */ jsx22(
|
|
3571
|
+
ReopenStep,
|
|
3572
|
+
{
|
|
3573
|
+
needsStage: options.needsStage,
|
|
3574
|
+
stages: options.stages,
|
|
3575
|
+
texts,
|
|
3576
|
+
classNames,
|
|
3577
|
+
error: stepError,
|
|
3578
|
+
onCancel: () => setStep(null),
|
|
3579
|
+
onConfirm: async (toStageId) => {
|
|
3580
|
+
if (!onReopen) return;
|
|
3581
|
+
try {
|
|
3582
|
+
const message = errorOf2(await onReopen({ dealId: card.id, expectedVersion: card.version, ...toStageId !== void 0 ? { toStageId } : {} }));
|
|
3583
|
+
if (message) setStepError(message);
|
|
3584
|
+
else setStep(null);
|
|
3585
|
+
} catch {
|
|
3586
|
+
setStepError(texts.unexpectedError);
|
|
3587
|
+
}
|
|
3588
|
+
}
|
|
3589
|
+
}
|
|
3590
|
+
);
|
|
3591
|
+
}
|
|
3592
|
+
}
|
|
3593
|
+
const reopen = card.badge && reopenFor && onReopen ? reopenFor(card) : null;
|
|
3594
|
+
return /* @__PURE__ */ jsxs21(Fragment8, { children: [
|
|
3595
|
+
onMove && legalTargets ? /* @__PURE__ */ jsx22(MoveMenu, { cardTitle: card.title, targets: legalTargets(card).filter((t) => lost || columns.find((c) => c.id === t.stageId)?.kind !== "lost"), texts, classNames, onChoose: (stageId) => requestMove(card, stageId) }) : null,
|
|
3596
|
+
reopen ? /* @__PURE__ */ jsx22(
|
|
3597
|
+
"button",
|
|
3598
|
+
{
|
|
3599
|
+
type: "button",
|
|
3600
|
+
onClick: () => {
|
|
3601
|
+
setStepError(void 0);
|
|
3602
|
+
setStep({ kind: "reopen", card });
|
|
3603
|
+
},
|
|
3604
|
+
...boardPart(classNames, "secondaryButton"),
|
|
3605
|
+
children: texts.reopen
|
|
3606
|
+
}
|
|
3607
|
+
) : null
|
|
3608
|
+
] });
|
|
3609
|
+
};
|
|
3610
|
+
const renderCard = (card) => {
|
|
3611
|
+
const error = errors[card.id] ?? cardErrors?.[card.id];
|
|
3612
|
+
const build = (shellProps, dragging) => /* @__PURE__ */ jsx22(DealCard, { card, texts, classNames, pending: isPending(card.id), dragging, error, renderTitle: renderCardTitle, controls: controlsFor(card), shellProps }, card.id);
|
|
3613
|
+
if (!dnd || isPending(card.id)) return build({}, false);
|
|
3614
|
+
const Shell = dnd.Card;
|
|
3615
|
+
return /* @__PURE__ */ jsx22(Shell, { card, children: (shellProps, dragging) => build(shellProps, dragging) }, card.id);
|
|
3616
|
+
};
|
|
3617
|
+
const onScroll = () => {
|
|
3618
|
+
const row = rowRef.current;
|
|
3619
|
+
if (!row) return;
|
|
3620
|
+
const offsets = Array.from(row.querySelectorAll("[data-column-id]")).map((el) => el.offsetLeft - row.offsetLeft);
|
|
3621
|
+
setPosition(nearestColumnIndex(row.scrollLeft, offsets));
|
|
3622
|
+
};
|
|
3623
|
+
if (columns.length === 0) {
|
|
3624
|
+
return /* @__PURE__ */ jsx22("div", { ...boardPart(classNames, "root"), children: /* @__PURE__ */ jsx22("p", { ...boardPart(classNames, "empty"), children: texts.emptyBoard }) });
|
|
3625
|
+
}
|
|
3626
|
+
const content = /* @__PURE__ */ jsxs21("div", { ...boardPart(classNames, "root"), children: [
|
|
3627
|
+
columns.length > 1 ? /* @__PURE__ */ jsx22("p", { ...boardPart(classNames, "position"), role: "status", "aria-live": "polite", children: texts.stagePosition(Math.min(position, columns.length - 1) + 1, columns.length) }) : null,
|
|
3628
|
+
/* @__PURE__ */ jsxs21("div", { ref: rowRef, role: "region", "aria-label": texts.boardLabel, tabIndex: 0, onScroll, ...boardPart(classNames, "row"), children: [
|
|
3629
|
+
view.map((column) => /* @__PURE__ */ jsx22(
|
|
3630
|
+
BoardColumn,
|
|
3631
|
+
{
|
|
3632
|
+
column,
|
|
3633
|
+
texts,
|
|
3634
|
+
classNames,
|
|
3635
|
+
renderCard,
|
|
3636
|
+
onAddCard,
|
|
3637
|
+
currencies,
|
|
3638
|
+
defaultCurrency,
|
|
3639
|
+
onShowMore,
|
|
3640
|
+
dnd
|
|
3641
|
+
},
|
|
3642
|
+
column.id
|
|
3643
|
+
)),
|
|
3644
|
+
endSlot ? /* @__PURE__ */ jsx22("div", { style: { flex: "0 0 auto", scrollSnapAlign: "end" }, children: endSlot }) : null
|
|
3645
|
+
] })
|
|
3646
|
+
] });
|
|
3647
|
+
if (!dnd) return content;
|
|
3648
|
+
const Provider = dnd.Provider;
|
|
3649
|
+
return /* @__PURE__ */ jsx22(Provider, { columns: view, onDrop: (cardId, toStageId) => {
|
|
3650
|
+
const card = cardOf(cardId);
|
|
3651
|
+
if (card) requestMove(card, toStageId);
|
|
3652
|
+
}, config: dnd.config, allow: (cardId, toStageId) => lost !== void 0 || columns.find((c) => c.id === toStageId)?.kind !== "lost", children: content });
|
|
3653
|
+
}
|
|
3654
|
+
function withoutKey(record, key) {
|
|
3655
|
+
if (!Object.hasOwn(record, key)) return record;
|
|
3656
|
+
const next = { ...record };
|
|
3657
|
+
delete next[key];
|
|
3658
|
+
return next;
|
|
3659
|
+
}
|
|
3014
3660
|
export {
|
|
3015
3661
|
ACTIVITY_ICONS,
|
|
3016
3662
|
ALL_SHORTCUT_CONTEXTS,
|
|
3017
3663
|
ARRIVAL_FADE_MS,
|
|
3018
3664
|
ActivityFeedRow,
|
|
3665
|
+
AddCardBox,
|
|
3019
3666
|
ArchiveButton,
|
|
3667
|
+
BoardColumn,
|
|
3020
3668
|
CLIENT_PROFILE_SHORTCUTS,
|
|
3021
3669
|
COPY_NOTE_COPIED,
|
|
3022
3670
|
COPY_NOTE_FAILED,
|
|
3023
3671
|
ConfirmAction,
|
|
3672
|
+
DealCard,
|
|
3024
3673
|
EmailBodyRenderer,
|
|
3025
3674
|
EmailThreadView,
|
|
3026
3675
|
EntityPicker,
|
|
@@ -3030,9 +3679,14 @@ export {
|
|
|
3030
3679
|
GUARDED_ACTION_FAILURE,
|
|
3031
3680
|
INBOX_SHORTCUTS,
|
|
3032
3681
|
KeyboardShortcutsPanel,
|
|
3682
|
+
LostStep,
|
|
3683
|
+
MoveMenu,
|
|
3033
3684
|
PICKER_SEARCH_FAILURE,
|
|
3685
|
+
Pager,
|
|
3686
|
+
PipelineBoard,
|
|
3034
3687
|
RENDER_ERRORS,
|
|
3035
3688
|
REPLY_LAYOUT_OPTIONS,
|
|
3689
|
+
ReopenStep,
|
|
3036
3690
|
ReplyPanel,
|
|
3037
3691
|
RestoreButton,
|
|
3038
3692
|
RichTextEditor,
|
|
@@ -3066,6 +3720,7 @@ export {
|
|
|
3066
3720
|
isTypingContext,
|
|
3067
3721
|
isValidScheduleDate,
|
|
3068
3722
|
isVideo,
|
|
3723
|
+
nearestColumnIndex,
|
|
3069
3724
|
opensInNewTab,
|
|
3070
3725
|
parseCustomSchedule,
|
|
3071
3726
|
prefetch,
|