@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/README.md +28 -0
- package/native/index.d.mts +15 -0
- package/native/index.d.ts +15 -0
- package/native/index.js +46 -2
- package/native/index.js.map +1 -1
- package/native/index.mjs +46 -2
- package/native/index.mjs.map +1 -1
- package/package.json +10 -10
- package/web/index.d.mts +15 -0
- package/web/index.d.ts +15 -0
- package/web/index.js +51 -3
- package/web/index.js.map +1 -1
- package/web/index.mjs +51 -3
- package/web/index.mjs.map +1 -1
package/web/index.d.ts
CHANGED
|
@@ -42,7 +42,22 @@ interface ContextMenuOptionItemProps extends ContextMenuItemBaseProps {
|
|
|
42
42
|
description?: ReactNode;
|
|
43
43
|
leadingControl?: "checkbox" | "radio";
|
|
44
44
|
leadingIcon?: ReactNode;
|
|
45
|
+
/** Status indicator slot rendered before the label group (e.g. `<Status />`). */
|
|
45
46
|
status?: ReactNode;
|
|
47
|
+
/**
|
|
48
|
+
* Vertical placement of the `status` slot within the cell.
|
|
49
|
+
*
|
|
50
|
+
* - `true` (default) — the indicator is aligned to the **first line** of the
|
|
51
|
+
* label and stays there when the label wraps or a `description` makes the
|
|
52
|
+
* cell taller.
|
|
53
|
+
* - `false` — the indicator is centred on the full height of the cell. This
|
|
54
|
+
* restores the previous behaviour for consumers that depend on it.
|
|
55
|
+
*
|
|
56
|
+
* Has no effect when `status` is not provided.
|
|
57
|
+
*
|
|
58
|
+
* @default true
|
|
59
|
+
*/
|
|
60
|
+
statusTopAlignment?: boolean;
|
|
46
61
|
iconWrapper?: ReactNode;
|
|
47
62
|
slot?: ReactNode;
|
|
48
63
|
slotContent?: ReactNode;
|
package/web/index.js
CHANGED
|
@@ -91,7 +91,11 @@ var ADDITIONAL_BLOCKED_PROPS = /* @__PURE__ */ new Set([
|
|
|
91
91
|
"fontSize",
|
|
92
92
|
"fontWeight",
|
|
93
93
|
"fontFamily",
|
|
94
|
-
"textDecoration"
|
|
94
|
+
"textDecoration",
|
|
95
|
+
// Cross-platform layout prop that Text consumes as CSS, never as an
|
|
96
|
+
// attribute. Pinned explicitly because it is now spread into the styled
|
|
97
|
+
// component rather than destructured away before it can reach the DOM.
|
|
98
|
+
"numberOfLines"
|
|
95
99
|
]);
|
|
96
100
|
function shouldForwardProp(key) {
|
|
97
101
|
if (ADDITIONAL_BLOCKED_PROPS.has(key)) return false;
|
|
@@ -335,6 +339,23 @@ var sizeToVariants = {
|
|
|
335
339
|
var sizeLabelOverride = {
|
|
336
340
|
xl: { fontSize: 20, lineHeight: "26px" }
|
|
337
341
|
};
|
|
342
|
+
var labelLineMetrics = {
|
|
343
|
+
bodyLg: { token: "body-lg", scaleStep: "175", lineHeight: "24px" },
|
|
344
|
+
bodyMd: { token: "body-md", scaleStep: "150", lineHeight: "20px" },
|
|
345
|
+
bodySm: { token: "body-sm", scaleStep: "125", lineHeight: "18px" },
|
|
346
|
+
bodyXs: { token: "body-xs", scaleStep: "100", lineHeight: "16px" }
|
|
347
|
+
};
|
|
348
|
+
var toCssLength = (value) => typeof value === "number" ? `${value}px` : value;
|
|
349
|
+
var resolveLabelLineHeight = (theme, size, variant, responsive) => {
|
|
350
|
+
const override = sizeLabelOverride[size];
|
|
351
|
+
if (override) return override.lineHeight;
|
|
352
|
+
const metrics = labelLineMetrics[variant];
|
|
353
|
+
const token = theme?.typographyTokens?.basic?.[metrics.token];
|
|
354
|
+
const lineHeight = toCssLength(token?.lineHeight ?? metrics.lineHeight);
|
|
355
|
+
if (!responsive) return lineHeight;
|
|
356
|
+
const step = token?.scaleStep ?? metrics.scaleStep;
|
|
357
|
+
return `var(--xui-lh-compact-${step}, ${lineHeight})`;
|
|
358
|
+
};
|
|
338
359
|
var SUBMENU_GAP = 8;
|
|
339
360
|
var SUBMENU_VIEWPORT_PADDING = 8;
|
|
340
361
|
var clipsOverflow = (style) => {
|
|
@@ -420,6 +441,7 @@ var OptionCell = ({
|
|
|
420
441
|
leadingControl,
|
|
421
442
|
leadingIcon,
|
|
422
443
|
status,
|
|
444
|
+
statusTopAlignment = true,
|
|
423
445
|
iconWrapper,
|
|
424
446
|
slot,
|
|
425
447
|
slotContent,
|
|
@@ -436,16 +458,24 @@ var OptionCell = ({
|
|
|
436
458
|
themeProductContext,
|
|
437
459
|
"data-testid": testId
|
|
438
460
|
}) => {
|
|
439
|
-
const
|
|
461
|
+
const resolvedTheme = (0, import_xui_core.useResolvedTheme)({
|
|
440
462
|
themeMode,
|
|
441
463
|
themeProductContext
|
|
442
464
|
});
|
|
465
|
+
const { theme: rawTheme } = resolvedTheme;
|
|
466
|
+
const responsive = resolvedTheme.responsive ?? true;
|
|
443
467
|
const theme = rawTheme;
|
|
444
468
|
const overlayLayer = (0, import_xui_core.useOverlayLayer)();
|
|
445
469
|
const ctx = useContextMenu();
|
|
446
470
|
const size = propSize ?? ctx?.size ?? "md";
|
|
447
471
|
const sizing = theme.sizing.contextMenu(size);
|
|
448
472
|
const variants = sizeToVariants[size];
|
|
473
|
+
const labelLineHeight = resolveLabelLineHeight(
|
|
474
|
+
theme,
|
|
475
|
+
size,
|
|
476
|
+
variants.label,
|
|
477
|
+
responsive
|
|
478
|
+
);
|
|
449
479
|
const id = (0, import_xui_core.useId)();
|
|
450
480
|
const registerCell = ctx?.registerCell;
|
|
451
481
|
const unregisterCell = ctx?.unregisterCell;
|
|
@@ -707,7 +737,25 @@ var OptionCell = ({
|
|
|
707
737
|
}
|
|
708
738
|
),
|
|
709
739
|
leadingIcon,
|
|
710
|
-
status,
|
|
740
|
+
status != null && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
741
|
+
"span",
|
|
742
|
+
{
|
|
743
|
+
"data-testid": "ctxmenu-status",
|
|
744
|
+
"data-status-alignment": statusTopAlignment ? "top" : "center",
|
|
745
|
+
style: {
|
|
746
|
+
display: "inline-flex",
|
|
747
|
+
alignItems: "center",
|
|
748
|
+
flexShrink: 0,
|
|
749
|
+
// Top alignment pins the slot to the top of the row and gives it
|
|
750
|
+
// the height of one label line, so the dot centres on the FIRST
|
|
751
|
+
// line and stays there when the label wraps or a `description`
|
|
752
|
+
// pushes the row taller. Without it the row's `alignItems:center`
|
|
753
|
+
// floats the dot to the middle of a multi-line cell.
|
|
754
|
+
...statusTopAlignment ? { alignSelf: "flex-start", minHeight: labelLineHeight } : {}
|
|
755
|
+
},
|
|
756
|
+
children: status
|
|
757
|
+
}
|
|
758
|
+
),
|
|
711
759
|
iconWrapper,
|
|
712
760
|
slot,
|
|
713
761
|
slotContent,
|