cosmic-ai-input 1.0.23 → 1.0.25
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs.js +4 -4
- package/dist/index.es.js +129 -117
- package/dist/style.css +1 -1
- package/package.json +2 -2
package/dist/index.cjs.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
// Generated at: 2026-
|
|
2
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const u=require("react/jsx-runtime"),c=require("react"),De=require("classnames"),ct=require("react-dom");var g=(r=>(r.INPUT="input",r.SELECT="select",r.MULTIPLE_SELECT="multiple-select",r.DATE_PICKER="date-picker",r.LABEL="label",r))(g||{});const P={BACKSPACE:"Backspace",ARROW_LEFT:"ArrowLeft",ARROW_RIGHT:"ArrowRight",ARROW_UP:"ArrowUp",ARROW_DOWN:"ArrowDown",ENTER:"Enter"},je=c.forwardRef(({value:r,position:o,id:l,onChange:h},k)=>{const y=c.useRef(null),p=c.useRef(null);c.useEffect(()=>{typeof k=="function"?k(y.current):k&&(k.current=y.current)},[k]);const M=
|
|
3
|
-
`&&(t=""),t},ae=()=>{var s;let t=((s=
|
|
1
|
+
// Generated at: 2026-05-11T02:34:16.428Z
|
|
2
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const u=require("react/jsx-runtime"),c=require("react"),De=require("classnames"),ct=require("react-dom");var g=(r=>(r.INPUT="input",r.SELECT="select",r.MULTIPLE_SELECT="multiple-select",r.DATE_PICKER="date-picker",r.LABEL="label",r))(g||{});const P={BACKSPACE:"Backspace",ARROW_LEFT:"ArrowLeft",ARROW_RIGHT:"ArrowRight",ARROW_UP:"ArrowUp",ARROW_DOWN:"ArrowDown",ENTER:"Enter"},je=c.forwardRef(({value:r,position:o,id:l,onChange:h},k)=>{const y=c.useRef(null),p=c.useRef(null);c.useEffect(()=>{typeof k=="function"?k(y.current):k&&(k.current=y.current)},[k]);const M=A=>{const m=A.target.value;h==null||h(m,g.DATE_PICKER)};c.useEffect(()=>{if(p.current)try{setTimeout(()=>{j()},100)}catch{}},[]);const j=()=>{if(p.current)try{p.current.showPicker()}catch{}},S=A=>{A.stopPropagation()};return u.jsx("div",{ref:y,id:l,style:{top:(o==null?void 0:o.top)||0,left:(o==null?void 0:o.left)||0},className:"cosmic-ai-input-datePicker",suppressHydrationWarning:!0,children:u.jsx("input",{ref:p,type:"date",value:r||"",onChange:M,onClick:S})})});je.displayName="DatePicker";function pe(r){const o=r.textContent||"",l=r.nextSibling;o.length?(l==null||l.setAttribute("style","display: none"),r.style.padding="2px 4px",r.style.borderTopLeftRadius="2px",r.style.borderBottomLeftRadius="2px",r.style.borderTopRightRadius="2px",r.style.borderBottomRightRadius="2px"):(l==null||l.setAttribute("style","display: inline"),r.style.padding="2px 0 2px 4px",r.style.borderTopLeftRadius="2px",r.style.borderBottomLeftRadius="2px",r.style.borderTopRightRadius="0",r.style.borderBottomRightRadius="0")}function W(r){if(r&&r.getAttribute("data-set-type")==="input"){const o=r.children[0];o.setAttribute("contenteditable","true"),requestAnimationFrame(()=>{o.focus()})}}function Pe(r){r&&r.getAttribute("data-set-type")==="input"&&r.children[0].setAttribute("contenteditable","false")}function v(r){return r&&(r!=null&&r.getAttribute)?r.getAttribute("data-set-type")==="input":!1}const Be=c.forwardRef(({options:r,value:o,position:l,id:h,height:k=37,onChange:y},p)=>{const[M,j]=c.useState(o||""),S=c.useRef(null);c.useEffect(()=>{typeof p=="function"?p(S.current):p&&(p.current=S.current)},[p]);const A=T=>{const b=M.split(",").filter(E=>E)||[];let R="";b.includes(T)?R=b.filter(E=>E!==T).join(","):b.length?R=`${b.join(",")},${T}`:R=T,j(R),y==null||y(R,g.MULTIPLE_SELECT)},m=M.split(",")||[];return u.jsx("div",{ref:S,className:"cosmic-ai-input-selectFloatElement",id:h,style:{position:"absolute",top:(l==null?void 0:l.top)||0,left:(l==null?void 0:l.left)||0,zIndex:5e3,maxHeight:`${k}px`},children:r.map((T,b)=>u.jsx("div",{className:`selectOption ${m.includes(T)?"selected":""}`,onClick:()=>A(T),children:T},b))})});Be.displayName="MultipleSelect";const Me=c.forwardRef(({options:r,value:o,position:l,id:h,height:k=120,onChange:y},p)=>{const[M,j]=c.useState(o||""),S=c.useRef(null);c.useEffect(()=>{typeof p=="function"?p(S.current):p&&(p.current=S.current)},[p]);const A=m=>{j(m),y==null||y(m,g.SELECT)};return u.jsx("div",{ref:S,className:"cosmic-ai-input-selectFloatElement",id:h,style:{position:"absolute",top:(l==null?void 0:l.top)||0,left:(l==null?void 0:l.left)||0,zIndex:5e3,maxHeight:`${k}px`},children:r.length>0&&r.map((m,T)=>u.jsx("div",{className:`selectOption ${M===m?"selected":""}`,onClick:()=>A(m),children:m},T))})});Me.displayName="Select";function ke(r){const o=r instanceof Element?r:document.getElementById(r);return o&&o.children[0].textContent||""}function Oe(r,o){const l=r instanceof Element?r:document.getElementById(r);l&&(l.children[0].textContent=o)}function ee(r){const o=document.createRange(),l=window.getSelection();l&&(!r||!(r instanceof Node)||(o.selectNodeContents(r),o.collapse(!0),l.removeAllRanges(),l.addRange(o)))}function F(r){const o=document.createRange(),l=window.getSelection();l&&(!r||!(r instanceof Node)||(o.selectNodeContents(r),o.collapse(!1),l.removeAllRanges(),l.addRange(o)))}function he(r){const o=window.getSelection();if(!o||o.rangeCount===0)return 0;if(!r||!(r instanceof Node))return;const l=o.getRangeAt(0),h=l.cloneRange();return h.selectNodeContents(r),h.setEnd(l.startContainer,l.startOffset),h.toString().length}function ot(){const r=window.getSelection();if(!r||r.rangeCount===0)return null;const l=r.getRangeAt(0).startContainer;return l.nodeType===Node.TEXT_NODE?l.parentElement:l.nodeType===Node.ELEMENT_NODE?l:null}function at(){const r=window.getSelection();return!r||r.rangeCount===0?null:r.getRangeAt(0).getBoundingClientRect()}function dt(){return new Promise(r=>{requestAnimationFrame(()=>{r(at())})})}function ut(){const r=window.getSelection();if(!r||r.rangeCount===0)return null;const o=r.getRangeAt(0),l=o.startContainer,h=o.startOffset;return l.nodeType===Node.TEXT_NODE?h>0?l:l.previousSibling:l.nodeType===Node.ELEMENT_NODE?h>0?l.childNodes[h-1]:l.previousSibling:null}function ft(){const r=window.getSelection();if(!r||r.rangeCount===0)return null;const o=r.getRangeAt(0),l=o.startContainer,h=o.startOffset;return l.nodeType===Node.TEXT_NODE?h<l.length?l:l.nextSibling:l.nodeType===Node.ELEMENT_NODE?h<l.childNodes.length?l.childNodes[h]:l.nextSibling:null}function pt(r){return r&&!r.getAttribute("data-set-type")}function $e(){return`${Date.now()}-${Math.random().toString(36).slice(2,9)}`}const te=/iPhone|iPad|iPod/i.test(navigator.userAgent)||navigator.userAgent.includes("Mac")&&"ontouchend"in document,ht=/Android|iPhone|iPad|iPod|Mobile/i.test(navigator.userAgent)||"ontouchend"in document,_e=c.forwardRef(({options:r,value:o,position:l,id:h,height:k=120,onChange:y},p)=>{const[M,j]=c.useState(o||""),[S,A]=c.useState(0),m=c.useRef(null),T=c.useRef(S),b=c.useCallback(R=>{j(R),y==null||y(R,g.LABEL)},[y]);return c.useEffect(()=>{typeof p=="function"?p(m.current):p&&(p.current=m.current)},[p]),c.useEffect(()=>{T.current=S},[S]),c.useEffect(()=>{A(0)},[r]),c.useEffect(()=>{const R=E=>{r.length!==0&&(E.key==="ArrowDown"?(E.preventDefault(),A(w=>w<r.length-1?w+1:w)):E.key==="ArrowUp"?(E.preventDefault(),A(w=>w>0?w-1:w)):E.key==="Enter"&&(E.preventDefault(),setTimeout(()=>{const w=T.current;w>=0&&r[w]&&b(r[w])},0)))};return document.addEventListener("keydown",R),()=>{document.removeEventListener("keydown",R)}},[r,b]),u.jsx("div",{ref:m,className:"cosmic-ai-input-selectFloatElement",id:h,style:{position:"absolute",top:(l==null?void 0:l.top)||0,left:(l==null?void 0:l.left)||0,zIndex:5e3,maxHeight:`${k}px`},children:r.length>0&&r.map((R,E)=>u.jsx("div",{className:`selectOption ${M===R?"selected":""} ${S===E?"highlighted":""}`,onClick:()=>b(R),onMouseEnter:()=>A(E),children:R},E))})});_e.displayName="Mention";const He=c.forwardRef((r,o)=>{const{value:l="",varList:h,placeholder:k="",maxLength:y,defaultRows:p=3,disabled:M=!1,defaultFocus:j=!1,textIndex:S=0,mentions:A=[],onFocus:m,onBlur:T,onChange:b,onClick:R,onSend:E,onKeyDown:w,onKeyUp:q,onMaxLengthExceeded:ne}=r,[gt,Et]=c.useState(l||""),[se,G]=c.useState(""),[yt,ie]=c.useState(""),[V,_]=c.useState(!1),[I,U]=c.useState({top:0,left:0}),[re,le]=c.useState([]),[X,ge]=c.useState(""),[C,ce]=c.useState(null),[oe,J]=c.useState(120),[Ee,ye]=c.useState(j),be=240,xe=240,Ae=240,Re=276,x=c.useRef(null),L=c.useRef(null),$=c.useRef(null),z=c.useRef(!1),D=(t,s)=>t.code===s||t.key===s,H=()=>{var s,e;let t=((e=(s=x.current)==null?void 0:s.innerText)==null?void 0:e.replace(/\u200B/g,""))||"";return t===`
|
|
3
|
+
`&&(t=""),t},ae=()=>{var s;let t=((s=x.current)==null?void 0:s.innerHTML)||"";return t==="<br>"&&(t=""),t},We=t=>{const s=[];let e=0;const i=/\[([^\]]+)\]/g;let a;const d=$e();let f=0;if(t===""||!t||t===`
|
|
4
4
|
`)return[{type:"text",content:"",id:`text-${f++}-${d}`}];const O=new Set((h||[]).map(N=>N.name));for(;(a=i.exec(t))!==null;){if(a.index>e){const B=t.substring(e,a.index).split(`
|
|
5
5
|
`);B.forEach((Y,lt)=>{Y&&s.push({type:"text",content:Y,id:`text-${f++}-${d}`}),lt<B.length-1&&s.push({type:"newline",id:`newline-${f++}-${d}`})})}const N=a[1];if(O.has(N)){const n=h.find(B=>B.name===N);(n==null?void 0:n.type)==="input"?s.push({type:"input",name:n==null?void 0:n.name,content:(n==null?void 0:n.content)||"",placeholder:(n==null?void 0:n.placeholder)||N,id:`input-${f++}-${d}`}):(n==null?void 0:n.type)==="label"?s.push({type:"label",name:n==null?void 0:n.name,content:(n==null?void 0:n.content)||"",id:`label-${f++}-${d}`}):(n==null?void 0:n.type)==="select"?s.push({type:"select",name:n==null?void 0:n.name,content:(n==null?void 0:n.content)||"",placeholder:(n==null?void 0:n.placeholder)||N,options:(n==null?void 0:n.options)||[],id:`select-${f++}-${d}`}):(n==null?void 0:n.type)==="multiple-select"?s.push({type:"multiple-select",name:n==null?void 0:n.name,content:(n==null?void 0:n.content)||"",placeholder:(n==null?void 0:n.placeholder)||N,options:(n==null?void 0:n.options)||[],id:`multiple-select-${f++}-${d}`}):(n==null?void 0:n.type)==="date-picker"&&s.push({type:"date-picker",name:n==null?void 0:n.name,content:(n==null?void 0:n.content)||"",placeholder:(n==null?void 0:n.placeholder)||N,id:`date-picker-${f++}-${d}`})}else s.push({type:"text",content:`[${N}]`,id:`text-${f++}-${d}`});e=i.lastIndex}if(e<t.length){const n=t.substring(e).split(`
|
|
6
|
-
`);n.forEach((B,Y)=>{B&&s.push({type:"text",content:B,id:`text-${f++}`}),Y<n.length-1&&s.push({type:"newline",id:`newline-${f++}`})})}return s},de=()=>{var t;(t=A.current)==null||t.setAttribute("contenteditable","true"),L.current&&(v(L.current)&&L.current.children[0].setAttribute("contenteditable","false"),L.current=null),te||F(A.current)},Fe=t=>{R==null||R(t)},Ce=t=>{de()},K=t=>{var e,i;const s=t.nativeEvent;if(z.current||s!=null&&s.isComposing){H().length>0?(e=A.current)==null||e.classList.remove("is-empty"):(i=A.current)==null||i.classList.add("is-empty");return}G(H()),ie(ae()),b==null||b(H()),tt(t)},ve=t=>{var s,e;if(!(z.current||(s=t.nativeEvent)!=null&&s.isComposing)&&D(t,P.ENTER)&&!t.shiftKey&&!ht){t.preventDefault();const i=H();if(i.length===0||(e=A.current)!=null&&e.innerHTML.match(/^<span>[\s\u200B]*(<br\s*\/?>[\s\u200B]*)+<\/span>$/))return;y?i.length<=y?E==null||E(i):ne==null||ne(i,y):E==null||E(i)}},qe=t=>{var e;if(V&&(C==null?void 0:C.type)===g.LABEL&&(D(t,P.ARROW_UP)||D(t,P.ARROW_DOWN)||D(t,P.ENTER))){t.preventDefault();return}_(!1),w==null||w(t);const s=ot();if(s&&pt(s)){if(D(t,P.ARROW_LEFT)){const i=s==null?void 0:s.previousElementSibling,a=he(s);i&&a===0&&v(i)&&i.children[0]&&(L.current=i,W(i),requestAnimationFrame(()=>{F(i.children[0])}))}if(D(t,P.ARROW_RIGHT)){const i=s==null?void 0:s.nextElementSibling,a=he(s);i&&a===((e=s.textContent)==null?void 0:e.length)&&v(i)&&i.children[0]&&(L.current=i,W(i),requestAnimationFrame(()=>{ee(i.children[0])}))}}if(D(t,P.BACKSPACE)&&t.target){const i=t.target;if(i.childElementCount===1&&i.children[0].tagName==="SPAN"){const a=i.children[0];i.childNodes.length===1&&(a.innerHTML===""&&t.preventDefault(),a.innerHTML==="<br>"&&(t.preventDefault(),a.innerHTML=""))}}if(s&&s.getAttribute("data-set-type")==="container"){if(D(t,P.ARROW_LEFT)){const i=ut();v(i)&&i.children[0]&&(L.current=i,W(i),requestAnimationFrame(()=>{F(i.children[0])}))}if(D(t,P.ARROW_RIGHT)){const i=ft();v(i)&&i.children[0]&&(L.current=i,W(i),requestAnimationFrame(()=>{ee(i.children[0])}))}}ve(t)},Ke=t=>{if(V&&(C==null?void 0:C.type)===g.LABEL&&(D(t,P.ARROW_UP)||D(t,P.ARROW_DOWN)||D(t,P.ENTER))){t.preventDefault();return}q==null||q(t)},Ve=t=>{const e=t.clipboardData.items;for(let i=0;i<e.length;i++)if(e[i].type.indexOf("image")!==-1){t.preventDefault();return}},Ue=t=>{t.preventDefault();const e=window.getSelection().toString();if(!e)return;const i=e.replace(/\u200B/g,"")||"",a=e.replace(/\u200B/g,"")||"";t.clipboardData.setData("text/plain",i),t.clipboardData.setData("text/html",a)},ze=t=>{m==null||m(t)},Ge=()=>{z.current=!0},Ie=()=>{setTimeout(()=>{G(H()),ie(ae()),b==null||b(H())},0)},Xe=(t,s)=>{s.stopPropagation()},me=(t,s)=>{var i;te||s.stopPropagation(),L.current&&Pe(L.current),(i=A.current)==null||i.setAttribute("contenteditable","false");const e=document.getElementById(t.id);L.current=e,requestAnimationFrame(()=>{W(e)})},Je=(t,s)=>{var a,d,f,O,N;w==null||w(s),s.stopPropagation();const e=s.target,i=he(e);if(D(s,P.BACKSPACE)&&i===0){const n=(a=e.parentElement)==null?void 0:a.previousElementSibling;n&&(v(n)&&n.children[0]&&((d=n.children[0].textContent)!=null&&d.length)?(L.current=n,W(n),F(n.children[0]),requestAnimationFrame(()=>{pe(n.children[0])})):(de(),F(n)))}if(D(s,P.ARROW_RIGHT)&&i===((f=e.textContent)==null?void 0:f.length)){const n=(O=e.parentElement)==null?void 0:O.nextElementSibling;n&&(v(n)&&n.children[0]&&((N=n.children[0].textContent)!=null&&N.length)?(L.current=n,W(n),ee(n.children[0]),requestAnimationFrame(()=>{pe(n.children[0])})):(de(),ee(n)))}D(s,P.ENTER)&&s.shiftKey&&s.preventDefault()},Qe=(t,s)=>{q==null||q(s);const e=s.target;pe(e)},we=(t,s)=>{var i;te||s.stopPropagation(),L.current&&Pe(L.current),(i=A.current)==null||i.setAttribute("contenteditable","false");const e=document.getElementById(t.id);L.current=e,requestAnimationFrame(()=>{W(e)})},Ze=(t,s)=>{G(H()),ie(ae()),b==null||b(H())},Ye=(t,s)=>{};c.useEffect(()=>{if(!V)return;const t=i=>{$.current&&!$.current.contains(i.target)&&_(!1)},s=i=>{$.current&&!$.current.contains(i.target)&&_(!1)},e=()=>{_(!1)};return document.addEventListener("mousedown",t),document.addEventListener("scroll",s,!0),window.addEventListener("resize",e),()=>{document.removeEventListener("mousedown",t),document.removeEventListener("scroll",s,!0),window.removeEventListener("resize",e)}},[V]);const Q=(t,s)=>{if(C&&s!==g.LABEL&&Oe(C.id,t),s===g.SELECT&&(_(!1),K({})),s===g.LABEL&&(fe(),_(!1),requestAnimationFrame(()=>{const e=window.getSelection();e&&Z.current&&(e.removeAllRanges(),e.addRange(Z.current),setTimeout(()=>{var f;const i=document.createElement("span");i.contentEditable="false",i.setAttribute("data-set-type","label"),i.id=C.id;const a=document.createElement("span");a.contentEditable="false",a.textContent=t,i.appendChild(a);const d=(f=A.current)==null?void 0:f.children;if((d==null?void 0:d.length)===1&&d[0].tagName==="SPAN"&&d[0].innerHTML==="[")A.current.innerHTML="",A.current.appendChild(i),setTimeout(()=>{K({}),fe()},0);else{document.execCommand("delete",!1,void 0);const O=Z.current;O.insertNode(i),O.setStartAfter(i),O.setEndAfter(i),e.removeAllRanges(),e.addRange(O),setTimeout(()=>{K({})},0)}},0))})),s===g.MULTIPLE_SELECT||s===g.DATE_PICKER){const e=document.getElementById(C.id);e&&e.children[0]&&e.children[1]&&(t.length>0?(e.children[0].setAttribute("style","display: inline"),e.children[0].setAttribute("contenteditable","false"),e.children[1].setAttribute("style","display: none"),e.children[1].setAttribute("contenteditable","true")):(e.children[0].setAttribute("style","display: none"),e.children[0].setAttribute("contenteditable","true"),e.children[1].setAttribute("style","display: inline"),e.children[1].setAttribute("contenteditable","true"))),K({})}},Z=c.useRef(null),et=(x==null?void 0:x.map(t=>t.prefix))||[],tt=t=>{const s=t==null?void 0:t.nativeEvent,e=s==null?void 0:s.data;et.includes(e)&&dt().then(i=>{var d;const a=window.getSelection();a&&a.rangeCount>0&&(Z.current=a.getRangeAt(0)),nt({options:((d=x.find(f=>f.prefix===e))==null?void 0:d.options)||[],value:"",type:g.LABEL,id:"label-"+$e()},i)})},nt=(t,s)=>{le(t.options),U({top:-999999,left:-999999999}),ce(t),J(Ae),_(!0),requestAnimationFrame(()=>{if($.current){const e=$.current.getBoundingClientRect();let i=s.left,a=s.top+s.height;window.innerWidth-s.right<be&&s.width<e.width&&(i=s.right-e.width),s.top<e.height&&(a=s.top+s.height),U({top:a,left:i}),J(e.height)}})},Te=(t,s)=>{const i=s.target.getBoundingClientRect();le(t.options),ge(t.value||ke(t.id)),U({top:-999999,left:-999999999}),ce(t),J(Ae),_(!0),requestAnimationFrame(()=>{if($.current){const a=$.current.getBoundingClientRect();let d=i.left,f=i.top+i.height;window.innerWidth-i.right<be&&i.width<a.width&&(d=i.right-a.width),i.top<a.height&&(f=i.top+i.height),U({top:f,left:d}),J(a.height)}})},st=(t,s)=>{const i=s.target.getBoundingClientRect();let a=i.left,d=i.top-Re;window.innerWidth-i.right<xe&&(a=a-xe+i.width),i.top<Re&&(d=i.top+i.height),le(t.options),ge(t.value||ke(t.id)),U({top:d,left:a}),ce(t),_(!0)},it=(t,s)=>{Oe(t,s);const e=document.getElementById(t);e&&e.children[0]&&e.children[1]&&(s.length>0?(e.children[0].setAttribute("style","display: inline"),e.children[0].setAttribute("contenteditable","false"),e.children[1].setAttribute("style","display: none"),e.children[1].setAttribute("contenteditable","true")):(e.children[0].setAttribute("style","display: none"),e.children[0].setAttribute("contenteditable","true"),e.children[1].setAttribute("style","display: inline"),e.children[1].setAttribute("contenteditable","true"))),K({})},[rt,Se]=c.useState([]),[ue,Le]=c.useState(!0),Ne=c.useCallback(()=>{Le(!1);const t=We(l),s=[];return t.forEach(e=>{var i,a,d,f,O,N;if(e.type==="text")s.push(u.jsx("span",{onKeyDown:n=>Ye(),children:e.content},e.id));else if(e.type==="newline")s.push(u.jsx("br",{},e.id));else if(e.type==="label")s.push(u.jsx("span",{id:e.id,"data-set-type":"label",contentEditable:!1,children:u.jsx("span",{contentEditable:!1,children:e.name})},e.id));else if(e.type==="input")s.push(u.jsxs("span",{id:e.id,"data-set-type":"input",contentEditable:!1,suppressContentEditableWarning:!0,onInput:n=>Ze(),onClick:n=>Xe(e,n),onMouseDown:n=>me(e,n),onTouchEnd:n=>me(e,n),"data-cosmic-ai-input-placeholder":e.placeholder,children:[u.jsx("span",{className:"cosmic-ai-input-inputContent",style:{padding:(i=e.content)!=null&&i.length?"2px 4px":"2px 0 2px 4px"},contentEditable:!1,onKeyDown:n=>Je(e,n),onKeyUp:n=>Qe(e,n),children:e.content}),u.jsx("span",{contentEditable:!1,style:{display:(a=e.content)!=null&&a.length?"none":"inline"},className:"cosmic-ai-input-placeholder",onMouseDown:n=>we(e,n),onTouchEnd:n=>we(e,n),children:e.placeholder})]},e.id));else if(e.type===g.SELECT){const n=e.content||((d=e.options)==null?void 0:d[0])||e.placeholder;s.push(u.jsx("span",{id:e.id,"data-set-type":"select",contentEditable:!1,suppressContentEditableWarning:!0,onClick:B=>Te(e,B),"data-cosmic-ai-input-placeholder":e.placeholder,children:u.jsx("span",{contentEditable:!1,children:n})},e.id))}else if(e.type===g.MULTIPLE_SELECT){const n=e.content||((f=e.options)==null?void 0:f[0]);s.push(u.jsxs("span",{id:e.id,"data-set-type":"multiple-select",contentEditable:!1,suppressContentEditableWarning:!0,onClick:B=>Te(e,B),"data-cosmic-ai-input-placeholder":e.placeholder,children:[u.jsx("span",{style:{display:n!=null&&n.length?"inline":"none"},contentEditable:!1,children:n}),u.jsx("span",{style:{display:n!=null&&n.length?"none":"inline"},className:"cosmic-ai-input-selectPlaceholder",contentEditable:!1,children:e.placeholder})]},e.id))}else e.type===g.DATE_PICKER&&s.push(u.jsxs("span",{id:e.id,"data-set-type":"date-picker",contentEditable:!1,suppressContentEditableWarning:!0,onClick:n=>st(e,n),"data-cosmic-ai-input-placeholder":e.placeholder,children:[u.jsx("span",{style:{display:(O=e.content)!=null&&O.length?"inline":"none"},contentEditable:!1,children:e.content}),u.jsx("span",{style:{display:(N=e.content)!=null&&N.length?"none":"inline"},className:"cosmic-ai-input-datePickerPlaceholder",contentEditable:!1,children:e.placeholder}),te&&u.jsx("input",{className:"cosmic-ai-input-ios-date-picker",type:"date",onChange:n=>{it(e.id,n.target.value)}})]},e.id))}),setTimeout(()=>{Le(!0)},0),s},[l]);c.useEffect(()=>{ue&&setTimeout(()=>{F(A.current)},0)},[ue]),c.useEffect(()=>{l!==se&&z.current===!1?(Se(Ne()),G(l),ye(!0)):(l===""||!l)&&Se(Ne()),z.current=!1},[l,se]),c.useEffect(()=>{if(!j&&!Ee)return;const t=new MutationObserver(()=>{A.current&&document.contains(A.current)&&(requestAnimationFrame(()=>{F(A.current),ye(!1)}),t.disconnect())});return A.current&&t.observe(document.body,{childList:!0,subtree:!0}),()=>t.disconnect()},[j,Ee]);const fe=()=>{A.current&&requestAnimationFrame(()=>{F(A.current)})};return c.useImperativeHandle(o,()=>({getCurrentValue:H,focus:fe})),u.jsxs("div",{className:De(`cosmic-ai-input-rows${p}`),style:{textIndent:S+"px"},children:[ue&&u.jsx("div",{"data-set-type":"container","data-cosmic-ai-input-placeholder":k,className:De("cosmic-ai-input",`cosmic-ai-input-rows${p}`,{"is-disabled":M},{"is-empty":se.length===0}),ref:A,contentEditable:!0,suppressContentEditableWarning:!0,onClick:t=>Fe(t),onFocus:t=>{ze(t)},onBlur:t=>{T==null||T(t)},onMouseDown:t=>Ce(),onTouchEnd:t=>Ce(),onKeyDown:t=>qe(t),onKeyUp:t=>Ke(t),onInput:t=>K(t),onCopy:t=>Ue(t),onPaste:t=>Ve(t),onCompositionStart:Ge,onCompositionEnd:Ie,children:rt}),V&&ct.createPortal((C==null?void 0:C.type)===g.MULTIPLE_SELECT?u.jsx(Be,{ref:$,options:re,value:X,position:I,height:oe,onChange:Q},g.MULTIPLE_SELECT):(C==null?void 0:C.type)===g.DATE_PICKER?u.jsx(je,{ref:$,value:X,position:I,onChange:Q},g.DATE_PICKER):(C==null?void 0:C.type)===g.LABEL?u.jsx(_e,{ref:$,options:re,value:X,position:I,height:oe,onChange:Q},g.LABEL):u.jsx(Me,{ref:$,options:re,value:X,position:I,height:oe,onChange:Q},g.SELECT),document.body)]})});He.displayName="AiInput";exports.default=He;
|
|
6
|
+
`);n.forEach((B,Y)=>{B&&s.push({type:"text",content:B,id:`text-${f++}`}),Y<n.length-1&&s.push({type:"newline",id:`newline-${f++}`})})}return s},de=()=>{var t;(t=x.current)==null||t.setAttribute("contenteditable","true"),L.current&&(v(L.current)&&L.current.children[0].setAttribute("contenteditable","false"),L.current=null),te||F(x.current)},Fe=t=>{R==null||R(t)},Ce=t=>{de()},K=t=>{var e,i;const s=t.nativeEvent;if(z.current||s!=null&&s.isComposing){H().length>0?(e=x.current)==null||e.classList.remove("is-empty"):(i=x.current)==null||i.classList.add("is-empty");return}G(H()),ie(ae()),b==null||b(H()),tt(t)},ve=t=>{var s,e;if(!(z.current||(s=t.nativeEvent)!=null&&s.isComposing)&&D(t,P.ENTER)&&!t.shiftKey&&!ht){t.preventDefault();const i=H();if(i.length===0||(e=x.current)!=null&&e.innerHTML.match(/^<span>[\s\u200B]*(<br\s*\/?>[\s\u200B]*)+<\/span>$/))return;y?i.length<=y?E==null||E(i):ne==null||ne(i,y):E==null||E(i)}},qe=t=>{var e;if(V&&(C==null?void 0:C.type)===g.LABEL&&(D(t,P.ARROW_UP)||D(t,P.ARROW_DOWN)||D(t,P.ENTER))){t.preventDefault();return}_(!1),w==null||w(t);const s=ot();if(s&&pt(s)){if(D(t,P.ARROW_LEFT)){const i=s==null?void 0:s.previousElementSibling,a=he(s);i&&a===0&&v(i)&&i.children[0]&&(L.current=i,W(i),requestAnimationFrame(()=>{F(i.children[0])}))}if(D(t,P.ARROW_RIGHT)){const i=s==null?void 0:s.nextElementSibling,a=he(s);i&&a===((e=s.textContent)==null?void 0:e.length)&&v(i)&&i.children[0]&&(L.current=i,W(i),requestAnimationFrame(()=>{ee(i.children[0])}))}}if(D(t,P.BACKSPACE)&&t.target){const i=t.target;if(i.childElementCount===1&&i.children[0].tagName==="SPAN"){const a=i.children[0];i.childNodes.length===1&&(a.innerHTML===""&&t.preventDefault(),a.innerHTML==="<br>"&&(t.preventDefault(),a.innerHTML=""))}}if(s&&s.getAttribute("data-set-type")==="container"){if(D(t,P.ARROW_LEFT)){const i=ut();v(i)&&i.children[0]&&(L.current=i,W(i),requestAnimationFrame(()=>{F(i.children[0])}))}if(D(t,P.ARROW_RIGHT)){const i=ft();v(i)&&i.children[0]&&(L.current=i,W(i),requestAnimationFrame(()=>{ee(i.children[0])}))}}ve(t)},Ke=t=>{if(V&&(C==null?void 0:C.type)===g.LABEL&&(D(t,P.ARROW_UP)||D(t,P.ARROW_DOWN)||D(t,P.ENTER))){t.preventDefault();return}q==null||q(t)},Ve=t=>{t.preventDefault();const s=t.clipboardData,e=s.items;for(let a=0;a<e.length;a++)if(e[a].type.indexOf("image")!==-1)return;const i=s.getData("text/plain");i&&document.execCommand("insertText",!1,i)},Ue=t=>{t.preventDefault();const e=window.getSelection().toString();if(!e)return;const i=e.replace(/\u200B/g,"")||"",a=e.replace(/\u200B/g,"")||"";t.clipboardData.setData("text/plain",i),t.clipboardData.setData("text/html",a)},ze=t=>{m==null||m(t)},Ge=()=>{z.current=!0},Ie=()=>{setTimeout(()=>{G(H()),ie(ae()),b==null||b(H())},0)},Xe=(t,s)=>{s.stopPropagation()},me=(t,s)=>{var i;te||s.stopPropagation(),L.current&&Pe(L.current),(i=x.current)==null||i.setAttribute("contenteditable","false");const e=document.getElementById(t.id);L.current=e,requestAnimationFrame(()=>{W(e)})},Je=(t,s)=>{var a,d,f,O,N;w==null||w(s),s.stopPropagation();const e=s.target,i=he(e);if(D(s,P.BACKSPACE)&&i===0){const n=(a=e.parentElement)==null?void 0:a.previousElementSibling;n&&(v(n)&&n.children[0]&&((d=n.children[0].textContent)!=null&&d.length)?(L.current=n,W(n),F(n.children[0]),requestAnimationFrame(()=>{pe(n.children[0])})):(de(),F(n)))}if(D(s,P.ARROW_RIGHT)&&i===((f=e.textContent)==null?void 0:f.length)){const n=(O=e.parentElement)==null?void 0:O.nextElementSibling;n&&(v(n)&&n.children[0]&&((N=n.children[0].textContent)!=null&&N.length)?(L.current=n,W(n),ee(n.children[0]),requestAnimationFrame(()=>{pe(n.children[0])})):(de(),ee(n)))}D(s,P.ENTER)&&s.shiftKey&&s.preventDefault()},Qe=(t,s)=>{q==null||q(s);const e=s.target;pe(e)},we=(t,s)=>{var i;te||s.stopPropagation(),L.current&&Pe(L.current),(i=x.current)==null||i.setAttribute("contenteditable","false");const e=document.getElementById(t.id);L.current=e,requestAnimationFrame(()=>{W(e)})},Ze=(t,s)=>{G(H()),ie(ae()),b==null||b(H())},Ye=(t,s)=>{};c.useEffect(()=>{if(!V)return;const t=i=>{$.current&&!$.current.contains(i.target)&&_(!1)},s=i=>{$.current&&!$.current.contains(i.target)&&_(!1)},e=()=>{_(!1)};return document.addEventListener("mousedown",t),document.addEventListener("scroll",s,!0),window.addEventListener("resize",e),()=>{document.removeEventListener("mousedown",t),document.removeEventListener("scroll",s,!0),window.removeEventListener("resize",e)}},[V]);const Q=(t,s)=>{if(C&&s!==g.LABEL&&Oe(C.id,t),s===g.SELECT&&(_(!1),K({})),s===g.LABEL&&(fe(),_(!1),requestAnimationFrame(()=>{const e=window.getSelection();e&&Z.current&&(e.removeAllRanges(),e.addRange(Z.current),setTimeout(()=>{var f;const i=document.createElement("span");i.contentEditable="false",i.setAttribute("data-set-type","label"),i.id=C.id;const a=document.createElement("span");a.contentEditable="false",a.textContent=t,i.appendChild(a);const d=(f=x.current)==null?void 0:f.children;if((d==null?void 0:d.length)===1&&d[0].tagName==="SPAN"&&d[0].innerHTML==="[")x.current.innerHTML="",x.current.appendChild(i),setTimeout(()=>{K({}),fe()},0);else{document.execCommand("delete",!1,void 0);const O=Z.current;O.insertNode(i),O.setStartAfter(i),O.setEndAfter(i),e.removeAllRanges(),e.addRange(O),setTimeout(()=>{K({})},0)}},0))})),s===g.MULTIPLE_SELECT||s===g.DATE_PICKER){const e=document.getElementById(C.id);e&&e.children[0]&&e.children[1]&&(t.length>0?(e.children[0].setAttribute("style","display: inline"),e.children[0].setAttribute("contenteditable","false"),e.children[1].setAttribute("style","display: none"),e.children[1].setAttribute("contenteditable","true")):(e.children[0].setAttribute("style","display: none"),e.children[0].setAttribute("contenteditable","true"),e.children[1].setAttribute("style","display: inline"),e.children[1].setAttribute("contenteditable","true"))),K({})}},Z=c.useRef(null),et=(A==null?void 0:A.map(t=>t.prefix))||[],tt=t=>{const s=t==null?void 0:t.nativeEvent,e=s==null?void 0:s.data;et.includes(e)&&dt().then(i=>{var d;const a=window.getSelection();a&&a.rangeCount>0&&(Z.current=a.getRangeAt(0)),nt({options:((d=A.find(f=>f.prefix===e))==null?void 0:d.options)||[],value:"",type:g.LABEL,id:"label-"+$e()},i)})},nt=(t,s)=>{le(t.options),U({top:-999999,left:-999999999}),ce(t),J(xe),_(!0),requestAnimationFrame(()=>{if($.current){const e=$.current.getBoundingClientRect();let i=s.left,a=s.top+s.height;window.innerWidth-s.right<be&&s.width<e.width&&(i=s.right-e.width),s.top<e.height&&(a=s.top+s.height),U({top:a,left:i}),J(e.height)}})},Te=(t,s)=>{const i=s.target.getBoundingClientRect();le(t.options),ge(t.value||ke(t.id)),U({top:-999999,left:-999999999}),ce(t),J(xe),_(!0),requestAnimationFrame(()=>{if($.current){const a=$.current.getBoundingClientRect();let d=i.left,f=i.top+i.height;window.innerWidth-i.right<be&&i.width<a.width&&(d=i.right-a.width),i.top<a.height&&(f=i.top+i.height),U({top:f,left:d}),J(a.height)}})},st=(t,s)=>{const i=s.target.getBoundingClientRect();let a=i.left,d=i.top-Re;window.innerWidth-i.right<Ae&&(a=a-Ae+i.width),i.top<Re&&(d=i.top+i.height),le(t.options),ge(t.value||ke(t.id)),U({top:d,left:a}),ce(t),_(!0)},it=(t,s)=>{Oe(t,s);const e=document.getElementById(t);e&&e.children[0]&&e.children[1]&&(s.length>0?(e.children[0].setAttribute("style","display: inline"),e.children[0].setAttribute("contenteditable","false"),e.children[1].setAttribute("style","display: none"),e.children[1].setAttribute("contenteditable","true")):(e.children[0].setAttribute("style","display: none"),e.children[0].setAttribute("contenteditable","true"),e.children[1].setAttribute("style","display: inline"),e.children[1].setAttribute("contenteditable","true"))),K({})},[rt,Se]=c.useState([]),[ue,Le]=c.useState(!0),Ne=c.useCallback(()=>{Le(!1);const t=We(l),s=[];return t.forEach(e=>{var i,a,d,f,O,N;if(e.type==="text")s.push(u.jsx("span",{onKeyDown:n=>Ye(),children:e.content},e.id));else if(e.type==="newline")s.push(u.jsx("br",{},e.id));else if(e.type==="label")s.push(u.jsx("span",{id:e.id,"data-set-type":"label",contentEditable:!1,children:u.jsx("span",{contentEditable:!1,children:e.name})},e.id));else if(e.type==="input")s.push(u.jsxs("span",{id:e.id,"data-set-type":"input",contentEditable:!1,suppressContentEditableWarning:!0,onInput:n=>Ze(),onClick:n=>Xe(e,n),onMouseDown:n=>me(e,n),onTouchEnd:n=>me(e,n),"data-cosmic-ai-input-placeholder":e.placeholder,children:[u.jsx("span",{className:"cosmic-ai-input-inputContent",style:{padding:(i=e.content)!=null&&i.length?"2px 4px":"2px 0 2px 4px"},contentEditable:!1,onKeyDown:n=>Je(e,n),onKeyUp:n=>Qe(e,n),children:e.content}),u.jsx("span",{contentEditable:!1,style:{display:(a=e.content)!=null&&a.length?"none":"inline"},className:"cosmic-ai-input-placeholder",onMouseDown:n=>we(e,n),onTouchEnd:n=>we(e,n),children:e.placeholder})]},e.id));else if(e.type===g.SELECT){const n=e.content||((d=e.options)==null?void 0:d[0])||e.placeholder;s.push(u.jsx("span",{id:e.id,"data-set-type":"select",contentEditable:!1,suppressContentEditableWarning:!0,onClick:B=>Te(e,B),"data-cosmic-ai-input-placeholder":e.placeholder,children:u.jsx("span",{contentEditable:!1,children:n})},e.id))}else if(e.type===g.MULTIPLE_SELECT){const n=e.content||((f=e.options)==null?void 0:f[0]);s.push(u.jsxs("span",{id:e.id,"data-set-type":"multiple-select",contentEditable:!1,suppressContentEditableWarning:!0,onClick:B=>Te(e,B),"data-cosmic-ai-input-placeholder":e.placeholder,children:[u.jsx("span",{style:{display:n!=null&&n.length?"inline":"none"},contentEditable:!1,children:n}),u.jsx("span",{style:{display:n!=null&&n.length?"none":"inline"},className:"cosmic-ai-input-selectPlaceholder",contentEditable:!1,children:e.placeholder})]},e.id))}else e.type===g.DATE_PICKER&&s.push(u.jsxs("span",{id:e.id,"data-set-type":"date-picker",contentEditable:!1,suppressContentEditableWarning:!0,onClick:n=>st(e,n),"data-cosmic-ai-input-placeholder":e.placeholder,children:[u.jsx("span",{style:{display:(O=e.content)!=null&&O.length?"inline":"none"},contentEditable:!1,children:e.content}),u.jsx("span",{style:{display:(N=e.content)!=null&&N.length?"none":"inline"},className:"cosmic-ai-input-datePickerPlaceholder",contentEditable:!1,children:e.placeholder}),te&&u.jsx("input",{style:{position:"absolute",left:0,opacity:0},type:"date",onChange:n=>{it(e.id,n.target.value)}})]},e.id))}),setTimeout(()=>{Le(!0)},0),s},[l]);c.useEffect(()=>{ue&&setTimeout(()=>{F(x.current)},0)},[ue]),c.useEffect(()=>{l!==se&&z.current===!1?(Se(Ne()),G(l),ye(!0)):(l===""||!l)&&Se(Ne()),z.current=!1},[l,se]),c.useEffect(()=>{if(!j&&!Ee)return;const t=new MutationObserver(()=>{x.current&&document.contains(x.current)&&(requestAnimationFrame(()=>{F(x.current),ye(!1)}),t.disconnect())});return x.current&&t.observe(document.body,{childList:!0,subtree:!0}),()=>t.disconnect()},[j,Ee]);const fe=()=>{x.current&&requestAnimationFrame(()=>{F(x.current)})};return c.useImperativeHandle(o,()=>({getCurrentValue:H,focus:fe})),u.jsxs("div",{className:De(`cosmic-ai-input-rows${p}`),style:{textIndent:S+"px"},children:[ue&&u.jsx("div",{"data-set-type":"container","data-cosmic-ai-input-placeholder":k,className:De("cosmic-ai-input",`cosmic-ai-input-rows${p}`,{"is-disabled":M},{"is-empty":se.length===0}),ref:x,contentEditable:!0,suppressContentEditableWarning:!0,onClick:t=>Fe(t),onFocus:t=>{ze(t)},onBlur:t=>{T==null||T(t)},onMouseDown:t=>Ce(),onTouchEnd:t=>Ce(),onKeyDown:t=>qe(t),onKeyUp:t=>Ke(t),onInput:t=>K(t),onCopy:t=>Ue(t),onPaste:t=>Ve(t),onCompositionStart:Ge,onCompositionEnd:Ie,children:rt}),V&&ct.createPortal((C==null?void 0:C.type)===g.MULTIPLE_SELECT?u.jsx(Be,{ref:$,options:re,value:X,position:I,height:oe,onChange:Q},g.MULTIPLE_SELECT):(C==null?void 0:C.type)===g.DATE_PICKER?u.jsx(je,{ref:$,value:X,position:I,onChange:Q},g.DATE_PICKER):(C==null?void 0:C.type)===g.LABEL?u.jsx(_e,{ref:$,options:re,value:X,position:I,height:oe,onChange:Q},g.LABEL):u.jsx(Me,{ref:$,options:re,value:X,position:I,height:oe,onChange:Q},g.SELECT),document.body)]})});He.displayName="AiInput";exports.default=He;
|
package/dist/index.es.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
// Generated at: 2026-
|
|
1
|
+
// Generated at: 2026-05-11T02:34:16.035Z
|
|
2
2
|
import { jsx as u, jsxs as ie } from "react/jsx-runtime";
|
|
3
3
|
import { forwardRef as X, useRef as H, useEffect as B, useState as S, useCallback as We, useImperativeHandle as ut } from "react";
|
|
4
4
|
import $e from "classnames";
|
|
5
5
|
import { createPortal as ft } from "react-dom";
|
|
6
|
-
var h = /* @__PURE__ */ ((
|
|
6
|
+
var h = /* @__PURE__ */ ((s) => (s.INPUT = "input", s.SELECT = "select", s.MULTIPLE_SELECT = "multiple-select", s.DATE_PICKER = "date-picker", s.LABEL = "label", s))(h || {});
|
|
7
7
|
const P = {
|
|
8
8
|
BACKSPACE: "Backspace",
|
|
9
9
|
ARROW_LEFT: "ArrowLeft",
|
|
@@ -12,7 +12,7 @@ const P = {
|
|
|
12
12
|
ARROW_DOWN: "ArrowDown",
|
|
13
13
|
ENTER: "Enter"
|
|
14
14
|
}, Fe = X(
|
|
15
|
-
({ value:
|
|
15
|
+
({ value: s, position: o, id: r, onChange: p }, k) => {
|
|
16
16
|
const E = H(null), f = H(null);
|
|
17
17
|
B(() => {
|
|
18
18
|
typeof k == "function" ? k(E.current) : k && (k.current = E.current);
|
|
@@ -36,14 +36,14 @@ const P = {
|
|
|
36
36
|
f.current.showPicker();
|
|
37
37
|
} catch {
|
|
38
38
|
}
|
|
39
|
-
},
|
|
39
|
+
}, w = (A) => {
|
|
40
40
|
A.stopPropagation();
|
|
41
41
|
};
|
|
42
42
|
return /* @__PURE__ */ u(
|
|
43
43
|
"div",
|
|
44
44
|
{
|
|
45
45
|
ref: E,
|
|
46
|
-
id:
|
|
46
|
+
id: r,
|
|
47
47
|
style: {
|
|
48
48
|
top: (o == null ? void 0 : o.top) || 0,
|
|
49
49
|
left: (o == null ? void 0 : o.left) || 0
|
|
@@ -55,9 +55,9 @@ const P = {
|
|
|
55
55
|
{
|
|
56
56
|
ref: f,
|
|
57
57
|
type: "date",
|
|
58
|
-
value:
|
|
58
|
+
value: s || "",
|
|
59
59
|
onChange: W,
|
|
60
|
-
onClick:
|
|
60
|
+
onClick: w
|
|
61
61
|
}
|
|
62
62
|
)
|
|
63
63
|
}
|
|
@@ -65,60 +65,60 @@ const P = {
|
|
|
65
65
|
}
|
|
66
66
|
);
|
|
67
67
|
Fe.displayName = "DatePicker";
|
|
68
|
-
function ye(
|
|
69
|
-
const o =
|
|
70
|
-
o.length ? (
|
|
68
|
+
function ye(s) {
|
|
69
|
+
const o = s.textContent || "", r = s.nextSibling;
|
|
70
|
+
o.length ? (r == null || r.setAttribute("style", "display: none"), s.style.padding = "2px 4px", s.style.borderTopLeftRadius = "2px", s.style.borderBottomLeftRadius = "2px", s.style.borderTopRightRadius = "2px", s.style.borderBottomRightRadius = "2px") : (r == null || r.setAttribute("style", "display: inline"), s.style.padding = "2px 0 2px 4px", s.style.borderTopLeftRadius = "2px", s.style.borderBottomLeftRadius = "2px", s.style.borderTopRightRadius = "0", s.style.borderBottomRightRadius = "0");
|
|
71
71
|
}
|
|
72
|
-
function K(
|
|
73
|
-
if (
|
|
74
|
-
const o =
|
|
72
|
+
function K(s) {
|
|
73
|
+
if (s && s.getAttribute("data-set-type") === "input") {
|
|
74
|
+
const o = s.children[0];
|
|
75
75
|
o.setAttribute("contenteditable", "true"), requestAnimationFrame(() => {
|
|
76
76
|
o.focus();
|
|
77
77
|
});
|
|
78
78
|
}
|
|
79
79
|
}
|
|
80
|
-
function Be(
|
|
81
|
-
|
|
80
|
+
function Be(s) {
|
|
81
|
+
s && s.getAttribute("data-set-type") === "input" && s.children[0].setAttribute("contenteditable", "false");
|
|
82
82
|
}
|
|
83
|
-
function q(
|
|
84
|
-
return
|
|
83
|
+
function q(s) {
|
|
84
|
+
return s && (s != null && s.getAttribute) ? s.getAttribute("data-set-type") === "input" : !1;
|
|
85
85
|
}
|
|
86
86
|
const ve = X(({
|
|
87
|
-
options:
|
|
87
|
+
options: s,
|
|
88
88
|
value: o,
|
|
89
|
-
position:
|
|
89
|
+
position: r,
|
|
90
90
|
id: p,
|
|
91
91
|
height: k = 37,
|
|
92
92
|
onChange: E
|
|
93
93
|
}, f) => {
|
|
94
|
-
const [W, M] = S(o || ""),
|
|
94
|
+
const [W, M] = S(o || ""), w = H(null);
|
|
95
95
|
B(() => {
|
|
96
|
-
typeof f == "function" ? f(
|
|
96
|
+
typeof f == "function" ? f(w.current) : f && (f.current = w.current);
|
|
97
97
|
}, [f]);
|
|
98
|
-
const A = (
|
|
98
|
+
const A = (T) => {
|
|
99
99
|
const y = W.split(",").filter((g) => g) || [];
|
|
100
100
|
let C = "";
|
|
101
|
-
y.includes(
|
|
101
|
+
y.includes(T) ? C = y.filter((g) => g !== T).join(",") : y.length ? C = `${y.join(",")},${T}` : C = T, M(C), E == null || E(C, h.MULTIPLE_SELECT);
|
|
102
102
|
}, m = W.split(",") || [];
|
|
103
103
|
return /* @__PURE__ */ u(
|
|
104
104
|
"div",
|
|
105
105
|
{
|
|
106
|
-
ref:
|
|
106
|
+
ref: w,
|
|
107
107
|
className: "cosmic-ai-input-selectFloatElement",
|
|
108
108
|
id: p,
|
|
109
109
|
style: {
|
|
110
110
|
position: "absolute",
|
|
111
|
-
top: (
|
|
112
|
-
left: (
|
|
111
|
+
top: (r == null ? void 0 : r.top) || 0,
|
|
112
|
+
left: (r == null ? void 0 : r.left) || 0,
|
|
113
113
|
zIndex: 5e3,
|
|
114
114
|
maxHeight: `${k}px`
|
|
115
115
|
},
|
|
116
|
-
children:
|
|
116
|
+
children: s.map((T, y) => /* @__PURE__ */ u(
|
|
117
117
|
"div",
|
|
118
118
|
{
|
|
119
|
-
className: `selectOption ${m.includes(
|
|
120
|
-
onClick: () => A(
|
|
121
|
-
children:
|
|
119
|
+
className: `selectOption ${m.includes(T) ? "selected" : ""}`,
|
|
120
|
+
onClick: () => A(T),
|
|
121
|
+
children: T
|
|
122
122
|
},
|
|
123
123
|
y
|
|
124
124
|
))
|
|
@@ -127,16 +127,16 @@ const ve = X(({
|
|
|
127
127
|
});
|
|
128
128
|
ve.displayName = "MultipleSelect";
|
|
129
129
|
const Ke = X(({
|
|
130
|
-
options:
|
|
130
|
+
options: s,
|
|
131
131
|
value: o,
|
|
132
|
-
position:
|
|
132
|
+
position: r,
|
|
133
133
|
id: p,
|
|
134
134
|
height: k = 120,
|
|
135
135
|
onChange: E
|
|
136
136
|
}, f) => {
|
|
137
|
-
const [W, M] = S(o || ""),
|
|
137
|
+
const [W, M] = S(o || ""), w = H(null);
|
|
138
138
|
B(() => {
|
|
139
|
-
typeof f == "function" ? f(
|
|
139
|
+
typeof f == "function" ? f(w.current) : f && (f.current = w.current);
|
|
140
140
|
}, [f]);
|
|
141
141
|
const A = (m) => {
|
|
142
142
|
M(m), E == null || E(m, h.SELECT);
|
|
@@ -144,118 +144,118 @@ const Ke = X(({
|
|
|
144
144
|
return /* @__PURE__ */ u(
|
|
145
145
|
"div",
|
|
146
146
|
{
|
|
147
|
-
ref:
|
|
147
|
+
ref: w,
|
|
148
148
|
className: "cosmic-ai-input-selectFloatElement",
|
|
149
149
|
id: p,
|
|
150
150
|
style: {
|
|
151
151
|
position: "absolute",
|
|
152
|
-
top: (
|
|
153
|
-
left: (
|
|
152
|
+
top: (r == null ? void 0 : r.top) || 0,
|
|
153
|
+
left: (r == null ? void 0 : r.left) || 0,
|
|
154
154
|
zIndex: 5e3,
|
|
155
155
|
maxHeight: `${k}px`
|
|
156
156
|
},
|
|
157
|
-
children:
|
|
157
|
+
children: s.length > 0 && s.map((m, T) => /* @__PURE__ */ u(
|
|
158
158
|
"div",
|
|
159
159
|
{
|
|
160
160
|
className: `selectOption ${W === m ? "selected" : ""}`,
|
|
161
161
|
onClick: () => A(m),
|
|
162
162
|
children: m
|
|
163
163
|
},
|
|
164
|
-
|
|
164
|
+
T
|
|
165
165
|
))
|
|
166
166
|
}
|
|
167
167
|
);
|
|
168
168
|
});
|
|
169
169
|
Ke.displayName = "Select";
|
|
170
|
-
function Me(
|
|
171
|
-
const o =
|
|
170
|
+
function Me(s) {
|
|
171
|
+
const o = s instanceof Element ? s : document.getElementById(s);
|
|
172
172
|
return o && o.children[0].textContent || "";
|
|
173
173
|
}
|
|
174
|
-
function _e(
|
|
175
|
-
const
|
|
176
|
-
|
|
174
|
+
function _e(s, o) {
|
|
175
|
+
const r = s instanceof Element ? s : document.getElementById(s);
|
|
176
|
+
r && (r.children[0].textContent = o);
|
|
177
177
|
}
|
|
178
|
-
function le(
|
|
179
|
-
const o = document.createRange(),
|
|
180
|
-
|
|
178
|
+
function le(s) {
|
|
179
|
+
const o = document.createRange(), r = window.getSelection();
|
|
180
|
+
r && (!s || !(s instanceof Node) || (o.selectNodeContents(s), o.collapse(!0), r.removeAllRanges(), r.addRange(o)));
|
|
181
181
|
}
|
|
182
|
-
function V(
|
|
183
|
-
const o = document.createRange(),
|
|
184
|
-
|
|
182
|
+
function V(s) {
|
|
183
|
+
const o = document.createRange(), r = window.getSelection();
|
|
184
|
+
r && (!s || !(s instanceof Node) || (o.selectNodeContents(s), o.collapse(!1), r.removeAllRanges(), r.addRange(o)));
|
|
185
185
|
}
|
|
186
|
-
function be(
|
|
186
|
+
function be(s) {
|
|
187
187
|
const o = window.getSelection();
|
|
188
188
|
if (!o || o.rangeCount === 0)
|
|
189
189
|
return 0;
|
|
190
|
-
if (!
|
|
190
|
+
if (!s || !(s instanceof Node))
|
|
191
191
|
return;
|
|
192
|
-
const
|
|
193
|
-
return p.selectNodeContents(
|
|
192
|
+
const r = o.getRangeAt(0), p = r.cloneRange();
|
|
193
|
+
return p.selectNodeContents(s), p.setEnd(r.startContainer, r.startOffset), p.toString().length;
|
|
194
194
|
}
|
|
195
195
|
function pt() {
|
|
196
|
-
const
|
|
197
|
-
if (!
|
|
196
|
+
const s = window.getSelection();
|
|
197
|
+
if (!s || s.rangeCount === 0)
|
|
198
198
|
return null;
|
|
199
|
-
const
|
|
200
|
-
return
|
|
199
|
+
const r = s.getRangeAt(0).startContainer;
|
|
200
|
+
return r.nodeType === Node.TEXT_NODE ? r.parentElement : r.nodeType === Node.ELEMENT_NODE ? r : null;
|
|
201
201
|
}
|
|
202
202
|
function ht() {
|
|
203
|
-
const
|
|
204
|
-
return !
|
|
203
|
+
const s = window.getSelection();
|
|
204
|
+
return !s || s.rangeCount === 0 ? null : s.getRangeAt(0).getBoundingClientRect();
|
|
205
205
|
}
|
|
206
206
|
function gt() {
|
|
207
|
-
return new Promise((
|
|
207
|
+
return new Promise((s) => {
|
|
208
208
|
requestAnimationFrame(() => {
|
|
209
|
-
|
|
209
|
+
s(ht());
|
|
210
210
|
});
|
|
211
211
|
});
|
|
212
212
|
}
|
|
213
213
|
function Et() {
|
|
214
|
-
const
|
|
215
|
-
if (!
|
|
216
|
-
const o =
|
|
217
|
-
return
|
|
214
|
+
const s = window.getSelection();
|
|
215
|
+
if (!s || s.rangeCount === 0) return null;
|
|
216
|
+
const o = s.getRangeAt(0), r = o.startContainer, p = o.startOffset;
|
|
217
|
+
return r.nodeType === Node.TEXT_NODE ? p > 0 ? r : r.previousSibling : r.nodeType === Node.ELEMENT_NODE ? p > 0 ? r.childNodes[p - 1] : r.previousSibling : null;
|
|
218
218
|
}
|
|
219
219
|
function yt() {
|
|
220
|
-
const
|
|
221
|
-
if (!
|
|
222
|
-
const o =
|
|
223
|
-
return
|
|
220
|
+
const s = window.getSelection();
|
|
221
|
+
if (!s || s.rangeCount === 0) return null;
|
|
222
|
+
const o = s.getRangeAt(0), r = o.startContainer, p = o.startOffset;
|
|
223
|
+
return r.nodeType === Node.TEXT_NODE ? p < r.length ? r : r.nextSibling : r.nodeType === Node.ELEMENT_NODE ? p < r.childNodes.length ? r.childNodes[p] : r.nextSibling : null;
|
|
224
224
|
}
|
|
225
|
-
function bt(
|
|
226
|
-
return
|
|
225
|
+
function bt(s) {
|
|
226
|
+
return s && !s.getAttribute("data-set-type");
|
|
227
227
|
}
|
|
228
228
|
function He() {
|
|
229
229
|
return `${Date.now()}-${Math.random().toString(36).slice(2, 9)}`;
|
|
230
230
|
}
|
|
231
|
-
const
|
|
232
|
-
options:
|
|
231
|
+
const se = /iPhone|iPad|iPod/i.test(navigator.userAgent) || navigator.userAgent.includes("Mac") && "ontouchend" in document, At = /Android|iPhone|iPad|iPod|Mobile/i.test(navigator.userAgent) || "ontouchend" in document, Ve = X(({
|
|
232
|
+
options: s,
|
|
233
233
|
value: o,
|
|
234
|
-
position:
|
|
234
|
+
position: r,
|
|
235
235
|
id: p,
|
|
236
236
|
height: k = 120,
|
|
237
237
|
onChange: E
|
|
238
238
|
}, f) => {
|
|
239
|
-
const [W, M] = S(o || ""), [
|
|
239
|
+
const [W, M] = S(o || ""), [w, A] = S(0), m = H(null), T = H(w), y = We((C) => {
|
|
240
240
|
M(C), E == null || E(C, h.LABEL);
|
|
241
241
|
}, [E]);
|
|
242
242
|
return B(() => {
|
|
243
243
|
typeof f == "function" ? f(m.current) : f && (f.current = m.current);
|
|
244
244
|
}, [f]), B(() => {
|
|
245
|
-
|
|
246
|
-
}, [
|
|
245
|
+
T.current = w;
|
|
246
|
+
}, [w]), B(() => {
|
|
247
247
|
A(0);
|
|
248
|
-
}, [
|
|
248
|
+
}, [s]), B(() => {
|
|
249
249
|
const C = (g) => {
|
|
250
|
-
|
|
251
|
-
const x =
|
|
252
|
-
x >= 0 &&
|
|
250
|
+
s.length !== 0 && (g.key === "ArrowDown" ? (g.preventDefault(), A((x) => x < s.length - 1 ? x + 1 : x)) : g.key === "ArrowUp" ? (g.preventDefault(), A((x) => x > 0 ? x - 1 : x)) : g.key === "Enter" && (g.preventDefault(), setTimeout(() => {
|
|
251
|
+
const x = T.current;
|
|
252
|
+
x >= 0 && s[x] && y(s[x]);
|
|
253
253
|
}, 0)));
|
|
254
254
|
};
|
|
255
255
|
return document.addEventListener("keydown", C), () => {
|
|
256
256
|
document.removeEventListener("keydown", C);
|
|
257
257
|
};
|
|
258
|
-
}, [
|
|
258
|
+
}, [s, y]), /* @__PURE__ */ u(
|
|
259
259
|
"div",
|
|
260
260
|
{
|
|
261
261
|
ref: m,
|
|
@@ -263,15 +263,15 @@ const re = /iPhone|iPad|iPod/i.test(navigator.userAgent) || navigator.userAgent.
|
|
|
263
263
|
id: p,
|
|
264
264
|
style: {
|
|
265
265
|
position: "absolute",
|
|
266
|
-
top: (
|
|
267
|
-
left: (
|
|
266
|
+
top: (r == null ? void 0 : r.top) || 0,
|
|
267
|
+
left: (r == null ? void 0 : r.left) || 0,
|
|
268
268
|
zIndex: 5e3,
|
|
269
269
|
maxHeight: `${k}px`
|
|
270
270
|
},
|
|
271
|
-
children:
|
|
271
|
+
children: s.length > 0 && s.map((C, g) => /* @__PURE__ */ u(
|
|
272
272
|
"div",
|
|
273
273
|
{
|
|
274
|
-
className: `selectOption ${W === C ? "selected" : ""} ${
|
|
274
|
+
className: `selectOption ${W === C ? "selected" : ""} ${w === g ? "highlighted" : ""}`,
|
|
275
275
|
onClick: () => y(C),
|
|
276
276
|
onMouseEnter: () => A(g),
|
|
277
277
|
children: C
|
|
@@ -282,26 +282,26 @@ const re = /iPhone|iPad|iPod/i.test(navigator.userAgent) || navigator.userAgent.
|
|
|
282
282
|
);
|
|
283
283
|
});
|
|
284
284
|
Ve.displayName = "Mention";
|
|
285
|
-
const Ct = X((
|
|
285
|
+
const Ct = X((s, o) => {
|
|
286
286
|
const {
|
|
287
|
-
value:
|
|
287
|
+
value: r = "",
|
|
288
288
|
varList: p,
|
|
289
289
|
placeholder: k = "",
|
|
290
290
|
maxLength: E,
|
|
291
291
|
defaultRows: f = 3,
|
|
292
292
|
disabled: W = !1,
|
|
293
293
|
defaultFocus: M = !1,
|
|
294
|
-
textIndex:
|
|
294
|
+
textIndex: w = 0,
|
|
295
295
|
mentions: A = [],
|
|
296
296
|
onFocus: m,
|
|
297
|
-
onBlur:
|
|
297
|
+
onBlur: T,
|
|
298
298
|
onChange: y,
|
|
299
299
|
onClick: C,
|
|
300
300
|
onSend: g,
|
|
301
301
|
onKeyDown: x,
|
|
302
302
|
onKeyUp: U,
|
|
303
|
-
onMaxLengthExceeded:
|
|
304
|
-
} =
|
|
303
|
+
onMaxLengthExceeded: re
|
|
304
|
+
} = s, [Rt, mt] = S(r || ""), [oe, J] = S(""), [xt, ce] = S(""), [j, F] = S(!1), [Q, G] = S({ top: 0, left: 0 }), [ae, de] = S([]), [Z, Ae] = S(""), [R, ue] = S(null), [fe, Y] = S(120), [Ce, Re] = S(M), me = 240, xe = 240, Te = 240, we = 276, b = H(null), L = H(null), $ = H(null), I = H(!1), D = (t, i) => t.code === i || t.key === i, v = () => {
|
|
305
305
|
var i, e;
|
|
306
306
|
let t = ((e = (i = b.current) == null ? void 0 : i.innerText) == null ? void 0 : e.replace(/\u200B/g, "")) || "";
|
|
307
307
|
return t === `
|
|
@@ -405,7 +405,7 @@ const Ct = X((r, o) => {
|
|
|
405
405
|
(t = b.current) == null || t.setAttribute("contenteditable", "true"), L.current && (q(L.current) && L.current.children[0].setAttribute(
|
|
406
406
|
"contenteditable",
|
|
407
407
|
"false"
|
|
408
|
-
), L.current = null),
|
|
408
|
+
), L.current = null), se || V(b.current);
|
|
409
409
|
}, Ue = (t) => {
|
|
410
410
|
C == null || C(t);
|
|
411
411
|
}, Le = (t) => {
|
|
@@ -417,7 +417,7 @@ const Ct = X((r, o) => {
|
|
|
417
417
|
v().length > 0 ? (e = b.current) == null || e.classList.remove("is-empty") : (l = b.current) == null || l.classList.add("is-empty");
|
|
418
418
|
return;
|
|
419
419
|
}
|
|
420
|
-
J(v()), ce(pe()), y == null || y(v()),
|
|
420
|
+
J(v()), ce(pe()), y == null || y(v()), st(t);
|
|
421
421
|
}, ze = (t) => {
|
|
422
422
|
var i, e;
|
|
423
423
|
if (!(I.current || (i = t.nativeEvent) != null && i.isComposing) && D(t, P.ENTER) && !t.shiftKey && !At) {
|
|
@@ -427,7 +427,7 @@ const Ct = X((r, o) => {
|
|
|
427
427
|
/^<span>[\s\u200B]*(<br\s*\/?>[\s\u200B]*)+<\/span>$/
|
|
428
428
|
))
|
|
429
429
|
return;
|
|
430
|
-
E ? l.length <= E ? g == null || g(l) :
|
|
430
|
+
E ? l.length <= E ? g == null || g(l) : re == null || re(l, E) : g == null || g(l);
|
|
431
431
|
}
|
|
432
432
|
}, je = (t) => {
|
|
433
433
|
var e;
|
|
@@ -480,12 +480,13 @@ const Ct = X((r, o) => {
|
|
|
480
480
|
}
|
|
481
481
|
U == null || U(t);
|
|
482
482
|
}, Ie = (t) => {
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
483
|
+
t.preventDefault();
|
|
484
|
+
const i = t.clipboardData, e = i.items;
|
|
485
|
+
for (let c = 0; c < e.length; c++)
|
|
486
|
+
if (e[c].type.indexOf("image") !== -1)
|
|
487
487
|
return;
|
|
488
|
-
|
|
488
|
+
const l = i.getData("text/plain");
|
|
489
|
+
l && document.execCommand("insertText", !1, l);
|
|
489
490
|
}, Xe = (t) => {
|
|
490
491
|
t.preventDefault();
|
|
491
492
|
const e = window.getSelection().toString();
|
|
@@ -504,7 +505,7 @@ const Ct = X((r, o) => {
|
|
|
504
505
|
i.stopPropagation();
|
|
505
506
|
}, Ne = (t, i) => {
|
|
506
507
|
var l;
|
|
507
|
-
|
|
508
|
+
se || i.stopPropagation(), L.current && Be(L.current), (l = b.current) == null || l.setAttribute("contenteditable", "false");
|
|
508
509
|
const e = document.getElementById(t.id);
|
|
509
510
|
L.current = e, requestAnimationFrame(() => {
|
|
510
511
|
K(e);
|
|
@@ -532,7 +533,7 @@ const Ct = X((r, o) => {
|
|
|
532
533
|
ye(e);
|
|
533
534
|
}, Se = (t, i) => {
|
|
534
535
|
var l;
|
|
535
|
-
|
|
536
|
+
se || i.stopPropagation(), L.current && Be(L.current), (l = b.current) == null || l.setAttribute("contenteditable", "false");
|
|
536
537
|
const e = document.getElementById(t.id);
|
|
537
538
|
L.current = e, requestAnimationFrame(() => {
|
|
538
539
|
K(e);
|
|
@@ -582,19 +583,19 @@ const Ct = X((r, o) => {
|
|
|
582
583
|
);
|
|
583
584
|
e && e.children[0] && e.children[1] && (t.length > 0 ? (e.children[0].setAttribute("style", "display: inline"), e.children[0].setAttribute("contenteditable", "false"), e.children[1].setAttribute("style", "display: none"), e.children[1].setAttribute("contenteditable", "true")) : (e.children[0].setAttribute("style", "display: none"), e.children[0].setAttribute("contenteditable", "true"), e.children[1].setAttribute("style", "display: inline"), e.children[1].setAttribute("contenteditable", "true"))), z({});
|
|
584
585
|
}
|
|
585
|
-
}, te = H(null), lt = (A == null ? void 0 : A.map((t) => t.prefix)) || [],
|
|
586
|
+
}, te = H(null), lt = (A == null ? void 0 : A.map((t) => t.prefix)) || [], st = (t) => {
|
|
586
587
|
const i = t == null ? void 0 : t.nativeEvent, e = i == null ? void 0 : i.data;
|
|
587
588
|
lt.includes(e) && gt().then((l) => {
|
|
588
589
|
var a;
|
|
589
590
|
const c = window.getSelection();
|
|
590
|
-
c && c.rangeCount > 0 && (te.current = c.getRangeAt(0)),
|
|
591
|
+
c && c.rangeCount > 0 && (te.current = c.getRangeAt(0)), rt({
|
|
591
592
|
options: ((a = A.find((d) => d.prefix === e)) == null ? void 0 : a.options) || [],
|
|
592
593
|
value: "",
|
|
593
594
|
type: h.LABEL,
|
|
594
595
|
id: "label-" + He()
|
|
595
596
|
}, l);
|
|
596
597
|
});
|
|
597
|
-
},
|
|
598
|
+
}, rt = (t, i) => {
|
|
598
599
|
de(t.options), G({ top: -999999, left: -999999999 }), ue(t), Y(xe), F(!0), requestAnimationFrame(() => {
|
|
599
600
|
if ($.current) {
|
|
600
601
|
const e = $.current.getBoundingClientRect();
|
|
@@ -613,8 +614,8 @@ const Ct = X((r, o) => {
|
|
|
613
614
|
});
|
|
614
615
|
}, ot = (t, i) => {
|
|
615
616
|
const l = i.target.getBoundingClientRect();
|
|
616
|
-
let c = l.left, a = l.top -
|
|
617
|
-
window.innerWidth - l.right <
|
|
617
|
+
let c = l.left, a = l.top - we;
|
|
618
|
+
window.innerWidth - l.right < Te && (c = c - Te + l.width), l.top < we && (a = l.top + l.height), de(t.options), Ae(t.value || Me(t.id)), G({ top: a, left: c }), ue(t), F(!0);
|
|
618
619
|
}, ct = (t, i) => {
|
|
619
620
|
_e(t, i);
|
|
620
621
|
const e = document.getElementById(
|
|
@@ -623,7 +624,7 @@ const Ct = X((r, o) => {
|
|
|
623
624
|
e && e.children[0] && e.children[1] && (i.length > 0 ? (e.children[0].setAttribute("style", "display: inline"), e.children[0].setAttribute("contenteditable", "false"), e.children[1].setAttribute("style", "display: none"), e.children[1].setAttribute("contenteditable", "true")) : (e.children[0].setAttribute("style", "display: none"), e.children[0].setAttribute("contenteditable", "true"), e.children[1].setAttribute("style", "display: inline"), e.children[1].setAttribute("contenteditable", "true"))), z({});
|
|
624
625
|
}, [at, Pe] = S([]), [ge, ke] = S(!0), Oe = We(() => {
|
|
625
626
|
ke(!1);
|
|
626
|
-
const t = qe(
|
|
627
|
+
const t = qe(r), i = [];
|
|
627
628
|
return t.forEach((e) => {
|
|
628
629
|
var l, c, a, d, O, N;
|
|
629
630
|
if (e.type === "text")
|
|
@@ -775,9 +776,20 @@ const Ct = X((r, o) => {
|
|
|
775
776
|
children: e.placeholder
|
|
776
777
|
}
|
|
777
778
|
),
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
779
|
+
se && /* @__PURE__ */ u(
|
|
780
|
+
"input",
|
|
781
|
+
{
|
|
782
|
+
style: {
|
|
783
|
+
position: "absolute",
|
|
784
|
+
left: 0,
|
|
785
|
+
opacity: 0
|
|
786
|
+
},
|
|
787
|
+
type: "date",
|
|
788
|
+
onChange: (n) => {
|
|
789
|
+
ct(e.id, n.target.value);
|
|
790
|
+
}
|
|
791
|
+
}
|
|
792
|
+
)
|
|
781
793
|
]
|
|
782
794
|
},
|
|
783
795
|
e.id
|
|
@@ -786,14 +798,14 @@ const Ct = X((r, o) => {
|
|
|
786
798
|
}), setTimeout(() => {
|
|
787
799
|
ke(!0);
|
|
788
800
|
}, 0), i;
|
|
789
|
-
}, [
|
|
801
|
+
}, [r]);
|
|
790
802
|
B(() => {
|
|
791
803
|
ge && setTimeout(() => {
|
|
792
804
|
V(b.current);
|
|
793
805
|
}, 0);
|
|
794
806
|
}, [ge]), B(() => {
|
|
795
|
-
|
|
796
|
-
}, [
|
|
807
|
+
r !== oe && I.current === !1 ? (Pe(Oe()), J(r), Re(!0)) : (r === "" || !r) && Pe(Oe()), I.current = !1;
|
|
808
|
+
}, [r, oe]), B(() => {
|
|
797
809
|
if (!M && !Ce) return;
|
|
798
810
|
const t = new MutationObserver(() => {
|
|
799
811
|
b.current && document.contains(b.current) && (requestAnimationFrame(() => {
|
|
@@ -811,7 +823,7 @@ const Ct = X((r, o) => {
|
|
|
811
823
|
getCurrentValue: v,
|
|
812
824
|
focus: Ee
|
|
813
825
|
})), // 最外层的防止renderContainer为false的时候样式坍塌
|
|
814
|
-
/* @__PURE__ */ ie("div", { className: $e(`cosmic-ai-input-rows${f}`), style: { textIndent:
|
|
826
|
+
/* @__PURE__ */ ie("div", { className: $e(`cosmic-ai-input-rows${f}`), style: { textIndent: w + "px" }, children: [
|
|
815
827
|
ge && /* @__PURE__ */ u(
|
|
816
828
|
"div",
|
|
817
829
|
{
|
|
@@ -831,7 +843,7 @@ const Ct = X((r, o) => {
|
|
|
831
843
|
Je(t);
|
|
832
844
|
},
|
|
833
845
|
onBlur: (t) => {
|
|
834
|
-
|
|
846
|
+
T == null || T(t);
|
|
835
847
|
},
|
|
836
848
|
onMouseDown: (t) => Le(),
|
|
837
849
|
onTouchEnd: (t) => Le(),
|
package/dist/style.css
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
.cosmic-ai-input{font-size:14px;outline:none;line-height:26px}.cosmic-ai-input p{margin:0}.cosmic-ai-input span{word-break:break-all}.cosmic-ai-input [data-set-type=input]{color:#b4c5fc;padding:0 2px;caret-color:#000}.cosmic-ai-input [data-set-type=label]{padding:0 2px;outline:none;cursor:pointer;position:relative;display:inline-block;cursor:text}.cosmic-ai-input [data-set-type=label] span{color:#2356f6;outline:none;background-color:#f2f5fe;border-radius:2px;white-space:nowrap;padding:0 4px;display:inline-block}.cosmic-ai-input [data-set-type=select]{padding:0 2px;outline:none;color:#2356f6;cursor:pointer;position:relative;display:inline-block}.cosmic-ai-input [data-set-type=select] span{outline:none;background-color:#f2f5fe;border-radius:2px;white-space:nowrap;padding:0 16px 0 4px;display:inline-block}.cosmic-ai-input [data-set-type=select]:after{content:"";position:absolute;right:6px;top:50%;transform:translateY(-50%);width:0;height:0;border-left:4px solid transparent;border-right:4px solid transparent;border-top:5px solid #2356f6;pointer-events:none}.cosmic-ai-input [data-set-type=multiple-select]{padding:0 2px;outline:none;color:#2356f6;cursor:pointer;position:relative;display:inline-block}.cosmic-ai-input [data-set-type=multiple-select] span{outline:none;background-color:#f2f5fe;border-radius:2px;white-space:nowrap;padding:2px 16px 2px 4px;display:inline-block}.cosmic-ai-input [data-set-type=multiple-select]:after{content:"";position:absolute;right:6px;top:50%;transform:translateY(-50%);width:0;height:0;border-left:4px solid transparent;border-right:4px solid transparent;border-top:5px solid #2356f6;pointer-events:none}.cosmic-ai-input [data-set-type=date-picker]{padding:0 2px;outline:none;color:#2356f6;cursor:pointer;position:relative;display:inline-block}.cosmic-ai-input [data-set-type=date-picker] span{outline:none;background-color:#f2f5fe;border-radius:2px;white-space:nowrap;padding:2px 16px 2px 4px;display:inline-block}.cosmic-ai-input [data-set-type=date-picker]:after{content:"";position:absolute;right:6px;top:50%;transform:translateY(-50%);width:0;height:0;border-left:4px solid transparent;border-right:4px solid transparent;border-top:5px solid #2356f6;pointer-events:none}.cosmic-ai-input.is-empty:after{content:attr(data-cosmic-ai-input-placeholder);color:#999;pointer-events:none;text-indent:0;white-space:pre-wrap;word-break:break-all;overflow-wrap:break-word}.cosmic-ai-input.is-disabled{opacity:.5;pointer-events:none;cursor:not-allowed}.cosmic-ai-input-displayNone{display:none}.cosmic-ai-input-inputContent{outline:none;color:#2356f6;background-color:#f2f5fe;border-radius:2px}.cosmic-ai-input-placeholder{background-color:#f2f5fe;padding:2px 4px 2px 0;border-top-right-radius:2px;border-bottom-right-radius:2px}.cosmic-ai-input-selectPlaceholder,.cosmic-ai-input-datePickerPlaceholder{color:#b4c5fc}.cosmic-ai-input-rows1{min-height:auto}.cosmic-ai-input-rows2{min-height:46px}.cosmic-ai-input-rows3{min-height:69px}.cosmic-ai-input-rows4{min-height:92px}.cosmic-ai-input-selectFloatElement{background-color:#fff;border:1px solid #e0e0e0;border-radius:4px;box-shadow:0 2px 8px #00000026;overflow-y:auto;z-index:5000;max-width:240px}.cosmic-ai-input-selectFloatElement .selectOption{padding:8px 12px;cursor:pointer;transition:background-color .2s ease;border-bottom:1px solid #f0f0f0;font-size:14px;color:#333;box-sizing:border-box;word-wrap:break-word;word-break:break-all;display:flex;align-items:center;justify-content:space-between}.cosmic-ai-input-selectFloatElement .selectOption:last-child{border-bottom:none}.cosmic-ai-input-selectFloatElement .selectOption:hover{background-color:#f5f5f5}.cosmic-ai-input-selectFloatElement .selectOption.selected{background-color:#e6f0ff;color:#2356f6;font-weight:500}.cosmic-ai-input-selectFloatElement .selectOption.selected:after{content:"✓";color:#2356f6;padding-left:6px}.cosmic-ai-input-selectFloatElement .selectOption.highlighted{background-color:#f0f0f0;font-weight:500}.cosmic-ai-input-datePicker{position:absolute;z-index:5000}.cosmic-ai-input-datePicker input[type=date]{visibility:hidden;height:0!important;box-sizing:border-box;border:none!important;position:relative;top:-10px}.cosmic-ai-input-
|
|
1
|
+
.cosmic-ai-input{font-size:14px;outline:none;line-height:26px}.cosmic-ai-input p{margin:0}.cosmic-ai-input span{word-break:break-all}.cosmic-ai-input [data-set-type=input]{color:#b4c5fc;padding:0 2px;caret-color:#000}.cosmic-ai-input [data-set-type=label]{padding:0 2px;outline:none;cursor:pointer;position:relative;display:inline-block;cursor:text}.cosmic-ai-input [data-set-type=label] span{color:#2356f6;outline:none;background-color:#f2f5fe;border-radius:2px;white-space:nowrap;padding:0 4px;display:inline-block}.cosmic-ai-input [data-set-type=select]{padding:0 2px;outline:none;color:#2356f6;cursor:pointer;position:relative;display:inline-block}.cosmic-ai-input [data-set-type=select] span{outline:none;background-color:#f2f5fe;border-radius:2px;white-space:nowrap;padding:0 16px 0 4px;display:inline-block}.cosmic-ai-input [data-set-type=select]:after{content:"";position:absolute;right:6px;top:50%;transform:translateY(-50%);width:0;height:0;border-left:4px solid transparent;border-right:4px solid transparent;border-top:5px solid #2356f6;pointer-events:none}.cosmic-ai-input [data-set-type=multiple-select]{padding:0 2px;outline:none;color:#2356f6;cursor:pointer;position:relative;display:inline-block}.cosmic-ai-input [data-set-type=multiple-select] span{outline:none;background-color:#f2f5fe;border-radius:2px;white-space:nowrap;padding:2px 16px 2px 4px;display:inline-block}.cosmic-ai-input [data-set-type=multiple-select]:after{content:"";position:absolute;right:6px;top:50%;transform:translateY(-50%);width:0;height:0;border-left:4px solid transparent;border-right:4px solid transparent;border-top:5px solid #2356f6;pointer-events:none}.cosmic-ai-input [data-set-type=date-picker]{padding:0 2px;outline:none;color:#2356f6;cursor:pointer;position:relative;display:inline-block}.cosmic-ai-input [data-set-type=date-picker] span{outline:none;background-color:#f2f5fe;border-radius:2px;white-space:nowrap;padding:2px 16px 2px 4px;display:inline-block}.cosmic-ai-input [data-set-type=date-picker]:after{content:"";position:absolute;right:6px;top:50%;transform:translateY(-50%);width:0;height:0;border-left:4px solid transparent;border-right:4px solid transparent;border-top:5px solid #2356f6;pointer-events:none}.cosmic-ai-input.is-empty:after{content:attr(data-cosmic-ai-input-placeholder);color:#999;pointer-events:none;text-indent:0;white-space:pre-wrap;word-break:break-all;overflow-wrap:break-word}.cosmic-ai-input.is-disabled{opacity:.5;pointer-events:none;cursor:not-allowed}.cosmic-ai-input-displayNone{display:none}.cosmic-ai-input-inputContent{outline:none;color:#2356f6;background-color:#f2f5fe;border-radius:2px}.cosmic-ai-input-placeholder{background-color:#f2f5fe;padding:2px 4px 2px 0;border-top-right-radius:2px;border-bottom-right-radius:2px}.cosmic-ai-input-selectPlaceholder,.cosmic-ai-input-datePickerPlaceholder{color:#b4c5fc}.cosmic-ai-input-rows1{min-height:auto}.cosmic-ai-input-rows2{min-height:46px}.cosmic-ai-input-rows3{min-height:69px}.cosmic-ai-input-rows4{min-height:92px}.cosmic-ai-input-selectFloatElement{background-color:#fff;border:1px solid #e0e0e0;border-radius:4px;box-shadow:0 2px 8px #00000026;overflow-y:auto;z-index:5000;max-width:240px}.cosmic-ai-input-selectFloatElement .selectOption{padding:8px 12px;cursor:pointer;transition:background-color .2s ease;border-bottom:1px solid #f0f0f0;font-size:14px;color:#333;box-sizing:border-box;word-wrap:break-word;word-break:break-all;display:flex;align-items:center;justify-content:space-between}.cosmic-ai-input-selectFloatElement .selectOption:last-child{border-bottom:none}.cosmic-ai-input-selectFloatElement .selectOption:hover{background-color:#f5f5f5}.cosmic-ai-input-selectFloatElement .selectOption.selected{background-color:#e6f0ff;color:#2356f6;font-weight:500}.cosmic-ai-input-selectFloatElement .selectOption.selected:after{content:"✓";color:#2356f6;padding-left:6px}.cosmic-ai-input-selectFloatElement .selectOption.highlighted{background-color:#f0f0f0;font-weight:500}.cosmic-ai-input-datePicker{position:absolute;z-index:5000}.cosmic-ai-input-datePicker input[type=date]{visibility:hidden;height:0!important;box-sizing:border-box;border:none!important;position:relative;top:-10px}.cosmic-ai-input-commonSlot{padding:2px 0}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cosmic-ai-input",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.25",
|
|
4
4
|
"description": "A powerful AI conversation input component for React with TypeScript support",
|
|
5
5
|
"main": "./dist/index.cjs.js",
|
|
6
6
|
"module": "./dist/index.es.js",
|
|
@@ -81,4 +81,4 @@
|
|
|
81
81
|
},
|
|
82
82
|
"bundledDependencies": [],
|
|
83
83
|
"bundleDependencies": []
|
|
84
|
-
}
|
|
84
|
+
}
|