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.
@@ -63,6 +63,10 @@ export declare const countryFlags: {
63
63
  svgFlag: string;
64
64
  emojiFlag: string;
65
65
  };
66
+ CAM: {
67
+ svgFlag: string;
68
+ emojiFlag: string;
69
+ };
66
70
  };
67
71
  export declare const SVGCountryFlag: ({ flag }: {
68
72
  flag: CountryFlag;
@@ -46,3 +46,13 @@ export declare const MultiLingualString: ({ value }: {
46
46
  value: MLS;
47
47
  }) => string;
48
48
  export declare const useMultiLingualString: (value: MLS) => string;
49
+ /**
50
+ * Translates a multilingual string based on the provided locale.
51
+ *
52
+ * @param locale - The locale object containing language information.
53
+ * @param value - The multilingual string (MLS) object, which includes mappings
54
+ * of languages to their respective string values.
55
+ * @returns The translated string corresponding to the locale's language, or
56
+ * the default language value if the locale's language is not found.
57
+ */
58
+ export declare function translateMultiLingualString(locale: Intl.Locale, value: MLS): string;
@@ -24,4 +24,12 @@ export interface SearchFormProps {
24
24
  onChange: (value: QueryConditions<any>) => void;
25
25
  queryConditions: QueryConditions<any>;
26
26
  }
27
+ export declare function getNumberOfFilters({ properties, queryConditions, }: {
28
+ properties: SearchFormProps["properties"];
29
+ queryConditions: QueryConditions<any>;
30
+ }): number;
31
+ export declare function getReadableFilters({ properties, queryConditions, }: {
32
+ properties: SearchFormProps["properties"];
33
+ queryConditions: QueryConditions<any>;
34
+ }): string;
27
35
  export declare const SearchForm: ({ db, properties, styles, className, layout, onChange, queryConditions, }: SearchFormProps) => import("react/jsx-runtime").JSX.Element;
@@ -1,10 +1,15 @@
1
1
  import { DataProperty, DraftRecord, GenericRecord, ObjectProperty, Schema, SchemaType, Table } from 'sera-db';
2
+ import { MantineSpacing } from '@mantine/core';
2
3
  import { DisplayInterface } from '../data/display';
4
+ interface FieldArgs<R> {
5
+ display?: React.ComponentType<DisplayInterface<any>>;
6
+ visible?: (record: R) => boolean;
7
+ }
3
8
  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
9
  name?: string;
5
10
  fields: (ST["allProperties"] | {
6
11
  prop: ST["allProperties"];
7
- display: React.ComponentType<DisplayInterface<any>>;
12
+ args?: FieldArgs<R>;
8
13
  } | ((store: Table<ID, R, DR>, record: R) => React.ReactNode))[][];
9
14
  }
10
15
  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>> {
@@ -16,4 +21,57 @@ export interface SeraViewProps<ID extends string | number, R extends GenericReco
16
21
  className?: string;
17
22
  }
18
23
  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;
19
- export declare function makeFieldDisplay<ID extends string | number, R extends GenericRecord<ID, DR>, DR extends DraftRecord<ID>>(props: (DataProperty | ObjectProperty)[], display?: React.ComponentType<DisplayInterface<any>>): (store: Table<ID, R, DR>, record: R) => React.ReactNode;
24
+ /**
25
+ * Creates a nested field renderer function for displaying nested record properties.
26
+ *
27
+ * This function determines the appropriate display component based on the property type
28
+ * (data property or object property) and cardinality, then returns a function that renders
29
+ * the property value within a ViewNestedPropertyItem component.
30
+ *
31
+ * @template ID - The type of the record identifier (string or number)
32
+ * @template R - The generic record type extending GenericRecord
33
+ * @template DR - The draft record type extending DraftRecord
34
+ *
35
+ * @param props - Array of properties defining the nested path to the field
36
+ * @param display - Optional custom display component for rendering the field value
37
+ *
38
+ * @returns A function that takes a store and record, returning a React node to display the nested field
39
+ *
40
+ * @throws {Error} When no display component is found for the specified datatype
41
+ *
42
+ * @example
43
+ * ```tsx
44
+ * const renderField = makeNestedField([userProperty, nameProperty]);
45
+ * const node = renderField(store, record);
46
+ * ```
47
+ */
48
+ export declare function makeNestedField<ID extends string | number, R extends GenericRecord<ID, DR>, DR extends DraftRecord<ID>>(props: (DataProperty | ObjectProperty)[], args?: FieldArgs<R>): (store: Table<ID, R, DR>, record: R) => React.ReactNode;
49
+ /**
50
+ * Groups multiple fields together in a row layout using SimpleGrid.
51
+ *
52
+ * This function creates a renderer that displays multiple fields side-by-side
53
+ * in a grid layout with equal column widths.
54
+ *
55
+ * @template ID - The type of the record identifier (string or number)
56
+ * @template R - The generic record type extending GenericRecord
57
+ * @template DR - The draft record type extending DraftRecord
58
+ *
59
+ * @param fields - Array of field definitions to display in the group
60
+ *
61
+ * @returns A function that takes a store and record, returning a React node with grouped fields
62
+ *
63
+ * @example
64
+ * ```tsx
65
+ * const groupedFields = groupFields([firstNameProperty, lastNameProperty]);
66
+ * const node = groupedFields(store, record);
67
+ * ```
68
+ */
69
+ export declare function groupFields<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>>(schema: Schema<ID, R, DR, PF, F, ST>, fields: (ST["allProperties"] | {
70
+ prop: ST["allProperties"];
71
+ args?: FieldArgs<R>;
72
+ } | ((store: Table<ID, R, DR>, record: R) => React.ReactNode))[], args?: {
73
+ visible?: (record: R) => boolean;
74
+ flexGrow?: boolean;
75
+ flexGap?: MantineSpacing;
76
+ }): (store: Table<ID, R, DR>, record: R) => React.ReactNode;
77
+ export {};
@@ -4,8 +4,9 @@ export interface ViewItemProps<ID extends string | number, R extends GenericReco
4
4
  store: Table<ID, R, DR>;
5
5
  record: R;
6
6
  property: DataProperty | ObjectProperty;
7
+ visible?: (record: R) => boolean;
7
8
  DisplayComponent: React.ComponentType<DisplayInterface<any>>;
8
9
  }
