react-iro-gradient-picker 1.2.5 → 1.2.6

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/README.md CHANGED
@@ -323,6 +323,91 @@ radial-gradient(circle at 40% 40%, #C6FFDD, #FBD786, #F7797D)
323
323
  - **Flexible syntax**: Supports various positioning keywords and percentage values
324
324
  - **Error recovery**: Invalid gradients fall back to a default gradient instead of crashing
325
325
  - **Type safety**: Full TypeScript support with proper gradient object interfaces
326
+ - **Smart position mapping**: Automatically highlights correct position markers for all gradient formats
327
+
328
+ ## 📐 Gradient Value Format Guide
329
+
330
+ The component accepts gradient values in multiple formats and automatically maps them to the correct UI controls:
331
+
332
+ ### ✅ Supported Gradient Formats
333
+
334
+ #### Linear Gradients
335
+
336
+ ```css
337
+ /* Angle-based (0-360 degrees) */
338
+ linear-gradient(45deg, #FF6B6B, #4ECDC4)
339
+ linear-gradient(180deg, #667eea 0%, #764ba2 100%)
340
+
341
+ /* Named directions (automatically converted to angles) */
342
+ linear-gradient(to top, #FF6B6B, #4ECDC4) → 0deg
343
+ linear-gradient(to top right, #FF6B6B, #4ECDC4) → 45deg
344
+ linear-gradient(to right, #FF6B6B, #4ECDC4) → 90deg
345
+ linear-gradient(to bottom, #FF6B6B, #4ECDC4) → 180deg
346
+ ```
347
+
348
+ #### Radial Gradients - Standard Positions
349
+
350
+ ```css
351
+ /* Standard position keywords (auto-mapped to UI markers) */
352
+ radial-gradient(circle at center, #FF6B6B, #4ECDC4)
353
+ radial-gradient(circle at top left, #FF6B6B, #4ECDC4)
354
+ radial-gradient(circle at top center, #FF6B6B, #4ECDC4) ✨ Maps to "center top"
355
+ radial-gradient(circle at right center, #FF6B6B, #4ECDC4) ✨ Maps to "center right"
356
+
357
+ /* Percentage-based positions */
358
+ radial-gradient(circle at 70% 30%, #FF6B6B, #4ECDC4)
359
+ radial-gradient(circle at 0% 100%, #FF6B6B, #4ECDC4)
360
+ ```
361
+
362
+ #### Radial Gradients - Edge Cases ✨ NEW
363
+
364
+ ```css
365
+ /* Size-only gradients (automatically default to center position) */
366
+ radial-gradient(70, #ff0000, #0000ff) ✨ → circle at center
367
+ radial-gradient(150%, #FFB347, #FFCC33, #FF6347) ✨ → circle at center
368
+ radial-gradient(200px, #FF6B6B, #4ECDC4) ✨ → circle at center
369
+
370
+ /* Size keywords (automatically default to center position) */
371
+ radial-gradient(closest-side, #FF6B6B, #4ECDC4) ✨ → circle at center
372
+ radial-gradient(farthest-corner, #FF6B6B, #4ECDC4) ✨ → circle at center
373
+ ```
374
+
375
+ ### 🎯 Position Mapping Intelligence
376
+
377
+ The component intelligently maps gradient positions to UI markers:
378
+
379
+ | **Input Format** | **UI Marker Highlighted** | **Notes** |
380
+ | ------------------------ | ------------------------- | ------------------------------- |
381
+ | `circle at center` | Center (●) | Standard center position |
382
+ | `circle at top center` | Center Top (●) | Alias automatically normalized |
383
+ | `circle at right center` | Center Right (●) | Alias automatically normalized |
384
+ | `70`, `150%`, `200px` | Center (●) | Size-only defaults to center |
385
+ | `closest-side` | Center (●) | Size keywords default to center |
386
+ | `circle at 25% 75%` | No marker | Custom percentage position |
387
+
388
+ ### 📝 Gradient Value Requirements
389
+
390
+ #### ✅ Valid Examples
391
+
392
+ ```css
393
+ /* With explicit positions (recommended) */
394
+ linear-gradient(90deg, #FF6B6B 0%, #4ECDC4 100%)
395
+ radial-gradient(circle at center, #FF6B6B 0%, #4ECDC4 50%, #FFD93D 100%)
396
+
397
+ /* Without positions (auto-distributed) */
398
+ linear-gradient(45deg, #FF6B6B, #4ECDC4, #FFD93D)
399
+ radial-gradient(circle at top left, #FF6B6B, #4ECDC4)
400
+ ```
401
+
402
+ #### ❌ Invalid Examples
403
+
404
+ ```css
405
+ /* Missing gradient type */
406
+ 90deg, #FF6B6B, #4ECDC4
407
+
408
+ /* Invalid color format */
409
+ linear-gradient(90deg, notacolor, #4ECDC4)
410
+ ```
326
411
 
327
412
  ## Props
328
413
 
@@ -351,39 +436,48 @@ radial-gradient(circle at 40% 40%, #C6FFDD, #FBD786, #F7797D)
351
436
  | showReset | `bool` | `false` | Show/hide reset button in the picker interface |
352
437
  | onReset | `function` | `null` | Callback function triggered when reset button is clicked |
353
438
 
354
- When passing a value for a gradient, you must specify the position of all colors. Otherwise the component will throw an exception.
355
- For example:
356
-
357
- ### Wrong
439
+ ## 🎯 Radial Gradient Position Reference
358
440
 
359
- ```
360
-
361
- linear-gradient(180deg, #000000,#ff0000)
362
-
363
- ```
364
-
365
- ### Correct
441
+ The component supports all standard radial gradient positions and automatically maps them to UI markers:
366
442
 
367
- ```
368
-
369
- linear-gradient(180deg, #000000 0%,#ff0000 100%)
443
+ ### Standard Positions (9-Point Grid)
370
444
 
445
+ ```css
446
+ /* Top Row */
447
+ circle at left top → Top-Left marker (●)
448
+ circle at center top → Top-Center marker (●)
449
+ circle at right top → Top-Right marker (●)
450
+
451
+ /* Middle Row */
452
+ circle at left → Middle-Left marker (●)
453
+ circle at center → Center marker (●) [Default]
454
+ circle at right → Middle-Right marker (●)
455
+
456
+ /* Bottom Row */
457
+ circle at left bottom → Bottom-Left marker (●)
458
+ circle at center bottom → Bottom-Center marker (●)
459
+ circle at right bottom → Bottom-Right marker (●)
371
460
  ```
372
461
 
373
- If you are using a radial gradient a list of possible directions for it:
462
+ ### Position Aliases (Auto-Normalized)
374
463
 
464
+ ```css
465
+ /* These aliases are automatically converted: */
466
+ circle at top center → circle at center top
467
+ circle at bottom center → circle at center bottom
468
+ circle at left center → circle at center left
469
+ circle at right center → circle at center right
375
470
  ```
376
471
 
377
- circle at left top
378
- circle at center top
379
- circle at right top
380
- circle at left
381
- circle at center
382
- circle at right
383
- circle at left bottom
384
- circle at center bottom
385
- circle at right bottom
472
+ ### Edge Cases (Auto-Defaulted to Center)
386
473
 
474
+ ```css
475
+ /* Size-only gradients default to center: */
476
+ 70 → circle at center
477
+ 150% → circle at center
478
+ 200px → circle at center
479
+ closest-side → circle at center
480
+ farthest-corner → circle at center
387
481
  ```
388
482
 
389
483
  ## Default color list
package/dist/index.es.js CHANGED
@@ -6432,9 +6432,7 @@ var validGradient = (function (input) {
6432
6432
  var firstPart = parts[0];
6433
6433
  var isDirection = false;
6434
6434
  if (type === 'linear') {
6435
- isDirection =
6436
- /^\d+deg$/i.test(firstPart) ||
6437
- /^to\s+/.test(firstPart);
6435
+ isDirection = /^\d+deg$/i.test(firstPart) || /^to\s+/.test(firstPart);
6438
6436
  }
6439
6437
  else if (type === 'radial') {
6440
6438
  // For radial gradients, check for size, shape, or position keywords
@@ -6603,12 +6601,23 @@ var parseGradient = (function (str) {
6603
6601
  var findF = (_a = LINEAR_POS.find(function (item) { return item.name === angle_1; })) === null || _a === void 0 ? void 0 : _a.angle;
6604
6602
  var helperAngle = type === 'linear' ? '180' : 'circle at center';
6605
6603
  var modifier = findF || angle_1 || helperAngle;
6604
+ // For radial gradients, preserve the full modifier string to maintain positioning
6605
+ var processedModifier = void 0;
6606
+ if (type === 'radial') {
6607
+ // Keep the full radial gradient specification
6608
+ processedModifier = modifier;
6609
+ }
6610
+ else {
6611
+ // For linear gradients, extract number if it's a degree value
6612
+ processedModifier =
6613
+ modifier.match(/\d+/) !== null
6614
+ ? Number((_b = modifier.match(/\d+/)) === null || _b === void 0 ? void 0 : _b.join(''))
6615
+ : modifier;
6616
+ }
6606
6617
  return {
6607
6618
  gradient: typeof gradient !== 'string' ? gradient.original : str,
6608
6619
  type: type,
6609
- modifier: modifier.match(/\d+/) !== null
6610
- ? Number((_b = modifier.match(/\d+/)) === null || _b === void 0 ? void 0 : _b.join(''))
6611
- : modifier,
6620
+ modifier: processedModifier,
6612
6621
  stops: stops.map(function (stop, index) {
6613
6622
  var formatStop = ["".concat(stop.color), index];
6614
6623
  if (stop.position || stop.position === 0) {