@immense/vue-pom-generator 1.0.86 → 1.0.88

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.mjs CHANGED
@@ -236,6 +236,7 @@ function resolveInjectionSupportOptions(options) {
236
236
  layoutDirs: isNuxt ? ["app/layouts"] : options.layoutDirs ?? ["src/layouts"],
237
237
  wrapperSearchRoots: isNuxt ? [] : options.wrapperSearchRoots ?? [],
238
238
  nativeWrappers: options.nativeWrappers ?? {},
239
+ optionKeyAttribute: options.optionKeyAttribute ?? {},
239
240
  excludedComponents: options.excludedComponents ?? [],
240
241
  existingIdBehavior: options.existingIdBehavior ?? "error",
241
242
  testIdAttribute: (options.testIdAttribute ?? "data-testid").trim() || "data-testid"
@@ -1286,12 +1287,13 @@ function findDirectiveByName(node, directiveName, argumentName) {
1286
1287
  return matchesDirective;
1287
1288
  });
1288
1289
  }
1290
+ const ACTION_EVENTS = /* @__PURE__ */ new Set(["click", "change", "mousedown"]);
1289
1291
  function isClickDirective(prop) {
1290
1292
  if (prop.type !== NodeTypes.DIRECTIVE) {
1291
1293
  return false;
1292
1294
  }
1293
1295
  const directive = prop;
1294
- return directive.name === "on" && directive.arg?.type === NodeTypes.SIMPLE_EXPRESSION && directive.arg.content === "click";
1296
+ return directive.name === "on" && directive.arg?.type === NodeTypes.SIMPLE_EXPRESSION && ACTION_EVENTS.has(directive.arg.content);
1295
1297
  }
