Skip to content

Commit 517868f

Browse files
v1.0.3
* data tables done * 1.0.3 * dashboard widgets, resizable, drag and drop, with actions done * persist layout to local storage done
1 parent 410bd5a commit 517868f

39 files changed

+2648
-399
lines changed

dist/index.d.ts

Lines changed: 120 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
import * as React$1 from 'react';
2-
import React__default, { ReactNode } from 'react';
3-
import * as react_jsx_runtime from 'react/jsx-runtime';
1+
import React$1, { ReactNode, ComponentType } from 'react';
42
import { ZodSchema } from 'zod';
53

64
/** Each item within a section */
@@ -135,7 +133,7 @@ interface DashboardProps {
135133
* Preferred:
136134
* - New apps should use: sidebar + navbar (+ footer when needed)
137135
*/
138-
declare const Template: React__default.FC<DashboardProps>;
136+
declare function Template({ children, sidebarContent, logo, onLogout, navbar, footer, }: DashboardProps): JSX.Element;
139137

140138
/**
141139
* Props for `Breadcrumb` component.
@@ -148,7 +146,7 @@ interface BreadcrumbProps {
148146
* Accessible breadcrumb navigation.
149147
* Renders a current page label and a link to home.
150148
*/
151-
declare const Breadcrumb: React__default.FC<BreadcrumbProps>;
149+
declare const Breadcrumb: React$1.FC<BreadcrumbProps>;
152150

153151
/** The list of supported field types. */
154152
type FieldType = 'text' | 'number' | 'textarea' | 'select' | 'checkbox' | 'multiSelect' | 'custom';
@@ -175,14 +173,14 @@ interface FieldConfigDynamicForm {
175173
/** For select or multiSelect, an array of label/value pairs. */
176174
options?: FieldOption[];
177175
/** Default initial value (e.g. '', 0, [], etc.). */
178-
defaultValue?: any;
176+
defaultValue?: unknown;
179177
/** For multiSelect or custom logic, an optional URL for searching. */
180178
/**
181179
* If `type` is 'custom', you can specify a React component
182180
* that the form will render. This component should accept
183-
* props like { value: any, onChange: (val: any) => void } at minimum.
181+
* props like { value: unknown, onChange: (val: unknown) => void } at minimum.
184182
*/
185-
component?: React__default.ComponentType<any>;
183+
component?: ComponentType<Record<string, unknown>>;
186184
step?: string;
187185
/**
188186
* Tailwind classes for the field wrapper (the <div>).
@@ -194,19 +192,19 @@ interface FieldConfigDynamicForm {
194192
*/
195193
labelClassName?: string;
196194
inputClassName?: string;
197-
props?: Record<string, any>;
195+
props?: Record<string, unknown>;
198196
}
199197

200198
interface ControlledZodDynamicFormProps {
201-
schema: ZodSchema<any>;
199+
schema: ZodSchema<Record<string, unknown>>;
202200
fields: FieldConfigDynamicForm[];
203-
values: Record<string, any>;
204-
onChangeField: (fieldName: string, newValue: any) => void;
205-
onSubmit: (parsedValues: Record<string, any>) => void;
201+
values: Record<string, unknown>;
202+
onChangeField: (fieldName: string, newValue: unknown) => void;
203+
onSubmit: (parsedValues: Record<string, unknown>) => void;
206204
submitLabel?: string;
207-
header?: React__default.ReactNode;
205+
header?: ReactNode;
208206
}
209-
declare function ControlledZodDynamicForm({ schema, fields, values, onChangeField, onSubmit, submitLabel, header, }: ControlledZodDynamicFormProps): react_jsx_runtime.JSX.Element;
207+
declare function ControlledZodDynamicForm({ schema, fields, values, onChangeField, onSubmit, submitLabel, header, }: ControlledZodDynamicFormProps): JSX.Element;
210208

211209
interface ToolbarItem {
212210
/** Whether to show/hide the item. Default is true. */
@@ -217,7 +215,7 @@ interface ToolbarItem {
217215
*/
218216
position?: 'left' | 'right';
219217
/** The React node to render. e.g. a search input, a button, etc. */
220-
node: React__default.ReactNode;
218+
node: React$1.ReactNode;
221219
}
222220

223221
interface ColumnConfigTable<T> {
@@ -231,6 +229,24 @@ interface ColumnConfigTable<T> {
231229
anchor: HTMLElement | null;
232230
content: React.ReactNode;
233231
}) => void) => React.ReactNode;
232+
/** Sorting configuration */
233+
sortable?: boolean;
234+
sortComparator?: (a: unknown, b: unknown, rowA: T, rowB: T) => number;
235+
/** Filtering configuration */
236+
filterable?: boolean;
237+
filterPredicate?: (value: unknown, row: T, query: string) => boolean;
238+
/** Inline editing configuration */
239+
editable?: boolean;
240+
editor?: (args: {
241+
value: unknown;
242+
row: T;
243+
rowIndex: number;
244+
onChange: (next: unknown) => void;
245+
onCommit: () => void;
246+
onCancel: () => void;
247+
}) => React.ReactNode;
248+
/** Optional className for the cell */
249+
cellClassName?: string;
234250
}
235251

