@xsolla/xui-multi-select 0.149.1 → 0.150.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 +49 -0
- package/native/index.d.mts +23 -0
- package/native/index.d.ts +23 -0
- package/native/index.js +159 -135
- package/native/index.js.map +1 -1
- package/native/index.mjs +159 -135
- package/native/index.mjs.map +1 -1
- package/package.json +5 -5
- package/web/index.d.mts +23 -0
- package/web/index.d.ts +23 -0
- package/web/index.js +159 -135
- package/web/index.js.map +1 -1
- package/web/index.mjs +159 -135
- package/web/index.mjs.map +1 -1
package/web/index.mjs
CHANGED
|
@@ -1941,6 +1941,7 @@ var MultiSelectControl = forwardRef3(
|
|
|
1941
1941
|
iconRight,
|
|
1942
1942
|
disabled = false,
|
|
1943
1943
|
extraClear = false,
|
|
1944
|
+
width,
|
|
1944
1945
|
themeMode,
|
|
1945
1946
|
themeProductContext
|
|
1946
1947
|
}, ref) => {
|
|
@@ -1989,6 +1990,7 @@ var MultiSelectControl = forwardRef3(
|
|
|
1989
1990
|
Box,
|
|
1990
1991
|
{
|
|
1991
1992
|
ref,
|
|
1993
|
+
width,
|
|
1992
1994
|
backgroundColor,
|
|
1993
1995
|
borderColor,
|
|
1994
1996
|
borderWidth: borderColor !== "transparent" ? 1 : 0,
|
|
@@ -2000,7 +2002,7 @@ var MultiSelectControl = forwardRef3(
|
|
|
2000
2002
|
alignItems: "center",
|
|
2001
2003
|
gap: 8,
|
|
2002
2004
|
style: {
|
|
2003
|
-
cursor: isDisable ? "not-allowed" : "pointer",
|
|
2005
|
+
cursor: isDisable ? "not-allowed" : onClick ? "pointer" : "default",
|
|
2004
2006
|
boxSizing: "border-box",
|
|
2005
2007
|
height: flexible ? "auto" : sizeStyles.height,
|
|
2006
2008
|
position: "relative",
|
|
@@ -2008,7 +2010,7 @@ var MultiSelectControl = forwardRef3(
|
|
|
2008
2010
|
// Above backdrop when open
|
|
2009
2011
|
},
|
|
2010
2012
|
onPress: isDisable ? void 0 : onClick,
|
|
2011
|
-
hoverStyle: !isDisable && !isFocus && !isOpen && !isError ? {
|
|
2013
|
+
hoverStyle: !isDisable && onClick && !isFocus && !isOpen && !isError ? {
|
|
2012
2014
|
backgroundColor: inputColors.bgHover,
|
|
2013
2015
|
borderColor: inputColors.borderHover
|
|
2014
2016
|
} : void 0,
|
|
@@ -2164,6 +2166,7 @@ var useMultiSelect = ({
|
|
|
2164
2166
|
|
|
2165
2167
|
// src/MultiSelect.tsx
|
|
2166
2168
|
import { Fragment, jsx as jsx726, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
2169
|
+
var EXTERNAL_MENU_MIN_WIDTH_DEFAULT = 540;
|
|
2167
2170
|
var MultiSelect = forwardRef4(
|
|
2168
2171
|
({
|
|
2169
2172
|
options,
|
|
@@ -2182,6 +2185,10 @@ var MultiSelect = forwardRef4(
|
|
|
2182
2185
|
iconLeft,
|
|
2183
2186
|
iconRight,
|
|
2184
2187
|
maxHeight = 300,
|
|
2188
|
+
dropdownMenu = true,
|
|
2189
|
+
onTriggerPress,
|
|
2190
|
+
menuOpen = false,
|
|
2191
|
+
menuMinWidth,
|
|
2185
2192
|
themeMode,
|
|
2186
2193
|
themeProductContext
|
|
2187
2194
|
}, ref) => {
|
|
@@ -2209,10 +2216,10 @@ var MultiSelect = forwardRef4(
|
|
|
2209
2216
|
onChange
|
|
2210
2217
|
});
|
|
2211
2218
|
useEffect3(() => {
|
|
2212
|
-
if (isDisable) {
|
|
2219
|
+
if (isDisable || !dropdownMenu) {
|
|
2213
2220
|
onClose();
|
|
2214
2221
|
}
|
|
2215
|
-
}, [isDisable, onClose]);
|
|
2222
|
+
}, [isDisable, dropdownMenu, onClose]);
|
|
2216
2223
|
const menuItems = options.map((opt) => {
|
|
2217
2224
|
const id = String(opt.value);
|
|
2218
2225
|
const checked = values.map(String).includes(id);
|
|
@@ -2229,138 +2236,155 @@ var MultiSelect = forwardRef4(
|
|
|
2229
2236
|
const newValues = checked ? [...values, value2] : values.filter((v) => v !== value2);
|
|
2230
2237
|
onChoose(newValues.map(String));
|
|
2231
2238
|
};
|
|
2232
|
-
|
|
2233
|
-
|
|
2234
|
-
|
|
2235
|
-
|
|
2236
|
-
|
|
2237
|
-
|
|
2238
|
-
|
|
2239
|
-
|
|
2240
|
-
|
|
2241
|
-
|
|
2242
|
-
|
|
2243
|
-
|
|
2244
|
-
|
|
2245
|
-
|
|
2246
|
-
|
|
2247
|
-
|
|
2248
|
-
|
|
2249
|
-
|
|
2250
|
-
|
|
2251
|
-
|
|
2252
|
-
|
|
2253
|
-
|
|
2254
|
-
|
|
2255
|
-
|
|
2256
|
-
|
|
2257
|
-
|
|
2258
|
-
|
|
2259
|
-
|
|
2260
|
-
|
|
2261
|
-
|
|
2262
|
-
|
|
2263
|
-
|
|
2264
|
-
|
|
2265
|
-
|
|
2266
|
-
|
|
2267
|
-
|
|
2268
|
-
|
|
2269
|
-
|
|
2270
|
-
|
|
2271
|
-
|
|
2272
|
-
|
|
2273
|
-
|
|
2274
|
-
|
|
2275
|
-
|
|
2276
|
-
|
|
2277
|
-
|
|
2278
|
-
|
|
2279
|
-
|
|
2280
|
-
|
|
2281
|
-
|
|
2282
|
-
|
|
2283
|
-
|
|
2284
|
-
|
|
2285
|
-
|
|
2286
|
-
|
|
2287
|
-
|
|
2288
|
-
|
|
2289
|
-
|
|
2290
|
-
|
|
2291
|
-
|
|
2292
|
-
|
|
2293
|
-
|
|
2294
|
-
|
|
2295
|
-
|
|
2296
|
-
|
|
2297
|
-
|
|
2298
|
-
|
|
2299
|
-
|
|
2300
|
-
|
|
2301
|
-
top: "100%",
|
|
2302
|
-
left: 0,
|
|
2303
|
-
right: 0,
|
|
2304
|
-
marginTop: 4,
|
|
2305
|
-
zIndex: 1001,
|
|
2306
|
-
// Above control (1000) and backdrop (999)
|
|
2307
|
-
boxShadow: theme.shadow.popover,
|
|
2308
|
-
maxHeight,
|
|
2309
|
-
overflowY: "auto"
|
|
2310
|
-
},
|
|
2311
|
-
children: menuItems.map((item, _index) => {
|
|
2312
|
-
const brandColors = theme.colors.control.brand.primary;
|
|
2313
|
-
const contentColors = theme.colors.content;
|
|
2314
|
-
return /* @__PURE__ */ jsx726(
|
|
2315
|
-
Box,
|
|
2316
|
-
{
|
|
2317
|
-
paddingHorizontal: sizeStyles.paddingHorizontal,
|
|
2318
|
-
paddingVertical: 8,
|
|
2319
|
-
onPress: () => {
|
|
2320
|
-
if (!item.disabled) {
|
|
2321
|
-
handleItemToggle(item.id, !item.checked);
|
|
2322
|
-
}
|
|
2323
|
-
},
|
|
2324
|
-
flexDirection: "row",
|
|
2325
|
-
alignItems: "center",
|
|
2326
|
-
justifyContent: "space-between",
|
|
2327
|
-
backgroundColor: item.checked ? brandColors.bg : "transparent",
|
|
2328
|
-
hoverStyle: !item.disabled && !item.checked ? {
|
|
2329
|
-
backgroundColor: theme.colors.control.input.bgHover
|
|
2330
|
-
} : void 0,
|
|
2331
|
-
style: {
|
|
2332
|
-
cursor: item.disabled ? "not-allowed" : "pointer",
|
|
2333
|
-
opacity: item.disabled ? 0.5 : 1
|
|
2334
|
-
},
|
|
2335
|
-
children: /* @__PURE__ */ jsx726(
|
|
2336
|
-
Text,
|
|
2337
|
-
{
|
|
2338
|
-
color: item.checked ? contentColors.on.brand : theme.colors.content.secondary,
|
|
2339
|
-
fontSize: sizeStyles.fontSize,
|
|
2340
|
-
fontWeight: "400",
|
|
2341
|
-
children: item.children
|
|
2342
|
-
}
|
|
2343
|
-
)
|
|
2239
|
+
const controlMenuOpen = dropdownMenu ? isOpen : Boolean(menuOpen);
|
|
2240
|
+
const controlOnClick = dropdownMenu ? onSelectClick : onTriggerPress;
|
|
2241
|
+
const externalFieldLayout = !dropdownMenu ? {
|
|
2242
|
+
width: "100%",
|
|
2243
|
+
minWidth: menuMinWidth ?? EXTERNAL_MENU_MIN_WIDTH_DEFAULT,
|
|
2244
|
+
boxSizing: "border-box"
|
|
2245
|
+
} : void 0;
|
|
2246
|
+
return /* @__PURE__ */ jsxs4(
|
|
2247
|
+
Box,
|
|
2248
|
+
{
|
|
2249
|
+
flexDirection: "column",
|
|
2250
|
+
gap: sizeStyles.fieldGap,
|
|
2251
|
+
style: externalFieldLayout,
|
|
2252
|
+
children: [
|
|
2253
|
+
label && /* @__PURE__ */ jsx726(
|
|
2254
|
+
Text,
|
|
2255
|
+
{
|
|
2256
|
+
color: theme.colors.content.secondary,
|
|
2257
|
+
fontSize: sizeStyles.fontSize - 2,
|
|
2258
|
+
fontWeight: "500",
|
|
2259
|
+
children: label
|
|
2260
|
+
}
|
|
2261
|
+
),
|
|
2262
|
+
/* @__PURE__ */ jsxs4(
|
|
2263
|
+
Box,
|
|
2264
|
+
{
|
|
2265
|
+
ref,
|
|
2266
|
+
style: {
|
|
2267
|
+
position: "relative",
|
|
2268
|
+
...externalFieldLayout ? { width: "100%" } : {}
|
|
2269
|
+
},
|
|
2270
|
+
children: [
|
|
2271
|
+
/* @__PURE__ */ jsx726(
|
|
2272
|
+
MultiSelectControl,
|
|
2273
|
+
{
|
|
2274
|
+
ref: controlRef,
|
|
2275
|
+
isOpen: controlMenuOpen,
|
|
2276
|
+
isFocus,
|
|
2277
|
+
isError,
|
|
2278
|
+
size,
|
|
2279
|
+
state,
|
|
2280
|
+
disabled: isDisable,
|
|
2281
|
+
onClick: controlOnClick,
|
|
2282
|
+
width: dropdownMenu ? void 0 : "100%",
|
|
2283
|
+
removeValue: onRemove,
|
|
2284
|
+
removeAllValues: onRemoveAll,
|
|
2285
|
+
stateList,
|
|
2286
|
+
selectedItems,
|
|
2287
|
+
variant,
|
|
2288
|
+
flexible,
|
|
2289
|
+
placeholder,
|
|
2290
|
+
removeTagsButtons,
|
|
2291
|
+
iconLeft,
|
|
2292
|
+
iconRight,
|
|
2293
|
+
extraClear
|
|
2294
|
+
}
|
|
2295
|
+
),
|
|
2296
|
+
dropdownMenu && isOpen && !isDisable && /* @__PURE__ */ jsxs4(Fragment, { children: [
|
|
2297
|
+
/* @__PURE__ */ jsx726(
|
|
2298
|
+
Box,
|
|
2299
|
+
{
|
|
2300
|
+
style: {
|
|
2301
|
+
position: "fixed",
|
|
2302
|
+
top: 0,
|
|
2303
|
+
left: 0,
|
|
2304
|
+
right: 0,
|
|
2305
|
+
bottom: 0,
|
|
2306
|
+
zIndex: 999,
|
|
2307
|
+
cursor: "default"
|
|
2344
2308
|
},
|
|
2345
|
-
|
|
2346
|
-
|
|
2347
|
-
|
|
2348
|
-
|
|
2349
|
-
|
|
2350
|
-
|
|
2351
|
-
|
|
2352
|
-
|
|
2353
|
-
|
|
2354
|
-
|
|
2355
|
-
|
|
2356
|
-
|
|
2357
|
-
|
|
2358
|
-
|
|
2359
|
-
|
|
2360
|
-
|
|
2361
|
-
|
|
2362
|
-
|
|
2363
|
-
|
|
2309
|
+
onPress: onClose
|
|
2310
|
+
}
|
|
2311
|
+
),
|
|
2312
|
+
/* @__PURE__ */ jsx726(
|
|
2313
|
+
Box,
|
|
2314
|
+
{
|
|
2315
|
+
ref: menuRef,
|
|
2316
|
+
backgroundColor: theme.colors.background.secondary,
|
|
2317
|
+
borderColor: theme.colors.border.secondary,
|
|
2318
|
+
borderWidth: 1,
|
|
2319
|
+
borderRadius: theme.radius.button,
|
|
2320
|
+
paddingVertical: 4,
|
|
2321
|
+
style: {
|
|
2322
|
+
position: "absolute",
|
|
2323
|
+
top: "100%",
|
|
2324
|
+
left: 0,
|
|
2325
|
+
right: 0,
|
|
2326
|
+
marginTop: 4,
|
|
2327
|
+
zIndex: 1001,
|
|
2328
|
+
// Above control (1000) and backdrop (999)
|
|
2329
|
+
boxShadow: theme.shadow.popover,
|
|
2330
|
+
maxHeight,
|
|
2331
|
+
overflowY: "auto"
|
|
2332
|
+
},
|
|
2333
|
+
children: menuItems.map((item, _index) => {
|
|
2334
|
+
const brandColors = theme.colors.control.brand.primary;
|
|
2335
|
+
const contentColors = theme.colors.content;
|
|
2336
|
+
return /* @__PURE__ */ jsx726(
|
|
2337
|
+
Box,
|
|
2338
|
+
{
|
|
2339
|
+
paddingHorizontal: sizeStyles.paddingHorizontal,
|
|
2340
|
+
paddingVertical: 8,
|
|
2341
|
+
onPress: () => {
|
|
2342
|
+
if (!item.disabled) {
|
|
2343
|
+
handleItemToggle(item.id, !item.checked);
|
|
2344
|
+
}
|
|
2345
|
+
},
|
|
2346
|
+
flexDirection: "row",
|
|
2347
|
+
alignItems: "center",
|
|
2348
|
+
justifyContent: "space-between",
|
|
2349
|
+
backgroundColor: item.checked ? brandColors.bg : "transparent",
|
|
2350
|
+
hoverStyle: !item.disabled && !item.checked ? {
|
|
2351
|
+
backgroundColor: theme.colors.control.input.bgHover
|
|
2352
|
+
} : void 0,
|
|
2353
|
+
style: {
|
|
2354
|
+
cursor: item.disabled ? "not-allowed" : "pointer",
|
|
2355
|
+
opacity: item.disabled ? 0.5 : 1
|
|
2356
|
+
},
|
|
2357
|
+
children: /* @__PURE__ */ jsx726(
|
|
2358
|
+
Text,
|
|
2359
|
+
{
|
|
2360
|
+
color: item.checked ? contentColors.on.brand : theme.colors.content.secondary,
|
|
2361
|
+
fontSize: sizeStyles.fontSize,
|
|
2362
|
+
fontWeight: "400",
|
|
2363
|
+
children: item.children
|
|
2364
|
+
}
|
|
2365
|
+
)
|
|
2366
|
+
},
|
|
2367
|
+
item.id
|
|
2368
|
+
);
|
|
2369
|
+
})
|
|
2370
|
+
}
|
|
2371
|
+
)
|
|
2372
|
+
] })
|
|
2373
|
+
]
|
|
2374
|
+
}
|
|
2375
|
+
),
|
|
2376
|
+
errorMessage && /* @__PURE__ */ jsx726(
|
|
2377
|
+
Text,
|
|
2378
|
+
{
|
|
2379
|
+
color: theme.colors.content.alert.primary,
|
|
2380
|
+
fontSize: sizeStyles.fontSize - 2,
|
|
2381
|
+
style: { lineHeight: sizeStyles.lineHeight + "px" },
|
|
2382
|
+
children: errorMessage
|
|
2383
|
+
}
|
|
2384
|
+
)
|
|
2385
|
+
]
|
|
2386
|
+
}
|
|
2387
|
+
);
|
|
2364
2388
|
}
|
|
2365
2389
|
);
|
|
2366
2390
|
MultiSelect.displayName = "MultiSelect";
|