react-iro-gradient-picker 1.2.4 → 1.2.5

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/dist/index.es.js CHANGED
@@ -6430,10 +6430,20 @@ var validGradient = (function (input) {
6430
6430
  var colorStops = [];
6431
6431
  // Determine if first part is direction/angle or color stop
6432
6432
  var firstPart = parts[0];
6433
- var isDirection = /^\d+deg$/i.test(firstPart) ||
6434
- /^to\s+/.test(firstPart) ||
6435
- /^(?:circle|ellipse)/.test(firstPart) ||
6436
- /at\s+/.test(firstPart);
6433
+ var isDirection = false;
6434
+ if (type === 'linear') {
6435
+ isDirection =
6436
+ /^\d+deg$/i.test(firstPart) ||
6437
+ /^to\s+/.test(firstPart);
6438
+ }
6439
+ else if (type === 'radial') {
6440
+ // For radial gradients, check for size, shape, or position keywords
6441
+ isDirection =
6442
+ /^(?:circle|ellipse)/.test(firstPart) ||
6443
+ /at\s+/.test(firstPart) ||
6444
+ /^(?:closest-side|closest-corner|farthest-side|farthest-corner)$/i.test(firstPart) ||
6445
+ /^\d+(?:%|px|em|rem)?$/i.test(firstPart); // Size values like "70", "70%", "70px"
6446
+ }
6437
6447
  if (isDirection) {
6438
6448
  if (type === 'linear') {
6439
6449
  if (/^\d+deg$/i.test(firstPart)) {
@@ -7455,9 +7465,18 @@ var Markers = function (_a) {
7455
7465
  };
7456
7466
  var onDrag = function (e) {
7457
7467
  var _a;
7458
- var x = e.clientX;
7459
- var y = e.clientY;
7468
+ // Defensive check for event object
7469
+ if (!e) {
7470
+ console.warn('onDrag called with undefined event object');
7471
+ return;
7472
+ }
7473
+ var x = e.clientX || 0;
7474
+ var y = e.clientY || 0;
7460
7475
  var rect = (_a = node === null || node === void 0 ? void 0 : node.current) === null || _a === void 0 ? void 0 : _a.getBoundingClientRect();
7476
+ if (!rect) {
7477
+ console.warn('Unable to get bounding rect for drag operation');
7478
+ return;
7479
+ }
7461
7480
  var rootDistance = y - rect.y;
7462
7481
  // Now we know user is actually dragging
7463
7482
  setIsDragging(true);
@@ -7712,10 +7731,15 @@ var GradientPanel = function (_a) {
7712
7731
  }
7713
7732
  };
7714
7733
  var onDrag = function (e) {
7715
- var x = e.clientX;
7716
- var y = e.clientY;
7717
- var shiftKey = e.shiftKey;
7718
- var ctrlKey = e.ctrlKey * 2;
7734
+ // Defensive check for event object
7735
+ if (!e) {
7736
+ console.warn('onDrag called with undefined event object');
7737
+ return;
7738
+ }
7739
+ var x = e.clientX || 0;
7740
+ var y = e.clientY || 0;
7741
+ var shiftKey = e.shiftKey || false;
7742
+ var ctrlKey = (e.ctrlKey || false) * 2;
7719
7743
  pointMoveTo({
7720
7744
  x: x,
7721
7745
  y: y,
@@ -7854,7 +7878,10 @@ var IroGradient = function (_a) {
7854
7878
  console.warn('Gradient parsing failed, using fallback:', parsed);
7855
7879
  var fallback = parseGradient('linear-gradient(90deg, #ffffff 0%, #000000 100%)');
7856
7880
  // Ensure fallback has valid structure
7857
- if (fallback && typeof fallback === 'object' && Array.isArray(fallback.stops) && fallback.stops.length > 0) {
7881
+ if (fallback &&
7882
+ typeof fallback === 'object' &&
7883
+ Array.isArray(fallback.stops) &&
7884
+ fallback.stops.length > 0) {
7858
7885
  return fallback;
7859
7886
  }
7860
7887
  // Ultimate fallback with guaranteed structure
@@ -7869,7 +7896,10 @@ var IroGradient = function (_a) {
7869
7896
  };
7870
7897
  }
7871
7898
  // Validate parsed result has required structure
7872
- if (parsed && typeof parsed === 'object' && Array.isArray(parsed.stops) && parsed.stops.length > 0) {
7899
+ if (parsed &&
7900
+ typeof parsed === 'object' &&
7901
+ Array.isArray(parsed.stops) &&
7902
+ parsed.stops.length > 0) {
7873
7903
  return parsed;
7874
7904
  }
7875
7905
  // If parsed result is invalid, use ultimate fallback
@@ -7904,11 +7934,22 @@ var IroGradient = function (_a) {
7904
7934
  var isUpdatingFromGradientStop = useRef(false);
7905
7935
  var _t = __read(useState(200), 2), pickerWidth = _t[0], setPickerWidth = _t[1];
7906
7936
  // Safe extraction of stop data with fallbacks
7907
- var safeStops = Array.isArray(stops) && stops.length > 0 ? stops : [['rgba(255, 255, 255, 1)', 0, 0], ['rgba(0, 0, 0, 1)', 1, 1]];
7937
+ var safeStops = Array.isArray(stops) && stops.length > 0
7938
+ ? stops
7939
+ : [
7940
+ ['rgba(255, 255, 255, 1)', 0, 0],
7941
+ ['rgba(0, 0, 0, 1)', 1, 1]
7942
+ ];
7908
7943
  var safeLastStop = rgbaToArray(safeStops[safeStops.length - 1][0]);
7909
- var safeParsedLastStop = Array.isArray(safeLastStop) && safeLastStop.length >= 4 ? safeLastStop : [255, 255, 255, 1];
7944
+ var safeParsedLastStop = Array.isArray(safeLastStop) && safeLastStop.length >= 4
7945
+ ? safeLastStop
7946
+ : [255, 255, 255, 1];
7910
7947
  var activeStopIndex = safeStops.length - 1;
7911
- var activeStop = rgbaToHex([safeParsedLastStop[0], safeParsedLastStop[1], safeParsedLastStop[2]]);
7948
+ var activeStop = rgbaToHex([
7949
+ safeParsedLastStop[0],
7950
+ safeParsedLastStop[1],
7951
+ safeParsedLastStop[2]
7952
+ ]);
7912
7953
  var activeAlpha = Math.round(safeParsedLastStop[3] * 100);
7913
7954
  // Responsive width for IroColorPicker - match solid picker logic
7914
7955
  useEffect(function () {