blunt-ui 0.3.1 → 0.3.3
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 +101 -1
- package/dist/components/ConfirmDialog/ConfirmDialog.d.ts +5 -0
- package/dist/components/ConfirmDialog/ConfirmDialog.stories.d.ts +8 -0
- package/dist/components/ConfirmDialog/ConfirmDialog.test.d.ts +0 -0
- package/dist/components/ConfirmDialog/ConfirmDialog.types.d.ts +13 -0
- package/dist/components/ConfirmDialog/index.d.ts +4 -0
- package/dist/components/ConfirmDialog/useConfirm.d.ts +6 -0
- package/dist/components/ConfirmDialog/useConfirm.test.d.ts +0 -0
- package/dist/components/ConfirmDialog/useConfirm.types.d.ts +14 -0
- package/dist/components/DatePicker/DatePicker.d.ts +5 -0
- package/dist/components/DatePicker/DatePicker.stories.d.ts +11 -0
- package/dist/components/DatePicker/DatePicker.test.d.ts +0 -0
- package/dist/components/DatePicker/DatePicker.types.d.ts +14 -0
- package/dist/components/DatePicker/index.d.ts +2 -0
- package/dist/components/Editable/Editable.d.ts +5 -0
- package/dist/components/Editable/Editable.stories.d.ts +10 -0
- package/dist/components/Editable/Editable.types.d.ts +9 -0
- package/dist/components/Editable/index.d.ts +2 -0
- package/dist/components/Field/Field.d.ts +5 -0
- package/dist/components/Field/Field.stories.d.ts +8 -0
- package/dist/components/Field/Field.types.d.ts +6 -0
- package/dist/components/Field/index.d.ts +2 -0
- package/dist/components/Form/index.d.ts +2 -0
- package/dist/components/Form/useForm.d.ts +2 -0
- package/dist/components/Form/useForm.test.d.ts +1 -0
- package/dist/components/Form/useForm.types.d.ts +20 -0
- package/dist/components/Input/Input.types.d.ts +1 -1
- package/dist/components/Select/Select.types.d.ts +2 -3
- package/dist/components/Spinner/Spinner.d.ts +5 -0
- package/dist/components/Spinner/Spinner.stories.d.ts +9 -0
- package/dist/components/Spinner/Spinner.types.d.ts +8 -0
- package/dist/components/Spinner/index.d.ts +2 -0
- package/dist/components/Table/Table.d.ts +1 -1
- package/dist/components/Table/Table.stories.d.ts +2 -10
- package/dist/components/Table/Table.types.d.ts +2 -1
- package/dist/components/Table/index.d.ts +2 -0
- package/dist/components/Table/useTable.d.ts +12 -0
- package/dist/components/Table/useTableSort.d.ts +1 -1
- package/dist/components/Textarea/Textarea.d.ts +5 -0
- package/dist/components/Textarea/Textarea.stories.d.ts +8 -0
- package/dist/components/Textarea/Textarea.types.d.ts +11 -0
- package/dist/components/Textarea/index.d.ts +2 -0
- package/dist/components/Toast/index.d.ts +2 -0
- package/dist/components/Toast/useToast.d.ts +6 -0
- package/dist/components/Toast/useToast.test.d.ts +0 -0
- package/dist/components/Toast/useToast.types.d.ts +17 -0
- package/dist/index.cjs +576 -257
- package/dist/index.d.ts +21 -14
- package/dist/index.js +1757 -1221
- package/dist/{components/ThemeProvider/index.d.ts → themes/ThemeProvider.d.ts} +1 -1
- package/dist/themes/index.d.ts +2 -1
- package/package.json +1 -1
- package/dist/components/DataTable/DataTable.d.ts +0 -5
- package/dist/components/DataTable/DataTable.stories.d.ts +0 -13
- package/dist/components/DataTable/DataTable.types.d.ts +0 -25
- package/dist/components/DataTable/index.d.ts +0 -2
- package/dist/themes/default.d.ts +0 -2
- /package/dist/{styles → themes}/GlobalStyles.d.ts +0 -0
- /package/dist/{consts.d.ts → themes/consts.d.ts} +0 -0
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# blunt-ui
|
|
2
2
|
|
|
3
|
-
React + TypeScript + styled-components. Thick borders, offset shadows, no fluff.
|
|
3
|
+
React + TypeScript + styled-components. Thick borders, offset shadows, no fluff. 11 components, 3 hooks.
|
|
4
4
|
|
|
5
5
|
**Live demo:** https://blunt-ui.vercel.app/
|
|
6
6
|
|
|
@@ -179,6 +179,106 @@ const { values, errors, handleChange, handleBlur, handleSubmit, reset } =
|
|
|
179
179
|
|
|
180
180
|
The `name` on each input needs to match the key in `initialValues`. Use `reset()` to clear everything back to the start.
|
|
181
181
|
|
|
182
|
+
## Table
|
|
183
|
+
|
|
184
|
+
Read-only table with sorting and pagination. You define columns, pass data, done. Sorting and pagination work in both uncontrolled mode (component handles state internally) and controlled mode (you own the state, useful when data comes from an API).
|
|
185
|
+
|
|
186
|
+
Sizes: `sm`, `md`, `lg`.
|
|
187
|
+
|
|
188
|
+
```tsx
|
|
189
|
+
const columns = [
|
|
190
|
+
{ key: "name", header: "Name", sortable: true },
|
|
191
|
+
{ key: "role", header: "Role" },
|
|
192
|
+
{ key: "status", header: "Status", render: (v) => <Badge>{v}</Badge> },
|
|
193
|
+
];
|
|
194
|
+
|
|
195
|
+
<Table
|
|
196
|
+
columns={columns}
|
|
197
|
+
data={rows}
|
|
198
|
+
rowKey="id"
|
|
199
|
+
striped
|
|
200
|
+
bordered
|
|
201
|
+
pageSize={10}
|
|
202
|
+
emptyMessage="No results"
|
|
203
|
+
/>;
|
|
204
|
+
```
|
|
205
|
+
|
|
206
|
+
**Sorting** — add `sortable: true` to any column. By default the table sorts client-side. If you want to handle it yourself (e.g. send a query param to your backend), pass `sort` + `onSortChange` and it becomes controlled — the table just shows the sort indicator and tells you when it changed, you bring the sorted data.
|
|
207
|
+
|
|
208
|
+
**Pagination** — set `pageSize` and the table slices the data automatically. For server-side pagination, also pass `totalRows` so it knows how many pages there are, and control `page` + `onPageChange` yourself. If you need both sort and page in one callback, use `onChange` instead.
|
|
209
|
+
|
|
210
|
+
**Other stuff** — `loading` replaces rows with skeleton cells while data is loading. `stickyHeader` keeps the header in view when the table scrolls. `caption` adds a proper `<caption>` for accessibility.
|
|
211
|
+
|
|
212
|
+
Color props: `borderColor`, `headerColor`, `rowColor`, `stripeColor`.
|
|
213
|
+
|
|
214
|
+
## DataTable
|
|
215
|
+
|
|
216
|
+
Editable table — good for things like spreadsheet-style input or inline CRUD. Each column can be editable or not, and you can mix text inputs with dropdowns.
|
|
217
|
+
|
|
218
|
+
```tsx
|
|
219
|
+
const columns = [
|
|
220
|
+
{ key: "name", header: "Name", editable: true },
|
|
221
|
+
{ key: "qty", header: "Qty", editable: true, width: "80px" },
|
|
222
|
+
{
|
|
223
|
+
key: "status",
|
|
224
|
+
header: "Status",
|
|
225
|
+
editable: true,
|
|
226
|
+
options: [
|
|
227
|
+
{ value: "todo", label: "To do" },
|
|
228
|
+
{ value: "in_progress", label: "In progress" },
|
|
229
|
+
{ value: "done", label: "Done" },
|
|
230
|
+
],
|
|
231
|
+
},
|
|
232
|
+
];
|
|
233
|
+
|
|
234
|
+
<DataTable
|
|
235
|
+
columns={columns}
|
|
236
|
+
defaultData={[{ name: "Widget", qty: "1", status: "todo" }]}
|
|
237
|
+
onChange={(rows) => console.log(rows)}
|
|
238
|
+
deletable
|
|
239
|
+
addRowLabel="Add item"
|
|
240
|
+
/>;
|
|
241
|
+
```
|
|
242
|
+
|
|
243
|
+
**Editing** — click a text cell to start editing, Enter to confirm, Escape to cancel. For select cells (columns with `options`), one click opens the dropdown directly; picking an option saves immediately. Tab and Shift+Tab move between editable cells. Tab past the last cell adds a new row automatically.
|
|
244
|
+
|
|
245
|
+
**Select columns** — add `options: [{ value, label }]` to a column. The cell stores the `value` but displays the `label`. The column still needs `editable: true`.
|
|
246
|
+
|
|
247
|
+
**Controlled vs uncontrolled** — same pattern as the rest of the library. Pass `defaultData` and forget about it, or pass `data` + `onChange` if you need to keep the data in your own state.
|
|
248
|
+
|
|
249
|
+
**Per-cell editability** — `editable` can be a function `(row, rowIndex) => boolean` if you need some cells to be editable based on row content.
|
|
250
|
+
|
|
251
|
+
`deletable` adds a remove button per row. `newRowFactory` lets you control what an empty new row looks like (useful if you need generated IDs or default values).
|
|
252
|
+
|
|
253
|
+
Color props: `borderColor`, `headerColor`.
|
|
254
|
+
|
|
255
|
+
## useTable
|
|
256
|
+
|
|
257
|
+
Helper hook for when your table data comes from a server. It keeps track of the current sort and page so you can use them in a fetch call, and passes them back to `<Table>` as controlled props.
|
|
258
|
+
|
|
259
|
+
```tsx
|
|
260
|
+
const { sort, page, onSortChange, onPageChange } = useTable({
|
|
261
|
+
defaultPage: 1,
|
|
262
|
+
});
|
|
263
|
+
|
|
264
|
+
useEffect(() => {
|
|
265
|
+
fetchProducts({ sort, page });
|
|
266
|
+
}, [sort, page]);
|
|
267
|
+
|
|
268
|
+
<Table
|
|
269
|
+
columns={columns}
|
|
270
|
+
data={serverData}
|
|
271
|
+
sort={sort}
|
|
272
|
+
onSortChange={onSortChange}
|
|
273
|
+
page={page}
|
|
274
|
+
onPageChange={onPageChange}
|
|
275
|
+
pageSize={20}
|
|
276
|
+
totalRows={totalCount}
|
|
277
|
+
/>;
|
|
278
|
+
```
|
|
279
|
+
|
|
280
|
+
When the user changes the sort column, the page resets to 1 automatically — that's usually what you want so you don't end up on page 5 of a different sort order. Pass `defaultSort` if you need a column sorted on first load.
|
|
281
|
+
|
|
182
282
|
## Design tokens
|
|
183
283
|
|
|
184
284
|
Colors, spacing, font sizes, and border radius live in `src/consts.ts`. All components pull from there, so changing a token updates everything at once.
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { ConfirmDialogProps } from './ConfirmDialog.types';
|
|
2
|
+
export declare function ConfirmDialog({ open, title, message, confirmLabel, cancelLabel, variant, size, onConfirm, onCancel, }: ConfirmDialogProps): import("react/jsx-runtime").JSX.Element;
|
|
3
|
+
export declare namespace ConfirmDialog {
|
|
4
|
+
var displayName: string;
|
|
5
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { Meta, StoryObj } from '@storybook/react';
|
|
2
|
+
import { ConfirmDialog } from './ConfirmDialog';
|
|
3
|
+
declare const meta: Meta<typeof ConfirmDialog>;
|
|
4
|
+
export default meta;
|
|
5
|
+
type Story = StoryObj<typeof ConfirmDialog>;
|
|
6
|
+
export declare const Default: Story;
|
|
7
|
+
export declare const Danger: Story;
|
|
8
|
+
export declare const WithHook: Story;
|
|
File without changes
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { ModalSizes } from '../Modal';
|
|
2
|
+
export type ConfirmVariant = "default" | "danger";
|
|
3
|
+
export interface ConfirmDialogProps {
|
|
4
|
+
open: boolean;
|
|
5
|
+
title?: string;
|
|
6
|
+
message: string;
|
|
7
|
+
confirmLabel?: string;
|
|
8
|
+
cancelLabel?: string;
|
|
9
|
+
variant?: ConfirmVariant;
|
|
10
|
+
size?: ModalSizes;
|
|
11
|
+
onConfirm: () => void;
|
|
12
|
+
onCancel: () => void;
|
|
13
|
+
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export { ConfirmDialog } from './ConfirmDialog';
|
|
2
|
+
export type { ConfirmDialogProps, ConfirmVariant } from './ConfirmDialog.types';
|
|
3
|
+
export { useConfirm, ConfirmProvider } from './useConfirm';
|
|
4
|
+
export type { ConfirmOptions, ConfirmFn, ConfirmContextValue, } from './useConfirm.types';
|
|
File without changes
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { ConfirmVariant } from './ConfirmDialog.types';
|
|
2
|
+
import { ModalSizes } from '../Modal';
|
|
3
|
+
export interface ConfirmOptions {
|
|
4
|
+
title?: string;
|
|
5
|
+
message: string;
|
|
6
|
+
confirmLabel?: string;
|
|
7
|
+
cancelLabel?: string;
|
|
8
|
+
variant?: ConfirmVariant;
|
|
9
|
+
size?: ModalSizes;
|
|
10
|
+
}
|
|
11
|
+
export type ConfirmFn = (options: ConfirmOptions) => Promise<boolean>;
|
|
12
|
+
export interface ConfirmContextValue {
|
|
13
|
+
confirm: ConfirmFn;
|
|
14
|
+
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { DatePickerProps } from './DatePicker.types';
|
|
2
|
+
export declare function DatePicker({ value, onChange, placeholder, size, disabled, clearable, minDate, maxDate, formatDate, id, error, }: DatePickerProps): import("react/jsx-runtime").JSX.Element;
|
|
3
|
+
export declare namespace DatePicker {
|
|
4
|
+
var displayName: string;
|
|
5
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Meta, StoryObj } from '@storybook/react';
|
|
2
|
+
import { DatePicker } from './DatePicker';
|
|
3
|
+
declare const meta: Meta<typeof DatePicker>;
|
|
4
|
+
export default meta;
|
|
5
|
+
type Story = StoryObj<typeof DatePicker>;
|
|
6
|
+
export declare const Default: Story;
|
|
7
|
+
export declare const WithValue: Story;
|
|
8
|
+
export declare const WithMinMax: Story;
|
|
9
|
+
export declare const Sizes: Story;
|
|
10
|
+
export declare const Disabled: Story;
|
|
11
|
+
export declare const WithError: Story;
|
|
File without changes
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export type DatePickerSizes = "sm" | "md" | "lg";
|
|
2
|
+
export interface DatePickerProps {
|
|
3
|
+
value?: Date | null;
|
|
4
|
+
onChange?: (date: Date | null) => void;
|
|
5
|
+
placeholder?: string;
|
|
6
|
+
size?: DatePickerSizes;
|
|
7
|
+
disabled?: boolean;
|
|
8
|
+
clearable?: boolean;
|
|
9
|
+
minDate?: Date;
|
|
10
|
+
maxDate?: Date;
|
|
11
|
+
formatDate?: (date: Date) => string;
|
|
12
|
+
id?: string;
|
|
13
|
+
error?: boolean | string;
|
|
14
|
+
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { EditableProps } from './Editable.types';
|
|
2
|
+
export declare function Editable({ value, defaultValue, onChange, onSubmit, onCancel, placeholder, disabled, }: EditableProps): import("react/jsx-runtime").JSX.Element;
|
|
3
|
+
export declare namespace Editable {
|
|
4
|
+
var displayName: string;
|
|
5
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Meta, StoryObj } from '@storybook/react';
|
|
2
|
+
import { Editable } from './Editable';
|
|
3
|
+
declare const meta: Meta<typeof Editable>;
|
|
4
|
+
export default meta;
|
|
5
|
+
type Story = StoryObj<typeof Editable>;
|
|
6
|
+
export declare const Default: Story;
|
|
7
|
+
export declare const Placeholder: Story;
|
|
8
|
+
export declare const Controlled: Story;
|
|
9
|
+
export declare const Disabled: Story;
|
|
10
|
+
export declare const InTable: Story;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { Meta, StoryObj } from '@storybook/react';
|
|
2
|
+
import { Field } from './Field';
|
|
3
|
+
declare const meta: Meta<typeof Field>;
|
|
4
|
+
export default meta;
|
|
5
|
+
type Story = StoryObj<typeof Field>;
|
|
6
|
+
export declare const Default: Story;
|
|
7
|
+
export declare const Empty: Story;
|
|
8
|
+
export declare const WithLink: Story;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { ChangeEvent, FocusEvent, FormEvent } from 'react';
|
|
2
|
+
type FieldElement = HTMLInputElement | HTMLSelectElement | HTMLTextAreaElement;
|
|
3
|
+
export interface UseFormOptions<T extends Record<string, string>> {
|
|
4
|
+
initialValues: T;
|
|
5
|
+
validate?: (values: T) => Partial<Record<keyof T, string | undefined>>;
|
|
6
|
+
onSubmit?: (values: T) => void | Promise<void>;
|
|
7
|
+
onError?: (errors: Partial<Record<keyof T, string>>) => void;
|
|
8
|
+
}
|
|
9
|
+
export interface UseFormReturn<T extends Record<string, string>> {
|
|
10
|
+
values: T;
|
|
11
|
+
errors: Partial<Record<keyof T, string>>;
|
|
12
|
+
touched: Partial<Record<keyof T, boolean>>;
|
|
13
|
+
handleChange: (e: ChangeEvent<FieldElement>) => void;
|
|
14
|
+
handleBlur: (e: FocusEvent<FieldElement>) => void;
|
|
15
|
+
handleSubmit: (e?: FormEvent) => void;
|
|
16
|
+
setFieldValue: (field: keyof T, value: string) => void;
|
|
17
|
+
reset: (newValues?: T) => void;
|
|
18
|
+
isSubmitting: boolean;
|
|
19
|
+
}
|
|
20
|
+
export {};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ComponentPropsWithRef, ReactNode } from 'react';
|
|
2
2
|
export type InputTypes = "text" | "email" | "password" | "number" | "search" | "tel" | "url";
|
|
3
3
|
export type InputSizes = "sm" | "md" | "lg";
|
|
4
|
-
export type InputVariants = "default" | "outlined"
|
|
4
|
+
export type InputVariants = "default" | "outlined";
|
|
5
5
|
export interface InputProps extends Omit<ComponentPropsWithRef<"input">, "size" | "type"> {
|
|
6
6
|
type?: InputTypes;
|
|
7
7
|
size?: InputSizes;
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { ComponentPropsWithRef } from 'react';
|
|
2
|
-
|
|
3
|
-
export type
|
|
4
|
-
export type SelectVariants = InputVariants;
|
|
2
|
+
export type SelectSizes = "sm" | "md" | "lg";
|
|
3
|
+
export type SelectVariants = "default" | "outlined";
|
|
5
4
|
export interface SelectOption {
|
|
6
5
|
value: string;
|
|
7
6
|
label: string;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Meta, StoryObj } from '@storybook/react';
|
|
2
|
+
import { Spinner } from './Spinner';
|
|
3
|
+
declare const meta: Meta<typeof Spinner>;
|
|
4
|
+
export default meta;
|
|
5
|
+
type Story = StoryObj<typeof Spinner>;
|
|
6
|
+
export declare const Default: Story;
|
|
7
|
+
export declare const Sizes: Story;
|
|
8
|
+
export declare const Weights: Story;
|
|
9
|
+
export declare const CustomColor: Story;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { TableProps } from './Table.types';
|
|
2
|
-
export declare function Table<T extends Record<string, unknown> = Record<string, unknown>>({ columns, data, rowKey, size, striped, bordered, stickyHeader, caption, emptyMessage, loading, sort, defaultSort, onSortChange, pageSize, page, defaultPage, totalRows, onPageChange, onChange, borderColor, headerColor, rowColor, stripeColor, className, style, }: TableProps<T>): import("react/jsx-runtime").JSX.Element;
|
|
2
|
+
export declare function Table<T extends Record<string, unknown> = Record<string, unknown>>({ columns, data, rowKey, size, striped, bordered, stickyHeader, caption, emptyMessage, loading, sort, defaultSort, onSortChange, pageSize, page, defaultPage, totalRows, onPageChange, onChange, onRowClick, borderColor, headerColor, rowColor, stripeColor, className, style, }: TableProps<T>): import("react/jsx-runtime").JSX.Element;
|
|
3
3
|
export declare namespace Table {
|
|
4
4
|
var displayName: string;
|
|
5
5
|
}
|
|
@@ -4,22 +4,14 @@ declare const meta: Meta<typeof Table>;
|
|
|
4
4
|
export default meta;
|
|
5
5
|
type Story = StoryObj<typeof Table>;
|
|
6
6
|
export declare const Default: Story;
|
|
7
|
-
export declare const Striped: Story;
|
|
8
|
-
export declare const Bordered: Story;
|
|
9
7
|
export declare const StripedAndBordered: Story;
|
|
10
|
-
export declare const Small: Story;
|
|
11
|
-
export declare const Large: Story;
|
|
12
|
-
export declare const WithCaption: Story;
|
|
13
8
|
export declare const WithCustomRender: Story;
|
|
14
9
|
export declare const Sortable: Story;
|
|
15
10
|
export declare const SortableControlled: Story;
|
|
11
|
+
export declare const WithUseTable: Story;
|
|
16
12
|
export declare const Loading: Story;
|
|
17
13
|
export declare const Empty: Story;
|
|
18
14
|
export declare const Paginated: Story;
|
|
19
|
-
export declare const PaginatedSortable: Story;
|
|
20
15
|
export declare const StickyHeader: Story;
|
|
21
|
-
export declare const
|
|
22
|
-
export declare const CustomBorderColor: Story;
|
|
23
|
-
export declare const CustomHeaderColor: Story;
|
|
24
|
-
export declare const CustomRowColors: Story;
|
|
16
|
+
export declare const WithRowClick: Story;
|
|
25
17
|
export declare const FullyCustomized: Story;
|
|
@@ -27,7 +27,7 @@ export interface TableProps<T extends Record<string, unknown> = Record<string, u
|
|
|
27
27
|
caption?: string;
|
|
28
28
|
emptyMessage?: string;
|
|
29
29
|
loading?: boolean;
|
|
30
|
-
sort?: SortState;
|
|
30
|
+
sort?: SortState | null;
|
|
31
31
|
defaultSort?: SortState;
|
|
32
32
|
onSortChange?: (sort: SortState | null) => void;
|
|
33
33
|
pageSize?: number;
|
|
@@ -40,6 +40,7 @@ export interface TableProps<T extends Record<string, unknown> = Record<string, u
|
|
|
40
40
|
headerColor?: string;
|
|
41
41
|
rowColor?: string;
|
|
42
42
|
stripeColor?: string;
|
|
43
|
+
onRowClick?: (row: T) => void;
|
|
43
44
|
className?: string;
|
|
44
45
|
style?: CSSProperties;
|
|
45
46
|
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { SortState } from './Table.types';
|
|
2
|
+
export interface UseTableOptions {
|
|
3
|
+
defaultSort?: SortState;
|
|
4
|
+
defaultPage?: number;
|
|
5
|
+
}
|
|
6
|
+
export interface UseTableReturn {
|
|
7
|
+
sort: SortState | null;
|
|
8
|
+
page: number;
|
|
9
|
+
onSortChange: (sort: SortState | null) => void;
|
|
10
|
+
onPageChange: (page: number) => void;
|
|
11
|
+
}
|
|
12
|
+
export declare function useTable({ defaultSort, defaultPage, }?: UseTableOptions): UseTableReturn;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { TextareaProps } from './Textarea.types';
|
|
2
|
+
export declare function Textarea({ ref, size, variant, label, helperText, error, fullWidth, id, value, defaultValue, onChange, ...props }: TextareaProps): import("react/jsx-runtime").JSX.Element;
|
|
3
|
+
export declare namespace Textarea {
|
|
4
|
+
var displayName: string;
|
|
5
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { Meta, StoryObj } from '@storybook/react';
|
|
2
|
+
import { Textarea } from './Textarea';
|
|
3
|
+
declare const meta: Meta<typeof Textarea>;
|
|
4
|
+
export default meta;
|
|
5
|
+
type Story = StoryObj<typeof Textarea>;
|
|
6
|
+
export declare const Default: Story;
|
|
7
|
+
export declare const Error: Story;
|
|
8
|
+
export declare const WithHelperText: Story;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { ComponentPropsWithRef } from 'react';
|
|
2
|
+
export type TextareaSizes = "sm" | "md" | "lg";
|
|
3
|
+
export type TextareaVariants = "default" | "outlined";
|
|
4
|
+
export interface TextareaProps extends Omit<ComponentPropsWithRef<"textarea">, "size"> {
|
|
5
|
+
size?: TextareaSizes;
|
|
6
|
+
variant?: TextareaVariants;
|
|
7
|
+
label?: string;
|
|
8
|
+
helperText?: string;
|
|
9
|
+
error?: boolean | string;
|
|
10
|
+
fullWidth?: boolean;
|
|
11
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
import { ToastContextValue } from './useToast.types';
|
|
3
|
+
export declare function ToastProvider({ children }: {
|
|
4
|
+
children: ReactNode;
|
|
5
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
6
|
+
export declare function useToast(): ToastContextValue;
|
|
File without changes
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { ToastVariants, ToastPosition } from './Toast.types';
|
|
2
|
+
export interface ToastOptions {
|
|
3
|
+
message: string;
|
|
4
|
+
variant?: ToastVariants;
|
|
5
|
+
duration?: number;
|
|
6
|
+
position?: ToastPosition;
|
|
7
|
+
}
|
|
8
|
+
export interface ToastFn {
|
|
9
|
+
(options: ToastOptions): void;
|
|
10
|
+
success: (message: string, options?: Omit<ToastOptions, "message" | "variant">) => void;
|
|
11
|
+
error: (message: string, options?: Omit<ToastOptions, "message" | "variant">) => void;
|
|
12
|
+
warning: (message: string, options?: Omit<ToastOptions, "message" | "variant">) => void;
|
|
13
|
+
info: (message: string, options?: Omit<ToastOptions, "message" | "variant">) => void;
|
|
14
|
+
}
|
|
15
|
+
export interface ToastContextValue {
|
|
16
|
+
toast: ToastFn;
|
|
17
|
+
}
|