@xsolla/xui-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/package.json +3 -3
- package/web/index.js +128 -19
- package/web/index.js.map +1 -1
- package/web/index.mjs +117 -8
- package/web/index.mjs.map +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xsolla/xui-select",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.133.0",
|
|
4
4
|
"main": "./web/index.js",
|
|
5
5
|
"module": "./web/index.mjs",
|
|
6
6
|
"types": "./web/index.d.ts",
|
|
@@ -13,8 +13,8 @@
|
|
|
13
13
|
"test:coverage": "vitest run --coverage"
|
|
14
14
|
},
|
|
15
15
|
"dependencies": {
|
|
16
|
-
"@xsolla/xui-core": "0.
|
|
17
|
-
"@xsolla/xui-primitives-core": "0.
|
|
16
|
+
"@xsolla/xui-core": "0.133.0",
|
|
17
|
+
"@xsolla/xui-primitives-core": "0.133.0"
|
|
18
18
|
},
|
|
19
19
|
"peerDependencies": {
|
|
20
20
|
"react": ">=16.8.0",
|
package/web/index.js
CHANGED
|
@@ -35,13 +35,120 @@ __export(index_exports, {
|
|
|
35
35
|
module.exports = __toCommonJS(index_exports);
|
|
36
36
|
|
|
37
37
|
// src/Select.tsx
|
|
38
|
-
var
|
|
38
|
+
var import_react3 = __toESM(require("react"));
|
|
39
39
|
|
|
40
40
|
// ../primitives-web/src/Box.tsx
|
|
41
|
-
var
|
|
41
|
+
var import_react2 = __toESM(require("react"));
|
|
42
42
|
var import_styled_components = __toESM(require("styled-components"));
|
|
43
|
+
|
|
44
|
+
// ../primitives-web/src/filterDOMProps.ts
|
|
45
|
+
var import_react = __toESM(require("react"));
|
|
46
|
+
var NON_HTML_PROPS = /* @__PURE__ */ new Set([
|
|
47
|
+
// BoxProps — layout & styling
|
|
48
|
+
"backgroundColor",
|
|
49
|
+
"borderColor",
|
|
50
|
+
"borderWidth",
|
|
51
|
+
"borderBottomWidth",
|
|
52
|
+
"borderBottomColor",
|
|
53
|
+
"borderTopWidth",
|
|
54
|
+
"borderTopColor",
|
|
55
|
+
"borderLeftWidth",
|
|
56
|
+
"borderLeftColor",
|
|
57
|
+
"borderRightWidth",
|
|
58
|
+
"borderRightColor",
|
|
59
|
+
"borderRadius",
|
|
60
|
+
"borderStyle",
|
|
61
|
+
"flexDirection",
|
|
62
|
+
"flexWrap",
|
|
63
|
+
"alignItems",
|
|
64
|
+
"justifyContent",
|
|
65
|
+
"alignSelf",
|
|
66
|
+
"flex",
|
|
67
|
+
"flexShrink",
|
|
68
|
+
"gap",
|
|
69
|
+
"position",
|
|
70
|
+
"top",
|
|
71
|
+
"bottom",
|
|
72
|
+
"left",
|
|
73
|
+
"right",
|
|
74
|
+
"outline",
|
|
75
|
+
"overflow",
|
|
76
|
+
"overflowX",
|
|
77
|
+
"overflowY",
|
|
78
|
+
"zIndex",
|
|
79
|
+
"cursor",
|
|
80
|
+
"padding",
|
|
81
|
+
"paddingHorizontal",
|
|
82
|
+
"paddingVertical",
|
|
83
|
+
"paddingTop",
|
|
84
|
+
"paddingBottom",
|
|
85
|
+
"paddingLeft",
|
|
86
|
+
"paddingRight",
|
|
87
|
+
"margin",
|
|
88
|
+
"marginTop",
|
|
89
|
+
"marginBottom",
|
|
90
|
+
"marginLeft",
|
|
91
|
+
"marginRight",
|
|
92
|
+
"minWidth",
|
|
93
|
+
"minHeight",
|
|
94
|
+
"maxWidth",
|
|
95
|
+
"maxHeight",
|
|
96
|
+
"hoverStyle",
|
|
97
|
+
"pressStyle",
|
|
98
|
+
"focusStyle",
|
|
99
|
+
"outlineColor",
|
|
100
|
+
"outlineWidth",
|
|
101
|
+
"outlineOffset",
|
|
102
|
+
"outlineStyle",
|
|
103
|
+
// BoxProps — RN-only
|
|
104
|
+
"onPress",
|
|
105
|
+
"onLayout",
|
|
106
|
+
"onMoveShouldSetResponder",
|
|
107
|
+
"onResponderGrant",
|
|
108
|
+
"onResponderMove",
|
|
109
|
+
"onResponderRelease",
|
|
110
|
+
"onResponderTerminate",
|
|
111
|
+
"testID",
|
|
112
|
+
// Box — custom element type
|
|
113
|
+
"elementType",
|
|
114
|
+
// TextProps
|
|
115
|
+
"fontSize",
|
|
116
|
+
"fontWeight",
|
|
117
|
+
"fontFamily",
|
|
118
|
+
"lineHeight",
|
|
119
|
+
"whiteSpace",
|
|
120
|
+
"textAlign",
|
|
121
|
+
"textDecoration",
|
|
122
|
+
"numberOfLines",
|
|
123
|
+
"letterSpacing",
|
|
124
|
+
"textTransform",
|
|
125
|
+
// SpinnerProps
|
|
126
|
+
"strokeWidth",
|
|
127
|
+
// DividerProps
|
|
128
|
+
"vertical",
|
|
129
|
+
"dashStroke"
|
|
130
|
+
]);
|
|
131
|
+
function createFilteredElement(defaultTag) {
|
|
132
|
+
const Component = import_react.default.forwardRef(
|
|
133
|
+
({ children, elementType, ...props }, ref) => {
|
|
134
|
+
const Tag = elementType || defaultTag;
|
|
135
|
+
const htmlProps = {};
|
|
136
|
+
for (const key of Object.keys(props)) {
|
|
137
|
+
if (!NON_HTML_PROPS.has(key)) {
|
|
138
|
+
htmlProps[key] = props[key];
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
return import_react.default.createElement(Tag, { ref, ...htmlProps }, children);
|
|
142
|
+
}
|
|
143
|
+
);
|
|
144
|
+
Component.displayName = `Filtered(${defaultTag})`;
|
|
145
|
+
return Component;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
// ../primitives-web/src/Box.tsx
|
|
43
149
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
44
|
-
var
|
|
150
|
+
var FilteredDiv = createFilteredElement("div");
|
|
151
|
+
var StyledBox = (0, import_styled_components.default)(FilteredDiv)`
|
|
45
152
|
display: flex;
|
|
46
153
|
box-sizing: border-box;
|
|
47
154
|
background-color: ${(props) => props.backgroundColor || "transparent"};
|
|
@@ -128,7 +235,7 @@ var StyledBox = import_styled_components.default.div`
|
|
|
128
235
|
${(props) => props.pressStyle?.backgroundColor && `background-color: ${props.pressStyle.backgroundColor};`}
|
|
129
236
|
}
|
|
130
237
|
`;
|
|
131
|
-
var Box =
|
|
238
|
+
var Box = import_react2.default.forwardRef(
|
|
132
239
|
({
|
|
133
240
|
children,
|
|
134
241
|
onPress,
|
|
@@ -180,7 +287,7 @@ var Box = import_react.default.forwardRef(
|
|
|
180
287
|
StyledBox,
|
|
181
288
|
{
|
|
182
289
|
ref,
|
|
183
|
-
as,
|
|
290
|
+
elementType: as,
|
|
184
291
|
id,
|
|
185
292
|
type: as === "button" ? type || "button" : void 0,
|
|
186
293
|
disabled: as === "button" ? disabled : void 0,
|
|
@@ -211,7 +318,8 @@ Box.displayName = "Box";
|
|
|
211
318
|
// ../primitives-web/src/Text.tsx
|
|
212
319
|
var import_styled_components2 = __toESM(require("styled-components"));
|
|
213
320
|
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
214
|
-
var
|
|
321
|
+
var FilteredSpan = createFilteredElement("span");
|
|
322
|
+
var StyledText = (0, import_styled_components2.default)(FilteredSpan)`
|
|
215
323
|
color: ${(props) => props.color || "inherit"};
|
|
216
324
|
font-size: ${(props) => typeof props.fontSize === "number" ? `${props.fontSize}px` : props.fontSize || "inherit"};
|
|
217
325
|
font-weight: ${(props) => props.fontWeight || "normal"};
|
|
@@ -244,7 +352,8 @@ var Text = ({
|
|
|
244
352
|
// ../primitives-web/src/Icon.tsx
|
|
245
353
|
var import_styled_components3 = __toESM(require("styled-components"));
|
|
246
354
|
var import_jsx_runtime3 = require("react/jsx-runtime");
|
|
247
|
-
var
|
|
355
|
+
var FilteredDiv2 = createFilteredElement("div");
|
|
356
|
+
var StyledIcon = (0, import_styled_components3.default)(FilteredDiv2)`
|
|
248
357
|
display: flex;
|
|
249
358
|
align-items: center;
|
|
250
359
|
justify-content: center;
|
|
@@ -735,22 +844,22 @@ var Select = ({
|
|
|
735
844
|
themeProductContext
|
|
736
845
|
}) => {
|
|
737
846
|
const { theme } = (0, import_xui_core.useResolvedTheme)({ themeMode, themeProductContext });
|
|
738
|
-
const [isOpen, setIsOpen] = (0,
|
|
739
|
-
const [selectedValue, setSelectedValue] = (0,
|
|
740
|
-
const [searchValue, setSearchValue] = (0,
|
|
741
|
-
const containerRef = (0,
|
|
742
|
-
const dropdownRef = (0,
|
|
743
|
-
const selectedItemRef = (0,
|
|
744
|
-
const searchInputRef = (0,
|
|
847
|
+
const [isOpen, setIsOpen] = (0, import_react3.useState)(false);
|
|
848
|
+
const [selectedValue, setSelectedValue] = (0, import_react3.useState)(value);
|
|
849
|
+
const [searchValue, setSearchValue] = (0, import_react3.useState)("");
|
|
850
|
+
const containerRef = (0, import_react3.useRef)(null);
|
|
851
|
+
const dropdownRef = (0, import_react3.useRef)(null);
|
|
852
|
+
const selectedItemRef = (0, import_react3.useRef)(null);
|
|
853
|
+
const searchInputRef = (0, import_react3.useRef)(null);
|
|
745
854
|
const isDisable = externalState === "disable" || disabled;
|
|
746
855
|
const isError = externalState === "error" || !!errorMessage;
|
|
747
856
|
const isFocus = externalState === "focus" || isOpen;
|
|
748
|
-
|
|
857
|
+
import_react3.default.useEffect(() => {
|
|
749
858
|
if (value !== void 0) {
|
|
750
859
|
setSelectedValue(value);
|
|
751
860
|
}
|
|
752
861
|
}, [value]);
|
|
753
|
-
(0,
|
|
862
|
+
(0, import_react3.useEffect)(() => {
|
|
754
863
|
if (isFocus && selectedItemRef.current && dropdownRef.current) {
|
|
755
864
|
const timeoutId = setTimeout(() => {
|
|
756
865
|
const selectedItem = selectedItemRef.current;
|
|
@@ -761,17 +870,17 @@ var Select = ({
|
|
|
761
870
|
return () => clearTimeout(timeoutId);
|
|
762
871
|
}
|
|
763
872
|
}, [isFocus]);
|
|
764
|
-
(0,
|
|
873
|
+
(0, import_react3.useEffect)(() => {
|
|
765
874
|
if (isFocus && searchable) {
|
|
766
875
|
searchInputRef.current?.focus();
|
|
767
876
|
}
|
|
768
877
|
}, [isFocus, searchable]);
|
|
769
|
-
(0,
|
|
878
|
+
(0, import_react3.useEffect)(() => {
|
|
770
879
|
if (!isFocus) {
|
|
771
880
|
setSearchValue("");
|
|
772
881
|
}
|
|
773
882
|
}, [isFocus]);
|
|
774
|
-
(0,
|
|
883
|
+
(0, import_react3.useEffect)(() => {
|
|
775
884
|
if (import_xui_core.isNative || !isOpen) return;
|
|
776
885
|
const handleClickOutside = (event) => {
|
|
777
886
|
if (containerRef.current && !containerRef.current.contains(event.target)) {
|