@xsolla/xui-multi-select 0.132.0 → 0.133.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.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_react8 = require("react");
38
+ var import_react10 = require("react");
39
39
 
40
40
  // ../primitives-native/src/Box.tsx
41
41
  var import_react_native = require("react-native");
@@ -302,7 +302,7 @@ var Icon = ({ children, color, size }) => {
302
302
  var import_xui_core4 = require("@xsolla/xui-core");
303
303
 
304
304
  // src/MultiSelectControl.tsx
305
- var import_react6 = require("react");
305
+ var import_react8 = require("react");
306
306
  var import_xui_core3 = require("@xsolla/xui-core");
307
307
 
308
308
  // ../icons-base/dist/web/index.mjs
@@ -750,11 +750,12 @@ var lineContent113 = `<svg viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.
750
750
  var Remove = (props) => /* @__PURE__ */ (0, import_jsx_runtime117.jsx)(BaseIcon, { ...props, solidContent: solidContent113, lineContent: lineContent113 });
751
751
 
752
752
  // src/useMultiSelectControl.tsx
753
- var import_react5 = require("react");
753
+ var import_react7 = require("react");
754
754
 
755
755
  // ../tag/dist/web/index.mjs
756
- var import_react4 = __toESM(require("react"), 1);
756
+ var import_react5 = __toESM(require("react"), 1);
757
757
  var import_styled_components3 = __toESM(require("styled-components"), 1);
758
+ var import_react6 = __toESM(require("react"), 1);
758
759
  var import_jsx_runtime393 = require("react/jsx-runtime");
759
760
  var import_styled_components4 = __toESM(require("styled-components"), 1);
760
761
  var import_jsx_runtime394 = require("react/jsx-runtime");
@@ -763,6 +764,7 @@ var import_jsx_runtime395 = require("react/jsx-runtime");
763
764
  var import_xui_core = require("@xsolla/xui-core");
764
765
 
765
766
  // ../icons/dist/web/index.mjs
767
+ var import_react4 = __toESM(require("react"), 1);
766
768
  var import_styled_components2 = __toESM(require("styled-components"), 1);
767
769
  var import_jsx_runtime391 = require("react/jsx-runtime");
768
770
 
@@ -845,7 +847,109 @@ var X = createLucideIcon("X", [
845
847
 
846
848
  // ../icons/dist/web/index.mjs
847
849
  var import_jsx_runtime392 = require("react/jsx-runtime");
848
- var StyledIcon2 = import_styled_components2.default.div`
850
+ var NON_HTML_PROPS = /* @__PURE__ */ new Set([
851
+ // BoxProps — layout & styling
852
+ "backgroundColor",
853
+ "borderColor",
854
+ "borderWidth",
855
+ "borderBottomWidth",
856
+ "borderBottomColor",
857
+ "borderTopWidth",
858
+ "borderTopColor",
859
+ "borderLeftWidth",
860
+ "borderLeftColor",
861
+ "borderRightWidth",
862
+ "borderRightColor",
863
+ "borderRadius",
864
+ "borderStyle",
865
+ "flexDirection",
866
+ "flexWrap",
867
+ "alignItems",
868
+ "justifyContent",
869
+ "alignSelf",
870
+ "flex",
871
+ "flexShrink",
872
+ "gap",
873
+ "position",
874
+ "top",
875
+ "bottom",
876
+ "left",
877
+ "right",
878
+ "outline",
879
+ "overflow",
880
+ "overflowX",
881
+ "overflowY",
882
+ "zIndex",
883
+ "cursor",
884
+ "padding",
885
+ "paddingHorizontal",
886
+ "paddingVertical",
887
+ "paddingTop",
888
+ "paddingBottom",
889
+ "paddingLeft",
890
+ "paddingRight",
891
+ "margin",
892
+ "marginTop",
893
+ "marginBottom",
894
+ "marginLeft",
895
+ "marginRight",
896
+ "minWidth",
897
+ "minHeight",
898
+ "maxWidth",
899
+ "maxHeight",
900
+ "hoverStyle",
901
+ "pressStyle",
902
+ "focusStyle",
903
+ "outlineColor",
904
+ "outlineWidth",
905
+ "outlineOffset",
906
+ "outlineStyle",
907
+ // BoxProps — RN-only
908
+ "onPress",
909
+ "onLayout",
910
+ "onMoveShouldSetResponder",
911
+ "onResponderGrant",
912
+ "onResponderMove",
913
+ "onResponderRelease",
914
+ "onResponderTerminate",
915
+ "testID",
916
+ // Box — custom element type
917
+ "elementType",
918
+ // TextProps
919
+ "fontSize",
920
+ "fontWeight",
921
+ "fontFamily",
922
+ "lineHeight",
923
+ "whiteSpace",
924
+ "textAlign",
925
+ "textDecoration",
926
+ "numberOfLines",
927
+ "letterSpacing",
928
+ "textTransform",
929
+ // SpinnerProps
930
+ "strokeWidth",
931
+ // DividerProps
932
+ "vertical",
933
+ "dashStroke"
934
+ ]);
935
+ function createFilteredElement(defaultTag) {
936
+ const Component = import_react4.default.forwardRef(
937
+ ({ children, elementType, ...props }, ref) => {
938
+ const Tag2 = elementType || defaultTag;
939
+ const htmlProps = {};
940
+ for (const key of Object.keys(props)) {
941
+ if (!NON_HTML_PROPS.has(key)) {
942
+ htmlProps[key] = props[key];
943
+ }
944
+ }
945
+ return import_react4.default.createElement(Tag2, { ref, ...htmlProps }, children);
946
+ }
947
+ );
948
+ Component.displayName = `Filtered(${defaultTag})`;
949
+ return Component;
950
+ }
951
+ var FilteredDiv = createFilteredElement("div");
952
+ var StyledIcon2 = (0, import_styled_components2.default)(FilteredDiv)`
849
953
  display: flex;
850
954
  align-items: center;
851
955
  justify-content: center;
@@ -867,7 +971,109 @@ var X2 = (props) => /* @__PURE__ */ (0, import_jsx_runtime392.jsx)(Icon3, { ...p
867
971
 
868
972
  // ../tag/dist/web/index.mjs
869
973
  var import_jsx_runtime396 = require("react/jsx-runtime");
870
- var StyledBox = import_styled_components3.default.div`
974
+ var NON_HTML_PROPS2 = /* @__PURE__ */ new Set([
975
+ // BoxProps — layout & styling
976
+ "backgroundColor",
977
+ "borderColor",
978
+ "borderWidth",
979
+ "borderBottomWidth",
980
+ "borderBottomColor",
981
+ "borderTopWidth",
982
+ "borderTopColor",
983
+ "borderLeftWidth",
984
+ "borderLeftColor",
985
+ "borderRightWidth",
986
+ "borderRightColor",
987
+ "borderRadius",
988
+ "borderStyle",
989
+ "flexDirection",
990
+ "flexWrap",
991
+ "alignItems",
992
+ "justifyContent",
993
+ "alignSelf",
994
+ "flex",
995
+ "flexShrink",
996
+ "gap",
997
+ "position",
998
+ "top",
999
+ "bottom",
1000
+ "left",
1001
+ "right",
1002
+ "outline",
1003
+ "overflow",
1004
+ "overflowX",
1005
+ "overflowY",
1006
+ "zIndex",
1007
+ "cursor",
1008
+ "padding",
1009
+ "paddingHorizontal",
1010
+ "paddingVertical",
1011
+ "paddingTop",
1012
+ "paddingBottom",
1013
+ "paddingLeft",
1014
+ "paddingRight",
1015
+ "margin",
1016
+ "marginTop",
1017
+ "marginBottom",
1018
+ "marginLeft",
1019
+ "marginRight",
1020
+ "minWidth",
1021
+ "minHeight",
1022
+ "maxWidth",
1023
+ "maxHeight",
1024
+ "hoverStyle",
1025
+ "pressStyle",
1026
+ "focusStyle",
1027
+ "outlineColor",
1028
+ "outlineWidth",
1029
+ "outlineOffset",
1030
+ "outlineStyle",
1031
+ // BoxProps — RN-only
1032
+ "onPress",
1033
+ "onLayout",
1034
+ "onMoveShouldSetResponder",
1035
+ "onResponderGrant",
1036
+ "onResponderMove",
1037
+ "onResponderRelease",
1038
+ "onResponderTerminate",
1039
+ "testID",
1040
+ // Box — custom element type
1041
+ "elementType",
1042
+ // TextProps
1043
+ "fontSize",
1044
+ "fontWeight",
1045
+ "fontFamily",
1046
+ "lineHeight",
1047
+ "whiteSpace",
1048
+ "textAlign",
1049
+ "textDecoration",
1050
+ "numberOfLines",
1051
+ "letterSpacing",
1052
+ "textTransform",
1053
+ // SpinnerProps
1054
+ "strokeWidth",
1055
+ // DividerProps
1056
+ "vertical",
1057
+ "dashStroke"
1058
+ ]);
1059
+ function createFilteredElement2(defaultTag) {
1060
+ const Component = import_react6.default.forwardRef(
1061
+ ({ children, elementType, ...props }, ref) => {
1062
+ const Tag2 = elementType || defaultTag;
1063
+ const htmlProps = {};
1064
+ for (const key of Object.keys(props)) {
1065
+ if (!NON_HTML_PROPS2.has(key)) {
1066
+ htmlProps[key] = props[key];
1067
+ }
1068
+ }
1069
+ return import_react6.default.createElement(Tag2, { ref, ...htmlProps }, children);
1070
+ }
1071
+ );
1072
+ Component.displayName = `Filtered(${defaultTag})`;
1073
+ return Component;
1074
+ }
1075
+ var FilteredDiv2 = createFilteredElement2("div");
1076
+ var StyledBox = (0, import_styled_components3.default)(FilteredDiv2)`
871
1077
  display: flex;
872
1078
  box-sizing: border-box;
873
1079
  background-color: ${(props) => props.backgroundColor || "transparent"};
@@ -954,7 +1160,7 @@ var StyledBox = import_styled_components3.default.div`
954
1160
  ${(props) => props.pressStyle?.backgroundColor && `background-color: ${props.pressStyle.backgroundColor};`}
955
1161
  }