1296
1298
  function tryGetClickDirective(node) {
1297
1299
  return node.props.find((p) => isClickDirective(p));
@@ -1693,6 +1695,17 @@ function getKeyDirectiveInfo(node) {
1693
1695
  const runtimeSource = getVueExpressionSource(keyExpression, "loc", "compiled");
1694
1696
  return toResolvedKeyInfo(selectorSource, runtimeSource);
1695
1697
  }
1698
+ function getBindingKeyInfo(node, attrName) {
1699
+ const directive = findDirectiveByName(node, "bind", attrName);
1700
+ const exp = directive?.exp;
1701
+ if (!exp || exp.type !== NodeTypes.SIMPLE_EXPRESSION && exp.type !== NodeTypes.COMPOUND_EXPRESSION) {
1702
+ return null;
1703
+ }
1704
+ const expression = exp;
1705
+ const selectorSource = getVueExpressionSource(expression, "compiled", "loc");
1706
+ const runtimeSource = getVueExpressionSource(expression, "loc", "compiled");
1707
+ return toResolvedKeyInfo(selectorSource, runtimeSource);
1708
+ }
1696
1709
  function getModelBindingValues(node) {
1697
1710
  let vModel = "";
1698
1711
  const vModelDirective = findDirectiveByName(node, "model");
@@ -1712,6 +1725,15 @@ function getModelBindingValues(node) {
1712
1725
  }
1713
1726
  return { vModel, modelValue };
1714
1727
  }
1728
+ function getBindingValueHint(node) {
1729
+ const directive = findDirectiveByName(node, "bind", "value");
1730
+ const exp = directive?.exp;
1731
+ if (!exp || exp.type !== NodeTypes.SIMPLE_EXPRESSION && exp.type !== NodeTypes.COMPOUND_EXPRESSION) {
1732
+ return null;
1733
+ }
1734
+ const source = getVueExpressionSource(exp, "loc", "content");
1735
+ return source || null;
1736
+ }
1715
1737
  function getStaticIdOrNameHint(node) {
1716
1738
  let idAttr = findAttributeByKey(node, "id");
1717
1739
  if (!idAttr) {
@@ -2963,6 +2985,7 @@ Fix: either (1) include ${bestKeyPreservePlaceholder} in your :${attrLabel} temp
2963
2985
  case "radio":
2964
2986
  case "grid":
2965
2987
  case "link":
2988
+ case "tab":
2966
2989
  return role;
2967
2990
  default:
2968
2991
  return void 0;
@@ -3588,7 +3611,8 @@ const STANDALONE_WRAPPER_FALLBACK_ROLES = /* @__PURE__ */ new Set([
3588
3611
  "checkbox",
3589
3612
  "toggle",
3590
3613
  "radio",
3591
- "link"
3614
+ "link",
3615
+ "tab"
3592
3616
  ]);
3593
3617
  function stripTrailingAsciiDigits(value) {
3594
3618
  let end = value.length;
@@ -7490,6 +7514,7 @@ function createTestIdTransform(componentName, componentHierarchyMap, nativeWrapp
7490
7514
  const wrapperSearchRoots = options.wrapperSearchRoots ?? [];
7491
7515
  const annotatorMetadata = options.annotatorMetadata ?? null;
7492
7516
  const crossFileKeyRegistry = options.crossFileKeyRegistry;
7517
+ const optionKeyAttribute = options.optionKeyAttribute ?? {};
7493
7518
  const safeRealpath2 = (p) => {
7494
7519
  try {
7495
7520
  return fs.existsSync(p) ? fs.realpathSync(p) : p;
@@ -7670,6 +7695,13 @@ Fix: set \`role\` explicitly in nativeWrappers (e.g. { "${element.tag}": { role:
7670
7695
  const getBestAvailableKeyInfo = () => {
7671
7696
  const parentNode = context.parent && typeof context.parent === "object" ? context.parent : null;
7672
7697
  const isDirectVForChild = parentNode?.type === NodeTypes.FOR;
7698
+ const configuredAttrName = optionKeyAttribute[componentName];
7699
+ if (configuredAttrName && configuredAttrName !== "key") {
7700
+ const bindingKeyInfo = getBindingKeyInfo(element, configuredAttrName);
7701
+ if (bindingKeyInfo) {
7702
+ return bindingKeyInfo;
7703
+ }
7704
+ }
7673
7705
  const vForKeyInfo = (isDirectVForChild ? getKeyDirectiveInfo(element) : null) || getContainedInVForDirectiveKeyInfo(context, element, hierarchyMap);
7674
7706
  if (vForKeyInfo) {
7675
7707
  return vForKeyInfo;
@@ -7877,7 +7909,8 @@ Fix: remove the explicit ${attrLabel}, or change existingIdBehavior to "overwrit
7877
7909
  const rawIdentifier = getStaticAttributeContent(element, "id") || getStaticAttributeContent(element, "name");
7878
7910
  const labelText = getAssociatedLabelText(element, hierarchyMap);
7879
7911
  const { vModel, modelValue } = getModelBindingValues(element);
7880
- const bindingHint = modelValue || vModel || null;
7912
+ const valueBindingHint = nativeHtmlRole === "radio" || nativeHtmlRole === "checkbox" ? getBindingValueHint(element) : null;
7913
+ const bindingHint = modelValue || vModel || valueBindingHint || null;
7881
7914
  const labelToken = labelText ? toPascalCase(labelText) : "";
7882
7915
  const bindingToken = bindingHint ? toPascalCase(bindingHint) : "";
7883
7916
  let identifierToken = null;
@@ -7975,7 +8008,7 @@ Fix: remove the explicit ${attrLabel}, or change existingIdBehavior to "overwrit
7975
8008
  }
7976
8009
  if (existingElementDataTestId) {
7977
8010
  const inferredRole = getNativeRoleFromTagSuffix().toLowerCase();
7978
- const isRecognizedInteractiveRole = inferredRole === "button" || inferredRole === "input" || inferredRole === "select" || inferredRole === "vselect" || inferredRole === "checkbox" || inferredRole === "toggle" || inferredRole === "radio" || inferredRole === "grid" || inferredRole === "link" || isComponentLikeTag(element.tag);
8011
+ const isRecognizedInteractiveRole = inferredRole === "button" || inferredRole === "input" || inferredRole === "select" || inferredRole === "vselect" || inferredRole === "checkbox" || inferredRole === "toggle" || inferredRole === "radio" || inferredRole === "grid" || inferredRole === "link" || inferredRole === "tab" || isComponentLikeTag(element.tag);
7979
8012
  if (!isRecognizedInteractiveRole) {
7980
8013
  return;
7981
8014
  }
@@ -8048,6 +8081,7 @@ function createBuildProcessorPlugin(options) {
8048
8081
  generation,
8049
8082
  projectRootRef,
8050
8083
  nativeWrappers,
8084
+ optionKeyAttribute,
8051
8085
  excludedComponents,
8052
8086
  getWrapperSearchRoots,
8053
8087
  getResolvedRouterEntry,
@@ -8180,7 +8214,8 @@ function createBuildProcessorPlugin(options) {
8180
8214
  warn: (message) => loggerRef.current.warn(message),
8181
8215
  vueFilesPathMap,
8182
8216
  wrapperSearchRoots: getWrapperSearchRoots(),
8183
- crossFileKeyRegistry
8217
+ crossFileKeyRegistry,
8218
+ optionKeyAttribute
8184
8219
  }
8185
8220
  )
8186
8221
  ]
@@ -8299,6 +8334,7 @@ function createBuildProcessorPlugin(options) {
8299
8334
  function createDevProcessorPlugin(options) {
8300
8335
  const {
8301
8336
  nativeWrappers,
8337
+ optionKeyAttribute,
8302
8338
  excludedComponents,
8303
8339
  getPageDirs,
8304
8340
  getComponentDirs,
@@ -8532,7 +8568,8 @@ function createDevProcessorPlugin(options) {
8532
8568
  warn: (message) => loggerRef.current.warn(message),
8533
8569
  vueFilesPathMap: provisionalVuePathMap,
8534
8570
  wrapperSearchRoots: getWrapperSearchRoots(),
8535
- crossFileKeyRegistry: provisionalKeyRegistry
8571
+ crossFileKeyRegistry: provisionalKeyRegistry,
8572
+ optionKeyAttribute
8536
8573
  }
8537
8574
  )
8538
8575
  ]
@@ -9063,6 +9100,7 @@ function createInternalPlugins(options) {
9063
9100
  elementMetadata,
9064
9101
  vueFilesPathMap,
9065
9102
  nativeWrappers,
9103
+ optionKeyAttribute,
9066
9104
  excludedComponents,
9067
9105
  getPageDirs,
9068
9106
  getComponentDirs,
@@ -9113,6 +9151,7 @@ function createInternalPlugins(options) {
9113
9151
  generation,
9114
9152
  projectRootRef,
9115
9153
  nativeWrappers,
9154
+ optionKeyAttribute,
9116
9155
  excludedComponents,
9117
9156
  getWrapperSearchRoots,
9118
9157
  getResolvedRouterEntry: resolveRouterEntry2,
@@ -9120,6 +9159,7 @@ function createInternalPlugins(options) {
9120
9159
  });
9121
9160
  const devProcessor = createDevProcessorPlugin({
9122
9161
  nativeWrappers,
9162
+ optionKeyAttribute,
9123
9163
  excludedComponents,
9124
9164
  getPageDirs,
9125
9165
  getComponentDirs,
@@ -9324,6 +9364,7 @@ function createVuePluginWithTestIds(options) {
9324
9364
  nameCollisionBehavior,
9325
9365
  missingSemanticNameBehavior = "error",
9326
9366
  nativeWrappers,
9367
+ optionKeyAttribute,
9327
9368
  elementMetadata,
9328
9369
  semanticNameMap,
9329
9370
  componentHierarchyMap,
@@ -9398,7 +9439,8 @@ function createVuePluginWithTestIds(options) {
9398
9439
  vueFilesPathMap,
9399
9440
  wrapperSearchRoots: getWrapperSearchRoots(),
9400
9441
  annotatorMetadata,
9401
- crossFileKeyRegistry
9442
+ crossFileKeyRegistry,
9443
+ optionKeyAttribute
9402
9444
  }
9403
9445
  )
9404
9446
  );
@@ -9455,7 +9497,8 @@ function createVuePluginWithTestIds(options) {
9455
9497
  vueFilesPathMap,
9456
9498
  wrapperSearchRoots: getWrapperSearchRoots(),
9457
9499
  annotatorMetadata,
9458
- crossFileKeyRegistry
9500
+ crossFileKeyRegistry,
9501
+ optionKeyAttribute
9459
9502
  }
9460
9503
  );
9461
9504
  perFileTransform.set(componentName, transform);
@@ -9792,6 +9835,7 @@ function createVuePomGeneratorPlugins(options = {}) {
9792
9835
  layoutDirs: injection.layoutDirs,
9793
9836
  wrapperSearchRoots: injection.wrapperSearchRoots,
9794
9837
  nativeWrappers: injection.nativeWrappers,
9838
+ optionKeyAttribute: injection.optionKeyAttribute,
9795
9839
  excludedComponents: injection.excludeComponents,
9796
9840
  existingIdBehavior: injection.existingIdBehavior,
9797
9841
  testIdAttribute: injection.attribute
@@ -9799,6 +9843,7 @@ function createVuePomGeneratorPlugins(options = {}) {
9799
9843
  };
9800
9844
  const resolvedInjectionOptions = resolvedInjectionOptionsRef.current;
9801
9845
  const nativeWrappers = resolvedInjectionOptions.nativeWrappers;
9846
+ const optionKeyAttribute = resolvedInjectionOptions.optionKeyAttribute;
9802
9847
  const excludedComponents = resolvedInjectionOptions.excludedComponents;
9803
9848
  const testIdAttribute = resolvedInjectionOptions.testIdAttribute;
9804
9849
  const routerEntry = !isNuxt ? vueGenerationOptions?.router?.entry : void 0;
@@ -9921,6 +9966,7 @@ function createVuePomGeneratorPlugins(options = {}) {
9921
9966
  nameCollisionBehavior: resolvedGenerationOptions.nameCollisionBehavior,
9922
9967
  missingSemanticNameBehavior: resolvedGenerationOptions.missingSemanticNameBehavior,
9923
9968
  nativeWrappers,
9969
+ optionKeyAttribute,
9924
9970
  elementMetadata,
9925
9971
  semanticNameMap,
9926
9972
  componentHierarchyMap,
@@ -9946,6 +9992,7 @@ function createVuePomGeneratorPlugins(options = {}) {
9946
9992
  elementMetadata,
9947
9993
  vueFilesPathMap,
9948
9994
  nativeWrappers,
9995
+ optionKeyAttribute,
9949
9996
  excludedComponents,
9950
9997
  getPageDirs,
9951
9998
  getComponentDirs,