@designbasekorea/ui 0.2.20 → 0.2.22

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
@@ -5405,20 +5405,6 @@ const ColorPicker = ({ size = 'm', type = 'dropdown', position = 'bottom-left',
5405
5405
  const newColor = hslToHex(newHue, saturation, lightness);
5406
5406
  handleColorChange(newColor);
5407
5407
  };
5408
- // Saturation 슬라이더 변경
5409
- const handleSaturationChange = (e) => {
5410
- const newSaturation = parseInt(e.target.value);
5411
- setSaturation(newSaturation);
5412
- const newColor = hslToHex(hue, newSaturation, lightness);
5413
- handleColorChange(newColor);
5414
- };
5415
- // Lightness 슬라이더 변경
5416
- const handleLightnessChange = (e) => {
5417
- const newLightness = parseInt(e.target.value);
5418
- setLightness(newLightness);
5419
- const newColor = hslToHex(hue, saturation, newLightness);
5420
- handleColorChange(newColor);
5421
- };
5422
5408
  // Alpha 슬라이더 변경
5423
5409
  const handleAlphaChange = (e) => {
5424
5410
  const newAlpha = parseInt(e.target.value);
@@ -5541,25 +5527,54 @@ const ColorPicker = ({ size = 'm', type = 'dropdown', position = 'bottom-left',
5541
5527
  'designbase-color-picker--open': isOpen,
5542
5528
  'designbase-color-picker--no-input': !showInput,
5543
5529
  }, className);
5530
+ // 메인 컬러 선택 영역 클릭 핸들러
5531
+ const handleColorAreaClick = (e) => {
5532
+ const rect = e.currentTarget.getBoundingClientRect();
5533
+ const x = e.clientX - rect.left;
5534
+ const y = e.clientY - rect.top;
5535
+ // 좌측은 채도 낮고, 우측은 채도 최대치
5536
+ const saturation = Math.round((x / rect.width) * 100);
5537
+ // 위로는 밝기 최대, 아래로는 밝기 어둡게
5538
+ const lightness = Math.round(100 - (y / rect.height) * 100);
5539
+ setSaturation(Math.max(0, Math.min(100, saturation)));
5540
+ setLightness(Math.max(0, Math.min(100, lightness)));
5541
+ const newColor = hslToHex(hue, saturation, lightness);
5542
+ handleColorChange(newColor);
5543
+ };
5544
+ // 스포이드 기능 (색상 추출)
5545
+ const handleEyedropperClick = async () => {
5546
+ try {
5547
+ // EyeDropper API 지원 확인
5548
+ if ('EyeDropper' in window) {
5549
+ const eyeDropper = new window.EyeDropper();
5550
+ const result = await eyeDropper.open();
5551
+ const hexColor = result.sRGBHex;
5552
+ handleColorChange(hexColor);
5553
+ updateHSLFromHex(hexColor);
5554
+ }
5555
+ else {
5556
+ // EyeDropper API가 지원되지 않는 경우 대체 기능
5557
+ console.log('EyeDropper API is not supported in this browser');
5558
+ // 여기에 대체 기능을 구현할 수 있습니다
5559
+ }
5560
+ }
5561
+ catch (err) {
5562
+ console.error('EyeDropper failed:', err);
5563
+ }
5564
+ };
5544
5565
  // 컬러 선택 UI
5545
- const renderColorSelector = () => (jsxRuntime.jsxs("div", { className: "designbase-color-picker__selector", children: [showFormatSelector && (jsxRuntime.jsx("div", { className: "designbase-color-picker__format-selector", children: ['hex', 'rgb', 'rgba', 'hsl', 'hsla'].map((format) => (jsxRuntime.jsx("button", { type: "button", className: clsx('designbase-color-picker__format-button', { 'designbase-color-picker__format-button--active': colorFormat === format }), onClick: () => setColorFormat(format), children: format.toUpperCase() }, format))) })), jsxRuntime.jsxs("div", { className: "designbase-color-picker__sliders", children: [jsxRuntime.jsxs("div", { className: "designbase-color-picker__slider-group", children: [jsxRuntime.jsxs("label", { className: "designbase-color-picker__slider-label", children: ["Hue ", jsxRuntime.jsxs("span", { className: "designbase-color-picker__slider-value", children: [hue, "\u00B0"] })] }), jsxRuntime.jsx("input", { type: "range", min: "0", max: "360", value: hue, onChange: handleHueChange, className: "designbase-color-picker__slider designbase-color-picker__slider--hue" })] }), jsxRuntime.jsxs("div", { className: "designbase-color-picker__slider-group", children: [jsxRuntime.jsxs("label", { className: "designbase-color-picker__slider-label", children: ["Saturation ", jsxRuntime.jsxs("span", { className: "designbase-color-picker__slider-value", children: [saturation, "%"] })] }), jsxRuntime.jsx("input", { type: "range", min: "0", max: "100", value: saturation, onChange: handleSaturationChange, className: "designbase-color-picker__slider designbase-color-picker__slider--saturation", style: {
5546
- background: `linear-gradient(to right,
5547
- hsl(${hue}, 0%, ${lightness}%),
5548
- hsl(${hue}, 100%, ${lightness}%))`
5549
- } })] }), jsxRuntime.jsxs("div", { className: "designbase-color-picker__slider-group", children: [jsxRuntime.jsxs("label", { className: "designbase-color-picker__slider-label", children: ["Lightness ", jsxRuntime.jsxs("span", { className: "designbase-color-picker__slider-value", children: [lightness, "%"] })] }), jsxRuntime.jsx("input", { type: "range", min: "0", max: "100", value: lightness, onChange: handleLightnessChange, className: "designbase-color-picker__slider designbase-color-picker__slider--lightness", style: {
5550
- background: `linear-gradient(to right,
5551
- hsl(${hue}, ${saturation}%, 0%),
5552
- hsl(${hue}, ${saturation}%, 50%),
5553
- hsl(${hue}, ${saturation}%, 100%))`
5554
- } })] }), showAlpha && (jsxRuntime.jsxs("div", { className: "designbase-color-picker__slider-group", children: [jsxRuntime.jsxs("label", { className: "designbase-color-picker__slider-label", children: ["Alpha ", jsxRuntime.jsxs("span", { className: "designbase-color-picker__slider-value", children: [alpha, "%"] })] }), jsxRuntime.jsx("input", { type: "range", min: "0", max: "100", value: alpha, onChange: handleAlphaChange, className: "designbase-color-picker__slider designbase-color-picker__slider--alpha", style: {
5555
- background: `linear-gradient(to right,
5556
- transparent,
5557
- hsl(${hue}, ${saturation}%, ${lightness}%))`
5558
- } })] }))] }), jsxRuntime.jsxs("div", { className: "designbase-color-picker__preview", children: [jsxRuntime.jsx("div", { className: "designbase-color-picker__preview-box", style: {
5559
- backgroundColor: showAlpha
5560
- ? `hsla(${hue}, ${saturation}%, ${lightness}%, ${alpha / 100})`
5561
- : `hsl(${hue}, ${saturation}%, ${lightness}%)`
5562
- } }), jsxRuntime.jsxs("div", { className: "designbase-color-picker__preview-info", children: [jsxRuntime.jsx("div", { className: "designbase-color-picker__preview-value", children: getFormattedColor() }), showCopyButton && (jsxRuntime.jsx("button", { type: "button", className: "designbase-color-picker__copy-button", onClick: handleCopy, "aria-label": "Copy color value", children: isCopied ? jsxRuntime.jsx(icons.DoneIcon, { size: 14 }) : jsxRuntime.jsx(icons.CopyIcon, { size: 14 }) }))] })] })] }));
5566
+ const renderColorSelector = () => (jsxRuntime.jsxs("div", { className: "designbase-color-picker__selector", children: [jsxRuntime.jsx("div", { className: "designbase-color-picker__color-area", children: jsxRuntime.jsx("div", { className: "designbase-color-picker__color-field", style: {
5567
+ background: `linear-gradient(to right,
5568
+ hsl(${hue}, 0%, 50%),
5569
+ hsl(${hue}, 100%, 50%)),
5570
+ linear-gradient(to bottom,
5571
+ hsl(${hue}, 100%, 100%),
5572
+ hsl(${hue}, 100%, 0%))`
5573
+ }, onClick: handleColorAreaClick, children: jsxRuntime.jsx("div", { className: "designbase-color-picker__color-pointer", style: {
5574
+ left: `${saturation}%`,
5575
+ top: `${100 - lightness}%`,
5576
+ backgroundColor: `hsl(${hue}, ${saturation}%, ${lightness}%)`
5577
+ } }) }) }), jsxRuntime.jsxs("div", { className: "designbase-color-picker__controls", children: [jsxRuntime.jsx("button", { type: "button", className: "designbase-color-picker__eyedropper", onClick: handleEyedropperClick, "aria-label": "Eyedropper tool", children: jsxRuntime.jsx(icons.PaletteIcon, { size: 16 }) }), jsxRuntime.jsx("div", { className: "designbase-color-picker__hue-slider", children: jsxRuntime.jsx("input", { type: "range", min: "0", max: "360", value: hue, onChange: handleHueChange, className: "designbase-color-picker__slider designbase-color-picker__slider--hue" }) }), showAlpha && (jsxRuntime.jsx("div", { className: "designbase-color-picker__alpha-slider", children: jsxRuntime.jsx("input", { type: "range", min: "0", max: "100", value: alpha, onChange: handleAlphaChange, className: "designbase-color-picker__slider designbase-color-picker__slider--alpha" }) }))] }), jsxRuntime.jsxs("div", { className: "designbase-color-picker__value-display", children: [showFormatSelector && (jsxRuntime.jsxs("select", { className: "designbase-color-picker__format-select", value: colorFormat, onChange: (e) => setColorFormat(e.target.value), children: [jsxRuntime.jsx("option", { value: "hex", children: "HEX" }), jsxRuntime.jsx("option", { value: "rgb", children: "RGB" }), jsxRuntime.jsx("option", { value: "rgba", children: "RGBA" }), jsxRuntime.jsx("option", { value: "hsl", children: "HSL" }), jsxRuntime.jsx("option", { value: "hsla", children: "HSLA" })] })), jsxRuntime.jsx("input", { type: "text", value: inputValue, onChange: handleInputChange, onBlur: handleInputBlur, className: "designbase-color-picker__value-input", placeholder: "#000000" }), showAlpha && (jsxRuntime.jsxs("span", { className: "designbase-color-picker__alpha-percent", children: [alpha, "%"] })), showCopyButton && (jsxRuntime.jsx("button", { type: "button", className: "designbase-color-picker__copy-button", onClick: handleCopy, "aria-label": "Copy color value", children: isCopied ? jsxRuntime.jsx(icons.DoneIcon, { size: 14 }) : jsxRuntime.jsx(icons.CopyIcon, { size: 14 }) }))] })] }));
5563
5578
  return (jsxRuntime.jsxs("div", { ref: pickerRef, className: classes, children: [jsxRuntime.jsxs("div", { className: "designbase-color-picker__trigger", children: [jsxRuntime.jsx("div", { className: "designbase-color-picker__color-display", onClick: togglePicker, children: jsxRuntime.jsx("div", { className: "designbase-color-picker__color-box", style: {
5564
5579
  backgroundColor: showAlpha
5565
5580
  ? `hsla(${hue}, ${saturation}%, ${lightness}%, ${alpha / 100})`