@immense/vue-pom-generator 1.0.99 → 1.0.100

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
@@ -8687,6 +8687,24 @@ function getStaticAttributeContent(element, name) {
8687
8687
  function getNativeHtmlControlRole(element) {
8688
8688
  return getElementControlRole(element);
8689
8689
  }
8690
+ function getConventionalOptionIdentityAttribute(element) {
8691
+ const explicitRole = getStaticAttributeContent(element, "role")?.toLowerCase();
8692
+ if (explicitRole === "option") {
8693
+ return "data-value";
8694
+ }
8695
+ if (explicitRole === "radio") {
8696
+ return "value";
8697
+ }
8698
+ const tag = element.tag.toLowerCase();
8699
+ const type = getStaticAttributeContent(element, "type")?.toLowerCase();
8700
+ if ((tag === "input" || tag === "uinput") && type === "radio") {
8701
+ return "value";
8702
+ }
8703
+ return null;
8704
+ }
8705
+ function describeConventionalOption(element) {
8706
+ return getConventionalOptionIdentityAttribute(element) === "value" ? "radio" : `<${element.tag} role="option">`;
8707
+ }
8690
8708
  function normalizeControlLabelText(value) {
8691
8709
  const normalized = (value ?? "").replace(/\*/g, " ").replace(/\s+/g, " ").trim();
8692
8710
  return normalized || null;
@@ -9241,15 +9259,55 @@ Fix: set \`role\` explicitly in nativeWrappers (e.g. { "${element.tag}": { role:
9241
9259
  const getBestAvailableKeyInfo = () => {
9242
9260
  const parentNode = context.parent && typeof context.parent === "object" ? context.parent : null;
9243
9261
  const isDirectVForChild = parentNode?.type === NodeTypes.FOR;
9244
- const configuredAttrName = optionKeyAttribute[componentName];
9262
+ const isInVForScope = isDirectVForChild || context.scopes.vFor > 0;
9263
+ const vForKeyInfo = (isDirectVForChild ? getKeyDirectiveInfo(element) : null) || getContainedInVForDirectiveKeyInfo(context, element, hierarchyMap);
9264
+ const conventionalIdentityAttribute = getConventionalOptionIdentityAttribute(element);
9265
+ const configuredAttrName = optionKeyAttribute[componentName]?.trim();
9266
+ if (configuredAttrName === "key") {
9267
+ if (vForKeyInfo) {
9268
+ return vForKeyInfo;
9269
+ }
9270
+ if (isInVForScope && conventionalIdentityAttribute) {
9271
+ const loc = element.loc.start;
9272
+ throw new Error(
9273
+ `[vue-pom-generator] optionKeyAttribute maps ${componentName} to "key", but repeated ${describeConventionalOption(element)} has no resolvable v-for :key.
9274
+ File: ${context.filename ?? "unknown"}:${loc.line}:${loc.column}
9275
+
9276
+ Fix: bind :key on the repeated option or remove the override to use the conventional :${conventionalIdentityAttribute} identity.`
9277
+ );
9278
+ }
9279
+ }
9245
9280
  if (configuredAttrName && configuredAttrName !== "key") {
9246
9281
  const bindingKeyInfo = getBindingKeyInfo(element, configuredAttrName);
9247
9282
  if (bindingKeyInfo) {
9248
9283
  selectorParameterName = configuredAttrName === "value" ? "value" : "key";
9249
9284
  return bindingKeyInfo;
9250
9285
  }
9286
+ if (isInVForScope && conventionalIdentityAttribute) {
9287
+ const loc = element.loc.start;
9288
+ throw new Error(
9289
+ `[vue-pom-generator] optionKeyAttribute maps ${componentName} to "${configuredAttrName}", but repeated ${describeConventionalOption(element)} does not bind :${configuredAttrName}.
9290
+ File: ${context.filename ?? "unknown"}:${loc.line}:${loc.column}
9291
+
9292
+ Fix: bind :${configuredAttrName} on the option element or remove the override to use the conventional :${conventionalIdentityAttribute} identity.`
9293
+ );
9294
+ }
9295
+ }
9296
+ if (conventionalIdentityAttribute) {
9297
+ const bindingKeyInfo = getBindingKeyInfo(element, conventionalIdentityAttribute);
9298
+ if (bindingKeyInfo) {
9299
+ selectorParameterName = conventionalIdentityAttribute === "value" ? "value" : "key";
9300
+ return bindingKeyInfo;
9301
+ }
9302
+ if (isInVForScope) {
9303
+ const loc = element.loc.start;
9304
+ throw new Error(
9305
+ `[vue-pom-generator] Repeated ${describeConventionalOption(element)} must bind :${conventionalIdentityAttribute} for generated option selection.
9306
+ Component: ${componentName}
9307
+ File: ${context.filename ?? "unknown"}:${loc.line}:${loc.column}`
9308
+ );
9309
+ }
9251
9310
  }
9252
- const vForKeyInfo = (isDirectVForChild ? getKeyDirectiveInfo(element) : null) || getContainedInVForDirectiveKeyInfo(context, element, hierarchyMap);
9253
9311
  if (vForKeyInfo) {
9254
9312
  return vForKeyInfo;
9255
9313
  }