react-iro-gradient-picker 1.1.6 → 1.1.7

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.js CHANGED
@@ -7792,7 +7792,9 @@ var IroGradient = function (_a) {
7792
7792
  React.useEffect(function () {
7793
7793
  var initializeIroPicker = function () {
7794
7794
  var _a, _b;
7795
- if (((_b = (_a = iroPickerRef.current) === null || _a === void 0 ? void 0 : _a.colorPicker) === null || _b === void 0 ? void 0 : _b.color) && activeColor.hex) {
7795
+ if (((_b = (_a = iroPickerRef.current) === null || _a === void 0 ? void 0 : _a.colorPicker) === null || _b === void 0 ? void 0 : _b.color) &&
7796
+ activeColor.hex &&
7797
+ typeof activeColor.alpha === 'number') {
7796
7798
  console.log('🚀 Initializing iro picker with activeColor:', activeColor);
7797
7799
  // Wait a bit for the picker to be fully ready, then update
7798
7800
  setTimeout(function () {
@@ -7813,13 +7815,19 @@ var IroGradient = function (_a) {
7813
7815
  var handleSetActiveColor = React.useCallback(function (newActiveColor) {
7814
7816
  console.log('🎯 Gradient stop clicked, setting active color:', newActiveColor);
7815
7817
  setActiveColor(newActiveColor);
7816
- // Force immediate update of iro picker with longer delay for first-time reliability
7817
- setTimeout(function () {
7818
- updateIroPickerColor({
7819
- hex: newActiveColor.hex,
7820
- alpha: newActiveColor.alpha
7821
- });
7822
- }, 50); // Increased from 5ms to 50ms for better first-time success
7818
+ // Validate before updating iro picker
7819
+ if (newActiveColor.hex && typeof newActiveColor.alpha === 'number') {
7820
+ // Force immediate update of iro picker with longer delay for first-time reliability
7821
+ setTimeout(function () {
7822
+ updateIroPickerColor({
7823
+ hex: newActiveColor.hex,
7824
+ alpha: newActiveColor.alpha
7825
+ });
7826
+ }, 50); // Increased from 5ms to 50ms for better first-time success
7827
+ }
7828
+ else {
7829
+ console.log('⚠️ Skipping iro picker update in handleSetActiveColor - invalid data:', newActiveColor);
7830
+ }
7823
7831
  }, [updateIroPickerColor]);
7824
7832
  // Update iro picker when activeColor changes (e.g., clicking gradient stops)
7825
7833
  React.useEffect(function () {
@@ -7829,18 +7837,17 @@ var IroGradient = function (_a) {
7829
7837
  index: activeColor.index,
7830
7838
  loc: activeColor.loc
7831
7839
  });
7840
+ // Validate activeColor before proceeding
7841
+ if (!activeColor.hex || typeof activeColor.alpha !== 'number') {
7842
+ console.log('⚠️ Skipping iro picker update - invalid activeColor:', activeColor);
7843
+ return;
7844
+ }
7832
7845
  // Add a small delay to ensure the activeColor state has fully updated
7833
7846
  var timeoutId = setTimeout(function () {
7834
7847
  updateIroPickerColor({ hex: activeColor.hex, alpha: activeColor.alpha });
7835
7848
  }, 10);
7836
7849
  return function () { return clearTimeout(timeoutId); };
7837
- }, [
7838
- activeColor.hex,
7839
- activeColor.alpha,
7840
- activeColor.index,
7841
- activeColor.loc,
7842
- updateIroPickerColor
7843
- ]);
7850
+ }, [activeColor, updateIroPickerColor]);
7844
7851
  var updateGradient = React.useCallback(function (newColor) {
7845
7852
  if (Array.isArray(newColor)) {
7846
7853
  // Handle the case where it's called with stops array