@nokecy/qc-ui 1.0.66 → 1.0.67

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.
Files changed (123) hide show
  1. package/dist/cjs/components/RegexEditor/core/RegexEditor.d.ts +34 -0
  2. package/dist/cjs/components/RegexEditor/core/RegexEditor.js +223 -0
  3. package/dist/cjs/components/RegexEditor/core/RegexEditor.less +119 -0
  4. package/dist/cjs/components/RegexEditor/core/extensions/errorMarker.d.ts +49 -0
  5. package/dist/cjs/components/RegexEditor/core/extensions/errorMarker.js +158 -0
  6. package/dist/cjs/components/RegexEditor/core/types.d.ts +79 -0
  7. package/dist/cjs/components/RegexEditor/core/types.js +5 -0
  8. package/dist/cjs/components/RegexEditor/hooks/index.d.ts +9 -0
  9. package/dist/cjs/components/RegexEditor/hooks/index.js +19 -0
  10. package/dist/cjs/components/RegexEditor/hooks/useRegexTester.d.ts +95 -0
  11. package/dist/cjs/components/RegexEditor/hooks/useRegexTester.js +234 -0
  12. package/dist/cjs/components/RegexEditor/hooks/useRegexValidation.d.ts +71 -0
  13. package/dist/cjs/components/RegexEditor/hooks/useRegexValidation.js +215 -0
  14. package/dist/cjs/components/RegexEditor/hooks/useTemplateManager.d.ts +64 -0
  15. package/dist/cjs/components/RegexEditor/hooks/useTemplateManager.js +438 -0
  16. package/dist/cjs/components/RegexEditor/index.d.ts +16 -0
  17. package/dist/cjs/components/RegexEditor/index.js +232 -0
  18. package/dist/cjs/components/RegexEditor/templates/TemplateSelector.d.ts +36 -0
  19. package/dist/cjs/components/RegexEditor/templates/TemplateSelector.js +322 -0
  20. package/dist/cjs/components/RegexEditor/templates/builtinTemplates.d.ts +36 -0
  21. package/dist/cjs/components/RegexEditor/templates/builtinTemplates.js +340 -0
  22. package/dist/cjs/components/RegexEditor/templates/index.d.ts +10 -0
  23. package/dist/cjs/components/RegexEditor/templates/index.js +184 -0
  24. package/dist/cjs/components/RegexEditor/templates/storage.d.ts +74 -0
  25. package/dist/cjs/components/RegexEditor/templates/storage.js +337 -0
  26. package/dist/cjs/components/RegexEditor/templates/templateManager.d.ts +67 -0
  27. package/dist/cjs/components/RegexEditor/templates/templateManager.js +277 -0
  28. package/dist/cjs/components/RegexEditor/templates/types.d.ts +111 -0
  29. package/dist/cjs/components/RegexEditor/templates/types.js +94 -0
  30. package/dist/cjs/components/RegexEditor/testing/types.d.ts +55 -0
  31. package/dist/cjs/components/RegexEditor/testing/types.js +5 -0
  32. package/dist/cjs/components/RegexEditor/validation/complexity.d.ts +22 -0
  33. package/dist/cjs/components/RegexEditor/validation/complexity.js +196 -0
  34. package/dist/cjs/components/RegexEditor/validation/parser.d.ts +53 -0
  35. package/dist/cjs/components/RegexEditor/validation/parser.js +129 -0
  36. package/dist/cjs/components/RegexEditor/validation/types.d.ts +146 -0
  37. package/dist/cjs/components/RegexEditor/validation/types.js +5 -0
  38. package/dist/cjs/components/RegexEditor/validation/validator.d.ts +60 -0
  39. package/dist/cjs/components/RegexEditor/validation/validator.js +218 -0
  40. package/dist/cjs/components/RegexEditor/visualizer/FlagsSelector.d.ts +20 -0
  41. package/dist/cjs/components/RegexEditor/visualizer/FlagsSelector.js +98 -0
  42. package/dist/cjs/components/RegexEditor/visualizer/MatchItem.d.ts +25 -0
  43. package/dist/cjs/components/RegexEditor/visualizer/MatchItem.js +201 -0
  44. package/dist/cjs/components/RegexEditor/visualizer/RegexRailroadDiagram.d.ts +32 -0
  45. package/dist/cjs/components/RegexEditor/visualizer/RegexRailroadDiagram.js +192 -0
  46. package/dist/cjs/components/RegexEditor/visualizer/RegexTester.d.ts +22 -0
  47. package/dist/cjs/components/RegexEditor/visualizer/RegexTester.js +255 -0
  48. package/dist/cjs/components/RegexEditor/visualizer/astToRailroad.d.ts +19 -0
  49. package/dist/cjs/components/RegexEditor/visualizer/astToRailroad.js +155 -0
  50. package/dist/cjs/components/RegexEditor/visualizer/index.d.ts +12 -0
  51. package/dist/cjs/components/RegexEditor/visualizer/index.js +76 -0
  52. package/dist/cjs/components/RegexEditor/visualizer/types.d.ts +131 -0
  53. package/dist/cjs/components/RegexEditor/visualizer/types.js +5 -0
  54. package/dist/cjs/components/RegexEditor/visualizer/utils.d.ts +106 -0
  55. package/dist/cjs/components/RegexEditor/visualizer/utils.js +268 -0
  56. package/dist/cjs/index.d.ts +3 -1
  57. package/dist/cjs/index.js +55 -0
  58. package/dist/cjs/standardFormDialog/useStandardFormSchema.d.ts +1 -1
  59. package/dist/cjs/standardFormDialog/withStandardForm.d.ts +2 -2
  60. package/dist/cjs/types/railroad-diagrams.d.ts +59 -0
  61. package/dist/cjs/types/regexp-tree.d.ts +175 -0
  62. package/dist/esm/components/RegexEditor/core/RegexEditor.d.ts +34 -0
  63. package/dist/esm/components/RegexEditor/core/RegexEditor.js +214 -0
  64. package/dist/esm/components/RegexEditor/core/RegexEditor.less +119 -0
  65. package/dist/esm/components/RegexEditor/core/extensions/errorMarker.d.ts +49 -0
  66. package/dist/esm/components/RegexEditor/core/extensions/errorMarker.js +154 -0
  67. package/dist/esm/components/RegexEditor/core/types.d.ts +79 -0
  68. package/dist/esm/components/RegexEditor/core/types.js +1 -0
  69. package/dist/esm/components/RegexEditor/hooks/index.d.ts +9 -0
  70. package/dist/esm/components/RegexEditor/hooks/index.js +8 -0
  71. package/dist/esm/components/RegexEditor/hooks/useRegexTester.d.ts +95 -0
  72. package/dist/esm/components/RegexEditor/hooks/useRegexTester.js +230 -0
  73. package/dist/esm/components/RegexEditor/hooks/useRegexValidation.d.ts +71 -0
  74. package/dist/esm/components/RegexEditor/hooks/useRegexValidation.js +211 -0
  75. package/dist/esm/components/RegexEditor/hooks/useTemplateManager.d.ts +64 -0
  76. package/dist/esm/components/RegexEditor/hooks/useTemplateManager.js +430 -0
  77. package/dist/esm/components/RegexEditor/index.d.ts +16 -0
  78. package/dist/esm/components/RegexEditor/index.js +27 -0
  79. package/dist/esm/components/RegexEditor/templates/TemplateSelector.d.ts +36 -0
  80. package/dist/esm/components/RegexEditor/templates/TemplateSelector.js +316 -0
  81. package/dist/esm/components/RegexEditor/templates/builtinTemplates.d.ts +36 -0
  82. package/dist/esm/components/RegexEditor/templates/builtinTemplates.js +335 -0
  83. package/dist/esm/components/RegexEditor/templates/index.d.ts +10 -0
  84. package/dist/esm/components/RegexEditor/templates/index.js +19 -0
  85. package/dist/esm/components/RegexEditor/templates/storage.d.ts +74 -0
  86. package/dist/esm/components/RegexEditor/templates/storage.js +335 -0
  87. package/dist/esm/components/RegexEditor/templates/templateManager.d.ts +67 -0
  88. package/dist/esm/components/RegexEditor/templates/templateManager.js +274 -0
  89. package/dist/esm/components/RegexEditor/templates/types.d.ts +111 -0
  90. package/dist/esm/components/RegexEditor/templates/types.js +90 -0
  91. package/dist/esm/components/RegexEditor/testing/types.d.ts +55 -0
  92. package/dist/esm/components/RegexEditor/testing/types.js +1 -0
  93. package/dist/esm/components/RegexEditor/validation/complexity.d.ts +22 -0
  94. package/dist/esm/components/RegexEditor/validation/complexity.js +190 -0
  95. package/dist/esm/components/RegexEditor/validation/parser.d.ts +53 -0
  96. package/dist/esm/components/RegexEditor/validation/parser.js +123 -0
  97. package/dist/esm/components/RegexEditor/validation/types.d.ts +145 -0
  98. package/dist/esm/components/RegexEditor/validation/types.js +1 -0
  99. package/dist/esm/components/RegexEditor/validation/validator.d.ts +60 -0
  100. package/dist/esm/components/RegexEditor/validation/validator.js +213 -0
  101. package/dist/esm/components/RegexEditor/visualizer/FlagsSelector.d.ts +20 -0
  102. package/dist/esm/components/RegexEditor/visualizer/FlagsSelector.js +93 -0
  103. package/dist/esm/components/RegexEditor/visualizer/MatchItem.d.ts +25 -0
  104. package/dist/esm/components/RegexEditor/visualizer/MatchItem.js +194 -0
  105. package/dist/esm/components/RegexEditor/visualizer/RegexRailroadDiagram.d.ts +32 -0
  106. package/dist/esm/components/RegexEditor/visualizer/RegexRailroadDiagram.js +186 -0
  107. package/dist/esm/components/RegexEditor/visualizer/RegexTester.d.ts +22 -0
  108. package/dist/esm/components/RegexEditor/visualizer/RegexTester.js +248 -0
  109. package/dist/esm/components/RegexEditor/visualizer/astToRailroad.d.ts +18 -0
  110. package/dist/esm/components/RegexEditor/visualizer/astToRailroad.js +150 -0
  111. package/dist/esm/components/RegexEditor/visualizer/index.d.ts +12 -0
  112. package/dist/esm/components/RegexEditor/visualizer/index.js +17 -0
  113. package/dist/esm/components/RegexEditor/visualizer/types.d.ts +131 -0
  114. package/dist/esm/components/RegexEditor/visualizer/types.js +1 -0
  115. package/dist/esm/components/RegexEditor/visualizer/utils.d.ts +106 -0
  116. package/dist/esm/components/RegexEditor/visualizer/utils.js +256 -0
  117. package/dist/esm/index.d.ts +3 -1
  118. package/dist/esm/index.js +5 -2
  119. package/dist/esm/types/railroad-diagrams.d.ts +59 -0
  120. package/dist/esm/types/regexp-tree.d.ts +175 -0
  121. package/dist/umd/qc-ui.min.css +1 -1
  122. package/dist/umd/qc-ui.min.js +1 -1
  123. package/package.json +23 -7
