sellmate-design-system-react 9.0.0-beta.16 → 9.0.0-beta.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.
@@ -18,6 +18,7 @@
18
18
  | `allSelectedLabel?` | `string` | `'전체'` | 전체선택 레이블 |
19
19
  | `placeholder?` | `string` | `'선택'` | placeholder |
20
20
  | `disabled?` | `boolean` | `false` | 비활성 |
21
+ | `clearable?` | `boolean` | `false` | 선택값 지우기(×) 버튼 노출. 선택값이 있고 비활성이 아닐 때만 나타나며, 누르면 드롭다운을 열지 않고 값만 비운다. |
21
22
  | `error?` | `boolean` | `false` | 에러 상태 |
22
23
  | `rules?` | `Rule[]` | — | 유효성 규칙 — 닫힐 때 자동 검증 |
23
24
  | `labelTooltipProps?` | `Partial<STooltipProps>` | — | 레이블 툴팁 상세 옵션 |
@@ -38,6 +38,11 @@ export interface SSelectProps {
38
38
  placeholder?: string;
39
39
  /** 비활성 */
40
40
  disabled?: boolean;
41
+ /**
42
+ * 선택값 지우기(×) 버튼 노출. 선택값이 있고 비활성이 아닐 때만 나타나며,
43
+ * 누르면 드롭다운을 열지 않고 값만 비운다.
44
+ */
45
+ clearable?: boolean;
41
46
  /** 에러 상태 */
42
47
  error?: boolean;
43
48
  /** 유효성 규칙 — 닫힐 때 자동 검증 */
package/dist/index.cjs CHANGED
@@ -10438,6 +10438,7 @@ var SSelectImpl = /* @__PURE__ */ react.forwardRef(function SSelect({
10438
10438
  allSelectedLabel = "\uC804\uCCB4",
10439
10439
  placeholder = "\uC120\uD0DD",
10440
10440
  disabled = false,
10441
+ clearable = false,
10441
10442
  error = false,
10442
10443
  rules,
10443
10444
  labelTooltipProps,
@@ -10593,6 +10594,11 @@ var SSelectImpl = /* @__PURE__ */ react.forwardRef(function SSelect({
10593
10594
  return labelByValue.get(selected[0]) ?? selected[0];
10594
10595
  })();
10595
10596
  const isPlaceholder = selected.length === 0;
10597
+ const showClear = clearable && !effectiveDisabled && !isPlaceholder;
10598
+ const handleClear = () => {
10599
+ emit3([]);
10600
+ if (rules && rules.length > 0) setRuleError(runRules(multi ? [] : "", rules));
10601
+ };
10596
10602
  const handleSelect = (nextValue) => {
10597
10603
  if (multi) {
10598
10604
  const next = selected.includes(nextValue) ? selected.filter((v) => v !== nextValue) : [...selected, nextValue];
@@ -10735,15 +10741,53 @@ var SSelectImpl = /* @__PURE__ */ react.forwardRef(function SSelect({
10735
10741
  dangerouslySetInnerHTML: { __html: sanitizeInlineHtml(triggerText) }
10736
10742
  }
10737
10743
  ) : /* @__PURE__ */ jsxRuntime.jsx("span", { className: "truncate", children: triggerText }),
10738
- /* @__PURE__ */ jsxRuntime.jsx(
10739
- SIcon,
10740
- {
10741
- name: "chevronDown",
10742
- size: 12,
10743
- color: effectiveDisabled ? "var(--cmp-select-icon-disabled)" : "var(--cmp-select-icon-default)",
10744
- className: cn("shrink-0 transition-transform duration-200", open && "rotate-180")
10745
- }
10746
- )
10744
+ /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "flex shrink-0 items-center gap-[8px]", children: [
10745
+ showClear && /* @__PURE__ */ jsxRuntime.jsxs(
10746
+ "span",
10747
+ {
10748
+ role: "button",
10749
+ tabIndex: 0,
10750
+ "aria-label": "\uC120\uD0DD \uC9C0\uC6B0\uAE30",
10751
+ className: "group/select-clear relative inline-flex shrink-0 cursor-pointer items-center justify-center",
10752
+ style: {
10753
+ width: "var(--cmp-ghostButton-xxs-size)",
10754
+ height: "var(--cmp-ghostButton-xxs-size)",
10755
+ borderRadius: "var(--cmp-ghostButton-radius-sm)"
10756
+ },
10757
+ onClick: (event) => {
10758
+ event.preventDefault();
10759
+ event.stopPropagation();
10760
+ handleClear();
10761
+ },
10762
+ onKeyDown: (event) => {
10763
+ if (event.key !== "Enter" && event.key !== " ") return;
10764
+ event.preventDefault();
10765
+ event.stopPropagation();
10766
+ handleClear();
10767
+ },
10768
+ children: [
10769
+ /* @__PURE__ */ jsxRuntime.jsx(
10770
+ "span",
10771
+ {
10772
+ "aria-hidden": true,
10773
+ className: "pointer-events-none absolute inset-0 rounded-[inherit] opacity-0 transition-opacity duration-200 group-hover/select-clear:opacity-5",
10774
+ style: { background: "var(--cmp-ghostButton-default-hover-bg)" }
10775
+ }
10776
+ ),
10777
+ /* @__PURE__ */ jsxRuntime.jsx(SIcon, { name: "close", size: 12, color: "var(--cmp-ghostButton-default-content)" })
10778
+ ]
10779
+ }
10780
+ ),
10781
+ /* @__PURE__ */ jsxRuntime.jsx(
10782
+ SIcon,
10783
+ {
10784
+ name: "chevronDown",
10785
+ size: 12,
10786
+ color: effectiveDisabled ? "var(--cmp-select-icon-disabled)" : "var(--cmp-select-icon-default)",
10787
+ className: cn("shrink-0 transition-transform duration-200", open && "rotate-180")
10788
+ }
10789
+ )
10790
+ ] })
10747
10791
  ]
10748
10792
  }
10749
10793
  ),