tw-react-components 0.0.132

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (78) hide show
  1. package/LICENCE +21 -0
  2. package/README.md +3 -0
  3. package/index.cjs.d.ts +1 -0
  4. package/index.cjs.default.js +1 -0
  5. package/index.cjs.js +1881 -0
  6. package/index.cjs.mjs +2 -0
  7. package/index.esm.d.ts +1 -0
  8. package/index.esm.js +1790 -0
  9. package/package.json +32 -0
  10. package/src/components/Badge/index.d.ts +9 -0
  11. package/src/components/Block/index.d.ts +15 -0
  12. package/src/components/Button/index.d.ts +20 -0
  13. package/src/components/Card/index.d.ts +8 -0
  14. package/src/components/DataTable/index.d.ts +68 -0
  15. package/src/components/Dialog/ConfirmDialog.d.ts +11 -0
  16. package/src/components/Dialog/Dialog.d.ts +21 -0
  17. package/src/components/Dialog/FormDialog.d.ts +16 -0
  18. package/src/components/Dialog/ListSorterDialog.d.ts +12 -0
  19. package/src/components/Dialog/PdfViewerDialog.d.ts +10 -0
  20. package/src/components/Dialog/index.d.ts +5 -0
  21. package/src/components/DropdownMenu/index.d.ts +31 -0
  22. package/src/components/Flex/index.d.ts +25 -0
  23. package/src/components/Form/controls/FormGroup.d.ts +6 -0
  24. package/src/components/Form/controls/Label.d.ts +10 -0
  25. package/src/components/Form/controls/custom/date-time/DateSelector.d.ts +14 -0
  26. package/src/components/Form/controls/custom/date-time/DaysView.d.ts +13 -0
  27. package/src/components/Form/controls/custom/date-time/MonthsView.d.ts +12 -0
  28. package/src/components/Form/controls/custom/date-time/TimeSelector.d.ts +10 -0
  29. package/src/components/Form/controls/custom/date-time/YearsView.d.ts +11 -0
  30. package/src/components/Form/controls/custom/date-time/index.d.ts +27 -0
  31. package/src/components/Form/controls/custom/index.d.ts +2 -0
  32. package/src/components/Form/controls/custom/select/index.d.ts +38 -0
  33. package/src/components/Form/controls/index.d.ts +5 -0
  34. package/src/components/Form/controls/primitive/BasicInput.d.ts +37 -0
  35. package/src/components/Form/controls/primitive/CheckBoxInput.d.ts +4 -0
  36. package/src/components/Form/controls/primitive/EmailInput.d.ts +4 -0
  37. package/src/components/Form/controls/primitive/NumberInput.d.ts +4 -0
  38. package/src/components/Form/controls/primitive/PasswordInput.d.ts +4 -0
  39. package/src/components/Form/controls/primitive/TextInput.d.ts +4 -0
  40. package/src/components/Form/controls/primitive/TextareaInput.d.ts +4 -0
  41. package/src/components/Form/controls/primitive/index.d.ts +7 -0
  42. package/src/components/Form/controls/with-form.d.ts +51 -0
  43. package/src/components/Form/index.d.ts +1 -0
  44. package/src/components/Hint/index.d.ts +24 -0
  45. package/src/components/Layout/index.d.ts +10 -0
  46. package/src/components/List/index.d.ts +22 -0
  47. package/src/components/ListSorter/index.d.ts +11 -0
  48. package/src/components/Navbar/index.d.ts +6 -0
  49. package/src/components/Pagination/index.d.ts +9 -0
  50. package/src/components/Popover/index.d.ts +8 -0
  51. package/src/components/Sidebar/SidebarItem.d.ts +10 -0
  52. package/src/components/Sidebar/index.d.ts +26 -0
  53. package/src/components/Spinner/index.d.ts +7 -0
  54. package/src/components/Switch/index.d.ts +4 -0
  55. package/src/components/Table/index.d.ts +9 -0
  56. package/src/components/Tabs/index.d.ts +7 -0
  57. package/src/components/ThemeSwitcher/index.d.ts +6 -0
  58. package/src/components/Tooltip/index.d.ts +9 -0
  59. package/src/components/index.d.ts +24 -0
  60. package/src/components/types.d.ts +19 -0
  61. package/src/contexts/LayoutContext.d.ts +13 -0
  62. package/src/contexts/index.d.ts +1 -0
  63. package/src/helpers/cn.d.ts +2 -0
  64. package/src/helpers/compareDates.d.ts +2 -0
  65. package/src/helpers/generalComparator.d.ts +1 -0
  66. package/src/helpers/getDisplayDate.d.ts +1 -0
  67. package/src/helpers/index.d.ts +7 -0
  68. package/src/helpers/isEmpty.d.ts +1 -0
  69. package/src/helpers/mergeRefs.d.ts +2 -0
  70. package/src/helpers/resolveTargetObject.d.ts +1 -0
  71. package/src/hooks/index.d.ts +6 -0
  72. package/src/hooks/useDays.d.ts +5 -0
  73. package/src/hooks/useLongPress.d.ts +7 -0
  74. package/src/hooks/useMonths.d.ts +5 -0
  75. package/src/hooks/useOnSwipe.d.ts +4 -0
  76. package/src/hooks/useOutsideClick.d.ts +2 -0
  77. package/src/hooks/usePagination.d.ts +1 -0
  78. package/src/index.d.ts +4 -0
