@qwanyx/stack 0.2.22 → 0.2.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/components/ComboBox.d.ts +2 -2
- package/dist/index.cjs.js +1 -1
- package/dist/index.esm.js +2 -2
- package/package.json +1 -1
|
@@ -18,8 +18,8 @@ export interface ComboBoxProps {
|
|
|
18
18
|
placeholder?: string;
|
|
19
19
|
/** Allow creating new options */
|
|
20
20
|
allowCreate?: boolean;
|
|
21
|
-
/** Called when a new option is created */
|
|
22
|
-
onCreate?: (label: string) => ComboBoxOption | void;
|
|
21
|
+
/** Called when a new option is created (can be async) */
|
|
22
|
+
onCreate?: (label: string) => ComboBoxOption | Promise<ComboBoxOption> | void;
|
|
23
23
|
/** Label above the input */
|
|
24
24
|
label?: string;
|
|
25
25
|
/** Disabled state */
|
package/dist/index.cjs.js
CHANGED
|
@@ -140,4 +140,4 @@ React keys must be passed directly to JSX without using spread:
|
|
|
140
140
|
pointer-events: none;
|
|
141
141
|
font-size: 14px;
|
|
142
142
|
}
|
|
143
|
-
`;return x.jsxs("div",{className:i,style:{border:`1px solid ${l.border}`,borderRadius:"8px",background:l.background,overflow:"hidden"},children:[x.jsx("style",{children:d}),x.jsxs(Oc,{initialConfig:a,children:[x.jsx(rf,{theme:l,disabled:o}),x.jsx("div",{style:{position:"relative"},children:x.jsx(xd,{contentEditable:x.jsx(Dd,{className:"mail-editor-content",style:{outline:"none",minHeight:u,padding:"16px",fontSize:"14px",lineHeight:1.6,color:l.text}}),placeholder:x.jsx("div",{className:"mail-editor-placeholder",children:t}),ErrorBoundary:jd})}),x.jsx(Jd,{}),x.jsx(Zd,{}),x.jsx(Ld,{}),x.jsx(Od,{onChange:c}),r&&x.jsx(nf,{html:r})]}),n&&x.jsx(sf,{replyTo:n,theme:l})]})}const uf={background:"#ffffff",text:"#111827",textSecondary:"#6b7280",border:"#e5e7eb",primary:"#3b82f6",chipBackground:"#f3f4f6",chipText:"#374151",hoverBackground:"#f9fafb"};function lf({options:r,value:e,onChange:t,placeholder:n="Search or select...",allowCreate:s=!0,onCreate:o,label:i,disabled:u=!1,max:l=0,theme:a={},className:c=""}){const d={...uf,...a},[f,h]=T.useState(!1),[p,g]=T.useState(""),_=T.useRef(null),C=T.useRef(null);T.useEffect(()=>{function w(F){_.current&&!_.current.contains(F.target)&&(h(!1),g(""))}return document.addEventListener("mousedown",w),()=>document.removeEventListener("mousedown",w)},[]);const y=r.filter(w=>w.label.toLowerCase().includes(p.toLowerCase())&&!e.includes(w.id)),D=s&&p.trim()&&!r.some(w=>w.label.toLowerCase()===p.toLowerCase()),b=e.map(w=>r.find(F=>F.id===w)).filter(Boolean),E=T.useCallback(w=>{var F;l>0&&e.length>=l||(t([...e,w]),g(""),(F=C.current)==null||F.focus())},[e,t,l]),v=T.useCallback(w=>{t(e.filter(F=>F!==w))},[e,t]),S=T.useCallback(()=>{if(!D)return;const w=o==null?void 0:o(p.trim());w&&E(w.id),g("")},[D,p,o,E]),A=T.useCallback(w=>{w.key==="Enter"?(w.preventDefault(),D?S():y.length>0&&E(y[0].id)):w.key==="Backspace"&&!p&&e.length>0?v(e[e.length-1]):w.key==="Escape"&&(h(!1),g(""))},[D,y,p,e,S,E,v]);return x.jsxs("div",{ref:_,className:c,style:{position:"relative"},children:[i&&x.jsx("label",{style:{display:"block",fontSize:"12px",textTransform:"uppercase",color:d.textSecondary,marginBottom:"4px"},children:i}),x.jsxs("div",{onClick:()=>!u&&h(!0),style:{display:"flex",flexWrap:"wrap",gap:"6px",padding:"8px 12px",border:`1px solid ${f?d.primary:d.border}`,borderRadius:"8px",background:u?d.hoverBackground:d.background,cursor:u?"not-allowed":"text",minHeight:"42px",alignItems:"center"},children:[b.map(w=>x.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:"4px",padding:"2px 8px",borderRadius:"4px",fontSize:"13px",background:w.color||d.chipBackground,color:w.color?"#fff":d.chipText},children:[w.label,!u&&x.jsx("button",{type:"button",onClick:F=>{F.stopPropagation(),v(w.id)},style:{border:"none",background:"transparent",cursor:"pointer",padding:"0 2px",fontSize:"14px",color:"inherit",opacity:.7},children:"×"})]},w.id)),x.jsx("input",{ref:C,type:"text",value:p,onChange:w=>{g(w.target.value),f||h(!0)},onFocus:()=>h(!0),onKeyDown:A,placeholder:b.length===0?n:"",disabled:u||l>0&&e.length>=l,style:{flex:1,minWidth:"60px",border:"none",outline:"none",fontSize:"14px",background:"transparent",color:d.text}})]}),f&&!u&&x.jsx("div",{style:{position:"absolute",top:"100%",left:0,right:0,marginTop:"4px",background:d.background,border:`1px solid ${d.border}`,borderRadius:"8px",boxShadow:"0 4px 12px rgba(0,0,0,0.1)",maxHeight:"200px",overflowY:"auto",zIndex:50},children:y.length===0&&!D?x.jsx("div",{style:{padding:"12px",fontSize:"14px",color:d.textSecondary,textAlign:"center"},children:p?"No matches":"No options available"}):x.jsxs(x.Fragment,{children:[y.map(w=>x.jsx("div",{onClick:()=>E(w.id),style:{padding:"10px 12px",fontSize:"14px",cursor:"pointer",color:d.text},onMouseEnter:F=>{F.currentTarget.style.background=d.hoverBackground||""},onMouseLeave:F=>{F.currentTarget.style.background=""},children:w.label},w.id)),D&&x.jsxs("div",{onClick:S,style:{padding:"10px 12px",fontSize:"14px",cursor:"pointer",color:d.primary,borderTop:y.length>0?`1px solid ${d.border}`:"none"},onMouseEnter:w=>{w.currentTarget.style.background=d.hoverBackground||""},onMouseLeave:w=>{w.currentTarget.style.background=""},children:['+ Create "',p.trim(),'"']})]})})]})}exports.AnimatedCardFlip=da;exports.ApiClient=Qo;exports.AuthManager=Jo;exports.Card=la;exports.ComboBox=lf;exports.DataOperations=nn;exports.Detail=aa;exports.GraphClient=jl;exports.Mail=ha;exports.MailClient=Go;exports.MailEditor=of;exports.SelectableList=pa;exports.Stack=ua;exports.getApiClient=qs;exports.initializeApiClient=na;exports.useMutation=sa;exports.useQuery=Yo;
|
|
143
|
+
`;return x.jsxs("div",{className:i,style:{border:`1px solid ${l.border}`,borderRadius:"8px",background:l.background,overflow:"hidden"},children:[x.jsx("style",{children:d}),x.jsxs(Oc,{initialConfig:a,children:[x.jsx(rf,{theme:l,disabled:o}),x.jsx("div",{style:{position:"relative"},children:x.jsx(xd,{contentEditable:x.jsx(Dd,{className:"mail-editor-content",style:{outline:"none",minHeight:u,padding:"16px",fontSize:"14px",lineHeight:1.6,color:l.text}}),placeholder:x.jsx("div",{className:"mail-editor-placeholder",children:t}),ErrorBoundary:jd})}),x.jsx(Jd,{}),x.jsx(Zd,{}),x.jsx(Ld,{}),x.jsx(Od,{onChange:c}),r&&x.jsx(nf,{html:r})]}),n&&x.jsx(sf,{replyTo:n,theme:l})]})}const uf={background:"#ffffff",text:"#111827",textSecondary:"#6b7280",border:"#e5e7eb",primary:"#3b82f6",chipBackground:"#f3f4f6",chipText:"#374151",hoverBackground:"#f9fafb"};function lf({options:r,value:e,onChange:t,placeholder:n="Search or select...",allowCreate:s=!0,onCreate:o,label:i,disabled:u=!1,max:l=0,theme:a={},className:c=""}){const d={...uf,...a},[f,h]=T.useState(!1),[p,g]=T.useState(""),_=T.useRef(null),C=T.useRef(null);T.useEffect(()=>{function w(F){_.current&&!_.current.contains(F.target)&&(h(!1),g(""))}return document.addEventListener("mousedown",w),()=>document.removeEventListener("mousedown",w)},[]);const y=r.filter(w=>w.label.toLowerCase().includes(p.toLowerCase())&&!e.includes(w.id)),D=s&&p.trim()&&!r.some(w=>w.label.toLowerCase()===p.toLowerCase()),b=e.map(w=>r.find(F=>F.id===w)).filter(Boolean),E=T.useCallback(w=>{var F;l>0&&e.length>=l||(t([...e,w]),g(""),(F=C.current)==null||F.focus())},[e,t,l]),v=T.useCallback(w=>{t(e.filter(F=>F!==w))},[e,t]),S=T.useCallback(async()=>{if(!D)return;const w=await(o==null?void 0:o(p.trim()));w&&E(w.id),g("")},[D,p,o,E]),A=T.useCallback(w=>{w.key==="Enter"?(w.preventDefault(),D?S():y.length>0&&E(y[0].id)):w.key==="Backspace"&&!p&&e.length>0?v(e[e.length-1]):w.key==="Escape"&&(h(!1),g(""))},[D,y,p,e,S,E,v]);return x.jsxs("div",{ref:_,className:c,style:{position:"relative"},children:[i&&x.jsx("label",{style:{display:"block",fontSize:"12px",textTransform:"uppercase",color:d.textSecondary,marginBottom:"4px"},children:i}),x.jsxs("div",{onClick:()=>!u&&h(!0),style:{display:"flex",flexWrap:"wrap",gap:"6px",padding:"8px 12px",border:`1px solid ${f?d.primary:d.border}`,borderRadius:"8px",background:u?d.hoverBackground:d.background,cursor:u?"not-allowed":"text",minHeight:"42px",alignItems:"center"},children:[b.map(w=>x.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:"4px",padding:"2px 8px",borderRadius:"4px",fontSize:"13px",background:w.color||d.chipBackground,color:w.color?"#fff":d.chipText},children:[w.label,!u&&x.jsx("button",{type:"button",onClick:F=>{F.stopPropagation(),v(w.id)},style:{border:"none",background:"transparent",cursor:"pointer",padding:"0 2px",fontSize:"14px",color:"inherit",opacity:.7},children:"×"})]},w.id)),x.jsx("input",{ref:C,type:"text",value:p,onChange:w=>{g(w.target.value),f||h(!0)},onFocus:()=>h(!0),onKeyDown:A,placeholder:b.length===0?n:"",disabled:u||l>0&&e.length>=l,style:{flex:1,minWidth:"60px",border:"none",outline:"none",fontSize:"14px",background:"transparent",color:d.text}})]}),f&&!u&&x.jsx("div",{style:{position:"absolute",top:"100%",left:0,right:0,marginTop:"4px",background:d.background,border:`1px solid ${d.border}`,borderRadius:"8px",boxShadow:"0 4px 12px rgba(0,0,0,0.1)",maxHeight:"200px",overflowY:"auto",zIndex:50},children:y.length===0&&!D?x.jsx("div",{style:{padding:"12px",fontSize:"14px",color:d.textSecondary,textAlign:"center"},children:p?"No matches":"No options available"}):x.jsxs(x.Fragment,{children:[y.map(w=>x.jsx("div",{onClick:()=>E(w.id),style:{padding:"10px 12px",fontSize:"14px",cursor:"pointer",color:d.text},onMouseEnter:F=>{F.currentTarget.style.background=d.hoverBackground||""},onMouseLeave:F=>{F.currentTarget.style.background=""},children:w.label},w.id)),D&&x.jsxs("div",{onClick:S,style:{padding:"10px 12px",fontSize:"14px",cursor:"pointer",color:d.primary,borderTop:y.length>0?`1px solid ${d.border}`:"none"},onMouseEnter:w=>{w.currentTarget.style.background=d.hoverBackground||""},onMouseLeave:w=>{w.currentTarget.style.background=""},children:['+ Create "',p.trim(),'"']})]})})]})}exports.AnimatedCardFlip=da;exports.ApiClient=Qo;exports.AuthManager=Jo;exports.Card=la;exports.ComboBox=lf;exports.DataOperations=nn;exports.Detail=aa;exports.GraphClient=jl;exports.Mail=ha;exports.MailClient=Go;exports.MailEditor=of;exports.SelectableList=pa;exports.Stack=ua;exports.getApiClient=qs;exports.initializeApiClient=na;exports.useMutation=sa;exports.useQuery=Yo;
|
package/dist/index.esm.js
CHANGED
|
@@ -11979,9 +11979,9 @@ function bf({
|
|
|
11979
11979
|
l > 0 && e.length >= l || (t([...e, C]), g(""), (N = D.current) == null || N.focus());
|
|
11980
11980
|
}, [e, t, l]), b = Q((C) => {
|
|
11981
11981
|
t(e.filter((N) => N !== C));
|
|
11982
|
-
}, [e, t]), S = Q(() => {
|
|
11982
|
+
}, [e, t]), S = Q(async () => {
|
|
11983
11983
|
if (!w) return;
|
|
11984
|
-
const C = o == null ? void 0 : o(p.trim());
|
|
11984
|
+
const C = await (o == null ? void 0 : o(p.trim()));
|
|
11985
11985
|
C && A(C.id), g("");
|
|
11986
11986
|
}, [w, p, o, A]), E = Q((C) => {
|
|
11987
11987
|
C.key === "Enter" ? (C.preventDefault(), w ? S() : y.length > 0 && A(y[0].id)) : C.key === "Backspace" && !p && e.length > 0 ? b(e[e.length - 1]) : C.key === "Escape" && (h(!1), g(""));
|
package/package.json
CHANGED