@xsolla/xui-select 0.136.0 → 0.138.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 +98 -21
- package/web/index.js.map +1 -1
- package/web/index.mjs +87 -10
- 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.138.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.138.0",
|
|
17
|
+
"@xsolla/xui-primitives-core": "0.138.0"
|
|
18
18
|
},
|
|
19
19
|
"peerDependencies": {
|
|
20
20
|
"react": ">=16.8.0",
|
package/web/index.js
CHANGED
|
@@ -35,13 +35,85 @@ __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
|
+
|
|
47
|
+
// ../../node_modules/@emotion/memoize/dist/memoize.esm.js
|
|
48
|
+
function memoize(fn) {
|
|
49
|
+
var cache = {};
|
|
50
|
+
return function(arg) {
|
|
51
|
+
if (cache[arg] === void 0) cache[arg] = fn(arg);
|
|
52
|
+
return cache[arg];
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
var memoize_esm_default = memoize;
|
|
56
|
+
|
|
57
|
+
// ../../node_modules/@emotion/is-prop-valid/dist/is-prop-valid.esm.js
|
|
58
|
+
var reactPropsRegex = /^((children|dangerouslySetInnerHTML|key|ref|autoFocus|defaultValue|defaultChecked|innerHTML|suppressContentEditableWarning|suppressHydrationWarning|valueLink|accept|acceptCharset|accessKey|action|allow|allowUserMedia|allowPaymentRequest|allowFullScreen|allowTransparency|alt|async|autoComplete|autoPlay|capture|cellPadding|cellSpacing|challenge|charSet|checked|cite|classID|className|cols|colSpan|content|contentEditable|contextMenu|controls|controlsList|coords|crossOrigin|data|dateTime|decoding|default|defer|dir|disabled|disablePictureInPicture|download|draggable|encType|form|formAction|formEncType|formMethod|formNoValidate|formTarget|frameBorder|headers|height|hidden|high|href|hrefLang|htmlFor|httpEquiv|id|inputMode|integrity|is|keyParams|keyType|kind|label|lang|list|loading|loop|low|marginHeight|marginWidth|max|maxLength|media|mediaGroup|method|min|minLength|multiple|muted|name|nonce|noValidate|open|optimum|pattern|placeholder|playsInline|poster|preload|profile|radioGroup|readOnly|referrerPolicy|rel|required|reversed|role|rows|rowSpan|sandbox|scope|scoped|scrolling|seamless|selected|shape|size|sizes|slot|span|spellCheck|src|srcDoc|srcLang|srcSet|start|step|style|summary|tabIndex|target|title|type|useMap|value|width|wmode|wrap|about|datatype|inlist|prefix|property|resource|typeof|vocab|autoCapitalize|autoCorrect|autoSave|color|inert|itemProp|itemScope|itemType|itemID|itemRef|on|results|security|unselectable|accentHeight|accumulate|additive|alignmentBaseline|allowReorder|alphabetic|amplitude|arabicForm|ascent|attributeName|attributeType|autoReverse|azimuth|baseFrequency|baselineShift|baseProfile|bbox|begin|bias|by|calcMode|capHeight|clip|clipPathUnits|clipPath|clipRule|colorInterpolation|colorInterpolationFilters|colorProfile|colorRendering|contentScriptType|contentStyleType|cursor|cx|cy|d|decelerate|descent|diffuseConstant|direction|display|divisor|dominantBaseline|dur|dx|dy|edgeMode|elevation|enableBackground|end|exponent|externalResourcesRequired|fill|fillOpacity|fillRule|filter|filterRes|filterUnits|floodColor|floodOpacity|focusable|fontFamily|fontSize|fontSizeAdjust|fontStretch|fontStyle|fontVariant|fontWeight|format|from|fr|fx|fy|g1|g2|glyphName|glyphOrientationHorizontal|glyphOrientationVertical|glyphRef|gradientTransform|gradientUnits|hanging|horizAdvX|horizOriginX|ideographic|imageRendering|in|in2|intercept|k|k1|k2|k3|k4|kernelMatrix|kernelUnitLength|kerning|keyPoints|keySplines|keyTimes|lengthAdjust|letterSpacing|lightingColor|limitingConeAngle|local|markerEnd|markerMid|markerStart|markerHeight|markerUnits|markerWidth|mask|maskContentUnits|maskUnits|mathematical|mode|numOctaves|offset|opacity|operator|order|orient|orientation|origin|overflow|overlinePosition|overlineThickness|panose1|paintOrder|pathLength|patternContentUnits|patternTransform|patternUnits|pointerEvents|points|pointsAtX|pointsAtY|pointsAtZ|preserveAlpha|preserveAspectRatio|primitiveUnits|r|radius|refX|refY|renderingIntent|repeatCount|repeatDur|requiredExtensions|requiredFeatures|restart|result|rotate|rx|ry|scale|seed|shapeRendering|slope|spacing|specularConstant|specularExponent|speed|spreadMethod|startOffset|stdDeviation|stemh|stemv|stitchTiles|stopColor|stopOpacity|strikethroughPosition|strikethroughThickness|string|stroke|strokeDasharray|strokeDashoffset|strokeLinecap|strokeLinejoin|strokeMiterlimit|strokeOpacity|strokeWidth|surfaceScale|systemLanguage|tableValues|targetX|targetY|textAnchor|textDecoration|textRendering|textLength|to|transform|u1|u2|underlinePosition|underlineThickness|unicode|unicodeBidi|unicodeRange|unitsPerEm|vAlphabetic|vHanging|vIdeographic|vMathematical|values|vectorEffect|version|vertAdvY|vertOriginX|vertOriginY|viewBox|viewTarget|visibility|widths|wordSpacing|writingMode|x|xHeight|x1|x2|xChannelSelector|xlinkActuate|xlinkArcrole|xlinkHref|xlinkRole|xlinkShow|xlinkTitle|xlinkType|xmlBase|xmlns|xmlnsXlink|xmlLang|xmlSpace|y|y1|y2|yChannelSelector|z|zoomAndPan|for|class|autofocus)|(([Dd][Aa][Tt][Aa]|[Aa][Rr][Ii][Aa]|x)-.*))$/;
|
|
59
|
+
var index = memoize_esm_default(
|
|
60
|
+
function(prop) {
|
|
61
|
+
return reactPropsRegex.test(prop) || prop.charCodeAt(0) === 111 && prop.charCodeAt(1) === 110 && prop.charCodeAt(2) < 91;
|
|
62
|
+
}
|
|
63
|
+
/* Z+1 */
|
|
64
|
+
);
|
|
65
|
+
var is_prop_valid_esm_default = index;
|
|
66
|
+
|
|
67
|
+
// ../primitives-web/src/filterDOMProps.ts
|
|
68
|
+
var ADDITIONAL_BLOCKED_PROPS = /* @__PURE__ */ new Set([
|
|
69
|
+
// RN-only event handlers (pass isPropValid's on* pattern)
|
|
70
|
+
"onPress",
|
|
71
|
+
"onChangeText",
|
|
72
|
+
"onLayout",
|
|
73
|
+
"onMoveShouldSetResponder",
|
|
74
|
+
"onResponderGrant",
|
|
75
|
+
"onResponderMove",
|
|
76
|
+
"onResponderRelease",
|
|
77
|
+
"onResponderTerminate",
|
|
78
|
+
// SVG attributes that pass isPropValid
|
|
79
|
+
"strokeWidth",
|
|
80
|
+
// CSS properties that pass isPropValid but are used as component props
|
|
81
|
+
"overflow",
|
|
82
|
+
"cursor",
|
|
83
|
+
"fontSize",
|
|
84
|
+
"fontWeight",
|
|
85
|
+
"fontFamily",
|
|
86
|
+
"textDecoration"
|
|
87
|
+
]);
|
|
88
|
+
function shouldForwardProp(key) {
|
|
89
|
+
if (ADDITIONAL_BLOCKED_PROPS.has(key)) return false;
|
|
90
|
+
return is_prop_valid_esm_default(key);
|
|
91
|
+
}
|
|
92
|
+
function createFilteredElement(defaultTag) {
|
|
93
|
+
const Component = import_react.default.forwardRef(
|
|
94
|
+
({ children, elementType, ...props }, ref) => {
|
|
95
|
+
const Tag = elementType || defaultTag;
|
|
96
|
+
const htmlProps = {};
|
|
97
|
+
for (const key of Object.keys(props)) {
|
|
98
|
+
if (shouldForwardProp(key)) {
|
|
99
|
+
htmlProps[key] = props[key];
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
return import_react.default.createElement(
|
|
103
|
+
Tag,
|
|
104
|
+
{ ref, ...htmlProps },
|
|
105
|
+
children
|
|
106
|
+
);
|
|
107
|
+
}
|
|
108
|
+
);
|
|
109
|
+
Component.displayName = `Filtered(${defaultTag})`;
|
|
110
|
+
return Component;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
// ../primitives-web/src/Box.tsx
|
|
43
114
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
44
|
-
var
|
|
115
|
+
var FilteredDiv = createFilteredElement("div");
|
|
116
|
+
var StyledBox = (0, import_styled_components.default)(FilteredDiv)`
|
|
45
117
|
display: flex;
|
|
46
118
|
box-sizing: border-box;
|
|
47
119
|
background-color: ${(props) => props.backgroundColor || "transparent"};
|
|
@@ -128,7 +200,7 @@ var StyledBox = import_styled_components.default.div`
|
|
|
128
200
|
${(props) => props.pressStyle?.backgroundColor && `background-color: ${props.pressStyle.backgroundColor};`}
|
|
129
201
|
}
|
|
130
202
|
`;
|
|
131
|
-
var Box =
|
|
203
|
+
var Box = import_react2.default.forwardRef(
|
|
132
204
|
({
|
|
133
205
|
children,
|
|
134
206
|
onPress,
|
|
@@ -153,6 +225,8 @@ var Box = import_react.default.forwardRef(
|
|
|
153
225
|
type,
|
|
154
226
|
disabled,
|
|
155
227
|
id,
|
|
228
|
+
testID,
|
|
229
|
+
"data-testid": dataTestId,
|
|
156
230
|
...props
|
|
157
231
|
}, ref) => {
|
|
158
232
|
if (as === "img" && src) {
|
|
@@ -180,7 +254,7 @@ var Box = import_react.default.forwardRef(
|
|
|
180
254
|
StyledBox,
|
|
181
255
|
{
|
|
182
256
|
ref,
|
|
183
|
-
as,
|
|
257
|
+
elementType: as,
|
|
184
258
|
id,
|
|
185
259
|
type: as === "button" ? type || "button" : void 0,
|
|
186
260
|
disabled: as === "button" ? disabled : void 0,
|
|
@@ -200,6 +274,7 @@ var Box = import_react.default.forwardRef(
|
|
|
200
274
|
"aria-controls": ariaControls,
|
|
201
275
|
"aria-live": ariaLive,
|
|
202
276
|
tabIndex: tabIndex !== void 0 ? tabIndex : void 0,
|
|
277
|
+
"data-testid": dataTestId || testID,
|
|
203
278
|
...props,
|
|
204
279
|
children
|
|
205
280
|
}
|
|
@@ -211,7 +286,8 @@ Box.displayName = "Box";
|
|
|
211
286
|
// ../primitives-web/src/Text.tsx
|
|
212
287
|
var import_styled_components2 = __toESM(require("styled-components"));
|
|
213
288
|
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
214
|
-
var
|
|
289
|
+
var FilteredSpan = createFilteredElement("span");
|
|
290
|
+
var StyledText = (0, import_styled_components2.default)(FilteredSpan)`
|
|
215
291
|
color: ${(props) => props.color || "inherit"};
|
|
216
292
|
font-size: ${(props) => typeof props.fontSize === "number" ? `${props.fontSize}px` : props.fontSize || "inherit"};
|
|
217
293
|
font-weight: ${(props) => props.fontWeight || "normal"};
|
|
@@ -244,7 +320,8 @@ var Text = ({
|
|
|
244
320
|
// ../primitives-web/src/Icon.tsx
|
|
245
321
|
var import_styled_components3 = __toESM(require("styled-components"));
|
|
246
322
|
var import_jsx_runtime3 = require("react/jsx-runtime");
|
|
247
|
-
var
|
|
323
|
+
var FilteredDiv2 = createFilteredElement("div");
|
|
324
|
+
var StyledIcon = (0, import_styled_components3.default)(FilteredDiv2)`
|
|
248
325
|
display: flex;
|
|
249
326
|
align-items: center;
|
|
250
327
|
justify-content: center;
|
|
@@ -735,22 +812,22 @@ var Select = ({
|
|
|
735
812
|
themeProductContext
|
|
736
813
|
}) => {
|
|
737
814
|
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,
|
|
815
|
+
const [isOpen, setIsOpen] = (0, import_react3.useState)(false);
|
|
816
|
+
const [selectedValue, setSelectedValue] = (0, import_react3.useState)(value);
|
|
817
|
+
const [searchValue, setSearchValue] = (0, import_react3.useState)("");
|
|
818
|
+
const containerRef = (0, import_react3.useRef)(null);
|
|
819
|
+
const dropdownRef = (0, import_react3.useRef)(null);
|
|
820
|
+
const selectedItemRef = (0, import_react3.useRef)(null);
|
|
821
|
+
const searchInputRef = (0, import_react3.useRef)(null);
|
|
745
822
|
const isDisable = externalState === "disable" || disabled;
|
|
746
823
|
const isError = externalState === "error" || !!errorMessage;
|
|
747
824
|
const isFocus = externalState === "focus" || isOpen;
|
|
748
|
-
|
|
825
|
+
import_react3.default.useEffect(() => {
|
|
749
826
|
if (value !== void 0) {
|
|
750
827
|
setSelectedValue(value);
|
|
751
828
|
}
|
|
752
829
|
}, [value]);
|
|
753
|
-
(0,
|
|
830
|
+
(0, import_react3.useEffect)(() => {
|
|
754
831
|
if (isFocus && selectedItemRef.current && dropdownRef.current) {
|
|
755
832
|
const timeoutId = setTimeout(() => {
|
|
756
833
|
const selectedItem = selectedItemRef.current;
|
|
@@ -761,17 +838,17 @@ var Select = ({
|
|
|
761
838
|
return () => clearTimeout(timeoutId);
|
|
762
839
|
}
|
|
763
840
|
}, [isFocus]);
|
|
764
|
-
(0,
|
|
841
|
+
(0, import_react3.useEffect)(() => {
|
|
765
842
|
if (isFocus && searchable) {
|
|
766
843
|
searchInputRef.current?.focus();
|
|
767
844
|
}
|
|
768
845
|
}, [isFocus, searchable]);
|
|
769
|
-
(0,
|
|
846
|
+
(0, import_react3.useEffect)(() => {
|
|
770
847
|
if (!isFocus) {
|
|
771
848
|
setSearchValue("");
|
|
772
849
|
}
|
|
773
850
|
}, [isFocus]);
|
|
774
|
-
(0,
|
|
851
|
+
(0, import_react3.useEffect)(() => {
|
|
775
852
|
if (import_xui_core.isNative || !isOpen) return;
|
|
776
853
|
const handleClickOutside = (event) => {
|
|
777
854
|
if (containerRef.current && !containerRef.current.contains(event.target)) {
|
|
@@ -987,7 +1064,7 @@ var Select = ({
|
|
|
987
1064
|
}
|
|
988
1065
|
)
|
|
989
1066
|
}
|
|
990
|
-
) : filteredOptions.map((option,
|
|
1067
|
+
) : filteredOptions.map((option, index2) => {
|
|
991
1068
|
const optionValue = getOptionValue(option);
|
|
992
1069
|
const optionLabel = getOptionLabel(option);
|
|
993
1070
|
const isOptionDisabled = getOptionDisabled(option);
|
|
@@ -1024,7 +1101,7 @@ var Select = ({
|
|
|
1024
1101
|
}
|
|
1025
1102
|
)
|
|
1026
1103
|
},
|
|
1027
|
-
|
|
1104
|
+
index2
|
|
1028
1105
|
);
|
|
1029
1106
|
})
|
|
1030
1107
|
}
|