sera-components 1.6.2 → 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.
- package/dist/data/inputs/foreign-key-input.d.ts +3 -3
- package/dist/data/inputs/phone-number-input.d.ts +1 -0
- package/dist/form/embedded-form-item.d.ts +23 -0
- package/dist/form/embedded-form.d.ts +60 -0
- package/dist/form/form.d.ts +8 -44
- package/dist/form/index.d.ts +2 -0
- package/dist/index.js +1779 -1585
- package/dist/index.umd.cjs +7 -7
- package/dist/misc/index.d.ts +1 -0
- package/dist/misc/row.d.ts +54 -0
- package/dist/table/embedded-table.d.ts +4 -0
- package/dist/table/make-columns.d.ts +20 -0
- package/dist/table/table-action.d.ts +1 -0
- package/dist/table/table-content.d.ts +2 -0
- package/dist/utils/index.d.ts +1 -0
- package/dist/utils/test-id.d.ts +72 -0
- package/package.json +1 -1
package/dist/misc/index.d.ts
CHANGED
|
@@ -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;
|
package/dist/utils/index.d.ts
CHANGED
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { DataProperty, NestedProperty, ObjectProperty } from 'sera-db';
|
|
2
|
+
/**
|
|
3
|
+
* Context to control test ID generation.
|
|
4
|
+
* Set to true to enable data-testid attributes on components.
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* ```tsx
|
|
8
|
+
* // In your app entry point
|
|
9
|
+
* import { TestIdProvider } from "sera-components";
|
|
10
|
+
*
|
|
11
|
+
* function App() {
|
|
12
|
+
* // Enable test IDs only in development/test mode
|
|
13
|
+
* const enableTestIds = import.meta.env.DEV || import.meta.env.MODE === "test";
|
|
14
|
+
*
|
|
15
|
+
* return (
|
|
16
|
+
* <TestIdProvider value={enableTestIds}>
|
|
17
|
+
* <YourApp />
|
|
18
|
+
* </TestIdProvider>
|
|
19
|
+
* );
|
|
20
|
+
* }
|
|
21
|
+
* ```
|
|
22
|
+
*/
|
|
23
|
+
export declare const TestIdContext: import('react').Context<boolean>;
|
|
24
|
+
/**
|
|
25
|
+
* Provider component for enabling/disabling test IDs globally.
|
|
26
|
+
*
|
|
27
|
+
* @example
|
|
28
|
+
* ```tsx
|
|
29
|
+
* <TestIdProvider value={true}>
|
|
30
|
+
* <App />
|
|
31
|
+
* </TestIdProvider>
|
|
32
|
+
* ```
|
|
33
|
+
*/
|
|
34
|
+
export declare const TestIdProvider: import('react').Provider<boolean>;
|
|
35
|
+
/**
|
|
36
|
+
* Hook that returns test ID props when test IDs are enabled via TestIdContext.
|
|
37
|
+
* Returns an object with data-testid attribute when enabled, or an empty object when disabled.
|
|
38
|
+
*
|
|
39
|
+
* @param name - The test ID name to use
|
|
40
|
+
* @returns An object containing the data-testid attribute or an empty object
|
|
41
|
+
*
|
|
42
|
+
* @example
|
|
43
|
+
* ```tsx
|
|
44
|
+
* function MyInput({ name }: { name: string }) {
|
|
45
|
+
* const testId = useTestId(`input:${name}`);
|
|
46
|
+
* return <input {...testId} />;
|
|
47
|
+
* }
|
|
48
|
+
* ```
|
|
49
|
+
*/
|
|
50
|
+
export declare function useTestId(name: string): {
|
|
51
|
+
"data-testid"?: string;
|
|
52
|
+
};
|
|
53
|
+
/**
|
|
54
|
+
* Non-hook utility for getting test ID props.
|
|
55
|
+
* Use this when you can't use hooks (e.g., in render functions or callbacks).
|
|
56
|
+
*
|
|
57
|
+
* @param name - The test ID name to use
|
|
58
|
+
* @param enabled - Whether test IDs are enabled
|
|
59
|
+
* @returns An object containing the data-testid attribute or an empty object
|
|
60
|
+
*/
|
|
61
|
+
export declare function getTestIdProps(name: string, enabled: boolean): {
|
|
62
|
+
"data-testid"?: string;
|
|
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
|
+
};
|