@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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xsolla/xui-multi-select",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.135.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.
|
|
14
|
-
"@xsolla/xui-core": "0.
|
|
15
|
-
"@xsolla/xui-dropdown": "0.
|
|
16
|
-
"@xsolla/xui-primitives-core": "0.
|
|
13
|
+
"@xsolla/xui-checkbox": "0.135.0",
|
|
14
|
+
"@xsolla/xui-core": "0.135.0",
|
|
15
|
+
"@xsolla/xui-dropdown": "0.135.0",
|
|
16
|
+
"@xsolla/xui-primitives-core": "0.135.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
|
|
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
|
|
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
|
|
718
|
+
var import_react5 = require("react");
|
|
719
719
|
|
|
720
720
|
// ../tag/dist/web/index.mjs
|
|
721
|
-
var
|
|
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
|
|
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
|
|
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 =
|
|
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
|
-
|
|
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
|
|
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
|
|
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;
|
|
@@ -1253,14 +1045,10 @@ var StyledIcon4 = (0, import_styled_components8.default)(FilteredDiv22)`
|
|
|
1253
1045
|
var Icon4 = ({ children, ...props }) => {
|
|
1254
1046
|
return /* @__PURE__ */ (0, import_jsx_runtime395.jsx)(StyledIcon4, { ...props, children });
|
|
1255
1047
|
};
|
|
1256
|
-
var SELECTABLE_BORDER_RADIUS = 8;
|
|
1257
1048
|
var Tag = ({
|
|
1258
1049
|
size = "md",
|
|
1259
1050
|
tone = "primary",
|
|
1260
1051
|
type = "solid",
|
|
1261
|
-
variant = "default",
|
|
1262
|
-
selected = false,
|
|
1263
|
-
onPress,
|
|
1264
1052
|
children,
|
|
1265
1053
|
iconLeft,
|
|
1266
1054
|
iconRight,
|
|
@@ -1271,20 +1059,6 @@ var Tag = ({
|
|
|
1271
1059
|
const { theme } = (0, import_xui_core.useResolvedTheme)({ themeMode, themeProductContext });
|
|
1272
1060
|
const sizeStyles = theme.sizing.tag(size);
|
|
1273
1061
|
const resolveColors = () => {
|
|
1274
|
-
if (variant === "selectable") {
|
|
1275
|
-
if (selected) {
|
|
1276
|
-
return {
|
|
1277
|
-
bg: theme.colors.control.brand.secondary.bg,
|
|
1278
|
-
text: theme.colors.content.brand.primary,
|
|
1279
|
-
border: theme.colors.border.secondary
|
|
1280
|
-
};
|
|
1281
|
-
}
|
|
1282
|
-
return {
|
|
1283
|
-
bg: theme.colors.overlay.mono,
|
|
1284
|
-
text: theme.colors.content.primary,
|
|
1285
|
-
border: theme.colors.border.secondary
|
|
1286
|
-
};
|
|
1287
|
-
}
|
|
1288
1062
|
const isOutlined = type === "outlined";
|
|
1289
1063
|
switch (tone) {
|
|
1290
1064
|
case "primary":
|
|
@@ -1338,16 +1112,12 @@ var Tag = ({
|
|
|
1338
1112
|
}
|
|
1339
1113
|
};
|
|
1340
1114
|
const { bg, text, border } = resolveColors();
|
|
1341
|
-
const isSelectable = variant === "selectable";
|
|
1342
|
-
const borderRadius = isSelectable ? SELECTABLE_BORDER_RADIUS : sizeStyles.radius;
|
|
1343
1115
|
const isIconOnly = !children && (!!iconLeft || !!iconRight);
|
|
1344
1116
|
return /* @__PURE__ */ (0, import_jsx_runtime396.jsxs)(
|
|
1345
1117
|
Box2,
|
|
1346
1118
|
{
|
|
1347
|
-
as: isSelectable ? "button" : void 0,
|
|
1348
|
-
onPress: isSelectable ? onPress : void 0,
|
|
1349
1119
|
backgroundColor: bg,
|
|
1350
|
-
borderRadius,
|
|
1120
|
+
borderRadius: sizeStyles.radius,
|
|
1351
1121
|
height: sizeStyles.height,
|
|
1352
1122
|
width: isIconOnly ? sizeStyles.height : void 0,
|
|
1353
1123
|
paddingHorizontal: isIconOnly ? 0 : sizeStyles.padding,
|
|
@@ -1358,8 +1128,6 @@ var Tag = ({
|
|
|
1358
1128
|
borderWidth: sizeStyles.borderWidth,
|
|
1359
1129
|
borderColor: border,
|
|
1360
1130
|
borderStyle: "solid",
|
|
1361
|
-
cursor: isSelectable ? "pointer" : "default",
|
|
1362
|
-
hoverStyle: isSelectable && !selected ? { backgroundColor: theme.colors.control.brand.tertiary.bgHover } : void 0,
|
|
1363
1131
|
style: {
|
|
1364
1132
|
overflow: "hidden",
|
|
1365
1133
|
textOverflow: "ellipsis",
|
|
@@ -1407,15 +1175,15 @@ var useMultiSelectControl = ({
|
|
|
1407
1175
|
themeProductContext
|
|
1408
1176
|
}) => {
|
|
1409
1177
|
const { theme } = (0, import_xui_core2.useResolvedTheme)({ themeMode, themeProductContext });
|
|
1410
|
-
const displayStateRef = (0,
|
|
1411
|
-
const savedWidthsRef = (0,
|
|
1412
|
-
const itemsRef = (0,
|
|
1413
|
-
const [itemsWidth, setItemsWidth] = (0,
|
|
1414
|
-
const [selectedContent, setSelectedContent] = (0,
|
|
1178
|
+
const displayStateRef = (0, import_react5.useRef)(0 /* Placeholder */);
|
|
1179
|
+
const savedWidthsRef = (0, import_react5.useRef)(null);
|
|
1180
|
+
const itemsRef = (0, import_react5.useRef)(null);
|
|
1181
|
+
const [itemsWidth, setItemsWidth] = (0, import_react5.useState)(0);
|
|
1182
|
+
const [selectedContent, setSelectedContent] = (0, import_react5.useState)(
|
|
1415
1183
|
null
|
|
1416
1184
|
);
|
|
1417
1185
|
const isPlaceholder = !selectedItems || selectedItems.length === 0;
|
|
1418
|
-
(0,
|
|
1186
|
+
(0, import_react5.useEffect)(() => {
|
|
1419
1187
|
if (!containerRef.current) return;
|
|
1420
1188
|
const resizeObserver = new ResizeObserver((entries) => {
|
|
1421
1189
|
for (const entry of entries) {
|
|
@@ -1425,7 +1193,7 @@ var useMultiSelectControl = ({
|
|
|
1425
1193
|
resizeObserver.observe(containerRef.current);
|
|
1426
1194
|
return () => resizeObserver.disconnect();
|
|
1427
1195
|
}, [containerRef]);
|
|
1428
|
-
const widthsDependencies = (0,
|
|
1196
|
+
const widthsDependencies = (0, import_react5.useMemo)(
|
|
1429
1197
|
() => ({
|
|
1430
1198
|
stateList: stateList.map((item) => item.value),
|
|
1431
1199
|
variant,
|
|
@@ -1583,7 +1351,7 @@ var useMultiSelectControl = ({
|
|
|
1583
1351
|
displayStateRef.current = 3 /* Render */;
|
|
1584
1352
|
setItemsRender();
|
|
1585
1353
|
};
|
|
1586
|
-
(0,
|
|
1354
|
+
(0, import_react5.useEffect)(() => {
|
|
1587
1355
|
if (isPlaceholder) {
|
|
1588
1356
|
displayStateRef.current = 0 /* Placeholder */;
|
|
1589
1357
|
setPlaceholder();
|
|
@@ -1617,7 +1385,7 @@ var useMultiSelectControl = ({
|
|
|
1617
1385
|
widthsDependencies,
|
|
1618
1386
|
stateList
|
|
1619
1387
|
]);
|
|
1620
|
-
(0,
|
|
1388
|
+
(0, import_react5.useEffect)(() => {
|
|
1621
1389
|
if (displayStateRef.current !== 2 /* Calculation */) return;
|
|
1622
1390
|
const rafId = requestAnimationFrame(() => {
|
|
1623
1391
|
if (displayStateRef.current === 2 /* Calculation */) {
|
|
@@ -1636,7 +1404,7 @@ var useMultiSelectControl = ({
|
|
|
1636
1404
|
|
|
1637
1405
|
// src/MultiSelectControl.tsx
|
|
1638
1406
|
var import_jsx_runtime398 = require("react/jsx-runtime");
|
|
1639
|
-
var MultiSelectControl = (0,
|
|
1407
|
+
var MultiSelectControl = (0, import_react6.forwardRef)(
|
|
1640
1408
|
({
|
|
1641
1409
|
variant = "tag",
|
|
1642
1410
|
flexible = true,
|
|
@@ -1664,7 +1432,7 @@ var MultiSelectControl = (0, import_react8.forwardRef)(
|
|
|
1664
1432
|
const inputColors = theme.colors.control.input;
|
|
1665
1433
|
const state = externalState || (disabled ? "disable" : "default");
|
|
1666
1434
|
const isDisable = state === "disable" || disabled;
|
|
1667
|
-
const containerRef = (0,
|
|
1435
|
+
const containerRef = (0, import_react6.useRef)(null);
|
|
1668
1436
|
const { itemsRef, selectedContent, isCalculating } = useMultiSelectControl({
|
|
1669
1437
|
variant,
|
|
1670
1438
|
flexible,
|
|
@@ -1787,7 +1555,7 @@ var MultiSelectControl = (0, import_react8.forwardRef)(
|
|
|
1787
1555
|
MultiSelectControl.displayName = "MultiSelectControl";
|
|
1788
1556
|
|
|
1789
1557
|
// src/useMultiSelect.ts
|
|
1790
|
-
var
|
|
1558
|
+
var import_react7 = require("react");
|
|
1791
1559
|
var initialState = {
|
|
1792
1560
|
values: [],
|
|
1793
1561
|
selectedItems: [],
|
|
@@ -1798,12 +1566,12 @@ var useMultiSelect = ({
|
|
|
1798
1566
|
value = [],
|
|
1799
1567
|
onChange
|
|
1800
1568
|
}) => {
|
|
1801
|
-
const [state, setState] = (0,
|
|
1802
|
-
const optionsRef = (0,
|
|
1803
|
-
(0,
|
|
1569
|
+
const [state, setState] = (0, import_react7.useState)(initialState);
|
|
1570
|
+
const optionsRef = (0, import_react7.useRef)(options);
|
|
1571
|
+
(0, import_react7.useEffect)(() => {
|
|
1804
1572
|
optionsRef.current = options;
|
|
1805
1573
|
}, [options]);
|
|
1806
|
-
(0,
|
|
1574
|
+
(0, import_react7.useEffect)(() => {
|
|
1807
1575
|
const selectedItems = options.filter((opt) => value.includes(opt.value));
|
|
1808
1576
|
setState((prevState) => ({
|
|
1809
1577
|
...prevState,
|
|
@@ -1811,7 +1579,7 @@ var useMultiSelect = ({
|
|
|
1811
1579
|
selectedItems
|
|
1812
1580
|
}));
|
|
1813
1581
|
}, [options, value]);
|
|
1814
|
-
const onChoose = (0,
|
|
1582
|
+
const onChoose = (0, import_react7.useCallback)(
|
|
1815
1583
|
(selectedIds) => {
|
|
1816
1584
|
const newValues = optionsRef.current.filter((opt) => selectedIds.includes(String(opt.value))).map((opt) => opt.value);
|
|
1817
1585
|
const newSelectedItems = optionsRef.current.filter(
|
|
@@ -1826,7 +1594,7 @@ var useMultiSelect = ({
|
|
|
1826
1594
|
},
|
|
1827
1595
|
[onChange]
|
|
1828
1596
|
);
|
|
1829
|
-
const onRemove = (0,
|
|
1597
|
+
const onRemove = (0, import_react7.useCallback)(
|
|
1830
1598
|
(value2, event) => {
|
|
1831
1599
|
event?.stopPropagation();
|
|
1832
1600
|
setState((prev) => {
|
|
@@ -1844,7 +1612,7 @@ var useMultiSelect = ({
|
|
|
1844
1612
|
},
|
|
1845
1613
|
[onChange]
|
|
1846
1614
|
);
|
|
1847
|
-
const onRemoveAll = (0,
|
|
1615
|
+
const onRemoveAll = (0, import_react7.useCallback)(() => {
|
|
1848
1616
|
setState((prevState) => ({
|
|
1849
1617
|
...prevState,
|
|
1850
1618
|
values: [],
|
|
@@ -1852,13 +1620,13 @@ var useMultiSelect = ({
|
|
|
1852
1620
|
}));
|
|
1853
1621
|
onChange?.([]);
|
|
1854
1622
|
}, [onChange]);
|
|
1855
|
-
const onSelectClick = (0,
|
|
1623
|
+
const onSelectClick = (0, import_react7.useCallback)(() => {
|
|
1856
1624
|
setState((prevState) => ({
|
|
1857
1625
|
...prevState,
|
|
1858
1626
|
isOpen: !prevState.isOpen
|
|
1859
1627
|
}));
|
|
1860
1628
|
}, []);
|
|
1861
|
-
const onClose = (0,
|
|
1629
|
+
const onClose = (0, import_react7.useCallback)(() => {
|
|
1862
1630
|
setState((prevState) => ({
|
|
1863
1631
|
...prevState,
|
|
1864
1632
|
isOpen: false
|
|
@@ -1879,7 +1647,7 @@ var useMultiSelect = ({
|
|
|
1879
1647
|
|
|
1880
1648
|
// src/MultiSelect.tsx
|
|
1881
1649
|
var import_jsx_runtime399 = require("react/jsx-runtime");
|
|
1882
|
-
var MultiSelect = (0,
|
|
1650
|
+
var MultiSelect = (0, import_react8.forwardRef)(
|
|
1883
1651
|
({
|
|
1884
1652
|
options,
|
|
1885
1653
|
errorMessage,
|
|
@@ -1901,8 +1669,8 @@ var MultiSelect = (0, import_react10.forwardRef)(
|
|
|
1901
1669
|
themeProductContext
|
|
1902
1670
|
}, ref) => {
|
|
1903
1671
|
const { theme } = (0, import_xui_core4.useResolvedTheme)({ themeMode, themeProductContext });
|
|
1904
|
-
const controlRef = (0,
|
|
1905
|
-
const menuRef = (0,
|
|
1672
|
+
const controlRef = (0, import_react8.useRef)(null);
|
|
1673
|
+
const menuRef = (0, import_react8.useRef)(null);
|
|
1906
1674
|
const sizeStyles = theme.sizing.input(size);
|
|
1907
1675
|
const state = externalState || (disabled ? "disable" : "default");
|
|
1908
1676
|
const isDisable = state === "disable" || disabled;
|
|
@@ -1923,7 +1691,7 @@ var MultiSelect = (0, import_react10.forwardRef)(
|
|
|
1923
1691
|
value,
|
|
1924
1692
|
onChange
|
|
1925
1693
|
});
|
|
1926
|
-
(0,
|
|
1694
|
+
(0, import_react8.useEffect)(() => {
|
|
1927
1695
|
if (isDisable) {
|
|
1928
1696
|
onClose();
|
|
1929
1697
|
}
|