@ordinatio/ui 1.7.0 → 1.9.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 +8 -0
- package/README.md +52 -1
- package/dist/index.d.mts +320 -2
- package/dist/index.mjs +543 -162
- package/package.json +2 -1
package/dist/index.mjs
CHANGED
|
@@ -877,10 +877,280 @@ function ActivityFeedRow({
|
|
|
877
877
|
] });
|
|
878
878
|
}
|
|
879
879
|
|
|
880
|
-
// src/
|
|
881
|
-
import { useCallback as useCallback2, useEffect as useEffect3,
|
|
880
|
+
// src/hooks/use-guarded-action.ts
|
|
881
|
+
import { useCallback as useCallback2, useEffect as useEffect3, useRef as useRef3, useState as useState4 } from "react";
|
|
882
|
+
var GUARDED_ACTION_FAILURE = "Something went wrong. Please try again.";
|
|
883
|
+
var errorOf = (result) => {
|
|
884
|
+
if (typeof result !== "object" || result === null) return null;
|
|
885
|
+
const error = result.error;
|
|
886
|
+
return typeof error === "string" && error !== "" ? error : null;
|
|
887
|
+
};
|
|
888
|
+
function useGuardedAction(action, options = {}) {
|
|
889
|
+
const [busy, setBusy] = useState4(false);
|
|
890
|
+
const [error, setError] = useState4(null);
|
|
891
|
+
const running = useRef3(false);
|
|
892
|
+
const mounted = useRef3(true);
|
|
893
|
+
const latest = useRef3({ action, options });
|
|
894
|
+
latest.current = { action, options };
|
|
895
|
+
useEffect3(() => {
|
|
896
|
+
mounted.current = true;
|
|
897
|
+
return () => {
|
|
898
|
+
mounted.current = false;
|
|
899
|
+
};
|
|
900
|
+
}, []);
|
|
901
|
+
const run = useCallback2(async (...args) => {
|
|
902
|
+
if (running.current) return;
|
|
903
|
+
running.current = true;
|
|
904
|
+
setBusy(true);
|
|
905
|
+
setError(null);
|
|
906
|
+
try {
|
|
907
|
+
const result = await latest.current.action(...args);
|
|
908
|
+
const refusal = errorOf(result);
|
|
909
|
+
if (refusal) {
|
|
910
|
+
if (mounted.current) setError(refusal);
|
|
911
|
+
} else {
|
|
912
|
+
latest.current.options.onDone?.(result);
|
|
913
|
+
}
|
|
914
|
+
} catch (thrown) {
|
|
915
|
+
try {
|
|
916
|
+
latest.current.options.onFailure?.(thrown);
|
|
917
|
+
} catch {
|
|
918
|
+
}
|
|
919
|
+
if (mounted.current) setError(latest.current.options.failureMessage ?? GUARDED_ACTION_FAILURE);
|
|
920
|
+
} finally {
|
|
921
|
+
running.current = false;
|
|
922
|
+
if (mounted.current) setBusy(false);
|
|
923
|
+
}
|
|
924
|
+
}, []);
|
|
925
|
+
const clearError = useCallback2(() => setError(null), []);
|
|
926
|
+
return { run, busy, error, clearError };
|
|
927
|
+
}
|
|
928
|
+
|
|
929
|
+
// src/components/restore-button.tsx
|
|
882
930
|
import { jsx as jsx7, jsxs as jsxs6 } from "react/jsx-runtime";
|
|
883
931
|
var defaults3 = {
|
|
932
|
+
root: { display: "inline-flex", flexDirection: "column", alignItems: "flex-end", gap: "4px" },
|
|
933
|
+
button: { flexShrink: 0, padding: 0, border: "none", backgroundColor: "transparent", fontSize: "14px", color: "#404040", cursor: "pointer" },
|
|
934
|
+
error: { fontSize: "14px", color: "#dc2626" }
|
|
935
|
+
};
|
|
936
|
+
function RestoreButton({ action, onDone, onFailure, labels, failureMessage, classNames }) {
|
|
937
|
+
const { run, busy, error } = useGuardedAction(action, { onDone: () => onDone?.(), onFailure, failureMessage });
|
|
938
|
+
const part = (key, extra) => {
|
|
939
|
+
const className = classNames?.[key];
|
|
940
|
+
return className ? { className } : { style: { ...defaults3[key], ...extra } };
|
|
941
|
+
};
|
|
942
|
+
return /* @__PURE__ */ jsxs6("span", { ...part("root"), children: [
|
|
943
|
+
/* @__PURE__ */ jsx7("button", { type: "button", disabled: busy, onClick: () => void run(), ...part("button", busy ? { opacity: 0.5, cursor: "not-allowed" } : void 0), children: busy ? labels?.busy ?? "Restoring\u2026" : labels?.idle ?? "Restore" }),
|
|
944
|
+
error ? /* @__PURE__ */ jsx7("span", { role: "alert", ...part("error"), children: error }) : null
|
|
945
|
+
] });
|
|
946
|
+
}
|
|
947
|
+
|
|
948
|
+
// src/components/undo-notice.tsx
|
|
949
|
+
import { useState as useState5 } from "react";
|
|
950
|
+
import { jsx as jsx8, jsxs as jsxs7 } from "react/jsx-runtime";
|
|
951
|
+
var defaults4 = {
|
|
952
|
+
root: { display: "flex", flexWrap: "wrap", alignItems: "center", gap: "4px 12px", padding: "8px 12px", fontSize: "14px", borderRadius: "6px", backgroundColor: "#f5f5f5", color: "#262626" },
|
|
953
|
+
message: { minWidth: 0, overflowWrap: "break-word" },
|
|
954
|
+
link: { color: "#be123c" },
|
|
955
|
+
undo: { padding: 0, border: "none", backgroundColor: "transparent", fontSize: "14px", fontWeight: 500, color: "#be123c", cursor: "pointer" },
|
|
956
|
+
dismiss: { marginLeft: "auto", padding: 0, border: "none", backgroundColor: "transparent", color: "#737373", cursor: "pointer" },
|
|
957
|
+
error: { width: "100%", color: "#dc2626" }
|
|
958
|
+
};
|
|
959
|
+
var defaultMoved = (name) => `Moved \u201C${name}\u201D to the Trash.`;
|
|
960
|
+
function UndoNotice({ name, action, onDone, onFailure, trashHref, LinkComponent = "a", labels, failureMessage, classNames }) {
|
|
961
|
+
const [hidden, setHidden] = useState5(false);
|
|
962
|
+
const { run, busy, error } = useGuardedAction(action, {
|
|
963
|
+
onDone: () => {
|
|
964
|
+
onDone?.();
|
|
965
|
+
setHidden(true);
|
|
966
|
+
},
|
|
967
|
+
onFailure,
|
|
968
|
+
failureMessage
|
|
969
|
+
});
|
|
970
|
+
const Link = LinkComponent;
|
|
971
|
+
const part = (key, extra) => {
|
|
972
|
+
const className = classNames?.[key];
|
|
973
|
+
return className ? { className } : { style: { ...defaults4[key], ...extra } };
|
|
974
|
+
};
|
|
975
|
+
if (hidden) return null;
|
|
976
|
+
return /* @__PURE__ */ jsxs7("div", { role: "status", ...part("root"), children: [
|
|
977
|
+
/* @__PURE__ */ jsx8("span", { ...part("message"), children: (labels?.moved ?? defaultMoved)(name) }),
|
|
978
|
+
trashHref ? /* @__PURE__ */ jsx8(Link, { href: trashHref, ...part("link"), children: labels?.viewTrash ?? "View Trash" }) : null,
|
|
979
|
+
/* @__PURE__ */ jsx8("button", { type: "button", disabled: busy, onClick: () => void run(), ...part("undo", busy ? { opacity: 0.5, cursor: "not-allowed" } : void 0), children: busy ? labels?.undoing ?? "Undoing\u2026" : labels?.undo ?? "Undo" }),
|
|
980
|
+
/* @__PURE__ */ jsx8("button", { type: "button", "aria-label": labels?.dismiss ?? "Dismiss", onClick: () => setHidden(true), ...part("dismiss"), children: "\xD7" }),
|
|
981
|
+
error ? /* @__PURE__ */ jsx8("span", { role: "alert", ...part("error"), children: error }) : null
|
|
982
|
+
] });
|
|
983
|
+
}
|
|
984
|
+
|
|
985
|
+
// src/components/trashed-banner.tsx
|
|
986
|
+
import { jsx as jsx9, jsxs as jsxs8 } from "react/jsx-runtime";
|
|
987
|
+
function formatTrashedDate(date, locale = "en-US", timeZone) {
|
|
988
|
+
return date.toLocaleDateString(locale, { year: "numeric", month: "short", day: "numeric", ...timeZone ? { timeZone } : {} });
|
|
989
|
+
}
|
|
990
|
+
var defaults5 = {
|
|
991
|
+
root: { display: "flex", flexWrap: "wrap", alignItems: "center", justifyContent: "space-between", gap: "12px", maxWidth: "28rem", padding: "8px 12px", fontSize: "14px", borderRadius: "6px", backgroundColor: "#fffbeb", color: "#78350f" },
|
|
992
|
+
text: {},
|
|
993
|
+
action: {}
|
|
994
|
+
};
|
|
995
|
+
function TrashedBanner({ since, by, restore, formatDate: formatDate2 = formatTrashedDate, labels, classNames }) {
|
|
996
|
+
const part = (key) => {
|
|
997
|
+
const className = classNames?.[key];
|
|
998
|
+
return className ? { className } : { style: defaults5[key] };
|
|
999
|
+
};
|
|
1000
|
+
const when = since ? formatDate2(since) : labels?.earlier ?? "earlier";
|
|
1001
|
+
const sentence = `${labels?.intro ? `${labels.intro} ` : ""}${labels?.since ?? "In the Trash since"} ${when} ${labels?.by ?? "by"} ${by}.`;
|
|
1002
|
+
return /* @__PURE__ */ jsxs8("div", { role: "status", ...part("root"), children: [
|
|
1003
|
+
/* @__PURE__ */ jsx9("span", { ...part("text"), children: sentence }),
|
|
1004
|
+
restore ? /* @__PURE__ */ jsx9("span", { ...part("action"), children: restore }) : null
|
|
1005
|
+
] });
|
|
1006
|
+
}
|
|
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
|
+
|
|
1050
|
+
// src/components/show-once-secret.tsx
|
|
1051
|
+
import { useEffect as useEffect5 } from "react";
|
|
1052
|
+
|
|
1053
|
+
// src/hooks/use-copy-to-clipboard.ts
|
|
1054
|
+
import { useCallback as useCallback3, useEffect as useEffect4, useRef as useRef4, useState as useState6 } from "react";
|
|
1055
|
+
var COPY_NOTE_COPIED = "Copied.";
|
|
1056
|
+
var COPY_NOTE_FAILED = "Could not copy automatically. Select the text and copy it yourself.";
|
|
1057
|
+
function useCopyToClipboard(options = {}) {
|
|
1058
|
+
const [status, setStatus] = useState6(null);
|
|
1059
|
+
const latest = useRef4(options);
|
|
1060
|
+
latest.current = options;
|
|
1061
|
+
const mounted = useRef4(true);
|
|
1062
|
+
const ticket = useRef4(0);
|
|
1063
|
+
const timer = useRef4(null);
|
|
1064
|
+
const clearTimer = () => {
|
|
1065
|
+
if (timer.current !== null) clearTimeout(timer.current);
|
|
1066
|
+
timer.current = null;
|
|
1067
|
+
};
|
|
1068
|
+
useEffect4(() => {
|
|
1069
|
+
mounted.current = true;
|
|
1070
|
+
return () => {
|
|
1071
|
+
mounted.current = false;
|
|
1072
|
+
clearTimer();
|
|
1073
|
+
};
|
|
1074
|
+
}, []);
|
|
1075
|
+
const show = (next) => {
|
|
1076
|
+
clearTimer();
|
|
1077
|
+
setStatus(next);
|
|
1078
|
+
const after = latest.current.resetAfterMs;
|
|
1079
|
+
if (after !== void 0 && after > 0) timer.current = setTimeout(() => setStatus(null), after);
|
|
1080
|
+
};
|
|
1081
|
+
const copy = useCallback3(async (text) => {
|
|
1082
|
+
const mine = ++ticket.current;
|
|
1083
|
+
let ok = false;
|
|
1084
|
+
try {
|
|
1085
|
+
await navigator.clipboard.writeText(text);
|
|
1086
|
+
ok = true;
|
|
1087
|
+
} catch {
|
|
1088
|
+
ok = false;
|
|
1089
|
+
}
|
|
1090
|
+
if (mounted.current && mine === ticket.current) show(ok ? "copied" : "failed");
|
|
1091
|
+
return ok;
|
|
1092
|
+
}, []);
|
|
1093
|
+
const reset = useCallback3(() => {
|
|
1094
|
+
ticket.current += 1;
|
|
1095
|
+
clearTimer();
|
|
1096
|
+
setStatus(null);
|
|
1097
|
+
}, []);
|
|
1098
|
+
const note = status === "copied" ? options.copiedNote ?? COPY_NOTE_COPIED : status === "failed" ? options.failedNote ?? COPY_NOTE_FAILED : null;
|
|
1099
|
+
return { copy, note, status, reset };
|
|
1100
|
+
}
|
|
1101
|
+
|
|
1102
|
+
// src/components/show-once-secret.tsx
|
|
1103
|
+
import { jsx as jsx11, jsxs as jsxs10 } from "react/jsx-runtime";
|
|
1104
|
+
var defaults7 = {
|
|
1105
|
+
root: { display: "flex", flexDirection: "column", gap: "8px", padding: "12px 16px", border: "1px solid #fcd34d", borderRadius: "6px", backgroundColor: "#fffbeb" },
|
|
1106
|
+
title: { margin: 0, fontSize: "14px", fontWeight: 500, color: "#78350f" },
|
|
1107
|
+
warning: { fontWeight: 400 },
|
|
1108
|
+
secret: { display: "block", padding: "4px 8px", fontFamily: "monospace", fontSize: "14px", overflowWrap: "anywhere", borderRadius: "4px", border: "1px solid #e5e5e5", backgroundColor: "#ffffff", color: "#171717", userSelect: "all" },
|
|
1109
|
+
actions: { display: "flex", flexWrap: "wrap", alignItems: "center", gap: "12px" },
|
|
1110
|
+
copy: { padding: "4px 12px", fontSize: "14px", border: "1px solid #d4d4d4", borderRadius: "6px", backgroundColor: "#ffffff", color: "#262626", cursor: "pointer" },
|
|
1111
|
+
done: { padding: "4px 12px", fontSize: "14px", border: "none", backgroundColor: "transparent", color: "#404040", cursor: "pointer" },
|
|
1112
|
+
note: { fontSize: "14px", color: "#404040" }
|
|
1113
|
+
};
|
|
1114
|
+
function ShowOnceSecret({ secret, title, onDone, display = "text", secretTestId, children, labels, classNames }) {
|
|
1115
|
+
const { copy, note, status, reset } = useCopyToClipboard({ copiedNote: labels?.copied, failedNote: labels?.failed });
|
|
1116
|
+
useEffect5(() => {
|
|
1117
|
+
reset();
|
|
1118
|
+
}, [secret, reset]);
|
|
1119
|
+
const part = (key) => {
|
|
1120
|
+
const className = classNames?.[key];
|
|
1121
|
+
return className ? { className } : { style: defaults7[key] };
|
|
1122
|
+
};
|
|
1123
|
+
return /* @__PURE__ */ jsxs10("div", { ...part("root"), children: [
|
|
1124
|
+
/* @__PURE__ */ jsxs10("p", { ...part("title"), children: [
|
|
1125
|
+
title,
|
|
1126
|
+
" ",
|
|
1127
|
+
/* @__PURE__ */ jsx11("span", { ...part("warning"), children: labels?.warning ?? "Copy it now: you will not see it again." })
|
|
1128
|
+
] }),
|
|
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(
|
|
1133
|
+
"button",
|
|
1134
|
+
{
|
|
1135
|
+
type: "button",
|
|
1136
|
+
onClick: () => {
|
|
1137
|
+
reset();
|
|
1138
|
+
onDone();
|
|
1139
|
+
},
|
|
1140
|
+
...part("done"),
|
|
1141
|
+
children: labels?.done ?? "Done"
|
|
1142
|
+
}
|
|
1143
|
+
),
|
|
1144
|
+
/* @__PURE__ */ jsx11("span", { role: "status", "data-status": status ?? void 0, ...part("note"), children: note })
|
|
1145
|
+
] }),
|
|
1146
|
+
children
|
|
1147
|
+
] });
|
|
1148
|
+
}
|
|
1149
|
+
|
|
1150
|
+
// src/components/entity-picker.tsx
|
|
1151
|
+
import { useCallback as useCallback4, useEffect as useEffect6, useId as useId2, useRef as useRef5, useState as useState7 } from "react";
|
|
1152
|
+
import { jsx as jsx12, jsxs as jsxs11 } from "react/jsx-runtime";
|
|
1153
|
+
var defaults8 = {
|
|
884
1154
|
root: { position: "relative", display: "inline-flex", alignItems: "center", gap: "4px", width: "100%" },
|
|
885
1155
|
input: { flex: 1, minWidth: 0, padding: "8px 10px", fontSize: "14px", border: "1px solid #d4d4d4", borderRadius: "6px", backgroundColor: "#ffffff", color: "#171717" },
|
|
886
1156
|
clear: { padding: "4px 8px", fontSize: "14px", border: "1px solid transparent", borderRadius: "6px", backgroundColor: "transparent", color: "#525252", cursor: "pointer" },
|
|
@@ -915,28 +1185,28 @@ function EntityPicker({
|
|
|
915
1185
|
style
|
|
916
1186
|
}) {
|
|
917
1187
|
const listId = useId2();
|
|
918
|
-
const listRef =
|
|
919
|
-
const inputRef =
|
|
920
|
-
const selectAfterRender =
|
|
921
|
-
const [text, setText] =
|
|
922
|
-
const [editing, setEditing] =
|
|
923
|
-
const [open, setOpen] =
|
|
924
|
-
const [results, setResults] =
|
|
925
|
-
const [status, setStatus] =
|
|
926
|
-
const [searched, setSearched] =
|
|
927
|
-
const [activeIndex, setActiveIndex] =
|
|
928
|
-
const timer =
|
|
929
|
-
const controller =
|
|
930
|
-
const latest =
|
|
931
|
-
const cancelSearch =
|
|
1188
|
+
const listRef = useRef5(null);
|
|
1189
|
+
const inputRef = useRef5(null);
|
|
1190
|
+
const selectAfterRender = useRef5(null);
|
|
1191
|
+
const [text, setText] = useState7("");
|
|
1192
|
+
const [editing, setEditing] = useState7(false);
|
|
1193
|
+
const [open, setOpen] = useState7(false);
|
|
1194
|
+
const [results, setResults] = useState7([]);
|
|
1195
|
+
const [status, setStatus] = useState7("idle");
|
|
1196
|
+
const [searched, setSearched] = useState7(false);
|
|
1197
|
+
const [activeIndex, setActiveIndex] = useState7(-1);
|
|
1198
|
+
const timer = useRef5(null);
|
|
1199
|
+
const controller = useRef5(null);
|
|
1200
|
+
const latest = useRef5(0);
|
|
1201
|
+
const cancelSearch = useCallback4(() => {
|
|
932
1202
|
if (timer.current) clearTimeout(timer.current);
|
|
933
1203
|
timer.current = null;
|
|
934
1204
|
controller.current?.abort();
|
|
935
1205
|
controller.current = null;
|
|
936
1206
|
latest.current++;
|
|
937
1207
|
}, []);
|
|
938
|
-
|
|
939
|
-
const runSearch =
|
|
1208
|
+
useEffect6(() => cancelSearch, [cancelSearch]);
|
|
1209
|
+
const runSearch = useCallback4(
|
|
940
1210
|
(query) => {
|
|
941
1211
|
cancelSearch();
|
|
942
1212
|
const trimmed = query.trim();
|
|
@@ -991,17 +1261,17 @@ function EntityPicker({
|
|
|
991
1261
|
const showListbox = showPopup && results.length > 0;
|
|
992
1262
|
const activeId = showListbox && activeIndex >= 0 ? `${listId}-opt-${activeIndex}` : void 0;
|
|
993
1263
|
const announcement = !showPopup ? "" : status === "loading" ? loadingText : status === "error" ? errorText : results.length === 0 ? emptyText : "";
|
|
994
|
-
|
|
1264
|
+
useEffect6(() => {
|
|
995
1265
|
if (showListbox && activeIndex >= 0) listRef.current?.children[activeIndex]?.scrollIntoView?.({ block: "nearest" });
|
|
996
1266
|
}, [showListbox, activeIndex]);
|
|
997
|
-
|
|
1267
|
+
useEffect6(() => {
|
|
998
1268
|
const pending = selectAfterRender.current;
|
|
999
1269
|
if (!pending || editing) return;
|
|
1000
1270
|
if ((value ? getKey(value) : null) !== pending.key) return;
|
|
1001
1271
|
selectAfterRender.current = null;
|
|
1002
1272
|
if (document.activeElement === inputRef.current) inputRef.current?.select();
|
|
1003
1273
|
}, [value, editing, getKey]);
|
|
1004
|
-
|
|
1274
|
+
useEffect6(() => {
|
|
1005
1275
|
if (disabled) stopEditing();
|
|
1006
1276
|
}, [disabled]);
|
|
1007
1277
|
const onKeyDown = (event) => {
|
|
@@ -1027,7 +1297,7 @@ function EntityPicker({
|
|
|
1027
1297
|
const partProps = (key) => {
|
|
1028
1298
|
const className = classNames?.[key];
|
|
1029
1299
|
if (className) return { className, style: key === "root" ? style : void 0 };
|
|
1030
|
-
return { style: key === "root" ? { ...
|
|
1300
|
+
return { style: key === "root" ? { ...defaults8.root, ...style } : defaults8[key] };
|
|
1031
1301
|
};
|
|
1032
1302
|
const optionProps = (active) => {
|
|
1033
1303
|
const optionClass = classNames?.option;
|
|
@@ -1036,8 +1306,8 @@ function EntityPicker({
|
|
|
1036
1306
|
return { className, style: optionClass ? void 0 : { ...optionDefaults.base, ...active && !activeClass ? optionDefaults.active : {} } };
|
|
1037
1307
|
};
|
|
1038
1308
|
const shown = editing ? text : value ? getLabel(value) : "";
|
|
1039
|
-
return /* @__PURE__ */
|
|
1040
|
-
/* @__PURE__ */
|
|
1309
|
+
return /* @__PURE__ */ jsxs11("div", { ...partProps("root"), children: [
|
|
1310
|
+
/* @__PURE__ */ jsx12(
|
|
1041
1311
|
"input",
|
|
1042
1312
|
{
|
|
1043
1313
|
...partProps("input"),
|
|
@@ -1069,19 +1339,19 @@ function EntityPicker({
|
|
|
1069
1339
|
}
|
|
1070
1340
|
}
|
|
1071
1341
|
),
|
|
1072
|
-
name !== void 0 ? /* @__PURE__ */
|
|
1073
|
-
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: () => {
|
|
1074
1344
|
onChange(null);
|
|
1075
1345
|
inputRef.current?.focus();
|
|
1076
1346
|
}, children: "\xD7" }) : null,
|
|
1077
|
-
/* @__PURE__ */
|
|
1347
|
+
/* @__PURE__ */ jsx12("div", { role: "status", "aria-live": "polite", style: visuallyHidden2, children: announcement }),
|
|
1078
1348
|
showPopup ? (
|
|
1079
1349
|
// mousedown anywhere in the popup (an option, the scrollbar, a message) must not move focus out of the input, or its
|
|
1080
1350
|
// blur would close the list before the click lands (and make a long list impossible to scroll by dragging)
|
|
1081
|
-
/* @__PURE__ */
|
|
1082
|
-
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) => {
|
|
1083
1353
|
const active = index === activeIndex;
|
|
1084
|
-
return /* @__PURE__ */
|
|
1354
|
+
return /* @__PURE__ */ jsx12(
|
|
1085
1355
|
"li",
|
|
1086
1356
|
{
|
|
1087
1357
|
id: `${listId}-opt-${index}`,
|
|
@@ -1097,16 +1367,16 @@ function EntityPicker({
|
|
|
1097
1367
|
getKey(item)
|
|
1098
1368
|
);
|
|
1099
1369
|
}) }) : null,
|
|
1100
|
-
status === "loading" ? /* @__PURE__ */
|
|
1101
|
-
status === "error" ? /* @__PURE__ */
|
|
1102
|
-
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
|
|
1103
1373
|
] })
|
|
1104
1374
|
) : null
|
|
1105
1375
|
] });
|
|
1106
1376
|
}
|
|
1107
1377
|
|
|
1108
1378
|
// src/components/rich-text-editor.tsx
|
|
1109
|
-
import { useCallback as
|
|
1379
|
+
import { useCallback as useCallback5, useEffect as useEffect7, useRef as useRef6, useState as useState8 } from "react";
|
|
1110
1380
|
|
|
1111
1381
|
// src/components/rich-text-editor-styles.ts
|
|
1112
1382
|
var containerStyle = {
|
|
@@ -1159,7 +1429,7 @@ var editableStyle = {
|
|
|
1159
1429
|
};
|
|
1160
1430
|
|
|
1161
1431
|
// src/components/rich-text-editor.tsx
|
|
1162
|
-
import { jsx as
|
|
1432
|
+
import { jsx as jsx13, jsxs as jsxs12 } from "react/jsx-runtime";
|
|
1163
1433
|
var TOOLBAR_BUTTONS = [
|
|
1164
1434
|
{ command: "bold", label: "B", ariaLabel: "Bold" },
|
|
1165
1435
|
{ command: "italic", label: "I", ariaLabel: "Italic" },
|
|
@@ -1191,26 +1461,26 @@ function RichTextEditor({
|
|
|
1191
1461
|
className,
|
|
1192
1462
|
style
|
|
1193
1463
|
}) {
|
|
1194
|
-
const editorRef =
|
|
1195
|
-
const [isFocused, setIsFocused] =
|
|
1196
|
-
const [isEmpty, setIsEmpty] =
|
|
1197
|
-
const [linkError, setLinkError] =
|
|
1198
|
-
|
|
1464
|
+
const editorRef = useRef6(null);
|
|
1465
|
+
const [isFocused, setIsFocused] = useState8(false);
|
|
1466
|
+
const [isEmpty, setIsEmpty] = useState8(isEmptyHtml(content));
|
|
1467
|
+
const [linkError, setLinkError] = useState8(null);
|
|
1468
|
+
useEffect7(() => {
|
|
1199
1469
|
const el = editorRef.current;
|
|
1200
1470
|
if (el && !isFocused && el.innerHTML !== content) {
|
|
1201
1471
|
el.innerHTML = content;
|
|
1202
1472
|
setIsEmpty(isEmptyHtml(content));
|
|
1203
1473
|
}
|
|
1204
1474
|
}, [content, isFocused, editable]);
|
|
1205
|
-
|
|
1475
|
+
useEffect7(() => {
|
|
1206
1476
|
if (autoFocus) editorRef.current?.focus();
|
|
1207
1477
|
}, []);
|
|
1208
|
-
const handleInput =
|
|
1478
|
+
const handleInput = useCallback5(() => {
|
|
1209
1479
|
const html = editorRef.current?.innerHTML ?? "";
|
|
1210
1480
|
setIsEmpty(isEmptyHtml(html));
|
|
1211
1481
|
onChange(html);
|
|
1212
1482
|
}, [onChange]);
|
|
1213
|
-
const runCommand =
|
|
1483
|
+
const runCommand = useCallback5(
|
|
1214
1484
|
(command, value) => {
|
|
1215
1485
|
editorRef.current?.focus();
|
|
1216
1486
|
document.execCommand(command, false, value);
|
|
@@ -1218,7 +1488,7 @@ function RichTextEditor({
|
|
|
1218
1488
|
},
|
|
1219
1489
|
[handleInput]
|
|
1220
1490
|
);
|
|
1221
|
-
const handleLink =
|
|
1491
|
+
const handleLink = useCallback5(() => {
|
|
1222
1492
|
const url = window.prompt("Link URL")?.trim();
|
|
1223
1493
|
setLinkError(null);
|
|
1224
1494
|
if (!url) return;
|
|
@@ -1229,7 +1499,7 @@ function RichTextEditor({
|
|
|
1229
1499
|
runCommand("createLink", url);
|
|
1230
1500
|
}, [runCommand]);
|
|
1231
1501
|
if (!editable) {
|
|
1232
|
-
return /* @__PURE__ */
|
|
1502
|
+
return /* @__PURE__ */ jsx13(
|
|
1233
1503
|
"div",
|
|
1234
1504
|
{
|
|
1235
1505
|
className: [className, "ordinatio-rte", "ordinatio-rte-readonly"].filter(Boolean).join(" "),
|
|
@@ -1238,9 +1508,9 @@ function RichTextEditor({
|
|
|
1238
1508
|
}
|
|
1239
1509
|
);
|
|
1240
1510
|
}
|
|
1241
|
-
return /* @__PURE__ */
|
|
1242
|
-
/* @__PURE__ */
|
|
1243
|
-
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(
|
|
1244
1514
|
"button",
|
|
1245
1515
|
{
|
|
1246
1516
|
type: "button",
|
|
@@ -1254,7 +1524,7 @@ function RichTextEditor({
|
|
|
1254
1524
|
},
|
|
1255
1525
|
btn.command
|
|
1256
1526
|
)),
|
|
1257
|
-
/* @__PURE__ */
|
|
1527
|
+
/* @__PURE__ */ jsx13(
|
|
1258
1528
|
"button",
|
|
1259
1529
|
{
|
|
1260
1530
|
type: "button",
|
|
@@ -1267,10 +1537,10 @@ function RichTextEditor({
|
|
|
1267
1537
|
children: "\u{1F517}"
|
|
1268
1538
|
}
|
|
1269
1539
|
),
|
|
1270
|
-
toolbarRight ? /* @__PURE__ */
|
|
1540
|
+
toolbarRight ? /* @__PURE__ */ jsx13("div", { className: "ordinatio-rte-toolbar-right", style: toolbarRightStyle, children: toolbarRight }) : null
|
|
1271
1541
|
] }),
|
|
1272
|
-
linkError ? /* @__PURE__ */
|
|
1273
|
-
/* @__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: [
|
|
1274
1544
|
isEmpty ? (
|
|
1275
1545
|
// Shown while empty REGARDLESS of focus — WorldClass cycle 1:
|
|
1276
1546
|
// the prior `isEmpty && !isFocused` condition hid the
|
|
@@ -1279,7 +1549,7 @@ function RichTextEditor({
|
|
|
1279
1549
|
// the click landed. Matches native `<textarea placeholder>`
|
|
1280
1550
|
// behavior (visible while focused-and-empty, removed only once
|
|
1281
1551
|
// the user types).
|
|
1282
|
-
/* @__PURE__ */
|
|
1552
|
+
/* @__PURE__ */ jsx13(
|
|
1283
1553
|
"div",
|
|
1284
1554
|
{
|
|
1285
1555
|
"aria-hidden": "true",
|
|
@@ -1289,7 +1559,7 @@ function RichTextEditor({
|
|
|
1289
1559
|
}
|
|
1290
1560
|
)
|
|
1291
1561
|
) : null,
|
|
1292
|
-
/* @__PURE__ */
|
|
1562
|
+
/* @__PURE__ */ jsx13(
|
|
1293
1563
|
"div",
|
|
1294
1564
|
{
|
|
1295
1565
|
ref: editorRef,
|
|
@@ -1311,7 +1581,7 @@ function RichTextEditor({
|
|
|
1311
1581
|
}
|
|
1312
1582
|
|
|
1313
1583
|
// src/components/reply-panel.tsx
|
|
1314
|
-
import { useEffect as
|
|
1584
|
+
import { useEffect as useEffect8, useId as useId3, useRef as useRef7, useState as useState9 } from "react";
|
|
1315
1585
|
|
|
1316
1586
|
// src/components/subject-prefix.ts
|
|
1317
1587
|
function prefixSubject(subject, mode) {
|
|
@@ -1401,7 +1671,7 @@ var disabledButtonStyle = {
|
|
|
1401
1671
|
};
|
|
1402
1672
|
|
|
1403
1673
|
// src/components/reply-panel.tsx
|
|
1404
|
-
import { Fragment as Fragment3, jsx as
|
|
1674
|
+
import { Fragment as Fragment3, jsx as jsx14, jsxs as jsxs13 } from "react/jsx-runtime";
|
|
1405
1675
|
function ReplyPanel({
|
|
1406
1676
|
mode = "reply",
|
|
1407
1677
|
subject,
|
|
@@ -1425,17 +1695,17 @@ function ReplyPanel({
|
|
|
1425
1695
|
const ccId = `${idPrefix}-cc`;
|
|
1426
1696
|
const bccId = `${idPrefix}-bcc`;
|
|
1427
1697
|
const subjectId = `${idPrefix}-subject`;
|
|
1428
|
-
const [to, setTo] =
|
|
1429
|
-
const [cc, setCc] =
|
|
1430
|
-
const [bcc, setBcc] =
|
|
1431
|
-
const [showCcBcc, setShowCcBcc] =
|
|
1432
|
-
const [editedSubject, setEditedSubject] =
|
|
1433
|
-
const [body, setBody] =
|
|
1434
|
-
const [sending, setSending] =
|
|
1435
|
-
const [error, setError] =
|
|
1436
|
-
const [sent, setSent] =
|
|
1437
|
-
const isMountedRef =
|
|
1438
|
-
|
|
1698
|
+
const [to, setTo] = useState9(defaultTo);
|
|
1699
|
+
const [cc, setCc] = useState9(initialCc);
|
|
1700
|
+
const [bcc, setBcc] = useState9("");
|
|
1701
|
+
const [showCcBcc, setShowCcBcc] = useState9(initialShowCcBcc || !!initialCc);
|
|
1702
|
+
const [editedSubject, setEditedSubject] = useState9(defaultSubject);
|
|
1703
|
+
const [body, setBody] = useState9(initialBody);
|
|
1704
|
+
const [sending, setSending] = useState9(false);
|
|
1705
|
+
const [error, setError] = useState9(null);
|
|
1706
|
+
const [sent, setSent] = useState9(false);
|
|
1707
|
+
const isMountedRef = useRef7(true);
|
|
1708
|
+
useEffect8(() => {
|
|
1439
1709
|
isMountedRef.current = true;
|
|
1440
1710
|
return () => {
|
|
1441
1711
|
isMountedRef.current = false;
|
|
@@ -1480,16 +1750,16 @@ function ReplyPanel({
|
|
|
1480
1750
|
if (isMountedRef.current) setSending(false);
|
|
1481
1751
|
}
|
|
1482
1752
|
};
|
|
1483
|
-
return /* @__PURE__ */
|
|
1753
|
+
return /* @__PURE__ */ jsxs13(
|
|
1484
1754
|
"div",
|
|
1485
1755
|
{
|
|
1486
1756
|
className: [className, "ordinatio-reply-panel"].filter(Boolean).join(" "),
|
|
1487
1757
|
style: className ? style : { display: "flex", flexDirection: "column", gap: "8px", ...style },
|
|
1488
1758
|
children: [
|
|
1489
|
-
/* @__PURE__ */
|
|
1490
|
-
/* @__PURE__ */
|
|
1491
|
-
/* @__PURE__ */
|
|
1492
|
-
/* @__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(
|
|
1493
1763
|
"input",
|
|
1494
1764
|
{
|
|
1495
1765
|
id: toId,
|
|
@@ -1517,7 +1787,7 @@ function ReplyPanel({
|
|
|
1517
1787
|
// and aria-controls referenced ids (ccId/bccId) that don't
|
|
1518
1788
|
// exist in the DOM until AFTER this button has already
|
|
1519
1789
|
// unmounted. A one-directional reveal, not a toggle.
|
|
1520
|
-
/* @__PURE__ */
|
|
1790
|
+
/* @__PURE__ */ jsx14(
|
|
1521
1791
|
"button",
|
|
1522
1792
|
{
|
|
1523
1793
|
type: "button",
|
|
@@ -1530,10 +1800,10 @@ function ReplyPanel({
|
|
|
1530
1800
|
)
|
|
1531
1801
|
) : null
|
|
1532
1802
|
] }),
|
|
1533
|
-
showCcBcc ? /* @__PURE__ */
|
|
1534
|
-
/* @__PURE__ */
|
|
1535
|
-
/* @__PURE__ */
|
|
1536
|
-
/* @__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(
|
|
1537
1807
|
"input",
|
|
1538
1808
|
{
|
|
1539
1809
|
id: ccId,
|
|
@@ -1551,9 +1821,9 @@ function ReplyPanel({
|
|
|
1551
1821
|
}
|
|
1552
1822
|
)
|
|
1553
1823
|
] }),
|
|
1554
|
-
/* @__PURE__ */
|
|
1555
|
-
/* @__PURE__ */
|
|
1556
|
-
/* @__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(
|
|
1557
1827
|
"input",
|
|
1558
1828
|
{
|
|
1559
1829
|
id: bccId,
|
|
@@ -1572,9 +1842,9 @@ function ReplyPanel({
|
|
|
1572
1842
|
)
|
|
1573
1843
|
] })
|
|
1574
1844
|
] }) : null,
|
|
1575
|
-
/* @__PURE__ */
|
|
1576
|
-
/* @__PURE__ */
|
|
1577
|
-
/* @__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(
|
|
1578
1848
|
"input",
|
|
1579
1849
|
{
|
|
1580
1850
|
id: subjectId,
|
|
@@ -1593,9 +1863,9 @@ function ReplyPanel({
|
|
|
1593
1863
|
)
|
|
1594
1864
|
] })
|
|
1595
1865
|
] }),
|
|
1596
|
-
error ? /* @__PURE__ */
|
|
1597
|
-
sent && resolvedSuccessMessage ? /* @__PURE__ */
|
|
1598
|
-
/* @__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(
|
|
1599
1869
|
RichTextEditor,
|
|
1600
1870
|
{
|
|
1601
1871
|
content: body,
|
|
@@ -1609,8 +1879,8 @@ function ReplyPanel({
|
|
|
1609
1879
|
locked: sending
|
|
1610
1880
|
}
|
|
1611
1881
|
),
|
|
1612
|
-
/* @__PURE__ */
|
|
1613
|
-
showCancel && onCancel ? /* @__PURE__ */
|
|
1882
|
+
/* @__PURE__ */ jsxs13("div", { className: "ordinatio-reply-actions", style: actionsRowStyle, children: [
|
|
1883
|
+
showCancel && onCancel ? /* @__PURE__ */ jsx14(
|
|
1614
1884
|
"button",
|
|
1615
1885
|
{
|
|
1616
1886
|
type: "button",
|
|
@@ -1621,7 +1891,7 @@ function ReplyPanel({
|
|
|
1621
1891
|
children: "Cancel"
|
|
1622
1892
|
}
|
|
1623
1893
|
) : null,
|
|
1624
|
-
/* @__PURE__ */
|
|
1894
|
+
/* @__PURE__ */ jsx14(
|
|
1625
1895
|
"button",
|
|
1626
1896
|
{
|
|
1627
1897
|
type: "button",
|
|
@@ -1639,7 +1909,7 @@ function ReplyPanel({
|
|
|
1639
1909
|
}
|
|
1640
1910
|
|
|
1641
1911
|
// src/hooks/use-keyboard-shortcuts.ts
|
|
1642
|
-
import { useEffect as
|
|
1912
|
+
import { useEffect as useEffect9, useCallback as useCallback6 } from "react";
|
|
1643
1913
|
|
|
1644
1914
|
// src/hooks/is-typing-context.ts
|
|
1645
1915
|
var TYPING_TAG_RE = /^(INPUT|TEXTAREA|SELECT)$/;
|
|
@@ -1664,14 +1934,14 @@ function useKeyboardShortcuts({
|
|
|
1664
1934
|
ignoreTags = []
|
|
1665
1935
|
}) {
|
|
1666
1936
|
const malformed = !Array.isArray(shortcuts);
|
|
1667
|
-
|
|
1937
|
+
useEffect9(() => {
|
|
1668
1938
|
if (malformed) {
|
|
1669
1939
|
console.error(
|
|
1670
1940
|
"[useKeyboardShortcuts] expected { shortcuts: KeyboardShortcut[] } \u2014 got a non-array `shortcuts` (legacy array call form?). All shortcuts for this caller are disabled until the call is fixed."
|
|
1671
1941
|
);
|
|
1672
1942
|
}
|
|
1673
1943
|
}, [malformed]);
|
|
1674
|
-
const handleKeyDown =
|
|
1944
|
+
const handleKeyDown = useCallback6(
|
|
1675
1945
|
(e) => {
|
|
1676
1946
|
if (!enabled || malformed) return;
|
|
1677
1947
|
if (e.isComposing || e.keyCode === 229) return;
|
|
@@ -1699,7 +1969,7 @@ function useKeyboardShortcuts({
|
|
|
1699
1969
|
},
|
|
1700
1970
|
[shortcuts, enabled, ignoreTags, malformed]
|
|
1701
1971
|
);
|
|
1702
|
-
|
|
1972
|
+
useEffect9(() => {
|
|
1703
1973
|
window.addEventListener("keydown", handleKeyDown);
|
|
1704
1974
|
return () => window.removeEventListener("keydown", handleKeyDown);
|
|
1705
1975
|
}, [handleKeyDown]);
|
|
@@ -1869,13 +2139,13 @@ function getShortcut(context, action) {
|
|
|
1869
2139
|
}
|
|
1870
2140
|
|
|
1871
2141
|
// src/components/keyboard-shortcuts-panel.tsx
|
|
1872
|
-
import { useEffect as
|
|
1873
|
-
import { Fragment as Fragment4, jsx as
|
|
2142
|
+
import { useEffect as useEffect10, useState as useState10 } from "react";
|
|
2143
|
+
import { Fragment as Fragment4, jsx as jsx15, jsxs as jsxs14 } from "react/jsx-runtime";
|
|
1874
2144
|
function KeyboardShortcutsPanel({
|
|
1875
2145
|
contexts = ALL_SHORTCUT_CONTEXTS
|
|
1876
2146
|
}) {
|
|
1877
|
-
const [open, setOpen] =
|
|
1878
|
-
|
|
2147
|
+
const [open, setOpen] = useState10(false);
|
|
2148
|
+
useEffect10(() => {
|
|
1879
2149
|
function handleKey(e) {
|
|
1880
2150
|
if (e.key === "?" && !e.metaKey && !e.ctrlKey && !e.altKey) {
|
|
1881
2151
|
const tag = e.target?.tagName;
|
|
@@ -1892,33 +2162,33 @@ function KeyboardShortcutsPanel({
|
|
|
1892
2162
|
return () => window.removeEventListener("keydown", handleKey);
|
|
1893
2163
|
}, [open]);
|
|
1894
2164
|
if (!open) return null;
|
|
1895
|
-
return /* @__PURE__ */
|
|
1896
|
-
/* @__PURE__ */
|
|
2165
|
+
return /* @__PURE__ */ jsxs14(Fragment4, { children: [
|
|
2166
|
+
/* @__PURE__ */ jsx15(
|
|
1897
2167
|
"div",
|
|
1898
2168
|
{
|
|
1899
2169
|
className: "fixed inset-0 z-50 bg-black/50 backdrop-blur-sm",
|
|
1900
2170
|
onClick: () => setOpen(false)
|
|
1901
2171
|
}
|
|
1902
2172
|
),
|
|
1903
|
-
/* @__PURE__ */
|
|
1904
|
-
/* @__PURE__ */
|
|
1905
|
-
/* @__PURE__ */
|
|
1906
|
-
/* @__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: [
|
|
1907
2177
|
"Press ",
|
|
1908
|
-
/* @__PURE__ */
|
|
2178
|
+
/* @__PURE__ */ jsx15("kbd", { className: "px-1.5 py-0.5 bg-muted rounded text-xs font-mono", children: "?" }),
|
|
1909
2179
|
" to toggle this panel"
|
|
1910
2180
|
] })
|
|
1911
2181
|
] }),
|
|
1912
|
-
/* @__PURE__ */
|
|
1913
|
-
/* @__PURE__ */
|
|
1914
|
-
/* @__PURE__ */
|
|
1915
|
-
/* @__PURE__ */
|
|
1916
|
-
/* @__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 })
|
|
1917
2187
|
] }, key)) })
|
|
1918
2188
|
] }, ctx.name)) }),
|
|
1919
|
-
/* @__PURE__ */
|
|
2189
|
+
/* @__PURE__ */ jsxs14("div", { className: "px-6 py-3 border-t bg-muted/30 text-xs text-muted-foreground text-center", children: [
|
|
1920
2190
|
"Press ",
|
|
1921
|
-
/* @__PURE__ */
|
|
2191
|
+
/* @__PURE__ */ jsx15("kbd", { className: "px-1 py-0.5 bg-muted rounded", children: "Esc" }),
|
|
1922
2192
|
" to close"
|
|
1923
2193
|
] })
|
|
1924
2194
|
] }) })
|
|
@@ -1926,21 +2196,21 @@ function KeyboardShortcutsPanel({
|
|
|
1926
2196
|
}
|
|
1927
2197
|
|
|
1928
2198
|
// src/hooks/use-auto-save.ts
|
|
1929
|
-
import { useEffect as
|
|
2199
|
+
import { useEffect as useEffect11, useRef as useRef8, useCallback as useCallback7, useState as useState11 } from "react";
|
|
1930
2200
|
function useAutoSave({
|
|
1931
2201
|
data,
|
|
1932
2202
|
onSave,
|
|
1933
2203
|
delay = 5e3,
|
|
1934
2204
|
enabled = true
|
|
1935
2205
|
}) {
|
|
1936
|
-
const [lastSavedAt, setLastSavedAt] =
|
|
1937
|
-
const [isSaving, setIsSaving] =
|
|
1938
|
-
const [saveError, setSaveError] =
|
|
1939
|
-
const timerRef =
|
|
1940
|
-
const dataRef =
|
|
1941
|
-
const savedDataRef =
|
|
2206
|
+
const [lastSavedAt, setLastSavedAt] = useState11(null);
|
|
2207
|
+
const [isSaving, setIsSaving] = useState11(false);
|
|
2208
|
+
const [saveError, setSaveError] = useState11(null);
|
|
2209
|
+
const timerRef = useRef8(null);
|
|
2210
|
+
const dataRef = useRef8(data);
|
|
2211
|
+
const savedDataRef = useRef8(null);
|
|
1942
2212
|
dataRef.current = data;
|
|
1943
|
-
const save =
|
|
2213
|
+
const save = useCallback7(async () => {
|
|
1944
2214
|
const currentJson = JSON.stringify(dataRef.current);
|
|
1945
2215
|
if (currentJson === savedDataRef.current) return;
|
|
1946
2216
|
setIsSaving(true);
|
|
@@ -1955,7 +2225,7 @@ function useAutoSave({
|
|
|
1955
2225
|
setIsSaving(false);
|
|
1956
2226
|
}
|
|
1957
2227
|
}, [onSave]);
|
|
1958
|
-
|
|
2228
|
+
useEffect11(() => {
|
|
1959
2229
|
if (!enabled) return;
|
|
1960
2230
|
if (timerRef.current) clearTimeout(timerRef.current);
|
|
1961
2231
|
timerRef.current = setTimeout(save, delay);
|
|
@@ -1967,19 +2237,19 @@ function useAutoSave({
|
|
|
1967
2237
|
}
|
|
1968
2238
|
|
|
1969
2239
|
// src/hooks/use-polling.ts
|
|
1970
|
-
import { useEffect as
|
|
2240
|
+
import { useEffect as useEffect12, useCallback as useCallback8, useRef as useRef9, useState as useState12 } from "react";
|
|
1971
2241
|
function usePolling({
|
|
1972
2242
|
fetcher,
|
|
1973
2243
|
interval = 3e4,
|
|
1974
2244
|
enabled = true,
|
|
1975
2245
|
onError
|
|
1976
2246
|
}) {
|
|
1977
|
-
const [data, setData] =
|
|
1978
|
-
const [isLoading, setIsLoading] =
|
|
1979
|
-
const [isRefreshing, setIsRefreshing] =
|
|
1980
|
-
const [error, setError] =
|
|
1981
|
-
const mountedRef =
|
|
1982
|
-
const doFetch =
|
|
2247
|
+
const [data, setData] = useState12(null);
|
|
2248
|
+
const [isLoading, setIsLoading] = useState12(true);
|
|
2249
|
+
const [isRefreshing, setIsRefreshing] = useState12(false);
|
|
2250
|
+
const [error, setError] = useState12(null);
|
|
2251
|
+
const mountedRef = useRef9(true);
|
|
2252
|
+
const doFetch = useCallback8(async (isInitial = false) => {
|
|
1983
2253
|
if (isInitial) setIsLoading(true);
|
|
1984
2254
|
else setIsRefreshing(true);
|
|
1985
2255
|
try {
|
|
@@ -2000,36 +2270,36 @@ function usePolling({
|
|
|
2000
2270
|
}
|
|
2001
2271
|
}
|
|
2002
2272
|
}, [fetcher, onError]);
|
|
2003
|
-
|
|
2273
|
+
useEffect12(() => {
|
|
2004
2274
|
mountedRef.current = true;
|
|
2005
2275
|
if (enabled) doFetch(true);
|
|
2006
2276
|
return () => {
|
|
2007
2277
|
mountedRef.current = false;
|
|
2008
2278
|
};
|
|
2009
2279
|
}, [doFetch, enabled]);
|
|
2010
|
-
|
|
2280
|
+
useEffect12(() => {
|
|
2011
2281
|
if (!enabled) return;
|
|
2012
2282
|
const timer = setInterval(() => doFetch(false), interval);
|
|
2013
2283
|
return () => clearInterval(timer);
|
|
2014
2284
|
}, [doFetch, interval, enabled]);
|
|
2015
|
-
const refresh =
|
|
2285
|
+
const refresh = useCallback8(() => doFetch(false), [doFetch]);
|
|
2016
2286
|
return { data, isLoading, isRefreshing, error, refresh };
|
|
2017
2287
|
}
|
|
2018
2288
|
|
|
2019
2289
|
// src/hooks/use-server-search.ts
|
|
2020
|
-
import { useEffect as
|
|
2290
|
+
import { useEffect as useEffect13, useRef as useRef10, useState as useState13, useCallback as useCallback9 } from "react";
|
|
2021
2291
|
function useServerSearch({
|
|
2022
2292
|
fetcher,
|
|
2023
2293
|
debounce = 150,
|
|
2024
2294
|
minChars = 1,
|
|
2025
2295
|
enabled = true
|
|
2026
2296
|
}) {
|
|
2027
|
-
const [query, setQuery] =
|
|
2028
|
-
const [results, setResults] =
|
|
2029
|
-
const [isSearching, setIsSearching] =
|
|
2030
|
-
const [isOpen, setIsOpen] =
|
|
2031
|
-
const timerRef =
|
|
2032
|
-
|
|
2297
|
+
const [query, setQuery] = useState13("");
|
|
2298
|
+
const [results, setResults] = useState13([]);
|
|
2299
|
+
const [isSearching, setIsSearching] = useState13(false);
|
|
2300
|
+
const [isOpen, setIsOpen] = useState13(false);
|
|
2301
|
+
const timerRef = useRef10(null);
|
|
2302
|
+
useEffect13(() => {
|
|
2033
2303
|
if (!enabled || query.length < minChars) {
|
|
2034
2304
|
setResults([]);
|
|
2035
2305
|
return;
|
|
@@ -2050,7 +2320,7 @@ function useServerSearch({
|
|
|
2050
2320
|
if (timerRef.current) clearTimeout(timerRef.current);
|
|
2051
2321
|
};
|
|
2052
2322
|
}, [query, fetcher, debounce, minChars, enabled]);
|
|
2053
|
-
const clear =
|
|
2323
|
+
const clear = useCallback9(() => {
|
|
2054
2324
|
setQuery("");
|
|
2055
2325
|
setResults([]);
|
|
2056
2326
|
setIsOpen(false);
|
|
@@ -2059,9 +2329,9 @@ function useServerSearch({
|
|
|
2059
2329
|
}
|
|
2060
2330
|
|
|
2061
2331
|
// src/hooks/use-iframe-focus-reclaim.ts
|
|
2062
|
-
import { useEffect as
|
|
2332
|
+
import { useEffect as useEffect14 } from "react";
|
|
2063
2333
|
function useIframeFocusReclaim(containerRef, enabled = true, iframeSelector = "iframe") {
|
|
2064
|
-
|
|
2334
|
+
useEffect14(() => {
|
|
2065
2335
|
if (!enabled) return;
|
|
2066
2336
|
const el = containerRef.current;
|
|
2067
2337
|
if (!el) return;
|
|
@@ -2188,11 +2458,11 @@ function useIframeFocusReclaim(containerRef, enabled = true, iframeSelector = "i
|
|
|
2188
2458
|
}
|
|
2189
2459
|
|
|
2190
2460
|
// src/hooks/use-form-action-keeping-input.ts
|
|
2191
|
-
import { useRef as
|
|
2461
|
+
import { useRef as useRef11, useState as useState14, useTransition } from "react";
|
|
2192
2462
|
function useFormActionKeepingInput(action, initialState) {
|
|
2193
|
-
const [state, setState] =
|
|
2463
|
+
const [state, setState] = useState14(initialState);
|
|
2194
2464
|
const [pending, startTransition] = useTransition();
|
|
2195
|
-
const inFlight =
|
|
2465
|
+
const inFlight = useRef11(false);
|
|
2196
2466
|
const onSubmit = (event) => {
|
|
2197
2467
|
event.preventDefault();
|
|
2198
2468
|
if (inFlight.current || pending) return;
|
|
@@ -2212,9 +2482,9 @@ function useFormActionKeepingInput(action, initialState) {
|
|
|
2212
2482
|
}
|
|
2213
2483
|
|
|
2214
2484
|
// src/hooks/use-synced-select.ts
|
|
2215
|
-
import { useLayoutEffect, useRef as
|
|
2485
|
+
import { useLayoutEffect, useRef as useRef12 } from "react";
|
|
2216
2486
|
function useSyncedSelect(value, resultKey) {
|
|
2217
|
-
const ref =
|
|
2487
|
+
const ref = useRef12(null);
|
|
2218
2488
|
useLayoutEffect(() => {
|
|
2219
2489
|
if (ref.current && ref.current.value !== value) ref.current.value = value;
|
|
2220
2490
|
}, [value, resultKey]);
|
|
@@ -2222,9 +2492,9 @@ function useSyncedSelect(value, resultKey) {
|
|
|
2222
2492
|
}
|
|
2223
2493
|
|
|
2224
2494
|
// src/hooks/use-saved-notice.ts
|
|
2225
|
-
import { useState as
|
|
2495
|
+
import { useState as useState15 } from "react";
|
|
2226
2496
|
function useSavedNotice(state) {
|
|
2227
|
-
const [editedAfter, setEditedAfter] =
|
|
2497
|
+
const [editedAfter, setEditedAfter] = useState15(null);
|
|
2228
2498
|
return {
|
|
2229
2499
|
showSaved: Boolean(state.saved) && editedAfter !== state,
|
|
2230
2500
|
markEdited: () => setEditedAfter(state)
|
|
@@ -2232,13 +2502,13 @@ function useSavedNotice(state) {
|
|
|
2232
2502
|
}
|
|
2233
2503
|
|
|
2234
2504
|
// src/hooks/use-arrival.ts
|
|
2235
|
-
import { useEffect as
|
|
2505
|
+
import { useEffect as useEffect15, useRef as useRef13, useState as useState16 } from "react";
|
|
2236
2506
|
var ARRIVAL_FADE_MS = 3e3;
|
|
2237
2507
|
function useArrival(active) {
|
|
2238
|
-
const ref =
|
|
2239
|
-
const done =
|
|
2240
|
-
const [soft, setSoft] =
|
|
2241
|
-
|
|
2508
|
+
const ref = useRef13(null);
|
|
2509
|
+
const done = useRef13(false);
|
|
2510
|
+
const [soft, setSoft] = useState16(false);
|
|
2511
|
+
useEffect15(() => {
|
|
2242
2512
|
const element = ref.current;
|
|
2243
2513
|
if (!active || done.current || !element) return;
|
|
2244
2514
|
done.current = true;
|
|
@@ -2250,6 +2520,103 @@ function useArrival(active) {
|
|
|
2250
2520
|
return { ref, soft };
|
|
2251
2521
|
}
|
|
2252
2522
|
|
|
2523
|
+
// src/hooks/use-signed-answer.ts
|
|
2524
|
+
import { useEffect as useEffect16, useRef as useRef14, useState as useState17 } from "react";
|
|
2525
|
+
function useSignedAnswer({ signature, load, active = true, delayMs = 0, onError }) {
|
|
2526
|
+
const [answer, setAnswer] = useState17(null);
|
|
2527
|
+
const latest = useRef14({ load, onError });
|
|
2528
|
+
latest.current = { load, onError };
|
|
2529
|
+
useEffect16(() => {
|
|
2530
|
+
setAnswer(null);
|
|
2531
|
+
if (!active) return;
|
|
2532
|
+
let cancelled = false;
|
|
2533
|
+
const timer = setTimeout(async () => {
|
|
2534
|
+
let value;
|
|
2535
|
+
try {
|
|
2536
|
+
value = await latest.current.load();
|
|
2537
|
+
} catch (error) {
|
|
2538
|
+
try {
|
|
2539
|
+
latest.current.onError?.(error);
|
|
2540
|
+
} catch {
|
|
2541
|
+
}
|
|
2542
|
+
value = null;
|
|
2543
|
+
}
|
|
2544
|
+
if (!cancelled) setAnswer({ signature, value });
|
|
2545
|
+
}, delayMs);
|
|
2546
|
+
return () => {
|
|
2547
|
+
cancelled = true;
|
|
2548
|
+
clearTimeout(timer);
|
|
2549
|
+
};
|
|
2550
|
+
}, [active, signature, delayMs]);
|
|
2551
|
+
const current = active && answer !== null && answer.signature === signature;
|
|
2552
|
+
return { value: current ? answer.value : null, ready: current };
|
|
2553
|
+
}
|
|
2554
|
+
|
|
2555
|
+
// src/hooks/use-picker-session.ts
|
|
2556
|
+
import { useCallback as useCallback10, useEffect as useEffect17, useRef as useRef15, useState as useState18 } from "react";
|
|
2557
|
+
var PICKER_SEARCH_FAILURE = "The search could not be run. Check your connection, then try again.";
|
|
2558
|
+
function usePickerSession({ source, failureMessage = PICKER_SEARCH_FAILURE, resetKey, onSourceError }) {
|
|
2559
|
+
const [picking, setPicking] = useState18(false);
|
|
2560
|
+
const [searchError, setSearchError] = useState18(null);
|
|
2561
|
+
const searchSeq = useRef15(0);
|
|
2562
|
+
const rootRef = useRef15(null);
|
|
2563
|
+
const restoreOpener = useRef15(false);
|
|
2564
|
+
const latest = useRef15({ source, failureMessage, onSourceError });
|
|
2565
|
+
latest.current = { source, failureMessage, onSourceError };
|
|
2566
|
+
const [seenKey, setSeenKey] = useState18(resetKey);
|
|
2567
|
+
const [epoch, setEpoch] = useState18(0);
|
|
2568
|
+
if (!Object.is(seenKey, resetKey)) {
|
|
2569
|
+
setSeenKey(resetKey);
|
|
2570
|
+
setPicking(false);
|
|
2571
|
+
setSearchError(null);
|
|
2572
|
+
setEpoch((value) => value + 1);
|
|
2573
|
+
}
|
|
2574
|
+
useEffect17(() => {
|
|
2575
|
+
searchSeq.current += 1;
|
|
2576
|
+
}, [epoch]);
|
|
2577
|
+
useEffect17(() => {
|
|
2578
|
+
if (picking) rootRef.current?.querySelector('input[role="combobox"]')?.focus();
|
|
2579
|
+
else if (restoreOpener.current) {
|
|
2580
|
+
restoreOpener.current = false;
|
|
2581
|
+
rootRef.current?.querySelector("button[data-opener]")?.focus();
|
|
2582
|
+
}
|
|
2583
|
+
}, [picking]);
|
|
2584
|
+
const open = useCallback10(() => setPicking(true), []);
|
|
2585
|
+
const invalidateSearch = useCallback10(() => {
|
|
2586
|
+
searchSeq.current += 1;
|
|
2587
|
+
}, []);
|
|
2588
|
+
const close = useCallback10(() => {
|
|
2589
|
+
searchSeq.current += 1;
|
|
2590
|
+
restoreOpener.current = true;
|
|
2591
|
+
setPicking(false);
|
|
2592
|
+
setSearchError(null);
|
|
2593
|
+
}, []);
|
|
2594
|
+
const search = useCallback10(async (query) => {
|
|
2595
|
+
const seq = ++searchSeq.current;
|
|
2596
|
+
let result;
|
|
2597
|
+
try {
|
|
2598
|
+
result = await latest.current.source(query);
|
|
2599
|
+
} catch (thrown) {
|
|
2600
|
+
try {
|
|
2601
|
+
latest.current.onSourceError?.(thrown);
|
|
2602
|
+
} catch {
|
|
2603
|
+
}
|
|
2604
|
+
result = { ok: false, error: latest.current.failureMessage };
|
|
2605
|
+
}
|
|
2606
|
+
if (seq === searchSeq.current) setSearchError(result.ok ? null : result.error);
|
|
2607
|
+
if (!result.ok) throw new Error(result.error);
|
|
2608
|
+
return result.options;
|
|
2609
|
+
}, []);
|
|
2610
|
+
const onKeyDown = useCallback10(
|
|
2611
|
+
(event) => {
|
|
2612
|
+
if (event.key === "Enter" && picking && event.target.getAttribute("role") === "combobox") event.preventDefault();
|
|
2613
|
+
if (event.key === "Escape" && picking) close();
|
|
2614
|
+
},
|
|
2615
|
+
[picking, close]
|
|
2616
|
+
);
|
|
2617
|
+
return { picking, open, close, search, searchError, invalidateSearch, groupProps: { ref: rootRef, onKeyDown } };
|
|
2618
|
+
}
|
|
2619
|
+
|
|
2253
2620
|
// src/hooks/use-cached-fetch.ts
|
|
2254
2621
|
var cache = /* @__PURE__ */ new Map();
|
|
2255
2622
|
var inflight = /* @__PURE__ */ new Map();
|
|
@@ -2305,21 +2672,21 @@ function clearCache() {
|
|
|
2305
2672
|
}
|
|
2306
2673
|
|
|
2307
2674
|
// src/hooks/use-preferences.ts
|
|
2308
|
-
import { useState as
|
|
2675
|
+
import { useState as useState19, useEffect as useEffect18, useCallback as useCallback11 } from "react";
|
|
2309
2676
|
function usePreferences({
|
|
2310
2677
|
endpoint,
|
|
2311
|
-
defaults:
|
|
2678
|
+
defaults: defaults9
|
|
2312
2679
|
}) {
|
|
2313
|
-
const [preferences, setPreferences] =
|
|
2314
|
-
const [loading, setLoading] =
|
|
2315
|
-
const [error, setError] =
|
|
2316
|
-
const fetchPreferences =
|
|
2680
|
+
const [preferences, setPreferences] = useState19(defaults9 ?? null);
|
|
2681
|
+
const [loading, setLoading] = useState19(true);
|
|
2682
|
+
const [error, setError] = useState19(null);
|
|
2683
|
+
const fetchPreferences = useCallback11(async () => {
|
|
2317
2684
|
try {
|
|
2318
2685
|
setError(null);
|
|
2319
2686
|
const res = await fetch(endpoint);
|
|
2320
2687
|
if (!res.ok) {
|
|
2321
2688
|
if (res.status === 401) {
|
|
2322
|
-
setPreferences(
|
|
2689
|
+
setPreferences(defaults9 ?? null);
|
|
2323
2690
|
return;
|
|
2324
2691
|
}
|
|
2325
2692
|
throw new Error("Failed to fetch preferences");
|
|
@@ -2331,11 +2698,11 @@ function usePreferences({
|
|
|
2331
2698
|
} finally {
|
|
2332
2699
|
setLoading(false);
|
|
2333
2700
|
}
|
|
2334
|
-
}, [endpoint,
|
|
2335
|
-
|
|
2701
|
+
}, [endpoint, defaults9]);
|
|
2702
|
+
useEffect18(() => {
|
|
2336
2703
|
fetchPreferences();
|
|
2337
2704
|
}, [fetchPreferences]);
|
|
2338
|
-
const updatePreferences =
|
|
2705
|
+
const updatePreferences = useCallback11(
|
|
2339
2706
|
async (updates) => {
|
|
2340
2707
|
setPreferences((prev) => prev ? { ...prev, ...updates } : updates);
|
|
2341
2708
|
setError(null);
|
|
@@ -2693,6 +3060,8 @@ export {
|
|
|
2693
3060
|
ActivityFeedRow,
|
|
2694
3061
|
ArchiveButton,
|
|
2695
3062
|
CLIENT_PROFILE_SHORTCUTS,
|
|
3063
|
+
COPY_NOTE_COPIED,
|
|
3064
|
+
COPY_NOTE_FAILED,
|
|
2696
3065
|
ConfirmAction,
|
|
2697
3066
|
EmailBodyRenderer,
|
|
2698
3067
|
EmailThreadView,
|
|
@@ -2700,12 +3069,19 @@ export {
|
|
|
2700
3069
|
ErrorBoundary,
|
|
2701
3070
|
FORM_SHORTCUTS,
|
|
2702
3071
|
GLOBAL_SHORTCUTS,
|
|
3072
|
+
GUARDED_ACTION_FAILURE,
|
|
2703
3073
|
INBOX_SHORTCUTS,
|
|
2704
3074
|
KeyboardShortcutsPanel,
|
|
3075
|
+
PICKER_SEARCH_FAILURE,
|
|
3076
|
+
Pager,
|
|
2705
3077
|
RENDER_ERRORS,
|
|
2706
3078
|
REPLY_LAYOUT_OPTIONS,
|
|
2707
3079
|
ReplyPanel,
|
|
3080
|
+
RestoreButton,
|
|
2708
3081
|
RichTextEditor,
|
|
3082
|
+
ShowOnceSecret,
|
|
3083
|
+
TrashedBanner,
|
|
3084
|
+
UndoNotice,
|
|
2709
3085
|
cachedFetch,
|
|
2710
3086
|
canViewInline,
|
|
2711
3087
|
clearCache,
|
|
@@ -2713,6 +3089,7 @@ export {
|
|
|
2713
3089
|
formatFileSize,
|
|
2714
3090
|
formatPhone,
|
|
2715
3091
|
formatPhoneInput,
|
|
3092
|
+
formatTrashedDate,
|
|
2716
3093
|
getNextMondayMorning,
|
|
2717
3094
|
getNextWeekday,
|
|
2718
3095
|
getQuickScheduleOptions,
|
|
@@ -2744,13 +3121,17 @@ export {
|
|
|
2744
3121
|
useArrival,
|
|
2745
3122
|
useAutoSave,
|
|
2746
3123
|
useContextShortcuts,
|
|
3124
|
+
useCopyToClipboard,
|
|
2747
3125
|
useFormActionKeepingInput,
|
|
3126
|
+
useGuardedAction,
|
|
2748
3127
|
useIframeFocusReclaim,
|
|
2749
3128
|
useKeyboardShortcuts,
|
|
3129
|
+
usePickerSession,
|
|
2750
3130
|
usePolling,
|
|
2751
3131
|
usePreferences,
|
|
2752
3132
|
useSavedNotice,
|
|
2753
3133
|
useServerSearch,
|
|
3134
|
+
useSignedAnswer,
|
|
2754
3135
|
useSyncedSelect,
|
|
2755
3136
|
withErrorBoundary
|
|
2756
3137
|
};
|