@designbasekorea/ui 0.1.15 → 0.1.17

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
@@ -4902,6 +4902,17 @@ const Input = React.forwardRef(({ type = 'text', label, placeholder, defaultValu
4902
4902
  });
4903
4903
  Input.displayName = 'Input';
4904
4904
 
4905
+ // DoneIcon이 있으면 사용하고, 없으면 기본 SVG 사용
4906
+ let DoneIcon = null;
4907
+ let MinusIcon = null;
4908
+ try {
4909
+ const icons = require('@designbasekorea/icons');
4910
+ DoneIcon = icons.DoneIcon || null;
4911
+ MinusIcon = icons.MinusIcon || null;
4912
+ }
4913
+ catch (e) {
4914
+ // 아이콘 패키지가 없으면 기본 SVG 사용
4915
+ }
4905
4916
  const Checkbox = React.forwardRef(({ isSelected, defaultSelected, isIndeterminate = false, isDisabled = false, isReadOnly = false, isRequired = false, hasLabel = true, size = 'm', children, className, name, value, onChange, ...props }, forwardedRef) => {
4906
4917
  const [selected, setSelected] = React.useState(isSelected ?? defaultSelected ?? false);
4907
4918
  React.useEffect(() => {
@@ -4923,16 +4934,7 @@ const Checkbox = React.forwardRef(({ isSelected, defaultSelected, isIndeterminat
4923
4934
  'designbase-checkbox--readonly': isReadOnly,
4924
4935
  'designbase-checkbox--no-label': !hasLabel,
4925
4936
  }, className);
4926
- const getIconColor = () => {
4927
- if (isDisabled) {
4928
- return 'var(--color-action-interactive-icon-disabled)';
4929
- }
4930
- if (selected || isIndeterminate) {
4931
- return 'var(--color-action-interactive-icon-selected)';
4932
- }
4933
- return 'var(--color-action-interactive-icon)';
4934
- };
4935
- return (jsxRuntimeExports.jsxs("label", { className: classes, children: [jsxRuntimeExports.jsx("input", { ...props, ref: forwardedRef, name: name, value: value, type: "checkbox", checked: selected, onChange: handleChange, disabled: isDisabled, readOnly: isReadOnly, required: isRequired, className: "designbase-checkbox__input" }), jsxRuntimeExports.jsxs("div", { className: "designbase-checkbox__visual", children: [selected && !isIndeterminate && (jsxRuntimeExports.jsx("svg", { className: "designbase-checkbox__check-icon", viewBox: "0 0 24 24", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: jsxRuntimeExports.jsx("path", { d: "M20 6L9 17L4 12", stroke: getIconColor(), strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round" }) })), isIndeterminate && (jsxRuntimeExports.jsx("svg", { className: "designbase-checkbox__indeterminate-icon", viewBox: "0 0 24 24", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: jsxRuntimeExports.jsx("path", { d: "M5 12H19", stroke: getIconColor(), strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round" }) }))] }), children && jsxRuntimeExports.jsx("span", { className: "designbase-checkbox__label", children: children })] }));
4937
+ return (jsxRuntimeExports.jsxs("label", { className: classes, children: [jsxRuntimeExports.jsx("input", { ...props, ref: forwardedRef, name: name, value: value, type: "checkbox", checked: selected, onChange: handleChange, disabled: isDisabled, readOnly: isReadOnly, required: isRequired, className: "designbase-checkbox__input" }), jsxRuntimeExports.jsxs("div", { className: "designbase-checkbox__visual", children: [selected && !isIndeterminate && (jsxRuntimeExports.jsx("div", { className: "designbase-checkbox__check-icon", children: DoneIcon ? (jsxRuntimeExports.jsx(DoneIcon, { size: 16 })) : (jsxRuntimeExports.jsx("svg", { viewBox: "0 0 24 24", fill: "none", xmlns: "http://www.w3.org/2000/svg", width: "16", height: "16", children: jsxRuntimeExports.jsx("path", { d: "M20 6L9 17L4 12", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round" }) })) })), isIndeterminate && (jsxRuntimeExports.jsx("div", { className: "designbase-checkbox__indeterminate-icon", children: MinusIcon ? (jsxRuntimeExports.jsx(MinusIcon, { size: 16 })) : (jsxRuntimeExports.jsx("svg", { viewBox: "0 0 24 24", fill: "none", xmlns: "http://www.w3.org/2000/svg", width: "16", height: "16", children: jsxRuntimeExports.jsx("path", { d: "M5 12H19", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round" }) })) }))] }), children && jsxRuntimeExports.jsx("span", { className: "designbase-checkbox__label", children: children })] }));
4936
4938
  });
4937
4939
  Checkbox.displayName = 'Checkbox';
4938
4940
 
@@ -6054,6 +6056,20 @@ const Carousel = ({ items, size = 'm', variant = 'default', theme = 'light', tra
6054
6056
  };
6055
6057
 
6056
6058
  const Chip = ({ label, size = 'm', variant = 'default', color = 'primary', deletable = false, onDelete, onClick, startIcon, endIcon, disabled = false, selected = false, fullWidth = false, className, ...props }) => {
6059
+ // 사이즈별 아이콘 크기
6060
+ const getIconSize = () => {
6061
+ switch (size) {
6062
+ case 's':
6063
+ return 12;
6064
+ case 'm':
6065
+ return 16;
6066
+ case 'l':
6067
+ return 20;
6068
+ default:
6069
+ return 16;
6070
+ }
6071
+ };
6072
+ const iconSize = getIconSize();
6057
6073
  const handleDelete = (e) => {
6058
6074
  e.stopPropagation();
6059
6075
  if (!disabled && onDelete) {
@@ -6065,7 +6081,7 @@ const Chip = ({ label, size = 'm', variant = 'default', color = 'primary', delet
6065
6081
  onClick();
6066
6082
  }
6067
6083
  };
6068
- const classes = clsx('designbase-chip', `designbase-chip--${size}`, `designbase-chip--${variant}`, `designbase-chip--${color}`, {
6084
+ const classes = clsx('designbase-chip', `designbase-chip--${size}`, `designbase-chip--${variant}`, {
6069
6085
  'designbase-chip--deletable': deletable,
6070
6086
  'designbase-chip--disabled': disabled,
6071
6087
  'designbase-chip--selected': selected,
@@ -6077,7 +6093,11 @@ const Chip = ({ label, size = 'm', variant = 'default', color = 'primary', delet
6077
6093
  e.preventDefault();
6078
6094
  handleClick();
6079
6095
  }
6080
- }, ...props, children: [startIcon && (jsxRuntimeExports.jsx("span", { className: "designbase-chip__start-icon", children: startIcon })), jsxRuntimeExports.jsx("span", { className: "designbase-chip__label", children: label }), endIcon && !deletable && (jsxRuntimeExports.jsx("span", { className: "designbase-chip__end-icon", children: endIcon })), deletable && (jsxRuntimeExports.jsx("button", { type: "button", className: "designbase-chip__delete-button", onClick: handleDelete, disabled: disabled, "aria-label": `${label} 삭제`, children: jsxRuntimeExports.jsx("i", { className: "designbase-icon-x" }) }))] }));
6096
+ }, ...props, children: [startIcon && (jsxRuntimeExports.jsx("span", { className: "designbase-chip__start-icon", children: React.isValidElement(startIcon)
6097
+ ? React.cloneElement(startIcon, { size: iconSize })
6098
+ : startIcon })), jsxRuntimeExports.jsx("span", { className: "designbase-chip__label", children: label }), endIcon && !deletable && (jsxRuntimeExports.jsx("span", { className: "designbase-chip__end-icon", children: React.isValidElement(endIcon)
6099
+ ? React.cloneElement(endIcon, { size: iconSize })
6100
+ : endIcon })), deletable && (jsxRuntimeExports.jsx("button", { type: "button", className: "designbase-chip__delete-button", onClick: handleDelete, disabled: disabled, "aria-label": `${label} 삭제`, children: jsxRuntimeExports.jsx("svg", { width: iconSize, height: iconSize, viewBox: "0 0 24 24", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: jsxRuntimeExports.jsx("path", { d: "M18 6L6 18M6 6l12 12", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round" }) }) }))] }));
6081
6101
  };
6082
6102
  Chip.displayName = 'Chip';
6083
6103