@xsolla/xui-multi-select 0.133.0 → 0.135.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 +36 -268
- package/native/index.js.map +1 -1
- package/native/index.mjs +8 -240
- package/native/index.mjs.map +1 -1
- package/package.json +5 -5
- package/web/index.js +36 -268
- package/web/index.js.map +1 -1
- package/web/index.mjs +8 -240
- package/web/index.mjs.map +1 -1
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
|
|
38
|
+
var import_react8 = 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
|
|
305
|
+
var import_react6 = require("react");
|
|
306
306
|
var import_xui_core3 = require("@xsolla/xui-core");
|
|
307
307
|
|
|
308
308
|
// ../icons-base/dist/web/index.mjs
|
|
@@ -750,12 +750,11 @@ 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
|
|
753
|
+
var import_react5 = require("react");
|
|
754
754
|
|
|
755
755
|
// ../tag/dist/web/index.mjs
|
|
756
|
-
var
|
|
756
|
+
var import_react4 = __toESM(require("react"), 1);
|
|
757
757
|
var import_styled_components3 = __toESM(require("styled-components"), 1);
|
|
758
|
-
var import_react6 = __toESM(require("react"), 1);
|
|
759
758
|
var import_jsx_runtime393 = require("react/jsx-runtime");
|
|
760
759
|
var import_styled_components4 = __toESM(require("styled-components"), 1);
|
|
761
760
|
var import_jsx_runtime394 = require("react/jsx-runtime");
|
|
@@ -764,7 +763,6 @@ var import_jsx_runtime395 = require("react/jsx-runtime");
|
|
|
764
763
|
var import_xui_core = require("@xsolla/xui-core");
|
|
765
764
|
|
|
766
765
|
// ../icons/dist/web/index.mjs
|
|
767
|
-
var import_react4 = __toESM(require("react"), 1);
|
|
768
766
|
var import_styled_components2 = __toESM(require("styled-components"), 1);
|
|
769
767
|
var import_jsx_runtime391 = require("react/jsx-runtime");
|
|
770
768
|
|
|
@@ -847,109 +845,7 @@ var X = createLucideIcon("X", [
|
|
|
847
845
|
|
|
848
846
|
// ../icons/dist/web/index.mjs
|
|
849
847
|
var import_jsx_runtime392 = require("react/jsx-runtime");
|
|
850
|
-
var
|
|
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)`
|
|
848
|
+
var StyledIcon2 = import_styled_components2.default.div`
|
|
953
849
|
display: flex;
|
|
954
850
|
align-items: center;
|
|
955
851
|
justify-content: center;
|
|
@@ -971,109 +867,7 @@ var X2 = (props) => /* @__PURE__ */ (0, import_jsx_runtime392.jsx)(Icon3, { ...p
|
|
|
971
867
|
|
|
972
868
|
// ../tag/dist/web/index.mjs
|
|
973
869
|
var import_jsx_runtime396 = require("react/jsx-runtime");
|
|
974
|
-
var
|
|
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)`
|
|
870
|
+
var StyledBox = import_styled_components3.default.div`
|
|
1077
871
|
display: flex;
|
|
1078
872
|
box-sizing: border-box;
|
|
1079
873
|
background-color: ${(props) => props.backgroundColor || "transparent"};
|
|
@@ -1160,7 +954,7 @@ var StyledBox = (0, import_styled_components3.default)(FilteredDiv2)`
|
|
|
1160
954
|
${(props) => props.pressStyle?.backgroundColor && `background-color: ${props.pressStyle.backgroundColor};`}
|
|
1161
955
|
}
|
|
1162
956
|
`;
|
|
1163
|
-
var Box2 =
|
|
957
|
+
var Box2 = import_react4.default.forwardRef(
|
|
1164
958
|
({
|
|
1165
959
|
children,
|
|
1166
960
|
onPress,
|
|
@@ -1212,7 +1006,7 @@ var Box2 = import_react5.default.forwardRef(
|
|
|
1212
1006
|
StyledBox,
|
|
1213
1007
|
{
|
|
1214
1008
|
ref,
|
|
1215
|
-
|
|
1009
|
+
as,
|
|
1216
1010
|
id,
|
|
1217
1011
|
type: as === "button" ? type || "button" : void 0,
|
|
1218
1012
|
disabled: as === "button" ? disabled : void 0,
|
|
@@ -1239,8 +1033,7 @@ var Box2 = import_react5.default.forwardRef(
|
|
|
1239
1033
|
}
|
|
1240
1034
|
);
|
|
1241
1035
|
Box2.displayName = "Box";
|
|
1242
|
-
var
|
|
1243
|
-
var StyledText = (0, import_styled_components4.default)(FilteredSpan)`
|
|
1036
|
+
var StyledText = import_styled_components4.default.span`
|
|
1244
1037
|
color: ${(props) => props.color || "inherit"};
|
|
1245
1038
|
font-size: ${(props) => typeof props.fontSize === "number" ? `${props.fontSize}px` : props.fontSize || "inherit"};
|
|
1246
1039
|
font-weight: ${(props) => props.fontWeight || "normal"};
|
|
@@ -1269,8 +1062,7 @@ var Text2 = ({
|
|
|
1269
1062
|
}
|
|
1270
1063
|
);
|
|
1271
1064
|
};
|
|
1272
|
-
var
|
|
1273
|
-
var StyledIcon3 = (0, import_styled_components5.default)(FilteredDiv22)`
|
|
1065
|
+
var StyledIcon3 = import_styled_components5.default.div`
|
|
1274
1066
|
display: flex;
|
|
1275
1067
|
align-items: center;
|
|
1276
1068
|
justify-content: center;
|
|
@@ -1288,14 +1080,10 @@ var StyledIcon3 = (0, import_styled_components5.default)(FilteredDiv22)`
|
|
|
1288
1080
|
var Icon4 = ({ children, ...props }) => {
|
|
1289
1081
|
return /* @__PURE__ */ (0, import_jsx_runtime395.jsx)(StyledIcon3, { ...props, children });
|
|
1290
1082
|
};
|
|
1291
|
-
var SELECTABLE_BORDER_RADIUS = 8;
|
|
1292
1083
|
var Tag = ({
|
|
1293
1084
|
size = "md",
|
|
1294
1085
|
tone = "primary",
|
|
1295
1086
|
type = "solid",
|
|
1296
|
-
variant = "default",
|
|
1297
|
-
selected = false,
|
|
1298
|
-
onPress,
|
|
1299
1087
|
children,
|
|
1300
1088
|
iconLeft,
|
|
1301
1089
|
iconRight,
|
|
@@ -1306,20 +1094,6 @@ var Tag = ({
|
|
|
1306
1094
|
const { theme } = (0, import_xui_core.useResolvedTheme)({ themeMode, themeProductContext });
|
|
1307
1095
|
const sizeStyles = theme.sizing.tag(size);
|
|
1308
1096
|
const resolveColors = () => {
|
|
1309
|
-
if (variant === "selectable") {
|
|
1310
|
-
if (selected) {
|
|
1311
|
-
return {
|
|
1312
|
-
bg: theme.colors.control.brand.secondary.bg,
|
|
1313
|
-
text: theme.colors.content.brand.primary,
|
|
1314
|
-
border: theme.colors.border.secondary
|
|
1315
|
-
};
|
|
1316
|
-
}
|
|
1317
|
-
return {
|
|
1318
|
-
bg: theme.colors.overlay.mono,
|
|
1319
|
-
text: theme.colors.content.primary,
|
|
1320
|
-
border: theme.colors.border.secondary
|
|
1321
|
-
};
|
|
1322
|
-
}
|
|
1323
1097
|
const isOutlined = type === "outlined";
|
|
1324
1098
|
switch (tone) {
|
|
1325
1099
|
case "primary":
|
|
@@ -1373,16 +1147,12 @@ var Tag = ({
|
|
|
1373
1147
|
}
|
|
1374
1148
|
};
|
|
1375
1149
|
const { bg, text, border } = resolveColors();
|
|
1376
|
-
const isSelectable = variant === "selectable";
|
|
1377
|
-
const borderRadius = isSelectable ? SELECTABLE_BORDER_RADIUS : sizeStyles.radius;
|
|
1378
1150
|
const isIconOnly = !children && (!!iconLeft || !!iconRight);
|
|
1379
1151
|
return /* @__PURE__ */ (0, import_jsx_runtime396.jsxs)(
|
|
1380
1152
|
Box2,
|
|
1381
1153
|
{
|
|
1382
|
-
as: isSelectable ? "button" : void 0,
|
|
1383
|
-
onPress: isSelectable ? onPress : void 0,
|
|
1384
1154
|
backgroundColor: bg,
|
|
1385
|
-
borderRadius,
|
|
1155
|
+
borderRadius: sizeStyles.radius,
|
|
1386
1156
|
height: sizeStyles.height,
|
|
1387
1157
|
width: isIconOnly ? sizeStyles.height : void 0,
|
|
1388
1158
|
paddingHorizontal: isIconOnly ? 0 : sizeStyles.padding,
|
|
@@ -1393,8 +1163,6 @@ var Tag = ({
|
|
|
1393
1163
|
borderWidth: sizeStyles.borderWidth,
|
|
1394
1164
|
borderColor: border,
|
|
1395
1165
|
borderStyle: "solid",
|
|
1396
|
-
cursor: isSelectable ? "pointer" : "default",
|
|
1397
|
-
hoverStyle: isSelectable && !selected ? { backgroundColor: theme.colors.control.brand.tertiary.bgHover } : void 0,
|
|
1398
1166
|
style: {
|
|
1399
1167
|
overflow: "hidden",
|
|
1400
1168
|
textOverflow: "ellipsis",
|
|
@@ -1442,15 +1210,15 @@ var useMultiSelectControl = ({
|
|
|
1442
1210
|
themeProductContext
|
|
1443
1211
|
}) => {
|
|
1444
1212
|
const { theme } = (0, import_xui_core2.useResolvedTheme)({ themeMode, themeProductContext });
|
|
1445
|
-
const displayStateRef = (0,
|
|
1446
|
-
const savedWidthsRef = (0,
|
|
1447
|
-
const itemsRef = (0,
|
|
1448
|
-
const [itemsWidth, setItemsWidth] = (0,
|
|
1449
|
-
const [selectedContent, setSelectedContent] = (0,
|
|
1213
|
+
const displayStateRef = (0, import_react5.useRef)(0 /* Placeholder */);
|
|
1214
|
+
const savedWidthsRef = (0, import_react5.useRef)(null);
|
|
1215
|
+
const itemsRef = (0, import_react5.useRef)(null);
|
|
1216
|
+
const [itemsWidth, setItemsWidth] = (0, import_react5.useState)(0);
|
|
1217
|
+
const [selectedContent, setSelectedContent] = (0, import_react5.useState)(
|
|
1450
1218
|
null
|
|
1451
1219
|
);
|
|
1452
1220
|
const isPlaceholder = !selectedItems || selectedItems.length === 0;
|
|
1453
|
-
(0,
|
|
1221
|
+
(0, import_react5.useEffect)(() => {
|
|
1454
1222
|
if (!containerRef.current) return;
|
|
1455
1223
|
const resizeObserver = new ResizeObserver((entries) => {
|
|
1456
1224
|
for (const entry of entries) {
|
|
@@ -1460,7 +1228,7 @@ var useMultiSelectControl = ({
|
|
|
1460
1228
|
resizeObserver.observe(containerRef.current);
|
|
1461
1229
|
return () => resizeObserver.disconnect();
|
|
1462
1230
|
}, [containerRef]);
|
|
1463
|
-
const widthsDependencies = (0,
|
|
1231
|
+
const widthsDependencies = (0, import_react5.useMemo)(
|
|
1464
1232
|
() => ({
|
|
1465
1233
|
stateList: stateList.map((item) => item.value),
|
|
1466
1234
|
variant,
|
|
@@ -1618,7 +1386,7 @@ var useMultiSelectControl = ({
|
|
|
1618
1386
|
displayStateRef.current = 3 /* Render */;
|
|
1619
1387
|
setItemsRender();
|
|
1620
1388
|
};
|
|
1621
|
-
(0,
|
|
1389
|
+
(0, import_react5.useEffect)(() => {
|
|
1622
1390
|
if (isPlaceholder) {
|
|
1623
1391
|
displayStateRef.current = 0 /* Placeholder */;
|
|
1624
1392
|
setPlaceholder();
|
|
@@ -1652,7 +1420,7 @@ var useMultiSelectControl = ({
|
|
|
1652
1420
|
widthsDependencies,
|
|
1653
1421
|
stateList
|
|
1654
1422
|
]);
|
|
1655
|
-
(0,
|
|
1423
|
+
(0, import_react5.useEffect)(() => {
|
|
1656
1424
|
if (displayStateRef.current !== 2 /* Calculation */) return;
|
|
1657
1425
|
const rafId = requestAnimationFrame(() => {
|
|
1658
1426
|
if (displayStateRef.current === 2 /* Calculation */) {
|
|
@@ -1671,7 +1439,7 @@ var useMultiSelectControl = ({
|
|
|
1671
1439
|
|
|
1672
1440
|
// src/MultiSelectControl.tsx
|
|
1673
1441
|
var import_jsx_runtime398 = require("react/jsx-runtime");
|
|
1674
|
-
var MultiSelectControl = (0,
|
|
1442
|
+
var MultiSelectControl = (0, import_react6.forwardRef)(
|
|
1675
1443
|
({
|
|
1676
1444
|
variant = "tag",
|
|
1677
1445
|
flexible = true,
|
|
@@ -1699,7 +1467,7 @@ var MultiSelectControl = (0, import_react8.forwardRef)(
|
|
|
1699
1467
|
const inputColors = theme.colors.control.input;
|
|
1700
1468
|
const state = externalState || (disabled ? "disable" : "default");
|
|
1701
1469
|
const isDisable = state === "disable" || disabled;
|
|
1702
|
-
const containerRef = (0,
|
|
1470
|
+
const containerRef = (0, import_react6.useRef)(null);
|
|
1703
1471
|
const { itemsRef, selectedContent, isCalculating } = useMultiSelectControl({
|
|
1704
1472
|
variant,
|
|
1705
1473
|
flexible,
|
|
@@ -1822,7 +1590,7 @@ var MultiSelectControl = (0, import_react8.forwardRef)(
|
|
|
1822
1590
|
MultiSelectControl.displayName = "MultiSelectControl";
|
|
1823
1591
|
|
|
1824
1592
|
// src/useMultiSelect.ts
|
|
1825
|
-
var
|
|
1593
|
+
var import_react7 = require("react");
|
|
1826
1594
|
var initialState = {
|
|
1827
1595
|
values: [],
|
|
1828
1596
|
selectedItems: [],
|
|
@@ -1833,12 +1601,12 @@ var useMultiSelect = ({
|
|
|
1833
1601
|
value = [],
|
|
1834
1602
|
onChange
|
|
1835
1603
|
}) => {
|
|
1836
|
-
const [state, setState] = (0,
|
|
1837
|
-
const optionsRef = (0,
|
|
1838
|
-
(0,
|
|
1604
|
+
const [state, setState] = (0, import_react7.useState)(initialState);
|
|
1605
|
+
const optionsRef = (0, import_react7.useRef)(options);
|
|
1606
|
+
(0, import_react7.useEffect)(() => {
|
|
1839
1607
|
optionsRef.current = options;
|
|
1840
1608
|
}, [options]);
|
|
1841
|
-
(0,
|
|
1609
|
+
(0, import_react7.useEffect)(() => {
|
|
1842
1610
|
const selectedItems = options.filter((opt) => value.includes(opt.value));
|
|
1843
1611
|
setState((prevState) => ({
|
|
1844
1612
|
...prevState,
|
|
@@ -1846,7 +1614,7 @@ var useMultiSelect = ({
|
|
|
1846
1614
|
selectedItems
|
|
1847
1615
|
}));
|
|
1848
1616
|
}, [options, value]);
|
|
1849
|
-
const onChoose = (0,
|
|
1617
|
+
const onChoose = (0, import_react7.useCallback)(
|
|
1850
1618
|
(selectedIds) => {
|
|
1851
1619
|
const newValues = optionsRef.current.filter((opt) => selectedIds.includes(String(opt.value))).map((opt) => opt.value);
|
|
1852
1620
|
const newSelectedItems = optionsRef.current.filter(
|
|
@@ -1861,7 +1629,7 @@ var useMultiSelect = ({
|
|
|
1861
1629
|
},
|
|
1862
1630
|
[onChange]
|
|
1863
1631
|
);
|
|
1864
|
-
const onRemove = (0,
|
|
1632
|
+
const onRemove = (0, import_react7.useCallback)(
|
|
1865
1633
|
(value2, event) => {
|
|
1866
1634
|
event?.stopPropagation();
|
|
1867
1635
|
setState((prev) => {
|
|
@@ -1879,7 +1647,7 @@ var useMultiSelect = ({
|
|
|
1879
1647
|
},
|
|
1880
1648
|
[onChange]
|
|
1881
1649
|
);
|
|
1882
|
-
const onRemoveAll = (0,
|
|
1650
|
+
const onRemoveAll = (0, import_react7.useCallback)(() => {
|
|
1883
1651
|
setState((prevState) => ({
|
|
1884
1652
|
...prevState,
|
|
1885
1653
|
values: [],
|
|
@@ -1887,13 +1655,13 @@ var useMultiSelect = ({
|
|
|
1887
1655
|
}));
|
|
1888
1656
|
onChange?.([]);
|
|
1889
1657
|
}, [onChange]);
|
|
1890
|
-
const onSelectClick = (0,
|
|
1658
|
+
const onSelectClick = (0, import_react7.useCallback)(() => {
|
|
1891
1659
|
setState((prevState) => ({
|
|
1892
1660
|
...prevState,
|
|
1893
1661
|
isOpen: !prevState.isOpen
|
|
1894
1662
|
}));
|
|
1895
1663
|
}, []);
|
|
1896
|
-
const onClose = (0,
|
|
1664
|
+
const onClose = (0, import_react7.useCallback)(() => {
|
|
1897
1665
|
setState((prevState) => ({
|
|
1898
1666
|
...prevState,
|
|
1899
1667
|
isOpen: false
|
|
@@ -1914,7 +1682,7 @@ var useMultiSelect = ({
|
|
|
1914
1682
|
|
|
1915
1683
|
// src/MultiSelect.tsx
|
|
1916
1684
|
var import_jsx_runtime399 = require("react/jsx-runtime");
|
|
1917
|
-
var MultiSelect = (0,
|
|
1685
|
+
var MultiSelect = (0, import_react8.forwardRef)(
|
|
1918
1686
|
({
|
|
1919
1687
|
options,
|
|
1920
1688
|
errorMessage,
|
|
@@ -1936,8 +1704,8 @@ var MultiSelect = (0, import_react10.forwardRef)(
|
|
|
1936
1704
|
themeProductContext
|
|
1937
1705
|
}, ref) => {
|
|
1938
1706
|
const { theme } = (0, import_xui_core4.useResolvedTheme)({ themeMode, themeProductContext });
|
|
1939
|
-
const controlRef = (0,
|
|
1940
|
-
const menuRef = (0,
|
|
1707
|
+
const controlRef = (0, import_react8.useRef)(null);
|
|
1708
|
+
const menuRef = (0, import_react8.useRef)(null);
|
|
1941
1709
|
const sizeStyles = theme.sizing.input(size);
|
|
1942
1710
|
const state = externalState || (disabled ? "disable" : "default");
|
|
1943
1711
|
const isDisable = state === "disable" || disabled;
|
|
@@ -1958,7 +1726,7 @@ var MultiSelect = (0, import_react10.forwardRef)(
|
|
|
1958
1726
|
value,
|
|
1959
1727
|
onChange
|
|
1960
1728
|
});
|
|
1961
|
-
(0,
|
|
1729
|
+
(0, import_react8.useEffect)(() => {
|
|
1962
1730
|
if (isDisable) {
|
|
1963
1731
|
onClose();
|
|
1964
1732
|
}
|