@nokecy/qc-ui 1.0.66 → 1.0.68

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 (143) hide show
  1. package/dist/cjs/ag-grid-plus/hooks/useGridPlusColumnState.d.ts +12 -0
  2. package/dist/cjs/ag-grid-plus/hooks/useGridPlusColumnState.js +15 -0
  3. package/dist/cjs/ag-grid-plus/index.d.ts +2 -9
  4. package/dist/cjs/ag-grid-plus/index.js +8 -6
  5. package/dist/cjs/ag-grid-plus/setting/index.js +2 -2
  6. package/dist/cjs/array-table/columnHelper.d.ts +126 -0
  7. package/dist/cjs/array-table/columnHelper.js +241 -0
  8. package/dist/cjs/array-table/hooks.d.ts +23 -0
  9. package/dist/cjs/array-table/hooks.js +230 -0
  10. package/dist/cjs/array-table/index.js +141 -208
  11. package/dist/cjs/components/RegexEditor/core/RegexEditor.d.ts +34 -0
  12. package/dist/cjs/components/RegexEditor/core/RegexEditor.js +223 -0
  13. package/dist/cjs/components/RegexEditor/core/RegexEditor.less +119 -0
  14. package/dist/cjs/components/RegexEditor/core/extensions/errorMarker.d.ts +49 -0
  15. package/dist/cjs/components/RegexEditor/core/extensions/errorMarker.js +158 -0
  16. package/dist/cjs/components/RegexEditor/core/types.d.ts +79 -0
  17. package/dist/cjs/components/RegexEditor/core/types.js +5 -0
  18. package/dist/cjs/components/RegexEditor/hooks/index.d.ts +9 -0
  19. package/dist/cjs/components/RegexEditor/hooks/index.js +19 -0
  20. package/dist/cjs/components/RegexEditor/hooks/useRegexTester.d.ts +95 -0
  21. package/dist/cjs/components/RegexEditor/hooks/useRegexTester.js +234 -0
  22. package/dist/cjs/components/RegexEditor/hooks/useRegexValidation.d.ts +71 -0
  23. package/dist/cjs/components/RegexEditor/hooks/useRegexValidation.js +215 -0
  24. package/dist/cjs/components/RegexEditor/hooks/useTemplateManager.d.ts +64 -0
  25. package/dist/cjs/components/RegexEditor/hooks/useTemplateManager.js +438 -0
  26. package/dist/cjs/components/RegexEditor/index.d.ts +16 -0
  27. package/dist/cjs/components/RegexEditor/index.js +232 -0
  28. package/dist/cjs/components/RegexEditor/templates/TemplateSelector.d.ts +36 -0
  29. package/dist/cjs/components/RegexEditor/templates/TemplateSelector.js +322 -0
  30. package/dist/cjs/components/RegexEditor/templates/builtinTemplates.d.ts +36 -0
  31. package/dist/cjs/components/RegexEditor/templates/builtinTemplates.js +340 -0
  32. package/dist/cjs/components/RegexEditor/templates/index.d.ts +10 -0
  33. package/dist/cjs/components/RegexEditor/templates/index.js +184 -0
  34. package/dist/cjs/components/RegexEditor/templates/storage.d.ts +74 -0
  35. package/dist/cjs/components/RegexEditor/templates/storage.js +337 -0
  36. package/dist/cjs/components/RegexEditor/templates/templateManager.d.ts +67 -0
  37. package/dist/cjs/components/RegexEditor/templates/templateManager.js +277 -0
  38. package/dist/cjs/components/RegexEditor/templates/types.d.ts +111 -0
  39. package/dist/cjs/components/RegexEditor/templates/types.js +94 -0
  40. package/dist/cjs/components/RegexEditor/testing/types.d.ts +55 -0
  41. package/dist/cjs/components/RegexEditor/testing/types.js +5 -0
  42. package/dist/cjs/components/RegexEditor/validation/complexity.d.ts +22 -0
  43. package/dist/cjs/components/RegexEditor/validation/complexity.js +196 -0
  44. package/dist/cjs/components/RegexEditor/validation/parser.d.ts +53 -0
  45. package/dist/cjs/components/RegexEditor/validation/parser.js +129 -0
  46. package/dist/cjs/components/RegexEditor/validation/types.d.ts +146 -0
  47. package/dist/cjs/components/RegexEditor/validation/types.js +5 -0
  48. package/dist/cjs/components/RegexEditor/validation/validator.d.ts +60 -0
  49. package/dist/cjs/components/RegexEditor/validation/validator.js +218 -0
  50. package/dist/cjs/components/RegexEditor/visualizer/FlagsSelector.d.ts +20 -0
  51. package/dist/cjs/components/RegexEditor/visualizer/FlagsSelector.js +98 -0
  52. package/dist/cjs/components/RegexEditor/visualizer/MatchItem.d.ts +25 -0
  53. package/dist/cjs/components/RegexEditor/visualizer/MatchItem.js +201 -0
  54. package/dist/cjs/components/RegexEditor/visualizer/RegexRailroadDiagram.d.ts +32 -0
  55. package/dist/cjs/components/RegexEditor/visualizer/RegexRailroadDiagram.js +192 -0
  56. package/dist/cjs/components/RegexEditor/visualizer/RegexTester.d.ts +22 -0
  57. package/dist/cjs/components/RegexEditor/visualizer/RegexTester.js +255 -0
  58. package/dist/cjs/components/RegexEditor/visualizer/astToRailroad.d.ts +19 -0
  59. package/dist/cjs/components/RegexEditor/visualizer/astToRailroad.js +155 -0
  60. package/dist/cjs/components/RegexEditor/visualizer/index.d.ts +12 -0
  61. package/dist/cjs/components/RegexEditor/visualizer/index.js +76 -0
  62. package/dist/cjs/components/RegexEditor/visualizer/types.d.ts +131 -0
  63. package/dist/cjs/components/RegexEditor/visualizer/types.js +5 -0
  64. package/dist/cjs/components/RegexEditor/visualizer/utils.d.ts +106 -0
  65. package/dist/cjs/components/RegexEditor/visualizer/utils.js +268 -0
  66. package/dist/cjs/index.d.ts +6 -2
  67. package/dist/cjs/index.js +68 -0
  68. package/dist/cjs/standardFormDialog/useStandardFormSchema.d.ts +1 -1
  69. package/dist/cjs/standardFormDialog/withStandardForm.d.ts +2 -2
  70. package/dist/cjs/types/railroad-diagrams.d.ts +59 -0
  71. package/dist/cjs/types/regexp-tree.d.ts +175 -0
  72. package/dist/esm/ag-grid-plus/hooks/useGridPlusColumnState.d.ts +12 -0
  73. package/dist/esm/ag-grid-plus/hooks/useGridPlusColumnState.js +10 -0
  74. package/dist/esm/ag-grid-plus/index.d.ts +2 -9
  75. package/dist/esm/ag-grid-plus/index.js +2 -5
  76. package/dist/esm/ag-grid-plus/setting/index.js +1 -1
  77. package/dist/esm/array-table/columnHelper.d.ts +126 -0
  78. package/dist/esm/array-table/columnHelper.js +235 -0
  79. package/dist/esm/array-table/hooks.d.ts +23 -0
  80. package/dist/esm/array-table/hooks.js +224 -0
  81. package/dist/esm/array-table/index.js +142 -209
  82. package/dist/esm/components/RegexEditor/core/RegexEditor.d.ts +34 -0
  83. package/dist/esm/components/RegexEditor/core/RegexEditor.js +214 -0
  84. package/dist/esm/components/RegexEditor/core/RegexEditor.less +119 -0
  85. package/dist/esm/components/RegexEditor/core/extensions/errorMarker.d.ts +49 -0
  86. package/dist/esm/components/RegexEditor/core/extensions/errorMarker.js +154 -0
  87. package/dist/esm/components/RegexEditor/core/types.d.ts +79 -0
  88. package/dist/esm/components/RegexEditor/core/types.js +1 -0
  89. package/dist/esm/components/RegexEditor/hooks/index.d.ts +9 -0
  90. package/dist/esm/components/RegexEditor/hooks/index.js +8 -0
  91. package/dist/esm/components/RegexEditor/hooks/useRegexTester.d.ts +95 -0
  92. package/dist/esm/components/RegexEditor/hooks/useRegexTester.js +230 -0
  93. package/dist/esm/components/RegexEditor/hooks/useRegexValidation.d.ts +71 -0
  94. package/dist/esm/components/RegexEditor/hooks/useRegexValidation.js +211 -0
  95. package/dist/esm/components/RegexEditor/hooks/useTemplateManager.d.ts +64 -0
  96. package/dist/esm/components/RegexEditor/hooks/useTemplateManager.js +430 -0
  97. package/dist/esm/components/RegexEditor/index.d.ts +16 -0
  98. package/dist/esm/components/RegexEditor/index.js +27 -0
  99. package/dist/esm/components/RegexEditor/templates/TemplateSelector.d.ts +36 -0
  100. package/dist/esm/components/RegexEditor/templates/TemplateSelector.js +316 -0
  101. package/dist/esm/components/RegexEditor/templates/builtinTemplates.d.ts +36 -0
  102. package/dist/esm/components/RegexEditor/templates/builtinTemplates.js +335 -0
  103. package/dist/esm/components/RegexEditor/templates/index.d.ts +10 -0
  104. package/dist/esm/components/RegexEditor/templates/index.js +19 -0
  105. package/dist/esm/components/RegexEditor/templates/storage.d.ts +74 -0
  106. package/dist/esm/components/RegexEditor/templates/storage.js +335 -0
  107. package/dist/esm/components/RegexEditor/templates/templateManager.d.ts +67 -0
  108. package/dist/esm/components/RegexEditor/templates/templateManager.js +274 -0
  109. package/dist/esm/components/RegexEditor/templates/types.d.ts +111 -0
  110. package/dist/esm/components/RegexEditor/templates/types.js +90 -0
  111. package/dist/esm/components/RegexEditor/testing/types.d.ts +55 -0
  112. package/dist/esm/components/RegexEditor/testing/types.js +1 -0
  113. package/dist/esm/components/RegexEditor/validation/complexity.d.ts +22 -0
  114. package/dist/esm/components/RegexEditor/validation/complexity.js +190 -0
  115. package/dist/esm/components/RegexEditor/validation/parser.d.ts +53 -0
  116. package/dist/esm/components/RegexEditor/validation/parser.js +123 -0
  117. package/dist/esm/components/RegexEditor/validation/types.d.ts +145 -0
  118. package/dist/esm/components/RegexEditor/validation/types.js +1 -0
  119. package/dist/esm/components/RegexEditor/validation/validator.d.ts +60 -0
  120. package/dist/esm/components/RegexEditor/validation/validator.js +213 -0
  121. package/dist/esm/components/RegexEditor/visualizer/FlagsSelector.d.ts +20 -0
  122. package/dist/esm/components/RegexEditor/visualizer/FlagsSelector.js +93 -0
  123. package/dist/esm/components/RegexEditor/visualizer/MatchItem.d.ts +25 -0
  124. package/dist/esm/components/RegexEditor/visualizer/MatchItem.js +194 -0
  125. package/dist/esm/components/RegexEditor/visualizer/RegexRailroadDiagram.d.ts +32 -0
  126. package/dist/esm/components/RegexEditor/visualizer/RegexRailroadDiagram.js +186 -0
  127. package/dist/esm/components/RegexEditor/visualizer/RegexTester.d.ts +22 -0
  128. package/dist/esm/components/RegexEditor/visualizer/RegexTester.js +248 -0
  129. package/dist/esm/components/RegexEditor/visualizer/astToRailroad.d.ts +18 -0
  130. package/dist/esm/components/RegexEditor/visualizer/astToRailroad.js +150 -0
  131. package/dist/esm/components/RegexEditor/visualizer/index.d.ts +12 -0
  132. package/dist/esm/components/RegexEditor/visualizer/index.js +17 -0
  133. package/dist/esm/components/RegexEditor/visualizer/types.d.ts +131 -0
  134. package/dist/esm/components/RegexEditor/visualizer/types.js +1 -0
  135. package/dist/esm/components/RegexEditor/visualizer/utils.d.ts +106 -0
  136. package/dist/esm/components/RegexEditor/visualizer/utils.js +256 -0
  137. package/dist/esm/index.d.ts +6 -2
  138. package/dist/esm/index.js +7 -3
  139. package/dist/esm/types/railroad-diagrams.d.ts +59 -0
  140. package/dist/esm/types/regexp-tree.d.ts +175 -0
  141. package/dist/umd/qc-ui.min.css +1 -1
  142. package/dist/umd/qc-ui.min.js +1 -1
  143. package/package.json +23 -7
