UNPKG

@kitn.ai/ui

Version:

Framework-agnostic, Shadow-DOM web components for building AI chat interfaces — works in React, Vue, Angular, Svelte, or plain HTML. Authored in SolidJS.

2 lines (1 loc) 1.36 kB
import{f as p,g as b,o as f,i as d,c as o,F as k,a as m,b as x,t as y,p as z}from"./chunks/define-CNSKFZCd.js";import{P as A}from"./chunks/prompt-suggestion-9lvgFcEa.js";var w=y("<div>");const C=e=>typeof e=="string"?e:e.label,S=e=>typeof e=="string"?e:e.value??e.label,O=e=>typeof e=="string"?void 0:e.icon;function l(e){var s;const r=((s=e.textContent)==null?void 0:s.trim())??"",a=e.getAttribute("value")??r;return{label:r,value:a,icon:e.getAttribute("icon")??void 0}}p("kai-suggestions",{suggestions:[],variant:"outline",size:"md",layout:"chips",block:!1,highlight:void 0},(e,{dispatch:s,flag:r,element:a})=>{const[g,u]=b([]);f(()=>{const t=()=>{const h=[...a.querySelectorAll("kai-suggestion")];u(h.map(l))};t();const i=new MutationObserver(t);i.observe(a,{childList:!0,attributes:!0,subtree:!0}),z(()=>i.disconnect())});const c=()=>[...e.suggestions??[],...g()],n=()=>e.layout==="list",v=()=>n()?"flex flex-col gap-0.5":r("block")?"flex flex-col gap-2":"flex flex-wrap gap-2";return(()=>{var t=w();return d(t,o(k,{get each(){return c()},children:i=>o(A,{get variant(){return e.variant},get size(){return e.size},get icon(){return O(i)},get block(){return r("block")},get list(){return n()},get highlight(){return e.highlight},onClick:()=>s("kai-select",{value:S(i)}),get children(){return C(i)}})})),m(()=>x(t,v())),t})()});export{l as parseSuggestionNode};