@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.
- package/dist/cjs/components/RegexEditor/core/RegexEditor.d.ts +34 -0
- package/dist/cjs/components/RegexEditor/core/RegexEditor.js +223 -0
- package/dist/cjs/components/RegexEditor/core/RegexEditor.less +119 -0
- package/dist/cjs/components/RegexEditor/core/extensions/errorMarker.d.ts +49 -0
- package/dist/cjs/components/RegexEditor/core/extensions/errorMarker.js +158 -0
- package/dist/cjs/components/RegexEditor/core/types.d.ts +79 -0
- package/dist/cjs/components/RegexEditor/core/types.js +5 -0
- package/dist/cjs/components/RegexEditor/hooks/index.d.ts +9 -0
- package/dist/cjs/components/RegexEditor/hooks/index.js +19 -0
- package/dist/cjs/components/RegexEditor/hooks/useRegexTester.d.ts +95 -0
- package/dist/cjs/components/RegexEditor/hooks/useRegexTester.js +234 -0
- package/dist/cjs/components/RegexEditor/hooks/useRegexValidation.d.ts +71 -0
- package/dist/cjs/components/RegexEditor/hooks/useRegexValidation.js +215 -0
- package/dist/cjs/components/RegexEditor/hooks/useTemplateManager.d.ts +64 -0
- package/dist/cjs/components/RegexEditor/hooks/useTemplateManager.js +438 -0
- package/dist/cjs/components/RegexEditor/index.d.ts +16 -0
- package/dist/cjs/components/RegexEditor/index.js +232 -0
- package/dist/cjs/components/RegexEditor/templates/TemplateSelector.d.ts +36 -0
- package/dist/cjs/components/RegexEditor/templates/TemplateSelector.js +322 -0
- package/dist/cjs/components/RegexEditor/templates/builtinTemplates.d.ts +36 -0
- package/dist/cjs/components/RegexEditor/templates/builtinTemplates.js +340 -0
- package/dist/cjs/components/RegexEditor/templates/index.d.ts +10 -0
- package/dist/cjs/components/RegexEditor/templates/index.js +184 -0
- package/dist/cjs/components/RegexEditor/templates/storage.d.ts +74 -0
- package/dist/cjs/components/RegexEditor/templates/storage.js +337 -0
- package/dist/cjs/components/RegexEditor/templates/templateManager.d.ts +67 -0
- package/dist/cjs/components/RegexEditor/templates/templateManager.js +277 -0
- package/dist/cjs/components/RegexEditor/templates/types.d.ts +111 -0
- package/dist/cjs/components/RegexEditor/templates/types.js +94 -0
- package/dist/cjs/components/RegexEditor/testing/types.d.ts +55 -0
- package/dist/cjs/components/RegexEditor/testing/types.js +5 -0
- package/dist/cjs/components/RegexEditor/validation/complexity.d.ts +22 -0
- package/dist/cjs/components/RegexEditor/validation/complexity.js +196 -0
- package/dist/cjs/components/RegexEditor/validation/parser.d.ts +53 -0
- package/dist/cjs/components/RegexEditor/validation/parser.js +129 -0
- package/dist/cjs/components/RegexEditor/validation/types.d.ts +146 -0
- package/dist/cjs/components/RegexEditor/validation/types.js +5 -0
- package/dist/cjs/components/RegexEditor/validation/validator.d.ts +60 -0
- package/dist/cjs/components/RegexEditor/validation/validator.js +218 -0
- package/dist/cjs/components/RegexEditor/visualizer/FlagsSelector.d.ts +20 -0
- package/dist/cjs/components/RegexEditor/visualizer/FlagsSelector.js +98 -0
- package/dist/cjs/components/RegexEditor/visualizer/MatchItem.d.ts +25 -0
- package/dist/cjs/components/RegexEditor/visualizer/MatchItem.js +201 -0
- package/dist/cjs/components/RegexEditor/visualizer/RegexRailroadDiagram.d.ts +32 -0
- package/dist/cjs/components/RegexEditor/visualizer/RegexRailroadDiagram.js +192 -0
- package/dist/cjs/components/RegexEditor/visualizer/RegexTester.d.ts +22 -0
- package/dist/cjs/components/RegexEditor/visualizer/RegexTester.js +255 -0
- package/dist/cjs/components/RegexEditor/visualizer/astToRailroad.d.ts +19 -0
- package/dist/cjs/components/RegexEditor/visualizer/astToRailroad.js +155 -0
- package/dist/cjs/components/RegexEditor/visualizer/index.d.ts +12 -0
- package/dist/cjs/components/RegexEditor/visualizer/index.js +76 -0
- package/dist/cjs/components/RegexEditor/visualizer/types.d.ts +131 -0
- package/dist/cjs/components/RegexEditor/visualizer/types.js +5 -0
- package/dist/cjs/components/RegexEditor/visualizer/utils.d.ts +106 -0
- package/dist/cjs/components/RegexEditor/visualizer/utils.js +268 -0
- package/dist/cjs/index.d.ts +3 -1
- package/dist/cjs/index.js +55 -0
- package/dist/cjs/standardFormDialog/useStandardFormSchema.d.ts +1 -1
- package/dist/cjs/standardFormDialog/withStandardForm.d.ts +2 -2
- package/dist/cjs/types/railroad-diagrams.d.ts +59 -0
- package/dist/cjs/types/regexp-tree.d.ts +175 -0
- package/dist/esm/components/RegexEditor/core/RegexEditor.d.ts +34 -0
- package/dist/esm/components/RegexEditor/core/RegexEditor.js +214 -0
- package/dist/esm/components/RegexEditor/core/RegexEditor.less +119 -0
- package/dist/esm/components/RegexEditor/core/extensions/errorMarker.d.ts +49 -0
- package/dist/esm/components/RegexEditor/core/extensions/errorMarker.js +154 -0
- package/dist/esm/components/RegexEditor/core/types.d.ts +79 -0
- package/dist/esm/components/RegexEditor/core/types.js +1 -0
- package/dist/esm/components/RegexEditor/hooks/index.d.ts +9 -0
- package/dist/esm/components/RegexEditor/hooks/index.js +8 -0
- package/dist/esm/components/RegexEditor/hooks/useRegexTester.d.ts +95 -0
- package/dist/esm/components/RegexEditor/hooks/useRegexTester.js +230 -0
- package/dist/esm/components/RegexEditor/hooks/useRegexValidation.d.ts +71 -0
- package/dist/esm/components/RegexEditor/hooks/useRegexValidation.js +211 -0
- package/dist/esm/components/RegexEditor/hooks/useTemplateManager.d.ts +64 -0
- package/dist/esm/components/RegexEditor/hooks/useTemplateManager.js +430 -0
- package/dist/esm/components/RegexEditor/index.d.ts +16 -0
- package/dist/esm/components/RegexEditor/index.js +27 -0
- package/dist/esm/components/RegexEditor/templates/TemplateSelector.d.ts +36 -0
- package/dist/esm/components/RegexEditor/templates/TemplateSelector.js +316 -0
- package/dist/esm/components/RegexEditor/templates/builtinTemplates.d.ts +36 -0
- package/dist/esm/components/RegexEditor/templates/builtinTemplates.js +335 -0
- package/dist/esm/components/RegexEditor/templates/index.d.ts +10 -0
- package/dist/esm/components/RegexEditor/templates/index.js +19 -0
- package/dist/esm/components/RegexEditor/templates/storage.d.ts +74 -0
- package/dist/esm/components/RegexEditor/templates/storage.js +335 -0
- package/dist/esm/components/RegexEditor/templates/templateManager.d.ts +67 -0
- package/dist/esm/components/RegexEditor/templates/templateManager.js +274 -0
- package/dist/esm/components/RegexEditor/templates/types.d.ts +111 -0
- package/dist/esm/components/RegexEditor/templates/types.js +90 -0
- package/dist/esm/components/RegexEditor/testing/types.d.ts +55 -0
- package/dist/esm/components/RegexEditor/testing/types.js +1 -0
- package/dist/esm/components/RegexEditor/validation/complexity.d.ts +22 -0
- package/dist/esm/components/RegexEditor/validation/complexity.js +190 -0
- package/dist/esm/components/RegexEditor/validation/parser.d.ts +53 -0
- package/dist/esm/components/RegexEditor/validation/parser.js +123 -0
- package/dist/esm/components/RegexEditor/validation/types.d.ts +145 -0
- package/dist/esm/components/RegexEditor/validation/types.js +1 -0
- package/dist/esm/components/RegexEditor/validation/validator.d.ts +60 -0
- package/dist/esm/components/RegexEditor/validation/validator.js +213 -0
- package/dist/esm/components/RegexEditor/visualizer/FlagsSelector.d.ts +20 -0
- package/dist/esm/components/RegexEditor/visualizer/FlagsSelector.js +93 -0
- package/dist/esm/components/RegexEditor/visualizer/MatchItem.d.ts +25 -0
- package/dist/esm/components/RegexEditor/visualizer/MatchItem.js +194 -0
- package/dist/esm/components/RegexEditor/visualizer/RegexRailroadDiagram.d.ts +32 -0
- package/dist/esm/components/RegexEditor/visualizer/RegexRailroadDiagram.js +186 -0
- package/dist/esm/components/RegexEditor/visualizer/RegexTester.d.ts +22 -0
- package/dist/esm/components/RegexEditor/visualizer/RegexTester.js +248 -0
- package/dist/esm/components/RegexEditor/visualizer/astToRailroad.d.ts +18 -0
- package/dist/esm/components/RegexEditor/visualizer/astToRailroad.js +150 -0
- package/dist/esm/components/RegexEditor/visualizer/index.d.ts +12 -0
- package/dist/esm/components/RegexEditor/visualizer/index.js +17 -0
- package/dist/esm/components/RegexEditor/visualizer/types.d.ts +131 -0
- package/dist/esm/components/RegexEditor/visualizer/types.js +1 -0
- package/dist/esm/components/RegexEditor/visualizer/utils.d.ts +106 -0
- package/dist/esm/components/RegexEditor/visualizer/utils.js +256 -0
- package/dist/esm/index.d.ts +3 -1
- package/dist/esm/index.js +5 -2
- package/dist/esm/types/railroad-diagrams.d.ts +59 -0
- package/dist/esm/types/regexp-tree.d.ts +175 -0
- package/dist/umd/qc-ui.min.css +1 -1
- package/dist/umd/qc-ui.min.js +1 -1
- package/package.json +23 -7
|
@@ -0,0 +1,316 @@
|
|
|
1
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
2
|
+
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
3
|
+
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."); }
|
|
4
|
+
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
5
|
+
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
6
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
7
|
+
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
8
|
+
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); }
|
|
9
|
+
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; }
|
|
10
|
+
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
|
11
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
12
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
13
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
14
|
+
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
15
|
+
/**
|
|
16
|
+
* 模板选择器组件
|
|
17
|
+
*
|
|
18
|
+
* @module RegexEditor/templates/TemplateSelector
|
|
19
|
+
* @description 提供模板选择、搜索、分类筛选等功能的UI组件
|
|
20
|
+
*/
|
|
21
|
+
|
|
22
|
+
import React, { useState, useMemo } from 'react';
|
|
23
|
+
import { Input, Select, Card, Tag, Empty, Space, Typography, Tooltip } from 'antd';
|
|
24
|
+
import { SearchOutlined, ClockCircleOutlined, FireOutlined, StarOutlined } from '@ant-design/icons';
|
|
25
|
+
import { TemplateCategory as Category } from "./types";
|
|
26
|
+
var Search = Input.Search;
|
|
27
|
+
var Option = Select.Option;
|
|
28
|
+
var Text = Typography.Text,
|
|
29
|
+
Paragraph = Typography.Paragraph;
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* 模板选择器组件属性
|
|
33
|
+
*/
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* 分类显示名称映射
|
|
37
|
+
*/
|
|
38
|
+
var CATEGORY_LABELS = _defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty({}, Category.BUSINESS, '业务模板'), Category.COMMON, '通用模式'), Category.DATE_TIME, '日期时间'), Category.NUMBER, '数字格式'), Category.TEXT, '文本格式'), Category.VALIDATION, '数据验证'), Category.EXTRACTION, '数据提取'), Category.CUSTOM, '自定义');
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* 复杂度标签配置
|
|
42
|
+
*/
|
|
43
|
+
var COMPLEXITY_CONFIG = {
|
|
44
|
+
simple: {
|
|
45
|
+
label: '简单',
|
|
46
|
+
color: 'success'
|
|
47
|
+
},
|
|
48
|
+
medium: {
|
|
49
|
+
label: '中等',
|
|
50
|
+
color: 'warning'
|
|
51
|
+
},
|
|
52
|
+
complex: {
|
|
53
|
+
label: '复杂',
|
|
54
|
+
color: 'error'
|
|
55
|
+
}
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* 模板选择器组件
|
|
60
|
+
*
|
|
61
|
+
* @example
|
|
62
|
+
* ```tsx
|
|
63
|
+
* <TemplateSelector
|
|
64
|
+
* templates={allTemplates}
|
|
65
|
+
* onSelect={(template) => setPattern(template.pattern)}
|
|
66
|
+
* selectedId={currentTemplateId}
|
|
67
|
+
* />
|
|
68
|
+
* ```
|
|
69
|
+
*/
|
|
70
|
+
export var TemplateSelector = function TemplateSelector(_ref) {
|
|
71
|
+
var templates = _ref.templates,
|
|
72
|
+
onSelect = _ref.onSelect,
|
|
73
|
+
selectedId = _ref.selectedId,
|
|
74
|
+
_ref$showCustom = _ref.showCustom,
|
|
75
|
+
showCustom = _ref$showCustom === void 0 ? true : _ref$showCustom,
|
|
76
|
+
className = _ref.className;
|
|
77
|
+
var _useState = useState(''),
|
|
78
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
79
|
+
searchKeyword = _useState2[0],
|
|
80
|
+
setSearchKeyword = _useState2[1];
|
|
81
|
+
var _useState3 = useState('all'),
|
|
82
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
83
|
+
selectedCategory = _useState4[0],
|
|
84
|
+
setSelectedCategory = _useState4[1];
|
|
85
|
+
var _useState5 = useState('default'),
|
|
86
|
+
_useState6 = _slicedToArray(_useState5, 2),
|
|
87
|
+
sortBy = _useState6[0],
|
|
88
|
+
setSortBy = _useState6[1];
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* 过滤和排序后的模板列表
|
|
92
|
+
*/
|
|
93
|
+
var filteredTemplates = useMemo(function () {
|
|
94
|
+
var result = templates;
|
|
95
|
+
|
|
96
|
+
// 分类筛选
|
|
97
|
+
if (selectedCategory !== 'all') {
|
|
98
|
+
result = result.filter(function (t) {
|
|
99
|
+
return t.category === selectedCategory;
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
// 隐藏自定义模板(如果需要)
|
|
104
|
+
if (!showCustom) {
|
|
105
|
+
result = result.filter(function (t) {
|
|
106
|
+
return !t.isCustom;
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
// 关键字搜索
|
|
111
|
+
if (searchKeyword) {
|
|
112
|
+
var keyword = searchKeyword.toLowerCase();
|
|
113
|
+
result = result.filter(function (t) {
|
|
114
|
+
return t.name.toLowerCase().includes(keyword) || t.description.toLowerCase().includes(keyword) || t.tags.some(function (tag) {
|
|
115
|
+
return tag.toLowerCase().includes(keyword);
|
|
116
|
+
}) || t.pattern.toLowerCase().includes(keyword);
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
// 排序
|
|
121
|
+
if (sortBy === 'popular') {
|
|
122
|
+
result = _toConsumableArray(result).sort(function (a, b) {
|
|
123
|
+
return (b.useCount || 0) - (a.useCount || 0);
|
|
124
|
+
});
|
|
125
|
+
} else if (sortBy === 'recent') {
|
|
126
|
+
result = _toConsumableArray(result).sort(function (a, b) {
|
|
127
|
+
var _a$lastUsed, _b$lastUsed;
|
|
128
|
+
var aTime = ((_a$lastUsed = a.lastUsed) === null || _a$lastUsed === void 0 ? void 0 : _a$lastUsed.getTime()) || 0;
|
|
129
|
+
var bTime = ((_b$lastUsed = b.lastUsed) === null || _b$lastUsed === void 0 ? void 0 : _b$lastUsed.getTime()) || 0;
|
|
130
|
+
return bTime - aTime;
|
|
131
|
+
});
|
|
132
|
+
}
|
|
133
|
+
return result;
|
|
134
|
+
}, [templates, selectedCategory, searchKeyword, sortBy, showCustom]);
|
|
135
|
+
|
|
136
|
+
/**
|
|
137
|
+
* 渲染模板卡片
|
|
138
|
+
*/
|
|
139
|
+
var renderTemplateCard = function renderTemplateCard(template) {
|
|
140
|
+
var isSelected = template.id === selectedId;
|
|
141
|
+
var complexityConfig = COMPLEXITY_CONFIG[template.complexity];
|
|
142
|
+
return /*#__PURE__*/React.createElement(Card, {
|
|
143
|
+
key: template.id,
|
|
144
|
+
size: "small",
|
|
145
|
+
hoverable: true,
|
|
146
|
+
className: "template-card ".concat(isSelected ? 'template-card-selected' : ''),
|
|
147
|
+
onClick: function onClick() {
|
|
148
|
+
return onSelect(template);
|
|
149
|
+
},
|
|
150
|
+
style: {
|
|
151
|
+
marginBottom: 12,
|
|
152
|
+
borderColor: isSelected ? '#1890ff' : undefined,
|
|
153
|
+
backgroundColor: isSelected ? '#e6f7ff' : undefined
|
|
154
|
+
}
|
|
155
|
+
}, /*#__PURE__*/React.createElement(Space, {
|
|
156
|
+
direction: "vertical",
|
|
157
|
+
size: 4,
|
|
158
|
+
style: {
|
|
159
|
+
width: '100%'
|
|
160
|
+
}
|
|
161
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
162
|
+
style: {
|
|
163
|
+
display: 'flex',
|
|
164
|
+
justifyContent: 'space-between',
|
|
165
|
+
alignItems: 'center'
|
|
166
|
+
}
|
|
167
|
+
}, /*#__PURE__*/React.createElement(Text, {
|
|
168
|
+
strong: true
|
|
169
|
+
}, template.name), /*#__PURE__*/React.createElement(Space, {
|
|
170
|
+
size: 4
|
|
171
|
+
}, template.isCustom && /*#__PURE__*/React.createElement(Tag, {
|
|
172
|
+
color: "purple",
|
|
173
|
+
icon: /*#__PURE__*/React.createElement(StarOutlined, null)
|
|
174
|
+
}, "\u81EA\u5B9A\u4E49"), /*#__PURE__*/React.createElement(Tag, {
|
|
175
|
+
color: complexityConfig.color
|
|
176
|
+
}, complexityConfig.label))), /*#__PURE__*/React.createElement(Paragraph, {
|
|
177
|
+
type: "secondary",
|
|
178
|
+
style: {
|
|
179
|
+
margin: 0,
|
|
180
|
+
fontSize: 12
|
|
181
|
+
},
|
|
182
|
+
ellipsis: {
|
|
183
|
+
rows: 2,
|
|
184
|
+
tooltip: template.description
|
|
185
|
+
}
|
|
186
|
+
}, template.description), /*#__PURE__*/React.createElement(Tooltip, {
|
|
187
|
+
title: "\u70B9\u51FB\u5E94\u7528\u6B64\u6A21\u677F"
|
|
188
|
+
}, /*#__PURE__*/React.createElement("code", {
|
|
189
|
+
style: {
|
|
190
|
+
display: 'block',
|
|
191
|
+
padding: '4px 8px',
|
|
192
|
+
backgroundColor: '#f5f5f5',
|
|
193
|
+
borderRadius: 4,
|
|
194
|
+
fontSize: 12,
|
|
195
|
+
overflow: 'hidden',
|
|
196
|
+
textOverflow: 'ellipsis',
|
|
197
|
+
whiteSpace: 'nowrap'
|
|
198
|
+
}
|
|
199
|
+
}, template.pattern)), /*#__PURE__*/React.createElement("div", {
|
|
200
|
+
style: {
|
|
201
|
+
display: 'flex',
|
|
202
|
+
justifyContent: 'space-between',
|
|
203
|
+
alignItems: 'center'
|
|
204
|
+
}
|
|
205
|
+
}, /*#__PURE__*/React.createElement(Space, {
|
|
206
|
+
size: 4,
|
|
207
|
+
wrap: true
|
|
208
|
+
}, template.tags.slice(0, 3).map(function (tag) {
|
|
209
|
+
return /*#__PURE__*/React.createElement(Tag, {
|
|
210
|
+
key: tag,
|
|
211
|
+
style: {
|
|
212
|
+
margin: 0,
|
|
213
|
+
fontSize: 11
|
|
214
|
+
}
|
|
215
|
+
}, tag);
|
|
216
|
+
}), template.tags.length > 3 && /*#__PURE__*/React.createElement(Tag, {
|
|
217
|
+
style: {
|
|
218
|
+
margin: 0,
|
|
219
|
+
fontSize: 11
|
|
220
|
+
}
|
|
221
|
+
}, "+", template.tags.length - 3)), /*#__PURE__*/React.createElement(Space, {
|
|
222
|
+
size: 8,
|
|
223
|
+
style: {
|
|
224
|
+
fontSize: 11,
|
|
225
|
+
color: '#999'
|
|
226
|
+
}
|
|
227
|
+
}, template.useCount !== undefined && /*#__PURE__*/React.createElement("span", null, /*#__PURE__*/React.createElement(FireOutlined, null), " ", template.useCount), template.lastUsed && /*#__PURE__*/React.createElement("span", null, /*#__PURE__*/React.createElement(ClockCircleOutlined, null), " ", formatDate(template.lastUsed))))));
|
|
228
|
+
};
|
|
229
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
230
|
+
className: className,
|
|
231
|
+
style: {
|
|
232
|
+
height: '100%',
|
|
233
|
+
display: 'flex',
|
|
234
|
+
flexDirection: 'column'
|
|
235
|
+
}
|
|
236
|
+
}, /*#__PURE__*/React.createElement(Space, {
|
|
237
|
+
direction: "vertical",
|
|
238
|
+
size: 12,
|
|
239
|
+
style: {
|
|
240
|
+
marginBottom: 16
|
|
241
|
+
}
|
|
242
|
+
}, /*#__PURE__*/React.createElement(Search, {
|
|
243
|
+
placeholder: "\u641C\u7D22\u6A21\u677F\u540D\u79F0\u3001\u63CF\u8FF0\u6216\u6807\u7B7E...",
|
|
244
|
+
allowClear: true,
|
|
245
|
+
prefix: /*#__PURE__*/React.createElement(SearchOutlined, null),
|
|
246
|
+
value: searchKeyword,
|
|
247
|
+
onChange: function onChange(e) {
|
|
248
|
+
return setSearchKeyword(e.target.value);
|
|
249
|
+
}
|
|
250
|
+
}), /*#__PURE__*/React.createElement(Space, {
|
|
251
|
+
size: 8,
|
|
252
|
+
style: {
|
|
253
|
+
width: '100%'
|
|
254
|
+
}
|
|
255
|
+
}, /*#__PURE__*/React.createElement(Select, {
|
|
256
|
+
style: {
|
|
257
|
+
flex: 1
|
|
258
|
+
},
|
|
259
|
+
value: selectedCategory,
|
|
260
|
+
onChange: setSelectedCategory,
|
|
261
|
+
placeholder: "\u9009\u62E9\u5206\u7C7B"
|
|
262
|
+
}, /*#__PURE__*/React.createElement(Option, {
|
|
263
|
+
value: "all"
|
|
264
|
+
}, "\u5168\u90E8\u5206\u7C7B"), Object.entries(CATEGORY_LABELS).map(function (_ref2) {
|
|
265
|
+
var _ref3 = _slicedToArray(_ref2, 2),
|
|
266
|
+
value = _ref3[0],
|
|
267
|
+
label = _ref3[1];
|
|
268
|
+
return /*#__PURE__*/React.createElement(Option, {
|
|
269
|
+
key: value,
|
|
270
|
+
value: value
|
|
271
|
+
}, label);
|
|
272
|
+
})), /*#__PURE__*/React.createElement(Select, {
|
|
273
|
+
style: {
|
|
274
|
+
width: 100
|
|
275
|
+
},
|
|
276
|
+
value: sortBy,
|
|
277
|
+
onChange: setSortBy
|
|
278
|
+
}, /*#__PURE__*/React.createElement(Option, {
|
|
279
|
+
value: "default"
|
|
280
|
+
}, "\u9ED8\u8BA4"), /*#__PURE__*/React.createElement(Option, {
|
|
281
|
+
value: "popular"
|
|
282
|
+
}, "\u6700\u70ED\u95E8"), /*#__PURE__*/React.createElement(Option, {
|
|
283
|
+
value: "recent"
|
|
284
|
+
}, "\u6700\u8FD1\u4F7F\u7528")))), /*#__PURE__*/React.createElement("div", {
|
|
285
|
+
style: {
|
|
286
|
+
flex: 1,
|
|
287
|
+
overflowY: 'auto'
|
|
288
|
+
}
|
|
289
|
+
}, filteredTemplates.length > 0 ? filteredTemplates.map(renderTemplateCard) : /*#__PURE__*/React.createElement(Empty, {
|
|
290
|
+
description: searchKeyword || selectedCategory !== 'all' ? '没有找到匹配的模板' : '暂无可用模板'
|
|
291
|
+
})), /*#__PURE__*/React.createElement("div", {
|
|
292
|
+
style: {
|
|
293
|
+
marginTop: 12,
|
|
294
|
+
paddingTop: 12,
|
|
295
|
+
borderTop: '1px solid #f0f0f0',
|
|
296
|
+
fontSize: 12,
|
|
297
|
+
color: '#999',
|
|
298
|
+
textAlign: 'center'
|
|
299
|
+
}
|
|
300
|
+
}, "\u5171 ", filteredTemplates.length, " \u4E2A\u6A21\u677F", searchKeyword && " (\u641C\u7D22: \"".concat(searchKeyword, "\")")));
|
|
301
|
+
};
|
|
302
|
+
|
|
303
|
+
/**
|
|
304
|
+
* 格式化日期显示
|
|
305
|
+
*/
|
|
306
|
+
function formatDate(date) {
|
|
307
|
+
var now = new Date();
|
|
308
|
+
var diff = now.getTime() - date.getTime();
|
|
309
|
+
var days = Math.floor(diff / (1000 * 60 * 60 * 24));
|
|
310
|
+
if (days === 0) return '今天';
|
|
311
|
+
if (days === 1) return '昨天';
|
|
312
|
+
if (days < 7) return "".concat(days, "\u5929\u524D");
|
|
313
|
+
if (days < 30) return "".concat(Math.floor(days / 7), "\u5468\u524D");
|
|
314
|
+
if (days < 365) return "".concat(Math.floor(days / 30), "\u6708\u524D");
|
|
315
|
+
return "".concat(Math.floor(days / 365), "\u5E74\u524D");
|
|
316
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 内置正则表达式模板库
|
|
3
|
+
*
|
|
4
|
+
* @module RegexEditor/templates/builtinTemplates
|
|
5
|
+
* @description 提供20+个精心设计的内置正则表达式模板,覆盖常见业务场景
|
|
6
|
+
*/
|
|
7
|
+
import { RegexTemplate, TemplateCategory } from './types';
|
|
8
|
+
/**
|
|
9
|
+
* 内置模板库
|
|
10
|
+
*
|
|
11
|
+
* @description
|
|
12
|
+
* 包含以下分类:
|
|
13
|
+
* - 业务相关: 批次号、订单号、产品编码等
|
|
14
|
+
* - 通用模式: 邮箱、电话、URL、IP地址等
|
|
15
|
+
* - 日期时间: 各种日期时间格式
|
|
16
|
+
* - 数字格式: 整数、小数、货币等
|
|
17
|
+
* - 文本格式: 中文、英文、Unicode等
|
|
18
|
+
* - 数据验证: 长度、范围、格式验证
|
|
19
|
+
*/
|
|
20
|
+
export declare const BUILTIN_TEMPLATES: RegexTemplate[];
|
|
21
|
+
/**
|
|
22
|
+
* 获取所有内置模板
|
|
23
|
+
*/
|
|
24
|
+
export declare const getAllBuiltinTemplates: () => RegexTemplate[];
|
|
25
|
+
/**
|
|
26
|
+
* 按分类获取模板
|
|
27
|
+
*/
|
|
28
|
+
export declare const getTemplatesByCategory: (category: TemplateCategory) => RegexTemplate[];
|
|
29
|
+
/**
|
|
30
|
+
* 按ID获取模板
|
|
31
|
+
*/
|
|
32
|
+
export declare const getTemplateById: (id: string) => RegexTemplate | undefined;
|
|
33
|
+
/**
|
|
34
|
+
* 搜索模板(按名称、描述、标签)
|
|
35
|
+
*/
|
|
36
|
+
export declare const searchTemplates: (keyword: string) => RegexTemplate[];
|
|
@@ -0,0 +1,335 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 内置正则表达式模板库
|
|
3
|
+
*
|
|
4
|
+
* @module RegexEditor/templates/builtinTemplates
|
|
5
|
+
* @description 提供20+个精心设计的内置正则表达式模板,覆盖常见业务场景
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import { TemplateCategory } from "./types";
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* 内置模板库
|
|
12
|
+
*
|
|
13
|
+
* @description
|
|
14
|
+
* 包含以下分类:
|
|
15
|
+
* - 业务相关: 批次号、订单号、产品编码等
|
|
16
|
+
* - 通用模式: 邮箱、电话、URL、IP地址等
|
|
17
|
+
* - 日期时间: 各种日期时间格式
|
|
18
|
+
* - 数字格式: 整数、小数、货币等
|
|
19
|
+
* - 文本格式: 中文、英文、Unicode等
|
|
20
|
+
* - 数据验证: 长度、范围、格式验证
|
|
21
|
+
*/
|
|
22
|
+
export var BUILTIN_TEMPLATES = [
|
|
23
|
+
// ==================== 业务相关模板 ====================
|
|
24
|
+
{
|
|
25
|
+
id: 'lot-number',
|
|
26
|
+
name: '批次号',
|
|
27
|
+
pattern: '^LOT\\d{6}$',
|
|
28
|
+
description: '标准批次号格式: LOT + 6位数字',
|
|
29
|
+
category: TemplateCategory.BUSINESS,
|
|
30
|
+
tags: ['批次', 'LOT', '业务', '编号'],
|
|
31
|
+
examples: {
|
|
32
|
+
valid: ['LOT123456', 'LOT000001', 'LOT999999'],
|
|
33
|
+
invalid: ['LOT12345', 'lot123456', 'LOT1234567', 'LOT-123456']
|
|
34
|
+
},
|
|
35
|
+
complexity: 'simple'
|
|
36
|
+
}, {
|
|
37
|
+
id: 'order-number',
|
|
38
|
+
name: '订单号',
|
|
39
|
+
pattern: '^ORD\\d{8,12}$',
|
|
40
|
+
description: '订单号格式: ORD + 8-12位数字',
|
|
41
|
+
category: TemplateCategory.BUSINESS,
|
|
42
|
+
tags: ['订单', 'ORDER', '业务', '编号'],
|
|
43
|
+
examples: {
|
|
44
|
+
valid: ['ORD12345678', 'ORD123456789012'],
|
|
45
|
+
invalid: ['ORD1234567', 'ord12345678', 'ORD-12345678']
|
|
46
|
+
},
|
|
47
|
+
complexity: 'simple'
|
|
48
|
+
}, {
|
|
49
|
+
id: 'product-code',
|
|
50
|
+
name: '产品编码',
|
|
51
|
+
pattern: '^[A-Z]{2,4}\\d{4,8}$',
|
|
52
|
+
description: '产品编码: 2-4位大写字母 + 4-8位数字',
|
|
53
|
+
category: TemplateCategory.BUSINESS,
|
|
54
|
+
tags: ['产品', 'SKU', '编码', '业务'],
|
|
55
|
+
examples: {
|
|
56
|
+
valid: ['AB1234', 'ABCD12345678', 'SKU00001234'],
|
|
57
|
+
invalid: ['ab1234', 'A1234', 'ABCDE123', 'AB-1234']
|
|
58
|
+
},
|
|
59
|
+
complexity: 'simple'
|
|
60
|
+
},
|
|
61
|
+
// ==================== 通用模式模板 ====================
|
|
62
|
+
{
|
|
63
|
+
id: 'email',
|
|
64
|
+
name: '电子邮箱',
|
|
65
|
+
pattern: '^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\\.[a-zA-Z]{2,}$',
|
|
66
|
+
description: '标准电子邮箱地址格式',
|
|
67
|
+
category: TemplateCategory.COMMON,
|
|
68
|
+
tags: ['邮箱', 'email', '联系方式'],
|
|
69
|
+
examples: {
|
|
70
|
+
valid: ['user@example.com', 'test.user+tag@domain.co.uk'],
|
|
71
|
+
invalid: ['user@', '@example.com', 'user@.com', 'user example.com']
|
|
72
|
+
},
|
|
73
|
+
complexity: 'medium'
|
|
74
|
+
}, {
|
|
75
|
+
id: 'phone-cn',
|
|
76
|
+
name: '中国手机号',
|
|
77
|
+
pattern: '^1[3-9]\\d{9}$',
|
|
78
|
+
description: '中国大陆手机号码: 1开头 + 3-9的第二位 + 9位数字',
|
|
79
|
+
category: TemplateCategory.COMMON,
|
|
80
|
+
tags: ['手机', '电话', '中国', '联系方式'],
|
|
81
|
+
examples: {
|
|
82
|
+
valid: ['13812345678', '18900001234', '19512345678'],
|
|
83
|
+
invalid: ['12345678901', '1381234567', '138-1234-5678']
|
|
84
|
+
},
|
|
85
|
+
complexity: 'simple'
|
|
86
|
+
}, {
|
|
87
|
+
id: 'url',
|
|
88
|
+
name: 'URL地址',
|
|
89
|
+
pattern: '^https?:\\/\\/(www\\.)?[-a-zA-Z0-9@:%._\\+~#=]{1,256}\\.[a-zA-Z0-9()]{1,6}\\b([-a-zA-Z0-9()@:%_\\+.~#?&//=]*)$',
|
|
90
|
+
description: 'HTTP/HTTPS URL地址',
|
|
91
|
+
category: TemplateCategory.COMMON,
|
|
92
|
+
tags: ['URL', '链接', '网址'],
|
|
93
|
+
examples: {
|
|
94
|
+
valid: ['https://example.com', 'http://www.example.com/path?query=1'],
|
|
95
|
+
invalid: ['example.com', 'ftp://example.com', 'https://']
|
|
96
|
+
},
|
|
97
|
+
complexity: 'complex'
|
|
98
|
+
}, {
|
|
99
|
+
id: 'ipv4',
|
|
100
|
+
name: 'IPv4地址',
|
|
101
|
+
pattern: '^(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$',
|
|
102
|
+
description: 'IPv4地址格式 (0.0.0.0 - 255.255.255.255)',
|
|
103
|
+
category: TemplateCategory.COMMON,
|
|
104
|
+
tags: ['IP', 'IPv4', '网络', '地址'],
|
|
105
|
+
examples: {
|
|
106
|
+
valid: ['192.168.1.1', '10.0.0.1', '255.255.255.255', '0.0.0.0'],
|
|
107
|
+
invalid: ['256.1.1.1', '192.168.1', '192.168.1.1.1']
|
|
108
|
+
},
|
|
109
|
+
complexity: 'complex'
|
|
110
|
+
}, {
|
|
111
|
+
id: 'id-card-cn',
|
|
112
|
+
name: '中国身份证号',
|
|
113
|
+
pattern: '^[1-9]\\d{5}(18|19|20)\\d{2}(0[1-9]|1[0-2])(0[1-9]|[12]\\d|3[01])\\d{3}[\\dXx]$',
|
|
114
|
+
description: '中国大陆18位身份证号码',
|
|
115
|
+
category: TemplateCategory.COMMON,
|
|
116
|
+
tags: ['身份证', '证件', '中国'],
|
|
117
|
+
examples: {
|
|
118
|
+
valid: ['110101199003071234', '44010119900307123X'],
|
|
119
|
+
invalid: ['11010119900307123', '110101199013071234']
|
|
120
|
+
},
|
|
121
|
+
complexity: 'complex'
|
|
122
|
+
},
|
|
123
|
+
// ==================== 日期时间模板 ====================
|
|
124
|
+
{
|
|
125
|
+
id: 'date-iso',
|
|
126
|
+
name: 'ISO日期',
|
|
127
|
+
pattern: '^\\d{4}-\\d{2}-\\d{2}$',
|
|
128
|
+
description: 'ISO 8601日期格式: YYYY-MM-DD',
|
|
129
|
+
category: TemplateCategory.DATE_TIME,
|
|
130
|
+
tags: ['日期', 'ISO', 'YYYY-MM-DD'],
|
|
131
|
+
examples: {
|
|
132
|
+
valid: ['2025-01-27', '2024-12-31', '2000-01-01'],
|
|
133
|
+
invalid: ['2025/01/27', '25-01-27', '2025-1-27']
|
|
134
|
+
},
|
|
135
|
+
complexity: 'simple'
|
|
136
|
+
}, {
|
|
137
|
+
id: 'date-us',
|
|
138
|
+
name: '美式日期',
|
|
139
|
+
pattern: '^(0[1-9]|1[0-2])\\/(0[1-9]|[12]\\d|3[01])\\/\\d{4}$',
|
|
140
|
+
description: '美式日期格式: MM/DD/YYYY',
|
|
141
|
+
category: TemplateCategory.DATE_TIME,
|
|
142
|
+
tags: ['日期', '美国', 'MM/DD/YYYY'],
|
|
143
|
+
examples: {
|
|
144
|
+
valid: ['01/27/2025', '12/31/2024'],
|
|
145
|
+
invalid: ['13/01/2025', '01/32/2025', '1/27/2025']
|
|
146
|
+
},
|
|
147
|
+
complexity: 'medium'
|
|
148
|
+
}, {
|
|
149
|
+
id: 'time-24h',
|
|
150
|
+
name: '24小时时间',
|
|
151
|
+
pattern: '^([01]\\d|2[0-3]):[0-5]\\d(:[0-5]\\d)?$',
|
|
152
|
+
description: '24小时制时间: HH:MM 或 HH:MM:SS',
|
|
153
|
+
category: TemplateCategory.DATE_TIME,
|
|
154
|
+
tags: ['时间', '24小时', 'HH:MM'],
|
|
155
|
+
examples: {
|
|
156
|
+
valid: ['23:59', '00:00', '12:30:45'],
|
|
157
|
+
invalid: ['24:00', '23:60', '1:30']
|
|
158
|
+
},
|
|
159
|
+
complexity: 'medium'
|
|
160
|
+
}, {
|
|
161
|
+
id: 'datetime-iso',
|
|
162
|
+
name: 'ISO日期时间',
|
|
163
|
+
pattern: '^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(\\.\\d{3})?(Z|[+-]\\d{2}:\\d{2})$',
|
|
164
|
+
description: 'ISO 8601日期时间格式',
|
|
165
|
+
category: TemplateCategory.DATE_TIME,
|
|
166
|
+
tags: ['日期时间', 'ISO', 'timestamp'],
|
|
167
|
+
examples: {
|
|
168
|
+
valid: ['2025-01-27T14:30:00Z', '2025-01-27T14:30:00.123+08:00'],
|
|
169
|
+
invalid: ['2025-01-27 14:30:00', '2025-01-27T14:30']
|
|
170
|
+
},
|
|
171
|
+
complexity: 'complex'
|
|
172
|
+
},
|
|
173
|
+
// ==================== 数字格式模板 ====================
|
|
174
|
+
{
|
|
175
|
+
id: 'integer',
|
|
176
|
+
name: '整数',
|
|
177
|
+
pattern: '^-?\\d+$',
|
|
178
|
+
description: '整数(可选负号)',
|
|
179
|
+
category: TemplateCategory.NUMBER,
|
|
180
|
+
tags: ['数字', '整数', 'integer'],
|
|
181
|
+
examples: {
|
|
182
|
+
valid: ['123', '-456', '0'],
|
|
183
|
+
invalid: ['12.3', '1,234', '1e10']
|
|
184
|
+
},
|
|
185
|
+
complexity: 'simple'
|
|
186
|
+
}, {
|
|
187
|
+
id: 'decimal',
|
|
188
|
+
name: '小数',
|
|
189
|
+
pattern: '^-?\\d+\\.\\d+$',
|
|
190
|
+
description: '小数(必须有小数点和小数部分)',
|
|
191
|
+
category: TemplateCategory.NUMBER,
|
|
192
|
+
tags: ['数字', '小数', 'decimal', 'float'],
|
|
193
|
+
examples: {
|
|
194
|
+
valid: ['12.34', '-0.5', '3.14159'],
|
|
195
|
+
invalid: ['12', '12.', '.5', '12,34']
|
|
196
|
+
},
|
|
197
|
+
complexity: 'simple'
|
|
198
|
+
}, {
|
|
199
|
+
id: 'currency',
|
|
200
|
+
name: '货币金额',
|
|
201
|
+
pattern: '^-?\\d{1,3}(,\\d{3})*(\\.\\d{1,2})?$',
|
|
202
|
+
description: '货币格式(千分位逗号,最多2位小数)',
|
|
203
|
+
category: TemplateCategory.NUMBER,
|
|
204
|
+
tags: ['数字', '货币', '金额', 'money'],
|
|
205
|
+
examples: {
|
|
206
|
+
valid: ['1,234.56', '1,000', '-1,234,567.89'],
|
|
207
|
+
invalid: ['1234.56', '1,234.567', '1,23.45']
|
|
208
|
+
},
|
|
209
|
+
complexity: 'medium'
|
|
210
|
+
}, {
|
|
211
|
+
id: 'percentage',
|
|
212
|
+
name: '百分比',
|
|
213
|
+
pattern: '^-?\\d+(\\.\\d+)?%$',
|
|
214
|
+
description: '百分比格式(数字 + %)',
|
|
215
|
+
category: TemplateCategory.NUMBER,
|
|
216
|
+
tags: ['数字', '百分比', 'percent'],
|
|
217
|
+
examples: {
|
|
218
|
+
valid: ['25%', '99.9%', '-10.5%'],
|
|
219
|
+
invalid: ['25', '%25', '25 %']
|
|
220
|
+
},
|
|
221
|
+
complexity: 'simple'
|
|
222
|
+
},
|
|
223
|
+
// ==================== 文本格式模板 ====================
|
|
224
|
+
{
|
|
225
|
+
id: 'chinese',
|
|
226
|
+
name: '中文字符',
|
|
227
|
+
pattern: "^[\\u4e00-\\u9fa5]+$",
|
|
228
|
+
description: '仅包含中文字符(汉字)',
|
|
229
|
+
category: TemplateCategory.TEXT,
|
|
230
|
+
tags: ['文本', '中文', '汉字', 'chinese'],
|
|
231
|
+
examples: {
|
|
232
|
+
valid: ['你好', '中文测试', '北京'],
|
|
233
|
+
invalid: ['hello', '你好123', '你好!']
|
|
234
|
+
},
|
|
235
|
+
complexity: 'simple'
|
|
236
|
+
}, {
|
|
237
|
+
id: 'english-letters',
|
|
238
|
+
name: '英文字母',
|
|
239
|
+
pattern: '^[a-zA-Z]+$',
|
|
240
|
+
description: '仅包含英文字母(大小写)',
|
|
241
|
+
category: TemplateCategory.TEXT,
|
|
242
|
+
tags: ['文本', '英文', '字母', 'english'],
|
|
243
|
+
examples: {
|
|
244
|
+
valid: ['hello', 'World', 'ABC'],
|
|
245
|
+
invalid: ['hello123', 'hello!', 'hello world']
|
|
246
|
+
},
|
|
247
|
+
complexity: 'simple'
|
|
248
|
+
}, {
|
|
249
|
+
id: 'alphanumeric',
|
|
250
|
+
name: '字母数字',
|
|
251
|
+
pattern: '^[a-zA-Z0-9]+$',
|
|
252
|
+
description: '仅包含字母和数字',
|
|
253
|
+
category: TemplateCategory.TEXT,
|
|
254
|
+
tags: ['文本', '字母数字', 'alphanumeric'],
|
|
255
|
+
examples: {
|
|
256
|
+
valid: ['abc123', 'Test2025'],
|
|
257
|
+
invalid: ['abc-123', 'test_123', 'hello world']
|
|
258
|
+
},
|
|
259
|
+
complexity: 'simple'
|
|
260
|
+
},
|
|
261
|
+
// ==================== 数据验证模板 ====================
|
|
262
|
+
{
|
|
263
|
+
id: 'length-6-20',
|
|
264
|
+
name: '长度6-20字符',
|
|
265
|
+
pattern: '^.{6,20}$',
|
|
266
|
+
description: '任意字符,长度6-20',
|
|
267
|
+
category: TemplateCategory.VALIDATION,
|
|
268
|
+
tags: ['验证', '长度', 'length', '密码'],
|
|
269
|
+
examples: {
|
|
270
|
+
valid: ['123456', 'a'.repeat(20)],
|
|
271
|
+
invalid: ['12345', 'a'.repeat(21)]
|
|
272
|
+
},
|
|
273
|
+
complexity: 'simple'
|
|
274
|
+
}, {
|
|
275
|
+
id: 'password-strong',
|
|
276
|
+
name: '强密码',
|
|
277
|
+
pattern: '^(?=.*[a-z])(?=.*[A-Z])(?=.*\\d)(?=.*[@$!%*?&])[A-Za-z\\d@$!%*?&]{8,}$',
|
|
278
|
+
description: '至少8位,包含大小写字母、数字和特殊字符',
|
|
279
|
+
category: TemplateCategory.VALIDATION,
|
|
280
|
+
tags: ['验证', '密码', 'password', '安全'],
|
|
281
|
+
examples: {
|
|
282
|
+
valid: ['Test@123', 'MyP@ssw0rd'],
|
|
283
|
+
invalid: ['test123', 'TEST123', 'Test123', 'short@1']
|
|
284
|
+
},
|
|
285
|
+
complexity: 'complex'
|
|
286
|
+
}, {
|
|
287
|
+
id: 'username',
|
|
288
|
+
name: '用户名',
|
|
289
|
+
pattern: '^[a-zA-Z0-9_]{3,16}$',
|
|
290
|
+
description: '3-16位字母数字下划线',
|
|
291
|
+
category: TemplateCategory.VALIDATION,
|
|
292
|
+
tags: ['验证', '用户名', 'username'],
|
|
293
|
+
examples: {
|
|
294
|
+
valid: ['user123', 'test_user', 'MyUsername'],
|
|
295
|
+
invalid: ['us', 'user-name', 'a'.repeat(17)]
|
|
296
|
+
},
|
|
297
|
+
complexity: 'simple'
|
|
298
|
+
}];
|
|
299
|
+
|
|
300
|
+
/**
|
|
301
|
+
* 获取所有内置模板
|
|
302
|
+
*/
|
|
303
|
+
export var getAllBuiltinTemplates = function getAllBuiltinTemplates() {
|
|
304
|
+
return BUILTIN_TEMPLATES;
|
|
305
|
+
};
|
|
306
|
+
|
|
307
|
+
/**
|
|
308
|
+
* 按分类获取模板
|
|
309
|
+
*/
|
|
310
|
+
export var getTemplatesByCategory = function getTemplatesByCategory(category) {
|
|
311
|
+
return BUILTIN_TEMPLATES.filter(function (t) {
|
|
312
|
+
return t.category === category;
|
|
313
|
+
});
|
|
314
|
+
};
|
|
315
|
+
|
|
316
|
+
/**
|
|
317
|
+
* 按ID获取模板
|
|
318
|
+
*/
|
|
319
|
+
export var getTemplateById = function getTemplateById(id) {
|
|
320
|
+
return BUILTIN_TEMPLATES.find(function (t) {
|
|
321
|
+
return t.id === id;
|
|
322
|
+
});
|
|
323
|
+
};
|
|
324
|
+
|
|
325
|
+
/**
|
|
326
|
+
* 搜索模板(按名称、描述、标签)
|
|
327
|
+
*/
|
|
328
|
+
export var searchTemplates = function searchTemplates(keyword) {
|
|
329
|
+
var lowerKeyword = keyword.toLowerCase();
|
|
330
|
+
return BUILTIN_TEMPLATES.filter(function (t) {
|
|
331
|
+
return t.name.toLowerCase().includes(lowerKeyword) || t.description.toLowerCase().includes(lowerKeyword) || t.tags.some(function (tag) {
|
|
332
|
+
return tag.toLowerCase().includes(lowerKeyword);
|
|
333
|
+
});
|
|
334
|
+
});
|
|
335
|
+
};
|