-
Notifications
You must be signed in to change notification settings - Fork 3.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(dashboard): bring the hrm alive (#6703)
- Loading branch information
Showing
41 changed files
with
324 additions
and
297 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
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
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
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
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
40 changes: 40 additions & 0 deletions
40
apps/dashboard/src/components/primitives/form/form-context.ts
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 |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import React from 'react'; | ||
import { FieldPath, FieldValues, useFormContext } from 'react-hook-form'; | ||
|
||
type FormFieldContextValue< | ||
TFieldValues extends FieldValues = FieldValues, | ||
TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>, | ||
> = { | ||
name: TName; | ||
}; | ||
|
||
export const FormFieldContext = React.createContext<FormFieldContextValue>({} as FormFieldContextValue); | ||
|
||
type FormItemContextValue = { | ||
id: string; | ||
}; | ||
|
||
export const FormItemContext = React.createContext<FormItemContextValue>({} as FormItemContextValue); | ||
|
||
export const useFormField = () => { | ||
const fieldContext = React.useContext(FormFieldContext); | ||
const itemContext = React.useContext(FormItemContext); | ||
const { getFieldState, formState } = useFormContext(); | ||
|
||
const fieldState = getFieldState(fieldContext.name, formState); | ||
|
||
if (!fieldContext) { | ||
throw new Error('useFormField should be used within <FormField>'); | ||
} | ||
|
||
const { id } = itemContext; | ||
|
||
return { | ||
id, | ||
name: fieldContext.name, | ||
formItemId: `${id}-form-item`, | ||
formDescriptionId: `${id}-form-item-description`, | ||
formMessageId: `${id}-form-item-message`, | ||
...fieldState, | ||
}; | ||
}; |
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
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 |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from './form'; |
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
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,39 +1,13 @@ | ||
import * as React from 'react'; | ||
import { cva, type VariantProps } from 'class-variance-authority'; | ||
import { type VariantProps } from 'class-variance-authority'; | ||
|
||
import { cn } from '@/utils/ui'; | ||
|
||
const stepVariants = cva( | ||
'inline-flex items-center shadow-xs rounded-full border text-xs font-semibold transition-colors focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 bg-neutral-50', | ||
{ | ||
variants: { | ||
variant: { | ||
// use solid bg here because we usually stack these on top of each other | ||
neutral: 'border-neutral-100 text-neutral-400', | ||
feature: 'border-feature/30 text-feature/30', | ||
information: 'border-information/30 text-information/30', | ||
highlighted: 'border-highlighted/30 text-highlighted/30', | ||
stable: 'border-stable/30 text-stable/30', | ||
verified: 'border-verified/30 text-verified/30', | ||
destructive: 'border-destructive/30 text-destructive/30', | ||
warning: 'border-warning/30 text-warning/30', | ||
alert: 'border-alert/30 text-alert/30', | ||
}, | ||
size: { | ||
default: 'p-1 [&>svg]:size-3.5', | ||
}, | ||
}, | ||
defaultVariants: { | ||
variant: 'neutral', | ||
size: 'default', | ||
}, | ||
} | ||
); | ||
import { stepVariants } from './variants'; | ||
|
||
export interface StepProps extends React.HTMLAttributes<HTMLDivElement>, VariantProps<typeof stepVariants> {} | ||
|
||
function Step({ className, variant, ...props }: StepProps) { | ||
return <div className={cn(stepVariants({ variant }), className)} {...props} />; | ||
} | ||
|
||
export { Step, stepVariants }; | ||
export { Step }; |
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
Oops, something went wrong.