@@ -0,0 +1,175 @@
1
+ /**
2
+ * regexp-tree 库的类型定义
3
+ *
4
+ * @description
5
+ * 为 regexp-tree 库提供完整的 TypeScript 类型支持,包括 AST 节点类型和主要 API。
6
+ *
7
+ * @see https://github.com/DmitrySoshnikov/regexp-tree
8
+ */
9
+
10
+ declare module 'regexp-tree/ast' {
11
+ export interface AstClassMap {
12
+ 'RegExp': AstRegExp;
13
+ 'Disjunction': Disjunction;
14
+ 'Alternative': Alternative;
15
+ 'Assertion': Assertion;
16
+ 'Char': Char;
17
+ 'CharacterClass': CharacterClass;
18
+ 'ClassRange': ClassRange;
19
+ 'Backreference': Backreference;
20
+ 'Group': Group;
21
+ 'Repetition': Repetition;
22
+ 'Quantifier': Quantifier;
23
+ }
24
+
25
+ export type AstClass = keyof AstClassMap;
26
+ export type AstNode = AstClassMap[AstClass];
27
+ export type AstNodeLocation = {
28
+ line: number;
29
+ column: number;
30
+ offset: number;
31
+ };
32
+
33
+ export interface Base<T extends AstClass> {
34
+ type: T;
35
+ loc?: {
36
+ source: string;
37
+ start: AstNodeLocation;
38
+ end: AstNodeLocation;
39
+ };
40
+ }
41
+
42
+ export interface SimpleChar extends Base<'Char'> {
43
+ value: string;
44
+ kind: 'simple';
45
+ escaped?: true;
46
+ codePoint: number;
47
+ }
48
+
49
+ export interface SpecialChar extends Base<'Char'> {
50
+ value: string;
51
+ kind: 'meta' | 'control' | 'hex' | 'decimal' | 'oct' | 'unicode';
52
+ codePoint: number;
53
+ }
54
+
55
+ export type Char =
56
+ | SimpleChar
57
+ | SpecialChar;
58
+
59
+ export interface ClassRange extends Base<'ClassRange'> {
60
+ from: Char;
61
+ to: Char;
62
+ }
63
+
64
+ export interface CharacterClass extends Base<'CharacterClass'> {
65
+ negative?: true;
66
+ expressions: (Char | ClassRange)[];
67
+ }
68
+
69
+ export interface Alternative extends Base<'Alternative'> {
70
+ expressions: Expression[];
71
+ }
72
+
73
+ export interface Disjunction extends Base<'Disjunction'> {
74
+ left: Expression | null;
75
+ right: Expression | null;
76
+ }
77
+
78
+ export interface CapturingGroup extends Base<'Group'> {
79
+ capturing: true;
80
+ number: number;
81
+ name?: string;
82
+ nameRaw?: string;
83
+ expression: Expression | null;
84
+ }
85
+
86
+ export interface NoncapturingGroup extends Base<'Group'> {
87
+ capturing: false;
88
+ expression: Expression | null;
89
+ }
90
+
91
+ export type Group =
92
+ | CapturingGroup
93
+ | NoncapturingGroup;
94
+
95
+ export interface NumericBackreference extends Base<'Backreference'> {
96
+ kind: 'number';
97
+ number: number;
98
+ reference: number;
99
+ }
100
+
101
+ export interface NamedBackreference extends Base<'Backreference'> {
102
+ kind: 'name';
103
+ number: number;
104
+ reference: string;
105
+ referenceRaw: string;
106
+ }
107
+
108
+ export type Backreference =
109
+ | NumericBackreference
110
+ | NamedBackreference;
111
+
112
+ export interface Repetition extends Base<'Repetition'> {
113
+ expression: Expression;
114
+ quantifier: Quantifier;
115
+ }
116
+
117
+ export interface SimpleQuantifier extends Base<'Quantifier'> {
118
+ kind: '+' | '*' | '?';
119
+ greedy: boolean;
120
+ }
121
+
122
+ export interface RangeQuantifier extends Base<'Quantifier'> {
123
+ kind: 'Range';
124
+ from: number;
125
+ to?: number;
126
+ greedy: boolean;
127
+ }
128
+
129
+ export type Quantifier =
130
+ | SimpleQuantifier
131
+ | RangeQuantifier;
132
+
133
+ export interface SimpleAssertion extends Base<'Assertion'> {
134
+ kind: '^' | '$' | '\\b' | '\\B';
135
+ }
136
+
137
+ export interface LookaroundAssertion extends Base<'Assertion'> {
138
+ kind: 'Lookahead' | 'Lookbehind';
139
+ negative?: true;
140
+ assertion: Expression | null;
141
+ }
142
+
143
+ export type Assertion =
144
+ | SimpleAssertion
145
+ | LookaroundAssertion;
146
+
147
+ export type Expression =
148
+ | Char
149
+ | CharacterClass
150
+ | Alternative
151
+ | Disjunction
152
+ | Group
153
+ | Backreference
154
+ | Repetition
155
+ | Assertion;
156
+
157
+ export interface AstRegExp extends Base<'RegExp'> {
158
+ body: Expression | null;
159
+ flags: string;
160
+ }
161
+ }
162
+
163
+ declare module 'regexp-tree' {
164
+ import type { AstNode, AstRegExp } from 'regexp-tree/ast';
165
+
166
+ export type { AstNode, AstRegExp };
167
+
168
+ export interface ParserOptions {
169
+ captureLocations?: boolean;
170
+ allowGroupNameDuplicates?: boolean;
171
+ }
172
+
173
+ export function parse(pattern: string, options?: ParserOptions): AstRegExp;
174
+ export function traverse(ast: AstNode, handlers: Record<string, (path: any) => void>): void;
175
+ }
@@ -0,0 +1,34 @@
1
+ /**
2
+ * RegexEditor 组件
3
+ *
4
+ * @description
5
+ * CodeMirror 6 包装器组件,集成正则表达式验证和错误标注功能。
6
+ * 提供实时语法验证、错误高亮、复杂度分析等功能。
7
+ *
8
+ * @module RegexEditor/core/RegexEditor
9
+ *
10
+ * @example
11
+ * ```tsx
12
+ * <RegexEditor
13
+ * value={pattern}
14
+ * onChange={setPattern}
15
+ * placeholder="请输入正则表达式"
16
+ * showComplexity={true}
17
+ * onValidate={(result) => {
18
+ * if (!result.valid) {
19
+ * console.error('验证失败:', result.errors);
20
+ * }
21
+ * }}
22
+ * />
23
+ * ```
24
+ */
25
+ import React from 'react';
26
+ import type { RegexEditorProps } from './types';
27
+ import './RegexEditor.less';
28
+ /**
29
+ * RegexEditor 组件
30
+ *
31
+ * @param props - 组件属性
32
+ * @returns React 组件
33
+ */
34
+ export declare const RegexEditor: React.FC<RegexEditorProps>;
@@ -0,0 +1,214 @@
1
+ /**
2
+ * RegexEditor 组件
3
+ *
4
+ * @description
5
+ * CodeMirror 6 包装器组件,集成正则表达式验证和错误标注功能。
6
+ * 提供实时语法验证、错误高亮、复杂度分析等功能。
7
+ *
8
+ * @module RegexEditor/core/RegexEditor
9
+ *
10
+ * @example
11
+ * ```tsx
12
+ * <RegexEditor
13
+ * value={pattern}
14
+ * onChange={setPattern}
15
+ * placeholder="请输入正则表达式"
16
+ * showComplexity={true}
17
+ * onValidate={(result) => {
18
+ * if (!result.valid) {
19
+ * console.error('验证失败:', result.errors);
20
+ * }
21
+ * }}
22
+ * />
23
+ * ```
24
+ */
25
+
26
+ import React, { useMemo, useEffect, useRef } from 'react';
27
+ import CodeMirror from '@uiw/react-codemirror';
28
+ import { javascript } from '@codemirror/lang-javascript';
29
+ import { EditorView } from '@codemirror/view';
30
+ import { useRegexValidation } from "../hooks/useRegexValidation";
31
+ import { createErrorMarkers, updateErrorMarkers } from "./extensions/errorMarker";
32
+ import { RegexRailroadDiagram } from "../visualizer/RegexRailroadDiagram";
33
+ import "./RegexEditor.less";
34
+
35
+ /**
36
+ * RegexEditor 组件
37
+ *
38
+ * @param props - 组件属性
39
+ * @returns React 组件
40
+ */
41
+ export var RegexEditor = function RegexEditor(_ref) {
42
+ var _ref$value = _ref.value,
43
+ value = _ref$value === void 0 ? '' : _ref$value,
44
+ onChange = _ref.onChange,
45
+ _ref$placeholder = _ref.placeholder,
46
+ placeholder = _ref$placeholder === void 0 ? '请输入正则表达式' : _ref$placeholder,
47
+ _ref$readOnly = _ref.readOnly,
48
+ readOnly = _ref$readOnly === void 0 ? false : _ref$readOnly,
49
+ _ref$disabled = _ref.disabled,
50
+ disabled = _ref$disabled === void 0 ? false : _ref$disabled,
51
+ _ref$showComplexity = _ref.showComplexity,
52
+ showComplexity = _ref$showComplexity === void 0 ? false : _ref$showComplexity,
53
+ _ref$showRailroadDiag = _ref.showRailroadDiagram,
54
+ showRailroadDiagram = _ref$showRailroadDiag === void 0 ? false : _ref$showRailroadDiag,
55
+ onValidate = _ref.onValidate,
56
+ _ref$height = _ref.height,
57
+ height = _ref$height === void 0 ? '120px' : _ref$height;
58
+ // 编辑器引用
59
+ var editorRef = useRef(null);
60
+
61
+ // 验证 Hook
62
+ var _useRegexValidation = useRegexValidation(value),
63
+ validationResult = _useRegexValidation.validationResult,
64
+ complexity = _useRegexValidation.complexity,
65
+ isValidating = _useRegexValidation.isValidating;
66
+
67
+ // 通知验证结果
68
+ useEffect(function () {
69
+ if (validationResult && onValidate) {
70
+ onValidate(validationResult);
71
+ }
72
+ }, [validationResult, onValidate]);
73
+
74
+ // 更新错误标注
75
+ useEffect(function () {
76
+ var _editorRef$current;
77
+ if ((_editorRef$current = editorRef.current) !== null && _editorRef$current !== void 0 && _editorRef$current.view && validationResult) {
78
+ var errors = validationResult.errors || [];
79
+ updateErrorMarkers(editorRef.current.view, errors);
80
+ }
81
+ }, [validationResult]);
82
+
83
+ // 构建扩展
84
+ var extensions = useMemo(function () {
85
+ var exts = [
86
+ // JavaScript 语法高亮(支持正则表达式)
87
+ javascript(),
88
+ // 自动换行
89
+ EditorView.lineWrapping,
90
+ // 错误标注
91
+ createErrorMarkers([]),
92
+ // 自定义主题
93
+ EditorView.theme({
94
+ '&': {
95
+ fontSize: '14px',
96
+ border: '1px solid #d9d9d9',
97
+ borderRadius: '2px',
98
+ backgroundColor: '#fff'
99
+ },
100
+ '&.cm-focused': {
101
+ outline: 'none',
102
+ borderColor: '#40a9ff',
103
+ boxShadow: '0 0 0 2px rgba(24, 144, 255, 0.2)'
104
+ },
105
+ '.cm-content': {
106
+ padding: '8px 0',
107
+ fontFamily: '"Monaco", "Menlo", "Ubuntu Mono", "Consolas", monospace',
108
+ caretColor: '#000'
109
+ },
110
+ '.cm-line': {
111
+ padding: '0 12px'
112
+ },
113
+ '.cm-scroller': {
114
+ overflow: 'auto',
115
+ maxHeight: '400px'
116
+ },
117
+ '&.cm-editor.cm-focused': {
118
+ outline: 'none'
119
+ },
120
+ // 占位符样式
121
+ '.cm-placeholder': {
122
+ color: '#bfbfbf',
123
+ fontStyle: 'italic'
124
+ }
125
+ })];
126
+
127
+ // 只读模式
128
+ if (readOnly || disabled) {
129
+ exts.push(EditorView.editable.of(false));
130
+ }
131
+ return exts;
132
+ }, [readOnly, disabled]);
133
+
134
+ // 处理值变化
135
+ var handleChange = function handleChange(newValue) {
136
+ if (onChange && !readOnly && !disabled) {
137
+ onChange(newValue);
138
+ }
139
+ };
140
+ return /*#__PURE__*/React.createElement("div", {
141
+ className: "regex-editor"
142
+ }, /*#__PURE__*/React.createElement(CodeMirror, {
143
+ ref: editorRef,
144
+ value: value,
145
+ height: height,
146
+ placeholder: placeholder,
147
+ editable: !readOnly && !disabled,
148
+ extensions: extensions,
149
+ onChange: handleChange,
150
+ basicSetup: {
151
+ lineNumbers: false,
152
+ foldGutter: false,
153
+ highlightActiveLine: false,
154
+ highlightActiveLineGutter: false,
155
+ syntaxHighlighting: true,
156
+ bracketMatching: true,
157
+ autocompletion: false,
158
+ closeBrackets: true,
159
+ highlightSelectionMatches: true
160
+ },
161
+ className: readOnly || disabled ? 'cm-readonly' : ''
162
+ }), showComplexity && complexity && /*#__PURE__*/React.createElement("div", {
163
+ className: "regex-complexity"
164
+ }, /*#__PURE__*/React.createElement("div", {
165
+ className: "complexity-item"
166
+ }, /*#__PURE__*/React.createElement("span", {
167
+ className: "label"
168
+ }, "\u6027\u80FD\u8BC4\u5206:"), /*#__PURE__*/React.createElement("span", {
169
+ className: "score score-".concat(getScoreLevel(complexity.performanceScore))
170
+ }, complexity.performanceScore)), /*#__PURE__*/React.createElement("div", {
171
+ className: "complexity-item"
172
+ }, /*#__PURE__*/React.createElement("span", {
173
+ className: "label"
174
+ }, "\u56DE\u6EAF\u98CE\u9669:"), /*#__PURE__*/React.createElement("span", {
175
+ className: "risk risk-".concat(complexity.backtrackingRisk)
176
+ }, getRiskLabel(complexity.backtrackingRisk))), complexity.suggestions.length > 0 && /*#__PURE__*/React.createElement("div", {
177
+ className: "complexity-suggestions"
178
+ }, /*#__PURE__*/React.createElement("div", {
179
+ className: "suggestions-title"
180
+ }, "\u4F18\u5316\u5EFA\u8BAE:"), /*#__PURE__*/React.createElement("ul", null, complexity.suggestions.map(function (suggestion, index) {
181
+ return /*#__PURE__*/React.createElement("li", {
182
+ key: index
183
+ }, suggestion);
184
+ })))), showRailroadDiagram && /*#__PURE__*/React.createElement("div", {
185
+ style: {
186
+ marginTop: '16px'
187
+ }
188
+ }, /*#__PURE__*/React.createElement(RegexRailroadDiagram, {
189
+ pattern: value,
190
+ showTitle: true,
191
+ size: "default"
192
+ })));
193
+ };
194
+
195
+ /**
196
+ * 获取评分等级
197
+ */
198
+ var getScoreLevel = function getScoreLevel(score) {
199
+ if (score >= 80) return 'high';
200
+ if (score >= 60) return 'medium';
201
+ return 'low';
202
+ };
203
+
204
+ /**
205
+ * 获取风险标签
206
+ */
207
+ var getRiskLabel = function getRiskLabel(risk) {
208
+ var labels = {
209
+ low: '低',
210
+ medium: '中',
211
+ high: '高'
212
+ };
213
+ return labels[risk];
214
+ };
@@ -0,0 +1,119 @@
1
+ /**
2
+ * RegexEditor 组件样式
3
+ */
4
+
5
+ .regex-editor {
6
+ display: flex;
7
+ flex-direction: column;
8
+ gap: 12px;
9
+
10
+ // 复杂度信息区域
11
+ .regex-complexity {
12
+ padding: 12px;
13
+ background-color: #fafafa;
14
+ border: 1px solid #d9d9d9;
15
+ border-radius: 2px;
16
+ font-size: 13px;
17
+
18
+ .complexity-item {
19
+ display: flex;
20
+ align-items: center;
21
+ margin-bottom: 8px;
22
+
23
+ &:last-child {
24
+ margin-bottom: 0;
25
+ }
26
+
27
+ .label {
28
+ font-weight: 500;
29
+ color: #595959;
30
+ margin-right: 8px;
31
+ }
32
+
33
+ .score {
34
+ padding: 2px 8px;
35
+ border-radius: 2px;
36
+ font-weight: 600;
37
+
38
+ &.score-high {
39
+ background-color: #f6ffed;
40
+ color: #52c41a;
41
+ }
42
+
43
+ &.score-medium {
44
+ background-color: #fffbe6;
45
+ color: #faad14;
46
+ }
47
+
48
+ &.score-low {
49
+ background-color: #fff2f0;
50
+ color: #ff4d4f;
51
+ }
52
+ }
53
+
54
+ .risk {
55
+ padding: 2px 8px;
56
+ border-radius: 2px;
57
+ font-weight: 600;
58
+
59
+ &.risk-low {
60
+ background-color: #f6ffed;
61
+ color: #52c41a;
62
+ }
63
+
64
+ &.risk-medium {
65
+ background-color: #fffbe6;
66
+ color: #faad14;
67
+ }
68
+
69
+ &.risk-high {
70
+ background-color: #fff2f0;
71
+ color: #ff4d4f;
72
+ }
73
+ }
74
+ }
75
+
76
+ .complexity-suggestions {
77
+ margin-top: 12px;
78
+ padding-top: 12px;
79
+ border-top: 1px solid #e8e8e8;
80
+
81
+ .suggestions-title {
82
+ font-weight: 500;
83
+ color: #595959;
84
+ margin-bottom: 8px;
85
+ }
86
+
87
+ ul {
88
+ margin: 0;
89
+ padding-left: 20px;
90
+
91
+ li {
92
+ color: #8c8c8c;
93
+ line-height: 1.6;
94
+ margin-bottom: 4px;
95
+
96
+ &:last-child {
97
+ margin-bottom: 0;
98
+ }
99
+ }
100
+ }
101
+ }
102
+ }
103
+
104
+ // 错误标注样式
105
+ .cm-regex-error {
106
+ text-decoration: wavy underline red;
107
+ text-decoration-skip-ink: none;
108
+ }
109
+
110
+ .cm-regex-warning {
111
+ text-decoration: wavy underline orange;
112
+ text-decoration-skip-ink: none;
113
+ }
114
+
115
+ .cm-regex-info {
116
+ text-decoration: wavy underline blue;
117
+ text-decoration-skip-ink: none;
118
+ }
119
+ }
@@ -0,0 +1,49 @@
1
+ /**
2
+ * CodeMirror 错误标注扩展
3
+ *
4
+ * @description
5
+ * 为 CodeMirror 编辑器添加错误标注功能,支持波浪下划线高亮显示错误位置。
6
+ *
7
+ * @module RegexEditor/core/extensions/errorMarker
8
+ */
9
+ import { DecorationSet, EditorView } from '@codemirror/view';
10
+ import { StateField } from '@codemirror/state';
11
+ import type { RegexError } from '../../validation/types';
12
+ /**
13
+ * 设置错误的 StateEffect
14
+ */
15
+ export declare const setErrorsEffect: import("@codemirror/state").StateEffectType<RegexError[]>;
16
+ /**
17
+ * 错误装饰状态字段
18
+ *
19
+ * @description
20
+ * 管理错误标注的 DecorationSet
21
+ */
22
+ export declare const errorDecorationsField: StateField<DecorationSet>;
23
+ /**
24
+ * 创建错误标注扩展
25
+ *
26
+ * @param errors - 错误列表
27
+ * @returns CodeMirror 扩展数组
28
+ *
29
+ * @example
30
+ * ```typescript
31
+ * const extensions = [
32
+ * javascript(),
33
+ * createErrorMarkers(errors)
34
+ * ];
35
+ * ```
36
+ */
37
+ export declare const createErrorMarkers: (errors: RegexError[]) => StateField<DecorationSet>[];
38
+ /**
39
+ * 更新错误标注的辅助函数
40
+ *
41
+ * @param view - EditorView 实例
42
+ * @param errors - 新的错误列表
43
+ *
44
+ * @example
45
+ * ```typescript
46
+ * updateErrorMarkers(editorView, validationErrors);
47
+ * ```
48
+ */
49
+ export declare const updateErrorMarkers: (view: EditorView, errors: RegexError[]) => void;