sera-components 1.6.3 → 1.6.8

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.
@@ -3,3 +3,4 @@ export * from './language';
3
3
  export * from './transition';
4
4
  export * from './menu';
5
5
  export * from './locale';
6
+ export * from './row';
@@ -0,0 +1,54 @@
1
+ import { default as React } from 'react';
2
+ import { MantineSpacing } from '@mantine/core';
3
+ /**
4
+ * Props for the SeraRow component.
5
+ */
6
+ export interface SeraRowProps {
7
+ /** The content of the row */
8
+ children: React.ReactNode;
9
+ /** Gap between items, uses Mantine spacing theme */
10
+ gap?: MantineSpacing;
11
+ /** Vertical alignment of items (align-items CSS property) */
12
+ align?: React.CSSProperties["alignItems"];
13
+ /** Optional class name */
14
+ className?: string;
15
+ /** Optional inline styles */
16
+ style?: React.CSSProperties;
17
+ }
18
+ /**
19
+ * A flexible row layout component that wraps items with support for gaps and alignment.
20
+ *
21
+ * @example
22
+ * ```tsx
23
+ * <SeraRow gap="md" align="center">
24
+ * <SeraCol>Item 1</SeraCol>
25
+ * <SeraCol>Item 2</SeraCol>
26
+ * </SeraRow>
27
+ * ```
28
+ */
29
+ export declare const SeraRow: ({ children, gap, align, className, style, }: SeraRowProps) => import("react/jsx-runtime").JSX.Element;
30
+ /**
31
+ * Props for the SeraCol component.
32
+ */
33
+ export interface SeraColProps {
34
+ /** The content of the column */
35
+ children: React.ReactNode;
36
+ /** Fixed span width out of 12 columns (e.g., 6/12 = 50%). Takes precedence over grow. */
37
+ span?: number;
38
+ /** Flex grow factor. 0 means no grow (fit content). Default is 1 if both span and grow are not specified. */
39
+ grow?: number;
40
+ /** Optional class name */
41
+ className?: string;
42
+ /** Optional inline styles */
43
+ style?: React.CSSProperties;
44
+ }
45
+ /**
46
+ * A column component for flexible layouts supporting both fixed grid spans and flex grow.
47
+ *
48
+ * @example
49
+ * ```tsx
50
+ * <SeraCol span={6}>Fixed 50% width</SeraCol>
51
+ * <SeraCol grow={1}>Flexible width</SeraCol>
52
+ * ```
53
+ */
54
+ export declare const SeraCol: ({ children, span, grow, className, style, }: SeraColProps) => import("react/jsx-runtime").JSX.Element;
@@ -8,6 +8,10 @@ export interface SeraEmbeddedTableProps<R> {
8
8
  columns: SeraColumn<R>[];
9
9
  data: R[];
10
10
  actions?: SeraActionConfig<number>;
11
+ /** Whether to show striped rows, defaults to true */
12
+ striped?: boolean;
13
+ /** Whether to show selection checkboxes. Defaults to true if edit/delete actions exist, otherwise false. */
14
+ selectable?: boolean;
11
15
  }
12
16
  export declare const DEFAULT_PAGINATION_POSITIONS: Set<"topRight" | "bottomLeft" | "bottomRight">;
13
17
  export declare const SeraEmbeddedTable: <R>(props: SeraEmbeddedTableProps<R>) => import("react/jsx-runtime").JSX.Element;
@@ -9,6 +9,26 @@ export interface SeraColumn<R> {
9
9
  title: React.ReactNode;
10
10
  accessorFn: (record: R) => any;
11
11
  render: (record: R) => React.ReactNode;
12
+ /**
13
+ * Optional function to determine row spanning behavior for this column.
14
+ * @param record - The current row's data
15
+ * @param rowIndex - The index of the current row in the visible data
16
+ * @returns
17
+ * - undefined or 1: normal cell (no spanning)
18
+ * - 0: skip this cell (it's covered by a rowSpan from a cell above)
19
+ * - >1: this cell spans that many rows
20
+ */
21
+ rowSpan?: (record: R, rowIndex: number) => number | undefined;
22
+ /**
23
+ * Optional function to determine column spanning behavior for this column.
24
+ * @param record - The current row's data
25
+ * @param rowIndex - The index of the current row in the visible data
26
+ * @returns
27
+ * - undefined or 1: normal cell (no spanning)
28
+ * - 0: skip this cell (it's covered by a colSpan from a cell to the left)
29
+ * - >1: this cell spans that many columns
30
+ */
31
+ colSpan?: (record: R, rowIndex: number) => number | undefined;
12
32
  }
13
33
  /**
14
34
  * Creates a table column configuration for displaying entity properties in a data table.
@@ -14,3 +14,4 @@ export declare const SeraTableAction: <ID extends string | number>({ actions, re
14
14
  selectedRowKeys: ID[];
15
15
  }) => import("react/jsx-runtime").JSX.Element;
16
16
  export declare const hasAction: <ID extends string | number>(actions?: SeraActionConfig<ID>) => boolean;
17
+ export declare const hasSelectAction: <ID extends string | number>(actions?: SeraActionConfig<ID>) => boolean;
@@ -6,4 +6,6 @@ export declare const SeraTableContent: <R>(props: {
6
6
  bordered?: boolean;
7
7
  hasTopSection?: boolean;
8
8
  hasBottomSection?: boolean;
9
+ /** Whether to show striped rows, defaults to true */
10
+ striped?: boolean;
9
11
  }) => import("react/jsx-runtime").JSX.Element;
@@ -1,3 +1,4 @@
1
+ import { DataProperty, NestedProperty, ObjectProperty } from 'sera-db';
1
2
  /**
2
3
  * Context to control test ID generation.
3
4
  * Set to true to enable data-testid attributes on components.
@@ -60,3 +61,12 @@ export declare function useTestId(name: string): {
60
61
  export declare function getTestIdProps(name: string, enabled: boolean): {
61
62
  "data-testid"?: string;
62
63
  };
64
+ /**
65
+ * Hook that returns a test ID string for a given property.
66
+ *
67
+ * @param property - The property object, which can be a DataProperty, ObjectProperty, or NestedProperty
68
+ * @param postfix - An optional postfix string to append to the test ID (defaults to empty string)
69
+ */
70
+ export declare function usePropertyTestId(property: DataProperty | ObjectProperty | NestedProperty, postfix?: string): {
71
+ "data-testid"?: string;
72
+ };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "sera-components",
3
3
  "private": false,
4
- "version": "1.6.3",
4
+ "version": "1.6.8",
5
5
  "type": "module",
6
6
  "files": [
7
7
  "dist"