sera-components 1.6.10 → 1.8.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.
@@ -4,3 +4,4 @@ export * from './transition';
4
4
  export * from './menu';
5
5
  export * from './locale';
6
6
  export * from './row';
7
+ export * from './pop-confirm';
@@ -1,10 +1,10 @@
1
1
  import { Trie } from '../utils';
2
- import { NavigateFunction, Permission, NoArgsRoute, NoURLArgsRoute } from '../types';
2
+ import { NavigateFunction, Permission, Route } from '../types';
3
3
  type MenuKey = string;
4
- export interface MenuRoute<Q, R> {
5
- path: NoURLArgsRoute<Q> | NoArgsRoute;
4
+ export interface MenuRoute<P, R> {
5
+ path: Route<P>;
6
6
  role: R;
7
- defaultPathArgs?: Q;
7
+ defaultPathArgs?: P;
8
8
  }
9
9
  export interface SeraMenuItem<R> {
10
10
  key: MenuKey;
@@ -0,0 +1,29 @@
1
+ import { MultiLingualString as MLS } from 'sera-db';
2
+ import { ButtonProps, PopoverProps } from '@mantine/core';
3
+ export interface PopConfirmProps {
4
+ /** The element that triggers the popconfirm */
5
+ children: React.ReactNode;
6
+ /** Title/message shown in the popconfirm */
7
+ title: React.ReactNode;
8
+ /** Callback when confirm button is clicked */
9
+ onConfirm: () => void;
10
+ /** Callback when cancel button is clicked */
11
+ onCancel?: () => void;
12
+ /** Label for confirm button. Defaults to "Confirm" / "Xác nhận" */
13
+ confirmLabel?: MLS;
14
+ /** Label for cancel button. Defaults to "Cancel" / "Hủy" */
15
+ cancelLabel?: MLS;
16
+ /** Props for the confirm button */
17
+ confirmProps?: Omit<ButtonProps, "onClick">;
18
+ /** Props for the cancel button */
19
+ cancelProps?: Omit<ButtonProps, "onClick">;
20
+ /** Props for the Popover component */
21
+ popoverProps?: Omit<PopoverProps, "opened" | "onClose" | "children">;
22
+ /** Whether the popconfirm is disabled */
23
+ disabled?: boolean;
24
+ }
25
+ /**
26
+ * A popover-based confirmation component similar to AntDesign's Popconfirm.
27
+ * Wraps a trigger element and shows a confirmation popover when clicked.
28
+ */
29
+ export declare const PopConfirm: ({ children, title, onConfirm, onCancel, confirmLabel, cancelLabel, confirmProps, cancelProps, popoverProps, disabled, }: PopConfirmProps) => import("react/jsx-runtime").JSX.Element;
@@ -1,10 +1,10 @@
1
- import { EntityRoutes, LinkComponent } from './types';
1
+ import { EntityRoutes, EntityLinkComponent } from './types';
2
2
  export declare const SeraContext: import('react').Context<{
3
- link: LinkComponent;
3
+ EntityLink: EntityLinkComponent;
4
4
  entityRoutes: EntityRoutes;
5
5
  }>;
6
- export declare const SeraContextProvider: ({ link, entityRoutes, children, }: {
7
- link: LinkComponent;
6
+ export declare const SeraContextProvider: ({ EntityLink, entityRoutes, children, }: {
7
+ EntityLink: EntityLinkComponent;
8
8
  entityRoutes: EntityRoutes;
9
9
  children: React.ReactNode;
10
10
  }) => import("react/jsx-runtime").JSX.Element;
@@ -1,9 +1,16 @@
1
1
  import { SeraColumn } from './make-columns';
2
2
  import { SeraActionConfig } from './table-action';
3
3
  export interface SeraEmbeddedTableProps<R> {
4
+ /** Pagination configuration */
4
5
  pagination?: {
6
+ /** Position(s) to display pagination controls */
5
7
  positions?: Set<"topRight" | "bottomLeft" | "bottomCenter" | "bottomRight">;
8
+ /** Whether to show page size selector. Defaults to true. */
6
9
  showSizeChanger?: boolean;
10
+ /** Initial page size. Defaults to 10. */
11
+ pageSize?: number;
12
+ /** Available page size options in the dropdown. Defaults to [10, 20, 50, 100]. */
13
+ pageSizeOptions?: number[];
7
14
  };
8
15
  columns: SeraColumn<R>[];
9
16
  data: R[];
@@ -53,10 +53,12 @@ export interface SeraColumn<R> {
53
53
  * - Object properties with other cardinalities use SingleForeignKeyDisplay
54
54
  * - Non-object properties use components from DataType2DisplayComponent mapping
55
55
  */
56
- export declare function makeTableColumn<R>(db: DB, property: DOP, { title, nestedKey, component, }?: {
56
+ export declare function makeTableColumn<R>(db: DB, property: DOP, { title, nestedKey, component, rowSpan, colSpan, }?: {
57
57
  title?: React.ReactNode;
58
58
  nestedKey?: string;
59
59
  component?: React.ComponentType<DisplayInterface<any>>;
60
+ rowSpan?: (record: R, rowIndex: number) => number | undefined;
61
+ colSpan?: (record: R, rowIndex: number) => number | undefined;
60
62
  }): SeraColumn<R>;
61
63
  export declare function makeTableColumnFromNestedProperty<R>(db: DB, property: DOP, nestedProperty: DOP, { title, nestedKey, component, }?: {
62
64
  title?: React.ReactNode;
@@ -2,7 +2,7 @@ import { MantineSize } from '@mantine/core';
2
2
  export interface SeraActionConfig<ID extends string | number> {
3
3
  add?: () => void;
4
4
  edit?: (id: ID) => void;
5
- delete?: () => void;
5
+ delete?: (ids: ID[]) => void;
6
6
  export?: () => void;
7
7
  reload?: boolean;
8
8
  import?: () => void;
@@ -1,9 +1,11 @@
1
1
  import { MantineSize } from '@mantine/core';
2
- export declare const TablePagination: ({ total, pageIndex, pageSize, allowPageSizeChange, onUpdatePagination, }: {
2
+ export declare const TablePagination: ({ total, pageIndex, pageSize, allowPageSizeChange, pageSizeOptions, onUpdatePagination, }: {
3
3
  total: number;
4
4
  pageIndex: number;
5
5
  pageSize: number;
6
6
  allowPageSizeChange?: boolean;
7
+ /** Available page size options. Defaults to ["10", "20", "50", "100"]. */
8
+ pageSizeOptions?: string[];
7
9
  onUpdatePagination: (pageIndex: number, pageSize: number) => void;
8
10
  }) => import("react/jsx-runtime").JSX.Element;
9
11
  export declare function DataTablePageSizeSelector({ size, values, value, onChange, }: {
@@ -5,9 +5,14 @@ export interface SeraTableProps<ID extends string | number, Q extends {
5
5
  limit: number;
6
6
  offset: number;
7
7
  }, R> {
8
+ /** Pagination configuration */
8
9
  pagination?: {
10
+ /** Position(s) to display pagination controls */
9
11
  positions?: Set<"topRight" | "bottomLeft" | "bottomCenter" | "bottomRight">;
12
+ /** Whether to show page size selector. Defaults to true. */
10
13
  showSizeChanger?: boolean;
14
+ /** Available page size options in the dropdown. Defaults to [10, 20, 50, 100]. */
15
+ pageSizeOptions?: number[];
11
16
  };
12
17
  columns: SeraColumn<R>[];
13
18
  query: ObservableQuery<Q>;
package/dist/types.d.ts CHANGED
@@ -21,49 +21,27 @@ export interface NavigateFunction {
21
21
  }>, options?: any): void | Promise<void>;
22
22
  (delta: number): void | Promise<void>;
23
23
  }
24
- export interface NoArgsRoute {
25
- path(): {
24
+ export interface Route<P> {
25
+ path(args: P): {
26
26
  open: (navigate: NavigateFunction) => void;
27
27
  };
28
- getURL(): string;
28
+ getURL(args: P): string;
29
29
  pathDef: string;
30
30
  }
31
- export interface NoURLArgsRoute<Q> {
32
- path({ queryArgs }: {
33
- queryArgs: Q;
34
- }): {
35
- open: (navigate: NavigateFunction) => void;
36
- };
37
- getURL({ queryArgs }: {
38
- queryArgs: Q;
39
- }): string;
40
- pathDef: string;
41
- }
42
- export interface EntityRoute {
43
- path({ urlArgs }: {
44
- urlArgs: {
45
- id: string | number;
46
- };
47
- }): {
48
- open: (navigate: NavigateFunction) => void;
49
- };
50
- getURL({ urlArgs }: {
51
- urlArgs: {
52
- id: string | number;
53
- };
54
- }): string;
31
+ export interface EntityRoute extends Route<{
32
+ id: string | number;
33
+ }> {
55
34
  }
56
35
  export interface EntityRoutes extends Record<ClassName, {
57
36
  view: EntityRoute;
58
37
  edit: EntityRoute;
59
38
  }> {
60
39
  }
61
- export type LinkComponent = React.FunctionComponent<{
40
+ export type EntityLinkComponent = React.FunctionComponent<{
62
41
  path: EntityRoute;
63
- urlArgs: {
42
+ args: {
64
43
  id: string | number;
65
44
  };
66
- queryArgs: {};
67
45
  openInNewPage?: boolean;
68
46
  children?: React.ReactNode;
69
47
  }>;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "sera-components",
3
3
  "private": false,
4
- "version": "1.6.10",
4
+ "version": "1.8.0",
5
5
  "type": "module",
6
6
  "files": [
7
7
  "dist"