@react-typed-forms/schemas 1.0.0-dev.14 → 1.0.0-dev.15

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.
@@ -1,3 +1,3 @@
1
1
  {
2
- "nonCachedDurationMs": 1494.587678000331
2
+ "nonCachedDurationMs": 1447.798864999786
3
3
  }
@@ -14,9 +14,11 @@ type AllowedSchema<T> = T extends string ? SchemaField & {
14
14
  } : SchemaField & {
15
15
  type: FieldType.Any;
16
16
  };
17
- type AllowedField<T> = (name: string) => AllowedSchema<T>;
18
- export declare function buildSchema<T>(def: {
19
- [K in keyof T]-?: AllowedField<T[K]>;
17
+ type AllowedField<T, K> = (name: string) => (SchemaField & {
18
+ type: K;
19
+ }) | AllowedSchema<T>;
20
+ export declare function buildSchema<T, Custom = "">(def: {
21
+ [K in keyof T]-?: AllowedField<T[K], Custom>;
20
22
  }): SchemaField[];
21
23
  export declare function stringField(displayName: string, options?: Partial<Omit<SchemaField, "type">>): (name: string) => SchemaField & {
22
24
  field?: string | undefined;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@react-typed-forms/schemas",
3
- "version": "1.0.0-dev.14",
3
+ "version": "1.0.0-dev.15",
4
4
  "description": "",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",
@@ -21,10 +21,13 @@ type AllowedSchema<T> = T extends string
21
21
  type: FieldType.Compound;
22
22
  }
23
23
  : SchemaField & { type: FieldType.Any };
24
- type AllowedField<T> = (name: string) => AllowedSchema<T>;
25
24
 
26
- export function buildSchema<T>(def: {
27
- [K in keyof T]-?: AllowedField<T[K]>;
25
+ type AllowedField<T, K> = (
26
+ name: string
27
+ ) => (SchemaField & { type: K }) | AllowedSchema<T>;
28
+
29
+ export function buildSchema<T, Custom = "">(def: {
30
+ [K in keyof T]-?: AllowedField<T[K], Custom>;
28
31
  }): SchemaField[] {
29
32
  return Object.entries(def).map((x) =>
30
33
  (x[1] as (n: string) => SchemaField)(x[0])