@xsolla/xui-multi-select 0.221.1 → 0.223.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
@@ -354,7 +354,7 @@ var isWeb = false;
354
354
  // src/MultiSelect.tsx
355
355
  import {
356
356
  useModalId,
357
- useResolvedTheme as useResolvedTheme3,
357
+ useResolvedTheme as useResolvedTheme4,
358
358
  useOverlayLayer,
359
359
  LAYER_OFFSET
360
360
  } from "@xsolla/xui-core";
@@ -362,11 +362,11 @@ import { Search as SearchIcon } from "@xsolla/xui-icons-base";
362
362
 
363
363
  // src/MultiSelectControl.tsx
364
364
  import { forwardRef, useRef as useRef2 } from "react";
365
- import { useResolvedTheme as useResolvedTheme2 } from "@xsolla/xui-core";
365
+ import { useResolvedTheme as useResolvedTheme3 } from "@xsolla/xui-core";
366
366
  import {
367
367
  ChevronDown,
368
368
  ChevronUp,
369
- Remove,
369
+ Remove as Remove2,
370
370
  ExclamationMarkCr
371
371
  } from "@xsolla/xui-icons-base";
372
372
 
@@ -377,9 +377,91 @@ import {
377
377
  useRef,
378
378
  useState
379
379
  } from "react";
380
- import { Tag } from "@xsolla/xui-tag";
380
+ import { useResolvedTheme as useResolvedTheme2 } from "@xsolla/xui-core";
381
+
382
+ // src/MultiSelectItem.tsx
381
383
  import { useResolvedTheme } from "@xsolla/xui-core";
384
+ import { Remove } from "@xsolla/xui-icons-base";
382
385
  import { jsx as jsx4, jsxs } from "react/jsx-runtime";
386
+ var MultiSelectItem = ({
387
+ size = "md",
388
+ children,
389
+ onRemove,
390
+ disabled = false,
391
+ interactive = false,
392
+ testID,
393
+ themeMode,
394
+ themeProductContext
395
+ }) => {
396
+ const { theme } = useResolvedTheme({ themeMode, themeProductContext });
397
+ const sizeStyles = theme.sizing.tag(size);
398
+ const chipColors = theme.colors.control.mono.secondary;
399
+ const inputColors = theme.colors.control.input;
400
+ const backgroundColor = disabled ? inputColors.bgDisable : chipColors.bg;
401
+ const contentColor = disabled ? inputColors.textDisable : theme.colors.content.primary;
402
+ const removeLabel = typeof children === "string" ? `Remove ${children}` : "Remove";
403
+ return /* @__PURE__ */ jsxs(
404
+ Box,
405
+ {
406
+ testID,
407
+ backgroundColor,
408
+ borderRadius: theme.shape.knob.lg.borderRadius,
409
+ height: sizeStyles.height,
410
+ paddingHorizontal: sizeStyles.padding,
411
+ flexDirection: "row",
412
+ alignItems: "center",
413
+ justifyContent: "center",
414
+ gap: sizeStyles.gap,
415
+ borderWidth: 0,
416
+ hoverStyle: interactive && !disabled ? { backgroundColor: chipColors.bgHover } : void 0,
417
+ style: {
418
+ overflow: "hidden",
419
+ textOverflow: "ellipsis",
420
+ whiteSpace: "nowrap"
421
+ },
422
+ children: [
423
+ children !== void 0 && children !== null && /* @__PURE__ */ jsx4(
424
+ Text,
425
+ {
426
+ color: contentColor,
427
+ fontSize: sizeStyles.fontSize,
428
+ fontWeight: "500",
429
+ whiteSpace: "nowrap",
430
+ style: {
431
+ overflow: "hidden",
432
+ textOverflow: "ellipsis"
433
+ },
434
+ children
435
+ }
436
+ ),
437
+ onRemove && /* @__PURE__ */ jsx4(
438
+ Box,
439
+ {
440
+ role: "button",
441
+ "aria-label": removeLabel,
442
+ "aria-disabled": disabled || void 0,
443
+ alignItems: "center",
444
+ justifyContent: "center",
445
+ onPress: disabled ? void 0 : onRemove,
446
+ style: { cursor: disabled ? "not-allowed" : "pointer" },
447
+ children: /* @__PURE__ */ jsx4(
448
+ Remove,
449
+ {
450
+ size: sizeStyles.iconSize,
451
+ color: contentColor,
452
+ variant: "line"
453
+ }
454
+ )
455
+ }
456
+ )
457
+ ]
458
+ }
459
+ );
460
+ };
461
+ MultiSelectItem.displayName = "MultiSelectItem";
462
+
463
+ // src/useMultiSelectControl.tsx
464
+ import { jsx as jsx5, jsxs as jsxs2 } from "react/jsx-runtime";
383
465
  var COUNT_ITEM_VALUE = "count-item";