9
- export declare const ViewItem: (<ID extends string | number, R extends GenericRecord<ID, DR>, DR extends DraftRecord<ID>>({ store, record, property, DisplayComponent, }: ViewItemProps<ID, R, DR>) => import("react/jsx-runtime").JSX.Element) & {
10
+ export declare const ViewItem: (<ID extends string | number, R extends GenericRecord<ID, DR>, DR extends DraftRecord<ID>>({ store, record, property, DisplayComponent, visible, }: ViewItemProps<ID, R, DR>) => import("react/jsx-runtime").JSX.Element) & {
10
11
  displayName: string;
11
12
  };
@@ -5,6 +5,7 @@ export interface ViewNestedPropertyItemProps<ID extends string | number, R exten
5
5
  record: R;
6
6
  properties: (DataProperty | ObjectProperty)[];
7
7
  DisplayComponent: React.ComponentType<DisplayInterface<any>>;
8
+ visible?: (record: R) => boolean;
8
9
  }
9
10
  /**
10
11
  * A component that renders a nested property item.
@@ -37,6 +38,6 @@ export interface ViewNestedPropertyItemProps<ID extends string | number, R exten
37
38
  * />
38
39
  * ```
39
40
  */
40
- export declare const ViewNestedPropertyItem: (<ID extends string | number, R extends GenericRecord<ID, DR>, DR extends DraftRecord<ID>>({ store, record, properties, DisplayComponent, }: ViewNestedPropertyItemProps<ID, R, DR>) => import("react/jsx-runtime").JSX.Element) & {
41
+ export declare const ViewNestedPropertyItem: (<ID extends string | number, R extends GenericRecord<ID, DR>, DR extends DraftRecord<ID>>({ store, record, properties, DisplayComponent, visible, }: ViewNestedPropertyItemProps<ID, R, DR>) => import("react/jsx-runtime").JSX.Element) & {
41
42
  displayName: string;
42
43
  };
@@ -1,2 +1,2 @@
1
- export { SeraView, makeFieldDisplay } from './View';
1
+ export { SeraView, makeNestedField, groupFields } from './View';
2
2
  export { SeraViewTab } from './ViewTab';
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "sera-components",
3
3
  "private": false,
4
- "version": "1.4.7",
4
+ "version": "1.5.0",
5
5
  "type": "module",
6
6
  "files": [
7
7
  "dist"
@@ -44,7 +44,7 @@
44
44
  "react-dom": "^19.0.0",
45
45
  "react-imask": "^7.6.1",
46
46
  "react-router": "^7.7.1",
47
- "sera-db": "^1.12.6",
47
+ "sera-db": "^1.12.7",
48
48
  "throttle-debounce": "^5.0.2",
49
49
  "dayjs": "^1.11.18"
50
50
  }