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