forked from nextui-org/nextui
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(use-calendar-picker): fixed the UI month/year sync (nextui-org#3785)
- Loading branch information
1 parent
3b77e2e
commit 5f35a84
Showing
2 changed files
with
55 additions
and
120 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,68 +1,63 @@ | ||
import { AccordionProps } from '@nextui-org/react'; | ||
import { | ||
Accordion, | ||
AccordionItem, | ||
AccordionItemProps | ||
} from '@nextui-org/accordion'; | ||
import { forwardRef, ReactNode } from 'react'; | ||
import {forwardRef, ReactNode} from "react"; | ||
|
||
export interface AccordionTreeItemProps | ||
extends Omit<AccordionItemProps, 'children'> { | ||
import AccordionItem, {AccordionItemProps} from "./accordion-item"; | ||
import Accordion, {AccordionProps} from "./accordion"; | ||
|
||
export interface AccordionTreeItemProps extends Omit<AccordionItemProps, "children"> { | ||
contentMain?: ReactNode; | ||
contentChildren?: AccordionTreeItemProps[]; | ||
} | ||
|
||
export interface AccordionTreeProps extends Omit<AccordionProps, 'children'> { | ||
export interface AccordionTreeProps extends Omit<AccordionProps, "children"> { | ||
items: AccordionTreeItemProps[]; | ||
} | ||
|
||
const AccordionTree = forwardRef<HTMLDivElement, AccordionTreeProps>( | ||
(props, ref) => { | ||
const { | ||
items, | ||
itemClasses: propsItemClasses, | ||
className, | ||
isCompact = true, | ||
selectionMode = 'multiple', | ||
...otherProps | ||
} = props; | ||
const AccordionTree = forwardRef<HTMLDivElement, AccordionTreeProps>((props, ref) => { | ||
const { | ||
items, | ||
itemClasses: propsItemClasses, | ||
className, | ||
isCompact = true, | ||
selectionMode = "multiple", | ||
...otherProps | ||
} = props; | ||
|
||
const itemClasses = { | ||
...propsItemClasses, | ||
trigger: propsItemClasses?.trigger ?? "py-1", | ||
base: propsItemClasses?.base ?? "py-0", | ||
}; | ||
|
||
const itemClasses = { | ||
...propsItemClasses, | ||
trigger: propsItemClasses?.trigger ?? 'py-1', | ||
base: propsItemClasses?.base ?? 'py-0' | ||
}; | ||
return ( | ||
<Accordion | ||
ref={ref} | ||
{...otherProps} | ||
className={className} | ||
isCompact={isCompact} | ||
itemClasses={itemClasses} | ||
selectionMode={selectionMode} | ||
> | ||
{items.map((item, index) => { | ||
const {contentMain, contentChildren, ...itemProps} = item; | ||
|
||
return ( | ||
<Accordion | ||
ref={ref} | ||
{...otherProps} | ||
selectionMode={selectionMode} | ||
isCompact={isCompact} | ||
itemClasses={itemClasses} | ||
className={className} | ||
> | ||
{items.map((item, index) => { | ||
const { contentMain, contentChildren, ...itemProps } = item; | ||
return ( | ||
<AccordionItem key={index} {...itemProps}> | ||
{contentMain && contentMain} | ||
{contentChildren && ( | ||
<AccordionTree | ||
itemClasses={itemClasses} | ||
isCompact={isCompact} | ||
selectionMode={selectionMode} | ||
items={contentChildren} | ||
/> | ||
)} | ||
</AccordionItem> | ||
); | ||
})} | ||
</Accordion> | ||
); | ||
} | ||
); | ||
return ( | ||
<AccordionItem key={index} {...itemProps}> | ||
{contentMain && contentMain} | ||
{contentChildren && ( | ||
<AccordionTree | ||
isCompact={isCompact} | ||
itemClasses={itemClasses} | ||
items={contentChildren} | ||
selectionMode={selectionMode} | ||
/> | ||
)} | ||
</AccordionItem> | ||
); | ||
})} | ||
</Accordion> | ||
); | ||
}); | ||
|
||
AccordionTree.displayName = 'NextUI.AccordionTree'; | ||
AccordionTree.displayName = "NextUI.AccordionTree"; | ||
|
||
export default AccordionTree; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters