@inkeep/agents-ui 0.0.0-dev-20260508215802 → 0.0.0-dev-20260508234956
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/primitives/components/embedded-chat/use-inkeep-chat.cjs +2 -2
- package/dist/primitives/components/embedded-chat/use-inkeep-chat.d.ts +0 -13
- package/dist/primitives/components/embedded-chat/use-inkeep-chat.js +183 -181
- package/dist/styled/components/message.cjs +1 -1
- package/dist/styled/components/message.js +210 -272
- package/dist/styled/inkeep.css.cjs +0 -78
- package/dist/styled/inkeep.css.js +0 -78
- package/package.json +1 -2
- package/dist/node_modules/.pnpm/@hookform_resolvers@5.2.2_react-hook-form@7.70.0_react@19.3.0-canary-87ae75b3-20260128_/node_modules/@hookform/resolvers/zod/dist/zod.cjs +0 -1
- package/dist/node_modules/.pnpm/@hookform_resolvers@5.2.2_react-hook-form@7.70.0_react@19.3.0-canary-87ae75b3-20260128_/node_modules/@hookform/resolvers/zod/dist/zod.js +0 -93
- package/dist/node_modules/.pnpm/zod@4.3.6/node_modules/zod/v4/core/core.cjs +0 -1
- package/dist/node_modules/.pnpm/zod@4.3.6/node_modules/zod/v4/core/core.js +0 -49
- package/dist/node_modules/.pnpm/zod@4.3.6/node_modules/zod/v4/core/errors.cjs +0 -1
- package/dist/node_modules/.pnpm/zod@4.3.6/node_modules/zod/v4/core/errors.js +0 -19
- package/dist/node_modules/.pnpm/zod@4.3.6/node_modules/zod/v4/core/parse.cjs +0 -1
- package/dist/node_modules/.pnpm/zod@4.3.6/node_modules/zod/v4/core/parse.js +0 -28
- package/dist/node_modules/.pnpm/zod@4.3.6/node_modules/zod/v4/core/util.cjs +0 -1
- package/dist/node_modules/.pnpm/zod@4.3.6/node_modules/zod/v4/core/util.js +0 -23
- package/dist/styled/components/ask-user-form.cjs +0 -1
- package/dist/styled/components/ask-user-form.d.ts +0 -96
- package/dist/styled/components/ask-user-form.js +0 -672
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("react/jsx-runtime"),Y=require("../../node_modules/.pnpm/@hookform_resolvers@5.2.2_react-hook-form@7.70.0_react@19.3.0-canary-87ae75b3-20260128_/node_modules/@hookform/resolvers/zod/dist/zod.cjs"),b=require("react"),y=require("react-hook-form"),x=require("zod"),f=require("../utils.cjs"),E=require("./ui/recipes/button.cjs"),S="border border-gray-200 dark:border-white-alpha-200 rounded-lg mb-3 p-4 bg-white dark:bg-gray-dark-900",q="text-xs font-medium text-gray-700 dark:text-white-alpha-700 select-none",$="text-xs px-2 py-1.5 rounded-md border bg-white dark:bg-gray-dark-900 text-gray-800 dark:text-white-alpha-800 border-gray-200 dark:border-white-alpha-200 focus:outline-none focus:ring-1 focus:ring-inkeep-expanded-primary-500 disabled:opacity-60 disabled:cursor-not-allowed",F="text-2xs text-gray-500 dark:text-white-alpha-500 mt-0.5",z="text-2xs text-red-600 dark:text-red-400 mt-0.5",M=e=>{switch(e){case"short":return"w-20";case"medium":return"w-48";default:return"w-full"}};function _(e){return!(e.length>200||/[+*?}]\)?[+*?{]/.test(e)||/\\\d/.test(e)||/\([^)]*\|[^)]*\)[+*?{]/.test(e))}function H(e){const a=e.required!==!1;switch(e.type){case"boolean":return x.z.boolean().default(!1);case"number":{let t=x.z.number();e.validation?.min!==void 0&&(t=t.min(e.validation.min)),e.validation?.max!==void 0&&(t=t.max(e.validation.max));const s=a?t:t.optional();return x.z.preprocess(i=>{if(!(i===""||i===null||i===void 0)){if(typeof i=="string"){const l=Number(i);return Number.isNaN(l)?i:l}return i}},s)}case"email":{let t=x.z.string().email("Enter a valid email");return e.validation?.minLength!==void 0&&(t=t.min(e.validation.minLength)),e.validation?.maxLength!==void 0&&(t=t.max(e.validation.maxLength)),a?t.min(1,"Required"):t.or(x.z.literal(""))}case"date":{const t=x.z.string();return a?t.min(1,"Required"):t.optional()}default:{let t=x.z.string();if(e.validation?.minLength!==void 0&&(t=t.min(e.validation.minLength)),e.validation?.maxLength!==void 0&&(t=t.max(e.validation.maxLength)),e.validation?.pattern&&_(e.validation.pattern))try{t=t.regex(new RegExp(e.validation.pattern),"Invalid format")}catch{}if(e.options&&e.options.length>0){const s=e.options.map(l=>l.value),i=x.z.enum(s);return a?i:i.or(x.z.literal(""))}return a?t.min(1,"Required"):t}}}function J(e){let a;switch(e.itemType){case"number":a=x.z.preprocess(s=>s===""||s===null||s===void 0?void 0:Number(s),x.z.number());break;case"email":a=x.z.string().email();break;case"boolean":a=x.z.boolean();break;default:a=x.z.string().min(1)}let t=x.z.array(a);return e.min!==void 0&&(t=t.min(e.min,`At least ${e.min}`)),e.max!==void 0&&(t=t.max(e.max,`At most ${e.max}`)),t}function K(e){return e.kind==="leaf"?H(e):e.kind==="list"?J(e):e.kind==="groupList"?W(e):B(e.children)}function B(e){const a={};for(const t of e)a[t.id]=K(t);return x.z.object(a)}function W(e){const a=B(e.item.children);let t=x.z.array(a);return e.min!==void 0&&(t=t.min(e.min,`At least ${e.min}`)),e.max!==void 0&&(t=t.max(e.max,`At most ${e.max}`)),t}function Q(e){return B(e)}function X(e){if(e.default!==void 0)return e.default;if(e.options&&e.options.length>0)return e.options[0]?.value??"";switch(e.type){case"boolean":return!1;case"number":return"";default:return""}}function L(e){const a={};for(const t of e)if(t.kind==="leaf")a[t.id]=X(t);else if(t.kind==="list")a[t.id]=[];else if(t.kind==="groupList"){const s=t.min??0,i=[];for(let l=0;l<s;l++)i.push(L(t.item.children));a[t.id]=i}else a[t.id]=L(t.children);return a}function V(e,a=[]){for(const t of e){if(t.kind==="leaf")return[...a,t.id];if(t.kind==="group"){const s=V(t.children,[...a,t.id]);if(s)return s}}}function Z(e,a=[]){for(const t of e)if(t.kind==="leaf"){if(!(t.default!==void 0&&t.default!==""))return[...a,t.id]}else if(t.kind==="group"){const s=Z(t.children,[...a,t.id]);if(s)return s}}function ee(e){return Z(e)??V(e)}const re=({input:e,output:a,status:t,errorText:s,onSubmit:i,onDecline:l})=>t==="pending"?r.jsx("div",{className:S,children:r.jsxs("div",{className:"space-y-3 animate-pulse",children:[r.jsx("div",{className:"h-3 w-32 bg-gray-100 dark:bg-white-alpha-100 rounded"}),r.jsx("div",{className:"h-7 w-full bg-gray-100 dark:bg-white-alpha-100 rounded"}),r.jsx("div",{className:"h-7 w-full bg-gray-100 dark:bg-white-alpha-100 rounded"})]})}):t==="declined"?r.jsx("div",{className:S,children:r.jsx("div",{className:"text-xs font-medium text-gray-700 dark:text-white-alpha-700",children:s||"User declined to provide input."})}):t==="submitted"&&a?r.jsx(te,{output:a}):!e||!Array.isArray(e.form)?r.jsx("div",{className:S,children:r.jsx("div",{className:"text-xs text-gray-500 dark:text-white-alpha-500 italic",children:"Preparing form…"})}):r.jsx(ae,{input:e,onSubmit:i??(()=>{}),onDecline:l??(()=>{})}),te=({output:e})=>r.jsxs("div",{className:S,children:[e.message&&r.jsx("div",{className:"text-sm font-medium text-gray-800 dark:text-white-alpha-800 mb-3",children:e.message}),r.jsx("div",{className:"space-y-3",children:e.form.map(a=>r.jsx(P,{node:a,value:e.answers[a.id]},a.id))})]}),P=({node:e,value:a})=>{if(e.kind==="group"){const t=a&&typeof a=="object"&&!Array.isArray(a)?a:{};return r.jsxs("fieldset",{className:"border-l-2 border-gray-100 dark:border-white-alpha-100 pl-3",children:[e.label&&r.jsx("legend",{className:"text-xs font-semibold text-gray-700 dark:text-white-alpha-700 mb-2",children:e.label}),r.jsx("div",{className:"space-y-3",children:e.children.map(s=>r.jsx(P,{node:s,value:t[s.id]},s.id))})]})}if(e.kind==="list"){const t=Array.isArray(a)?a:[];return r.jsxs("div",{className:"flex flex-col gap-1",children:[r.jsx("span",{className:q,children:e.label}),r.jsx("div",{className:"flex flex-wrap gap-1",children:t.length===0?r.jsx("span",{className:"text-2xs text-gray-500 dark:text-white-alpha-500 italic",children:"(none)"}):t.map((s,i)=>{const l=G(s);return r.jsx("span",{className:"inline-flex items-center gap-1 px-2 py-0.5 rounded-full bg-gray-100 dark:bg-white-alpha-100 text-2xs text-gray-700 dark:text-white-alpha-700",children:l},`${l}-${i}`)})})]})}if(e.kind==="groupList"){const t=Array.isArray(a)?a:[];return r.jsxs("fieldset",{className:"border-l-2 border-gray-100 dark:border-white-alpha-100 pl-3",children:[r.jsx("legend",{className:"text-xs font-semibold text-gray-700 dark:text-white-alpha-700 mb-2",children:e.label}),r.jsx("div",{className:"space-y-2",children:t.length===0?r.jsx("span",{className:"text-2xs text-gray-500 dark:text-white-alpha-500 italic",children:"(none)"}):t.map((s,i)=>{const l=s&&typeof s=="object"&&!Array.isArray(s)?s:{};return r.jsxs("div",{className:"pl-2 py-1 rounded-md bg-gray-50/50 dark:bg-white-alpha-50/50",children:[r.jsxs("span",{className:"text-2xs font-medium text-gray-500 dark:text-white-alpha-500 uppercase tracking-wider",children:["#",i+1]}),r.jsx("div",{className:"mt-1 space-y-2",children:e.item.children.map(n=>r.jsx(P,{node:n,value:l[n.id]},n.id))})]},`row-${i}-${e.id}`)})})]})}return r.jsxs("div",{className:"flex flex-col gap-1",children:[r.jsx("span",{className:q,children:e.label}),r.jsx("span",{className:f.cn($,M(e.width),"inline-block opacity-70"),"aria-disabled":"true",children:a===void 0||a===""?r.jsx("span",{className:"italic text-gray-500 dark:text-white-alpha-500",children:"(empty)"}):e.type==="boolean"?a?"Yes":"No":String(a)})]})},ae=({input:e,onSubmit:a,onDecline:t})=>{const s=e.form??[],i=b.useMemo(()=>Q(s),[s]),l=b.useMemo(()=>L(s),[s]),n=b.useMemo(()=>ee(s),[s]),h=Y.zodResolver(i),m=y.useForm({resolver:h,defaultValues:l,mode:"onBlur",reValidateMode:"onChange",shouldFocusError:!0}),A=m.handleSubmit(c=>{a(c)});return r.jsx(y.FormProvider,{...m,children:r.jsxs("form",{onSubmit:A,className:S,noValidate:!0,"aria-label":e.message||"User input form",children:[e.message&&r.jsx("div",{className:"text-sm font-medium text-gray-800 dark:text-white-alpha-800 mb-3",children:e.message}),r.jsx("div",{className:"space-y-3",children:s.map(c=>r.jsx(D,{node:c,pathPrefix:"",autoFocusPath:n},c.id))}),r.jsxs("div",{className:"flex items-center justify-end gap-2 mt-4",children:[r.jsx("button",{type:"button",className:E.button({size:"xs",variant:"ghost"}),onClick:t,disabled:m.formState.isSubmitting,children:"Cancel"}),r.jsx("button",{type:"submit",className:E.button({size:"xs",variant:"primaryFilled"}),disabled:m.formState.isSubmitting,children:m.formState.isSubmitting?"Submitting…":"Submit"})]})]})})},D=({node:e,pathPrefix:a,autoFocusPath:t})=>{const s=a?`${a}.${e.id}`:e.id;return e.kind==="group"?r.jsx(se,{node:e,path:s,autoFocusPath:t}):e.kind==="list"?r.jsx(ne,{node:e,path:s}):e.kind==="groupList"?r.jsx(ce,{node:e,path:s,autoFocusPath:t}):r.jsx(ie,{node:e,path:s,autoFocusPath:t})},se=({node:e,path:a,autoFocusPath:t})=>r.jsxs("fieldset",{className:"border-l-2 border-gray-100 dark:border-white-alpha-100 pl-3","aria-labelledby":e.label?`group-${a}`:void 0,children:[e.label&&r.jsx("legend",{id:`group-${a}`,className:"text-xs font-semibold text-gray-700 dark:text-white-alpha-700 mb-2 px-1",children:e.label}),e.helpText&&r.jsx("div",{className:F,children:e.helpText}),r.jsx("div",{className:"space-y-3",children:e.children.map(s=>r.jsx(D,{node:s,pathPrefix:a,autoFocusPath:t},s.id))})]}),ie=({node:e,path:a,autoFocusPath:t})=>{const{register:s,control:i}=y.useFormContext(),l=e.required!==!1,n=`askuser-${a.replace(/\./g,"-")}`,h=`${n}-error`,m=`${n}-help`,{errors:A}=y.useFormState({control:i,name:a}),c=U(A,a),j=b.useMemo(()=>t!==void 0&&t.join(".")===a,[t,a]),k=r.jsxs("label",{htmlFor:n,className:q,children:[e.label,l&&r.jsx("span",{"aria-label":"required",className:"text-red-500 ml-0.5",children:"*"})]}),p=r.jsxs(r.Fragment,{children:[e.helpText&&r.jsx("div",{id:m,className:F,children:e.helpText}),c&&r.jsx("div",{id:h,role:"alert",className:z,children:c})]});if(e.type==="boolean")return r.jsx(y.Controller,{name:a,control:i,render:({field:d})=>r.jsxs("div",{className:"flex items-start gap-3",children:[r.jsx("button",{type:"button",role:"switch",id:n,"aria-checked":!!d.value,"aria-required":l,"aria-invalid":!!c,"aria-describedby":f.cn(e.helpText&&m,c&&h)||void 0,onClick:()=>d.onChange(!d.value),onBlur:d.onBlur,ref:j?R:void 0,className:f.cn("inline-flex h-5 w-9 items-center rounded-full border transition-colors mt-0.5","border-gray-200 dark:border-white-alpha-200","focus:outline-none focus:ring-1 focus:ring-inkeep-expanded-primary-500",d.value?"bg-inkeep-expanded-primary-500":"bg-gray-100 dark:bg-white-alpha-100"),children:r.jsx("span",{className:f.cn("inline-block h-3.5 w-3.5 rounded-full bg-white shadow transform transition-transform",d.value?"translate-x-4":"translate-x-0.5")})}),r.jsxs("div",{className:"flex flex-col flex-1",children:[k,p]})]})});if(e.type==="multiline")return r.jsxs("div",{className:"flex flex-col gap-1",children:[k,r.jsx(y.Controller,{name:a,control:i,render:({field:d})=>r.jsx(le,{id:n,value:d.value??"",onChange:u=>d.onChange(u.target.value),onBlur:d.onBlur,placeholder:e.placeholder,autoComplete:e.autocomplete??"off","aria-required":l,"aria-invalid":!!c,"aria-describedby":f.cn(e.helpText&&m,c&&h)||void 0,focusOnMount:j,className:f.cn($,"w-full resize-none min-h-[60px]")})}),p]});if(e.options&&e.options.length>0){const d=s(a);return r.jsxs("div",{className:"flex flex-col gap-1",children:[k,r.jsxs("select",{id:n,...d,ref:u=>{d.ref(u),j&&R(u)},"aria-required":l,"aria-invalid":!!c,"aria-describedby":f.cn(e.helpText&&m,c&&h)||void 0,className:f.cn($,M(e.width)),children:[!l&&r.jsx("option",{value:"",children:"—"}),e.options.map(u=>r.jsx("option",{value:u.value,children:u.label??u.value},u.value))]}),p]})}const w=e.type==="date"?"date":e.type==="email"?"email":"text",T=e.type==="number"?"numeric":void 0,N=s(a);return r.jsxs("div",{className:"flex flex-col gap-1",children:[k,r.jsx("input",{id:n,type:w,inputMode:T,placeholder:e.placeholder,autoComplete:e.autocomplete??"off","aria-required":l,"aria-invalid":!!c,"aria-describedby":f.cn(e.helpText&&m,c&&h)||void 0,...N,ref:d=>{N.ref(d),j&&R(d)},className:f.cn($,M(e.width))}),p]})};function R(e){e&&requestAnimationFrame(()=>{typeof e.focus=="function"&&e.focus()})}const le=({value:e,className:a,focusOnMount:t,...s})=>{const i=b.useRef(null);return b.useEffect(()=>{const l=i.current;if(!l)return;l.style.height="0";const n=Math.min(l.scrollHeight,200);l.style.height=`${n}px`},[e]),b.useEffect(()=>{t&&requestAnimationFrame(()=>i.current?.focus())},[]),r.jsx("textarea",{ref:i,value:e,className:a,rows:3,...s})},ne=({node:e,path:a})=>{const{control:t,setValue:s,trigger:i}=y.useFormContext(),l=y.useWatch({control:t,name:a}),n=Array.isArray(l)?l:[],h=`askuser-${a.replace(/\./g,"-")}`,m=`${h}-error`,{errors:A}=y.useFormState({control:t,name:a}),c=U(A,a),j=(e.min??0)>0,k=e.max??Number.POSITIVE_INFINITY,p=n.length>=k,[w,T]=b.useState(""),N=b.useCallback(o=>{s(a,o,{shouldValidate:!0,shouldDirty:!0,shouldTouch:!0})},[s,a]),d=b.useCallback(o=>{N([...n,o])},[n,N]),u=b.useCallback(o=>{N(n.filter((v,g)=>g!==o))},[n,N]),C=b.useCallback(()=>{const o=w.trim();if(!o||p)return;let v;if(e.itemType==="number"){const g=Number(o);if(Number.isNaN(g))return;v=g}else e.itemType==="boolean"?v=o==="true":v=o;d(v),T("")},[w,p,e.itemType,d]),O=o=>{o.key==="Enter"||o.key===","?(o.preventDefault(),C()):o.key==="Backspace"&&w===""&&n.length>0&&u(n.length-1)};return e.options&&e.options.length>0?r.jsxs("div",{className:"flex flex-col gap-1",children:[r.jsxs("label",{htmlFor:h,className:q,children:[e.label,j&&r.jsx("span",{"aria-label":"required",className:"text-red-500 ml-0.5",children:"*"})]}),r.jsx("fieldset",{className:"flex flex-wrap gap-1.5",id:h,children:e.options.map(o=>{const v=n.findIndex(I=>I===o.value),g=v>=0;return r.jsx("button",{type:"button","aria-pressed":g,onClick:()=>{g?u(v):p||d(o.value),i(a)},className:f.cn("inline-flex items-center gap-1 px-2 py-0.5 rounded-full text-2xs border transition-colors",g?"bg-inkeep-expanded-primary-500 text-white border-inkeep-expanded-primary-500":"bg-white dark:bg-gray-dark-900 text-gray-700 dark:text-white-alpha-700 border-gray-200 dark:border-white-alpha-200 hover:bg-gray-50 dark:hover:bg-white-alpha-50"),children:o.label??o.value},o.value)})}),e.helpText&&r.jsx("div",{className:F,children:e.helpText}),c&&r.jsx("div",{id:m,role:"alert",className:z,children:c})]}):r.jsxs("div",{className:"flex flex-col gap-1",children:[r.jsxs("label",{htmlFor:h,className:q,children:[e.label,j&&r.jsx("span",{"aria-label":"required",className:"text-red-500 ml-0.5",children:"*"})]}),r.jsxs("div",{className:f.cn($,"w-full flex flex-wrap gap-1 items-center cursor-text min-h-[32px] py-1"),onClick:()=>document.getElementById(h)?.focus(),children:[n.map((o,v)=>{const g=G(o);return r.jsxs("span",{className:"inline-flex items-center gap-1 px-2 py-0.5 rounded-full bg-gray-100 dark:bg-white-alpha-100 text-2xs text-gray-700 dark:text-white-alpha-700",children:[g,r.jsx("button",{type:"button",onClick:I=>{I.stopPropagation(),u(v)},"aria-label":`Remove ${g}`,className:"text-gray-500 hover:text-gray-700 dark:text-white-alpha-500 dark:hover:text-white-alpha-700",children:"×"})]},`${g}-${v}`)}),r.jsx("input",{id:h,type:e.itemType==="number"?"text":e.itemType==="email"?"email":"text",inputMode:e.itemType==="number"?"numeric":void 0,value:w,placeholder:n.length===0?e.placeholder??"Type and press Enter…":"",onChange:o=>T(o.target.value),onKeyDown:O,onBlur:C,"aria-required":j,"aria-invalid":!!c,"aria-describedby":c?m:void 0,disabled:p,className:"flex-1 min-w-[80px] outline-none bg-transparent text-xs"})]}),e.helpText&&r.jsx("div",{className:F,children:e.helpText}),c&&r.jsx("div",{id:m,role:"alert",className:z,children:c})]})};function G(e){if(e==null)return"";if(typeof e=="string"||typeof e=="number"||typeof e=="boolean")return String(e);try{return JSON.stringify(e)}catch{return""}}const ce=({node:e,path:a,autoFocusPath:t})=>{const{control:s}=y.useFormContext(),{errors:i}=y.useFormState({control:s,name:a}),{fields:l,append:n,remove:h}=y.useFieldArray({control:s,name:a}),m=`askuser-${a.replace(/\./g,"-")}`,A=`${m}-error`,c=U(i,a),j=(e.min??0)>0,k=e.max??Number.POSITIVE_INFINITY,p=l.length>=k,w=e.min??0,T=l.length>w,N=b.useCallback(()=>{p||n(L(e.item.children))},[n,p,e.item.children]);return r.jsxs("fieldset",{className:"border-l-2 border-gray-100 dark:border-white-alpha-100 pl-3","aria-labelledby":`grouplist-${m}`,children:[r.jsxs("legend",{id:`grouplist-${m}`,className:"text-xs font-semibold text-gray-700 dark:text-white-alpha-700 mb-2 px-1",children:[e.label,j&&r.jsx("span",{"aria-label":"required",className:"text-red-500 ml-0.5",children:"*"})]}),e.helpText&&r.jsx("div",{className:F,children:e.helpText}),r.jsx("div",{className:"space-y-3",children:l.length===0?r.jsxs("div",{className:"text-2xs text-gray-500 dark:text-white-alpha-500 italic",children:["No rows yet — click “",e.addLabel??"Add row","” below."]}):l.map((d,u)=>r.jsxs("div",{className:"relative pl-2 py-2 rounded-md bg-gray-50/50 dark:bg-white-alpha-50/50",children:[r.jsxs("div",{className:"flex items-start justify-between mb-1",children:[r.jsxs("span",{className:"text-2xs font-medium text-gray-500 dark:text-white-alpha-500 uppercase tracking-wider",children:["#",u+1]}),T&&r.jsx("button",{type:"button",onClick:()=>h(u),"aria-label":`Remove row ${u+1}`,className:"text-2xs text-gray-500 hover:text-red-500 dark:text-white-alpha-500",children:"Remove"})]}),r.jsx("div",{className:"space-y-3",children:e.item.children.map(C=>r.jsx(D,{node:C,pathPrefix:`${a}.${u}`,autoFocusPath:t},C.id))})]},d.id))}),r.jsx("div",{className:"mt-2",children:r.jsxs("button",{type:"button",onClick:N,disabled:p,className:f.cn(E.button({size:"xs",variant:"outline"})),children:["+ ",e.addLabel??"Add row"]})}),c&&r.jsx("div",{id:A,role:"alert",className:z,children:c})]})};function U(e,a){const t=a.split(".");let s=e;for(const i of t)if(s&&typeof s=="object"&&i in s)s=s[i];else return;if(s&&typeof s=="object"&&"message"in s){const i=s.message;return typeof i=="string"?i:void 0}}exports.AskUserForm=re;
|
|
@@ -1,96 +0,0 @@
|
|
|
1
|
-
import { FC } from 'react';
|
|
2
|
-
/**
|
|
3
|
-
* Form-schema vocabulary mirrored from agents-api default-tools.ts. The
|
|
4
|
-
* shape of `form` 1:1 determines the shape of the answers returned to the
|
|
5
|
-
* server — children of a group nest under that group's id, list answers
|
|
6
|
-
* come back as arrays. No separate mapping config: structure IS the
|
|
7
|
-
* mapping.
|
|
8
|
-
*/
|
|
9
|
-
export type LeafType = 'text' | 'multiline' | 'number' | 'email' | 'boolean' | 'date';
|
|
10
|
-
export type ListItemType = 'text' | 'number' | 'email' | 'date' | 'boolean';
|
|
11
|
-
export type Width = 'short' | 'medium' | 'full';
|
|
12
|
-
export interface LeafNode {
|
|
13
|
-
kind: 'leaf';
|
|
14
|
-
id: string;
|
|
15
|
-
label: string;
|
|
16
|
-
type: LeafType;
|
|
17
|
-
default?: string | number | boolean;
|
|
18
|
-
required?: boolean;
|
|
19
|
-
options?: Array<{
|
|
20
|
-
value: string;
|
|
21
|
-
label?: string;
|
|
22
|
-
}>;
|
|
23
|
-
placeholder?: string;
|
|
24
|
-
helpText?: string;
|
|
25
|
-
autocomplete?: string;
|
|
26
|
-
width?: Width;
|
|
27
|
-
validation?: {
|
|
28
|
-
minLength?: number;
|
|
29
|
-
maxLength?: number;
|
|
30
|
-
pattern?: string;
|
|
31
|
-
min?: number;
|
|
32
|
-
max?: number;
|
|
33
|
-
};
|
|
34
|
-
}
|
|
35
|
-
export interface ListNode {
|
|
36
|
-
kind: 'list';
|
|
37
|
-
id: string;
|
|
38
|
-
label: string;
|
|
39
|
-
itemType: ListItemType;
|
|
40
|
-
options?: Array<{
|
|
41
|
-
value: string;
|
|
42
|
-
label?: string;
|
|
43
|
-
}>;
|
|
44
|
-
min?: number;
|
|
45
|
-
max?: number;
|
|
46
|
-
placeholder?: string;
|
|
47
|
-
helpText?: string;
|
|
48
|
-
}
|
|
49
|
-
export interface GroupNode {
|
|
50
|
-
kind: 'group';
|
|
51
|
-
id: string;
|
|
52
|
-
label?: string;
|
|
53
|
-
helpText?: string;
|
|
54
|
-
children: FormNode[];
|
|
55
|
-
}
|
|
56
|
-
export interface GroupListNode {
|
|
57
|
-
kind: 'groupList';
|
|
58
|
-
id: string;
|
|
59
|
-
label: string;
|
|
60
|
-
helpText?: string;
|
|
61
|
-
/** Each row is an instance of this group template. */
|
|
62
|
-
item: GroupNode;
|
|
63
|
-
min?: number;
|
|
64
|
-
max?: number;
|
|
65
|
-
/** Verb-noun label for the add-row button (e.g., "Add attendee"). */
|
|
66
|
-
addLabel?: string;
|
|
67
|
-
}
|
|
68
|
-
export type FormNode = LeafNode | GroupNode | ListNode | GroupListNode;
|
|
69
|
-
export type AnswerValue = string | number | boolean | AnswerValue[] | {
|
|
70
|
-
[k: string]: AnswerValue;
|
|
71
|
-
};
|
|
72
|
-
export type AnswersMap = Record<string, AnswerValue>;
|
|
73
|
-
export interface AskUserInput {
|
|
74
|
-
message?: string;
|
|
75
|
-
form: FormNode[];
|
|
76
|
-
/** Legacy v1 shape, ignored when `form` is present. */
|
|
77
|
-
questions?: unknown;
|
|
78
|
-
}
|
|
79
|
-
export interface AskUserOutput {
|
|
80
|
-
form: FormNode[];
|
|
81
|
-
answers: AnswersMap;
|
|
82
|
-
message?: string;
|
|
83
|
-
}
|
|
84
|
-
export type AskUserFormStatus = 'pending' | 'active' | 'submitted' | 'declined';
|
|
85
|
-
export interface AskUserFormProps {
|
|
86
|
-
/** undefined while tool input is still streaming. */
|
|
87
|
-
input?: AskUserInput;
|
|
88
|
-
/** present once the user submitted (state output-available). */
|
|
89
|
-
output?: AskUserOutput;
|
|
90
|
-
status: AskUserFormStatus;
|
|
91
|
-
/** error text from output-error state. */
|
|
92
|
-
errorText?: string;
|
|
93
|
-
onSubmit?: (answers: AnswersMap) => void;
|
|
94
|
-
onDecline?: () => void;
|
|
95
|
-
}
|
|
96
|
-
export declare const AskUserForm: FC<AskUserFormProps>;
|