@@ -83,29 +83,36 @@ const ItemTemplate = React.memo((props: ItemTemplateProps) => {
8383    ) ; 
8484} ) ; 
8585
86- const  Shortcuts  =  ( )  =>  { 
86+ const  printItemText  =  ( item : ShortcutsItem )  =>  { 
87+     return  item . text  ??  null ; 
88+ } ; 
89+ 
90+ const  Shortcuts : React . FC  =  ( )  =>  { 
8791    // Contexts 
8892    const  {  configs }  =  useContext ( DatepickerContext ) ; 
8993
9094    const  callPastFunction  =  ( data : unknown ,  numberValue : number )  =>  { 
9195        return  typeof  data  ===  "function"  ? data ( numberValue )  : null ; 
9296    } ; 
9397
94-     // eslint-disable-next-line @typescript-eslint/ban-ts-comment 
95-     //  @ts -ignore 
96-     const   printItemText   =   item   =>   { 
97-         return   "text"   in   item  ?  item . text  :  "" ; 
98-     } ; 
98+     const   shortcutOptions   =   configs 
99+         ?  Object . entries ( DEFAULT_SHORTCUTS ) . filter ( ( [ key ] )   =>   { 
100+                return   configs . shortcuts  ?  Object . keys ( configs . shortcuts ) . includes ( key )  :  true ; 
101+            } ) 
102+         :  Object . entries ( DEFAULT_SHORTCUTS ) ; 
99103
100104    return  ( 
101105        < div  className = "md:border-b mb-3 lg:mb-0 lg:border-r lg:border-b-0 border-gray-300 dark:border-gray-700 pr-1" > 
102106            < ul  className = "w-full tracking-wide flex flex-wrap lg:flex-col pb-1 lg:pb-0" > 
103-                 { Object . entries ( DEFAULT_SHORTCUTS ) . map ( ( [ key ,  item ] ,  index )  => 
104-                     key   ===   "past"  ? ( 
105-                         ( Array . isArray ( item )  ?  item  :  [ ] ) . map ( ( item ,  index )  =>  ( 
107+                 { shortcutOptions . map ( ( [ key ,  item ] ,  index )  => 
108+                     Array . isArray ( item )  ? ( 
109+                         item . map ( ( item ,  index )  =>  ( 
106110                            < ItemTemplate  key = { index }  item = { item } > 
107111                                < > 
108-                                     { configs  &&  configs . shortcuts  &&  key  in  configs . shortcuts 
112+                                     { key  ===  "past"  && 
113+                                     configs ?. shortcuts  && 
114+                                     key  in  configs . shortcuts  && 
115+                                     item . daysNumber 
109116                                        ? callPastFunction ( configs . shortcuts [ key ] ,  item . daysNumber ) 
110117                                        : item . text } 
111118                                </ > 
@@ -114,7 +121,7 @@ const Shortcuts = () => {
114121                    )  : ( 
115122                        < ItemTemplate  key = { index }  item = { item } > 
116123                            < > 
117-                                 { configs   &&   configs . shortcuts  &&  key  in  configs . shortcuts 
124+                                 { configs ? .shortcuts  &&  key  in  configs . shortcuts 
118125                                    ? configs . shortcuts [ key  as  keyof  typeof  configs . shortcuts ] 
119126                                    : printItemText ( item ) } 
120127                            </ > 
0 commit comments