package/package.json ADDED
@@ -0,0 +1,32 @@
1
+ {
2
+ "name": "tw-react-components",
3
+ "description": "A set of React components build with TailwindCSS to make a nice dashboard.",
4
+ "version": "0.0.132",
5
+ "license": "MIT",
6
+ "homepage": "https://bacali95.github.io/tw-react-components",
7
+ "author": {
8
+ "name": "Nasreddine Bac Ali",
9
+ "email": "nasreddine.bacali95@gmail.com",
10
+ "url": "https://github.com/bacali95"
11
+ },
12
+ "repository": {
13
+ "type": "git",
14
+ "url": "git+https://github.com/bacali95/tw-react-components.git"
15
+ },
16
+ "bugs": {
17
+ "url": "https://github.com/bacali95/tw-react-components/issues"
18
+ },
19
+ "exports": {
20
+ ".": {
21
+ "module": "./index.esm.js",
22
+ "import": "./index.cjs.mjs",
23
+ "default": "./index.cjs.js"
24
+ },
25
+ "./tailwindcss-plugin.cjs": {
26
+ "default": "./tailwindcss-plugin.cjs"
27
+ },
28
+ "./package.json": "./package.json"
29
+ },
30
+ "module": "./index.esm.js",
31
+ "main": "./index.cjs.js"
32
+ }
@@ -0,0 +1,9 @@
1
+ /// <reference types="react" />
2
+ import { ButtonProps, ButtonVariant } from '../Button';
3
+ export type BadgeVariant = Exclude<ButtonVariant, 'text'>;
4
+ export type BadgeProps = Omit<ButtonProps, 'variant'> & {
5
+ variant?: BadgeVariant;
6
+ };
7
+ export declare const Badge: import("react").ForwardRefExoticComponent<Omit<ButtonProps, "variant"> & {
8
+ variant?: BadgeVariant | undefined;
9
+ } & import("react").RefAttributes<HTMLButtonElement>>;
@@ -0,0 +1,15 @@
1
+ import { ComponentProps, PropsWithoutRef } from 'react';
2
+ export type BlockProps = PropsWithoutRef<ComponentProps<'div'> & {
3
+ className?: string;
4
+ centered?: boolean;
5
+ container?: boolean;
6
+ fullWidth?: boolean;
7
+ fullHeight?: boolean;
8
+ }>;
9
+ export declare const Block: import("react").ForwardRefExoticComponent<Omit<import("react").ClassAttributes<HTMLDivElement> & import("react").HTMLAttributes<HTMLDivElement> & {
10
+ className?: string | undefined;
11
+ centered?: boolean | undefined;
12
+ container?: boolean | undefined;
13
+ fullWidth?: boolean | undefined;
14
+ fullHeight?: boolean | undefined;
15
+ }, "ref"> & import("react").RefAttributes<HTMLDivElement>>;
@@ -0,0 +1,20 @@
1
+ import { LucideIcon } from 'lucide-react';
2
+ import { ComponentProps, PropsWithoutRef } from 'react';
3
+ import { Color, Size } from '../types';
4
+ export type ButtonVariant = 'filled' | 'outlined' | 'text';
5
+ export type ButtonProps = PropsWithoutRef<ComponentProps<'button'>> & {
6
+ size?: Size;
7
+ color?: Color;
8
+ variant?: ButtonVariant;
9
+ rounded?: boolean;
10
+ prefixIcon?: LucideIcon;
11
+ suffixIcon?: LucideIcon;
12
+ };
13
+ export declare const Button: import("react").ForwardRefExoticComponent<Omit<import("react").DetailedHTMLProps<import("react").ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, "ref"> & {
14
+ size?: Size | undefined;
15
+ color?: Color | undefined;
16
+ variant?: ButtonVariant | undefined;
17
+ rounded?: boolean | undefined;
18
+ prefixIcon?: LucideIcon | undefined;
19
+ suffixIcon?: LucideIcon | undefined;
20
+ } & import("react").RefAttributes<HTMLButtonElement>>;
@@ -0,0 +1,8 @@
1
+ /// <reference types="react" />
2
+ export declare const Card: import("react").ForwardRefExoticComponent<Omit<import("react").ClassAttributes<HTMLDivElement> & import("react").HTMLAttributes<HTMLDivElement> & {
3
+ className?: string | undefined;
4
+ centered?: boolean | undefined;
5
+ container?: boolean | undefined;
6
+ fullWidth?: boolean | undefined;
7
+ fullHeight?: boolean | undefined;
8
+ }, "ref"> & import("react").RefAttributes<HTMLDivElement>>;
@@ -0,0 +1,68 @@
1
+ import { LucideIcon } from 'lucide-react';
2
+ import { ComponentProps, FC, ReactNode } from 'react';
3
+ import { HintBadgeProps, HintDotProps } from '../Hint';
4
+ import { PaginationProps } from '../Pagination';
5
+ import { Color, Paths, ResolvePath } from '../types';
6
+ export type DataTableColumn<T, Field extends Paths<T> = Paths<T>> = {
7
+ className?: string;
8
+ header: ReactNode;
9
+ field: Field;
10
+ noSorting?: boolean;
11
+ hide?: boolean;
12
+ align?: ComponentProps<'td'>['align'];
13
+ render?: (item: T, rowIndex: number) => ReactNode;
14
+ comparator?: (a: ResolvePath<T, Field>, b: ResolvePath<T, Field>) => number;
15
+ };
16
+ export type DataTableColumns<T> = Partial<{
17
+ [Field in Paths<T>]: DataTableColumn<T, Field>;
18
+ }>;
19
+ export type DataTableSorting<T, Field extends Paths<T> = Paths<T>> = {
20
+ field: Field;
21
+ direction: 'asc' | 'desc';
22
+ comparator: (a: ResolvePath<T, Field>, b: ResolvePath<T, Field>) => number;
23
+ };
24
+ export type DataTableRowExtraContent<T> = {
25
+ idGetter: (item: T) => number;
26
+ singleExpansion?: boolean;
27
+ component: FC<{
28
+ item: T;
29
+ rowIndex: number;
30
+ }>;
31
+ };
32
+ declare const possiblePageSize: readonly [5, 10, 25, 50, 100, 500, 1000];
33
+ export type DataTablePageSize = (typeof possiblePageSize)[number];
34
+ export type DataTableAction<T> = {
35
+ icon: LucideIcon;
36
+ label?: string;
37
+ hasNotification?: (item: T, rowIndex: number) => {
38
+ type: 'badge';
39
+ props: HintBadgeProps;
40
+ } | {
41
+ type: 'dot';
42
+ props: HintDotProps;
43
+ } | boolean;
44
+ color?: Color;
45
+ hide?: boolean | ((item: T) => boolean);
46
+ onClick: (item: T, rowIndex: number) => void;
47
+ };
48
+ export type DataTableProps<T> = {
49
+ className?: string;
50
+ rows: T[];
51
+ columns: DataTableColumn<T>[] | DataTableColumns<T>;
52
+ sorting?: {
53
+ sorting: DataTableSorting<T> | undefined;
54
+ onSortingChange: (sorting: DataTableSorting<T>) => void;
55
+ };
56
+ pagination?: PaginationProps & {
57
+ pageSize?: DataTablePageSize;
58
+ onPageSizeChange?: (pageSize: DataTablePageSize) => void;
59
+ };
60
+ actions?: DataTableAction<T>[];
61
+ isLoading?: boolean;
62
+ rowExtraContent?: DataTableRowExtraContent<T>;
63
+ noDataMessage?: ReactNode;
64
+ onRowClick?: DataTableAction<T>['onClick'];
65
+ rowClassName?: (item: T, rowIndex: number) => string | undefined;
66
+ };
67
+ export declare function DataTable<T>({ className, columns, rows, sorting, pagination, actions, isLoading, rowExtraContent, noDataMessage, onRowClick, rowClassName, }: DataTableProps<T>): import("react/jsx-runtime").JSX.Element;
68
+ export {};
@@ -0,0 +1,11 @@
1
+ import { FC, PropsWithChildren, ReactNode } from 'react';
2
+ type Props = {
3
+ open: boolean;
4
+ title: ReactNode;
5
+ yesLabel?: string;
6
+ noLabel?: string;
7
+ onConfirm: () => void;
8
+ onClose: () => void;
9
+ };
10
+ export declare const ConfirmDialog: FC<PropsWithChildren<Props>>;
11
+ export {};
@@ -0,0 +1,21 @@
1
+ import * as DialogPrimitive from '@radix-ui/react-dialog';
2
+ import { HTMLAttributes } from 'react';
3
+ export declare const Dialog: import("react").FC<DialogPrimitive.DialogProps> & {
4
+ Portal: import("react").FC<DialogPrimitive.DialogPortalProps>;
5
+ Overlay: import("react").ForwardRefExoticComponent<Omit<DialogPrimitive.DialogOverlayProps & import("react").RefAttributes<HTMLDivElement>, "ref"> & import("react").RefAttributes<HTMLDivElement>>;
6
+ Close: import("react").ForwardRefExoticComponent<DialogPrimitive.DialogCloseProps & import("react").RefAttributes<HTMLButtonElement>>;
7
+ Trigger: import("react").ForwardRefExoticComponent<DialogPrimitive.DialogTriggerProps & import("react").RefAttributes<HTMLButtonElement>>;
8
+ Content: import("react").ForwardRefExoticComponent<Omit<DialogPrimitive.DialogContentProps & import("react").RefAttributes<HTMLDivElement>, "ref"> & {
9
+ fullScreen?: boolean | undefined;
10
+ } & import("react").RefAttributes<HTMLDivElement>>;
11
+ Header: {
12
+ ({ className, ...props }: HTMLAttributes<HTMLDivElement>): import("react/jsx-runtime").JSX.Element;
13
+ displayName: string;
14
+ };
15
+ Footer: {
16
+ ({ className, ...props }: HTMLAttributes<HTMLDivElement>): import("react/jsx-runtime").JSX.Element;
17
+ displayName: string;
18
+ };
19
+ Title: import("react").ForwardRefExoticComponent<Omit<DialogPrimitive.DialogTitleProps & import("react").RefAttributes<HTMLHeadingElement>, "ref"> & import("react").RefAttributes<HTMLHeadingElement>>;
20
+ Description: import("react").ForwardRefExoticComponent<Omit<DialogPrimitive.DialogDescriptionProps & import("react").RefAttributes<HTMLParagraphElement>, "ref"> & import("react").RefAttributes<HTMLParagraphElement>>;
21
+ };
@@ -0,0 +1,16 @@
1
+ import { PropsWithChildren, ReactNode } from 'react';
2
+ import { FieldValues, SubmitErrorHandler, SubmitHandler, UseFormReturn } from 'react-hook-form';
3
+ type Props<T extends FieldValues> = {
4
+ className?: string;
5
+ open: boolean;
6
+ title: ReactNode;
7
+ form: UseFormReturn<T>;
8
+ submitLabel?: string;
9
+ cancelLabel?: string;
10
+ extraAction?: ReactNode;
11
+ onSubmit: SubmitHandler<T>;
12
+ onInvalid?: SubmitErrorHandler<T>;
13
+ onClose: () => void;
14
+ };
15
+ export declare const FormDialog: <T extends FieldValues>({ className, open, title, form, children, submitLabel, cancelLabel, extraAction, onSubmit, onInvalid, onClose, }: PropsWithChildren<Props<T>>) => import("react/jsx-runtime").JSX.Element;
16
+ export {};
@@ -0,0 +1,12 @@
1
+ import { ListSorterItem, ListSorterProps } from '../ListSorter';
2
+ export type ListSorterDialogProps<T extends ListSorterItem> = {
3
+ className?: string;
4
+ open: boolean;
5
+ title: string;
6
+ onClose: () => void;
7
+ } & Omit<ListSorterProps<T>, 'onChange'> & {
8
+ cancelLabel?: string;
9
+ submitLabel?: string;
10
+ onSubmit: (items: T[]) => void;
11
+ };
12
+ export declare function ListSorterDialog<T extends ListSorterItem>({ className, open, title, items, idResolver, renderer, cancelLabel, submitLabel, onSubmit, onClose, }: ListSorterDialogProps<T>): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,10 @@
1
+ import { FC, ReactNode } from 'react';
2
+ type Props = {
3
+ open: boolean;
4
+ title: ReactNode;
5
+ url?: string;
6
+ data?: string;
7
+ onClose: () => void;
8
+ };
9
+ export declare const PdfViewerDialog: FC<Props>;
10
+ export {};
@@ -0,0 +1,5 @@
1
+ export * from './ConfirmDialog';
2
+ export * from './Dialog';
3
+ export * from './FormDialog';
4
+ export * from './ListSorterDialog';
5
+ export * from './PdfViewerDialog';
@@ -0,0 +1,31 @@
1
+ import * as DropdownMenuPrimitive from '@radix-ui/react-dropdown-menu';
2
+ import { HTMLAttributes } from 'react';
3
+ export declare const DropdownMenu: import("react").FC<DropdownMenuPrimitive.DropdownMenuProps> & {
4
+ Trigger: import("react").ForwardRefExoticComponent<DropdownMenuPrimitive.DropdownMenuTriggerProps & import("react").RefAttributes<HTMLButtonElement>>;
5
+ Content: import("react").ForwardRefExoticComponent<Omit<DropdownMenuPrimitive.DropdownMenuContentProps & import("react").RefAttributes<HTMLDivElement>, "ref"> & import("react").RefAttributes<HTMLDivElement>>;
6
+ Item: import("react").ForwardRefExoticComponent<Omit<DropdownMenuPrimitive.DropdownMenuItemProps & import("react").RefAttributes<HTMLDivElement>, "ref"> & {
7
+ inset?: boolean | undefined;
8
+ } & import("react").RefAttributes<HTMLDivElement>>;
9
+ CheckboxItem: import("react").ForwardRefExoticComponent<Omit<DropdownMenuPrimitive.DropdownMenuCheckboxItemProps & import("react").RefAttributes<HTMLDivElement>, "ref"> & import("react").RefAttributes<HTMLDivElement>>;
10
+ RadioItem: import("react").ForwardRefExoticComponent<Omit<DropdownMenuPrimitive.DropdownMenuRadioItemProps & import("react").RefAttributes<HTMLDivElement>, "ref"> & import("react").RefAttributes<HTMLDivElement>>;
11
+ Label: import("react").ForwardRefExoticComponent<Omit<DropdownMenuPrimitive.DropdownMenuLabelProps & import("react").RefAttributes<HTMLDivElement>, "ref"> & {
12
+ inset?: boolean | undefined;
13
+ } & import("react").RefAttributes<HTMLDivElement>>;
14
+ Separator: import("react").ForwardRefExoticComponent<Omit<DropdownMenuPrimitive.DropdownMenuSeparatorProps & import("react").RefAttributes<HTMLDivElement>, "ref"> & import("react").RefAttributes<HTMLDivElement>>;
15
+ Icon: import("react").ForwardRefExoticComponent<{
16
+ className?: string | undefined;
17
+ icon: import("lucide-react").LucideIcon;
18
+ } & import("react").RefAttributes<SVGSVGElement>>;
19
+ Shortcut: {
20
+ ({ className, ...props }: HTMLAttributes<HTMLSpanElement>): import("react/jsx-runtime").JSX.Element;
21
+ displayName: string;
22
+ };
23
+ Group: import("react").ForwardRefExoticComponent<DropdownMenuPrimitive.DropdownMenuGroupProps & import("react").RefAttributes<HTMLDivElement>>;
24
+ Portal: import("react").FC<DropdownMenuPrimitive.DropdownMenuPortalProps>;
25
+ Sub: import("react").FC<DropdownMenuPrimitive.DropdownMenuSubProps>;
26
+ SubContent: import("react").ForwardRefExoticComponent<Omit<DropdownMenuPrimitive.DropdownMenuSubContentProps & import("react").RefAttributes<HTMLDivElement>, "ref"> & import("react").RefAttributes<HTMLDivElement>>;
27
+ SubTrigger: import("react").ForwardRefExoticComponent<Omit<DropdownMenuPrimitive.DropdownMenuSubTriggerProps & import("react").RefAttributes<HTMLDivElement>, "ref"> & {
28
+ inset?: boolean | undefined;
29
+ } & import("react").RefAttributes<HTMLDivElement>>;
30
+ RadioGroup: import("react").ForwardRefExoticComponent<DropdownMenuPrimitive.DropdownMenuRadioGroupProps & import("react").RefAttributes<HTMLDivElement>>;
31
+ };
@@ -0,0 +1,25 @@
1
+ /// <reference types="react" />
2
+ import { BlockProps } from '../Block';
3
+ type Direction = 'row' | 'column';
4
+ type Position = 'start' | 'center' | 'end';
5
+ export type FlexProps = BlockProps & {
6
+ reverse?: boolean;
7
+ wrap?: boolean;
8
+ direction?: Direction;
9
+ align?: Position;
10
+ justify?: Position | 'between';
11
+ };
12
+ export declare const Flex: import("react").ForwardRefExoticComponent<Omit<import("react").ClassAttributes<HTMLDivElement> & import("react").HTMLAttributes<HTMLDivElement> & {
13
+ className?: string | undefined;
14
+ centered?: boolean | undefined;
15
+ container?: boolean | undefined;
16
+ fullWidth?: boolean | undefined;
17
+ fullHeight?: boolean | undefined;
18
+ }, "ref"> & {
19
+ reverse?: boolean | undefined;
20
+ wrap?: boolean | undefined;
21
+ direction?: Direction | undefined;
22
+ align?: Position | undefined;
23
+ justify?: Position | "between" | undefined;
24
+ } & import("react").RefAttributes<HTMLDivElement>>;
25
+ export {};
@@ -0,0 +1,6 @@
1
+ import { FC, PropsWithChildren } from 'react';
2
+ export type FormGroupProps = PropsWithChildren<{
3
+ className?: string;
4
+ label: string;
5
+ }>;
6
+ export declare const FormGroup: FC<FormGroupProps>;
@@ -0,0 +1,10 @@
1
+ import { FC, PropsWithChildren, ReactNode } from 'react';
2
+ type Props = {
3
+ className?: string;
4
+ description?: ReactNode;
5
+ required?: boolean;
6
+ hasErrors?: boolean;
7
+ htmlFor?: string;
8
+ };
9
+ export declare const Label: FC<PropsWithChildren<Props>>;
10
+ export {};
@@ -0,0 +1,14 @@
1
+ import { FC } from 'react';
2
+ export type View = 'days' | 'months' | 'years';
3
+ type DateSelectorProps = {
4
+ date: Date;
5
+ value?: string | Date | null;
6
+ minDate?: Date;
7
+ maxDate?: Date;
8
+ locale?: string;
9
+ calendarView: View;
10
+ setCalendarView: (view: View) => void;
11
+ setNewDate: (date: Date) => void;
12
+ };
13
+ export declare const DateSelector: FC<DateSelectorProps>;
14
+ export {};
@@ -0,0 +1,13 @@
1
+ import { FC } from 'react';
2
+ type DaysViewProps = {
3
+ date: Date;
4
+ value?: string | Date | null;
5
+ month: number;
6
+ year: number;
7
+ minDate?: Date;
8
+ maxDate?: Date;
9
+ locale?: string;
10
+ setNewDate: (date: Date) => void;
11
+ };
12
+ export declare const DaysView: FC<DaysViewProps>;
13
+ export {};
@@ -0,0 +1,12 @@
1
+ import { FC } from 'react';
2
+ type MonthsViewProps = {
3
+ date: Date;
4
+ value?: string | Date | null;
5
+ year: number;
6
+ minDate?: Date;
7
+ maxDate?: Date;
8
+ locale?: string;
9
+ selectMonth: (month: number) => () => void;
10
+ };
11
+ export declare const MonthsView: FC<MonthsViewProps>;
12
+ export {};
@@ -0,0 +1,10 @@
1
+ import { FC } from 'react';
2
+ type TimeSelectorProps = {
3
+ date: Date;
4
+ step?: number;
5
+ minDate?: Date;
6
+ maxDate?: Date;
7
+ setNewDate: (date: Date) => void;
8
+ };
9
+ export declare const TimeSelector: FC<TimeSelectorProps>;
10
+ export {};
@@ -0,0 +1,11 @@
1
+ import { FC } from 'react';
2
+ type YearsViewProps = {
3
+ date: Date;
4
+ value?: string | Date | null;
5
+ years: number[];
6
+ minDate?: Date;
7
+ maxDate?: Date;
8
+ selectYear: (month: number) => () => void;
9
+ };
10
+ export declare const YearsView: FC<YearsViewProps>;
11
+ export {};
@@ -0,0 +1,27 @@
1
+ /// <reference types="react" />
2
+ import { BasicInputProps } from '../../primitive';
3
+ export type DateTimeInputType = 'date' | 'time' | 'datetime-local';
4
+ export type DateTimeInputProps = {
5
+ value?: string | Date | null;
6
+ type?: DateTimeInputType;
7
+ hasErrors?: boolean;
8
+ clearable?: boolean;
9
+ step?: number;
10
+ minDate?: Date;
11
+ maxDate?: Date;
12
+ displayFormat?: string;
13
+ displayLocale?: string;
14
+ onChange?: (date?: Date | null) => void;
15
+ } & Pick<BasicInputProps<'text'>, 'className' | 'inputClassName' | 'extensionClassName' | 'label' | 'name' | 'description' | 'placeholder' | 'required' | 'disabled' | 'onBlur' | 'size' | 'readOnly'>;
16
+ export declare const DateTimeInput: import("react").ForwardRefExoticComponent<{
17
+ value?: string | Date | null | undefined;
18
+ type?: DateTimeInputType | undefined;
19
+ hasErrors?: boolean | undefined;
20
+ clearable?: boolean | undefined;
21
+ step?: number | undefined;
22
+ minDate?: Date | undefined;
23
+ maxDate?: Date | undefined;
24
+ displayFormat?: string | undefined;
25
+ displayLocale?: string | undefined;
26
+ onChange?: ((date?: Date | null) => void) | undefined;
27
+ } & Pick<BasicInputProps<"text">, "size" | "label" | "disabled" | "name" | "placeholder" | "readOnly" | "required" | "className" | "onBlur" | "inputClassName" | "extensionClassName" | "description"> & import("react").RefAttributes<HTMLDivElement>>;
@@ -0,0 +1,2 @@
1
+ export * from './date-time';
2
+ export * from './select';
@@ -0,0 +1,38 @@
1
+ import { ForwardedRef, JSX, ReactNode, RefObject } from 'react';
2
+ import { BasicInputProps } from '../../primitive';
3
+ export type SelectInputType = 'select';
4
+ export type SelectItem<T, Group extends boolean = false> = {
5
+ id: string | number;
6
+ label: string;
7
+ } & (Group extends false ? {
8
+ group?: false;
9
+ value: T;
10
+ } : {
11
+ group: true;
12
+ value?: never;
13
+ items: SelectItem<T>[];
14
+ });
15
+ export type SelectInputProps<T = any> = {
16
+ items: SelectItem<T, boolean>[];
17
+ renderItem?: (item: SelectItem<T>, selected?: boolean) => ReactNode;
18
+ clearable?: boolean;
19
+ allowAddition?: boolean;
20
+ onNewItemAdded?: (value: string) => void;
21
+ search?: boolean;
22
+ searchPredicate?: (item: SelectItem<T>, searchValue: string) => boolean;
23
+ selectPredicate?: (a: T, b: T) => boolean;
24
+ parentRef?: RefObject<HTMLDivElement>;
25
+ } & ({
26
+ multiple?: false;
27
+ value?: T | null;
28
+ onChange?: (item?: T) => void;
29
+ } | {
30
+ multiple: true;
31
+ value: T[];
32
+ onChange?: (item?: T[]) => void;
33
+ }) & Pick<BasicInputProps<'text'>, 'className' | 'inputClassName' | 'extensionClassName' | 'name' | 'label' | 'size' | 'placeholder' | 'required' | 'hasErrors' | 'disabled' | 'readOnly'>;
34
+ export declare const SelectInput: (<T>(props: SelectInputProps<T> & {
35
+ ref?: ForwardedRef<HTMLDivElement>;
36
+ }) => JSX.Element) & {
37
+ readonly $$typeof: symbol;
38
+ };
@@ -0,0 +1,5 @@
1
+ export * from './custom';
2
+ export * from './primitive';
3
+ export * from './FormGroup';
4
+ export * from './Label';
5
+ export * from './with-form';
@@ -0,0 +1,37 @@
1
+ import { LucideIcon } from 'lucide-react';
2
+ import { ComponentProps, FC, MouseEvent, PropsWithChildren, ReactNode } from 'react';
3
+ import { Size } from '../../../types';
4
+ export type InputType = ComponentProps<'input'>['type'] | 'textarea';
5
+ export type BasicInputProps<Type extends InputType> = {
6
+ inputClassName?: string;
7
+ extensionClassName?: string;
8
+ type?: Type;
9
+ label?: string;
10
+ description?: ReactNode;
11
+ size?: Size;
12
+ hasErrors?: boolean;
13
+ clearable?: boolean;
14
+ suffixIcon?: LucideIcon;
15
+ onClear?: () => void;
16
+ onSuffixIconClick?: (event: MouseEvent<HTMLDivElement>) => void;
17
+ } & Omit<Type extends 'textarea' ? ComponentProps<'textarea'> : ComponentProps<'input'>, 'id' | 'ref' | 'size'>;
18
+ export declare const BasicInput: import("react").ForwardRefExoticComponent<{
19
+ inputClassName?: string | undefined;
20
+ extensionClassName?: string | undefined;
21
+ type?: InputType;
22
+ label?: string | undefined;
23
+ description?: ReactNode;
24
+ size?: Size | undefined;
25
+ hasErrors?: boolean | undefined;
26
+ clearable?: boolean | undefined;
27
+ suffixIcon?: LucideIcon | undefined;
28
+ onClear?: (() => void) | undefined;
29
+ onSuffixIconClick?: ((event: MouseEvent<HTMLDivElement>) => void) | undefined;
30
+ } & Omit<import("react").DetailedHTMLProps<import("react").InputHTMLAttributes<HTMLInputElement>, HTMLInputElement> | import("react").DetailedHTMLProps<import("react").TextareaHTMLAttributes<HTMLTextAreaElement>, HTMLTextAreaElement>, "id" | "ref" | "size"> & import("react").RefAttributes<HTMLInputElement | HTMLTextAreaElement>>;
31
+ export declare const BasicInputExtension: FC<PropsWithChildren<{
32
+ className?: string;
33
+ size: Size;
34
+ hasErrors?: boolean;
35
+ disabled?: boolean;
36
+ onClick?: (event: MouseEvent<HTMLDivElement>) => void;
37
+ }>>;
@@ -0,0 +1,4 @@
1
+ /// <reference types="react" />
2
+ import { BasicInputProps } from './BasicInput';
3
+ export type CheckboxInputProps = Omit<BasicInputProps<'checkbox'>, 'type'>;
4
+ export declare const CheckboxInput: import("react").ForwardRefExoticComponent<CheckboxInputProps & import("react").RefAttributes<HTMLInputElement>>;
@@ -0,0 +1,4 @@
1
+ /// <reference types="react" />
2
+ import { BasicInputProps } from './BasicInput';
3
+ export type EmailInputProps = Omit<BasicInputProps<'email'>, 'type'>;
4
+ export declare const EmailInput: import("react").ForwardRefExoticComponent<EmailInputProps & import("react").RefAttributes<HTMLInputElement>>;
@@ -0,0 +1,4 @@
1
+ /// <reference types="react" />
2
+ import { BasicInputProps } from './BasicInput';
3
+ export type NumberInputProps = Omit<BasicInputProps<'number'>, 'type'>;
4
+ export declare const NumberInput: import("react").ForwardRefExoticComponent<NumberInputProps & import("react").RefAttributes<HTMLInputElement>>;
@@ -0,0 +1,4 @@
1
+ /// <reference types="react" />
2
+ import { BasicInputProps } from './BasicInput';
3
+ export type PasswordInputProps = Omit<BasicInputProps<'number'>, 'type'>;
4
+ export declare const PasswordInput: import("react").ForwardRefExoticComponent<PasswordInputProps & import("react").RefAttributes<HTMLInputElement>>;
@@ -0,0 +1,4 @@
1
+ /// <reference types="react" />
2
+ import { BasicInputProps } from './BasicInput';
3
+ export type TextInputProps = Omit<BasicInputProps<'text'>, 'type'>;
4
+ export declare const TextInput: import("react").ForwardRefExoticComponent<TextInputProps & import("react").RefAttributes<HTMLInputElement>>;
@@ -0,0 +1,4 @@
1
+ /// <reference types="react" />
2
+ import { BasicInputProps } from './BasicInput';
3
+ export type TextareaInputProps = Omit<BasicInputProps<'textarea'>, 'type'>;
4
+ export declare const TextareaInput: import("react").ForwardRefExoticComponent<TextareaInputProps & import("react").RefAttributes<HTMLTextAreaElement>>;
@@ -0,0 +1,7 @@
1
+ export * from './BasicInput';
2
+ export * from './CheckBoxInput';
3
+ export * from './EmailInput';
4
+ export * from './NumberInput';
5
+ export * from './PasswordInput';
6
+ export * from './TextareaInput';
7
+ export * from './TextInput';
@@ -0,0 +1,51 @@
1
+ import { ForwardRefExoticComponent } from 'react';
2
+ import { ControllerRenderProps, Validate } from 'react-hook-form';
3
+ import { DateTimeInputProps, DateTimeInputType, SelectInputProps, SelectInputType } from './custom';
4
+ import { BasicInputProps, CheckboxInputProps, EmailInputProps, InputType, NumberInputProps, PasswordInputProps, TextInputProps, TextareaInputProps } from './primitive';
5
+ export type WithFormProps<Type extends InputType | SelectInputType, Props = Type extends DateTimeInputType ? DateTimeInputProps : Type extends SelectInputType ? SelectInputProps : Omit<BasicInputProps<Type>, 'type'>> = {
6
+ name: string;
7
+ pattern?: RegExp;
8
+ validate?: Type extends 'number' ? Validate<number, any> : Type extends DateTimeInputType ? Validate<Date, any> : Type extends SelectInputType ? Validate<any, any> : Validate<string, any>;
9
+ } & Omit<Props, 'pattern' | keyof Omit<ControllerRenderProps, 'disabled'>>;
10
+ export declare const FormInputs: {
11
+ Text: ForwardRefExoticComponent<{
12
+ name: string;
13
+ pattern?: RegExp | undefined;
14
+ validate?: Validate<string, any> | undefined;
15
+ } & Omit<TextInputProps, "pattern" | "ref" | "name" | "value" | "onChange" | "onBlur"> & import("react").RefAttributes<HTMLInputElement>>;
16
+ Email: ForwardRefExoticComponent<{
17
+ name: string;
18
+ pattern?: RegExp | undefined;
19
+ validate?: Validate<string, any> | undefined;
20
+ } & Omit<EmailInputProps, "pattern" | "ref" | "name" | "value" | "onChange" | "onBlur"> & import("react").RefAttributes<HTMLInputElement>>;
21
+ Password: ForwardRefExoticComponent<{
22
+ name: string;
23
+ pattern?: RegExp | undefined;
24
+ validate?: Validate<string, any> | undefined;
25
+ } & Omit<PasswordInputProps, "pattern" | "ref" | "name" | "value" | "onChange" | "onBlur"> & import("react").RefAttributes<HTMLInputElement>>;
26
+ Textarea: ForwardRefExoticComponent<{
27
+ name: string;
28
+ pattern?: RegExp | undefined;
29
+ validate?: Validate<string, any> | undefined;
30
+ } & Omit<TextareaInputProps, "pattern" | "ref" | "name" | "value" | "onChange" | "onBlur"> & import("react").RefAttributes<HTMLTextAreaElement>>;
31
+ Number: ForwardRefExoticComponent<{
32
+ name: string;
33
+ pattern?: RegExp | undefined;
34
+ validate?: Validate<number, any> | undefined;
35
+ } & Omit<NumberInputProps, "pattern" | "ref" | "name" | "value" | "onChange" | "onBlur"> & import("react").RefAttributes<HTMLInputElement>>;
36
+ Checkbox: ForwardRefExoticComponent<{
37
+ name: string;
38
+ pattern?: RegExp | undefined;
39
+ validate?: Validate<string, any> | undefined;
40
+ } & Omit<CheckboxInputProps, "pattern" | "ref" | "name" | "value" | "onChange" | "onBlur"> & import("react").RefAttributes<HTMLInputElement>>;
41
+ DateTime: ForwardRefExoticComponent<{
42
+ name: string;
43
+ pattern?: RegExp | undefined;
44
+ validate?: Validate<Date, any> | undefined;
45
+ } & Omit<DateTimeInputProps, "pattern" | "ref" | "name" | "value" | "onChange" | "onBlur"> & import("react").RefAttributes<HTMLDivElement>>;
46
+ Select: ForwardRefExoticComponent<{
47
+ name: string;
48
+ pattern?: RegExp | undefined;
49
+ validate?: Validate<any, any> | undefined;
50
+ } & Omit<SelectInputProps, "pattern" | "ref" | "name" | "value" | "onChange" | "onBlur"> & import("react").RefAttributes<HTMLInputElement>>;
51
+ };
@@ -0,0 +1 @@
1
+ export * from './controls';