@stacksjs/components 0.2.516 → 0.2.517
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/{ChatInbox-wpg039q7.stx → ChatInbox-cbbb5x1n.stx} +7 -1
- package/dist/index.js +1 -1
- package/dist/ui/chat/contact-link.d.ts +9 -0
- package/dist/ui/chat/controller.d.ts +1 -1
- package/dist/ui/chat/index.d.ts +2 -1
- package/package.json +3 -3
- package/src/ui/chat/ChatInbox.stx +7 -1
- package/src/ui/chat/README.md +10 -0
- package/src/ui/chat/contact-link.ts +27 -0
- package/src/ui/chat/controller.ts +1 -1
- package/src/ui/chat/index.ts +2 -1
|
@@ -7,11 +7,16 @@ export const sizeClasses = compact ? 'min-h-[340px] h-[min(560px,calc(100dvh-230
|
|
|
7
7
|
export const selectedInboxClass = 'hidden'
|
|
8
8
|
export const backButtonClass = ''
|
|
9
9
|
export const inboxWidth = 'w-full'
|
|
10
|
+
// Where the selected contact's face and name lead (contact-link.ts): a URL
|
|
11
|
+
// with {field} placeholders filled from the contact, e.g. "/people/{username}".
|
|
12
|
+
export const contactHref = $props.contactHref || ''
|
|
10
13
|
</script>
|
|
11
14
|
<script client>
|
|
15
|
+
import { contactLink } from './contact-link'
|
|
12
16
|
const active = useReactiveProp('active', {{ active }})
|
|
13
17
|
const compact = {{ compact }}
|
|
14
18
|
const selectedInboxClass = {{ selectedInboxClass }}
|
|
19
|
+
const contactHref = {{ contactHref }}
|
|
15
20
|
const chat = useStore({{ storeName }})
|
|
16
21
|
const rows = chat.rows
|
|
17
22
|
const selected = chat.selected
|
|
@@ -56,6 +61,7 @@ const emptyThread = derived(() => hasSelection() && !threadLoading() && messages
|
|
|
56
61
|
const selectedName = derived(() => selected()?.name || '')
|
|
57
62
|
const selectedRole = derived(() => selected()?.role || '')
|
|
58
63
|
const selectedAvatar = derived(() => selected()?.avatar || '')
|
|
64
|
+
const selectedHref = derived(() => contactLink(selected(), contactHref))
|
|
59
65
|
const sendLabel = derived(() => sending() ? 'Sending...' : 'Send message')
|
|
60
66
|
function timestamp(value) { return new Date(value).toLocaleString([], { month: 'short', day: 'numeric', hour: 'numeric', minute: '2-digit' }) }
|
|
61
67
|
function submit() { return chat.send() }
|
|
@@ -89,7 +95,7 @@ effect(() => { if (active() && visibility() === 'visible') chat.refresh(true) })
|
|
|
89
95
|
</div>
|
|
90
96
|
<div :if="hasSelection" class="flex flex-1 flex-col min-w-0">
|
|
91
97
|
<header class="flex items-center gap-3 px-4 py-4 border-b border-line">
|
|
92
|
-
<button type="button" @click="chat.back()" aria-label="Back to inbox" class="stx-chat-back {{ backButtonClass }} p-2 rounded-lg hover:bg-surface-hover"><span class="i-lucide-arrow-left" aria-hidden="true"></span></button><Avatar :src="selectedAvatar" :alt="selectedName" size="md" className="shrink-0" /><div class="flex-1"><h2 class="font-semibold text-fg-strong" :text="selectedName"></h2><p class="mt-0.5 text-xs text-fg-muted" :text="selectedRole"></p></div><button type="button" @click="chat.refresh(true)" aria-label="Refresh conversation" class="p-2 text-fg-muted rounded-lg hover:bg-surface-hover"><span class="i-lucide-refresh-cw" aria-hidden="true"></span></button>
|
|
98
|
+
<button type="button" @click="chat.back()" aria-label="Back to inbox" class="stx-chat-back {{ backButtonClass }} p-2 rounded-lg hover:bg-surface-hover"><span class="i-lucide-arrow-left" aria-hidden="true"></span></button><StxLink :if="selectedHref" :to="selectedHref" className="stx-chat-person flex flex-1 gap-3 items-center min-w-0 rounded-lg hover:opacity-80 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent"><Avatar :src="selectedAvatar" :alt="selectedName" size="md" className="shrink-0" /><div class="min-w-0"><h2 class="font-semibold text-fg-strong truncate" :text="selectedName"></h2><p class="mt-0.5 text-xs text-fg-muted" :text="selectedRole"></p></div></StxLink><div :if="!selectedHref" class="stx-chat-person flex flex-1 gap-3 items-center min-w-0"><Avatar :src="selectedAvatar" :alt="selectedName" size="md" className="shrink-0" /><div class="min-w-0"><h2 class="font-semibold text-fg-strong truncate" :text="selectedName"></h2><p class="mt-0.5 text-xs text-fg-muted" :text="selectedRole"></p></div></div><button type="button" @click="chat.refresh(true)" aria-label="Refresh conversation" class="p-2 text-fg-muted rounded-lg hover:bg-surface-hover"><span class="i-lucide-refresh-cw" aria-hidden="true"></span></button>
|
|
93
99
|
</header>
|
|
94
100
|
<div ref="chat-history" role="log" aria-label="Conversation history" aria-live="polite" aria-relevant="additions" :aria-busy="threadLoading" class="flex flex-col flex-1 min-h-0 overflow-y-auto px-4 py-5 gap-4">
|
|
95
101
|
<button :if="hasMore" type="button" @click="chat.older()" :disabled="threadLoading" class="self-center text-sm text-accent-soft-ink font-medium underline">Load earlier messages</button>
|
package/dist/index.js
CHANGED
|
@@ -22,4 +22,4 @@ ${r.join(`
|
|
|
22
22
|
`);return{html:a.replace(/(<span class="[^"]*")[^>]*?\s+style="[^"]*"/g,(k,b)=>je.test(/class="([^"]*)"/.exec(b)?.[1]??"")?b:k),css:y}}async function qu(e,t={}){let{theme:s="auto",language:o="typescript",lineNumbers:n=!1,wrapLines:a=!0}=t,r=s==="auto"?globalThis.matchMedia?.("(prefers-color-scheme: dark)").matches?"github-dark":"github-light":s==="dark"?ze:Re,i;try{i=await _a()}catch{return{html:ye(e),css:"",language:o,theme:r}}if(s==="auto"){let d=await Ga(i,e,o);if(d)return{html:d.html,css:d.css,language:o,theme:"auto"}}let c;try{c=await i.highlight(e,o,{theme:r})}catch{return{html:ye(e),css:"",language:o,theme:r}}let p=c,u=typeof p==="string"?{html:p,css:""}:{html:p?.html??ye(e),css:p?.css??""};return{html:u.html,css:u.css,language:o,theme:r}}function Wu(e){if(e.includes("<!DOCTYPE")||e.includes("<html"))return"html";if(e.includes("<?php"))return"php";if(e.includes("import")&&e.includes("from"))return"typescript";if(e.includes("function")||e.includes("const"))return"javascript";if(e.includes("{")&&e.includes("}"))return"json";if(e.includes("$")&&e.includes("|"))return"bash";if(e.includes("#")&&e.includes("##"))return"markdown";return"typescript"}function Ku(e,t){return`<div class="${t?`rounded-md overflow-auto text-sm leading-relaxed font-mono ${t}`:"rounded-md overflow-auto text-sm leading-relaxed font-mono"}">${e}</div>`}var F=null,Ya=(e)=>e===1?0:1;function re(e,t){return t.split(".").reduce((s,o)=>s?.[o],e)}function ke(e,t={}){return e.replace(/\{(\w+)\}/g,(s,o)=>t[o]!==void 0?String(t[o]):s)}function Uu(e){let{locale:t,fallbackLocale:s="en",messages:o,pluralRules:n={},dateTimeFormats:a={},numberFormats:r={},missing:i,warnMissing:c=!0}=e;function p(b,x={}){let E=re(o[t],b);if(E===void 0&&s)E=re(o[s],b);if(E===void 0){if(i){let A=i(t,b);if(A)return ke(A,x)}if(c&&typeof console<"u")console.warn(`[i18n] Missing translation for key "${b}" in locale "${t}"`);return b}if(typeof E==="string")return ke(E,x);return String(E)}function u(b,x,E={}){let A=p(b,{...E,count:x});if(A.includes("|")){let S=A.split("|").map((K)=>K.trim()),z=(n[t]||Ya)(x,t),B=S[z]||S[S.length-1];return ke(B,{...E,count:x})}return A}function d(b,x="default"){let E=typeof b==="number"?new Date(b):b,A=a[x]||a.default||{};return new Intl.DateTimeFormat(t,A).format(E)}function g(b,x="default"){let E=r[x]||r.default||{};return new Intl.NumberFormat(t,E).format(b)}function f(b){if(re(o[t],b)!==void 0)return!0;if(s)return re(o[s],b)!==void 0;return!1}function y(b){if(!o[b]){console.warn(`[i18n] Locale "${b}" not found. Available locales: ${Object.keys(o).join(", ")}`);return}t=b}function C(b,x){if(!o[b])o[b]={};o[b]={...o[b],...x}}function k(b){delete o[b]}return{get locale(){return t},get availableLocales(){return Object.keys(o)},setLocale:y,t:p,tc:u,d,n:g,te:f,addMessages:C,removeLocale:k}}function Ju(e){F=e}function Gu(){return F}function Yu(e,t){if(!F)return console.warn("[i18n] No global i18n instance set. Call setI18n() first."),e;return F.t(e,t)}function Xu(e,t,s){if(!F)return console.warn("[i18n] No global i18n instance set. Call setI18n() first."),e;return F.tc(e,t,s)}function Qu(e,t){if(!F)return console.warn("[i18n] No global i18n instance set. Call setI18n() first."),String(e);return F.d(e,t)}function Zu(e,t){if(!F)return console.warn("[i18n] No global i18n instance set. Call setI18n() first."),String(e);return F.n(e,t)}var eh={en:(e)=>e===1?0:1,de:(e)=>e===1?0:1,nl:(e)=>e===1?0:1,sv:(e)=>e===1?0:1,fr:(e)=>e===0||e===1?0:1,pt_BR:(e)=>e===0||e===1?0:1,ru:(e)=>{if(e%10===1&&e%100!==11)return 0;if(e%10>=2&&e%10<=4&&(e%100<10||e%100>=20))return 1;return 2},pl:(e)=>{if(e===1)return 0;if(e%10>=2&&e%10<=4&&(e%100<10||e%100>=20))return 1;return 2},cs:(e)=>{if(e===1)return 0;if(e>=2&&e<=4)return 1;return 2},ar:(e)=>{if(e===0)return 0;if(e===1)return 1;if(e===2)return 2;if(e%100>=3&&e%100<=10)return 3;if(e%100>=11)return 4;return 5},ja:()=>0,ko:()=>0,zh:()=>0,th:()=>0,vi:()=>0},th={short:{year:"numeric",month:"numeric",day:"numeric"},long:{year:"numeric",month:"long",day:"numeric"},full:{weekday:"long",year:"numeric",month:"long",day:"numeric"},time:{hour:"numeric",minute:"numeric"},datetime:{year:"numeric",month:"numeric",day:"numeric",hour:"numeric",minute:"numeric"}},sh={decimal:{style:"decimal",minimumFractionDigits:2,maximumFractionDigits:2},currency:{style:"currency",currency:"USD"},percent:{style:"percent",minimumFractionDigits:0,maximumFractionDigits:2},compact:{notation:"compact"}};function oh(e){let t=["ar","he","fa","ur","yi"],s=e.split("-")[0].toLowerCase();return t.includes(s)}async function nh(e,t){try{return await t()}catch(s){return console.error(`[i18n] Failed to load messages for locale "${e}":`,s),{}}}var ah={en:{common:{loading:"Loading...",error:"Error",retry:"Retry",cancel:"Cancel",confirm:"Confirm",close:"Close",save:"Save",delete:"Delete",edit:"Edit",search:"Search",clear:"Clear",submit:"Submit",reset:"Reset"},form:{required:"This field is required",invalid:"Invalid value",tooShort:"Value is too short (minimum {min} characters)",tooLong:"Value is too long (maximum {max} characters)",invalidEmail:"Invalid email address",invalidUrl:"Invalid URL"},pagination:{previous:"Previous",next:"Next",page:"Page {page}",of:"of {total}"}},es:{common:{loading:"Cargando...",error:"Error",retry:"Reintentar",cancel:"Cancelar",confirm:"Confirmar",close:"Cerrar",save:"Guardar",delete:"Eliminar",edit:"Editar",search:"Buscar",clear:"Limpiar",submit:"Enviar",reset:"Restablecer"},form:{required:"Este campo es obligatorio",invalid:"Valor inv\xE1lido",tooShort:"El valor es demasiado corto (m\xEDnimo {min} caracteres)",tooLong:"El valor es demasiado largo (m\xE1ximo {max} caracteres)",invalidEmail:"Direcci\xF3n de correo electr\xF3nico inv\xE1lida",invalidUrl:"URL inv\xE1lida"},pagination:{previous:"Anterior",next:"Siguiente",page:"P\xE1gina {page}",of:"de {total}"}},fr:{common:{loading:"Chargement...",error:"Erreur",retry:"R\xE9essayer",cancel:"Annuler",confirm:"Confirmer",close:"Fermer",save:"Enregistrer",delete:"Supprimer",edit:"Modifier",search:"Rechercher",clear:"Effacer",submit:"Soumettre",reset:"R\xE9initialiser"},form:{required:"Ce champ est obligatoire",invalid:"Valeur invalide",tooShort:"La valeur est trop courte (minimum {min} caract\xE8res)",tooLong:"La valeur est trop longue (maximum {max} caract\xE8res)",invalidEmail:"Adresse e-mail invalide",invalidUrl:"URL invalide"},pagination:{previous:"Pr\xE9c\xE9dent",next:"Suivant",page:"Page {page}",of:"sur {total}"}}};function ih(e={}){let{max:t=10,ttl:s=0,include:o,exclude:n,hooks:a,debug:r=!1}=e,i=new Map,c=0,p=0;function u(...h){if(r)console.log("[KeepAlive]",...h)}function d(h){if(n){if(n instanceof RegExp&&n.test(h))return!1;if(Array.isArray(n)&&n.includes(h))return!1}if(o){if(o instanceof RegExp&&!o.test(h))return!1;if(Array.isArray(o)&&!o.includes(h))return!1}return!0}function g(h){if(!s||!h.expiresAt)return!1;return Date.now()>h.expiresAt}function f(h){let m=i.get(h);if(m)m.lastAccessedAt=Date.now(),m.accessCount++,m.instance.lastAccessedAt=m.lastAccessedAt,i.delete(h),i.set(h,m),u(`Touched: ${h} (access count: ${m.accessCount})`)}function y(){if(i.size===0)return!1;let h=i.keys().next().value;if(!h)return!1;let m=i.get(h);if(m){u(`Evicting LRU: ${h}`);let T=m.instance.hooks;if(T?.onDeactivate)T.onDeactivate(m.instance);if(a?.onDeactivate)a.onDeactivate(m.instance);return i.delete(h),!0}return!1}function C(h,m,T){if(!d(m.type))return u(`Type not cacheable: ${m.type}`),m;if(i.size>=t)y();let M=Date.now(),U={instance:{...m,hooks:T||m.hooks,createdAt:m.createdAt||M,lastAccessedAt:M},accessCount:0,createdAt:M,lastAccessedAt:M,expiresAt:s?M+s:void 0};if(i.set(h,U),u(`Cached: ${h} (size: ${i.size}/${t})`),T?.onMount)T.onMount(U.instance);if(a?.onMount)a.onMount(U.instance);return U.instance}function k(h){let m=i.get(h);if(!m)return p++,u(`Miss: ${h}`),null;if(g(m))return u(`Expired: ${h}`),i.delete(h),p++,null;return c++,f(h),u(`Hit: ${h}`),m.instance}function b(h){let m=i.get(h);if(!m)return!1;if(g(m))return i.delete(h),!1;return!0}function x(h){let m=i.get(h);if(!m)return!1;u(`Removing: ${h}`);let T=m.instance.hooks;if(T?.onUnmount)T.onUnmount(m.instance);if(a?.onUnmount)a.onUnmount(m.instance);return i.delete(h)}function E(){u("Clearing cache"),i.forEach((h)=>{let m=h.instance.hooks;if(m?.onUnmount)m.onUnmount(h.instance);if(a?.onUnmount)a.onUnmount(h.instance)}),i.clear(),c=0,p=0}function A(){let h=0,m=Date.now();for(let[T,M]of i.entries())if(g(M))u(`Pruning expired: ${T}`),x(T),h++;while(i.size>t)if(y())h++;else break;if(h>0)u(`Pruned ${h} entries`);return h}function S(h){let m=k(h);if(!m)return null;u(`Activating: ${h}`);let T=m.hooks;if(T?.onActivate)T.onActivate(m);if(a?.onActivate)a.onActivate(m);if(m.state&&T?.onRestore)T.onRestore(m,m.state);return m}function V(h){let m=i.get(h);if(!m)return!1;u(`Deactivating: ${h}`);let T=m.instance,M=T.hooks;if(M?.onSave)T.state=M.onSave(T);if(M?.onDeactivate)M.onDeactivate(T);if(a?.onDeactivate)a.onDeactivate(T);return!0}function z(){let h=c+p;return{hits:c,misses:p,size:i.size,max:t,hitRate:h>0?c/h:0,keys:Array.from(i.keys())}}function B(){return Array.from(i.keys())}function K(){return i.size}return{cache:C,get:k,has:b,remove:x,clear:E,prune:A,activate:S,deactivate:V,getStats:z,keys:B,size:K}}function lh(e){let t=new Map;return{set(s,o){if(t.has(s))t.delete(s);if(t.set(s,o),t.size>e){let n=t.keys().next().value;if(n)t.delete(n)}},get(s){if(!t.has(s))return;let o=t.get(s);return t.delete(s),t.set(s,o),o},has(s){return t.has(s)},delete(s){return t.delete(s)},clear(){t.clear()},get size(){return t.size},keys(){return Array.from(t.keys())},values(){return Array.from(t.values())},forEach(s){t.forEach(s)}}}function ch(){let e=new Map;return{save(t,s){e.set(t,JSON.parse(JSON.stringify(s)))},restore(t){let s=e.get(t);return s?JSON.parse(JSON.stringify(s)):null},has(t){return e.has(t)},remove(t){return e.delete(t)},clear(){e.clear()},keys(){return Array.from(e.keys())},get size(){return e.size}}}function dh(e,t={}){let{maxSize:s=100,reset:o}=t,n=[];return{acquire(){if(n.length>0)return n.pop();return e()},release(a){if(n.length<s){if(o)o(a);n.push(a)}},clear(){n.length=0},get size(){return n.length},get maxSize(){return s}}}var W=new Map;async function ie(e,t){let s=t||e.toString();if(W.has(s))return W.get(s);let o=e();W.set(s,o);try{return await o}catch(n){throw W.delete(s),n}}function uh(e,t={}){let{retryAttempts:s=3,retryDelay:o=1000,onLoading:n,onLoaded:a,onError:r}=t,i="idle",c,p,u=async(d=0)=>{try{if(i==="loading"||i==="loaded"){if(c)return c}i="loading",n?.();let g=await ie(e);return c=g,i="loaded",a?.(g),g}catch(g){let f=g;if(d<s)return await new Promise((y)=>setTimeout(y,o*(d+1))),u(d+1);throw i="error",p=f,r?.(f),f}};return{get state(){return i},get module(){return c},get error(){return p},load:()=>u(),preload:()=>u()}}function Xa(e,t,s={}){if(!e)return console.warn("lazyLoad: element is null"),()=>{};let{root:o=null,rootMargin:n="0px",threshold:a=0.01,placeholder:r,errorContent:i,onLoading:c,onLoaded:p,onError:u}=s,d=!1,g=null;if(r)if(typeof r==="string")e.innerHTML=r;else e.innerHTML="",e.appendChild(r);return g=new IntersectionObserver(async(y)=>{for(let C of y)if(C.isIntersecting&&!d){d=!0,g?.disconnect();try{c?.();let k=await ie(t);if(p?.(k),k&&typeof k.default?.render==="function"){let b=await k.default.render();e.innerHTML=b}}catch(k){let b=k;if(u?.(b),i)if(typeof i==="string")e.innerHTML=i;else e.innerHTML="",e.appendChild(i);else e.innerHTML=`<div style="color: red;">Failed to load component: ${b.message}</div>`}}},{root:o,rootMargin:n,threshold:a}),g.observe(e),()=>{g?.disconnect(),g=null}}function hh(e,t,s={}){let o=[],n=Array.from(e);for(let a of n){let r=typeof t==="function"&&t.length>0?()=>t(a):t,i=Xa(a,r,s);o.push(i)}return()=>{o.forEach((a)=>a())}}function Qa(e){return ie(e)}function fh(e){return Promise.all(e.map((t)=>Qa(t)))}function mh(e){if(e)W.delete(e);else W.clear()}function gh(){return{size:W.size,keys:Array.from(W.keys())}}function bh(e){return{async load(t){let s=e[t];if(!s)throw Error(`No route found for path: ${t}`);return ie(s,`route:${t}`)},async preload(t){return this.load(t)},async preloadRoutes(t){return Promise.all(t.map((s)=>this.preload(s)))}}}function Za(e,t,s={}){if(!e)return()=>{};let{root:o=null,rootMargin:n="50px",threshold:a=0.01,placeholder:r,onLoading:i,onLoaded:c,onError:p}=s;if(r&&typeof r==="string")e.src=r;let u=!1,d=null;return d=new IntersectionObserver((f)=>{for(let y of f)if(y.isIntersecting&&!u)u=!0,d?.disconnect(),i?.(),e.src=t,e.addEventListener("load",()=>{c?.(e),e.classList.add("loaded")},{once:!0}),e.addEventListener("error",(C)=>{let k=Error(`Failed to load image: ${t}`);p?.(k),e.classList.add("error")},{once:!0})},{root:o,rootMargin:n,threshold:a}),d.observe(e),()=>{d?.disconnect(),d=null}}function xh(e=document,t={}){let s=e.querySelectorAll("img[data-lazy-src]"),o=[];return s.forEach((n)=>{let a=n.getAttribute("data-lazy-src");if(a){let r=Za(n,a,t);o.push(r)}}),()=>{o.forEach((n)=>n())}}var Ce={colors:{primary:"#3b82f6",secondary:"#8b5cf6",success:"#10b981",warning:"#f59e0b",danger:"#ef4444",info:"#06b6d4",gray:"#6b7280",white:"#ffffff",black:"#000000"},typography:{fontFamily:{sans:'system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif',serif:'Georgia, Cambria, "Times New Roman", Times, serif',mono:'Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace'},fontSize:{xs:"0.75rem",sm:"0.875rem",base:"1rem",lg:"1.125rem",xl:"1.25rem","2xl":"1.5rem","3xl":"1.875rem","4xl":"2.25rem"},fontWeight:{light:"300",normal:"400",medium:"500",semibold:"600",bold:"700"},lineHeight:{tight:"1.25",normal:"1.5",relaxed:"1.75"}},spacing:{xs:"0.25rem",sm:"0.5rem",md:"1rem",lg:"1.5rem",xl:"2rem","2xl":"3rem","3xl":"4rem","4xl":"6rem"},borderRadius:{none:"0",sm:"0.125rem",md:"0.375rem",lg:"0.5rem",full:"9999px"},shadows:{sm:"0 1px 2px 0 rgba(0, 0, 0, 0.05)",md:"0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06)",lg:"0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05)",xl:"0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04)","2xl":"0 25px 50px -12px rgba(0, 0, 0, 0.25)",none:"none"},components:{button:{borderRadius:"0.375rem",padding:"0.5rem 1rem",fontSize:"0.875rem",fontWeight:"500"},input:{borderRadius:"0.375rem",padding:"0.5rem 0.75rem",fontSize:"0.875rem",borderWidth:"1px"},card:{borderRadius:"0.5rem",padding:"1.5rem",shadow:"0 1px 3px 0 rgba(0, 0, 0, 0.1)"}}};function He(e,t){let s={...e};for(let o in t)if(t[o]instanceof Object&&o in e)s[o]=He(e[o],t[o]);else s[o]=t[o];return s}function Q(e){return He(Ce,e)}var le=Ce;function wh(){return le}function er(e){let t=[];if(e.colors)Object.entries(e.colors).forEach(([s,o])=>{if(o)t.push(`--color-${s}: ${o};`)});if(e.typography?.fontFamily)Object.entries(e.typography.fontFamily).forEach(([s,o])=>{if(o)t.push(`--font-${s}: ${o};`)});if(e.typography?.fontSize)Object.entries(e.typography.fontSize).forEach(([s,o])=>{if(o)t.push(`--text-${s}: ${o};`)});if(e.typography?.fontWeight)Object.entries(e.typography.fontWeight).forEach(([s,o])=>{if(o)t.push(`--font-weight-${s}: ${o};`)});if(e.typography?.lineHeight)Object.entries(e.typography.lineHeight).forEach(([s,o])=>{if(o)t.push(`--leading-${s}: ${o};`)});if(e.spacing)Object.entries(e.spacing).forEach(([s,o])=>{if(o)t.push(`--spacing-${s}: ${o};`)});if(e.borderRadius)Object.entries(e.borderRadius).forEach(([s,o])=>{if(o)t.push(`--radius-${s}: ${o};`)});if(e.shadows)Object.entries(e.shadows).forEach(([s,o])=>{if(o)t.push(`--shadow-${s}: ${o};`)});if(e.components?.button)Object.entries(e.components.button).forEach(([s,o])=>{if(o)t.push(`--button-${s.replace(/([A-Z])/g,"-$1").toLowerCase()}: ${o};`)});if(e.components?.input)Object.entries(e.components.input).forEach(([s,o])=>{if(o)t.push(`--input-${s.replace(/([A-Z])/g,"-$1").toLowerCase()}: ${o};`)});if(e.components?.card)Object.entries(e.components.card).forEach(([s,o])=>{if(o)t.push(`--card-${s.replace(/([A-Z])/g,"-$1").toLowerCase()}: ${o};`)});return`:root {
|
|
23
23
|
${t.join(`
|
|
24
24
|
`)}
|
|
25
|
-
}`}function yh(e,t){if(le=e,typeof document>"u")return;let s=t||document.documentElement;if(e.colors)Object.entries(e.colors).forEach(([o,n])=>{if(n)s.style.setProperty(`--color-${o}`,n)});if(e.typography?.fontFamily)Object.entries(e.typography.fontFamily).forEach(([o,n])=>{if(n)s.style.setProperty(`--font-${o}`,n)});if(e.typography?.fontSize)Object.entries(e.typography.fontSize).forEach(([o,n])=>{if(n)s.style.setProperty(`--text-${o}`,n)});if(e.typography?.fontWeight)Object.entries(e.typography.fontWeight).forEach(([o,n])=>{if(n)s.style.setProperty(`--font-weight-${o}`,n)});if(e.typography?.lineHeight)Object.entries(e.typography.lineHeight).forEach(([o,n])=>{if(n)s.style.setProperty(`--leading-${o}`,n)});if(e.spacing)Object.entries(e.spacing).forEach(([o,n])=>{if(n)s.style.setProperty(`--spacing-${o}`,n)});if(e.borderRadius)Object.entries(e.borderRadius).forEach(([o,n])=>{if(n)s.style.setProperty(`--radius-${o}`,n)});if(e.shadows)Object.entries(e.shadows).forEach(([o,n])=>{if(n)s.style.setProperty(`--shadow-${o}`,n)});if(e.components?.button)Object.entries(e.components.button).forEach(([o,n])=>{if(n)s.style.setProperty(`--button-${o.replace(/([A-Z])/g,"-$1").toLowerCase()}`,n)});if(e.components?.input)Object.entries(e.components.input).forEach(([o,n])=>{if(n)s.style.setProperty(`--input-${o.replace(/([A-Z])/g,"-$1").toLowerCase()}`,n)});if(e.components?.card)Object.entries(e.components.card).forEach(([o,n])=>{if(n)s.style.setProperty(`--card-${o.replace(/([A-Z])/g,"-$1").toLowerCase()}`,n)})}function kh(){return le}function Ch(e){let t=e.split("."),s=le;for(let o of t)if(s&&typeof s==="object"&&o in s)s=s[o];else return;return s}var $h={default:Ce,purple:Q({colors:{primary:"#8b5cf6",secondary:"#a78bfa"}}),green:Q({colors:{primary:"#10b981",secondary:"#34d399"}}),orange:Q({colors:{primary:"#f97316",secondary:"#fb923c"}}),dark:Q({colors:{primary:"#60a5fa",secondary:"#a78bfa",gray:"#9ca3af",white:"#1f2937",black:"#f9fafb"}}),minimal:Q({borderRadius:{none:"0",sm:"0",md:"0.125rem",lg:"0.25rem",full:"0.25rem"},shadows:{sm:"none",md:"0 1px 2px 0 rgba(0, 0, 0, 0.05)",lg:"0 1px 3px 0 rgba(0, 0, 0, 0.1)",xl:"0 4px 6px -1px rgba(0, 0, 0, 0.1)","2xl":"0 10px 15px -3px rgba(0, 0, 0, 0.1)",none:"none"}})};function Sh(e){return er(e)}var sr="./ChatInbox-wpg039q7.stx";var nr="./ChatMessage-rj37tdgn.stx";import{derived as ce,effect as ar,state as D}from"@stacksjs/stx";import{useBroadcastStream as rr}from"@stacksjs/stx/composables/use-broadcast-stream";function Lh(e){let t=e.endpoint??"/messages",s=D([]),o=D([]),n=D(null),a=D(""),r=D([]),i=D(!1),c=D(!1),p=D(!1),u=D(""),d=D(""),g=D(""),f=D(!1),y=D(!1),C=D(4000),k=D(!1),b=new Set,x=null,E=null,A="",S=0,V=new Map,z=null,B=!1,K=0;function h(){S++,s.set([]),o.set([]),n.set(null),a.set(""),r.set([]),d.set(""),u.set(""),i.set(!1),c.set(!1),p.set(!1),V=new Map,z=null,K=0,y.set(!1),x?.close(),x=null}function m(){let w=e.scopeKey();if(w!==A)h(),A=w;return qe(),S}async function T(w,v){let I=await e.request(`${t}${w}`,{...v,cache:"no-store"}),P=await I.json().catch(()=>({}));if(!I.ok)throw Error(P.error||"Could not load messages. Try again.");return P}let M=ce(()=>{let w=g().toLowerCase().trim();return s().map((v)=>({...v,conversation:o().find((I)=>I.recipient_id===v.id)})).filter((v)=>(!w||`${v.name} ${v.role}`.toLowerCase().includes(w))&&(!f()||(v.conversation?.unread??0)>0)).sort((v,I)=>(I.conversation?.last_message?.id??0)-(v.conversation?.last_message?.id??0)||v.name.localeCompare(I.name))}),U=ce(()=>o().reduce((w,v)=>w+v.unread,0)),$e=ce(()=>!!a()&&!!d().trim()&&d().trim().length<=C()&&!p()&&!c()),Fe=ce(e.selfId);function G(w){u.set(w instanceof Error?w.message:"Could not load messages. Try again.")}async function de(w,v,I=!0){let P=await T(`/conversations/${v}`);if(w!==S||v!==a()||e.scopeKey()!==A)return;let j=P.messages[0]?.id;if(r.set([...r().filter((me)=>j&&me.id<j),...P.messages]),r().length===P.messages.length)y.set(P.has_more);let ee=P.messages.at(-1);if(I&&ee){if(await T(`/conversations/${v}/read`,{method:"POST",body:JSON.stringify({through_id:ee.id})}),w===S&&v===a())o.update((me)=>me.map((ge)=>ge.id===v?{...ge,unread:0}:ge))}}async function pe(){let w=m();i.set(!0),u.set("");try{let v=await T("");if(w!==S||e.scopeKey()!==A)return;s.set(v.contacts),o.set(v.conversations),C.set(v.max_length),i.set(!1);let I=n()?v.contacts.find((j)=>j.id===n().id):null;if(n()&&!I){let j=n().id;Se(),V.delete(j),d.set(""),z=null}else if(I)n.set(I);let P=e.initialRecipient?.()??0;if(P>0&&P!==K){let j=v.contacts.find((ee)=>ee.id===P);if(j)K=P,await ue(j)}}catch(v){if(w===S)G(v)}finally{if(w===S)i.set(!1)}}async function ue(w){if(m(),n())V.set(n().id,d());let v=++S;p.set(!1),n.set(w),d.set(V.get(w.id)??""),a.set(""),r.set([]),y.set(!1),u.set(""),c.set(!0);try{let I=await T("/conversations",{method:"POST",body:JSON.stringify({recipient_id:w.id})});if(v!==S||e.scopeKey()!==A)return;a.set(I.id),await de(v,I.id)}catch(I){if(v===S)G(I)}finally{if(v===S)c.set(!1);Z()}}function Se(){if(n())V.set(n().id,d());S++,p.set(!1),c.set(!1),n.set(null),a.set(""),r.set([]),u.set("")}async function Ve(){if(m(),!$e())return;let w=a(),v=d().trim(),I=S,P=z?.body===v&&z.thread===w?z.key:crypto.randomUUID();z={body:v,key:P,thread:w},p.set(!0),u.set("");try{if(await T(`/conversations/${w}/messages`,{method:"POST",body:JSON.stringify({body:v,client_key:P})}),I!==S||e.scopeKey()!==A)return;if(d().trim()===v)d.set("");V.delete(n().id),z=null,await de(I,w),await pe()}catch(j){if(I===S)G(j)}finally{if(I===S)p.set(!1);Z()}}async function Be(){let w=a(),v=r()[0]?.id,I=S;if(!w||!v||c())return;c.set(!0);try{let P=await T(`/conversations/${w}?before=${v}`);if(I===S&&w===a())r.set([...P.messages,...r()]),y.set(P.has_more)}catch(P){if(I===S)G(P)}finally{if(I===S)c.set(!1);Z()}}async function Te(w=!1){if(B||p()||c())return;B=!0;try{if(await pe(),w&&n()&&!a())await ue(n());else if(w&&a())await de(S,a())}catch(v){G(v)}finally{B=!1,Z()}}let he=!1;async function fe(){if(B||p()||c()){he=!0;return}await Te([...b].some((w)=>w()))}function qe(){if(x||!b.size||!e.selfId()||!e.broadcastEndpoint)return;let w=A;x=rr({endpoint:e.broadcastEndpoint,request:e.request,onStatus:(v)=>k.set(v),onConnected:()=>{if(w===e.scopeKey())fe()},onMessage:(v)=>{if(w===e.scopeKey()&&v.event.startsWith("messaging."))fe()}})}function We(w=()=>!1){if(b.add(w),m(),!E)E=ar(()=>{m()});return()=>{if(b.delete(w),!b.size)x?.close(),x=null,E?.(),E=null}}function Z(){if(he)he=!1,fe()}return{contacts:s,conversations:o,selected:n,threadId:a,messages:r,loading:i,threadLoading:c,sending:p,error:u,draft:d,search:g,unreadOnly:f,hasMore:y,maxLength:C,rows:M,unread:U,canSend:$e,selfId:Fe,load:pe,open:ue,back:Se,send:Ve,older:Be,refresh:Te,reset:h,observe:We,connected:k}}var lr="./ChatUnreadBadge-3vq0t8d2.stx";var dr="./ChatLauncher-3zph4trh.stx";export{et as Accordion,st as AccordionItem,zu as AnimationClasses,nt as Audio,ut as Avatar,ft as Badge,gt as Breadcrumb,X as Breakpoints,yt as Button,$t as Calendar,Ot as Card,sr as ChatInbox,dr as ChatLauncher,nr as ChatMessage,lr as ChatUnreadBadge,Dt as Checkbox,bo as Checkout,Ke as CodeBlock,Rt as Combobox,jt as ComboboxButton,Ft as ComboboxInput,Bt as ComboboxOption,Wt as ComboboxOptions,_t as CommandPalette,Jt as CommandPaletteItem,R as ComponentError,Tt as DateRangePicker,vo as DefaultPaymentMethod,Yt as Dialog,Qt as DialogBackdrop,es as DialogDescription,ss as DialogPanel,ns as DialogTitle,rs as Drawer,ls as Dropdown,ds as DropdownButton,us as DropdownItem,fs as DropdownItems,Ou as Easing,ys as EmailInput,It as EmptyState,J as ErrorTypes,_s as FilterChip,Js as FilterChips,_e as Footer,gs as Form,Ue as Hero,vs as Image,Je as Installation,wu as KeyboardKeys,Ir as KeyboardShortcuts,Wa as KeyframeAnimations,Ys as ListRow,Rs as Listbox,js as ListboxButton,Fs as ListboxLabel,Bs as ListboxOption,Ws as ListboxOptions,rt as Login,Qs as NavBar,ro as Navigator,lo as Notification,Cs as NumberInput,po as Pager,ho as PagerDots,mo as Pagination,Ss as PasswordInput,yo as PaymentMethods,So as Popover,Eo as PopoverButton,Ao as PopoverPanel,Lo as Portal,No as Progress,l as PropTypes,Mo as Radio,zo as RadioGroup,Ho as RadioGroupDescription,Vo as RadioGroupLabel,qo as RadioGroupOption,qr as SHADE_VAR_PREFIX,Es as SearchInput,eo as SectionCard,Ko as Select,Uo as Sidebar,Go as SidebarFooter,Xo as SidebarHeader,Zo as SidebarItem,tn as SidebarPinned,on as SidebarSection,an as SidebarSpace,dn as SidebarSpaceSwitcher,ln as SidebarSpaces,lt as Signup,kn as Skeleton,$n as Spinner,Tn as Stepper,In as StepperStep,ae as StorageManager,Co as SubscriptionCheckout,Pn as Switch,Ee as THEMED_FAMILIES,Wn as Tab,so as TabBar,no as TabBarItem,_n as TabList,Jn as TabPanel,On as Table,Dn as TableBody,Rn as TableCell,jn as TableHead,Fn as TableHeader,Bn as TableRow,Yn as Tabs,Qn as Teleport,As as TextInput,ea as Textarea,Pt as ThemeToggle,sa as Tooltip,na as Transition,dt as TwoFactorChallenge,ra as Video,la as VirtualList,da as VirtualTable,Vu as animate,ju as animateWithClass,bu as announceToScreenReader,De as applyAnimation,Ku as applyHeadwindClasses,yh as applyTheme,$u as aria,bt as assert,Ci as assertProp,kt as buttonPropSchema,xi as clearErrorHandler,mh as clearModuleCache,Hr as closeOverlay,ah as componentMessages,gr as copyToClipboard,gu as createAriaDescription,mu as createAriaLabel,Lh as createChat,dh as createComponentPool,wi as createDebugger,xu as createFocusTrap,Uu as createI18n,ih as createKeepAlive,qa as createKeyframeAnimation,Hu as createKeyframes,lh as createLRUCache,H as createPropValidator,bh as createRouteLoader,vu as createRovingTabindex,Pi as createSafeClickHandler,Su as createScreenReaderText,Au as createSkipLink,ch as createStateManager,yp as createStorage,Q as createTheme,Va as cssAnimation,Qu as d,th as dateTimeFormats,Ce as defaultTheme,Pe as deriveSpaceTint,Wu as detectLanguage,vi as devAssert,za as easeInBack,Ne as easeInBounce,La as easeInCirc,ga as easeInCubic,Da as easeInElastic,Ia as easeInExpo,Ha as easeInOutBack,Fa as easeInOutBounce,Na as easeInOutCirc,xa as easeInOutCubic,Ra as easeInOutElastic,Pa as easeInOutExpo,ma as easeInOutQuad,ya as easeInOutQuart,$a as easeInOutQuint,Ea as easeInOutSine,ha as easeInQuad,va as easeInQuart,ka as easeInQuint,Sa as easeInSine,ja as easeOutBack,ve as easeOutBounce,Oa as easeOutCirc,ba as easeOutCubic,Ma as easeOutElastic,Aa as easeOutExpo,fa as easeOutQuad,wa as easeOutQuart,Ca as easeOutQuint,Ta as easeOutSine,yi as errorBoundary,bs as formPropSchema,Oe as generateId,yr as generateSEOTags,Sh as generateThemeCSS,gh as getCacheStats,Iu as getColorSchemePreference,be as getEffectiveTheme,xe as getFocusableElements,_a as getHighlighter,Gu as getI18n,Ge as getSystemTheme,wh as getTheme,Ch as getThemeValue,oe as handleError,yu as hasFocus,qu as highlight,oh as isRTL,Fr as isTopOverlay,Cu as isVisibleToScreenReader,Xa as lazyLoad,hh as lazyLoadAll,uh as lazyLoadComponent,Za as lazyLoadImage,xh as lazyLoadImages,ie as lazyLoadModule,ua as linear,nh as loadLocaleMessages,ne as macosColors,ku as moveFocus,Zu as n,wn as normalizeSpace,_d as normalizeSpaces,sh as numberFormats,Os as numberInputPropSchema,jr as openOverlay,Vr as openOverlays,eh as pluralRules,Eu as prefersHighContrast,Tu as prefersReducedMotion,Qa as preloadModule,fh as preloadModules,Du as removeAnimation,Bd as resolveIconColor,Vd as resolveSidebarTheme,xn as resolveSpaceTint,Ru as sequenceAnimations,bi as setErrorHandler,Ju as setI18n,Xe as setLink,O as setMeta,Ye as setTitle,Ae as sidebarThemes,Ud as spaceIndexOf,Jd as spaceTintPayload,vn as spaceTintVars,Kd as spaceWashGradient,Mu as staggerAnimation,wp as storage,Wr as stxThemePreset,Yu as t,Xu as tc,Ls as textInputPropSchema,$h as themePresets,er as themeToCSSProperties,Kr as themeVariableNames,Or as useBreakpoint,Cr as useClickOutside,mr as useCopyCode,xr as useDarkMode,Sr as useFocusTrap,Mr as useIsDarkMode,Dr as useIsDesktop,Nr as useIsMobile,Er as useKeyboard,Pr as useLocalStorage,Y as useMediaQuery,Rr as usePrefersReducedMotion,wr as useSEO,kh as useTheme,Pu as validateAriaRelationships,Ai as validateButtonProps,Zl as validateEmailInputProps,Fl as validateFormProps,tc as validateNumberInputProps,ec as validatePasswordInputProps,vt as validateProps,sc as validateSearchInputProps,Oi as validateSize,Ql as validateTextInputProps,Li as validateVariant,Ba as waitForAnimation,xt as warn,$i as warnProp,Ie as wrapErrorHandler};
|
|
25
|
+
}`}function yh(e,t){if(le=e,typeof document>"u")return;let s=t||document.documentElement;if(e.colors)Object.entries(e.colors).forEach(([o,n])=>{if(n)s.style.setProperty(`--color-${o}`,n)});if(e.typography?.fontFamily)Object.entries(e.typography.fontFamily).forEach(([o,n])=>{if(n)s.style.setProperty(`--font-${o}`,n)});if(e.typography?.fontSize)Object.entries(e.typography.fontSize).forEach(([o,n])=>{if(n)s.style.setProperty(`--text-${o}`,n)});if(e.typography?.fontWeight)Object.entries(e.typography.fontWeight).forEach(([o,n])=>{if(n)s.style.setProperty(`--font-weight-${o}`,n)});if(e.typography?.lineHeight)Object.entries(e.typography.lineHeight).forEach(([o,n])=>{if(n)s.style.setProperty(`--leading-${o}`,n)});if(e.spacing)Object.entries(e.spacing).forEach(([o,n])=>{if(n)s.style.setProperty(`--spacing-${o}`,n)});if(e.borderRadius)Object.entries(e.borderRadius).forEach(([o,n])=>{if(n)s.style.setProperty(`--radius-${o}`,n)});if(e.shadows)Object.entries(e.shadows).forEach(([o,n])=>{if(n)s.style.setProperty(`--shadow-${o}`,n)});if(e.components?.button)Object.entries(e.components.button).forEach(([o,n])=>{if(n)s.style.setProperty(`--button-${o.replace(/([A-Z])/g,"-$1").toLowerCase()}`,n)});if(e.components?.input)Object.entries(e.components.input).forEach(([o,n])=>{if(n)s.style.setProperty(`--input-${o.replace(/([A-Z])/g,"-$1").toLowerCase()}`,n)});if(e.components?.card)Object.entries(e.components.card).forEach(([o,n])=>{if(n)s.style.setProperty(`--card-${o.replace(/([A-Z])/g,"-$1").toLowerCase()}`,n)})}function kh(){return le}function Ch(e){let t=e.split("."),s=le;for(let o of t)if(s&&typeof s==="object"&&o in s)s=s[o];else return;return s}var $h={default:Ce,purple:Q({colors:{primary:"#8b5cf6",secondary:"#a78bfa"}}),green:Q({colors:{primary:"#10b981",secondary:"#34d399"}}),orange:Q({colors:{primary:"#f97316",secondary:"#fb923c"}}),dark:Q({colors:{primary:"#60a5fa",secondary:"#a78bfa",gray:"#9ca3af",white:"#1f2937",black:"#f9fafb"}}),minimal:Q({borderRadius:{none:"0",sm:"0",md:"0.125rem",lg:"0.25rem",full:"0.25rem"},shadows:{sm:"none",md:"0 1px 2px 0 rgba(0, 0, 0, 0.05)",lg:"0 1px 3px 0 rgba(0, 0, 0, 0.1)",xl:"0 4px 6px -1px rgba(0, 0, 0, 0.1)","2xl":"0 10px 15px -3px rgba(0, 0, 0, 0.1)",none:"none"}})};function Sh(e){return er(e)}var sr="./ChatInbox-cbbb5x1n.stx";var nr="./ChatMessage-rj37tdgn.stx";function Ah(e,t=""){if(!e)return"";let s=e;if(typeof s.href==="string"&&s.href)return s.href;if(!t)return"";let o=!1,n=t.replace(/\{(\w+)\}/g,(a,r)=>{let i=s[r];if(i==null||i==="")return o=!0,"";return encodeURIComponent(String(i))});return o?"":n}import{derived as ce,effect as ar,state as D}from"@stacksjs/stx";import{useBroadcastStream as rr}from"@stacksjs/stx/composables/use-broadcast-stream";function Nh(e){let t=e.endpoint??"/messages",s=D([]),o=D([]),n=D(null),a=D(""),r=D([]),i=D(!1),c=D(!1),p=D(!1),u=D(""),d=D(""),g=D(""),f=D(!1),y=D(!1),C=D(4000),k=D(!1),b=new Set,x=null,E=null,A="",S=0,V=new Map,z=null,B=!1,K=0;function h(){S++,s.set([]),o.set([]),n.set(null),a.set(""),r.set([]),d.set(""),u.set(""),i.set(!1),c.set(!1),p.set(!1),V=new Map,z=null,K=0,y.set(!1),x?.close(),x=null}function m(){let w=e.scopeKey();if(w!==A)h(),A=w;return qe(),S}async function T(w,v){let I=await e.request(`${t}${w}`,{...v,cache:"no-store"}),P=await I.json().catch(()=>({}));if(!I.ok)throw Error(P.error||"Could not load messages. Try again.");return P}let M=ce(()=>{let w=g().toLowerCase().trim();return s().map((v)=>({...v,conversation:o().find((I)=>I.recipient_id===v.id)})).filter((v)=>(!w||`${v.name} ${v.role}`.toLowerCase().includes(w))&&(!f()||(v.conversation?.unread??0)>0)).sort((v,I)=>(I.conversation?.last_message?.id??0)-(v.conversation?.last_message?.id??0)||v.name.localeCompare(I.name))}),U=ce(()=>o().reduce((w,v)=>w+v.unread,0)),$e=ce(()=>!!a()&&!!d().trim()&&d().trim().length<=C()&&!p()&&!c()),Fe=ce(e.selfId);function G(w){u.set(w instanceof Error?w.message:"Could not load messages. Try again.")}async function de(w,v,I=!0){let P=await T(`/conversations/${v}`);if(w!==S||v!==a()||e.scopeKey()!==A)return;let j=P.messages[0]?.id;if(r.set([...r().filter((me)=>j&&me.id<j),...P.messages]),r().length===P.messages.length)y.set(P.has_more);let ee=P.messages.at(-1);if(I&&ee){if(await T(`/conversations/${v}/read`,{method:"POST",body:JSON.stringify({through_id:ee.id})}),w===S&&v===a())o.update((me)=>me.map((ge)=>ge.id===v?{...ge,unread:0}:ge))}}async function pe(){let w=m();i.set(!0),u.set("");try{let v=await T("");if(w!==S||e.scopeKey()!==A)return;s.set(v.contacts),o.set(v.conversations),C.set(v.max_length),i.set(!1);let I=n()?v.contacts.find((j)=>j.id===n().id):null;if(n()&&!I){let j=n().id;Se(),V.delete(j),d.set(""),z=null}else if(I)n.set(I);let P=e.initialRecipient?.()??0;if(P>0&&P!==K){let j=v.contacts.find((ee)=>ee.id===P);if(j)K=P,await ue(j)}}catch(v){if(w===S)G(v)}finally{if(w===S)i.set(!1)}}async function ue(w){if(m(),n())V.set(n().id,d());let v=++S;p.set(!1),n.set(w),d.set(V.get(w.id)??""),a.set(""),r.set([]),y.set(!1),u.set(""),c.set(!0);try{let I=await T("/conversations",{method:"POST",body:JSON.stringify({recipient_id:w.id})});if(v!==S||e.scopeKey()!==A)return;a.set(I.id),await de(v,I.id)}catch(I){if(v===S)G(I)}finally{if(v===S)c.set(!1);Z()}}function Se(){if(n())V.set(n().id,d());S++,p.set(!1),c.set(!1),n.set(null),a.set(""),r.set([]),u.set("")}async function Ve(){if(m(),!$e())return;let w=a(),v=d().trim(),I=S,P=z?.body===v&&z.thread===w?z.key:crypto.randomUUID();z={body:v,key:P,thread:w},p.set(!0),u.set("");try{if(await T(`/conversations/${w}/messages`,{method:"POST",body:JSON.stringify({body:v,client_key:P})}),I!==S||e.scopeKey()!==A)return;if(d().trim()===v)d.set("");V.delete(n().id),z=null,await de(I,w),await pe()}catch(j){if(I===S)G(j)}finally{if(I===S)p.set(!1);Z()}}async function Be(){let w=a(),v=r()[0]?.id,I=S;if(!w||!v||c())return;c.set(!0);try{let P=await T(`/conversations/${w}?before=${v}`);if(I===S&&w===a())r.set([...P.messages,...r()]),y.set(P.has_more)}catch(P){if(I===S)G(P)}finally{if(I===S)c.set(!1);Z()}}async function Te(w=!1){if(B||p()||c())return;B=!0;try{if(await pe(),w&&n()&&!a())await ue(n());else if(w&&a())await de(S,a())}catch(v){G(v)}finally{B=!1,Z()}}let he=!1;async function fe(){if(B||p()||c()){he=!0;return}await Te([...b].some((w)=>w()))}function qe(){if(x||!b.size||!e.selfId()||!e.broadcastEndpoint)return;let w=A;x=rr({endpoint:e.broadcastEndpoint,request:e.request,onStatus:(v)=>k.set(v),onConnected:()=>{if(w===e.scopeKey())fe()},onMessage:(v)=>{if(w===e.scopeKey()&&v.event.startsWith("messaging."))fe()}})}function We(w=()=>!1){if(b.add(w),m(),!E)E=ar(()=>{m()});return()=>{if(b.delete(w),!b.size)x?.close(),x=null,E?.(),E=null}}function Z(){if(he)he=!1,fe()}return{contacts:s,conversations:o,selected:n,threadId:a,messages:r,loading:i,threadLoading:c,sending:p,error:u,draft:d,search:g,unreadOnly:f,hasMore:y,maxLength:C,rows:M,unread:U,canSend:$e,selfId:Fe,load:pe,open:ue,back:Se,send:Ve,older:Be,refresh:Te,reset:h,observe:We,connected:k}}var lr="./ChatUnreadBadge-3vq0t8d2.stx";var dr="./ChatLauncher-3zph4trh.stx";export{et as Accordion,st as AccordionItem,zu as AnimationClasses,nt as Audio,ut as Avatar,ft as Badge,gt as Breadcrumb,X as Breakpoints,yt as Button,$t as Calendar,Ot as Card,sr as ChatInbox,dr as ChatLauncher,nr as ChatMessage,lr as ChatUnreadBadge,Dt as Checkbox,bo as Checkout,Ke as CodeBlock,Rt as Combobox,jt as ComboboxButton,Ft as ComboboxInput,Bt as ComboboxOption,Wt as ComboboxOptions,_t as CommandPalette,Jt as CommandPaletteItem,R as ComponentError,Tt as DateRangePicker,vo as DefaultPaymentMethod,Yt as Dialog,Qt as DialogBackdrop,es as DialogDescription,ss as DialogPanel,ns as DialogTitle,rs as Drawer,ls as Dropdown,ds as DropdownButton,us as DropdownItem,fs as DropdownItems,Ou as Easing,ys as EmailInput,It as EmptyState,J as ErrorTypes,_s as FilterChip,Js as FilterChips,_e as Footer,gs as Form,Ue as Hero,vs as Image,Je as Installation,wu as KeyboardKeys,Ir as KeyboardShortcuts,Wa as KeyframeAnimations,Ys as ListRow,Rs as Listbox,js as ListboxButton,Fs as ListboxLabel,Bs as ListboxOption,Ws as ListboxOptions,rt as Login,Qs as NavBar,ro as Navigator,lo as Notification,Cs as NumberInput,po as Pager,ho as PagerDots,mo as Pagination,Ss as PasswordInput,yo as PaymentMethods,So as Popover,Eo as PopoverButton,Ao as PopoverPanel,Lo as Portal,No as Progress,l as PropTypes,Mo as Radio,zo as RadioGroup,Ho as RadioGroupDescription,Vo as RadioGroupLabel,qo as RadioGroupOption,qr as SHADE_VAR_PREFIX,Es as SearchInput,eo as SectionCard,Ko as Select,Uo as Sidebar,Go as SidebarFooter,Xo as SidebarHeader,Zo as SidebarItem,tn as SidebarPinned,on as SidebarSection,an as SidebarSpace,dn as SidebarSpaceSwitcher,ln as SidebarSpaces,lt as Signup,kn as Skeleton,$n as Spinner,Tn as Stepper,In as StepperStep,ae as StorageManager,Co as SubscriptionCheckout,Pn as Switch,Ee as THEMED_FAMILIES,Wn as Tab,so as TabBar,no as TabBarItem,_n as TabList,Jn as TabPanel,On as Table,Dn as TableBody,Rn as TableCell,jn as TableHead,Fn as TableHeader,Bn as TableRow,Yn as Tabs,Qn as Teleport,As as TextInput,ea as Textarea,Pt as ThemeToggle,sa as Tooltip,na as Transition,dt as TwoFactorChallenge,ra as Video,la as VirtualList,da as VirtualTable,Vu as animate,ju as animateWithClass,bu as announceToScreenReader,De as applyAnimation,Ku as applyHeadwindClasses,yh as applyTheme,$u as aria,bt as assert,Ci as assertProp,kt as buttonPropSchema,xi as clearErrorHandler,mh as clearModuleCache,Hr as closeOverlay,ah as componentMessages,Ah as contactLink,gr as copyToClipboard,gu as createAriaDescription,mu as createAriaLabel,Nh as createChat,dh as createComponentPool,wi as createDebugger,xu as createFocusTrap,Uu as createI18n,ih as createKeepAlive,qa as createKeyframeAnimation,Hu as createKeyframes,lh as createLRUCache,H as createPropValidator,bh as createRouteLoader,vu as createRovingTabindex,Pi as createSafeClickHandler,Su as createScreenReaderText,Au as createSkipLink,ch as createStateManager,yp as createStorage,Q as createTheme,Va as cssAnimation,Qu as d,th as dateTimeFormats,Ce as defaultTheme,Pe as deriveSpaceTint,Wu as detectLanguage,vi as devAssert,za as easeInBack,Ne as easeInBounce,La as easeInCirc,ga as easeInCubic,Da as easeInElastic,Ia as easeInExpo,Ha as easeInOutBack,Fa as easeInOutBounce,Na as easeInOutCirc,xa as easeInOutCubic,Ra as easeInOutElastic,Pa as easeInOutExpo,ma as easeInOutQuad,ya as easeInOutQuart,$a as easeInOutQuint,Ea as easeInOutSine,ha as easeInQuad,va as easeInQuart,ka as easeInQuint,Sa as easeInSine,ja as easeOutBack,ve as easeOutBounce,Oa as easeOutCirc,ba as easeOutCubic,Ma as easeOutElastic,Aa as easeOutExpo,fa as easeOutQuad,wa as easeOutQuart,Ca as easeOutQuint,Ta as easeOutSine,yi as errorBoundary,bs as formPropSchema,Oe as generateId,yr as generateSEOTags,Sh as generateThemeCSS,gh as getCacheStats,Iu as getColorSchemePreference,be as getEffectiveTheme,xe as getFocusableElements,_a as getHighlighter,Gu as getI18n,Ge as getSystemTheme,wh as getTheme,Ch as getThemeValue,oe as handleError,yu as hasFocus,qu as highlight,oh as isRTL,Fr as isTopOverlay,Cu as isVisibleToScreenReader,Xa as lazyLoad,hh as lazyLoadAll,uh as lazyLoadComponent,Za as lazyLoadImage,xh as lazyLoadImages,ie as lazyLoadModule,ua as linear,nh as loadLocaleMessages,ne as macosColors,ku as moveFocus,Zu as n,wn as normalizeSpace,_d as normalizeSpaces,sh as numberFormats,Os as numberInputPropSchema,jr as openOverlay,Vr as openOverlays,eh as pluralRules,Eu as prefersHighContrast,Tu as prefersReducedMotion,Qa as preloadModule,fh as preloadModules,Du as removeAnimation,Bd as resolveIconColor,Vd as resolveSidebarTheme,xn as resolveSpaceTint,Ru as sequenceAnimations,bi as setErrorHandler,Ju as setI18n,Xe as setLink,O as setMeta,Ye as setTitle,Ae as sidebarThemes,Ud as spaceIndexOf,Jd as spaceTintPayload,vn as spaceTintVars,Kd as spaceWashGradient,Mu as staggerAnimation,wp as storage,Wr as stxThemePreset,Yu as t,Xu as tc,Ls as textInputPropSchema,$h as themePresets,er as themeToCSSProperties,Kr as themeVariableNames,Or as useBreakpoint,Cr as useClickOutside,mr as useCopyCode,xr as useDarkMode,Sr as useFocusTrap,Mr as useIsDarkMode,Dr as useIsDesktop,Nr as useIsMobile,Er as useKeyboard,Pr as useLocalStorage,Y as useMediaQuery,Rr as usePrefersReducedMotion,wr as useSEO,kh as useTheme,Pu as validateAriaRelationships,Ai as validateButtonProps,Zl as validateEmailInputProps,Fl as validateFormProps,tc as validateNumberInputProps,ec as validatePasswordInputProps,vt as validateProps,sc as validateSearchInputProps,Oi as validateSize,Ql as validateTextInputProps,Li as validateVariant,Ba as waitForAnimation,xt as warn,$i as warnProp,Ie as wrapErrorHandler};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Where a chat contact's face and name lead, or '' for nowhere.
|
|
3
|
+
*
|
|
4
|
+
* A contact's own `href` wins. Otherwise `template` is a URL with `{field}`
|
|
5
|
+
* placeholders filled (URL-encoded) from the contact, e.g. "/people/{username}".
|
|
6
|
+
* A placeholder whose field is empty means that contact gets no link, so an app
|
|
7
|
+
* can send a handle only for the people whose page it may show.
|
|
8
|
+
*/
|
|
9
|
+
export declare function contactLink(person: object | null | undefined, template?: string): string;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { DerivedSignal, Signal } from '@stacksjs/stx';
|
|
2
2
|
/** Transport-injected messaging state shared by any STX app. */
|
|
3
3
|
export declare function createChat(options: ChatOptions): ChatController;
|
|
4
|
-
export declare interface ChatContact { id: number, name: string, role: string, avatar?: string | null }
|
|
4
|
+
export declare interface ChatContact { id: number, name: string, role: string, avatar?: string | null, href?: string | null }
|
|
5
5
|
export declare interface ChatMessage { id: number, sender_id: number, body: string, created_at: string, read_at: string | null, client_key: string }
|
|
6
6
|
export declare interface ChatConversation { id: string, recipient_id: number, unread: number, last_message: ChatMessage | null }
|
|
7
7
|
export declare interface ChatOptions {
|
package/dist/ui/chat/index.d.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
export declare interface ChatInboxProps { store?: string, compact?: boolean, active?: boolean, className?: string }
|
|
1
|
+
export declare interface ChatInboxProps { store?: string, compact?: boolean, active?: boolean, className?: string, contactHref?: string }
|
|
2
2
|
export declare interface ChatMessageProps { body?: string, author?: string, time?: string, outgoing?: boolean, className?: string }
|
|
3
3
|
export declare interface ChatLauncherProps { store?: string, href?: string, placement?: 'floating' | 'inline', className?: string }
|
|
4
4
|
export { default as ChatInbox } from './ChatInbox.stx';
|
|
5
5
|
export { default as ChatMessage } from './ChatMessage.stx';
|
|
6
|
+
export * from './contact-link';
|
|
6
7
|
export * from './controller';
|
|
7
8
|
export { default as ChatUnreadBadge } from './ChatUnreadBadge.stx';
|
|
8
9
|
export { default as ChatLauncher } from './ChatLauncher.stx';
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stacksjs/components",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.2.
|
|
4
|
+
"version": "0.2.517",
|
|
5
5
|
"description": "A modern component library built with STX, featuring headwind utility classes and TypeScript syntax highlighting.",
|
|
6
6
|
"author": "Chris Breuer <chris@stacksjs.org>",
|
|
7
7
|
"license": "MIT",
|
|
@@ -77,8 +77,8 @@
|
|
|
77
77
|
"dependencies": {
|
|
78
78
|
"@iconify-json/f7": "^1.2.2",
|
|
79
79
|
"@stacksjs/ts-css": "^0.3.11",
|
|
80
|
-
"@stacksjs/stx": "0.2.
|
|
81
|
-
"bun-plugin-stx": "0.2.
|
|
80
|
+
"@stacksjs/stx": "0.2.517",
|
|
81
|
+
"bun-plugin-stx": "0.2.517",
|
|
82
82
|
"ts-syntax-highlighter": "^0.2.17"
|
|
83
83
|
},
|
|
84
84
|
"devDependencies": {
|
|
@@ -7,11 +7,16 @@ export const sizeClasses = compact ? 'min-h-[340px] h-[min(560px,calc(100dvh-230
|
|
|
7
7
|
export const selectedInboxClass = 'hidden'
|
|
8
8
|
export const backButtonClass = ''
|
|
9
9
|
export const inboxWidth = 'w-full'
|
|
10
|
+
// Where the selected contact's face and name lead (contact-link.ts): a URL
|
|
11
|
+
// with {field} placeholders filled from the contact, e.g. "/people/{username}".
|
|
12
|
+
export const contactHref = $props.contactHref || ''
|
|
10
13
|
</script>
|
|
11
14
|
<script client>
|
|
15
|
+
import { contactLink } from './contact-link'
|
|
12
16
|
const active = useReactiveProp('active', {{ active }})
|
|
13
17
|
const compact = {{ compact }}
|
|
14
18
|
const selectedInboxClass = {{ selectedInboxClass }}
|
|
19
|
+
const contactHref = {{ contactHref }}
|
|
15
20
|
const chat = useStore({{ storeName }})
|
|
16
21
|
const rows = chat.rows
|
|
17
22
|
const selected = chat.selected
|
|
@@ -56,6 +61,7 @@ const emptyThread = derived(() => hasSelection() && !threadLoading() && messages
|
|
|
56
61
|
const selectedName = derived(() => selected()?.name || '')
|
|
57
62
|
const selectedRole = derived(() => selected()?.role || '')
|
|
58
63
|
const selectedAvatar = derived(() => selected()?.avatar || '')
|
|
64
|
+
const selectedHref = derived(() => contactLink(selected(), contactHref))
|
|
59
65
|
const sendLabel = derived(() => sending() ? 'Sending...' : 'Send message')
|
|
60
66
|
function timestamp(value) { return new Date(value).toLocaleString([], { month: 'short', day: 'numeric', hour: 'numeric', minute: '2-digit' }) }
|
|
61
67
|
function submit() { return chat.send() }
|
|
@@ -89,7 +95,7 @@ effect(() => { if (active() && visibility() === 'visible') chat.refresh(true) })
|
|
|
89
95
|
</div>
|
|
90
96
|
<div :if="hasSelection" class="flex flex-1 flex-col min-w-0">
|
|
91
97
|
<header class="flex items-center gap-3 px-4 py-4 border-b border-line">
|
|
92
|
-
<button type="button" @click="chat.back()" aria-label="Back to inbox" class="stx-chat-back {{ backButtonClass }} p-2 rounded-lg hover:bg-surface-hover"><span class="i-lucide-arrow-left" aria-hidden="true"></span></button><Avatar :src="selectedAvatar" :alt="selectedName" size="md" className="shrink-0" /><div class="flex-1"><h2 class="font-semibold text-fg-strong" :text="selectedName"></h2><p class="mt-0.5 text-xs text-fg-muted" :text="selectedRole"></p></div><button type="button" @click="chat.refresh(true)" aria-label="Refresh conversation" class="p-2 text-fg-muted rounded-lg hover:bg-surface-hover"><span class="i-lucide-refresh-cw" aria-hidden="true"></span></button>
|
|
98
|
+
<button type="button" @click="chat.back()" aria-label="Back to inbox" class="stx-chat-back {{ backButtonClass }} p-2 rounded-lg hover:bg-surface-hover"><span class="i-lucide-arrow-left" aria-hidden="true"></span></button><StxLink :if="selectedHref" :to="selectedHref" className="stx-chat-person flex flex-1 gap-3 items-center min-w-0 rounded-lg hover:opacity-80 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent"><Avatar :src="selectedAvatar" :alt="selectedName" size="md" className="shrink-0" /><div class="min-w-0"><h2 class="font-semibold text-fg-strong truncate" :text="selectedName"></h2><p class="mt-0.5 text-xs text-fg-muted" :text="selectedRole"></p></div></StxLink><div :if="!selectedHref" class="stx-chat-person flex flex-1 gap-3 items-center min-w-0"><Avatar :src="selectedAvatar" :alt="selectedName" size="md" className="shrink-0" /><div class="min-w-0"><h2 class="font-semibold text-fg-strong truncate" :text="selectedName"></h2><p class="mt-0.5 text-xs text-fg-muted" :text="selectedRole"></p></div></div><button type="button" @click="chat.refresh(true)" aria-label="Refresh conversation" class="p-2 text-fg-muted rounded-lg hover:bg-surface-hover"><span class="i-lucide-refresh-cw" aria-hidden="true"></span></button>
|
|
93
99
|
</header>
|
|
94
100
|
<div ref="chat-history" role="log" aria-label="Conversation history" aria-live="polite" aria-relevant="additions" :aria-busy="threadLoading" class="flex flex-col flex-1 min-h-0 overflow-y-auto px-4 py-5 gap-4">
|
|
95
101
|
<button :if="hasMore" type="button" @click="chat.older()" :disabled="threadLoading" class="self-center text-sm text-accent-soft-ink font-medium underline">Load earlier messages</button>
|
package/src/ui/chat/README.md
CHANGED
|
@@ -53,6 +53,16 @@ counts. The popup supports Escape and returns focus to its launcher when closed.
|
|
|
53
53
|
`ChatInbox compact` stacks inbox and thread even on a wide viewport; its `active`
|
|
54
54
|
reactive prop controls read acknowledgement for a hidden or closed panel.
|
|
55
55
|
|
|
56
|
+
The selected contact's face and name in the thread header link wherever the
|
|
57
|
+
app says. `contactHref` is a URL with `{field}` placeholders filled from the
|
|
58
|
+
contact; a contact whose field is empty or missing gets no link, so send a
|
|
59
|
+
handle only for people whose page the viewer may open. A contact's own `href`
|
|
60
|
+
wins over the template.
|
|
61
|
+
|
|
62
|
+
```html
|
|
63
|
+
<ChatInbox store="chat" contactHref="/people/{username}?from=messages" />
|
|
64
|
+
```
|
|
65
|
+
|
|
56
66
|
Contacts may include an uploaded image URL in `avatar`. The inbox and thread
|
|
57
67
|
header share `Avatar`, which follows refreshed photos and falls back to initials
|
|
58
68
|
when an image is missing or cannot load.
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Where a chat contact's face and name lead, or '' for nowhere.
|
|
3
|
+
*
|
|
4
|
+
* A contact's own `href` wins. Otherwise `template` is a URL with `{field}`
|
|
5
|
+
* placeholders filled (URL-encoded) from the contact, e.g. "/people/{username}".
|
|
6
|
+
* A placeholder whose field is empty means that contact gets no link, so an app
|
|
7
|
+
* can send a handle only for the people whose page it may show.
|
|
8
|
+
*/
|
|
9
|
+
export function contactLink(person: object | null | undefined, template = ''): string {
|
|
10
|
+
if (!person)
|
|
11
|
+
return ''
|
|
12
|
+
const contact = person as Record<string, unknown>
|
|
13
|
+
if (typeof contact.href === 'string' && contact.href)
|
|
14
|
+
return contact.href
|
|
15
|
+
if (!template)
|
|
16
|
+
return ''
|
|
17
|
+
let missing = false
|
|
18
|
+
const url = template.replace(/\{(\w+)\}/g, (_, key: string) => {
|
|
19
|
+
const value = contact[key]
|
|
20
|
+
if (value == null || value === '') {
|
|
21
|
+
missing = true
|
|
22
|
+
return ''
|
|
23
|
+
}
|
|
24
|
+
return encodeURIComponent(String(value))
|
|
25
|
+
})
|
|
26
|
+
return missing ? '' : url
|
|
27
|
+
}
|
|
@@ -2,7 +2,7 @@ import type { DerivedSignal, Signal } from '@stacksjs/stx'
|
|
|
2
2
|
import { derived, effect, state } from '@stacksjs/stx'
|
|
3
3
|
import { useBroadcastStream } from '@stacksjs/stx/composables/use-broadcast-stream'
|
|
4
4
|
|
|
5
|
-
export interface ChatContact { id: number, name: string, role: string, avatar?: string | null }
|
|
5
|
+
export interface ChatContact { id: number, name: string, role: string, avatar?: string | null, href?: string | null }
|
|
6
6
|
export interface ChatMessage { id: number, sender_id: number, body: string, created_at: string, read_at: string | null, client_key: string }
|
|
7
7
|
export interface ChatConversation { id: string, recipient_id: number, unread: number, last_message: ChatMessage | null }
|
|
8
8
|
export interface ChatOptions {
|
package/src/ui/chat/index.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
export { default as ChatInbox } from './ChatInbox.stx'
|
|
2
2
|
export { default as ChatMessage } from './ChatMessage.stx'
|
|
3
|
+
export * from './contact-link'
|
|
3
4
|
export * from './controller'
|
|
4
|
-
export interface ChatInboxProps { store?: string, compact?: boolean, active?: boolean, className?: string }
|
|
5
|
+
export interface ChatInboxProps { store?: string, compact?: boolean, active?: boolean, className?: string, contactHref?: string }
|
|
5
6
|
export interface ChatMessageProps { body?: string, author?: string, time?: string, outgoing?: boolean, className?: string }
|
|
6
7
|
export { default as ChatUnreadBadge } from './ChatUnreadBadge.stx'
|
|
7
8
|
|