956
1162
  `;
957
- var Box2 = import_react4.default.forwardRef(
1163
+ var Box2 = import_react5.default.forwardRef(
958
1164
  ({
959
1165
  children,
960
1166
  onPress,
@@ -1006,7 +1212,7 @@ var Box2 = import_react4.default.forwardRef(
1006
1212
  StyledBox,
1007
1213
  {
1008
1214
  ref,
1009
- as,
1215
+ elementType: as,
1010
1216
  id,
1011
1217
  type: as === "button" ? type || "button" : void 0,
1012
1218
  disabled: as === "button" ? disabled : void 0,
@@ -1033,7 +1239,8 @@ var Box2 = import_react4.default.forwardRef(
1033
1239
  }
1034
1240
  );
1035
1241
  Box2.displayName = "Box";
1036
- var StyledText = import_styled_components4.default.span`
1242
+ var FilteredSpan = createFilteredElement2("span");
1243
+ var StyledText = (0, import_styled_components4.default)(FilteredSpan)`
1037
1244
  color: ${(props) => props.color || "inherit"};
1038
1245
  font-size: ${(props) => typeof props.fontSize === "number" ? `${props.fontSize}px` : props.fontSize || "inherit"};
1039
1246
  font-weight: ${(props) => props.fontWeight || "normal"};
@@ -1062,7 +1269,8 @@ var Text2 = ({
1062
1269
  }
1063
1270
  );
1064
1271
  };
1065
- var StyledIcon3 = import_styled_components5.default.div`
1272
+ var FilteredDiv22 = createFilteredElement2("div");
1273
+ var StyledIcon3 = (0, import_styled_components5.default)(FilteredDiv22)`
1066
1274
  display: flex;
1067
1275
  align-items: center;
1068
1276
  justify-content: center;
@@ -1234,15 +1442,15 @@ var useMultiSelectControl = ({
1234
1442
  themeProductContext
1235
1443
  }) => {
1236
1444
  const { theme } = (0, import_xui_core2.useResolvedTheme)({ themeMode, themeProductContext });
1237
- const displayStateRef = (0, import_react5.useRef)(0 /* Placeholder */);
1238
- const savedWidthsRef = (0, import_react5.useRef)(null);
1239
- const itemsRef = (0, import_react5.useRef)(null);
1240
- const [itemsWidth, setItemsWidth] = (0, import_react5.useState)(0);
1241
- const [selectedContent, setSelectedContent] = (0, import_react5.useState)(
1445
+ const displayStateRef = (0, import_react7.useRef)(0 /* Placeholder */);
1446
+ const savedWidthsRef = (0, import_react7.useRef)(null);
1447
+ const itemsRef = (0, import_react7.useRef)(null);
1448
+ const [itemsWidth, setItemsWidth] = (0, import_react7.useState)(0);
1449
+ const [selectedContent, setSelectedContent] = (0, import_react7.useState)(
1242
1450
  null
1243
1451
  );
1244
1452
  const isPlaceholder = !selectedItems || selectedItems.length === 0;
1245
- (0, import_react5.useEffect)(() => {
1453
+ (0, import_react7.useEffect)(() => {
1246
1454
  if (!containerRef.current) return;
1247
1455
  const resizeObserver = new ResizeObserver((entries) => {
1248
1456
  for (const entry of entries) {
@@ -1252,7 +1460,7 @@ var useMultiSelectControl = ({
1252
1460
  resizeObserver.observe(containerRef.current);
1253
1461
  return () => resizeObserver.disconnect();
1254
1462
  }, [containerRef]);
1255
- const widthsDependencies = (0, import_react5.useMemo)(
1463
+ const widthsDependencies = (0, import_react7.useMemo)(
1256
1464
  () => ({
1257
1465
  stateList: stateList.map((item) => item.value),
1258
1466
  variant,
@@ -1410,7 +1618,7 @@ var useMultiSelectControl = ({
1410
1618
  displayStateRef.current = 3 /* Render */;
1411
1619
  setItemsRender();
1412
1620
  };
1413
- (0, import_react5.useEffect)(() => {
1621
+ (0, import_react7.useEffect)(() => {
1414
1622
  if (isPlaceholder) {
1415
1623
  displayStateRef.current = 0 /* Placeholder */;
1416
1624
  setPlaceholder();
@@ -1444,7 +1652,7 @@ var useMultiSelectControl = ({
1444
1652
  widthsDependencies,
1445
1653
  stateList
1446
1654
  ]);
1447
- (0, import_react5.useEffect)(() => {
1655
+ (0, import_react7.useEffect)(() => {
1448
1656
  if (displayStateRef.current !== 2 /* Calculation */) return;
1449
1657
  const rafId = requestAnimationFrame(() => {
1450
1658
  if (displayStateRef.current === 2 /* Calculation */) {
@@ -1463,7 +1671,7 @@ var useMultiSelectControl = ({
1463
1671
 
1464
1672
  // src/MultiSelectControl.tsx
1465
1673
  var import_jsx_runtime398 = require("react/jsx-runtime");
1466
- var MultiSelectControl = (0, import_react6.forwardRef)(
1674
+ var MultiSelectControl = (0, import_react8.forwardRef)(
1467
1675
  ({
1468
1676
  variant = "tag",
1469
1677
  flexible = true,
@@ -1491,7 +1699,7 @@ var MultiSelectControl = (0, import_react6.forwardRef)(
1491
1699
  const inputColors = theme.colors.control.input;
1492
1700
  const state = externalState || (disabled ? "disable" : "default");
1493
1701
  const isDisable = state === "disable" || disabled;
1494
- const containerRef = (0, import_react6.useRef)(null);
1702
+ const containerRef = (0, import_react8.useRef)(null);
1495
1703
  const { itemsRef, selectedContent, isCalculating } = useMultiSelectControl({
1496
1704
  variant,
1497
1705
  flexible,
@@ -1614,7 +1822,7 @@ var MultiSelectControl = (0, import_react6.forwardRef)(
1614
1822
  MultiSelectControl.displayName = "MultiSelectControl";
1615
1823
 
1616
1824
  // src/useMultiSelect.ts
1617
- var import_react7 = require("react");
1825
+ var import_react9 = require("react");
1618
1826
  var initialState = {
1619
1827
  values: [],
1620
1828
  selectedItems: [],
@@ -1625,12 +1833,12 @@ var useMultiSelect = ({
1625
1833
  value = [],
1626
1834
  onChange
1627
1835
  }) => {
1628
- const [state, setState] = (0, import_react7.useState)(initialState);
1629
- const optionsRef = (0, import_react7.useRef)(options);
1630
- (0, import_react7.useEffect)(() => {
1836
+ const [state, setState] = (0, import_react9.useState)(initialState);
1837
+ const optionsRef = (0, import_react9.useRef)(options);
1838
+ (0, import_react9.useEffect)(() => {
1631
1839
  optionsRef.current = options;
1632
1840
  }, [options]);
1633
- (0, import_react7.useEffect)(() => {
1841
+ (0, import_react9.useEffect)(() => {
1634
1842
  const selectedItems = options.filter((opt) => value.includes(opt.value));
1635
1843
  setState((prevState) => ({
1636
1844
  ...prevState,
@@ -1638,7 +1846,7 @@ var useMultiSelect = ({
1638
1846
  selectedItems
1639
1847
  }));
1640
1848
  }, [options, value]);
1641
- const onChoose = (0, import_react7.useCallback)(
1849
+ const onChoose = (0, import_react9.useCallback)(
1642
1850
  (selectedIds) => {
1643
1851
  const newValues = optionsRef.current.filter((opt) => selectedIds.includes(String(opt.value))).map((opt) => opt.value);
1644
1852
  const newSelectedItems = optionsRef.current.filter(
@@ -1653,7 +1861,7 @@ var useMultiSelect = ({
1653
1861
  },
1654
1862
  [onChange]
1655
1863
  );
1656
- const onRemove = (0, import_react7.useCallback)(
1864
+ const onRemove = (0, import_react9.useCallback)(
1657
1865
  (value2, event) => {
1658
1866
  event?.stopPropagation();
1659
1867
  setState((prev) => {
@@ -1671,7 +1879,7 @@ var useMultiSelect = ({
1671
1879
  },
1672
1880
  [onChange]
1673
1881
  );
1674
- const onRemoveAll = (0, import_react7.useCallback)(() => {
1882
+ const onRemoveAll = (0, import_react9.useCallback)(() => {
1675
1883
  setState((prevState) => ({
1676
1884
  ...prevState,
1677
1885
  values: [],
@@ -1679,13 +1887,13 @@ var useMultiSelect = ({
1679
1887
  }));
1680
1888
  onChange?.([]);
1681
1889
  }, [onChange]);
1682
- const onSelectClick = (0, import_react7.useCallback)(() => {
1890
+ const onSelectClick = (0, import_react9.useCallback)(() => {
1683
1891
  setState((prevState) => ({
1684
1892
  ...prevState,
1685
1893
  isOpen: !prevState.isOpen
1686
1894
  }));
1687
1895
  }, []);
1688
- const onClose = (0, import_react7.useCallback)(() => {
1896
+ const onClose = (0, import_react9.useCallback)(() => {
1689
1897
  setState((prevState) => ({
1690
1898
  ...prevState,
1691
1899
  isOpen: false
@@ -1706,7 +1914,7 @@ var useMultiSelect = ({
1706
1914
 
1707
1915
  // src/MultiSelect.tsx
1708
1916
  var import_jsx_runtime399 = require("react/jsx-runtime");
1709
- var MultiSelect = (0, import_react8.forwardRef)(
1917
+ var MultiSelect = (0, import_react10.forwardRef)(
1710
1918
  ({
1711
1919
  options,
1712
1920
  errorMessage,
@@ -1728,8 +1936,8 @@ var MultiSelect = (0, import_react8.forwardRef)(
1728
1936
  themeProductContext
1729
1937
  }, ref) => {
1730
1938
  const { theme } = (0, import_xui_core4.useResolvedTheme)({ themeMode, themeProductContext });
1731
- const controlRef = (0, import_react8.useRef)(null);
1732
- const menuRef = (0, import_react8.useRef)(null);
1939
+ const controlRef = (0, import_react10.useRef)(null);
1940
+ const menuRef = (0, import_react10.useRef)(null);
1733
1941
  const sizeStyles = theme.sizing.input(size);
1734
1942
  const state = externalState || (disabled ? "disable" : "default");
1735
1943
  const isDisable = state === "disable" || disabled;
@@ -1750,7 +1958,7 @@ var MultiSelect = (0, import_react8.forwardRef)(
1750
1958
  value,
1751
1959
  onChange
1752
1960
  });
1753
- (0, import_react8.useEffect)(() => {
1961
+ (0, import_react10.useEffect)(() => {
1754
1962
  if (isDisable) {
1755
1963
  onClose();
1756
1964
  }