@testid/antd-testid-runtime 1.0.4 → 1.0.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.mts CHANGED
@@ -33,10 +33,12 @@ interface TestIdMarkConfig {
33
33
  /**
34
34
  * Ant Design Vue CSS 类名前缀 (对应 ConfigProvider 的 prefixCls)
35
35
  *
36
- * 默认: 'ant' → 匹配 .ant-modal, .ant-picker-dropdown 等
37
- * 若项目使用 <a-config-provider prefixCls="my-ui"> 则设为 'my-ui'
36
+ * 支持数组,可同时匹配多个前缀体系:
37
+ * 默认: ['ant'] → 匹配 .ant-modal, .ant-picker-dropdown
38
+ * 若项目使用 <a-config-provider prefixCls="my-ui"> 则设为 ['my-ui']
39
+ * 混合使用: ['ant', 'my-ui'] → 同时匹配两个体系的所有浮层组件
38
40
  */
39
- antdClassPrefix: string;
41
+ antdClassPrefix: string[];
40
42
  /** 忽略不打标的 HTML 标签名 */
41
43
  ignoreTags: string[];
42
44
  /** 包含此 class 的 DOM 跳过打标 */
@@ -299,6 +301,8 @@ declare class TestIdObserver {
299
301
  private reachesBody;
300
302
  /**
301
303
  * 检测节点 class 是否匹配某个浮层类型
304
+ *
305
+ * 遍历 popupClassMap 中的所有 class 组合,任一组合全部命中即匹配。
302
306
  */
303
307
  private matchPopupClass;
304
308
  /**
package/dist/index.d.ts CHANGED
@@ -33,10 +33,12 @@ interface TestIdMarkConfig {
33
33
  /**
34
34
  * Ant Design Vue CSS 类名前缀 (对应 ConfigProvider 的 prefixCls)
35
35
  *
36
- * 默认: 'ant' → 匹配 .ant-modal, .ant-picker-dropdown 等
37
- * 若项目使用 <a-config-provider prefixCls="my-ui"> 则设为 'my-ui'
36
+ * 支持数组,可同时匹配多个前缀体系:
37
+ * 默认: ['ant'] → 匹配 .ant-modal, .ant-picker-dropdown
38
+ * 若项目使用 <a-config-provider prefixCls="my-ui"> 则设为 ['my-ui']
39
+ * 混合使用: ['ant', 'my-ui'] → 同时匹配两个体系的所有浮层组件
38
40
  */
39
- antdClassPrefix: string;
41
+ antdClassPrefix: string[];
40
42
  /** 忽略不打标的 HTML 标签名 */
41
43
  ignoreTags: string[];
42
44
  /** 包含此 class 的 DOM 跳过打标 */
@@ -299,6 +301,8 @@ declare class TestIdObserver {
299
301
  private reachesBody;
300
302
  /**
301
303
  * 检测节点 class 是否匹配某个浮层类型
304
+ *
305
+ * 遍历 popupClassMap 中的所有 class 组合,任一组合全部命中即匹配。
302
306
  */
303
307
  private matchPopupClass;
304
308
  /**
package/dist/index.js CHANGED
@@ -60,7 +60,7 @@ var defaultConfig = {
60
60
  globalPrefix: "",
61
61
  compilePrefix: "static_",
62
62
  runtimePagePrefix: "dynamic_",
63
- antdClassPrefix: "ant",
63
+ antdClassPrefix: ["ant"],
64
64
  popupPrefixMap: {
65
65
  modal: "modal_",
66
66
  drawer: "drawer_",
@@ -184,19 +184,26 @@ function buildPopupTestId(type, tag, counterId) {
184
184
 
185
185
  // src/utils/testIdObserver.ts
186
186
  var POPUP_CLASS_SUFFIX_MAP = {
187
- modal: ".{prefix}-modal",
188
- drawer: ".{prefix}-drawer",
189
- select: ".{prefix}-select-dropdown",
190
- datePicker: ".{prefix}-picker-dropdown",
191
- popconfirm: ".{prefix}-popover.{prefix}-popconfirm",
192
- dropdown: ".{prefix}-dropdown",
193
- tooltip: ".{prefix}-tooltip"
187
+ modal: ["-modal"],
188
+ drawer: ["-drawer"],
189
+ select: ["-select-dropdown"],
190
+ datePicker: [
191
+ "-picker-dropdown",
192
+ // Ant Design Vue 4.x (新)
193
+ "-calendar-picker-container"
194
+ // Ant Design Vue 1.x (旧)
195
+ ],
196
+ popconfirm: ["-popover", "-popconfirm"],
197
+ dropdown: ["-dropdown"],
198
+ tooltip: ["-tooltip"]
194
199
  };
195
- function buildPopupClassMap(prefix) {
200
+ function buildPopupClassMap(prefixes) {
196
201
  const result = {};
197
202
  const entries = Object.entries(POPUP_CLASS_SUFFIX_MAP);
198
- for (const [type, template] of entries) {
199
- result[type] = template.replace(/\{prefix\}/g, prefix);
203
+ for (const [type, suffixClasses] of entries) {
204
+ result[type] = prefixes.map(
205
+ (prefix) => suffixClasses.map((suffix) => `${prefix}${suffix}`)
206
+ );
200
207
  }
201
208
  return result;
202
209
  }
@@ -449,18 +456,19 @@ var TestIdObserver = class {
449
456
  }
450
457
  /**
451
458
  * 检测节点 class 是否匹配某个浮层类型
459
+ *
460
+ * 遍历 popupClassMap 中的所有 class 组合,任一组合全部命中即匹配。
452
461
  */
453
462
  matchPopupClass(node) {
454
463
  const classStr = node.className || "";
455
464
  if (typeof classStr !== "string") return null;
465
+ const classList = classStr.split(/\s+/);
456
466
  const entries = Object.entries(this.popupClassMap);
457
- for (const [type, selector] of entries) {
458
- const classes = selector.replace(/^\./, "").split(".");
459
- const allMatch = classes.every(
460
- (cls) => classStr.split(/\s+/).includes(cls)
461
- );
462
- if (allMatch) {
463
- return type;
467
+ for (const [type, selectorSets] of entries) {
468
+ for (const requiredClasses of selectorSets) {
469
+ if (requiredClasses.every((cls) => classList.includes(cls))) {
470
+ return type;
471
+ }
464
472
  }
465
473
  }
466
474
  return null;
package/dist/index.mjs CHANGED
@@ -18,7 +18,7 @@ var defaultConfig = {
18
18
  globalPrefix: "",
19
19
  compilePrefix: "static_",
20
20
  runtimePagePrefix: "dynamic_",
21
- antdClassPrefix: "ant",
21
+ antdClassPrefix: ["ant"],
22
22
  popupPrefixMap: {
23
23
  modal: "modal_",
24
24
  drawer: "drawer_",
@@ -142,19 +142,26 @@ function buildPopupTestId(type, tag, counterId) {
142
142
 
143
143
  // src/utils/testIdObserver.ts
144
144
  var POPUP_CLASS_SUFFIX_MAP = {
145
- modal: ".{prefix}-modal",
146
- drawer: ".{prefix}-drawer",
147
- select: ".{prefix}-select-dropdown",
148
- datePicker: ".{prefix}-picker-dropdown",
149
- popconfirm: ".{prefix}-popover.{prefix}-popconfirm",
150
- dropdown: ".{prefix}-dropdown",
151
- tooltip: ".{prefix}-tooltip"
145
+ modal: ["-modal"],
146
+ drawer: ["-drawer"],
147
+ select: ["-select-dropdown"],
148
+ datePicker: [
149
+ "-picker-dropdown",
150
+ // Ant Design Vue 4.x (新)
151
+ "-calendar-picker-container"
152
+ // Ant Design Vue 1.x (旧)
153
+ ],
154
+ popconfirm: ["-popover", "-popconfirm"],
155
+ dropdown: ["-dropdown"],
156
+ tooltip: ["-tooltip"]
152
157
  };
153
- function buildPopupClassMap(prefix) {
158
+ function buildPopupClassMap(prefixes) {
154
159
  const result = {};
155
160
  const entries = Object.entries(POPUP_CLASS_SUFFIX_MAP);
156
- for (const [type, template] of entries) {
157
- result[type] = template.replace(/\{prefix\}/g, prefix);
161
+ for (const [type, suffixClasses] of entries) {
162
+ result[type] = prefixes.map(
163
+ (prefix) => suffixClasses.map((suffix) => `${prefix}${suffix}`)
164
+ );
158
165
  }
159
166
  return result;
160
167
  }
@@ -407,18 +414,19 @@ var TestIdObserver = class {
407
414
  }
408
415
  /**
409
416
  * 检测节点 class 是否匹配某个浮层类型
417
+ *
418
+ * 遍历 popupClassMap 中的所有 class 组合,任一组合全部命中即匹配。
410
419
  */
411
420
  matchPopupClass(node) {
412
421
  const classStr = node.className || "";
413
422
  if (typeof classStr !== "string") return null;
423
+ const classList = classStr.split(/\s+/);
414
424
  const entries = Object.entries(this.popupClassMap);
415
- for (const [type, selector] of entries) {
416
- const classes = selector.replace(/^\./, "").split(".");
417
- const allMatch = classes.every(
418
- (cls) => classStr.split(/\s+/).includes(cls)
419
- );
420
- if (allMatch) {
421
- return type;
425
+ for (const [type, selectorSets] of entries) {
426
+ for (const requiredClasses of selectorSets) {
427
+ if (requiredClasses.every((cls) => classList.includes(cls))) {
428
+ return type;
429
+ }
422
430
  }
423
431
  }
424
432
  return null;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@testid/antd-testid-runtime",
3
- "version": "1.0.4",
3
+ "version": "1.0.6",
4
4
  "description": "运行时兜底打标模块 — MutationObserver + 锚点计数器 + 浮层计数器 + ID 重复检测",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",
@@ -15,6 +15,12 @@
15
15
  "files": [
16
16
  "dist"
17
17
  ],
18
+ "repository": {
19
+ "type": "git",
20
+ "url": "https://github.com/testid/testid-plugins.git",
21
+ "directory": "packages/antd-testid-runtime"
22
+ },
23
+
18
24
  "scripts": {
19
25
  "build": "tsup src/index.ts --dts --format esm,cjs --clean",
20
26
  "dev": "tsup src/index.ts --dts --format esm,cjs --watch"
@@ -24,4 +30,4 @@
24
30
  "tsup": "^8.0.0",
25
31
  "typescript": "^5.3.0"
26
32
  }
27
- }
33
+ }