fast-trieve-search-component
Advanced tools
Comparing version 0.8.0 to 0.9.0
@@ -1,3 +0,2 @@ | ||
import "./app.css"; | ||
export { TrieveModalSearch, initTrieveModalSearch } from "./TrieveModal"; | ||
//# sourceMappingURL=index.d.ts.map |
@@ -1,1 +0,1 @@ | ||
import{e as $,f as w,g as O}from"./chunk-3VJ6DIWU.js";import"./chunk-EX7TRSJS.js";import l,{useEffect as rt,lazy as W,startTransition as nt}from"react";import{startTransition as D,useEffect as H,useMemo as F,useRef as q}from"react";var B=()=>{let{setOpen:t,props:e,open:o,inputRef:r}=w(),n=e.openKeyCombination||[{ctrl:!0},{key:"k"}],k=q(0),C=()=>k.current===0?!0:Date.now()-k.current>=10,M=F(()=>s=>{if(C()){if(k.current=Date.now(),!o){let f=n.find(c=>c.ctrl);(f&&(s.metaKey||s.ctrlKey)||!f)&&n.filter(d=>!d.ctrl).every(d=>s.key===d.key)&&(s.preventDefault(),s.stopPropagation(),D(()=>{t(!0)}))}if(o&&s.key==="Escape")t(!1);else if(o){if(s.key=="ArrowDown"){s.preventDefault(),s.stopPropagation();let f=document.activeElement,c=f.id;if(console.log("focusedElement",f),c&&c.startsWith("trieve-search-item-")){let d=parseInt(c.split("-")[3]);console.log("index",d),document.getElementById(`trieve-search-item-${d+1}`)?.focus()}(!c||!c.startsWith("trieve-search-item-"))&&document.getElementById("trieve-search-item-0")?.focus()}else if(s.key=="ArrowUp"){s.preventDefault(),s.stopPropagation();let c=document.activeElement.id;if(c&&c.startsWith("trieve-search-item-")){let d=parseInt(c.split("-")[3]);d>0?document.getElementById(`trieve-search-item-${d-1}`)?.focus():r.current?.focus()}}}}},[o]);H(()=>(document.addEventListener("keydown",M),()=>{document.removeEventListener("keydown",M)}),[M])};import*as m from"react";var L=()=>{let{props:t,mode:e,setMode:o,query:r}=w();return m.createElement("div",{className:`mode-switch-wrapper ${e} ${r?"has-query ":""}${t.type}`.trim()},m.createElement("div",null,m.createElement("button",{className:e==="search"?"active":"",onClick:()=>o("search")},m.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},m.createElement("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),m.createElement("path",{d:"M10 10m-7 0a7 7 0 1 0 14 0a7 7 0 1 0 -14 0"}),m.createElement("path",{d:"M21 21l-6 -6"})),"Search"),m.createElement("button",{className:e==="chat"?"active":"",onClick:()=>o("chat")},m.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},m.createElement("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),m.createElement("path",{d:"M16 18a2 2 0 0 1 2 2a2 2 0 0 1 2 -2a2 2 0 0 1 -2 -2a2 2 0 0 1 -2 2zm0 -12a2 2 0 0 1 2 2a2 2 0 0 1 2 -2a2 2 0 0 1 -2 -2a2 2 0 0 1 -2 2zm-7 12a6 6 0 0 1 6 -6a6 6 0 0 1 -6 -6a6 6 0 0 1 -6 6a6 6 0 0 1 6 6z"})),"Ask AI")))};import a,{Fragment as J}from"react";var T=({setOpen:t})=>{let{props:e}=w(),o=e.openKeyCombination||[{ctrl:!0},{key:"k"}],r=e.ButtonEl;return a.createElement(a.Fragment,null,r?a.createElement("button",{onClick:()=>{t()},type:"button"},a.createElement(r,null)):a.createElement("button",{onClick:()=>{t()},id:"open-trieve-modal",type:"button",className:`${e.theme} ${e.responsive??!1?"responsive":""}`},a.createElement("div",{className:`${e.responsive??!1?"responsive":""}`},a.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},a.createElement("circle",{cx:"11",cy:"11",r:"8"}),a.createElement("path",{d:"m21 21-4.3-4.3"})),a.createElement("div",{className:`${e.responsive??!1?"responsive":""}`},e.placeholder)),a.createElement("span",{key:"open-button",className:`open ${e.responsive??!1?"responsive":""}`},o.map(n=>a.createElement(J,{key:n.key},n.ctrl?a.createElement(a.Fragment,null,a.createElement("span",{className:"mac"},"\u2318 "),a.createElement("span",{className:"not-mac"},"Ctrl ")):a.createElement("span",{key:"no-key"}," ",o.length>1?"+":null," ",n.label||n.key))))))};import z from"react";import{createRoot as R}from"react-dom/client";var U=Object.defineProperty,V=(t,e,o)=>e in t?U(t,e,{enumerable:!0,configurable:!0,writable:!0,value:o}):t[e]=o,E=(t,e,o)=>V(t,typeof e!="symbol"?e+"":e,o),Z={stringify:t=>t?"true":"false",parse:t=>/^[ty1-9]/i.test(t)},_={stringify:t=>t.name,parse:(t,e,o)=>{let r=(()=>{if(typeof window<"u"&&t in window)return window[t];if(typeof global<"u"&&t in global)return global[t]})();return typeof r=="function"?r.bind(o):void 0}},G={stringify:t=>JSON.stringify(t),parse:t=>JSON.parse(t)},Q={stringify:t=>`${t}`,parse:t=>parseFloat(t)},X={stringify:t=>t,parse:t=>t},A={string:X,number:Q,boolean:Z,function:_,json:G};function Y(t){return t.replace(/([a-z0-9])([A-Z])/g,(e,o,r)=>`${o}-${r.toLowerCase()}`)}var x=Symbol.for("r2wc.render"),S=Symbol.for("r2wc.connected"),g=Symbol.for("r2wc.context"),y=Symbol.for("r2wc.props");function j(t,e,o){var r,n,k;e.props||(e.props=t.propTypes?Object.keys(t.propTypes):[]),e.events||(e.events=[]);let C=Array.isArray(e.props)?e.props.slice():Object.keys(e.props),M=Array.isArray(e.events)?e.events.slice():Object.keys(e.events),s={},f={},c={},d={};for(let p of C){s[p]=Array.isArray(e.props)?"string":e.props[p];let i=Y(p);c[p]=i,d[i]=p}for(let p of M)f[p]=Array.isArray(e.events)?{}:e.events[p];class N extends HTMLElement{constructor(){super(),E(this,k,!0),E(this,n),E(this,r,{}),E(this,"container"),e.shadow?this.container=this.attachShadow({mode:e.shadow}):this.container=this,this[y].container=this.container;for(let i of C){let b=c[i],u=this.getAttribute(b),h=s[i],v=h?A[h]:null;v!=null&&v.parse&&u&&(this[y][i]=v.parse(u,b,this))}for(let i of M)this[y][i]=b=>{let u=i.replace(/^on/,"").toLowerCase();this.dispatchEvent(new CustomEvent(u,{detail:b,...f[i]}))}}static get observedAttributes(){return Object.keys(d)}connectedCallback(){this[S]=!0,this[x]()}disconnectedCallback(){this[S]=!1,this[g]&&o.unmount(this[g]),delete this[g]}attributeChangedCallback(i,b,u){let h=d[i],v=s[h],P=v?A[v]:null;h in s&&P!=null&&P.parse&&u&&(this[y][h]=P.parse(u,i,this),this[x]())}[(k=S,n=g,r=y,x)](){this[S]&&(this[g]?o.update(this[g],this[y]):this[g]=o.mount(this.container,t,this[y]))}}for(let p of C){let i=c[p],b=s[p];Object.defineProperty(N.prototype,p,{enumerable:!0,configurable:!0,get(){return this[y][p]},set(u){this[y][p]=u;let h=b?A[b]:null;if(h!=null&&h.stringify){let v=h.stringify(u,i,this);this.getAttribute(i)!==v&&this.setAttribute(i,v)}else this[x]()}})}return N}function tt(t,e,o){let r=R(t),n=z.createElement(e,o);return r.render(n),{root:r,ReactComponent:e}}function et({root:t,ReactComponent:e},o){let r=z.createElement(e,o);t.render(r)}function ot({root:t}){t.unmount()}function K(t,e={}){return j(t,e,{mount:tt,update:et,unmount:ot})}var st=W(()=>import("./SearchMode-KZRRPNNX.js")),it=W(()=>import("./ChatMode-RACTQI5W.js")),at=()=>{B();let{mode:t,open:e,setOpen:o,setMode:r,props:n}=w();return rt(()=>{document.documentElement.style.setProperty("--tv-prop-brand-color",n.brandColor??"#CB53EB"),n.theme==="dark"?document.documentElement.style.setProperty("--tv-prop-scrollbar-thumb-color","var(--tv-zinc-700)"):document.documentElement.style.setProperty("--tv-prop-scrollbar-thumb-color","var(--tv-zinc-300)")},[n.brandColor]),l.createElement(l.Fragment,null,l.createElement(T,{setOpen:()=>{nt(()=>{o(!0),r(n.defaultSearchMode||"search")})}}),e&&l.createElement(l.Fragment,null,l.createElement("div",{onClick:()=>{o(!1)},id:"trieve-search-modal-overlay"}),l.createElement("div",{id:"trieve-search-modal",className:`${t==="chat"?"chat-modal-mobile ":""} ${n.theme==="dark"?"dark ":""} ${n.type}`.trim()},n.allowSwitchingModes&&l.createElement(L,null),l.createElement("div",{className:"search-container",style:{display:t==="search"?"block":"none"}},l.createElement(st,null)),l.createElement("div",{className:t==="chat"?" chat-container":" ",style:{display:t==="chat"?"block":"none"}},l.createElement(it,null)))))},ct=t=>{let e=K(()=>l.createElement(I,{...t}));customElements.get("trieve-modal-search")||customElements.define("trieve-modal-search",e)},I=t=>l.createElement($,{onLoadProps:t},l.createElement(O,null,l.createElement(at,null)));export{I as TrieveModalSearch,ct as initTrieveModalSearch}; | ||
import{e as $,f as g,g as O}from"./chunk-3VJ6DIWU.js";import"./chunk-EX7TRSJS.js";import l,{useEffect as rt,lazy as W,startTransition as nt}from"react";import{startTransition as D,useEffect as H,useMemo as F,useRef as q}from"react";var B=()=>{let{setOpen:t,props:e,open:o,inputRef:r}=g(),n=e.openKeyCombination||[{ctrl:!0},{key:"k"}],k=q(0),C=()=>k.current===0?!0:Date.now()-k.current>=10,M=F(()=>s=>{if(C()){if(k.current=Date.now(),!o){let f=n.find(c=>c.ctrl);(f&&(s.metaKey||s.ctrlKey)||!f)&&n.filter(d=>!d.ctrl).every(d=>s.key===d.key)&&(s.preventDefault(),s.stopPropagation(),D(()=>{t(!0)}))}if(o&&s.key==="Escape")t(!1);else if(o){if(s.key=="ArrowDown"){s.preventDefault(),s.stopPropagation();let f=document.activeElement,c=f.id;if(console.log("focusedElement",f),c&&c.startsWith("trieve-search-item-")){let d=parseInt(c.split("-")[3]);console.log("index",d),document.getElementById(`trieve-search-item-${d+1}`)?.focus()}(!c||!c.startsWith("trieve-search-item-"))&&document.getElementById("trieve-search-item-0")?.focus()}else if(s.key=="ArrowUp"){s.preventDefault(),s.stopPropagation();let c=document.activeElement.id;if(c&&c.startsWith("trieve-search-item-")){let d=parseInt(c.split("-")[3]);d>0?document.getElementById(`trieve-search-item-${d-1}`)?.focus():r.current?.focus()}}}}},[o]);H(()=>(document.addEventListener("keydown",M),()=>{document.removeEventListener("keydown",M)}),[M])};import*as m from"react";var L=()=>{let{props:t,mode:e,setMode:o,query:r}=g();return m.createElement("div",{className:`mode-switch-wrapper ${e} ${r?"has-query ":""}${t.type}`.trim()},m.createElement("div",null,m.createElement("button",{className:e==="search"?"active":"",onClick:()=>o("search")},m.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},m.createElement("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),m.createElement("path",{d:"M10 10m-7 0a7 7 0 1 0 14 0a7 7 0 1 0 -14 0"}),m.createElement("path",{d:"M21 21l-6 -6"})),"Search"),m.createElement("button",{className:e==="chat"?"active":"",onClick:()=>o("chat")},m.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},m.createElement("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),m.createElement("path",{d:"M16 18a2 2 0 0 1 2 2a2 2 0 0 1 2 -2a2 2 0 0 1 -2 -2a2 2 0 0 1 -2 2zm0 -12a2 2 0 0 1 2 2a2 2 0 0 1 2 -2a2 2 0 0 1 -2 -2a2 2 0 0 1 -2 2zm-7 12a6 6 0 0 1 6 -6a6 6 0 0 1 -6 -6a6 6 0 0 1 -6 6a6 6 0 0 1 6 6z"})),"Ask AI")))};import a,{Fragment as J}from"react";var T=({setOpen:t})=>{let{props:e}=g(),o=e.openKeyCombination||[{ctrl:!0},{key:"k"}],r=e.ButtonEl;return a.createElement(a.Fragment,null,r?a.createElement("button",{onClick:()=>{t()},type:"button"},a.createElement(r,null)):a.createElement("button",{onClick:()=>{t()},id:"open-trieve-modal",type:"button",className:`${e.theme} ${e.responsive??!1?"responsive":""}`},a.createElement("div",{className:`${e.responsive??!1?"responsive":""}`},a.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},a.createElement("circle",{cx:"11",cy:"11",r:"8"}),a.createElement("path",{d:"m21 21-4.3-4.3"})),a.createElement("div",{className:`${e.responsive??!1?"responsive":""}`},e.placeholder)),a.createElement("span",{key:"open-button",className:`open ${e.responsive??!1?"responsive":""}`},o.map(n=>a.createElement(J,{key:n.key},n.ctrl?a.createElement(a.Fragment,null,a.createElement("span",{className:"mac"},"\u2318 "),a.createElement("span",{className:"not-mac"},"Ctrl ")):a.createElement("span",{key:"no-key"}," ",o.length>1?"+":null," ",n.label||n.key))))))};import z from"react";import{createRoot as R}from"react-dom/client";var U=Object.defineProperty,V=(t,e,o)=>e in t?U(t,e,{enumerable:!0,configurable:!0,writable:!0,value:o}):t[e]=o,E=(t,e,o)=>V(t,typeof e!="symbol"?e+"":e,o),Z={stringify:t=>t?"true":"false",parse:t=>/^[ty1-9]/i.test(t)},_={stringify:t=>t.name,parse:(t,e,o)=>{let r=(()=>{if(typeof window<"u"&&t in window)return window[t];if(typeof global<"u"&&t in global)return global[t]})();return typeof r=="function"?r.bind(o):void 0}},G={stringify:t=>JSON.stringify(t),parse:t=>JSON.parse(t)},Q={stringify:t=>`${t}`,parse:t=>parseFloat(t)},X={stringify:t=>t,parse:t=>t},A={string:X,number:Q,boolean:Z,function:_,json:G};function Y(t){return t.replace(/([a-z0-9])([A-Z])/g,(e,o,r)=>`${o}-${r.toLowerCase()}`)}var S=Symbol.for("r2wc.render"),x=Symbol.for("r2wc.connected"),w=Symbol.for("r2wc.context"),y=Symbol.for("r2wc.props");function j(t,e,o){var r,n,k;e.props||(e.props=t.propTypes?Object.keys(t.propTypes):[]),e.events||(e.events=[]);let C=Array.isArray(e.props)?e.props.slice():Object.keys(e.props),M=Array.isArray(e.events)?e.events.slice():Object.keys(e.events),s={},f={},c={},d={};for(let p of C){s[p]=Array.isArray(e.props)?"string":e.props[p];let i=Y(p);c[p]=i,d[i]=p}for(let p of M)f[p]=Array.isArray(e.events)?{}:e.events[p];class N extends HTMLElement{constructor(){super(),E(this,k,!0),E(this,n),E(this,r,{}),E(this,"container"),e.shadow?this.container=this.attachShadow({mode:e.shadow}):this.container=this,this[y].container=this.container;for(let i of C){let b=c[i],u=this.getAttribute(b),h=s[i],v=h?A[h]:null;v!=null&&v.parse&&u&&(this[y][i]=v.parse(u,b,this))}for(let i of M)this[y][i]=b=>{let u=i.replace(/^on/,"").toLowerCase();this.dispatchEvent(new CustomEvent(u,{detail:b,...f[i]}))}}static get observedAttributes(){return Object.keys(d)}connectedCallback(){this[x]=!0,this[S]()}disconnectedCallback(){this[x]=!1,this[w]&&o.unmount(this[w]),delete this[w]}attributeChangedCallback(i,b,u){let h=d[i],v=s[h],P=v?A[v]:null;h in s&&P!=null&&P.parse&&u&&(this[y][h]=P.parse(u,i,this),this[S]())}[(k=x,n=w,r=y,S)](){this[x]&&(this[w]?o.update(this[w],this[y]):this[w]=o.mount(this.container,t,this[y]))}}for(let p of C){let i=c[p],b=s[p];Object.defineProperty(N.prototype,p,{enumerable:!0,configurable:!0,get(){return this[y][p]},set(u){this[y][p]=u;let h=b?A[b]:null;if(h!=null&&h.stringify){let v=h.stringify(u,i,this);this.getAttribute(i)!==v&&this.setAttribute(i,v)}else this[S]()}})}return N}function tt(t,e,o){let r=R(t),n=z.createElement(e,o);return r.render(n),{root:r,ReactComponent:e}}function et({root:t,ReactComponent:e},o){let r=z.createElement(e,o);t.render(r)}function ot({root:t}){t.unmount()}function K(t,e={}){return j(t,e,{mount:tt,update:et,unmount:ot})}var st=W(()=>import("./SearchMode-KZRRPNNX.js")),it=W(()=>import("./ChatMode-RACTQI5W.js")),at=()=>{B();let{mode:t,open:e,setOpen:o,setMode:r,props:n}=g();return rt(()=>{document.documentElement.style.setProperty("--tv-prop-brand-color",n.brandColor??"#CB53EB"),n.theme==="dark"?document.documentElement.style.setProperty("--tv-prop-scrollbar-thumb-color","var(--tv-zinc-700)"):document.documentElement.style.setProperty("--tv-prop-scrollbar-thumb-color","var(--tv-zinc-300)")},[n.brandColor]),l.createElement(l.Fragment,null,l.createElement(T,{setOpen:()=>{nt(()=>{o(!0),r(n.defaultSearchMode||"search")})}}),e&&l.createElement(l.Fragment,null,l.createElement("div",{onClick:()=>{o(!1)},id:"trieve-search-modal-overlay"}),l.createElement("div",{id:"trieve-search-modal",className:`${t==="chat"?"chat-modal-mobile ":""} ${n.theme==="dark"?"dark ":""} ${n.type}`.trim()},n.allowSwitchingModes&&l.createElement(L,null),l.createElement("div",{className:"search-container",style:{display:t==="search"?"block":"none"}},l.createElement(st,null)),l.createElement("div",{className:t==="chat"?" chat-container":" ",style:{display:t==="chat"?"block":"none"}},l.createElement(it,null)))))},ct=t=>{let e=K(()=>l.createElement(I,{...t}));customElements.get("trieve-modal-search")||customElements.define("trieve-modal-search",e)},I=t=>l.createElement($,{onLoadProps:t},l.createElement(O,null,l.createElement(at,null)));export{I as TrieveModalSearch,ct as initTrieveModalSearch}; |
import { ModalProps } from "../utils/hooks/modal-context"; | ||
import "../app.css"; | ||
export declare function renderToDiv(element: HTMLElement, props: ModalProps): void; | ||
//# sourceMappingURL=index.d.ts.map |
@@ -14,2 +14,5 @@ { | ||
}, | ||
"./styles": { | ||
"default": "./dist/index.css" | ||
}, | ||
"./vanilla": { | ||
@@ -19,3 +22,3 @@ "import": "./dist/vanilla/index.js" | ||
}, | ||
"version": "0.8.0", | ||
"version": "0.9.0", | ||
"license": "MIT", | ||
@@ -22,0 +25,0 @@ "homepage": "https://github.com/devflowinc/trieve/tree/main/clients/search-component", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
628980
66
2411