@svgrid/enterprise 3.1.66 → 3.1.68
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/cdn/svgrid-enterprise.svelte-external.js +1 -1
- package/dist/designer/assets/{index-3vpkdW1l.js → index-Dwe1MXA7.js} +1 -1
- package/dist/designer/index.html +1 -1
- package/dist/fields/BaseTabs.svelte +81 -12
- package/dist/fields/BaseTabs.svelte.d.ts +9 -0
- package/dist/fields/RecordView.svelte +102 -58
- package/dist/fields/SvBase.svelte +4 -1
- package/dist/fields/SvBase.svelte.d.ts +9 -0
- package/dist/fields/activity.svelte.d.ts +37 -0
- package/dist/fields/activity.svelte.js +1 -1
- package/dist/fields/base-tables.d.ts +4 -0
- package/dist/fields/index.d.ts +1 -1
- package/dist/fields/index.js +1 -1
- package/dist/fields/messages/record.d.ts +14 -0
- package/dist/fields/messages/record.js +1 -1
- package/dist/fields/messages/shell.d.ts +7 -0
- package/dist/fields/messages/shell.js +1 -1
- package/dist/fields/messages.svelte.d.ts +21 -0
- package/dist/node/studio.js +1 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/dist/wc/sv-base-element.js +103 -98
- package/package.json +1 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
|
-
import{recordActionsFor}from"./record-actions";import{commentSnippets}from"./comment-snippets.svelte";import{onDestroy,onMount,tick,untrack}from"svelte";import{commentDraftsOf,getRecordRequest,holdForRecordEditor}from"./editor-request.svelte";import{SvModal,announce,portalToBody,toast}from"@svgrid/grid";import{DOCK_MAX,DOCK_MIN,DOCK_NARROW,recordDock,recordDockWidth,setRecordDock,setRecordDockWidth}from"./record-dock.svelte";import FieldInput from"./FieldInput.svelte";import{fieldPropsOf,getFieldType,originalColumn,ruleFieldNames}from"./registry.svelte";import{protectionText}from"./field-access.svelte";import{isReadOnlyGrid}from"./base-share";import{canCommentIn,canDeleteRecord}from"./base-permissions";import{askDeleteRecord}from"./record-delete.svelte";import{cellText,dataRows,fieldColumns,leafFilter,primaryIdOf}from"./grid-access";import{recordWalkOf}from"./record-walk";import{addComment,commentStoreTakes,commentVotes,commentsOf,commentsTakeVotes,deleteComment,editComment,historyOf,historyState,loadHistory,markSeen,mayVoteComment,myCommentVote,ownsComment,timeAgo,unseenOf,voteComment}from"./activity.svelte";import{uploadAttachment}from"./attachments";import{findFieldUser}from"./sources.svelte";import{encodeMentions,mentionText,parseMentions}from"./mentions";import MentionInput from"./MentionInput.svelte";import{dictationSupported,dictate,withSaid}from"./dictation.svelte";import UserFace from"./UserFace.svelte";import{recordProposalsFor}from"../review/card-marks.svelte";import{bm,bmCount}from"./messages.svelte";let{ctrl,rowId,editPrimary=false,focus,onClose}=$props();let current=$state(rowId);let open=$state(true);let editing=$state(null);let showHidden=$state(false);let comment=$state("");let picked=$state([]);const rows=$derived(ctrl.allRows??[]);let lastAt=-1;function rowIndexOf(list,id){if(id==null)return-1;for(const near of[lastAt,untrack(()=>ctrl.activeCell?.rowIndex??-1)]){if(near<0)continue;for(let d=0;d<=200;d++){if(list[near+d]?.id===id)return lastAt=near+d;if(d&&near-d>=0&&list[near-d]?.id===id)return lastAt=near-d}}return lastAt=list.findIndex(r=>r.id===id)}const index=$derived(rowIndexOf(rows,current));const row=$derived(index>=0?rows[index]:null);const isDraft=$derived(!!ctrl.props?.baseIsDraft?.(current));let lastIndex=0;const at=$derived.by(()=>{if(index>=0)lastIndex=index;return lastIndex});const walk=$derived(recordWalkOf(ctrl));const model=$derived(ctrl.props?.rowModel);const grouped=$derived((ctrl.groupingColumns??[]).length>0);const notRead=r=>String(r.id).startsWith("sv-ph:");function isRecord(r){const kind=r.original?.__group?.kind;return kind?kind==="leaf":r.__treeRow||!(typeof r.getCanExpand==="function"&&r.getCanExpand())}function rowFrom(from,by){for(let i=from+by;i>=0&&i<rows.length;i+=by){const r=rows[i];if(notRead(r)||isRecord(r))return i}return-1}function rowBeside(by){const seen=at;return rowFrom(index>=0?index:by>0?seen-1:seen,by)}let located=$state(0);const walkPlace=$derived(walk&&!isDraft?(void located,walk.place(current)):null);let lastPlace=-1;const walkAt=$derived.by(()=>{if(walkPlace!=null)lastPlace=walkPlace;return lastPlace});const walkFrom=by=>walkPlace!=null?walkAt:by>0?walkAt-1:walkAt;const canPrev=$derived(walk?walkAt>=0&&walk.has(walkFrom(-1),-1):rowBeside(-1)>=0);const canNext=$derived(walk?walkAt>=0&&walk.has(walkFrom(1),1):rowBeside(1)>=0);const records=$derived(!model&&grouped?dataRows(ctrl):null);const total=$derived(walk?walk.total():model?.getState?model.recordCount?.()??model.getState().rowCount??rows.length:(records??rows).length);const locale=$derived(ctrl.props?.localization?.locale);const place=$derived.by(()=>{if(isDraft)return null;if(walk)return walkPlace;if(index<0)return null;if(model)return grouped||model.isPinned?.(current)?null:index-Math.max(0,rows.length-total);return records?records.findIndex(r=>r.id===current):index});const positionText=$derived.by(()=>{if(isDraft)return bm("record.newRecord");if(!walk&&index<0)return bmCount("record.notInView",total,{count:total.toLocaleString(locale)});if(place==null)return bmCount("viewbar.records",total);return bm("record.position",{index:(place+1).toLocaleString(locale),total:total.toLocaleString(locale)})});const filteredOut=$derived.by(()=>{if(!row)return false;const keep=leafFilter(ctrl);return!!keep&&!keep(row)});const columns=$derived((ctrl.allColumns??[]).filter(c=>!c.id.startsWith("__")&&(c.columnDef.field!=null||c.columnDef.fieldFn!=null)));const hidden=$derived.by(()=>{const shownIds=new Set(columns.map(c=>c.id));return fieldColumns(ctrl).filter(c=>!shownIds.has(c.id)).map(c=>({id:c.id,columnDef:c.def}))});function valueOf(c){if(!row)return void 0;const base=c.columnDef.fieldFn?c.columnDef.fieldFn(row.original):row.original?.[c.columnDef.field];return ctrl.getCellDisplayValue(row.id,c.id,columns.includes(c)?row.getCellValueByColumnId(c.id):base)}const asField=c=>({id:c.id,field:String(c.columnDef.field??c.id),header:label(c),fieldType:c.columnDef.fieldType,def:c.columnDef,visible:true});const primaryId=$derived(primaryIdOf(ctrl));const primary=$derived(columns.find(c=>c.id===primaryId)??columns.find(c=>c.columnDef.fieldType==="text"||!c.columnDef.fieldType&&c.columnDef.editorType==null)??columns[0]);const title=$derived(row&&primary?cellText(asField(primary),valueOf(primary),row)||bm("record.untitled"):bm("record.record"));function label(c){return typeof c.columnDef.header==="string"?c.columnDef.header:c.id}const protectionOf=c=>c.columnDef.fieldType?protectionText(originalColumn(c.columnDef),fieldPropsOf(originalColumn(c.columnDef)),ruleFieldNames(c.columnDef)):null;const iconOf=c=>c.columnDef.fieldType?getFieldType(c.columnDef.fieldType)?.icon:void 0;function editable(c){if(!row||!ctrl.editingEnabled)return false;const ci=ctrl.allColumns.findIndex(x=>x.id===c.id);if(ci<0)return false;return ctrl.isCellEditableAt?!!ctrl.isCellEditableAt(index,ci):c.columnDef.editable!==false}const editorOpen=$derived(editing!=null);$effect(()=>{if(editorOpen)return untrack(holdForRecordEditor)});onMount(()=>{if(editPrimary&&primary&&editable(primary))editing=primary.id});let settled=$state(false);const settling=setTimeout(()=>settled=true,400);onDestroy(()=>{clearTimeout(settling);walk?.stop?.()});let locating=null;$effect(()=>{const w=walk;const r=row;if(!w?.locate||!r||isDraft||walkPlace!=null||locating===r.id)return;locating=r.id;untrack(()=>void w.locate(r.id,r.original).finally(()=>located+=1))});let commentBox=$state(null);const commentFocusFor=r=>r?.focus==="comment"&&r.ctrl===ctrl;const initialFocus=()=>focus==="comment"||commentFocusFor(getRecordRequest())?commentBox:null;$effect(()=>{const r=getRecordRequest();if(!commentFocusFor(r))return;untrack(()=>{if(r.rowId!==current)current=r.rowId;queueMicrotask(()=>commentBox?.focus())})});let listening=$state(null);const speakable=c=>dictationSupported()&&(c.columnDef.fieldType==="text"||c.columnDef.fieldType==="longText");async function speakInto(c){if(listening)return;listening=c.id;try{const said=await dictate();if(said)commit(c,withSaid(row?.getCellValueByColumnId?.(c.id),said,c.columnDef.fieldType==="longText"))}finally{listening=null}}async function speakComment(){if(listening)return;listening=":comment";try{const said=await dictate();if(said)comment=withSaid(comment,said,false)}finally{listening=null}}function sameValue(a,b){const none=x=>x==null||x===""||Array.isArray(x)&&!x.length;if(none(a)&&none(b))return true;return typeof a==="object"||typeof b==="object"?JSON.stringify(a)===JSON.stringify(b):String(a)===String(b)}function commit(c,v){editing=null;if(!row||v===void 0)return;const none=x=>x==null||x===""||Array.isArray(x)&&!x.length;if(none(v)&&none(row.getCellValueByColumnId?.(c.id)))return;const at2=rowIndexOf(ctrl.allRows,current);if(at2<0||!ctrl.startEditing(at2,c.id))return;ctrl.updateEditingCellValue(v);ctrl.saveEditingCell()}let fieldsBox=$state(null);const focusField=id=>[...fieldsBox?.querySelectorAll("[data-frv-field]")??[]].find(el=>el.dataset.frvField===id)?.querySelector(".sv-frv-open")?.focus();function stopEditing(c){editing=null;setTimeout(()=>{const now=document.activeElement;if(editing==null&&(!now||now===document.body||now.getAttribute("role")==="dialog"))focusField(c.id)},0)}const typedInto=c=>["text","number","textarea","fieldNumber","fieldTime",void 0].includes(c.columnDef.editorType);function escapeBox(e){if(e.key!=="Escape"||e.isComposing)return;if((unsaved||deletingNote!=null)&&editing==null)return escapeComment(e);const c=editing!=null?columns.find(x=>x.id===editing):void 0;if(!c||!(typedInto(c)||c.columnDef.editorType==="fieldRating"))return;e.stopPropagation();stopEditing(c)}function editBeside(c,dir){const at2=columns.findIndex(x=>x.id===c.id);for(let i=at2+dir;i>=0&&i<columns.length;i+=dir){const next=columns[i];if(!editable(next)||next.columnDef.editorType==="checkbox")continue;if(typedInto(next))editing=next.id;else{editing=null;void tick().then(()=>focusField(next.id))}return}}let awaited=$state(null);let awaitedRow=$state(null);let stepping=false;let pressed=0;function arrived(){stepping=false;if(!pressed)return;const by=pressed>0?1:-1;pressed-=by;queueMicrotask(()=>void go(by))}$effect(()=>{const id=awaited;if(id!=null&&rowIndexOf(rows,id)>=0)untrack(()=>{current=id;awaited=null;arrived()})});$effect(()=>{const at2=awaitedRow;const r=at2==null?void 0:rows[at2];if(r&&!notRead(r))untrack(()=>{awaitedRow=null;lastAt=at2;if(isRecord(r))current=r.id;arrived()})});let swipeAt=null;function swipeStart(e){const t=e.touches[0];const from=e.target;const busy=!!from?.closest?.('input, textarea, select, [contenteditable="true"], .sv-frv-files, [data-no-swipe]');swipeAt=e.touches.length===1&&t&&!busy?{x:t.clientX,y:t.clientY,t:Date.now()}:null}function swipeEnd(e){const s0=swipeAt;swipeAt=null;const t=e.changedTouches[0];if(!s0||!t||editing!=null)return;const dx=t.clientX-s0.x;const dy=t.clientY-s0.y;if(Math.abs(dx)<70||Math.abs(dx)<Math.abs(dy)*1.8||Date.now()-s0.t>700)return;if(dx<0&&canNext)void go(1);else if(dx>0&&canPrev)void go(-1)}function keepInSight(e){const el=e.target;if(!el?.matches?.('input, textarea, [contenteditable="true"]')||typeof window==="undefined"||window.innerWidth>600)return;setTimeout(()=>el.scrollIntoView?.({block:"center",behavior:"smooth"}),320)}async function go(by){if(stepping){pressed+=by;return}if(editingNote!=null){stepHeld=true;announce(bm("record.commentHoldsStep"));editBox?.focus();return}editing=null;if(walk){stepping=true;const id=await walk.step(walkFrom(by),by);if(id==null){stepping=false;pressed=0;return}awaited=id;setTimeout(()=>{if(awaited!==id)return;awaited=null;stepping=false;pressed=0},3e3);return}const to=rowBeside(by);if(to<0)return;const next=rows[to];if(!notRead(next)){lastAt=to;current=next.id;return}stepping=true;awaitedRow=to;ctrl.buildApi?.().scrollToRow?.(to)}const allCols=$derived([...columns,...hidden]);const restorable=c=>!!c&&c.columnDef.editorType!=="attachment"&&c.columnDef.editorType!=="fieldLink";const feed=$derived.by(()=>{if(!row)return[];const edits=historyOf(ctrl,row.id).map((ch,i)=>{if(ch.added)return{key:`a${ch.at}-${i}`,at:ch.at,by:ch.by,remote:true,kind:"added",field:"",text:""};const c=allCols.find(x=>x.id===ch.columnId);const show=v=>c?cellText(asField(c),v,row):String(v??"");return{key:`e${ch.at}${ch.columnId}-${i}`,at:ch.at,by:ch.by,automation:ch.automation,via:ch.via,through:ch.through,remote:ch.remote,undone:ch.undone,redone:ch.redone,kind:"edit",field:c?label(c):ch.columnId,text:show(ch.value),..."from"in ch&&show(ch.from)?{from:show(ch.from)}:{},..."from"in ch&&restorable(c)?{restore:{col:c,value:ch.from??null}}:{}}});const notes=commentsOf(ctrl,row.id).map(n=>({key:n.id,at:n.at,by:n.by,kind:"comment",field:"",text:n.text,parts:parseMentions(n.text),note:n}));return[...edits,...notes].sort((a,b)=>a.at-b.at)});const person=item=>item.by?findFieldUser(item.by)?.name??bm("record.someone"):item.remote?bm("record.someoneElse"):bm("record.you");const who=item=>item.automation?bm("record.byAutomation",{name:item.automation}):item.via?bm("record.acceptedBy",{source:item.via,person:person(item)}):item.through?bm("record.through",{person:person(item),source:item.through}):person(item);const shownId=$derived(row?.id);$effect(()=>{const id=shownId;if(id!=null)untrack(()=>loadHistory(ctrl,id))});const history=$derived(row?historyState(ctrl,row.id):{loading:false});$effect(()=>{const id=row?.id;if(id!=null&&unseenOf(ctrl,id))untrack(()=>markSeen(ctrl,id))});const proposals=$derived(row?recordProposalsFor(ctrl.props?.getRowId,row.original,row.id):null);const proposalOf=c=>proposals?.list.find(p=>p.field===String(c.columnDef.field??c.id));const proposedText=(c,p)=>cellText(asField(c),p.after,row)||proposals?.messages.empty||"";let deciding=$state(false);async function decide(ids,how){if(!proposals||deciding||!ids.length)return;deciding=true;try{await(how==="accept"?proposals.accept(ids):proposals.reject(ids))}finally{deciding=false}}const readOnly=$derived(isReadOnlyGrid(ctrl));const canComment=$derived(canCommentIn(ctrl));const takesFiles=$derived(commentStoreTakes("files"));const takesInternal=$derived(commentStoreTakes("internal"));let commentFiles=$state([]);let uploading=$state(0);let internalNote=$state(false);let fileInput=$state(null);const canSend=$derived((!!comment.trim()||commentFiles.length>0)&&uploading===0);async function attach(list){if(!list||!row)return;const forRow=row.id;for(const file of Array.from(list)){uploading+=1;try{const done=await uploadAttachment(file,{},{row:row?.original,columnId:"",signal:new AbortController().signal,onProgress:()=>{}});if(row?.id===forRow)commentFiles=[...commentFiles,done]}catch(e){toast.error(bm("record.commentUploadFailed",{name:file.name,error:e instanceof Error?e.message:String(e)}))}finally{uploading-=1}}if(fileInput)fileInput.value=""}const snippets=$derived(commentSnippets());let repliesOpen=$state(false);let replies=$state(null);let repliesError=$state("");let replyQuery=$state("");let replyName=$state("");let naming=$state(false);const shownReplies=$derived((replies??[]).filter(r=>!replyQuery.trim()||(r.title+" "+r.text).toLowerCase().includes(replyQuery.trim().toLowerCase())));const recordRef=()=>({rowId:String(row?.original?.id??row?.id??""),row:row?.original??{}});async function openReplies(){if(repliesOpen){repliesOpen=false;return}const list=snippets;if(!list||!row)return;repliesOpen=true;replies=null;repliesError="";replyQuery="";naming=false;const forRow=row.id;try{const got=await list.list(ctrl?.props?.baseTableId,recordRef());if(row?.id===forRow)replies=Array.isArray(got)?got:[]}catch(e){repliesError=e instanceof Error?e.message:String(e);replies=[]}}function pickReply(reply){comment=comment.trim()?comment.replace(/\s+$/,"")+"\n\n"+reply.text:reply.text;if(reply.files?.length)commentFiles=[...commentFiles,...reply.files.filter(f=>!commentFiles.some(x=>x.id===f.id))];repliesOpen=false;void tick().then(()=>commentBox?.focus())}async function saveReply(){const keep=snippets?.save;const title2=replyName.trim();if(!keep||!title2||!comment.trim())return;try{await keep(ctrl?.props?.baseTableId,{title:title2,text:comment});toast.success(bm("record.replySaved"));naming=false;replyName="";replies=null;repliesOpen=false}catch(e){toast.error(bm("record.replyNotSaved",{error:e instanceof Error?e.message:String(e)}))}}$effect(()=>{void current;repliesOpen=false});function send(){if(!row||!canSend||!canComment||isDraft)return;addComment(ctrl,row.id,encodeMentions(comment,picked),{files:commentFiles,internal:internalNote});comment="";picked=[];commentFiles=[];internalNote=false;announce(bm("record.commentAddedSay"))}const fileSize=n=>n==null?"":n<1024?`${n} B`:n<1048576?`${Math.round(n/1024)} KB`:`${(n/1048576).toFixed(1)} MB`;let editingNote=$state(null);let editText=$state("");let editPicked=$state([]);let deletingNote=$state(null);let editBox=$state(null);let sendButton=$state(null);const unsaved=$derived(!!row&&(!!comment.trim()||editingNote!=null));$effect(()=>{const id=current;const drafts=commentDraftsOf(ctrl);const kept=drafts.get(id);comment=kept?.text??"";picked=kept?.picked??[];editingNote=null;deletingNote=null});$effect(()=>{const drafts=commentDraftsOf(ctrl);if(comment.trim())drafts.set(current,{text:comment,picked});else drafts.delete(current)});function closing(){if(comment.trim())toast.info(bm("record.commentKept"));onClose()}let narrow=$state(typeof window!=="undefined"&&window.innerWidth<DOCK_NARROW);$effect(()=>{const look=()=>narrow=window.innerWidth<DOCK_NARROW;window.addEventListener("resize",look);return()=>window.removeEventListener("resize",look)});const mode=$derived(narrow?"center":recordDock());const DOCKS=[{id:"center",key:"record.dockCenter",icon:"M3 4.5h14v11H3zM6.5 7.5h7v5h-7z"},{id:"right",key:"record.dockRight",icon:"M3 4.5h14v11H3zM11.5 4.5v11"},{id:"full",key:"record.dockFull",icon:"M3 4.5h14v11H3zM3 7.5h14"}];function dockAt(next){if(next===mode)return;editing=null;setRecordDock(next);announce(bm(DOCKS.find(d=>d.id===next).key))}let anchor=$state(null);let side=$state(null);let sideTop=$state(0);const sideTitleId=`sv-frv-side-${Math.random().toString(36).slice(2,9)}`;$effect(()=>{if(mode!=="right"||!anchor)return;const width=recordDockWidth();const host=anchor.closest(".sv-fbase-tables")??anchor.closest(".sv-grid-root");const before=host?.style.marginInlineEnd??"";if(host)host.style.marginInlineEnd=`${width}px`;const place2=()=>{const top=host?host.getBoundingClientRect().top:0;sideTop=Math.round(Math.min(Math.max(0,top),window.innerHeight*.3))};place2();const watch=typeof ResizeObserver==="function"&&host?new ResizeObserver(place2):null;if(host)watch?.observe(host);window.addEventListener("resize",place2);window.addEventListener("scroll",place2,{passive:true,capture:true});return()=>{if(host)host.style.marginInlineEnd=before;watch?.disconnect();window.removeEventListener("resize",place2);window.removeEventListener("scroll",place2,{capture:true})}});$effect(()=>{if(mode!=="right"||!side)return;const panel=side;void tick().then(()=>{if(panel.contains(document.activeElement))return;const to=initialFocus()??panel.querySelector('.sv-frv-side-body button:not(:disabled), .sv-frv-side-body input, .sv-frv-side-body textarea, .sv-frv-side-body [tabindex="0"]');(to??panel).focus({preventScroll:true})})});function sideKey(e){if(e.key!=="Escape"||e.defaultPrevented||e.isComposing)return;if(unsaved||deletingNote!=null)return;e.stopPropagation();closeSide()}function closeSide(){open=false;closing()}const activeId=$derived(mode==="right"?(ctrl.allRows??[])[ctrl.activeCell?.rowIndex??-1]?.id??void 0:void 0);let seenActive=null;$effect(()=>{const id=activeId;const docked=mode==="right";untrack(()=>{if(!docked||seenActive===null){seenActive=docked?id:null;return}if(id===seenActive)return;seenActive=id;if(!id||id===current||editingNote!=null)return;if(!dataRows(ctrl).some(r=>r.id===id))return;editing=null;current=id})});let dragFrom=null;function edgeDown(e){dragFrom={x:e.clientX,w:recordDockWidth()};e.currentTarget.setPointerCapture(e.pointerId)}function edgeMove(e){if(!dragFrom)return;setRecordDockWidth(Math.min(DOCK_MAX,Math.max(DOCK_MIN,dragFrom.w+(dragFrom.x-e.clientX))))}function edgeUp(e){if(!dragFrom)return;dragFrom=null;e.currentTarget.releasePointerCapture(e.pointerId)}function edgeKey(e){const by=e.key==="ArrowLeft"?24:e.key==="ArrowRight"?-24:0;if(!by)return;e.preventDefault();setRecordDockWidth(recordDockWidth()+by)}let escapeHeld=$state(false);let stepHeld=$state(false);$effect(()=>{void comment;void editText;escapeHeld=false;stepHeld=false});$effect(()=>{if(!unsaved)return;const onDown=e=>{if(!e.target?.classList?.contains("sv-modal__backdrop"))return;escapeHeld=true;announce(bm(editingNote!=null?"record.commentNotSaved":"record.commentNotSent"))};window.addEventListener("pointerdown",onDown,true);return()=>window.removeEventListener("pointerdown",onDown,true)});function escapeComment(e){const at2=e.target;if(!fieldsBox?.closest('[role="dialog"]')?.contains(at2))return;if(at2.getAttribute("aria-controls"))return;e.stopPropagation();if(deletingNote!=null)return keepNote();if(editingNote!=null&&at2.closest("form")?.contains(editBox))return cancelEdit();if(at2===commentBox)sendButton?.focus();escapeHeld=true;announce(bm(editingNote!=null?"record.commentNotSaved":"record.commentNotSent"))}let feedBox=$state(null);const focusNote=id=>void tick().then(()=>[...feedBox?.querySelectorAll("[data-note]")??[]].find(n=>n.dataset.note===id)?.querySelector("button")?.focus());function keepNote(){const id=deletingNote;deletingNote=null;if(id)focusNote(id)}const takeFocus=node=>node.focus();function startEdit(n){deletingNote=null;editingNote=n.id;editText=mentionText(n.text,id=>findFieldUser(id)?.name);editPicked=parseMentions(n.text).flatMap(p=>"mention"in p?[mentioned(p.mention,p.name)]:[]);void tick().then(()=>{editBox?.focus();editBox?.setSelectionRange(editText.length,editText.length)})}function saveEdit(){const id=editingNote;if(row&&id&&editText.trim()){editComment(ctrl,row.id,id,encodeMentions(editText,editPicked));announce(bm("record.commentSavedSay"))}editingNote=null;if(id)focusNote(id)}function cancelEdit(){const id=editingNote;editingNote=null;if(id)focusNote(id)}const mentioned=(id,name)=>findFieldUser(id)??{id,name:name||bm("record.someone")};function voteTitle(dir,ids){if(!ids.length)return bm(dir==="up"?"record.voteUp":"record.voteDown");const names=ids.map(id=>findFieldUser(id)?.name??bm("record.someone"));const list=names.join(", ");return bm(dir==="up"?"record.votedUpBy":"record.votedDownBy",{names:list})}
|
|
2
|
+
import{recordActionsFor}from"./record-actions";import{commentSnippets}from"./comment-snippets.svelte";import{onDestroy,onMount,tick,untrack}from"svelte";import{commentDraftsOf,getRecordRequest,holdForRecordEditor}from"./editor-request.svelte";import{SvModal,announce,portalToBody,toast}from"@svgrid/grid";import{DOCK_MAX,DOCK_MIN,DOCK_NARROW,recordDock,recordDockWidth,setRecordDock,setRecordDockWidth}from"./record-dock.svelte";import FieldInput from"./FieldInput.svelte";import{fieldPropsOf,getFieldType,originalColumn,ruleFieldNames}from"./registry.svelte";import{protectionText}from"./field-access.svelte";import{isReadOnlyGrid}from"./base-share";import{canCommentIn,canDeleteRecord}from"./base-permissions";import{askDeleteRecord}from"./record-delete.svelte";import{cellText,dataRows,fieldColumns,leafFilter,primaryIdOf}from"./grid-access";import{recordWalkOf}from"./record-walk";import{addComment,commentStoreTakes,commentThreads,commentVotes,commentsOf,commentsResolve,commentsTakeReplies,commentsTakeVotes,deleteComment,editComment,historyOf,historyState,loadHistory,markSeen,mayVoteComment,myCommentVote,ownsComment,resolveComment,timeAgo,unseenOf,voteComment}from"./activity.svelte";import{uploadAttachment}from"./attachments";import{findFieldUser}from"./sources.svelte";import{encodeMentions,mentionText,parseMentions}from"./mentions";import MentionInput from"./MentionInput.svelte";import{dictationSupported,dictate,withSaid}from"./dictation.svelte";import UserFace from"./UserFace.svelte";import{recordProposalsFor}from"../review/card-marks.svelte";import{bm,bmCount}from"./messages.svelte";let{ctrl,rowId,editPrimary=false,focus,onClose}=$props();let current=$state(rowId);let open=$state(true);let editing=$state(null);let showHidden=$state(false);let comment=$state("");let picked=$state([]);const rows=$derived(ctrl.allRows??[]);let lastAt=-1;function rowIndexOf(list,id){if(id==null)return-1;for(const near of[lastAt,untrack(()=>ctrl.activeCell?.rowIndex??-1)]){if(near<0)continue;for(let d=0;d<=200;d++){if(list[near+d]?.id===id)return lastAt=near+d;if(d&&near-d>=0&&list[near-d]?.id===id)return lastAt=near-d}}return lastAt=list.findIndex(r=>r.id===id)}const index=$derived(rowIndexOf(rows,current));const row=$derived(index>=0?rows[index]:null);const isDraft=$derived(!!ctrl.props?.baseIsDraft?.(current));let lastIndex=0;const at=$derived.by(()=>{if(index>=0)lastIndex=index;return lastIndex});const walk=$derived(recordWalkOf(ctrl));const model=$derived(ctrl.props?.rowModel);const grouped=$derived((ctrl.groupingColumns??[]).length>0);const notRead=r=>String(r.id).startsWith("sv-ph:");function isRecord(r){const kind=r.original?.__group?.kind;return kind?kind==="leaf":r.__treeRow||!(typeof r.getCanExpand==="function"&&r.getCanExpand())}function rowFrom(from,by){for(let i=from+by;i>=0&&i<rows.length;i+=by){const r=rows[i];if(notRead(r)||isRecord(r))return i}return-1}function rowBeside(by){const seen=at;return rowFrom(index>=0?index:by>0?seen-1:seen,by)}let located=$state(0);const walkPlace=$derived(walk&&!isDraft?(void located,walk.place(current)):null);let lastPlace=-1;const walkAt=$derived.by(()=>{if(walkPlace!=null)lastPlace=walkPlace;return lastPlace});const walkFrom=by=>walkPlace!=null?walkAt:by>0?walkAt-1:walkAt;const canPrev=$derived(walk?walkAt>=0&&walk.has(walkFrom(-1),-1):rowBeside(-1)>=0);const canNext=$derived(walk?walkAt>=0&&walk.has(walkFrom(1),1):rowBeside(1)>=0);const records=$derived(!model&&grouped?dataRows(ctrl):null);const total=$derived(walk?walk.total():model?.getState?model.recordCount?.()??model.getState().rowCount??rows.length:(records??rows).length);const locale=$derived(ctrl.props?.localization?.locale);const place=$derived.by(()=>{if(isDraft)return null;if(walk)return walkPlace;if(index<0)return null;if(model)return grouped||model.isPinned?.(current)?null:index-Math.max(0,rows.length-total);return records?records.findIndex(r=>r.id===current):index});const positionText=$derived.by(()=>{if(isDraft)return bm("record.newRecord");if(!walk&&index<0)return bmCount("record.notInView",total,{count:total.toLocaleString(locale)});if(place==null)return bmCount("viewbar.records",total);return bm("record.position",{index:(place+1).toLocaleString(locale),total:total.toLocaleString(locale)})});const filteredOut=$derived.by(()=>{if(!row)return false;const keep=leafFilter(ctrl);return!!keep&&!keep(row)});const columns=$derived((ctrl.allColumns??[]).filter(c=>!c.id.startsWith("__")&&(c.columnDef.field!=null||c.columnDef.fieldFn!=null)));const hidden=$derived.by(()=>{const shownIds=new Set(columns.map(c=>c.id));return fieldColumns(ctrl).filter(c=>!shownIds.has(c.id)).map(c=>({id:c.id,columnDef:c.def}))});function valueOf(c){if(!row)return void 0;const base=c.columnDef.fieldFn?c.columnDef.fieldFn(row.original):row.original?.[c.columnDef.field];return ctrl.getCellDisplayValue(row.id,c.id,columns.includes(c)?row.getCellValueByColumnId(c.id):base)}const asField=c=>({id:c.id,field:String(c.columnDef.field??c.id),header:label(c),fieldType:c.columnDef.fieldType,def:c.columnDef,visible:true});const primaryId=$derived(primaryIdOf(ctrl));const primary=$derived(columns.find(c=>c.id===primaryId)??columns.find(c=>c.columnDef.fieldType==="text"||!c.columnDef.fieldType&&c.columnDef.editorType==null)??columns[0]);const title=$derived(row&&primary?cellText(asField(primary),valueOf(primary),row)||bm("record.untitled"):bm("record.record"));function label(c){return typeof c.columnDef.header==="string"?c.columnDef.header:c.id}const protectionOf=c=>c.columnDef.fieldType?protectionText(originalColumn(c.columnDef),fieldPropsOf(originalColumn(c.columnDef)),ruleFieldNames(c.columnDef)):null;const iconOf=c=>c.columnDef.fieldType?getFieldType(c.columnDef.fieldType)?.icon:void 0;function editable(c){if(!row||!ctrl.editingEnabled)return false;const ci=ctrl.allColumns.findIndex(x=>x.id===c.id);if(ci<0)return false;return ctrl.isCellEditableAt?!!ctrl.isCellEditableAt(index,ci):c.columnDef.editable!==false}const editorOpen=$derived(editing!=null);$effect(()=>{if(editorOpen)return untrack(holdForRecordEditor)});onMount(()=>{if(editPrimary&&primary&&editable(primary))editing=primary.id});let settled=$state(false);const settling=setTimeout(()=>settled=true,400);onDestroy(()=>{clearTimeout(settling);walk?.stop?.()});let locating=null;$effect(()=>{const w=walk;const r=row;if(!w?.locate||!r||isDraft||walkPlace!=null||locating===r.id)return;locating=r.id;untrack(()=>void w.locate(r.id,r.original).finally(()=>located+=1))});let commentBox=$state(null);const commentFocusFor=r=>r?.focus==="comment"&&r.ctrl===ctrl;const initialFocus=()=>focus==="comment"||commentFocusFor(getRecordRequest())?commentBox:null;$effect(()=>{const r=getRecordRequest();if(!commentFocusFor(r))return;untrack(()=>{if(r.rowId!==current)current=r.rowId;queueMicrotask(()=>commentBox?.focus())})});let listening=$state(null);const speakable=c=>dictationSupported()&&(c.columnDef.fieldType==="text"||c.columnDef.fieldType==="longText");async function speakInto(c){if(listening)return;listening=c.id;try{const said=await dictate();if(said)commit(c,withSaid(row?.getCellValueByColumnId?.(c.id),said,c.columnDef.fieldType==="longText"))}finally{listening=null}}async function speakComment(){if(listening)return;listening=":comment";try{const said=await dictate();if(said)comment=withSaid(comment,said,false)}finally{listening=null}}function sameValue(a,b){const none=x=>x==null||x===""||Array.isArray(x)&&!x.length;if(none(a)&&none(b))return true;return typeof a==="object"||typeof b==="object"?JSON.stringify(a)===JSON.stringify(b):String(a)===String(b)}function commit(c,v){editing=null;if(!row||v===void 0)return;const none=x=>x==null||x===""||Array.isArray(x)&&!x.length;if(none(v)&&none(row.getCellValueByColumnId?.(c.id)))return;const at2=rowIndexOf(ctrl.allRows,current);if(at2<0||!ctrl.startEditing(at2,c.id))return;ctrl.updateEditingCellValue(v);ctrl.saveEditingCell()}let fieldsBox=$state(null);const focusField=id=>[...fieldsBox?.querySelectorAll("[data-frv-field]")??[]].find(el=>el.dataset.frvField===id)?.querySelector(".sv-frv-open")?.focus();function stopEditing(c){editing=null;setTimeout(()=>{const now=document.activeElement;if(editing==null&&(!now||now===document.body||now.getAttribute("role")==="dialog"))focusField(c.id)},0)}const typedInto=c=>["text","number","textarea","fieldNumber","fieldTime",void 0].includes(c.columnDef.editorType);function escapeBox(e){if(e.key!=="Escape"||e.isComposing)return;if((unsaved||deletingNote!=null)&&editing==null)return escapeComment(e);const c=editing!=null?columns.find(x=>x.id===editing):void 0;if(!c||!(typedInto(c)||c.columnDef.editorType==="fieldRating"))return;e.stopPropagation();stopEditing(c)}function editBeside(c,dir){const at2=columns.findIndex(x=>x.id===c.id);for(let i=at2+dir;i>=0&&i<columns.length;i+=dir){const next=columns[i];if(!editable(next)||next.columnDef.editorType==="checkbox")continue;if(typedInto(next))editing=next.id;else{editing=null;void tick().then(()=>focusField(next.id))}return}}let awaited=$state(null);let awaitedRow=$state(null);let stepping=false;let pressed=0;function arrived(){stepping=false;if(!pressed)return;const by=pressed>0?1:-1;pressed-=by;queueMicrotask(()=>void go(by))}$effect(()=>{const id=awaited;if(id!=null&&rowIndexOf(rows,id)>=0)untrack(()=>{current=id;awaited=null;arrived()})});$effect(()=>{const at2=awaitedRow;const r=at2==null?void 0:rows[at2];if(r&&!notRead(r))untrack(()=>{awaitedRow=null;lastAt=at2;if(isRecord(r))current=r.id;arrived()})});let swipeAt=null;function swipeStart(e){const t=e.touches[0];const from=e.target;const busy=!!from?.closest?.('input, textarea, select, [contenteditable="true"], .sv-frv-files, [data-no-swipe]');swipeAt=e.touches.length===1&&t&&!busy?{x:t.clientX,y:t.clientY,t:Date.now()}:null}function swipeEnd(e){const s0=swipeAt;swipeAt=null;const t=e.changedTouches[0];if(!s0||!t||editing!=null)return;const dx=t.clientX-s0.x;const dy=t.clientY-s0.y;if(Math.abs(dx)<70||Math.abs(dx)<Math.abs(dy)*1.8||Date.now()-s0.t>700)return;if(dx<0&&canNext)void go(1);else if(dx>0&&canPrev)void go(-1)}function keepInSight(e){const el=e.target;if(!el?.matches?.('input, textarea, [contenteditable="true"]')||typeof window==="undefined"||window.innerWidth>600)return;setTimeout(()=>el.scrollIntoView?.({block:"center",behavior:"smooth"}),320)}async function go(by){if(stepping){pressed+=by;return}if(editingNote!=null){stepHeld=true;announce(bm("record.commentHoldsStep"));editBox?.focus();return}editing=null;if(walk){stepping=true;const id=await walk.step(walkFrom(by),by);if(id==null){stepping=false;pressed=0;return}awaited=id;setTimeout(()=>{if(awaited!==id)return;awaited=null;stepping=false;pressed=0},3e3);return}const to=rowBeside(by);if(to<0)return;const next=rows[to];if(!notRead(next)){lastAt=to;current=next.id;return}stepping=true;awaitedRow=to;ctrl.buildApi?.().scrollToRow?.(to)}const allCols=$derived([...columns,...hidden]);const restorable=c=>!!c&&c.columnDef.editorType!=="attachment"&&c.columnDef.editorType!=="fieldLink";const feed=$derived.by(()=>{if(!row)return[];const edits=historyOf(ctrl,row.id).map((ch,i)=>{if(ch.added)return{key:`a${ch.at}-${i}`,at:ch.at,by:ch.by,remote:true,kind:"added",field:"",text:""};const c=allCols.find(x=>x.id===ch.columnId);const show=v=>c?cellText(asField(c),v,row):String(v??"");return{key:`e${ch.at}${ch.columnId}-${i}`,at:ch.at,by:ch.by,automation:ch.automation,via:ch.via,through:ch.through,remote:ch.remote,undone:ch.undone,redone:ch.redone,kind:"edit",field:c?label(c):ch.columnId,text:show(ch.value),..."from"in ch&&show(ch.from)?{from:show(ch.from)}:{},..."from"in ch&&restorable(c)?{restore:{col:c,value:ch.from??null}}:{}}});const notes=commentThreads(commentsOf(ctrl,row.id)).top.map(noteItem);return[...edits,...notes].sort((a,b)=>a.at-b.at)});const noteItem=n=>({key:n.id,at:n.at,by:n.by,kind:"comment",field:"",text:n.text,parts:parseMentions(n.text),note:n});const threads=$derived(row?commentThreads(commentsOf(ctrl,row.id)).replies:new Map);let answering=$state(null);let openThreads=$state(new Set);const nameOf=id=>id?findFieldUser(id)?.name??bm("record.someone"):bm("record.someone");function replyTo(note){answering=note;void tick().then(()=>commentBox?.focus())}const preview=item=>{const text=(item.parts??[]).map(p=>"mention"in p?"@"+mentioned(p.mention,p.name).name:p.text).join("").replace(/\s+/g," ").trim();return text.length>90?text.slice(0,89)+"…":text};function toggleThread(id){const next=new Set(openThreads);if(next.has(id))next.delete(id);else next.add(id);openThreads=next}function resolveThread(note,on){if(!row)return;resolveComment(ctrl,row.id,note.id,on);if(on)openThreads=new Set([...openThreads].filter(x=>x!==note.id));if(on&&answering?.id===note.id)answering=null;announce(bm(on?"record.threadResolvedSay":"record.threadReopenedSay"))}const person=item=>item.by?findFieldUser(item.by)?.name??bm("record.someone"):item.remote?bm("record.someoneElse"):bm("record.you");const who=item=>item.automation?bm("record.byAutomation",{name:item.automation}):item.via?bm("record.acceptedBy",{source:item.via,person:person(item)}):item.through?bm("record.through",{person:person(item),source:item.through}):person(item);const shownId=$derived(row?.id);$effect(()=>{const id=shownId;if(id!=null)untrack(()=>loadHistory(ctrl,id))});const history=$derived(row?historyState(ctrl,row.id):{loading:false});$effect(()=>{const id=row?.id;if(id!=null&&unseenOf(ctrl,id))untrack(()=>markSeen(ctrl,id))});const proposals=$derived(row?recordProposalsFor(ctrl.props?.getRowId,row.original,row.id):null);const proposalOf=c=>proposals?.list.find(p=>p.field===String(c.columnDef.field??c.id));const proposedText=(c,p)=>cellText(asField(c),p.after,row)||proposals?.messages.empty||"";let deciding=$state(false);async function decide(ids,how){if(!proposals||deciding||!ids.length)return;deciding=true;try{await(how==="accept"?proposals.accept(ids):proposals.reject(ids))}finally{deciding=false}}const readOnly=$derived(isReadOnlyGrid(ctrl));const canComment=$derived(canCommentIn(ctrl));const takesFiles=$derived(commentStoreTakes("files"));const takesInternal=$derived(commentStoreTakes("internal"));let commentFiles=$state([]);let uploading=$state(0);let internalNote=$state(false);let fileInput=$state(null);const canSend=$derived((!!comment.trim()||commentFiles.length>0)&&uploading===0);async function attach(list){if(!list||!row)return;const forRow=row.id;for(const file of Array.from(list)){uploading+=1;try{const done=await uploadAttachment(file,{},{row:row?.original,columnId:"",signal:new AbortController().signal,onProgress:()=>{}});if(row?.id===forRow)commentFiles=[...commentFiles,done]}catch(e){toast.error(bm("record.commentUploadFailed",{name:file.name,error:e instanceof Error?e.message:String(e)}))}finally{uploading-=1}}if(fileInput)fileInput.value=""}const snippets=$derived(commentSnippets());let repliesOpen=$state(false);let replies=$state(null);let repliesError=$state("");let replyQuery=$state("");let replyName=$state("");let naming=$state(false);const shownReplies=$derived((replies??[]).filter(r=>!replyQuery.trim()||(r.title+" "+r.text).toLowerCase().includes(replyQuery.trim().toLowerCase())));const recordRef=()=>({rowId:String(row?.original?.id??row?.id??""),row:row?.original??{}});async function openReplies(){if(repliesOpen){repliesOpen=false;return}const list=snippets;if(!list||!row)return;repliesOpen=true;replies=null;repliesError="";replyQuery="";naming=false;const forRow=row.id;try{const got=await list.list(ctrl?.props?.baseTableId,recordRef());if(row?.id===forRow)replies=Array.isArray(got)?got:[]}catch(e){repliesError=e instanceof Error?e.message:String(e);replies=[]}}function pickReply(reply){comment=comment.trim()?comment.replace(/\s+$/,"")+"\n\n"+reply.text:reply.text;if(reply.files?.length)commentFiles=[...commentFiles,...reply.files.filter(f=>!commentFiles.some(x=>x.id===f.id))];repliesOpen=false;void tick().then(()=>commentBox?.focus())}async function saveReply(){const keep=snippets?.save;const title2=replyName.trim();if(!keep||!title2||!comment.trim())return;try{await keep(ctrl?.props?.baseTableId,{title:title2,text:comment});toast.success(bm("record.replySaved"));naming=false;replyName="";replies=null;repliesOpen=false}catch(e){toast.error(bm("record.replyNotSaved",{error:e instanceof Error?e.message:String(e)}))}}$effect(()=>{void current;repliesOpen=false});function send(){if(!row||!canSend||!canComment||isDraft)return;const answered=answering&&commentsOf(ctrl,row.id).some(c=>c.id===answering.id)?answering:null;addComment(ctrl,row.id,encodeMentions(comment,picked),{files:commentFiles,internal:internalNote,...answered?{replyTo:answered.id}:{}});comment="";picked=[];commentFiles=[];internalNote=false;answering=null;announce(bm(answered?"record.replyAddedSay":"record.commentAddedSay"))}const fileSize=n=>n==null?"":n<1024?`${n} B`:n<1048576?`${Math.round(n/1024)} KB`:`${(n/1048576).toFixed(1)} MB`;let editingNote=$state(null);let editText=$state("");let editPicked=$state([]);let deletingNote=$state(null);let editBox=$state(null);let sendButton=$state(null);const unsaved=$derived(!!row&&(!!comment.trim()||editingNote!=null));$effect(()=>{const id=current;const drafts=commentDraftsOf(ctrl);const kept=drafts.get(id);comment=kept?.text??"";picked=kept?.picked??[];editingNote=null;deletingNote=null;answering=null});$effect(()=>{const drafts=commentDraftsOf(ctrl);if(comment.trim())drafts.set(current,{text:comment,picked});else drafts.delete(current)});function closing(){if(comment.trim())toast.info(bm("record.commentKept"));onClose()}let narrow=$state(typeof window!=="undefined"&&window.innerWidth<DOCK_NARROW);$effect(()=>{const look=()=>narrow=window.innerWidth<DOCK_NARROW;window.addEventListener("resize",look);return()=>window.removeEventListener("resize",look)});const mode=$derived(narrow?"center":recordDock());const DOCKS=[{id:"center",key:"record.dockCenter",icon:"M3 4.5h14v11H3zM6.5 7.5h7v5h-7z"},{id:"right",key:"record.dockRight",icon:"M3 4.5h14v11H3zM11.5 4.5v11"},{id:"full",key:"record.dockFull",icon:"M3 4.5h14v11H3zM3 7.5h14"}];function dockAt(next){if(next===mode)return;editing=null;setRecordDock(next);announce(bm(DOCKS.find(d=>d.id===next).key))}let anchor=$state(null);let side=$state(null);let sideTop=$state(0);const sideTitleId=`sv-frv-side-${Math.random().toString(36).slice(2,9)}`;$effect(()=>{if(mode!=="right"||!anchor)return;const width=recordDockWidth();const host=anchor.closest(".sv-fbase-tables")??anchor.closest(".sv-grid-root");const before=host?.style.marginInlineEnd??"";if(host)host.style.marginInlineEnd=`${width}px`;const place2=()=>{const top=host?host.getBoundingClientRect().top:0;sideTop=Math.round(Math.min(Math.max(0,top),window.innerHeight*.3))};place2();const watch=typeof ResizeObserver==="function"&&host?new ResizeObserver(place2):null;if(host)watch?.observe(host);window.addEventListener("resize",place2);window.addEventListener("scroll",place2,{passive:true,capture:true});return()=>{if(host)host.style.marginInlineEnd=before;watch?.disconnect();window.removeEventListener("resize",place2);window.removeEventListener("scroll",place2,{capture:true})}});$effect(()=>{if(mode!=="right"||!side)return;const panel=side;void tick().then(()=>{if(panel.contains(document.activeElement))return;const to=initialFocus()??panel.querySelector('.sv-frv-side-body button:not(:disabled), .sv-frv-side-body input, .sv-frv-side-body textarea, .sv-frv-side-body [tabindex="0"]');(to??panel).focus({preventScroll:true})})});function sideKey(e){if(e.key!=="Escape"||e.defaultPrevented||e.isComposing)return;if(unsaved||deletingNote!=null)return;e.stopPropagation();closeSide()}function closeSide(){open=false;closing()}const activeId=$derived(mode==="right"?(ctrl.allRows??[])[ctrl.activeCell?.rowIndex??-1]?.id??void 0:void 0);let seenActive=null;$effect(()=>{const id=activeId;const docked=mode==="right";untrack(()=>{if(!docked||seenActive===null){seenActive=docked?id:null;return}if(id===seenActive)return;seenActive=id;if(!id||id===current||editingNote!=null)return;if(!dataRows(ctrl).some(r=>r.id===id))return;editing=null;current=id})});let dragFrom=null;function edgeDown(e){dragFrom={x:e.clientX,w:recordDockWidth()};e.currentTarget.setPointerCapture(e.pointerId)}function edgeMove(e){if(!dragFrom)return;setRecordDockWidth(Math.min(DOCK_MAX,Math.max(DOCK_MIN,dragFrom.w+(dragFrom.x-e.clientX))))}function edgeUp(e){if(!dragFrom)return;dragFrom=null;e.currentTarget.releasePointerCapture(e.pointerId)}function edgeKey(e){const by=e.key==="ArrowLeft"?24:e.key==="ArrowRight"?-24:0;if(!by)return;e.preventDefault();setRecordDockWidth(recordDockWidth()+by)}let escapeHeld=$state(false);let stepHeld=$state(false);$effect(()=>{void comment;void editText;escapeHeld=false;stepHeld=false});$effect(()=>{if(!unsaved)return;const onDown=e=>{if(!e.target?.classList?.contains("sv-modal__backdrop"))return;escapeHeld=true;announce(bm(editingNote!=null?"record.commentNotSaved":"record.commentNotSent"))};window.addEventListener("pointerdown",onDown,true);return()=>window.removeEventListener("pointerdown",onDown,true)});function escapeComment(e){const at2=e.target;if(!fieldsBox?.closest('[role="dialog"]')?.contains(at2))return;if(at2.getAttribute("aria-controls"))return;e.stopPropagation();if(deletingNote!=null)return keepNote();if(editingNote!=null&&at2.closest("form")?.contains(editBox))return cancelEdit();if(at2===commentBox)sendButton?.focus();escapeHeld=true;announce(bm(editingNote!=null?"record.commentNotSaved":"record.commentNotSent"))}let feedBox=$state(null);const focusNote=id=>void tick().then(()=>[...feedBox?.querySelectorAll("[data-note]")??[]].find(n=>n.dataset.note===id)?.querySelector("button")?.focus());function keepNote(){const id=deletingNote;deletingNote=null;if(id)focusNote(id)}const takeFocus=node=>node.focus();function startEdit(n){deletingNote=null;editingNote=n.id;editText=mentionText(n.text,id=>findFieldUser(id)?.name);editPicked=parseMentions(n.text).flatMap(p=>"mention"in p?[mentioned(p.mention,p.name)]:[]);void tick().then(()=>{editBox?.focus();editBox?.setSelectionRange(editText.length,editText.length)})}function saveEdit(){const id=editingNote;if(row&&id&&editText.trim()){editComment(ctrl,row.id,id,encodeMentions(editText,editPicked));announce(bm("record.commentSavedSay"))}editingNote=null;if(id)focusNote(id)}function cancelEdit(){const id=editingNote;editingNote=null;if(id)focusNote(id)}const mentioned=(id,name)=>findFieldUser(id)??{id,name:name||bm("record.someone")};function voteTitle(dir,ids){if(!ids.length)return bm(dir==="up"?"record.voteUp":"record.voteDown");const names=ids.map(id=>findFieldUser(id)?.name??bm("record.someone"));const list=names.join(", ");return bm(dir==="up"?"record.votedUpBy":"record.votedDownBy",{names:list})}
|
|
3
3
|
</script>
|
|
4
4
|
|
|
5
5
|
{#snippet field(c: Col, canEdit: boolean)}
|
|
@@ -113,68 +113,106 @@ import{recordActionsFor}from"./record-actions";import{commentSnippets}from"./com
|
|
|
113
113
|
{/if}
|
|
114
114
|
{/if}
|
|
115
115
|
</div>
|
|
116
|
+
{#snippet entry(item: FeedItem)}
|
|
117
|
+
<div class="sv-frv-item-head"><strong>{who(item)}</strong>{#if item.note?.internal}<span class="sv-frv-internal-tag">{bm('record.internalTag')}</span>{/if}{item.kind === 'edit' ? ` ${bm(item.undone ? 'record.undidField' : item.redone ? 'record.redidField' : 'record.changedField', { field: item.field })}` : item.kind === 'added' ? ` ${bm('record.addedRecord')}` : ''}<span class="sv-frv-when">{timeAgo(item.at)}</span></div>
|
|
118
|
+
{#if item.note && editingNote === item.note.id}
|
|
119
|
+
<form class="sv-frv-comment" onsubmit={(e) => { e.preventDefault(); saveEdit() }}>
|
|
120
|
+
<MentionInput bind:value={editText} bind:picked={editPicked} bind:box={editBox} onSubmit={saveEdit} />
|
|
121
|
+
{#if stepHeld}<p class="sv-frv-held">{bm('record.commentHoldsStep')}</p>{:else if escapeHeld}<p class="sv-frv-held">{bm('record.commentNotSaved')}</p>{/if}
|
|
122
|
+
<div class="sv-frv-note-acts">
|
|
123
|
+
<button type="button" class="sv-frv-link" onclick={cancelEdit}>{bm('record.cancelComment')}</button>
|
|
124
|
+
<button type="submit" class="sv-frv-btn" disabled={!editText.trim()}>{bm('record.saveComment')}</button>
|
|
125
|
+
</div>
|
|
126
|
+
</form>
|
|
127
|
+
{:else if item.kind !== 'added'}
|
|
128
|
+
<div class="sv-frv-item-body">
|
|
129
|
+
{#if item.parts}{#each item.parts as part, i (i)}{#if 'mention' in part}{@const user = mentioned(part.mention, part.name)}<span class="sv-frv-mention" title={user.email ?? user.name}><UserFace {user} size={14} />@{user.name}</span>{:else}{part.text}{/if}{/each}{:else}{#if item.from !== undefined}<span class="sv-frv-from">{item.from}</span><span class="sv-frv-arrow" aria-label={bm('record.changedTo')}>→</span>{/if}{item.text || (item.kind === 'edit' ? bm('record.cleared') : '')}{/if}{#if item.note?.editedAt} <span class="sv-frv-when">{bm('record.commentEdited')}</span>{/if}
|
|
130
|
+
{#if item.note?.files?.length}
|
|
131
|
+
<ul class="sv-frv-files" aria-label={bm('record.commentFiles')}>
|
|
132
|
+
{#each item.note.files as f (f.id)}
|
|
133
|
+
<li><a href={f.url} target="_blank" rel="noopener noreferrer" download={f.name}>{f.name}</a>{#if f.size != null}<span class="sv-frv-when">{fileSize(f.size)}</span>{/if}</li>
|
|
134
|
+
{/each}
|
|
135
|
+
</ul>
|
|
136
|
+
{/if}
|
|
137
|
+
</div>
|
|
138
|
+
{#if item.restore && !readOnly && editable(item.restore.col) && !sameValue(row?.getCellValueByColumnId?.(item.restore.col.id), item.restore.value)}
|
|
139
|
+
{@const back = item.restore}
|
|
140
|
+
<button type="button" class="sv-frv-link sv-frv-restore" title={bm('record.restoreHint', { field: item.field })} onclick={() => commit(back.col, back.value)}>{bm('record.restoreValue')}</button>
|
|
141
|
+
{/if}
|
|
142
|
+
{#if item.note}
|
|
143
|
+
{@const note = item.note}
|
|
144
|
+
{@const votes = commentVotes(note)}
|
|
145
|
+
{@const mine = myCommentVote(note)}
|
|
146
|
+
{@const voting = canComment && mayVoteComment(note)}
|
|
147
|
+
{@const showVotes = commentsTakeVotes() && (voting || votes.up.length > 0 || votes.down.length > 0)}
|
|
148
|
+
{@const owns = canComment && (ownsComment(note, 'update') || ownsComment(note, 'remove'))}
|
|
149
|
+
{#if canComment && deletingNote === note.id}
|
|
150
|
+
<div class="sv-frv-note-acts" role="group" aria-label={bm('record.deleteCommentAsk')}>
|
|
151
|
+
<span>{bm('record.deleteCommentAsk')}</span>
|
|
152
|
+
<button type="button" class="sv-frv-link" onclick={() => { if (row) deleteComment(ctrl, row.id, note.id); deletingNote = null; announce(bm('record.commentDeletedSay')) }}>{bm('record.deleteComment')}</button>
|
|
153
|
+
<button type="button" class="sv-frv-link" use:takeFocus onclick={keepNote}>{bm('record.cancelComment')}</button>
|
|
154
|
+
</div>
|
|
155
|
+
{:else if showVotes || owns}
|
|
156
|
+
<div class="sv-frv-note-acts" data-note={note.id}>
|
|
157
|
+
{#if showVotes}
|
|
158
|
+
|
|
159
|
+
<span class="sv-frv-votes" role="group" aria-label={bm('record.commentVotes')}>
|
|
160
|
+
<button type="button" class="sv-frv-vote" class:is-mine={mine === 'up'} aria-pressed={mine === 'up'} aria-label={bm('record.voteUpCount', { count: votes.up.length })} title={voteTitle('up', votes.up)} disabled={!voting} onclick={() => { if (row) voteComment(ctrl, row.id, note.id, 'up') }}>
|
|
161
|
+
<svg viewBox="0 0 24 24" width="13" height="13" aria-hidden="true"><path d="M7 10v11H3V10h4zm2 11h8.3a2 2 0 0 0 2-1.6l1.4-7A2 2 0 0 0 18.7 10H14V5.5A2.5 2.5 0 0 0 11.5 3L9 10v11z" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linejoin="round" /></svg>
|
|
162
|
+
<span>{votes.up.length}</span>
|
|
163
|
+
</button>
|
|
164
|
+
<button type="button" class="sv-frv-vote is-down" class:is-mine={mine === 'down'} aria-pressed={mine === 'down'} aria-label={bm('record.voteDownCount', { count: votes.down.length })} title={voteTitle('down', votes.down)} disabled={!voting} onclick={() => { if (row) voteComment(ctrl, row.id, note.id, 'down') }}>
|
|
165
|
+
<svg viewBox="0 0 24 24" width="13" height="13" aria-hidden="true"><path d="M17 14V3h4v11h-4zM15 3H6.7a2 2 0 0 0-2 1.6l-1.4 7A2 2 0 0 0 5.3 14H10v4.5a2.5 2.5 0 0 0 2.5 2.5L15 14V3z" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linejoin="round" /></svg>
|
|
166
|
+
<span>{votes.down.length}</span>
|
|
167
|
+
</button>
|
|
168
|
+
</span>
|
|
169
|
+
{/if}
|
|
170
|
+
{#if owns && ownsComment(note, 'update')}<button type="button" class="sv-frv-link" onclick={() => startEdit(note)}>{bm('record.editComment')}</button>{/if}
|
|
171
|
+
{#if owns && ownsComment(note, 'remove')}<button type="button" class="sv-frv-link" onclick={() => { editingNote = null; deletingNote = note.id }}>{bm('record.deleteComment')}</button>{/if}
|
|
172
|
+
</div>
|
|
173
|
+
{/if}
|
|
174
|
+
{/if}
|
|
175
|
+
{/if}
|
|
176
|
+
{/snippet}
|
|
116
177
|
<aside class="sv-frv-activity" aria-label={bm('record.activity')}>
|
|
117
178
|
<h3 class="sv-frv-activity-title">{bm('record.activity')}</h3>
|
|
118
179
|
<ol class="sv-frv-feed" bind:this={feedBox}>
|
|
119
180
|
{#each feed as item (item.key)}
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
{#if item.restore && !readOnly && editable(item.restore.col) && !sameValue(row?.getCellValueByColumnId?.(item.restore.col.id), item.restore.value)}
|
|
143
|
-
{@const back = item.restore}
|
|
144
|
-
<button type="button" class="sv-frv-link sv-frv-restore" title={bm('record.restoreHint', { field: item.field })} onclick={() => commit(back.col, back.value)}>{bm('record.restoreValue')}</button>
|
|
181
|
+
{@const thread = item.note ? (threads.get(item.note.id) ?? []) : []}
|
|
182
|
+
{@const folded = !!item.note?.resolved && !openThreads.has(item.note.id)}
|
|
183
|
+
<li class="sv-frv-item" class:is-comment={item.kind === 'comment'} class:is-internal={!!item.note?.internal} class:is-resolved={!!item.note?.resolved}>
|
|
184
|
+
{#if folded && item.note?.resolved}
|
|
185
|
+
{@const note = item.note}
|
|
186
|
+
|
|
187
|
+
<div class="sv-frv-resolved">
|
|
188
|
+
<svg viewBox="0 0 16 16" width="13" height="13" aria-hidden="true"><path d="M3 8.5l3 3 7-7" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round" /></svg>
|
|
189
|
+
<span><strong>{who(item)}</strong>: {preview(item)}</span>
|
|
190
|
+
</div>
|
|
191
|
+
<div class="sv-frv-thread-acts">
|
|
192
|
+
<span class="sv-frv-when">{bm('record.threadResolvedBy', { person: nameOf(item.note.resolved.by) })}, {timeAgo(item.note.resolved.at)}</span>
|
|
193
|
+
<button type="button" class="sv-frv-link" aria-expanded="false" onclick={() => toggleThread(note.id)}>{bmCount('record.showThread', 1 + thread.length)}</button>
|
|
194
|
+
</div>
|
|
195
|
+
{:else}
|
|
196
|
+
{@render entry(item)}
|
|
197
|
+
{#if thread.length}
|
|
198
|
+
<ol class="sv-frv-thread" aria-label={bm('record.threadReplies')}>
|
|
199
|
+
{#each thread as answer (answer.id)}
|
|
200
|
+
<li class="sv-frv-item is-comment is-reply" class:is-internal={!!answer.internal}>{@render entry(noteItem(answer))}</li>
|
|
201
|
+
{/each}
|
|
202
|
+
</ol>
|
|
145
203
|
{/if}
|
|
146
|
-
{#if item.note}
|
|
204
|
+
{#if item.note && ((canComment && !isDraft && (commentsTakeReplies() || commentsResolve())) || item.note.resolved)}
|
|
147
205
|
{@const note = item.note}
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
<
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
</div>
|
|
159
|
-
{:else if showVotes || owns}
|
|
160
|
-
<div class="sv-frv-note-acts" data-note={note.id}>
|
|
161
|
-
{#if showVotes}
|
|
162
|
-
|
|
163
|
-
<span class="sv-frv-votes" role="group" aria-label={bm('record.commentVotes')}>
|
|
164
|
-
<button type="button" class="sv-frv-vote" class:is-mine={mine === 'up'} aria-pressed={mine === 'up'} aria-label={bm('record.voteUpCount', { count: votes.up.length })} title={voteTitle('up', votes.up)} disabled={!voting} onclick={() => { if (row) voteComment(ctrl, row.id, note.id, 'up') }}>
|
|
165
|
-
<svg viewBox="0 0 24 24" width="13" height="13" aria-hidden="true"><path d="M7 10v11H3V10h4zm2 11h8.3a2 2 0 0 0 2-1.6l1.4-7A2 2 0 0 0 18.7 10H14V5.5A2.5 2.5 0 0 0 11.5 3L9 10v11z" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linejoin="round" /></svg>
|
|
166
|
-
<span>{votes.up.length}</span>
|
|
167
|
-
</button>
|
|
168
|
-
<button type="button" class="sv-frv-vote is-down" class:is-mine={mine === 'down'} aria-pressed={mine === 'down'} aria-label={bm('record.voteDownCount', { count: votes.down.length })} title={voteTitle('down', votes.down)} disabled={!voting} onclick={() => { if (row) voteComment(ctrl, row.id, note.id, 'down') }}>
|
|
169
|
-
<svg viewBox="0 0 24 24" width="13" height="13" aria-hidden="true"><path d="M17 14V3h4v11h-4zM15 3H6.7a2 2 0 0 0-2 1.6l-1.4 7A2 2 0 0 0 5.3 14H10v4.5a2.5 2.5 0 0 0 2.5 2.5L15 14V3z" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linejoin="round" /></svg>
|
|
170
|
-
<span>{votes.down.length}</span>
|
|
171
|
-
</button>
|
|
172
|
-
</span>
|
|
173
|
-
{/if}
|
|
174
|
-
{#if owns && ownsComment(note, 'update')}<button type="button" class="sv-frv-link" onclick={() => startEdit(note)}>{bm('record.editComment')}</button>{/if}
|
|
175
|
-
{#if owns && ownsComment(note, 'remove')}<button type="button" class="sv-frv-link" onclick={() => { editingNote = null; deletingNote = note.id }}>{bm('record.deleteComment')}</button>{/if}
|
|
176
|
-
</div>
|
|
177
|
-
{/if}
|
|
206
|
+
<div class="sv-frv-thread-acts">
|
|
207
|
+
{#if note.resolved}
|
|
208
|
+
<span class="sv-frv-when">{bm('record.threadResolvedBy', { person: nameOf(note.resolved.by) })}</span>
|
|
209
|
+
{#if canComment && commentsResolve()}<button type="button" class="sv-frv-link" onclick={() => resolveThread(note, false)}>{bm('record.reopenThread')}</button>{/if}
|
|
210
|
+
<button type="button" class="sv-frv-link" aria-expanded="true" onclick={() => toggleThread(note.id)}>{bm('record.hideThread')}</button>
|
|
211
|
+
{:else}
|
|
212
|
+
{#if commentsTakeReplies()}<button type="button" class="sv-frv-link" class:is-on={answering?.id === note.id} onclick={() => replyTo(note)}>{bm('record.replyComment')}</button>{/if}
|
|
213
|
+
{#if commentsResolve()}<button type="button" class="sv-frv-link" title={bm('record.resolveThreadHint')} onclick={() => resolveThread(note, true)}>{bm('record.resolveThread')}</button>{/if}
|
|
214
|
+
{/if}
|
|
215
|
+
</div>
|
|
178
216
|
{/if}
|
|
179
217
|
{/if}
|
|
180
218
|
</li>
|
|
@@ -196,6 +234,12 @@ import{recordActionsFor}from"./record-actions";import{commentSnippets}from"./com
|
|
|
196
234
|
send()
|
|
197
235
|
}}
|
|
198
236
|
>
|
|
237
|
+
{#if answering}
|
|
238
|
+
<div class="sv-frv-answering">
|
|
239
|
+
<span>{bm('record.replyingTo', { person: nameOf(answering.by) })}</span>
|
|
240
|
+
<button type="button" class="sv-frv-link" aria-label={bm('record.cancelReply')} title={bm('record.cancelReply')} onclick={() => (answering = null)}>×</button>
|
|
241
|
+
</div>
|
|
242
|
+
{/if}
|
|
199
243
|
<MentionInput bind:value={comment} bind:picked bind:box={commentBox} onSubmit={send} />
|
|
200
244
|
{#if escapeHeld && editingNote == null}<p class="sv-frv-held">{bm('record.commentNotSent')}</p>{/if}
|
|
201
245
|
{#if commentFiles.length || uploading}
|
|
@@ -354,5 +398,5 @@ import{recordActionsFor}from"./record-actions";import{commentSnippets}from"./com
|
|
|
354
398
|
{/if}
|
|
355
399
|
|
|
356
400
|
<style>
|
|
357
|
-
.sv-frv-dock{display:inline-flex;gap:2px;padding:2px;border:1px solid var(--sg-border, #e2e8f0);border-radius:8px;background:var(--sg-header-bg, #f8fafc)}.sv-frv-dock-btn{display:grid;place-items:center;width:28px;height:24px;padding:0;border:0;border-radius:6px;background:none;color:var(--sg-muted, #64748b);cursor:pointer}.sv-frv-dock-btn:hover{color:var(--sg-fg, #0f172a)}.sv-frv-dock-btn.is-on{background:var(--sg-bg, #fff);color:var(--sg-accent, #2563eb);box-shadow:0 1px 2px #0f172a26}.sv-frv-dock-btn:focus-visible{outline:2px solid var(--sg-accent, #2563eb);outline-offset:1px}.sv-frv-side{position:fixed;right:0;bottom:0;z-index:9000;display:flex;flex-direction:column;box-sizing:border-box;max-width:100vw;background:var(--sg-bg, #fff);color:var(--sg-fg, #0f172a);border-inline-start:1px solid var(--sg-border, #e2e8f0);box-shadow:-12px 0 32px -16px #0f172a59;font-size:13.5px;line-height:1.6}.sv-frv-side:focus{outline:none}.sv-frv-edge{position:absolute;inset-block:0;inset-inline-start:-4px;width:8px;cursor:ew-resize;touch-action:none;z-index:1}.sv-frv-edge:hover,.sv-frv-edge:focus-visible{background:color-mix(in srgb,var(--sg-accent, #2563eb) 25%,transparent);outline:none}.sv-frv-side-head{display:flex;align-items:center;gap:10px;padding:11px 14px;border-bottom:1px solid var(--sg-border, #e2e8f0)}.sv-frv-side-title{flex:1;min-width:0;margin:0;font-size:15px;font-weight:650;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.sv-frv-side-x{flex:none;width:28px;height:28px;display:grid;place-items:center;background:none;border:0;color:var(--sg-muted, #64748b);cursor:pointer;border-radius:6px;font-size:20px;line-height:1}.sv-frv-side-x:hover{background:var(--sg-row-hover-bg, #f1f5f9);color:var(--sg-fg, #0f172a)}.sv-frv-side-body{flex:1;min-height:0;overflow:auto;padding:14px}.sv-frv-side-foot{padding:10px 14px;border-top:1px solid var(--sg-border, #e2e8f0)}.sv-frv-side .sv-frv-layout{grid-template-columns:minmax(0,1fr)}.sv-frv-proposals{display:flex;align-items:center;justify-content:space-between;gap:12px;margin:0 0 12px;padding:8px 12px;border-radius:var(--sg-radius, 6px);font-size:13px;background:color-mix(in srgb,var(--sg-accent, #2563eb) 8%,var(--sg-bg, #fff));border:1px solid color-mix(in srgb,var(--sg-accent, #2563eb) 30%,var(--sg-border, #e2e8f0))}.sv-frv-proposal{display:flex;flex-wrap:wrap;align-items:center;gap:4px 10px;margin-top:6px;padding:6px 8px;font-size:13px;border-inline-start:3px solid var(--sg-accent, #2563eb);border-radius:0 var(--sg-radius, 6px) var(--sg-radius, 6px) 0;background:color-mix(in srgb,var(--sg-accent, #2563eb) 6%,var(--sg-bg, #fff))}.sv-frv-proposal-by{color:var(--sg-muted, #64748b);font-size:12px}.sv-frv-filtered{display:flex;align-items:center;gap:6px;margin:0 0 12px;font-size:12px;color:var(--sg-muted, #64748b)}.sv-frv-filtered svg{flex:none}.sv-frv-proposal-value{font-weight:600;overflow-wrap:anywhere}.sv-frv-proposal-acts{display:inline-flex;gap:6px;margin-inline-start:auto}.sv-frv-proposal-acts .sv-frv-btn{height:26px;padding:0 10px}.sv-frv-btn.is-accept{background:var(--sg-accent, #2563eb);border-color:var(--sg-accent, #2563eb);color:var(--sg-on-accent, #fff)}.sv-frv-proposal-why{flex-basis:100%;color:var(--sg-muted, #64748b);font-size:12px}.sv-frv-layout{display:grid;grid-template-columns:minmax(0,1fr) 280px;gap:20px;align-items:start}.sv-frv-fields{display:flex;flex-direction:column;gap:14px;min-width:0}.sv-frv-field{display:flex;flex-direction:column;gap:6px}.sv-frv-label{display:flex;align-items:center;gap:6px;font-size:12px;font-weight:600;color:var(--sg-muted, #64748b)}.sv-frv-mic{display:inline-flex;align-items:center;justify-content:center;width:32px;height:32px;margin:-8px -6px -8px auto;padding:0;border:0;border-radius:50%;background:transparent;color:var(--sg-accent, #2563eb);cursor:pointer}.sv-frv-mic:hover:not(:disabled){background:color-mix(in srgb,var(--sg-accent, #2563eb) 12%,transparent)}.sv-frv-mic:disabled:not(.is-on){opacity:.4;cursor:default}.sv-frv-mic.is-on,.sv-frv-mic-comment.is-on{color:var(--sg-danger, #dc2626);animation:sv-frv-listen 1s ease-in-out infinite}.sv-frv-mic-comment{display:inline-flex;align-items:center;gap:4px}@keyframes sv-frv-listen{50%{opacity:.45}}@media(prefers-reduced-motion:reduce){.sv-frv-mic.is-on,.sv-frv-mic-comment.is-on{animation:none}}.sv-frv-ro{font-weight:400;font-size:11px;opacity:.8}.sv-frv-hidden-toggle{align-self:flex-start;border:0;padding:2px 0;background:none;font:inherit;font-size:13px;color:var(--sg-fg, #0f172a);text-decoration:underline;cursor:pointer}.sv-frv-activity{position:sticky;top:0;display:flex;flex-direction:column;gap:8px;max-height:70vh;padding-inline-start:16px;border-inline-start:1px solid var(--sg-border, #e2e8f0)}.sv-frv-activity-title{margin:0;font-size:13px;font-weight:600}.sv-frv-feed{list-style:none;margin:0;padding:0;display:flex;flex-direction:column;gap:10px;overflow:auto;min-height:60px}.sv-frv-item{font-size:12px}.sv-frv-item-head{color:var(--sg-muted, #64748b)}.sv-frv-item-head strong{color:var(--sg-fg, #0f172a);font-weight:600}.sv-frv-from{color:var(--sg-muted, #64748b);text-decoration:line-through}.sv-frv-arrow{margin:0 5px;color:var(--sg-muted, #64748b)}.sv-frv-when{margin-inline-start:6px;color:var(--sg-fg, #0f172a)}.sv-frv-note-acts{display:flex;align-items:center;justify-content:flex-end;gap:10px;margin-top:4px;font-size:12px;color:var(--sg-muted, #64748b)}.sv-frv-link{padding:0;border:0;background:none;font:inherit;font-size:12px;color:var(--sg-muted, #64748b);cursor:pointer}.sv-frv-link:hover{color:var(--sg-fg, #0f172a);text-decoration:underline}.sv-frv-restore{margin-top:2px}.sv-frv-votes{display:inline-flex;gap:4px;margin-right:auto}.sv-frv-vote{display:inline-flex;align-items:center;gap:4px;min-height:24px;padding:2px 8px;border:1px solid var(--sg-border, #e2e8f0);border-radius:999px;background:var(--sg-bg, #fff);font:inherit;font-size:12px;color:var(--sg-muted, #64748b);cursor:pointer}.sv-frv-vote:hover:not(:disabled){color:var(--sg-fg, #0f172a);border-color:color-mix(in srgb,var(--sg-fg, #0f172a) 30%,transparent)}.sv-frv-vote:focus-visible{outline:2px solid var(--sg-accent, #2563eb);outline-offset:2px}.sv-frv-vote:disabled{cursor:default}.sv-frv-vote.is-mine{color:var(--sg-accent, #2563eb);border-color:var(--sg-accent, #2563eb);background:color-mix(in srgb,var(--sg-accent, #2563eb) 10%,transparent)}.sv-frv-vote.is-down.is-mine{color:#b42318;border-color:#b42318;background:color-mix(in srgb,#b42318 10%,transparent)}.sv-frv-link:focus-visible{outline:2px solid var(--sg-accent, #2563eb);outline-offset:2px}.sv-frv-item-body{margin-top:2px;white-space:pre-wrap;word-break:break-word}.sv-frv-item.is-comment .sv-frv-item-body{padding:6px 8px;border-radius:8px;background:color-mix(in srgb,var(--sg-fg, #0f172a) 5%,transparent)}.sv-frv-none{color:var(--sg-muted, #64748b);font-size:12px}.sv-frv-comment{display:grid;gap:6px}.sv-frv-held{margin:0;font-size:12px;color:var(--sg-fg, #0f172a)}.sv-frv-mention{display:inline-flex;align-items:center;gap:3px;padding:0 5px 0 2px;border-radius:999px;vertical-align:baseline;font-weight:600;color:var(--sg-accent, #2563eb);background:color-mix(in srgb,var(--sg-accent, #2563eb) 12%,transparent)}.sv-frv-comment .sv-frv-btn{justify-self:end}.sv-frv-send{display:flex;align-items:center;justify-content:flex-end;gap:12px;flex-wrap:wrap}.sv-frv-attach{display:inline-flex;align-items:center;gap:4px;margin-inline-end:auto}.sv-frv-internal{display:inline-flex;align-items:center;gap:4px;font-size:12px;color:var(--sg-muted, #64748b);cursor:pointer}.sv-frv-files{list-style:none;margin:6px 0 0;padding:0;display:flex;flex-direction:column;gap:3px}.sv-frv-replies-open{display:inline-flex;align-items:center;gap:4px}.sv-frv-replies{display:flex;flex-direction:column;gap:6px;padding:8px;border:1px solid var(--sg-border, #e2e8f0);border-radius:8px;background:var(--sg-bg, #fff)}.sv-frv-replies-search,.sv-frv-replies-save input{font:inherit;font-size:13px;padding:5px 8px;border:1px solid var(--sg-border, #e2e8f0);border-radius:6px;background:var(--sg-bg, #fff);color:var(--sg-fg, #0f172a);min-width:0}.sv-frv-replies-list{list-style:none;margin:0;padding:0;max-height:220px;overflow:auto;display:flex;flex-direction:column;gap:2px}.sv-frv-reply{display:flex;flex-direction:column;gap:2px;width:100%;text-align:start;padding:6px 8px;border:0;border-radius:6px;background:none;font:inherit;font-size:13px;color:inherit;cursor:pointer}.sv-frv-reply:hover,.sv-frv-reply:focus-visible{background:var(--sg-hover, #f1f5f9)}.sv-frv-reply span{color:var(--sg-muted, #64748b);font-size:12px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.sv-frv-replies-save{display:flex;gap:6px}.sv-frv-replies-save input{flex:1}.sv-frv-files li{display:flex;align-items:baseline;gap:6px;min-width:0;overflow-wrap:anywhere}.sv-frv-files a{color:var(--sg-accent, #2563eb)}.sv-frv-files.is-draft{margin:0;font-size:12px}.sv-frv-internal-tag{margin-inline-start:6px;padding:0 6px;border-radius:999px;font-size:11px;font-weight:600;color:#92400e;background:#fef3c7}.sv-frv-item.is-comment.is-internal .sv-frv-item-body{background:color-mix(in srgb,#f59e0b 12%,transparent)}.sv-frv-gone{color:var(--sg-muted, #64748b)}.sv-frv-footer{display:flex;align-items:center;gap:6px;width:100%}.sv-frv-pos{flex:1;font-size:13px;color:var(--sg-muted, #64748b)}.sv-frv-btn{display:inline-flex;align-items:center;justify-content:center;height:32px;min-width:32px;padding:0 12px;font:inherit;font-size:13px;cursor:pointer;border:1px solid var(--sg-border, #e2e8f0);border-radius:var(--sg-radius, 6px);background:var(--sg-bg, #fff);color:var(--sg-fg, #0f172a)}.sv-frv-btn:disabled{opacity:.4;cursor:default}.sv-frv-btn.is-primary{background:var(--sg-fg, #0f172a);color:var(--sg-bg, #fff);border-color:var(--sg-fg, #0f172a)}.sv-frv-btn.is-danger{color:var(--sg-danger, #b91c1c)}@media(max-width:760px){.sv-frv-layout{grid-template-columns:minmax(0,1fr)}.sv-frv-activity{position:static;padding-inline-start:0;border-inline-start:0;border-top:1px solid var(--sg-border, #e2e8f0);padding-top:12px}}@media(max-width:600px){:global(.sv-modal:has(.sv-frv-layout)){width:100vw!important;max-width:100vw;height:100dvh;max-height:100dvh;border-radius:0}}.sv-frv-apps{display:flex;flex-wrap:wrap;gap:14px;justify-content:flex-end;margin:0 0 8px}.sv-frv-app{display:inline-flex;align-items:center;gap:5px}
|
|
401
|
+
.sv-frv-dock{display:inline-flex;gap:2px;padding:2px;border:1px solid var(--sg-border, #e2e8f0);border-radius:8px;background:var(--sg-header-bg, #f8fafc)}.sv-frv-dock-btn{display:grid;place-items:center;width:28px;height:24px;padding:0;border:0;border-radius:6px;background:none;color:var(--sg-muted, #64748b);cursor:pointer}.sv-frv-dock-btn:hover{color:var(--sg-fg, #0f172a)}.sv-frv-dock-btn.is-on{background:var(--sg-bg, #fff);color:var(--sg-accent, #2563eb);box-shadow:0 1px 2px #0f172a26}.sv-frv-dock-btn:focus-visible{outline:2px solid var(--sg-accent, #2563eb);outline-offset:1px}.sv-frv-side{position:fixed;right:0;bottom:0;z-index:9000;display:flex;flex-direction:column;box-sizing:border-box;max-width:100vw;background:var(--sg-bg, #fff);color:var(--sg-fg, #0f172a);border-inline-start:1px solid var(--sg-border, #e2e8f0);box-shadow:-12px 0 32px -16px #0f172a59;font-size:13.5px;line-height:1.6}.sv-frv-side:focus{outline:none}.sv-frv-edge{position:absolute;inset-block:0;inset-inline-start:-4px;width:8px;cursor:ew-resize;touch-action:none;z-index:1}.sv-frv-edge:hover,.sv-frv-edge:focus-visible{background:color-mix(in srgb,var(--sg-accent, #2563eb) 25%,transparent);outline:none}.sv-frv-side-head{display:flex;align-items:center;gap:10px;padding:11px 14px;border-bottom:1px solid var(--sg-border, #e2e8f0)}.sv-frv-side-title{flex:1;min-width:0;margin:0;font-size:15px;font-weight:650;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.sv-frv-side-x{flex:none;width:28px;height:28px;display:grid;place-items:center;background:none;border:0;color:var(--sg-muted, #64748b);cursor:pointer;border-radius:6px;font-size:20px;line-height:1}.sv-frv-side-x:hover{background:var(--sg-row-hover-bg, #f1f5f9);color:var(--sg-fg, #0f172a)}.sv-frv-side-body{flex:1;min-height:0;overflow:auto;padding:14px}.sv-frv-side-foot{padding:10px 14px;border-top:1px solid var(--sg-border, #e2e8f0)}.sv-frv-side .sv-frv-layout{grid-template-columns:minmax(0,1fr)}.sv-frv-proposals{display:flex;align-items:center;justify-content:space-between;gap:12px;margin:0 0 12px;padding:8px 12px;border-radius:var(--sg-radius, 6px);font-size:13px;background:color-mix(in srgb,var(--sg-accent, #2563eb) 8%,var(--sg-bg, #fff));border:1px solid color-mix(in srgb,var(--sg-accent, #2563eb) 30%,var(--sg-border, #e2e8f0))}.sv-frv-proposal{display:flex;flex-wrap:wrap;align-items:center;gap:4px 10px;margin-top:6px;padding:6px 8px;font-size:13px;border-inline-start:3px solid var(--sg-accent, #2563eb);border-radius:0 var(--sg-radius, 6px) var(--sg-radius, 6px) 0;background:color-mix(in srgb,var(--sg-accent, #2563eb) 6%,var(--sg-bg, #fff))}.sv-frv-proposal-by{color:var(--sg-muted, #64748b);font-size:12px}.sv-frv-filtered{display:flex;align-items:center;gap:6px;margin:0 0 12px;font-size:12px;color:var(--sg-muted, #64748b)}.sv-frv-filtered svg{flex:none}.sv-frv-proposal-value{font-weight:600;overflow-wrap:anywhere}.sv-frv-proposal-acts{display:inline-flex;gap:6px;margin-inline-start:auto}.sv-frv-proposal-acts .sv-frv-btn{height:26px;padding:0 10px}.sv-frv-btn.is-accept{background:var(--sg-accent, #2563eb);border-color:var(--sg-accent, #2563eb);color:var(--sg-on-accent, #fff)}.sv-frv-proposal-why{flex-basis:100%;color:var(--sg-muted, #64748b);font-size:12px}.sv-frv-layout{display:grid;grid-template-columns:minmax(0,1fr) 280px;gap:20px;align-items:start}.sv-frv-fields{display:flex;flex-direction:column;gap:14px;min-width:0}.sv-frv-field{display:flex;flex-direction:column;gap:6px}.sv-frv-label{display:flex;align-items:center;gap:6px;font-size:12px;font-weight:600;color:var(--sg-muted, #64748b)}.sv-frv-mic{display:inline-flex;align-items:center;justify-content:center;width:32px;height:32px;margin:-8px -6px -8px auto;padding:0;border:0;border-radius:50%;background:transparent;color:var(--sg-accent, #2563eb);cursor:pointer}.sv-frv-mic:hover:not(:disabled){background:color-mix(in srgb,var(--sg-accent, #2563eb) 12%,transparent)}.sv-frv-mic:disabled:not(.is-on){opacity:.4;cursor:default}.sv-frv-mic.is-on,.sv-frv-mic-comment.is-on{color:var(--sg-danger, #dc2626);animation:sv-frv-listen 1s ease-in-out infinite}.sv-frv-mic-comment{display:inline-flex;align-items:center;gap:4px}@keyframes sv-frv-listen{50%{opacity:.45}}@media(prefers-reduced-motion:reduce){.sv-frv-mic.is-on,.sv-frv-mic-comment.is-on{animation:none}}.sv-frv-ro{font-weight:400;font-size:11px;opacity:.8}.sv-frv-hidden-toggle{align-self:flex-start;border:0;padding:2px 0;background:none;font:inherit;font-size:13px;color:var(--sg-fg, #0f172a);text-decoration:underline;cursor:pointer}.sv-frv-activity{position:sticky;top:0;display:flex;flex-direction:column;gap:8px;max-height:70vh;padding-inline-start:16px;border-inline-start:1px solid var(--sg-border, #e2e8f0)}.sv-frv-activity-title{margin:0;font-size:13px;font-weight:600}.sv-frv-feed{list-style:none;margin:0;padding:0;display:flex;flex-direction:column;gap:10px;overflow:auto;min-height:60px}.sv-frv-item{font-size:12px}.sv-frv-item-head{color:var(--sg-muted, #64748b)}.sv-frv-item-head strong{color:var(--sg-fg, #0f172a);font-weight:600}.sv-frv-from{color:var(--sg-muted, #64748b);text-decoration:line-through}.sv-frv-arrow{margin:0 5px;color:var(--sg-muted, #64748b)}.sv-frv-when{margin-inline-start:6px;color:var(--sg-fg, #0f172a)}.sv-frv-note-acts{display:flex;align-items:center;justify-content:flex-end;gap:10px;margin-top:4px;font-size:12px;color:var(--sg-muted, #64748b)}.sv-frv-link{padding:0;border:0;background:none;font:inherit;font-size:12px;color:var(--sg-muted, #64748b);cursor:pointer}.sv-frv-link:hover{color:var(--sg-fg, #0f172a);text-decoration:underline}.sv-frv-restore{margin-top:2px}.sv-frv-votes{display:inline-flex;gap:4px;margin-right:auto}.sv-frv-vote{display:inline-flex;align-items:center;gap:4px;min-height:24px;padding:2px 8px;border:1px solid var(--sg-border, #e2e8f0);border-radius:999px;background:var(--sg-bg, #fff);font:inherit;font-size:12px;color:var(--sg-muted, #64748b);cursor:pointer}.sv-frv-vote:hover:not(:disabled){color:var(--sg-fg, #0f172a);border-color:color-mix(in srgb,var(--sg-fg, #0f172a) 30%,transparent)}.sv-frv-vote:focus-visible{outline:2px solid var(--sg-accent, #2563eb);outline-offset:2px}.sv-frv-vote:disabled{cursor:default}.sv-frv-vote.is-mine{color:var(--sg-accent, #2563eb);border-color:var(--sg-accent, #2563eb);background:color-mix(in srgb,var(--sg-accent, #2563eb) 10%,transparent)}.sv-frv-vote.is-down.is-mine{color:#b42318;border-color:#b42318;background:color-mix(in srgb,#b42318 10%,transparent)}.sv-frv-link:focus-visible{outline:2px solid var(--sg-accent, #2563eb);outline-offset:2px}.sv-frv-item-body{margin-top:2px;white-space:pre-wrap;word-break:break-word}.sv-frv-item.is-comment .sv-frv-item-body{padding:6px 8px;border-radius:8px;background:color-mix(in srgb,var(--sg-fg, #0f172a) 5%,transparent)}.sv-frv-none{color:var(--sg-muted, #64748b);font-size:12px}.sv-frv-comment{display:grid;gap:6px}.sv-frv-held{margin:0;font-size:12px;color:var(--sg-fg, #0f172a)}.sv-frv-mention{display:inline-flex;align-items:center;gap:3px;padding:0 5px 0 2px;border-radius:999px;vertical-align:baseline;font-weight:600;color:var(--sg-accent, #2563eb);background:color-mix(in srgb,var(--sg-accent, #2563eb) 12%,transparent)}.sv-frv-comment .sv-frv-btn{justify-self:end}.sv-frv-send{display:flex;align-items:center;justify-content:flex-end;gap:12px;flex-wrap:wrap}.sv-frv-attach{display:inline-flex;align-items:center;gap:4px;margin-inline-end:auto}.sv-frv-internal{display:inline-flex;align-items:center;gap:4px;font-size:12px;color:var(--sg-muted, #64748b);cursor:pointer}.sv-frv-files{list-style:none;margin:6px 0 0;padding:0;display:flex;flex-direction:column;gap:3px}.sv-frv-replies-open{display:inline-flex;align-items:center;gap:4px}.sv-frv-replies{display:flex;flex-direction:column;gap:6px;padding:8px;border:1px solid var(--sg-border, #e2e8f0);border-radius:8px;background:var(--sg-bg, #fff)}.sv-frv-replies-search,.sv-frv-replies-save input{font:inherit;font-size:13px;padding:5px 8px;border:1px solid var(--sg-border, #e2e8f0);border-radius:6px;background:var(--sg-bg, #fff);color:var(--sg-fg, #0f172a);min-width:0}.sv-frv-replies-list{list-style:none;margin:0;padding:0;max-height:220px;overflow:auto;display:flex;flex-direction:column;gap:2px}.sv-frv-reply{display:flex;flex-direction:column;gap:2px;width:100%;text-align:start;padding:6px 8px;border:0;border-radius:6px;background:none;font:inherit;font-size:13px;color:inherit;cursor:pointer}.sv-frv-reply:hover,.sv-frv-reply:focus-visible{background:var(--sg-hover, #f1f5f9)}.sv-frv-reply span{color:var(--sg-muted, #64748b);font-size:12px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.sv-frv-replies-save{display:flex;gap:6px}.sv-frv-replies-save input{flex:1}.sv-frv-files li{display:flex;align-items:baseline;gap:6px;min-width:0;overflow-wrap:anywhere}.sv-frv-files a{color:var(--sg-accent, #2563eb)}.sv-frv-files.is-draft{margin:0;font-size:12px}.sv-frv-internal-tag{margin-inline-start:6px;padding:0 6px;border-radius:999px;font-size:11px;font-weight:600;color:#92400e;background:#fef3c7}.sv-frv-item.is-comment.is-internal .sv-frv-item-body{background:color-mix(in srgb,#f59e0b 12%,transparent)}.sv-frv-gone{color:var(--sg-muted, #64748b)}.sv-frv-thread{list-style:none;margin:6px 0 0;padding:0 0 0 12px;border-inline-start:2px solid var(--sg-border, #e2e8f0);display:flex;flex-direction:column;gap:8px}.sv-frv-thread-acts{display:flex;flex-wrap:wrap;align-items:center;gap:4px 12px;margin-top:4px;font-size:12px}.sv-frv-thread-acts .sv-frv-link{white-space:nowrap}.sv-frv-thread-acts .sv-frv-when{margin-inline-start:0;color:var(--sg-muted, #64748b)}.sv-frv-thread-acts .sv-frv-link.is-on{color:var(--sg-accent, #2563eb);font-weight:600}.sv-frv-resolved{display:flex;align-items:flex-start;gap:6px;padding:6px 8px;border-radius:8px;color:var(--sg-muted, #64748b);background:color-mix(in srgb,#16a34a 8%,transparent);overflow:hidden}.sv-frv-resolved svg{flex:none;margin-top:2px;color:#16a34a}.sv-frv-resolved span{min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.sv-frv-resolved strong{color:var(--sg-fg, #0f172a);font-weight:600}.sv-frv-answering{display:flex;align-items:center;justify-content:space-between;gap:8px;padding:4px 8px;border-radius:6px;font-size:12px;color:var(--sg-accent, #2563eb);background:color-mix(in srgb,var(--sg-accent, #2563eb) 8%,transparent)}.sv-frv-answering .sv-frv-link{font-size:15px;line-height:1}.sv-frv-footer{display:flex;align-items:center;gap:6px;width:100%}.sv-frv-pos{flex:1;font-size:13px;color:var(--sg-muted, #64748b)}.sv-frv-btn{display:inline-flex;align-items:center;justify-content:center;height:32px;min-width:32px;padding:0 12px;font:inherit;font-size:13px;cursor:pointer;border:1px solid var(--sg-border, #e2e8f0);border-radius:var(--sg-radius, 6px);background:var(--sg-bg, #fff);color:var(--sg-fg, #0f172a)}.sv-frv-btn:disabled{opacity:.4;cursor:default}.sv-frv-btn.is-primary{background:var(--sg-fg, #0f172a);color:var(--sg-bg, #fff);border-color:var(--sg-fg, #0f172a)}.sv-frv-btn.is-danger{color:var(--sg-danger, #b91c1c)}@media(max-width:760px){.sv-frv-layout{grid-template-columns:minmax(0,1fr)}.sv-frv-activity{position:static;padding-inline-start:0;border-inline-start:0;border-top:1px solid var(--sg-border, #e2e8f0);padding-top:12px}}@media(max-width:600px){:global(.sv-modal:has(.sv-frv-layout)){width:100vw!important;max-width:100vw;height:100dvh;max-height:100dvh;border-radius:0}}.sv-frv-apps{display:flex;flex-wrap:wrap;gap:14px;justify-content:flex-end;margin:0 0 8px}.sv-frv-app{display:inline-flex;align-items:center;gap:5px}
|
|
358
402
|
</style>
|