@estiva-app/ui 0.105.0 → 0.106.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/dist/AttachmentCard.d.ts.map +1 -1
- package/dist/CommentBox.d.ts +10 -6
- package/dist/CommentBox.d.ts.map +1 -1
- package/dist/ConversationCard.d.ts +4 -3
- package/dist/ConversationCard.d.ts.map +1 -1
- package/dist/ReactionRow.d.ts +12 -2
- package/dist/ReactionRow.d.ts.map +1 -1
- package/dist/conversation.examples.d.ts +28 -2
- package/dist/conversation.examples.d.ts.map +1 -1
- package/dist/editor.js +163 -23
- package/dist/editor.js.map +4 -4
- package/dist/index.js +99 -6
- package/dist/index.js.map +4 -4
- package/package.json +3 -3
- package/registry.json +4 -16
- package/src/AttachmentCard.tsx +4 -1
- package/src/CommentBox.mdx +5 -2
- package/src/CommentBox.stories.tsx +57 -25
- package/src/CommentBox.test.tsx +72 -12
- package/src/CommentBox.tsx +59 -23
- package/src/ConversationCard.mdx +2 -0
- package/src/ConversationCard.stories.tsx +30 -6
- package/src/ConversationCard.test.tsx +63 -1
- package/src/ConversationCard.tsx +39 -7
- package/src/ReactionRow.tsx +8 -2
- package/src/conversation.examples.tsx +36 -7
package/dist/index.js
CHANGED
|
@@ -752,6 +752,7 @@ var typeLabelOf = (name) => extensionOf(name).toUpperCase() || "FILE";
|
|
|
752
752
|
var TILE_CLASSES = TYPE_TILE_CLASSES;
|
|
753
753
|
var NAME_CLASSES = "text-caption font-medium text-text-primary truncate";
|
|
754
754
|
var NOTE_CLASSES = "text-small tracking-wide leading-tight truncate";
|
|
755
|
+
var FAILED_NOTE_CLASSES = "text-small tracking-wide leading-tight line-clamp-2 text-error-default";
|
|
755
756
|
function TypeIcon({ name }) {
|
|
756
757
|
const Icon = ICON_BY_EXTENSION[extensionOf(name)] ?? IconFile;
|
|
757
758
|
return /* @__PURE__ */ jsx12(Icon, { size: 20, stroke: 1.5 });
|
|
@@ -912,7 +913,7 @@ function AttachmentCard({
|
|
|
912
913
|
{
|
|
913
914
|
text: (failed || warning ? note : state === "uploading" ? note ?? "Uploading\u2026" : note ?? sizeText) ?? "",
|
|
914
915
|
hint: noteHint,
|
|
915
|
-
className:
|
|
916
|
+
className: failed ? FAILED_NOTE_CLASSES : cn(NOTE_CLASSES, warning ? "text-warning-default" : "text-text-secondary")
|
|
916
917
|
}
|
|
917
918
|
)
|
|
918
919
|
] }),
|
|
@@ -4801,8 +4802,75 @@ function archivedLine(archive, noun, options = {}) {
|
|
|
4801
4802
|
if (!archive.with)
|
|
4802
4803
|
return `Archived. Unarchive it${where} to ${to}.`;
|
|
4803
4804
|
const word = noun?.trim();
|
|
4804
|
-
return `Unarchive the ${word
|
|
4805
|
+
return `Unarchive the ${word || "parent"}${where} to ${to}.`;
|
|
4806
|
+
}
|
|
4807
|
+
|
|
4808
|
+
// node_modules/@estiva-app/conversation/dist/refusals.js
|
|
4809
|
+
var REFUSAL_REASONS = {
|
|
4810
|
+
"too-long": "it is too long",
|
|
4811
|
+
gone: "this message was deleted, or you can no longer write here",
|
|
4812
|
+
"no-access": "you can no longer write here",
|
|
4813
|
+
archived: "this team is archived",
|
|
4814
|
+
busy: "too many at once, try again in a moment",
|
|
4815
|
+
clock: "your computer\u2019s clock is wrong; set it and try again",
|
|
4816
|
+
"signed-out": "you are signed out; sign in again",
|
|
4817
|
+
unknown: "something went wrong, try again"
|
|
4818
|
+
};
|
|
4819
|
+
function textOf(reason) {
|
|
4820
|
+
if (reason == null)
|
|
4821
|
+
return "";
|
|
4822
|
+
if (typeof reason === "string") {
|
|
4823
|
+
const json = reason.trim();
|
|
4824
|
+
if (json.startsWith("{")) {
|
|
4825
|
+
try {
|
|
4826
|
+
return textOf(JSON.parse(json)) || reason;
|
|
4827
|
+
} catch {
|
|
4828
|
+
return reason;
|
|
4829
|
+
}
|
|
4830
|
+
}
|
|
4831
|
+
return reason;
|
|
4832
|
+
}
|
|
4833
|
+
if (reason instanceof Error)
|
|
4834
|
+
return textOf(reason.message);
|
|
4835
|
+
if (typeof reason === "object") {
|
|
4836
|
+
const r = reason;
|
|
4837
|
+
for (const key of ["error", "message", "reason"]) {
|
|
4838
|
+
const value = r[key];
|
|
4839
|
+
if (typeof value === "string")
|
|
4840
|
+
return textOf(value);
|
|
4841
|
+
if (value && typeof value === "object")
|
|
4842
|
+
return textOf(value);
|
|
4843
|
+
}
|
|
4844
|
+
}
|
|
4845
|
+
return String(reason);
|
|
4846
|
+
}
|
|
4847
|
+
var CAUSES = new Set(Object.keys(REFUSAL_REASONS));
|
|
4848
|
+
var RULES = [
|
|
4849
|
+
[/content (is \d+ bytes, max|exceeds maximum size)|too long/i, "too-long"],
|
|
4850
|
+
[/rate-limited|quota|too many|too busy|relay is busy|admission|\b429\b|concurrency/i, "busy"],
|
|
4851
|
+
[/timestamp too far|clock/i, "clock"],
|
|
4852
|
+
[/auth-required|insufficient scope|does not match authenticated|signed out|sign in|\b401\b|token_rejected|session_expired/i, "signed-out"],
|
|
4853
|
+
[/archived/i, "archived"],
|
|
4854
|
+
[/target (event )?not found|not (editable|deletable) by you|was deleted|no longer on this page/i, "gone"],
|
|
4855
|
+
[/^(restricted|blocked):|not a (channel |relay )?member|only members|no longer (post|write)|banned|timed out until|writes are fenced|\b403\b/i, "no-access"]
|
|
4856
|
+
];
|
|
4857
|
+
function refusalCause(reason) {
|
|
4858
|
+
if (reason && typeof reason === "object" && "cause" in reason) {
|
|
4859
|
+
const cause = reason.cause;
|
|
4860
|
+
if (typeof cause === "string" && CAUSES.has(cause))
|
|
4861
|
+
return cause;
|
|
4862
|
+
}
|
|
4863
|
+
const text = textOf(reason);
|
|
4864
|
+
for (const [rule, cause] of RULES)
|
|
4865
|
+
if (rule.test(text))
|
|
4866
|
+
return cause;
|
|
4867
|
+
return "unknown";
|
|
4805
4868
|
}
|
|
4869
|
+
function refusalReason(reason) {
|
|
4870
|
+
return REFUSAL_REASONS[refusalCause(reason)];
|
|
4871
|
+
}
|
|
4872
|
+
var MB = 1024 * 1024;
|
|
4873
|
+
var UPLOAD_LIMITS = { gif: 10 * MB, image: 50 * MB, other: 1e8 };
|
|
4806
4874
|
|
|
4807
4875
|
// src/archivedLine.ts
|
|
4808
4876
|
var archivedLine2 = archivedLine;
|
|
@@ -6014,6 +6082,29 @@ function ResolvedCheck({ by, note, at }) {
|
|
|
6014
6082
|
function Words({ children }) {
|
|
6015
6083
|
return /* @__PURE__ */ jsx81("div", { className: "relative w-full break-words pb-2 pl-8 pr-2 pt-1", children: /* @__PURE__ */ jsx81("div", { className: "flex flex-col gap-2 text-body-2 text-text-secondary", children }) });
|
|
6016
6084
|
}
|
|
6085
|
+
function useReactionRefusal(reactions) {
|
|
6086
|
+
const [refused, setRefused] = useState23();
|
|
6087
|
+
const latest = useRef19(0);
|
|
6088
|
+
const toggle = reactions?.onToggle;
|
|
6089
|
+
if (!reactions || !toggle) return { row: reactions, refused };
|
|
6090
|
+
const onToggle = (emoji) => {
|
|
6091
|
+
const mine = ++latest.current;
|
|
6092
|
+
setRefused(void 0);
|
|
6093
|
+
const say = (reason) => {
|
|
6094
|
+
if (mine === latest.current) setRefused(refusalReason(reason));
|
|
6095
|
+
};
|
|
6096
|
+
const answer = toggle(emoji);
|
|
6097
|
+
if (!answer) return;
|
|
6098
|
+
return answer.then((said) => {
|
|
6099
|
+
if (said && !said.accepted) say(said.reason);
|
|
6100
|
+
return said;
|
|
6101
|
+
}, (reason) => {
|
|
6102
|
+
say(reason);
|
|
6103
|
+
return { accepted: false, reason };
|
|
6104
|
+
});
|
|
6105
|
+
};
|
|
6106
|
+
return { row: { ...reactions, onToggle }, refused };
|
|
6107
|
+
}
|
|
6017
6108
|
function Reactions({ reactions, refused, readOnly }) {
|
|
6018
6109
|
if ((!reactions || reactions.reactions.length === 0) && !refused) return null;
|
|
6019
6110
|
return /* @__PURE__ */ jsxs59("div", { className: "relative flex w-full flex-col gap-1 pb-2 pl-8 pt-1", children: [
|
|
@@ -6084,7 +6175,7 @@ function useEditing(editing, onEditingChange) {
|
|
|
6084
6175
|
return [now, set];
|
|
6085
6176
|
}
|
|
6086
6177
|
function ConversationCard(props) {
|
|
6087
|
-
const { author, about, files, reactions,
|
|
6178
|
+
const { author, about, files, reactions, isNew = false, urgent = false, own = false, editor, deleted = false, replies, onReply, resolved, noun = "comment", onResolve, resolveHint, resolveRefused, onReopen, selected, onClick, onDelete, deleteNote, deleteRefused, menu, menuAfter, menuLabel, editLabel, deleteLabel, moreLabel = "More actions", className, children } = props;
|
|
6088
6179
|
const readOnly = (props.readOnly ?? false) || deleted;
|
|
6089
6180
|
const inThreadCard = useContext14(InThreadCard);
|
|
6090
6181
|
const item = useContext14(InConversationItem);
|
|
@@ -6106,7 +6197,8 @@ function ConversationCard(props) {
|
|
|
6106
6197
|
const showStrip = hovered && !isEditing && !readOnly;
|
|
6107
6198
|
const strip = useRef19(null);
|
|
6108
6199
|
const wordsEnd = useClearOfStrip(root, strip, showStrip);
|
|
6109
|
-
const
|
|
6200
|
+
const { row: reactionRow, refused: reactionRefused } = useReactionRefusal(reactions);
|
|
6201
|
+
const react = reactionRow?.onToggle;
|
|
6110
6202
|
const press = onClick ?? (readOnly && !replies?.count ? void 0 : item?.toggle);
|
|
6111
6203
|
const reply = onReply ?? item?.show;
|
|
6112
6204
|
const marked = selected ?? (item && !item.under ? item.open : void 0);
|
|
@@ -6163,7 +6255,7 @@ function ConversationCard(props) {
|
|
|
6163
6255
|
/* @__PURE__ */ jsx81(Words, { children })
|
|
6164
6256
|
] }),
|
|
6165
6257
|
!deleted && files && /* @__PURE__ */ jsx81("div", { className: "relative flex w-full flex-wrap items-start gap-2 pb-2 pl-8 pr-2", children: files }),
|
|
6166
|
-
/* @__PURE__ */ jsx81(Reactions, { reactions, refused: reactionRefused, readOnly }),
|
|
6258
|
+
/* @__PURE__ */ jsx81(Reactions, { reactions: reactionRow, refused: reactionRefused, readOnly }),
|
|
6167
6259
|
resolved?.note && // Who resolved it and the note, above the way into the replies; the check by the time says "Resolved" (Katerina, 1 November).
|
|
6168
6260
|
/* @__PURE__ */ jsx81("div", { className: "relative w-full pb-1", children: /* @__PURE__ */ jsx81("div", { className: "-ml-2 w-[calc(100%+8px)]", children: /* @__PURE__ */ jsx81(EndedLine, { by: resolved.by, note: resolved.note, at: resolved.at }) }) }),
|
|
6169
6261
|
repliesRow && /* @__PURE__ */ jsx81("div", { className: "relative w-full", children: repliesRow })
|
|
@@ -6223,7 +6315,8 @@ function ConversationCard(props) {
|
|
|
6223
6315
|
] });
|
|
6224
6316
|
}
|
|
6225
6317
|
function ReplyCard(props) {
|
|
6226
|
-
const { id, author, about, files,
|
|
6318
|
+
const { id, author, about, files, isNew = false, urgent = false, own = false, editor, onDelete, deleteNote, deleteRefused, menu, menuAfter, menuLabel, editLabel, deleteLabel, moreLabel = "More actions", noun = "reply", className, children } = props;
|
|
6319
|
+
const { row: reactions, refused: reactionRefused } = useReactionRefusal(props.reactions);
|
|
6227
6320
|
const readOnly = props.readOnly ?? false;
|
|
6228
6321
|
const [hovered, setHovered] = useState23(false);
|
|
6229
6322
|
const [menuOpen, setMenuOpen] = useState23(false);
|