react-iro-gradient-picker 2.0.4 → 2.0.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 +79 -4
- package/dist/index.es.js.map +1 -1
- package/dist/index.js +79 -4
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.es.js
CHANGED
|
@@ -6877,6 +6877,7 @@ var IroColorPicker = forwardRef(function (_a, ref) {
|
|
|
6877
6877
|
var theme = detectedTheme;
|
|
6878
6878
|
var isUpdatingColor = useRef(false);
|
|
6879
6879
|
var _o = __read(useState(width || 200), 2), containerWidth = _o[0], setContainerWidth = _o[1];
|
|
6880
|
+
var _p = __read(useState(true), 2), isLoading = _p[0], setIsLoading = _p[1];
|
|
6880
6881
|
// Set up ResizeObserver to make the color picker responsive
|
|
6881
6882
|
// Only when width prop is NOT provided (parent doesn't control width)
|
|
6882
6883
|
useEffect(function () {
|
|
@@ -7035,12 +7036,15 @@ var IroColorPicker = forwardRef(function (_a, ref) {
|
|
|
7035
7036
|
if (!colorPickerRef.current || !colorPickerRef.current.color) {
|
|
7036
7037
|
throw new Error('ColorPicker was not created properly');
|
|
7037
7038
|
}
|
|
7039
|
+
// Update picker ready state and notify parent
|
|
7040
|
+
setIsLoading(false);
|
|
7038
7041
|
// Force update of imperative handle by calling onMount callback
|
|
7039
7042
|
if (onMount) {
|
|
7040
7043
|
setTimeout(function () { return onMount(colorPickerRef.current); }, 0);
|
|
7041
7044
|
}
|
|
7042
7045
|
}
|
|
7043
7046
|
catch (error) {
|
|
7047
|
+
setIsLoading(false);
|
|
7044
7048
|
colorPickerRef.current = null;
|
|
7045
7049
|
return null; // Return null to indicate failure
|
|
7046
7050
|
}
|
|
@@ -7195,13 +7199,69 @@ var IroColorPicker = forwardRef(function (_a, ref) {
|
|
|
7195
7199
|
useEffect(function () {
|
|
7196
7200
|
if (!width)
|
|
7197
7201
|
return;
|
|
7198
|
-
|
|
7202
|
+
var retryCount = 0;
|
|
7203
|
+
var maxRetries = 3;
|
|
7204
|
+
var createWithRetry = function () {
|
|
7205
|
+
// Longer initial delay to ensure DOM is completely ready
|
|
7206
|
+
var timeoutId = setTimeout(function () {
|
|
7207
|
+
try {
|
|
7208
|
+
var result = createColorPicker(width);
|
|
7209
|
+
if (!result &&
|
|
7210
|
+
colorPickerRef.current === null &&
|
|
7211
|
+
retryCount < maxRetries) {
|
|
7212
|
+
retryCount++;
|
|
7213
|
+
// Exponential backoff: 100ms, 200ms, 400ms
|
|
7214
|
+
setTimeout(createWithRetry, 100 * Math.pow(2, retryCount - 1));
|
|
7215
|
+
}
|
|
7216
|
+
}
|
|
7217
|
+
catch (error) {
|
|
7218
|
+
if (retryCount < maxRetries) {
|
|
7219
|
+
retryCount++;
|
|
7220
|
+
setTimeout(createWithRetry, 100 * Math.pow(2, retryCount - 1));
|
|
7221
|
+
}
|
|
7222
|
+
}
|
|
7223
|
+
}, 100); // Increased from 50ms to 100ms
|
|
7224
|
+
return function () { return clearTimeout(timeoutId); };
|
|
7225
|
+
};
|
|
7226
|
+
var cleanupFn = createWithRetry();
|
|
7227
|
+
return function () {
|
|
7228
|
+
if (cleanupFn)
|
|
7229
|
+
cleanupFn();
|
|
7230
|
+
};
|
|
7199
7231
|
}, [width, theme, createColorPicker]);
|
|
7200
7232
|
// useEffect for when containerWidth is used (internal ResizeObserver)
|
|
7201
7233
|
useEffect(function () {
|
|
7202
7234
|
if (width)
|
|
7203
7235
|
return; // Don't run if width prop is provided
|
|
7204
|
-
|
|
7236
|
+
var retryCount = 0;
|
|
7237
|
+
var maxRetries = 3;
|
|
7238
|
+
var createWithRetry = function () {
|
|
7239
|
+
// Longer initial delay to ensure DOM is completely ready
|
|
7240
|
+
var timeoutId = setTimeout(function () {
|
|
7241
|
+
try {
|
|
7242
|
+
var result = createColorPicker(containerWidth);
|
|
7243
|
+
if (!result &&
|
|
7244
|
+
colorPickerRef.current === null &&
|
|
7245
|
+
retryCount < maxRetries) {
|
|
7246
|
+
retryCount++;
|
|
7247
|
+
// Exponential backoff: 100ms, 200ms, 400ms
|
|
7248
|
+
setTimeout(createWithRetry, 100 * Math.pow(2, retryCount - 1));
|
|
7249
|
+
}
|
|
7250
|
+
}
|
|
7251
|
+
catch (error) {
|
|
7252
|
+
if (retryCount < maxRetries) {
|
|
7253
|
+
retryCount++;
|
|
7254
|
+
setTimeout(createWithRetry, 100 * Math.pow(2, retryCount - 1));
|
|
7255
|
+
}
|
|
7256
|
+
}
|
|
7257
|
+
}, 100); // Increased from 50ms to 100ms
|
|
7258
|
+
return function () { return clearTimeout(timeoutId); };
|
|
7259
|
+
};
|
|
7260
|
+
var cleanupFn = createWithRetry();
|
|
7261
|
+
return function () {
|
|
7262
|
+
if (cleanupFn)
|
|
7263
|
+
cleanupFn();
|
|
7264
|
+
};
|
|
7205
7265
|
}, [containerWidth, theme, createColorPicker, width]);
|
|
7206
7266
|
// Update color when prop changes
|
|
7207
7267
|
useEffect(function () {
|
|
@@ -7305,10 +7365,25 @@ var IroColorPicker = forwardRef(function (_a, ref) {
|
|
|
7305
7365
|
minWidth: 0,
|
|
7306
7366
|
overflow: 'hidden',
|
|
7307
7367
|
justifyContent: 'center',
|
|
7308
|
-
minHeight: 'auto',
|
|
7368
|
+
minHeight: isLoading ? width || containerWidth : 'auto',
|
|
7309
7369
|
position: 'relative',
|
|
7310
7370
|
backgroundColor: 'transparent'
|
|
7311
|
-
} }
|
|
7371
|
+
} }, isLoading && (React.createElement("div", { style: {
|
|
7372
|
+
position: 'absolute',
|
|
7373
|
+
inset: 0,
|
|
7374
|
+
display: 'flex',
|
|
7375
|
+
alignItems: 'center',
|
|
7376
|
+
justifyContent: 'center',
|
|
7377
|
+
background: 'var(--colorpicker-panel-bg, #1e293b)'
|
|
7378
|
+
} },
|
|
7379
|
+
React.createElement("div", { style: {
|
|
7380
|
+
width: '32px',
|
|
7381
|
+
height: '32px',
|
|
7382
|
+
border: '3px solid rgba(59, 130, 246, 0.3)',
|
|
7383
|
+
borderTop: '3px solid rgb(59, 130, 246)',
|
|
7384
|
+
borderRadius: '50%',
|
|
7385
|
+
animation: 'spin 0.8s linear infinite'
|
|
7386
|
+
} })))));
|
|
7312
7387
|
});
|
|
7313
7388
|
IroColorPicker.displayName = 'IroColorPicker';
|
|
7314
7389
|
|