@designbasekorea/ui 0.2.35 → 0.2.36

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
@@ -5323,17 +5323,19 @@ Chip.displayName = 'Chip';
5323
5323
 
5324
5324
  /* ----------------------- 유틸 ----------------------- */
5325
5325
  const clamp = (n, min, max) => Math.max(min, Math.min(max, n));
5326
+ const normalizeHex = (s) => (s || '').trim().toUpperCase();
5327
+ /** #RRGGBB → {r,g,b} */
5326
5328
  const hexToRgb = (hex) => {
5327
5329
  const m = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hex.trim());
5328
5330
  if (!m)
5329
5331
  return null;
5330
5332
  return { r: parseInt(m[1], 16), g: parseInt(m[2], 16), b: parseInt(m[3], 16) };
5331
5333
  };
5332
- const rgbToHex = (r, g, b) => {
5333
- const toHex = (n) => clamp(Math.round(n), 0, 255).toString(16).padStart(2, '0');
5334
- return `#${toHex(r)}${toHex(g)}${toHex(b)}`.toUpperCase();
5334
+ /** RGB HEX */
5335
+ const toHex = (r, g, b) => {
5336
+ const h = (x) => clamp(Math.round(x), 0, 255).toString(16).padStart(2, '0');
5337
+ return `#${h(r)}${h(g)}${h(b)}`.toUpperCase();
5335
5338
  };
5336
- /** RGB ↔ HSV (HSV: h[0-360], s[0-100], v[0-100]) */
5337
5339
  const rgbToHsv = (r, g, b) => {
5338
5340
  r /= 255;
5339
5341
  g /= 255;
@@ -5357,7 +5359,7 @@ const rgbToHsv = (r, g, b) => {
5357
5359
  }
5358
5360
  const s = max === 0 ? 0 : d / max;
5359
5361
  const v = max;
5360
- return { h: Math.round(h * 100) / 100, s: Math.round(s * 10000) / 100, v: Math.round(v * 10000) / 100 };
5362
+ return { h, s: s * 100, v: v * 100 };
5361
5363
  };
5362
5364
  const hsvToRgb = (h, s, v) => {
5363
5365
  s /= 100;
@@ -5425,86 +5427,123 @@ const rgbToHsl = (r, g, b) => {
5425
5427
  }
5426
5428
  h *= 60;
5427
5429
  }
5428
- return {
5429
- h: Math.round(h * 100) / 100,
5430
- s: Math.round(s * 10000) / 100,
5431
- l: Math.round(l * 10000) / 100,
5432
- };
5430
+ return { h, s: s * 100, l: l * 100 };
5433
5431
  };
5434
5432
  /* ----------------------- 컴포넌트 ----------------------- */
