@tirth_jasoliya/ui 1.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/README.md +240 -0
- package/dist/index.cjs +3133 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +398 -0
- package/dist/index.d.ts +398 -0
- package/dist/index.js +3091 -0
- package/dist/index.js.map +1 -0
- package/package.json +44 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,398 @@
|
|
|
1
|
+
import * as React$1 from 'react';
|
|
2
|
+
import React__default, { ReactNode } from 'react';
|
|
3
|
+
import { ColumnDef, Table } from '@tanstack/react-table';
|
|
4
|
+
import { LucideIcon } from 'lucide-react';
|
|
5
|
+
import * as class_variance_authority_types from 'class-variance-authority/types';
|
|
6
|
+
import { VariantProps } from 'class-variance-authority';
|
|
7
|
+
import { motion } from 'framer-motion';
|
|
8
|
+
|
|
9
|
+
type Paths<T, Prefix extends string = ''> = T extends object ? {
|
|
10
|
+
[K in keyof T]: K extends string ? T[K] extends object ? Paths<T[K], `${Prefix}${K}.`> | `${Prefix}${K}` : `${Prefix}${K}` : never;
|
|
11
|
+
}[keyof T] : never;
|
|
12
|
+
type FilterConfig<T> = {
|
|
13
|
+
key: Paths<T>;
|
|
14
|
+
placeholder: string;
|
|
15
|
+
type?: "text" | "select" | "date" | "number";
|
|
16
|
+
options?: {
|
|
17
|
+
label: string;
|
|
18
|
+
value: string;
|
|
19
|
+
}[];
|
|
20
|
+
width?: string;
|
|
21
|
+
icon?: LucideIcon;
|
|
22
|
+
};
|
|
23
|
+
type PaginationConfig = {
|
|
24
|
+
enabled: boolean;
|
|
25
|
+
pageSize?: number;
|
|
26
|
+
pageSizeOptions?: number[];
|
|
27
|
+
showInfo?: boolean;
|
|
28
|
+
showPageNumbers?: boolean;
|
|
29
|
+
};
|
|
30
|
+
type TableSettings = {
|
|
31
|
+
hideHeader?: boolean;
|
|
32
|
+
enableSorting?: boolean;
|
|
33
|
+
toolbar?: boolean;
|
|
34
|
+
enableFiltering?: boolean;
|
|
35
|
+
enableGlobalFilter?: boolean;
|
|
36
|
+
enableColumnVisibility?: boolean;
|
|
37
|
+
enableRowSelection?: boolean;
|
|
38
|
+
enableColumnResizing?: boolean;
|
|
39
|
+
enableColumnPinning?: boolean;
|
|
40
|
+
fixedCheckboxColumn?: boolean;
|
|
41
|
+
stickyHeader?: boolean;
|
|
42
|
+
showSerialNumbers?: boolean;
|
|
43
|
+
striped?: boolean;
|
|
44
|
+
hoverable?: boolean;
|
|
45
|
+
compact?: boolean;
|
|
46
|
+
bordered?: boolean;
|
|
47
|
+
fullHeight?: boolean;
|
|
48
|
+
};
|
|
49
|
+
type GroupColumnDef<TData> = ColumnDef<TData> & {
|
|
50
|
+
columns?: GroupColumnDef<TData>[];
|
|
51
|
+
enablePinning?: boolean;
|
|
52
|
+
headerAlign?: 'left' | 'center' | 'right';
|
|
53
|
+
};
|
|
54
|
+
type DataTableProps<TData> = {
|
|
55
|
+
data: TData[];
|
|
56
|
+
columns: GroupColumnDef<TData>[];
|
|
57
|
+
filters?: FilterConfig<TData>[];
|
|
58
|
+
pagination?: PaginationConfig;
|
|
59
|
+
settings?: TableSettings;
|
|
60
|
+
header?: React.ReactNode;
|
|
61
|
+
footer?: React.ReactNode;
|
|
62
|
+
className?: string;
|
|
63
|
+
maxHeight?: string;
|
|
64
|
+
loading?: boolean;
|
|
65
|
+
error?: string;
|
|
66
|
+
emptyMessage?: string;
|
|
67
|
+
onRowSelectionChange?: (selectedRows: TData[]) => void;
|
|
68
|
+
onExport?: (data: TData[]) => void;
|
|
69
|
+
onRefresh?: () => void;
|
|
70
|
+
onTableReady?: (table: Table<TData>) => void;
|
|
71
|
+
children?: (table: Table<TData>) => React.ReactNode;
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
declare function DataTable<T>({ data, columns: initialColumns, filters, pagination, settings, header, footer, className, maxHeight, loading, error, emptyMessage, onRowSelectionChange, onExport, onRefresh, onTableReady, children, }: DataTableProps<T>): React$1.JSX.Element;
|
|
75
|
+
|
|
76
|
+
declare const buttonVariants: (props?: ({
|
|
77
|
+
variant?: "default" | "destructive" | "outline" | "secondary" | "ghost" | "link" | null | undefined;
|
|
78
|
+
size?: "default" | "sm" | "lg" | "icon" | null | undefined;
|
|
79
|
+
} & class_variance_authority_types.ClassProp) | undefined) => string;
|
|
80
|
+
declare function Button({ className, variant, size, asChild, ...props }: React$1.ComponentProps<"button"> & VariantProps<typeof buttonVariants> & {
|
|
81
|
+
asChild?: boolean;
|
|
82
|
+
}): React$1.JSX.Element;
|
|
83
|
+
|
|
84
|
+
interface DataTableActionBarProps<TData> extends React$1.ComponentProps<typeof motion.div> {
|
|
85
|
+
table: Table<TData> | null;
|
|
86
|
+
visible?: boolean;
|
|
87
|
+
container?: Element | DocumentFragment | null;
|
|
88
|
+
children: React$1.ReactNode;
|
|
89
|
+
}
|
|
90
|
+
declare function DataTableActionBar<TData>({ table, visible: visibleProp, container: containerProp, children, className, ...props }: DataTableActionBarProps<TData>): React$1.ReactPortal | null;
|
|
91
|
+
interface DataTableActionBarActionProps extends React$1.ComponentProps<typeof Button> {
|
|
92
|
+
tooltip?: string;
|
|
93
|
+
isPending?: boolean;
|
|
94
|
+
}
|
|
95
|
+
declare function DataTableActionBarAction({ size, tooltip, isPending, disabled, className, children, ...props }: DataTableActionBarActionProps): React$1.JSX.Element;
|
|
96
|
+
interface DataTableActionBarSelectionProps<TData> {
|
|
97
|
+
table: Table<TData> | null;
|
|
98
|
+
}
|
|
99
|
+
declare function DataTableActionBarSelection<TData>({ table }: DataTableActionBarSelectionProps<TData>): React$1.JSX.Element | null;
|
|
100
|
+
|
|
101
|
+
type DataTemplateField<T> = {
|
|
102
|
+
key: keyof T;
|
|
103
|
+
label: string;
|
|
104
|
+
type?: "text" | "number" | "date" | "boolean";
|
|
105
|
+
sortable?: boolean;
|
|
106
|
+
filterable?: boolean;
|
|
107
|
+
searchable?: boolean;
|
|
108
|
+
};
|
|
109
|
+
type DataTemplateFilter<T> = {
|
|
110
|
+
key: keyof T;
|
|
111
|
+
label: string;
|
|
112
|
+
type: "text" | "select" | "date" | "number" | "boolean";
|
|
113
|
+
options?: {
|
|
114
|
+
label: string;
|
|
115
|
+
value: string;
|
|
116
|
+
}[];
|
|
117
|
+
placeholder?: string;
|
|
118
|
+
icon?: LucideIcon;
|
|
119
|
+
};
|
|
120
|
+
type DataTemplatePagination = {
|
|
121
|
+
enabled: boolean;
|
|
122
|
+
pageSize?: number;
|
|
123
|
+
pageSizeOptions?: number[];
|
|
124
|
+
showInfo?: boolean;
|
|
125
|
+
showPageNumbers?: boolean;
|
|
126
|
+
};
|
|
127
|
+
type DataTemplateSettings = {
|
|
128
|
+
enableSorting?: boolean;
|
|
129
|
+
enableFiltering?: boolean;
|
|
130
|
+
enableGlobalSearch?: boolean;
|
|
131
|
+
enableSelection?: boolean;
|
|
132
|
+
enableExport?: boolean;
|
|
133
|
+
toolbar?: boolean;
|
|
134
|
+
selectionMode?: "single" | "multiple";
|
|
135
|
+
gridCols?: {
|
|
136
|
+
default: number;
|
|
137
|
+
sm?: number;
|
|
138
|
+
md?: number;
|
|
139
|
+
lg?: number;
|
|
140
|
+
xl?: number;
|
|
141
|
+
"2xl"?: number;
|
|
142
|
+
};
|
|
143
|
+
gap?: number;
|
|
144
|
+
aspectRatio?: "square" | "video" | "auto" | string;
|
|
145
|
+
minCardWidth?: number;
|
|
146
|
+
maxCardWidth?: number;
|
|
147
|
+
};
|
|
148
|
+
type DataTemplateType<T> = (item: T, index: number, isSelected: boolean, onToggleSelect: () => void) => ReactNode;
|
|
149
|
+
type DataTemplateProps<T> = {
|
|
150
|
+
data: T[];
|
|
151
|
+
template: DataTemplateType<T>;
|
|
152
|
+
fields: DataTemplateField<T>[];
|
|
153
|
+
filters?: DataTemplateFilter<T>[];
|
|
154
|
+
pagination?: DataTemplatePagination;
|
|
155
|
+
settings?: DataTemplateSettings;
|
|
156
|
+
header?: ReactNode;
|
|
157
|
+
footer?: ReactNode;
|
|
158
|
+
className?: string;
|
|
159
|
+
loading?: boolean;
|
|
160
|
+
error?: string;
|
|
161
|
+
emptyMessage?: string;
|
|
162
|
+
emptyIcon?: ReactNode;
|
|
163
|
+
onSelectionChange?: (selectedItems: T[]) => void;
|
|
164
|
+
onExport?: (data: T[]) => void;
|
|
165
|
+
onRefresh?: () => void;
|
|
166
|
+
onTemplateReady?: (controller: DataTemplateController<T>) => void;
|
|
167
|
+
children?: (controller: DataTemplateController<T>) => ReactNode;
|
|
168
|
+
};
|
|
169
|
+
type DataTemplateController<T> = {
|
|
170
|
+
getSelectedItems: () => T[];
|
|
171
|
+
clearSelection: () => void;
|
|
172
|
+
selectAll: () => void;
|
|
173
|
+
getFilteredData: () => T[];
|
|
174
|
+
getTotalCount: () => number;
|
|
175
|
+
getVisibleCount: () => number;
|
|
176
|
+
refresh: () => void;
|
|
177
|
+
exportData: () => void;
|
|
178
|
+
};
|
|
179
|
+
type DataTemplateActionBarProps<T> = {
|
|
180
|
+
controller: DataTemplateController<T>;
|
|
181
|
+
visible?: boolean;
|
|
182
|
+
container?: Element | DocumentFragment | null;
|
|
183
|
+
children: React__default.ReactNode;
|
|
184
|
+
className?: string;
|
|
185
|
+
};
|
|
186
|
+
type DataTemplateActionBarActionProps = {
|
|
187
|
+
tooltip?: string;
|
|
188
|
+
isPending?: boolean;
|
|
189
|
+
size?: "sm" | "icon";
|
|
190
|
+
variant?: "default" | "secondary" | "outline" | "ghost";
|
|
191
|
+
disabled?: boolean;
|
|
192
|
+
className?: string;
|
|
193
|
+
children: React__default.ReactNode;
|
|
194
|
+
onClick?: () => void;
|
|
195
|
+
};
|
|
196
|
+
|
|
197
|
+
declare function DataTemplate<T extends Record<string, any>>({ data, template, fields, filters, pagination, settings, header, footer, className, loading, error, emptyMessage, emptyIcon, onSelectionChange, onExport, onRefresh, onTemplateReady, children, }: DataTemplateProps<T>): React$1.JSX.Element;
|
|
198
|
+
|
|
199
|
+
declare function DataTemplateActionBar<T>({ controller, visible: visibleProp, container: containerProp, children, className, ...props }: DataTemplateActionBarProps<T> & React$1.ComponentProps<typeof motion.div>): React$1.ReactPortal | null;
|
|
200
|
+
declare function DataTemplateActionBarAction({ size, variant, tooltip, isPending, disabled, className, children, onClick, ...props }: DataTemplateActionBarActionProps): React$1.JSX.Element;
|
|
201
|
+
interface DataTemplateActionBarSelectionProps<T> {
|
|
202
|
+
controller: DataTemplateController<T>;
|
|
203
|
+
}
|
|
204
|
+
declare function DataTemplateActionBarSelection<T>({ controller }: DataTemplateActionBarSelectionProps<T>): React$1.JSX.Element | null;
|
|
205
|
+
|
|
206
|
+
type SpacingSize = 'none' | 'tight' | 'default' | 'loose' | 'extra-loose';
|
|
207
|
+
type AppContainerProps = {
|
|
208
|
+
children: ReactNode;
|
|
209
|
+
className?: string;
|
|
210
|
+
spacing?: SpacingSize;
|
|
211
|
+
padding?: 'none' | 'tight' | 'default' | 'loose';
|
|
212
|
+
};
|
|
213
|
+
|
|
214
|
+
type BreadcrumbItem<TRoute extends string = string> = {
|
|
215
|
+
label: string;
|
|
216
|
+
href?: TRoute;
|
|
217
|
+
};
|
|
218
|
+
type AppMeta<TRoute extends string = string> = {
|
|
219
|
+
title: ReactNode;
|
|
220
|
+
description?: string;
|
|
221
|
+
breadcrumbs?: BreadcrumbItem<TRoute>[];
|
|
222
|
+
primaryActions?: ReactNode;
|
|
223
|
+
secondaryActions?: ReactNode;
|
|
224
|
+
backAction?: {
|
|
225
|
+
content?: ReactNode;
|
|
226
|
+
onClick?: () => void;
|
|
227
|
+
href?: TRoute;
|
|
228
|
+
};
|
|
229
|
+
pagination?: {
|
|
230
|
+
hasNext: boolean;
|
|
231
|
+
hasPrevious: boolean;
|
|
232
|
+
onNext?: () => void;
|
|
233
|
+
onPrevious?: () => void;
|
|
234
|
+
nextLabel?: string;
|
|
235
|
+
previousLabel?: string;
|
|
236
|
+
};
|
|
237
|
+
tabs?: {
|
|
238
|
+
id: string;
|
|
239
|
+
content: ReactNode;
|
|
240
|
+
onClick?: () => void;
|
|
241
|
+
href?: TRoute;
|
|
242
|
+
isActive?: boolean;
|
|
243
|
+
}[];
|
|
244
|
+
metadata?: {
|
|
245
|
+
label: string;
|
|
246
|
+
value: ReactNode;
|
|
247
|
+
}[];
|
|
248
|
+
status?: {
|
|
249
|
+
color: 'success' | 'warning' | 'critical' | 'info' | 'default';
|
|
250
|
+
content: ReactNode;
|
|
251
|
+
};
|
|
252
|
+
};
|
|
253
|
+
type AppMetaContextType<TRoute extends string = string> = {
|
|
254
|
+
meta: AppMeta<TRoute>;
|
|
255
|
+
setMeta: (meta: Partial<AppMeta<TRoute>>) => void;
|
|
256
|
+
resetMeta: () => void;
|
|
257
|
+
};
|
|
258
|
+
|
|
259
|
+
declare const AppMetaProvider: ({ children }: {
|
|
260
|
+
children: ReactNode;
|
|
261
|
+
}) => React$1.JSX.Element;
|
|
262
|
+
declare function createTypedAppMetaContext<TRoute extends string>(): {
|
|
263
|
+
TypedAppMetaProvider: ({ children }: {
|
|
264
|
+
children: ReactNode;
|
|
265
|
+
}) => React$1.JSX.Element;
|
|
266
|
+
useTypedAppMeta: () => AppMetaContextType<TRoute>;
|
|
267
|
+
TypedAppMetaContext: React$1.Context<AppMetaContextType<TRoute> | undefined>;
|
|
268
|
+
};
|
|
269
|
+
|
|
270
|
+
declare function createPageTemplateHook<TRoute extends string>({ useTypedAppMeta, }: {
|
|
271
|
+
useTypedAppMeta: () => AppMetaContextType<TRoute>;
|
|
272
|
+
}): {
|
|
273
|
+
usePageTemplate: (options: AppMeta<TRoute>) => void;
|
|
274
|
+
};
|
|
275
|
+
|
|
276
|
+
type ColumnConfig$1 = {
|
|
277
|
+
content: ReactNode;
|
|
278
|
+
align?: 'left' | 'center' | 'right';
|
|
279
|
+
width?: 'auto' | 'fill';
|
|
280
|
+
className?: string;
|
|
281
|
+
};
|
|
282
|
+
type AppHeaderProps = {
|
|
283
|
+
className?: string;
|
|
284
|
+
columns?: [ColumnConfig$1?, ColumnConfig$1?, ColumnConfig$1?];
|
|
285
|
+
showBackButton?: boolean;
|
|
286
|
+
meta?: AppMeta;
|
|
287
|
+
};
|
|
288
|
+
|
|
289
|
+
type SplitRatio = "one-half" | "one-third" | "two-third" | "one-fourth" | "three-fourth" | "one-fifth" | "four-fifth";
|
|
290
|
+
type SheetSide = "right" | "bottom" | "left" | "top";
|
|
291
|
+
type SheetMode = "fullscreen" | "container";
|
|
292
|
+
type BaseAppContentProps = {
|
|
293
|
+
children: React__default.ReactNode;
|
|
294
|
+
className?: string;
|
|
295
|
+
variant?: "default" | "card" | "border" | "transparent";
|
|
296
|
+
header?: React__default.ReactNode;
|
|
297
|
+
footer?: React__default.ReactNode;
|
|
298
|
+
headerClassName?: string;
|
|
299
|
+
footerClassName?: string;
|
|
300
|
+
parentContainer?: boolean;
|
|
301
|
+
padding?: "none" | "tight" | "default" | "loose";
|
|
302
|
+
};
|
|
303
|
+
type FullLayoutProps = BaseAppContentProps & {
|
|
304
|
+
layout?: "full";
|
|
305
|
+
};
|
|
306
|
+
type SplitLayoutProps = BaseAppContentProps & {
|
|
307
|
+
layout: "split";
|
|
308
|
+
splitRatio?: SplitRatio;
|
|
309
|
+
reverse?: boolean;
|
|
310
|
+
};
|
|
311
|
+
type SheetOptions = {
|
|
312
|
+
sheetContent: React__default.ReactNode;
|
|
313
|
+
sheetWidth?: SplitRatio;
|
|
314
|
+
sheetSide?: SheetSide;
|
|
315
|
+
sheetMode?: SheetMode;
|
|
316
|
+
onSheetClose?: () => void;
|
|
317
|
+
showSheetOverlay?: boolean;
|
|
318
|
+
sheetClassName?: string;
|
|
319
|
+
isSheetOpen?: boolean;
|
|
320
|
+
onSheetOpenChange?: (open: boolean) => void;
|
|
321
|
+
sheetTrigger?: React__default.ReactNode;
|
|
322
|
+
disableOverlay?: boolean;
|
|
323
|
+
};
|
|
324
|
+
type WithSheetLayoutProps = BaseAppContentProps & {
|
|
325
|
+
layout: "with-sheet";
|
|
326
|
+
} & SheetOptions;
|
|
327
|
+
type AppContentProps = FullLayoutProps | SplitLayoutProps | WithSheetLayoutProps;
|
|
328
|
+
|
|
329
|
+
type ColumnConfig = {
|
|
330
|
+
content: React.ReactNode;
|
|
331
|
+
align?: 'left' | 'center' | 'right';
|
|
332
|
+
width?: 'auto' | 'fill';
|
|
333
|
+
className?: string;
|
|
334
|
+
};
|
|
335
|
+
type AppFooterProps = {
|
|
336
|
+
className?: string;
|
|
337
|
+
columns?: [ColumnConfig?, ColumnConfig?, ColumnConfig?];
|
|
338
|
+
meta?: AppMeta;
|
|
339
|
+
};
|
|
340
|
+
|
|
341
|
+
declare function createLayoutComponents<TRoute extends string>({ useTypedAppMeta, }: {
|
|
342
|
+
useTypedAppMeta: () => AppMetaContextType<TRoute>;
|
|
343
|
+
}): {
|
|
344
|
+
AppHeader: (props: Omit<AppHeaderProps, "meta">) => React$1.JSX.Element;
|
|
345
|
+
AppFooter: (props: Omit<AppFooterProps, "meta">) => React$1.JSX.Element;
|
|
346
|
+
AppContent: (props: AppContentProps) => React$1.JSX.Element;
|
|
347
|
+
AppContainer: (props: AppContainerProps) => React$1.JSX.Element;
|
|
348
|
+
};
|
|
349
|
+
|
|
350
|
+
type CopyToClipboardProps = {
|
|
351
|
+
text: string;
|
|
352
|
+
children?: React.ReactNode;
|
|
353
|
+
className?: string;
|
|
354
|
+
size?: "sm" | "default" | "lg" | "icon";
|
|
355
|
+
variant?: "ghost" | "outline" | "default" | "secondary" | "destructive" | "link";
|
|
356
|
+
};
|
|
357
|
+
type FormatINROptions = {
|
|
358
|
+
prefix?: string;
|
|
359
|
+
suffix?: string;
|
|
360
|
+
withSymbol?: boolean;
|
|
361
|
+
compact?: boolean;
|
|
362
|
+
};
|
|
363
|
+
type FormatDateOptions = {
|
|
364
|
+
format?: "dd-mm-yyyy" | "dd-mmm-yyyy" | "iso" | "long" | "short";
|
|
365
|
+
separator?: string;
|
|
366
|
+
};
|
|
367
|
+
type StatusBadgeProps = {
|
|
368
|
+
status: string | boolean | number;
|
|
369
|
+
className?: string;
|
|
370
|
+
showDot?: boolean;
|
|
371
|
+
capitalize?: boolean;
|
|
372
|
+
size?: 'sm' | 'md' | 'lg';
|
|
373
|
+
variant?: 'solid' | 'outline' | 'subtle';
|
|
374
|
+
customColors?: {
|
|
375
|
+
bg?: string;
|
|
376
|
+
text?: string;
|
|
377
|
+
border?: string;
|
|
378
|
+
dot?: string;
|
|
379
|
+
};
|
|
380
|
+
icon?: React.ReactNode;
|
|
381
|
+
};
|
|
382
|
+
declare class GeneralHelper {
|
|
383
|
+
private static currencyFormatter;
|
|
384
|
+
private static compactFormatter;
|
|
385
|
+
private static MONTH_NAMES_SHORT;
|
|
386
|
+
static copyToClipboard(text: string): Promise<void>;
|
|
387
|
+
static CopyToClipboard: ({ text, children, className, size, variant, }: CopyToClipboardProps) => React$1.JSX.Element;
|
|
388
|
+
static formatINR(amount: number, options?: FormatINROptions): string;
|
|
389
|
+
static formatDate(input: string | number | Date, options?: FormatDateOptions): string;
|
|
390
|
+
static toProperCase(text: string): string;
|
|
391
|
+
static toProperCaseAdvanced(text: string): string;
|
|
392
|
+
static StatusBadge: ({ status, className, showDot, capitalize, size, variant, customColors, icon, trueMessage, falseMessage, }: StatusBadgeProps & {
|
|
393
|
+
trueMessage?: string;
|
|
394
|
+
falseMessage?: string;
|
|
395
|
+
}) => React$1.JSX.Element;
|
|
396
|
+
}
|
|
397
|
+
|
|
398
|
+
export { type AppMeta, AppMetaProvider, DataTable, DataTableActionBar, DataTableActionBarAction, DataTableActionBarSelection, type DataTableProps, DataTemplate, DataTemplateActionBar, DataTemplateActionBarAction, DataTemplateActionBarSelection, type DataTemplateProps, GeneralHelper, createLayoutComponents, createPageTemplateHook, createTypedAppMetaContext };
|