@xsolla/xui-input-color 0.184.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/web/index.js ADDED
@@ -0,0 +1,956 @@
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
+ InputColor: () => InputColor
34
+ });
35
+ module.exports = __toCommonJS(index_exports);
36
+
37
+ // src/InputColor.tsx
38
+ var import_react4 = 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
+ ]);
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
+ // ../../foundation/primitives-web/src/Box.tsx
114
+ var import_jsx_runtime = require("react/jsx-runtime");
115
+ var FilteredDiv = createFilteredElement("div");
116
+ var StyledBox = (0, import_styled_components.default)(FilteredDiv)`
117
+ display: flex;
118
+ box-sizing: border-box;
119
+ background-color: ${(props) => props.backgroundColor || "transparent"};
120
+ border-color: ${(props) => props.borderColor || "transparent"};
121
+ border-width: ${(props) => typeof props.borderWidth === "number" ? `${props.borderWidth}px` : props.borderWidth || 0};
122
+
123
+ ${(props) => props.borderBottomWidth !== void 0 && `
124
+ border-bottom-width: ${typeof props.borderBottomWidth === "number" ? `${props.borderBottomWidth}px` : props.borderBottomWidth};
125
+ border-bottom-color: ${props.borderBottomColor || props.borderColor || "transparent"};
126
+ border-bottom-style: solid;
127
+ `}
128
+ ${(props) => props.borderTopWidth !== void 0 && `
129
+ border-top-width: ${typeof props.borderTopWidth === "number" ? `${props.borderTopWidth}px` : props.borderTopWidth};
130
+ border-top-color: ${props.borderTopColor || props.borderColor || "transparent"};
131
+ border-top-style: solid;
132
+ `}
133
+ ${(props) => props.borderLeftWidth !== void 0 && `
134
+ border-left-width: ${typeof props.borderLeftWidth === "number" ? `${props.borderLeftWidth}px` : props.borderLeftWidth};
135
+ border-left-color: ${props.borderLeftColor || props.borderColor || "transparent"};
136
+ border-left-style: solid;
137
+ `}
138
+ ${(props) => props.borderRightWidth !== void 0 && `
139
+ border-right-width: ${typeof props.borderRightWidth === "number" ? `${props.borderRightWidth}px` : props.borderRightWidth};
140
+ border-right-color: ${props.borderRightColor || props.borderColor || "transparent"};
141
+ border-right-style: solid;
142
+ `}
143
+
144
+ border-style: ${(props) => props.borderStyle || (props.borderWidth || props.borderBottomWidth || props.borderTopWidth || props.borderLeftWidth || props.borderRightWidth ? "solid" : "none")};
145
+ border-radius: ${(props) => typeof props.borderRadius === "number" ? `${props.borderRadius}px` : props.borderRadius || 0};
146
+ height: ${(props) => typeof props.height === "number" ? `${props.height}px` : props.height || "auto"};
147
+ width: ${(props) => typeof props.width === "number" ? `${props.width}px` : props.width || "auto"};
148
+ min-width: ${(props) => typeof props.minWidth === "number" ? `${props.minWidth}px` : props.minWidth || "auto"};
149
+ min-height: ${(props) => typeof props.minHeight === "number" ? `${props.minHeight}px` : props.minHeight || "auto"};
150
+ max-width: ${(props) => typeof props.maxWidth === "number" ? `${props.maxWidth}px` : props.maxWidth || "none"};
151
+ max-height: ${(props) => typeof props.maxHeight === "number" ? `${props.maxHeight}px` : props.maxHeight || "none"};
152
+
153
+ padding: ${(props) => typeof props.padding === "number" ? `${props.padding}px` : props.padding || 0};
154
+ ${(props) => props.paddingHorizontal && `
155
+ padding-left: ${typeof props.paddingHorizontal === "number" ? `${props.paddingHorizontal}px` : props.paddingHorizontal};
156
+ padding-right: ${typeof props.paddingHorizontal === "number" ? `${props.paddingHorizontal}px` : props.paddingHorizontal};
157
+ `}
158
+ ${(props) => props.paddingVertical && `
159
+ padding-top: ${typeof props.paddingVertical === "number" ? `${props.paddingVertical}px` : props.paddingVertical};
160
+ padding-bottom: ${typeof props.paddingVertical === "number" ? `${props.paddingVertical}px` : props.paddingVertical};
161
+ `}
162
+ ${(props) => props.paddingTop !== void 0 && `padding-top: ${typeof props.paddingTop === "number" ? `${props.paddingTop}px` : props.paddingTop};`}
163
+ ${(props) => props.paddingBottom !== void 0 && `padding-bottom: ${typeof props.paddingBottom === "number" ? `${props.paddingBottom}px` : props.paddingBottom};`}
164
+ ${(props) => props.paddingLeft !== void 0 && `padding-left: ${typeof props.paddingLeft === "number" ? `${props.paddingLeft}px` : props.paddingLeft};`}
165
+ ${(props) => props.paddingRight !== void 0 && `padding-right: ${typeof props.paddingRight === "number" ? `${props.paddingRight}px` : props.paddingRight};`}
166
+
167
+ margin: ${(props) => typeof props.margin === "number" ? `${props.margin}px` : props.margin || 0};
168
+ ${(props) => props.marginTop !== void 0 && `margin-top: ${typeof props.marginTop === "number" ? `${props.marginTop}px` : props.marginTop};`}
169
+ ${(props) => props.marginBottom !== void 0 && `margin-bottom: ${typeof props.marginBottom === "number" ? `${props.marginBottom}px` : props.marginBottom};`}
170
+ ${(props) => props.marginLeft !== void 0 && `margin-left: ${typeof props.marginLeft === "number" ? `${props.marginLeft}px` : props.marginLeft};`}
171
+ ${(props) => props.marginRight !== void 0 && `margin-right: ${typeof props.marginRight === "number" ? `${props.marginRight}px` : props.marginRight};`}
172
+
173
+ flex-direction: ${(props) => props.flexDirection || "column"};
174
+ flex-wrap: ${(props) => props.flexWrap || "nowrap"};
175
+ align-items: ${(props) => props.alignItems || "stretch"};
176
+ justify-content: ${(props) => props.justifyContent || "flex-start"};
177
+ cursor: ${(props) => props.cursor ? props.cursor : props.onClick || props.onPress ? "pointer" : "inherit"};
178
+ position: ${(props) => props.position || "static"};
179
+ top: ${(props) => typeof props.top === "number" ? `${props.top}px` : props.top};
180
+ bottom: ${(props) => typeof props.bottom === "number" ? `${props.bottom}px` : props.bottom};
181
+ left: ${(props) => typeof props.left === "number" ? `${props.left}px` : props.left};
182
+ right: ${(props) => typeof props.right === "number" ? `${props.right}px` : props.right};
183
+ flex: ${(props) => props.flex};
184
+ flex-shrink: ${(props) => props.flexShrink ?? 1};
185
+ gap: ${(props) => typeof props.gap === "number" ? `${props.gap}px` : props.gap || 0};
186
+ align-self: ${(props) => props.alignSelf || "auto"};
187
+ overflow: ${(props) => props.overflow || "visible"};
188
+ overflow-x: ${(props) => props.overflowX || "visible"};
189
+ overflow-y: ${(props) => props.overflowY || "visible"};
190
+ z-index: ${(props) => props.zIndex};
191
+ opacity: ${(props) => props.disabled ? 0.5 : 1};
192
+ pointer-events: ${(props) => props.disabled ? "none" : "auto"};
193
+
194
+ &:hover {
195
+ ${(props) => props.hoverStyle?.backgroundColor && `background-color: ${props.hoverStyle.backgroundColor};`}
196
+ ${(props) => props.hoverStyle?.borderColor && `border-color: ${props.hoverStyle.borderColor};`}
197
+ }
198
+
199
+ &:active {
200
+ ${(props) => props.pressStyle?.backgroundColor && `background-color: ${props.pressStyle.backgroundColor};`}
201
+ }
202
+ `;
203
+ var Box = import_react2.default.forwardRef(
204
+ ({
205
+ children,
206
+ onPress,
207
+ onKeyDown,
208
+ onKeyUp,
209
+ role,
210
+ "aria-label": ariaLabel,
211
+ "aria-labelledby": ariaLabelledBy,
212
+ "aria-current": ariaCurrent,
213
+ "aria-disabled": ariaDisabled,
214
+ "aria-live": ariaLive,
215
+ "aria-busy": ariaBusy,
216
+ "aria-describedby": ariaDescribedBy,
217
+ "aria-expanded": ariaExpanded,
218
+ "aria-haspopup": ariaHasPopup,
219
+ "aria-pressed": ariaPressed,
220
+ "aria-controls": ariaControls,
221
+ tabIndex,
222
+ as,
223
+ src,
224
+ alt,
225
+ onError,
226
+ onLoad,
227
+ type,
228
+ disabled,
229
+ id,
230
+ testID,
231
+ "data-testid": dataTestId,
232
+ ...props
233
+ }, ref) => {
234
+ if (as === "img" && src) {
235
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
236
+ "img",
237
+ {
238
+ src,
239
+ alt: alt || "",
240
+ onError,
241
+ onLoad,
242
+ style: {
243
+ display: "block",
244
+ objectFit: "cover",
245
+ width: typeof props.width === "number" ? `${props.width}px` : props.width,
246
+ height: typeof props.height === "number" ? `${props.height}px` : props.height,
247
+ borderRadius: typeof props.borderRadius === "number" ? `${props.borderRadius}px` : props.borderRadius,
248
+ position: props.position,
249
+ top: typeof props.top === "number" ? `${props.top}px` : props.top,
250
+ left: typeof props.left === "number" ? `${props.left}px` : props.left,
251
+ right: typeof props.right === "number" ? `${props.right}px` : props.right,
252
+ bottom: typeof props.bottom === "number" ? `${props.bottom}px` : props.bottom,
253
+ ...props.style
254
+ }
255
+ }
256
+ );
257
+ }
258
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
259
+ StyledBox,
260
+ {
261
+ ref,
262
+ elementType: as,
263
+ id,
264
+ type: as === "button" ? type || "button" : void 0,
265
+ disabled: as === "button" ? disabled : void 0,
266
+ onClick: onPress,
267
+ onKeyDown,
268
+ onKeyUp,
269
+ role,
270
+ "aria-label": ariaLabel,
271
+ "aria-labelledby": ariaLabelledBy,
272
+ "aria-current": ariaCurrent,
273
+ "aria-disabled": ariaDisabled,
274
+ "aria-busy": ariaBusy,
275
+ "aria-describedby": ariaDescribedBy,
276
+ "aria-expanded": ariaExpanded,
277
+ "aria-haspopup": ariaHasPopup,
278
+ "aria-pressed": ariaPressed,
279
+ "aria-controls": ariaControls,
280
+ "aria-live": ariaLive,
281
+ tabIndex: tabIndex !== void 0 ? tabIndex : void 0,
282
+ "data-testid": dataTestId || testID,
283
+ ...props,
284
+ children
285
+ }
286
+ );
287
+ }
288
+ );
289
+ Box.displayName = "Box";
290
+
291
+ // ../../foundation/primitives-web/src/Text.tsx
292
+ var import_styled_components2 = __toESM(require("styled-components"));
293
+ var import_jsx_runtime2 = require("react/jsx-runtime");
294
+ var FilteredSpan = createFilteredElement("span");
295
+ var StyledText = (0, import_styled_components2.default)(FilteredSpan)`
296
+ color: ${(props) => props.color || "inherit"};
297
+ font-size: ${(props) => typeof props.fontSize === "number" ? `${props.fontSize}px` : props.fontSize || "inherit"};
298
+ font-weight: ${(props) => props.fontWeight || "normal"};
299
+ font-family: ${(props) => props.fontFamily || '"Aktiv Grotesk", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif'};
300
+ line-height: ${(props) => typeof props.lineHeight === "number" ? `${props.lineHeight}px` : props.lineHeight || "inherit"};
301
+ white-space: ${(props) => props.whiteSpace || "normal"};
302
+ text-align: ${(props) => props.textAlign || "inherit"};
303
+ text-decoration: ${(props) => props.textDecoration || "none"};
304
+ `;
305
+ var Text = ({
306
+ style,
307
+ className,
308
+ id,
309
+ role,
310
+ testID,
311
+ "data-testid": dataTestId,
312
+ numberOfLines: _numberOfLines,
313
+ ...props
314
+ }) => {
315
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
316
+ StyledText,
317
+ {
318
+ ...props,
319
+ style,
320
+ className,
321
+ id,
322
+ role,
323
+ "data-testid": dataTestId || testID
324
+ }
325
+ );
326
+ };
327
+
328
+ // ../../foundation/primitives-web/src/Input.tsx
329
+ var import_react3 = require("react");
330
+ var import_styled_components3 = __toESM(require("styled-components"));
331
+ var import_jsx_runtime3 = require("react/jsx-runtime");
332
+ var FilteredInput = createFilteredElement("input");
333
+ var StyledInput = (0, import_styled_components3.default)(FilteredInput)`
334
+ background: transparent;
335
+ border: none;
336
+ outline: none;
337
+ width: 100%;
338
+ height: 100%;
339
+ padding: 0;
340
+ margin: 0;
341
+ color: ${(props) => props.color || "inherit"};
342
+ font-size: ${(props) => typeof props.fontSize === "number" ? `${props.fontSize}px` : props.fontSize || "inherit"};
343
+ font-family: ${(props) => props.fontFamily || '"Aktiv Grotesk", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif'};
344
+ text-align: inherit;
345
+
346
+ &::placeholder {
347
+ color: ${(props) => props.placeholderTextColor || "rgba(255, 255, 255, 0.5)"};
348
+ }
349
+
350
+ &:disabled {
351
+ cursor: not-allowed;
352
+ }
353
+
354
+ /* Override browser autofill background */
355
+ &:-webkit-autofill,
356
+ &:-webkit-autofill:hover,
357
+ &:-webkit-autofill:focus,
358
+ &:-webkit-autofill:active {
359
+ -webkit-box-shadow: 0 0 0 1000px transparent inset !important;
360
+ -webkit-background-clip: text !important;
361
+ -webkit-text-fill-color: ${(props) => props.color || "inherit"} !important;
362
+ }
363
+ `;
364
+ var InputPrimitive = (0, import_react3.forwardRef)(
365
+ ({
366
+ value,
367
+ placeholder,
368
+ onChange,
369
+ onChangeText,
370
+ onFocus,
371
+ onBlur,
372
+ onKeyDown,
373
+ disabled,
374
+ secureTextEntry,
375
+ style,
376
+ color,
377
+ fontSize,
378
+ fontFamily,
379
+ placeholderTextColor,
380
+ maxLength,
381
+ name,
382
+ type,
383
+ inputMode,
384
+ autoComplete,
385
+ id,
386
+ "aria-invalid": ariaInvalid,
387
+ "aria-describedby": ariaDescribedBy,
388
+ "aria-labelledby": ariaLabelledBy,
389
+ "aria-label": ariaLabel,
390
+ "aria-disabled": ariaDisabled,
391
+ "data-testid": dataTestId,
392
+ testID,
393
+ ...rest
394
+ }, ref) => {
395
+ const handleChange = (e) => {
396
+ if (onChange) {
397
+ onChange(e);
398
+ }
399
+ if (onChangeText) {
400
+ onChangeText(e.target.value);
401
+ }
402
+ };
403
+ const inputValue = value !== void 0 ? value : "";
404
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
405
+ StyledInput,
406
+ {
407
+ ref,
408
+ id,
409
+ value: inputValue,
410
+ name,
411
+ placeholder,
412
+ onChange: handleChange,
413
+ onFocus,
414
+ onBlur,
415
+ onKeyDown,
416
+ disabled,
417
+ type: secureTextEntry ? "password" : type || "text",
418
+ inputMode,
419
+ autoComplete,
420
+ style,
421
+ color,
422
+ fontSize,
423
+ fontFamily,
424
+ placeholderTextColor,
425
+ maxLength,
426
+ "aria-invalid": ariaInvalid,
427
+ "aria-describedby": ariaDescribedBy,
428
+ "aria-labelledby": ariaLabelledBy,
429
+ "aria-label": ariaLabel,
430
+ "aria-disabled": ariaDisabled,
431
+ "data-testid": dataTestId || testID,
432
+ ...rest
433
+ }
434
+ );
435
+ }
436
+ );
437
+ InputPrimitive.displayName = "InputPrimitive";
438
+
439
+ // ../../foundation/primitives-web/src/index.tsx
440
+ var isWeb = true;
441
+
442
+ // src/InputColor.tsx
443
+ var import_xui_core = require("@xsolla/xui-core");
444
+ var import_jsx_runtime4 = require("react/jsx-runtime");
445
+ var clamp = (n, min, max) => Math.min(Math.max(n, min), max);
446
+ var HEX_CHARS = /[^0-9a-fA-F]/g;
447
+ function hexToRgba(hex) {
448
+ let h = (hex || "").replace(/^#/, "");
449
+ if (h.length === 3 || h.length === 4) {
450
+ h = h.split("").map((c) => c + c).join("");
451
+ }
452
+ const r = parseInt(h.slice(0, 2), 16);
453
+ const g = parseInt(h.slice(2, 4), 16);
454
+ const b = parseInt(h.slice(4, 6), 16);
455
+ const a = h.length >= 8 ? parseInt(h.slice(6, 8), 16) / 255 : 1;
456
+ return {
457
+ r: Number.isNaN(r) ? 0 : r,
458
+ g: Number.isNaN(g) ? 0 : g,
459
+ b: Number.isNaN(b) ? 0 : b,
460
+ a: Number.isNaN(a) ? 1 : parseFloat(a.toFixed(2))
461
+ };
462
+ }
463
+ function rgbaToHex({ r, g, b, a }, includeAlpha) {
464
+ const toHex = (n) => Math.round(clamp(n, 0, 255)).toString(16).padStart(2, "0");
465
+ const alpha = includeAlpha ? toHex(clamp(a, 0, 1) * 255) : "";
466
+ return `#${toHex(r)}${toHex(g)}${toHex(b)}${alpha}`.toUpperCase();
467
+ }
468
+ var SWATCH_SIZE = {
469
+ xl: 36,
470
+ lg: 32,
471
+ md: 26,
472
+ sm: 20,
473
+ xs: 14
474
+ };
475
+ var ALPHA_WIDTH = {
476
+ xl: 96,
477
+ lg: 86,
478
+ md: 77,
479
+ sm: 67,
480
+ xs: 58
481
+ };
482
+ var FRAME_GAP = {
483
+ xl: 10,
484
+ lg: 10,
485
+ md: 8,
486
+ sm: 6,
487
+ xs: 4
488
+ };
489
+ var CHECKERBOARD = "conic-gradient(rgba(0,0,0,0.45) 25%, transparent 0 50%, rgba(0,0,0,0.45) 0 75%, transparent 0)";
490
+ function cornerRadii(corner, radius) {
491
+ const map = {
492
+ all: [radius, radius, radius, radius],
493
+ left: [radius, 0, 0, radius],
494
+ right: [0, radius, radius, 0],
495
+ middle: [0, 0, 0, 0]
496
+ };
497
+ const [tl, tr, br, bl] = map[corner];
498
+ return {
499
+ borderTopLeftRadius: tl,
500
+ borderTopRightRadius: tr,
501
+ borderBottomRightRadius: br,
502
+ borderBottomLeftRadius: bl
503
+ };
504
+ }
505
+ function ColorSwatch({
506
+ size,
507
+ rgba,
508
+ transparency,
509
+ borderColor
510
+ }) {
511
+ const solid = `rgb(${rgba.r}, ${rgba.g}, ${rgba.b})`;
512
+ const withAlpha = `rgba(${rgba.r}, ${rgba.g}, ${rgba.b}, ${rgba.a})`;
513
+ return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(
514
+ Box,
515
+ {
516
+ width: size,
517
+ height: size,
518
+ position: "relative",
519
+ borderColor,
520
+ borderWidth: 1,
521
+ style: { borderRadius: 4, overflow: "hidden" },
522
+ "data-testid": "input-color__swatch-preview",
523
+ children: [
524
+ transparency && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
525
+ Box,
526
+ {
527
+ "aria-hidden": true,
528
+ style: {
529
+ position: "absolute",
530
+ inset: 0,
531
+ backgroundImage: CHECKERBOARD,
532
+ backgroundSize: "8px 8px",
533
+ opacity: 0.2
534
+ }
535
+ }
536
+ ),
537
+ transparency ? /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(import_jsx_runtime4.Fragment, { children: [
538
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
539
+ Box,
540
+ {
541
+ style: {
542
+ position: "absolute",
543
+ top: 0,
544
+ bottom: 0,
545
+ left: 0,
546
+ right: "50%",
547
+ backgroundColor: solid
548
+ }
549
+ }
550
+ ),
551
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
552
+ Box,
553
+ {
554
+ style: {
555
+ position: "absolute",
556
+ top: 0,
557
+ bottom: 0,
558
+ left: "50%",
559
+ right: 0,
560
+ backgroundColor: withAlpha
561
+ }
562
+ }
563
+ )
564
+ ] }) : /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
565
+ Box,
566
+ {
567
+ style: { position: "absolute", inset: 0, backgroundColor: solid }
568
+ }
569
+ )
570
+ ]
571
+ }
572
+ );
573
+ }
574
+ function TextField({
575
+ value,
576
+ onCommit,
577
+ sanitize,
578
+ maxLength,
579
+ textAlign = "left",
580
+ color,
581
+ fontSize,
582
+ fontFamily,
583
+ ariaLabel,
584
+ inputMode = "text",
585
+ step,
586
+ testID,
587
+ onFocus,
588
+ onBlur
589
+ }) {
590
+ const [text, setText] = (0, import_react4.useState)(value);
591
+ const isFocusedRef = (0, import_react4.useRef)(false);
592
+ (0, import_react4.useEffect)(() => {
593
+ if (!isFocusedRef.current) setText(value);
594
+ }, [value]);
595
+ const handleChange = (e) => {
596
+ const next = sanitize(e.target.value);
597
+ setText(next);
598
+ onCommit(next);
599
+ };
600
+ const handleFocus = () => {
601
+ isFocusedRef.current = true;
602
+ onFocus();
603
+ };
604
+ const handleBlur = () => {
605
+ isFocusedRef.current = false;
606
+ setText(value);
607
+ onBlur();
608
+ };
609
+ const handleKeyDown = (e) => {
610
+ if (e.key === "Enter") {
611
+ e.currentTarget.blur();
612
+ return;
613
+ }
614
+ if (step && (e.key === "ArrowUp" || e.key === "ArrowDown")) {
615
+ e.preventDefault();
616
+ const current = Number.parseInt(text, 10);
617
+ const base = Number.isNaN(current) ? 0 : current;
618
+ const next = String(
619
+ clamp(base + (e.key === "ArrowUp" ? 1 : -1), step.min, step.max)
620
+ );
621
+ setText(next);
622
+ onCommit(next);
623
+ }
624
+ };
625
+ return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(Box, { flex: 1, height: "100%", justifyContent: "center", children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
626
+ InputPrimitive,
627
+ {
628
+ value: text,
629
+ onChange: handleChange,
630
+ onFocus: handleFocus,
631
+ onBlur: handleBlur,
632
+ onKeyDown: handleKeyDown,
633
+ type: "text",
634
+ inputMode,
635
+ maxLength,
636
+ color,
637
+ fontSize,
638
+ fontFamily,
639
+ "aria-label": ariaLabel,
640
+ "data-testid": testID,
641
+ style: textAlign === "center" ? { textAlign: "center" } : void 0
642
+ }
643
+ ) });
644
+ }
645
+ var CHANNEL_LABEL = {
646
+ red: "Red channel",
647
+ green: "Green channel",
648
+ blue: "Blue channel",
649
+ alpha: "Opacity percentage"
650
+ };
651
+ var InputColor = (0, import_react4.forwardRef)(
652
+ ({
653
+ value,
654
+ defaultValue,
655
+ onChange,
656
+ onSwatchClick,
657
+ type = "color-hex",
658
+ transparency = false,
659
+ size = "md",
660
+ label,
661
+ id: providedId,
662
+ "aria-label": ariaLabel,
663
+ testID,
664
+ themeMode,
665
+ themeProductContext
666
+ }, ref) => {
667
+ const { theme } = (0, import_xui_core.useResolvedTheme)({ themeMode, themeProductContext });
668
+ const [internalValue, setInternalValue] = (0, import_react4.useState)(
669
+ value ?? defaultValue ?? "#000000"
670
+ );
671
+ (0, import_react4.useEffect)(() => {
672
+ if (value !== void 0) setInternalValue(value);
673
+ }, [value]);
674
+ const currentValue = internalValue;
675
+ const [focusedKey, setFocusedKey] = (0, import_react4.useState)(null);
676
+ const [liveMessage, setLiveMessage] = (0, import_react4.useState)("");
677
+ const rawId = (0, import_xui_core.useId)();
678
+ const safeId = rawId.replace(/:/g, "");
679
+ const inputId = providedId || `input-color-${safeId}`;
680
+ const labelId = `${inputId}-label`;
681
+ const rgba = (0, import_react4.useMemo)(() => hexToRgba(currentValue), [currentValue]);
682
+ const sizeStyles = theme.sizing.input(size);
683
+ const inputColors = theme.colors.control.input;
684
+ const borderRadius = theme.shape.input[size].borderRadius;
685
+ const swatchSize = SWATCH_SIZE[size];
686
+ const showSwatch = type === "color" || type === "color-hex" || type === "color-rgb";
687
+ const isHex = type === "hex" || type === "color-hex";
688
+ const isRgb = type === "rgb" || type === "color-rgb";
689
+ const isSwatchOnly = type === "color";
690
+ const textColor = inputColors.text;
691
+ const placeholderColor = inputColors.placeholder;
692
+ const fontFamily = theme.fonts.body;
693
+ const emit = (next) => {
694
+ setInternalValue(next);
695
+ setLiveMessage(`Color updated to ${next}`);
696
+ onChange?.(next);
697
+ };
698
+ const emitFromRgba = (next) => emit(rgbaToHex(next, transparency));
699
+ const segmentVisuals = (focused) => {
700
+ let backgroundColor = inputColors.bg;
701
+ let borderColor = inputColors.border;
702
+ let outlineColor;
703
+ if (focused) {
704
+ backgroundColor = theme.colors.control.focus.bg;
705
+ outlineColor = theme.colors.border.brand;
706
+ }
707
+ return { backgroundColor, borderColor, outlineColor };
708
+ };
709
+ const renderSegment = (key, corner, content, opts = {}) => {
710
+ const focused = focusedKey === key;
711
+ const { backgroundColor, borderColor, outlineColor } = segmentVisuals(focused);
712
+ const width = opts.square ? sizeStyles.height : opts.width;
713
+ return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
714
+ Box,
715
+ {
716
+ backgroundColor,
717
+ borderColor,
718
+ borderWidth: 1,
719
+ height: sizeStyles.height,
720
+ width,
721
+ flex: opts.flex,
722
+ flexDirection: "row",
723
+ alignItems: "center",
724
+ justifyContent: opts.square ? "center" : "flex-start",
725
+ gap: FRAME_GAP[size],
726
+ paddingHorizontal: opts.square ? 0 : sizeStyles.paddingHorizontal,
727
+ position: "relative",
728
+ style: {
729
+ ...cornerRadii(corner, borderRadius),
730
+ minWidth: opts.square ? void 0 : 40,
731
+ ...outlineColor && isWeb ? { outline: `1px solid ${outlineColor}`, outlineOffset: "-1px" } : outlineColor && !isWeb ? { borderColor: outlineColor } : {}
732
+ },
733
+ hoverStyle: !focused ? {
734
+ backgroundColor: inputColors.bgHover,
735
+ borderColor: inputColors.borderHover
736
+ } : void 0,
737
+ children: content
738
+ },
739
+ key
740
+ );
741
+ };
742
+ const swatchVisual = /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
743
+ ColorSwatch,
744
+ {
745
+ size: swatchSize,
746
+ rgba,
747
+ transparency,
748
+ borderColor: theme.colors.border.secondary
749
+ }
750
+ );
751
+ const swatchNode = isSwatchOnly ? /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
752
+ Box,
753
+ {
754
+ as: "button",
755
+ type: "button",
756
+ onPress: () => onSwatchClick?.(),
757
+ cursor: "pointer",
758
+ backgroundColor: "transparent",
759
+ borderWidth: 0,
760
+ padding: 0,
761
+ alignItems: "center",
762
+ justifyContent: "center",
763
+ "aria-label": "Open color picker",
764
+ "data-testid": "input-color__swatch",
765
+ onFocus: () => setFocusedKey("swatch"),
766
+ onBlur: () => setFocusedKey(null),
767
+ children: swatchVisual
768
+ }
769
+ ) : /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
770
+ Box,
771
+ {
772
+ "aria-hidden": true,
773
+ alignItems: "center",
774
+ justifyContent: "center",
775
+ "data-testid": "input-color__swatch-decorative",
776
+ children: swatchVisual
777
+ }
778
+ );
779
+ const hexContent = /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(import_jsx_runtime4.Fragment, { children: [
780
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
781
+ Text,
782
+ {
783
+ color: placeholderColor,
784
+ fontSize: sizeStyles.fontSize,
785
+ style: { lineHeight: `${sizeStyles.lineHeight}px` },
786
+ children: "#"
787
+ }
788
+ ),
789
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
790
+ TextField,
791
+ {
792
+ value: rgbaToHex(rgba, false).replace(/^#/, ""),
793
+ sanitize: (t) => t.replace(HEX_CHARS, "").toUpperCase(),
794
+ maxLength: 6,
795
+ onCommit: (digits) => {
796
+ if (digits.length === 3 || digits.length === 6) {
797
+ const next = hexToRgba(`#${digits}`);
798
+ emitFromRgba({ ...next, a: rgba.a });
799
+ }
800
+ },
801
+ color: textColor,
802
+ fontSize: sizeStyles.fontSize,
803
+ fontFamily,
804
+ ariaLabel: "Hex color value",
805
+ testID: "input-color__hex",
806
+ onFocus: () => setFocusedKey("hex"),
807
+ onBlur: () => setFocusedKey(null)
808
+ }
809
+ )
810
+ ] });
811
+ const channelContent = (channel) => {
812
+ const isAlpha = channel === "alpha";
813
+ const display = isAlpha ? Math.round(rgba.a * 100) : rgba[channel[0]];
814
+ const field = /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
815
+ TextField,
816
+ {
817
+ value: String(display),
818
+ inputMode: "numeric",
819
+ sanitize: (t) => t.replace(/[^0-9]/g, ""),
820
+ maxLength: 3,
821
+ step: isAlpha ? { min: 0, max: 100 } : { min: 0, max: 255 },
822
+ onCommit: (t) => {
823
+ if (t === "") return;
824
+ const num = parseInt(t, 10);
825
+ if (Number.isNaN(num)) return;
826
+ if (isAlpha) {
827
+ emitFromRgba({ ...rgba, a: clamp(num, 0, 100) / 100 });
828
+ } else {
829
+ const k = channel[0];
830
+ emitFromRgba({ ...rgba, [k]: clamp(num, 0, 255) });
831
+ }
832
+ },
833
+ color: textColor,
834
+ fontSize: sizeStyles.fontSize,
835
+ fontFamily,
836
+ ariaLabel: CHANNEL_LABEL[channel],
837
+ testID: `input-color__channel-${channel}`,
838
+ onFocus: () => setFocusedKey(`channel-${channel}`),
839
+ onBlur: () => setFocusedKey(null)
840
+ }
841
+ );
842
+ if (!isAlpha) return field;
843
+ return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(import_jsx_runtime4.Fragment, { children: [
844
+ field,
845
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
846
+ Text,
847
+ {
848
+ color: placeholderColor,
849
+ fontSize: sizeStyles.fontSize,
850
+ style: { lineHeight: `${sizeStyles.lineHeight}px` },
851
+ children: "%"
852
+ }
853
+ )
854
+ ] });
855
+ };
856
+ const cells = [];
857
+ if (isSwatchOnly) {
858
+ cells.push({ key: "swatch", content: swatchNode, square: true });
859
+ } else if (isHex) {
860
+ cells.push({
861
+ key: "field",
862
+ flex: 1,
863
+ content: /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(import_jsx_runtime4.Fragment, { children: [
864
+ showSwatch && swatchNode,
865
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(Box, { flex: 1, flexDirection: "row", alignItems: "center", gap: 4, children: hexContent })
866
+ ] })
867
+ });
868
+ } else if (isRgb) {
869
+ if (showSwatch) {
870
+ cells.push({ key: "swatch", content: swatchNode, square: true });
871
+ }
872
+ ["red", "green", "blue"].forEach(
873
+ (channel) => cells.push({
874
+ key: `channel-${channel}`,
875
+ content: channelContent(channel),
876
+ flex: 1
877
+ })
878
+ );
879
+ }
880
+ if (transparency) {
881
+ cells.push({
882
+ key: "channel-alpha",
883
+ content: channelContent("alpha"),
884
+ width: ALPHA_WIDTH[size]
885
+ });
886
+ }
887
+ const control = cells.map((cell, i) => {
888
+ const corner = cells.length === 1 ? "all" : i === 0 ? "left" : i === cells.length - 1 ? "right" : "middle";
889
+ return renderSegment(cell.key, corner, cell.content, {
890
+ flex: cell.flex,
891
+ width: cell.width,
892
+ square: cell.square
893
+ });
894
+ });
895
+ return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(
896
+ Box,
897
+ {
898
+ ref,
899
+ flexDirection: "column",
900
+ gap: sizeStyles.fieldGap,
901
+ width: isSwatchOnly ? void 0 : "100%",
902
+ testID,
903
+ children: [
904
+ label && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(Box, { as: "label", id: labelId, children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
905
+ Text,
906
+ {
907
+ color: theme.colors.content.secondary,
908
+ fontSize: sizeStyles.fontSize - 2,
909
+ fontWeight: "500",
910
+ children: label
911
+ }
912
+ ) }),
913
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
914
+ Box,
915
+ {
916
+ flexDirection: "row",
917
+ alignItems: "center",
918
+ gap: 2,
919
+ width: isSwatchOnly ? void 0 : "100%",
920
+ role: "group",
921
+ "aria-labelledby": label ? labelId : void 0,
922
+ "aria-label": !label ? ariaLabel : void 0,
923
+ children: control
924
+ }
925
+ ),
926
+ isWeb && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
927
+ Box,
928
+ {
929
+ role: "status",
930
+ "aria-live": "polite",
931
+ "data-testid": "input-color__live",
932
+ style: {
933
+ position: "absolute",
934
+ width: 1,
935
+ height: 1,
936
+ padding: 0,
937
+ margin: -1,
938
+ overflow: "hidden",
939
+ clip: "rect(0 0 0 0)",
940
+ whiteSpace: "nowrap",
941
+ border: 0
942
+ },
943
+ children: liveMessage
944
+ }
945
+ )
946
+ ]
947
+ }
948
+ );
949
+ }
950
+ );
951
+ InputColor.displayName = "InputColor";
952
+ // Annotate the CommonJS export names for ESM import in node:
953
+ 0 && (module.exports = {
954
+ InputColor
955
+ });
956
+ //# sourceMappingURL=index.js.map