384
466
  var useMultiSelectControl = ({
385
467
  variant,
@@ -395,7 +477,7 @@ var useMultiSelectControl = ({
395
477
  themeMode,
396
478
  themeProductContext
397
479
  }) => {
398
- const { theme } = useResolvedTheme({ themeMode, themeProductContext });
480
+ const { theme } = useResolvedTheme2({ themeMode, themeProductContext });
399
481
  const displayStateRef = useRef(0 /* Placeholder */);
400
482
  const savedWidthsRef = useRef(null);
401
483
  const itemsRef = useRef(null);
@@ -459,7 +541,7 @@ var useMultiSelectControl = ({
459
541
  };
460
542
  const setPlaceholder = () => {
461
543
  setSelectedContent(
462
- /* @__PURE__ */ jsx4(
544
+ /* @__PURE__ */ jsx5(
463
545
  Text,
464
546
  {
465
547
  color: theme.colors.control.input.placeholder,
@@ -512,7 +594,7 @@ var useMultiSelectControl = ({
512
594
  const canRemove = !isCount && !isLocked;
513
595
  const isReducable = index === 0 && displayStateRef.current === 3 /* Render */ && displayedItemsCount === 0 || flexible;
514
596
  if (variant === "tag") {
515
- return /* @__PURE__ */ jsx4(
597
+ return /* @__PURE__ */ jsx5(
516
598
  Box,
517
599
  {
518
600
  onPress: canRemove ? (e) => {
@@ -521,14 +603,14 @@ var useMultiSelectControl = ({
521
603
  } : void 0,
522
604
  style: {
523
605
  minWidth: isReducable ? 0 : "fit-content",
524
- opacity: disabled ? 0.5 : 1,
525
606
  cursor: isLocked ? "default" : disabled || isCount ? "not-allowed" : "pointer"
526
607
  },
527
- children: /* @__PURE__ */ jsx4(
528
- Tag,
608
+ children: /* @__PURE__ */ jsx5(
609
+ MultiSelectItem,
529
610
  {
530
611
  size,
531
- tone: "primary",
612
+ disabled,
613
+ interactive: canRemove,
532
614
  onRemove: removeTagsButtons && canRemove ? (e) => {
533
615
  e?.stopPropagation();
534
616
  if (!disabled) removeValue(item.value, e);
@@ -542,7 +624,7 @@ var useMultiSelectControl = ({
542
624
  }
543
625
  const isCountItem = hasHidden;
544
626
  const needsComma = index < displayedItems.length - 2 || index < displayedItems.length - 1 && !isCountItem;
545
- return /* @__PURE__ */ jsxs(
627
+ return /* @__PURE__ */ jsxs2(
546
628
  Text,
547
629
  {
548
630
  color: theme.colors.content.primary,
@@ -558,7 +640,7 @@ var useMultiSelectControl = ({
558
640
  },
559
641
  children: [
560
642
  item.label,
561
- needsComma ? ",\xA0" : "\xA0"
643
+ needsComma ? ", " : " "
562
644
  ]
563
645
  },
564
646
  item.value
@@ -644,7 +726,7 @@ var useMultiSelectControl = ({
644
726
  };
645
727
 
646
728
  // src/MultiSelectControl.tsx
647
- import { jsx as jsx5, jsxs as jsxs2 } from "react/jsx-runtime";
729
+ import { jsx as jsx6, jsxs as jsxs3 } from "react/jsx-runtime";
648
730
  var MultiSelectControl = forwardRef(
649
731
  ({
650
732
  variant = "tag",
@@ -669,7 +751,7 @@ var MultiSelectControl = forwardRef(
669
751
  themeMode,
670
752
  themeProductContext
671
753
  }, ref) => {
672
- const { theme } = useResolvedTheme2({ themeMode, themeProductContext });
754
+ const { theme } = useResolvedTheme3({ themeMode, themeProductContext });
673
755
  const sizeStyles = theme.sizing.input(size);
674
756
  const inputColors = theme.colors.control.input;
675
757
  const state = externalState || (disabled ? "disable" : "default");
@@ -704,7 +786,7 @@ var MultiSelectControl = forwardRef(
704
786
  borderColor = inputColors.borderHover;
705
787
  }
706
788
  const iconColor = isDisable ? inputColors.textDisable : inputColors.placeholder;
707
- return /* @__PURE__ */ jsxs2(
789
+ return /* @__PURE__ */ jsxs3(
708
790
  Box,
709
791
  {
710
792
  ref,
@@ -732,7 +814,7 @@ var MultiSelectControl = forwardRef(
732
814
  borderColor: inputColors.borderHover
733
815
  } : void 0,
734
816
  children: [
735
- /* @__PURE__ */ jsxs2(
817
+ /* @__PURE__ */ jsxs3(
736
818
  Box,
737
819
  {
738
820
  ref: containerRef,
@@ -742,8 +824,8 @@ var MultiSelectControl = forwardRef(
742
824
  gap: 8,
743
825
  style: { minWidth: 0 },
744
826
  children: [
745
- iconLeft && /* @__PURE__ */ jsx5(Icon, { size: sizeStyles.iconSize, color: iconColor, variant: "line", children: iconLeft }),
746
- /* @__PURE__ */ jsx5(
827
+ iconLeft && /* @__PURE__ */ jsx6(Icon, { size: sizeStyles.iconSize, color: iconColor, variant: "line", children: iconLeft }),
828
+ /* @__PURE__ */ jsx6(
747
829
  Box,
748
830
  {
749
831
  ref: itemsRef,
@@ -759,8 +841,8 @@ var MultiSelectControl = forwardRef(
759
841
  ]
760
842
  }
761
843
  ),
762
- /* @__PURE__ */ jsxs2(Box, { flexDirection: "row", alignItems: "center", gap: 4, children: [
763
- extraClear && selectedItems.length > 0 && !isDisable && /* @__PURE__ */ jsx5(
844
+ /* @__PURE__ */ jsxs3(Box, { flexDirection: "row", alignItems: "center", gap: 4, children: [
845
+ extraClear && selectedItems.length > 0 && !isDisable && /* @__PURE__ */ jsx6(
764
846
  Box,
765
847
  {
766
848
  onPress: (e) => {
@@ -768,11 +850,11 @@ var MultiSelectControl = forwardRef(
768
850
  removeAllValues();
769
851
  },
770
852
  style: { cursor: "pointer" },
771
- children: /* @__PURE__ */ jsx5(Remove, { size: 18, color: iconColor, variant: "line" })
853
+ children: /* @__PURE__ */ jsx6(Remove2, { size: 18, color: iconColor, variant: "line" })
772
854
  }
773
855
  ),
774
- isError && /* @__PURE__ */ jsx5(ExclamationMarkCr, { size: 18, color: theme.colors.content.alert.primary }),
775
- iconRight ? iconRight : isOpen ? /* @__PURE__ */ jsx5(ChevronUp, { size: 18, color: iconColor, variant: "line" }) : /* @__PURE__ */ jsx5(ChevronDown, { size: 18, color: iconColor, variant: "line" })
856
+ isError && /* @__PURE__ */ jsx6(ExclamationMarkCr, { size: 18, color: theme.colors.content.alert.primary }),
857
+ iconRight ? iconRight : isOpen ? /* @__PURE__ */ jsx6(ChevronUp, { size: 18, color: iconColor, variant: "line" }) : /* @__PURE__ */ jsx6(ChevronDown, { size: 18, color: iconColor, variant: "line" })
776
858
  ] })
777
859
  ]
778
860
  }
@@ -890,11 +972,11 @@ var useMultiSelect = ({
890
972
  };
891
973
 
892
974
  // src/Portal.native.tsx
893
- import { Fragment, jsx as jsx6 } from "react/jsx-runtime";
894
- var Portal = ({ children }) => /* @__PURE__ */ jsx6(Fragment, { children });
975
+ import { Fragment, jsx as jsx7 } from "react/jsx-runtime";
976
+ var Portal = ({ children }) => /* @__PURE__ */ jsx7(Fragment, { children });
895
977
 
896
978
  // src/MultiSelect.tsx
897
- import { Fragment as Fragment2, jsx as jsx7, jsxs as jsxs3 } from "react/jsx-runtime";
979
+ import { Fragment as Fragment2, jsx as jsx8, jsxs as jsxs4 } from "react/jsx-runtime";
898
980
  var EXTERNAL_MENU_MIN_WIDTH_DEFAULT = 540;
899
981
  var SEARCH_ROW_HEIGHT = 60;
900
982
  var SELECT_ALL_ROW_HEIGHT = 37;
@@ -931,7 +1013,7 @@ var MultiSelect = forwardRef2(
931
1013
  themeMode,
932
1014
  themeProductContext
933
1015
  }, ref) => {
934
- const { theme } = useResolvedTheme3({ themeMode, themeProductContext });
1016
+ const { theme } = useResolvedTheme4({ themeMode, themeProductContext });
935
1017
  const modalId = useModalId();
936
1018
  const overlayLayer = useOverlayLayer();
937
1019
  const controlRef = useRef4(null);
@@ -1067,8 +1149,8 @@ var MultiSelect = forwardRef2(
1067
1149
  minWidth: menuMinWidth ?? EXTERNAL_MENU_MIN_WIDTH_DEFAULT,
1068
1150
  boxSizing: "border-box"
1069
1151
  } : void 0;
1070
- const dropdown = dropdownMenu && isOpen && !isDisable && (!isWeb || menuPosition) && /* @__PURE__ */ jsxs3(Fragment2, { children: [
1071
- !isWeb && /* @__PURE__ */ jsx7(
1152
+ const dropdown = dropdownMenu && isOpen && !isDisable && (!isWeb || menuPosition) && /* @__PURE__ */ jsxs4(Fragment2, { children: [
1153
+ !isWeb && /* @__PURE__ */ jsx8(
1072
1154
  Box,
1073
1155
  {
1074
1156
  "data-modal-id": modalId,
@@ -1084,7 +1166,7 @@ var MultiSelect = forwardRef2(
1084
1166
  onPress: onClose
1085
1167
  }
1086
1168
  ),
1087
- /* @__PURE__ */ jsxs3(
1169
+ /* @__PURE__ */ jsxs4(
1088
1170
  Box,
1089
1171
  {
1090
1172
  ref: menuRef,
@@ -1107,14 +1189,14 @@ var MultiSelect = forwardRef2(
1107
1189
  boxShadow: theme.shadow.popover
1108
1190
  },
1109
1191
  children: [
1110
- searchable && isWeb && /* @__PURE__ */ jsx7(
1192
+ searchable && isWeb && /* @__PURE__ */ jsx8(
1111
1193
  Box,
1112
1194
  {
1113
1195
  paddingHorizontal: sizeStyles.paddingHorizontal,
1114
1196
  paddingVertical: sizeStyles.paddingVertical,
1115
1197
  borderBottomWidth: 1,
1116
1198
  borderColor: theme.colors.border.secondary,
1117
- children: /* @__PURE__ */ jsxs3(
1199
+ children: /* @__PURE__ */ jsxs4(
1118
1200
  Box,
1119
1201
  {
1120
1202
  flexDirection: "row",
@@ -1122,15 +1204,15 @@ var MultiSelect = forwardRef2(
1122
1204
  gap: sizeStyles.paddingHorizontal / 2,
1123
1205
  paddingHorizontal: 4,
1124
1206
  children: [
1125
- /* @__PURE__ */ jsx7(
1207
+ /* @__PURE__ */ jsx8(
1126
1208
  Icon,
1127
1209
  {
1128
1210
  size: sizeStyles.iconSize - 2,
1129
1211
  color: inputColors.placeholder,
1130
- children: /* @__PURE__ */ jsx7(SearchIcon, {})
1212
+ children: /* @__PURE__ */ jsx8(SearchIcon, {})
1131
1213
  }
1132
1214
  ),
1133
- /* @__PURE__ */ jsx7(
1215
+ /* @__PURE__ */ jsx8(
1134
1216
  Box,
1135
1217
  {
1136
1218
  as: "input",
@@ -1157,7 +1239,7 @@ var MultiSelect = forwardRef2(
1157
1239
  )
1158
1240
  }
1159
1241
  ),
1160
- showSelectAll && /* @__PURE__ */ jsx7(
1242
+ showSelectAll && /* @__PURE__ */ jsx8(
1161
1243
  Box,
1162
1244
  {
1163
1245
  role: "button",
@@ -1174,7 +1256,7 @@ var MultiSelect = forwardRef2(
1174
1256
  backgroundColor: theme.colors.control.input.bgHover
1175
1257
  },
1176
1258
  style: { cursor: "pointer" },
1177
- children: /* @__PURE__ */ jsx7(
1259
+ children: /* @__PURE__ */ jsx8(
1178
1260
  Text,
1179
1261
  {
1180
1262
  color: theme.colors.content.brand.primary,
@@ -1186,7 +1268,7 @@ var MultiSelect = forwardRef2(
1186
1268
  )
1187
1269
  }
1188
1270
  ),
1189
- /* @__PURE__ */ jsx7(
1271
+ /* @__PURE__ */ jsx8(
1190
1272
  Box,
1191
1273
  {
1192
1274
  paddingVertical: 4,
@@ -1196,13 +1278,13 @@ var MultiSelect = forwardRef2(
1196
1278
  overflowX: optionListOverflowX,
1197
1279
  scrollbarWidth: "none"
1198
1280
  },
1199
- children: menuItems.length === 0 ? /* @__PURE__ */ jsx7(
1281
+ children: menuItems.length === 0 ? /* @__PURE__ */ jsx8(
1200
1282
  Box,
1201
1283
  {
1202
1284
  paddingVertical: sizeStyles.paddingVertical * 2,
1203
1285
  paddingHorizontal: sizeStyles.paddingHorizontal,
1204
1286
  alignItems: "center",
1205
- children: /* @__PURE__ */ jsx7(
1287
+ children: /* @__PURE__ */ jsx8(
1206
1288
  Text,
1207
1289
  {
1208
1290
  color: theme.colors.content.tertiary,
@@ -1215,7 +1297,7 @@ var MultiSelect = forwardRef2(
1215
1297
  const brandColors = theme.colors.control.brand.primary;
1216
1298
  const contentColors = theme.colors.content;
1217
1299
  const isInert = item.locked && item.checked;
1218
- return /* @__PURE__ */ jsx7(
1300
+ return /* @__PURE__ */ jsx8(
1219
1301
  Box,
1220
1302
  {
1221
1303
  testID,
@@ -1238,7 +1320,7 @@ var MultiSelect = forwardRef2(
1238
1320
  opacity: item.disabled ? 0.5 : 1,
1239
1321
  minWidth: optionRowMinWidth
1240
1322
  },
1241
- children: /* @__PURE__ */ jsx7(
1323
+ children: /* @__PURE__ */ jsx8(
1242
1324
  Text,
1243
1325
  {
1244
1326
  color: item.checked ? contentColors.on.brand : theme.colors.content.secondary,
@@ -1259,7 +1341,7 @@ var MultiSelect = forwardRef2(
1259
1341
  }
1260
1342
  )
1261
1343
  ] });
1262
- return /* @__PURE__ */ jsxs3(
1344
+ return /* @__PURE__ */ jsxs4(
1263
1345
  Box,
1264
1346
  {
1265
1347
  ref: containerRef,
@@ -1268,7 +1350,7 @@ var MultiSelect = forwardRef2(
1268
1350
  gap: sizeStyles.fieldGap,
1269
1351
  style: externalFieldLayout,
1270
1352
  children: [
1271
- label && /* @__PURE__ */ jsx7(
1353
+ label && /* @__PURE__ */ jsx8(
1272
1354
  Text,
1273
1355
  {
1274
1356
  color: theme.colors.content.secondary,
@@ -1277,7 +1359,7 @@ var MultiSelect = forwardRef2(
1277
1359
  children: label
1278
1360
  }
1279
1361
  ),
1280
- /* @__PURE__ */ jsxs3(
1362
+ /* @__PURE__ */ jsxs4(
1281
1363
  Box,
1282
1364
  {
1283
1365
  ref,
@@ -1286,7 +1368,7 @@ var MultiSelect = forwardRef2(
1286
1368
  ...externalFieldLayout ? { width: "100%" } : {}
1287
1369
  },
1288
1370
  children: [
1289
- /* @__PURE__ */ jsx7(
1371
+ /* @__PURE__ */ jsx8(
1290
1372
  MultiSelectControl,
1291
1373
  {
1292
1374
  ref: controlRef,
@@ -1311,11 +1393,11 @@ var MultiSelect = forwardRef2(
1311
1393
  extraClear
1312
1394
  }
1313
1395
  ),
1314
- isWeb ? /* @__PURE__ */ jsx7(Portal, { children: dropdown }) : dropdown
1396
+ isWeb ? /* @__PURE__ */ jsx8(Portal, { children: dropdown }) : dropdown
1315
1397
  ]
1316
1398
  }
1317
1399
  ),
1318
- errorMessage && /* @__PURE__ */ jsx7(
1400
+ errorMessage && /* @__PURE__ */ jsx8(
1319
1401
  Text,
1320
1402
  {
1321
1403
  color: theme.colors.content.alert.primary,