5435
- const ColorPicker = ({ size = 'm', type = 'dropdown', position = 'bottom-left', value, defaultValue = '#006FFF', showInput = true, showAlpha = true, showFormatSelector = true, showCopyButton = true, disabled = false, readonly = false, onChange, onApply, onCancel, className, }) => {
5436
- /** 내부 HSV + alpha */
5437
- const [h, setH] = React.useState(211);
5438
- const [s, setS] = React.useState(100);
5439
- const [v, setV] = React.useState(50);
5433
+ const ColorPicker = ({ size = 'm', type = 'dropdown', position = 'bottom-left', value, defaultValue = '#006FFF', showInput = true, showAlpha = true, showFormatSelector = true, showCopyButton = true, disabled = false, readonly = false, onChangeFormat = 'hex', fireOnInit = false, changeDebounceMs = 0, onChange, onApply, onCancel, className, }) => {
5434
+ /** 초기 HSV props에서 즉시 도출(StrictMode 안전) */
5435
+ const initialHex = normalizeHex(value || defaultValue) || '#006FFF';
5436
+ const initialRgb = hexToRgb(initialHex) || { r: 0, g: 111, b: 255 };
5437
+ const initialHsv = rgbToHsv(initialRgb.r, initialRgb.g, initialRgb.b);
5438
+ const [h, setH] = React.useState(() => initialHsv.h);
5439
+ const [s, setS] = React.useState(() => initialHsv.s);
5440
+ const [v, setV] = React.useState(() => initialHsv.v);
5440
5441
  const [a, setA] = React.useState(100);
5441
5442
  const [isOpen, setIsOpen] = React.useState(false);
5442
5443
  const [format, setFormat] = React.useState('hex');
5443
5444
  const [isCopied, setIsCopied] = React.useState(false);
5444
- const [colorInput, setColorInput] = React.useState('');
5445
+ const [colorInput, setColorInput] = React.useState(() => initialHex);
5445
5446
  const [alphaInput, setAlphaInput] = React.useState('100');
5446
5447
  const [tempColor, setTempColor] = React.useState('');
5447
5448
  const pickerRef = React.useRef(null);
5448
5449
  const areaRef = React.useRef(null);
5449
5450
  const dragging = React.useRef(false);
5450
- /** 초기값 세팅 */
5451
+ /** onChange 보호 상태 */
5452
+ const lastEmittedRef = React.useRef(normalizeHex(initialHex)); // ✅ 초기값 미리 기록
5453
+ const didMountRef = React.useRef(false); // ✅ 첫 렌더 감지
5454
+ const emitErrorCountRef = React.useRef(0);
5455
+ const emitBlockedUntilRef = React.useRef(0);
5456
+ /** 제어형(value) 변화 → HSV 반영 */
5451
5457
  React.useEffect(() => {
5452
- const initial = (value || defaultValue).toUpperCase();
5453
- const rgb = hexToRgb(initial);
5454
- if (rgb) {
5455
- const { h, s, v } = rgbToHsv(rgb.r, rgb.g, rgb.b);
5456
- setH(h);
5457
- setS(s);
5458
- setV(v);
5459
- }
5460
- setColorInput(initial);
5461
- setAlphaInput('100');
5462
- }, []);
5463
- /** 제어형(value) → HSV */
5464
- React.useEffect(() => {
5465
- if (!value)
5458
+ if (value == null)
5466
5459
  return;
5467
- const rgb = hexToRgb(value);
5468
- if (rgb) {
5469
- const { h, s, v } = rgbToHsv(rgb.r, rgb.g, rgb.b);
5470
- setH(h);
5471
- setS(s);
5472
- setV(v);
5473
- }
5460
+ const norm = normalizeHex(value);
5461
+ const rgb = hexToRgb(norm);
5462
+ if (!rgb)
5463
+ return;
5464
+ const hsv = rgbToHsv(rgb.r, rgb.g, rgb.b);
5465
+ setH(hsv.h);
5466
+ setS(hsv.s);
5467
+ setV(hsv.v);
5468
+ setColorInput(norm);
5474
5469
  }, [value]);
5475
- /** RGB/HSL 계산 */
5470
+ /** 파생값 */
5476
5471
  const rgb = React.useMemo(() => hsvToRgb(h, s, v), [h, s, v]);
5477
- const hex = React.useMemo(() => rgbToHex(rgb.r, rgb.g, rgb.b), [rgb]);
5472
+ const hex = React.useMemo(() => toHex(rgb.r, rgb.g, rgb.b), [rgb]);
5478
5473
  const hsl = React.useMemo(() => rgbToHsl(rgb.r, rgb.g, rgb.b), [rgb]);
5479
- /** 출력값 formatted */
5480
- const formatted = React.useMemo(() => {
5474
+ /** UI 표시 문자열 */
5475
+ const uiFormatted = React.useMemo(() => {
5481
5476
  const alpha = a / 100;
5482
5477
  switch (format) {
5483
5478
  case 'hex': return hex;
5484
5479
  case 'rgb': return `rgb(${rgb.r}, ${rgb.g}, ${rgb.b})`;
5485
5480
  case 'rgba': return `rgba(${rgb.r}, ${rgb.g}, ${rgb.b}, ${alpha.toFixed(2)})`;
5486
- case 'hsl': return `hsl(${hsl.h}, ${hsl.s}%, ${hsl.l}%)`;
5487
- case 'hsla': return `hsla(${hsl.h}, ${hsl.s}%, ${hsl.l}%, ${alpha.toFixed(2)})`;
5481
+ case 'hsl': return `hsl(${Math.round(hsl.h)}, ${Math.round(hsl.s)}%, ${Math.round(hsl.l)}%)`;
5482
+ case 'hsla': return `hsla(${Math.round(hsl.h)}, ${Math.round(hsl.s)}%, ${Math.round(hsl.l)}%, ${alpha.toFixed(2)})`;
5488
5483
  default: return hex;
5489
5484
  }
5490
5485
  }, [format, hex, rgb, hsl, a]);
5491
- /** 무한 루프 방지: formatted이 부모 value랑 같으면 onChange 호출하지 않음 */
5486
+ /** 콜백으로 내보낼 문자열 */
5487
+ const outward = React.useMemo(() => {
5488
+ if (onChangeFormat === 'hex')
5489
+ return hex;
5490
+ return uiFormatted;
5491
+ }, [hex, uiFormatted, onChangeFormat]);
5492
+ /** 최초 렌더 스킵 + 동일값/레이트리밋 검사 후 onChange */
5492
5493
  React.useEffect(() => {
5493
- if (value !== undefined && value.toUpperCase() === formatted.toUpperCase())
5494
+ if (!onChange)
5495
+ return;
5496
+ // 첫 렌더는 기본 차단 (옵션으로 허용)
5497
+ if (!didMountRef.current) {
5498
+ didMountRef.current = true;
5499
+ if (!fireOnInit)
5500
+ return; // 기본: 초기 발사 금지
5501
+ }
5502
+ const now = Date.now();
5503
+ if (emitBlockedUntilRef.current > now)
5494
5504
  return;
5495
- onChange?.(formatted);
5505
+ const currentHexNorm = normalizeHex(outward);
5506
+ const last = lastEmittedRef.current;
5507
+ // 제어형: 부모 value와 동일하면 발사 금지
5508
+ if (value && normalizeHex(value) === currentHexNorm)
5509
+ return;
5510
+ // 직전 발사값과 동일하면 금지
5511
+ if (last === currentHexNorm)
5512
+ return;
5513
+ const fire = () => {
5514
+ try {
5515
+ lastEmittedRef.current = currentHexNorm;
5516
+ onChange(onChangeFormat === 'hex' ? currentHexNorm : outward);
5517
+ emitErrorCountRef.current = 0;
5518
+ }
5519
+ catch (e) {
5520
+ emitErrorCountRef.current += 1;
5521
+ if (emitErrorCountRef.current >= 20) {
5522
+ emitBlockedUntilRef.current = Date.now() + 3000;
5523
+ // eslint-disable-next-line no-console
5524
+ console.warn('[ColorPicker] onChange errors too frequent; temporarily muted.');
5525
+ }
5526
+ }
5527
+ };
5528
+ if (changeDebounceMs > 0) {
5529
+ const t = setTimeout(fire, changeDebounceMs);
5530
+ return () => clearTimeout(t);
5531
+ }
5532
+ fire();
5496
5533
  // eslint-disable-next-line react-hooks/exhaustive-deps
5497
- }, [formatted]); // onChangevalue 의존성에서 제거
5498
- /** formatted 변경시 colorInput 동기화 */
5534
+ }, [outward]); // 의도적으로 onChange/value 제외
5535
+ /** colorInput 동기화(표시 전용) */
5499
5536
  React.useEffect(() => {
5500
- setColorInput(formatted.toUpperCase());
5501
- }, [formatted]);
5537
+ const next = format === 'hex' ? normalizeHex(uiFormatted) : uiFormatted;
5538
+ if (colorInput !== next)
5539
+ setColorInput(next);
5540
+ // eslint-disable-next-line react-hooks/exhaustive-deps
5541
+ }, [uiFormatted, format]);
5502
5542
  /** 드롭다운 외부 클릭 닫기 */
