@estiva-app/ui 0.104.3 → 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/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: cn(NOTE_CLASSES, failed ? "text-error-default" : warning ? "text-warning-default" : "text-text-secondary")
916
+ className: failed ? FAILED_NOTE_CLASSES : cn(NOTE_CLASSES, warning ? "text-warning-default" : "text-text-secondary")
916
917
  }
917
918
  )
918
919
  ] }),
@@ -2006,8 +2007,8 @@ function MoveDialog({
2006
2007
  topLabel,
2007
2008
  startIn,
2008
2009
  heading = "Move",
2009
- folderLabel = "Folder",
2010
- noFolder = "There is no other folder it can be moved to.",
2010
+ folderLabel = "Team",
2011
+ noFolder = "There is no other team it can be moved to.",
2011
2012
  check,
2012
2013
  onMove,
2013
2014
  onClose
@@ -2042,7 +2043,8 @@ function MoveDialog({
2042
2043
  setPickedFolder(id);
2043
2044
  setPicked(void 0);
2044
2045
  };
2045
- const folderName = destinations?.find((candidate) => candidate.id === folder)?.name ?? "this folder";
2046
+ const chosenName = destinations?.find((candidate) => candidate.id === folder)?.name;
2047
+ const folderName = chosenName || "this team";
2046
2048
  const status = nests && folder ? read[folder] : void 0;
2047
2049
  const targets = Array.isArray(status) ? status : [];
2048
2050
  const valueOf = (place) => place.id || TOP;
@@ -2070,11 +2072,11 @@ function MoveDialog({
2070
2072
  value: folder,
2071
2073
  onChange: chooseFolder,
2072
2074
  options: (destinations ?? []).map((candidate) => ({ value: candidate.id, label: candidate.name })),
2073
- placeholder: destinations ? "Pick a folder" : "Reading\u2026",
2075
+ placeholder: destinations ? "Pick a team" : "Reading\u2026",
2074
2076
  ariaLabel: folderLabel
2075
2077
  }
2076
2078
  ) }),
2077
- nests && folder && (status === "failed" ? /* @__PURE__ */ jsx28(EmptyState, { scope: "section", message: `${folderName} could not be read.`, action: { label: "Try again", onClick: () => readPlaces(folder) } }) : Array.isArray(status) && targets.length === 0 ? /* @__PURE__ */ jsx28(EmptyState, { scope: "section", message: `There is nowhere in ${folderName} to put it.` }) : /* @__PURE__ */ jsx28(Field, { label: "Put it under", children: /* @__PURE__ */ jsx28(
2079
+ nests && folder && (status === "failed" ? /* @__PURE__ */ jsx28(EmptyState, { scope: "section", message: `${chosenName || "This team"} could not be read.`, action: { label: "Try again", onClick: () => readPlaces(folder) } }) : Array.isArray(status) && targets.length === 0 ? /* @__PURE__ */ jsx28(EmptyState, { scope: "section", message: `There is nowhere in ${folderName} to put it.` }) : /* @__PURE__ */ jsx28(Field, { label: "Put it under", children: /* @__PURE__ */ jsx28(
2078
2080
  Select,
2079
2081
  {
2080
2082
  value: parent ?? "",
@@ -4800,8 +4802,75 @@ function archivedLine(archive, noun, options = {}) {
4800
4802
  if (!archive.with)
4801
4803
  return `Archived. Unarchive it${where} to ${to}.`;
4802
4804
  const word = noun?.trim();
4803
- return `Unarchive the ${word === "folder" ? "Folder" : word || "parent"}${where} to ${to}.`;
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";
4804
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 };
4805
4874
 
4806
4875
  // src/archivedLine.ts
4807
4876
  var archivedLine2 = archivedLine;
@@ -6013,6 +6082,29 @@ function ResolvedCheck({ by, note, at }) {
6013
6082
  function Words({ children }) {
6014
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 }) });
6015
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
+ }
6016
6108
  function Reactions({ reactions, refused, readOnly }) {
6017
6109
  if ((!reactions || reactions.reactions.length === 0) && !refused) return null;
6018
6110
  return /* @__PURE__ */ jsxs59("div", { className: "relative flex w-full flex-col gap-1 pb-2 pl-8 pt-1", children: [
@@ -6083,7 +6175,7 @@ function useEditing(editing, onEditingChange) {
6083
6175
  return [now, set];
6084
6176
  }
6085
6177
  function ConversationCard(props) {
6086
- const { author, about, files, reactions, reactionRefused, 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;
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;
6087
6179
  const readOnly = (props.readOnly ?? false) || deleted;
6088
6180
  const inThreadCard = useContext14(InThreadCard);
6089
6181
  const item = useContext14(InConversationItem);
@@ -6105,7 +6197,8 @@ function ConversationCard(props) {
6105
6197
  const showStrip = hovered && !isEditing && !readOnly;
6106
6198
  const strip = useRef19(null);
6107
6199
  const wordsEnd = useClearOfStrip(root, strip, showStrip);
6108
- const react = reactions?.onToggle;
6200
+ const { row: reactionRow, refused: reactionRefused } = useReactionRefusal(reactions);
6201
+ const react = reactionRow?.onToggle;
6109
6202
  const press = onClick ?? (readOnly && !replies?.count ? void 0 : item?.toggle);
6110
6203
  const reply = onReply ?? item?.show;
6111
6204
  const marked = selected ?? (item && !item.under ? item.open : void 0);
@@ -6162,7 +6255,7 @@ function ConversationCard(props) {
6162
6255
  /* @__PURE__ */ jsx81(Words, { children })
6163
6256
  ] }),
6164
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 }),
6165
- /* @__PURE__ */ jsx81(Reactions, { reactions, refused: reactionRefused, readOnly }),
6258
+ /* @__PURE__ */ jsx81(Reactions, { reactions: reactionRow, refused: reactionRefused, readOnly }),
6166
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).
6167
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 }) }) }),
6168
6261
  repliesRow && /* @__PURE__ */ jsx81("div", { className: "relative w-full", children: repliesRow })
@@ -6222,7 +6315,8 @@ function ConversationCard(props) {
6222
6315
  ] });
6223
6316
  }
6224
6317
  function ReplyCard(props) {
6225
- const { id, author, about, files, reactions, reactionRefused, isNew = false, urgent = false, own = false, editor, onDelete, deleteNote, deleteRefused, menu, menuAfter, menuLabel, editLabel, deleteLabel, moreLabel = "More actions", noun = "reply", className, children } = props;
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);
6226
6320
  const readOnly = props.readOnly ?? false;
6227
6321
  const [hovered, setHovered] = useState23(false);
6228
6322
  const [menuOpen, setMenuOpen] = useState23(false);