warqadui 0.0.32 → 0.0.34

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
@@ -443,17 +443,18 @@ interface PostTableActions {
443
443
  focus: (columnId: string) => void;
444
444
  setError: (columnId: string, error: boolean | string) => void;
445
445
  }
446
+ interface PostTableChangeParams<TData> {
447
+ entryData: Partial<TData>;
448
+ actions: PostTableActions;
449
+ actionType: "add" | "edit" | "delete";
450
+ fullData: TData[];
451
+ }
446
452
  interface PostTableProps<TData> {
447
453
  columns: (ColumnDef<TData, any> & {
448
454
  key?: string;
449
455
  })[];
450
456
  data?: TData[];
451
- onChange?: (params: {
452
- entryData: Partial<TData>;
453
- actions: PostTableActions;
454
- actionType: "add" | "edit" | "delete";
455
- fullData: TData[];
456
- }) => void | Promise<void | boolean>;
457
+ onChange?: (params: PostTableChangeParams<TData>) => void | Promise<void | boolean>;
457
458
  isLoading?: boolean;
458
459
  className?: string;
459
460
  verticalLines?: boolean;
@@ -467,9 +468,12 @@ interface PostTableProps<TData> {
467
468
  hasSubComponent?: (row: TData) => boolean;
468
469
  defaultExpanded?: boolean;
469
470
  submitLoading?: boolean;
471
+ onCancel?: () => void;
472
+ onEdit?: (row: TData) => void;
473
+ onDelete?: (row: TData) => void;
470
474
  }
471
475
  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
472
- defaultExpanded, submitLoading, }: PostTableProps<TData>): react_jsx_runtime.JSX.Element;
476
+ defaultExpanded, submitLoading, onCancel, onEdit, onDelete, }: PostTableProps<TData>): react_jsx_runtime.JSX.Element;
473
477
 
474
478
  type SimpleTableColumn<TData> = ColumnDef<TData, any> & {
475
479
  key?: string;
@@ -704,4 +708,4 @@ interface StorageManager {
704
708
  */
705
709
  declare const storage: StorageManager;
706
710
 
707
- export { A4DataView, Badge, type BadgeProps, Branding, type BrandingProps, Button, type ButtonProps, Card, CardContent, CardDescription, CardFooter, CardHeader, CardTitle, ClassicSpin, CodeBlock, DashboardLayout, DataTable, type DataTableColumn, DateInput, type DateInputProps, type DeleteFunction, type FetchFunction, type FetchProps, Fields, InfoGrid, Input, type InputProps, LoadingBox, LoadingSpin, Modal, type ModalProps, type NavItem, type NavItems, type Option, OverlaySpin, PageA4, PageHeader, type PdfOptions, PhoneInput, type PhoneInputProps, type PostFunction, PostTable, type PostTableActions, type PutFunction, SearchApi, SearchApiContent, SearchApiInput, SearchApiItem, type SearchApiProps, SearchApiTrigger, Select, SelectContent, SelectItem, type SelectProps, SelectTrigger, SimpleTable, type SimpleTableColumn, type StorageManager, type StoreConfig, Textarea, type TextareaProps, type ThemeConfig, ThemeProvider, ThemeToggle, type UseModalReturn, type WarqadConfig, type WarqadConfigContextType, WarqadProvider, generatePdf, storage, useA4StatementView, useApi, useModal, useSearchApiContext, useSelectContext, useTheme, useTransaction, useWarqadConfig };
711
+ export { A4DataView, Badge, type BadgeProps, Branding, type BrandingProps, Button, type ButtonProps, Card, CardContent, CardDescription, CardFooter, CardHeader, CardTitle, ClassicSpin, CodeBlock, DashboardLayout, DataTable, type DataTableColumn, DateInput, type DateInputProps, type DeleteFunction, type FetchFunction, type FetchProps, Fields, InfoGrid, Input, type InputProps, LoadingBox, LoadingSpin, Modal, type ModalProps, type NavItem, type NavItems, type Option, OverlaySpin, PageA4, PageHeader, type PdfOptions, PhoneInput, type PhoneInputProps, type PostFunction, PostTable, type PostTableActions, type PostTableChangeParams, type PutFunction, SearchApi, SearchApiContent, SearchApiInput, SearchApiItem, type SearchApiProps, SearchApiTrigger, Select, SelectContent, SelectItem, type SelectProps, SelectTrigger, SimpleTable, type SimpleTableColumn, type StorageManager, type StoreConfig, Textarea, type TextareaProps, type ThemeConfig, ThemeProvider, ThemeToggle, type UseModalReturn, type WarqadConfig, type WarqadConfigContextType, WarqadProvider, generatePdf, storage, useA4StatementView, useApi, useModal, useSearchApiContext, useSelectContext, useTheme, useTransaction, useWarqadConfig };
package/dist/index.d.ts CHANGED
@@ -443,17 +443,18 @@ interface PostTableActions {
443
443
  focus: (columnId: string) => void;
444
444
  setError: (columnId: string, error: boolean | string) => void;
445
445
  }
446
+ interface PostTableChangeParams<TData> {
447
+ entryData: Partial<TData>;
448
+ actions: PostTableActions;
449
+ actionType: "add" | "edit" | "delete";
450
+ fullData: TData[];
451
+ }
446
452
  interface PostTableProps<TData> {
447
453
  columns: (ColumnDef<TData, any> & {
448
454
  key?: string;
449
455
  })[];
450
456
  data?: TData[];
451
- onChange?: (params: {
452
- entryData: Partial<TData>;
453
- actions: PostTableActions;
454
- actionType: "add" | "edit" | "delete";
455
- fullData: TData[];
456
- }) => void | Promise<void | boolean>;
457
+ onChange?: (params: PostTableChangeParams<TData>) => void | Promise<void | boolean>;
457
458
  isLoading?: boolean;
458
459
  className?: string;
459
460
  verticalLines?: boolean;
@@ -467,9 +468,12 @@ interface PostTableProps<TData> {
467
468
  hasSubComponent?: (row: TData) => boolean;
468
469
  defaultExpanded?: boolean;
469
470
  submitLoading?: boolean;
471
+ onCancel?: () => void;
472
+ onEdit?: (row: TData) => void;
473
+ onDelete?: (row: TData) => void;
470
474
  }
471
475
  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
472
- defaultExpanded, submitLoading, }: PostTableProps<TData>): react_jsx_runtime.JSX.Element;
476
+ defaultExpanded, submitLoading, onCancel, onEdit, onDelete, }: PostTableProps<TData>): react_jsx_runtime.JSX.Element;
473
477
 