5503
5543
  React.useEffect(() => {
5504
5544
  const handler = (e) => {
5505
- if (pickerRef.current && !pickerRef.current.contains(e.target)) {
5545
+ if (pickerRef.current && !pickerRef.current.contains(e.target))
5506
5546
  setIsOpen(false);
5507
- }
5508
5547
  };
5509
5548
  if (isOpen && type === 'dropdown')
5510
5549
  document.addEventListener('mousedown', handler);
@@ -5518,8 +5557,8 @@ const ColorPicker = ({ size = 'm', type = 'dropdown', position = 'bottom-left',
5518
5557
  const rect = el.getBoundingClientRect();
5519
5558
  const x = clamp(clientX - rect.left, 0, rect.width);
5520
5559
  const y = clamp(clientY - rect.top, 0, rect.height);
5521
- const newS = Math.round((x / rect.width) * 100);
5522
- const newV = Math.round(100 - (y / rect.height) * 100);
5560
+ const newS = (x / rect.width) * 100;
5561
+ const newV = 100 - (y / rect.height) * 100;
5523
5562
  setS(newS);
5524
5563
  setV(newV);
5525
5564
  };
@@ -5533,13 +5572,13 @@ const ColorPicker = ({ size = 'm', type = 'dropdown', position = 'bottom-left',
5533
5572
  return; const t = e.touches[0]; updateFromArea(t.clientX, t.clientY); };
5534
5573
  const onAreaTouchEnd = () => { dragging.current = false; };
5535
5574
  /** 슬라이더 */
5536
- const onHueChange = React.useCallback((e) => setH(parseInt(e.target.value, 10)), []);
5575
+ const onHueChange = React.useCallback((e) => setH(parseFloat(e.target.value)), []);
5537
5576
  const onAlphaChange = React.useCallback((e) => {
5538
5577
  const newAlpha = parseInt(e.target.value, 10);
5539
5578
  setA(newAlpha);
5540
5579
  setAlphaInput(String(newAlpha));
5541
5580
  }, []);
5542
- /** 컬러 인풋 (엔터 확정) */
5581
+ /** 컬러 인풋 확정 */
5543
5582
  const commitColorInput = React.useCallback(() => {
5544
5583
  const str = colorInput.trim();
5545
5584
  if (/^#([0-9A-Fa-f]{6})$/.test(str)) {
@@ -5548,7 +5587,7 @@ const ColorPicker = ({ size = 'm', type = 'dropdown', position = 'bottom-left',
5548
5587
  setH(hsv.h);
5549
5588
  setS(hsv.s);
5550
5589
  setV(hsv.v);
5551
- setColorInput(str.toUpperCase());
5590
+ setColorInput(normalizeHex(str));
5552
5591
  return;
5553
5592
  }
5554
5593
  let m = /^rgb\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*\)$/i.exec(str);
@@ -5560,7 +5599,7 @@ const ColorPicker = ({ size = 'm', type = 'dropdown', position = 'bottom-left',
5560
5599
  setH(hsv.h);
5561
5600
  setS(hsv.s);
5562
5601
  setV(hsv.v);
5563
- setColorInput(`rgb(${r}, ${g}, ${b})`.toUpperCase());
5602
+ setColorInput(`rgb(${r}, ${g}, ${b})`);
5564
5603
  return;
5565
5604
  }
5566
5605
  m = /^rgba\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(0|1|0?\.\d+)\s*\)$/i.exec(str);
@@ -5575,42 +5614,47 @@ const ColorPicker = ({ size = 'm', type = 'dropdown', position = 'bottom-left',
5575
5614
  setV(hsv.v);
5576
5615
  setA(Math.round(alpha * 100));
5577
5616
  setAlphaInput(String(Math.round(alpha * 100)));
5578
- setColorInput(`rgba(${r}, ${g}, ${b}, ${alpha})`.toUpperCase());
5617
+ setColorInput(`rgba(${r}, ${g}, ${b}, ${alpha})`);
5579
5618
  return;
5580
5619
  }
5581
- setColorInput(formatted.toUpperCase());
5582
- }, [colorInput, formatted]);
5583
- const onColorKeyDown = (e) => {
5584
- if (e.key === 'Enter')
5585
- commitColorInput();
5620
+ // 인식 실패 → 표시값으로 원복
5621
+ setColorInput(format === 'hex' ? normalizeHex(uiFormatted) : uiFormatted);
5622
+ }, [colorInput, uiFormatted, format]);
5623
+ const onColorKeyDown = (e) => { if (e.key === 'Enter')
5624
+ commitColorInput(); };
5625
+ const onColorBlur = () => {
5626
+ const next = format === 'hex' ? normalizeHex(uiFormatted) : uiFormatted;
5627
+ if (colorInput !== next)
5628
+ setColorInput(next);
5586
5629
  };
5587
- const onColorBlur = () => setColorInput(formatted.toUpperCase());
5588
- /** 알파 인풋 (엔터 확정) */
5630
+ /** 알파 인풋 확정 */
5589
5631
  const commitAlphaInput = React.useCallback(() => {
5590
5632
  const n = Number(alphaInput.trim());
5591
5633
  if (!Number.isNaN(n) && n >= 0 && n <= 100) {
5592
- setA(Math.round(n));
5593
- setAlphaInput(String(Math.round(n)));
5634
+ const rounded = Math.round(n);
5635
+ if (a !== rounded)
5636
+ setA(rounded);
5637
+ if (alphaInput !== String(rounded))
5638
+ setAlphaInput(String(rounded));
5594
5639
  return;
5595
5640
  }
5596
5641
  setAlphaInput(String(a));
5597
5642
  }, [alphaInput, a]);
5598
- const onAlphaInputKeyDown = (e) => {
5599
- if (e.key === 'Enter')
5600
- commitAlphaInput();
5601
- };
5602
- const onAlphaInputBlur = () => setAlphaInput(String(a));
5643
+ const onAlphaInputKeyDown = (e) => { if (e.key === 'Enter')
5644
+ commitAlphaInput(); };
5645
+ const onAlphaInputBlur = () => { if (alphaInput !== String(a))
5646
+ setAlphaInput(String(a)); };
5603
5647
  /** 복사 */
5604
5648
  const onCopy = React.useCallback(async () => {
5605
5649
  try {
5606
- await navigator.clipboard.writeText(formatted);
5650
+ await navigator.clipboard.writeText(uiFormatted);
5607
5651
  setIsCopied(true);
5608
5652
  setTimeout(() => setIsCopied(false), 1600);
5609
5653
  }
5610
5654
  catch (e) {
5611
5655
  console.error(e);
5612
5656
  }
5613
- }, [formatted]);
5657
+ }, [uiFormatted]);
5614
5658
  /** EyeDropper */
5615
5659
  const onEyedrop = React.useCallback(async () => {
5616
5660
  try {
@@ -5628,7 +5672,7 @@ const ColorPicker = ({ size = 'm', type = 'dropdown', position = 'bottom-left',
5628
5672
  console.error(e);
5629
5673
  }
5630
5674
  }, []);
5631
- /** modal open(중요: formatted deps 제거) */
5675
+ /** 모달 */
5632
5676
  const handleModalOpen = React.useCallback(() => {
5633
5677
  if (type === 'modal')
5634
5678
  setTempColor(hex);
@@ -5636,10 +5680,11 @@ const ColorPicker = ({ size = 'm', type = 'dropdown', position = 'bottom-left',
5636
5680
  }, [type, hex]);
5637
5681
  const handleModalApply = React.useCallback(() => {
5638
5682
  if (type === 'modal') {
5639
- onApply?.(formatted);
5683
+ const out = onChangeFormat === 'hex' ? hex : uiFormatted;
5684
+ onApply?.(out);
5640
5685
  setIsOpen(false);
5641
5686
  }
5642
- }, [type, formatted, onApply]);
5687
+ }, [type, hex, uiFormatted, onApply, onChangeFormat]);
5643
5688
  const handleModalCancel = React.useCallback(() => {
5644
5689
  if (type === 'modal') {
5645
5690
  const rgb = hexToRgb(tempColor);
@@ -5656,28 +5701,28 @@ const ColorPicker = ({ size = 'm', type = 'dropdown', position = 'bottom-left',
5656
5701
  /** 스타일 */
5657
5702
  const hueTrackStyle = React.useMemo(() => ({
5658
5703
  background: `linear-gradient(to right,
5659
- hsl(0,100%,50%),
5660
- hsl(60,100%,50%),
5661
- hsl(120,100%,50%),
5662
- hsl(180,100%,50%),
5663
- hsl(240,100%,50%),
5664
- hsl(300,100%,50%),
5665
- hsl(360,100%,50%))`,
5704
+ hsl(0,100%,50%),
5705
+ hsl(60,100%,50%),
5706
+ hsl(120,100%,50%),
5707
+ hsl(180,100%,50%),
5708
+ hsl(240,100%,50%),
5709
+ hsl(300,100%,50%),
5710
+ hsl(360,100%,50%))`,
5666
5711
  }), []);
5667
5712
  const areaBackground = React.useMemo(() => ({
5668
5713
  backgroundImage: `
5669
- linear-gradient(to top, rgba(0,0,0,1), rgba(0,0,0,0)),
5670
- linear-gradient(to right, #ffffff, hsl(${h}, 100%, 50%))
5671
- `,
5714
+ linear-gradient(to top, rgba(0,0,0,1), rgba(0,0,0,0)),
5715
+ linear-gradient(to right, #ffffff, hsl(${h}, 100%, 50%))
5716
+ `,
5672
5717
  }), [h]);
5673
5718
  const alphaTrackStyle = React.useMemo(() => ({
5674
5719
  backgroundImage: `
5675
- linear-gradient(45deg, var(--db-border-base) 25%, transparent 25%),
5676
- linear-gradient(-45deg, var(--db-border-base) 25%, transparent 25%),
5677
- linear-gradient(45deg, transparent 75%, var(--db-border-base) 75%),
5678
- linear-gradient(-45deg, transparent 75%, var(--db-border-base) 75%),
5679
- linear-gradient(to right, rgba(${rgb.r}, ${rgb.g}, ${rgb.b}, 0), rgba(${rgb.r}, ${rgb.g}, ${rgb.b}, 1))
5680
- `,
5720
+ linear-gradient(45deg, var(--db-border-base) 25%, transparent 25%),
5721
+ linear-gradient(-45deg, var(--db-border-base) 25%, transparent 25%),
5722
+ linear-gradient(45deg, transparent 75%, var(--db-border-base) 75%),
5723
+ linear-gradient(-45deg, transparent 75%, var(--db-border-base) 75%),
5724
+ linear-gradient(to right, rgba(${rgb.r}, ${rgb.g}, ${rgb.b}, 0), rgba(${rgb.r}, ${rgb.g}, ${rgb.b}, 1))
5725
+ `,
5681
5726
  backgroundSize: '8px 8px,8px 8px,8px 8px,8px 8px,100% 100%',
5682
5727
  backgroundPosition: '0 0,0 4px,4px -4px,-4px 0,0 0',
5683
5728
  backgroundColor: 'var(--db-surface-base)',
@@ -5689,9 +5734,7 @@ const ColorPicker = ({ size = 'm', type = 'dropdown', position = 'bottom-left',
5689
5734
  'designbase-color-picker--no-input': !showInput,
5690
5735
  }, className);
5691
5736
  const Trigger = (jsxRuntime.jsxs("div", { className: "designbase-color-picker__trigger", onClick: () => !disabled && !readonly && (type === 'modal' ? handleModalOpen() : setIsOpen(v => !v)), children: [jsxRuntime.jsx("div", { className: "designbase-color-picker__color-display", children: jsxRuntime.jsx("div", { className: "designbase-color-picker__color-box", style: {
5692
- backgroundColor: showAlpha
5693
- ? `rgba(${rgb.r}, ${rgb.g}, ${rgb.b}, ${a / 100})`
5694
- : hex
5737
+ backgroundColor: showAlpha ? `rgba(${rgb.r}, ${rgb.g}, ${rgb.b}, ${a / 100})` : hex
5695
5738
  } }) }), showInput && (jsxRuntime.jsx("input", { type: "text", value: colorInput, onChange: (e) => setColorInput(e.target.value), onKeyDown: onColorKeyDown, onBlur: onColorBlur, onClick: (e) => e.stopPropagation(), disabled: disabled, readOnly: readonly, className: "designbase-color-picker__input", placeholder: "#000000" })), showInput && showCopyButton && (jsxRuntime.jsx("button", { type: "button", className: "designbase-color-picker__copy-button-inline", onClick: (e) => { e.stopPropagation(); onCopy(); }, disabled: disabled, "aria-label": "Copy color value", children: isCopied ? jsxRuntime.jsx(icons.DoneIcon, { size: 14 }) : jsxRuntime.jsx(icons.CopyIcon, { size: 14 }) })), jsxRuntime.jsx("button", { type: "button", className: "designbase-color-picker__toggle", disabled: disabled, "aria-label": "Toggle color picker", children: jsxRuntime.jsx(icons.ChevronDownIcon, { size: 16 }) })] }));
5696
5739
  const Selector = (jsxRuntime.jsxs("div", { className: "designbase-color-picker__selector", children: [jsxRuntime.jsx("div", { className: "designbase-color-picker__color-area", children: jsxRuntime.jsx("div", { ref: areaRef, className: "designbase-color-picker__color-field", style: areaBackground, onMouseDown: onAreaMouseDown, onMouseMove: onAreaMouseMove, onMouseUp: onAreaMouseUp, onMouseLeave: onAreaLeave, onTouchStart: onAreaTouchStart, onTouchMove: onAreaTouchMove, onTouchEnd: onAreaTouchEnd, children: jsxRuntime.jsx("div", { className: "designbase-color-picker__color-pointer", style: { left: `${s}%`, top: `${100 - v}%`, backgroundColor: `rgb(${rgb.r}, ${rgb.g}, ${rgb.b})` } }) }) }), jsxRuntime.jsxs("div", { className: "designbase-color-picker__controls", children: [jsxRuntime.jsx(Button, { variant: "tertiary", size: "m", iconOnly: true, onClick: onEyedrop, "aria-label": "Eyedropper tool", children: jsxRuntime.jsx(icons.EyedropperIcon, {}) }), jsxRuntime.jsxs("div", { className: "designbase-color-picker__slider-container", children: [jsxRuntime.jsx("div", { className: "designbase-color-picker__hue-slider", children: jsxRuntime.jsx("input", { type: "range", min: 0, max: 360, value: h, onChange: onHueChange, className: "designbase-color-picker__slider designbase-color-picker__slider--hue", style: hueTrackStyle }) }), showAlpha && (jsxRuntime.jsx("div", { className: "designbase-color-picker__alpha-slider", children: jsxRuntime.jsx("input", { type: "range", min: 0, max: 100, value: a, onChange: onAlphaChange, className: "designbase-color-picker__slider designbase-color-picker__slider--alpha", style: alphaTrackStyle }) }))] })] }), jsxRuntime.jsxs("div", { className: "designbase-color-picker__value-display", children: [showFormatSelector && (jsxRuntime.jsx(Select, { value: format, onChange: (v) => setFormat(v), showClearButton: false, options: [
5697
5740
  { label: 'HEX', value: 'hex' },