236252
/**
@@ -253,14 +269,67 @@ interface TableDataCustomProps<T> {
253269
pagination?: PaginationProps;
254270
errorMessage?: string | null;
255271
toolbarItems?: ToolbarItem[];
272+
/** Feature toggles */
273+
enableSelection?: boolean;
274+
enableSorting?: boolean;
275+
enableFilter?: boolean;
276+
enableInlineEdit?: boolean;
277+
/** Filtering (controlled/uncontrolled) */
278+
filterQuery?: string;
279+
onFilterQueryChange?: (query: string) => void;
280+
/** Selection callback */
281+
onSelectionChange?: (selectedRows: T[], selectedIndices: number[]) => void;
282+
/** Inline cell edit callback */
283+
onCellEdit?: (rowIndex: number, columnKey: keyof T, nextValue: unknown, row: T) => void;
256284
}
257285

258286
/**
259287
* Public table component with built-in error boundary.
260288
* Wraps `TableDataCustomBase` in `TableErrorBoundary` to provide a safe fallback.
261289
* Consumers should import `TableDataCustom` from the package root.
262290
*/
263-
declare function TableDataCustom<T>(props: TableDataCustomProps<T>): react_jsx_runtime.JSX.Element;
291+
declare function TableDataCustom<T>(props: TableDataCustomProps<T>): JSX.Element;
292+
293+
type WidgetType = 'card' | 'stat' | 'progress' | 'activity' | 'chart' | 'custom';
294+
type WidgetId = string;
295+
type WidgetPosition = {
296+
x: number;
297+
y: number;
298+
w: number;
299+
h: number;
300+
};
301+
type BaseWidgetConfig = {
302+
id: WidgetId;
303+
type: WidgetType;
304+
title?: string;
305+
position: WidgetPosition;
306+
props?: Record<string, unknown>;
307+
};
308+
type DashboardLayout = BaseWidgetConfig[];
309+
type GridConfig = {
310+
cols: number;
311+
rowHeight: number;
312+
gap: number;
313+
};
314+
type ChartKind = 'line' | 'bar' | 'pie';
315+
type ChartAdapter = {
316+
render: (kind: ChartKind, props: Record<string, unknown>) => JSX.Element;
317+
};
318+
319+
type Props = {
320+
grid: GridConfig;
321+
widgets: DashboardLayout;
322+
onLayoutChange?: (next: DashboardLayout) => void;
323+
renderWidget?: (w: BaseWidgetConfig) => JSX.Element;
324+
chartAdapter?: ChartAdapter;
325+
enableDrag?: boolean;
326+
enableResize?: boolean;
327+
showActions?: boolean;
328+
persistKey?: string;
329+
};
330+
declare function DashboardGrid({ grid, widgets, onLayoutChange, renderWidget, chartAdapter, enableDrag, enableResize, showActions, persistKey, }: Props): JSX.Element;
331+
332+
declare const DefaultChartAdapter: ChartAdapter;
264333

