@overdoser/react-toolkit 0.0.1
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.
- package/README.md +106 -0
- package/components/Button/Button.d.ts +17 -0
- package/components/Button/Button.stories.d.ts +17 -0
- package/components/Button/index.d.ts +2 -0
- package/components/Dropdown/Dropdown.d.ts +39 -0
- package/components/Dropdown/Dropdown.stories.d.ts +8 -0
- package/components/Dropdown/DropdownItem.d.ts +5 -0
- package/components/Dropdown/index.d.ts +4 -0
- package/components/Form/Form.d.ts +9 -0
- package/components/Form/Form.stories.d.ts +8 -0
- package/components/Form/FormField.d.ts +19 -0
- package/components/Form/index.d.ts +4 -0
- package/components/Link/Link.d.ts +6 -0
- package/components/Link/Link.stories.d.ts +9 -0
- package/components/Link/index.d.ts +2 -0
- package/components/List/List.d.ts +9 -0
- package/components/List/List.stories.d.ts +9 -0
- package/components/List/index.d.ts +2 -0
- package/components/Modal/Modal.d.ts +46 -0
- package/components/Modal/Modal.stories.d.ts +9 -0
- package/components/Modal/index.d.ts +2 -0
- package/components/Popover/Popover.d.ts +18 -0
- package/components/Popover/Popover.stories.d.ts +9 -0
- package/components/Popover/index.d.ts +2 -0
- package/components/Table/Table.d.ts +55 -0
- package/components/Table/Table.stories.d.ts +20 -0
- package/components/Table/index.d.ts +4 -0
- package/components/Table/useTableSort.d.ts +33 -0
- package/components/Typography/Typography.d.ts +12 -0
- package/components/Typography/Typography.stories.d.ts +15 -0
- package/components/Typography/index.d.ts +2 -0
- package/components/inputs/Checkbox/Checkbox.d.ts +12 -0
- package/components/inputs/Checkbox/Checkbox.stories.d.ts +9 -0
- package/components/inputs/Checkbox/index.d.ts +2 -0
- package/components/inputs/Input/Input.d.ts +15 -0
- package/components/inputs/Input/Input.stories.d.ts +13 -0
- package/components/inputs/Input/index.d.ts +2 -0
- package/components/inputs/Radio/Radio.d.ts +24 -0
- package/components/inputs/Radio/Radio.stories.d.ts +7 -0
- package/components/inputs/Radio/index.d.ts +2 -0
- package/components/inputs/Select/Select.d.ts +19 -0
- package/components/inputs/Select/Select.stories.d.ts +9 -0
- package/components/inputs/Select/index.d.ts +2 -0
- package/components/inputs/Textarea/Textarea.d.ts +7 -0
- package/components/inputs/Textarea/Textarea.stories.d.ts +10 -0
- package/components/inputs/Textarea/index.d.ts +2 -0
- package/hooks/useClickOutside.d.ts +14 -0
- package/hooks/useFocusTrap.d.ts +18 -0
- package/hooks/useKeyboard.d.ts +12 -0
- package/index.css +1 -0
- package/index.d.ts +32 -0
- package/index.js +1129 -0
- package/package.json +31 -0
- package/test-setup.d.ts +0 -0
package/README.md
ADDED
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
# @crk/react-toolkit
|
|
2
|
+
|
|
3
|
+
A modern, themeable React component library with SCSS modules.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @crk/react-toolkit
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Setup
|
|
12
|
+
|
|
13
|
+
Import the stylesheet in your app entry point:
|
|
14
|
+
|
|
15
|
+
```ts
|
|
16
|
+
import '@crk/react-toolkit/index.css';
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
## Theming
|
|
20
|
+
|
|
21
|
+
Override `--crk-*` CSS custom properties to customize the theme:
|
|
22
|
+
|
|
23
|
+
```css
|
|
24
|
+
:root {
|
|
25
|
+
--crk-color-primary: #3b82f6;
|
|
26
|
+
--crk-color-danger: #ef4444;
|
|
27
|
+
--crk-font-family: 'Inter', sans-serif;
|
|
28
|
+
}
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
## Components
|
|
32
|
+
|
|
33
|
+
| Component | Description |
|
|
34
|
+
| --- | --- |
|
|
35
|
+
| **Button** | Variants: `primary`, `secondary`, `danger`, `ghost`. Multiple sizes. Loading states with `dots`, `shimmer`, and `border` animations. |
|
|
36
|
+
| **Link** | Styled link with variants and external link support. |
|
|
37
|
+
| **Typography** | Renders `h1`-`h6`, `p`, `span`, `label`. Supports `weight`, `color`, `align`, and `truncate`. |
|
|
38
|
+
| **List / ListItem** | Ordered and unordered lists with configurable spacing. |
|
|
39
|
+
| **Table** | Sortable columns, multi-sort with Ctrl+click, pagination, and server-side sort support. |
|
|
40
|
+
| **Dropdown** | Menu dropdown with chevron indicator. Also works as a selectable form input with `options`, `value`, and `onChange`. |
|
|
41
|
+
| **Popover** | Positioned popover anchored to a trigger element. |
|
|
42
|
+
| **Modal** | Portal-based modal with `Header`, `Body`, and `Footer` compound components. Includes focus trap and escape/backdrop close. |
|
|
43
|
+
| **Form / FormField** | Form wrapper with react-hook-form integration. |
|
|
44
|
+
| **Input** | Text input with sizes, error state, and prefix/suffix slots. |
|
|
45
|
+
| **Select** | Native `<select>` with a custom arrow indicator. |
|
|
46
|
+
| **Checkbox** | Checkbox with label and indeterminate state support. |
|
|
47
|
+
| **Radio / RadioGroup** | Context-based radio group. |
|
|
48
|
+
| **Textarea** | Textarea with resize control. |
|
|
49
|
+
|
|
50
|
+
## Hooks
|
|
51
|
+
|
|
52
|
+
| Hook | Description |
|
|
53
|
+
| --- | --- |
|
|
54
|
+
| `useClickOutside` | Detect clicks outside a ref element. |
|
|
55
|
+
| `useFocusTrap` | Trap focus within a container. |
|
|
56
|
+
| `useKeyboard` | Bind keyboard shortcuts. |
|
|
57
|
+
| `useTableSort` | Manage table sort state (single and multi-column). |
|
|
58
|
+
|
|
59
|
+
## Usage
|
|
60
|
+
|
|
61
|
+
### Button
|
|
62
|
+
|
|
63
|
+
```tsx
|
|
64
|
+
import { Button } from '@crk/react-toolkit';
|
|
65
|
+
|
|
66
|
+
<Button variant="primary" size="md" onClick={handleClick}>
|
|
67
|
+
Save
|
|
68
|
+
</Button>
|
|
69
|
+
|
|
70
|
+
<Button variant="danger" loading loadingType="dots">
|
|
71
|
+
Deleting...
|
|
72
|
+
</Button>
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
### Form
|
|
76
|
+
|
|
77
|
+
```tsx
|
|
78
|
+
import { Form, FormField, Input, Button } from '@crk/react-toolkit';
|
|
79
|
+
import { useForm } from 'react-hook-form';
|
|
80
|
+
|
|
81
|
+
function LoginForm() {
|
|
82
|
+
const methods = useForm();
|
|
83
|
+
|
|
84
|
+
return (
|
|
85
|
+
<Form formMethods={methods} onSubmit={methods.handleSubmit(onSubmit)}>
|
|
86
|
+
<FormField name="email" label="Email">
|
|
87
|
+
<Input />
|
|
88
|
+
</FormField>
|
|
89
|
+
<FormField name="password" label="Password">
|
|
90
|
+
<Input type="password" />
|
|
91
|
+
</FormField>
|
|
92
|
+
<Button type="submit" variant="primary">Log in</Button>
|
|
93
|
+
</Form>
|
|
94
|
+
);
|
|
95
|
+
}
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
## Peer Dependencies
|
|
99
|
+
|
|
100
|
+
- `react` >= 18
|
|
101
|
+
- `react-dom` >= 18
|
|
102
|
+
- `react-hook-form` >= 7 (optional, needed for Form/FormField)
|
|
103
|
+
|
|
104
|
+
## License
|
|
105
|
+
|
|
106
|
+
MIT
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { ComponentPropsWithRef } from 'react';
|
|
2
|
+
export interface ButtonClasses {
|
|
3
|
+
root: string;
|
|
4
|
+
content: string;
|
|
5
|
+
shimmer: string;
|
|
6
|
+
dots: string;
|
|
7
|
+
dot: string;
|
|
8
|
+
}
|
|
9
|
+
export interface ButtonProps extends ComponentPropsWithRef<'button'> {
|
|
10
|
+
classes?: Partial<ButtonClasses>;
|
|
11
|
+
variant?: 'primary' | 'secondary' | 'danger' | 'ghost';
|
|
12
|
+
size?: 'sm' | 'md' | 'lg';
|
|
13
|
+
loading?: boolean;
|
|
14
|
+
loadingStyle?: 'dots' | 'shimmer' | 'border';
|
|
15
|
+
fullWidth?: boolean;
|
|
16
|
+
}
|
|
17
|
+
export declare const Button: import('react').ForwardRefExoticComponent<Omit<ButtonProps, "ref"> & import('react').RefAttributes<HTMLButtonElement>>;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { Meta, StoryObj } from '@storybook/react';
|
|
2
|
+
import { Button } from './Button';
|
|
3
|
+
declare const meta: Meta<typeof Button>;
|
|
4
|
+
export default meta;
|
|
5
|
+
type Story = StoryObj<typeof Button>;
|
|
6
|
+
export declare const Primary: Story;
|
|
7
|
+
export declare const Secondary: Story;
|
|
8
|
+
export declare const Danger: Story;
|
|
9
|
+
export declare const Ghost: Story;
|
|
10
|
+
export declare const LoadingDots: Story;
|
|
11
|
+
export declare const LoadingShimmer: Story;
|
|
12
|
+
export declare const LoadingBorder: Story;
|
|
13
|
+
export declare const LoadingAllStyles: Story;
|
|
14
|
+
export declare const Small: Story;
|
|
15
|
+
export declare const Large: Story;
|
|
16
|
+
export declare const FullWidth: Story;
|
|
17
|
+
export declare const AllVariants: Story;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { CSSProperties } from 'react';
|
|
2
|
+
export interface DropdownOption {
|
|
3
|
+
value: string;
|
|
4
|
+
label: string;
|
|
5
|
+
disabled?: boolean;
|
|
6
|
+
}
|
|
7
|
+
export interface DropdownClasses {
|
|
8
|
+
root: string;
|
|
9
|
+
trigger: string;
|
|
10
|
+
triggerLabel: string;
|
|
11
|
+
chevron: string;
|
|
12
|
+
menu: string;
|
|
13
|
+
item: string;
|
|
14
|
+
}
|
|
15
|
+
export interface DropdownProps {
|
|
16
|
+
/** Custom trigger content — used when no `options` are provided */
|
|
17
|
+
trigger?: React.ReactNode;
|
|
18
|
+
children?: React.ReactNode;
|
|
19
|
+
align?: 'left' | 'right';
|
|
20
|
+
className?: string;
|
|
21
|
+
style?: CSSProperties;
|
|
22
|
+
onOpen?: () => void;
|
|
23
|
+
onClose?: () => void;
|
|
24
|
+
/** When provided, the Dropdown acts as a selectable input */
|
|
25
|
+
options?: DropdownOption[];
|
|
26
|
+
/** Placeholder shown when no value is selected */
|
|
27
|
+
placeholder?: string;
|
|
28
|
+
/** Controlled value */
|
|
29
|
+
value?: string;
|
|
30
|
+
/** Called when an option is selected */
|
|
31
|
+
onChange?: (value: string) => void;
|
|
32
|
+
/** Error state styling */
|
|
33
|
+
error?: boolean;
|
|
34
|
+
/** Full width trigger */
|
|
35
|
+
fullWidth?: boolean;
|
|
36
|
+
/** Custom class overrides for internal elements */
|
|
37
|
+
classes?: Partial<DropdownClasses>;
|
|
38
|
+
}
|
|
39
|
+
export declare const Dropdown: import('react').ForwardRefExoticComponent<DropdownProps & import('react').RefAttributes<HTMLDivElement>>;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { Meta, StoryObj } from '@storybook/react';
|
|
2
|
+
import { Dropdown } from './Dropdown';
|
|
3
|
+
declare const meta: Meta<typeof Dropdown>;
|
|
4
|
+
export default meta;
|
|
5
|
+
type Story = StoryObj<typeof Dropdown>;
|
|
6
|
+
export declare const Default: Story;
|
|
7
|
+
export declare const AlignRight: Story;
|
|
8
|
+
export declare const WithDisabledItem: Story;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { ComponentPropsWithRef } from 'react';
|
|
2
|
+
export interface DropdownItemProps extends ComponentPropsWithRef<'button'> {
|
|
3
|
+
disabled?: boolean;
|
|
4
|
+
}
|
|
5
|
+
export declare const DropdownItem: import('react').ForwardRefExoticComponent<Omit<DropdownItemProps, "ref"> & import('react').RefAttributes<HTMLButtonElement>>;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { UseFormReturn, FieldValues, SubmitHandler } from 'react-hook-form';
|
|
2
|
+
export interface FormProps<T extends FieldValues> {
|
|
3
|
+
form: UseFormReturn<T>;
|
|
4
|
+
onSubmit: SubmitHandler<T>;
|
|
5
|
+
className?: string;
|
|
6
|
+
style?: React.CSSProperties;
|
|
7
|
+
children: React.ReactNode;
|
|
8
|
+
}
|
|
9
|
+
export declare function Form<T extends FieldValues>({ form, onSubmit, className, style, children, }: FormProps<T>): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { Meta, StoryObj } from '@storybook/react';
|
|
2
|
+
import { Form } from './Form';
|
|
3
|
+
declare const meta: Meta<typeof Form>;
|
|
4
|
+
export default meta;
|
|
5
|
+
type Story = StoryObj<typeof Form>;
|
|
6
|
+
export declare const Default: Story;
|
|
7
|
+
export declare const WithValidation: Story;
|
|
8
|
+
export declare const WithLoadingSubmit: Story;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { ReactElement, CSSProperties, ReactNode } from 'react';
|
|
2
|
+
export interface FormFieldClasses {
|
|
3
|
+
field: string;
|
|
4
|
+
label: string;
|
|
5
|
+
error: string;
|
|
6
|
+
helperText: string;
|
|
7
|
+
}
|
|
8
|
+
export interface FormFieldProps {
|
|
9
|
+
name: string;
|
|
10
|
+
label?: ReactNode;
|
|
11
|
+
helperText?: ReactNode;
|
|
12
|
+
required?: boolean;
|
|
13
|
+
rules?: Record<string, unknown>;
|
|
14
|
+
classes?: Partial<FormFieldClasses>;
|
|
15
|
+
className?: string;
|
|
16
|
+
style?: CSSProperties;
|
|
17
|
+
children: ReactElement;
|
|
18
|
+
}
|
|
19
|
+
export declare function FormField({ name, label, helperText, required, rules, classes, className, style, children, }: FormFieldProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { ComponentPropsWithRef } from 'react';
|
|
2
|
+
export interface LinkProps extends ComponentPropsWithRef<'a'> {
|
|
3
|
+
variant?: 'default' | 'muted' | 'danger';
|
|
4
|
+
external?: boolean;
|
|
5
|
+
}
|
|
6
|
+
export declare const Link: import('react').ForwardRefExoticComponent<Omit<LinkProps, "ref"> & import('react').RefAttributes<HTMLAnchorElement>>;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Meta, StoryObj } from '@storybook/react';
|
|
2
|
+
import { Link } from './Link';
|
|
3
|
+
declare const meta: Meta<typeof Link>;
|
|
4
|
+
export default meta;
|
|
5
|
+
type Story = StoryObj<typeof Link>;
|
|
6
|
+
export declare const Default: Story;
|
|
7
|
+
export declare const Muted: Story;
|
|
8
|
+
export declare const Danger: Story;
|
|
9
|
+
export declare const External: Story;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { ComponentPropsWithRef } from 'react';
|
|
2
|
+
export interface ListProps extends ComponentPropsWithRef<'ul'> {
|
|
3
|
+
variant?: 'unordered' | 'ordered' | 'none';
|
|
4
|
+
spacing?: 'sm' | 'md' | 'lg';
|
|
5
|
+
}
|
|
6
|
+
export declare const List: import('react').ForwardRefExoticComponent<Omit<ListProps, "ref"> & import('react').RefAttributes<HTMLOListElement | HTMLUListElement>>;
|
|
7
|
+
export interface ListItemProps extends ComponentPropsWithRef<'li'> {
|
|
8
|
+
}
|
|
9
|
+
export declare const ListItem: import('react').ForwardRefExoticComponent<Omit<ListItemProps, "ref"> & import('react').RefAttributes<HTMLLIElement>>;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Meta, StoryObj } from '@storybook/react';
|
|
2
|
+
import { List } from './List';
|
|
3
|
+
declare const meta: Meta<typeof List>;
|
|
4
|
+
export default meta;
|
|
5
|
+
type Story = StoryObj<typeof List>;
|
|
6
|
+
export declare const Unordered: Story;
|
|
7
|
+
export declare const Ordered: Story;
|
|
8
|
+
export declare const NoStyle: Story;
|
|
9
|
+
export declare const Spacing: Story;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { forwardRef, ReactNode, CSSProperties, FC } from 'react';
|
|
2
|
+
export interface ModalClasses {
|
|
3
|
+
backdrop: string;
|
|
4
|
+
modal: string;
|
|
5
|
+
header: string;
|
|
6
|
+
closeButton: string;
|
|
7
|
+
body: string;
|
|
8
|
+
footer: string;
|
|
9
|
+
}
|
|
10
|
+
export interface ModalHeaderProps {
|
|
11
|
+
children: ReactNode;
|
|
12
|
+
className?: string;
|
|
13
|
+
style?: CSSProperties;
|
|
14
|
+
onClose?: () => void;
|
|
15
|
+
}
|
|
16
|
+
export interface ModalBodyProps {
|
|
17
|
+
children: ReactNode;
|
|
18
|
+
className?: string;
|
|
19
|
+
style?: CSSProperties;
|
|
20
|
+
}
|
|
21
|
+
export interface ModalFooterProps {
|
|
22
|
+
children: ReactNode;
|
|
23
|
+
className?: string;
|
|
24
|
+
style?: CSSProperties;
|
|
25
|
+
}
|
|
26
|
+
declare const Header: FC<ModalHeaderProps>;
|
|
27
|
+
declare const Body: FC<ModalBodyProps>;
|
|
28
|
+
declare const Footer: FC<ModalFooterProps>;
|
|
29
|
+
export interface ModalProps {
|
|
30
|
+
open: boolean;
|
|
31
|
+
onClose: () => void;
|
|
32
|
+
closeOnBackdrop?: boolean;
|
|
33
|
+
closeOnEscape?: boolean;
|
|
34
|
+
size?: 'sm' | 'md' | 'lg' | 'fullscreen';
|
|
35
|
+
classes?: Partial<ModalClasses>;
|
|
36
|
+
className?: string;
|
|
37
|
+
style?: CSSProperties;
|
|
38
|
+
children: ReactNode;
|
|
39
|
+
}
|
|
40
|
+
type ModalComponent = ReturnType<typeof forwardRef<HTMLDivElement, ModalProps>> & {
|
|
41
|
+
Header: typeof Header;
|
|
42
|
+
Body: typeof Body;
|
|
43
|
+
Footer: typeof Footer;
|
|
44
|
+
};
|
|
45
|
+
export declare const Modal: ModalComponent;
|
|
46
|
+
export {};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Meta, StoryObj } from '@storybook/react';
|
|
2
|
+
import { Modal } from './Modal';
|
|
3
|
+
declare const meta: Meta<typeof Modal>;
|
|
4
|
+
export default meta;
|
|
5
|
+
type Story = StoryObj<typeof Modal>;
|
|
6
|
+
export declare const Default: Story;
|
|
7
|
+
export declare const Small: Story;
|
|
8
|
+
export declare const Large: Story;
|
|
9
|
+
export declare const NoBackdropClose: Story;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { CSSProperties } from 'react';
|
|
2
|
+
export interface PopoverClasses {
|
|
3
|
+
root: string;
|
|
4
|
+
trigger: string;
|
|
5
|
+
popover: string;
|
|
6
|
+
}
|
|
7
|
+
export interface PopoverProps {
|
|
8
|
+
trigger: React.ReactNode;
|
|
9
|
+
content: React.ReactNode;
|
|
10
|
+
position?: 'top' | 'bottom' | 'left' | 'right';
|
|
11
|
+
open?: boolean;
|
|
12
|
+
onOpenChange?: (open: boolean) => void;
|
|
13
|
+
classes?: Partial<PopoverClasses>;
|
|
14
|
+
className?: string;
|
|
15
|
+
style?: CSSProperties;
|
|
16
|
+
children?: never;
|
|
17
|
+
}
|
|
18
|
+
export declare const Popover: import('react').ForwardRefExoticComponent<PopoverProps & import('react').RefAttributes<HTMLDivElement>>;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Meta, StoryObj } from '@storybook/react';
|
|
2
|
+
import { Popover } from './Popover';
|
|
3
|
+
declare const meta: Meta<typeof Popover>;
|
|
4
|
+
export default meta;
|
|
5
|
+
type Story = StoryObj<typeof Popover>;
|
|
6
|
+
export declare const Bottom: Story;
|
|
7
|
+
export declare const Top: Story;
|
|
8
|
+
export declare const Left: Story;
|
|
9
|
+
export declare const Right: Story;
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
import { SortConfig } from './useTableSort';
|
|
3
|
+
export interface ColumnDef<T> {
|
|
4
|
+
key: keyof T & string;
|
|
5
|
+
header: ReactNode;
|
|
6
|
+
sortable?: boolean;
|
|
7
|
+
render?: (value: T[keyof T], row: T, index: number) => ReactNode;
|
|
8
|
+
width?: string | number;
|
|
9
|
+
align?: 'left' | 'center' | 'right';
|
|
10
|
+
}
|
|
11
|
+
export interface PaginationConfig {
|
|
12
|
+
/** Current page (1-based) */
|
|
13
|
+
page: number;
|
|
14
|
+
/** Rows per page */
|
|
15
|
+
pageSize: number;
|
|
16
|
+
/** Total number of rows (required for server-side pagination) */
|
|
17
|
+
totalRows?: number;
|
|
18
|
+
/** Available page size options */
|
|
19
|
+
pageSizeOptions?: number[];
|
|
20
|
+
/** Called when page or pageSize changes */
|
|
21
|
+
onPageChange: (page: number, pageSize: number) => void;
|
|
22
|
+
}
|
|
23
|
+
export interface TableClasses {
|
|
24
|
+
wrapper: string;
|
|
25
|
+
root: string;
|
|
26
|
+
headerCell: string;
|
|
27
|
+
row: string;
|
|
28
|
+
cell: string;
|
|
29
|
+
emptyCell: string;
|
|
30
|
+
paginator: string;
|
|
31
|
+
pageButton: string;
|
|
32
|
+
}
|
|
33
|
+
export interface TableProps<T extends Record<string, unknown>> {
|
|
34
|
+
data: T[];
|
|
35
|
+
columns: ColumnDef<T>[];
|
|
36
|
+
/** Controlled sort config — when provided with onSort, sorting is external (server-side) */
|
|
37
|
+
sortConfig?: SortConfig[];
|
|
38
|
+
/** Sort callback — when provided, Table won't sort data internally */
|
|
39
|
+
onSort?: (config: SortConfig[]) => void;
|
|
40
|
+
/** Enable multi-column sort via Ctrl+click (default: true) */
|
|
41
|
+
multiSort?: boolean;
|
|
42
|
+
striped?: boolean;
|
|
43
|
+
hoverable?: boolean;
|
|
44
|
+
compact?: boolean;
|
|
45
|
+
className?: string;
|
|
46
|
+
style?: React.CSSProperties;
|
|
47
|
+
rowKey?: keyof T & string;
|
|
48
|
+
emptyMessage?: ReactNode;
|
|
49
|
+
/** Pagination config — when provided, shows a paginator below the table */
|
|
50
|
+
pagination?: PaginationConfig;
|
|
51
|
+
classes?: Partial<TableClasses>;
|
|
52
|
+
}
|
|
53
|
+
declare function TableInner<T extends Record<string, unknown>>({ data, columns, sortConfig: controlledSortConfig, onSort, multiSort, striped, hoverable, compact, className, style, rowKey, emptyMessage, pagination, classes, }: TableProps<T>): import("react/jsx-runtime").JSX.Element;
|
|
54
|
+
export declare const Table: typeof TableInner;
|
|
55
|
+
export {};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { Meta, StoryObj } from '@storybook/react';
|
|
2
|
+
import { Table } from './Table';
|
|
3
|
+
type User = {
|
|
4
|
+
id: number;
|
|
5
|
+
name: string;
|
|
6
|
+
email: string;
|
|
7
|
+
age: number;
|
|
8
|
+
role: string;
|
|
9
|
+
};
|
|
10
|
+
declare const meta: Meta<typeof Table<User>>;
|
|
11
|
+
export default meta;
|
|
12
|
+
type Story = StoryObj<typeof Table<User>>;
|
|
13
|
+
export declare const Default: Story;
|
|
14
|
+
export declare const Striped: Story;
|
|
15
|
+
export declare const Hoverable: Story;
|
|
16
|
+
export declare const Compact: Story;
|
|
17
|
+
export declare const MultiSort: Story;
|
|
18
|
+
export declare const WithPagination: Story;
|
|
19
|
+
export declare const ServerSideSort: Story;
|
|
20
|
+
export declare const Empty: Story;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/** Describes the sort state for a single column. */
|
|
2
|
+
export interface SortConfig {
|
|
3
|
+
/** Column key to sort by. */
|
|
4
|
+
key: string;
|
|
5
|
+
/** Sort direction. */
|
|
6
|
+
direction: 'asc' | 'desc';
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Client-side sorting hook for tabular data.
|
|
10
|
+
*
|
|
11
|
+
* Supports single and multi-column sort with asc → desc → none cycling.
|
|
12
|
+
*
|
|
13
|
+
* @param data - Array of row objects to sort.
|
|
14
|
+
* @param initialSort - Optional initial sort configuration.
|
|
15
|
+
* @returns An object containing:
|
|
16
|
+
* - `sortedData` — the sorted copy of `data`.
|
|
17
|
+
* - `sortConfig` — current active sort columns and directions.
|
|
18
|
+
* - `requestSort(key)` — single-column sort (replaces any existing sort).
|
|
19
|
+
* - `requestMultiSort(key)` — adds/toggles a column in multi-sort mode.
|
|
20
|
+
* - `resetSort()` — clears all sorting.
|
|
21
|
+
*
|
|
22
|
+
* @example
|
|
23
|
+
* ```tsx
|
|
24
|
+
* const { sortedData, sortConfig, requestSort } = useTableSort(users);
|
|
25
|
+
* ```
|
|
26
|
+
*/
|
|
27
|
+
export declare function useTableSort<T extends Record<string, unknown>>(data: T[], initialSort?: SortConfig[]): {
|
|
28
|
+
sortedData: T[];
|
|
29
|
+
sortConfig: SortConfig[];
|
|
30
|
+
requestSort: (key: keyof T & string) => void;
|
|
31
|
+
requestMultiSort: (key: keyof T & string) => void;
|
|
32
|
+
resetSort: () => void;
|
|
33
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { ComponentPropsWithRef } from 'react';
|
|
2
|
+
type TypographyVariant = 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6' | 'p' | 'span' | 'label';
|
|
3
|
+
export interface TypographyProps extends Omit<ComponentPropsWithRef<'p'>, 'color'> {
|
|
4
|
+
variant?: TypographyVariant;
|
|
5
|
+
weight?: 'normal' | 'medium' | 'semibold' | 'bold';
|
|
6
|
+
color?: 'default' | 'muted' | 'primary' | 'danger' | 'success';
|
|
7
|
+
align?: 'left' | 'center' | 'right';
|
|
8
|
+
truncate?: boolean;
|
|
9
|
+
children: React.ReactNode;
|
|
10
|
+
}
|
|
11
|
+
export declare const Typography: import('react').ForwardRefExoticComponent<Omit<TypographyProps, "ref"> & import('react').RefAttributes<HTMLElement>>;
|
|
12
|
+
export {};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { Meta, StoryObj } from '@storybook/react';
|
|
2
|
+
import { Typography } from './Typography';
|
|
3
|
+
declare const meta: Meta<typeof Typography>;
|
|
4
|
+
export default meta;
|
|
5
|
+
type Story = StoryObj<typeof Typography>;
|
|
6
|
+
export declare const Heading1: Story;
|
|
7
|
+
export declare const Heading2: Story;
|
|
8
|
+
export declare const Heading3: Story;
|
|
9
|
+
export declare const Heading4: Story;
|
|
10
|
+
export declare const Heading5: Story;
|
|
11
|
+
export declare const Heading6: Story;
|
|
12
|
+
export declare const Paragraph: Story;
|
|
13
|
+
export declare const Muted: Story;
|
|
14
|
+
export declare const Truncated: Story;
|
|
15
|
+
export declare const AllVariants: Story;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { ComponentPropsWithRef, ReactNode } from 'react';
|
|
2
|
+
export interface CheckboxClasses {
|
|
3
|
+
root: string;
|
|
4
|
+
input: string;
|
|
5
|
+
label: string;
|
|
6
|
+
}
|
|
7
|
+
export interface CheckboxProps extends ComponentPropsWithRef<'input'> {
|
|
8
|
+
label?: ReactNode;
|
|
9
|
+
indeterminate?: boolean;
|
|
10
|
+
classes?: Partial<CheckboxClasses>;
|
|
11
|
+
}
|
|
12
|
+
export declare const Checkbox: import('react').ForwardRefExoticComponent<Omit<CheckboxProps, "ref"> & import('react').RefAttributes<HTMLInputElement>>;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Meta, StoryObj } from '@storybook/react';
|
|
2
|
+
import { Checkbox } from './Checkbox';
|
|
3
|
+
declare const meta: Meta<typeof Checkbox>;
|
|
4
|
+
export default meta;
|
|
5
|
+
type Story = StoryObj<typeof Checkbox>;
|
|
6
|
+
export declare const Default: Story;
|
|
7
|
+
export declare const Checked: Story;
|
|
8
|
+
export declare const Indeterminate: Story;
|
|
9
|
+
export declare const Disabled: Story;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { ComponentPropsWithRef, ReactNode } from 'react';
|
|
2
|
+
export interface InputClasses {
|
|
3
|
+
root: string;
|
|
4
|
+
wrapper: string;
|
|
5
|
+
prefix: string;
|
|
6
|
+
suffix: string;
|
|
7
|
+
}
|
|
8
|
+
export interface InputProps extends Omit<ComponentPropsWithRef<'input'>, 'prefix'> {
|
|
9
|
+
inputSize?: 'sm' | 'md' | 'lg';
|
|
10
|
+
error?: boolean;
|
|
11
|
+
prefix?: ReactNode;
|
|
12
|
+
suffix?: ReactNode;
|
|
13
|
+
classes?: Partial<InputClasses>;
|
|
14
|
+
}
|
|
15
|
+
export declare const Input: import('react').ForwardRefExoticComponent<Omit<InputProps, "ref"> & import('react').RefAttributes<HTMLInputElement>>;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Meta, StoryObj } from '@storybook/react';
|
|
2
|
+
import { Input } from './Input';
|
|
3
|
+
declare const meta: Meta<typeof Input>;
|
|
4
|
+
export default meta;
|
|
5
|
+
type Story = StoryObj<typeof Input>;
|
|
6
|
+
export declare const Default: Story;
|
|
7
|
+
export declare const Small: Story;
|
|
8
|
+
export declare const Large: Story;
|
|
9
|
+
export declare const WithError: Story;
|
|
10
|
+
export declare const WithPrefix: Story;
|
|
11
|
+
export declare const WithSuffix: Story;
|
|
12
|
+
export declare const WithPrefixAndSuffix: Story;
|
|
13
|
+
export declare const Disabled: Story;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { ComponentPropsWithRef, ReactNode, CSSProperties } from 'react';
|
|
2
|
+
export interface RadioGroupProps {
|
|
3
|
+
name: string;
|
|
4
|
+
value?: string;
|
|
5
|
+
onChange?: (value: string) => void;
|
|
6
|
+
className?: string;
|
|
7
|
+
style?: CSSProperties;
|
|
8
|
+
children: ReactNode;
|
|
9
|
+
}
|
|
10
|
+
export declare const RadioGroup: {
|
|
11
|
+
({ name, value, onChange, className, style, children, }: RadioGroupProps): import("react/jsx-runtime").JSX.Element;
|
|
12
|
+
displayName: string;
|
|
13
|
+
};
|
|
14
|
+
export interface RadioClasses {
|
|
15
|
+
root: string;
|
|
16
|
+
input: string;
|
|
17
|
+
label: string;
|
|
18
|
+
}
|
|
19
|
+
export interface RadioProps extends Omit<ComponentPropsWithRef<'input'>, 'type'> {
|
|
20
|
+
label?: ReactNode;
|
|
21
|
+
value: string;
|
|
22
|
+
classes?: Partial<RadioClasses>;
|
|
23
|
+
}
|
|
24
|
+
export declare const Radio: import('react').ForwardRefExoticComponent<Omit<RadioProps, "ref"> & import('react').RefAttributes<HTMLInputElement>>;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { Meta, StoryObj } from '@storybook/react';
|
|
2
|
+
import { RadioGroup } from './Radio';
|
|
3
|
+
declare const meta: Meta<typeof RadioGroup>;
|
|
4
|
+
export default meta;
|
|
5
|
+
type Story = StoryObj<typeof RadioGroup>;
|
|
6
|
+
export declare const Default: Story;
|
|
7
|
+
export declare const WithDefault: Story;
|