cosmic-ai-input 1.0.22 → 1.0.23
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs.js +1 -1
- package/dist/index.es.js +1 -1
- package/package.json +1 -1
package/dist/index.cjs.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// Generated at: 2026-04-04T08:
|
|
1
|
+
// Generated at: 2026-04-04T08:33:52.146Z
|
|
2
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=x=>{const m=x.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=x=>{x.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 x=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:()=>x(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 x=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:()=>x(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,x]=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(()=>{x(0)},[r]),c.useEffect(()=>{const R=E=>{r.length!==0&&(E.key==="ArrowDown"?(E.preventDefault(),x(w=>w<r.length-1?w+1:w)):E.key==="ArrowUp"?(E.preventDefault(),x(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:()=>x(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:x=[],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,Ae=240,xe=240,Re=276,A=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=A.current)==null?void 0:s.innerText)==null?void 0:e.replace(/\u200B/g,""))||"";return t===`
|
|
3
3
|
`&&(t=""),t},ae=()=>{var s;let t=((s=A.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(`
|
package/dist/index.es.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// Generated at: 2026-04-04T08:
|
|
1
|
+
// Generated at: 2026-04-04T08:33:51.690Z
|
|
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";
|
package/package.json
CHANGED