@payfit/unity-components
Version:
70 lines (69 loc) • 3.66 kB
TypeScript
import { RegisteredRouter, ValidateLinkOptions } from '@tanstack/react-router';
import { SubTaskProps as RawSubTaskProps } from '../../../../components/task-menu/parts/RawSubTask.js';
type SubTaskRouterProps<TRouter extends RegisteredRouter = RegisteredRouter, TOptions = unknown> = Omit<RawSubTaskProps, 'href' | 'onPress'> & ValidateLinkOptions<TRouter, TOptions>;
type SubTaskButtonProps = Omit<RawSubTaskProps, 'href'> & {
onPress: NonNullable<RawSubTaskProps['onPress']>;
};
export type SubTaskProps<TRouter extends RegisteredRouter = RegisteredRouter, TOptions = unknown> = SubTaskRouterProps<TRouter, TOptions> | SubTaskButtonProps;
/**
* A subtask component that integrates with Tanstack Router for seamless navigation within task groups.
* Represents individual subtask items within a TaskGroup that can be either links for navigation or buttons
* for custom interactions, with support for various visual states including completed, uncompleted, and locked.
* @param {SubTaskProps} props - Either router-based props (with 'to') or button-based props (with 'onPress')
* @example
* ```tsx
* import { SubTask } from '@payfit/unity-components/integrations/tanstack-router'
* import { TaskMenu, TaskGroup } from '@payfit/unity-components'
*
* function OnboardingTaskGroup() {
* return (
* <TaskMenu label="Onboarding tasks">
* <TaskGroup
* uniqueId="onboarding"
* label="Complete Onboarding"
* taskNumber={1}
* taskStatus="uncompleted"
* >
* <SubTask
* uniqueId="profile-setup"
* label="Complete Profile Information"
* taskStatus="uncompleted"
* to="/onboarding/profile"
* />
* <SubTask
* uniqueId="validate-email"
* label="Validate Email Address"
* taskStatus="completed"
* onPress={() => console.log('Email validation triggered')}
* />
* <SubTask
* uniqueId="final-approval"
* label="Manager Approval"
* taskStatus="locked"
* to="/onboarding/approval"
* />
* </TaskGroup>
* </TaskMenu>
* )
* }
* ```
* @remarks
* - Automatically renders as a link when 'to' prop is provided, or as a button when 'onPress' is provided
* - Supports type-safe route parameters, search params, and relative navigation with Tanstack Router
* - Integrates with TaskGroup component for hierarchical task organization
* - Provides automatic active state styling based on current route
* - Supports multiple task states: completed, uncompleted, and locked
* - Displays a dot indicator instead of a numbered badge to distinguish from main Task components
* - Maintains all accessibility features from the underlying RawSubTask component
* - SubTask selection state is automatically managed based on routing context
* @see {@link SubTaskProps} for all available props
* @see Source code in {@link https://github.com/PayFit/hr-apps/tree/master/libs/shared/unity/components/src/integrations/tanstack-router/components/task-menu GitHub}
* @see Design specs {@link https://www.figma.com/design/poaMyU7abAgL9VRhx4ygyy/Unity-DS-%3E-Components-Library Figma}
* @see Design docs in {@link https://www.payfit.design/ Payfit.design}
* @see Developer docs in {@link https://unity-components.payfit.io/?path=/ unity-components.payfit.io}
*/
declare function SubTask<TRouter extends RegisteredRouter = RegisteredRouter, TOptions = unknown>(props: SubTaskProps<TRouter, TOptions>): import("react/jsx-runtime").JSX.Element;
declare namespace SubTask {
var displayName: string;
}
export { SubTask };