@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.css +1 -1
- package/dist/index.css.map +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.esm.css +1 -1
- package/dist/index.esm.css.map +1 -1
- package/dist/index.esm.js +25 -23
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +25 -23
- package/dist/index.js.map +1 -1
- package/dist/index.umd.css +1 -1
- package/dist/index.umd.css.map +1 -1
- package/dist/index.umd.js +25 -23
- package/dist/index.umd.js.map +1 -1
- package/package.json +1 -1
package/dist/index.umd.js
CHANGED
|
@@ -4057,7 +4057,7 @@
|
|
|
4057
4057
|
});
|
|
4058
4058
|
Checkbox.displayName = 'Checkbox';
|
|
4059
4059
|
|
|
4060
|
-
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 }) => {
|
|
4060
|
+
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 }) => {
|
|
4061
4061
|
const [isOpen, setIsOpen] = React.useState(false);
|
|
4062
4062
|
const [selectedValue, setSelectedValue] = React.useState(value ?? defaultValue ?? (multiple ? [] : ''));
|
|
4063
4063
|
const [searchTerm, setSearchTerm] = React.useState('');
|
|
@@ -4215,7 +4215,7 @@
|
|
|
4215
4215
|
const triggerClasses = clsx('designbase-select__trigger', {
|
|
4216
4216
|
'designbase-select__trigger--focused': isOpen,
|
|
4217
4217
|
});
|
|
4218
|
-
const dropdownClasses = clsx('designbase-select__dropdown', `designbase-select__dropdown--${dropdownWidth}`, {
|
|
4218
|
+
const dropdownClasses = clsx('designbase-select__dropdown', `designbase-select__dropdown--${dropdownWidth}`, `designbase-select__dropdown--${position}`, {
|
|
4219
4219
|
'designbase-select__dropdown--open': isOpen,
|
|
4220
4220
|
});
|
|
4221
4221
|
const filteredOptions = getFilteredOptions();
|
|
@@ -5478,12 +5478,14 @@
|
|
|
5478
5478
|
return; const t = e.touches[0]; updateFromArea(t.clientX, t.clientY); };
|
|
5479
5479
|
const onAreaTouchEnd = () => { dragging.current = false; };
|
|
5480
5480
|
/** 슬라이더 */
|
|
5481
|
-
const onHueChange = (e) =>
|
|
5482
|
-
|
|
5481
|
+
const onHueChange = React.useCallback((e) => {
|
|
5482
|
+
setH(parseInt(e.target.value, 10));
|
|
5483
|
+
}, []);
|
|
5484
|
+
const onAlphaChange = React.useCallback((e) => {
|
|
5483
5485
|
const newAlpha = parseInt(e.target.value, 10);
|
|
5484
5486
|
setA(newAlpha);
|
|
5485
5487
|
setAlphaInput(String(newAlpha)); // 실시간 동기화
|
|
5486
|
-
};
|
|
5488
|
+
}, []);
|
|
5487
5489
|
/** 컬러 인풋: 엔터로만 확정 */
|
|
5488
5490
|
const tryCommitColorInput = () => {
|
|
5489
5491
|
const str = colorInput.trim();
|
|
@@ -5552,7 +5554,7 @@
|
|
|
5552
5554
|
setAlphaInput(String(a));
|
|
5553
5555
|
};
|
|
5554
5556
|
/** 복사 */
|
|
5555
|
-
const onCopy = async () => {
|
|
5557
|
+
const onCopy = React.useCallback(async () => {
|
|
5556
5558
|
try {
|
|
5557
5559
|
await navigator.clipboard.writeText(formatted);
|
|
5558
5560
|
setIsCopied(true);
|
|
@@ -5561,9 +5563,9 @@
|
|
|
5561
5563
|
catch (e) {
|
|
5562
5564
|
console.error(e);
|
|
5563
5565
|
}
|
|
5564
|
-
};
|
|
5566
|
+
}, [formatted]);
|
|
5565
5567
|
/** EyeDropper */
|
|
5566
|
-
const onEyedrop = async () => {
|
|
5568
|
+
const onEyedrop = React.useCallback(async () => {
|
|
5567
5569
|
try {
|
|
5568
5570
|
if ('EyeDropper' in window) {
|
|
5569
5571
|
const eye = new window.EyeDropper();
|
|
@@ -5581,21 +5583,21 @@
|
|
|
5581
5583
|
catch (e) {
|
|
5582
5584
|
console.error(e);
|
|
5583
5585
|
}
|
|
5584
|
-
};
|
|
5586
|
+
}, []);
|
|
5585
5587
|
/** 모달용 핸들러 */
|
|
5586
|
-
const handleModalOpen = () => {
|
|
5588
|
+
const handleModalOpen = React.useCallback(() => {
|
|
5587
5589
|
if (type === 'modal') {
|
|
5588
5590
|
setTempColor(formatted);
|
|
5589
5591
|
}
|
|
5590
5592
|
setIsOpen(true);
|
|
5591
|
-
};
|
|
5592
|
-
const handleModalApply = () => {
|
|
5593
|
+
}, [type, formatted]);
|
|
5594
|
+
const handleModalApply = React.useCallback(() => {
|
|
5593
5595
|
if (type === 'modal') {
|
|
5594
5596
|
onApply?.(formatted);
|
|
5595
5597
|
setIsOpen(false);
|
|
5596
5598
|
}
|
|
5597
|
-
};
|
|
5598
|
-
const handleModalCancel = () => {
|
|
5599
|
+
}, [type, formatted, onApply]);
|
|
5600
|
+
const handleModalCancel = React.useCallback(() => {
|
|
5599
5601
|
if (type === 'modal') {
|
|
5600
5602
|
// 원래 색상으로 복원
|
|
5601
5603
|
const rgb = hexToRgb(tempColor);
|
|
@@ -5608,9 +5610,9 @@
|
|
|
5608
5610
|
onCancel?.();
|
|
5609
5611
|
setIsOpen(false);
|
|
5610
5612
|
}
|
|
5611
|
-
};
|
|
5613
|
+
}, [type, tempColor, onCancel]);
|
|
5612
5614
|
/** 배경 스타일 */
|
|
5613
|
-
const hueTrackStyle = {
|
|
5615
|
+
const hueTrackStyle = React.useMemo(() => ({
|
|
5614
5616
|
background: `linear-gradient(to right,
|
|
5615
5617
|
hsl(0,100%,50%),
|
|
5616
5618
|
hsl(60,100%,50%),
|
|
@@ -5619,15 +5621,15 @@
|
|
|
5619
5621
|
hsl(240,100%,50%),
|
|
5620
5622
|
hsl(300,100%,50%),
|
|
5621
5623
|
hsl(360,100%,50%))`,
|
|
5622
|
-
};
|
|
5623
|
-
const areaBackground = {
|
|
5624
|
+
}), []);
|
|
5625
|
+
const areaBackground = React.useMemo(() => ({
|
|
5624
5626
|
backgroundImage: `
|
|
5625
5627
|
linear-gradient(to top, rgba(0,0,0,1), rgba(0,0,0,0)),
|
|
5626
5628
|
linear-gradient(to right, #ffffff, hsl(${h}, 100%, 50%))
|
|
5627
5629
|
`,
|
|
5628
|
-
};
|
|
5630
|
+
}), [h]);
|
|
5629
5631
|
/** ✔︎ 알파 트랙: 색상 무관, 고정 흑백 그라디언트 */
|
|
5630
|
-
const alphaTrackStyle = {
|
|
5632
|
+
const alphaTrackStyle = React.useMemo(() => ({
|
|
5631
5633
|
backgroundImage: `
|
|
5632
5634
|
linear-gradient(45deg, var(--db-border-base) 25%, transparent 25%),
|
|
5633
5635
|
linear-gradient(-45deg, var(--db-border-base) 25%, transparent 25%),
|
|
@@ -5638,7 +5640,7 @@
|
|
|
5638
5640
|
backgroundSize: '8px 8px,8px 8px,8px 8px,8px 8px,100% 100%',
|
|
5639
5641
|
backgroundPosition: '0 0,0 4px,4px -4px,-4px 0,0 0',
|
|
5640
5642
|
backgroundColor: 'var(--db-surface-base)',
|
|
5641
|
-
};
|
|
5643
|
+
}), []);
|
|
5642
5644
|
const classes = clsx('designbase-color-picker', `designbase-color-picker--${size}`, `designbase-color-picker--${position}`, {
|
|
5643
5645
|
'designbase-color-picker--disabled': disabled,
|
|
5644
5646
|
'designbase-color-picker--readonly': readonly,
|
|
@@ -5652,8 +5654,8 @@
|
|
|
5652
5654
|
{ label: 'RGBA', value: 'rgba' },
|
|
5653
5655
|
{ label: 'HSL', value: 'hsl' },
|
|
5654
5656
|
{ label: 'HSLA', value: 'hsla' },
|
|
5655
|
-
], 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, {}) }))] })] }));
|
|
5656
|
-
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: "
|
|
5657
|
+
], 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, {}) }))] })] }));
|
|
5658
|
+
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" })] }) })] }))] }));
|
|
5657
5659
|
};
|
|
5658
5660
|
ColorPicker.displayName = 'ColorPicker';
|
|
5659
5661
|
|