@@ -0,0 +1,106 @@
1
+ /**
2
+ * 正则表达式可视化 - 工具函数
3
+ *
4
+ * @module RegexEditor/visualizer/utils
5
+ * @description 提供匹配、标志转换等工具函数
6
+ */
7
+ import type { RegexFlags, MatchResult } from './types';
8
+ /**
9
+ * 将标志对象转换为标志字符串
10
+ *
11
+ * @param flags - 标志对象
12
+ * @returns 标志字符串 (如 "gim")
13
+ *
14
+ * @example
15
+ * ```ts
16
+ * flagsToString({ global: true, ignoreCase: true })
17
+ * // => "gi"
18
+ * ```
19
+ */
20
+ export declare function flagsToString(flags?: RegexFlags): string;
21
+ /**
22
+ * 将标志字符串转换为标志对象
23
+ *
24
+ * @param flagsStr - 标志字符串 (如 "gim")
25
+ * @returns 标志对象
26
+ *
27
+ * @example
28
+ * ```ts
29
+ * stringToFlags("gi")
30
+ * // => { global: true, ignoreCase: true }
31
+ * ```
32
+ */
33
+ export declare function stringToFlags(flagsStr: string): RegexFlags;
34
+ /**
35
+ * 执行正则匹配并返回所有匹配结果
36
+ *
37
+ * @param pattern - 正则表达式模式
38
+ * @param text - 测试文本
39
+ * @param flags - 标志
40
+ * @param maxMatches - 最大匹配数量限制
41
+ * @param timeout - 超时时间 (毫秒)
42
+ * @returns 匹配结果数组,如果出错返回 null
43
+ *
44
+ * @example
45
+ * ```ts
46
+ * const results = performMatch('\\d+', 'abc 123 def 456', { global: true });
47
+ * // => [
48
+ * // { index: 4, lastIndex: 7, fullMatch: '123', groups: ['123'] },
49
+ * // { index: 12, lastIndex: 15, fullMatch: '456', groups: ['456'] }
50
+ * // ]
51
+ * ```
52
+ */
53
+ export declare function performMatch(pattern: string, text: string, flags?: RegexFlags, maxMatches?: number, timeout?: number): MatchResult[] | null;
54
+ /**
55
+ * 执行正则替换并返回结果
56
+ *
57
+ * @param pattern - 正则表达式模式
58
+ * @param text - 原始文本
59
+ * @param replaceText - 替换文本 (支持 $1, $2 等)
60
+ * @param flags - 标志
61
+ * @returns 替换后的文本,如果出错返回 null
62
+ *
63
+ * @example
64
+ * ```ts
65
+ * performReplace('(\\d+)', 'abc 123 def', 'NUM:$1', { global: true })
66
+ * // => "abc NUM:123 def"
67
+ * ```
68
+ */
69
+ export declare function performReplace(pattern: string, text: string, replaceText: string, flags?: RegexFlags): string | null;
70
+ /**
71
+ * 高亮文本中的匹配部分
72
+ *
73
+ * @param text - 原始文本
74
+ * @param matches - 匹配结果数组
75
+ * @returns 带高亮标记的 HTML 字符串
76
+ *
77
+ * @example
78
+ * ```ts
79
+ * highlightMatches('abc 123 def', [
80
+ * { index: 4, lastIndex: 7, fullMatch: '123', groups: ['123'] }
81
+ * ])
82
+ * // => 'abc <mark class="regex-match">123</mark> def'
83
+ * ```
84
+ */
85
+ export declare function highlightMatches(text: string, matches: MatchResult[]): string;
86
+ /**
87
+ * 格式化匹配位置
88
+ *
89
+ * @param match - 匹配结果
90
+ * @returns 格式化的位置字符串
91
+ *
92
+ * @example
93
+ * ```ts
94
+ * formatPosition({ index: 10, lastIndex: 15, ... })
95
+ * // => "10-15"
96
+ * ```
97
+ */
98
+ export declare function formatPosition(match: MatchResult): string;
99
+ /**
100
+ * 检查正则表达式是否有效
101
+ *
102
+ * @param pattern - 正则表达式模式
103
+ * @param flags - 标志
104
+ * @returns 是否有效
105
+ */
106
+ export declare function isValidRegex(pattern: string, flags?: RegexFlags): boolean;
@@ -0,0 +1,268 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.flagsToString = flagsToString;
7
+ exports.formatPosition = formatPosition;
8
+ exports.highlightMatches = highlightMatches;
9
+ exports.isValidRegex = isValidRegex;
10
+ exports.performMatch = performMatch;
11
+ exports.performReplace = performReplace;
12
+ exports.stringToFlags = stringToFlags;
13
+ function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
14
+ function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
15
+ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
16
+ function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
17
+ function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
18
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
19
+ /**
20
+ * 正则表达式可视化 - 工具函数
21
+ *
22
+ * @module RegexEditor/visualizer/utils
23
+ * @description 提供匹配、标志转换等工具函数
24
+ */
25
+
26
+ /**
27
+ * 将标志对象转换为标志字符串
28
+ *
29
+ * @param flags - 标志对象
30
+ * @returns 标志字符串 (如 "gim")
31
+ *
32
+ * @example
33
+ * ```ts
34
+ * flagsToString({ global: true, ignoreCase: true })
35
+ * // => "gi"
36
+ * ```
37
+ */
38
+ function flagsToString(flags) {
39
+ if (!flags) return '';
40
+ var result = '';
41
+ if (flags.global) result += 'g';
42
+ if (flags.ignoreCase) result += 'i';
43
+ if (flags.multiline) result += 'm';
44
+ if (flags.dotAll) result += 's';
45
+ if (flags.unicode) result += 'u';
46
+ if (flags.sticky) result += 'y';
47
+ return result;
48
+ }
49
+
50
+ /**
51
+ * 将标志字符串转换为标志对象
52
+ *
53
+ * @param flagsStr - 标志字符串 (如 "gim")
54
+ * @returns 标志对象
55
+ *
56
+ * @example
57
+ * ```ts
58
+ * stringToFlags("gi")
59
+ * // => { global: true, ignoreCase: true }
60
+ * ```
61
+ */
62
+ function stringToFlags(flagsStr) {
63
+ return {
64
+ global: flagsStr.includes('g'),
65
+ ignoreCase: flagsStr.includes('i'),
66
+ multiline: flagsStr.includes('m'),
67
+ dotAll: flagsStr.includes('s'),
68
+ unicode: flagsStr.includes('u'),
69
+ sticky: flagsStr.includes('y')
70
+ };
71
+ }
72
+
73
+ /**
74
+ * 执行正则匹配并返回所有匹配结果
75
+ *
76
+ * @param pattern - 正则表达式模式
77
+ * @param text - 测试文本
78
+ * @param flags - 标志
79
+ * @param maxMatches - 最大匹配数量限制
80
+ * @param timeout - 超时时间 (毫秒)
81
+ * @returns 匹配结果数组,如果出错返回 null
82
+ *
83
+ * @example
84
+ * ```ts
85
+ * const results = performMatch('\\d+', 'abc 123 def 456', { global: true });
86
+ * // => [
87
+ * // { index: 4, lastIndex: 7, fullMatch: '123', groups: ['123'] },
88
+ * // { index: 12, lastIndex: 15, fullMatch: '456', groups: ['456'] }
89
+ * // ]
90
+ * ```
91
+ */
92
+ function performMatch(pattern, text, flags) {
93
+ var maxMatches = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 1000;
94
+ var timeout = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : 5000;
95
+ try {
96
+ // 创建正则表达式
97
+ var flagsStr = flagsToString(flags);
98
+ var regex = new RegExp(pattern, flagsStr);
99
+ var results = [];
100
+ var startTime = Date.now();
101
+
102
+ // 如果是全局匹配,使用 exec 循环
103
+ if (flags !== null && flags !== void 0 && flags.global) {
104
+ var match;
105
+ while ((match = regex.exec(text)) !== null) {
106
+ // 检查超时
107
+ if (Date.now() - startTime > timeout) {
108
+ console.warn('正则匹配超时');
109
+ break;
110
+ }
111
+
112
+ // 检查数量限制
113
+ if (results.length >= maxMatches) {
114
+ console.warn("\u5339\u914D\u6570\u91CF\u8D85\u8FC7\u9650\u5236 (".concat(maxMatches, ")"));
115
+ break;
116
+ }
117
+ if (match.index !== undefined) {
118
+ results.push({
119
+ index: match.index,
120
+ lastIndex: match.index + match[0].length,
121
+ fullMatch: match[0],
122
+ groups: Array.from(match),
123
+ namedGroups: match.groups
124
+ });
125
+ }
126
+
127
+ // 防止无限循环(零宽匹配)
128
+ if (match.index === regex.lastIndex) {
129
+ regex.lastIndex++;
130
+ }
131
+ }
132
+ } else {
133
+ // 非全局匹配,只匹配一次
134
+ var _match = regex.exec(text);
135
+ if (_match && _match.index !== undefined) {
136
+ results.push({
137
+ index: _match.index,
138
+ lastIndex: _match.index + _match[0].length,
139
+ fullMatch: _match[0],
140
+ groups: Array.from(_match),
141
+ namedGroups: _match.groups
142
+ });
143
+ }
144
+ }
145
+ return results;
146
+ } catch (error) {
147
+ console.error('正则匹配错误:', error);
148
+ return null;
149
+ }
150
+ }
151
+
152
+ /**
153
+ * 执行正则替换并返回结果
154
+ *
155
+ * @param pattern - 正则表达式模式
156
+ * @param text - 原始文本
157
+ * @param replaceText - 替换文本 (支持 $1, $2 等)
158
+ * @param flags - 标志
159
+ * @returns 替换后的文本,如果出错返回 null
160
+ *
161
+ * @example
162
+ * ```ts
163
+ * performReplace('(\\d+)', 'abc 123 def', 'NUM:$1', { global: true })
164
+ * // => "abc NUM:123 def"
165
+ * ```
166
+ */
167
+ function performReplace(pattern, text, replaceText, flags) {
168
+ try {
169
+ var flagsStr = flagsToString(flags);
170
+ var regex = new RegExp(pattern, flagsStr);
171
+ return text.replace(regex, replaceText);
172
+ } catch (error) {
173
+ console.error('正则替换错误:', error);
174
+ return null;
175
+ }
176
+ }
177
+
178
+ /**
179
+ * 高亮文本中的匹配部分
180
+ *
181
+ * @param text - 原始文本
182
+ * @param matches - 匹配结果数组
183
+ * @returns 带高亮标记的 HTML 字符串
184
+ *
185
+ * @example
186
+ * ```ts
187
+ * highlightMatches('abc 123 def', [
188
+ * { index: 4, lastIndex: 7, fullMatch: '123', groups: ['123'] }
189
+ * ])
190
+ * // => 'abc <mark class="regex-match">123</mark> def'
191
+ * ```
192
+ */
193
+ function highlightMatches(text, matches) {
194
+ if (!matches || matches.length === 0) {
195
+ return escapeHtml(text);
196
+ }
197
+
198
+ // 按索引排序
199
+ var sortedMatches = _toConsumableArray(matches).sort(function (a, b) {
200
+ return a.index - b.index;
201
+ });
202
+ var result = '';
203
+ var lastIndex = 0;
204
+ sortedMatches.forEach(function (match, idx) {
205
+ // 添加未匹配部分
206
+ if (match.index > lastIndex) {
207
+ result += escapeHtml(text.substring(lastIndex, match.index));
208
+ }
209
+
210
+ // 添加匹配部分 (带高亮)
211
+ result += "<mark class=\"regex-match\" data-match-index=\"".concat(idx, "\">").concat(escapeHtml(match.fullMatch), "</mark>");
212
+ lastIndex = match.lastIndex;
213
+ });
214
+
215
+ // 添加剩余部分
216
+ if (lastIndex < text.length) {
217
+ result += escapeHtml(text.substring(lastIndex));
218
+ }
219
+ return result;
220
+ }
221
+
222
+ /**
223
+ * 转义 HTML 特殊字符
224
+ */
225
+ function escapeHtml(text) {
226
+ var map = {
227
+ '&': '&amp;',
228
+ '<': '&lt;',
229
+ '>': '&gt;',
230
+ '"': '&quot;',
231
+ "'": '&#039;'
232
+ };
233
+ return text.replace(/[&<>"']/g, function (char) {
234
+ return map[char];
235
+ });
236
+ }
237
+
238
+ /**
239
+ * 格式化匹配位置
240
+ *
241
+ * @param match - 匹配结果
242
+ * @returns 格式化的位置字符串
243
+ *
244
+ * @example
245
+ * ```ts
246
+ * formatPosition({ index: 10, lastIndex: 15, ... })
247
+ * // => "10-15"
248
+ * ```
249
+ */
250
+ function formatPosition(match) {
251
+ return "".concat(match.index, "-").concat(match.lastIndex);
252
+ }
253
+
254
+ /**
255
+ * 检查正则表达式是否有效
256
+ *
257
+ * @param pattern - 正则表达式模式
258
+ * @param flags - 标志
259
+ * @returns 是否有效
260
+ */
261
+ function isValidRegex(pattern, flags) {
262
+ try {
263
+ new RegExp(pattern, flagsToString(flags));
264
+ return true;
265
+ } catch (_unused) {
266
+ return false;
267
+ }
268
+ }
@@ -1,6 +1,7 @@
1
- import { AgGridColumn, AgGridPlus, flattenTreeDeep, GridPlusContext } from "./ag-grid-plus";
1
+ import { AgGridColumn, AgGridPlus, flattenTreeDeep, GridPlusContext, useGridPlusColumnState } from "./ag-grid-plus";
2
2
  import ArrayTable from "./array-table";
