@fanam-pkg/core-ui-sass
Version:
485 lines (424 loc) • 11.3 kB
text/typescript
import {IDecodedAddress, IFile, JSONObject, FileType as MimeType, IFormData, JSONValues} from "@fanam-pkg/core-utils"
import {ImageProps, StaticImageData} from "next/image"
import {
ButtonHTMLAttributes,
ChangeEvent,
FormEvent,
InputHTMLAttributes,
KeyboardEvent,
LegacyRef,
MouseEvent,
MutableRefObject,
ReactNode,
SelectHTMLAttributes,
} from "react"
export type FormValueType =
| string
| string[]
| number
| IFormData<JSONValues>
| IFormData<JSONValues>[]
| IFile
| IFile[]
| JSONObject
| Date
export type FileAttachmentType = IFile | IFile[] | null
export type ButtonType =
| "success-outlined"
| "success-text"
| "success-filled"
| "danger-outlined"
| "danger-text"
| "danger-filled"
| "primary-outlined"
| "primary-text"
| "primary-filled"
export type CommonSelectionType = string | number | JSONObject | JSONObject[]
export type DropdownType<K = CommonSelectionType> = IFormData<K> | string | number | FormValueType
export type SelectedType<K = CommonSelectionType> = IFormData<K> | string | number
export type CustomWheelType = "days" | "months" | "years" | "hours" | "minutes" | "meridians"
export type DateTimePickerType = "date" | "time" | "date-time"
export type PaginationType = number
export type WheelPickerAnimation = "flat" | "wheel"
export type NotifyType = "error" | "success" | "information"
export type ActionType = "view" | "edit" | "delete" | "block" | "unblock"
export type ElementType =
| "input"
| "drop-down"
| "text-area"
| "date-picker"
| "file-picker"
| "checkbox"
| "radio-button"
| "profile-picker"
| "multi-select"
export interface IAction {
label: string
action: ActionType
onClick: () => void
}
export interface StatusButtonArr {
name: string
id: string
}
export interface ImageViewProps extends ImageProps {
wrapperClass?: string
imgWidth?: number
imgHeight?: number
imgSize?: number
objectFit?: "cover" | "contain"
overflow?: "hidden" | "scroll" | "auto"
placeHolder?: string | StaticImageData
onClick?: (event: MouseEvent<HTMLDivElement> | MouseEvent<HTMLImageElement>) => void
}
export interface ButtonProps extends ButtonHTMLAttributes<HTMLButtonElement> {
buttonType?: ButtonType
wrapperClass?: string
leadingClass?: string
trailingClass?: string
trailingIcon?: string | StaticImageData
leadingIcon?: string | StaticImageData
onClickTrailingIcon?: () => void
onClickLeadingIcon?: () => void
}
export interface ChipItemProps extends IFormData {
selChipClass?: string
defaultChipClass?: string
leadingIcon?: string | StaticImageData
avatar?: string | StaticImageData
trailingIcon?: string | StaticImageData
onClickTrailingIcon?: () => void
onClickLeadingIcon?: () => void
onClick?: (index: number, item: ChipItemProps) => void
}
export interface ChipProps {
label?: string
isRequired?: boolean
chips?: ChipItemProps[]
chip?: ChipItemProps
onSelectItems?: (items: ChipItemProps[]) => void
onSelectItem?: (items: ChipItemProps) => void
wrapperClass?: string
children?: ReactNode
isMultiple?: boolean
leadingIcon?: string | StaticImageData
trailingIcon?: string | StaticImageData
onClickTrailingIcon?: () => void
onClickLeadingIcon?: () => void
}
export interface NotifyPopupProps {
ctaText?: string
type: NotifyType
description?: string
onClickCta?: () => void
title?: string
animate?: boolean
}
export interface INotifyPopup {
notify: NotifyPopupProps | null
toggleNotify: (alert?: NotifyPopupProps) => void
}
export interface SkeletonLoaderProps {
loading?: boolean
}
export interface IPageLoaderProps {
loading?: boolean
toggleLoading: (loading?: boolean) => void
}
export interface BreadCrumbsProps {
items: string[]
}
export interface IPopup {
children?: ReactNode
message?: string
title?: string
heading?: string
isClosable?: boolean
}
export interface PopupProps {
popup: IPopup
togglePopup: (popup?: IPopup) => void
closable?: boolean
}
export interface DialogContentProps {
isClosable?: boolean
primaryButtonText?: string
secondaryButtonText?: string
onClickPrimary?: () => void
onClickSecondary?: () => void
title?: string
body?: ReactNode
message?: string
buttonTypeSecondary?: ButtonType
buttonTypePrimary?: ButtonType
}
export interface DialogProps {
dialog?: DialogContentProps
toggleDialog: (content?: DialogContentProps) => void
}
export interface OtpInputProps {
error: string
type?: string
handleInputChange: (index: number, event: ChangeEvent<HTMLInputElement>) => void
inputRefs: MutableRefObject<(HTMLInputElement | null)[]>
otpValues: string[]
handleKeyDown: (index: number, event: KeyboardEvent<HTMLInputElement>) => void
}
export interface ProfileNameProps {
name: string
wrapperClass?: string
contentClass?: string
onClick?: () => void
}
export interface CheckboxProps {
label?: string
isRequired?: boolean
items?: IFormData[]
item?: IFormData
name?: string
isEditing?: boolean
onSelectItems?: (items: IFormData[] | Record<string, IFormData[]>) => void
onSelectItem?: (item: IFormData | Record<string, IFormData>) => void
wrapperClass?: string
}
export interface RadioButtonProps extends CheckboxProps {
radioGroupName?: string
}
export interface FormElementProps {
label?: string
disabled?: boolean
error?: string
name?: string
selected?: SelectedType
wrapperClass?: string
isRequired?: boolean
}
export interface DropDownProps extends SelectHTMLAttributes<HTMLSelectElement>, FormElementProps {
options: DropdownType[]
disabled?: boolean
selected?: SelectedType
onChangeData: (data: DropdownType, selIndex: number) => void
placeholder?: string
image?: string | StaticImageData
items?: [] /* This is mentioned to resolve the build issue */
}
export interface DropDownSearchProps {
options: IFormData[]
disabled?: boolean
onChangeData: (data: Record<string, IFormData[]> | IFormData[]) => void
name?: string
label: string
error?: string
value?: string[]
wrapperClass?: string
}
export interface DropdownStyleProps {
error?: string
selected?: SelectedType
label?: string
disabled?: boolean
}
export interface TextFieldProps extends FormElementProps, InputHTMLAttributes<HTMLInputElement> {
tailingIcon?: string | StaticImageData
disabled?: boolean
leadingIcon?: string | StaticImageData
wrapperClass?: string
onClickIcon?: () => void
onChangeData?: (value: FormValueType) => void
maxLength?: number
ref?: LegacyRef<HTMLInputElement>
helperText?: string
placeholder?: string
inputRegex?: RegExp | string
}
export interface CustomWheelProps {
selected: number
type: CustomWheelType
data: string[]
onChange: (type: CustomWheelType, position: number) => void
}
export interface DatePickerProps {
minDate?: Date
maxDate?: Date
selDate: Date | null
type: DateTimePickerType
onSelectDate?: (date: Date) => void
onCancel?: () => void
}
export interface TextFieldCalendarProps extends TextFieldProps {
closable?: boolean
dateFormat?: string
startDate?: string | number | Date
endDate?: string | number | Date
pickerType?: DateTimePickerType
}
export interface IDatePickerProps extends TextFieldProps {
startDate?: Date
endDate?: Date
dateFormat?: string
minDate?: Date | string
maxDate?: Date | string
}
export interface TextAreaProps extends FormElementProps, InputHTMLAttributes<HTMLTextAreaElement> {
onChangeData: (value: FormValueType) => void
}
export type FileType =
| "image/apng"
| "image/bmp"
| "image/gif"
| "image/jpeg"
| "image/pjpeg"
| "image/png"
| "image/svg+xml"
| "image/tiff"
| "image/webp"
| "image/x-icon"
| "video/mp4"
| "video/x-m4v"
| "video/*"
| "application/pdf"
| "image/*"
| "youtube/*"
export interface FileUploadProps {
wrapperClass?: string
children?: ReactNode
isMultiple?: boolean
fileType?: FileType | FileType[]
name?: string
maxSize?: number
onChangeData?: (file: FormValueType, selIndex?: number) => void
error?: string
imageUrl?: string | string[]
inputClassName?: string
disabled?: boolean
}
export interface IEditFileProps {
disabled: boolean
}
export interface TableHeaderProps {
title: string
rowKey: string
className?: string
}
export interface TableProps<T> {
tableItems: T[]
tableHeaders: TableHeaderProps[]
maxItems?: number | null
wrapperClass?: string
isLoading?: boolean
}
export interface CarouselProps {
children: ReactNode
webItems?: number
mobItems?: number
showButton?: boolean
showDots?: boolean
dotClass?: string
itemClass?: string
containerClass?: string
slideClass?: string
autoPlay?: boolean
isSwipe?: boolean
slideItems?: number
}
export interface TabProps {
isChip?: boolean
tabs: IFormData[]
selIndex?: number
onClickTab?: (index: number, item: IFormData) => void
wrapperClass?: string
}
export interface ITabStyle {
isChip: boolean
}
export interface VideoProps {
url: string
type?: string
}
export interface MediaPreviewProps {
url: string
mime: MimeType
onClickClose?: () => void
}
export interface MediaProps extends MediaPreviewProps {
wrapperClass?: string
onClick?: () => void
}
export interface FormFooterProps {
primaryButtonText: string
onSubmit: (event?: FormEvent<HTMLFormElement>) => void
secondaryButtonText?: string
children?: ReactNode
wrapperClass?: string
onCancel?: () => void
footerWrapperClass?: string
}
export interface IProfileCardProps {
name?: string
email: string
elementRef: MutableRefObject<HTMLElement | null>
onClickProfile?: () => void
onClickLogout: () => void
onToggle: (show: boolean) => void
}
export interface GroupFormItemProps extends FileUploadProps {
elementType?: ElementType
label?: string
error?: string
helperText?: string
value?: FormValueType
name?: string
radioGroupName?: string
maxLength?: number
options?: DropdownType[]
option?: IFormData
type?: string
inputRegex?: RegExp | string
disabled?: boolean
wrapperClass?: string
pickerType?: DateTimePickerType
dateFormat?: string
childTop?: ReactNode
childBottom?: ReactNode
isRequired?: boolean
childElement?: ReactNode
startDate?: Date | string
endDate?: Date | string
maxCount?: number
onChangeValue?: (data: JSONObject, selIndex?: number) => void
}
export interface FormSectionProps {
title?: string
description?: string
childElements?: GroupFormItemProps[]
children?: ReactNode
wrapperClassGrid?: string
wrapperClass?: string
}
export interface GroupFormProps {
wrapperClass?: string
formSections: FormSectionProps | FormSectionProps[]
}
export interface ProfileUploadProps {
disabled?: boolean
wrapperClass?: string
onChangeData: (data: FormValueType) => void
value?: IFile
name?: string
}
export interface WheelPickerProps {
animation?: WheelPickerAnimation
items: string[]
selected: number
type: CustomWheelType
onChange: (type: CustomWheelType, position: number) => void
}
export interface WheelPickerStyleProps {
containerHeight: string
itemHeight: string
dynamicSpace: string
}
export interface MapViewProps {
decodedAddress?: IDecodedAddress
onConfirm: (addressData: IDecodedAddress) => void
}