@xsolla/xui-multi-select 0.221.0 → 0.222.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/web/index.mjs CHANGED
@@ -70,7 +70,7 @@ function shouldForwardProp(key) {
70
70
  function createFilteredElement(defaultTag) {
71
71
  const Component = React.forwardRef(
72
72
  ({ children, elementType, ...props }, ref) => {
73
- const Tag2 = elementType || defaultTag;
73
+ const Tag = elementType || defaultTag;
74
74
  const htmlProps = {};
75
75
  for (const key of Object.keys(props)) {
76
76
  if (shouldForwardProp(key)) {
@@ -78,7 +78,7 @@ function createFilteredElement(defaultTag) {
78
78
  }
79
79
  }
80
80
  return React.createElement(
81
- Tag2,
81
+ Tag,
82
82
  { ref, ...htmlProps },
83
83
  children
84
84
  );
@@ -377,7 +377,7 @@ var isWeb = true;
377
377
  // src/MultiSelect.tsx
378
378
  import {
379
379
  useModalId,
380
- useResolvedTheme as useResolvedTheme3,
380
+ useResolvedTheme as useResolvedTheme4,
381
381
  useOverlayLayer,
382
382
  LAYER_OFFSET
383
383
  } from "@xsolla/xui-core";
@@ -385,11 +385,11 @@ import { Search as SearchIcon } from "@xsolla/xui-icons-base";
385
385
 
386
386
  // src/MultiSelectControl.tsx
387
387
  import { forwardRef, useRef as useRef2 } from "react";
388
- import { useResolvedTheme as useResolvedTheme2 } from "@xsolla/xui-core";
388
+ import { useResolvedTheme as useResolvedTheme3 } from "@xsolla/xui-core";
389
389
  import {
390
390
  ChevronDown,
391
391
  ChevronUp,
392
- Remove,
392
+ Remove as Remove2,
393
393
  ExclamationMarkCr
394
394
  } from "@xsolla/xui-icons-base";
395
395
 
@@ -400,9 +400,91 @@ import {
400
400
  useRef,
401
401
  useState
402
402
  } from "react";
403
- import { Tag } from "@xsolla/xui-tag";
403
+ import { useResolvedTheme as useResolvedTheme2 } from "@xsolla/xui-core";
404
+
405
+ // src/MultiSelectItem.tsx
404
406
  import { useResolvedTheme } from "@xsolla/xui-core";
407
+ import { Remove } from "@xsolla/xui-icons-base";
405
408
  import { jsx as jsx4, jsxs } from "react/jsx-runtime";
409
+ var MultiSelectItem = ({
410
+ size = "md",
411
+ children,
412
+ onRemove,
413
+ disabled = false,
414
+ interactive = false,
415
+ testID,
416
+ themeMode,
417
+ themeProductContext
418
+ }) => {
419
+ const { theme } = useResolvedTheme({ themeMode, themeProductContext });
420
+ const sizeStyles = theme.sizing.tag(size);
421
+ const chipColors = theme.colors.control.mono.secondary;
422
+ const inputColors = theme.colors.control.input;
423
+ const backgroundColor = disabled ? inputColors.bgDisable : chipColors.bg;
424
+ const contentColor = disabled ? inputColors.textDisable : theme.colors.content.primary;
425
+ const removeLabel = typeof children === "string" ? `Remove ${children}` : "Remove";
426
+ return /* @__PURE__ */ jsxs(
427
+ Box,
428
+ {
429
+ testID,
430
+ backgroundColor,
431
+ borderRadius: theme.shape.knob.lg.borderRadius,
432
+ height: sizeStyles.height,
433
+ paddingHorizontal: sizeStyles.padding,
434
+ flexDirection: "row",
435
+ alignItems: "center",
436
+ justifyContent: "center",
437
+ gap: sizeStyles.gap,
438
+ borderWidth: 0,
439
+ hoverStyle: interactive && !disabled ? { backgroundColor: chipColors.bgHover } : void 0,
440
+ style: {
441
+ overflow: "hidden",
442
+ textOverflow: "ellipsis",
443
+ whiteSpace: "nowrap"
444
+ },
445
+ children: [
446
+ children !== void 0 && children !== null && /* @__PURE__ */ jsx4(
447
+ Text,
448
+ {
449
+ color: contentColor,
450
+ fontSize: sizeStyles.fontSize,
451
+ fontWeight: "500",
452
+ whiteSpace: "nowrap",
453
+ style: {
454
+ overflow: "hidden",
455
+ textOverflow: "ellipsis"
456
+ },
457
+ children
458
+ }
459
+ ),
460
+ onRemove && /* @__PURE__ */ jsx4(
461
+ Box,
462
+ {
463
+ role: "button",
464
+ "aria-label": removeLabel,
465
+ "aria-disabled": disabled || void 0,
466
+ alignItems: "center",
467
+ justifyContent: "center",
468
+ onPress: disabled ? void 0 : onRemove,
469
+ style: { cursor: disabled ? "not-allowed" : "pointer" },
470
+ children: /* @__PURE__ */ jsx4(
471
+ Remove,
472
+ {
473
+ size: sizeStyles.iconSize,
474
+ color: contentColor,
475
+ variant: "line"
476
+ }
477
+ )
478
+ }
479
+ )
480
+ ]
481
+ }
482
+ );
483
+ };
484
+ MultiSelectItem.displayName = "MultiSelectItem";
485
+
486
+ // src/useMultiSelectControl.tsx
487
+ import { jsx as jsx5, jsxs as jsxs2 } from "react/jsx-runtime";
406
488
  var COUNT_ITEM_VALUE = "count-item";
407
489
  var useMultiSelectControl = ({
408
490
  variant,
@@ -418,7 +500,7 @@ var useMultiSelectControl = ({
418
500
  themeMode,
419
501
  themeProductContext
420
502
  }) => {
421
- const { theme } = useResolvedTheme({ themeMode, themeProductContext });
503
+ const { theme } = useResolvedTheme2({ themeMode, themeProductContext });
422
504
  const displayStateRef = useRef(0 /* Placeholder */);
423
505
  const savedWidthsRef = useRef(null);
424
506
  const itemsRef = useRef(null);
@@ -482,7 +564,7 @@ var useMultiSelectControl = ({
482
564
  };
483
565
  const setPlaceholder = () => {
484
566
  setSelectedContent(
485
- /* @__PURE__ */ jsx4(
567
+ /* @__PURE__ */ jsx5(
486
568
  Text,
487
569
  {
488
570
  color: theme.colors.control.input.placeholder,
@@ -535,7 +617,7 @@ var useMultiSelectControl = ({
535
617
  const canRemove = !isCount && !isLocked;
536
618
  const isReducable = index2 === 0 && displayStateRef.current === 3 /* Render */ && displayedItemsCount === 0 || flexible;
537
619
  if (variant === "tag") {
538
- return /* @__PURE__ */ jsx4(
620
+ return /* @__PURE__ */ jsx5(
539
621
  Box,
540
622
  {
541
623
  onPress: canRemove ? (e) => {
@@ -544,14 +626,14 @@ var useMultiSelectControl = ({
544
626
  } : void 0,
545
627
  style: {
546
628
  minWidth: isReducable ? 0 : "fit-content",
547
- opacity: disabled ? 0.5 : 1,
548
629
  cursor: isLocked ? "default" : disabled || isCount ? "not-allowed" : "pointer"
549
630
  },
550
- children: /* @__PURE__ */ jsx4(
551
- Tag,
631
+ children: /* @__PURE__ */ jsx5(
632
+ MultiSelectItem,
552
633
  {
553
634
  size,
554
- tone: "primary",
635
+ disabled,
636
+ interactive: canRemove,
555
637
  onRemove: removeTagsButtons && canRemove ? (e) => {
556
638
  e?.stopPropagation();
557
639
  if (!disabled) removeValue(item.value, e);
@@ -565,7 +647,7 @@ var useMultiSelectControl = ({
565
647
  }
566
648
  const isCountItem = hasHidden;
567
649
  const needsComma = index2 < displayedItems.length - 2 || index2 < displayedItems.length - 1 && !isCountItem;
568
- return /* @__PURE__ */ jsxs(
650
+ return /* @__PURE__ */ jsxs2(
569
651
  Text,
570
652
  {
571
653
  color: theme.colors.content.primary,
@@ -581,7 +663,7 @@ var useMultiSelectControl = ({
581
663
  },
582
664
  children: [
583
665
  item.label,
584
- needsComma ? ",\xA0" : "\xA0"
666
+ needsComma ? ", " : " "
585
667
  ]
586
668
  },
587
669
  item.value
@@ -667,7 +749,7 @@ var useMultiSelectControl = ({
667
749
  };
668
750
 
669
751
  // src/MultiSelectControl.tsx
670
- import { jsx as jsx5, jsxs as jsxs2 } from "react/jsx-runtime";
752
+ import { jsx as jsx6, jsxs as jsxs3 } from "react/jsx-runtime";
671
753
  var MultiSelectControl = forwardRef(
672
754
  ({
673
755
  variant = "tag",
@@ -692,7 +774,7 @@ var MultiSelectControl = forwardRef(
692
774
  themeMode,
693
775
  themeProductContext
694
776
  }, ref) => {
695
- const { theme } = useResolvedTheme2({ themeMode, themeProductContext });
777
+ const { theme } = useResolvedTheme3({ themeMode, themeProductContext });
696
778
  const sizeStyles = theme.sizing.input(size);
697
779
  const inputColors = theme.colors.control.input;
698
780
  const state = externalState || (disabled ? "disable" : "default");
@@ -727,7 +809,7 @@ var MultiSelectControl = forwardRef(
727
809
  borderColor = inputColors.borderHover;
728
810
  }
729
811
  const iconColor = isDisable ? inputColors.textDisable : inputColors.placeholder;
730
- return /* @__PURE__ */ jsxs2(
812
+ return /* @__PURE__ */ jsxs3(
731
813
  Box,
732
814
  {
733
815
  ref,
@@ -755,7 +837,7 @@ var MultiSelectControl = forwardRef(
755
837
  borderColor: inputColors.borderHover
756
838
  } : void 0,
757
839
  children: [
758
- /* @__PURE__ */ jsxs2(
840
+ /* @__PURE__ */ jsxs3(
759
841
  Box,
760
842
  {
761
843
  ref: containerRef,
@@ -765,8 +847,8 @@ var MultiSelectControl = forwardRef(
765
847
  gap: 8,
766
848
  style: { minWidth: 0 },
767
849
  children: [
768
- iconLeft && /* @__PURE__ */ jsx5(Icon, { size: sizeStyles.iconSize, color: iconColor, variant: "line", children: iconLeft }),
769
- /* @__PURE__ */ jsx5(
850
+ iconLeft && /* @__PURE__ */ jsx6(Icon, { size: sizeStyles.iconSize, color: iconColor, variant: "line", children: iconLeft }),
851
+ /* @__PURE__ */ jsx6(
770
852
  Box,
771
853
  {
772
854
  ref: itemsRef,
@@ -782,8 +864,8 @@ var MultiSelectControl = forwardRef(
782
864
  ]
783
865
  }
784
866
  ),
785
- /* @__PURE__ */ jsxs2(Box, { flexDirection: "row", alignItems: "center", gap: 4, children: [
786
- extraClear && selectedItems.length > 0 && !isDisable && /* @__PURE__ */ jsx5(
867
+ /* @__PURE__ */ jsxs3(Box, { flexDirection: "row", alignItems: "center", gap: 4, children: [
868
+ extraClear && selectedItems.length > 0 && !isDisable && /* @__PURE__ */ jsx6(
787
869
  Box,
788
870
  {
789
871
  onPress: (e) => {
@@ -791,11 +873,11 @@ var MultiSelectControl = forwardRef(
791
873
  removeAllValues();
792
874
  },
793
875
  style: { cursor: "pointer" },
794
- children: /* @__PURE__ */ jsx5(Remove, { size: 18, color: iconColor, variant: "line" })
876
+ children: /* @__PURE__ */ jsx6(Remove2, { size: 18, color: iconColor, variant: "line" })
795
877
  }
796
878
  ),
797
- isError && /* @__PURE__ */ jsx5(ExclamationMarkCr, { size: 18, color: theme.colors.content.alert.primary }),
798
- iconRight ? iconRight : isOpen ? /* @__PURE__ */ jsx5(ChevronUp, { size: 18, color: iconColor, variant: "line" }) : /* @__PURE__ */ jsx5(ChevronDown, { size: 18, color: iconColor, variant: "line" })
879
+ isError && /* @__PURE__ */ jsx6(ExclamationMarkCr, { size: 18, color: theme.colors.content.alert.primary }),
880
+ iconRight ? iconRight : isOpen ? /* @__PURE__ */ jsx6(ChevronUp, { size: 18, color: iconColor, variant: "line" }) : /* @__PURE__ */ jsx6(ChevronDown, { size: 18, color: iconColor, variant: "line" })
799
881
  ] })
800
882
  ]
801
883
  }
@@ -923,7 +1005,7 @@ var Portal = ({ children }) => {
923
1005
  };
924
1006
 
925
1007
  // src/MultiSelect.tsx
926
- import { Fragment, jsx as jsx6, jsxs as jsxs3 } from "react/jsx-runtime";
1008
+ import { Fragment, jsx as jsx7, jsxs as jsxs4 } from "react/jsx-runtime";
927
1009
  var EXTERNAL_MENU_MIN_WIDTH_DEFAULT = 540;
928
1010
  var SEARCH_ROW_HEIGHT = 60;
929
1011
  var SELECT_ALL_ROW_HEIGHT = 37;
@@ -960,7 +1042,7 @@ var MultiSelect = forwardRef2(
960
1042
  themeMode,
961
1043
  themeProductContext
962
1044
  }, ref) => {
963
- const { theme } = useResolvedTheme3({ themeMode, themeProductContext });
1045
+ const { theme } = useResolvedTheme4({ themeMode, themeProductContext });
964
1046
  const modalId = useModalId();
965
1047
  const overlayLayer = useOverlayLayer();
966
1048
  const controlRef = useRef4(null);
@@ -1096,8 +1178,8 @@ var MultiSelect = forwardRef2(
1096
1178
  minWidth: menuMinWidth ?? EXTERNAL_MENU_MIN_WIDTH_DEFAULT,
1097
1179
  boxSizing: "border-box"
1098
1180
  } : void 0;
1099
- const dropdown = dropdownMenu && isOpen && !isDisable && (!isWeb || menuPosition) && /* @__PURE__ */ jsxs3(Fragment, { children: [
1100
- !isWeb && /* @__PURE__ */ jsx6(
1181
+ const dropdown = dropdownMenu && isOpen && !isDisable && (!isWeb || menuPosition) && /* @__PURE__ */ jsxs4(Fragment, { children: [
1182
+ !isWeb && /* @__PURE__ */ jsx7(
1101
1183
  Box,
1102
1184
  {
1103
1185
  "data-modal-id": modalId,
@@ -1113,7 +1195,7 @@ var MultiSelect = forwardRef2(
1113
1195
  onPress: onClose
1114
1196
  }
1115
1197
  ),
1116
- /* @__PURE__ */ jsxs3(
1198
+ /* @__PURE__ */ jsxs4(
1117
1199
  Box,
1118
1200
  {
1119
1201
  ref: menuRef,
@@ -1136,14 +1218,14 @@ var MultiSelect = forwardRef2(
1136
1218
  boxShadow: theme.shadow.popover
1137
1219
  },
1138
1220
  children: [
1139
- searchable && isWeb && /* @__PURE__ */ jsx6(
1221
+ searchable && isWeb && /* @__PURE__ */ jsx7(
1140
1222
  Box,
1141
1223
  {
1142
1224
  paddingHorizontal: sizeStyles.paddingHorizontal,
1143
1225
  paddingVertical: sizeStyles.paddingVertical,
1144
1226
  borderBottomWidth: 1,
1145
1227
  borderColor: theme.colors.border.secondary,
1146
- children: /* @__PURE__ */ jsxs3(
1228
+ children: /* @__PURE__ */ jsxs4(
1147
1229
  Box,
1148
1230
  {
1149
1231
  flexDirection: "row",
@@ -1151,15 +1233,15 @@ var MultiSelect = forwardRef2(
1151
1233
  gap: sizeStyles.paddingHorizontal / 2,
1152
1234
  paddingHorizontal: 4,
1153
1235
  children: [
1154
- /* @__PURE__ */ jsx6(
1236
+ /* @__PURE__ */ jsx7(
1155
1237
  Icon,
1156
1238
  {
1157
1239
  size: sizeStyles.iconSize - 2,
1158
1240
  color: inputColors.placeholder,
1159
- children: /* @__PURE__ */ jsx6(SearchIcon, {})
1241
+ children: /* @__PURE__ */ jsx7(SearchIcon, {})
1160
1242
  }
1161
1243
  ),
1162
- /* @__PURE__ */ jsx6(
1244
+ /* @__PURE__ */ jsx7(
1163
1245
  Box,
1164
1246
  {
1165
1247
  as: "input",
@@ -1186,7 +1268,7 @@ var MultiSelect = forwardRef2(
1186
1268
  )
1187
1269
  }
1188
1270
  ),
1189
- showSelectAll && /* @__PURE__ */ jsx6(
1271
+ showSelectAll && /* @__PURE__ */ jsx7(
1190
1272
  Box,
1191
1273
  {
1192
1274
  role: "button",
@@ -1203,7 +1285,7 @@ var MultiSelect = forwardRef2(
1203
1285
  backgroundColor: theme.colors.control.input.bgHover
1204
1286
  },
1205
1287
  style: { cursor: "pointer" },
1206
- children: /* @__PURE__ */ jsx6(
1288
+ children: /* @__PURE__ */ jsx7(
1207
1289
  Text,
1208
1290
  {
1209
1291
  color: theme.colors.content.brand.primary,
@@ -1215,7 +1297,7 @@ var MultiSelect = forwardRef2(
1215
1297
  )
1216
1298
  }
1217
1299
  ),
1218
- /* @__PURE__ */ jsx6(
1300
+ /* @__PURE__ */ jsx7(
1219
1301
  Box,
1220
1302
  {
1221
1303
  paddingVertical: 4,
@@ -1225,13 +1307,13 @@ var MultiSelect = forwardRef2(
1225
1307
  overflowX: optionListOverflowX,
1226
1308
  scrollbarWidth: "none"
1227
1309
  },
1228
- children: menuItems.length === 0 ? /* @__PURE__ */ jsx6(
1310
+ children: menuItems.length === 0 ? /* @__PURE__ */ jsx7(
1229
1311
  Box,
1230
1312
  {
1231
1313
  paddingVertical: sizeStyles.paddingVertical * 2,
1232
1314
  paddingHorizontal: sizeStyles.paddingHorizontal,
1233
1315
  alignItems: "center",
1234
- children: /* @__PURE__ */ jsx6(
1316
+ children: /* @__PURE__ */ jsx7(
1235
1317
  Text,
1236
1318
  {
1237
1319
  color: theme.colors.content.tertiary,
@@ -1244,7 +1326,7 @@ var MultiSelect = forwardRef2(
1244
1326
  const brandColors = theme.colors.control.brand.primary;
1245
1327
  const contentColors = theme.colors.content;
1246
1328
  const isInert = item.locked && item.checked;
1247
- return /* @__PURE__ */ jsx6(
1329
+ return /* @__PURE__ */ jsx7(
1248
1330
  Box,
1249
1331
  {
1250
1332
  testID,
@@ -1267,7 +1349,7 @@ var MultiSelect = forwardRef2(
1267
1349
  opacity: item.disabled ? 0.5 : 1,
1268
1350
  minWidth: optionRowMinWidth
1269
1351
  },
1270
- children: /* @__PURE__ */ jsx6(
1352
+ children: /* @__PURE__ */ jsx7(
1271
1353
  Text,
1272
1354
  {
1273
1355
  color: item.checked ? contentColors.on.brand : theme.colors.content.secondary,
@@ -1288,7 +1370,7 @@ var MultiSelect = forwardRef2(
1288
1370
  }
1289
1371
  )
1290
1372
  ] });
1291
- return /* @__PURE__ */ jsxs3(
1373
+ return /* @__PURE__ */ jsxs4(
1292
1374
  Box,
1293
1375
  {
1294
1376
  ref: containerRef,
@@ -1297,7 +1379,7 @@ var MultiSelect = forwardRef2(
1297
1379
  gap: sizeStyles.fieldGap,
1298
1380
  style: externalFieldLayout,
1299
1381
  children: [
1300
- label && /* @__PURE__ */ jsx6(
1382
+ label && /* @__PURE__ */ jsx7(
1301
1383
  Text,
1302
1384
  {
1303
1385
  color: theme.colors.content.secondary,
@@ -1306,7 +1388,7 @@ var MultiSelect = forwardRef2(
1306
1388
  children: label
1307
1389
  }
1308
1390
  ),
1309
- /* @__PURE__ */ jsxs3(
1391
+ /* @__PURE__ */ jsxs4(
1310
1392
  Box,
1311
1393
  {
1312
1394
  ref,
@@ -1315,7 +1397,7 @@ var MultiSelect = forwardRef2(
1315
1397
  ...externalFieldLayout ? { width: "100%" } : {}
1316
1398
  },
1317
1399
  children: [
1318
- /* @__PURE__ */ jsx6(
1400
+ /* @__PURE__ */ jsx7(
1319
1401
  MultiSelectControl,
1320
1402
  {
1321
1403
  ref: controlRef,
@@ -1340,11 +1422,11 @@ var MultiSelect = forwardRef2(
1340
1422
  extraClear
1341
1423
  }
1342
1424
  ),
1343
- isWeb ? /* @__PURE__ */ jsx6(Portal, { children: dropdown }) : dropdown
1425
+ isWeb ? /* @__PURE__ */ jsx7(Portal, { children: dropdown }) : dropdown
1344
1426
  ]
1345
1427
  }
1346
1428
  ),
1347
- errorMessage && /* @__PURE__ */ jsx6(
1429
+ errorMessage && /* @__PURE__ */ jsx7(
1348
1430
  Text,
1349
1431
  {
1350
1432
  color: theme.colors.content.alert.primary,