sera-components 1.4.7 → 1.5.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.
- package/dist/data/display/DateTimeDisplay.d.ts +2 -0
- package/dist/data/display/EnumDisplay.d.ts +1 -1
- package/dist/data/display/index.d.ts +0 -1
- package/dist/data/inputs/DateRangeInput.d.ts +4 -0
- package/dist/data/inputs/EnumInput.d.ts +2 -0
- package/dist/data/inputs/ForeignKeyInput.d.ts +5 -3
- package/dist/data/inputs/PhoneNumberInput.d.ts +1 -0
- package/dist/data/inputs/index.d.ts +5 -2
- package/dist/form/Form.d.ts +12 -2
- package/dist/form/FormItem.d.ts +16 -2
- package/dist/form/FormNestedPropertyItem.d.ts +38 -0
- package/dist/form/index.d.ts +1 -0
- package/dist/index.js +1806 -1453
- package/dist/index.umd.cjs +7 -7
- package/dist/misc/CountryFlag.d.ts +4 -0
- package/dist/misc/Language.d.ts +10 -0
- package/dist/search/SearchForm.d.ts +8 -0
- package/dist/view/View.d.ts +60 -2
- package/dist/view/ViewItem.d.ts +2 -1
- package/dist/view/ViewNestedPropertyItem.d.ts +2 -1
- package/dist/view/index.d.ts +1 -1
- package/package.json +2 -2
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import { DisplayInterface } from '.';
|
|
2
|
+
export declare function formatDate(locale: Intl.Locale, value: Date): string;
|
|
3
|
+
export declare function formatDateTime(locale: Intl.Locale, value: Date, withSeconds?: boolean): string;
|
|
2
4
|
export declare const DateTimeDisplay: ({ value }: DisplayInterface<Date>) => import("react/jsx-runtime").JSX.Element;
|
|
3
5
|
export declare const DateDisplay: ({ value }: DisplayInterface<Date>) => import("react/jsx-runtime").JSX.Element;
|
|
4
6
|
export declare const DateTimeHideTimeDisplay: ({ value }: DisplayInterface<Date>) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { DisplayInterface } from '.';
|
|
2
|
-
export declare const EnumDisplay: ({
|
|
2
|
+
export declare const EnumDisplay: ({ property, value }: DisplayInterface<any>) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -4,7 +4,6 @@ export { SingleForeignKeyDisplay, MultiForeignKeyDisplay } from './ForeignKeyDis
|
|
|
4
4
|
export type DisplayInterface<T> = {
|
|
5
5
|
db: DB;
|
|
6
6
|
property: DataProperty | ObjectProperty;
|
|
7
|
-
nestedProperty?: DataProperty | ObjectProperty;
|
|
8
7
|
value: T;
|
|
9
8
|
};
|
|
10
9
|
export declare const DataType2DisplayComponent: Partial<Record<DataType, React.ComponentType<DisplayInterface<any>>>>;
|
|
@@ -3,10 +3,10 @@ import { Record } from 'sera-db';
|
|
|
3
3
|
export declare const SingleForeignKeyInput: (<T>(_props: InputInterface<T>) => import("react/jsx-runtime").JSX.Element) & {
|
|
4
4
|
displayName: string;
|
|
5
5
|
};
|
|
6
|
-
export declare const MultiForeignKeyInput: (<ID extends string | number>({ db, property, value: recordIds, onChange, }: InputInterface<ID[]>) => import("react/jsx-runtime").JSX.Element) & {
|
|
6
|
+
export declare const MultiForeignKeyInput: (<ID extends string | number>({ db, property, value: recordIds, onChange, freeze, }: InputInterface<ID[]>) => import("react/jsx-runtime").JSX.Element) & {
|
|
7
7
|
displayName: string;
|
|
8
8
|
};
|
|
9
|
-
export declare const SearchInput: <ID extends string | number, R extends Record<ID>>({ name, data, onSelect, renderOption, isIdInteger, query, setQuery, }: {
|
|
9
|
+
export declare const SearchInput: <ID extends string | number, R extends Record<ID>>({ name, data, onSelect, renderOption, isIdInteger, query, setQuery, freeze, }: {
|
|
10
10
|
name?: string;
|
|
11
11
|
query: string;
|
|
12
12
|
setQuery: (query: string) => void;
|
|
@@ -14,9 +14,11 @@ export declare const SearchInput: <ID extends string | number, R extends Record<
|
|
|
14
14
|
data: R[];
|
|
15
15
|
renderOption: (record: R) => React.ReactNode;
|
|
16
16
|
isIdInteger?: boolean;
|
|
17
|
+
freeze?: boolean;
|
|
17
18
|
}) => import("react/jsx-runtime").JSX.Element;
|
|
18
|
-
export declare const CardList: <R>({ items, onDelete, render, }: {
|
|
19
|
+
export declare const CardList: <R>({ items, onDelete, render, freeze, }: {
|
|
19
20
|
items: R[];
|
|
20
21
|
onDelete: (value: R) => void;
|
|
21
22
|
render: (value: R) => React.ReactNode;
|
|
23
|
+
freeze?: boolean;
|
|
22
24
|
}) => import("react/jsx-runtime").JSX.Element | undefined;
|
|
@@ -3,8 +3,9 @@ import { BooleanInput } from './BooleanInput';
|
|
|
3
3
|
import { NumberInput } from './NumberInput';
|
|
4
4
|
import { TextInput } from './TextInput';
|
|
5
5
|
import { DateInput } from './DateInput';
|
|
6
|
+
import { EnumInput } from './EnumInput';
|
|
6
7
|
export { SingleForeignKeyInput, MultiForeignKeyInput } from './ForeignKeyInput';
|
|
7
|
-
export { DateRangeInput } from './DateRangeInput';
|
|
8
|
+
export { DateRangeInput, DateTimeRangeInput } from './DateRangeInput';
|
|
8
9
|
/**
|
|
9
10
|
* Interface for input components in forms
|
|
10
11
|
* @interface InputInterface
|
|
@@ -13,6 +14,7 @@ export { DateRangeInput } from './DateRangeInput';
|
|
|
13
14
|
* @property {any} value - The current value of the input
|
|
14
15
|
* @property {function} onChange - Callback function triggered when input value changes
|
|
15
16
|
* @property {boolean | string} [error] - If the type is boolean it will be error, if there is a string message it should display that message
|
|
17
|
+
* @property {boolean} [freeze = false] - Whether the input is available for editing
|
|
16
18
|
*/
|
|
17
19
|
export type InputInterface<T> = {
|
|
18
20
|
db: DB;
|
|
@@ -20,9 +22,10 @@ export type InputInterface<T> = {
|
|
|
20
22
|
value: T;
|
|
21
23
|
onChange: (value: T) => void;
|
|
22
24
|
error?: boolean | string;
|
|
25
|
+
freeze?: boolean;
|
|
23
26
|
};
|
|
24
27
|
/**
|
|
25
28
|
* Mapping of data types to their corresponding input components
|
|
26
29
|
*/
|
|
27
30
|
export declare const DataType2InputComponent: Partial<Record<DataType, React.FC<InputInterface<any>>>>;
|
|
28
|
-
export { NumberInput, BooleanInput, TextInput, DateInput };
|
|
31
|
+
export { NumberInput, BooleanInput, TextInput, DateInput, EnumInput };
|
package/dist/form/Form.d.ts
CHANGED
|
@@ -1,17 +1,26 @@
|
|
|
1
1
|
import { DraftRecord, GenericRecord, MultiLingualString, Schema, SchemaType, Table } from 'sera-db';
|
|
2
|
+
import { InputInterface } from '../data/inputs';
|
|
2
3
|
import { FormItemLayout } from './FormItem';
|
|
3
4
|
export interface CustomField {
|
|
4
5
|
name: string;
|
|
5
6
|
label: MultiLingualString;
|
|
6
7
|
description?: MultiLingualString;
|
|
7
8
|
}
|
|
9
|
+
interface FieldArgs<DR> {
|
|
10
|
+
input?: React.ComponentType<InputInterface<any>>;
|
|
11
|
+
freeze?: boolean;
|
|
12
|
+
visible?: (record: DR) => boolean;
|
|
13
|
+
}
|
|
8
14
|
export interface FieldGroup<ID extends string | number, R extends GenericRecord<ID, DR>, DR extends DraftRecord<ID>, PF extends keyof R, F extends keyof DR, ST extends SchemaType<ID, R, DR, PF, F>> {
|
|
9
15
|
name?: string;
|
|
10
|
-
fields: ST["allProperties"]
|
|
16
|
+
fields: (ST["allProperties"] | {
|
|
17
|
+
prop: ST["allProperties"];
|
|
18
|
+
args?: FieldArgs<DR>;
|
|
19
|
+
} | ((store: Table<ID, R, DR>, record: R | DR) => React.ReactNode))[][];
|
|
11
20
|
}
|
|
12
21
|
export interface SeraFormProps<ID extends string | number, R extends GenericRecord<ID, DR>, DR extends DraftRecord<ID>, PF extends keyof R, F extends keyof DR, ST extends SchemaType<ID, R, DR, PF, F>> {
|
|
13
22
|
schema: Schema<ID, R, DR, PF, F, ST>;
|
|
14
|
-
store: Table<
|
|
23
|
+
store: Table<ID, R, DR>;
|
|
15
24
|
fieldGroups: FieldGroup<ID, R, DR, PF, F, ST>[];
|
|
16
25
|
layout?: FormItemLayout;
|
|
17
26
|
actions: {
|
|
@@ -59,3 +68,4 @@ export interface SeraFormProps<ID extends string | number, R extends GenericReco
|
|
|
59
68
|
* ```
|
|
60
69
|
*/
|
|
61
70
|
export declare const SeraForm: <ID extends string | number, R extends GenericRecord<ID, DR>, DR extends DraftRecord<ID>, PF extends keyof R, F extends keyof DR, ST extends SchemaType<ID, R, DR, PF, F>>(props: SeraFormProps<ID, R, DR, PF, F, ST>) => import("react/jsx-runtime").JSX.Element;
|
|
71
|
+
export {};
|
package/dist/form/FormItem.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { DataProperty, DraftRecord, GenericRecord, ObjectProperty, Table, validators } from 'sera-db';
|
|
1
|
+
import { DataProperty, DB, DraftRecord, GenericRecord, ObjectProperty, Table, validators } from 'sera-db';
|
|
2
2
|
import { InputInterface } from '../data/inputs';
|
|
3
3
|
export interface FormItemHorizontalLayout {
|
|
4
4
|
type: "horizontal";
|
|
@@ -18,13 +18,27 @@ export interface FormItemProps<ID extends string | number, R extends GenericReco
|
|
|
18
18
|
InputComponent: React.FC<InputInterface<any>> | React.ComponentType<InputInterface<any>>;
|
|
19
19
|
validator: validators.ValueValidator;
|
|
20
20
|
layout?: FormItemLayout;
|
|
21
|
+
freeze?: boolean;
|
|
21
22
|
}
|
|
23
|
+
export declare const DEFAULT_LAYOUT: FormItemVerticalLayout;
|
|
22
24
|
/**
|
|
23
25
|
* FormItem component for creating form elements with labels, tooltips and layout options.
|
|
24
26
|
*
|
|
25
27
|
* Supports both horizontal and vertical layouts. In horizontal layout, the label and input are placed side by side in a grid.
|
|
26
28
|
* In vertical layout, the label is positioned above the input using Mantine's Input.Wrapper.
|
|
27
29
|
*/
|
|
28
|
-
export declare const FormItem: (<ID extends string | number, R extends GenericRecord<ID, DR>, DR extends DraftRecord<ID>>({ store, record, property, layout, InputComponent, validator, }: FormItemProps<ID, R, DR>) => import("react/jsx-runtime").JSX.Element) & {
|
|
30
|
+
export declare const FormItem: (<ID extends string | number, R extends GenericRecord<ID, DR>, DR extends DraftRecord<ID>>({ store, record, property, layout, InputComponent, validator, freeze, }: FormItemProps<ID, R, DR>) => import("react/jsx-runtime").JSX.Element) & {
|
|
29
31
|
displayName: string;
|
|
30
32
|
};
|
|
33
|
+
export declare function FormItemInner({ db, layout, property, InputComponent, freeze, value, error, onChange, }: {
|
|
34
|
+
db: DB;
|
|
35
|
+
layout: FormItemLayout;
|
|
36
|
+
property: DataProperty | ObjectProperty;
|
|
37
|
+
InputComponent: React.FC<InputInterface<any>> | React.ComponentType<InputInterface<any>>;
|
|
38
|
+
validator: validators.ValueValidator;
|
|
39
|
+
freeze: boolean;
|
|
40
|
+
value: any;
|
|
41
|
+
error: string | undefined;
|
|
42
|
+
onChange: (value: any) => void;
|
|
43
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
44
|
+
export declare function isHorizontalLayout(layout: FormItemLayout): layout is FormItemHorizontalLayout;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { DataProperty, DraftRecord, GenericRecord, ObjectProperty, validators, Table } from 'sera-db';
|
|
2
|
+
import { InputInterface } from '../data';
|
|
3
|
+
import { FormItemLayout } from './FormItem';
|
|
4
|
+
export interface FormNestedPropertyItemProps<ID extends string | number, R extends GenericRecord<ID, DR>, DR extends DraftRecord<ID>> {
|
|
5
|
+
store: Table<ID, R, DR>;
|
|
6
|
+
record: DR | R;
|
|
7
|
+
properties: (DataProperty | ObjectProperty)[];
|
|
8
|
+
InputComponent: React.ComponentType<InputInterface<any>>;
|
|
9
|
+
validator: validators.ValueValidator;
|
|
10
|
+
layout?: FormItemLayout;
|
|
11
|
+
freeze?: boolean;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* A component that renders a nested property input for forms.
|
|
15
|
+
*
|
|
16
|
+
* This component traverses through a chain of properties to create input fields
|
|
17
|
+
* for deeply nested property values in a record. It handles embedded objects
|
|
18
|
+
* by creating nested form structures.
|
|
19
|
+
*
|
|
20
|
+
* @template ID - The type of the record identifier (string or number)
|
|
21
|
+
* @template R - The type of the generic record extending GenericRecord
|
|
22
|
+
* @template DR - The type of the draft record extending DraftRecord
|
|
23
|
+
*
|
|
24
|
+
* @param props - The component properties
|
|
25
|
+
* @param props.store - The table store containing the record data
|
|
26
|
+
* @param props.record - The draft record being edited
|
|
27
|
+
* @param props.properties - Array of properties defining the path to the nested value
|
|
28
|
+
* @param props.InputComponent - React component used to render the field input
|
|
29
|
+
*
|
|
30
|
+
* @returns A JSX element with input fields for the nested property
|
|
31
|
+
*/
|
|
32
|
+
export declare const FormNestedPropertyItem: (<ID extends string | number, R extends GenericRecord<ID, DR>, DR extends DraftRecord<ID>>({ store, record, properties, layout, InputComponent, validator, freeze, }: FormNestedPropertyItemProps<ID, R, DR>) => import("react/jsx-runtime").JSX.Element) & {
|
|
33
|
+
displayName: string;
|
|
34
|
+
};
|
|
35
|
+
export declare function makeFieldForm<ID extends string | number, R extends GenericRecord<ID, DR>, DR extends DraftRecord<ID>>(props: (DataProperty | ObjectProperty)[], validators: validators.ValueValidator, args?: {
|
|
36
|
+
input?: React.ComponentType<InputInterface<any>>;
|
|
37
|
+
freeze?: boolean;
|
|
38
|
+
}): (store: Table<ID, R, DR>, record: DR) => React.ReactNode;
|
package/dist/form/index.d.ts
CHANGED