@desktalk/miniapp-note 0.1.0-alpha.2 → 0.1.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/frontend.js +74 -22
- package/dist/frontend.js.map +3 -3
- package/package.json +3 -3
package/dist/frontend.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var h=window.React,
|
|
1
|
+
var h=window.React,We=h.Children,Be=h.Component,je=h.Fragment,Ue=h.Profiler,Ye=h.PureComponent,Xe=h.StrictMode,Ge=h.Suspense,Ke=h.cloneElement,Je=h.createContext,Qe=h.createElement,Ze=h.createRef,ft=h.forwardRef,tr=h.isValidElement,er=h.lazy,rr=h.memo,ir=h.startTransition,x=h.useCallback,nr=h.useContext,sr=h.useDebugValue,or=h.useDeferredValue,W=h.useEffect,ar=h.useId,_t=h.useImperativeHandle,dr=h.useInsertionEffect,lr=h.useLayoutEffect,cr=h.useMemo,hr=h.useReducer,H=h.useRef,I=h.useState,ur=h.useSyncExternalStore,pr=h.useTransition,mr=h.version,ot=window.ReactDOM,xt=ot.createRoot,gr=ot.hydrateRoot;import{useCommand as B,MiniAppIdProvider as wt,WindowIdProvider as yt}from"@desktalk/sdk";var v={root:"NoteApp_root",rootCompact:"NoteApp_rootCompact",listPanel:"NoteApp_listPanel",listHeader:"NoteApp_listHeader",searchInput:"NoteApp_searchInput",newNoteBtn:"NoteApp_newNoteBtn",noteList:"NoteApp_noteList",noteItem:"NoteApp_noteItem",noteItemActive:"NoteApp_noteItem NoteApp_noteItemActive",emptyState:"NoteApp_emptyState",noteTitle:"NoteApp_noteTitle",notePreview:"NoteApp_notePreview",noteDate:"NoteApp_noteDate",editorPanel:"NoteApp_editorPanel",editorHeader:"NoteApp_editorHeader",editorTitle:"NoteApp_editorTitle",editorTags:"NoteApp_editorTags",editorTag:"NoteApp_editorTag",editorBody:"NoteApp_editorBody",editorPlaceholder:"NoteApp_editorPlaceholder",saveStatus:"NoteApp_saveStatus",saveStatusSaving:"NoteApp_saveStatus NoteApp_saveStatusSaving"},G=window.__desktalk_jsx_runtime,u=G.jsx,T=G.jsxs,vr=G.jsxDEV,fr=G.Fragment;function kt(t){try{const e=new Date(t),i=new Date().getTime()-e.getTime(),n=Math.floor(i/6e4);if(n<1)return"just now";if(n<60)return`${n}m ago`;const s=Math.floor(n/60);if(s<24)return`${s}h ago`;const o=Math.floor(s/24);return o<7?`${o}d ago`:e.toLocaleDateString(void 0,{month:"short",day:"numeric"})}catch{return""}}function Ct({notes:t,selectedId:e,onSelect:r,onCreate:i,searchQuery:n,onSearchChange:s}){const o=H(null);return T("div",{className:v.listPanel,children:[T("div",{className:v.listHeader,children:[u("input",{ref:o,type:"text",className:v.searchInput,placeholder:"Search notes...",value:n,onChange:a=>s(a.target.value)}),u("button",{className:v.newNoteBtn,onClick:i,title:"New note",children:"+"})]}),u("div",{className:v.noteList,children:t.length===0?u("div",{className:v.emptyState,children:n?"No notes match your search":"No notes yet"}):t.map(a=>T("div",{className:a.id===e?v.noteItemActive:v.noteItem,onClick:()=>r(a.id),children:[u("div",{className:v.noteTitle,children:a.title}),u("div",{className:v.notePreview,children:a.preview}),u("div",{className:v.noteDate,children:kt(a.updatedAt)})]},a.id))})]})}var Et=`.dt-tooltip-popup {
|
|
2
2
|
position: fixed;
|
|
3
3
|
z-index: 2147483647;
|
|
4
4
|
padding: 6px 10px;
|
|
@@ -107,7 +107,7 @@ var h=window.React,qe=h.Children,Be=h.Component,je=h.Fragment,Ue=h.Profiler,Ye=h
|
|
|
107
107
|
border-top: none;
|
|
108
108
|
border-bottom: none;
|
|
109
109
|
}
|
|
110
|
-
`,At="dt-tooltip-popup",L=8,
|
|
110
|
+
`,At="dt-tooltip-popup",L=8,at=!1;function St(){if(at)return;let t=document.createElement("style");t.setAttribute("data-dt-tooltip",""),t.textContent=Et,document.head.appendChild(t),at=!0}var zt=class extends HTMLElement{_popup=null;_showTimeout=null;_tooltipId="";_visible=!1;static get observedAttributes(){return["content","placement","delay","disabled"]}get content(){return this.getAttribute("content")??""}set content(t){this.setAttribute("content",t)}get placement(){let t=this.getAttribute("placement");return t==="bottom"||t==="left"||t==="right"?t:"top"}set placement(t){this.setAttribute("placement",t)}get delay(){let t=Number(this.getAttribute("delay"));return Number.isFinite(t)&&t>0?t:0}set delay(t){this.setAttribute("delay",String(t))}get disabled(){return this.hasAttribute("disabled")}set disabled(t){t?this.setAttribute("disabled",""):this.removeAttribute("disabled")}constructor(){super();let t=this.attachShadow({mode:"open"});t.innerHTML="<slot></slot>",this._tooltipId=`dt-tip-${Math.random().toString(36).slice(2,9)}`}connectedCallback(){St(),this.addEventListener("mouseenter",this._onEnter),this.addEventListener("mouseleave",this._onLeave),this.addEventListener("focusin",this._onEnter),this.addEventListener("focusout",this._onLeave)}disconnectedCallback(){this.removeEventListener("mouseenter",this._onEnter),this.removeEventListener("mouseleave",this._onLeave),this.removeEventListener("focusin",this._onEnter),this.removeEventListener("focusout",this._onLeave),this._hide()}attributeChangedCallback(t,e,r){t==="disabled"&&this.disabled&&this._hide(),t==="content"&&this._popup&&(this._popup.textContent=this.content)}_onEnter=()=>{if(this.disabled||!this.content)return;this._showTimeout!==null&&clearTimeout(this._showTimeout);let t=()=>{this._createPopup(),this._position(),this._visible=!0};this.delay>0?this._showTimeout=setTimeout(t,this.delay):t()};_onLeave=()=>{this._hide()};_createPopup(){if(this._popup)return;let t=document.createElement("div");t.className=At,t.id=this._tooltipId,t.setAttribute("role","tooltip"),t.textContent=this.content,document.body.appendChild(t),this._popup=t;let e=this._getTrigger();e&&e.setAttribute("aria-describedby",this._tooltipId)}_hide(){if(this._showTimeout!==null&&(clearTimeout(this._showTimeout),this._showTimeout=null),this._popup){let t=this._getTrigger();t&&t.removeAttribute("aria-describedby"),this._popup.remove(),this._popup=null,this._visible=!1}}_getTrigger(){let t=this.shadowRoot?.querySelector("slot")?.assignedElements();return t&&t.length>0?t[0]:null}_position(){let t=this._popup;if(!t)return;let e=this.getBoundingClientRect(),r=t.getBoundingClientRect(),i=window.innerWidth,n=window.innerHeight,s=this.placement;s==="top"&&e.top-r.height-L<0?s="bottom":s==="bottom"&&e.bottom+r.height+L>n?s="top":s==="left"&&e.left-r.width-L<0?s="right":s==="right"&&e.right+r.width+L>i&&(s="left"),t.setAttribute("data-actual-placement",s);let o,a;switch(s){case"top":a=e.left+e.width/2,o=e.top-r.height-L;break;case"bottom":a=e.left+e.width/2,o=e.bottom+L;break;case"left":a=e.left-r.width-L,o=e.top+e.height/2;break;case"right":a=e.right+L,o=e.top+e.height/2;break}t.style.left=`${a}px`,t.style.top=`${o}px`}},Mt=`:host {
|
|
111
111
|
display: block;
|
|
112
112
|
margin-bottom: 12px;
|
|
113
113
|
}
|
|
@@ -356,7 +356,7 @@ var h=window.React,qe=h.Children,Be=h.Component,je=h.Fragment,Ue=h.Profiler,Ye=h
|
|
|
356
356
|
.dt-select-trigger[aria-expanded='true'] .dt-select-chevron {
|
|
357
357
|
transform: rotate(180deg);
|
|
358
358
|
}
|
|
359
|
-
`,It="dt-select-trigger",dt="dt-select-label",Rt="dt-select-chevron",Ft="dt-select-menu",$t="dt-select-option",
|
|
359
|
+
`,It="dt-select-trigger",dt="dt-select-label",Rt="dt-select-chevron",Ft="dt-select-menu",$t="dt-select-option",Pt="dt-select-option--active",lt=!1;function Dt(){if(lt)return;let t=document.createElement("style");t.setAttribute("data-dt-select",""),t.textContent=Lt,document.head.appendChild(t),lt=!0}var Vt=class extends HTMLElement{_menu=null;_trigger=null;_options=[];_open=!1;_menuId="";static get observedAttributes(){return["value","placeholder","disabled","align"]}get value(){return this.getAttribute("value")??""}set value(t){this.setAttribute("value",t)}get placeholder(){return this.getAttribute("placeholder")??"Select\u2026"}set placeholder(t){this.setAttribute("placeholder",t)}get disabled(){return this.hasAttribute("disabled")}set disabled(t){t?this.setAttribute("disabled",""):this.removeAttribute("disabled")}get align(){return this.getAttribute("align")==="right"?"right":"left"}set align(t){this.setAttribute("align",t)}get options(){return this._options}set options(t){this._options=t,this._updateLabel(),this._open&&this._renderMenuItems()}constructor(){super();let t=this.attachShadow({mode:"open"}),e=document.createElement("style");e.textContent=Ht,t.appendChild(e);let r=document.createElement("button");r.type="button",r.className=It,r.setAttribute("aria-haspopup","listbox"),r.setAttribute("aria-expanded","false");let i=document.createElement("span");i.className=dt,r.appendChild(i);let n=document.createElement("span");n.className=Rt,n.setAttribute("aria-hidden","true"),n.textContent="\u25BE",r.appendChild(n),t.appendChild(r),this._trigger=r,this._menuId=`dt-sel-${Math.random().toString(36).slice(2,9)}`}connectedCallback(){Dt(),this._trigger.addEventListener("click",this._onTriggerClick),this._updateLabel()}disconnectedCallback(){this._trigger.removeEventListener("click",this._onTriggerClick),this._close()}attributeChangedCallback(t){t==="value"&&(this._updateLabel(),this._open&&this._renderMenuItems()),t==="placeholder"&&!this.value&&this._updateLabel(),t==="disabled"&&this.disabled&&this._close()}_updateLabel(){let t=this._trigger.querySelector(`.${dt}`),e=this._options.find(r=>r.value===this.value);t.textContent=e?.label??this.placeholder}_onTriggerClick=()=>{this.disabled||(this._open?this._close():this._openMenu())};_openMenu(){if(this._open)return;let t=document.createElement("div");t.className=Ft,t.id=this._menuId,t.setAttribute("role","listbox"),document.body.appendChild(t),this._menu=t,this._renderMenuItems(),this._position(),requestAnimationFrame(()=>{t.setAttribute("data-open","")}),this._open=!0,this._trigger.setAttribute("aria-expanded","true"),requestAnimationFrame(()=>{document.addEventListener("mousedown",this._onOutsideClick),document.addEventListener("keydown",this._onKeyDown)})}_close(){if(this._open){if(document.removeEventListener("mousedown",this._onOutsideClick),document.removeEventListener("keydown",this._onKeyDown),this._menu){this._menu.removeAttribute("data-open");let t=this._menu;setTimeout(()=>t.remove(),140),this._menu=null}this._open=!1,this._trigger.setAttribute("aria-expanded","false")}}_onOutsideClick=t=>{let e=t.target;this._menu?.contains(e)||this.contains(e)||this._close()};_onKeyDown=t=>{t.key==="Escape"&&(this._close(),this._trigger.focus())};_renderMenuItems(){let t=this._menu;if(t){t.innerHTML="";for(let e of this._options){let r=document.createElement("button");r.type="button",r.className=$t,r.setAttribute("role","option"),r.setAttribute("aria-selected",String(e.value===this.value)),e.value===this.value&&r.classList.add(Pt);let i=document.createElement("span");i.textContent=e.label,r.appendChild(i),r.addEventListener("click",()=>{this._selectValue(e.value)}),t.appendChild(r)}}}_selectValue(t){let e=this.value;this.value=t,this._updateLabel(),this._close(),t!==e&&this.dispatchEvent(new CustomEvent("dt-change",{detail:{value:t},bubbles:!0,composed:!0}))}_position(){let t=this._menu;if(!t)return;let e=this.getBoundingClientRect(),r=10,i=Math.max(e.width,240),n=e.bottom+r,s=t.scrollHeight||260,o=window.innerHeight;if(n+s>o&&e.top-s-r>0&&(n=e.top-s-r),t.style.minWidth=`${i}px`,this.align==="right"){let a=window.innerWidth;t.style.right=`${a-e.right}px`,t.style.left="auto"}else t.style.left=`${e.left}px`,t.style.right="auto";t.style.top=`${n}px`}},Ot=`:host {
|
|
360
360
|
display: block;
|
|
361
361
|
margin-bottom: 12px;
|
|
362
362
|
}
|
|
@@ -448,7 +448,7 @@ var h=window.React,qe=h.Children,Be=h.Component,je=h.Fragment,Ue=h.Profiler,Ye=h
|
|
|
448
448
|
::slotted(*) {
|
|
449
449
|
min-width: 0;
|
|
450
450
|
}
|
|
451
|
-
`,
|
|
451
|
+
`,qt="dt-grid-inner",Wt=class extends HTMLElement{static get observedAttributes(){return["cols","gap","min-width"]}get cols(){let t=this.getAttribute("cols");return t==="1"||t==="2"||t==="3"||t==="4"||t==="5"||t==="6"?t:null}set cols(t){t===null?this.removeAttribute("cols"):this.setAttribute("cols",t)}get gap(){let t=this.getAttribute("gap");return t==="0"||t==="4"||t==="8"||t==="12"||t==="20"||t==="24"||t==="32"?t:"16"}set gap(t){this.setAttribute("gap",t)}get minWidth(){let t=this.getAttribute("min-width");return t==="150"||t==="180"||t==="200"||t==="260"||t==="300"?t:"220"}set minWidth(t){this.setAttribute("min-width",t)}constructor(){super();let t=this.attachShadow({mode:"open"}),e=document.createElement("style");e.textContent=Ot,t.appendChild(e);let r=document.createElement("div");r.className=qt,r.innerHTML="<slot></slot>",t.appendChild(r)}},Bt=`:host {
|
|
452
452
|
display: block;
|
|
453
453
|
margin-bottom: 12px;
|
|
454
454
|
}
|
|
@@ -860,7 +860,7 @@ var h=window.React,qe=h.Children,Be=h.Component,je=h.Fragment,Ue=h.Profiler,Ye=h
|
|
|
860
860
|
width: 1em;
|
|
861
861
|
height: 1em;
|
|
862
862
|
}
|
|
863
|
-
`,te="dt-button-inner",ee=class extends HTMLElement{static get observedAttributes(){return["variant","size","disabled","fullwidth","type"]}_button;_slot;get variant(){let t=this.getAttribute("variant");return t==="secondary"||t==="ghost"||t==="danger"?t:"primary"}set variant(t){this.setAttribute("variant",t)}get size(){let t=this.getAttribute("size");return t==="sm"||t==="lg"?t:"md"}set size(t){this.setAttribute("size",t)}get disabled(){return this.hasAttribute("disabled")}set disabled(t){t?this.setAttribute("disabled",""):this.removeAttribute("disabled")}get fullwidth(){return this.hasAttribute("fullwidth")}set fullwidth(t){t?this.setAttribute("fullwidth",""):this.removeAttribute("fullwidth")}get type(){let t=this.getAttribute("type");return t==="submit"||t==="reset"?t:"button"}set type(t){this.setAttribute("type",t)}constructor(){super();let t=this.attachShadow({mode:"open"}),e=document.createElement("style");e.textContent=Zt,t.appendChild(e),this._button=document.createElement("button"),this._button.className=te,this._button.type=this.type,this._button.disabled=this.disabled,this._slot=document.createElement("slot"),this._button.appendChild(this._slot),t.appendChild(this._button)}attributeChangedCallback(t,e,r){switch(t){case"disabled":this._button.disabled=this.disabled;break;case"type":this._button.type=this.type;break}}},re=`:host {
|
|
863
|
+
`,te="dt-button-inner",ee=class extends HTMLElement{static get observedAttributes(){return["variant","size","disabled","fullwidth","type"]}_button;_slot;get variant(){let t=this.getAttribute("variant");return t==="secondary"||t==="ghost"||t==="danger"?t:"primary"}set variant(t){this.setAttribute("variant",t)}get size(){let t=this.getAttribute("size");return t==="sm"||t==="lg"?t:"md"}set size(t){this.setAttribute("size",t)}get disabled(){return this.hasAttribute("disabled")}set disabled(t){t?this.setAttribute("disabled",""):this.removeAttribute("disabled")}get fullwidth(){return this.hasAttribute("fullwidth")}set fullwidth(t){t?this.setAttribute("fullwidth",""):this.removeAttribute("fullwidth")}get type(){let t=this.getAttribute("type");return t==="submit"||t==="reset"?t:"button"}set type(t){this.setAttribute("type",t)}constructor(){super();let t=this.attachShadow({mode:"open"}),e=document.createElement("style");e.textContent=Zt,t.appendChild(e),this._button=document.createElement("button"),this._button.className=te,this._button.type=this.type,this._button.disabled=this.disabled,this._slot=document.createElement("slot"),this._button.appendChild(this._slot),this._button.addEventListener("click",()=>{if(this.type==="submit"&&!this.disabled){let r=this.closest("form");r&&r.requestSubmit()}}),t.appendChild(this._button)}attributeChangedCallback(t,e,r){switch(t){case"disabled":this._button.disabled=this.disabled;break;case"type":this._button.type=this.type;break}}},re=`:host {
|
|
864
864
|
display: block;
|
|
865
865
|
}
|
|
866
866
|
|
|
@@ -1093,7 +1093,7 @@ var h=window.React,qe=h.Children,Be=h.Component,je=h.Fragment,Ue=h.Profiler,Ye=h
|
|
|
1093
1093
|
letter-spacing: 0.08em;
|
|
1094
1094
|
font-size: 0.75rem;
|
|
1095
1095
|
}
|
|
1096
|
-
`;function
|
|
1096
|
+
`;function oe(t){return t==null||t===!1?null:t===!0?"":String(t)}function ae(t,e){let r=t.querySelectorAll("*");for(let i of r){let n=i.getAttribute("data-field");if(n){let s=e[n];i.textContent=s==null?"":String(s)}for(let s of i.getAttributeNames()){if(s==="data-field"||!s.startsWith("data-field-"))continue;let o=s.slice(11);if(!o)continue;let a=i.getAttribute(s);if(!a)continue;let d=oe(e[a]);d===null?i.removeAttribute(o):i.setAttribute(o,d)}}}function ct(t,e){let r=t.content.cloneNode(!0);return ae(r,e),r}var ht=class{_count=0;_estimateSize=56;_overscan=5;_fixedSize=null;_viewportHeight=0;_scrollTop=0;_sizes=new Map;constructor(t={}){this._count=t.count??0,this._estimateSize=t.estimateSize??56,this._overscan=t.overscan??5,this._fixedSize=t.fixedSize??null}setCount(t){this._count=Math.max(0,t);for(let e of this._sizes.keys())e>=this._count&&this._sizes.delete(e)}setViewportHeight(t){this._viewportHeight=Math.max(0,t)}setScrollTop(t){this._scrollTop=Math.max(0,t)}setEstimateSize(t){this._estimateSize=Math.max(1,t)}setFixedSize(t){this._fixedSize=t&&t>0?t:null}resetMeasurements(){this._sizes.clear()}measure(t,e){if(this._fixedSize!==null||t<0||t>=this._count)return 0;let r=Math.max(1,Math.round(e)),i=this._sizes.get(t);return i===r?0:(this._sizes.set(t,r),this.getOffset(t+1)<=this._scrollTop?r-(i??this._estimateSize):0)}getOffset(t){if(t<=0)return 0;let e=Math.min(t,this._count);if(this._fixedSize!==null)return e*this._fixedSize;let r=0;for(let i=0;i<e;i+=1)r+=this._sizes.get(i)??this._estimateSize;return r}getTotalHeight(){return this.getOffset(this._count)}getRange(){if(this._count===0)return{start:0,end:0,paddingTop:0,paddingBottom:0,totalHeight:0};if(this._fixedSize!==null){let a=Math.max(1,Math.ceil(this._viewportHeight/this._fixedSize)),d=Math.max(0,Math.floor(this._scrollTop/this._fixedSize)-this._overscan),l=Math.min(this._count,d+a+this._overscan*2),g=d*this._fixedSize,_=this._count*this._fixedSize,b=Math.max(0,_-g-(l-d)*this._fixedSize);return{start:d,end:l,paddingTop:g,paddingBottom:b,totalHeight:_}}let t=0,e=0;for(;t<this._count;){let a=this._sizes.get(t)??this._estimateSize;if(e+a>this._scrollTop)break;e+=a,t+=1}t=Math.max(0,t-this._overscan);let r=this.getOffset(t),i=t,n=0;for(;i<this._count&&n<this._viewportHeight;)n+=this._sizes.get(i)??this._estimateSize,i+=1;i=Math.min(this._count,i+this._overscan);let s=this.getTotalHeight(),o=Math.max(0,s-this.getOffset(i));return{start:t,end:i,paddingTop:r,paddingBottom:o,totalHeight:s}}};function de(t){return t&&typeof t=="object"?t:{value:t}}function le(t){return t==="center"||t==="right"?t:"left"}var ut=class extends HTMLElement{static get observedAttributes(){return["field","header","width","min-width","align"]}get field(){return this.getAttribute("field")??""}get header(){return this.getAttribute("header")??this.field}get width(){return this.getAttribute("width")??"auto"}get minWidth(){return this.getAttribute("min-width")??"0"}get align(){return le(this.getAttribute("align"))}connectedCallback(){this.hidden=!0}attributeChangedCallback(){this.dispatchEvent(new CustomEvent("dt-column-change",{bubbles:!0,composed:!0}))}},ce=class extends HTMLElement{_rows=[];_columns=[];_virtualizer=new ht({estimateSize:40,overscan:5,fixedSize:40});_root;_scroll;_header;_body;_canvas;_emptyState;_resizeObserver=null;_mutationObserver=null;_sortField=null;_sortDirection="asc";static get observedAttributes(){return["row-height","sortable","striped","bordered","empty-text"]}get rows(){return this._rows}set rows(t){this._rows=Array.isArray(t)?t:[],this._virtualizer.setCount(this._rows.length),this._render()}get rowHeight(){let t=Number(this.getAttribute("row-height")??"40");return Number.isFinite(t)&&t>0?t:40}set rowHeight(t){this.setAttribute("row-height",String(t))}get sortable(){return this.hasAttribute("sortable")}get emptyText(){return this.getAttribute("empty-text")??"No data"}constructor(){super();let t=this.attachShadow({mode:"open"}),e=document.createElement("style");e.textContent=se,t.appendChild(e),this._root=document.createElement("div"),this._root.className="dt-table-view",this._scroll=document.createElement("div"),this._scroll.className="dt-table-scroll",this._scroll.addEventListener("scroll",this._onScroll,{passive:!0}),this._header=document.createElement("div"),this._header.className="dt-table-header",this._body=document.createElement("div"),this._body.className="dt-table-body",this._canvas=document.createElement("div"),this._canvas.className="dt-table-canvas",this._emptyState=document.createElement("div"),this._emptyState.className="dt-table-empty",this._body.append(this._canvas,this._emptyState),this._scroll.append(this._header,this._body),this._root.appendChild(this._scroll),t.appendChild(this._root)}connectedCallback(){this._virtualizer.setFixedSize(this.rowHeight),this._virtualizer.setEstimateSize(this.rowHeight),this._syncColumns(),this._resizeObserver=new ResizeObserver(t=>{for(let e of t)if(e.target===this._scroll){let r=this._header.offsetHeight;this._virtualizer.setViewportHeight(Math.max(0,e.contentRect.height-r)),this._render()}}),this._resizeObserver.observe(this._scroll),this._mutationObserver=new MutationObserver(()=>{this._syncColumns(),this._render()}),this._mutationObserver.observe(this,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["field","header","width","min-width","align"]}),this._virtualizer.setCount(this._rows.length),this._virtualizer.setViewportHeight(Math.max(0,this._scroll.clientHeight-this._header.offsetHeight)),this._render()}disconnectedCallback(){this._scroll.removeEventListener("scroll",this._onScroll),this._resizeObserver?.disconnect(),this._mutationObserver?.disconnect(),this._resizeObserver=null,this._mutationObserver=null}attributeChangedCallback(t){t==="row-height"&&(this._virtualizer.setFixedSize(this.rowHeight),this._virtualizer.setEstimateSize(this.rowHeight)),this._render()}_onScroll=()=>{this._virtualizer.setScrollTop(Math.max(0,this._scroll.scrollTop-this._header.offsetHeight)),this._renderBody()};_syncColumns(){this._columns=Array.from(this.children).filter(t=>t instanceof ut).map(t=>({field:t.field,header:t.header,width:t.width,minWidth:t.minWidth,align:t.align,template:Array.from(t.children).find(e=>e instanceof HTMLTemplateElement)??null})).filter(t=>t.field)}_render(){if(!this.isConnected)return;this._emptyState.textContent=this.emptyText;let t=this._columns.length>0?this._columns.map(e=>this._toGridColumn(e)).join(" "):"minmax(0, 1fr)";this._header.style.setProperty("--dt-table-columns",t),this._canvas.style.setProperty("--dt-table-columns",t),this._renderHeader(),this._renderBody()}_renderHeader(){let t=document.createDocumentFragment();for(let e of this._columns){let r=document.createElement("div");r.className="dt-table-header-cell",r.dataset.align=e.align,this.sortable&&(r.classList.add("dt-table-header-cell--sortable"),r.tabIndex=0,r.setAttribute("role","button"),r.setAttribute("aria-label",`Sort by ${e.header}`),r.addEventListener("click",()=>this._requestSort(e.field)),r.addEventListener("keydown",n=>{(n.key==="Enter"||n.key===" ")&&(n.preventDefault(),this._requestSort(e.field))}));let i=document.createElement("span");if(i.className="dt-table-header-label",i.textContent=e.header,this.sortable){let n=document.createElement("span");n.className="dt-table-sort-indicator",this._sortField===e.field?n.textContent=this._sortDirection==="asc"?"\u25B2":"\u25BC":n.textContent="\u2195",i.appendChild(n)}r.appendChild(i),t.appendChild(r)}this._header.replaceChildren(t)}_renderBody(){if(this._rows.length===0||this._columns.length===0){this._emptyState.hidden=!1,this._canvas.replaceChildren(),this._body.style.height="140px",this._canvas.style.height="0px";return}this._emptyState.hidden=!0,this._virtualizer.setCount(this._rows.length),this._virtualizer.setScrollTop(Math.max(0,this._scroll.scrollTop-this._header.offsetHeight)),this._virtualizer.setViewportHeight(Math.max(0,this._scroll.clientHeight-this._header.offsetHeight));let t=this._virtualizer.getRange();this._body.style.height=`${Math.max(t.totalHeight,this._scroll.clientHeight-this._header.offsetHeight)}px`,this._canvas.style.height=`${t.totalHeight}px`;let e=document.createDocumentFragment();for(let r=t.start;r<t.end;r+=1)e.appendChild(this._renderRow(r));this._canvas.replaceChildren(e)}_renderRow(t){let e=this._rows[t],r=document.createElement("div");r.className="dt-table-row dt-table-row--clickable",r.style.top=`${this._virtualizer.getOffset(t)}px`,r.style.height=`${this.rowHeight}px`,r.style.setProperty("--dt-table-columns",this._header.style.getPropertyValue("--dt-table-columns")),r.addEventListener("click",()=>{this.dispatchEvent(new CustomEvent("dt-row-click",{detail:{row:e,index:t},bubbles:!0,composed:!0}))});let i=de(e);for(let n of this._columns){let s=document.createElement("div");if(s.className="dt-table-cell",s.dataset.align=n.align,n.template)s.appendChild(ct(n.template,i));else{let o=i[n.field];s.textContent=o==null?"":String(o)}r.appendChild(s)}return r}_requestSort(t){this._sortField===t?this._sortDirection=this._sortDirection==="asc"?"desc":"asc":(this._sortField=t,this._sortDirection="asc"),this._renderHeader(),this.dispatchEvent(new CustomEvent("dt-sort",{detail:{field:t,direction:this._sortDirection},bubbles:!0,composed:!0}))}_toGridColumn(t){let e=/^\d+$/.test(t.minWidth)?`${t.minWidth}px`:t.minWidth;if(t.width==="auto")return`minmax(${e}, 1fr)`;let r=/^\d+$/.test(t.width)?`${t.width}px`:t.width;return`minmax(${e}, ${r})`}},he=`:host {
|
|
1097
1097
|
display: block;
|
|
1098
1098
|
min-height: 120px;
|
|
1099
1099
|
color: var(--dt-text);
|
|
@@ -1279,7 +1279,7 @@ var h=window.React,qe=h.Children,Be=h.Component,je=h.Fragment,Ue=h.Profiler,Ye=h
|
|
|
1279
1279
|
.dt-chart__status[hidden] {
|
|
1280
1280
|
display: none;
|
|
1281
1281
|
}
|
|
1282
|
-
`,Z=null;function ge(){return window.__DtChart?Promise.resolve(window.__DtChart):Z||(Z=new Promise((t,e)=>{let r=document.createElement("script");r.src="/api/ui/chart.umd.js",r.async=!0,r.dataset.dtChart="true",r.onload=()=>{if(window.__DtChart){t(window.__DtChart);return}e(new Error("Chart runtime loaded without a __DtChart export."))},r.onerror=()=>e(new Error("Failed to load the Chart.js runtime bundle.")),document.head.appendChild(r)}),Z)}function j(t,e,r){return Math.min(r,Math.max(e,t))}function be(t){return t?t.split(",").map(e=>e.trim()).filter(Boolean):[]}function tt(t){let e=t.trim().match(/^#([0-9a-f]{3}|[0-9a-f]{6})$/i);if(e){let n=e[1],s=n.length===3?n.split("").map(l=>`${l}${l}`).join(""):n,
|
|
1282
|
+
`,Z=null;function ge(){return window.__DtChart?Promise.resolve(window.__DtChart):Z||(Z=new Promise((t,e)=>{let r=document.createElement("script");r.src="/api/ui/chart.umd.js",r.async=!0,r.dataset.dtChart="true",r.onload=()=>{if(window.__DtChart){t(window.__DtChart);return}e(new Error("Chart runtime loaded without a __DtChart export."))},r.onerror=()=>e(new Error("Failed to load the Chart.js runtime bundle.")),document.head.appendChild(r)}),Z)}function j(t,e,r){return Math.min(r,Math.max(e,t))}function be(t){return t?t.split(",").map(e=>e.trim()).filter(Boolean):[]}function tt(t){let e=t.trim().match(/^#([0-9a-f]{3}|[0-9a-f]{6})$/i);if(e){let n=e[1],s=n.length===3?n.split("").map(l=>`${l}${l}`).join(""):n,o=parseInt(s.slice(0,2),16)/255,a=parseInt(s.slice(2,4),16)/255,d=parseInt(s.slice(4,6),16)/255;return mt(o,a,d)}let r=t.trim().match(/^rgba?\((\d+(?:\.\d+)?)[,\s]+(\d+(?:\.\d+)?)[,\s]+(\d+(?:\.\d+)?)(?:[,/\s]+[\d.]+)?\)$/i);if(r)return mt(Number(r[1])/255,Number(r[2])/255,Number(r[3])/255);let i=t.trim().match(/^hsla?\(([-\d.]+)(?:deg)?[,\s]+([\d.]+)%[,\s]+([\d.]+)%(?:[,/\s]+[\d.]+)?\)$/i);return i?{h:(Number(i[1])%360+360)%360,s:j(Number(i[2]),0,100),l:j(Number(i[3]),0,100)}:null}function mt(t,e,r){let i=Math.max(t,e,r),n=Math.min(t,e,r),s=i-n,o=0,a=(i+n)/2,d=s===0?0:s/(1-Math.abs(2*a-1));if(s!==0)switch(i){case t:o=60*((e-r)/s%6);break;case e:o=60*((r-t)/s+2);break;default:o=60*((t-e)/s+4);break}return{h:(o+360)%360,s:Math.round(d*100),l:Math.round(a*100)}}function D(t,e=1){return`hsla(${Math.round(t.h)} ${Math.round(t.s)}% ${Math.round(t.l)}% / ${e})`}function ve(t){let e=tt(t)??{h:185,s:88,l:56};return[0,32,68,118,164,212,258,304].map((r,i)=>({h:(e.h+r)%360,s:j(e.s-i*2,55,90),l:j(e.l+(i%2===0?0:6)-i,38,66)}))}function K(t){return!!t&&typeof t=="object"&&!Array.isArray(t)}function gt(t,e){if(!K(t)||!K(e))return e??t;let r={...t};for(let[i,n]of Object.entries(e)){let s=r[i];r[i]=K(s)&&K(n)?gt(s,n):n}return r}function fe(t){return t==="top"||t==="bottom"||t==="left"||t==="right"?t:"none"}function _e(t){return t==="bar"||t==="line"||t==="area"||t==="pie"||t==="doughnut"||t==="radar"||t==="scatter"||t==="bubble"?t:"bar"}function xe(t){return t==="bar"||t==="line"||t==="area"||t==="scatter"||t==="bubble"}function we(t){return t.map(e=>e.trim()).filter(Boolean)}var ye=class extends HTMLElement{_canvas;_status;_runtime=null;_loadPromise=null;_chart=null;_renderedType=null;_dataInput=null;_optionsOverride=null;_syncFrame=0;static get observedAttributes(){return["type","legend","stacked","labels"]}get type(){return _e(this.getAttribute("type"))}set type(t){this.setAttribute("type",t)}get legend(){return fe(this.getAttribute("legend"))}set legend(t){this.setAttribute("legend",t)}get stacked(){return this.hasAttribute("stacked")}set stacked(t){this.toggleAttribute("stacked",t)}get labels(){return we(be(this.getAttribute("labels")))}set labels(t){this.setAttribute("labels",t.join(","))}get data(){return this._dataInput}set data(t){this._dataInput=t?structuredClone(t):null,this._scheduleSync()}get options(){return this._optionsOverride}set options(t){this._optionsOverride=t?structuredClone(t):null,this._renderChart()}constructor(){super();let t=this.attachShadow({mode:"open"}),e=document.createElement("style");e.textContent=me,t.appendChild(e);let r=document.createElement("div");r.className="dt-chart",this._canvas=document.createElement("canvas"),this._canvas.className="dt-chart__canvas",this._status=document.createElement("div"),this._status.className="dt-chart__status",this._status.textContent="Loading chart",r.append(this._canvas,this._status),t.appendChild(r)}connectedCallback(){this._canvas.addEventListener("click",this._handleCanvasClick),this._ensureRuntime().then(()=>this._renderChart()),this._scheduleSync()}disconnectedCallback(){this._canvas.removeEventListener("click",this._handleCanvasClick),this._syncFrame!==0&&(cancelAnimationFrame(this._syncFrame),this._syncFrame=0),this._chart?.destroy(),this._chart=null,this._renderedType=null}attributeChangedCallback(){this._scheduleSync()}_handleCanvasClick=t=>{if(!this._chart)return;let e=this._chart.getElementsAtEventForMode(t,"nearest",{intersect:!0},!0)[0];if(!e)return;let r=Array.isArray(this._chart.data.labels)?this._chart.data.labels[e.index]??null:null,i=this._chart.data.datasets[e.datasetIndex],n=Array.isArray(i?.data)?i.data[e.index]:void 0;this.dispatchEvent(new CustomEvent("dt-chart-click",{bubbles:!0,composed:!0,detail:{label:r,datasetIndex:e.datasetIndex,index:e.index,value:n}}))};_scheduleSync(){this._syncFrame===0&&(this._syncFrame=requestAnimationFrame(()=>{this._syncFrame=0,this._syncFromCurrentSource()}))}_syncFromCurrentSource(){this._renderChart()}async _ensureRuntime(){return this._runtime?this._runtime:(this._loadPromise||(this._loadPromise=ge().then(t=>(this._runtime=t,t))),this._loadPromise)}async _renderChart(){let t=this._dataInput;if(!t){this._setStatus("Waiting for data");return}let e=await this._ensureRuntime(),r=this._buildConfig(e,t),i=r.type;!this._chart||this._renderedType!==i?(this._chart?.destroy(),this._chart=new e.Chart(this._canvas,r),this._renderedType=i):(this._chart.data=r.data,this._chart.options=r.options,this._chart.update()),this._setStatus(t.datasets.length>0?null:"Waiting for data")}_buildConfig(t,e){let r=getComputedStyle(this),i=r.getPropertyValue("--dt-accent").trim()||"#42d4ff",n=r.getPropertyValue("--dt-text").trim()||"#d6ebff",s=r.getPropertyValue("--dt-text-muted").trim()||"#7b93a6",o=r.getPropertyValue("--dt-border").trim()||"rgba(123, 147, 166, 0.3)",a=r.getPropertyValue("--font-mono").trim()||"'SF Mono', Monaco, 'Cascadia Code', 'Roboto Mono', Consolas, monospace",d=ve(i),l=this.type==="area"?"line":this.type,g={labels:e.labels??this.labels,datasets:e.datasets.map((b,w)=>{let C=d[w%d.length],m=b.color??D(C,1),M={label:b.label??"",data:b.data,backgroundColor:l==="line"||l==="radar"||l==="scatter"?D(C,l==="scatter"?.95:.24):m,borderColor:m,pointBackgroundColor:m,pointBorderColor:m,pointHoverBackgroundColor:m,pointRadius:this.type==="line"||this.type==="area"?3:4,pointHoverRadius:this.type==="line"||this.type==="area"?5:6,borderWidth:2,tension:l==="line"||this.type==="area"?.32:void 0,fill:this.type==="area"};return l==="pie"||l==="doughnut"?{...M,backgroundColor:Array.isArray(b.data)?b.data.map((F,E)=>D(d[E%d.length],.86)):m,borderColor:Array.isArray(b.data)?b.data.map((F,E)=>D(d[E%d.length],1)):m,borderWidth:1}:l==="scatter"||l==="bubble"?{...M,showLine:!1,backgroundColor:D(C,.78)}:M})},_={responsive:!0,maintainAspectRatio:!1,animation:{duration:320},interaction:{mode:"nearest",intersect:!0},plugins:{legend:{display:this.legend!=="none",position:this.legend==="none"?"top":this.legend,labels:{color:n,boxWidth:12,boxHeight:12,padding:14,font:{family:a,size:11}}},tooltip:{backgroundColor:"rgba(10, 18, 24, 0.92)",borderColor:ke(o,i,.35),borderWidth:1,titleColor:n,bodyColor:n,footerColor:s,titleFont:{family:a,size:11},bodyFont:{family:a,size:11},padding:10}},scales:xe(this.type)?{x:{stacked:this.stacked,grid:{display:!1,color:o},border:{color:o},ticks:{color:s,font:{family:a,size:11}}},y:{stacked:this.stacked,beginAtZero:!0,grid:{display:!1,color:o},border:{color:o},ticks:{color:s,font:{family:a,size:11}}}}:l==="radar"?{r:{angleLines:{color:o},grid:{color:o},pointLabels:{color:s,font:{family:a,size:11}},ticks:{color:s,backdropColor:"transparent",font:{family:a,size:10}}}}:void 0};return{type:l,data:g,options:gt(_,this._optionsOverride??{})}}_setStatus(t){if(!t){this._status.hidden=!0;return}this._status.hidden=!1,this._status.textContent=t}};function ke(t,e,r){let i=tt(t),n=tt(e);if(!i||!n)return t;let s=j(r,0,1),o=((n.h-i.h)%360+540)%360-180;return D({h:(i.h+o*s+360)%360,s:i.s+(n.s-i.s)*s,l:i.l+(n.l-i.l)*s})}var Ce=`:host {
|
|
1283
1283
|
display: block;
|
|
1284
1284
|
color: var(--dt-text);
|
|
1285
1285
|
font-family: var(--font-sans, 'Inter', sans-serif);
|
|
@@ -1564,6 +1564,34 @@ ${r}`}var ze=class extends HTMLElement{_body;_caret;_contentOverride=null;_runti
|
|
|
1564
1564
|
color: var(--dt-text);
|
|
1565
1565
|
}
|
|
1566
1566
|
|
|
1567
|
+
.milkdown .ProseMirror.editor {
|
|
1568
|
+
padding: 0px 54px;
|
|
1569
|
+
}
|
|
1570
|
+
|
|
1571
|
+
.milkdown .ProseMirror.editor h1 {
|
|
1572
|
+
font-size: 36px;
|
|
1573
|
+
}
|
|
1574
|
+
|
|
1575
|
+
.milkdown .ProseMirror.editor h2 {
|
|
1576
|
+
font-size: 30px;
|
|
1577
|
+
}
|
|
1578
|
+
|
|
1579
|
+
.milkdown .ProseMirror.editor h3 {
|
|
1580
|
+
font-size: 24px;
|
|
1581
|
+
}
|
|
1582
|
+
|
|
1583
|
+
.milkdown .ProseMirror.editor h4 {
|
|
1584
|
+
font-size: 20px;
|
|
1585
|
+
}
|
|
1586
|
+
|
|
1587
|
+
.milkdown .ProseMirror.editor h5 {
|
|
1588
|
+
font-size: 16px;
|
|
1589
|
+
}
|
|
1590
|
+
|
|
1591
|
+
.milkdown .ProseMirror.editor h6 {
|
|
1592
|
+
font-size: 16px;
|
|
1593
|
+
}
|
|
1594
|
+
|
|
1567
1595
|
.milkdown .editor {
|
|
1568
1596
|
min-height: 100%;
|
|
1569
1597
|
padding: 16px 18px 20px;
|
|
@@ -1574,10 +1602,6 @@ ${r}`}var ze=class extends HTMLElement{_body;_caret;_contentOverride=null;_runti
|
|
|
1574
1602
|
line-height: 1.7;
|
|
1575
1603
|
}
|
|
1576
1604
|
|
|
1577
|
-
.milkdown .editor > :first-child {
|
|
1578
|
-
margin-top: 0;
|
|
1579
|
-
}
|
|
1580
|
-
|
|
1581
1605
|
.milkdown .editor h1,
|
|
1582
1606
|
.milkdown .editor h2,
|
|
1583
1607
|
.milkdown .editor h3,
|
|
@@ -1603,10 +1627,6 @@ ${r}`}var ze=class extends HTMLElement{_body;_caret;_contentOverride=null;_runti
|
|
|
1603
1627
|
font-size: 1.08rem;
|
|
1604
1628
|
}
|
|
1605
1629
|
|
|
1606
|
-
.milkdown .editor p {
|
|
1607
|
-
margin: 0.65em 0;
|
|
1608
|
-
}
|
|
1609
|
-
|
|
1610
1630
|
.milkdown .editor code {
|
|
1611
1631
|
padding: 2px 5px;
|
|
1612
1632
|
border-radius: 2px;
|
|
@@ -1663,6 +1683,38 @@ ${r}`}var ze=class extends HTMLElement{_body;_caret;_contentOverride=null;_runti
|
|
|
1663
1683
|
padding-left: 1.5rem;
|
|
1664
1684
|
}
|
|
1665
1685
|
|
|
1686
|
+
/* Runtime Milkdown styles are injected after this file, so use scoped CSS
|
|
1687
|
+
variables instead of direct property overrides. */
|
|
1688
|
+
.milkdown .milkdown-list-item-block {
|
|
1689
|
+
--crepe-color-outline: var(--dt-text-secondary);
|
|
1690
|
+
}
|
|
1691
|
+
|
|
1692
|
+
.milkdown .milkdown-block-handle {
|
|
1693
|
+
--crepe-color-outline: var(--dt-text-muted);
|
|
1694
|
+
}
|
|
1695
|
+
|
|
1696
|
+
.milkdown .milkdown-block-handle .operation-item:hover {
|
|
1697
|
+
--crepe-color-outline: var(--dt-text-secondary);
|
|
1698
|
+
}
|
|
1699
|
+
|
|
1700
|
+
.milkdown .milkdown-toolbar {
|
|
1701
|
+
--crepe-color-outline: var(--dt-text-muted);
|
|
1702
|
+
--crepe-color-hover: color-mix(
|
|
1703
|
+
in srgb,
|
|
1704
|
+
var(--dt-surface-hover) 88%,
|
|
1705
|
+
var(--dt-text-secondary) 12%
|
|
1706
|
+
);
|
|
1707
|
+
--crepe-color-selected: color-mix(in srgb, var(--dt-surface-active) 74%, var(--dt-accent) 26%);
|
|
1708
|
+
}
|
|
1709
|
+
|
|
1710
|
+
.milkdown .milkdown-toolbar .toolbar-item:hover {
|
|
1711
|
+
--crepe-color-outline: var(--dt-text-secondary);
|
|
1712
|
+
}
|
|
1713
|
+
|
|
1714
|
+
.milkdown .milkdown-toolbar .toolbar-item.active {
|
|
1715
|
+
--crepe-color-primary: var(--dt-accent);
|
|
1716
|
+
}
|
|
1717
|
+
|
|
1666
1718
|
.milkdown .editor img {
|
|
1667
1719
|
max-width: 100%;
|
|
1668
1720
|
border-radius: 2px;
|
|
@@ -1677,15 +1729,15 @@ ${r}`}var ze=class extends HTMLElement{_body;_caret;_contentOverride=null;_runti
|
|
|
1677
1729
|
.milkdown .editor td {
|
|
1678
1730
|
border: 1px solid var(--dt-border);
|
|
1679
1731
|
}
|
|
1680
|
-
`,rt=null;function Ne(){return window.__DtMilkdown?Promise.resolve(window.__DtMilkdown):rt||(rt=new Promise((t,e)=>{let r=document.createElement("script");r.src="/api/ui/milkdown.umd.js",r.async=!0,r.dataset.dtMilkdown="true",r.onload=()=>{if(window.__DtMilkdown){t(window.__DtMilkdown);return}e(new Error("Milkdown runtime loaded without a __DtMilkdown export."))},r.onerror=()=>e(new Error("Failed to load the Milkdown runtime bundle.")),document.head.appendChild(r)}),rt)}var Te=class extends HTMLElement{
|
|
1681
|
-
`)){const l=d.trim();if(l.startsWith("title:"))n=l.slice(6).trim().replace(/^["']|["']$/g,""),
|
|
1682
|
-
`)}function
|
|
1683
|
-
`).length,
|
|
1732
|
+
`,rt=null;function Ne(){return window.__DtMilkdown?Promise.resolve(window.__DtMilkdown):rt||(rt=new Promise((t,e)=>{let r=document.createElement("script");r.src="/api/ui/milkdown.umd.js",r.async=!0,r.dataset.dtMilkdown="true",r.onload=()=>{if(window.__DtMilkdown){t(window.__DtMilkdown);return}e(new Error("Milkdown runtime loaded without a __DtMilkdown export."))},r.onerror=()=>e(new Error("Failed to load the Milkdown runtime bundle.")),document.head.appendChild(r)}),rt)}var Te=class extends HTMLElement{_shadow;_runtimeStyleAnchor;_surface;_content;_status;_runtime=null;_loadPromise=null;_editor=null;_pendingValue="";_changeTimer=null;_setupToken=0;_suppressNextChange=!1;static get observedAttributes(){return["placeholder","readonly"]}get placeholder(){return this.getAttribute("placeholder")??""}set placeholder(t){this.setAttribute("placeholder",t)}get readonly(){return this.hasAttribute("readonly")}set readonly(t){this.toggleAttribute("readonly",t)}get value(){return this._editor&&(this._pendingValue=this._editor.getMarkdown()),this._pendingValue}set value(t){let e=String(t??"");this._pendingValue=e,this._editor&&this._runtime&&this._editor.getMarkdown()!==e&&(this._suppressNextChange=!0,this._editor.editor.action(this._runtime.replaceAll(e)))}constructor(){super();let t=this.attachShadow({mode:"open"});this._shadow=t;let e=document.createElement("style");e.textContent=Me,t.appendChild(e),this._runtimeStyleAnchor=document.createComment("runtime-styles"),t.appendChild(this._runtimeStyleAnchor),this._surface=document.createElement("div"),this._surface.className="dt-markdown-editor",this._content=document.createElement("div"),this._content.className="dt-markdown-editor__surface";let r=document.createElement("div");r.className="dt-markdown-editor__content",this._content.appendChild(r),this._status=document.createElement("div"),this._status.className="dt-markdown-editor__status",this._status.textContent="Loading editor",this._surface.append(this._content,this._status),t.appendChild(this._surface)}connectedCallback(){this._initializeEditor()}disconnectedCallback(){this._setupToken+=1,this._clearChangeTimer(),this._destroyEditor()}attributeChangedCallback(t){if(t==="readonly"){this._editor?.setReadonly(this.readonly);return}t==="placeholder"&&this.isConnected&&this._initializeEditor(!0)}async _ensureRuntime(){return this._runtime?this._runtime:(this._loadPromise||(this._loadPromise=Ne().then(t=>{this._runtime=t;let e=this._runtimeStyleAnchor;for(let r of t.cssEntries){let i=document.createElement("style");i.dataset.css=r.name,i.textContent=r.css,e.parentNode.insertBefore(i,e.nextSibling)}return t})),this._loadPromise)}async _initializeEditor(t=!1){let e=++this._setupToken;if(this._setStatus("Loading editor"),t)await this._destroyEditor();else if(this._editor){this._setStatus(null);return}try{let r=await this._ensureRuntime();if(!this.isConnected||e!==this._setupToken)return;this._content.replaceChildren();let i=document.createElement("div");i.className="dt-markdown-editor__content",this._content.appendChild(i);let n=new r.Crepe({root:i,defaultValue:this._pendingValue,features:{[r.Crepe.Feature.CodeMirror]:!1,[r.Crepe.Feature.ImageBlock]:!1,[r.Crepe.Feature.Latex]:!1},featureConfigs:{[r.Crepe.Feature.Placeholder]:{text:this.placeholder,mode:"doc"}}});if(n.on(s=>{s.markdownUpdated((o,a)=>{if(this._pendingValue=a,this._suppressNextChange){this._suppressNextChange=!1;return}this._queueChange(a)}),s.focus(()=>{this.dispatchEvent(new CustomEvent("dt-focus",{bubbles:!0,composed:!0}))}),s.blur(()=>{this.dispatchEvent(new CustomEvent("dt-blur",{bubbles:!0,composed:!0}))})}),await n.create(),!this.isConnected||e!==this._setupToken){await n.destroy();return}this._editor=n,this._editor.setReadonly(this.readonly),this._pendingValue=this._editor.getMarkdown(),this._setStatus(null)}catch{e===this._setupToken&&this._setStatus("Failed to load editor")}}async _destroyEditor(){let t=this._editor;if(this._editor=null,!!t)try{await t.destroy()}catch{}}_queueChange(t){this._clearChangeTimer(),this._changeTimer=setTimeout(()=>{this._changeTimer=null,this.dispatchEvent(new CustomEvent("dt-change",{bubbles:!0,composed:!0,detail:{value:t}}))},300)}_clearChangeTimer(){this._changeTimer&&(clearTimeout(this._changeTimer),this._changeTimer=null)}_setStatus(t){if(t){this._status.hidden=!1,this._status.textContent=t;return}this._status.hidden=!0}};customElements.get("dt-tooltip")||customElements.define("dt-tooltip",zt),customElements.get("dt-card")||customElements.define("dt-card",Tt),customElements.get("dt-select")||customElements.define("dt-select",Vt),customElements.get("dt-grid")||customElements.define("dt-grid",Wt),customElements.get("dt-stack")||customElements.define("dt-stack",Ut),customElements.get("dt-stat")||customElements.define("dt-stat",Gt),customElements.get("dt-badge")||customElements.define("dt-badge",Qt),customElements.get("dt-button")||customElements.define("dt-button",ee),customElements.get("dt-divider")||customElements.define("dt-divider",ne),customElements.get("dt-list-view")||customElements.define("dt-list-view",pe),customElements.get("dt-table-view")||customElements.define("dt-table-view",ce),customElements.get("dt-column")||customElements.define("dt-column",ut),customElements.get("dt-chart")||customElements.define("dt-chart",ye),customElements.get("dt-markdown")||customElements.define("dt-markdown",ze),customElements.get("dt-markdown-editor")||customElements.define("dt-markdown-editor",Te);function Le(t){const e=t.match(/^---\r?\n[\s\S]*?\r?\n---\r?\n?([\s\S]*)$/);return e?e[1]:t}var He=ft(function({note:e,loading:r,onSave:i},n){const s=H(null),[o,a]=I("idle"),d=H(null),l=H(i);return l.current=i,W(()=>{if(s.current&&e){const g=Le(e.content);s.current.value=g}},[e?.id]),W(()=>{const g=s.current;if(!g)return;const _=b=>{const w=b.detail;w&&(d.current&&clearTimeout(d.current),a("saving"),d.current=setTimeout(()=>{l.current(w.value),a("saved")},500))};return g.addEventListener("dt-change",_),()=>g.removeEventListener("dt-change",_)},[]),W(()=>()=>{d.current&&clearTimeout(d.current)},[]),_t(n,()=>({getMarkdown(){return s.current?.value??null},setMarkdown(g){s.current&&(s.current.value=g)},getCursorLine(){return 1},getSelectedText(){return""}}),[]),e?T("div",{className:v.editorPanel,children:[T("div",{className:v.editorHeader,children:[T("div",{children:[u("div",{className:v.editorTitle,children:e.title}),e.tags.length>0&&u("div",{className:v.editorTags,children:e.tags.map(g=>u("span",{className:v.editorTag,children:g},g))})]}),u("span",{className:o==="saving"?v.saveStatusSaving:v.saveStatus,children:o==="saving"?"Saving...":o==="saved"?"Saved":""})]}),u("div",{className:v.editorBody,children:u("dt-markdown-editor",{ref:s,placeholder:"Start writing...",style:{height:"100%"}})})]}):u("div",{className:v.editorPanel,children:u("div",{className:v.editorPlaceholder,children:r?"Loading...":"Select a note or create a new one"})})});import{ActionsProvider as Ie,Action as R,useCommand as J}from"@desktalk/sdk";var Re=/^---\r?\n([\s\S]*?)\r?\n---\r?\n?([\s\S]*)$/;function Fe(t){const e=t.match(Re);if(!e){const d=t.match(/^#\s+(.+)$/m);return{title:d?d[1].trim():"Untitled",tags:[],created:null,body:t}}const r=e[1],i=e[2];let n="Untitled",s=[],o=null,a=!1;for(const d of r.split(`
|
|
1733
|
+
`)){const l=d.trim();if(l.startsWith("title:"))n=l.slice(6).trim().replace(/^["']|["']$/g,""),a=!1;else if(l.startsWith("created:"))o=l.slice(8).trim(),a=!1;else if(l.startsWith("tags:")){a=!0;const g=l.slice(5).trim();g.startsWith("[")&&g.endsWith("]")&&(s=g.slice(1,-1).split(",").map(_=>_.trim().replace(/^["']|["']$/g,"")).filter(Boolean),a=!1)}else a&&l.startsWith("- ")?s.push(l.slice(2).trim().replace(/^["']|["']$/g,"")):a=!1}return{title:n,tags:s,created:o,body:i}}function $e(t,e,r,i){const n=["---",`title: "${t.replace(/"/g,'\\"')}"`];if(e.length>0){n.push("tags:");for(const s of e)n.push(` - ${s}`)}return n.push(`created: ${r}`,"---","",i),n.join(`
|
|
1734
|
+
`)}function Pe(t,e,r,i,n){const o=t.substring(0,n).split(`
|
|
1735
|
+
`).length,a=r.split(`
|
|
1684
1736
|
`),d=i.split(`
|
|
1685
|
-
`),l=Math.max(0,
|
|
1737
|
+
`),l=Math.max(0,o-4),g=t.split(`
|
|
1686
1738
|
`),_=e.split(`
|
|
1687
|
-
`),b=[];b.push(`@@ -${
|
|
1688
|
-
`),firstChangedLine:
|
|
1739
|
+
`),b=[];b.push(`@@ -${o},${a.length} +${o},${d.length} @@`);for(let m=l;m<o-1;m++)b.push(` ${g[m]}`);for(const m of a)b.push(`-${m}`);for(const m of d)b.push(`+${m}`);const w=o-1+a.length,C=Math.min(_.length,w+3);for(let m=w;m<C;m++)_[m]!==void 0&&b.push(` ${_[m]}`);return{diff:b.join(`
|
|
1740
|
+
`),firstChangedLine:o}}function De({children:t,selectedNoteId:e,selectedNote:r,notes:i,editorRef:n,onNoteCreated:s,onNoteDeleted:o,onSearch:a,onNoteUpdated:d,onSelectNote:l,onRefresh:g}){const _=J("notes.create"),b=J("notes.delete"),w=J("notes.search"),C=J("notes.update"),m=x(async f=>{const p=await _({title:f?.title||void 0,content:f?.content||void 0,tags:f?.tags||void 0,path:f?.path||void 0});return s(p),p},[_,s]),M=x(async()=>{e&&(await b({id:e}),o(e))},[b,e,o]),F=x(async f=>{const p=f?.query||"";return a(p),await w({query:p})},[w,a]),E=x(()=>{if(!r)return null;const f=n.current;if(!f)return null;const p=f.getMarkdown();return p===null?null:$e(r.title,r.tags,r.createdAt,p)},[r,n]),$=x(async()=>({notes:i.slice(0,20).map(p=>({id:p.id,title:p.title,updatedAt:p.updatedAt,selected:p.id===e}))}),[i,e]),A=x(async f=>{const p=f?.id;return p?i.find(N=>N.id===p)?(await l(p),{success:!0}):{success:!1,error:`Note not found: ${p}`}:{success:!1,error:"id parameter is required"}},[i,l]),U=x(async()=>{if(!e||!r)return{error:"No note is currently open"};const f=n.current;if(!f)return{error:"Editor is not ready"};const p=E();return p===null?{error:"Editor is not ready"}:{id:r.id,title:r.title,content:p,cursorLine:f.getCursorLine(),selectedText:f.getSelectedText()}},[e,r,n,E]),V=x(async f=>{if(!e||!r)return{success:!1,error:"No note is currently open"};const p=n.current;if(!p)return{success:!1,error:"Editor is not ready"};const y=f?.old_text,N=f?.new_text;if(y===void 0||N===void 0)return{success:!1,error:"Both old_text and new_text are required"};const S=E();if(S===null)return{success:!1,error:"Editor is not ready"};let P,O;if(y==="")P=N+S,O=0;else{const z=S.indexOf(y);if(z===-1)return{success:!1,error:"Text not found in note"};const X=S.indexOf(y,z+1);if(X!==-1){let it=2,nt=X+1;for(;;){const st=S.indexOf(y,nt);if(st===-1)break;it++,nt=st+1}return{success:!1,error:`Text appears ${it} times; provide more surrounding context to make it unique`}}P=S.substring(0,z)+N+S.substring(z+y.length),O=z}const c=Fe(P);p.setMarkdown(c.body);const k=c.tags.length!==r.tags.length||c.tags.some((z,X)=>z!==r.tags[X]),q=c.title!==r.title;if(k||q){const z=await C({id:e,tags:c.tags,content:c.body});d(z)}const{diff:Y,firstChangedLine:vt}=Pe(S,P,y,N,O);return{success:!0,diff:Y,firstChangedLine:vt}},[e,r,n,E,C,d]);return T(Ie,{children:[u(R,{name:"Create Note",description:"Create a new note with optional title, content, and path",params:{title:{type:"string",description:"Note title",required:!1},content:{type:"string",description:"Note content in Markdown",required:!1},tags:{type:"string",description:"Comma-separated tags",required:!1},path:{type:"string",description:'Relative path for the note (e.g. "work/meeting-notes"). Becomes the note ID. Auto-generated if omitted.',required:!1}},handler:m}),u(R,{name:"Delete Note",description:"Delete the currently selected note",handler:M}),u(R,{name:"Search Notes",description:"Search notes by keyword",params:{query:{type:"string",description:"Search query",required:!0}},handler:F}),u(R,{name:"List Notes",description:"Return the 20 most recent notes with selection status",handler:$}),u(R,{name:"Select Note",description:"Select a note by ID and open it in the editor",params:{id:{type:"string",description:"Note ID (relative path without .md)",required:!0}},handler:A}),u(R,{name:"Get Editing Context",description:"Return the current editor state for the selected note including content, cursor position, and selected text",handler:U}),u(R,{name:"Edit Note",description:"Apply a text replacement to the current note content including front matter. Use old_text to find exact text and new_text to replace it. To edit tags or title, modify the YAML front matter directly.",params:{old_text:{type:"string",description:"Exact text to find in the note content (must appear exactly once). Searches the full content including YAML front matter. Use empty string to insert at beginning.",required:!0},new_text:{type:"string",description:"Replacement text",required:!0}},handler:V}),t]})}var Ve=720;function Oe(){const[t,e]=I([]),[r,i]=I(null),[n,s]=I(null),[o,a]=I(""),[d,l]=I(!1),[g,_]=I(!1),b=H(null),w=H(null),C=B("notes.list"),m=B("notes.get"),M=B("notes.update"),F=B("notes.search"),E=B("notes.create"),$=x(async()=>{try{let c;o?c=await F({query:o}):c=await C(),e(c)}catch(c){console.error("Failed to fetch notes:",c)}},[C,F,o]),A=x(()=>{$()},[$]);W(()=>{A()},[A]),W(()=>{if(!w.current)return;const c=q=>{_(q<=Ve)};c(w.current.clientWidth);const k=new ResizeObserver(q=>{const Y=q[0];Y&&c(Y.contentRect.width)});return k.observe(w.current),()=>k.disconnect()},[]);const U=x(async c=>{i(c),l(!0);try{const k=await m({id:c});s(k)}catch(k){console.error("Failed to load note:",k),s(null)}finally{l(!1)}},[m]),V=H(null),f=x(c=>{a(c),V.current&&clearTimeout(V.current),V.current=setTimeout(()=>{},300)},[]),p=x(async c=>{if(!(!r||!n))try{const k=await M({id:r,content:c});s(k),$()}catch(k){console.error("Failed to save note:",k)}},[r,n,M,$]),y=x(c=>{A(),i(c.id),s(c)},[A]),N=x(c=>{r===c&&(i(null),s(null)),A()},[r,A]),S=x(c=>{r===c.id&&s(c),A()},[r,A]),P=x(c=>{a(c)},[]),O=x(async()=>{try{const c=await E({});y(c)}catch(c){console.error("Failed to create note:",c)}},[E,y]);return u(De,{selectedNoteId:r,selectedNote:n,notes:t,editorRef:b,onNoteCreated:y,onNoteDeleted:N,onSearch:P,onNoteUpdated:S,onSelectNote:U,onRefresh:A,children:T("div",{ref:w,className:`${v.root}${g?` ${v.rootCompact}`:""}`,children:[u(Ct,{notes:t,selectedId:r,onSelect:U,onCreate:O,searchQuery:o,onSearchChange:f}),u(He,{ref:b,note:n,loading:d,onSave:p})]})})}function qe(t){const e=xt(t.root);return e.render(u(yt,{windowId:t.windowId,children:u(wt,{miniAppId:t.miniAppId,children:u(Oe,{})})})),{deactivate(){e.unmount()}}}export{qe as activate};
|
|
1689
1741
|
(() => {
|
|
1690
1742
|
if (typeof document === 'undefined') return;
|
|
1691
1743
|
const styleId = "desktalk-style-desktalk-miniapp-note-emi3yz";
|