@xsolla/xui-context-menu 0.196.1 → 0.197.1

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/web/index.mjs CHANGED
@@ -58,7 +58,11 @@ var ADDITIONAL_BLOCKED_PROPS = /* @__PURE__ */ new Set([
58
58
  "fontSize",
59
59
  "fontWeight",
60
60
  "fontFamily",
61
- "textDecoration"
61
+ "textDecoration",
62
+ // Cross-platform layout prop that Text consumes as CSS, never as an
63
+ // attribute. Pinned explicitly because it is now spread into the styled
64
+ // component rather than destructured away before it can reach the DOM.
65
+ "numberOfLines"
62
66
  ]);
63
67
  function shouldForwardProp(key) {
64
68
  if (ADDITIONAL_BLOCKED_PROPS.has(key)) return false;
@@ -313,6 +317,23 @@ var sizeToVariants = {
313
317
  var sizeLabelOverride = {
314
318
  xl: { fontSize: 20, lineHeight: "26px" }
315
319
  };
320
+ var labelLineMetrics = {
321
+ bodyLg: { token: "body-lg", scaleStep: "175", lineHeight: "24px" },
322
+ bodyMd: { token: "body-md", scaleStep: "150", lineHeight: "20px" },
323
+ bodySm: { token: "body-sm", scaleStep: "125", lineHeight: "18px" },
324
+ bodyXs: { token: "body-xs", scaleStep: "100", lineHeight: "16px" }
325
+ };
326
+ var toCssLength = (value) => typeof value === "number" ? `${value}px` : value;
327
+ var resolveLabelLineHeight = (theme, size, variant, responsive) => {
328
+ const override = sizeLabelOverride[size];
329
+ if (override) return override.lineHeight;
330
+ const metrics = labelLineMetrics[variant];
331
+ const token = theme?.typographyTokens?.basic?.[metrics.token];
332
+ const lineHeight = toCssLength(token?.lineHeight ?? metrics.lineHeight);
333
+ if (!responsive) return lineHeight;
334
+ const step = token?.scaleStep ?? metrics.scaleStep;
335
+ return `var(--xui-lh-compact-${step}, ${lineHeight})`;
336
+ };
316
337
  var SUBMENU_GAP = 8;
317
338
  var SUBMENU_VIEWPORT_PADDING = 8;
318
339
  var clipsOverflow = (style) => {
@@ -398,6 +419,7 @@ var OptionCell = ({
398
419
  leadingControl,
399
420
  leadingIcon,
400
421
  status,
422
+ statusTopAlignment = true,
401
423
  iconWrapper,
402
424
  slot,
403
425
  slotContent,
@@ -414,16 +436,24 @@ var OptionCell = ({
414
436
  themeProductContext,
415
437
  "data-testid": testId
416
438
  }) => {
417
- const { theme: rawTheme } = useResolvedTheme({
439
+ const resolvedTheme = useResolvedTheme({
418
440
  themeMode,
419
441
  themeProductContext
420
442
  });
443
+ const { theme: rawTheme } = resolvedTheme;
444
+ const responsive = resolvedTheme.responsive ?? true;
421
445
  const theme = rawTheme;
422
446
  const overlayLayer = useOverlayLayer();
423
447
  const ctx = useContextMenu();
424
448
  const size = propSize ?? ctx?.size ?? "md";
425
449
  const sizing = theme.sizing.contextMenu(size);
426
450
  const variants = sizeToVariants[size];
451
+ const labelLineHeight = resolveLabelLineHeight(
452
+ theme,
453
+ size,
454
+ variants.label,
455
+ responsive
456
+ );
427
457
  const id = useId();
428
458
  const registerCell = ctx?.registerCell;
429
459
  const unregisterCell = ctx?.unregisterCell;
@@ -685,7 +715,25 @@ var OptionCell = ({
685
715
  }
686
716
  ),
687
717
  leadingIcon,
688
- status,
718
+ status != null && /* @__PURE__ */ jsx2(
719
+ "span",
720
+ {
721
+ "data-testid": "ctxmenu-status",
722
+ "data-status-alignment": statusTopAlignment ? "top" : "center",
723
+ style: {
724
+ display: "inline-flex",
725
+ alignItems: "center",
726
+ flexShrink: 0,
727
+ // Top alignment pins the slot to the top of the row and gives it
728
+ // the height of one label line, so the dot centres on the FIRST
729
+ // line and stays there when the label wraps or a `description`
730
+ // pushes the row taller. Without it the row's `alignItems:center`
731
+ // floats the dot to the middle of a multi-line cell.
732
+ ...statusTopAlignment ? { alignSelf: "flex-start", minHeight: labelLineHeight } : {}
733
+ },
734
+ children: status
735
+ }
736
+ ),
689
737
  iconWrapper,
690
738
  slot,
691
739
  slotContent,