UNPKG

@nexusui/components

Version:

These are custom components specially-developed for NexusUI applications. They will make your life easier by giving you out-of-the-box implementations for various high-level UI elements that you can drop directly into your application.

2 lines (1 loc) 489 B
import t from"lodash/groupBy";import{useMemo as e}from"react";const n=(n,o)=>{const r=e((()=>t(n,(t=>{const e=t.name.split(".");return e.pop(),e.join("")}))),[n]);return{sortedFiles:e((()=>{let t=[];const e=new RegExp(`\\.${o}$`,"i");return Object.keys(r).sort().forEach((n=>{const s=r[n],a=null!==o;a&&s.sort(((t,n)=>e.test(t.name)?-1:e.test(n.name)?1:n.name>t.name?-1:t.name>n.name?1:0)),t=t.concat(s.map(((t,e)=>(t.isSubFile=e>0&&a,t))))})),t}),[r,o])}};export{n as useParentFileSort};