veo-sdk 0.5.0 → 0.5.2

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.
@@ -285,6 +285,33 @@ function buildStepContent(step, doc, callbacks) {
285
285
  container.appendChild(createCloseButton(doc, () => callbacks.onDismiss()));
286
286
  return container;
287
287
  }
288
+ function buildContentNodes(step, doc) {
289
+ const blocks = normalizeBlocks(step);
290
+ if (blocks) {
291
+ return blocks.filter((b) => b.type !== "button").map((b) => buildContentBlock(b, doc)).filter((n) => n !== null);
292
+ }
293
+ const nodes = [];
294
+ if (typeof step.imageUrl === "string" && step.imageUrl && isSafeUrl(step.imageUrl)) {
295
+ const img = doc.createElement("img");
296
+ img.className = "veo-guide-image";
297
+ img.src = step.imageUrl;
298
+ img.alt = typeof step.title === "string" ? step.title : "";
299
+ nodes.push(img);
300
+ }
301
+ if (typeof step.title === "string" && step.title) {
302
+ const heading = doc.createElement("h2");
303
+ heading.className = "veo-guide-title";
304
+ heading.textContent = step.title;
305
+ nodes.push(heading);
306
+ }
307
+ if (typeof step.content === "string" && step.content) {
308
+ const paragraph = doc.createElement("p");
309
+ paragraph.className = "veo-guide-text";
310
+ paragraph.textContent = step.content;
311
+ nodes.push(paragraph);
312
+ }
313
+ return nodes;
314
+ }
288
315
  function renderLegacyStep(container, step, doc, callbacks) {
289
316
  if (typeof step.imageUrl === "string" && step.imageUrl && isSafeUrl(step.imageUrl)) {
290
317
  const img = doc.createElement("img");
@@ -850,6 +877,18 @@ var GUIDE_STYLES = `
850
877
  .veo-guide-text em { font-style: italic; }
851
878
  .veo-guide-text u { text-decoration: underline; }
852
879
  .veo-guide-text s { text-decoration: line-through; }
880
+ /*
881
+ * El \xDALTIMO bloque de contenido no deja su margin-bottom colgando: ese margen
882
+ * existe para separar del bloque SIGUIENTE, y sin siguiente se suma al padding
883
+ * de la tarjeta y parece un "hueco fantasma" (p.ej. quitar el bot\xF3n de un
884
+ * tooltip dejaba el espacio como si siguiera ah\xED). El pen\xFAltimo hijo es el
885
+ * \xFAltimo bloque real (el \u2715 de cerrar siempre va \xFAltimo y es absoluto). La
886
+ * mayor especificidad le gana a las reglas por clase, pero NO a un margen
887
+ * inline elegido expl\xEDcitamente por el autor (block.style.marginBottom).
888
+ */
889
+ .veo-guide-content > :nth-last-child(2) {
890
+ margin-bottom: 0;
891
+ }
853
892
  .veo-guide-actions {
854
893
  display: flex; gap: 8px; justify-content: var(--veo-actions-justify);
855
894
  }
@@ -1016,10 +1055,22 @@ var GUIDE_STYLES = `
1016
1055
  padding: 3px 9px;
1017
1056
  white-space: nowrap;
1018
1057
  }
1058
+ .veo-badge--text {
1059
+ color: var(--veo-primary);
1060
+ font-weight: 600;
1061
+ white-space: nowrap;
1062
+ text-decoration: underline dotted;
1063
+ text-underline-offset: 3px;
1064
+ }
1019
1065
  .veo-badge--image img { display: block; border-radius: 4px; object-fit: cover; }
1020
1066
  /* El tooltip del badge usa strategy fixed (el host vive dentro del flujo del
1021
- cliente; un absoluto se recortar\xEDa con overflow de ancestros). */
1022
- .veo-badge-tooltip { position: fixed; }
1067
+ cliente; un absoluto se recortar\xEDa con overflow de ancestros). Su ancho es
1068
+ personalizable v\xEDa var dedicada (--veo-width no sirve: el :host la define
1069
+ en 420px siempre y pisar\xEDa el default de 300px de los tooltips). */
1070
+ .veo-badge-tooltip {
1071
+ position: fixed;
1072
+ max-width: var(--veo-badge-tip-width, 300px);
1073
+ }
1023
1074
  @keyframes veo-badge-pulse {
1024
1075
  0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--veo-primary) 45%, transparent); }
1025
1076
  70% { box-shadow: 0 0 0 7px transparent; }
@@ -1203,6 +1254,13 @@ var BadgeRenderer = class extends BaseRenderer {
1203
1254
  const { host, root } = this.createHost();
1204
1255
  const ownerDocument = root.ownerDocument ?? document;
1205
1256
  this.applyDesign(step.style);
1257
+ const tipWidth = step.style?.width;
1258
+ if (typeof tipWidth === "number" && Number.isFinite(tipWidth)) {
1259
+ host.style.setProperty(
1260
+ "--veo-badge-tip-width",
1261
+ `${Math.min(720, Math.max(220, tipWidth))}px`
1262
+ );
1263
+ }
1206
1264
  this.trigger = step.style?.badgeTrigger === "click" ? "click" : "hover";
1207
1265
  const rawSide = step.style?.tooltipPlacement;
1208
1266
  this.side = rawSide === "bottom" || rawSide === "left" || rawSide === "right" ? rawSide : "top";
@@ -1229,18 +1287,11 @@ var BadgeRenderer = class extends BaseRenderer {
1229
1287
  onCtaClick: (action, target, meta) => {
1230
1288
  emit("cta_clicked", meta);
1231
1289
  if (action === "url" && target) window.open(target, "_blank", "noopener,noreferrer");
1232
- if (action === "dismiss") {
1233
- emit("dismissed");
1234
- context.onClose();
1235
- return;
1236
- }
1237
1290
  this.closeTooltip();
1238
1291
  if (action === "guide" && target) context.onOpenGuide?.(target);
1239
1292
  },
1240
- onDismiss: () => {
1241
- emit("dismissed");
1242
- context.onClose();
1243
- }
1293
+ // La ✕ también cierra solo el tooltip (nunca el badge, nunca dismissed).
1294
+ onDismiss: () => this.closeTooltip()
1244
1295
  });
