@xsolla/xui-multi-select 0.171.2 → 0.171.3-pr330.1781564486
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.js +116 -84
- package/native/index.js.map +1 -1
- package/native/index.mjs +116 -84
- package/native/index.mjs.map +1 -1
- package/package.json +6 -5
- package/web/index.js +121 -83
- package/web/index.js.map +1 -1
- package/web/index.mjs +119 -81
- package/web/index.mjs.map +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xsolla/xui-multi-select",
|
|
3
|
-
"version": "0.171.
|
|
3
|
+
"version": "0.171.3-pr330.1781564486",
|
|
4
4
|
"main": "./web/index.js",
|
|
5
5
|
"module": "./web/index.mjs",
|
|
6
6
|
"types": "./web/index.d.ts",
|
|
@@ -10,13 +10,14 @@
|
|
|
10
10
|
"build:native": "PLATFORM=native tsup"
|
|
11
11
|
},
|
|
12
12
|
"dependencies": {
|
|
13
|
-
"@xsolla/xui-checkbox": "0.171.
|
|
14
|
-
"@xsolla/xui-core": "0.171.
|
|
15
|
-
"@xsolla/xui-dropdown": "0.171.
|
|
16
|
-
"@xsolla/xui-primitives-core": "0.171.
|
|
13
|
+
"@xsolla/xui-checkbox": "0.171.3-pr330.1781564486",
|
|
14
|
+
"@xsolla/xui-core": "0.171.3-pr330.1781564486",
|
|
15
|
+
"@xsolla/xui-dropdown": "0.171.3-pr330.1781564486",
|
|
16
|
+
"@xsolla/xui-primitives-core": "0.171.3-pr330.1781564486"
|
|
17
17
|
},
|
|
18
18
|
"peerDependencies": {
|
|
19
19
|
"react": ">=16.8.0",
|
|
20
|
+
"react-dom": ">=16.8.0",
|
|
20
21
|
"styled-components": ">=4"
|
|
21
22
|
},
|
|
22
23
|
"devDependencies": {
|
package/web/index.js
CHANGED
|
@@ -35,7 +35,7 @@ __export(index_exports, {
|
|
|
35
35
|
module.exports = __toCommonJS(index_exports);
|
|
36
36
|
|
|
37
37
|
// src/MultiSelect.tsx
|
|
38
|
-
var
|
|
38
|
+
var import_react12 = require("react");
|
|
39
39
|
|
|
40
40
|
// ../../foundation/primitives-web/src/Box.tsx
|
|
41
41
|
var import_react2 = __toESM(require("react"));
|
|
@@ -353,6 +353,9 @@ var Icon = ({
|
|
|
353
353
|
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(StyledIcon, { "data-testid": dataTestId || testID, ...props, children });
|
|
354
354
|
};
|
|
355
355
|
|
|
356
|
+
// ../../foundation/primitives-web/src/index.tsx
|
|
357
|
+
var isWeb = true;
|
|
358
|
+
|
|
356
359
|
// src/MultiSelect.tsx
|
|
357
360
|
var import_xui_core4 = require("@xsolla/xui-core");
|
|
358
361
|
|
|
@@ -2221,10 +2224,20 @@ var useMultiSelect = ({
|
|
|
2221
2224
|
};
|
|
2222
2225
|
};
|
|
2223
2226
|
|
|
2227
|
+
// src/Portal.web.tsx
|
|
2228
|
+
var import_react11 = require("react");
|
|
2229
|
+
var import_react_dom = require("react-dom");
|
|
2230
|
+
var Portal = ({ children }) => {
|
|
2231
|
+
const [mountNode, setMountNode] = (0, import_react11.useState)(null);
|
|
2232
|
+
(0, import_react11.useEffect)(() => setMountNode(document.body), []);
|
|
2233
|
+
if (!mountNode) return null;
|
|
2234
|
+
return (0, import_react_dom.createPortal)(children, mountNode);
|
|
2235
|
+
};
|
|
2236
|
+
|
|
2224
2237
|
// src/MultiSelect.tsx
|
|
2225
2238
|
var import_jsx_runtime733 = require("react/jsx-runtime");
|
|
2226
2239
|
var EXTERNAL_MENU_MIN_WIDTH_DEFAULT = 540;
|
|
2227
|
-
var MultiSelect = (0,
|
|
2240
|
+
var MultiSelect = (0, import_react12.forwardRef)(
|
|
2228
2241
|
({
|
|
2229
2242
|
options,
|
|
2230
2243
|
errorMessage,
|
|
@@ -2251,8 +2264,10 @@ var MultiSelect = (0, import_react11.forwardRef)(
|
|
|
2251
2264
|
themeProductContext
|
|
2252
2265
|
}, ref) => {
|
|
2253
2266
|
const { theme } = (0, import_xui_core4.useResolvedTheme)({ themeMode, themeProductContext });
|
|
2254
|
-
const
|
|
2255
|
-
const
|
|
2267
|
+
const modalId = (0, import_xui_core4.useModalId)();
|
|
2268
|
+
const controlRef = (0, import_react12.useRef)(null);
|
|
2269
|
+
const menuRef = (0, import_react12.useRef)(null);
|
|
2270
|
+
const [menuPosition, setMenuPosition] = (0, import_react12.useState)(null);
|
|
2256
2271
|
const sizeStyles = theme.sizing.input(size);
|
|
2257
2272
|
const state = externalState || (disabled ? "disable" : "default");
|
|
2258
2273
|
const isDisable = state === "disable" || disabled;
|
|
@@ -2273,7 +2288,7 @@ var MultiSelect = (0, import_react11.forwardRef)(
|
|
|
2273
2288
|
value,
|
|
2274
2289
|
onChange
|
|
2275
2290
|
});
|
|
2276
|
-
(0,
|
|
2291
|
+
(0, import_react12.useEffect)(() => {
|
|
2277
2292
|
if (isDisable || !dropdownMenu) {
|
|
2278
2293
|
onClose();
|
|
2279
2294
|
}
|
|
@@ -2296,11 +2311,111 @@ var MultiSelect = (0, import_react11.forwardRef)(
|
|
|
2296
2311
|
};
|
|
2297
2312
|
const controlMenuOpen = dropdownMenu ? isOpen : Boolean(menuOpen);
|
|
2298
2313
|
const controlOnClick = dropdownMenu ? onSelectClick : onTriggerPress;
|
|
2314
|
+
const updateMenuPosition = (0, import_react12.useCallback)(() => {
|
|
2315
|
+
if (!isWeb || !controlRef.current) return;
|
|
2316
|
+
const rect = controlRef.current.getBoundingClientRect();
|
|
2317
|
+
setMenuPosition({
|
|
2318
|
+
left: rect.left,
|
|
2319
|
+
top: rect.bottom + 4,
|
|
2320
|
+
width: rect.width
|
|
2321
|
+
});
|
|
2322
|
+
}, []);
|
|
2323
|
+
(0, import_react12.useEffect)(() => {
|
|
2324
|
+
if (!isWeb || !controlMenuOpen || isDisable || !dropdownMenu) return;
|
|
2325
|
+
updateMenuPosition();
|
|
2326
|
+
window.addEventListener("resize", updateMenuPosition);
|
|
2327
|
+
window.addEventListener("scroll", updateMenuPosition, true);
|
|
2328
|
+
return () => {
|
|
2329
|
+
window.removeEventListener("resize", updateMenuPosition);
|
|
2330
|
+
window.removeEventListener("scroll", updateMenuPosition, true);
|
|
2331
|
+
};
|
|
2332
|
+
}, [controlMenuOpen, dropdownMenu, isDisable, updateMenuPosition]);
|
|
2299
2333
|
const externalFieldLayout = !dropdownMenu ? {
|
|
2300
2334
|
width: "100%",
|
|
2301
2335
|
minWidth: menuMinWidth ?? EXTERNAL_MENU_MIN_WIDTH_DEFAULT,
|
|
2302
2336
|
boxSizing: "border-box"
|
|
2303
2337
|
} : void 0;
|
|
2338
|
+
const dropdown = dropdownMenu && isOpen && !isDisable && (!isWeb || menuPosition) && /* @__PURE__ */ (0, import_jsx_runtime733.jsxs)(import_jsx_runtime733.Fragment, { children: [
|
|
2339
|
+
/* @__PURE__ */ (0, import_jsx_runtime733.jsx)(
|
|
2340
|
+
Box,
|
|
2341
|
+
{
|
|
2342
|
+
"data-modal-id": modalId,
|
|
2343
|
+
style: {
|
|
2344
|
+
position: "fixed",
|
|
2345
|
+
top: 0,
|
|
2346
|
+
left: 0,
|
|
2347
|
+
right: 0,
|
|
2348
|
+
bottom: 0,
|
|
2349
|
+
zIndex: 999,
|
|
2350
|
+
cursor: "default"
|
|
2351
|
+
},
|
|
2352
|
+
onPress: onClose
|
|
2353
|
+
}
|
|
2354
|
+
),
|
|
2355
|
+
/* @__PURE__ */ (0, import_jsx_runtime733.jsx)(
|
|
2356
|
+
Box,
|
|
2357
|
+
{
|
|
2358
|
+
ref: menuRef,
|
|
2359
|
+
"data-modal-id": modalId,
|
|
2360
|
+
backgroundColor: theme.colors.background.secondary,
|
|
2361
|
+
borderColor: theme.colors.border.secondary,
|
|
2362
|
+
borderWidth: 1,
|
|
2363
|
+
borderRadius: sizeStyles.radius,
|
|
2364
|
+
paddingVertical: 4,
|
|
2365
|
+
style: {
|
|
2366
|
+
position: isWeb ? "fixed" : "absolute",
|
|
2367
|
+
top: isWeb ? menuPosition?.top : "100%",
|
|
2368
|
+
left: isWeb ? menuPosition?.left : 0,
|
|
2369
|
+
right: isWeb ? void 0 : 0,
|
|
2370
|
+
width: isWeb ? menuPosition?.width : void 0,
|
|
2371
|
+
marginTop: isWeb ? void 0 : 4,
|
|
2372
|
+
zIndex: 1001,
|
|
2373
|
+
// Above control (1000) and backdrop (999)
|
|
2374
|
+
boxShadow: theme.shadow.popover,
|
|
2375
|
+
maxHeight,
|
|
2376
|
+
overflowY: "auto"
|
|
2377
|
+
},
|
|
2378
|
+
children: menuItems.map((item, _index) => {
|
|
2379
|
+
const brandColors = theme.colors.control.brand.primary;
|
|
2380
|
+
const contentColors = theme.colors.content;
|
|
2381
|
+
return /* @__PURE__ */ (0, import_jsx_runtime733.jsx)(
|
|
2382
|
+
Box,
|
|
2383
|
+
{
|
|
2384
|
+
testID,
|
|
2385
|
+
paddingHorizontal: sizeStyles.paddingHorizontal,
|
|
2386
|
+
paddingVertical: 8,
|
|
2387
|
+
onPress: () => {
|
|
2388
|
+
if (!item.disabled) {
|
|
2389
|
+
handleItemToggle(item.id, !item.checked);
|
|
2390
|
+
}
|
|
2391
|
+
},
|
|
2392
|
+
flexDirection: "row",
|
|
2393
|
+
alignItems: "center",
|
|
2394
|
+
justifyContent: "space-between",
|
|
2395
|
+
backgroundColor: item.checked ? brandColors.bg : "transparent",
|
|
2396
|
+
hoverStyle: !item.disabled && !item.checked ? {
|
|
2397
|
+
backgroundColor: theme.colors.control.input.bgHover
|
|
2398
|
+
} : void 0,
|
|
2399
|
+
style: {
|
|
2400
|
+
cursor: item.disabled ? "not-allowed" : "pointer",
|
|
2401
|
+
opacity: item.disabled ? 0.5 : 1
|
|
2402
|
+
},
|
|
2403
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime733.jsx)(
|
|
2404
|
+
Text,
|
|
2405
|
+
{
|
|
2406
|
+
color: item.checked ? contentColors.on.brand : theme.colors.content.secondary,
|
|
2407
|
+
fontSize: sizeStyles.fontSize,
|
|
2408
|
+
fontWeight: "400",
|
|
2409
|
+
children: item.children
|
|
2410
|
+
}
|
|
2411
|
+
)
|
|
2412
|
+
},
|
|
2413
|
+
item.id
|
|
2414
|
+
);
|
|
2415
|
+
})
|
|
2416
|
+
}
|
|
2417
|
+
)
|
|
2418
|
+
] });
|
|
2304
2419
|
return /* @__PURE__ */ (0, import_jsx_runtime733.jsxs)(
|
|
2305
2420
|
Box,
|
|
2306
2421
|
{
|
|
@@ -2352,84 +2467,7 @@ var MultiSelect = (0, import_react11.forwardRef)(
|
|
|
2352
2467
|
extraClear
|
|
2353
2468
|
}
|
|
2354
2469
|
),
|
|
2355
|
-
|
|
2356
|
-
/* @__PURE__ */ (0, import_jsx_runtime733.jsx)(
|
|
2357
|
-
Box,
|
|
2358
|
-
{
|
|
2359
|
-
style: {
|
|
2360
|
-
position: "fixed",
|
|
2361
|
-
top: 0,
|
|
2362
|
-
left: 0,
|
|
2363
|
-
right: 0,
|
|
2364
|
-
bottom: 0,
|
|
2365
|
-
zIndex: 999,
|
|
2366
|
-
cursor: "default"
|
|
2367
|
-
},
|
|
2368
|
-
onPress: onClose
|
|
2369
|
-
}
|
|
2370
|
-
),
|
|
2371
|
-
/* @__PURE__ */ (0, import_jsx_runtime733.jsx)(
|
|
2372
|
-
Box,
|
|
2373
|
-
{
|
|
2374
|
-
ref: menuRef,
|
|
2375
|
-
backgroundColor: theme.colors.background.secondary,
|
|
2376
|
-
borderColor: theme.colors.border.secondary,
|
|
2377
|
-
borderWidth: 1,
|
|
2378
|
-
borderRadius: theme.shape.input[size].borderRadius,
|
|
2379
|
-
paddingVertical: 4,
|
|
2380
|
-
style: {
|
|
2381
|
-
position: "absolute",
|
|
2382
|
-
top: "100%",
|
|
2383
|
-
left: 0,
|
|
2384
|
-
right: 0,
|
|
2385
|
-
marginTop: 4,
|
|
2386
|
-
zIndex: 1001,
|
|
2387
|
-
// Above control (1000) and backdrop (999)
|
|
2388
|
-
boxShadow: theme.shadow.popover,
|
|
2389
|
-
maxHeight,
|
|
2390
|
-
overflowY: "auto"
|
|
2391
|
-
},
|
|
2392
|
-
children: menuItems.map((item, _index) => {
|
|
2393
|
-
const brandColors = theme.colors.control.brand.primary;
|
|
2394
|
-
const contentColors = theme.colors.content;
|
|
2395
|
-
return /* @__PURE__ */ (0, import_jsx_runtime733.jsx)(
|
|
2396
|
-
Box,
|
|
2397
|
-
{
|
|
2398
|
-
testID,
|
|
2399
|
-
paddingHorizontal: sizeStyles.paddingHorizontal,
|
|
2400
|
-
paddingVertical: 8,
|
|
2401
|
-
onPress: () => {
|
|
2402
|
-
if (!item.disabled) {
|
|
2403
|
-
handleItemToggle(item.id, !item.checked);
|
|
2404
|
-
}
|
|
2405
|
-
},
|
|
2406
|
-
flexDirection: "row",
|
|
2407
|
-
alignItems: "center",
|
|
2408
|
-
justifyContent: "space-between",
|
|
2409
|
-
backgroundColor: item.checked ? brandColors.bg : "transparent",
|
|
2410
|
-
hoverStyle: !item.disabled && !item.checked ? {
|
|
2411
|
-
backgroundColor: theme.colors.control.input.bgHover
|
|
2412
|
-
} : void 0,
|
|
2413
|
-
style: {
|
|
2414
|
-
cursor: item.disabled ? "not-allowed" : "pointer",
|
|
2415
|
-
opacity: item.disabled ? 0.5 : 1
|
|
2416
|
-
},
|
|
2417
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime733.jsx)(
|
|
2418
|
-
Text,
|
|
2419
|
-
{
|
|
2420
|
-
color: item.checked ? contentColors.on.brand : theme.colors.content.secondary,
|
|
2421
|
-
fontSize: sizeStyles.fontSize,
|
|
2422
|
-
fontWeight: "400",
|
|
2423
|
-
children: item.children
|
|
2424
|
-
}
|
|
2425
|
-
)
|
|
2426
|
-
},
|
|
2427
|
-
item.id
|
|
2428
|
-
);
|
|
2429
|
-
})
|
|
2430
|
-
}
|
|
2431
|
-
)
|
|
2432
|
-
] })
|
|
2470
|
+
isWeb ? /* @__PURE__ */ (0, import_jsx_runtime733.jsx)(Portal, { children: dropdown }) : dropdown
|
|
2433
2471
|
]
|
|
2434
2472
|
}
|
|
2435
2473
|
),
|