3
3
  import ArrayTableIndex from "./array-table-index";
4
+ import { ColumnPresets } from "./array-table/columnHelper";
4
5
  import Card from "./card";
5
6
  import Dashboard from "./dashboard";
6
7
  import DialogSelect from "./dialogSelect";
@@ -19,10 +20,13 @@ import { GeneratedListPage } from "./generatedListPage";
19
20
  import { StandardFormDialog, withStandardForm, FieldCreators, createSelectField, createCascaderField } from "./standardFormDialog";
20
21
  import DeleteConfirm from "./deleteConfirm";
21
22
  import { RuleBuilder } from "./RuleBuilder";
22
- export { AgGridColumn, AgGridPlus, ArrayTable, ArrayTableIndex, Card, Dashboard, DialogSelect, DraggableModal, Editable, ExtensibleGrid, flattenTreeDeep, FormDesigner, FormProContext, FormProLayout, GridPlusContext, ImportModal, QueryBuilder, ToolBar, FullScreenAlert, ConfirmPro, GeneratedListPage, StandardFormDialog, withStandardForm, FieldCreators, createSelectField, createCascaderField, DeleteConfirm, RuleBuilder };
23
+ import { RegexEditor, useRegexValidation, useTemplateManager, TemplateSelector, TemplateCategory, RegexTester, FlagsSelector, MatchItem, RegexRailroadDiagram } from "./components/RegexEditor";
24
+ export { AgGridColumn, AgGridPlus, ArrayTable, ArrayTableIndex, ColumnPresets, Card, Dashboard, DialogSelect, DraggableModal, Editable, ExtensibleGrid, flattenTreeDeep, FormDesigner, FormProContext, FormProLayout, GridPlusContext, useGridPlusColumnState, ImportModal, QueryBuilder, ToolBar, FullScreenAlert, ConfirmPro, GeneratedListPage, StandardFormDialog, withStandardForm, FieldCreators, createSelectField, createCascaderField, DeleteConfirm, RuleBuilder, RegexEditor, useRegexValidation, useTemplateManager, TemplateSelector, TemplateCategory, RegexTester, FlagsSelector, MatchItem, RegexRailroadDiagram, };
23
25
  export type * from "./generatedListPage";
