react-dsl-editor 0.4.3 → 0.4.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/index.d.ts CHANGED
@@ -28,7 +28,7 @@ export declare interface DSL<T extends string> {
28
28
  errors: DSLError[];
29
29
  }
30
30
 
31
- export declare function DslEditor<T extends string>({ code, onChange, onParsed, grammar, wrap, tooltipProps, suggestions: clientSuggestions, className, syntaxColors, ...textareaProps }: {
31
+ export declare function DslEditor<T extends string>({ code, onChange, onParsed, grammar, wrap, tooltipProps, suggestions: clientSuggestions, validate, className, syntaxColors, ...textareaProps }: {
32
32
  code: string;
33
33
  onChange: (text: string) => void;
34
34
  onParsed?: (dsl: DSL<T>) => void;
@@ -36,6 +36,7 @@ export declare function DslEditor<T extends string>({ code, onChange, onParsed,
36
36
  wrap?: boolean;
37
37
  className?: string;
38
38
  tooltipProps?: HTMLAttributes<HTMLElement>;
39
+ validate?: (node: T, text: string) => string | undefined;
39
40
  suggestions?: (node: CSTNode<T>) => string[] | undefined;
40
41
  syntaxColors?: SyntaxColorsProvider;
41
42
  } & Omit<TextareaHTMLAttributes<HTMLTextAreaElement>, 'wrap' | 'onChange'>): JSX.Element;
@@ -45,7 +46,6 @@ export declare interface DSLError {
45
46
  expected?: string[];
46
47
  start: number;
47
48
  end: number;
48
- depth: number;
49
49
  }
50
50
 
51
51
  export declare class DSLParser<T extends string> {
@@ -54,6 +54,8 @@ export declare class DSLParser<T extends string> {
54
54
  private _parseStrict;
55
55
  parseStrict(input: string): ParserSuccess<T> | undefined;
56
56
  parse(input: string): DSL<T>;
57
+ protected validate(node: T, text: string): string | undefined;
58
+ private validateCST;
57
59
  }
58
60
 
59
61
  export declare const eof: GrammarNode<never>;
@@ -82,7 +84,7 @@ export declare function nodeName<T extends string>(node: {
82
84
  grammar: GrammarNode<T>;
83
85
  }): T | undefined;
84
86
 
85
- export declare type NodeTypes<T> = _NodeTypes<T> | 'error';
87
+ export declare type NodeTypes<T> = _NodeTypes<T>;
86
88
 
87
89
  declare type _NodeTypes<T> = T extends GrammarNode<infer U> ? U : never;
88
90
 
@@ -137,6 +139,11 @@ declare const themes: {
137
139
  readonly dark: string[];
138
140
  };
139
141
 
142
+ export declare interface ValidationError<T extends string> {
143
+ node: CSTNode<T>;
144
+ message: string;
145
+ }
146
+
140
147
  export declare function visit<T extends string, V = string>(parserResult: ParserSuccess<T>, type: T[], extractor?: (node: ParserSuccess<T>) => V): V[];
141
148
 
142
149
  export declare function visitPredicate<T extends string, V = string>(parserResult: ParserSuccess<T>, filter: (v: ParserSuccess<T>) => boolean, extractor?: (node: ParserSuccess<T>) => V): V[];