@xsolla/xui-multi-select 0.133.0 → 0.134.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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xsolla/xui-multi-select",
3
- "version": "0.133.0",
3
+ "version": "0.134.0",
4
4
  "main": "./web/index.js",
5
5
  "module": "./web/index.mjs",
6
6
  "types": "./web/index.d.ts",
@@ -10,10 +10,10 @@
10
10
  "build:native": "PLATFORM=native tsup"
11
11
  },
12
12
  "dependencies": {
13
- "@xsolla/xui-checkbox": "0.133.0",
14
- "@xsolla/xui-core": "0.133.0",
15
- "@xsolla/xui-dropdown": "0.133.0",
16
- "@xsolla/xui-primitives-core": "0.133.0"
13
+ "@xsolla/xui-checkbox": "0.134.0",
14
+ "@xsolla/xui-core": "0.134.0",
15
+ "@xsolla/xui-dropdown": "0.134.0",
16
+ "@xsolla/xui-primitives-core": "0.134.0"
17
17
  },
18
18
  "peerDependencies": {
19
19
  "react": ">=16.8.0",
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 import_react10 = require("react");
38
+ var import_react8 = require("react");
39
39
 
40
40
  // ../primitives-web/src/Box.tsx
41
41
  var import_react = __toESM(require("react"));
@@ -267,7 +267,7 @@ var Icon = ({ children, ...props }) => {
267
267
  var import_xui_core4 = require("@xsolla/xui-core");
268
268
 
269
269
  // src/MultiSelectControl.tsx
270
- var import_react8 = require("react");
270
+ var import_react6 = require("react");
271
271
  var import_xui_core3 = require("@xsolla/xui-core");
272
272
 
273
273
  // ../icons-base/dist/web/index.mjs
@@ -715,12 +715,11 @@ var lineContent113 = `<svg viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.
715
715
  var Remove = (props) => /* @__PURE__ */ (0, import_jsx_runtime117.jsx)(BaseIcon, { ...props, solidContent: solidContent113, lineContent: lineContent113 });
716
716
 
717
717
  // src/useMultiSelectControl.tsx
718
- var import_react7 = require("react");
718
+ var import_react5 = require("react");
719
719
 
720
720
  // ../tag/dist/web/index.mjs
721
- var import_react5 = __toESM(require("react"), 1);
721
+ var import_react4 = __toESM(require("react"), 1);
722
722
  var import_styled_components6 = __toESM(require("styled-components"), 1);
723
- var import_react6 = __toESM(require("react"), 1);
724
723
  var import_jsx_runtime393 = require("react/jsx-runtime");
725
724
  var import_styled_components7 = __toESM(require("styled-components"), 1);
726
725
  var import_jsx_runtime394 = require("react/jsx-runtime");
@@ -729,7 +728,6 @@ var import_jsx_runtime395 = require("react/jsx-runtime");
729
728
  var import_xui_core = require("@xsolla/xui-core");
730
729
 
731
730
  // ../icons/dist/web/index.mjs
732
- var import_react4 = __toESM(require("react"), 1);
733
731
  var import_styled_components5 = __toESM(require("styled-components"), 1);
734
732
  var import_jsx_runtime391 = require("react/jsx-runtime");
735
733
 
@@ -812,109 +810,7 @@ var X = createLucideIcon("X", [
812
810
 
813
811
  // ../icons/dist/web/index.mjs
814
812
  var import_jsx_runtime392 = require("react/jsx-runtime");
815
- var NON_HTML_PROPS = /* @__PURE__ */ new Set([
816
- // BoxProps — layout & styling
817
- "backgroundColor",
818
- "borderColor",
819
- "borderWidth",
820
- "borderBottomWidth",
821
- "borderBottomColor",
822
- "borderTopWidth",
823
- "borderTopColor",
824
- "borderLeftWidth",
825
- "borderLeftColor",
826
- "borderRightWidth",
827
- "borderRightColor",
828
- "borderRadius",
829
- "borderStyle",
830
- "flexDirection",
831
- "flexWrap",
832
- "alignItems",
833
- "justifyContent",
834
- "alignSelf",
835
- "flex",
836
- "flexShrink",
837
- "gap",
838
- "position",
839
- "top",
840
- "bottom",
841
- "left",
842
- "right",
843
- "outline",
844
- "overflow",
845
- "overflowX",
846
- "overflowY",
847
- "zIndex",
848
- "cursor",
849
- "padding",
850
- "paddingHorizontal",
851
- "paddingVertical",
852
- "paddingTop",
853
- "paddingBottom",
854
- "paddingLeft",
855
- "paddingRight",
856
- "margin",
857
- "marginTop",
858
- "marginBottom",
859
- "marginLeft",
860
- "marginRight",
861
- "minWidth",
862
- "minHeight",
863
- "maxWidth",
864
- "maxHeight",
865
- "hoverStyle",
866
- "pressStyle",
867
- "focusStyle",
868
- "outlineColor",
869
- "outlineWidth",
870
- "outlineOffset",
871
- "outlineStyle",
872
- // BoxProps — RN-only
873
- "onPress",
874
- "onLayout",
875
- "onMoveShouldSetResponder",
876
- "onResponderGrant",
877
- "onResponderMove",
878
- "onResponderRelease",
879
- "onResponderTerminate",
880
- "testID",
881
- // Box — custom element type
882
- "elementType",
883
- // TextProps
884
- "fontSize",
885
- "fontWeight",
886
- "fontFamily",
887
- "lineHeight",
888
- "whiteSpace",
889
- "textAlign",
890
- "textDecoration",
891
- "numberOfLines",
892
- "letterSpacing",
893
- "textTransform",
894
- // SpinnerProps
895
- "strokeWidth",
896
- // DividerProps
897
- "vertical",
898
- "dashStroke"
899
- ]);
900
- function createFilteredElement(defaultTag) {
901
- const Component = import_react4.default.forwardRef(
902
- ({ children, elementType, ...props }, ref) => {
903
- const Tag2 = elementType || defaultTag;
904
- const htmlProps = {};
905
- for (const key of Object.keys(props)) {
906
- if (!NON_HTML_PROPS.has(key)) {
907
- htmlProps[key] = props[key];
908
- }
909
- }
910
- return import_react4.default.createElement(Tag2, { ref, ...htmlProps }, children);
911
- }
912
- );
913
- Component.displayName = `Filtered(${defaultTag})`;
914
- return Component;
915
- }
916
- var FilteredDiv = createFilteredElement("div");
917
- var StyledIcon3 = (0, import_styled_components5.default)(FilteredDiv)`
813
+ var StyledIcon3 = import_styled_components5.default.div`
918
814
  display: flex;
919
815
  align-items: center;
920
816
  justify-content: center;
@@ -936,109 +832,7 @@ var X2 = (props) => /* @__PURE__ */ (0, import_jsx_runtime392.jsx)(Icon3, { ...p
936
832
 
937
833
  // ../tag/dist/web/index.mjs
938
834
  var import_jsx_runtime396 = require("react/jsx-runtime");
939
- var NON_HTML_PROPS2 = /* @__PURE__ */ new Set([
940
- // BoxProps — layout & styling
941
- "backgroundColor",
942
- "borderColor",
943
- "borderWidth",
944
- "borderBottomWidth",
945
- "borderBottomColor",
946
- "borderTopWidth",
947
- "borderTopColor",
948
- "borderLeftWidth",
949
- "borderLeftColor",
950
- "borderRightWidth",
951
- "borderRightColor",
952
- "borderRadius",
953
- "borderStyle",
954
- "flexDirection",
955
- "flexWrap",
956
- "alignItems",
957
- "justifyContent",
958
- "alignSelf",
959
- "flex",
960
- "flexShrink",
961
- "gap",
962
- "position",
963
- "top",
964
- "bottom",
965
- "left",
966
- "right",
967
- "outline",
968
- "overflow",
969
- "overflowX",
970
- "overflowY",
971
- "zIndex",
972
- "cursor",
973
- "padding",
974
- "paddingHorizontal",
975
- "paddingVertical",
976
- "paddingTop",
977
- "paddingBottom",
978
- "paddingLeft",
979
- "paddingRight",
980
- "margin",
981
- "marginTop",
982
- "marginBottom",
983
- "marginLeft",
984
- "marginRight",
985
- "minWidth",
986
- "minHeight",
987
- "maxWidth",
988
- "maxHeight",
989
- "hoverStyle",
990
- "pressStyle",
991
- "focusStyle",
992
- "outlineColor",
993
- "outlineWidth",
994
- "outlineOffset",
995
- "outlineStyle",
996
- // BoxProps — RN-only
997
- "onPress",
998
- "onLayout",
999
- "onMoveShouldSetResponder",
1000
- "onResponderGrant",
1001
- "onResponderMove",
1002
- "onResponderRelease",
1003
- "onResponderTerminate",
1004
- "testID",
1005
- // Box — custom element type
1006
- "elementType",
1007
- // TextProps
1008
- "fontSize",
1009
- "fontWeight",
1010
- "fontFamily",
1011
- "lineHeight",
1012
- "whiteSpace",
1013
- "textAlign",
1014
- "textDecoration",
1015
- "numberOfLines",
1016
- "letterSpacing",
1017
- "textTransform",
1018
- // SpinnerProps
1019
- "strokeWidth",
1020
- // DividerProps
1021
- "vertical",
1022
- "dashStroke"
1023
- ]);
1024
- function createFilteredElement2(defaultTag) {
1025
- const Component = import_react6.default.forwardRef(
1026
- ({ children, elementType, ...props }, ref) => {
1027
- const Tag2 = elementType || defaultTag;
1028
- const htmlProps = {};
1029
- for (const key of Object.keys(props)) {
1030
- if (!NON_HTML_PROPS2.has(key)) {
1031
- htmlProps[key] = props[key];
1032
- }
1033
- }
1034
- return import_react6.default.createElement(Tag2, { ref, ...htmlProps }, children);
1035
- }
1036
- );
1037
- Component.displayName = `Filtered(${defaultTag})`;
1038
- return Component;
1039
- }
1040
- var FilteredDiv2 = createFilteredElement2("div");
1041
- var StyledBox2 = (0, import_styled_components6.default)(FilteredDiv2)`
835
+ var StyledBox2 = import_styled_components6.default.div`
1042
836
  display: flex;
1043
837
  box-sizing: border-box;
1044
838
  background-color: ${(props) => props.backgroundColor || "transparent"};
@@ -1125,7 +919,7 @@ var StyledBox2 = (0, import_styled_components6.default)(FilteredDiv2)`
1125
919
  ${(props) => props.pressStyle?.backgroundColor && `background-color: ${props.pressStyle.backgroundColor};`}
1126
920
  }
1127
921
  `;
1128
- var Box2 = import_react5.default.forwardRef(
922
+ var Box2 = import_react4.default.forwardRef(
1129
923
  ({
1130
924
  children,
1131
925
  onPress,
@@ -1177,7 +971,7 @@ var Box2 = import_react5.default.forwardRef(
1177
971
  StyledBox2,
1178
972
  {
1179
973
  ref,
1180
- elementType: as,
974
+ as,
1181
975
  id,
1182
976
  type: as === "button" ? type || "button" : void 0,
1183
977
  disabled: as === "button" ? disabled : void 0,
@@ -1204,8 +998,7 @@ var Box2 = import_react5.default.forwardRef(
1204
998
  }
1205
999
  );
1206
1000
  Box2.displayName = "Box";
1207
- var FilteredSpan = createFilteredElement2("span");
1208
- var StyledText2 = (0, import_styled_components7.default)(FilteredSpan)`
1001
+ var StyledText2 = import_styled_components7.default.span`
1209
1002
  color: ${(props) => props.color || "inherit"};
1210
1003
  font-size: ${(props) => typeof props.fontSize === "number" ? `${props.fontSize}px` : props.fontSize || "inherit"};
1211
1004
  font-weight: ${(props) => props.fontWeight || "normal"};
@@ -1234,8 +1027,7 @@ var Text2 = ({
1234
1027
  }
1235
1028
  );
1236
1029
  };
1237
- var FilteredDiv22 = createFilteredElement2("div");
1238
- var StyledIcon4 = (0, import_styled_components8.default)(FilteredDiv22)`
1030
+ var StyledIcon4 = import_styled_components8.default.div`
1239
1031
  display: flex;
1240
1032
  align-items: center;
1241
1033
  justify-content: center;
@@ -1407,15 +1199,15 @@ var useMultiSelectControl = ({
1407
1199
  themeProductContext
1408
1200
  }) => {
1409
1201
  const { theme } = (0, import_xui_core2.useResolvedTheme)({ themeMode, themeProductContext });
1410
- const displayStateRef = (0, import_react7.useRef)(0 /* Placeholder */);
1411
- const savedWidthsRef = (0, import_react7.useRef)(null);
1412
- const itemsRef = (0, import_react7.useRef)(null);
1413
- const [itemsWidth, setItemsWidth] = (0, import_react7.useState)(0);
1414
- const [selectedContent, setSelectedContent] = (0, import_react7.useState)(
1202
+ const displayStateRef = (0, import_react5.useRef)(0 /* Placeholder */);
1203
+ const savedWidthsRef = (0, import_react5.useRef)(null);
1204
+ const itemsRef = (0, import_react5.useRef)(null);
1205
+ const [itemsWidth, setItemsWidth] = (0, import_react5.useState)(0);
1206
+ const [selectedContent, setSelectedContent] = (0, import_react5.useState)(
1415
1207
  null
1416
1208
  );
1417
1209
  const isPlaceholder = !selectedItems || selectedItems.length === 0;
1418
- (0, import_react7.useEffect)(() => {
1210
+ (0, import_react5.useEffect)(() => {
1419
1211
  if (!containerRef.current) return;
1420
1212
  const resizeObserver = new ResizeObserver((entries) => {
1421
1213
  for (const entry of entries) {
@@ -1425,7 +1217,7 @@ var useMultiSelectControl = ({
1425
1217
  resizeObserver.observe(containerRef.current);
1426
1218
  return () => resizeObserver.disconnect();
1427
1219
  }, [containerRef]);
1428
- const widthsDependencies = (0, import_react7.useMemo)(
1220
+ const widthsDependencies = (0, import_react5.useMemo)(
1429
1221
  () => ({
1430
1222
  stateList: stateList.map((item) => item.value),
1431
1223
  variant,
@@ -1583,7 +1375,7 @@ var useMultiSelectControl = ({
1583
1375
  displayStateRef.current = 3 /* Render */;
1584
1376
  setItemsRender();
1585
1377
  };
1586
- (0, import_react7.useEffect)(() => {
1378
+ (0, import_react5.useEffect)(() => {
1587
1379
  if (isPlaceholder) {
1588
1380
  displayStateRef.current = 0 /* Placeholder */;
1589
1381
  setPlaceholder();
@@ -1617,7 +1409,7 @@ var useMultiSelectControl = ({
1617
1409
  widthsDependencies,
1618
1410
  stateList
1619
1411
  ]);
1620
- (0, import_react7.useEffect)(() => {
1412
+ (0, import_react5.useEffect)(() => {
1621
1413
  if (displayStateRef.current !== 2 /* Calculation */) return;
1622
1414
  const rafId = requestAnimationFrame(() => {
1623
1415
  if (displayStateRef.current === 2 /* Calculation */) {
@@ -1636,7 +1428,7 @@ var useMultiSelectControl = ({
1636
1428
 
1637
1429
  // src/MultiSelectControl.tsx
1638
1430
  var import_jsx_runtime398 = require("react/jsx-runtime");
1639
- var MultiSelectControl = (0, import_react8.forwardRef)(
1431
+ var MultiSelectControl = (0, import_react6.forwardRef)(
1640
1432
  ({
1641
1433
  variant = "tag",
1642
1434
  flexible = true,
@@ -1664,7 +1456,7 @@ var MultiSelectControl = (0, import_react8.forwardRef)(
1664
1456
  const inputColors = theme.colors.control.input;
1665
1457
  const state = externalState || (disabled ? "disable" : "default");
1666
1458
  const isDisable = state === "disable" || disabled;
1667
- const containerRef = (0, import_react8.useRef)(null);
1459
+ const containerRef = (0, import_react6.useRef)(null);
1668
1460
  const { itemsRef, selectedContent, isCalculating } = useMultiSelectControl({
1669
1461
  variant,
1670
1462
  flexible,
@@ -1787,7 +1579,7 @@ var MultiSelectControl = (0, import_react8.forwardRef)(
1787
1579
  MultiSelectControl.displayName = "MultiSelectControl";
1788
1580
 
1789
1581
  // src/useMultiSelect.ts
1790
- var import_react9 = require("react");
1582
+ var import_react7 = require("react");
1791
1583
  var initialState = {
1792
1584
  values: [],
1793
1585
  selectedItems: [],
@@ -1798,12 +1590,12 @@ var useMultiSelect = ({
1798
1590
  value = [],
1799
1591
  onChange
1800
1592
  }) => {
1801
- const [state, setState] = (0, import_react9.useState)(initialState);
1802
- const optionsRef = (0, import_react9.useRef)(options);
1803
- (0, import_react9.useEffect)(() => {
1593
+ const [state, setState] = (0, import_react7.useState)(initialState);
1594
+ const optionsRef = (0, import_react7.useRef)(options);
1595
+ (0, import_react7.useEffect)(() => {
1804
1596
  optionsRef.current = options;
1805
1597
  }, [options]);
1806
- (0, import_react9.useEffect)(() => {
1598
+ (0, import_react7.useEffect)(() => {
1807
1599
  const selectedItems = options.filter((opt) => value.includes(opt.value));
1808
1600
  setState((prevState) => ({
1809
1601
  ...prevState,
@@ -1811,7 +1603,7 @@ var useMultiSelect = ({
1811
1603
  selectedItems
1812
1604
  }));
1813
1605
  }, [options, value]);
1814
- const onChoose = (0, import_react9.useCallback)(
1606
+ const onChoose = (0, import_react7.useCallback)(
1815
1607
  (selectedIds) => {
1816
1608
  const newValues = optionsRef.current.filter((opt) => selectedIds.includes(String(opt.value))).map((opt) => opt.value);
1817
1609
  const newSelectedItems = optionsRef.current.filter(
@@ -1826,7 +1618,7 @@ var useMultiSelect = ({
1826
1618
  },
1827
1619
  [onChange]
1828
1620
  );
1829
- const onRemove = (0, import_react9.useCallback)(
1621
+ const onRemove = (0, import_react7.useCallback)(
1830
1622
  (value2, event) => {
1831
1623
  event?.stopPropagation();
1832
1624
  setState((prev) => {
@@ -1844,7 +1636,7 @@ var useMultiSelect = ({
1844
1636
  },
1845
1637
  [onChange]
1846
1638
  );
1847
- const onRemoveAll = (0, import_react9.useCallback)(() => {
1639
+ const onRemoveAll = (0, import_react7.useCallback)(() => {
1848
1640
  setState((prevState) => ({
1849
1641
  ...prevState,
1850
1642
  values: [],
@@ -1852,13 +1644,13 @@ var useMultiSelect = ({
1852
1644
  }));
1853
1645
  onChange?.([]);
1854
1646
  }, [onChange]);
1855
- const onSelectClick = (0, import_react9.useCallback)(() => {
1647
+ const onSelectClick = (0, import_react7.useCallback)(() => {
1856
1648
  setState((prevState) => ({
1857
1649
  ...prevState,
1858
1650
  isOpen: !prevState.isOpen
1859
1651
  }));
1860
1652
  }, []);
1861
- const onClose = (0, import_react9.useCallback)(() => {
1653
+ const onClose = (0, import_react7.useCallback)(() => {
1862
1654
  setState((prevState) => ({
1863
1655
  ...prevState,
1864
1656
  isOpen: false
@@ -1879,7 +1671,7 @@ var useMultiSelect = ({
1879
1671
 
1880
1672
  // src/MultiSelect.tsx
1881
1673
  var import_jsx_runtime399 = require("react/jsx-runtime");
1882
- var MultiSelect = (0, import_react10.forwardRef)(
1674
+ var MultiSelect = (0, import_react8.forwardRef)(
1883
1675
  ({
1884
1676
  options,
1885
1677
  errorMessage,
@@ -1901,8 +1693,8 @@ var MultiSelect = (0, import_react10.forwardRef)(
1901
1693
  themeProductContext
1902
1694
  }, ref) => {
1903
1695
  const { theme } = (0, import_xui_core4.useResolvedTheme)({ themeMode, themeProductContext });
1904
- const controlRef = (0, import_react10.useRef)(null);
1905
- const menuRef = (0, import_react10.useRef)(null);
1696
+ const controlRef = (0, import_react8.useRef)(null);
1697
+ const menuRef = (0, import_react8.useRef)(null);
1906
1698
  const sizeStyles = theme.sizing.input(size);
1907
1699
  const state = externalState || (disabled ? "disable" : "default");
1908
1700
  const isDisable = state === "disable" || disabled;
@@ -1923,7 +1715,7 @@ var MultiSelect = (0, import_react10.forwardRef)(
1923
1715
  value,
1924
1716
  onChange
1925
1717
  });
1926
- (0, import_react10.useEffect)(() => {
1718
+ (0, import_react8.useEffect)(() => {
1927
1719
  if (isDisable) {
1928
1720
  onClose();
1929
1721
  }