24
26
  export type * from "./standardFormDialog";
25
27
  export type * from "./deleteConfirm";
26
28
  export type * from "./importModal";
27
29
  export type * from "./fullScreenAlert";
28
30
  export type * from "./RuleBuilder";
31
+ export type { ColumnConfig } from "./array-table/columnHelper";
32
+ export type { ParseResult as RegexParseResult, ValidationResult as RegexValidationResult, RegexError, ComplexityMetrics, ASTNode, AstRegExp, RegexTemplate, TestResult as RegexTestResult, CodeMirrorWrapperProps, RegexEditorProps, RegexFlags, MatchResult, RegexTesterProps, FlagsSelectorProps, MatchItemProps, RegexRailroadDiagramProps, } from "./components/RegexEditor";
package/dist/cjs/index.js CHANGED
@@ -33,6 +33,12 @@ Object.defineProperty(exports, "Card", {
33
33
  return _card.default;
34
34
  }
35
35
  });
36
+ Object.defineProperty(exports, "ColumnPresets", {
37
+ enumerable: true,
38
+ get: function get() {
39
+ return _columnHelper.ColumnPresets;
40
+ }
41
+ });
36
42
  Object.defineProperty(exports, "ConfirmPro", {
37
43
  enumerable: true,
38
44
  get: function get() {
@@ -81,6 +87,12 @@ Object.defineProperty(exports, "FieldCreators", {
81
87
  return _standardFormDialog.FieldCreators;
82
88
  }
83
89
  });
90
+ Object.defineProperty(exports, "FlagsSelector", {
91
+ enumerable: true,
92
+ get: function get() {
93
+ return _RegexEditor.FlagsSelector;
94
+ }
95
+ });
84
96
  Object.defineProperty(exports, "FormDesigner", {
85
97
  enumerable: true,
86
98
  get: function get() {
@@ -123,12 +135,36 @@ Object.defineProperty(exports, "ImportModal", {
123
135
  return _importModal.default;
124
136
  }
125
137
  });
138
+ Object.defineProperty(exports, "MatchItem", {
139
+ enumerable: true,
140
+ get: function get() {
141
+ return _RegexEditor.MatchItem;
142
+ }
143
+ });
126
144
  Object.defineProperty(exports, "QueryBuilder", {
127
145
  enumerable: true,
128
146
  get: function get() {
129
147
  return _queryBuilder.default;
130
148
  }
131
149
  });
150
+ Object.defineProperty(exports, "RegexEditor", {
151
+ enumerable: true,
152
+ get: function get() {
153
+ return _RegexEditor.RegexEditor;
154
+ }
155
+ });
156
+ Object.defineProperty(exports, "RegexRailroadDiagram", {
157
+ enumerable: true,
158
+ get: function get() {
159
+ return _RegexEditor.RegexRailroadDiagram;
160
+ }
161
+ });
162
+ Object.defineProperty(exports, "RegexTester", {
163
+ enumerable: true,
164
+ get: function get() {
165
+ return _RegexEditor.RegexTester;
166
+ }
167
+ });
132
168
  Object.defineProperty(exports, "RuleBuilder", {
133
169
  enumerable: true,
134
170
  get: function get() {
@@ -141,6 +177,18 @@ Object.defineProperty(exports, "StandardFormDialog", {
141
177
  return _standardFormDialog.StandardFormDialog;
142
178
  }
143
179
  });
180
+ Object.defineProperty(exports, "TemplateCategory", {
181
+ enumerable: true,
182
+ get: function get() {
183
+ return _RegexEditor.TemplateCategory;
184
+ }
185
+ });
186
+ Object.defineProperty(exports, "TemplateSelector", {
187
+ enumerable: true,
188
+ get: function get() {
189
+ return _RegexEditor.TemplateSelector;
190
+ }
191
+ });
144
192
  Object.defineProperty(exports, "ToolBar", {
145
193
  enumerable: true,
146
194
  get: function get() {
@@ -165,6 +213,24 @@ Object.defineProperty(exports, "flattenTreeDeep", {
165
213
  return _agGridPlus.flattenTreeDeep;
166
214
  }
167
215
  });
216
+ Object.defineProperty(exports, "useGridPlusColumnState", {
217
+ enumerable: true,
218
+ get: function get() {
219
+ return _agGridPlus.useGridPlusColumnState;
220
+ }
221
+ });
222
+ Object.defineProperty(exports, "useRegexValidation", {
223
+ enumerable: true,
224
+ get: function get() {
225
+ return _RegexEditor.useRegexValidation;
226
+ }
227
+ });
228
+ Object.defineProperty(exports, "useTemplateManager", {
229
+ enumerable: true,
230
+ get: function get() {
231
+ return _RegexEditor.useTemplateManager;
232
+ }
233
+ });
168
234
  Object.defineProperty(exports, "withStandardForm", {
169
235
  enumerable: true,
170
236
  get: function get() {
@@ -174,6 +240,7 @@ Object.defineProperty(exports, "withStandardForm", {
174
240
  var _agGridPlus = require("./ag-grid-plus");
175
241
  var _arrayTable = _interopRequireDefault(require("./array-table"));
176
242
  var _arrayTableIndex = _interopRequireDefault(require("./array-table-index"));
243
+ var _columnHelper = require("./array-table/columnHelper");
177
244
  var _card = _interopRequireDefault(require("./card"));
178
245
  var _dashboard = _interopRequireDefault(require("./dashboard"));
179
246
  var _dialogSelect = _interopRequireDefault(require("./dialogSelect"));
@@ -192,4 +259,5 @@ var _generatedListPage = require("./generatedListPage");
192
259
  var _standardFormDialog = require("./standardFormDialog");
193
260
  var _deleteConfirm = _interopRequireDefault(require("./deleteConfirm"));
194
261
  var _RuleBuilder = require("./RuleBuilder");
262
+ var _RegexEditor = require("./components/RegexEditor");
195
263
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
@@ -32,7 +32,7 @@ export declare const createSelectField: (title: string, options: Array<{
32
32
  required?: boolean | undefined;
33
33
  placeholder?: string | undefined;
34
34
  gridSpan?: number | undefined;
35
- mode?: "multiple" | "tags" | undefined;
35
+ mode?: "tags" | "multiple" | undefined;
36
36
  } | undefined) => any;
37
37
  /**
38
38
  * 快速创建常用字段的工具函数集合
@@ -173,7 +173,7 @@ export declare const createSelectField: (title: string, options: {
173
173
  export declare const createCascaderField: (title: string, options: any[], config?: {
174
174
  required?: boolean | undefined;
175
175
  changeOnSelect?: boolean | undefined;
176
- expandTrigger?: "hover" | "click" | undefined;
176
+ expandTrigger?: "click" | "hover" | undefined;
177
177
  placeholder?: string | undefined;
178
178
  }) => {
179
179
  type: string;
@@ -187,7 +187,7 @@ export declare const createCascaderField: (title: string, options: any[], config
187
187
  };
188
188
  options: any[];
189
189
  changeOnSelect: boolean;
190
- expandTrigger: "hover" | "click";
190
+ expandTrigger: "click" | "hover";
191
191
  };
192
192
  };
193
193
  export default withStandardForm;
@@ -0,0 +1,59 @@
1
+ /**
2
+ * Type definitions for railroad-diagrams
3
+ * Project: https://github.com/tabatkins/railroad-diagrams
4
+ */
5
+
6
+ declare module 'railroad-diagrams' {
7
+ export class Diagram {
8
+ constructor(children: DiagramNode[]);
9
+ toSVG(): SVGElement;
10
+ toString(): string;
11
+ }
12
+
13
+ export class ComplexDiagram extends Diagram {}
14
+
15
+ export class Sequence {
16
+ constructor(children: DiagramNode[]);
17
+ }
18
+
19
+ export class Choice {
20
+ constructor(defaultIndex: number, children: DiagramNode[]);
21
+ }
22
+
23
+ export class Optional {
24
+ constructor(child: DiagramNode, skip?: 'skip');
25
+ }
26
+
27
+ export class OneOrMore {
28
+ constructor(child: DiagramNode, repeat?: DiagramNode);
29
+ }
30
+
31
+ export class ZeroOrMore {
32
+ constructor(child: DiagramNode, repeat?: DiagramNode, skip?: 'skip');
33
+ }
34
+
35
+ export class Terminal {
36
+ constructor(text: string);
37
+ }
38
+
39
+ export class NonTerminal {
40
+ constructor(text: string);
41
+ }
42
+
43
+ export class Comment {
44
+ constructor(text: string);
45
+ }
46
+
47
+ export class Skip {}
48
+
49
+ export type DiagramNode =
50
+ | Sequence
51
+ | Choice
52
+ | Optional
53
+ | OneOrMore
54
+ | ZeroOrMore
55
+ | Terminal
56
+ | NonTerminal
57
+ | Comment
58
+ | Skip;
59
+ }