@xsolla/xui-counter 0.200.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.d.mts +130 -0
- package/native/index.d.ts +130 -0
- package/native/index.js +676 -0
- package/native/index.js.map +1 -0
- package/native/index.mjs +646 -0
- package/native/index.mjs.map +1 -0
- package/package.json +59 -0
- package/web/index.d.mts +130 -0
- package/web/index.d.ts +130 -0
- package/web/index.js +696 -0
- package/web/index.js.map +1 -0
- package/web/index.mjs +659 -0
- package/web/index.mjs.map +1 -0
package/web/index.js
ADDED
|
@@ -0,0 +1,696 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
|
|
30
|
+
// src/index.tsx
|
|
31
|
+
var index_exports = {};
|
|
32
|
+
__export(index_exports, {
|
|
33
|
+
Counter: () => Counter
|
|
34
|
+
});
|
|
35
|
+
module.exports = __toCommonJS(index_exports);
|
|
36
|
+
|
|
37
|
+
// src/Counter.tsx
|
|
38
|
+
var import_react3 = __toESM(require("react"));
|
|
39
|
+
|
|
40
|
+
// ../../foundation/primitives-web/src/Box.tsx
|
|
41
|
+
var import_react2 = __toESM(require("react"));
|
|
42
|
+
var import_styled_components = __toESM(require("styled-components"));
|
|
43
|
+
|
|
44
|
+
// ../../foundation/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
|
+
// ../../foundation/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
|
+
// Cross-platform layout prop that Text consumes as CSS, never as an
|
|
88
|
+
// attribute. Pinned explicitly because it is now spread into the styled
|
|
89
|
+
// component rather than destructured away before it can reach the DOM.
|
|
90
|
+
"numberOfLines"
|
|
91
|
+
]);
|
|
92
|
+
function shouldForwardProp(key) {
|
|
93
|
+
if (ADDITIONAL_BLOCKED_PROPS.has(key)) return false;
|
|
94
|
+
return is_prop_valid_esm_default(key);
|
|
95
|
+
}
|
|
96
|
+
function createFilteredElement(defaultTag) {
|
|
97
|
+
const Component = import_react.default.forwardRef(
|
|
98
|
+
({ children, elementType, ...props }, ref) => {
|
|
99
|
+
const Tag = elementType || defaultTag;
|
|
100
|
+
const htmlProps = {};
|
|
101
|
+
for (const key of Object.keys(props)) {
|
|
102
|
+
if (shouldForwardProp(key)) {
|
|
103
|
+
htmlProps[key] = props[key];
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
return import_react.default.createElement(
|
|
107
|
+
Tag,
|
|
108
|
+
{ ref, ...htmlProps },
|
|
109
|
+
children
|
|
110
|
+
);
|
|
111
|
+
}
|
|
112
|
+
);
|
|
113
|
+
Component.displayName = `Filtered(${defaultTag})`;
|
|
114
|
+
return Component;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
// ../../foundation/primitives-web/src/Box.tsx
|
|
118
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
119
|
+
var FilteredDiv = createFilteredElement("div");
|
|
120
|
+
var StyledBox = (0, import_styled_components.default)(FilteredDiv)`
|
|
121
|
+
display: flex;
|
|
122
|
+
box-sizing: border-box;
|
|
123
|
+
background-color: ${(props) => props.backgroundColor || "transparent"};
|
|
124
|
+
border-color: ${(props) => props.borderColor || "transparent"};
|
|
125
|
+
border-width: ${(props) => typeof props.borderWidth === "number" ? `${props.borderWidth}px` : props.borderWidth || 0};
|
|
126
|
+
|
|
127
|
+
${(props) => props.borderBottomWidth !== void 0 && `
|
|
128
|
+
border-bottom-width: ${typeof props.borderBottomWidth === "number" ? `${props.borderBottomWidth}px` : props.borderBottomWidth};
|
|
129
|
+
border-bottom-color: ${props.borderBottomColor || props.borderColor || "transparent"};
|
|
130
|
+
border-bottom-style: solid;
|
|
131
|
+
`}
|
|
132
|
+
${(props) => props.borderTopWidth !== void 0 && `
|
|
133
|
+
border-top-width: ${typeof props.borderTopWidth === "number" ? `${props.borderTopWidth}px` : props.borderTopWidth};
|
|
134
|
+
border-top-color: ${props.borderTopColor || props.borderColor || "transparent"};
|
|
135
|
+
border-top-style: solid;
|
|
136
|
+
`}
|
|
137
|
+
${(props) => props.borderLeftWidth !== void 0 && `
|
|
138
|
+
border-left-width: ${typeof props.borderLeftWidth === "number" ? `${props.borderLeftWidth}px` : props.borderLeftWidth};
|
|
139
|
+
border-left-color: ${props.borderLeftColor || props.borderColor || "transparent"};
|
|
140
|
+
border-left-style: solid;
|
|
141
|
+
`}
|
|
142
|
+
${(props) => props.borderRightWidth !== void 0 && `
|
|
143
|
+
border-right-width: ${typeof props.borderRightWidth === "number" ? `${props.borderRightWidth}px` : props.borderRightWidth};
|
|
144
|
+
border-right-color: ${props.borderRightColor || props.borderColor || "transparent"};
|
|
145
|
+
border-right-style: solid;
|
|
146
|
+
`}
|
|
147
|
+
|
|
148
|
+
border-style: ${(props) => props.borderStyle || (props.borderWidth || props.borderBottomWidth || props.borderTopWidth || props.borderLeftWidth || props.borderRightWidth ? "solid" : "none")};
|
|
149
|
+
border-radius: ${(props) => typeof props.borderRadius === "number" ? `${props.borderRadius}px` : props.borderRadius || 0};
|
|
150
|
+
height: ${(props) => typeof props.height === "number" ? `${props.height}px` : props.height || "auto"};
|
|
151
|
+
width: ${(props) => typeof props.width === "number" ? `${props.width}px` : props.width || "auto"};
|
|
152
|
+
min-width: ${(props) => typeof props.minWidth === "number" ? `${props.minWidth}px` : props.minWidth || "auto"};
|
|
153
|
+
min-height: ${(props) => typeof props.minHeight === "number" ? `${props.minHeight}px` : props.minHeight || "auto"};
|
|
154
|
+
max-width: ${(props) => typeof props.maxWidth === "number" ? `${props.maxWidth}px` : props.maxWidth || "none"};
|
|
155
|
+
max-height: ${(props) => typeof props.maxHeight === "number" ? `${props.maxHeight}px` : props.maxHeight || "none"};
|
|
156
|
+
|
|
157
|
+
padding: ${(props) => typeof props.padding === "number" ? `${props.padding}px` : props.padding || 0};
|
|
158
|
+
${(props) => props.paddingHorizontal && `
|
|
159
|
+
padding-left: ${typeof props.paddingHorizontal === "number" ? `${props.paddingHorizontal}px` : props.paddingHorizontal};
|
|
160
|
+
padding-right: ${typeof props.paddingHorizontal === "number" ? `${props.paddingHorizontal}px` : props.paddingHorizontal};
|
|
161
|
+
`}
|
|
162
|
+
${(props) => props.paddingVertical && `
|
|
163
|
+
padding-top: ${typeof props.paddingVertical === "number" ? `${props.paddingVertical}px` : props.paddingVertical};
|
|
164
|
+
padding-bottom: ${typeof props.paddingVertical === "number" ? `${props.paddingVertical}px` : props.paddingVertical};
|
|
165
|
+
`}
|
|
166
|
+
${(props) => props.paddingTop !== void 0 && `padding-top: ${typeof props.paddingTop === "number" ? `${props.paddingTop}px` : props.paddingTop};`}
|
|
167
|
+
${(props) => props.paddingBottom !== void 0 && `padding-bottom: ${typeof props.paddingBottom === "number" ? `${props.paddingBottom}px` : props.paddingBottom};`}
|
|
168
|
+
${(props) => props.paddingLeft !== void 0 && `padding-left: ${typeof props.paddingLeft === "number" ? `${props.paddingLeft}px` : props.paddingLeft};`}
|
|
169
|
+
${(props) => props.paddingRight !== void 0 && `padding-right: ${typeof props.paddingRight === "number" ? `${props.paddingRight}px` : props.paddingRight};`}
|
|
170
|
+
|
|
171
|
+
margin: ${(props) => typeof props.margin === "number" ? `${props.margin}px` : props.margin || 0};
|
|
172
|
+
${(props) => props.marginTop !== void 0 && `margin-top: ${typeof props.marginTop === "number" ? `${props.marginTop}px` : props.marginTop};`}
|
|
173
|
+
${(props) => props.marginBottom !== void 0 && `margin-bottom: ${typeof props.marginBottom === "number" ? `${props.marginBottom}px` : props.marginBottom};`}
|
|
174
|
+
${(props) => props.marginLeft !== void 0 && `margin-left: ${typeof props.marginLeft === "number" ? `${props.marginLeft}px` : props.marginLeft};`}
|
|
175
|
+
${(props) => props.marginRight !== void 0 && `margin-right: ${typeof props.marginRight === "number" ? `${props.marginRight}px` : props.marginRight};`}
|
|
176
|
+
|
|
177
|
+
flex-direction: ${(props) => props.flexDirection || "column"};
|
|
178
|
+
flex-wrap: ${(props) => props.flexWrap || "nowrap"};
|
|
179
|
+
align-items: ${(props) => props.alignItems || "stretch"};
|
|
180
|
+
justify-content: ${(props) => props.justifyContent || "flex-start"};
|
|
181
|
+
cursor: ${(props) => props.cursor ? props.cursor : props.onClick || props.onPress ? "pointer" : "inherit"};
|
|
182
|
+
position: ${(props) => props.position || "static"};
|
|
183
|
+
top: ${(props) => typeof props.top === "number" ? `${props.top}px` : props.top};
|
|
184
|
+
bottom: ${(props) => typeof props.bottom === "number" ? `${props.bottom}px` : props.bottom};
|
|
185
|
+
left: ${(props) => typeof props.left === "number" ? `${props.left}px` : props.left};
|
|
186
|
+
right: ${(props) => typeof props.right === "number" ? `${props.right}px` : props.right};
|
|
187
|
+
flex: ${(props) => props.flex};
|
|
188
|
+
flex-shrink: ${(props) => props.flexShrink ?? 1};
|
|
189
|
+
gap: ${(props) => typeof props.gap === "number" ? `${props.gap}px` : props.gap || 0};
|
|
190
|
+
align-self: ${(props) => props.alignSelf || "auto"};
|
|
191
|
+
overflow: ${(props) => props.overflow || "visible"};
|
|
192
|
+
overflow-x: ${(props) => props.overflowX || "visible"};
|
|
193
|
+
overflow-y: ${(props) => props.overflowY || "visible"};
|
|
194
|
+
z-index: ${(props) => props.zIndex};
|
|
195
|
+
opacity: ${(props) => props.disabled ? 0.5 : 1};
|
|
196
|
+
pointer-events: ${(props) => props.disabled ? "none" : "auto"};
|
|
197
|
+
|
|
198
|
+
&:hover {
|
|
199
|
+
${(props) => props.hoverStyle?.backgroundColor && `background-color: ${props.hoverStyle.backgroundColor};`}
|
|
200
|
+
${(props) => props.hoverStyle?.borderColor && `border-color: ${props.hoverStyle.borderColor};`}
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
&:active {
|
|
204
|
+
${(props) => props.pressStyle?.backgroundColor && `background-color: ${props.pressStyle.backgroundColor};`}
|
|
205
|
+
}
|
|
206
|
+
`;
|
|
207
|
+
var Box = import_react2.default.forwardRef(
|
|
208
|
+
({
|
|
209
|
+
children,
|
|
210
|
+
onPress,
|
|
211
|
+
onKeyDown,
|
|
212
|
+
onKeyUp,
|
|
213
|
+
role,
|
|
214
|
+
"aria-label": ariaLabel,
|
|
215
|
+
"aria-labelledby": ariaLabelledBy,
|
|
216
|
+
"aria-current": ariaCurrent,
|
|
217
|
+
"aria-disabled": ariaDisabled,
|
|
218
|
+
"aria-live": ariaLive,
|
|
219
|
+
"aria-busy": ariaBusy,
|
|
220
|
+
"aria-describedby": ariaDescribedBy,
|
|
221
|
+
"aria-expanded": ariaExpanded,
|
|
222
|
+
"aria-haspopup": ariaHasPopup,
|
|
223
|
+
"aria-pressed": ariaPressed,
|
|
224
|
+
"aria-controls": ariaControls,
|
|
225
|
+
tabIndex,
|
|
226
|
+
as,
|
|
227
|
+
src,
|
|
228
|
+
alt,
|
|
229
|
+
onError,
|
|
230
|
+
onLoad,
|
|
231
|
+
type,
|
|
232
|
+
disabled,
|
|
233
|
+
id,
|
|
234
|
+
testID,
|
|
235
|
+
"data-testid": dataTestId,
|
|
236
|
+
...props
|
|
237
|
+
}, ref) => {
|
|
238
|
+
if (as === "img" && src) {
|
|
239
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
240
|
+
"img",
|
|
241
|
+
{
|
|
242
|
+
src,
|
|
243
|
+
alt: alt || "",
|
|
244
|
+
onError,
|
|
245
|
+
onLoad,
|
|
246
|
+
style: {
|
|
247
|
+
display: "block",
|
|
248
|
+
objectFit: "cover",
|
|
249
|
+
width: typeof props.width === "number" ? `${props.width}px` : props.width,
|
|
250
|
+
height: typeof props.height === "number" ? `${props.height}px` : props.height,
|
|
251
|
+
borderRadius: typeof props.borderRadius === "number" ? `${props.borderRadius}px` : props.borderRadius,
|
|
252
|
+
position: props.position,
|
|
253
|
+
top: typeof props.top === "number" ? `${props.top}px` : props.top,
|
|
254
|
+
left: typeof props.left === "number" ? `${props.left}px` : props.left,
|
|
255
|
+
right: typeof props.right === "number" ? `${props.right}px` : props.right,
|
|
256
|
+
bottom: typeof props.bottom === "number" ? `${props.bottom}px` : props.bottom,
|
|
257
|
+
...props.style
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
);
|
|
261
|
+
}
|
|
262
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
263
|
+
StyledBox,
|
|
264
|
+
{
|
|
265
|
+
ref,
|
|
266
|
+
elementType: as,
|
|
267
|
+
id,
|
|
268
|
+
type: as === "button" ? type || "button" : void 0,
|
|
269
|
+
disabled: as === "button" ? disabled : void 0,
|
|
270
|
+
onClick: onPress,
|
|
271
|
+
onKeyDown,
|
|
272
|
+
onKeyUp,
|
|
273
|
+
role,
|
|
274
|
+
"aria-label": ariaLabel,
|
|
275
|
+
"aria-labelledby": ariaLabelledBy,
|
|
276
|
+
"aria-current": ariaCurrent,
|
|
277
|
+
"aria-disabled": ariaDisabled,
|
|
278
|
+
"aria-busy": ariaBusy,
|
|
279
|
+
"aria-describedby": ariaDescribedBy,
|
|
280
|
+
"aria-expanded": ariaExpanded,
|
|
281
|
+
"aria-haspopup": ariaHasPopup,
|
|
282
|
+
"aria-pressed": ariaPressed,
|
|
283
|
+
"aria-controls": ariaControls,
|
|
284
|
+
"aria-live": ariaLive,
|
|
285
|
+
tabIndex: tabIndex !== void 0 ? tabIndex : void 0,
|
|
286
|
+
"data-testid": dataTestId || testID,
|
|
287
|
+
...props,
|
|
288
|
+
children
|
|
289
|
+
}
|
|
290
|
+
);
|
|
291
|
+
}
|
|
292
|
+
);
|
|
293
|
+
Box.displayName = "Box";
|
|
294
|
+
|
|
295
|
+
// ../../foundation/primitives-web/src/Text.tsx
|
|
296
|
+
var import_styled_components2 = __toESM(require("styled-components"));
|
|
297
|
+
|
|
298
|
+
// ../../foundation/primitives-web/src/textTruncation.ts
|
|
299
|
+
var truncationStyles = (numberOfLines) => {
|
|
300
|
+
if (!numberOfLines || numberOfLines < 1) return "";
|
|
301
|
+
if (numberOfLines === 1) {
|
|
302
|
+
return `
|
|
303
|
+
display: block;
|
|
304
|
+
max-width: 100%;
|
|
305
|
+
min-width: 0;
|
|
306
|
+
overflow: hidden;
|
|
307
|
+
text-overflow: ellipsis;
|
|
308
|
+
white-space: nowrap;
|
|
309
|
+
`;
|
|
310
|
+
}
|
|
311
|
+
return `
|
|
312
|
+
display: -webkit-box;
|
|
313
|
+
-webkit-box-orient: vertical;
|
|
314
|
+
-webkit-line-clamp: ${numberOfLines};
|
|
315
|
+
line-clamp: ${numberOfLines};
|
|
316
|
+
max-width: 100%;
|
|
317
|
+
min-width: 0;
|
|
318
|
+
overflow: hidden;
|
|
319
|
+
`;
|
|
320
|
+
};
|
|
321
|
+
|
|
322
|
+
// ../../foundation/primitives-web/src/Text.tsx
|
|
323
|
+
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
324
|
+
var FilteredSpan = createFilteredElement("span");
|
|
325
|
+
var StyledText = (0, import_styled_components2.default)(FilteredSpan)`
|
|
326
|
+
color: ${(props) => props.color || "inherit"};
|
|
327
|
+
font-size: ${(props) => typeof props.fontSize === "number" ? `${props.fontSize}px` : props.fontSize || "inherit"};
|
|
328
|
+
font-weight: ${(props) => props.fontWeight || "normal"};
|
|
329
|
+
font-family: ${(props) => props.fontFamily || '"Aktiv Grotesk", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif'};
|
|
330
|
+
line-height: ${(props) => typeof props.lineHeight === "number" ? `${props.lineHeight}px` : props.lineHeight || "inherit"};
|
|
331
|
+
white-space: ${(props) => props.whiteSpace || "normal"};
|
|
332
|
+
text-align: ${(props) => props.textAlign || "inherit"};
|
|
333
|
+
text-decoration: ${(props) => props.textDecoration || "none"};
|
|
334
|
+
|
|
335
|
+
/* Keep last: single-line truncation has to win over white-space above. */
|
|
336
|
+
${(props) => truncationStyles(props.numberOfLines)}
|
|
337
|
+
`;
|
|
338
|
+
var Text = ({
|
|
339
|
+
style,
|
|
340
|
+
className,
|
|
341
|
+
id,
|
|
342
|
+
role,
|
|
343
|
+
testID,
|
|
344
|
+
"data-testid": dataTestId,
|
|
345
|
+
...props
|
|
346
|
+
}) => {
|
|
347
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
348
|
+
StyledText,
|
|
349
|
+
{
|
|
350
|
+
...props,
|
|
351
|
+
style,
|
|
352
|
+
className,
|
|
353
|
+
id,
|
|
354
|
+
role,
|
|
355
|
+
"data-testid": dataTestId || testID
|
|
356
|
+
}
|
|
357
|
+
);
|
|
358
|
+
};
|
|
359
|
+
|
|
360
|
+
// ../../foundation/primitives-web/src/Icon.tsx
|
|
361
|
+
var import_styled_components3 = __toESM(require("styled-components"));
|
|
362
|
+
var import_jsx_runtime3 = require("react/jsx-runtime");
|
|
363
|
+
var FilteredDiv2 = createFilteredElement("div");
|
|
364
|
+
var StyledIcon = (0, import_styled_components3.default)(FilteredDiv2)`
|
|
365
|
+
display: flex;
|
|
366
|
+
align-items: center;
|
|
367
|
+
justify-content: center;
|
|
368
|
+
width: ${(props) => typeof props.size === "number" ? `${props.size}px` : props.size || "24px"};
|
|
369
|
+
height: ${(props) => typeof props.size === "number" ? `${props.size}px` : props.size || "24px"};
|
|
370
|
+
color: ${(props) => props.color || "currentColor"};
|
|
371
|
+
|
|
372
|
+
/* Icons paint themselves — each icon's own SVG sets its fill/stroke
|
|
373
|
+
(icons-base via inline "fill: currentColor", Lucide via "fill"/"stroke"
|
|
374
|
+
attributes). Do not add fill/stroke here: it re-strokes fill-based icons
|
|
375
|
+
and thickens the glyph. See FEP-877. */
|
|
376
|
+
svg {
|
|
377
|
+
width: 100%;
|
|
378
|
+
height: 100%;
|
|
379
|
+
}
|
|
380
|
+
`;
|
|
381
|
+
var Icon = ({
|
|
382
|
+
children,
|
|
383
|
+
testID,
|
|
384
|
+
"data-testid": dataTestId,
|
|
385
|
+
...props
|
|
386
|
+
}) => {
|
|
387
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(StyledIcon, { "data-testid": dataTestId || testID, ...props, children });
|
|
388
|
+
};
|
|
389
|
+
|
|
390
|
+
// ../../foundation/primitives-web/src/index.tsx
|
|
391
|
+
var isWeb = true;
|
|
392
|
+
|
|
393
|
+
// src/Counter.tsx
|
|
394
|
+
var import_xui_core = require("@xsolla/xui-core");
|
|
395
|
+
var import_xui_input = require("@xsolla/xui-input");
|
|
396
|
+
var import_xui_icons_base = require("@xsolla/xui-icons-base");
|
|
397
|
+
|
|
398
|
+
// src/utils.ts
|
|
399
|
+
var COUNTER_SIZE_CONFIG = {
|
|
400
|
+
xl: { control: 28, gap: 10, inputWidth: 149, readOnlyWidth: 100 },
|
|
401
|
+
lg: { control: 24, gap: 10, inputWidth: 142, readOnlyWidth: 90 },
|
|
402
|
+
md: { control: 24, gap: 8, inputWidth: 132, readOnlyWidth: 83 },
|
|
403
|
+
sm: { control: 18, gap: 8, inputWidth: 92, readOnlyWidth: 69 },
|
|
404
|
+
xs: { control: 16, gap: 6, inputWidth: 82, readOnlyWidth: 59 }
|
|
405
|
+
};
|
|
406
|
+
var clampToRange = (value, min, max) => {
|
|
407
|
+
let next = value;
|
|
408
|
+
if (typeof min === "number" && next < min) next = min;
|
|
409
|
+
if (typeof max === "number" && next > max) next = max;
|
|
410
|
+
return next;
|
|
411
|
+
};
|
|
412
|
+
var sanitizeCounterInput = (raw, allowNegative) => {
|
|
413
|
+
const digitsAndSigns = raw.replace(/[^\d-]/g, "");
|
|
414
|
+
const digits = digitsAndSigns.replace(/-/g, "");
|
|
415
|
+
if (allowNegative && digitsAndSigns.startsWith("-")) {
|
|
416
|
+
return `-${digits}`;
|
|
417
|
+
}
|
|
418
|
+
return digits;
|
|
419
|
+
};
|
|
420
|
+
var parseCounterValue = (raw) => {
|
|
421
|
+
const trimmed = raw.trim();
|
|
422
|
+
if (trimmed === "" || trimmed === "-") return null;
|
|
423
|
+
const parsed = Number.parseInt(trimmed, 10);
|
|
424
|
+
return Number.isNaN(parsed) ? null : parsed;
|
|
425
|
+
};
|
|
426
|
+
var allowsNegative = (min) => typeof min !== "number" || min < 0;
|
|
427
|
+
|
|
428
|
+
// src/Counter.tsx
|
|
429
|
+
var import_jsx_runtime4 = require("react/jsx-runtime");
|
|
430
|
+
var CounterButton = ({
|
|
431
|
+
icon,
|
|
432
|
+
label,
|
|
433
|
+
onPress,
|
|
434
|
+
available,
|
|
435
|
+
boxSize,
|
|
436
|
+
borderRadius,
|
|
437
|
+
color,
|
|
438
|
+
hoverColor,
|
|
439
|
+
testID
|
|
440
|
+
}) => /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
441
|
+
Box,
|
|
442
|
+
{
|
|
443
|
+
as: "button",
|
|
444
|
+
type: "button",
|
|
445
|
+
width: boxSize,
|
|
446
|
+
height: boxSize,
|
|
447
|
+
flexShrink: 0,
|
|
448
|
+
alignItems: "center",
|
|
449
|
+
justifyContent: "center",
|
|
450
|
+
padding: 0,
|
|
451
|
+
borderWidth: 0,
|
|
452
|
+
borderRadius,
|
|
453
|
+
backgroundColor: "transparent",
|
|
454
|
+
cursor: available ? "pointer" : "not-allowed",
|
|
455
|
+
disabled: !available,
|
|
456
|
+
"aria-disabled": !available || void 0,
|
|
457
|
+
"aria-label": label,
|
|
458
|
+
onPress,
|
|
459
|
+
hoverStyle: available ? { backgroundColor: hoverColor } : void 0,
|
|
460
|
+
...isWeb && {
|
|
461
|
+
onMouseDown: (e) => e.preventDefault()
|
|
462
|
+
},
|
|
463
|
+
"data-testid": testID,
|
|
464
|
+
testID,
|
|
465
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(Icon, { size: boxSize, color, children: icon })
|
|
466
|
+
}
|
|
467
|
+
);
|
|
468
|
+
var Counter = (0, import_react3.forwardRef)(
|
|
469
|
+
({
|
|
470
|
+
value,
|
|
471
|
+
defaultValue = null,
|
|
472
|
+
onChange,
|
|
473
|
+
min,
|
|
474
|
+
max,
|
|
475
|
+
step = 1,
|
|
476
|
+
size = "md",
|
|
477
|
+
type = "input",
|
|
478
|
+
disabled = false,
|
|
479
|
+
label,
|
|
480
|
+
"aria-label": ariaLabel,
|
|
481
|
+
decrementLabel = "Decrease quantity",
|
|
482
|
+
incrementLabel = "Increase quantity",
|
|
483
|
+
name,
|
|
484
|
+
id: providedId,
|
|
485
|
+
testID,
|
|
486
|
+
themeMode,
|
|
487
|
+
themeProductContext
|
|
488
|
+
}, ref) => {
|
|
489
|
+
const { theme } = (0, import_xui_core.useResolvedTheme)({ themeMode, themeProductContext });
|
|
490
|
+
const rawId = (0, import_xui_core.useId)();
|
|
491
|
+
const safeId = rawId.replace(/:/g, "");
|
|
492
|
+
const counterId = providedId || `counter-${safeId}`;
|
|
493
|
+
const isControlled = value !== void 0;
|
|
494
|
+
const [uncontrolledValue, setUncontrolledValue] = (0, import_react3.useState)(
|
|
495
|
+
defaultValue
|
|
496
|
+
);
|
|
497
|
+
const committedValue = isControlled ? value ?? null : uncontrolledValue;
|
|
498
|
+
const [draft, setDraft] = (0, import_react3.useState)(null);
|
|
499
|
+
const inputRef = (0, import_react3.useRef)(null);
|
|
500
|
+
import_react3.default.useImperativeHandle(
|
|
501
|
+
ref,
|
|
502
|
+
() => inputRef.current,
|
|
503
|
+
[]
|
|
504
|
+
);
|
|
505
|
+
const sizeConfig = COUNTER_SIZE_CONFIG[size];
|
|
506
|
+
const inputSizing = theme.sizing.input(size);
|
|
507
|
+
const isReadOnly = type === "readOnly";
|
|
508
|
+
const pendingValue = draft !== null ? parseCounterValue(draft) : committedValue;
|
|
509
|
+
const stepBase = pendingValue ?? min ?? 0;
|
|
510
|
+
const canDecrement = !disabled && (typeof min !== "number" || stepBase > min);
|
|
511
|
+
const canIncrement = !disabled && (typeof max !== "number" || stepBase < max);
|
|
512
|
+
const commit = (next) => {
|
|
513
|
+
setDraft(null);
|
|
514
|
+
const resolved = next ?? committedValue;
|
|
515
|
+
if (resolved === null) return;
|
|
516
|
+
const clamped = clampToRange(resolved, min, max);
|
|
517
|
+
if (!isControlled) setUncontrolledValue(clamped);
|
|
518
|
+
if (clamped !== committedValue) onChange?.(clamped);
|
|
519
|
+
};
|
|
520
|
+
const stepBy = (direction) => {
|
|
521
|
+
commit(clampToRange(stepBase + direction * step, min, max));
|
|
522
|
+
};
|
|
523
|
+
const handleInputChange = (e) => {
|
|
524
|
+
setDraft(sanitizeCounterInput(e.target.value, allowsNegative(min)));
|
|
525
|
+
};
|
|
526
|
+
const handleBlur = () => {
|
|
527
|
+
commit(draft !== null ? parseCounterValue(draft) : committedValue);
|
|
528
|
+
};
|
|
529
|
+
const handleKeyDown = (e) => {
|
|
530
|
+
if (e.key === "ArrowUp") {
|
|
531
|
+
e.preventDefault();
|
|
532
|
+
if (canIncrement) stepBy(1);
|
|
533
|
+
return;
|
|
534
|
+
}
|
|
535
|
+
if (e.key === "ArrowDown") {
|
|
536
|
+
e.preventDefault();
|
|
537
|
+
if (canDecrement) stepBy(-1);
|
|
538
|
+
return;
|
|
539
|
+
}
|
|
540
|
+
if (e.key === "Home" && typeof min === "number") {
|
|
541
|
+
e.preventDefault();
|
|
542
|
+
commit(min);
|
|
543
|
+
return;
|
|
544
|
+
}
|
|
545
|
+
if (e.key === "End" && typeof max === "number") {
|
|
546
|
+
e.preventDefault();
|
|
547
|
+
commit(max);
|
|
548
|
+
return;
|
|
549
|
+
}
|
|
550
|
+
if (e.key === "Enter" || e.key === "\n") {
|
|
551
|
+
e.preventDefault();
|
|
552
|
+
commit(draft !== null ? parseCounterValue(draft) : committedValue);
|
|
553
|
+
}
|
|
554
|
+
};
|
|
555
|
+
const enabledIconColor = theme.colors.content.secondary;
|
|
556
|
+
const disabledIconColor = theme.colors.control.text.disable;
|
|
557
|
+
const hoverColor = theme.colors.overlay.mono;
|
|
558
|
+
const buttonRadius = theme.shape.input[size].borderRadius;
|
|
559
|
+
const decrementButton = /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
560
|
+
CounterButton,
|
|
561
|
+
{
|
|
562
|
+
icon: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_xui_icons_base.MinusSq, {}),
|
|
563
|
+
label: decrementLabel,
|
|
564
|
+
onPress: () => {
|
|
565
|
+
if (canDecrement) stepBy(-1);
|
|
566
|
+
},
|
|
567
|
+
available: canDecrement,
|
|
568
|
+
boxSize: sizeConfig.control,
|
|
569
|
+
borderRadius: buttonRadius,
|
|
570
|
+
color: canDecrement ? enabledIconColor : disabledIconColor,
|
|
571
|
+
hoverColor,
|
|
572
|
+
testID: testID ? `${testID}__decrement` : void 0
|
|
573
|
+
}
|
|
574
|
+
);
|
|
575
|
+
const incrementButton = /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
576
|
+
CounterButton,
|
|
577
|
+
{
|
|
578
|
+
icon: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_xui_icons_base.PlusSq, {}),
|
|
579
|
+
label: incrementLabel,
|
|
580
|
+
onPress: () => {
|
|
581
|
+
if (canIncrement) stepBy(1);
|
|
582
|
+
},
|
|
583
|
+
available: canIncrement,
|
|
584
|
+
boxSize: sizeConfig.control,
|
|
585
|
+
borderRadius: buttonRadius,
|
|
586
|
+
color: canIncrement ? enabledIconColor : disabledIconColor,
|
|
587
|
+
hoverColor,
|
|
588
|
+
testID: testID ? `${testID}__increment` : void 0
|
|
589
|
+
}
|
|
590
|
+
);
|
|
591
|
+
const labelId = `${counterId}-label`;
|
|
592
|
+
const showLabel = Boolean(label) && !isReadOnly;
|
|
593
|
+
const labelNode = showLabel ? /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(Box, { as: "label", id: labelId, children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
594
|
+
Text,
|
|
595
|
+
{
|
|
596
|
+
color: theme.colors.content.secondary,
|
|
597
|
+
fontSize: inputSizing.fontSize - 2,
|
|
598
|
+
fontWeight: "500",
|
|
599
|
+
children: label
|
|
600
|
+
}
|
|
601
|
+
) }) : null;
|
|
602
|
+
if (isReadOnly) {
|
|
603
|
+
const readOnlyValue = String(committedValue ?? min ?? 0);
|
|
604
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(
|
|
605
|
+
Box,
|
|
606
|
+
{
|
|
607
|
+
flexDirection: "row",
|
|
608
|
+
alignItems: "center",
|
|
609
|
+
gap: sizeConfig.gap,
|
|
610
|
+
width: sizeConfig.readOnlyWidth,
|
|
611
|
+
role: "group",
|
|
612
|
+
"aria-label": ariaLabel || label,
|
|
613
|
+
"aria-disabled": disabled || void 0,
|
|
614
|
+
"data-testid": testID,
|
|
615
|
+
children: [
|
|
616
|
+
decrementButton,
|
|
617
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(Box, { flex: 1, minWidth: 0, "aria-live": "polite", alignItems: "center", children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
618
|
+
Text,
|
|
619
|
+
{
|
|
620
|
+
color: disabled ? theme.colors.control.input.textDisable : theme.colors.control.input.text,
|
|
621
|
+
fontSize: inputSizing.fontSize,
|
|
622
|
+
lineHeight: inputSizing.fontSize + 2,
|
|
623
|
+
textAlign: "center",
|
|
624
|
+
"data-testid": testID ? `${testID}__value` : void 0,
|
|
625
|
+
children: readOnlyValue
|
|
626
|
+
}
|
|
627
|
+
) }),
|
|
628
|
+
incrementButton
|
|
629
|
+
]
|
|
630
|
+
}
|
|
631
|
+
);
|
|
632
|
+
}
|
|
633
|
+
const displayValue = draft !== null ? draft : committedValue === null ? "" : String(committedValue);
|
|
634
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(
|
|
635
|
+
Box,
|
|
636
|
+
{
|
|
637
|
+
flexDirection: "column",
|
|
638
|
+
gap: inputSizing.fieldGap,
|
|
639
|
+
alignItems: "flex-start",
|
|
640
|
+
role: "group",
|
|
641
|
+
"aria-label": showLabel ? void 0 : ariaLabel,
|
|
642
|
+
"aria-labelledby": showLabel ? labelId : void 0,
|
|
643
|
+
"aria-disabled": disabled || void 0,
|
|
644
|
+
"data-testid": testID,
|
|
645
|
+
children: [
|
|
646
|
+
labelNode,
|
|
647
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(
|
|
648
|
+
Box,
|
|
649
|
+
{
|
|
650
|
+
flexDirection: "row",
|
|
651
|
+
alignItems: "center",
|
|
652
|
+
gap: sizeConfig.gap,
|
|
653
|
+
width: sizeConfig.inputWidth,
|
|
654
|
+
children: [
|
|
655
|
+
decrementButton,
|
|
656
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(Box, { flex: 1, minWidth: 0, children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
657
|
+
import_xui_input.Input,
|
|
658
|
+
{
|
|
659
|
+
ref: inputRef,
|
|
660
|
+
id: counterId,
|
|
661
|
+
name,
|
|
662
|
+
size,
|
|
663
|
+
value: displayValue,
|
|
664
|
+
disabled,
|
|
665
|
+
onChange: handleInputChange,
|
|
666
|
+
onBlur: handleBlur,
|
|
667
|
+
onKeyDown: handleKeyDown,
|
|
668
|
+
type: "text",
|
|
669
|
+
inputMode: "numeric",
|
|
670
|
+
role: "spinbutton",
|
|
671
|
+
"aria-valuenow": committedValue ?? void 0,
|
|
672
|
+
"aria-valuemin": min,
|
|
673
|
+
"aria-valuemax": max,
|
|
674
|
+
"aria-label": showLabel ? void 0 : ariaLabel,
|
|
675
|
+
...showLabel ? { "aria-labelledby": labelId } : {},
|
|
676
|
+
style: { textAlign: "center" },
|
|
677
|
+
themeMode,
|
|
678
|
+
themeProductContext,
|
|
679
|
+
testID: testID ? `${testID}__input` : void 0
|
|
680
|
+
}
|
|
681
|
+
) }),
|
|
682
|
+
incrementButton
|
|
683
|
+
]
|
|
684
|
+
}
|
|
685
|
+
)
|
|
686
|
+
]
|
|
687
|
+
}
|
|
688
|
+
);
|
|
689
|
+
}
|
|
690
|
+
);
|
|
691
|
+
Counter.displayName = "Counter";
|
|
692
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
693
|
+
0 && (module.exports = {
|
|
694
|
+
Counter
|
|
695
|
+
});
|
|
696
|
+
//# sourceMappingURL=index.js.map
|