@xsolla/xui-color-picker 0.136.0 → 0.137.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 +6 -6
- package/web/index.js +120 -45
- package/web/index.js.map +1 -1
- package/web/index.mjs +79 -4
- package/web/index.mjs.map +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xsolla/xui-color-picker",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.137.0",
|
|
4
4
|
"main": "./web/index.js",
|
|
5
5
|
"module": "./web/index.mjs",
|
|
6
6
|
"types": "./web/index.d.ts",
|
|
@@ -13,11 +13,11 @@
|
|
|
13
13
|
"test:coverage": "vitest run --coverage"
|
|
14
14
|
},
|
|
15
15
|
"dependencies": {
|
|
16
|
-
"@xsolla/xui-button": "0.
|
|
17
|
-
"@xsolla/xui-core": "0.
|
|
18
|
-
"@xsolla/xui-input": "0.
|
|
19
|
-
"@xsolla/xui-primitives-core": "0.
|
|
20
|
-
"@xsolla/xui-select": "0.
|
|
16
|
+
"@xsolla/xui-button": "0.137.0",
|
|
17
|
+
"@xsolla/xui-core": "0.137.0",
|
|
18
|
+
"@xsolla/xui-input": "0.137.0",
|
|
19
|
+
"@xsolla/xui-primitives-core": "0.137.0",
|
|
20
|
+
"@xsolla/xui-select": "0.137.0"
|
|
21
21
|
},
|
|
22
22
|
"peerDependencies": {
|
|
23
23
|
"react": ">=16.8.0"
|
package/web/index.js
CHANGED
|
@@ -39,13 +39,85 @@ __export(index_exports, {
|
|
|
39
39
|
module.exports = __toCommonJS(index_exports);
|
|
40
40
|
|
|
41
41
|
// src/ColorPicker.tsx
|
|
42
|
-
var
|
|
42
|
+
var import_react8 = require("react");
|
|
43
43
|
|
|
44
44
|
// ../primitives-web/src/Box.tsx
|
|
45
|
-
var
|
|
45
|
+
var import_react2 = __toESM(require("react"));
|
|
46
46
|
var import_styled_components = __toESM(require("styled-components"));
|
|
47
|
+
|
|
48
|
+
// ../primitives-web/src/filterDOMProps.ts
|
|
49
|
+
var import_react = __toESM(require("react"));
|
|
50
|
+
|
|
51
|
+
// ../../node_modules/@emotion/memoize/dist/memoize.esm.js
|
|
52
|
+
function memoize(fn) {
|
|
53
|
+
var cache = {};
|
|
54
|
+
return function(arg) {
|
|
55
|
+
if (cache[arg] === void 0) cache[arg] = fn(arg);
|
|
56
|
+
return cache[arg];
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
var memoize_esm_default = memoize;
|
|
60
|
+
|
|
61
|
+
// ../../node_modules/@emotion/is-prop-valid/dist/is-prop-valid.esm.js
|
|
62
|
+
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)-.*))$/;
|
|
63
|
+
var index = memoize_esm_default(
|
|
64
|
+
function(prop) {
|
|
65
|
+
return reactPropsRegex.test(prop) || prop.charCodeAt(0) === 111 && prop.charCodeAt(1) === 110 && prop.charCodeAt(2) < 91;
|
|
66
|
+
}
|
|
67
|
+
/* Z+1 */
|
|
68
|
+
);
|
|
69
|
+
var is_prop_valid_esm_default = index;
|
|
70
|
+
|
|
71
|
+
// ../primitives-web/src/filterDOMProps.ts
|
|
72
|
+
var ADDITIONAL_BLOCKED_PROPS = /* @__PURE__ */ new Set([
|
|
73
|
+
// RN-only event handlers (pass isPropValid's on* pattern)
|
|
74
|
+
"onPress",
|
|
75
|
+
"onChangeText",
|
|
76
|
+
"onLayout",
|
|
77
|
+
"onMoveShouldSetResponder",
|
|
78
|
+
"onResponderGrant",
|
|
79
|
+
"onResponderMove",
|
|
80
|
+
"onResponderRelease",
|
|
81
|
+
"onResponderTerminate",
|
|
82
|
+
// SVG attributes that pass isPropValid
|
|
83
|
+
"strokeWidth",
|
|
84
|
+
// CSS properties that pass isPropValid but are used as component props
|
|
85
|
+
"overflow",
|
|
86
|
+
"cursor",
|
|
87
|
+
"fontSize",
|
|
88
|
+
"fontWeight",
|
|
89
|
+
"fontFamily",
|
|
90
|
+
"textDecoration"
|
|
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
|
+
// ../primitives-web/src/Box.tsx
|
|
47
118
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
48
|
-
var
|
|
119
|
+
var FilteredDiv = createFilteredElement("div");
|
|
120
|
+
var StyledBox = (0, import_styled_components.default)(FilteredDiv)`
|
|
49
121
|
display: flex;
|
|
50
122
|
box-sizing: border-box;
|
|
51
123
|
background-color: ${(props) => props.backgroundColor || "transparent"};
|
|
@@ -132,7 +204,7 @@ var StyledBox = import_styled_components.default.div`
|
|
|
132
204
|
${(props) => props.pressStyle?.backgroundColor && `background-color: ${props.pressStyle.backgroundColor};`}
|
|
133
205
|
}
|
|
134
206
|
`;
|
|
135
|
-
var Box =
|
|
207
|
+
var Box = import_react2.default.forwardRef(
|
|
136
208
|
({
|
|
137
209
|
children,
|
|
138
210
|
onPress,
|
|
@@ -157,6 +229,8 @@ var Box = import_react.default.forwardRef(
|
|
|
157
229
|
type,
|
|
158
230
|
disabled,
|
|
159
231
|
id,
|
|
232
|
+
testID,
|
|
233
|
+
"data-testid": dataTestId,
|
|
160
234
|
...props
|
|
161
235
|
}, ref) => {
|
|
162
236
|
if (as === "img" && src) {
|
|
@@ -184,7 +258,7 @@ var Box = import_react.default.forwardRef(
|
|
|
184
258
|
StyledBox,
|
|
185
259
|
{
|
|
186
260
|
ref,
|
|
187
|
-
as,
|
|
261
|
+
elementType: as,
|
|
188
262
|
id,
|
|
189
263
|
type: as === "button" ? type || "button" : void 0,
|
|
190
264
|
disabled: as === "button" ? disabled : void 0,
|
|
@@ -204,6 +278,7 @@ var Box = import_react.default.forwardRef(
|
|
|
204
278
|
"aria-controls": ariaControls,
|
|
205
279
|
"aria-live": ariaLive,
|
|
206
280
|
tabIndex: tabIndex !== void 0 ? tabIndex : void 0,
|
|
281
|
+
"data-testid": dataTestId || testID,
|
|
207
282
|
...props,
|
|
208
283
|
children
|
|
209
284
|
}
|
|
@@ -218,7 +293,7 @@ var import_xui_button2 = require("@xsolla/xui-button");
|
|
|
218
293
|
var import_xui_core3 = require("@xsolla/xui-core");
|
|
219
294
|
|
|
220
295
|
// src/ColorPickerArea.tsx
|
|
221
|
-
var
|
|
296
|
+
var import_react4 = require("react");
|
|
222
297
|
var import_xui_core = require("@xsolla/xui-core");
|
|
223
298
|
|
|
224
299
|
// src/colorUtils.ts
|
|
@@ -411,7 +486,7 @@ function createColorFromHsb(h, s, b, a = 1) {
|
|
|
411
486
|
}
|
|
412
487
|
|
|
413
488
|
// src/utils.ts
|
|
414
|
-
var
|
|
489
|
+
var import_react3 = require("react");
|
|
415
490
|
function clamp(value, min, max) {
|
|
416
491
|
return Math.min(Math.max(value, min), max);
|
|
417
492
|
}
|
|
@@ -426,7 +501,7 @@ function snapValueToStep(value, min, max, step) {
|
|
|
426
501
|
return snappedValue;
|
|
427
502
|
}
|
|
428
503
|
function useMergedRefs(...refs) {
|
|
429
|
-
return (0,
|
|
504
|
+
return (0, import_react3.useCallback)((node) => {
|
|
430
505
|
refs.forEach((ref) => {
|
|
431
506
|
if (typeof ref === "function") {
|
|
432
507
|
ref(node);
|
|
@@ -437,9 +512,9 @@ function useMergedRefs(...refs) {
|
|
|
437
512
|
}, refs);
|
|
438
513
|
}
|
|
439
514
|
function useUpdatableState(updater, deps, initialUpdate = false) {
|
|
440
|
-
const [state, setState] = (0,
|
|
441
|
-
const isFirstRender = (0,
|
|
442
|
-
(0,
|
|
515
|
+
const [state, setState] = (0, import_react3.useState)(() => updater(void 0));
|
|
516
|
+
const isFirstRender = (0, import_react3.useRef)(true);
|
|
517
|
+
(0, import_react3.useEffect)(() => {
|
|
443
518
|
if (isFirstRender.current && !initialUpdate) {
|
|
444
519
|
isFirstRender.current = false;
|
|
445
520
|
return;
|
|
@@ -451,7 +526,7 @@ function useUpdatableState(updater, deps, initialUpdate = false) {
|
|
|
451
526
|
|
|
452
527
|
// src/ColorPickerArea.tsx
|
|
453
528
|
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
454
|
-
var ColorPickerArea = (0,
|
|
529
|
+
var ColorPickerArea = (0, import_react4.forwardRef)(function CustomColorArea(props, ref) {
|
|
455
530
|
const {
|
|
456
531
|
xChannelStep = 0.1,
|
|
457
532
|
yChannelStep = 0.1,
|
|
@@ -461,15 +536,15 @@ var ColorPickerArea = (0, import_react3.forwardRef)(function CustomColorArea(pro
|
|
|
461
536
|
onChangeEnd,
|
|
462
537
|
className
|
|
463
538
|
} = props;
|
|
464
|
-
const internalRef = (0,
|
|
539
|
+
const internalRef = (0, import_react4.useRef)(null);
|
|
465
540
|
const containerRef = useMergedRefs(ref, internalRef);
|
|
466
|
-
const [layout, setLayout] = (0,
|
|
467
|
-
const [isDragging, setIsDragging] = (0,
|
|
468
|
-
const [currentColor, setCurrentColor] = (0,
|
|
541
|
+
const [layout, setLayout] = (0, import_react4.useState)({ width: 0, height: 0 });
|
|
542
|
+
const [isDragging, setIsDragging] = (0, import_react4.useState)(false);
|
|
543
|
+
const [currentColor, setCurrentColor] = (0, import_react4.useState)(() => {
|
|
469
544
|
const initialValue = value || defaultValue || "#ffffff";
|
|
470
545
|
return parseColor(initialValue);
|
|
471
546
|
});
|
|
472
|
-
(0,
|
|
547
|
+
(0, import_react4.useEffect)(() => {
|
|
473
548
|
if (value !== void 0) {
|
|
474
549
|
setCurrentColor(parseColor(value));
|
|
475
550
|
}
|
|
@@ -480,7 +555,7 @@ var ColorPickerArea = (0, import_react3.forwardRef)(function CustomColorArea(pro
|
|
|
480
555
|
const brightness = hsb.b * 100;
|
|
481
556
|
const thumbX = saturation / 100 * 100;
|
|
482
557
|
const thumbY = 100 - brightness / 100 * 100;
|
|
483
|
-
const updateColor = (0,
|
|
558
|
+
const updateColor = (0, import_react4.useCallback)(
|
|
484
559
|
(x, y) => {
|
|
485
560
|
const newSaturation = snapValueToStep(x * 100, 0, 100, xChannelStep);
|
|
486
561
|
const newBrightness = snapValueToStep(
|
|
@@ -501,7 +576,7 @@ var ColorPickerArea = (0, import_react3.forwardRef)(function CustomColorArea(pro
|
|
|
501
576
|
},
|
|
502
577
|
[hue, hsb.a, xChannelStep, yChannelStep, onChange]
|
|
503
578
|
);
|
|
504
|
-
const handleMouseDown = (0,
|
|
579
|
+
const handleMouseDown = (0, import_react4.useCallback)(
|
|
505
580
|
(e) => {
|
|
506
581
|
if (import_xui_core.isNative) return;
|
|
507
582
|
setIsDragging(true);
|
|
@@ -512,7 +587,7 @@ var ColorPickerArea = (0, import_react3.forwardRef)(function CustomColorArea(pro
|
|
|
512
587
|
},
|
|
513
588
|
[updateColor]
|
|
514
589
|
);
|
|
515
|
-
const handleMouseMove = (0,
|
|
590
|
+
const handleMouseMove = (0, import_react4.useCallback)(
|
|
516
591
|
(e) => {
|
|
517
592
|
if (!isDragging || import_xui_core.isNative) return;
|
|
518
593
|
const rect = internalRef.current?.getBoundingClientRect?.();
|
|
@@ -523,13 +598,13 @@ var ColorPickerArea = (0, import_react3.forwardRef)(function CustomColorArea(pro
|
|
|
523
598
|
},
|
|
524
599
|
[isDragging, updateColor]
|
|
525
600
|
);
|
|
526
|
-
const handleMouseUp = (0,
|
|
601
|
+
const handleMouseUp = (0, import_react4.useCallback)(() => {
|
|
527
602
|
if (isDragging) {
|
|
528
603
|
setIsDragging(false);
|
|
529
604
|
onChangeEnd?.(currentColor.toString());
|
|
530
605
|
}
|
|
531
606
|
}, [isDragging, currentColor, onChangeEnd]);
|
|
532
|
-
(0,
|
|
607
|
+
(0, import_react4.useEffect)(() => {
|
|
533
608
|
if (import_xui_core.isWeb && isDragging) {
|
|
534
609
|
document.addEventListener("mousemove", handleMouseMove);
|
|
535
610
|
document.addEventListener("mouseup", handleMouseUp);
|
|
@@ -539,7 +614,7 @@ var ColorPickerArea = (0, import_react3.forwardRef)(function CustomColorArea(pro
|
|
|
539
614
|
};
|
|
540
615
|
}
|
|
541
616
|
}, [isDragging, handleMouseMove, handleMouseUp]);
|
|
542
|
-
const handleResponderMove = (0,
|
|
617
|
+
const handleResponderMove = (0, import_react4.useCallback)(
|
|
543
618
|
(e) => {
|
|
544
619
|
const { locationX, locationY } = e.nativeEvent;
|
|
545
620
|
const x = clamp(locationX / layout.width, 0, 1);
|
|
@@ -548,7 +623,7 @@ var ColorPickerArea = (0, import_react3.forwardRef)(function CustomColorArea(pro
|
|
|
548
623
|
},
|
|
549
624
|
[layout, updateColor]
|
|
550
625
|
);
|
|
551
|
-
const handleResponderRelease = (0,
|
|
626
|
+
const handleResponderRelease = (0, import_react4.useCallback)(() => {
|
|
552
627
|
setIsDragging(false);
|
|
553
628
|
onChangeEnd?.(currentColor.toString());
|
|
554
629
|
}, [currentColor, onChangeEnd]);
|
|
@@ -613,7 +688,7 @@ var ColorPickerArea = (0, import_react3.forwardRef)(function CustomColorArea(pro
|
|
|
613
688
|
});
|
|
614
689
|
|
|
615
690
|
// src/ColorPickerSlider.tsx
|
|
616
|
-
var
|
|
691
|
+
var import_react5 = require("react");
|
|
617
692
|
var import_xui_core2 = require("@xsolla/xui-core");
|
|
618
693
|
var import_jsx_runtime3 = require("react/jsx-runtime");
|
|
619
694
|
var ColorPickerSlider = ({
|
|
@@ -625,9 +700,9 @@ var ColorPickerSlider = ({
|
|
|
625
700
|
themeProductContext
|
|
626
701
|
}) => {
|
|
627
702
|
const { theme } = (0, import_xui_core2.useResolvedTheme)({ themeMode, themeProductContext });
|
|
628
|
-
const trackRef = (0,
|
|
629
|
-
const [layout, setLayout] = (0,
|
|
630
|
-
const [isDragging, setIsDragging] = (0,
|
|
703
|
+
const trackRef = (0, import_react5.useRef)(null);
|
|
704
|
+
const [layout, setLayout] = (0, import_react5.useState)({ width: 0, height: 0 });
|
|
705
|
+
const [isDragging, setIsDragging] = (0, import_react5.useState)(false);
|
|
631
706
|
const currentColor = parseColor(value);
|
|
632
707
|
const hsb = currentColor.toHsb();
|
|
633
708
|
const getChannelValue = () => {
|
|
@@ -638,7 +713,7 @@ var ColorPickerSlider = ({
|
|
|
638
713
|
const channelValue = getChannelValue();
|
|
639
714
|
const maxValue = getMaxValue();
|
|
640
715
|
const thumbPosition = channelValue / maxValue * 100;
|
|
641
|
-
const updateColor = (0,
|
|
716
|
+
const updateColor = (0, import_react5.useCallback)(
|
|
642
717
|
(x) => {
|
|
643
718
|
const newValue = snapValueToStep(x * maxValue, 0, maxValue, 1);
|
|
644
719
|
let newColor;
|
|
@@ -662,7 +737,7 @@ var ColorPickerSlider = ({
|
|
|
662
737
|
},
|
|
663
738
|
[channel, maxValue, hsb, onChange]
|
|
664
739
|
);
|
|
665
|
-
const handleMouseDown = (0,
|
|
740
|
+
const handleMouseDown = (0, import_react5.useCallback)(
|
|
666
741
|
(e) => {
|
|
667
742
|
if (import_xui_core2.isNative) return;
|
|
668
743
|
setIsDragging(true);
|
|
@@ -672,7 +747,7 @@ var ColorPickerSlider = ({
|
|
|
672
747
|
},
|
|
673
748
|
[updateColor]
|
|
674
749
|
);
|
|
675
|
-
const handleMouseMove = (0,
|
|
750
|
+
const handleMouseMove = (0, import_react5.useCallback)(
|
|
676
751
|
(e) => {
|
|
677
752
|
if (!isDragging || import_xui_core2.isNative) return;
|
|
678
753
|
const rect = trackRef.current?.getBoundingClientRect?.();
|
|
@@ -682,13 +757,13 @@ var ColorPickerSlider = ({
|
|
|
682
757
|
},
|
|
683
758
|
[isDragging, updateColor]
|
|
684
759
|
);
|
|
685
|
-
const handleMouseUp = (0,
|
|
760
|
+
const handleMouseUp = (0, import_react5.useCallback)(() => {
|
|
686
761
|
if (isDragging) {
|
|
687
762
|
setIsDragging(false);
|
|
688
763
|
onChangeEnd?.(currentColor.toString());
|
|
689
764
|
}
|
|
690
765
|
}, [isDragging, currentColor, onChangeEnd]);
|
|
691
|
-
(0,
|
|
766
|
+
(0, import_react5.useEffect)(() => {
|
|
692
767
|
if (import_xui_core2.isWeb && isDragging) {
|
|
693
768
|
document.addEventListener("mousemove", handleMouseMove);
|
|
694
769
|
document.addEventListener("mouseup", handleMouseUp);
|
|
@@ -698,7 +773,7 @@ var ColorPickerSlider = ({
|
|
|
698
773
|
};
|
|
699
774
|
}
|
|
700
775
|
}, [isDragging, handleMouseMove, handleMouseUp]);
|
|
701
|
-
const handleResponderMove = (0,
|
|
776
|
+
const handleResponderMove = (0, import_react5.useCallback)(
|
|
702
777
|
(e) => {
|
|
703
778
|
const { locationX } = e.nativeEvent;
|
|
704
779
|
const x = clamp(locationX / layout.width, 0, 1);
|
|
@@ -706,7 +781,7 @@ var ColorPickerSlider = ({
|
|
|
706
781
|
},
|
|
707
782
|
[layout, updateColor]
|
|
708
783
|
);
|
|
709
|
-
const handleResponderRelease = (0,
|
|
784
|
+
const handleResponderRelease = (0, import_react5.useCallback)(() => {
|
|
710
785
|
setIsDragging(false);
|
|
711
786
|
onChangeEnd?.(currentColor.toString());
|
|
712
787
|
}, [currentColor, onChangeEnd]);
|
|
@@ -762,7 +837,7 @@ var ColorPickerSlider = ({
|
|
|
762
837
|
};
|
|
763
838
|
|
|
764
839
|
// src/ColorPickerInput.tsx
|
|
765
|
-
var
|
|
840
|
+
var import_react6 = require("react");
|
|
766
841
|
var import_xui_input = require("@xsolla/xui-input");
|
|
767
842
|
var import_jsx_runtime4 = require("react/jsx-runtime");
|
|
768
843
|
var ColorPickerInput = ({
|
|
@@ -775,8 +850,8 @@ var ColorPickerInput = ({
|
|
|
775
850
|
const channelRange = value.getChannelRange(channel);
|
|
776
851
|
const intValue = channel === "alpha" ? channelValue * 100 : channelValue;
|
|
777
852
|
const roundedValue = Math.round(intValue);
|
|
778
|
-
const [inputValue, setInputValue] = (0,
|
|
779
|
-
(0,
|
|
853
|
+
const [inputValue, setInputValue] = (0, import_react6.useState)(String(roundedValue));
|
|
854
|
+
(0, import_react6.useEffect)(() => {
|
|
780
855
|
setInputValue(String(roundedValue));
|
|
781
856
|
}, [roundedValue]);
|
|
782
857
|
const handleChange = (e) => {
|
|
@@ -807,15 +882,15 @@ var ColorPickerInput = ({
|
|
|
807
882
|
};
|
|
808
883
|
|
|
809
884
|
// src/ColorPickerHexInput.tsx
|
|
810
|
-
var
|
|
885
|
+
var import_react7 = require("react");
|
|
811
886
|
var import_xui_input2 = require("@xsolla/xui-input");
|
|
812
887
|
var import_jsx_runtime5 = require("react/jsx-runtime");
|
|
813
888
|
var ColorPickerHexInput = ({
|
|
814
889
|
value,
|
|
815
890
|
onChange
|
|
816
891
|
}) => {
|
|
817
|
-
const [inputValue, setInputValue] = (0,
|
|
818
|
-
(0,
|
|
892
|
+
const [inputValue, setInputValue] = (0, import_react7.useState)(value);
|
|
893
|
+
(0, import_react7.useEffect)(() => {
|
|
819
894
|
setInputValue(value);
|
|
820
895
|
}, [value]);
|
|
821
896
|
const handleChange = (e) => {
|
|
@@ -948,7 +1023,7 @@ var ResetIcon = () => /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(
|
|
|
948
1023
|
]
|
|
949
1024
|
}
|
|
950
1025
|
);
|
|
951
|
-
var ColorPicker = (0,
|
|
1026
|
+
var ColorPicker = (0, import_react8.forwardRef)(
|
|
952
1027
|
({
|
|
953
1028
|
colorFormat: defaultColorFormat = "hex",
|
|
954
1029
|
alpha = true,
|
|
@@ -963,7 +1038,7 @@ var ColorPicker = (0, import_react7.forwardRef)(
|
|
|
963
1038
|
themeProductContext
|
|
964
1039
|
}, ref) => {
|
|
965
1040
|
const { theme } = (0, import_xui_core3.useResolvedTheme)({ themeMode, themeProductContext });
|
|
966
|
-
const prevColorRef = (0,
|
|
1041
|
+
const prevColorRef = (0, import_react8.useRef)(propValue);
|
|
967
1042
|
const [innerValue, setInnerValue] = useUpdatableState(
|
|
968
1043
|
(prevState) => {
|
|
969
1044
|
if (prevColorRef.current === propValue && prevState) return prevState;
|
|
@@ -973,8 +1048,8 @@ var ColorPicker = (0, import_react7.forwardRef)(
|
|
|
973
1048
|
[propValue],
|
|
974
1049
|
true
|
|
975
1050
|
);
|
|
976
|
-
const [initialValue] = (0,
|
|
977
|
-
const [isValueCopied, setValueCopied] = (0,
|
|
1051
|
+
const [initialValue] = (0, import_react8.useState)(() => innerValue);
|
|
1052
|
+
const [isValueCopied, setValueCopied] = (0, import_react8.useState)(false);
|
|
978
1053
|
const [colorFormat, setColorFormat] = useUpdatableState(
|
|
979
1054
|
() => addAlfaToChannel(defaultColorFormat, alpha),
|
|
980
1055
|
[defaultColorFormat, alpha],
|