@jamsr-ui/autocomplete
Advanced tools
Comparing version 0.0.18 to 0.0.19
@@ -1,3 +0,3 @@ | ||
export { AutoComplete } from './autocomplete.js'; | ||
export { AutoComplete, AutoCompleteProps } from './autocomplete.js'; | ||
import 'react/jsx-runtime'; | ||
import '@jamsr-ui/input'; |
"use client" | ||
"use strict";var R=Object.defineProperty;var re=Object.getOwnPropertyDescriptor;var se=Object.getOwnPropertyNames;var ae=Object.prototype.hasOwnProperty;var ue=(r,o)=>{for(var a in o)R(r,a,{get:o[a],enumerable:!0})},ie=(r,o,a,u)=>{if(o&&typeof o=="object"||typeof o=="function")for(let s of se(o))!ae.call(r,s)&&s!==a&&R(r,s,{get:()=>o[s],enumerable:!(u=re(o,s))||u.enumerable});return r};var pe=r=>ie(R({},"__esModule",{value:!0}),r);var ce={};ue(ce,{AutoComplete:()=>G});module.exports=pe(ce);var e=require("@floating-ui/react"),S=require("@jamsr-ui/button"),k=require("@jamsr-ui/hooks"),b=require("@jamsr-ui/input"),B=require("@jamsr-ui/shared-icons"),z=require("@jamsr-ui/utils"),p=require("react");var D=require("@jamsr-ui/shared-icons"),K=require("@jamsr-ui/utils"),g=require("react"),v=require("react/jsx-runtime"),f=(0,g.forwardRef)(({children:r,active:o,className:a,selected:u,disabled:s,...I},h)=>{let C=(0,g.useId)();return(0,v.jsxs)("div",{"data-slot":"item",ref:h,role:"option",id:C,"aria-selected":o,className:(0,K.cn)("flex w-full cursor-pointer select-none items-center gap-2 rounded-md p-2 text-sm text-foreground hover:bg-action-hover focus-visible:ring-2 focus-visible:ring-primary",a,{"bg-content1":o,"bg-content1/50":u,"cursor-not-allowed opacity-90 hover:bg-transparent":s}),...I,children:[r,u&&(0,v.jsx)(D.Check,{className:"absolute right-2 bg-background "})]})});f.displayName="UI.AutocompleteItem";var l=require("react/jsx-runtime");var G=r=>{let{classNames:o,defaultValue:a,onValueChange:u,value:s,inputValue:I,defaultInputValue:h,onInputValueChange:C,options:x,label:U,getOptionLabel:N,slotProps:$,renderOption:W,getOptionValue:F,...Y}=r,[L=s??"",M]=(0,k.useControlledState)({defaultProp:h,prop:I,onChange:C}),[O=null,E]=(0,k.useControlledState)({defaultProp:a,prop:s,onChange:u}),[P,i]=(0,p.useState)(!1),[_,T]=(0,p.useState)(!1),[c,y]=(0,p.useState)(null),A=(0,p.useRef)([]),{refs:V,floatingStyles:q,context:m}=(0,e.useFloating)({whileElementsMounted:e.autoUpdate,open:P,onOpenChange:i,middleware:[(0,e.offset)(1),(0,e.size)({apply({rects:t,availableHeight:n,elements:w}){Object.assign(w.floating.style,{width:`${t.reference.width}px`,maxHeight:`${n}px`})},padding:4})]}),J=(0,e.useRole)(m,{role:"listbox"}),Q=(0,e.useDismiss)(m),X=(0,e.useListNavigation)(m,{listRef:A,activeIndex:c,onNavigate:y,virtual:!0,loop:!0}),{getReferenceProps:Z,getFloatingProps:j,getItemProps:ee}=(0,e.useInteractions)([J,Q,X]);function te(t){let{value:n}=t.target;M(n),E(null),n?(i(!0),y(0)):i(!1)}let d=x.filter(t=>N(t).toLowerCase().startsWith(L.toLowerCase())),H=t=>{let n=F(t);M(n),E(n),y(null),i(!1)},oe=t=>{t.preventDefault(),i(!0),T(!0)};return(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(b.Input,{...Y,label:U,endContent:(0,l.jsx)(S.Button,{onClick:()=>{i(t=>!t),T(!P)},isIconOnly:!0,variant:"light",rounded:!0,children:(0,l.jsx)(B.ChevronDown,{})}),type:"search",autoComplete:"off",...Z({ref:V.setReference,onChange:te,value:L,onClick:oe,"aria-autocomplete":"list",onInput(){T(!1)},onKeyDown(t){if(t.key==="Enter"&&c!=null&&d[c]){let n=d?.[c];n&&H(n)}}}),...$?.input,className:(0,b.inputVariants)().input()}),P&&(0,l.jsx)(e.FloatingPortal,{children:(0,l.jsx)(e.FloatingFocusManager,{context:m,initialFocus:-1,visuallyHiddenDismiss:!0,children:(0,l.jsxs)("div",{className:(0,z.cn)("z-popover border-divider bg-background shadow-card rounded-lg border focus:outline-none",o?.wrapper),...j({ref:V.setFloating,style:{...q,overflowY:"auto"}}),children:[d.length===0&&(0,l.jsx)(f,{disabled:!0,children:"No results found"}),(_&&O?x:d).map((t,n)=>{let w=N(t),ne=F(t);return(0,l.jsx)(f,{...ee({ref(le){A.current[n]=le},onClick(){H(t),V.domReference.current?.focus()}}),active:c===n,selected:O===ne,children:W(t)},w)})]})})})]})};0&&(module.exports={AutoComplete}); | ||
"use strict";var R=Object.defineProperty;var re=Object.getOwnPropertyDescriptor;var se=Object.getOwnPropertyNames;var ae=Object.prototype.hasOwnProperty;var ue=(r,o)=>{for(var a in o)R(r,a,{get:o[a],enumerable:!0})},ie=(r,o,a,u)=>{if(o&&typeof o=="object"||typeof o=="function")for(let s of se(o))!ae.call(r,s)&&s!==a&&R(r,s,{get:()=>o[s],enumerable:!(u=re(o,s))||u.enumerable});return r};var pe=r=>ie(R({},"__esModule",{value:!0}),r);var ce={};ue(ce,{AutoComplete:()=>G});module.exports=pe(ce);var e=require("@floating-ui/react"),S=require("@jamsr-ui/button"),k=require("@jamsr-ui/hooks"),b=require("@jamsr-ui/input"),B=require("@jamsr-ui/shared-icons"),z=require("@jamsr-ui/utils"),p=require("react");var D=require("@jamsr-ui/shared-icons"),K=require("@jamsr-ui/utils"),g=require("react"),v=require("react/jsx-runtime"),f=(0,g.forwardRef)(({children:r,active:o,className:a,selected:u,disabled:s,...I},h)=>{let C=(0,g.useId)();return(0,v.jsxs)("div",{"data-slot":"item",ref:h,role:"option",id:C,"aria-selected":o,className:(0,K.cn)("flex w-full cursor-pointer select-none items-center gap-2 rounded-md p-2 text-sm text-foreground hover:bg-action-hover focus-visible:ring-2 focus-visible:ring-primary",a,{"bg-content1":o,"bg-content1/50":u,"cursor-not-allowed opacity-90 hover:bg-transparent":s}),...I,children:[r,u&&(0,v.jsx)(D.Check,{className:"absolute right-2 bg-background "})]})});f.displayName="UI.AutocompleteItem";var l=require("react/jsx-runtime");var G=r=>{let{classNames:o,defaultValue:a,onValueChange:u,value:s,inputValue:I,defaultInputValue:h,onInputValueChange:C,options:x,label:U,getOptionLabel:N,slotProps:$,renderOption:W,getOptionValue:F,...Y}=r,[L=s??"",M]=(0,k.useControlledState)({defaultProp:h,prop:I,onChange:C}),[O=null,A]=(0,k.useControlledState)({defaultProp:a,prop:s,onChange:u}),[P,i]=(0,p.useState)(!1),[_,y]=(0,p.useState)(!1),[c,T]=(0,p.useState)(null),E=(0,p.useRef)([]),{refs:V,floatingStyles:q,context:m}=(0,e.useFloating)({whileElementsMounted:e.autoUpdate,open:P,onOpenChange:i,middleware:[(0,e.offset)(1),(0,e.size)({apply({rects:t,availableHeight:n,elements:w}){Object.assign(w.floating.style,{width:`${t.reference.width}px`,maxHeight:`${n}px`})},padding:4})]}),J=(0,e.useRole)(m,{role:"listbox"}),Q=(0,e.useDismiss)(m),X=(0,e.useListNavigation)(m,{listRef:E,activeIndex:c,onNavigate:T,virtual:!0,loop:!0}),{getReferenceProps:Z,getFloatingProps:j,getItemProps:ee}=(0,e.useInteractions)([J,Q,X]);function te(t){let{value:n}=t.target;M(n),A(null),n?(i(!0),T(0)):i(!1)}let d=x.filter(t=>N(t).toLowerCase().startsWith(L.toLowerCase())),H=t=>{let n=F(t);M(n),A(n),T(null),i(!1)},oe=t=>{t.preventDefault(),i(!0),y(!0)};return(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(b.Input,{...Y,label:U,endContent:(0,l.jsx)(S.Button,{onClick:()=>{i(t=>!t),y(!P)},isIconOnly:!0,variant:"light",rounded:!0,children:(0,l.jsx)(B.ChevronDown,{})}),type:"search",autoComplete:"off",...Z({ref:V.setReference,onChange:te,value:L,onClick:oe,"aria-autocomplete":"list",onInput(){y(!1)},onKeyDown(t){if(t.key==="Enter"&&c!=null&&d[c]){let n=d?.[c];n&&H(n)}}}),...$?.input,className:(0,b.inputVariants)().input()}),P&&(0,l.jsx)(e.FloatingPortal,{children:(0,l.jsx)(e.FloatingFocusManager,{context:m,initialFocus:-1,visuallyHiddenDismiss:!0,children:(0,l.jsxs)("div",{className:(0,z.cn)("z-popover border-divider bg-background shadow-card rounded-lg border focus:outline-none",o?.wrapper),...j({ref:V.setFloating,style:{...q,overflowY:"auto"}}),children:[d.length===0&&(0,l.jsx)(f,{disabled:!0,children:"No results found"}),(_&&O?x:d).map((t,n)=>{let w=N(t),ne=F(t);return(0,l.jsx)(f,{...ee({ref(le){E.current[n]=le},onClick(){H(t),V.domReference.current?.focus()}}),active:c===n,selected:O===ne,children:W(t)},w)})]})})})]})};0&&(module.exports={AutoComplete}); |
{ | ||
"name": "@jamsr-ui/autocomplete", | ||
"version": "0.0.18", | ||
"version": "0.0.19", | ||
"description": "", | ||
@@ -25,7 +25,7 @@ "main": "./dist/index.mjs", | ||
"@floating-ui/react": "^0.26.16", | ||
"@jamsr-ui/button": "^0.0.18", | ||
"@jamsr-ui/input": "^0.0.18", | ||
"@jamsr-ui/shared-icons": "^0.0.17", | ||
"@jamsr-ui/utils": "^0.0.16", | ||
"@jamsr-ui/hooks": "^0.0.11" | ||
"@jamsr-ui/button": "^0.0.19", | ||
"@jamsr-ui/input": "^0.0.19", | ||
"@jamsr-ui/utils": "^0.0.17", | ||
"@jamsr-ui/hooks": "^0.0.12", | ||
"@jamsr-ui/shared-icons": "^0.0.18" | ||
}, | ||
@@ -32,0 +32,0 @@ "module": "dist/index.mjs", |
Sorry, the diff of this file is not supported yet
16065
+ Added@jamsr-ui/button@0.0.19(transitive)
+ Added@jamsr-ui/hooks@0.0.12(transitive)
+ Added@jamsr-ui/input@0.0.19(transitive)
+ Added@jamsr-ui/progress@0.0.19(transitive)
+ Added@jamsr-ui/ripple@0.0.19(transitive)
+ Added@jamsr-ui/shared-icons@0.0.18(transitive)
+ Added@jamsr-ui/utils@0.0.17(transitive)
- Removed@jamsr-ui/button@0.0.18(transitive)
- Removed@jamsr-ui/hooks@0.0.11(transitive)
- Removed@jamsr-ui/input@0.0.18(transitive)
- Removed@jamsr-ui/progress@0.0.18(transitive)
- Removed@jamsr-ui/ripple@0.0.18(transitive)
- Removed@jamsr-ui/shared-icons@0.0.17(transitive)
- Removed@jamsr-ui/utils@0.0.16(transitive)
Updated@jamsr-ui/button@^0.0.19
Updated@jamsr-ui/hooks@^0.0.12
Updated@jamsr-ui/input@^0.0.19
Updated@jamsr-ui/utils@^0.0.17