warqadui 0.0.10 → 0.0.11

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/dist/index.d.mts CHANGED
@@ -1,9 +1,9 @@
1
1
  import * as React$1 from 'react';
2
- import React__default, { ReactNode } from 'react';
2
+ import React__default, { ReactNode, HTMLAttributes } from 'react';
3
3
  import * as react_jsx_runtime from 'react/jsx-runtime';
4
4
  import * as react_hook_form from 'react-hook-form';
5
5
  import { FieldValues, Path, UseFormReturn } from 'react-hook-form';
6
- import { ColumnDef, SortingState, ColumnFiltersState } from '@tanstack/react-table';
6
+ import { ColumnDef, SortingState, ColumnFiltersState, RowData } from '@tanstack/react-table';
7
7
 
8
8
  interface ButtonProps extends React__default.ButtonHTMLAttributes<HTMLButtonElement> {
9
9
  variant?: "primary" | "secondary" | "outline" | "ghost" | "danger" | "warning";
@@ -26,9 +26,10 @@ interface DashboardLayoutProps {
26
26
  children: React__default.ReactNode;
27
27
  navItems: NavItems;
28
28
  title?: string;
29
- logo?: React__default.ReactNode;
29
+ logo?: React__default.ReactNode | string;
30
30
  userProfile?: React__default.ReactNode;
31
31
  fontFamily?: string;
32
+ sidebarFooter?: React__default.ReactNode;
32
33
  }
33
34
  declare const DashboardLayout: React__default.FC<DashboardLayoutProps>;
34
35
 
@@ -165,7 +166,7 @@ declare const DateInput: <T extends FieldValues>(props: DateInputProps<T> & {
165
166
 
166
167
  interface SearchApiProps extends Omit<React__default.InputHTMLAttributes<HTMLInputElement>, "onChange" | "value"> {
167
168
  label?: string;
168
- apiUrl: string;
169
+ api: string;
169
170
  placeholder?: string;
170
171
  value?: any;
171
172
  onChange?: (value: any) => void;
@@ -179,6 +180,7 @@ interface SearchApiProps extends Omit<React__default.InputHTMLAttributes<HTMLInp
179
180
  obj?: any;
180
181
  filter?: any[];
181
182
  v?: number;
183
+ variant?: "ghost" | "default";
182
184
  }
183
185
  declare const SearchApi: React__default.ForwardRefExoticComponent<SearchApiProps & React__default.RefAttributes<HTMLDivElement>>;
184
186
 
@@ -198,17 +200,19 @@ interface Option {
198
200
  label: string;
199
201
  disabled?: boolean;
200
202
  }
201
- interface SelectProps extends Omit<React.SelectHTMLAttributes<HTMLSelectElement>, "onChange"> {
202
- label: string;
203
+ interface SelectProps extends Omit<React__default.SelectHTMLAttributes<HTMLSelectElement>, "onChange" | "value"> {
204
+ label?: string;
203
205
  options: Option[];
204
- icon?: React.ReactNode;
206
+ icon?: React__default.ReactNode;
205
207
  error?: string;
206
208
  containerClassName?: string;
207
209
  name?: any;
208
210
  form?: any;
209
211
  onChange?: (value: string | number | boolean) => void;
212
+ value?: string | number | boolean;
213
+ variant?: "ghost" | "default";
210
214
  }
211
- declare const Select: React$1.ForwardRefExoticComponent<SelectProps & React$1.RefAttributes<HTMLSelectElement>>;
215
+ declare const Select: React__default.ForwardRefExoticComponent<SelectProps & React__default.RefAttributes<HTMLSelectElement>>;
212
216
 
213
217
  interface PhoneInputProps extends Omit<React.InputHTMLAttributes<HTMLInputElement>, "onChange"> {
214
218
  label: string;
@@ -230,6 +234,7 @@ interface InputProps<T extends FieldValues> extends Omit<React.InputHTMLAttribut
230
234
  name?: Path<T>;
231
235
  form?: UseFormReturn<T>;
232
236
  type?: "text" | "number" | "email" | "password";
237
+ variant?: "ghost" | "default";
233
238
  }
234
239
  declare const Input: <T extends FieldValues>(props: InputProps<T> & {
235
240
  ref?: React.ForwardedRef<HTMLInputElement>;
@@ -251,12 +256,23 @@ declare const Fields: {
251
256
  };
252
257
 
253
258
  interface DataTableProps<TData, TValue> {
254
- columns: ColumnDef<TData, TValue>[];
259
+ columns: (ColumnDef<TData, TValue> & {
260
+ key?: string;
261
+ })[];
255
262
  data: TData[];
256
263
  isLoading?: boolean;
257
264
  pageRows?: number;
258
265
  searchPlaceholder?: string;
259
266
  className?: string;
267
+ verticalLines?: boolean;
268
+ rowPadding?: string;
269
+ index?: boolean;
270
+ renderSubComponent?: (props: {
271
+ row: TData;
272
+ index: number;
273
+ }) => React__default.ReactNode;
274
+ hasSubComponent?: (row: TData) => boolean;
275
+ defaultExpanded?: boolean;
260
276
  onChange?: (state: {
261
277
  pagination: {
262
278
  pageIndex: number;
@@ -270,13 +286,85 @@ interface DataTableProps<TData, TValue> {
270
286
  filteredData: TData[];
271
287
  }) => void;
272
288
  }
273
- declare function DataTable<TData, TValue>({ columns, data, isLoading, pageRows, searchPlaceholder, className, onChange, }: DataTableProps<TData, TValue>): react_jsx_runtime.JSX.Element;
289
+ declare function DataTable<TData, TValue>({ columns: userColumns, data, isLoading, pageRows, searchPlaceholder, className, verticalLines, rowPadding, index, renderSubComponent, hasSubComponent, // default to true
290
+ defaultExpanded, onChange, }: DataTableProps<TData, TValue>): react_jsx_runtime.JSX.Element;
291
+
292
+ declare module "@tanstack/react-table" {
293
+ interface ColumnMeta<TData extends RowData, TValue> {
294
+ field?: (props: {
295
+ value: any;
296
+ onChange: (value: any) => void;
297
+ rowData: Partial<TData>;
298
+ setRowData: (data: Partial<TData>) => void;
299
+ }) => React__default.ReactNode;
300
+ }
301
+ }
302
+ interface PostTableActions {
303
+ focus: (columnId: string) => void;
304
+ setError: (columnId: string, hasError: boolean) => void;
305
+ }
306
+ interface PostTableProps<TData> {
307
+ columns: (ColumnDef<TData, any> & {
308
+ key?: string;
309
+ })[];
310
+ data?: TData[];
311
+ onChange?: (entryData: Partial<TData>, actions: PostTableActions, actionType: "add" | "edit" | "delete", fullData: TData[]) => void | Promise<void | boolean>;
312
+ isLoading?: boolean;
313
+ className?: string;
314
+ verticalLines?: boolean;
315
+ rowPadding?: string;
316
+ index?: boolean;
317
+ renderAddButton?: (entryData: Partial<TData>, handleSaveField: () => void, isSaving: boolean) => React__default.ReactNode;
318
+ renderSubComponent?: (props: {
319
+ row: TData;
320
+ index: number;
321
+ }) => React__default.ReactNode;
322
+ hasSubComponent?: (row: TData) => boolean;
323
+ defaultExpanded?: boolean;
324
+ }
325
+ declare function PostTable<TData extends Record<string, any>>({ columns: userColumns, data: controlledData, onChange, isLoading, className, verticalLines, rowPadding, index, renderAddButton, renderSubComponent, hasSubComponent, // default to true if renderSubComponent is provided
326
+ defaultExpanded, }: PostTableProps<TData>): react_jsx_runtime.JSX.Element;
327
+
328
+ interface SimpleTableProps<TData> {
329
+ columns: (ColumnDef<TData, any> & {
330
+ key?: string;
331
+ })[];
332
+ data: TData[];
333
+ className?: string;
334
+ renderFooter?: () => React__default.ReactNode;
335
+ rowPadding?: string;
336
+ verticalLines?: boolean;
337
+ }
338
+ declare function SimpleTable<TData>({ columns: userColumns, data, className, renderFooter, rowPadding, verticalLines, }: SimpleTableProps<TData>): react_jsx_runtime.JSX.Element;
339
+
340
+ interface BadgeProps extends HTMLAttributes<HTMLSpanElement> {
341
+ variant?: "primary" | "danger" | "warning" | "success";
342
+ size?: "sm" | "md" | "lg";
343
+ outline?: boolean;
344
+ }
345
+ declare const Badge: React__default.ForwardRefExoticComponent<BadgeProps & React__default.RefAttributes<HTMLSpanElement>>;
346
+
347
+ interface BrandingProps {
348
+ /**
349
+ * The text to display.
350
+ */
351
+ text: string;
352
+ /**
353
+ * Whether the component is disabled.
354
+ */
355
+ disabled?: boolean;
356
+ /**
357
+ * Additional class names.
358
+ */
359
+ className?: string;
360
+ }
361
+ declare const Branding: React__default.FC<BrandingProps>;
274
362
 
275
363
  interface ThemeConfig {
276
364
  primaryColor?: string;
277
365
  }
278
366
  interface WarqadConfig {
279
- apiUrl?: string;
367
+ api?: string;
280
368
  theme?: ThemeConfig;
281
369
  }
282
370
  interface WarqadConfigContextType {
@@ -353,4 +441,4 @@ interface PdfOptions {
353
441
  */
354
442
  declare const generatePdf: (elementId: string, options?: PdfOptions) => Promise<void>;
355
443
 
356
- export { Button, type ButtonProps, Card, CardContent, CardDescription, CardFooter, CardHeader, CardTitle, ClassicSpin, CodeBlock, DashboardLayout, DataTable, DateInput, type DateInputProps, Fields, Input, type InputProps, LoadingBox, LoadingSpin, Modal, type ModalProps, type NavItem, type NavItems, type Option, OverlaySpin, PageHeader, type PdfOptions, PhoneInput, type PhoneInputProps, SearchApi, type SearchApiProps, Select, type SelectProps, Textarea, type TextareaProps, type ThemeConfig, ThemeProvider, ThemeToggle, type UseModalReturn, type WarqadConfig, type WarqadConfigContextType, WarqadProvider, generatePdf, useApi, useModal, useTheme, useWarqadConfig };
444
+ export { Badge, type BadgeProps, Branding, type BrandingProps, Button, type ButtonProps, Card, CardContent, CardDescription, CardFooter, CardHeader, CardTitle, ClassicSpin, CodeBlock, DashboardLayout, DataTable, DateInput, type DateInputProps, Fields, Input, type InputProps, LoadingBox, LoadingSpin, Modal, type ModalProps, type NavItem, type NavItems, type Option, OverlaySpin, PageHeader, type PdfOptions, PhoneInput, type PhoneInputProps, PostTable, type PostTableActions, SearchApi, type SearchApiProps, Select, type SelectProps, SimpleTable, Textarea, type TextareaProps, type ThemeConfig, ThemeProvider, ThemeToggle, type UseModalReturn, type WarqadConfig, type WarqadConfigContextType, WarqadProvider, generatePdf, useApi, useModal, useTheme, useWarqadConfig };
package/dist/index.d.ts CHANGED
@@ -1,9 +1,9 @@
1
1
  import * as React$1 from 'react';
2
- import React__default, { ReactNode } from 'react';
2
+ import React__default, { ReactNode, HTMLAttributes } from 'react';
3
3
  import * as react_jsx_runtime from 'react/jsx-runtime';
4
4
  import * as react_hook_form from 'react-hook-form';
5
5
  import { FieldValues, Path, UseFormReturn } from 'react-hook-form';
6
- import { ColumnDef, SortingState, ColumnFiltersState } from '@tanstack/react-table';
6
+ import { ColumnDef, SortingState, ColumnFiltersState, RowData } from '@tanstack/react-table';
7
7
 
8
8
  interface ButtonProps extends React__default.ButtonHTMLAttributes<HTMLButtonElement> {
9
9
  variant?: "primary" | "secondary" | "outline" | "ghost" | "danger" | "warning";
@@ -26,9 +26,10 @@ interface DashboardLayoutProps {
26
26
  children: React__default.ReactNode;
27
27
  navItems: NavItems;
28
28
  title?: string;
29
- logo?: React__default.ReactNode;
29
+ logo?: React__default.ReactNode | string;
30
30
  userProfile?: React__default.ReactNode;
31
31
  fontFamily?: string;
32
+ sidebarFooter?: React__default.ReactNode;
32
33
  }
33
34
  declare const DashboardLayout: React__default.FC<DashboardLayoutProps>;
34
35
 
@@ -165,7 +166,7 @@ declare const DateInput: <T extends FieldValues>(props: DateInputProps<T> & {
165
166
 
166
167
  interface SearchApiProps extends Omit<React__default.InputHTMLAttributes<HTMLInputElement>, "onChange" | "value"> {
167
168
  label?: string;
168
- apiUrl: string;
169
+ api: string;
169
170
  placeholder?: string;
170
171
  value?: any;
171
172
  onChange?: (value: any) => void;
@@ -179,6 +180,7 @@ interface SearchApiProps extends Omit<React__default.InputHTMLAttributes<HTMLInp
179
180
  obj?: any;
180
181
  filter?: any[];
181
182
  v?: number;
183
+ variant?: "ghost" | "default";
182
184
  }
183
185
  declare const SearchApi: React__default.ForwardRefExoticComponent<SearchApiProps & React__default.RefAttributes<HTMLDivElement>>;
184
186
 
@@ -198,17 +200,19 @@ interface Option {
198
200
  label: string;
199
201
  disabled?: boolean;
200
202
  }
201
- interface SelectProps extends Omit<React.SelectHTMLAttributes<HTMLSelectElement>, "onChange"> {
202
- label: string;
203
+ interface SelectProps extends Omit<React__default.SelectHTMLAttributes<HTMLSelectElement>, "onChange" | "value"> {
204
+ label?: string;
203
205
  options: Option[];
204
- icon?: React.ReactNode;
206
+ icon?: React__default.ReactNode;
205
207
  error?: string;
206
208
  containerClassName?: string;
207
209
  name?: any;
208
210
  form?: any;
209
211
  onChange?: (value: string | number | boolean) => void;
212
+ value?: string | number | boolean;
213
+ variant?: "ghost" | "default";
210
214
  }
211
- declare const Select: React$1.ForwardRefExoticComponent<SelectProps & React$1.RefAttributes<HTMLSelectElement>>;
215
+ declare const Select: React__default.ForwardRefExoticComponent<SelectProps & React__default.RefAttributes<HTMLSelectElement>>;
212
216
 
213
217
  interface PhoneInputProps extends Omit<React.InputHTMLAttributes<HTMLInputElement>, "onChange"> {
214
218
  label: string;
@@ -230,6 +234,7 @@ interface InputProps<T extends FieldValues> extends Omit<React.InputHTMLAttribut
230
234
  name?: Path<T>;
231
235
  form?: UseFormReturn<T>;
232
236
  type?: "text" | "number" | "email" | "password";
237
+ variant?: "ghost" | "default";
233
238
  }
234
239
  declare const Input: <T extends FieldValues>(props: InputProps<T> & {
235
240
  ref?: React.ForwardedRef<HTMLInputElement>;
@@ -251,12 +256,23 @@ declare const Fields: {
251
256
  };
252
257
 
253
258
  interface DataTableProps<TData, TValue> {
254
- columns: ColumnDef<TData, TValue>[];
259
+ columns: (ColumnDef<TData, TValue> & {
260
+ key?: string;
261
+ })[];
255
262
  data: TData[];
256
263
  isLoading?: boolean;
257
264
  pageRows?: number;
258
265
  searchPlaceholder?: string;
259
266
  className?: string;
267
+ verticalLines?: boolean;
268
+ rowPadding?: string;
269
+ index?: boolean;
270
+ renderSubComponent?: (props: {
271
+ row: TData;
272
+ index: number;
273
+ }) => React__default.ReactNode;
274
+ hasSubComponent?: (row: TData) => boolean;
275
+ defaultExpanded?: boolean;
260
276
  onChange?: (state: {
261
277
  pagination: {
262
278
  pageIndex: number;
@@ -270,13 +286,85 @@ interface DataTableProps<TData, TValue> {
270
286
  filteredData: TData[];
271
287
  }) => void;
272
288
  }
273
- declare function DataTable<TData, TValue>({ columns, data, isLoading, pageRows, searchPlaceholder, className, onChange, }: DataTableProps<TData, TValue>): react_jsx_runtime.JSX.Element;
289
+ declare function DataTable<TData, TValue>({ columns: userColumns, data, isLoading, pageRows, searchPlaceholder, className, verticalLines, rowPadding, index, renderSubComponent, hasSubComponent, // default to true
290
+ defaultExpanded, onChange, }: DataTableProps<TData, TValue>): react_jsx_runtime.JSX.Element;
291
+
292
+ declare module "@tanstack/react-table" {
293
+ interface ColumnMeta<TData extends RowData, TValue> {
294
+ field?: (props: {
295
+ value: any;
296
+ onChange: (value: any) => void;
297
+ rowData: Partial<TData>;
298
+ setRowData: (data: Partial<TData>) => void;
299
+ }) => React__default.ReactNode;
300
+ }
301
+ }
302
+ interface PostTableActions {
303
+ focus: (columnId: string) => void;
304
+ setError: (columnId: string, hasError: boolean) => void;
305
+ }
306
+ interface PostTableProps<TData> {
307
+ columns: (ColumnDef<TData, any> & {
308
+ key?: string;
309
+ })[];
310
+ data?: TData[];
311
+ onChange?: (entryData: Partial<TData>, actions: PostTableActions, actionType: "add" | "edit" | "delete", fullData: TData[]) => void | Promise<void | boolean>;
312
+ isLoading?: boolean;
313
+ className?: string;
314
+ verticalLines?: boolean;
315
+ rowPadding?: string;
316
+ index?: boolean;
317
+ renderAddButton?: (entryData: Partial<TData>, handleSaveField: () => void, isSaving: boolean) => React__default.ReactNode;
318
+ renderSubComponent?: (props: {
319
+ row: TData;
320
+ index: number;
321
+ }) => React__default.ReactNode;
322
+ hasSubComponent?: (row: TData) => boolean;
323
+ defaultExpanded?: boolean;
324
+ }
325
+ declare function PostTable<TData extends Record<string, any>>({ columns: userColumns, data: controlledData, onChange, isLoading, className, verticalLines, rowPadding, index, renderAddButton, renderSubComponent, hasSubComponent, // default to true if renderSubComponent is provided
326
+ defaultExpanded, }: PostTableProps<TData>): react_jsx_runtime.JSX.Element;
327
+
328
+ interface SimpleTableProps<TData> {
329
+ columns: (ColumnDef<TData, any> & {
330
+ key?: string;
331
+ })[];
332
+ data: TData[];
333
+ className?: string;
334
+ renderFooter?: () => React__default.ReactNode;
335
+ rowPadding?: string;
336
+ verticalLines?: boolean;
337
+ }
338
+ declare function SimpleTable<TData>({ columns: userColumns, data, className, renderFooter, rowPadding, verticalLines, }: SimpleTableProps<TData>): react_jsx_runtime.JSX.Element;
339
+
340
+ interface BadgeProps extends HTMLAttributes<HTMLSpanElement> {
341
+ variant?: "primary" | "danger" | "warning" | "success";
342
+ size?: "sm" | "md" | "lg";
343
+ outline?: boolean;
344
+ }
345
+ declare const Badge: React__default.ForwardRefExoticComponent<BadgeProps & React__default.RefAttributes<HTMLSpanElement>>;
346
+
347
+ interface BrandingProps {
348
+ /**
349
+ * The text to display.
350
+ */
351
+ text: string;
352
+ /**
353
+ * Whether the component is disabled.
354
+ */
355
+ disabled?: boolean;
356
+ /**
357
+ * Additional class names.
358
+ */
359
+ className?: string;
360
+ }
361
+ declare const Branding: React__default.FC<BrandingProps>;
274
362
 
275
363
  interface ThemeConfig {
276
364
  primaryColor?: string;
277
365
  }
278
366
  interface WarqadConfig {
279
- apiUrl?: string;
367
+ api?: string;
280
368
  theme?: ThemeConfig;
281
369
  }
282
370
  interface WarqadConfigContextType {
@@ -353,4 +441,4 @@ interface PdfOptions {
353
441
  */
354
442
  declare const generatePdf: (elementId: string, options?: PdfOptions) => Promise<void>;
355
443
 
356
- export { Button, type ButtonProps, Card, CardContent, CardDescription, CardFooter, CardHeader, CardTitle, ClassicSpin, CodeBlock, DashboardLayout, DataTable, DateInput, type DateInputProps, Fields, Input, type InputProps, LoadingBox, LoadingSpin, Modal, type ModalProps, type NavItem, type NavItems, type Option, OverlaySpin, PageHeader, type PdfOptions, PhoneInput, type PhoneInputProps, SearchApi, type SearchApiProps, Select, type SelectProps, Textarea, type TextareaProps, type ThemeConfig, ThemeProvider, ThemeToggle, type UseModalReturn, type WarqadConfig, type WarqadConfigContextType, WarqadProvider, generatePdf, useApi, useModal, useTheme, useWarqadConfig };
444
+ export { Badge, type BadgeProps, Branding, type BrandingProps, Button, type ButtonProps, Card, CardContent, CardDescription, CardFooter, CardHeader, CardTitle, ClassicSpin, CodeBlock, DashboardLayout, DataTable, DateInput, type DateInputProps, Fields, Input, type InputProps, LoadingBox, LoadingSpin, Modal, type ModalProps, type NavItem, type NavItems, type Option, OverlaySpin, PageHeader, type PdfOptions, PhoneInput, type PhoneInputProps, PostTable, type PostTableActions, SearchApi, type SearchApiProps, Select, type SelectProps, SimpleTable, Textarea, type TextareaProps, type ThemeConfig, ThemeProvider, ThemeToggle, type UseModalReturn, type WarqadConfig, type WarqadConfigContextType, WarqadProvider, generatePdf, useApi, useModal, useTheme, useWarqadConfig };