sera-components 1.1.2 → 1.1.4
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/components/src/basic/CountryFlag.d.ts +75 -0
- package/dist/components/src/basic/Language.d.ts +47 -0
- package/dist/components/src/basic/Locale.d.ts +31 -0
- package/dist/components/src/basic/Menu.d.ts +62 -0
- package/dist/components/src/basic/Transition.d.ts +18 -0
- package/dist/components/src/basic/index.d.ts +5 -0
- package/dist/components/src/data/display/BooleanDisplay.d.ts +2 -0
- package/dist/components/src/data/display/DateTimeDisplay.d.ts +4 -0
- package/dist/components/src/data/display/ForeignKeyDisplay.d.ts +7 -0
- package/dist/components/src/data/display/TextDisplay.d.ts +2 -0
- package/dist/components/src/data/display/index.d.ts +17 -0
- package/dist/components/src/data/index.d.ts +2 -0
- package/dist/components/src/data/inputs/BooleanInput.d.ts +2 -0
- package/dist/components/src/data/inputs/ForeignKeyInput.d.ts +22 -0
- package/dist/components/src/data/inputs/NumberInput.d.ts +2 -0
- package/dist/components/src/data/inputs/PhoneNumberInput.d.ts +13 -0
- package/dist/components/src/data/inputs/TextInput.d.ts +2 -0
- package/dist/components/src/data/inputs/index.d.ts +21 -0
- package/dist/components/src/form/Form.d.ts +61 -0
- package/dist/components/src/form/FormItem.d.ts +31 -0
- package/dist/components/src/form/FormItemLabel.d.ts +9 -0
- package/dist/components/src/form/index.d.ts +3 -0
- package/dist/components/src/index.d.ts +7 -0
- package/dist/components/src/misc/index.d.ts +2 -0
- package/dist/components/src/misc/trie.d.ts +36 -0
- package/dist/components/src/misc/utils.d.ts +9 -0
- package/dist/components/src/table/EmbeddedTable.d.ts +13 -0
- package/dist/components/src/table/Table.d.ts +23 -0
- package/dist/components/src/table/TableAction.d.ts +16 -0
- package/dist/components/src/table/TableContent.d.ts +9 -0
- package/dist/components/src/table/TablePagination.d.ts +14 -0
- package/dist/components/src/table/index.d.ts +4 -0
- package/dist/components/src/table/makeColumns.d.ts +54 -0
- package/dist/components/src/view/MultiTabView.d.ts +1 -0
- package/dist/components/src/view/View.d.ts +20 -0
- package/dist/components/src/view/ViewItem.d.ts +12 -0
- package/dist/components/src/view/ViewNestedPropertyItem.d.ts +43 -0
- package/dist/components/src/view/ViewTab.d.ts +16 -0
- package/dist/components/src/view/index.d.ts +2 -0
- package/dist/index.css +1 -0
- package/dist/index.js +3504 -0
- package/dist/index.umd.cjs +33 -0
- package/package.json +8 -5
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { DataProperty, DB, DraftEmbeddedRecord, DraftRecord, EmbeddedSchema, GenericEmbeddedRecord, GenericRecord, ObjectProperty, Schema, SchemaType } from '../../../db/src/index.ts';
|
|
2
|
+
import { DisplayInterface, EntityRoutes } from '../data/display';
|
|
3
|
+
type DOP = DataProperty | ObjectProperty;
|
|
4
|
+
/**
|
|
5
|
+
* Represents a column configuration for a table component.
|
|
6
|
+
*/
|
|
7
|
+
export interface SeraColumn<R> {
|
|
8
|
+
key: string;
|
|
9
|
+
title: React.ReactNode;
|
|
10
|
+
accessorFn: (record: R) => any;
|
|
11
|
+
render: (record: R) => React.ReactNode;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Creates a table column configuration for displaying entity properties in a data table.
|
|
15
|
+
*
|
|
16
|
+
* @template R - The type of the record/row data
|
|
17
|
+
* @param db - The database instance used for data operations
|
|
18
|
+
* @param entityRoutes - Configuration object containing routing information for entities
|
|
19
|
+
* @param property - The data object property (DOP) that defines the column's data type and behavior
|
|
20
|
+
* @param nestedKey - Optional string indicating if this is a nested property path
|
|
21
|
+
* @returns A SeraColumn configuration object with key, title, accessor function, and render component
|
|
22
|
+
*
|
|
23
|
+
* @throws {Error} When no display component is found for the specified datatype
|
|
24
|
+
*
|
|
25
|
+
* @example
|
|
26
|
+
* ```tsx
|
|
27
|
+
* const column = makeTableColumn(db, routes, userNameProperty);
|
|
28
|
+
* // Returns a column that displays user names with appropriate formatting
|
|
29
|
+
* ```
|
|
30
|
+
*
|
|
31
|
+
* @remarks
|
|
32
|
+
* The function automatically selects the appropriate display component based on:
|
|
33
|
+
* - Object properties with cardinality "1:N" or "N:N" use MultiForeignKeyDisplay
|
|
34
|
+
* - Object properties with other cardinalities use SingleForeignKeyDisplay
|
|
35
|
+
* - Non-object properties use components from DataType2DisplayComponent mapping
|
|
36
|
+
*/
|
|
37
|
+
export declare function makeTableColumn<R>(db: DB, entityRoutes: EntityRoutes, property: DOP, { title, nestedKey, component, }?: {
|
|
38
|
+
title?: React.ReactNode;
|
|
39
|
+
nestedKey?: string;
|
|
40
|
+
component?: React.ComponentType<DisplayInterface<any>>;
|
|
41
|
+
}): SeraColumn<R>;
|
|
42
|
+
export declare function makeTableColumnFromNestedProperty<R>(db: DB, entityRoutes: EntityRoutes, property: DOP, nestedProperty: DOP, { title, nestedKey, component, }?: {
|
|
43
|
+
title?: React.ReactNode;
|
|
44
|
+
nestedKey?: string;
|
|
45
|
+
component?: React.ComponentType<DisplayInterface<any>>;
|
|
46
|
+
}): SeraColumn<R>;
|
|
47
|
+
export declare function makeTableColumns<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>, OR>(db: DB, schema: Schema<ID, R, DR, PF, F, ST> | EmbeddedSchema<R, DR, PF, F>, entityRoutes: EntityRoutes, selectedColumns: (PF | SeraColumn<OR>)[], options?: {
|
|
48
|
+
nestedKey?: string;
|
|
49
|
+
}): SeraColumn<OR>[];
|
|
50
|
+
export declare function makeEmbeddedTableColumns<R extends GenericEmbeddedRecord<DR>, DR extends DraftEmbeddedRecord, PF extends keyof R, F extends keyof DR, OR>(db: DB, schema: EmbeddedSchema<R, DR, PF, F>, entityRoutes: EntityRoutes, selectedColumns?: (PF | SeraColumn<OR>)[], options?: {
|
|
51
|
+
nestedKey?: string;
|
|
52
|
+
}): SeraColumn<OR>[];
|
|
53
|
+
export declare function isSeraColumn<R>(column: SeraColumn<R> | any): column is SeraColumn<R>;
|
|
54
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { DataProperty, DraftRecord, GenericRecord, ObjectProperty, Schema, SchemaType, Table } from '../../../db/src/index.ts';
|
|
2
|
+
import { DisplayInterface, EntityRoutes } from '../data/display';
|
|
3
|
+
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>> {
|
|
4
|
+
name?: string;
|
|
5
|
+
fields: (ST["allProperties"] | {
|
|
6
|
+
prop: ST["allProperties"];
|
|
7
|
+
display: React.ComponentType<DisplayInterface<any>>;
|
|
8
|
+
} | ((store: Table<ID, R, DR>, record: R) => React.ReactNode))[][];
|
|
9
|
+
}
|
|
10
|
+
export interface SeraViewProps<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>> {
|
|
11
|
+
schema: Schema<ID, R, DR, PF, F, ST>;
|
|
12
|
+
store: Table<ID, R, DR>;
|
|
13
|
+
fieldGroups: FieldGroup<ID, R, DR, PF, F, ST>[];
|
|
14
|
+
record: R;
|
|
15
|
+
styles?: React.CSSProperties;
|
|
16
|
+
className?: string;
|
|
17
|
+
entityRoutes: EntityRoutes;
|
|
18
|
+
}
|
|
19
|
+
export declare const SeraView: <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: SeraViewProps<ID, R, DR, PF, F, ST>) => import("react/jsx-runtime").JSX.Element;
|
|
20
|
+
export declare function makeFieldDisplay<ID extends string | number, R extends GenericRecord<ID, DR>, DR extends DraftRecord<ID>>(props: (DataProperty | ObjectProperty)[], entityRoutes: EntityRoutes, display?: React.ComponentType<DisplayInterface<any>>): (store: Table<ID, R, DR>, record: R) => React.ReactNode;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { DataProperty, DraftRecord, GenericRecord, ObjectProperty, Table } from '../../../db/src/index.ts';
|
|
2
|
+
import { DisplayInterface, EntityRoutes } from '../data';
|
|
3
|
+
export interface ViewItemProps<ID extends string | number, R extends GenericRecord<ID, DR>, DR extends DraftRecord<ID>> {
|
|
4
|
+
store: Table<ID, R, DR>;
|
|
5
|
+
record: R;
|
|
6
|
+
property: DataProperty | ObjectProperty;
|
|
7
|
+
DisplayComponent: React.ComponentType<DisplayInterface<any>>;
|
|
8
|
+
entityRoutes: EntityRoutes;
|
|
9
|
+
}
|
|
10
|
+
export declare const ViewItem: (<ID extends string | number, R extends GenericRecord<ID, DR>, DR extends DraftRecord<ID>>({ store, record, property, DisplayComponent, entityRoutes, }: ViewItemProps<ID, R, DR>) => import("react/jsx-runtime").JSX.Element) & {
|
|
11
|
+
displayName: string;
|
|
12
|
+
};
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { DataProperty, DraftRecord, GenericRecord, ObjectProperty, Table } from '../../../db/src/index.ts';
|
|
2
|
+
import { DisplayInterface, EntityRoutes } from '../data';
|
|
3
|
+
export interface ViewNestedPropertyItemProps<ID extends string | number, R extends GenericRecord<ID, DR>, DR extends DraftRecord<ID>> {
|
|
4
|
+
store: Table<ID, R, DR>;
|
|
5
|
+
record: R;
|
|
6
|
+
properties: (DataProperty | ObjectProperty)[];
|
|
7
|
+
DisplayComponent: React.ComponentType<DisplayInterface<any>>;
|
|
8
|
+
entityRoutes: EntityRoutes;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* A component that renders a nested property item.
|
|
12
|
+
*
|
|
13
|
+
* This component traverses through a chain of properties to display a deeply nested
|
|
14
|
+
* property value from a record. It shows the last property label and renders the value
|
|
15
|
+
* using the provided DisplayComponent.
|
|
16
|
+
*
|
|
17
|
+
* @template ID - The type of the record identifier (string or number)
|
|
18
|
+
* @template R - The type of the generic record extending GenericRecord
|
|
19
|
+
* @template DR - The type of the draft record extending DraftRecord
|
|
20
|
+
* @template PF - The property field type constrained to keys of R
|
|
21
|
+
* @template F - The field type constrained to keys of DR
|
|
22
|
+
*
|
|
23
|
+
* @param props - The component properties
|
|
24
|
+
* @param props.store - The table store containing the record data
|
|
25
|
+
* @param props.record - The record being viewed
|
|
26
|
+
* @param props.properties - Array of properties defining the path to the nested value
|
|
27
|
+
* @param props.DisplayComponent - React component used to render the field value
|
|
28
|
+
*
|
|
29
|
+
* @returns A JSX element displaying the nested property with its label and value
|
|
30
|
+
*
|
|
31
|
+
* @example
|
|
32
|
+
* ```tsx
|
|
33
|
+
* <ViewNestedPropertyItem
|
|
34
|
+
* store={userStore}
|
|
35
|
+
* record={user}
|
|
36
|
+
* properties={[addressProperty, streetProperty]}
|
|
37
|
+
* DisplayComponent={TextDisplay}
|
|
38
|
+
* />
|
|
39
|
+
* ```
|
|
40
|
+
*/
|
|
41
|
+
export declare const ViewNestedPropertyItem: (<ID extends string | number, R extends GenericRecord<ID, DR>, DR extends DraftRecord<ID>>({ store, record, properties, DisplayComponent, entityRoutes, }: ViewNestedPropertyItemProps<ID, R, DR>) => import("react/jsx-runtime").JSX.Element) & {
|
|
42
|
+
displayName: string;
|
|
43
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { DraftRecord, GenericRecord, Schema, SchemaType, Table } from '../../../db/src/index.ts';
|
|
2
|
+
import { FieldGroup } from './View';
|
|
3
|
+
import { EntityRoutes } from '../data';
|
|
4
|
+
export interface SeraViewTabProps<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>> {
|
|
5
|
+
schema: Schema<ID, R, DR, PF, F, ST>;
|
|
6
|
+
store: Table<ID, R, DR>;
|
|
7
|
+
fieldTabs: {
|
|
8
|
+
tabName: string;
|
|
9
|
+
fieldGroups: FieldGroup<ID, R, DR, PF, F, ST>[];
|
|
10
|
+
}[];
|
|
11
|
+
record: R;
|
|
12
|
+
tabStyles?: React.CSSProperties;
|
|
13
|
+
tabClassName?: string;
|
|
14
|
+
entityRoutes: EntityRoutes;
|
|
15
|
+
}
|
|
16
|
+
export declare const SeraViewTab: <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: SeraViewTabProps<ID, R, DR, PF, F, ST>) => import("react/jsx-runtime").JSX.Element;
|
package/dist/index.css
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
._requiredLabelLeft_l5p83_1:before{color:#ff4d4f;content:"*";font-family:SimSun,sans-serif;display:inline-block;margin-inline-end:4px;line-height:1px;font-size:14px}._requiredLabelRight_l5p83_11:after{color:#ff4d4f;content:"*";font-family:SimSun,sans-serif;display:inline-block;margin-inline-start:4px;line-height:1px;font-size:14px}._pageSizeSelectorActive_1wv6j_1{color:var(--mantine-color-text);opacity:1}._pageSizeSelectorActive_1wv6j_1 .mantine-Menu-itemLabel .mantine-Text-root{font-weight:700!important}
|