@designbasekorea/ui 0.2.26 → 0.2.28

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
@@ -4058,7 +4058,7 @@ const Checkbox = React.forwardRef(({ isSelected, defaultSelected, isIndeterminat
4058
4058
  });
4059
4059
  Checkbox.displayName = 'Checkbox';
4060
4060
 
4061
- const Select = ({ value, defaultValue, options, label, placeholder = '선택하세요', multiple = false, searchable = false, disabled = false, readOnly = false, required = false, error = false, errorMessage, helperText, size = 'm', fullWidth = false, dropdownWidth = 'auto', maxHeight = 200, showClearButton = true, className, onChange, onFocus, onBlur, ...props }) => {
4061
+ const Select = ({ value, defaultValue, options, label, placeholder = '선택하세요', multiple = false, searchable = false, disabled = false, readOnly = false, required = false, error = false, errorMessage, helperText, size = 'm', fullWidth = false, dropdownWidth = 'auto', position = 'bottom', maxHeight = 200, showClearButton = true, className, onChange, onFocus, onBlur, ...props }) => {
4062
4062
  const [isOpen, setIsOpen] = React.useState(false);
4063
4063
  const [selectedValue, setSelectedValue] = React.useState(value ?? defaultValue ?? (multiple ? [] : ''));
4064
4064
  const [searchTerm, setSearchTerm] = React.useState('');
@@ -4216,7 +4216,7 @@ const Select = ({ value, defaultValue, options, label, placeholder = '선택하
4216
4216
  const triggerClasses = clsx('designbase-select__trigger', {
4217
4217
  'designbase-select__trigger--focused': isOpen,
4218
4218
  });
4219
- const dropdownClasses = clsx('designbase-select__dropdown', `designbase-select__dropdown--${dropdownWidth}`, {
4219
+ const dropdownClasses = clsx('designbase-select__dropdown', `designbase-select__dropdown--${dropdownWidth}`, `designbase-select__dropdown--${position}`, {
4220
4220
  'designbase-select__dropdown--open': isOpen,
4221
4221
  });
4222
4222
  const filteredOptions = getFilteredOptions();
@@ -5479,12 +5479,14 @@ const ColorPicker = ({ size = 'm', type = 'dropdown', position = 'bottom-left',
5479
5479
  return; const t = e.touches[0]; updateFromArea(t.clientX, t.clientY); };
5480
5480
  const onAreaTouchEnd = () => { dragging.current = false; };
5481
5481
  /** 슬라이더 */
5482
- const onHueChange = (e) => setH(parseInt(e.target.value, 10));
5483
- const onAlphaChange = (e) => {
5482
+ const onHueChange = React.useCallback((e) => {
5483
+ setH(parseInt(e.target.value, 10));
5484
+ }, []);
5485
+ const onAlphaChange = React.useCallback((e) => {
5484
5486
  const newAlpha = parseInt(e.target.value, 10);
5485
5487
  setA(newAlpha);
5486
5488
  setAlphaInput(String(newAlpha)); // 실시간 동기화
5487
- };
5489
+ }, []);
5488
5490
  /** 컬러 인풋: 엔터로만 확정 */
5489
5491
  const tryCommitColorInput = () => {
5490
5492
  const str = colorInput.trim();
@@ -5553,7 +5555,7 @@ const ColorPicker = ({ size = 'm', type = 'dropdown', position = 'bottom-left',
5553
5555
  setAlphaInput(String(a));
5554
5556
  };
5555
5557
  /** 복사 */
5556
- const onCopy = async () => {
5558
+ const onCopy = React.useCallback(async () => {
5557
5559
  try {
5558
5560
  await navigator.clipboard.writeText(formatted);
5559
5561
  setIsCopied(true);
@@ -5562,9 +5564,9 @@ const ColorPicker = ({ size = 'm', type = 'dropdown', position = 'bottom-left',
5562
5564
  catch (e) {
5563
5565
  console.error(e);
5564
5566
  }
5565
- };
5567
+ }, [formatted]);
5566
5568
  /** EyeDropper */
5567
- const onEyedrop = async () => {
5569
+ const onEyedrop = React.useCallback(async () => {
5568
5570
  try {
5569
5571
  if ('EyeDropper' in window) {
5570
5572
  const eye = new window.EyeDropper();
@@ -5582,21 +5584,21 @@ const ColorPicker = ({ size = 'm', type = 'dropdown', position = 'bottom-left',
5582
5584
  catch (e) {
5583
5585
  console.error(e);
5584
5586
  }
5585
- };
5587
+ }, []);
5586
5588
  /** 모달용 핸들러 */
5587
- const handleModalOpen = () => {
5589
+ const handleModalOpen = React.useCallback(() => {
5588
5590
  if (type === 'modal') {
5589
5591
  setTempColor(formatted);
5590
5592
  }
5591
5593
  setIsOpen(true);
5592
- };
5593
- const handleModalApply = () => {
5594
+ }, [type, formatted]);
5595
+ const handleModalApply = React.useCallback(() => {
5594
5596
  if (type === 'modal') {
5595
5597
  onApply?.(formatted);
5596
5598
  setIsOpen(false);
5597
5599
  }
5598
- };
5599
- const handleModalCancel = () => {
5600
+ }, [type, formatted, onApply]);
5601
+ const handleModalCancel = React.useCallback(() => {
5600
5602
  if (type === 'modal') {
5601
5603
  // 원래 색상으로 복원
5602
5604
  const rgb = hexToRgb(tempColor);
@@ -5609,9 +5611,9 @@ const ColorPicker = ({ size = 'm', type = 'dropdown', position = 'bottom-left',
5609
5611
  onCancel?.();
5610
5612
  setIsOpen(false);
5611
5613
  }
5612
- };
5614
+ }, [type, tempColor, onCancel]);
5613
5615
  /** 배경 스타일 */
5614
- const hueTrackStyle = {
5616
+ const hueTrackStyle = React.useMemo(() => ({
5615
5617
  background: `linear-gradient(to right,
5616
5618
  hsl(0,100%,50%),
5617
5619
  hsl(60,100%,50%),
@@ -5620,15 +5622,15 @@ const ColorPicker = ({ size = 'm', type = 'dropdown', position = 'bottom-left',
5620
5622
  hsl(240,100%,50%),
5621
5623
  hsl(300,100%,50%),
5622
5624
  hsl(360,100%,50%))`,
5623
- };
5624
- const areaBackground = {
5625
+ }), []);
5626
+ const areaBackground = React.useMemo(() => ({
5625
5627
  backgroundImage: `
5626
5628
  linear-gradient(to top, rgba(0,0,0,1), rgba(0,0,0,0)),
5627
5629
  linear-gradient(to right, #ffffff, hsl(${h}, 100%, 50%))
5628
5630
  `,
5629
- };
5631
+ }), [h]);
5630
5632
  /** ✔︎ 알파 트랙: 색상 무관, 고정 흑백 그라디언트 */
5631
- const alphaTrackStyle = {
5633
+ const alphaTrackStyle = React.useMemo(() => ({
5632
5634
  backgroundImage: `
5633
5635
  linear-gradient(45deg, var(--db-border-base) 25%, transparent 25%),
5634
5636
  linear-gradient(-45deg, var(--db-border-base) 25%, transparent 25%),
@@ -5639,7 +5641,7 @@ const ColorPicker = ({ size = 'm', type = 'dropdown', position = 'bottom-left',
5639
5641
  backgroundSize: '8px 8px,8px 8px,8px 8px,8px 8px,100% 100%',
5640
5642
  backgroundPosition: '0 0,0 4px,4px -4px,-4px 0,0 0',
5641
5643
  backgroundColor: 'var(--db-surface-base)',
5642
- };
5644
+ }), []);
5643
5645
  const classes = clsx('designbase-color-picker', `designbase-color-picker--${size}`, `designbase-color-picker--${position}`, {
5644
5646
  'designbase-color-picker--disabled': disabled,
5645
5647
  'designbase-color-picker--readonly': readonly,
@@ -5653,8 +5655,8 @@ const ColorPicker = ({ size = 'm', type = 'dropdown', position = 'bottom-left',
5653
5655
  { label: 'RGBA', value: 'rgba' },
5654
5656
  { label: 'HSL', value: 'hsl' },
5655
5657
  { label: 'HSLA', value: 'hsla' },
5656
- ], size: "s" })), jsxRuntime.jsx(Input, { type: "text", value: colorInput, onChange: setColorInput, onKeyDown: onColorKeyDown, onBlur: onColorBlur, placeholder: "#000000", size: "s", className: "designbase-color-picker__value-input" }), showAlpha && (jsxRuntime.jsxs("div", { className: "designbase-color-picker__alpha-input-wrap", children: [jsxRuntime.jsx(Input, { type: "text", inputMode: "numeric", value: alphaInput, onChange: (value) => setAlphaInput(value.replace(/[^\d]/g, '').slice(0, 3)), onKeyDown: onAlphaInputKeyDown, onBlur: onAlphaInputBlur, placeholder: "100", size: "s", className: "designbase-color-picker__alpha-input", "aria-label": "Alpha percent" }), jsxRuntime.jsx("span", { className: "designbase-color-picker__alpha-suffix", children: "%" })] })), showCopyButton && (jsxRuntime.jsx(Button, { variant: "tertiary", size: "m", iconOnly: true, onClick: onCopy, "aria-label": "Copy color value", children: isCopied ? jsxRuntime.jsx(icons.DoneIcon, {}) : jsxRuntime.jsx(icons.CopyIcon, {}) }))] })] }));
5657
- return (jsxRuntime.jsxs("div", { ref: pickerRef, className: classes, children: [Trigger, type === 'dropdown' && isOpen && (jsxRuntime.jsx("div", { className: "designbase-color-picker__dropdown", onClick: (e) => e.stopPropagation(), children: Selector })), type === 'modal' && (jsxRuntime.jsxs(Modal, { isOpen: isOpen, onClose: handleModalCancel, title: "\uC0C9\uC0C1 \uC120\uD0DD", size: "s", children: [Selector, jsxRuntime.jsx(ModalFooter, { children: jsxRuntime.jsxs("div", { style: { display: 'flex', gap: '8px', justifyContent: 'flex-end' }, children: [jsxRuntime.jsx(Button, { variant: "secondary", size: "s", onClick: handleModalCancel, children: "\uCDE8\uC18C" }), jsxRuntime.jsx(Button, { variant: "primary", size: "s", onClick: handleModalApply, children: "\uC801\uC6A9" })] }) })] }))] }));
5658
+ ], size: "s", position: "top" })), jsxRuntime.jsx(Input, { type: "text", value: colorInput, onChange: setColorInput, onKeyDown: onColorKeyDown, onBlur: onColorBlur, placeholder: "#000000", size: "s", className: "designbase-color-picker__value-input" }), showAlpha && (jsxRuntime.jsxs("div", { className: "designbase-color-picker__alpha-input-wrap", children: [jsxRuntime.jsx(Input, { type: "text", inputMode: "numeric", value: alphaInput, onChange: (value) => setAlphaInput(value.replace(/[^\d]/g, '').slice(0, 3)), onKeyDown: onAlphaInputKeyDown, onBlur: onAlphaInputBlur, placeholder: "100", size: "s", className: "designbase-color-picker__alpha-input", "aria-label": "Alpha percent" }), jsxRuntime.jsx("span", { className: "designbase-color-picker__alpha-suffix", children: "%" })] })), showCopyButton && (jsxRuntime.jsx(Button, { variant: "tertiary", size: "m", iconOnly: true, onClick: onCopy, "aria-label": "Copy color value", children: isCopied ? jsxRuntime.jsx(icons.DoneIcon, {}) : jsxRuntime.jsx(icons.CopyIcon, {}) }))] })] }));
5659
+ return (jsxRuntime.jsxs("div", { ref: pickerRef, className: classes, children: [Trigger, type === 'dropdown' && isOpen && (jsxRuntime.jsx("div", { className: "designbase-color-picker__dropdown", onClick: (e) => e.stopPropagation(), children: Selector })), type === 'modal' && (jsxRuntime.jsxs(Modal, { isOpen: isOpen, onClose: handleModalCancel, title: "\uC0C9\uC0C1 \uC120\uD0DD", size: "s", children: [jsxRuntime.jsx(ModalBody, { children: Selector }), jsxRuntime.jsx(ModalFooter, { children: jsxRuntime.jsxs("div", { style: { display: 'flex', gap: '8px', justifyContent: 'flex-end' }, children: [jsxRuntime.jsx(Button, { variant: "tertiary", size: "s", onClick: handleModalCancel, children: "\uCDE8\uC18C" }), jsxRuntime.jsx(Button, { variant: "primary", size: "s", onClick: handleModalApply, children: "\uC801\uC6A9" })] }) })] }))] }));
5658
5660
  };
5659
5661
  ColorPicker.displayName = 'ColorPicker';
5660
5662