265334
/**
266335
* Setter type used by `useLocalStorage`.
@@ -278,7 +347,7 @@ declare function useLocalStorage<T>(key: string, initialValue: T): [T, (value: S
278347
* Toggles `dark` class on `<body>` when mode is 'dark'.
279348
* Returns `[colorMode, setColorMode]`.
280349
*/
281-
declare const useColorMode: () => (string | ((value: SetValue<string>) => void))[];
350+
declare const useColorMode: () => [string, (value: string | ((val: string) => string)) => void];
282351

283352
/**
284353
* Generate a compact page list for pagination controls.
@@ -308,17 +377,18 @@ type UseLoginOptions<TUser = unknown> = {
308377
login: (credentials: LoginCredentials) => Promise<LoginResult<TUser>>;
309378
schema?: ZodSchema<LoginCredentials>;
310379
};
311-
/**
312-
* A composable login hook: manages form state, validation, submit, and loading/errors.
313-
*/
314-
declare function useLogin<TUser = unknown>({ login, schema }: UseLoginOptions<TUser>): {
380+
type UseLoginReturn<TUser = unknown> = {
315381
values: LoginCredentials;
316382
update: <K extends keyof LoginCredentials>(key: K, value: LoginCredentials[K]) => void;
317383
submit: () => Promise<LoginResult<TUser>>;
318384
loading: boolean;
319385
error: string | null;
320386
result: LoginResult<TUser> | null;
321387
};
388+
/**
389+
* A composable login hook: manages form state, validation, submit, and loading/errors.
390+
*/
391+
declare function useLogin<TUser = unknown>({ login, schema, }: UseLoginOptions<TUser>): UseLoginReturn<TUser>;
322392

323393
/**
324394
* Generic registration payload.
@@ -331,17 +401,18 @@ type UseRegisterOptions<TUser = unknown> = {
331401
register: (payload: RegisterPayload) => Promise<TUser>;
332402
schema?: ZodSchema<RegisterPayload>;
333403
};
334-
/**
335-
* A composable registration hook: manages form state, validation, submit, and loading/errors.
336-
*/
337-
declare function useRegister<TUser = unknown>({ register, schema }: UseRegisterOptions<TUser>): {
404+
type UseRegisterReturn<TUser = unknown> = {
338405
values: RegisterPayload;
339406
update: <K extends string>(key: K, value: unknown) => void;
340407
submit: () => Promise<TUser>;
341408
loading: boolean;
342409
error: string | null;
343410
user: TUser | null;
344411
};
412+
/**
413+
* A composable registration hook: manages form state, validation, submit, and loading/errors.
414+
*/
415+
declare function useRegister<TUser = unknown>({ register, schema, }: UseRegisterOptions<TUser>): UseRegisterReturn<TUser>;
345416

346417
/**
347418
* Password reset input: allow email or username.
@@ -357,35 +428,48 @@ type UsePasswordResetOptions = {
357428
reset: (input: PasswordResetInput) => Promise<void>;
358429
schema?: ZodSchema<PasswordResetInput>;
359430
};
360-
/**
361-
* A composable password reset hook: manages form state, validation, submit, and loading/errors.
362-
*/
363-
declare function usePasswordReset({ reset, schema }: UsePasswordResetOptions): {
431+
type UsePasswordResetReturn = {
364432
values: PasswordResetInput;
365433
update: <K extends keyof PasswordResetInput>(key: K, value: PasswordResetInput[K]) => void;
366434
submit: () => Promise<void>;
367435
loading: boolean;
368436
error: string | null;
369437
success: boolean;
370438
};
439+
/**
440+
* A composable password reset hook: manages form state, validation, submit, and loading/errors.
441+
*/
442+
declare function usePasswordReset({ reset, schema, }: UsePasswordResetOptions): UsePasswordResetReturn;
371443

372444
/**
373445
* Manage ARIA live region announcements.
374446
* Returns a ref to attach to an element with `aria-live="polite"` or `assertive`.
375447
* Use `announce()` to set text content.
376448
*/
377-
declare function useLiveRegion(): {
378-
ref: React$1.MutableRefObject<HTMLElement | null>;
449+
type LiveRegionReturn = {
450+
ref: React.MutableRefObject<HTMLElement | null>;
379451
announce: (message: string) => void;
380452
};
453+
declare function useLiveRegion(): LiveRegionReturn;
381454
/**
382455
* Trap focus within a container element (e.g., modal) while `active`.
383456
* Adds keydown handlers to cycle focus.
384457
*/
385-
declare function useFocusTrap(active: boolean): {
386-
ref: React$1.MutableRefObject<HTMLElement | null>;
458+
type FocusTrapReturn = {
459+
ref: React.MutableRefObject<HTMLElement | null>;
387460
};
461+
declare function useFocusTrap(active: boolean): FocusTrapReturn;
388462

389-
var undefined$1 = undefined;
463+
type RovingConfig = {
464+
/** CSS selector for focusable items inside the container */
465+
selector: string;
466+
/** Optional: initial index to focus when mounted */
467+
initialIndex?: number;
468+
};
469+
/**
470+
* Roving tabindex keyboard navigation for lists/menus.
471+
* Attach to a container element; items should be focusable via `tabindex`.
472+
*/
473+
declare function useKeyboardNavigation(container: HTMLElement | null, { selector, initialIndex }: RovingConfig): void;
390474

391-
export { Breadcrumb, type BreadcrumbProps, type ColumnConfigTable, ControlledZodDynamicForm, type ControlledZodDynamicFormProps, type DashboardProps, type FieldConfigDynamicForm, type LoginCredentials, type LoginResult, type PaginationProps, type PasswordResetInput, type RegisterPayload, type SidebarActionItem, type SidebarExternalLink, type SidebarInternalLink, type SidebarItem$1 as SidebarItem, type SidebarSection, TableDataCustom, type TableDataCustomProps, Template, type TemplateFooterConfig, type TemplateLayoutConfig, type TemplateNavbarBrandConfig, type TemplateNavbarConfig, type TemplateSidebarConfig, type SidebarItem as TemplateSidebarItem, type ToolbarItem, type UseLoginOptions, type UsePasswordResetOptions, type UseRegisterOptions, type VisibilityRule, generatePageNumbers, useColorMode, useFocusTrap, undefined$1 as useKeyboardNavigation, useLiveRegion, useLocalStorage, useLogin, usePasswordReset, useRegister };
475+
export { type BaseWidgetConfig, Breadcrumb, type BreadcrumbProps, type ChartAdapter, type ChartKind, type ColumnConfigTable, ControlledZodDynamicForm, type ControlledZodDynamicFormProps, DashboardGrid, type DashboardLayout, type DashboardProps, DefaultChartAdapter, type FieldConfigDynamicForm, type GridConfig, type LoginCredentials, type LoginResult, type PaginationProps, type PasswordResetInput, type RegisterPayload, type SidebarActionItem, type SidebarExternalLink, type SidebarInternalLink, type SidebarItem$1 as SidebarItem, type SidebarSection, TableDataCustom, type TableDataCustomProps, Template, type TemplateFooterConfig, type TemplateLayoutConfig, type TemplateNavbarBrandConfig, type TemplateNavbarConfig, type TemplateSidebarConfig, type SidebarItem as TemplateSidebarItem, type ToolbarItem, type UseLoginOptions, type UsePasswordResetOptions, type UseRegisterOptions, type VisibilityRule, type WidgetPosition, type WidgetType, generatePageNumbers, useColorMode, useFocusTrap, useKeyboardNavigation, useLiveRegion, useLocalStorage, useLogin, usePasswordReset, useRegister };

0 commit comments

Comments
 (0)