@react-typed-forms/schemas 9.2.0 → 10.0.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.
@@ -1,4 +1,9 @@
1
1
  import { SchemaField, SchemaInterface } from "./types";
2
+ import { Control } from "@react-typed-forms/core";
3
+ export declare class DefaultSchemaInterface implements SchemaInterface {
4
+ isEmptyValue(f: SchemaField, value: any): boolean;
5
+ textValue(field: SchemaField, value: any, element?: boolean | undefined): string | undefined;
6
+ controlLength(f: SchemaField, control: Control<any>): number;
7
+ valueLength(field: SchemaField, value: any): number;
8
+ }
2
9
  export declare const defaultSchemaInterface: SchemaInterface;
3
- export declare function defaultIsEmpty(f: SchemaField, value: any): boolean;
4
- export declare function defaultTextValue(f: SchemaField, value: any): string | undefined;
package/lib/types.d.ts CHANGED
@@ -1,3 +1,4 @@
1
+ import { Control } from "@react-typed-forms/core";
1
2
  export interface SchemaField {
2
3
  type: string;
3
4
  field: string;
@@ -49,6 +50,8 @@ export type AnyControlDefinition = DataControlDefinition | GroupedControlsDefini
49
50
  export interface SchemaInterface {
50
51
  isEmptyValue(field: SchemaField, value: any): boolean;
51
52
  textValue(field: SchemaField, value: any, element?: boolean): string | undefined;
53
+ controlLength(field: SchemaField, control: Control<any>): number;
54
+ valueLength(field: SchemaField, value: any): number;
52
55
  }
53
56
  export interface ControlDefinition {
54
57
  type: string;
@@ -288,7 +291,8 @@ export interface ActionControlDefinition extends ControlDefinition {
288
291
  }
289
292
  export declare enum ValidatorType {
290
293
  Jsonata = "Jsonata",
291
- Date = "Date"
294
+ Date = "Date",
295
+ Length = "Length"
292
296
  }
293
297
  export interface SchemaValidator {
294
298
  type: string;
@@ -297,6 +301,11 @@ export interface JsonataValidator extends SchemaValidator {
297
301
  type: ValidatorType.Jsonata;
298
302
  expression: string;
299
303
  }
304
+ export interface LengthValidator extends SchemaValidator {
305
+ type: ValidatorType.Length;
306
+ min?: number | null;
307
+ max?: number | null;
308
+ }
300
309
  export declare enum DateComparison {
301
310
  NotBefore = "NotBefore",
302
311
  NotAfter = "NotAfter"
package/lib/util.d.ts CHANGED
@@ -1,7 +1,11 @@
1
1
  import { CompoundField, ControlDefinition, DataControlDefinition, DisplayOnlyRenderOptions, FieldOption, GroupedControlsDefinition, SchemaField, SchemaInterface } from "./types";
2
2
  import { MutableRefObject } from "react";
3
3
  import { Control } from "@react-typed-forms/core";
4
- import { DataContext, JsonPath } from "./controlRender";
4
+ export type JsonPath = string | number;
5
+ export interface DataContext {
6
+ data: Control<any>;
7
+ path: JsonPath[];
8
+ }
5
9
  export interface ControlDataContext extends DataContext {
6
10
  fields: SchemaField[];
7
11
  schemaInterface: SchemaInterface;
@@ -54,3 +58,5 @@ export declare function useDynamicHooks<P, Hooks extends Record<string, DynamicH
54
58
  [K in keyof Hooks]: DynamicHookValue<Hooks[K]>;
55
59
  };
56
60
  export declare function toDepString(x: any): string;
61
+ export declare function appendElementIndex(dataContext: ControlDataContext, elementIndex: number): ControlDataContext;
62
+ export declare function applyLengthRestrictions<Min, Max>(length: number, min: number | null | undefined, max: number | null | undefined, minValue: Min, maxValue: Max): [Min | undefined, Max | undefined];
@@ -1,4 +1,4 @@
1
- import { ControlDefinition } from "./types";
1
+ import { ControlDefinition, SchemaField, SchemaInterface } from "./types";
2
2
  import { Control } from "@react-typed-forms/core";
3
3
  import { ControlDataContext } from "./util";
4
- export declare function useValidationHook(definition: ControlDefinition): (control: Control<any>, hidden: boolean, groupContext: ControlDataContext) => void;
4
+ export declare function useValidationHook(definition: ControlDefinition, field: SchemaField | undefined): (control: Control<any>, hidden: boolean, groupContext: ControlDataContext, schemaInterface: SchemaInterface) => void;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@react-typed-forms/schemas",
3
- "version": "9.2.0",
3
+ "version": "10.0.0",
4
4
  "description": "",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",