1245
1296
  const content = buildTooltipContent(step);
1246
1297
  tooltip.appendChild(content);
@@ -1371,7 +1422,7 @@ function readBadgeConfig(step) {
1371
1422
  const raw = step.style?.badge;
1372
1423
  if (!raw || typeof raw !== "object") return { kind: "icon" };
1373
1424
  const b = raw;
1374
- const kind = b.kind === "dot" || b.kind === "pill" || b.kind === "image" || b.kind === "icon" ? b.kind : "icon";
1425
+ const kind = b.kind === "dot" || b.kind === "pill" || b.kind === "text" || b.kind === "image" || b.kind === "icon" ? b.kind : "icon";
1375
1426
  return {
1376
1427
  kind,
1377
1428
  icon: typeof b.icon === "string" ? b.icon : null,
@@ -1402,6 +1453,12 @@ function buildBadgeElement(config, doc) {
1402
1453
  if (config.color) btn.style.background = config.color;
1403
1454
  break;
1404
1455
  }
1456
+ case "text": {
1457
+ btn.textContent = config.text?.slice(0, 32) || "Nuevo";
1458
+ btn.style.fontSize = `${clamp2(Math.round(size * 0.7), 9, 28)}px`;
1459
+ if (config.color) btn.style.color = config.color;
1460
+ break;
1461
+ }
1405
1462
  case "image": {
1406
1463
  if (config.imageUrl && isSafeUrl(config.imageUrl)) {
1407
1464
  const img = doc.createElement("img");
@@ -1449,24 +1506,8 @@ function buildWalkthroughStepContent(step, stepIndex, totalSteps, doc, callbacks
1449
1506
  progress.appendChild(dot);
1450
1507
  }
1451
1508
  container.appendChild(progress);
1452
- if (typeof step.imageUrl === "string" && step.imageUrl && isSafeUrl(step.imageUrl)) {
1453
- const img = doc.createElement("img");
1454
- img.className = "veo-guide-image";
1455
- img.src = step.imageUrl;
1456
- img.alt = typeof step.title === "string" ? step.title : "";
1457
- container.appendChild(img);
1458
- }
1459
- if (typeof step.title === "string" && step.title) {
1460
- const heading = doc.createElement("h2");
1461
- heading.className = "veo-guide-title";
1462
- heading.textContent = step.title;
1463
- container.appendChild(heading);
1464
- }
1465
- if (typeof step.content === "string" && step.content) {
1466
- const paragraph = doc.createElement("p");
1467
- paragraph.className = "veo-guide-text";
1468
- paragraph.textContent = step.content;
1469
- container.appendChild(paragraph);
1509
+ for (const node of buildContentNodes(step, doc)) {
1510
+ container.appendChild(node);
1470
1511
  }
1471
1512
  const actions = doc.createElement("div");
1472
1513
  actions.className = "veo-walkthrough-actions";
@@ -2790,5 +2831,5 @@ function buildSelectorPath(element, maxAncestors = 5) {
2790
2831
  }
2791
2832
 
2792
2833
  export { ALWAYS_BLOCK_SELECTORS, BadgeRenderer, BannerRenderer, CustomRenderer, DEFAULT_AUTOCAPTURE_CONFIG, DEFAULT_TRACKER_BATCH_SIZE, DEFAULT_TRACKER_FLUSH_INTERVAL_MS, DEFAULT_TRACKER_MAX_RETRIES, FREQUENCY_CACHE_KEY_PREFIX, FREQUENCY_CACHE_MAX_ENTRIES, FREQUENCY_CACHE_TTL_MS, FormRenderer, InlineCustomRenderer, InlineFormRenderer, InlineRenderer, MAX_ANCESTORS, ModalRenderer, PRIORITY_ATTRIBUTES, SENSITIVE_ATTRIBUTES, TooltipRenderer, WALKTHROUGH_ABANDONMENT_TIMEOUT_MS, WALKTHROUGH_STATE_KEY_PREFIX, WalkthroughRenderer, buildSelectorPath, clearBuilderToken, closeGuidePreview, filterHumanClasses, hasDocument, hasLocalStorage, hasNavigatorSendBeacon, hasWindow, isBuilderMode, previewGuide, resolveBuilderContext, resolveBuilderToken, uuidv7 };
2793
- //# sourceMappingURL=chunk-UJTSYDQ6.mjs.map
2794
- //# sourceMappingURL=chunk-UJTSYDQ6.mjs.map
2834
+ //# sourceMappingURL=chunk-5QI3UUE5.mjs.map
2835
+ //# sourceMappingURL=chunk-5QI3UUE5.mjs.map