@xsolla/xui-context-menu 0.196.0 → 0.197.0

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/native/index.mjs CHANGED
@@ -240,6 +240,23 @@ var sizeToVariants = {
240
240
  var sizeLabelOverride = {
241
241
  xl: { fontSize: 20, lineHeight: "26px" }
242
242
  };
243
+ var labelLineMetrics = {
244
+ bodyLg: { token: "body-lg", scaleStep: "175", lineHeight: "24px" },
245
+ bodyMd: { token: "body-md", scaleStep: "150", lineHeight: "20px" },
246
+ bodySm: { token: "body-sm", scaleStep: "125", lineHeight: "18px" },
247
+ bodyXs: { token: "body-xs", scaleStep: "100", lineHeight: "16px" }
248
+ };
249
+ var toCssLength = (value) => typeof value === "number" ? `${value}px` : value;
250
+ var resolveLabelLineHeight = (theme, size, variant, responsive) => {
251
+ const override = sizeLabelOverride[size];
252
+ if (override) return override.lineHeight;
253
+ const metrics = labelLineMetrics[variant];
254
+ const token = theme?.typographyTokens?.basic?.[metrics.token];
255
+ const lineHeight = toCssLength(token?.lineHeight ?? metrics.lineHeight);
256
+ if (!responsive) return lineHeight;
257
+ const step = token?.scaleStep ?? metrics.scaleStep;
258
+ return `var(--xui-lh-compact-${step}, ${lineHeight})`;
259
+ };
243
260
  var SUBMENU_GAP = 8;
244
261
  var SUBMENU_VIEWPORT_PADDING = 8;
245
262
  var clipsOverflow = (style) => {
@@ -325,6 +342,7 @@ var OptionCell = ({
325
342
  leadingControl,
326
343
  leadingIcon,
327
344
  status,
345
+ statusTopAlignment = true,
328
346
  iconWrapper,
329
347
  slot,
330
348
  slotContent,
@@ -341,16 +359,24 @@ var OptionCell = ({
341
359
  themeProductContext,
342
360
  "data-testid": testId
343
361
  }) => {
344
- const { theme: rawTheme } = useResolvedTheme({
362
+ const resolvedTheme = useResolvedTheme({
345
363
  themeMode,
346
364
  themeProductContext
347
365
  });
366
+ const { theme: rawTheme } = resolvedTheme;
367
+ const responsive = resolvedTheme.responsive ?? true;
348
368
  const theme = rawTheme;
349
369
  const overlayLayer = useOverlayLayer();
350
370
  const ctx = useContextMenu();
351
371
  const size = propSize ?? ctx?.size ?? "md";
352
372
  const sizing = theme.sizing.contextMenu(size);
353
373
  const variants = sizeToVariants[size];
374
+ const labelLineHeight = resolveLabelLineHeight(
375
+ theme,
376
+ size,
377
+ variants.label,
378
+ responsive
379
+ );
354
380
  const id = useId();
355
381
  const registerCell = ctx?.registerCell;
356
382
  const unregisterCell = ctx?.unregisterCell;
@@ -612,7 +638,25 @@ var OptionCell = ({
612
638
  }
613
639
  ),
614
640
  leadingIcon,
615
- status,
641
+ status != null && /* @__PURE__ */ jsx2(
642
+ "span",
643
+ {
644
+ "data-testid": "ctxmenu-status",
645
+ "data-status-alignment": statusTopAlignment ? "top" : "center",
646
+ style: {
647
+ display: "inline-flex",
648
+ alignItems: "center",
649
+ flexShrink: 0,
650
+ // Top alignment pins the slot to the top of the row and gives it
651
+ // the height of one label line, so the dot centres on the FIRST
652
+ // line and stays there when the label wraps or a `description`
653
+ // pushes the row taller. Without it the row's `alignItems:center`
654
+ // floats the dot to the middle of a multi-line cell.
655
+ ...statusTopAlignment ? { alignSelf: "flex-start", minHeight: labelLineHeight } : {}
656
+ },
657
+ children: status
658
+ }
659
+ ),
616
660
  iconWrapper,
617
661
  slot,
618
662
  slotContent,