sera-components 1.7.0 → 1.8.1

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';
@@ -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,6 +1,6 @@
1
- import { DataProperty, DB, DraftEmbeddedRecord, DraftRecord, EmbeddedSchema, GenericEmbeddedRecord, GenericRecord, ObjectProperty, PropertyNames, Schema, SchemaType } from 'sera-db';
1
+ import { DataProperty, DB, DraftEmbeddedRecord, DraftRecord, EmbeddedSchema, GenericEmbeddedRecord, GenericRecord, NestedProperty, ObjectProperty, PropertyNames, Schema, SchemaType } from 'sera-db';
2
2
  import { DisplayInterface } from '../data/display';
3
- type DOP = DataProperty | ObjectProperty;
3
+ type DOP = DataProperty | ObjectProperty | NestedProperty;
4
4
  /**
5
5
  * Represents a column configuration for a table component.
6
6
  */
@@ -53,15 +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, }?: {
57
- title?: React.ReactNode;
58
- nestedKey?: string;
59
- component?: React.ComponentType<DisplayInterface<any>>;
60
- }): SeraColumn<R>;
61
- export declare function makeTableColumnFromNestedProperty<R>(db: DB, property: DOP, nestedProperty: DOP, { title, nestedKey, component, }?: {
56
+ export declare function makeTableColumn<R>(db: DB, property: DOP, { title, nestedKey, component, rowSpan, colSpan, }?: {
62
57
  title?: React.ReactNode;
63
58
  nestedKey?: string;
64
59
  component?: React.ComponentType<DisplayInterface<any>>;
60
+ rowSpan?: (record: R, rowIndex: number) => number | undefined;
61
+ colSpan?: (record: R, rowIndex: number) => number | undefined;
65
62
  }): SeraColumn<R>;
66
63
  export declare function makeTableColumns<ID extends string | number, R extends GenericRecord<ID, DR>, DR extends DraftRecord<ID>, PF extends PropertyNames<R>, F extends PropertyNames<DR>, ST extends SchemaType<ID, R, DR, PF, F>, OR>(db: DB, schema: Schema<ID, R, DR, PF, F, ST> | EmbeddedSchema<R, DR, PF, F>, selectedColumns: (PF | SeraColumn<OR>)[], options?: {
67
64
  nestedKey?: string;
@@ -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;
@@ -9,7 +9,8 @@ import { DataProperty, ObjectProperty, NestedProperty } from 'sera-db';
9
9
  * @example
10
10
  * ```typescript
11
11
  * const value = getPropertyValue(supplier, paymentPolicyProp);
12
- * const nestedValue = getPropertyValue(supplier, new NestedProperty(supplier.paymentPolicy, paymentPolicy.type));
12
+ * const nestedValue = getPropertyValue(supplier, supplier.paymentPolicy.property("type"));
13
+ * // Or manually: new NestedProperty(supplier.paymentPolicy, paymentPolicy.type)
13
14
  * ```
14
15
  */
15
16
  export declare function getPropertyValue(record: any, property: DataProperty | ObjectProperty | NestedProperty): any;
@@ -27,7 +28,7 @@ export declare function getPropertyValue(record: any, property: DataProperty | O
27
28
  * @example
28
29
  * ```typescript
29
30
  * setPropertyValue(draftSupplier, paymentPolicyProp, newPolicy);
30
- * setPropertyValue(draftSupplier, new NestedProperty(supplier.paymentPolicy, paymentPolicy.type), PaymentPolicyType.PaymentBeforeService);
31
+ * setPropertyValue(draftSupplier, supplier.paymentPolicy.property("type"), PaymentPolicyType.PaymentBeforeService);
31
32
  * ```
32
33
  */
33
34
  export declare function setPropertyValue(record: any, property: DataProperty | ObjectProperty | NestedProperty, value: any): void;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "sera-components",
3
3
  "private": false,
4
- "version": "1.7.0",
4
+ "version": "1.8.1",
5
5
  "type": "module",
6
6
  "files": [
7
7
  "dist"
@@ -46,7 +46,7 @@
46
46
  "react-dom": "^19.2.3",
47
47
  "react-imask": "^7.6.1",
48
48
  "react-router": "^7.7.1",
49
- "sera-db": "^1.13.1",
49
+ "sera-db": "^1.13.2",
50
50
  "throttle-debounce": "^5.0.2"
51
51
  }
52
52
  }