@dimaan/ui 0.0.0
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/LICENSE +18 -0
- package/README.md +116 -0
- package/dist/index.cjs +1296 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +321 -0
- package/dist/index.d.ts +321 -0
- package/dist/index.js +1263 -0
- package/dist/index.js.map +1 -0
- package/dist/preset.css +74 -0
- package/package.json +90 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,321 @@
|
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
import * as react from 'react';
|
|
3
|
+
import { HTMLAttributes, ReactNode, ReactElement, ButtonHTMLAttributes, InputHTMLAttributes, ChangeEvent, AnchorHTMLAttributes, Ref } from 'react';
|
|
4
|
+
import { ClassValue } from 'clsx';
|
|
5
|
+
|
|
6
|
+
interface DashboardLayoutContextValue {
|
|
7
|
+
collapsed: boolean;
|
|
8
|
+
setCollapsed: (next: boolean) => void;
|
|
9
|
+
toggleCollapsed: () => void;
|
|
10
|
+
mobileOpen: boolean;
|
|
11
|
+
setMobileOpen: (next: boolean) => void;
|
|
12
|
+
toggleMobileOpen: () => void;
|
|
13
|
+
}
|
|
14
|
+
declare function useDashboardLayout(): DashboardLayoutContextValue;
|
|
15
|
+
|
|
16
|
+
type DashboardContentProps = HTMLAttributes<HTMLElement>;
|
|
17
|
+
declare function DashboardContent({ className, children, ...props }: DashboardContentProps): react_jsx_runtime.JSX.Element;
|
|
18
|
+
|
|
19
|
+
interface DashboardLayoutProps extends HTMLAttributes<HTMLDivElement> {
|
|
20
|
+
defaultCollapsed?: boolean;
|
|
21
|
+
collapsed?: boolean;
|
|
22
|
+
onCollapsedChange?: (collapsed: boolean) => void;
|
|
23
|
+
children: ReactNode;
|
|
24
|
+
}
|
|
25
|
+
declare function DashboardLayout({ defaultCollapsed, collapsed: collapsedProp, onCollapsedChange, className, children, ...props }: DashboardLayoutProps): react_jsx_runtime.JSX.Element;
|
|
26
|
+
|
|
27
|
+
type DashboardMainProps = HTMLAttributes<HTMLDivElement>;
|
|
28
|
+
declare function DashboardMain({ className, children, ...props }: DashboardMainProps): react_jsx_runtime.JSX.Element;
|
|
29
|
+
|
|
30
|
+
type RenderLink = (props: {
|
|
31
|
+
href?: string;
|
|
32
|
+
className?: string;
|
|
33
|
+
children: ReactNode;
|
|
34
|
+
'aria-current'?: 'page';
|
|
35
|
+
}) => ReactElement;
|
|
36
|
+
interface AppShellNavItem {
|
|
37
|
+
key: string;
|
|
38
|
+
label: ReactNode;
|
|
39
|
+
href?: string;
|
|
40
|
+
icon?: ReactNode;
|
|
41
|
+
active?: boolean;
|
|
42
|
+
endSlot?: ReactNode;
|
|
43
|
+
/** Optional render prop for routing libraries (e.g. react-router <Link>). */
|
|
44
|
+
render?: RenderLink;
|
|
45
|
+
}
|
|
46
|
+
interface AppShellNavGroup {
|
|
47
|
+
key: string;
|
|
48
|
+
label: ReactNode;
|
|
49
|
+
icon?: ReactNode;
|
|
50
|
+
active?: boolean;
|
|
51
|
+
defaultOpen?: boolean;
|
|
52
|
+
items: AppShellNavItem[];
|
|
53
|
+
}
|
|
54
|
+
interface AppShellNavSection {
|
|
55
|
+
key: string;
|
|
56
|
+
label?: ReactNode;
|
|
57
|
+
items: Array<AppShellNavItem | AppShellNavGroup>;
|
|
58
|
+
}
|
|
59
|
+
interface AppShellBrand {
|
|
60
|
+
logo?: ReactNode;
|
|
61
|
+
name?: ReactNode;
|
|
62
|
+
href?: string;
|
|
63
|
+
}
|
|
64
|
+
interface AppShellProps extends Pick<DashboardLayoutProps, 'defaultCollapsed' | 'collapsed' | 'onCollapsedChange'> {
|
|
65
|
+
brand?: AppShellBrand;
|
|
66
|
+
/** Either a flat list of items, or grouped sections. */
|
|
67
|
+
nav: AppShellNavSection[] | Array<AppShellNavItem | AppShellNavGroup>;
|
|
68
|
+
title?: ReactNode;
|
|
69
|
+
searchPlaceholder?: string;
|
|
70
|
+
onSearch?: (value: string) => void;
|
|
71
|
+
/** Slot rendered after the search box (e.g. notifications, user menu). */
|
|
72
|
+
headerActions?: ReactNode;
|
|
73
|
+
/** Slot rendered at the bottom of the sidebar (e.g. user badge). */
|
|
74
|
+
sidebarFooter?: ReactNode;
|
|
75
|
+
children: ReactNode;
|
|
76
|
+
}
|
|
77
|
+
declare function AppShell({ brand, nav, title, searchPlaceholder, onSearch, headerActions, sidebarFooter, defaultCollapsed, collapsed, onCollapsedChange, children, }: AppShellProps): react_jsx_runtime.JSX.Element;
|
|
78
|
+
|
|
79
|
+
interface AvatarProps extends HTMLAttributes<HTMLSpanElement> {
|
|
80
|
+
src?: string;
|
|
81
|
+
alt?: string;
|
|
82
|
+
fallback?: string;
|
|
83
|
+
size?: 'sm' | 'md' | 'lg';
|
|
84
|
+
}
|
|
85
|
+
declare function Avatar({ src, alt, fallback, size, className, ...props }: AvatarProps): react_jsx_runtime.JSX.Element;
|
|
86
|
+
|
|
87
|
+
type ButtonVariant = 'primary' | 'secondary' | 'outline' | 'ghost' | 'destructive' | 'success' | 'warning' | 'link';
|
|
88
|
+
type ButtonSize = 'sm' | 'md' | 'lg' | 'icon' | 'icon-sm';
|
|
89
|
+
declare const buttonVariantClass: Record<ButtonVariant, string>;
|
|
90
|
+
declare const buttonSizeClass: Record<ButtonSize, string>;
|
|
91
|
+
declare const buttonBaseClass = "group/button relative inline-flex items-center justify-center font-medium select-none whitespace-nowrap outline-none transition-[background-color,color,box-shadow,opacity] focus-visible:ring-2 focus-visible:ring-offset-1 focus-visible:ring-offset-background disabled:pointer-events-none disabled:opacity-50 aria-disabled:pointer-events-none aria-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0";
|
|
92
|
+
|
|
93
|
+
interface ButtonProps extends ButtonHTMLAttributes<HTMLButtonElement> {
|
|
94
|
+
variant?: ButtonVariant;
|
|
95
|
+
size?: ButtonSize;
|
|
96
|
+
/** Show a leading spinner and disable interaction. */
|
|
97
|
+
loading?: boolean;
|
|
98
|
+
/** Optional text shown beside the spinner while loading. Defaults to keeping `children` visible. */
|
|
99
|
+
loadingText?: ReactNode;
|
|
100
|
+
/** Element rendered before the label (auto-hidden while loading). */
|
|
101
|
+
leadingIcon?: ReactNode;
|
|
102
|
+
/** Element rendered after the label (auto-hidden while loading). */
|
|
103
|
+
trailingIcon?: ReactNode;
|
|
104
|
+
/** Stretch to fill the parent's inline width. */
|
|
105
|
+
fullWidth?: boolean;
|
|
106
|
+
/**
|
|
107
|
+
* Render the button's classes onto the single child element instead of a `<button>`.
|
|
108
|
+
* Useful for routing libraries — e.g. `<Button asChild><Link to="/x">Go</Link></Button>`.
|
|
109
|
+
*/
|
|
110
|
+
asChild?: boolean;
|
|
111
|
+
}
|
|
112
|
+
declare const Button: react.ForwardRefExoticComponent<ButtonProps & react.RefAttributes<HTMLButtonElement>>;
|
|
113
|
+
|
|
114
|
+
type CheckboxSize = 'sm' | 'md';
|
|
115
|
+
interface CheckboxProps extends Omit<InputHTMLAttributes<HTMLInputElement>, 'type' | 'size' | 'onChange'> {
|
|
116
|
+
/** Tri-state visual: when true, renders a dash and sets `aria-checked="mixed"`. */
|
|
117
|
+
indeterminate?: boolean;
|
|
118
|
+
/** Convenience handler that receives the new checked boolean. */
|
|
119
|
+
onCheckedChange?: (checked: boolean) => void;
|
|
120
|
+
/** Standard change handler. Fires alongside `onCheckedChange`. */
|
|
121
|
+
onChange?: (event: ChangeEvent<HTMLInputElement>) => void;
|
|
122
|
+
size?: CheckboxSize;
|
|
123
|
+
}
|
|
124
|
+
declare const Checkbox: react.ForwardRefExoticComponent<CheckboxProps & react.RefAttributes<HTMLInputElement>>;
|
|
125
|
+
|
|
126
|
+
type DashboardHeaderProps = HTMLAttributes<HTMLElement>;
|
|
127
|
+
declare function DashboardHeader({ className, children, ...props }: DashboardHeaderProps): react_jsx_runtime.JSX.Element;
|
|
128
|
+
|
|
129
|
+
type HeaderActionsProps = HTMLAttributes<HTMLDivElement>;
|
|
130
|
+
declare function HeaderActions({ className, children, ...props }: HeaderActionsProps): react_jsx_runtime.JSX.Element;
|
|
131
|
+
|
|
132
|
+
interface HeaderCollapseTriggerProps extends Omit<ButtonProps, 'aria-label' | 'children'> {
|
|
133
|
+
'aria-label'?: string;
|
|
134
|
+
icon?: ReactNode;
|
|
135
|
+
}
|
|
136
|
+
declare function HeaderCollapseTrigger({ icon, className, onClick, variant, size, 'aria-label': ariaLabel, ...props }: HeaderCollapseTriggerProps): react_jsx_runtime.JSX.Element;
|
|
137
|
+
|
|
138
|
+
interface HeaderMobileTriggerProps extends Omit<ButtonProps, 'aria-label' | 'children'> {
|
|
139
|
+
'aria-label'?: string;
|
|
140
|
+
icon?: ReactNode;
|
|
141
|
+
}
|
|
142
|
+
declare function HeaderMobileTrigger({ icon, className, onClick, variant, size, 'aria-label': ariaLabel, ...props }: HeaderMobileTriggerProps): react_jsx_runtime.JSX.Element;
|
|
143
|
+
|
|
144
|
+
interface HeaderSearchProps extends InputHTMLAttributes<HTMLInputElement> {
|
|
145
|
+
icon?: ReactNode;
|
|
146
|
+
containerClassName?: string;
|
|
147
|
+
}
|
|
148
|
+
declare const HeaderSearch: react.ForwardRefExoticComponent<HeaderSearchProps & react.RefAttributes<HTMLInputElement>>;
|
|
149
|
+
|
|
150
|
+
type HeaderTitleProps = HTMLAttributes<HTMLDivElement>;
|
|
151
|
+
declare function HeaderTitle({ className, children, ...props }: HeaderTitleProps): react_jsx_runtime.JSX.Element;
|
|
152
|
+
|
|
153
|
+
type SidebarProps = HTMLAttributes<HTMLElement>;
|
|
154
|
+
declare function Sidebar({ className, children, ...props }: SidebarProps): react_jsx_runtime.JSX.Element;
|
|
155
|
+
|
|
156
|
+
type SidebarFooterProps = HTMLAttributes<HTMLDivElement>;
|
|
157
|
+
declare function SidebarFooter({ className, children, ...props }: SidebarFooterProps): react_jsx_runtime.JSX.Element;
|
|
158
|
+
|
|
159
|
+
interface SidebarGroupProps extends HTMLAttributes<HTMLDivElement> {
|
|
160
|
+
label?: ReactNode;
|
|
161
|
+
}
|
|
162
|
+
declare function SidebarGroup({ label, className, children, ...props }: SidebarGroupProps): react_jsx_runtime.JSX.Element;
|
|
163
|
+
|
|
164
|
+
type SidebarHeaderProps = HTMLAttributes<HTMLDivElement>;
|
|
165
|
+
declare function SidebarHeader({ className, children, ...props }: SidebarHeaderProps): react_jsx_runtime.JSX.Element;
|
|
166
|
+
|
|
167
|
+
type SidebarNavProps = HTMLAttributes<HTMLElement>;
|
|
168
|
+
declare function SidebarNav({ className, children, ...props }: SidebarNavProps): react_jsx_runtime.JSX.Element;
|
|
169
|
+
|
|
170
|
+
interface SidebarNavGroupProps extends Omit<ButtonHTMLAttributes<HTMLButtonElement>, 'children'> {
|
|
171
|
+
icon?: ReactNode;
|
|
172
|
+
label?: ReactNode;
|
|
173
|
+
endSlot?: ReactNode;
|
|
174
|
+
/** Highlight the parent (e.g. when one of its children is active). */
|
|
175
|
+
active?: boolean;
|
|
176
|
+
/** Uncontrolled initial state. */
|
|
177
|
+
defaultOpen?: boolean;
|
|
178
|
+
/** Controlled open state. */
|
|
179
|
+
open?: boolean;
|
|
180
|
+
onOpenChange?: (open: boolean) => void;
|
|
181
|
+
children: ReactNode;
|
|
182
|
+
}
|
|
183
|
+
declare function SidebarNavGroup({ icon, label, endSlot, active, defaultOpen, open: openProp, onOpenChange, className, children, onClick, ...props }: SidebarNavGroupProps): react_jsx_runtime.JSX.Element;
|
|
184
|
+
|
|
185
|
+
type SidebarNavItemRenderProps = {
|
|
186
|
+
className: string;
|
|
187
|
+
children: ReactNode;
|
|
188
|
+
title?: string;
|
|
189
|
+
'aria-current'?: 'page';
|
|
190
|
+
'data-active'?: 'true';
|
|
191
|
+
};
|
|
192
|
+
interface SidebarNavItemProps extends AnchorHTMLAttributes<HTMLAnchorElement> {
|
|
193
|
+
icon?: ReactNode;
|
|
194
|
+
active?: boolean;
|
|
195
|
+
label?: ReactNode;
|
|
196
|
+
endSlot?: ReactNode;
|
|
197
|
+
/**
|
|
198
|
+
* Override the rendered element. Use this to plug in routing-library link
|
|
199
|
+
* components (e.g. react-router `<Link>`) while keeping the styling.
|
|
200
|
+
*/
|
|
201
|
+
render?: (props: SidebarNavItemRenderProps) => ReactElement;
|
|
202
|
+
}
|
|
203
|
+
declare function SidebarNavItem({ icon, active, label, endSlot, className, children, render, ...props }: SidebarNavItemProps): react_jsx_runtime.JSX.Element;
|
|
204
|
+
|
|
205
|
+
type TableSize = 'sm' | 'md' | 'lg';
|
|
206
|
+
interface TableSizeClasses {
|
|
207
|
+
/** Applied to <tr> when needed (currently empty — present for symmetry). */
|
|
208
|
+
row: string;
|
|
209
|
+
/** Applied to <td>. */
|
|
210
|
+
cell: string;
|
|
211
|
+
/** Applied to <th>. */
|
|
212
|
+
head: string;
|
|
213
|
+
}
|
|
214
|
+
declare const tableSizeClass: Record<TableSize, TableSizeClasses>;
|
|
215
|
+
declare const tableBaseClass = "w-full caption-bottom border-collapse";
|
|
216
|
+
declare const selectedRowClass = "bg-muted/40";
|
|
217
|
+
declare const sortIconClass = "inline-flex h-3 w-3 shrink-0 items-center justify-center";
|
|
218
|
+
declare const alignClass: Record<ColumnAlign, string>;
|
|
219
|
+
|
|
220
|
+
type SortDirection = 'asc' | 'desc';
|
|
221
|
+
interface SortState {
|
|
222
|
+
/** Column id being sorted, or `null` when no sort is active. */
|
|
223
|
+
columnId: string | null;
|
|
224
|
+
direction: SortDirection;
|
|
225
|
+
}
|
|
226
|
+
interface PaginationState {
|
|
227
|
+
/** 0-based page index. */
|
|
228
|
+
pageIndex: number;
|
|
229
|
+
pageSize: number;
|
|
230
|
+
}
|
|
231
|
+
/** Set of row ids (returned from `getRowId`) that are currently selected. */
|
|
232
|
+
type RowSelectionState = ReadonlySet<string>;
|
|
233
|
+
type SortableValue = string | number | bigint | boolean | Date | null | undefined;
|
|
234
|
+
type ColumnAlign = 'start' | 'center' | 'end';
|
|
235
|
+
interface Column<T> {
|
|
236
|
+
/** Stable column id. Used for sort state and React keys. */
|
|
237
|
+
id: string;
|
|
238
|
+
/** Header label, ReactNode, or a function that returns the header content. */
|
|
239
|
+
header: ReactNode | (() => ReactNode);
|
|
240
|
+
/** Field on T to read for default rendering and default sorting. */
|
|
241
|
+
accessor?: keyof T;
|
|
242
|
+
/** Custom cell renderer. If omitted, renders `String(row[accessor] ?? '')`. */
|
|
243
|
+
render?: (row: T, rowIndex: number) => ReactNode;
|
|
244
|
+
/** Enable click-to-sort UI on the header. */
|
|
245
|
+
sortable?: boolean;
|
|
246
|
+
/** Optional override for the value used to compare during sorting. */
|
|
247
|
+
sortAccessor?: (row: T) => SortableValue;
|
|
248
|
+
/** Tailwind classes applied to both <th> and <td>. */
|
|
249
|
+
className?: string;
|
|
250
|
+
/** Inline alignment hint. Defaults to 'start'. */
|
|
251
|
+
align?: ColumnAlign;
|
|
252
|
+
}
|
|
253
|
+
interface TableProps<T> {
|
|
254
|
+
/** Source rows. In server-side mode, this is just the current page. */
|
|
255
|
+
data: readonly T[];
|
|
256
|
+
/** Column definitions. */
|
|
257
|
+
columns: ReadonlyArray<Column<T>>;
|
|
258
|
+
/** Stable id for each row. Required for selection; recommended always. */
|
|
259
|
+
getRowId: (row: T, index: number) => string;
|
|
260
|
+
/**
|
|
261
|
+
* Total row count across all pages. Pass this when the parent paginates/sorts
|
|
262
|
+
* server-side — Table will skip its local sort + slice.
|
|
263
|
+
*/
|
|
264
|
+
totalCount?: number;
|
|
265
|
+
defaultSort?: SortState;
|
|
266
|
+
sort?: SortState;
|
|
267
|
+
onSortChange?: (next: SortState) => void;
|
|
268
|
+
defaultPagination?: PaginationState;
|
|
269
|
+
pagination?: PaginationState;
|
|
270
|
+
onPaginationChange?: (next: PaginationState) => void;
|
|
271
|
+
/** Page size dropdown options. Defaults to [10, 25, 50]. */
|
|
272
|
+
pageSizeOptions?: readonly number[];
|
|
273
|
+
/** Force the paginator to render even when rowCount <= pageSize. */
|
|
274
|
+
showPagination?: boolean;
|
|
275
|
+
/** Adds the selection column + header checkbox. */
|
|
276
|
+
enableRowSelection?: boolean;
|
|
277
|
+
defaultSelectedRowIds?: ReadonlySet<string>;
|
|
278
|
+
selectedRowIds?: ReadonlySet<string>;
|
|
279
|
+
onSelectedRowIdsChange?: (next: ReadonlySet<string>) => void;
|
|
280
|
+
/** Per-row guard. Disabled rows have a disabled checkbox and are excluded from "select all". */
|
|
281
|
+
isRowSelectable?: (row: T) => boolean;
|
|
282
|
+
/** Render prop receives the array of selected rows currently present in `data`. */
|
|
283
|
+
bulkActions?: (selectedRows: T[]) => ReactNode;
|
|
284
|
+
/** Override the "{n} selected" label (i18n / RTL). */
|
|
285
|
+
renderSelectionLabel?: (count: number) => ReactNode;
|
|
286
|
+
/** Label for the "Clear" button on the toolbar. */
|
|
287
|
+
clearSelectionLabel?: ReactNode;
|
|
288
|
+
loading?: boolean;
|
|
289
|
+
/** Number of skeleton rows shown while loading. Defaults to current pageSize. */
|
|
290
|
+
loadingRowCount?: number;
|
|
291
|
+
/** Empty-state slot. Defaults to a centered "No data" message. */
|
|
292
|
+
emptyState?: ReactNode;
|
|
293
|
+
size?: TableSize;
|
|
294
|
+
className?: string;
|
|
295
|
+
tableClassName?: string;
|
|
296
|
+
/**
|
|
297
|
+
* Constrain the scrollable region's height. Accepts any CSS length (e.g. `400`,
|
|
298
|
+
* `'24rem'`, `'60vh'`). When set, the body scrolls vertically and the header
|
|
299
|
+
* sticks to the top.
|
|
300
|
+
*/
|
|
301
|
+
maxHeight?: number | string;
|
|
302
|
+
/** Stripe alternating rows. Defaults to false. */
|
|
303
|
+
striped?: boolean;
|
|
304
|
+
/** Optional row click handler. */
|
|
305
|
+
onRowClick?: (row: T, rowIndex: number) => void;
|
|
306
|
+
/** Optional ref to the underlying <table> element. */
|
|
307
|
+
tableRef?: Ref<HTMLTableElement>;
|
|
308
|
+
'aria-label'?: string;
|
|
309
|
+
'aria-labelledby'?: string;
|
|
310
|
+
/** Caption rendered as <caption className="sr-only"> for assistive tech. */
|
|
311
|
+
caption?: ReactNode;
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
declare function Table<T>(props: TableProps<T>): react_jsx_runtime.JSX.Element;
|
|
315
|
+
|
|
316
|
+
type Direction = 'ltr' | 'rtl';
|
|
317
|
+
declare function useDirection(): Direction;
|
|
318
|
+
|
|
319
|
+
declare function cn(...inputs: ClassValue[]): string;
|
|
320
|
+
|
|
321
|
+
export { AppShell, type AppShellBrand, type AppShellNavGroup, type AppShellNavItem, type AppShellNavSection, type AppShellProps, Avatar, type AvatarProps, Button, type ButtonProps, type ButtonSize, type ButtonVariant, Checkbox, type CheckboxProps, type CheckboxSize, type Column, type ColumnAlign, DashboardContent, type DashboardContentProps, DashboardHeader, type DashboardHeaderProps, DashboardLayout, type DashboardLayoutContextValue, type DashboardLayoutProps, DashboardMain, type DashboardMainProps, type Direction, HeaderActions, type HeaderActionsProps, HeaderCollapseTrigger, type HeaderCollapseTriggerProps, HeaderMobileTrigger, type HeaderMobileTriggerProps, HeaderSearch, type HeaderSearchProps, HeaderTitle, type HeaderTitleProps, type PaginationState, type RowSelectionState, Sidebar, SidebarFooter, type SidebarFooterProps, SidebarGroup, type SidebarGroupProps, SidebarHeader, type SidebarHeaderProps, SidebarNav, SidebarNavGroup, type SidebarNavGroupProps, SidebarNavItem, type SidebarNavItemProps, type SidebarNavItemRenderProps, type SidebarNavProps, type SidebarProps, type SortDirection, type SortState, type SortableValue, Table, type TableProps, type TableSize, type TableSizeClasses, buttonBaseClass, buttonSizeClass, buttonVariantClass, cn, alignClass as tableAlignClass, tableBaseClass, selectedRowClass as tableSelectedRowClass, tableSizeClass, sortIconClass as tableSortIconClass, useDashboardLayout, useDirection };
|