跳到主要内容

Tab Form

"tab + from" is a super component~

show code
enum DealType {
CAPITAL_RAISING = "capital_raising",
EQUITY = "equity",
STARTUP_PITCH = "startup_pitch",
PARTNERSHIPS = "partnerships",
SELL_A_BUSINESS = "sell_a_business",
}
const DealTypeOption = [
{
label: 'Capital Raising',
value: DealType.CAPITAL_RAISING,
info: 'Outline your business, growth goals and the debt funding needed for expansion.',
},
{
label: 'Equity',
value: DealType.EQUITY,
info: 'Share your business journey, goals and the specific support you seek in exchange for equity.',
},
{
label: 'Startup Pitch',
value: DealType.STARTUP_PITCH,
info: 'Create high value synergies by seeking suppliers, distribution channels, or collaborative opportunities for mutual growth.',
},
{
label: 'Partnerships',
value: DealType.PARTNERSHIPS,
info: 'Present your idea-stage business, seeking support in funding, products, or valuable feedback.',
},
{
label: 'Sell A Business',
value: DealType.SELL_A_BUSINESS,
info: 'Find a new owner to take your business forward. Describe the story so far and the price you have in mind to start the conversation. ',
},
];
type EventType = "Create" | "Draft" | "Update" | "Submit" | "Publish";



function Demo() {
const [tabId, setTabId] = useState("1")
const tabFormRef = useRef()
const defaultValues = {}
const dealTypeFormViewConfig = useDealTypeFormViewConfig({ defaultValues });
const dealBasicsFormViewConfig = useDealBasicsFormViewConfig({
defaultValues,
});
const businessFormViewViewConfig = useBusinessFormViewConfig({
defaultValues,
});
const marketFormViewonfig = useMarketFormViewConfig({ defaultValues });
const mediaFormViewConfig = useMediaFormViewConfig({ defaultValues });
const faqFromViewConfig = useFaqFromViewConfig({ defaultValues });
const tabConfig = useMemo(() => {
return [
{
id: "1",
label: "Deal Type",
node: dealTypeFormViewConfig,
},
{
id: "2",
label: "Deal Basics",
node: dealBasicsFormViewConfig,
},
{
id: "3",
label: "Business Details",
node: businessFormViewViewConfig,
},
{
id: "4",
label: "Market & Competition",
node: marketFormViewonfig,
},
{
id: "5",
label: "Uploads & Media",
node: mediaFormViewConfig,
},
{
id: "6",
label: "FAQs",
node: faqFromViewConfig,
},
];
// }, [dealTypeFormViewConfig, dealBasicsFormViewConfig, businessFormViewViewConfig, marketFormViewonfig, mediaFormViewConfig, faqFromViewConfig]);
}, []);
return (
<>
<TabForm
tabId={tabId}
handleTabChange={(newTabId) => {
setTabId(newTabId);
}}
tabConfig={tabConfig}
ref={tabFormRef}
/>
<Button onClick={() => {
tabFormRef.current!?.validate(Object.values(tabFormRef.current.getTabFormRef()))
}}>Submit</Button>
</>
);
}


render(<Demo />);

Props

tip
  • Type: any, can be customized as needed.
  • Default value:
    • Not specified: optional.
    • Specified as "require": mandatory.
  • Type link: Click to navigate to the details below.
OptionTypeDefaultDescription
tabConfigrequired
tabIdrequired
handleTabChangerequired

Type

TreeConfig

export interface Props {
tabId: string,
tabConfig: {
id: string;
label: string;
node: FormConfig;
}[],
handleTabChange: (tabId: string) => void
}