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.js
CHANGED
|
@@ -6885,6 +6885,7 @@ var IroColorPicker = React.forwardRef(function (_a, ref) {
|
|
|
6885
6885
|
var theme = detectedTheme;
|
|
6886
6886
|
var isUpdatingColor = React.useRef(false);
|
|
6887
6887
|
var _o = __read(React.useState(width || 200), 2), containerWidth = _o[0], setContainerWidth = _o[1];
|
|
6888
|
+
var _p = __read(React.useState(true), 2), isLoading = _p[0], setIsLoading = _p[1];
|
|
6888
6889
|
// Set up ResizeObserver to make the color picker responsive
|
|
6889
6890
|
// Only when width prop is NOT provided (parent doesn't control width)
|
|
6890
6891
|
React.useEffect(function () {
|
|
@@ -7043,12 +7044,15 @@ var IroColorPicker = React.forwardRef(function (_a, ref) {
|
|
|
7043
7044
|
if (!colorPickerRef.current || !colorPickerRef.current.color) {
|
|
7044
7045
|
throw new Error('ColorPicker was not created properly');
|
|
7045
7046
|
}
|
|
7047
|
+
// Update picker ready state and notify parent
|
|
7048
|
+
setIsLoading(false);
|
|
7046
7049
|
// Force update of imperative handle by calling onMount callback
|
|
7047
7050
|
if (onMount) {
|
|
7048
7051
|
setTimeout(function () { return onMount(colorPickerRef.current); }, 0);
|
|
7049
7052
|
}
|
|
7050
7053
|
}
|
|
7051
7054
|
catch (error) {
|
|
7055
|
+
setIsLoading(false);
|
|
7052
7056
|
colorPickerRef.current = null;
|
|
7053
7057
|
return null; // Return null to indicate failure
|
|
7054
7058
|
}
|
|
@@ -7203,13 +7207,69 @@ var IroColorPicker = React.forwardRef(function (_a, ref) {
|
|
|
7203
7207
|
React.useEffect(function () {
|
|
7204
7208
|
if (!width)
|
|
7205
7209
|
return;
|
|
7206
|
-
|
|
7210
|
+
var retryCount = 0;
|
|
7211
|
+
var maxRetries = 3;
|
|
7212
|
+
var createWithRetry = function () {
|
|
7213
|
+
// Longer initial delay to ensure DOM is completely ready
|
|
7214
|
+
var timeoutId = setTimeout(function () {
|
|
7215
|
+
try {
|
|
7216
|
+
var result = createColorPicker(width);
|
|
7217
|
+
if (!result &&
|
|
7218
|
+
colorPickerRef.current === null &&
|
|
7219
|
+
retryCount < maxRetries) {
|
|
7220
|
+
retryCount++;
|
|
7221
|
+
// Exponential backoff: 100ms, 200ms, 400ms
|
|
7222
|
+
setTimeout(createWithRetry, 100 * Math.pow(2, retryCount - 1));
|
|
7223
|
+
}
|
|
7224
|
+
}
|
|
7225
|
+
catch (error) {
|
|
7226
|
+
if (retryCount < maxRetries) {
|
|
7227
|
+
retryCount++;
|
|
7228
|
+
setTimeout(createWithRetry, 100 * Math.pow(2, retryCount - 1));
|
|
7229
|
+
}
|
|
7230
|
+
}
|
|
7231
|
+
}, 100); // Increased from 50ms to 100ms
|
|
7232
|
+
return function () { return clearTimeout(timeoutId); };
|
|
7233
|
+
};
|
|
7234
|
+
var cleanupFn = createWithRetry();
|
|
7235
|
+
return function () {
|
|
7236
|
+
if (cleanupFn)
|
|
7237
|
+
cleanupFn();
|
|
7238
|
+
};
|
|
7207
7239
|
}, [width, theme, createColorPicker]);
|
|
7208
7240
|
// useEffect for when containerWidth is used (internal ResizeObserver)
|
|
7209
7241
|
React.useEffect(function () {
|
|
7210
7242
|
if (width)
|
|
7211
7243
|
return; // Don't run if width prop is provided
|
|
7212
|
-
|
|
7244
|
+
var retryCount = 0;
|
|
7245
|
+
var maxRetries = 3;
|
|
7246
|
+
var createWithRetry = function () {
|
|
7247
|
+
// Longer initial delay to ensure DOM is completely ready
|
|
7248
|
+
var timeoutId = setTimeout(function () {
|
|
7249
|
+
try {
|
|
7250
|
+
var result = createColorPicker(containerWidth);
|
|
7251
|
+
if (!result &&
|
|
7252
|
+
colorPickerRef.current === null &&
|
|
7253
|
+
retryCount < maxRetries) {
|
|
7254
|
+
retryCount++;
|
|
7255
|
+
// Exponential backoff: 100ms, 200ms, 400ms
|
|
7256
|
+
setTimeout(createWithRetry, 100 * Math.pow(2, retryCount - 1));
|
|
7257
|
+
}
|
|
7258
|
+
}
|
|
7259
|
+
catch (error) {
|
|
7260
|
+
if (retryCount < maxRetries) {
|
|
7261
|
+
retryCount++;
|
|
7262
|
+
setTimeout(createWithRetry, 100 * Math.pow(2, retryCount - 1));
|
|
7263
|
+
}
|
|
7264
|
+
}
|
|
7265
|
+
}, 100); // Increased from 50ms to 100ms
|
|
7266
|
+
return function () { return clearTimeout(timeoutId); };
|
|
7267
|
+
};
|
|
7268
|
+
var cleanupFn = createWithRetry();
|
|
7269
|
+
return function () {
|
|
7270
|
+
if (cleanupFn)
|
|
7271
|
+
cleanupFn();
|
|
7272
|
+
};
|
|
7213
7273
|
}, [containerWidth, theme, createColorPicker, width]);
|
|
7214
7274
|
// Update color when prop changes
|
|
7215
7275
|
React.useEffect(function () {
|
|
@@ -7313,10 +7373,25 @@ var IroColorPicker = React.forwardRef(function (_a, ref) {
|
|
|
7313
7373
|
minWidth: 0,
|
|
7314
7374
|
overflow: 'hidden',
|
|
7315
7375
|
justifyContent: 'center',
|
|
7316
|
-
minHeight: 'auto',
|
|
7376
|
+
minHeight: isLoading ? width || containerWidth : 'auto',
|
|
7317
7377
|
position: 'relative',
|
|
7318
7378
|
backgroundColor: 'transparent'
|
|
7319
|
-
} }
|
|
7379
|
+
} }, isLoading && (React__default["default"].createElement("div", { style: {
|
|
7380
|
+
position: 'absolute',
|
|
7381
|
+
inset: 0,
|
|
7382
|
+
display: 'flex',
|
|
7383
|
+
alignItems: 'center',
|
|
7384
|
+
justifyContent: 'center',
|
|
7385
|
+
background: 'var(--colorpicker-panel-bg, #1e293b)'
|
|
7386
|
+
} },
|
|
7387
|
+
React__default["default"].createElement("div", { style: {
|
|
7388
|
+
width: '32px',
|
|
7389
|
+
height: '32px',
|
|
7390
|
+
border: '3px solid rgba(59, 130, 246, 0.3)',
|
|
7391
|
+
borderTop: '3px solid rgb(59, 130, 246)',
|
|
7392
|
+
borderRadius: '50%',
|
|
7393
|
+
animation: 'spin 0.8s linear infinite'
|
|
7394
|
+
} })))));
|
|
7320
7395
|
});
|
|
7321
7396
|
IroColorPicker.displayName = 'IroColorPicker';
|
|
7322
7397
|
|