@zenpatient-org/healthspan-marketing-ui 1.0.21 → 1.0.23

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.
@@ -1 +1 @@
1
- "use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("react/jsx-runtime"),l=require("react"),r=require("../../components/ChatMessage/chatMessage.module.css"),C=require("../Typography/Typography.cjs.js"),Q="(prefers-reduced-motion: reduce)",z=[900,1150],le=180,ce=130,de=140,ue=36,he=220,me=new Set("th he in er an re on at en nd ou ea ha to it is or ti as te ng of al ar st se le ve me yo wh ch ll".split(" ")),fe=o=>{const n=window.matchMedia(Q);return n.addEventListener("change",o),()=>n.removeEventListener("change",o)},pe=()=>window.matchMedia(Q).matches,ge=o=>{let n=Array.from(o).reduce((e,s)=>Math.imul(e^s.charCodeAt(0),16777619),2166136261);return()=>{n=n+1831565813|0;let e=Math.imul(n^n>>>15,1|n);return e=e+Math.imul(e^e>>>7,61|e)^e,((e^e>>>14)>>>0)/4294967296}},Se=(o,n)=>{const e=ge(n),s=(u,m)=>u+e()*(m-u);let T=0,d=0;return o.split("").map((u,m)=>{var c;const f=(c=o[m-1])!=null?c:"";let a;return m===0?a=0:/[.?!…]/.test(f)?a=s(180,260):/[,;:—]/.test(f)?a=s(120,180):u===" "?a=s(20,35):d>0?(d--,a=s(22,32)):me.has((f+u).toLowerCase())?a=s(24,36):e()<.15?(d=2+Math.floor(e()*3),a=s(22,32)):a=s(35,60),f===" "&&e()<.08&&(a+=s(60,110)),T+=a})},ve=o=>{const n=o.querySelector("p"),e=n.firstChild,s=e.textContent,T=n.getBoundingClientRect().left,d=getComputedStyle(o),u=parseFloat(d.paddingLeft)+parseFloat(d.paddingRight),m=document.createRange(),f=[0],a=[];let c,x=0;for(let h=0;h<s.length;h++){if(!/\s/.test(s[h])){m.setStart(e,h),m.setEnd(e,h+1);const y=m.getBoundingClientRect();c!==void 0&&y.top>c+1&&f.push(h),c=y.top,x=Math.max(x,y.right-T)}a.push(x)}return a[a.length-1]=o.getBoundingClientRect().width-u,{lineStarts:f,widths:a,lineHeight:parseFloat(getComputedStyle(n).lineHeight),padX:u,padY:parseFloat(d.paddingTop)+parseFloat(d.paddingBottom)}},J=(o,n)=>o.filter((e,s)=>s===0||e<n),xe=({sender:o,avatar:n,children:e,typing:s=!1,attachment:T,thinking:d,typeOut:u=!1,seed:m,onTyped:f})=>{var O,V;const a=l.useSyncExternalStore(fe,pe,()=>!1),[c,x]=l.useState(),[h,y]=l.useState(!1),[j,W]=l.useState(0),[L,Z]=l.useState(!1),[w,k]=l.useState(!u),[ee,H]=l.useState(!u),[p,te]=l.useState(),[$,se]=l.useState(0),[ae,ne]=l.useState(!1),R=l.useRef(null),P=l.useRef(null);d!=null&&d.length?(d!==c&&x(d),h&&y(!1)):c&&!h&&(a?x(void 0):(y(!0),Z(!0)));const S=typeof e=="string"?e:"",B=!c||h,A=u&&!ee&&!s&&!!S&&B,M=A&&!a,F=(O=c==null?void 0:c.length)!=null?O:0;l.useEffect(()=>{if(h||j>=F-1)return;const i=z[Math.min(j,z.length-1)],g=setTimeout(()=>W(j+1),i);return()=>clearTimeout(g)},[h,j,F]);const X=l.useEffectEvent(()=>{k(!0),f==null||f()});l.useLayoutEffect(()=>{if(!M)return;const i=ve(P.current);R.current.style.width=`${i.padX}px`,R.current.style.height=`${i.padY+i.lineHeight}px`,te(i)},[M,S]),l.useEffect(()=>{if(!A)return;if(a){X(),H(!0);return}if(!p)return;const i=R.current,g=Se(S,m!=null?m:S),b=performance.now()+(L?le:0)+ce;let I=p.padX,_,E,q=0;const D=N=>{var U;const v=g.filter(oe=>oe<=N-b).length,K=g[v]-((U=g[v-1])!=null?U:0),ie=p.padX+(v?p.widths[v-1]:0),re=K<ue?30:45;if(I+=(ie-I)*(1-Math.exp(-(N-(_!=null?_:N))/re)),_=N,i.style.width=`${I}px`,i.style.height=`${p.padY+p.lineHeight*J(p.lineStarts,v).length}px`,se(v),ne(v>0&&K>=de),v===g.length&&(E!=null||(E=N),E===N&&X(),N-E>=he)){i.style.width="",i.style.height="",H(!0);return}q=requestAnimationFrame(D)};return q=requestAnimationFrame(D),()=>cancelAnimationFrame(q)},[A,a,p,S,m,L]);const Y=(V=p==null?void 0:p.lineStarts)!=null?V:[0],G=J(Y,$);return t.jsxs("div",{className:r.root,children:[t.jsx("span",{className:r.avatar,children:t.jsx("img",{src:n,alt:"",className:r.avatarImage})}),t.jsxs("div",{className:r.content,children:[t.jsxs("div",{className:r.message,children:[t.jsx(C.Typography,{as:"p",defaultVariant:"bodySm",weight:"medium",className:r.sender,children:o}),t.jsxs("div",{className:r.slot,children:[c&&t.jsx("div",{className:r.status,"data-leaving":h||void 0,onAnimationEnd:()=>{h&&(y(!1),x(void 0))},children:c.map((i,g)=>t.jsx("span",{className:r.statusLine,"data-active":g===Math.min(j,F-1)||void 0,children:t.jsx(C.Typography,{defaultVariant:"headingXxs",children:i})},i))}),B&&t.jsx("div",{ref:R,className:r.bubble,"aria-live":s?"polite":void 0,"aria-hidden":u&&!s||void 0,"data-enter":M?L?"after-thinking":"direct":void 0,"data-typing":M||void 0,children:t.jsx(C.Typography,{as:"p",defaultVariant:"bodySm",className:r.text,children:s?t.jsxs("span",{role:"img","aria-label":`${o} is typing`,className:r.typing,children:[t.jsx("span",{children:"."}),t.jsx("span",{children:"."}),t.jsx("span",{children:"."})]}):M?G.map((i,g)=>{var b;return t.jsxs("span",{className:r.line,children:[S.slice(i,Math.min((b=Y[g+1])!=null?b:S.length,$)).trimEnd(),g===G.length-1&&t.jsx("span",{className:r.caret,"data-paused":ae&&!w||void 0,"data-ending":w||void 0})]},i)}):e})})]}),M&&t.jsx("div",{ref:P,className:`${r.bubble} ${r.measure}`,"aria-hidden":!0,children:t.jsx(C.Typography,{as:"p",defaultVariant:"bodySm",children:S})}),u&&t.jsx("span",{className:r.srOnly,"aria-live":"polite",children:w?S:""})]}),T]})]})};exports.ChatMessage=xe;
1
+ "use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("react/jsx-runtime"),n=require("react"),d=require("../../components/ChatMessage/chatMessage.module.css"),F=require("../Typography/Typography.cjs.js"),le="(prefers-reduced-motion: reduce)",ie=[900,1150],ve=180,xe=130,ye=140,be=36,Ne=220,Te=new Set("th he in er an re on at en nd ou ea ha to it is or ti as te ng of al ar st se le ve me yo wh ch ll".split(" ")),Me=u=>{const l=window.matchMedia(le);return l.addEventListener("change",u),()=>l.removeEventListener("change",u)},Re=()=>window.matchMedia(le).matches,Ee=u=>{let l=Array.from(u).reduce((e,s)=>Math.imul(e^s.charCodeAt(0),16777619),2166136261);return()=>{l=l+1831565813|0;let e=Math.imul(l^l>>>15,1|l);return e=e+Math.imul(e^e>>>7,61|e)^e,((e^e>>>14)>>>0)/4294967296}},je=(u,l)=>{const e=Ee(l),s=(c,f)=>c+e()*(f-c);let T=0,h=0;return u.split("").map((c,f)=>{var t;const m=(t=u[f-1])!=null?t:"";let i;return f===0?i=0:/[.?!…]/.test(m)?i=s(180,260):/[,;:—]/.test(m)?i=s(120,180):c===" "?i=s(20,35):h>0?(h--,i=s(22,32)):Te.has((m+c).toLowerCase())?i=s(24,36):e()<.15?(h=2+Math.floor(e()*3),i=s(22,32)):i=s(35,60),m===" "&&e()<.08&&(i+=s(60,110)),T+=i})},we=u=>{const l=u.querySelector("p"),e=l.firstChild,s=e.textContent,T=l.getBoundingClientRect().left,h=getComputedStyle(u),c=parseFloat(h.paddingLeft)+parseFloat(h.paddingRight),f=document.createRange(),m=[0],i=[];let t,b=0;for(let S=0;S<s.length;S++){if(!/\s/.test(s[S])){f.setStart(e,S),f.setEnd(e,S+1);const M=f.getBoundingClientRect();t!==void 0&&M.top>t+1&&m.push(S),t=M.top,b=Math.max(b,M.right-T)}i.push(b)}return i[i.length-1]=u.getBoundingClientRect().width-c,{lineStarts:m,widths:i,lineHeight:parseFloat(getComputedStyle(l).lineHeight),padX:c,padY:parseFloat(h.paddingTop)+parseFloat(h.paddingBottom)}},re=(u,l)=>u.filter((e,s)=>s===0||e<l),Ce=({sender:u,avatar:l,children:e,typing:s=!1,attachment:T,thinking:h,typeOut:c=!1,seed:f,onTyped:m})=>{var k,ee;const i=n.useSyncExternalStore(Me,Re,()=>!1),t=typeof e=="string"?e:"",b=s||!!e,[S,M]=n.useState(t),[p,I]=n.useState(),[x,$]=n.useState(!1),[R,oe]=n.useState(0),[q,ce]=n.useState(!1),[E,D]=n.useState(!c),[de,H]=n.useState(!c),[C,K]=n.useState(!1),[j,ue]=n.useState(!1),[g,U]=n.useState(),[W,z]=n.useState(0),[he,fe]=n.useState(!1),P=n.useRef(null),O=n.useRef(null),_=n.useRef(void 0);h!=null&&h.length?(h!==p&&I(h),x&&$(!1),b&&!C&&K(!0)):p&&!x?i?I(void 0):($(!0),ce(!0)):!p&&C&&K(!1),c&&t&&t!==S&&(M(t),S&&(ue(!0),D(!1),H(!1),z(0),U(void 0)));const J=b&&(!p||x||C),X=c&&!de&&!s&&!!t&&J,N=X&&!i,Y=(k=p==null?void 0:p.length)!=null?k:0;n.useEffect(()=>{if(x||R>=Y-1)return;const r=ie[Math.min(R,ie.length-1)],o=setTimeout(()=>oe(R+1),r);return()=>clearTimeout(o)},[x,R,Y]);const G=n.useEffectEvent(()=>{D(!0),m==null||m()});n.useEffect(()=>{c&&!t&&!p&&!E&&G()},[c,t,p,E]),n.useLayoutEffect(()=>{if(!N)return;const r=we(O.current),o=P.current;j?!o.style.width&&_.current&&(o.style.width=`${_.current.width}px`,o.style.height=`${_.current.height}px`):(o.style.width=`${r.padX}px`,o.style.height=`${r.padY+r.lineHeight}px`),U(r)},[N,t,j]),n.useEffect(()=>{if(!X)return;if(i){G(),H(!0);return}if(!g)return;const r=P.current,o=je(t,f!=null?f:t),A=performance.now()+(q?ve:0)+xe;let L=j?r.getBoundingClientRect().width:g.padX;const me=L;let B,w,V=0;const te=y=>{var ne;const v=o.filter(Se=>Se<=y-A).length,se=o[v]-((ne=o[v-1])!=null?ne:0),ae=g.padX+(v?g.widths[v-1]:0),pe=v===o.length?ae:Math.max(me,ae),ge=se<be?30:45;if(L+=(pe-L)*(1-Math.exp(-(y-(B!=null?B:y))/ge)),B=y,r.style.width=`${L}px`,r.style.height=`${g.padY+g.lineHeight*re(g.lineStarts,v).length}px`,z(v),fe(v>0&&se>=ye),v===o.length&&(w!=null||(w=y),w===y&&G(),y-w>=Ne)){r.style.width="",r.style.height="",_.current=r.getBoundingClientRect(),H(!0);return}V=requestAnimationFrame(te)};return V=requestAnimationFrame(te),()=>cancelAnimationFrame(V)},[X,i,g,t,f,q,j]);const Q=(ee=g==null?void 0:g.lineStarts)!=null?ee:[0],Z=re(Q,W);return a.jsxs("div",{className:d.root,children:[a.jsx("span",{className:d.avatar,children:a.jsx("img",{src:l,alt:"",className:d.avatarImage})}),a.jsxs("div",{className:d.content,children:[a.jsxs("div",{className:d.message,children:[a.jsx(F.Typography,{as:"p",defaultVariant:"bodySm",weight:"medium",className:d.sender,children:u}),a.jsxs("div",{className:d.slot,"data-stacked":C||void 0,children:[p&&a.jsx("div",{className:d.status,"data-leaving":x||void 0,onAnimationEnd:()=>{x&&($(!1),I(void 0))},children:p.map((r,o)=>a.jsx("span",{className:d.statusLine,"data-active":o===Math.min(R,Y-1)||void 0,children:a.jsx(F.Typography,{defaultVariant:"headingXxs",children:r})},r))}),J&&a.jsx("div",{ref:P,className:d.bubble,"aria-live":s?"polite":void 0,"aria-hidden":c&&!s||void 0,"data-enter":N&&!j?q?"after-thinking":"direct":void 0,"data-typing":N||void 0,children:a.jsx(F.Typography,{as:"p",defaultVariant:"bodySm",className:d.text,children:s?a.jsxs("span",{role:"img","aria-label":`${u} is typing`,className:d.typing,children:[a.jsx("span",{children:"."}),a.jsx("span",{children:"."}),a.jsx("span",{children:"."})]}):N?Z.map((r,o)=>{var A;return a.jsxs("span",{className:d.line,children:[t.slice(r,Math.min((A=Q[o+1])!=null?A:t.length,W)).trimEnd(),o===Z.length-1&&a.jsx("span",{className:d.caret,"data-paused":he&&!E||void 0,"data-ending":E||void 0})]},r)}):e})})]}),N&&a.jsx("div",{ref:O,className:`${d.bubble} ${d.measure}`,"aria-hidden":!0,children:a.jsx(F.Typography,{as:"p",defaultVariant:"bodySm",children:t})}),c&&a.jsx("span",{className:d.srOnly,"aria-live":"polite",children:E?t:""})]}),T]})]})};exports.ChatMessage=Ce;
@@ -8,9 +8,9 @@ export type ChatMessageProps = {
8
8
  typing?: boolean;
9
9
  /** Rendered under the bubble, e.g. a cancellation widget or a follow-up CTA. */
10
10
  attachment?: ReactNode;
11
- /** Status lines shown instead of the bubble. Each crossfades in place; the last holds until this is cleared. */
11
+ /** Status lines, above the bubble when there is text and in its place when there isn't. Each crossfades in place; the last holds until this is cleared. */
12
12
  thinking?: string[];
13
- /** Types out `children`, which must be a string. */
13
+ /** Types out `children`, which must be a string. New text types out again in the same bubble. */
14
14
  typeOut?: boolean;
15
15
  /** Seeds the typing rhythm, e.g. the message id, so a replay types the same way. Defaults to the text. */
16
16
  seed?: string;
@@ -1,157 +1,161 @@
1
1
  "use client";
2
- import { jsxs as R, jsx as o } from "react/jsx-runtime";
3
- import { useSyncExternalStore as ue, useState as v, useRef as J, useEffect as Q, useEffectEvent as he, useLayoutEffect as me } from "react";
4
- import i from "../../components/ChatMessage/chatMessage.module.css";
5
- import { Typography as A } from "../Typography/Typography.es.js";
6
- const k = "(prefers-reduced-motion: reduce)", W = [900, 1150], fe = 180, pe = 130, ge = 140, ve = 36, Se = 220, Ne = new Set(
2
+ import { jsxs as E, jsx as d } from "react/jsx-runtime";
3
+ import { useSyncExternalStore as ye, useState as f, useRef as K, useEffect as U, useEffectEvent as Me, useLayoutEffect as Ee } from "react";
4
+ import o from "../../components/ChatMessage/chatMessage.module.css";
5
+ import { Typography as $ } from "../Typography/Typography.es.js";
6
+ const de = "(prefers-reduced-motion: reduce)", oe = [900, 1150], xe = 180, Re = 130, Te = 140, we = 36, Ce = 220, Ae = new Set(
7
7
  "th he in er an re on at en nd ou ea ha to it is or ti as te ng of al ar st se le ve me yo wh ch ll".split(" ")
8
- ), Me = (r) => {
9
- const a = window.matchMedia(k);
10
- return a.addEventListener("change", r), () => a.removeEventListener("change", r);
11
- }, Ee = () => window.matchMedia(k).matches, ye = (r) => {
12
- let a = Array.from(r).reduce((e, t) => Math.imul(e ^ t.charCodeAt(0), 16777619), 2166136261);
8
+ ), Le = (c) => {
9
+ const i = window.matchMedia(de);
10
+ return i.addEventListener("change", c), () => i.removeEventListener("change", c);
11
+ }, _e = () => window.matchMedia(de).matches, Be = (c) => {
12
+ let i = Array.from(c).reduce((e, s) => Math.imul(e ^ s.charCodeAt(0), 16777619), 2166136261);
13
13
  return () => {
14
- a = a + 1831565813 | 0;
15
- let e = Math.imul(a ^ a >>> 15, 1 | a);
14
+ i = i + 1831565813 | 0;
15
+ let e = Math.imul(i ^ i >>> 15, 1 | i);
16
16
  return e = e + Math.imul(e ^ e >>> 7, 61 | e) ^ e, ((e ^ e >>> 14) >>> 0) / 4294967296;
17
17
  };
18
- }, Re = (r, a) => {
19
- const e = ye(a), t = (d, h) => d + e() * (h - d);
20
- let T = 0, c = 0;
21
- return r.split("").map((d, h) => {
22
- var l;
23
- const m = (l = r[h - 1]) != null ? l : "";
24
- let s;
25
- return h === 0 ? s = 0 : /[.?!…]/.test(m) ? s = t(180, 260) : /[,;:—]/.test(m) ? s = t(120, 180) : d === " " ? s = t(20, 35) : c > 0 ? (c--, s = t(22, 32)) : Ne.has((m + d).toLowerCase()) ? s = t(24, 36) : e() < 0.15 ? (c = 2 + Math.floor(e() * 3), s = t(22, 32)) : s = t(35, 60), m === " " && e() < 0.08 && (s += t(60, 110)), T += s;
18
+ }, Fe = (c, i) => {
19
+ const e = Be(i), s = (l, u) => l + e() * (u - l);
20
+ let x = 0, h = 0;
21
+ return c.split("").map((l, u) => {
22
+ var t;
23
+ const m = (t = c[u - 1]) != null ? t : "";
24
+ let n;
25
+ return u === 0 ? n = 0 : /[.?!…]/.test(m) ? n = s(180, 260) : /[,;:—]/.test(m) ? n = s(120, 180) : l === " " ? n = s(20, 35) : h > 0 ? (h--, n = s(22, 32)) : Ae.has((m + l).toLowerCase()) ? n = s(24, 36) : e() < 0.15 ? (h = 2 + Math.floor(e() * 3), n = s(22, 32)) : n = s(35, 60), m === " " && e() < 0.08 && (n += s(60, 110)), x += n;
26
26
  });
27
- }, Te = (r) => {
28
- const a = r.querySelector("p"), e = a.firstChild, t = e.textContent, T = a.getBoundingClientRect().left, c = getComputedStyle(r), d = parseFloat(c.paddingLeft) + parseFloat(c.paddingRight), h = document.createRange(), m = [0], s = [];
29
- let l, N = 0;
30
- for (let u = 0; u < t.length; u++) {
31
- if (!/\s/.test(t[u])) {
32
- h.setStart(e, u), h.setEnd(e, u + 1);
33
- const M = h.getBoundingClientRect();
34
- l !== void 0 && M.top > l + 1 && m.push(u), l = M.top, N = Math.max(N, M.right - T);
27
+ }, Ie = (c) => {
28
+ const i = c.querySelector("p"), e = i.firstChild, s = e.textContent, x = i.getBoundingClientRect().left, h = getComputedStyle(c), l = parseFloat(h.paddingLeft) + parseFloat(h.paddingRight), u = document.createRange(), m = [0], n = [];
29
+ let t, y = 0;
30
+ for (let v = 0; v < s.length; v++) {
31
+ if (!/\s/.test(s[v])) {
32
+ u.setStart(e, v), u.setEnd(e, v + 1);
33
+ const R = u.getBoundingClientRect();
34
+ t !== void 0 && R.top > t + 1 && m.push(v), t = R.top, y = Math.max(y, R.right - x);
35
35
  }
36
- s.push(N);
36
+ n.push(y);
37
37
  }
38
- return s[s.length - 1] = r.getBoundingClientRect().width - d, {
38
+ return n[n.length - 1] = c.getBoundingClientRect().width - l, {
39
39
  lineStarts: m,
40
- widths: s,
41
- lineHeight: parseFloat(getComputedStyle(a).lineHeight),
42
- padX: d,
43
- padY: parseFloat(c.paddingTop) + parseFloat(c.paddingBottom)
40
+ widths: n,
41
+ lineHeight: parseFloat(getComputedStyle(i).lineHeight),
42
+ padX: l,
43
+ padY: parseFloat(h.paddingTop) + parseFloat(h.paddingBottom)
44
44
  };
45
- }, Z = (r, a) => r.filter((e, t) => t === 0 || e < a), we = ({
46
- sender: r,
47
- avatar: a,
45
+ }, ce = (c, i) => c.filter((e, s) => s === 0 || e < i), Ye = ({
46
+ sender: c,
47
+ avatar: i,
48
48
  children: e,
49
- typing: t = !1,
50
- attachment: T,
51
- thinking: c,
52
- typeOut: d = !1,
53
- seed: h,
49
+ typing: s = !1,
50
+ attachment: x,
51
+ thinking: h,
52
+ typeOut: l = !1,
53
+ seed: u,
54
54
  onTyped: m
55
55
  }) => {
56
- var O, j;
57
- const s = ue(Me, Ee, () => !1), [l, N] = v(), [u, M] = v(!1), [b, ee] = v(0), [C, te] = v(!1), [F, se] = v(!d), [ae, P] = v(!d), [f, ne] = v(), [X, ie] = v(0), [re, le] = v(!1), L = J(null), Y = J(null);
58
- c != null && c.length ? (c !== l && N(c), u && M(!1)) : l && !u && (s ? N(void 0) : (M(!0), te(!0)));
59
- const g = typeof e == "string" ? e : "", q = !l || u, I = d && !ae && !t && !!g && q, y = I && !s, H = (O = l == null ? void 0 : l.length) != null ? O : 0;
60
- Q(() => {
61
- if (u || b >= H - 1) return;
62
- const n = W[Math.min(b, W.length - 1)], p = setTimeout(() => ee(b + 1), n);
63
- return () => clearTimeout(p);
64
- }, [u, b, H]);
65
- const G = he(() => {
66
- se(!0), m == null || m();
56
+ var se, ne;
57
+ const n = ye(Le, _e, () => !1), t = typeof e == "string" ? e : "", y = s || !!e, [v, R] = f(t), [p, H] = f(), [b, P] = f(!1), [T, he] = f(0), [X, ue] = f(!1), [w, W] = f(!l), [fe, Y] = f(!l), [L, z] = f(!1), [C, me] = f(!1), [g, J] = f(), [O, Q] = f(0), [pe, ge] = f(!1), q = K(null), Z = K(null), _ = K(void 0);
58
+ h != null && h.length ? (h !== p && H(h), b && P(!1), y && !L && z(!0)) : p && !b ? n ? H(void 0) : (P(!0), ue(!0)) : !p && L && z(!1), l && t && t !== v && (R(t), v && (me(!0), W(!1), Y(!1), Q(0), J(void 0)));
59
+ const k = y && (!p || b || L), G = l && !fe && !s && !!t && k, M = G && !n, V = (se = p == null ? void 0 : p.length) != null ? se : 0;
60
+ U(() => {
61
+ if (b || T >= V - 1) return;
62
+ const a = oe[Math.min(T, oe.length - 1)], r = setTimeout(() => he(T + 1), a);
63
+ return () => clearTimeout(r);
64
+ }, [b, T, V]);
65
+ const D = Me(() => {
66
+ W(!0), m == null || m();
67
67
  });
68
- me(() => {
69
- if (!y) return;
70
- const n = Te(Y.current);
71
- L.current.style.width = `${n.padX}px`, L.current.style.height = `${n.padY + n.lineHeight}px`, ne(n);
72
- }, [y, g]), Q(() => {
73
- if (!I) return;
74
- if (s) {
75
- G(), P(!0);
68
+ U(() => {
69
+ l && !t && !p && !w && D();
70
+ }, [l, t, p, w]), Ee(() => {
71
+ if (!M) return;
72
+ const a = Ie(Z.current), r = q.current;
73
+ C ? !r.style.width && _.current && (r.style.width = `${_.current.width}px`, r.style.height = `${_.current.height}px`) : (r.style.width = `${a.padX}px`, r.style.height = `${a.padY + a.lineHeight}px`), J(a);
74
+ }, [M, t, C]), U(() => {
75
+ if (!G) return;
76
+ if (n) {
77
+ D(), Y(!0);
76
78
  return;
77
79
  }
78
- if (!f) return;
79
- const n = L.current, p = Re(g, h != null ? h : g), _ = performance.now() + (C ? fe : 0) + pe;
80
- let $ = f.padX, w, x, B = 0;
81
- const K = (E) => {
82
- var z;
83
- const S = p.filter((de) => de <= E - _).length, U = p[S] - ((z = p[S - 1]) != null ? z : 0), oe = f.padX + (S ? f.widths[S - 1] : 0), ce = U < ve ? 30 : 45;
84
- if ($ += (oe - $) * (1 - Math.exp(-(E - (w != null ? w : E)) / ce)), w = E, n.style.width = `${$}px`, n.style.height = `${f.padY + f.lineHeight * Z(f.lineStarts, S).length}px`, ie(S), le(S > 0 && U >= ge), S === p.length && (x != null || (x = E), x === E && G(), E - x >= Se)) {
85
- n.style.width = "", n.style.height = "", P(!0);
80
+ if (!g) return;
81
+ const a = q.current, r = Fe(t, u != null ? u : t), B = performance.now() + (X ? xe : 0) + Re;
82
+ let F = C ? a.getBoundingClientRect().width : g.padX;
83
+ const ve = F;
84
+ let I, A, j = 0;
85
+ const ae = (N) => {
86
+ var le;
87
+ const S = r.filter((Ne) => Ne <= N - B).length, ie = r[S] - ((le = r[S - 1]) != null ? le : 0), re = g.padX + (S ? g.widths[S - 1] : 0), Se = S === r.length ? re : Math.max(ve, re), be = ie < we ? 30 : 45;
88
+ if (F += (Se - F) * (1 - Math.exp(-(N - (I != null ? I : N)) / be)), I = N, a.style.width = `${F}px`, a.style.height = `${g.padY + g.lineHeight * ce(g.lineStarts, S).length}px`, Q(S), ge(S > 0 && ie >= Te), S === r.length && (A != null || (A = N), A === N && D(), N - A >= Ce)) {
89
+ a.style.width = "", a.style.height = "", _.current = a.getBoundingClientRect(), Y(!0);
86
90
  return;
87
91
  }
88
- B = requestAnimationFrame(K);
92
+ j = requestAnimationFrame(ae);
89
93
  };
90
- return B = requestAnimationFrame(K), () => cancelAnimationFrame(B);
91
- }, [I, s, f, g, h, C]);
92
- const V = (j = f == null ? void 0 : f.lineStarts) != null ? j : [0], D = Z(V, X);
93
- return /* @__PURE__ */ R("div", { className: i.root, children: [
94
- /* @__PURE__ */ o("span", { className: i.avatar, children: /* @__PURE__ */ o("img", { src: a, alt: "", className: i.avatarImage }) }),
95
- /* @__PURE__ */ R("div", { className: i.content, children: [
96
- /* @__PURE__ */ R("div", { className: i.message, children: [
97
- /* @__PURE__ */ o(A, { as: "p", defaultVariant: "bodySm", weight: "medium", className: i.sender, children: r }),
98
- /* @__PURE__ */ R("div", { className: i.slot, children: [
99
- l && /* @__PURE__ */ o(
94
+ return j = requestAnimationFrame(ae), () => cancelAnimationFrame(j);
95
+ }, [G, n, g, t, u, X, C]);
96
+ const ee = (ne = g == null ? void 0 : g.lineStarts) != null ? ne : [0], te = ce(ee, O);
97
+ return /* @__PURE__ */ E("div", { className: o.root, children: [
98
+ /* @__PURE__ */ d("span", { className: o.avatar, children: /* @__PURE__ */ d("img", { src: i, alt: "", className: o.avatarImage }) }),
99
+ /* @__PURE__ */ E("div", { className: o.content, children: [
100
+ /* @__PURE__ */ E("div", { className: o.message, children: [
101
+ /* @__PURE__ */ d($, { as: "p", defaultVariant: "bodySm", weight: "medium", className: o.sender, children: c }),
102
+ /* @__PURE__ */ E("div", { className: o.slot, "data-stacked": L || void 0, children: [
103
+ p && /* @__PURE__ */ d(
100
104
  "div",
101
105
  {
102
- className: i.status,
103
- "data-leaving": u || void 0,
106
+ className: o.status,
107
+ "data-leaving": b || void 0,
104
108
  onAnimationEnd: () => {
105
- u && (M(!1), N(void 0));
109
+ b && (P(!1), H(void 0));
106
110
  },
107
- children: l.map((n, p) => /* @__PURE__ */ o(
111
+ children: p.map((a, r) => /* @__PURE__ */ d(
108
112
  "span",
109
113
  {
110
- className: i.statusLine,
111
- "data-active": p === Math.min(b, H - 1) || void 0,
112
- children: /* @__PURE__ */ o(A, { defaultVariant: "headingXxs", children: n })
114
+ className: o.statusLine,
115
+ "data-active": r === Math.min(T, V - 1) || void 0,
116
+ children: /* @__PURE__ */ d($, { defaultVariant: "headingXxs", children: a })
113
117
  },
114
- n
118
+ a
115
119
  ))
116
120
  }
117
121
  ),
118
- q && /* @__PURE__ */ o(
122
+ k && /* @__PURE__ */ d(
119
123
  "div",
120
124
  {
121
- ref: L,
122
- className: i.bubble,
123
- "aria-live": t ? "polite" : void 0,
124
- "aria-hidden": d && !t || void 0,
125
- "data-enter": y ? C ? "after-thinking" : "direct" : void 0,
126
- "data-typing": y || void 0,
127
- children: /* @__PURE__ */ o(A, { as: "p", defaultVariant: "bodySm", className: i.text, children: t ? /* @__PURE__ */ R("span", { role: "img", "aria-label": `${r} is typing`, className: i.typing, children: [
128
- /* @__PURE__ */ o("span", { children: "." }),
129
- /* @__PURE__ */ o("span", { children: "." }),
130
- /* @__PURE__ */ o("span", { children: "." })
131
- ] }) : y ? D.map((n, p) => {
132
- var _;
133
- return /* @__PURE__ */ R("span", { className: i.line, children: [
134
- g.slice(n, Math.min((_ = V[p + 1]) != null ? _ : g.length, X)).trimEnd(),
135
- p === D.length - 1 && /* @__PURE__ */ o(
125
+ ref: q,
126
+ className: o.bubble,
127
+ "aria-live": s ? "polite" : void 0,
128
+ "aria-hidden": l && !s || void 0,
129
+ "data-enter": M && !C ? X ? "after-thinking" : "direct" : void 0,
130
+ "data-typing": M || void 0,
131
+ children: /* @__PURE__ */ d($, { as: "p", defaultVariant: "bodySm", className: o.text, children: s ? /* @__PURE__ */ E("span", { role: "img", "aria-label": `${c} is typing`, className: o.typing, children: [
132
+ /* @__PURE__ */ d("span", { children: "." }),
133
+ /* @__PURE__ */ d("span", { children: "." }),
134
+ /* @__PURE__ */ d("span", { children: "." })
135
+ ] }) : M ? te.map((a, r) => {
136
+ var B;
137
+ return /* @__PURE__ */ E("span", { className: o.line, children: [
138
+ t.slice(a, Math.min((B = ee[r + 1]) != null ? B : t.length, O)).trimEnd(),
139
+ r === te.length - 1 && /* @__PURE__ */ d(
136
140
  "span",
137
141
  {
138
- className: i.caret,
139
- "data-paused": re && !F || void 0,
140
- "data-ending": F || void 0
142
+ className: o.caret,
143
+ "data-paused": pe && !w || void 0,
144
+ "data-ending": w || void 0
141
145
  }
142
146
  )
143
- ] }, n);
147
+ ] }, a);
144
148
  }) : e })
145
149
  }
146
150
  )
147
151
  ] }),
148
- y && /* @__PURE__ */ o("div", { ref: Y, className: `${i.bubble} ${i.measure}`, "aria-hidden": !0, children: /* @__PURE__ */ o(A, { as: "p", defaultVariant: "bodySm", children: g }) }),
149
- d && /* @__PURE__ */ o("span", { className: i.srOnly, "aria-live": "polite", children: F ? g : "" })
152
+ M && /* @__PURE__ */ d("div", { ref: Z, className: `${o.bubble} ${o.measure}`, "aria-hidden": !0, children: /* @__PURE__ */ d($, { as: "p", defaultVariant: "bodySm", children: t }) }),
153
+ l && /* @__PURE__ */ d("span", { className: o.srOnly, "aria-live": "polite", children: w ? t : "" })
150
154
  ] }),
151
- T
155
+ x
152
156
  ] })
153
157
  ] });
154
158
  };
155
159
  export {
156
- we as ChatMessage
160
+ Ye as ChatMessage
157
161
  };
@@ -95,6 +95,30 @@
95
95
  grid-area: 1 / 1;
96
96
  }
97
97
 
98
+ .slot[data-stacked] {
99
+ display: flex;
100
+ flex-direction: column;
101
+ align-items: flex-start;
102
+ }
103
+
104
+ .slot[data-stacked] .status {
105
+ grid-template-rows: 1fr;
106
+ margin-bottom: 9px;
107
+ overflow: hidden;
108
+ transition:
109
+ grid-template-rows 200ms ease-in-out,
110
+ margin-bottom 200ms ease-in-out;
111
+ }
112
+
113
+ .slot[data-stacked] .status[data-leaving] {
114
+ grid-template-rows: 0fr;
115
+ margin-bottom: 0;
116
+ }
117
+
118
+ .slot[data-stacked] .statusLine {
119
+ min-height: 0;
120
+ }
121
+
98
122
  .status {
99
123
  display: grid;
100
124
  animation: status-in 220ms ease-out;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zenpatient-org/healthspan-marketing-ui",
3
- "version": "1.0.21",
3
+ "version": "1.0.23",
4
4
  "description": "Design system",
5
5
  "main": "dist/index.cjs.js",
6
6
  "module": "dist/index.es.js",