@xsolla/xui-context-menu 0.136.0 → 0.138.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/package.json +8 -8
- package/web/index.js +151 -73
- package/web/index.js.map +1 -1
- package/web/index.mjs +99 -21
- package/web/index.mjs.map +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xsolla/xui-context-menu",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.138.0",
|
|
4
4
|
"main": "./web/index.js",
|
|
5
5
|
"module": "./web/index.mjs",
|
|
6
6
|
"types": "./web/index.d.ts",
|
|
@@ -13,13 +13,13 @@
|
|
|
13
13
|
"test:coverage": "vitest run --coverage"
|
|
14
14
|
},
|
|
15
15
|
"dependencies": {
|
|
16
|
-
"@xsolla/xui-checkbox": "0.
|
|
17
|
-
"@xsolla/xui-core": "0.
|
|
18
|
-
"@xsolla/xui-divider": "0.
|
|
19
|
-
"@xsolla/xui-icons": "0.
|
|
20
|
-
"@xsolla/xui-primitives-core": "0.
|
|
21
|
-
"@xsolla/xui-radio": "0.
|
|
22
|
-
"@xsolla/xui-spinner": "0.
|
|
16
|
+
"@xsolla/xui-checkbox": "0.138.0",
|
|
17
|
+
"@xsolla/xui-core": "0.138.0",
|
|
18
|
+
"@xsolla/xui-divider": "0.138.0",
|
|
19
|
+
"@xsolla/xui-icons": "0.138.0",
|
|
20
|
+
"@xsolla/xui-primitives-core": "0.138.0",
|
|
21
|
+
"@xsolla/xui-radio": "0.138.0",
|
|
22
|
+
"@xsolla/xui-spinner": "0.138.0"
|
|
23
23
|
},
|
|
24
24
|
"peerDependencies": {
|
|
25
25
|
"react": ">=16.8.0",
|
package/web/index.js
CHANGED
|
@@ -47,13 +47,85 @@ __export(index_exports, {
|
|
|
47
47
|
module.exports = __toCommonJS(index_exports);
|
|
48
48
|
|
|
49
49
|
// src/ContextMenu.tsx
|
|
50
|
-
var
|
|
50
|
+
var import_react11 = __toESM(require("react"));
|
|
51
51
|
|
|
52
52
|
// ../primitives-web/src/Box.tsx
|
|
53
|
-
var
|
|
53
|
+
var import_react2 = __toESM(require("react"));
|
|
54
54
|
var import_styled_components = __toESM(require("styled-components"));
|
|
55
|
+
|
|
56
|
+
// ../primitives-web/src/filterDOMProps.ts
|
|
57
|
+
var import_react = __toESM(require("react"));
|
|
58
|
+
|
|
59
|
+
// ../../node_modules/@emotion/memoize/dist/memoize.esm.js
|
|
60
|
+
function memoize(fn) {
|
|
61
|
+
var cache = {};
|
|
62
|
+
return function(arg) {
|
|
63
|
+
if (cache[arg] === void 0) cache[arg] = fn(arg);
|
|
64
|
+
return cache[arg];
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
var memoize_esm_default = memoize;
|
|
68
|
+
|
|
69
|
+
// ../../node_modules/@emotion/is-prop-valid/dist/is-prop-valid.esm.js
|
|
70
|
+
var reactPropsRegex = /^((children|dangerouslySetInnerHTML|key|ref|autoFocus|defaultValue|defaultChecked|innerHTML|suppressContentEditableWarning|suppressHydrationWarning|valueLink|accept|acceptCharset|accessKey|action|allow|allowUserMedia|allowPaymentRequest|allowFullScreen|allowTransparency|alt|async|autoComplete|autoPlay|capture|cellPadding|cellSpacing|challenge|charSet|checked|cite|classID|className|cols|colSpan|content|contentEditable|contextMenu|controls|controlsList|coords|crossOrigin|data|dateTime|decoding|default|defer|dir|disabled|disablePictureInPicture|download|draggable|encType|form|formAction|formEncType|formMethod|formNoValidate|formTarget|frameBorder|headers|height|hidden|high|href|hrefLang|htmlFor|httpEquiv|id|inputMode|integrity|is|keyParams|keyType|kind|label|lang|list|loading|loop|low|marginHeight|marginWidth|max|maxLength|media|mediaGroup|method|min|minLength|multiple|muted|name|nonce|noValidate|open|optimum|pattern|placeholder|playsInline|poster|preload|profile|radioGroup|readOnly|referrerPolicy|rel|required|reversed|role|rows|rowSpan|sandbox|scope|scoped|scrolling|seamless|selected|shape|size|sizes|slot|span|spellCheck|src|srcDoc|srcLang|srcSet|start|step|style|summary|tabIndex|target|title|type|useMap|value|width|wmode|wrap|about|datatype|inlist|prefix|property|resource|typeof|vocab|autoCapitalize|autoCorrect|autoSave|color|inert|itemProp|itemScope|itemType|itemID|itemRef|on|results|security|unselectable|accentHeight|accumulate|additive|alignmentBaseline|allowReorder|alphabetic|amplitude|arabicForm|ascent|attributeName|attributeType|autoReverse|azimuth|baseFrequency|baselineShift|baseProfile|bbox|begin|bias|by|calcMode|capHeight|clip|clipPathUnits|clipPath|clipRule|colorInterpolation|colorInterpolationFilters|colorProfile|colorRendering|contentScriptType|contentStyleType|cursor|cx|cy|d|decelerate|descent|diffuseConstant|direction|display|divisor|dominantBaseline|dur|dx|dy|edgeMode|elevation|enableBackground|end|exponent|externalResourcesRequired|fill|fillOpacity|fillRule|filter|filterRes|filterUnits|floodColor|floodOpacity|focusable|fontFamily|fontSize|fontSizeAdjust|fontStretch|fontStyle|fontVariant|fontWeight|format|from|fr|fx|fy|g1|g2|glyphName|glyphOrientationHorizontal|glyphOrientationVertical|glyphRef|gradientTransform|gradientUnits|hanging|horizAdvX|horizOriginX|ideographic|imageRendering|in|in2|intercept|k|k1|k2|k3|k4|kernelMatrix|kernelUnitLength|kerning|keyPoints|keySplines|keyTimes|lengthAdjust|letterSpacing|lightingColor|limitingConeAngle|local|markerEnd|markerMid|markerStart|markerHeight|markerUnits|markerWidth|mask|maskContentUnits|maskUnits|mathematical|mode|numOctaves|offset|opacity|operator|order|orient|orientation|origin|overflow|overlinePosition|overlineThickness|panose1|paintOrder|pathLength|patternContentUnits|patternTransform|patternUnits|pointerEvents|points|pointsAtX|pointsAtY|pointsAtZ|preserveAlpha|preserveAspectRatio|primitiveUnits|r|radius|refX|refY|renderingIntent|repeatCount|repeatDur|requiredExtensions|requiredFeatures|restart|result|rotate|rx|ry|scale|seed|shapeRendering|slope|spacing|specularConstant|specularExponent|speed|spreadMethod|startOffset|stdDeviation|stemh|stemv|stitchTiles|stopColor|stopOpacity|strikethroughPosition|strikethroughThickness|string|stroke|strokeDasharray|strokeDashoffset|strokeLinecap|strokeLinejoin|strokeMiterlimit|strokeOpacity|strokeWidth|surfaceScale|systemLanguage|tableValues|targetX|targetY|textAnchor|textDecoration|textRendering|textLength|to|transform|u1|u2|underlinePosition|underlineThickness|unicode|unicodeBidi|unicodeRange|unitsPerEm|vAlphabetic|vHanging|vIdeographic|vMathematical|values|vectorEffect|version|vertAdvY|vertOriginX|vertOriginY|viewBox|viewTarget|visibility|widths|wordSpacing|writingMode|x|xHeight|x1|x2|xChannelSelector|xlinkActuate|xlinkArcrole|xlinkHref|xlinkRole|xlinkShow|xlinkTitle|xlinkType|xmlBase|xmlns|xmlnsXlink|xmlLang|xmlSpace|y|y1|y2|yChannelSelector|z|zoomAndPan|for|class|autofocus)|(([Dd][Aa][Tt][Aa]|[Aa][Rr][Ii][Aa]|x)-.*))$/;
|
|
71
|
+
var index = memoize_esm_default(
|
|
72
|
+
function(prop) {
|
|
73
|
+
return reactPropsRegex.test(prop) || prop.charCodeAt(0) === 111 && prop.charCodeAt(1) === 110 && prop.charCodeAt(2) < 91;
|
|
74
|
+
}
|
|
75
|
+
/* Z+1 */
|
|
76
|
+
);
|
|
77
|
+
var is_prop_valid_esm_default = index;
|
|
78
|
+
|
|
79
|
+
// ../primitives-web/src/filterDOMProps.ts
|
|
80
|
+
var ADDITIONAL_BLOCKED_PROPS = /* @__PURE__ */ new Set([
|
|
81
|
+
// RN-only event handlers (pass isPropValid's on* pattern)
|
|
82
|
+
"onPress",
|
|
83
|
+
"onChangeText",
|
|
84
|
+
"onLayout",
|
|
85
|
+
"onMoveShouldSetResponder",
|
|
86
|
+
"onResponderGrant",
|
|
87
|
+
"onResponderMove",
|
|
88
|
+
"onResponderRelease",
|
|
89
|
+
"onResponderTerminate",
|
|
90
|
+
// SVG attributes that pass isPropValid
|
|
91
|
+
"strokeWidth",
|
|
92
|
+
// CSS properties that pass isPropValid but are used as component props
|
|
93
|
+
"overflow",
|
|
94
|
+
"cursor",
|
|
95
|
+
"fontSize",
|
|
96
|
+
"fontWeight",
|
|
97
|
+
"fontFamily",
|
|
98
|
+
"textDecoration"
|
|
99
|
+
]);
|
|
100
|
+
function shouldForwardProp(key) {
|
|
101
|
+
if (ADDITIONAL_BLOCKED_PROPS.has(key)) return false;
|
|
102
|
+
return is_prop_valid_esm_default(key);
|
|
103
|
+
}
|
|
104
|
+
function createFilteredElement(defaultTag) {
|
|
105
|
+
const Component = import_react.default.forwardRef(
|
|
106
|
+
({ children, elementType, ...props }, ref) => {
|
|
107
|
+
const Tag = elementType || defaultTag;
|
|
108
|
+
const htmlProps = {};
|
|
109
|
+
for (const key of Object.keys(props)) {
|
|
110
|
+
if (shouldForwardProp(key)) {
|
|
111
|
+
htmlProps[key] = props[key];
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
return import_react.default.createElement(
|
|
115
|
+
Tag,
|
|
116
|
+
{ ref, ...htmlProps },
|
|
117
|
+
children
|
|
118
|
+
);
|
|
119
|
+
}
|
|
120
|
+
);
|
|
121
|
+
Component.displayName = `Filtered(${defaultTag})`;
|
|
122
|
+
return Component;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
// ../primitives-web/src/Box.tsx
|
|
55
126
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
56
|
-
var
|
|
127
|
+
var FilteredDiv = createFilteredElement("div");
|
|
128
|
+
var StyledBox = (0, import_styled_components.default)(FilteredDiv)`
|
|
57
129
|
display: flex;
|
|
58
130
|
box-sizing: border-box;
|
|
59
131
|
background-color: ${(props) => props.backgroundColor || "transparent"};
|
|
@@ -140,7 +212,7 @@ var StyledBox = import_styled_components.default.div`
|
|
|
140
212
|
${(props) => props.pressStyle?.backgroundColor && `background-color: ${props.pressStyle.backgroundColor};`}
|
|
141
213
|
}
|
|
142
214
|
`;
|
|
143
|
-
var Box =
|
|
215
|
+
var Box = import_react2.default.forwardRef(
|
|
144
216
|
({
|
|
145
217
|
children,
|
|
146
218
|
onPress,
|
|
@@ -165,6 +237,8 @@ var Box = import_react.default.forwardRef(
|
|
|
165
237
|
type,
|
|
166
238
|
disabled,
|
|
167
239
|
id,
|
|
240
|
+
testID,
|
|
241
|
+
"data-testid": dataTestId,
|
|
168
242
|
...props
|
|
169
243
|
}, ref) => {
|
|
170
244
|
if (as === "img" && src) {
|
|
@@ -192,7 +266,7 @@ var Box = import_react.default.forwardRef(
|
|
|
192
266
|
StyledBox,
|
|
193
267
|
{
|
|
194
268
|
ref,
|
|
195
|
-
as,
|
|
269
|
+
elementType: as,
|
|
196
270
|
id,
|
|
197
271
|
type: as === "button" ? type || "button" : void 0,
|
|
198
272
|
disabled: as === "button" ? disabled : void 0,
|
|
@@ -212,6 +286,7 @@ var Box = import_react.default.forwardRef(
|
|
|
212
286
|
"aria-controls": ariaControls,
|
|
213
287
|
"aria-live": ariaLive,
|
|
214
288
|
tabIndex: tabIndex !== void 0 ? tabIndex : void 0,
|
|
289
|
+
"data-testid": dataTestId || testID,
|
|
215
290
|
...props,
|
|
216
291
|
children
|
|
217
292
|
}
|
|
@@ -223,7 +298,8 @@ Box.displayName = "Box";
|
|
|
223
298
|
// ../primitives-web/src/Text.tsx
|
|
224
299
|
var import_styled_components2 = __toESM(require("styled-components"));
|
|
225
300
|
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
226
|
-
var
|
|
301
|
+
var FilteredSpan = createFilteredElement("span");
|
|
302
|
+
var StyledText = (0, import_styled_components2.default)(FilteredSpan)`
|
|
227
303
|
color: ${(props) => props.color || "inherit"};
|
|
228
304
|
font-size: ${(props) => typeof props.fontSize === "number" ? `${props.fontSize}px` : props.fontSize || "inherit"};
|
|
229
305
|
font-weight: ${(props) => props.fontWeight || "normal"};
|
|
@@ -256,7 +332,8 @@ var Text = ({
|
|
|
256
332
|
// ../primitives-web/src/Icon.tsx
|
|
257
333
|
var import_styled_components3 = __toESM(require("styled-components"));
|
|
258
334
|
var import_jsx_runtime3 = require("react/jsx-runtime");
|
|
259
|
-
var
|
|
335
|
+
var FilteredDiv2 = createFilteredElement("div");
|
|
336
|
+
var StyledIcon = (0, import_styled_components3.default)(FilteredDiv2)`
|
|
260
337
|
display: flex;
|
|
261
338
|
align-items: center;
|
|
262
339
|
justify-content: center;
|
|
@@ -276,10 +353,11 @@ var Icon = ({ children, ...props }) => {
|
|
|
276
353
|
};
|
|
277
354
|
|
|
278
355
|
// ../primitives-web/src/Input.tsx
|
|
279
|
-
var
|
|
356
|
+
var import_react3 = require("react");
|
|
280
357
|
var import_styled_components4 = __toESM(require("styled-components"));
|
|
281
358
|
var import_jsx_runtime4 = require("react/jsx-runtime");
|
|
282
|
-
var
|
|
359
|
+
var FilteredInput = createFilteredElement("input");
|
|
360
|
+
var StyledInput = (0, import_styled_components4.default)(FilteredInput)`
|
|
283
361
|
background: transparent;
|
|
284
362
|
border: none;
|
|
285
363
|
outline: none;
|
|
@@ -310,7 +388,7 @@ var StyledInput = import_styled_components4.default.input`
|
|
|
310
388
|
-webkit-text-fill-color: ${(props) => props.color || "inherit"} !important;
|
|
311
389
|
}
|
|
312
390
|
`;
|
|
313
|
-
var InputPrimitive = (0,
|
|
391
|
+
var InputPrimitive = (0, import_react3.forwardRef)(
|
|
314
392
|
({
|
|
315
393
|
value,
|
|
316
394
|
placeholder,
|
|
@@ -387,14 +465,14 @@ var import_xui_core7 = require("@xsolla/xui-core");
|
|
|
387
465
|
var import_xui_spinner = require("@xsolla/xui-spinner");
|
|
388
466
|
|
|
389
467
|
// src/ContextMenuContext.tsx
|
|
390
|
-
var
|
|
391
|
-
var ContextMenuContext = (0,
|
|
468
|
+
var import_react4 = require("react");
|
|
469
|
+
var ContextMenuContext = (0, import_react4.createContext)(void 0);
|
|
392
470
|
var useContextMenu = () => {
|
|
393
|
-
const context = (0,
|
|
471
|
+
const context = (0, import_react4.useContext)(ContextMenuContext);
|
|
394
472
|
return context;
|
|
395
473
|
};
|
|
396
474
|
var useContextMenuRequired = () => {
|
|
397
|
-
const context = (0,
|
|
475
|
+
const context = (0, import_react4.useContext)(ContextMenuContext);
|
|
398
476
|
if (!context) {
|
|
399
477
|
throw new Error(
|
|
400
478
|
"useContextMenuRequired must be used within a ContextMenu component"
|
|
@@ -404,11 +482,11 @@ var useContextMenuRequired = () => {
|
|
|
404
482
|
};
|
|
405
483
|
|
|
406
484
|
// src/ContextMenuItem.tsx
|
|
407
|
-
var
|
|
485
|
+
var import_react5 = require("react");
|
|
408
486
|
var import_xui_core = require("@xsolla/xui-core");
|
|
409
487
|
var import_xui_icons = require("@xsolla/xui-icons");
|
|
410
488
|
var import_jsx_runtime5 = require("react/jsx-runtime");
|
|
411
|
-
var ContextMenuItem = (0,
|
|
489
|
+
var ContextMenuItem = (0, import_react5.forwardRef)(
|
|
412
490
|
({
|
|
413
491
|
children,
|
|
414
492
|
description,
|
|
@@ -429,10 +507,10 @@ var ContextMenuItem = (0, import_react4.forwardRef)(
|
|
|
429
507
|
const context = useContextMenu();
|
|
430
508
|
const size = propSize || context?.size || "md";
|
|
431
509
|
const sizeStyles = theme.sizing.contextMenu(size);
|
|
432
|
-
const itemRef = (0,
|
|
510
|
+
const itemRef = (0, import_react5.useRef)(null);
|
|
433
511
|
const brandColors = theme.colors.control.brand.primary;
|
|
434
512
|
const contentColors = theme.colors.content;
|
|
435
|
-
(0,
|
|
513
|
+
(0, import_react5.useEffect)(() => {
|
|
436
514
|
if (context && !disabled) {
|
|
437
515
|
const id = typeof children === "string" ? children : String(Math.random());
|
|
438
516
|
context.registerItem(id);
|
|
@@ -570,7 +648,7 @@ var ContextMenuItem = (0, import_react4.forwardRef)(
|
|
|
570
648
|
ContextMenuItem.displayName = "ContextMenuItem";
|
|
571
649
|
|
|
572
650
|
// src/ContextMenuCheckboxItem.tsx
|
|
573
|
-
var
|
|
651
|
+
var import_react6 = require("react");
|
|
574
652
|
var import_xui_core2 = require("@xsolla/xui-core");
|
|
575
653
|
var import_xui_icons2 = require("@xsolla/xui-icons");
|
|
576
654
|
var import_jsx_runtime6 = require("react/jsx-runtime");
|
|
@@ -645,7 +723,7 @@ var CheckboxIndicator = ({
|
|
|
645
723
|
}
|
|
646
724
|
);
|
|
647
725
|
};
|
|
648
|
-
var ContextMenuCheckboxItem = (0,
|
|
726
|
+
var ContextMenuCheckboxItem = (0, import_react6.forwardRef)(
|
|
649
727
|
({
|
|
650
728
|
children,
|
|
651
729
|
description,
|
|
@@ -665,8 +743,8 @@ var ContextMenuCheckboxItem = (0, import_react5.forwardRef)(
|
|
|
665
743
|
const context = useContextMenu();
|
|
666
744
|
const size = propSize || context?.size || "md";
|
|
667
745
|
const sizeStyles = theme.sizing.contextMenu(size);
|
|
668
|
-
const itemRef = (0,
|
|
669
|
-
(0,
|
|
746
|
+
const itemRef = (0, import_react6.useRef)(null);
|
|
747
|
+
(0, import_react6.useEffect)(() => {
|
|
670
748
|
if (context && !disabled) {
|
|
671
749
|
const id = typeof children === "string" ? children : String(Math.random());
|
|
672
750
|
context.registerItem(id);
|
|
@@ -779,11 +857,11 @@ var ContextMenuCheckboxItem = (0, import_react5.forwardRef)(
|
|
|
779
857
|
ContextMenuCheckboxItem.displayName = "ContextMenuCheckboxItem";
|
|
780
858
|
|
|
781
859
|
// src/ContextMenuRadioGroup.tsx
|
|
782
|
-
var
|
|
860
|
+
var import_react7 = require("react");
|
|
783
861
|
var import_jsx_runtime7 = require("react/jsx-runtime");
|
|
784
|
-
var RadioGroupContext = (0,
|
|
785
|
-
var useRadioGroup = () => (0,
|
|
786
|
-
var ContextMenuRadioGroup = (0,
|
|
862
|
+
var RadioGroupContext = (0, import_react7.createContext)(null);
|
|
863
|
+
var useRadioGroup = () => (0, import_react7.useContext)(RadioGroupContext);
|
|
864
|
+
var ContextMenuRadioGroup = (0, import_react7.forwardRef)(
|
|
787
865
|
({
|
|
788
866
|
children,
|
|
789
867
|
value,
|
|
@@ -796,7 +874,7 @@ var ContextMenuRadioGroup = (0, import_react6.forwardRef)(
|
|
|
796
874
|
ContextMenuRadioGroup.displayName = "ContextMenuRadioGroup";
|
|
797
875
|
|
|
798
876
|
// src/ContextMenuRadioItem.tsx
|
|
799
|
-
var
|
|
877
|
+
var import_react8 = require("react");
|
|
800
878
|
var import_xui_core3 = require("@xsolla/xui-core");
|
|
801
879
|
var import_jsx_runtime8 = require("react/jsx-runtime");
|
|
802
880
|
var radioSizeMap = {
|
|
@@ -862,7 +940,7 @@ var RadioIndicator = ({
|
|
|
862
940
|
}
|
|
863
941
|
);
|
|
864
942
|
};
|
|
865
|
-
var ContextMenuRadioItem = (0,
|
|
943
|
+
var ContextMenuRadioItem = (0, import_react8.forwardRef)(
|
|
866
944
|
({
|
|
867
945
|
children,
|
|
868
946
|
description,
|
|
@@ -879,9 +957,9 @@ var ContextMenuRadioItem = (0, import_react7.forwardRef)(
|
|
|
879
957
|
const radioGroup = useRadioGroup();
|
|
880
958
|
const size = propSize || context?.size || "md";
|
|
881
959
|
const sizeStyles = theme.sizing.contextMenu(size);
|
|
882
|
-
const itemRef = (0,
|
|
960
|
+
const itemRef = (0, import_react8.useRef)(null);
|
|
883
961
|
const checked = radioGroup?.value === value;
|
|
884
|
-
(0,
|
|
962
|
+
(0, import_react8.useEffect)(() => {
|
|
885
963
|
if (context && !disabled) {
|
|
886
964
|
const id = typeof children === "string" ? children : String(Math.random());
|
|
887
965
|
context.registerItem(id);
|
|
@@ -990,10 +1068,10 @@ var ContextMenuRadioItem = (0, import_react7.forwardRef)(
|
|
|
990
1068
|
ContextMenuRadioItem.displayName = "ContextMenuRadioItem";
|
|
991
1069
|
|
|
992
1070
|
// src/ContextMenuGroup.tsx
|
|
993
|
-
var
|
|
1071
|
+
var import_react9 = require("react");
|
|
994
1072
|
var import_xui_core4 = require("@xsolla/xui-core");
|
|
995
1073
|
var import_jsx_runtime9 = require("react/jsx-runtime");
|
|
996
|
-
var ContextMenuGroup = (0,
|
|
1074
|
+
var ContextMenuGroup = (0, import_react9.forwardRef)(
|
|
997
1075
|
({
|
|
998
1076
|
label,
|
|
999
1077
|
description,
|
|
@@ -1070,7 +1148,7 @@ var ContextMenuSeparator = ({
|
|
|
1070
1148
|
ContextMenuSeparator.displayName = "ContextMenuSeparator";
|
|
1071
1149
|
|
|
1072
1150
|
// src/ContextMenuSearch.tsx
|
|
1073
|
-
var
|
|
1151
|
+
var import_react10 = __toESM(require("react"));
|
|
1074
1152
|
var import_xui_core6 = require("@xsolla/xui-core");
|
|
1075
1153
|
|
|
1076
1154
|
// ../icons-base/dist/web/index.mjs
|
|
@@ -1511,7 +1589,7 @@ var Search = (props) => /* @__PURE__ */ (0, import_jsx_runtime384.jsx)(BaseIcon,
|
|
|
1511
1589
|
// src/ContextMenuSearch.tsx
|
|
1512
1590
|
var import_xui_divider = require("@xsolla/xui-divider");
|
|
1513
1591
|
var import_jsx_runtime398 = require("react/jsx-runtime");
|
|
1514
|
-
var ContextMenuSearch = (0,
|
|
1592
|
+
var ContextMenuSearch = (0, import_react10.forwardRef)(
|
|
1515
1593
|
({
|
|
1516
1594
|
value,
|
|
1517
1595
|
onChange,
|
|
@@ -1527,14 +1605,14 @@ var ContextMenuSearch = (0, import_react9.forwardRef)(
|
|
|
1527
1605
|
const context = useContextMenu();
|
|
1528
1606
|
const size = propSize || context?.size || "md";
|
|
1529
1607
|
const sizeStyles = theme.sizing.contextMenu(size);
|
|
1530
|
-
const inputRef = (0,
|
|
1608
|
+
const inputRef = (0, import_react10.useRef)(null);
|
|
1531
1609
|
const inputColors = theme.colors.control.input;
|
|
1532
|
-
|
|
1610
|
+
import_react10.default.useImperativeHandle(
|
|
1533
1611
|
ref,
|
|
1534
1612
|
() => inputRef.current,
|
|
1535
1613
|
[]
|
|
1536
1614
|
);
|
|
1537
|
-
(0,
|
|
1615
|
+
(0, import_react10.useEffect)(() => {
|
|
1538
1616
|
if (autoFocus && inputRef.current) {
|
|
1539
1617
|
setTimeout(() => {
|
|
1540
1618
|
inputRef.current?.focus();
|
|
@@ -1598,7 +1676,7 @@ ContextMenuSearch.displayName = "ContextMenuSearch";
|
|
|
1598
1676
|
|
|
1599
1677
|
// src/ContextMenu.tsx
|
|
1600
1678
|
var import_jsx_runtime399 = require("react/jsx-runtime");
|
|
1601
|
-
var ContextMenuRoot = (0,
|
|
1679
|
+
var ContextMenuRoot = (0, import_react11.forwardRef)(
|
|
1602
1680
|
({
|
|
1603
1681
|
children,
|
|
1604
1682
|
list,
|
|
@@ -1620,21 +1698,21 @@ var ContextMenuRoot = (0, import_react10.forwardRef)(
|
|
|
1620
1698
|
themeProductContext
|
|
1621
1699
|
}, ref) => {
|
|
1622
1700
|
const { theme } = (0, import_xui_core7.useResolvedTheme)({ themeMode, themeProductContext });
|
|
1623
|
-
const [internalIsOpen, setInternalIsOpen] = (0,
|
|
1624
|
-
const [activeIndex, setActiveIndex] = (0,
|
|
1625
|
-
const containerRef = (0,
|
|
1626
|
-
const menuRef = (0,
|
|
1627
|
-
const itemsRef = (0,
|
|
1701
|
+
const [internalIsOpen, setInternalIsOpen] = (0, import_react11.useState)(false);
|
|
1702
|
+
const [activeIndex, setActiveIndex] = (0, import_react11.useState)(-1);
|
|
1703
|
+
const containerRef = (0, import_react11.useRef)(null);
|
|
1704
|
+
const menuRef = (0, import_react11.useRef)(null);
|
|
1705
|
+
const itemsRef = (0, import_react11.useRef)([]);
|
|
1628
1706
|
const isOpen = propIsOpen !== void 0 ? propIsOpen : internalIsOpen;
|
|
1629
1707
|
const sizeStyles = theme.sizing.contextMenu(size);
|
|
1630
|
-
const closeMenu = (0,
|
|
1708
|
+
const closeMenu = (0, import_react11.useCallback)(() => {
|
|
1631
1709
|
if (propIsOpen === void 0) {
|
|
1632
1710
|
setInternalIsOpen(false);
|
|
1633
1711
|
}
|
|
1634
1712
|
onOpenChange?.(false);
|
|
1635
1713
|
setActiveIndex(-1);
|
|
1636
1714
|
}, [propIsOpen, onOpenChange]);
|
|
1637
|
-
const toggleMenu = (0,
|
|
1715
|
+
const toggleMenu = (0, import_react11.useCallback)(() => {
|
|
1638
1716
|
const nextOpen = !isOpen;
|
|
1639
1717
|
if (propIsOpen === void 0) {
|
|
1640
1718
|
setInternalIsOpen(nextOpen);
|
|
@@ -1644,7 +1722,7 @@ var ContextMenuRoot = (0, import_react10.forwardRef)(
|
|
|
1644
1722
|
setActiveIndex(-1);
|
|
1645
1723
|
}
|
|
1646
1724
|
}, [isOpen, propIsOpen, onOpenChange]);
|
|
1647
|
-
(0,
|
|
1725
|
+
(0, import_react11.useEffect)(() => {
|
|
1648
1726
|
const handleClickOutside = (event) => {
|
|
1649
1727
|
if (containerRef.current && !containerRef.current.contains(event.target)) {
|
|
1650
1728
|
closeMenu();
|
|
@@ -1657,7 +1735,7 @@ var ContextMenuRoot = (0, import_react10.forwardRef)(
|
|
|
1657
1735
|
document.removeEventListener("mousedown", handleClickOutside);
|
|
1658
1736
|
};
|
|
1659
1737
|
}, [isOpen, closeMenu]);
|
|
1660
|
-
(0,
|
|
1738
|
+
(0, import_react11.useEffect)(() => {
|
|
1661
1739
|
const handleEscape = (event) => {
|
|
1662
1740
|
if (event.key === "Escape") {
|
|
1663
1741
|
closeMenu();
|
|
@@ -1670,31 +1748,31 @@ var ContextMenuRoot = (0, import_react10.forwardRef)(
|
|
|
1670
1748
|
document.removeEventListener("keydown", handleEscape);
|
|
1671
1749
|
};
|
|
1672
1750
|
}, [isOpen, closeMenu]);
|
|
1673
|
-
(0,
|
|
1751
|
+
(0, import_react11.useEffect)(() => {
|
|
1674
1752
|
if (isOpen && menuRef.current) {
|
|
1675
1753
|
menuRef.current.focus();
|
|
1676
1754
|
}
|
|
1677
1755
|
}, [isOpen]);
|
|
1678
|
-
(0,
|
|
1756
|
+
(0, import_react11.useEffect)(() => {
|
|
1679
1757
|
if (!isOpen) {
|
|
1680
1758
|
itemsRef.current = [];
|
|
1681
1759
|
}
|
|
1682
1760
|
}, [isOpen]);
|
|
1683
|
-
const registerItem = (0,
|
|
1684
|
-
const
|
|
1685
|
-
if (
|
|
1761
|
+
const registerItem = (0, import_react11.useCallback)((id) => {
|
|
1762
|
+
const index2 = itemsRef.current.indexOf(id);
|
|
1763
|
+
if (index2 === -1) {
|
|
1686
1764
|
itemsRef.current.push(id);
|
|
1687
1765
|
return itemsRef.current.length - 1;
|
|
1688
1766
|
}
|
|
1689
|
-
return
|
|
1767
|
+
return index2;
|
|
1690
1768
|
}, []);
|
|
1691
|
-
const unregisterItem = (0,
|
|
1692
|
-
const
|
|
1693
|
-
if (
|
|
1694
|
-
itemsRef.current.splice(
|
|
1769
|
+
const unregisterItem = (0, import_react11.useCallback)((id) => {
|
|
1770
|
+
const index2 = itemsRef.current.indexOf(id);
|
|
1771
|
+
if (index2 !== -1) {
|
|
1772
|
+
itemsRef.current.splice(index2, 1);
|
|
1695
1773
|
}
|
|
1696
1774
|
}, []);
|
|
1697
|
-
const onItemSelect = (0,
|
|
1775
|
+
const onItemSelect = (0, import_react11.useCallback)(
|
|
1698
1776
|
(item) => {
|
|
1699
1777
|
onSelect?.(item);
|
|
1700
1778
|
if (item.variant === "checkbox") {
|
|
@@ -1710,7 +1788,7 @@ var ContextMenuRoot = (0, import_react10.forwardRef)(
|
|
|
1710
1788
|
},
|
|
1711
1789
|
[onSelect, onCheckedChange, closeOnSelect, closeMenu]
|
|
1712
1790
|
);
|
|
1713
|
-
const handleKeyDown = (0,
|
|
1791
|
+
const handleKeyDown = (0, import_react11.useCallback)(
|
|
1714
1792
|
(event) => {
|
|
1715
1793
|
const itemCount = itemsRef.current.length;
|
|
1716
1794
|
if (itemCount === 0) return;
|
|
@@ -1742,7 +1820,7 @@ var ContextMenuRoot = (0, import_react10.forwardRef)(
|
|
|
1742
1820
|
},
|
|
1743
1821
|
[closeMenu]
|
|
1744
1822
|
);
|
|
1745
|
-
const contextValue = (0,
|
|
1823
|
+
const contextValue = (0, import_react11.useMemo)(
|
|
1746
1824
|
() => ({
|
|
1747
1825
|
size,
|
|
1748
1826
|
closeMenu,
|
|
@@ -1770,12 +1848,12 @@ var ContextMenuRoot = (0, import_react10.forwardRef)(
|
|
|
1770
1848
|
};
|
|
1771
1849
|
};
|
|
1772
1850
|
const renderItems = (itemsData) => {
|
|
1773
|
-
return itemsData.map((item,
|
|
1774
|
-
const itemKey = item.id ||
|
|
1851
|
+
return itemsData.map((item, index2) => {
|
|
1852
|
+
const itemKey = item.id || index2;
|
|
1775
1853
|
const commonProps = {
|
|
1776
1854
|
disabled: item.disabled,
|
|
1777
1855
|
description: item.description,
|
|
1778
|
-
"data-testid": `context-menu-item-${item.id ||
|
|
1856
|
+
"data-testid": `context-menu-item-${item.id || index2}`
|
|
1779
1857
|
};
|
|
1780
1858
|
if (item.variant === "checkbox") {
|
|
1781
1859
|
return /* @__PURE__ */ (0, import_jsx_runtime399.jsx)(
|
|
@@ -1812,7 +1890,7 @@ var ContextMenuRoot = (0, import_react10.forwardRef)(
|
|
|
1812
1890
|
trailing: item.trailing?.type !== "shortcut" && item.trailing?.type !== "none" ? item.trailing?.content : void 0,
|
|
1813
1891
|
hasSubmenu: item.children && item.children.length > 0,
|
|
1814
1892
|
onPress: item.onPress,
|
|
1815
|
-
active: activeIndex ===
|
|
1893
|
+
active: activeIndex === index2,
|
|
1816
1894
|
children: item.label
|
|
1817
1895
|
},
|
|
1818
1896
|
itemKey
|
|
@@ -1820,7 +1898,7 @@ var ContextMenuRoot = (0, import_react10.forwardRef)(
|
|
|
1820
1898
|
});
|
|
1821
1899
|
};
|
|
1822
1900
|
const renderGroups = (groupsData) => {
|
|
1823
|
-
return groupsData.map((group, groupIndex) => /* @__PURE__ */ (0, import_jsx_runtime399.jsxs)(
|
|
1901
|
+
return groupsData.map((group, groupIndex) => /* @__PURE__ */ (0, import_jsx_runtime399.jsxs)(import_react11.default.Fragment, { children: [
|
|
1824
1902
|
groupIndex > 0 && /* @__PURE__ */ (0, import_jsx_runtime399.jsx)(ContextMenuSeparator, {}),
|
|
1825
1903
|
/* @__PURE__ */ (0, import_jsx_runtime399.jsx)(
|
|
1826
1904
|
ContextMenuGroup,
|
|
@@ -1929,15 +2007,15 @@ var ContextMenu = Object.assign(ContextMenuRoot, {
|
|
|
1929
2007
|
});
|
|
1930
2008
|
|
|
1931
2009
|
// src/hooks/useContextMenuPosition.ts
|
|
1932
|
-
var
|
|
2010
|
+
var import_react12 = require("react");
|
|
1933
2011
|
var useContextMenuPosition = ({
|
|
1934
2012
|
position,
|
|
1935
2013
|
menuRef,
|
|
1936
2014
|
isOpen,
|
|
1937
2015
|
offset = 8
|
|
1938
2016
|
}) => {
|
|
1939
|
-
const [adjustedPosition, setAdjustedPosition] = (0,
|
|
1940
|
-
(0,
|
|
2017
|
+
const [adjustedPosition, setAdjustedPosition] = (0, import_react12.useState)();
|
|
2018
|
+
(0, import_react12.useEffect)(() => {
|
|
1941
2019
|
if (!isOpen || !position || !menuRef.current) {
|
|
1942
2020
|
setAdjustedPosition(void 0);
|
|
1943
2021
|
return;
|
|
@@ -1985,7 +2063,7 @@ var useContextMenuPosition = ({
|
|
|
1985
2063
|
};
|
|
1986
2064
|
|
|
1987
2065
|
// src/hooks/useKeyboardNavigation.ts
|
|
1988
|
-
var
|
|
2066
|
+
var import_react13 = require("react");
|
|
1989
2067
|
var useKeyboardNavigation = ({
|
|
1990
2068
|
isOpen,
|
|
1991
2069
|
itemCount,
|
|
@@ -1995,9 +2073,9 @@ var useKeyboardNavigation = ({
|
|
|
1995
2073
|
onClose,
|
|
1996
2074
|
loop = true
|
|
1997
2075
|
}) => {
|
|
1998
|
-
const typeaheadBuffer = (0,
|
|
1999
|
-
const typeaheadTimeout = (0,
|
|
2000
|
-
(0,
|
|
2076
|
+
const typeaheadBuffer = (0, import_react13.useRef)("");
|
|
2077
|
+
const typeaheadTimeout = (0, import_react13.useRef)(null);
|
|
2078
|
+
(0, import_react13.useEffect)(() => {
|
|
2001
2079
|
if (!isOpen) {
|
|
2002
2080
|
typeaheadBuffer.current = "";
|
|
2003
2081
|
if (typeaheadTimeout.current) {
|
|
@@ -2005,7 +2083,7 @@ var useKeyboardNavigation = ({
|
|
|
2005
2083
|
}
|
|
2006
2084
|
}
|
|
2007
2085
|
}, [isOpen]);
|
|
2008
|
-
const handleKeyDown = (0,
|
|
2086
|
+
const handleKeyDown = (0, import_react13.useCallback)(
|
|
2009
2087
|
(event) => {
|
|
2010
2088
|
if (!isOpen || itemCount === 0) return;
|
|
2011
2089
|
switch (event.key) {
|