474
478
  type SimpleTableColumn<TData> = ColumnDef<TData, any> & {
475
479
  key?: string;
@@ -704,4 +708,4 @@ interface StorageManager {
704
708
  */
705
709
  declare const storage: StorageManager;
706
710
 
707
- export { A4DataView, Badge, type BadgeProps, Branding, type BrandingProps, Button, type ButtonProps, Card, CardContent, CardDescription, CardFooter, CardHeader, CardTitle, ClassicSpin, CodeBlock, DashboardLayout, DataTable, type DataTableColumn, DateInput, type DateInputProps, type DeleteFunction, type FetchFunction, type FetchProps, Fields, InfoGrid, Input, type InputProps, LoadingBox, LoadingSpin, Modal, type ModalProps, type NavItem, type NavItems, type Option, OverlaySpin, PageA4, PageHeader, type PdfOptions, PhoneInput, type PhoneInputProps, type PostFunction, PostTable, type PostTableActions, type PutFunction, SearchApi, SearchApiContent, SearchApiInput, SearchApiItem, type SearchApiProps, SearchApiTrigger, Select, SelectContent, SelectItem, type SelectProps, SelectTrigger, SimpleTable, type SimpleTableColumn, type StorageManager, type StoreConfig, Textarea, type TextareaProps, type ThemeConfig, ThemeProvider, ThemeToggle, type UseModalReturn, type WarqadConfig, type WarqadConfigContextType, WarqadProvider, generatePdf, storage, useA4StatementView, useApi, useModal, useSearchApiContext, useSelectContext, useTheme, useTransaction, useWarqadConfig };
711
+ export { A4DataView, Badge, type BadgeProps, Branding, type BrandingProps, Button, type ButtonProps, Card, CardContent, CardDescription, CardFooter, CardHeader, CardTitle, ClassicSpin, CodeBlock, DashboardLayout, DataTable, type DataTableColumn, DateInput, type DateInputProps, type DeleteFunction, type FetchFunction, type FetchProps, Fields, InfoGrid, Input, type InputProps, LoadingBox, LoadingSpin, Modal, type ModalProps, type NavItem, type NavItems, type Option, OverlaySpin, PageA4, PageHeader, type PdfOptions, PhoneInput, type PhoneInputProps, type PostFunction, PostTable, type PostTableActions, type PostTableChangeParams, type PutFunction, SearchApi, SearchApiContent, SearchApiInput, SearchApiItem, type SearchApiProps, SearchApiTrigger, Select, SelectContent, SelectItem, type SelectProps, SelectTrigger, SimpleTable, type SimpleTableColumn, type StorageManager, type StoreConfig, Textarea, type TextareaProps, type ThemeConfig, ThemeProvider, ThemeToggle, type UseModalReturn, type WarqadConfig, type WarqadConfigContextType, WarqadProvider, generatePdf, storage, useA4StatementView, useApi, useModal, useSearchApiContext, useSelectContext, useTheme, useTransaction, useWarqadConfig };
package/dist/index.js CHANGED
@@ -1117,7 +1117,7 @@ var useModal = (initialState = false) => {
1117
1117
  setState(data);
1118
1118
  open();
1119
1119
  }, []);
1120
- const ModalComponent = (props) => {
1120
+ const ModalComponent = () => {
1121
1121
  return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(Modal, { isOpen: true, onClose: close, title: state?.title, children: state?.content });
1122
1122
  };
1123
1123
  return {
@@ -3304,7 +3304,10 @@ function PostTable({
3304
3304
  hasSubComponent = () => true,
3305
3305
  // default to true if renderSubComponent is provided
3306
3306
  defaultExpanded = false,
3307
- submitLoading = false
3307
+ submitLoading = false,
3308
+ onCancel,
3309
+ onEdit,
3310
+ onDelete
3308
3311
  }) {
3309
3312
  const { theme } = useWarqadConfig();
3310
3313
  const primaryColor = theme?.primaryColor;
@@ -3359,7 +3362,10 @@ function PostTable({
3359
3362
  isSavingAsync,
3360
3363
  submitLoading,
3361
3364
  fieldErrors,
3362
- onChange
3365
+ onChange,
3366
+ onCancel,
3367
+ onEdit,
3368
+ onDelete
3363
3369
  });
3364
3370
  (0, import_react16.useEffect)(() => {
3365
3371
  latestStateRef.current = {
@@ -3369,7 +3375,10 @@ function PostTable({
3369
3375
  isSavingAsync,
3370
3376
  submitLoading,
3371
3377
  fieldErrors,
3372
- onChange
3378
+ onChange,
3379
+ onCancel,
3380
+ onEdit,
3381
+ onDelete
3373
3382
  };
3374
3383
  });
3375
3384
  const handleSaveField = (0, import_react16.useCallback)(async () => {
@@ -3442,19 +3451,25 @@ function PostTable({
3442
3451
  }
3443
3452
  }, []);
3444
3453
  const handleCancelEdit = (0, import_react16.useCallback)(() => {
3454
+ const { onCancel: onCancel2 } = latestStateRef.current;
3445
3455
  setEditingIndex(null);
3446
3456
  setEntryData({});
3447
3457
  setFieldErrors({});
3458
+ if (onCancel2) onCancel2();
3448
3459
  }, []);
3449
3460
  const handleEdit = (0, import_react16.useCallback)((index2, rowOriginal) => {
3461
+ const { onEdit: onEdit2 } = latestStateRef.current;
3450
3462
  setEditingIndex(index2);
3451
3463
  setEntryData(rowOriginal);
3464
+ if (onEdit2) onEdit2(rowOriginal);
3452
3465
  }, []);
3453
3466
  const handleDelete = (0, import_react16.useCallback)(
3454
3467
  (index2) => {
3455
- const { data: data2, editingIndex: editingIndex2, onChange: onChange2 } = latestStateRef.current;
3468
+ const { data: data2, editingIndex: editingIndex2, onChange: onChange2, onDelete: onDelete2 } = latestStateRef.current;
3469
+ const rowToDelete = data2[index2];
3456
3470
  const newData = data2.filter((_, i) => i !== index2);
3457
3471
  setData(newData);
3472
+ if (onDelete2) onDelete2(rowToDelete);
3458
3473
  const actions = {
3459
3474
  focus: (columnId) => {
3460
3475
  if (entryRowRef.current) {
package/dist/index.mjs CHANGED
@@ -1037,7 +1037,7 @@ var useModal = (initialState = false) => {
1037
1037
  setState(data);
1038
1038
  open();
1039
1039
  }, []);
1040
- const ModalComponent = (props) => {
1040
+ const ModalComponent = () => {
1041
1041
  return /* @__PURE__ */ jsx16(Modal, { isOpen: true, onClose: close, title: state?.title, children: state?.content });
1042
1042
  };
1043
1043
  return {
@@ -3275,7 +3275,10 @@ function PostTable({
3275
3275
  hasSubComponent = () => true,
3276
3276
  // default to true if renderSubComponent is provided
3277
3277
  defaultExpanded = false,
3278
- submitLoading = false
3278
+ submitLoading = false,
3279
+ onCancel,
3280
+ onEdit,
3281
+ onDelete
3279
3282
  }) {
3280
3283
  const { theme } = useWarqadConfig();
3281
3284
  const primaryColor = theme?.primaryColor;
@@ -3330,7 +3333,10 @@ function PostTable({
3330
3333
  isSavingAsync,
3331
3334
  submitLoading,
3332
3335
  fieldErrors,
3333
- onChange
3336
+ onChange,
3337
+ onCancel,
3338
+ onEdit,
3339
+ onDelete
3334
3340
  });
3335
3341
  useEffect10(() => {
3336
3342
  latestStateRef.current = {
@@ -3340,7 +3346,10 @@ function PostTable({
3340
3346
  isSavingAsync,
3341
3347
  submitLoading,
3342
3348
  fieldErrors,
3343
- onChange
3349
+ onChange,
3350
+ onCancel,
3351
+ onEdit,
3352
+ onDelete
3344
3353
  };
3345
3354
  });
3346
3355
  const handleSaveField = useCallback2(async () => {
@@ -3413,19 +3422,25 @@ function PostTable({
3413
3422
  }
3414
3423
  }, []);
3415
3424
  const handleCancelEdit = useCallback2(() => {
3425
+ const { onCancel: onCancel2 } = latestStateRef.current;
3416
3426
  setEditingIndex(null);
3417
3427
  setEntryData({});
3418
3428
  setFieldErrors({});
3429
+ if (onCancel2) onCancel2();
3419
3430
  }, []);
3420
3431
  const handleEdit = useCallback2((index2, rowOriginal) => {
3432
+ const { onEdit: onEdit2 } = latestStateRef.current;
3421
3433
  setEditingIndex(index2);
3422
3434
  setEntryData(rowOriginal);
3435
+ if (onEdit2) onEdit2(rowOriginal);
3423
3436
  }, []);
3424
3437
  const handleDelete = useCallback2(
3425
3438
  (index2) => {
3426
- const { data: data2, editingIndex: editingIndex2, onChange: onChange2 } = latestStateRef.current;
3439
+ const { data: data2, editingIndex: editingIndex2, onChange: onChange2, onDelete: onDelete2 } = latestStateRef.current;
3440
+ const rowToDelete = data2[index2];
3427
3441
  const newData = data2.filter((_, i) => i !== index2);
3428
3442
  setData(newData);
3443
+ if (onDelete2) onDelete2(rowToDelete);
3429
3444
  const actions = {
3430
3445
  focus: (columnId) => {
3431
3446
  if (entryRowRef.current) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "warqadui",
3
- "version": "0.0.32",
3
+ "version": "0.0.34",
4
4
  "main": "./dist/index.js",
5
5
  "module": "./dist/index.mjs",
6
6
  "types": "./dist/index.d.ts",
@@ -18,7 +18,8 @@
18
18
  "scripts": {
19
19
  "build": "tsup src/index.ts src/styles.css --format esm,cjs --dts --injectStyle",
20
20
  "dev": "tsup src/index.ts src/styles.css --format esm,cjs --dts --watch --injectStyle",
21
- "prepublish": "npm run build"
21
+ "prepublish": "npm run build",
22
+ "release": "npm run build && npm version patch && npm publish"
22
23
  },
23
24
  "peerDependencies": {
24
25
  "@tanstack/react-table": "^8.12.0",