cosmic-ai-input 1.0.3 → 1.0.6

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 CHANGED
@@ -1,3 +1,6 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const u=require("react/jsx-runtime"),a=require("react"),Fe=require("classnames"),Oe=require("react-dom"),ae=a.forwardRef(({value:c,position:r,id:s,onChange:h},S)=>{const[x,E]=a.useState(!0),m=a.useRef(null),C=a.useRef(null);a.useEffect(()=>{typeof S=="function"?S(m.current):S&&(S.current=m.current)},[S]);const w=d=>{console.log("DatePicker handleChange",d);const N=d.target.value;h==null||h(N,"date-picker")};a.useEffect(()=>{if(C.current)try{setTimeout(()=>{R()},100)}catch(d){console.log("无法自动打开日期选择器,浏览器安全策略限制",d)}},[]);const R=()=>{if(C.current)try{C.current.showPicker()}catch(d){console.log("点击后无法打开日期选择器",d)}},b=d=>{d.stopPropagation(),console.log("DatePicker handleClick",d)};return x?u.jsx("div",{ref:m,id:s,style:{top:(r==null?void 0:r.top)||0,left:(r==null?void 0:r.left)||0},className:"cosmic-ai-input-datePicker",suppressHydrationWarning:!0,children:u.jsx("input",{ref:C,type:"date",value:c||"",onChange:w,onClick:b})}):null});ae.displayName="DatePicker";function X(c){const r=c.textContent||"",s=c.nextSibling;r.length?(s==null||s.setAttribute("style","display: none"),c.style.padding="2px 4px",c.style.borderTopLeftRadius="2px",c.style.borderBottomLeftRadius="2px",c.style.borderTopRightRadius="2px",c.style.borderBottomRightRadius="2px"):(s==null||s.setAttribute("style","display: inline"),c.style.padding="2px 0 2px 4px",c.style.borderTopLeftRadius="2px",c.style.borderBottomLeftRadius="2px",c.style.borderTopRightRadius="0",c.style.borderBottomRightRadius="0")}function L(c){if(c&&c.getAttribute("data-set-type")==="input"){const r=c.children[0];r.setAttribute("contenteditable","true"),requestAnimationFrame(()=>{r.focus()})}}function ie(c){c&&c.getAttribute("data-set-type")==="input"&&c.children[0].setAttribute("contenteditable","false")}function F(c){return c&&c.getAttribute("data-set-type")==="input"}const de=a.forwardRef(({options:c,value:r,position:s,id:h,height:S=37,onChange:x},E)=>{const[m,C]=a.useState(r||""),w=a.useRef(null);a.useEffect(()=>{typeof E=="function"?E(w.current):E&&(E.current=w.current)},[E]);const R=d=>{const N=m.split(",").filter(D=>D)||[];let A="";N.includes(d)?A=N.filter(D=>D!==d).join(","):(console.log("handleOptionClick",N),N.length?A=`${N.join(",")},${d}`:A=d),C(A),x==null||x(A,"multiple-select")},b=m.split(",")||[];return u.jsx("div",{ref:w,className:"cosmic-ai-input-selectFloatElement",id:h,style:{position:"absolute",top:(s==null?void 0:s.top)||0,left:(s==null?void 0:s.left)||0,zIndex:5e3,maxHeight:`${S}px`},children:c.map((d,N)=>u.jsx("div",{className:`selectOption ${b.includes(d)?"selected":""}`,onClick:()=>R(d),children:d},N))})});de.displayName="MultipleSelect";const ue=a.forwardRef(({options:c,value:r,position:s,id:h,height:S=120,onChange:x},E)=>{const[m,C]=a.useState(r||""),w=a.useRef(null);a.useEffect(()=>{typeof E=="function"?E(w.current):E&&(E.current=w.current)},[E]);const R=b=>{C(b),x==null||x(b,"select")};return u.jsx("div",{ref:w,className:"cosmic-ai-input-selectFloatElement",id:h,style:{position:"absolute",top:(s==null?void 0:s.top)||0,left:(s==null?void 0:s.left)||0,zIndex:5e3,maxHeight:`${S}px`},children:c.map((b,d)=>u.jsx("div",{className:`selectOption ${m===b?"selected":""}`,onClick:()=>R(b),children:b},d))})});ue.displayName="Select";function re(c){const r=c instanceof Element?c:document.getElementById(c);return r&&r.children[0].textContent||""}function Me(c,r){const s=c instanceof Element?c:document.getElementById(c);s&&(s.children[0].textContent=r)}function q(c){const r=document.createRange(),s=window.getSelection();if(!s){console.error("无法获取selection对象");return}r.selectNodeContents(c),r.collapse(!0),s.removeAllRanges(),s.addRange(r)}function B(c){const r=document.createRange(),s=window.getSelection();if(!s){console.error("无法获取selection对象");return}r.selectNodeContents(c),r.collapse(!1),s.removeAllRanges(),s.addRange(r)}function G(c){const r=window.getSelection();if(!r||r.rangeCount===0)return 0;const s=r.getRangeAt(0),h=s.cloneRange();return h.selectNodeContents(c),h.setEnd(s.startContainer,s.startOffset),h.toString().length}function $e(){const c=window.getSelection();if(!c||c.rangeCount===0)return null;const s=c.getRangeAt(0).startContainer;return s.nodeType===Node.TEXT_NODE?s.parentElement:s.nodeType===Node.ELEMENT_NODE?s:null}function qe(){const c=window.getSelection();if(!c||c.rangeCount===0)return null;const r=c.getRangeAt(0),s=r.startContainer,h=r.startOffset;return s.nodeType===Node.TEXT_NODE?h>0?s:s.previousSibling:s.nodeType===Node.ELEMENT_NODE?h>0?s.childNodes[h-1]:s.previousSibling:null}function Be(){const c=window.getSelection();if(!c||c.rangeCount===0)return null;const r=c.getRangeAt(0),s=r.startContainer,h=r.startOffset;return s.nodeType===Node.TEXT_NODE?h<s.length?s:s.nextSibling:s.nodeType===Node.ELEMENT_NODE?h<s.childNodes.length?s.childNodes[h]:s.nextSibling:null}function Ve(c){return c&&!c.getAttribute("data-set-type")}const pe=a.forwardRef((c,r)=>{const{value:s,varList:h,placeholder:S="",maxLength:x,defaultRows:E=3,disabled:m=!1,onFocus:C,onBlur:w,onChange:R,onClick:b,onSend:d,onParse:N,onKeyDown:A,onKeyUp:D,onMaxLengthExceeded:V}=c,[J,He]=a.useState(s||""),[Ke,Q]=a.useState(s||""),[he,Y]=a.useState(""),[H,O]=a.useState(!1),[K,W]=a.useState({top:0,left:0}),[Z,v]=a.useState([]),[_,I]=a.useState(""),[j,ee]=a.useState(null),[te,ne]=a.useState(120),fe=240,ge=240,le=240,oe=276,M=a.useRef(null),y=a.useRef(null),T=a.useRef(null),$=()=>{var e;return((e=M.current)==null?void 0:e.innerText)||""},se=()=>{var e;return((e=M.current)==null?void 0:e.innerHTML)||""},ye=e=>{const n=[];let t=0;const o=/\[([^\]]+)\]/g;let p,f=0;const k=new Set(h.map(g=>g.name));for(;(p=o.exec(e))!==null;){if(p.index>t){const i=e.substring(t,p.index).split(`
2
- `);i.forEach((P,Le)=>{P&&n.push({type:"text",content:P,id:`text-${f++}`}),Le<i.length-1&&n.push({type:"newline",id:`newline-${f++}`})})}const g=p[1];if(k.has(g)){const l=h.find(i=>i.name===g);(l==null?void 0:l.type)==="input"?n.push({type:"input",name:l==null?void 0:l.name,content:(l==null?void 0:l.content)||"",placeholder:(l==null?void 0:l.placeholder)||g,id:`input-${f++}`}):(l==null?void 0:l.type)==="select"?n.push({type:"select",name:l==null?void 0:l.name,content:(l==null?void 0:l.content)||"",placeholder:(l==null?void 0:l.placeholder)||g,options:(l==null?void 0:l.options)||[],id:`select-${f++}`}):(l==null?void 0:l.type)==="multiple-select"?n.push({type:"multiple-select",name:l==null?void 0:l.name,content:(l==null?void 0:l.content)||"",placeholder:(l==null?void 0:l.placeholder)||g,options:(l==null?void 0:l.options)||[],id:`multiple-select-${f++}`}):(l==null?void 0:l.type)==="date-picker"&&n.push({type:"date-picker",name:l==null?void 0:l.name,content:(l==null?void 0:l.content)||"",placeholder:(l==null?void 0:l.placeholder)||g,id:`date-picker-${f++}`})}else n.push({type:"text",content:`[${g}]`,id:`text-${f++}`});t=o.lastIndex}if(t<e.length){const l=e.substring(t).split(`
3
- `);l.forEach((i,P)=>{i&&n.push({type:"text",content:i,id:`text-${f++}`}),P<l.length-1&&n.push({type:"newline",id:`newline-${f++}`})})}return n},z=()=>{var e;(e=M.current)==null||e.setAttribute("contenteditable","true"),y.current&&(F(y.current)&&y.current.children[0].setAttribute("contenteditable","false"),y.current=null)},xe=e=>{console.log("handleEditorClick",e),b==null||b(e)},Ee=e=>{console.log("handleEditorMouseDown",e),z()},be=e=>{console.log("handleEditorInput",e),Q($()),Y(se()),R==null||R($())},we=e=>{if(e.code==="Enter"&&!e.shiftKey){e.preventDefault();const n=$();console.log("onSend",n,"maxLength:",x,"length:",n.length),x?n.length<=x?d==null||d(n):(console.log("maxLength exceeded",n,x),V==null||V(n,x)):d==null||d(n)}},Ce=e=>{var t;console.log("handleEditorKeyDown",e),A==null||A(e);const n=$e();if(n&&Ve(n)){if(e.code==="ArrowLeft"){const o=n==null?void 0:n.previousElementSibling,p=G(n);o&&p===0&&F(o)&&o.children[0]&&(y.current=o,L(o),requestAnimationFrame(()=>{B(o.children[0])}))}if(e.code==="ArrowRight"){const o=n==null?void 0:n.nextElementSibling,p=G(n);o&&p===((t=n.textContent)==null?void 0:t.length)&&F(o)&&o.children[0]&&(y.current=o,L(o),requestAnimationFrame(()=>{q(o.children[0])}))}}if(n&&n.getAttribute("data-set-type")==="container"){if(e.code==="ArrowLeft"){const o=qe();F(o)&&o.children[0]&&(y.current=o,L(o),requestAnimationFrame(()=>{B(o.children[0])}))}if(e.code==="ArrowRight"){const o=Be();F(o)&&o.children[0]&&(y.current=o,L(o),requestAnimationFrame(()=>{q(o.children[0])}))}}we(e)},Re=e=>{console.log("handleEditorKeyUp",e),D==null||D(e)},Ae=(e,n)=>{n.stopPropagation(),console.log("handleInputClick",e)},Se=(e,n)=>{var o;n.stopPropagation(),console.log("handleInputMouseDown",e,n),y.current&&ie(y.current),(o=M.current)==null||o.setAttribute("contenteditable","false");const t=document.getElementById(e.id);y.current=t,requestAnimationFrame(()=>{L(t)})},ke=(e,n)=>{var p,f,k,g,l;console.log("handleInputKeyDown",e,n),A==null||A(n),n.stopPropagation();const t=n.target,o=G(t);if(n.code==="Backspace"&&o===0){const i=(p=t.parentElement)==null?void 0:p.previousElementSibling;console.log("previousElement",i),i&&(F(i)&&i.children[0]&&((f=i.children[0].textContent)!=null&&f.length)?(y.current=i,L(i),B(i.children[0]),requestAnimationFrame(()=>{X(i.children[0])})):(z(),B(i)))}if(n.code==="ArrowRight"&&o===((k=t.textContent)==null?void 0:k.length)){const i=(g=t.parentElement)==null?void 0:g.nextElementSibling;console.log("nextElement",i),i&&(F(i)&&i.children[0]&&((l=i.children[0].textContent)!=null&&l.length)?(y.current=i,L(i),q(i.children[0]),requestAnimationFrame(()=>{X(i.children[0])})):(z(),q(i)))}},me=(e,n)=>{console.log("handleInputKeyUp",e,n),D==null||D(n);const t=n.target;X(t)},Ne=(e,n)=>{var o;n.stopPropagation(),console.log("handlePlaceholderMouseDown",e),y.current&&ie(y.current),(o=M.current)==null||o.setAttribute("contenteditable","false");const t=document.getElementById(e.id);y.current=t,requestAnimationFrame(()=>{L(t)})},De=(e,n)=>{console.log("handleInputChange",e,n),Q($()),Y(se()),R==null||R($())},Te=(e,n)=>{console.log("handleTextSpanKeyDown 不生效",e,n)};a.useEffect(()=>{if(!H)return;const e=o=>{T.current&&!T.current.contains(o.target)&&O(!1)},n=o=>{T.current&&!T.current.contains(o.target)&&O(!1)},t=()=>{O(!1)};return document.addEventListener("mousedown",e),document.addEventListener("scroll",n,!0),window.addEventListener("resize",t),()=>{document.removeEventListener("mousedown",e),document.removeEventListener("scroll",n,!0),window.removeEventListener("resize",t)}},[H]);const U=(e,n)=>{if(console.log("handleFloatChange",e,n),j&&Me(j.id,e),n==="select"&&O(!1),n==="multiple-select"||n==="date-picker"){const t=document.getElementById(j.id);t&&t.children[0]&&t.children[1]&&(e.length>0?(t.children[0].setAttribute("style","display: inline"),t.children[0].setAttribute("contenteditable","false"),t.children[1].setAttribute("style","display: none"),t.children[1].setAttribute("contenteditable","true")):(t.children[0].setAttribute("style","display: none"),t.children[0].setAttribute("contenteditable","true"),t.children[1].setAttribute("style","display: inline"),t.children[1].setAttribute("contenteditable","true")))}},ce=(e,n)=>{console.log("handleSelectClick",e,n);const o=n.target.getBoundingClientRect();v(e.options),I(e.value||re(e.id)),W({top:-999999,left:-999999999}),ee(e),ne(ge),O(!0),requestAnimationFrame(()=>{if(T.current){console.log("currentFloatElementRef.current",T.current);const p=T.current.getBoundingClientRect();let f=o.left,k=o.top+o.height;window.innerWidth-o.right<fe&&o.width<p.width&&(f=o.right-p.width),o.top<p.height&&(k=o.top+o.height),W({top:k,left:f}),ne(p.height)}})},je=(e,n)=>{console.log("handleDatePickerClick",e,n);const o=n.target.getBoundingClientRect();let p=o.left,f=o.top-oe;window.innerWidth-o.right<le&&(p=p-le+o.width),o.top<oe&&(f=o.top+o.height),v(e.options),I(e.value||re(e.id)),W({top:f,left:p}),ee(e),O(!0)},Pe=()=>{const e=ye(J);console.log("parsed",e);const n=[];return e.forEach(t=>{var o,p,f,k,g,l;if(t.type==="text")n.push(u.jsx("span",{onKeyDown:i=>Te(t,i),children:t.content},t.id));else if(t.type==="newline")n.push(u.jsx("br",{},t.id));else if(t.type==="input")n.push(u.jsxs("span",{id:t.id,"data-set-type":"input",contentEditable:!1,suppressContentEditableWarning:!0,onInput:i=>De(t,i),onClick:i=>Ae(t,i),onMouseDown:i=>Se(t,i),"data-cosmic-ai-input-placeholder":t.placeholder,children:[u.jsx("span",{className:"cosmic-ai-input-inputContent",style:{padding:(o=t.content)!=null&&o.length?"2px 4px":"2px 0 2px 4px"},contentEditable:!1,onKeyDown:i=>ke(t,i),onKeyUp:i=>me(t,i),children:t.content}),u.jsx("span",{contentEditable:!1,style:{display:(p=t.content)!=null&&p.length?"none":"inline"},className:"cosmic-ai-input-placeholder",onMouseDown:i=>Ne(t,i),children:t.placeholder})]},t.id));else if(t.type==="select"){const i=t.content||((f=t.options)==null?void 0:f[0])||t.placeholder;n.push(u.jsx("span",{id:t.id,"data-set-type":"select",contentEditable:!0,suppressContentEditableWarning:!0,onClick:P=>ce(t,P),"data-cosmic-ai-input-placeholder":t.placeholder,children:u.jsx("span",{contentEditable:!1,children:i})},t.id))}else if(t.type==="multiple-select"){const i=t.content||((k=t.options)==null?void 0:k[0]);n.push(u.jsxs("span",{id:t.id,"data-set-type":"multiple-select",contentEditable:!0,suppressContentEditableWarning:!0,onClick:P=>ce(t,P),"data-cosmic-ai-input-placeholder":t.placeholder,children:[u.jsx("span",{style:{display:i!=null&&i.length?"inline":"none"},contentEditable:!1,children:i}),u.jsx("span",{style:{display:i!=null&&i.length?"none":"inline"},className:"cosmic-ai-input-selectPlaceholder",contentEditable:!1,children:t.placeholder})]},t.id))}else t.type==="date-picker"&&n.push(u.jsxs("span",{id:t.id,"data-set-type":"date-picker",contentEditable:!0,suppressContentEditableWarning:!0,onClick:i=>je(t,i),"data-cosmic-ai-input-placeholder":t.placeholder,children:[u.jsx("span",{style:{display:(g=t.content)!=null&&g.length?"inline":"none"},contentEditable:!1,children:t.content}),u.jsx("span",{style:{display:(l=t.content)!=null&&l.length?"none":"inline"},className:"cosmic-ai-input-datePickerPlaceholder",contentEditable:!1,children:t.placeholder})]},t.id))}),n};return a.useImperativeHandle(r,()=>({getCurrentValue:$})),u.jsxs(u.Fragment,{children:[u.jsx("div",{"data-set-type":"container","data-cosmic-ai-input-placeholder":S,className:Fe("cosmic-ai-input",`cosmic-ai-input-rows${E}`,{"is-disabled":m},{"is-empty":J.length===0||he==="<br>"}),ref:M,contentEditable:!0,suppressContentEditableWarning:!0,onClick:e=>xe(e),onFocus:e=>{C==null||C(e)},onBlur:e=>{w==null||w(e)},onMouseDown:e=>Ee(e),onKeyDown:e=>Ce(e),onKeyUp:e=>Re(e),onInput:e=>be(e),children:Pe()}),H&&Oe.createPortal((j==null?void 0:j.type)==="multiple-select"?u.jsx(de,{ref:T,options:Z,value:_,position:K,height:te,onChange:U},"multiple-select"):(j==null?void 0:j.type)==="date-picker"?u.jsx(ae,{ref:T,value:_,position:K,onChange:U},"date-picker"):u.jsx(ue,{ref:T,options:Z,value:_,position:K,height:te,onChange:U},"select"),document.body)]})});pe.displayName="AiInput";exports.default=pe;
1
+ // Generated at: 2026-01-16T02:43:07.012Z
2
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const p=require("react/jsx-runtime"),i=require("react"),xe=require("classnames"),_e=require("react-dom"),we=i.forwardRef(({value:c,position:r,id:s,onChange:a},S)=>{const[b,w]=i.useState(!0),k=i.useRef(null),R=i.useRef(null);i.useEffect(()=>{typeof S=="function"?S(k.current):S&&(S.current=k.current)},[S]);const m=u=>{console.log("DatePicker handleChange",u);const y=u.target.value;a==null||a(y,"date-picker")};i.useEffect(()=>{if(R.current)try{setTimeout(()=>{N()},100)}catch(u){console.log("无法自动打开日期选择器,浏览器安全策略限制",u)}},[]);const N=()=>{if(R.current)try{R.current.showPicker()}catch(u){console.log("点击后无法打开日期选择器",u)}},g=u=>{u.stopPropagation(),console.log("DatePicker handleClick",u)};return b?p.jsx("div",{ref:k,id:s,style:{top:(r==null?void 0:r.top)||0,left:(r==null?void 0:r.left)||0},className:"cosmic-ai-input-datePicker",suppressHydrationWarning:!0,children:p.jsx("input",{ref:R,type:"date",value:c||"",onChange:m,onClick:g})}):null});we.displayName="DatePicker";function Y(c){const r=c.textContent||"",s=c.nextSibling;r.length?(s==null||s.setAttribute("style","display: none"),c.style.padding="2px 4px",c.style.borderTopLeftRadius="2px",c.style.borderBottomLeftRadius="2px",c.style.borderTopRightRadius="2px",c.style.borderBottomRightRadius="2px"):(s==null||s.setAttribute("style","display: inline"),c.style.padding="2px 0 2px 4px",c.style.borderTopLeftRadius="2px",c.style.borderBottomLeftRadius="2px",c.style.borderTopRightRadius="0",c.style.borderBottomRightRadius="0")}function j(c){if(c&&c.getAttribute("data-set-type")==="input"){const r=c.children[0];r.setAttribute("contenteditable","true"),requestAnimationFrame(()=>{r.focus()})}}function Ee(c){c&&c.getAttribute("data-set-type")==="input"&&c.children[0].setAttribute("contenteditable","false")}function P(c){return c&&c.getAttribute("data-set-type")==="input"}const Ce=i.forwardRef(({options:c,value:r,position:s,id:a,height:S=37,onChange:b},w)=>{const[k,R]=i.useState(r||""),m=i.useRef(null);i.useEffect(()=>{typeof w=="function"?w(m.current):w&&(w.current=m.current)},[w]);const N=u=>{const y=k.split(",").filter(T=>T)||[];let F="";y.includes(u)?F=y.filter(T=>T!==u).join(","):(console.log("handleOptionClick",y),y.length?F=`${y.join(",")},${u}`:F=u),R(F),b==null||b(F,"multiple-select")},g=k.split(",")||[];return p.jsx("div",{ref:m,className:"cosmic-ai-input-selectFloatElement",id:a,style:{position:"absolute",top:(s==null?void 0:s.top)||0,left:(s==null?void 0:s.left)||0,zIndex:5e3,maxHeight:`${S}px`},children:c.map((u,y)=>p.jsx("div",{className:`selectOption ${g.includes(u)?"selected":""}`,onClick:()=>N(u),children:u},y))})});Ce.displayName="MultipleSelect";const me=i.forwardRef(({options:c,value:r,position:s,id:a,height:S=120,onChange:b},w)=>{const[k,R]=i.useState(r||""),m=i.useRef(null);i.useEffect(()=>{typeof w=="function"?w(m.current):w&&(w.current=m.current)},[w]);const N=g=>{R(g),b==null||b(g,"select")};return p.jsx("div",{ref:m,className:"cosmic-ai-input-selectFloatElement",id:a,style:{position:"absolute",top:(s==null?void 0:s.top)||0,left:(s==null?void 0:s.left)||0,zIndex:5e3,maxHeight:`${S}px`},children:c.length>0&&c.map((g,u)=>p.jsx("div",{className:`selectOption ${k===g?"selected":""}`,onClick:()=>N(g),children:g},u))})});me.displayName="Select";function be(c){const r=c instanceof Element?c:document.getElementById(c);return r&&r.children[0].textContent||""}function ze(c,r){const s=c instanceof Element?c:document.getElementById(c);s&&(s.children[0].textContent=r)}function V(c){const r=document.createRange(),s=window.getSelection();if(!s){console.error("无法获取selection对象");return}try{r.selectNodeContents(c),r.collapse(!0),s.removeAllRanges(),s.addRange(r)}catch(a){console.error("设置光标位置失败:",a)}}function M(c){const r=document.createRange(),s=window.getSelection();if(!s){console.error("无法获取selection对象");return}try{r.selectNodeContents(c),r.collapse(!1),s.removeAllRanges(),s.addRange(r)}catch(a){console.error("设置光标位置失败:",a)}}function Z(c){const r=window.getSelection();if(!r||r.rangeCount===0)return 0;const s=r.getRangeAt(0);try{const a=s.cloneRange();return a.selectNodeContents(c),a.setEnd(s.startContainer,s.startOffset),a.toString().length}catch(a){return console.error("获取光标位置失败:",a),0}}function ve(){const c=window.getSelection();if(!c||c.rangeCount===0)return null;const s=c.getRangeAt(0).startContainer;return s.nodeType===Node.TEXT_NODE?s.parentElement:s.nodeType===Node.ELEMENT_NODE?s:null}function Ue(){const c=window.getSelection();if(!c||c.rangeCount===0)return null;const r=c.getRangeAt(0),s=r.startContainer,a=r.startOffset;return s.nodeType===Node.TEXT_NODE?a>0?s:s.previousSibling:s.nodeType===Node.ELEMENT_NODE?a>0?s.childNodes[a-1]:s.previousSibling:null}function Xe(){const c=window.getSelection();if(!c||c.rangeCount===0)return null;const r=c.getRangeAt(0),s=r.startContainer,a=r.startOffset;return s.nodeType===Node.TEXT_NODE?a<s.length?s:s.nextSibling:s.nodeType===Node.ELEMENT_NODE?a<s.childNodes.length?s.childNodes[a]:s.nextSibling:null}function Ge(c){return c&&!c.getAttribute("data-set-type")}const Re=i.forwardRef((c,r)=>{const{value:s="",varList:a,placeholder:S="",maxLength:b,defaultRows:w=3,disabled:k=!1,defaultFocus:R=!1,onFocus:m,onBlur:N,onChange:g,onClick:u,onSend:y,onParse:F,onKeyDown:T,onKeyUp:O,onMaxLengthExceeded:K}=c,[Je,Qe]=i.useState(s||""),[W,_]=i.useState(""),[Ye,I]=i.useState(""),[z,H]=i.useState(!1),[v,U]=i.useState({top:0,left:0}),[ee,te]=i.useState([]),[X,ne]=i.useState(""),[L,le]=i.useState(null),[oe,se]=i.useState(120),[ce,re]=i.useState(R),Se=240,Ae=240,ie=240,ae=276,C=i.useRef(null),x=i.useRef(null),D=i.useRef(null),B=()=>{var l,n;let e=((n=(l=C.current)==null?void 0:l.innerText)==null?void 0:n.replace(/\u200B/g,""))||"";return e===`
3
+ `&&(e=""),e},de=()=>{var l;let e=((l=C.current)==null?void 0:l.innerHTML)||"";return e==="<br>"&&(e=""),e},ke=e=>{const l=[];let n=0;const o=/\[([^\]]+)\]/g;let d;const f=`${Date.now()}-${Math.random().toString(36).slice(2,9)}`;let h=0;if(e===""||!e||e===`
4
+ `)return[{type:"text",content:"​",id:`text-${h++}-${f}`}];const $=new Set((a||[]).map(E=>E.name));for(;(d=o.exec(e))!==null;){if(d.index>n){const A=e.substring(n,d.index).split(`
5
+ `);A.forEach((q,We)=>{q&&l.push({type:"text",content:q,id:`text-${h++}-${f}`}),We<A.length-1&&l.push({type:"newline",id:`newline-${h++}-${f}`})})}const E=d[1];if($.has(E)){const t=a.find(A=>A.name===E);(t==null?void 0:t.type)==="input"?l.push({type:"input",name:t==null?void 0:t.name,content:(t==null?void 0:t.content)||"",placeholder:(t==null?void 0:t.placeholder)||E,id:`input-${h++}-${f}`}):(t==null?void 0:t.type)==="select"?l.push({type:"select",name:t==null?void 0:t.name,content:(t==null?void 0:t.content)||"",placeholder:(t==null?void 0:t.placeholder)||E,options:(t==null?void 0:t.options)||[],id:`select-${h++}-${f}`}):(t==null?void 0:t.type)==="multiple-select"?l.push({type:"multiple-select",name:t==null?void 0:t.name,content:(t==null?void 0:t.content)||"",placeholder:(t==null?void 0:t.placeholder)||E,options:(t==null?void 0:t.options)||[],id:`multiple-select-${h++}-${f}`}):(t==null?void 0:t.type)==="date-picker"&&l.push({type:"date-picker",name:t==null?void 0:t.name,content:(t==null?void 0:t.content)||"",placeholder:(t==null?void 0:t.placeholder)||E,id:`date-picker-${h++}-${f}`})}else l.push({type:"text",content:`[${E}]`,id:`text-${h++}-${f}`});n=o.lastIndex}if(n<e.length){const t=e.substring(n).split(`
6
+ `);t.forEach((A,q)=>{A&&l.push({type:"text",content:A,id:`text-${h++}`}),q<t.length-1&&l.push({type:"newline",id:`newline-${h++}`})})}return l},G=()=>{var e;(e=C.current)==null||e.setAttribute("contenteditable","true"),x.current&&(P(x.current)&&x.current.children[0].setAttribute("contenteditable","false"),x.current=null),M(C.current)},Te=e=>{console.log("handleEditorClick",e),u==null||u(e)},De=e=>{console.log("handleEditorMouseDown",e),G()},ue=e=>{console.log("handleEditorInput",e),_(B()),I(de()),g==null||g(B())},Ne=e=>{var l,n;if(e.code==="Enter"&&!e.shiftKey){e.preventDefault();const o=B();if(console.log("onSend",o,"maxLength:",b,"length:",o.length),o.length===0||(console.log("containerRef.current?.innerHTML",(l=C.current)==null?void 0:l.innerHTML),(n=C.current)!=null&&n.innerHTML.match(/^<span>[\s\u200B]*(<br\s*\/?>[\s\u200B]*)+<\/span>$/)))return;b?o.length<=b?y==null||y(o):(console.log("maxLength exceeded",o,b),K==null||K(o,b)):y==null||y(o)}},Le=e=>{var n;console.log("handleEditorKeyDown",e),T==null||T(e);const l=ve();if(l&&Ge(l)){if(e.code==="ArrowLeft"){const o=l==null?void 0:l.previousElementSibling,d=Z(l);o&&d===0&&P(o)&&o.children[0]&&(x.current=o,j(o),requestAnimationFrame(()=>{M(o.children[0])}))}if(e.code==="ArrowRight"){const o=l==null?void 0:l.nextElementSibling,d=Z(l);o&&d===((n=l.textContent)==null?void 0:n.length)&&P(o)&&o.children[0]&&(x.current=o,j(o),requestAnimationFrame(()=>{V(o.children[0])}))}e.code==="Backspace"&&(l.innerHTML==="​"&&e.preventDefault(),l.innerHTML==="<br>"&&(e.preventDefault(),l.innerHTML="​"))}if(l&&l.getAttribute("data-set-type")==="container"){if(e.code==="ArrowLeft"){const o=Ue();P(o)&&o.children[0]&&(x.current=o,j(o),requestAnimationFrame(()=>{M(o.children[0])}))}if(e.code==="ArrowRight"){const o=Xe();P(o)&&o.children[0]&&(x.current=o,j(o),requestAnimationFrame(()=>{V(o.children[0])}))}}Ne(e)},$e=e=>{console.log("handleEditorKeyUp",e),O==null||O(e)},je=e=>{e.preventDefault();const n=window.getSelection().toString();if(!n)return;const o=n,d=n;e.clipboardData.setData("text/plain",o),e.clipboardData.setData("text/html",d)},Pe=e=>{m==null||m(e)},Me=(e,l)=>{l.stopPropagation(),console.log("handleInputClick",e)},Fe=(e,l)=>{var o;l.stopPropagation(),console.log("handleInputMouseDown",e,l),x.current&&Ee(x.current),(o=C.current)==null||o.setAttribute("contenteditable","false");const n=document.getElementById(e.id);x.current=n,requestAnimationFrame(()=>{j(n)})},Oe=(e,l)=>{var d,f,h,$,E;console.log("handleInputKeyDown",e,l),T==null||T(l),l.stopPropagation();const n=l.target,o=Z(n);if(l.code==="Backspace"&&o===0){const t=(d=n.parentElement)==null?void 0:d.previousElementSibling;console.log("previousElement",t),t&&(P(t)&&t.children[0]&&((f=t.children[0].textContent)!=null&&f.length)?(x.current=t,j(t),M(t.children[0]),requestAnimationFrame(()=>{Y(t.children[0])})):(G(),M(t)))}if(l.code==="ArrowRight"&&o===((h=n.textContent)==null?void 0:h.length)){const t=($=n.parentElement)==null?void 0:$.nextElementSibling;console.log("nextElement",t),t&&(P(t)&&t.children[0]&&((E=t.children[0].textContent)!=null&&E.length)?(x.current=t,j(t),V(t.children[0]),requestAnimationFrame(()=>{Y(t.children[0])})):(G(),V(t)))}},He=(e,l)=>{console.log("handleInputKeyUp",e,l),O==null||O(l);const n=l.target;Y(n)},Be=(e,l)=>{var o;l.stopPropagation(),console.log("handlePlaceholderMouseDown",e),x.current&&Ee(x.current),(o=C.current)==null||o.setAttribute("contenteditable","false");const n=document.getElementById(e.id);x.current=n,requestAnimationFrame(()=>{j(n)})},qe=(e,l)=>{console.log("handleInputChange",e,l),_(B()),I(de()),g==null||g(B())},Ve=(e,l)=>{console.log("handleTextSpanKeyDown 不生效",e,l)};i.useEffect(()=>{if(!z)return;const e=o=>{D.current&&!D.current.contains(o.target)&&H(!1)},l=o=>{D.current&&!D.current.contains(o.target)&&H(!1)},n=()=>{H(!1)};return document.addEventListener("mousedown",e),document.addEventListener("scroll",l,!0),window.addEventListener("resize",n),()=>{document.removeEventListener("mousedown",e),document.removeEventListener("scroll",l,!0),window.removeEventListener("resize",n)}},[z]);const J=(e,l)=>{if(console.log("handleFloatChange",e,l),L&&ze(L.id,e),l==="select"&&H(!1),l==="multiple-select"||l==="date-picker"){const n=document.getElementById(L.id);n&&n.children[0]&&n.children[1]&&(e.length>0?(n.children[0].setAttribute("style","display: inline"),n.children[0].setAttribute("contenteditable","false"),n.children[1].setAttribute("style","display: none"),n.children[1].setAttribute("contenteditable","true")):(n.children[0].setAttribute("style","display: none"),n.children[0].setAttribute("contenteditable","true"),n.children[1].setAttribute("style","display: inline"),n.children[1].setAttribute("contenteditable","true")))}ue({})},pe=(e,l)=>{console.log("handleSelectClick",e,l);const o=l.target.getBoundingClientRect();te(e.options),ne(e.value||be(e.id)),U({top:-999999,left:-999999999}),le(e),se(Ae),H(!0),requestAnimationFrame(()=>{if(D.current){console.log("currentFloatElementRef.current",D.current);const d=D.current.getBoundingClientRect();let f=o.left,h=o.top+o.height;window.innerWidth-o.right<Se&&o.width<d.width&&(f=o.right-d.width),o.top<d.height&&(h=o.top+o.height),U({top:h,left:f}),se(d.height)}})},Ke=(e,l)=>{console.log("handleDatePickerClick",e,l);const o=l.target.getBoundingClientRect();let d=o.left,f=o.top-ae;window.innerWidth-o.right<ie&&(d=d-ie+o.width),o.top<ae&&(f=o.top+o.height),te(e.options),ne(e.value||be(e.id)),U({top:f,left:d}),le(e),H(!0)},[fe,he]=i.useState([]),[Q,ge]=i.useState(!0),ye=i.useCallback(()=>{ge(!1);const e=ke(s),l=[];return e.forEach(n=>{var o,d,f,h,$,E;if(n.type==="text")l.push(p.jsx("span",{onKeyDown:t=>Ve(n,t),children:n.content},n.id));else if(n.type==="newline")l.push(p.jsx("br",{},n.id));else if(n.type==="input")l.push(p.jsxs("span",{id:n.id,"data-set-type":"input",contentEditable:!1,suppressContentEditableWarning:!0,onInput:t=>qe(n,t),onClick:t=>Me(n,t),onMouseDown:t=>Fe(n,t),"data-cosmic-ai-input-placeholder":n.placeholder,children:[p.jsx("span",{className:"cosmic-ai-input-inputContent",style:{padding:(o=n.content)!=null&&o.length?"2px 4px":"2px 0 2px 4px"},contentEditable:!1,onKeyDown:t=>Oe(n,t),onKeyUp:t=>He(n,t),children:n.content}),p.jsx("span",{contentEditable:!1,style:{display:(d=n.content)!=null&&d.length?"none":"inline"},className:"cosmic-ai-input-placeholder",onMouseDown:t=>Be(n,t),children:n.placeholder})]},n.id));else if(n.type==="select"){const t=n.content||((f=n.options)==null?void 0:f[0])||n.placeholder;l.push(p.jsx("span",{id:n.id,"data-set-type":"select",contentEditable:!1,suppressContentEditableWarning:!0,onClick:A=>pe(n,A),"data-cosmic-ai-input-placeholder":n.placeholder,children:p.jsx("span",{contentEditable:!1,children:t})},n.id))}else if(n.type==="multiple-select"){const t=n.content||((h=n.options)==null?void 0:h[0]);l.push(p.jsxs("span",{id:n.id,"data-set-type":"multiple-select",contentEditable:!1,suppressContentEditableWarning:!0,onClick:A=>pe(n,A),"data-cosmic-ai-input-placeholder":n.placeholder,children:[p.jsx("span",{style:{display:t!=null&&t.length?"inline":"none"},contentEditable:!1,children:t}),p.jsx("span",{style:{display:t!=null&&t.length?"none":"inline"},className:"cosmic-ai-input-selectPlaceholder",contentEditable:!1,children:n.placeholder})]},n.id))}else n.type==="date-picker"&&l.push(p.jsxs("span",{id:n.id,"data-set-type":"date-picker",contentEditable:!1,suppressContentEditableWarning:!0,onClick:t=>Ke(n,t),"data-cosmic-ai-input-placeholder":n.placeholder,children:[p.jsx("span",{style:{display:($=n.content)!=null&&$.length?"inline":"none"},contentEditable:!1,children:n.content}),p.jsx("span",{style:{display:(E=n.content)!=null&&E.length?"none":"inline"},className:"cosmic-ai-input-datePickerPlaceholder",contentEditable:!1,children:n.placeholder})]},n.id))}),setTimeout(()=>{ge(!0)},0),console.log("重新渲染 ============================>","elements",l,"parsed",e,s),l},[s]);return i.useEffect(()=>{Q&&setTimeout(()=>{M(C.current)},0)},[Q]),i.useEffect(()=>{s!==W?(he(ye()),_(s),re(!0)):(s===""||!s)&&he(ye())},[s,W]),i.useEffect(()=>{if(!R&&!ce)return;const e=new MutationObserver(()=>{C.current&&document.contains(C.current)&&(requestAnimationFrame(()=>{M(C.current),re(!1)}),e.disconnect())});return C.current&&e.observe(document.body,{childList:!0,subtree:!0}),()=>e.disconnect()},[R,ce]),i.useImperativeHandle(r,()=>({getCurrentValue:B})),console.log("renderElements",fe),p.jsxs("div",{className:xe(`cosmic-ai-input-rows${w}`),children:[Q&&p.jsx("div",{"data-set-type":"container","data-cosmic-ai-input-placeholder":S,className:xe("cosmic-ai-input",`cosmic-ai-input-rows${w}`,{"is-disabled":k},{"is-empty":W.length===0}),ref:C,contentEditable:!0,suppressContentEditableWarning:!0,onClick:e=>Te(e),onFocus:e=>{Pe(e)},onBlur:e=>{N==null||N(e)},onMouseDown:e=>De(e),onKeyDown:e=>Le(e),onKeyUp:e=>$e(e),onInput:e=>ue(e),onCopy:e=>je(e),children:fe}),z&&_e.createPortal((L==null?void 0:L.type)==="multiple-select"?p.jsx(Ce,{ref:D,options:ee,value:X,position:v,height:oe,onChange:J},"multiple-select"):(L==null?void 0:L.type)==="date-picker"?p.jsx(we,{ref:D,value:X,position:v,onChange:J},"date-picker"):p.jsx(me,{ref:D,options:ee,value:X,position:v,height:oe,onChange:J},"select"),document.body)]})});Re.displayName="AiInput";exports.default=Re;
package/dist/index.d.ts CHANGED
@@ -7,9 +7,10 @@ declare interface AiInputProps {
7
7
  value?: string;
8
8
  varList: (InputItem | SelectItem | MultipleSelectItem | DatePickerItem)[];
9
9
  placeholder?: string;
10
- maxLength?: 1 | 2 | 3 | 4 | undefined;
10
+ maxLength?: number;
11
11
  defaultRows?: number;
12
12
  disabled?: boolean;
13
+ defaultFocus?: boolean;
13
14
  onParse?: (parsedValue: string) => void;
14
15
  onSend?: (value: string) => void;
15
16
  onMaxLengthExceeded?: (value: string, maxLength: number) => void;
package/dist/index.es.js CHANGED
@@ -1,105 +1,106 @@
1
- import { jsx as h, jsxs as q, Fragment as Be } from "react/jsx-runtime";
2
- import { forwardRef as _, useState as A, useRef as $, useEffect as H, useImperativeHandle as Ve } from "react";
3
- import He from "classnames";
4
- import { createPortal as qe } from "react-dom";
5
- const he = _(
6
- ({ value: s, position: r, id: c, onChange: u }, k) => {
7
- const [y, E] = A(!0), N = $(null), w = $(null);
8
- H(() => {
9
- typeof k == "function" ? k(N.current) : k && (k.current = N.current);
1
+ // Generated at: 2026-01-16T02:43:06.582Z
2
+ import { jsx as h, jsxs as _ } from "react/jsx-runtime";
3
+ import { forwardRef as j, useState as w, useRef as O, useEffect as F, useCallback as Xe, useImperativeHandle as ve } from "react";
4
+ import Ce from "classnames";
5
+ import { createPortal as Ge } from "react-dom";
6
+ const ke = j(
7
+ ({ value: r, position: s, id: c, onChange: i }, k) => {
8
+ const [b, x] = w(!0), T = O(null), A = O(null);
9
+ F(() => {
10
+ typeof k == "function" ? k(T.current) : k && (k.current = T.current);
10
11
  }, [k]);
11
- const x = (a) => {
12
- console.log("DatePicker handleChange", a);
13
- const S = a.target.value;
14
- u == null || u(S, "date-picker");
12
+ const m = (d) => {
13
+ console.log("DatePicker handleChange", d);
14
+ const g = d.target.value;
15
+ i == null || i(g, "date-picker");
15
16
  };
16
- H(() => {
17
- if (w.current)
17
+ F(() => {
18
+ if (A.current)
18
19
  try {
19
20
  setTimeout(() => {
20
- C();
21
+ S();
21
22
  }, 100);
22
- } catch (a) {
23
- console.log("无法自动打开日期选择器,浏览器安全策略限制", a);
23
+ } catch (d) {
24
+ console.log("无法自动打开日期选择器,浏览器安全策略限制", d);
24
25
  }
25
26
  }, []);
26
- const C = () => {
27
- if (w.current)
27
+ const S = () => {
28
+ if (A.current)
28
29
  try {
29
- w.current.showPicker();
30
- } catch (a) {
31
- console.log("点击后无法打开日期选择器", a);
30
+ A.current.showPicker();
31
+ } catch (d) {
32
+ console.log("点击后无法打开日期选择器", d);
32
33
  }
33
- }, b = (a) => {
34
- a.stopPropagation(), console.log("DatePicker handleClick", a);
34
+ }, f = (d) => {
35
+ d.stopPropagation(), console.log("DatePicker handleClick", d);
35
36
  };
36
- return y ? /* @__PURE__ */ h(
37
+ return b ? /* @__PURE__ */ h(
37
38
  "div",
38
39
  {
39
- ref: N,
40
+ ref: T,
40
41
  id: c,
41
42
  style: {
42
- top: (r == null ? void 0 : r.top) || 0,
43
- left: (r == null ? void 0 : r.left) || 0
43
+ top: (s == null ? void 0 : s.top) || 0,
44
+ left: (s == null ? void 0 : s.left) || 0
44
45
  },
45
46
  className: "cosmic-ai-input-datePicker",
46
47
  suppressHydrationWarning: !0,
47
48
  children: /* @__PURE__ */ h(
48
49
  "input",
49
50
  {
50
- ref: w,
51
+ ref: A,
51
52
  type: "date",
52
- value: s || "",
53
- onChange: x,
54
- onClick: b
53
+ value: r || "",
54
+ onChange: m,
55
+ onClick: f
55
56
  }
56
57
  )
57
58
  }
58
59
  ) : null;
59
60
  }
60
61
  );
61
- he.displayName = "DatePicker";
62
- function Y(s) {
63
- const r = s.textContent || "", c = s.nextSibling;
64
- r.length ? (c == null || c.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") : (c == null || c.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");
62
+ ke.displayName = "DatePicker";
63
+ function te(r) {
64
+ const s = r.textContent || "", c = r.nextSibling;
65
+ s.length ? (c == null || c.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") : (c == null || c.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");
65
66
  }
66
- function F(s) {
67
- if (s && s.getAttribute("data-set-type") === "input") {
68
- const r = s.children[0];
69
- r.setAttribute("contenteditable", "true"), requestAnimationFrame(() => {
70
- r.focus();
67
+ function P(r) {
68
+ if (r && r.getAttribute("data-set-type") === "input") {
69
+ const s = r.children[0];
70
+ s.setAttribute("contenteditable", "true"), requestAnimationFrame(() => {
71
+ s.focus();
71
72
  });
72
73
  }
73
74
  }
74
- function ue(s) {
75
- s && s.getAttribute("data-set-type") === "input" && s.children[0].setAttribute("contenteditable", "false");
75
+ function me(r) {
76
+ r && r.getAttribute("data-set-type") === "input" && r.children[0].setAttribute("contenteditable", "false");
76
77
  }
77
- function O(s) {
78
- return s && s.getAttribute("data-set-type") === "input";
78
+ function M(r) {
79
+ return r && r.getAttribute("data-set-type") === "input";
79
80
  }
80
- const fe = _(({
81
- options: s,
82
- value: r,
81
+ const Re = j(({
82
+ options: r,
83
+ value: s,
83
84
  position: c,
84
- id: u,
85
+ id: i,
85
86
  height: k = 37,
86
- onChange: y
87
- }, E) => {
88
- const [N, w] = A(r || ""), x = $(null);
89
- H(() => {
90
- typeof E == "function" ? E(x.current) : E && (E.current = x.current);
91
- }, [E]);
92
- const C = (a) => {
93
- const S = N.split(",").filter((D) => D) || [];
94
- let m = "";
95
- S.includes(a) ? m = S.filter((D) => D !== a).join(",") : (console.log("handleOptionClick", S), S.length ? m = `${S.join(",")},${a}` : m = a), w(m), y == null || y(m, "multiple-select");
96
- }, b = N.split(",") || [];
87
+ onChange: b
88
+ }, x) => {
89
+ const [T, A] = w(s || ""), m = O(null);
90
+ F(() => {
91
+ typeof x == "function" ? x(m.current) : x && (x.current = m.current);
92
+ }, [x]);
93
+ const S = (d) => {
94
+ const g = T.split(",").filter((D) => D) || [];
95
+ let B = "";
96
+ g.includes(d) ? B = g.filter((D) => D !== d).join(",") : (console.log("handleOptionClick", g), g.length ? B = `${g.join(",")},${d}` : B = d), A(B), b == null || b(B, "multiple-select");
97
+ }, f = T.split(",") || [];
97
98
  return /* @__PURE__ */ h(
98
99
  "div",
99
100
  {
100
- ref: x,
101
+ ref: m,
101
102
  className: "cosmic-ai-input-selectFloatElement",
102
- id: u,
103
+ id: i,
103
104
  style: {
104
105
  position: "absolute",
105
106
  top: (c == null ? void 0 : c.top) || 0,
@@ -107,40 +108,40 @@ const fe = _(({
107
108
  zIndex: 5e3,
108
109
  maxHeight: `${k}px`
109
110
  },
110
- children: s.map((a, S) => /* @__PURE__ */ h(
111
+ children: r.map((d, g) => /* @__PURE__ */ h(
111
112
  "div",
112
113
  {
113
- className: `selectOption ${b.includes(a) ? "selected" : ""}`,
114
- onClick: () => C(a),
115
- children: a
114
+ className: `selectOption ${f.includes(d) ? "selected" : ""}`,
115
+ onClick: () => S(d),
116
+ children: d
116
117
  },
117
- S
118
+ g
118
119
  ))
119
120
  }
120
121
  );
121
122
  });
122
- fe.displayName = "MultipleSelect";
123
- const ge = _(({
124
- options: s,
125
- value: r,
123
+ Re.displayName = "MultipleSelect";
124
+ const Te = j(({
125
+ options: r,
126
+ value: s,
126
127
  position: c,
127
- id: u,
128
+ id: i,
128
129
  height: k = 120,
129
- onChange: y
130
- }, E) => {
131
- const [N, w] = A(r || ""), x = $(null);
132
- H(() => {
133
- typeof E == "function" ? E(x.current) : E && (E.current = x.current);
134
- }, [E]);
135
- const C = (b) => {
136
- w(b), y == null || y(b, "select");
130
+ onChange: b
131
+ }, x) => {
132
+ const [T, A] = w(s || ""), m = O(null);
133
+ F(() => {
134
+ typeof x == "function" ? x(m.current) : x && (x.current = m.current);
135
+ }, [x]);
136
+ const S = (f) => {
137
+ A(f), b == null || b(f, "select");
137
138
  };
138
139
  return /* @__PURE__ */ h(
139
140
  "div",
140
141
  {
141
- ref: x,
142
+ ref: m,
142
143
  className: "cosmic-ai-input-selectFloatElement",
143
- id: u,
144
+ id: i,
144
145
  style: {
145
146
  position: "absolute",
146
147
  top: (c == null ? void 0 : c.top) || 0,
@@ -148,427 +149,482 @@ const ge = _(({
148
149
  zIndex: 5e3,
149
150
  maxHeight: `${k}px`
150
151
  },
151
- children: s.map((b, a) => /* @__PURE__ */ h(
152
+ children: r.length > 0 && r.map((f, d) => /* @__PURE__ */ h(
152
153
  "div",
153
154
  {
154
- className: `selectOption ${N === b ? "selected" : ""}`,
155
- onClick: () => C(b),
156
- children: b
155
+ className: `selectOption ${T === f ? "selected" : ""}`,
156
+ onClick: () => S(f),
157
+ children: f
157
158
  },
158
- a
159
+ d
159
160
  ))
160
161
  }
161
162
  );
162
163
  });
163
- ge.displayName = "Select";
164
- function pe(s) {
165
- const r = s instanceof Element ? s : document.getElementById(s);
166
- return r && r.children[0].textContent || "";
164
+ Te.displayName = "Select";
165
+ function Ae(r) {
166
+ const s = r instanceof Element ? r : document.getElementById(r);
167
+ return s && s.children[0].textContent || "";
167
168
  }
168
- function Ke(s, r) {
169
- const c = s instanceof Element ? s : document.getElementById(s);
170
- c && (c.children[0].textContent = r);
169
+ function Je(r, s) {
170
+ const c = r instanceof Element ? r : document.getElementById(r);
171
+ c && (c.children[0].textContent = s);
171
172
  }
172
- function K(s) {
173
- const r = document.createRange(), c = window.getSelection();
173
+ function z(r) {
174
+ const s = document.createRange(), c = window.getSelection();
174
175
  if (!c) {
175
176
  console.error("无法获取selection对象");
176
177
  return;
177
178
  }
178
- r.selectNodeContents(s), r.collapse(!0), c.removeAllRanges(), c.addRange(r);
179
+ try {
180
+ s.selectNodeContents(r), s.collapse(!0), c.removeAllRanges(), c.addRange(s);
181
+ } catch (i) {
182
+ console.error("设置光标位置失败:", i);
183
+ }
179
184
  }
180
- function W(s) {
181
- const r = document.createRange(), c = window.getSelection();
185
+ function H(r) {
186
+ const s = document.createRange(), c = window.getSelection();
182
187
  if (!c) {
183
188
  console.error("无法获取selection对象");
184
189
  return;
185
190
  }
186
- r.selectNodeContents(s), r.collapse(!1), c.removeAllRanges(), c.addRange(r);
187
- }
188
- function Z(s) {
189
- const r = window.getSelection();
190
- if (!r || r.rangeCount === 0)
191
- return 0;
192
- const c = r.getRangeAt(0), u = c.cloneRange();
193
- return u.selectNodeContents(s), u.setEnd(c.startContainer, c.startOffset), u.toString().length;
191
+ try {
192
+ s.selectNodeContents(r), s.collapse(!1), c.removeAllRanges(), c.addRange(s);
193
+ } catch (i) {
194
+ console.error("设置光标位置失败:", i);
195
+ }
194
196
  }
195
- function We() {
197
+ function ne(r) {
196
198
  const s = window.getSelection();
197
199
  if (!s || s.rangeCount === 0)
200
+ return 0;
201
+ const c = s.getRangeAt(0);
202
+ try {
203
+ const i = c.cloneRange();
204
+ return i.selectNodeContents(r), i.setEnd(c.startContainer, c.startOffset), i.toString().length;
205
+ } catch (i) {
206
+ return console.error("获取光标位置失败:", i), 0;
207
+ }
208
+ }
209
+ function Qe() {
210
+ const r = window.getSelection();
211
+ if (!r || r.rangeCount === 0)
198
212
  return null;
199
- const c = s.getRangeAt(0).startContainer;
213
+ const c = r.getRangeAt(0).startContainer;
200
214
  return c.nodeType === Node.TEXT_NODE ? c.parentElement : c.nodeType === Node.ELEMENT_NODE ? c : null;
201
215
  }
202
- function _e() {
203
- const s = window.getSelection();
204
- if (!s || s.rangeCount === 0)
216
+ function Ye() {
217
+ const r = window.getSelection();
218
+ if (!r || r.rangeCount === 0)
205
219
  return null;
206
- const r = s.getRangeAt(0), c = r.startContainer, u = r.startOffset;
207
- return c.nodeType === Node.TEXT_NODE ? u > 0 ? c : c.previousSibling : c.nodeType === Node.ELEMENT_NODE ? u > 0 ? c.childNodes[u - 1] : c.previousSibling : null;
220
+ const s = r.getRangeAt(0), c = s.startContainer, i = s.startOffset;
221
+ return c.nodeType === Node.TEXT_NODE ? i > 0 ? c : c.previousSibling : c.nodeType === Node.ELEMENT_NODE ? i > 0 ? c.childNodes[i - 1] : c.previousSibling : null;
208
222
  }
209
- function ze() {
210
- const s = window.getSelection();
211
- if (!s || s.rangeCount === 0)
223
+ function Ze() {
224
+ const r = window.getSelection();
225
+ if (!r || r.rangeCount === 0)
212
226
  return null;
213
- const r = s.getRangeAt(0), c = r.startContainer, u = r.startOffset;
214
- return c.nodeType === Node.TEXT_NODE ? u < c.length ? c : c.nextSibling : c.nodeType === Node.ELEMENT_NODE ? u < c.childNodes.length ? c.childNodes[u] : c.nextSibling : null;
227
+ const s = r.getRangeAt(0), c = s.startContainer, i = s.startOffset;
228
+ return c.nodeType === Node.TEXT_NODE ? i < c.length ? c : c.nextSibling : c.nodeType === Node.ELEMENT_NODE ? i < c.childNodes.length ? c.childNodes[i] : c.nextSibling : null;
215
229
  }
216
- function je(s) {
217
- return s && !s.getAttribute("data-set-type");
230
+ function Ie(r) {
231
+ return r && !r.getAttribute("data-set-type");
218
232
  }
219
- const Ue = _((s, r) => {
220
- const { value: c, varList: u, placeholder: k = "", maxLength: y, defaultRows: E = 3, disabled: N = !1, onFocus: w, onBlur: x, onChange: C, onClick: b, onSend: a, onParse: S, onKeyDown: m, onKeyUp: D, onMaxLengthExceeded: z } = s, [I, Xe] = A(c || ""), [Ge, v] = A(c || ""), [ye, ee] = A(""), [j, M] = A(!1), [U, X] = A({ top: 0, left: 0 }), [te, ne] = A([]), [G, le] = A(""), [P, oe] = A(null), [ce, se] = A(120), Ee = 240, be = 240, ie = 240, re = 276, B = $(null), g = $(null), T = $(null), V = () => {
221
- var e;
222
- return ((e = B.current) == null ? void 0 : e.innerText) || "";
223
- }, ae = () => {
224
- var e;
225
- return ((e = B.current) == null ? void 0 : e.innerHTML) || "";
226
- }, xe = (e) => {
227
- const n = [];
228
- let t = 0;
233
+ const et = j((r, s) => {
234
+ const { value: c = "", varList: i, placeholder: k = "", maxLength: b, defaultRows: x = 3, disabled: T = !1, defaultFocus: A = !1, onFocus: m, onBlur: S, onChange: f, onClick: d, onSend: g, onParse: B, onKeyDown: D, onKeyUp: V, onMaxLengthExceeded: U } = r, [tt, nt] = w(c || ""), [X, v] = w(""), [lt, le] = w(""), [G, q] = w(!1), [J, Q] = w({ top: 0, left: 0 }), [oe, ce] = w([]), [Y, re] = w(""), [L, se] = w(null), [ie, ae] = w(120), [de, ue] = w(A), De = 240, Ne = 240, pe = 240, he = 276, C = O(null), y = O(null), N = O(null), K = () => {
235
+ var l, n;
236
+ let e = ((n = (l = C.current) == null ? void 0 : l.innerText) == null ? void 0 : n.replace(/\u200B/g, "")) || "";
237
+ return e === `
238
+ ` && (e = ""), e;
239
+ }, fe = () => {
240
+ var l;
241
+ let e = ((l = C.current) == null ? void 0 : l.innerHTML) || "";
242
+ return e === "<br>" && (e = ""), e;
243
+ }, Se = (e) => {
244
+ const l = [];
245
+ let n = 0;
229
246
  const o = /\[([^\]]+)\]/g;
230
- let d, p = 0;
231
- const R = new Set(u.map((f) => f.name));
232
- for (; (d = o.exec(e)) !== null; ) {
233
- if (d.index > t) {
234
- const i = e.substring(t, d.index).split(`
247
+ let a;
248
+ const u = `${Date.now()}-${Math.random().toString(36).slice(2, 9)}`;
249
+ let p = 0;
250
+ if (e === "" || !e || e === `
251
+ `)
252
+ return [{
253
+ type: "text",
254
+ content: "​",
255
+ id: `text-${p++}-${u}`
256
+ }];
257
+ const $ = new Set((i || []).map((E) => E.name));
258
+ for (; (a = o.exec(e)) !== null; ) {
259
+ if (a.index > n) {
260
+ const R = e.substring(n, a.index).split(`
235
261
  `);
236
- i.forEach((L, Me) => {
237
- L && n.push({
262
+ R.forEach((W, Ue) => {
263
+ W && l.push({
238
264
  type: "text",
239
- content: L,
240
- id: `text-${p++}`
241
- }), Me < i.length - 1 && n.push({
265
+ content: W,
266
+ id: `text-${p++}-${u}`
267
+ }), Ue < R.length - 1 && l.push({
242
268
  type: "newline",
243
- id: `newline-${p++}`
269
+ id: `newline-${p++}-${u}`
244
270
  });
245
271
  });
246
272
  }
247
- const f = d[1];
248
- if (R.has(f)) {
249
- const l = u.find((i) => i.name === f);
250
- (l == null ? void 0 : l.type) === "input" ? n.push({
273
+ const E = a[1];
274
+ if ($.has(E)) {
275
+ const t = i.find((R) => R.name === E);
276
+ (t == null ? void 0 : t.type) === "input" ? l.push({
251
277
  type: "input",
252
- name: l == null ? void 0 : l.name,
253
- content: (l == null ? void 0 : l.content) || "",
254
- placeholder: (l == null ? void 0 : l.placeholder) || f,
255
- id: `input-${p++}`
256
- }) : (l == null ? void 0 : l.type) === "select" ? n.push({
278
+ name: t == null ? void 0 : t.name,
279
+ content: (t == null ? void 0 : t.content) || "",
280
+ placeholder: (t == null ? void 0 : t.placeholder) || E,
281
+ id: `input-${p++}-${u}`
282
+ }) : (t == null ? void 0 : t.type) === "select" ? l.push({
257
283
  type: "select",
258
- name: l == null ? void 0 : l.name,
259
- content: (l == null ? void 0 : l.content) || "",
260
- placeholder: (l == null ? void 0 : l.placeholder) || f,
261
- options: (l == null ? void 0 : l.options) || [],
262
- id: `select-${p++}`
263
- }) : (l == null ? void 0 : l.type) === "multiple-select" ? n.push({
284
+ name: t == null ? void 0 : t.name,
285
+ content: (t == null ? void 0 : t.content) || "",
286
+ placeholder: (t == null ? void 0 : t.placeholder) || E,
287
+ options: (t == null ? void 0 : t.options) || [],
288
+ id: `select-${p++}-${u}`
289
+ }) : (t == null ? void 0 : t.type) === "multiple-select" ? l.push({
264
290
  type: "multiple-select",
265
- name: l == null ? void 0 : l.name,
266
- content: (l == null ? void 0 : l.content) || "",
267
- placeholder: (l == null ? void 0 : l.placeholder) || f,
268
- options: (l == null ? void 0 : l.options) || [],
269
- id: `multiple-select-${p++}`
270
- }) : (l == null ? void 0 : l.type) === "date-picker" && n.push({
291
+ name: t == null ? void 0 : t.name,
292
+ content: (t == null ? void 0 : t.content) || "",
293
+ placeholder: (t == null ? void 0 : t.placeholder) || E,
294
+ options: (t == null ? void 0 : t.options) || [],
295
+ id: `multiple-select-${p++}-${u}`
296
+ }) : (t == null ? void 0 : t.type) === "date-picker" && l.push({
271
297
  type: "date-picker",
272
- name: l == null ? void 0 : l.name,
273
- content: (l == null ? void 0 : l.content) || "",
274
- placeholder: (l == null ? void 0 : l.placeholder) || f,
275
- id: `date-picker-${p++}`
298
+ name: t == null ? void 0 : t.name,
299
+ content: (t == null ? void 0 : t.content) || "",
300
+ placeholder: (t == null ? void 0 : t.placeholder) || E,
301
+ id: `date-picker-${p++}-${u}`
276
302
  });
277
303
  } else
278
- n.push({
304
+ l.push({
279
305
  type: "text",
280
- content: `[${f}]`,
281
- id: `text-${p++}`
306
+ content: `[${E}]`,
307
+ id: `text-${p++}-${u}`
282
308
  });
283
- t = o.lastIndex;
309
+ n = o.lastIndex;
284
310
  }
285
- if (t < e.length) {
286
- const l = e.substring(t).split(`
311
+ if (n < e.length) {
312
+ const t = e.substring(n).split(`
287
313
  `);
288
- l.forEach((i, L) => {
289
- i && n.push({
314
+ t.forEach((R, W) => {
315
+ R && l.push({
290
316
  type: "text",
291
- content: i,
317
+ content: R,
292
318
  id: `text-${p++}`
293
- }), L < l.length - 1 && n.push({
319
+ }), W < t.length - 1 && l.push({
294
320
  type: "newline",
295
321
  id: `newline-${p++}`
296
322
  });
297
323
  });
298
324
  }
299
- return n;
300
- }, J = () => {
325
+ return l;
326
+ }, Z = () => {
301
327
  var e;
302
- (e = B.current) == null || e.setAttribute("contenteditable", "true"), g.current && (O(g.current) && g.current.children[0].setAttribute("contenteditable", "false"), g.current = null);
303
- }, we = (e) => {
304
- console.log("handleEditorClick", e), b == null || b(e);
305
- }, Ce = (e) => {
306
- console.log("handleEditorMouseDown", e), J();
307
- }, me = (e) => {
308
- console.log("handleEditorInput", e), v(V()), ee(ae()), C == null || C(V());
309
- }, Ae = (e) => {
328
+ (e = C.current) == null || e.setAttribute("contenteditable", "true"), y.current && (M(y.current) && y.current.children[0].setAttribute("contenteditable", "false"), y.current = null), H(C.current);
329
+ }, Le = (e) => {
330
+ console.log("handleEditorClick", e), d == null || d(e);
331
+ }, $e = (e) => {
332
+ console.log("handleEditorMouseDown", e), Z();
333
+ }, ge = (e) => {
334
+ console.log("handleEditorInput", e), v(K()), le(fe()), f == null || f(K());
335
+ }, Pe = (e) => {
336
+ var l, n;
310
337
  if (e.code === "Enter" && !e.shiftKey) {
311
338
  e.preventDefault();
312
- const n = V();
313
- console.log("onSend", n, "maxLength:", y, "length:", n.length), y ? n.length <= y ? a == null || a(n) : (console.log("maxLength exceeded", n, y), z == null || z(n, y)) : a == null || a(n);
339
+ const o = K();
340
+ if (console.log("onSend", o, "maxLength:", b, "length:", o.length), o.length === 0 || (console.log("containerRef.current?.innerHTML", (l = C.current) == null ? void 0 : l.innerHTML), (n = C.current) != null && n.innerHTML.match(/^<span>[\s\u200B]*(<br\s*\/?>[\s\u200B]*)+<\/span>$/)))
341
+ return;
342
+ b ? o.length <= b ? g == null || g(o) : (console.log("maxLength exceeded", o, b), U == null || U(o, b)) : g == null || g(o);
314
343
  }
315
- }, ke = (e) => {
316
- var t;
317
- console.log("handleEditorKeyDown", e), m == null || m(e);
318
- const n = We();
319
- if (n && je(n)) {
344
+ }, Fe = (e) => {
345
+ var n;
346
+ console.log("handleEditorKeyDown", e), D == null || D(e);
347
+ const l = Qe();
348
+ if (l && Ie(l)) {
320
349
  if (e.code === "ArrowLeft") {
321
- const o = n == null ? void 0 : n.previousElementSibling, d = Z(n);
322
- o && d === 0 && O(o) && o.children[0] && (g.current = o, F(o), requestAnimationFrame(() => {
323
- W(o.children[0]);
350
+ const o = l == null ? void 0 : l.previousElementSibling, a = ne(l);
351
+ o && a === 0 && M(o) && o.children[0] && (y.current = o, P(o), requestAnimationFrame(() => {
352
+ H(o.children[0]);
324
353
  }));
325
354
  }
326
355
  if (e.code === "ArrowRight") {
327
- const o = n == null ? void 0 : n.nextElementSibling, d = Z(n);
328
- o && d === ((t = n.textContent) == null ? void 0 : t.length) && O(o) && o.children[0] && (g.current = o, F(o), requestAnimationFrame(() => {
329
- K(o.children[0]);
356
+ const o = l == null ? void 0 : l.nextElementSibling, a = ne(l);
357
+ o && a === ((n = l.textContent) == null ? void 0 : n.length) && M(o) && o.children[0] && (y.current = o, P(o), requestAnimationFrame(() => {
358
+ z(o.children[0]);
330
359
  }));
331
360
  }
361
+ e.code === "Backspace" && (l.innerHTML === "​" && e.preventDefault(), l.innerHTML === "<br>" && (e.preventDefault(), l.innerHTML = "​"));
332
362
  }
333
- if (n && n.getAttribute("data-set-type") === "container") {
363
+ if (l && l.getAttribute("data-set-type") === "container") {
334
364
  if (e.code === "ArrowLeft") {
335
- const o = _e();
336
- O(o) && o.children[0] && (g.current = o, F(o), requestAnimationFrame(() => {
337
- W(o.children[0]);
365
+ const o = Ye();
366
+ M(o) && o.children[0] && (y.current = o, P(o), requestAnimationFrame(() => {
367
+ H(o.children[0]);
338
368
  }));
339
369
  }
340
370
  if (e.code === "ArrowRight") {
341
- const o = ze();
342
- O(o) && o.children[0] && (g.current = o, F(o), requestAnimationFrame(() => {
343
- K(o.children[0]);
371
+ const o = Ze();
372
+ M(o) && o.children[0] && (y.current = o, P(o), requestAnimationFrame(() => {
373
+ z(o.children[0]);
344
374
  }));
345
375
  }
346
376
  }
347
- Ae(e);
348
- }, Re = (e) => {
349
- console.log("handleEditorKeyUp", e), D == null || D(e);
350
- }, Ne = (e, n) => {
351
- n.stopPropagation(), console.log("handleInputClick", e);
352
- }, Se = (e, n) => {
377
+ Pe(e);
378
+ }, Me = (e) => {
379
+ console.log("handleEditorKeyUp", e), V == null || V(e);
380
+ }, He = (e) => {
381
+ e.preventDefault();
382
+ const n = window.getSelection().toString();
383
+ if (!n) return;
384
+ const o = n, a = n;
385
+ e.clipboardData.setData("text/plain", o), e.clipboardData.setData("text/html", a);
386
+ }, Oe = (e) => {
387
+ m == null || m(e);
388
+ }, Be = (e, l) => {
389
+ l.stopPropagation(), console.log("handleInputClick", e);
390
+ }, Ve = (e, l) => {
353
391
  var o;
354
- n.stopPropagation(), console.log("handleInputMouseDown", e, n), g.current && ue(g.current), (o = B.current) == null || o.setAttribute("contenteditable", "false");
355
- const t = document.getElementById(e.id);
356
- g.current = t, requestAnimationFrame(() => {
357
- F(t);
392
+ l.stopPropagation(), console.log("handleInputMouseDown", e, l), y.current && me(y.current), (o = C.current) == null || o.setAttribute("contenteditable", "false");
393
+ const n = document.getElementById(e.id);
394
+ y.current = n, requestAnimationFrame(() => {
395
+ P(n);
358
396
  });
359
- }, De = (e, n) => {
360
- var d, p, R, f, l;
361
- console.log("handleInputKeyDown", e, n), m == null || m(n), n.stopPropagation();
362
- const t = n.target, o = Z(t);
363
- if (n.code === "Backspace" && o === 0) {
364
- const i = (d = t.parentElement) == null ? void 0 : d.previousElementSibling;
365
- console.log("previousElement", i), i && (O(i) && i.children[0] && ((p = i.children[0].textContent) != null && p.length) ? (g.current = i, F(i), W(i.children[0]), requestAnimationFrame(() => {
366
- Y(i.children[0]);
367
- })) : (J(), W(i)));
397
+ }, qe = (e, l) => {
398
+ var a, u, p, $, E;
399
+ console.log("handleInputKeyDown", e, l), D == null || D(l), l.stopPropagation();
400
+ const n = l.target, o = ne(n);
401
+ if (l.code === "Backspace" && o === 0) {
402
+ const t = (a = n.parentElement) == null ? void 0 : a.previousElementSibling;
403
+ console.log("previousElement", t), t && (M(t) && t.children[0] && ((u = t.children[0].textContent) != null && u.length) ? (y.current = t, P(t), H(t.children[0]), requestAnimationFrame(() => {
404
+ te(t.children[0]);
405
+ })) : (Z(), H(t)));
368
406
  }
369
- if (n.code === "ArrowRight" && o === ((R = t.textContent) == null ? void 0 : R.length)) {
370
- const i = (f = t.parentElement) == null ? void 0 : f.nextElementSibling;
371
- console.log("nextElement", i), i && (O(i) && i.children[0] && ((l = i.children[0].textContent) != null && l.length) ? (g.current = i, F(i), K(i.children[0]), requestAnimationFrame(() => {
372
- Y(i.children[0]);
373
- })) : (J(), K(i)));
407
+ if (l.code === "ArrowRight" && o === ((p = n.textContent) == null ? void 0 : p.length)) {
408
+ const t = ($ = n.parentElement) == null ? void 0 : $.nextElementSibling;
409
+ console.log("nextElement", t), t && (M(t) && t.children[0] && ((E = t.children[0].textContent) != null && E.length) ? (y.current = t, P(t), z(t.children[0]), requestAnimationFrame(() => {
410
+ te(t.children[0]);
411
+ })) : (Z(), z(t)));
374
412
  }
375
- }, Te = (e, n) => {
376
- console.log("handleInputKeyUp", e, n), D == null || D(n);
377
- const t = n.target;
378
- Y(t);
379
- }, Pe = (e, n) => {
413
+ }, Ke = (e, l) => {
414
+ console.log("handleInputKeyUp", e, l), V == null || V(l);
415
+ const n = l.target;
416
+ te(n);
417
+ }, We = (e, l) => {
380
418
  var o;
381
- n.stopPropagation(), console.log("handlePlaceholderMouseDown", e), g.current && ue(g.current), (o = B.current) == null || o.setAttribute("contenteditable", "false");
382
- const t = document.getElementById(e.id);
383
- g.current = t, requestAnimationFrame(() => {
384
- F(t);
419
+ l.stopPropagation(), console.log("handlePlaceholderMouseDown", e), y.current && me(y.current), (o = C.current) == null || o.setAttribute("contenteditable", "false");
420
+ const n = document.getElementById(e.id);
421
+ y.current = n, requestAnimationFrame(() => {
422
+ P(n);
385
423
  });
386
- }, Le = (e, n) => {
387
- console.log("handleInputChange", e, n), v(V()), ee(ae()), C == null || C(V());
388
- }, Fe = (e, n) => {
389
- console.log("handleTextSpanKeyDown 不生效", e, n);
424
+ }, _e = (e, l) => {
425
+ console.log("handleInputChange", e, l), v(K()), le(fe()), f == null || f(K());
426
+ }, ze = (e, l) => {
427
+ console.log("handleTextSpanKeyDown 不生效", e, l);
390
428
  };
391
- H(() => {
392
- if (!j)
429
+ F(() => {
430
+ if (!G)
393
431
  return;
394
432
  const e = (o) => {
395
- T.current && !T.current.contains(o.target) && M(!1);
396
- }, n = (o) => {
397
- T.current && !T.current.contains(o.target) && M(!1);
398
- }, t = () => {
399
- M(!1);
433
+ N.current && !N.current.contains(o.target) && q(!1);
434
+ }, l = (o) => {
435
+ N.current && !N.current.contains(o.target) && q(!1);
436
+ }, n = () => {
437
+ q(!1);
400
438
  };
401
- return document.addEventListener("mousedown", e), document.addEventListener("scroll", n, !0), window.addEventListener("resize", t), () => {
402
- document.removeEventListener("mousedown", e), document.removeEventListener("scroll", n, !0), window.removeEventListener("resize", t);
439
+ return document.addEventListener("mousedown", e), document.addEventListener("scroll", l, !0), window.addEventListener("resize", n), () => {
440
+ document.removeEventListener("mousedown", e), document.removeEventListener("scroll", l, !0), window.removeEventListener("resize", n);
403
441
  };
404
- }, [j]);
405
- const Q = (e, n) => {
406
- if (console.log("handleFloatChange", e, n), P && Ke(P.id, e), n === "select" && M(!1), n === "multiple-select" || n === "date-picker") {
407
- const t = document.getElementById(P.id);
408
- t && t.children[0] && t.children[1] && (e.length > 0 ? (t.children[0].setAttribute("style", "display: inline"), t.children[0].setAttribute("contenteditable", "false"), t.children[1].setAttribute("style", "display: none"), t.children[1].setAttribute("contenteditable", "true")) : (t.children[0].setAttribute("style", "display: none"), t.children[0].setAttribute("contenteditable", "true"), t.children[1].setAttribute("style", "display: inline"), t.children[1].setAttribute("contenteditable", "true")));
442
+ }, [G]);
443
+ const I = (e, l) => {
444
+ if (console.log("handleFloatChange", e, l), L && Je(L.id, e), l === "select" && q(!1), l === "multiple-select" || l === "date-picker") {
445
+ const n = document.getElementById(L.id);
446
+ n && n.children[0] && n.children[1] && (e.length > 0 ? (n.children[0].setAttribute("style", "display: inline"), n.children[0].setAttribute("contenteditable", "false"), n.children[1].setAttribute("style", "display: none"), n.children[1].setAttribute("contenteditable", "true")) : (n.children[0].setAttribute("style", "display: none"), n.children[0].setAttribute("contenteditable", "true"), n.children[1].setAttribute("style", "display: inline"), n.children[1].setAttribute("contenteditable", "true")));
409
447
  }
410
- }, de = (e, n) => {
411
- console.log("handleSelectClick", e, n);
412
- const o = n.target.getBoundingClientRect();
413
- ne(e.options), le(e.value || pe(e.id)), X({ top: -999999, left: -999999999 }), oe(e), se(be), M(!0), requestAnimationFrame(() => {
414
- if (T.current) {
415
- console.log("currentFloatElementRef.current", T.current);
416
- const d = T.current.getBoundingClientRect();
417
- let p = o.left, R = o.top + o.height;
418
- window.innerWidth - o.right < Ee && o.width < d.width && (p = o.right - d.width), o.top < d.height && (R = o.top + o.height), X({ top: R, left: p }), se(d.height);
448
+ ge({});
449
+ }, ye = (e, l) => {
450
+ console.log("handleSelectClick", e, l);
451
+ const o = l.target.getBoundingClientRect();
452
+ ce(e.options), re(e.value || Ae(e.id)), Q({ top: -999999, left: -999999999 }), se(e), ae(Ne), q(!0), requestAnimationFrame(() => {
453
+ if (N.current) {
454
+ console.log("currentFloatElementRef.current", N.current);
455
+ const a = N.current.getBoundingClientRect();
456
+ let u = o.left, p = o.top + o.height;
457
+ window.innerWidth - o.right < De && o.width < a.width && (u = o.right - a.width), o.top < a.height && (p = o.top + o.height), Q({ top: p, left: u }), ae(a.height);
419
458
  }
420
459
  });
421
- }, Oe = (e, n) => {
422
- console.log("handleDatePickerClick", e, n);
423
- const o = n.target.getBoundingClientRect();
424
- let d = o.left, p = o.top - re;
425
- window.innerWidth - o.right < ie && (d = d - ie + o.width), o.top < re && (p = o.top + o.height), ne(e.options), le(e.value || pe(e.id)), X({ top: p, left: d }), oe(e), M(!0);
426
- }, $e = () => {
427
- const e = xe(I);
428
- console.log("parsed", e);
429
- const n = [];
430
- return e.forEach((t) => {
431
- var o, d, p, R, f, l;
432
- if (t.type === "text")
433
- n.push(
434
- /* @__PURE__ */ h("span", { onKeyDown: (i) => Fe(t, i), children: t.content }, t.id)
460
+ }, je = (e, l) => {
461
+ console.log("handleDatePickerClick", e, l);
462
+ const o = l.target.getBoundingClientRect();
463
+ let a = o.left, u = o.top - he;
464
+ window.innerWidth - o.right < pe && (a = a - pe + o.width), o.top < he && (u = o.top + o.height), ce(e.options), re(e.value || Ae(e.id)), Q({ top: u, left: a }), se(e), q(!0);
465
+ }, [Ee, be] = w([]), [ee, xe] = w(!0), we = Xe(() => {
466
+ xe(!1);
467
+ const e = Se(c), l = [];
468
+ return e.forEach((n) => {
469
+ var o, a, u, p, $, E;
470
+ if (n.type === "text")
471
+ l.push(
472
+ /* @__PURE__ */ h("span", { onKeyDown: (t) => ze(n, t), children: n.content }, n.id)
435
473
  );
436
- else if (t.type === "newline")
437
- n.push(/* @__PURE__ */ h("br", {}, t.id));
438
- else if (t.type === "input")
439
- n.push(
440
- /* @__PURE__ */ q(
474
+ else if (n.type === "newline")
475
+ l.push(/* @__PURE__ */ h("br", {}, n.id));
476
+ else if (n.type === "input")
477
+ l.push(
478
+ /* @__PURE__ */ _(
441
479
  "span",
442
480
  {
443
- id: t.id,
481
+ id: n.id,
444
482
  "data-set-type": "input",
445
483
  contentEditable: !1,
446
484
  suppressContentEditableWarning: !0,
447
- onInput: (i) => Le(t, i),
448
- onClick: (i) => Ne(t, i),
449
- onMouseDown: (i) => Se(t, i),
450
- "data-cosmic-ai-input-placeholder": t.placeholder,
485
+ onInput: (t) => _e(n, t),
486
+ onClick: (t) => Be(n, t),
487
+ onMouseDown: (t) => Ve(n, t),
488
+ "data-cosmic-ai-input-placeholder": n.placeholder,
451
489
  children: [
452
- /* @__PURE__ */ h("span", { className: "cosmic-ai-input-inputContent", style: { padding: (o = t.content) != null && o.length ? "2px 4px" : "2px 0 2px 4px" }, contentEditable: !1, onKeyDown: (i) => De(t, i), onKeyUp: (i) => Te(t, i), children: t.content }),
453
- /* @__PURE__ */ h("span", { contentEditable: !1, style: { display: (d = t.content) != null && d.length ? "none" : "inline" }, className: "cosmic-ai-input-placeholder", onMouseDown: (i) => Pe(t, i), children: t.placeholder })
490
+ /* @__PURE__ */ h("span", { className: "cosmic-ai-input-inputContent", style: { padding: (o = n.content) != null && o.length ? "2px 4px" : "2px 0 2px 4px" }, contentEditable: !1, onKeyDown: (t) => qe(n, t), onKeyUp: (t) => Ke(n, t), children: n.content }),
491
+ /* @__PURE__ */ h("span", { contentEditable: !1, style: { display: (a = n.content) != null && a.length ? "none" : "inline" }, className: "cosmic-ai-input-placeholder", onMouseDown: (t) => We(n, t), children: n.placeholder })
454
492
  ]
455
493
  },
456
- t.id
494
+ n.id
457
495
  )
458
496
  );
459
- else if (t.type === "select") {
460
- const i = t.content || ((p = t.options) == null ? void 0 : p[0]) || t.placeholder;
461
- n.push(
497
+ else if (n.type === "select") {
498
+ const t = n.content || ((u = n.options) == null ? void 0 : u[0]) || n.placeholder;
499
+ l.push(
462
500
  /* @__PURE__ */ h(
463
501
  "span",
464
502
  {
465
- id: t.id,
503
+ id: n.id,
466
504
  "data-set-type": "select",
467
- contentEditable: !0,
505
+ contentEditable: !1,
468
506
  suppressContentEditableWarning: !0,
469
- onClick: (L) => de(t, L),
470
- "data-cosmic-ai-input-placeholder": t.placeholder,
471
- children: /* @__PURE__ */ h("span", { contentEditable: !1, children: i })
507
+ onClick: (R) => ye(n, R),
508
+ "data-cosmic-ai-input-placeholder": n.placeholder,
509
+ children: /* @__PURE__ */ h("span", { contentEditable: !1, children: t })
472
510
  },
473
- t.id
511
+ n.id
474
512
  )
475
513
  );
476
- } else if (t.type === "multiple-select") {
477
- const i = t.content || ((R = t.options) == null ? void 0 : R[0]);
478
- n.push(
479
- /* @__PURE__ */ q(
514
+ } else if (n.type === "multiple-select") {
515
+ const t = n.content || ((p = n.options) == null ? void 0 : p[0]);
516
+ l.push(
517
+ /* @__PURE__ */ _(
480
518
  "span",
481
519
  {
482
- id: t.id,
520
+ id: n.id,
483
521
  "data-set-type": "multiple-select",
484
- contentEditable: !0,
522
+ contentEditable: !1,
485
523
  suppressContentEditableWarning: !0,
486
- onClick: (L) => de(t, L),
487
- "data-cosmic-ai-input-placeholder": t.placeholder,
524
+ onClick: (R) => ye(n, R),
525
+ "data-cosmic-ai-input-placeholder": n.placeholder,
488
526
  children: [
489
- /* @__PURE__ */ h("span", { style: { display: i != null && i.length ? "inline" : "none" }, contentEditable: !1, children: i }),
490
- /* @__PURE__ */ h("span", { style: { display: i != null && i.length ? "none" : "inline" }, className: "cosmic-ai-input-selectPlaceholder", contentEditable: !1, children: t.placeholder })
527
+ /* @__PURE__ */ h("span", { style: { display: t != null && t.length ? "inline" : "none" }, contentEditable: !1, children: t }),
528
+ /* @__PURE__ */ h("span", { style: { display: t != null && t.length ? "none" : "inline" }, className: "cosmic-ai-input-selectPlaceholder", contentEditable: !1, children: n.placeholder })
491
529
  ]
492
530
  },
493
- t.id
531
+ n.id
494
532
  )
495
533
  );
496
- } else t.type === "date-picker" && n.push(
497
- /* @__PURE__ */ q(
534
+ } else n.type === "date-picker" && l.push(
535
+ /* @__PURE__ */ _(
498
536
  "span",
499
537
  {
500
- id: t.id,
538
+ id: n.id,
501
539
  "data-set-type": "date-picker",
502
- contentEditable: !0,
540
+ contentEditable: !1,
503
541
  suppressContentEditableWarning: !0,
504
- onClick: (i) => Oe(t, i),
505
- "data-cosmic-ai-input-placeholder": t.placeholder,
542
+ onClick: (t) => je(n, t),
543
+ "data-cosmic-ai-input-placeholder": n.placeholder,
506
544
  children: [
507
- /* @__PURE__ */ h("span", { style: { display: (f = t.content) != null && f.length ? "inline" : "none" }, contentEditable: !1, children: t.content }),
508
- /* @__PURE__ */ h("span", { style: { display: (l = t.content) != null && l.length ? "none" : "inline" }, className: "cosmic-ai-input-datePickerPlaceholder", contentEditable: !1, children: t.placeholder })
545
+ /* @__PURE__ */ h("span", { style: { display: ($ = n.content) != null && $.length ? "inline" : "none" }, contentEditable: !1, children: n.content }),
546
+ /* @__PURE__ */ h("span", { style: { display: (E = n.content) != null && E.length ? "none" : "inline" }, className: "cosmic-ai-input-datePickerPlaceholder", contentEditable: !1, children: n.placeholder })
509
547
  ]
510
548
  },
511
- t.id
549
+ n.id
512
550
  )
513
551
  );
514
- }), n;
515
- };
516
- return Ve(r, () => ({
517
- getCurrentValue: V
518
- })), /* @__PURE__ */ q(Be, { children: [
519
- /* @__PURE__ */ h(
552
+ }), setTimeout(() => {
553
+ xe(!0);
554
+ }, 0), console.log("重新渲染 ============================>", "elements", l, "parsed", e, c), l;
555
+ }, [c]);
556
+ return F(() => {
557
+ ee && setTimeout(() => {
558
+ H(C.current);
559
+ }, 0);
560
+ }, [ee]), F(() => {
561
+ c !== X ? (be(we()), v(c), ue(!0)) : (c === "" || !c) && be(we());
562
+ }, [c, X]), F(() => {
563
+ if (!A && !de) return;
564
+ const e = new MutationObserver(() => {
565
+ C.current && document.contains(C.current) && (requestAnimationFrame(() => {
566
+ H(C.current), ue(!1);
567
+ }), e.disconnect());
568
+ });
569
+ return C.current && e.observe(document.body, { childList: !0, subtree: !0 }), () => e.disconnect();
570
+ }, [A, de]), ve(s, () => ({
571
+ getCurrentValue: K
572
+ })), console.log("renderElements", Ee), // 最外层的防止renderContainer为false的时候样式坍塌
573
+ /* @__PURE__ */ _("div", { className: Ce(`cosmic-ai-input-rows${x}`), children: [
574
+ ee && /* @__PURE__ */ h(
520
575
  "div",
521
576
  {
522
577
  "data-set-type": "container",
523
578
  "data-cosmic-ai-input-placeholder": k,
524
- className: He("cosmic-ai-input", `cosmic-ai-input-rows${E}`, { "is-disabled": N }, { "is-empty": I.length === 0 || ye === "<br>" }),
525
- ref: B,
579
+ className: Ce("cosmic-ai-input", `cosmic-ai-input-rows${x}`, { "is-disabled": T }, { "is-empty": X.length === 0 }),
580
+ ref: C,
526
581
  contentEditable: !0,
527
582
  suppressContentEditableWarning: !0,
528
- onClick: (e) => we(e),
583
+ onClick: (e) => Le(e),
529
584
  onFocus: (e) => {
530
- w == null || w(e);
585
+ Oe(e);
531
586
  },
532
587
  onBlur: (e) => {
533
- x == null || x(e);
588
+ S == null || S(e);
534
589
  },
535
- onMouseDown: (e) => Ce(e),
536
- onKeyDown: (e) => ke(e),
537
- onKeyUp: (e) => Re(e),
538
- onInput: (e) => me(e),
539
- children: $e()
590
+ onMouseDown: (e) => $e(e),
591
+ onKeyDown: (e) => Fe(e),
592
+ onKeyUp: (e) => Me(e),
593
+ onInput: (e) => ge(e),
594
+ onCopy: (e) => He(e),
595
+ children: Ee
540
596
  }
541
597
  ),
542
- j && qe(
543
- (P == null ? void 0 : P.type) === "multiple-select" ? /* @__PURE__ */ h(
544
- fe,
598
+ G && Ge(
599
+ (L == null ? void 0 : L.type) === "multiple-select" ? /* @__PURE__ */ h(
600
+ Re,
545
601
  {
546
- ref: T,
547
- options: te,
548
- value: G,
549
- position: U,
550
- height: ce,
551
- onChange: Q
602
+ ref: N,
603
+ options: oe,
604
+ value: Y,
605
+ position: J,
606
+ height: ie,
607
+ onChange: I
552
608
  },
553
609
  "multiple-select"
554
- ) : (P == null ? void 0 : P.type) === "date-picker" ? /* @__PURE__ */ h(
555
- he,
610
+ ) : (L == null ? void 0 : L.type) === "date-picker" ? /* @__PURE__ */ h(
611
+ ke,
556
612
  {
557
- ref: T,
558
- value: G,
559
- position: U,
560
- onChange: Q
613
+ ref: N,
614
+ value: Y,
615
+ position: J,
616
+ onChange: I
561
617
  },
562
618
  "date-picker"
563
619
  ) : /* @__PURE__ */ h(
564
- ge,
620
+ Te,
565
621
  {
566
- ref: T,
567
- options: te,
568
- value: G,
569
- position: U,
570
- height: ce,
571
- onChange: Q
622
+ ref: N,
623
+ options: oe,
624
+ value: Y,
625
+ position: J,
626
+ height: ie,
627
+ onChange: I
572
628
  },
573
629
  "select"
574
630
  ),
@@ -576,7 +632,7 @@ const Ue = _((s, r) => {
576
632
  )
577
633
  ] });
578
634
  });
579
- Ue.displayName = "AiInput";
635
+ et.displayName = "AiInput";
580
636
  export {
581
- Ue as default
637
+ et as default
582
638
  };
package/dist/style.css CHANGED
@@ -1 +1 @@
1
- .cosmic-ai-input{font-size:14px;outline:none}.cosmic-ai-input [data-set-type=input]{color:#b4c5fc;padding:0 2px;caret-color:#000}.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:before{content:attr(data-cosmic-ai-input-placeholder);position:absolute;color:#999;pointer-events:none}.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-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}
1
+ .cosmic-ai-input{font-size:14px;outline:none;line-height:24px}.cosmic-ai-input [data-set-type=input]{color:#b4c5fc;padding:0 2px;caret-color:#000}.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:before{content:attr(data-cosmic-ai-input-placeholder);position:absolute;color:#999;pointer-events:none}.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-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",
3
+ "version": "1.0.6",
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",