@tide-design/components 0.17.0 → 0.18.0

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.
@@ -3,21 +3,17 @@
3
3
  import { CheckboxGroupContext } from "../_internal/hooks/useChoiceGroup.js";
4
4
  import { choiceAreaClass, choiceInputClass, choiceMarkClass, choiceRootClass, choiceTextClass } from "../_internal/constants/choiceClass.js";
5
5
  import { cn } from "../_internal/libs/cn.js";
6
- import { checkboxInputStateClass, checkboxMarkClass } from "./constants/checkboxClass.js";
6
+ import { checkboxFillClass, checkboxInputStateClass, checkboxMarkClass, checkboxMarkShownClass } from "./constants/checkboxClass.js";
7
+ import { CheckboxMark } from "./components/CheckboxMark.js";
7
8
  import { useFieldControl } from "../_internal/hooks/useFieldControl.js";
8
9
  import { jsx, jsxs } from "react/jsx-runtime";
9
10
  import { use, useImperativeHandle, useLayoutEffect, useRef } from "react";
10
- import { CheckIcon, MinusIcon } from "@tide-design/icons";
11
11
 
12
12
  // src/Checkbox/Checkbox.tsx
13
13
  const boxClass = {
14
14
  sm: "size-4 rounded-sm",
15
15
  md: "size-5 rounded-sm"
16
16
  };
17
- const iconSize = {
18
- sm: 12,
19
- md: 16
20
- };
21
17
  /**
22
18
  * 네이티브 체크박스. 여러 개를 묶어 이름·설명·오류를 붙이려면 `Field group` 안의 `CheckboxGroup`에 둔다.
23
19
  * Tide props: `children`, `size`, `color`, `indeterminate`, `invalid`, `className`, `style` ({@link CheckboxOwnProps}). 나머지는 `<input>` 속성.
@@ -53,17 +49,20 @@ function Checkbox({ children, size = "md", color = "primary", indeterminate = fa
53
49
  type: "checkbox",
54
50
  className: cn(boxClass[size], choiceInputClass, checkboxInputStateClass)
55
51
  }),
56
- /* @__PURE__ */ jsx(CheckIcon, {
57
- size: iconSize[size],
58
- strokeWidth: 3,
59
- "data-mark": "check",
60
- className: cn(choiceMarkClass, checkboxMarkClass, "peer-checked:block peer-indeterminate:hidden")
52
+ /* @__PURE__ */ jsx("span", {
53
+ "aria-hidden": "true",
54
+ "data-fill": "",
55
+ className: cn(boxClass[size], checkboxFillClass)
56
+ }),
57
+ /* @__PURE__ */ jsx(CheckboxMark, {
58
+ kind: "check",
59
+ size,
60
+ className: cn(choiceMarkClass, checkboxMarkClass, checkboxMarkShownClass.check)
61
61
  }),
62
- /* @__PURE__ */ jsx(MinusIcon, {
63
- size: iconSize[size],
64
- strokeWidth: 3,
65
- "data-mark": "indeterminate",
66
- className: cn(choiceMarkClass, checkboxMarkClass, "peer-indeterminate:block")
62
+ /* @__PURE__ */ jsx(CheckboxMark, {
63
+ kind: "indeterminate",
64
+ size,
65
+ className: cn(choiceMarkClass, checkboxMarkClass, checkboxMarkShownClass.indeterminate)
67
66
  })
68
67
  ]
69
68
  }), children === void 0 || children === null ? null : /* @__PURE__ */ jsx("span", { children })]
@@ -0,0 +1,35 @@
1
+ import { jsx } from "react/jsx-runtime";
2
+
3
+ // src/Checkbox/components/CheckboxMark.tsx
4
+ const pathData = {
5
+ check: "M20 6 9 17l-5-5",
6
+ indeterminate: "M5 12h14"
7
+ };
8
+ const pixelSize = {
9
+ sm: 12,
10
+ md: 16
11
+ };
12
+ /** 그려지는 체크 표시. 상태는 input이 보조 기술에 알려 장식으로 숨긴다. */
13
+ function CheckboxMark({ kind, size, className }) {
14
+ const px = pixelSize[size];
15
+ return /* @__PURE__ */ jsx("svg", {
16
+ "aria-hidden": "true",
17
+ focusable: "false",
18
+ "data-mark": kind,
19
+ width: px,
20
+ height: px,
21
+ viewBox: "0 0 24 24",
22
+ fill: "none",
23
+ stroke: "currentColor",
24
+ strokeWidth: 48 / px,
25
+ strokeLinecap: "round",
26
+ strokeLinejoin: "round",
27
+ className,
28
+ children: /* @__PURE__ */ jsx("path", {
29
+ d: pathData[kind],
30
+ pathLength: 1
31
+ })
32
+ });
33
+ }
34
+
35
+ export { CheckboxMark };
@@ -1,7 +1,17 @@
1
1
  // src/Checkbox/constants/checkboxClass.ts
2
- /** 체크·indeterminate는 accent solid로 채운다. */
3
- const checkboxInputStateClass = "checked:border-accent checked:bg-accent-solid enabled:not-checked:not-indeterminate:group-hover/choice:bg-accent-subtle enabled:checked:group-hover/choice:bg-accent-solid-hover indeterminate:border-accent indeterminate:bg-accent-solid enabled:indeterminate:group-hover/choice:bg-accent-solid-hover enabled:not-checked:not-indeterminate:group-active/choice:bg-accent-subtle-active enabled:checked:group-active/choice:bg-accent-solid-active enabled:indeterminate:group-active/choice:bg-accent-solid-active";
4
- /** solid 위 흰 표시 */
5
- const checkboxMarkClass = "text-accent-on-solid forced-colors:[--tide-accent-on-solid:HighlightText]";
2
+ /** 체크 전 hover·누름은 subtle 바탕이다. 체크·indeterminate 채움은 채움 레이어가 맡고, forced-colors에서만 input이 칠한다. */
3
+ const checkboxInputStateClass = "checked:border-accent indeterminate:border-accent enabled:not-checked:not-indeterminate:group-hover/choice:bg-accent-subtle enabled:not-checked:not-indeterminate:group-active/choice:bg-accent-subtle-active forced-colors:enabled:checked:bg-accent-solid forced-colors:enabled:indeterminate:bg-accent-solid";
4
+ /**
5
+ * 체크·indeterminate 채움. input과 같은 크기라 테두리까지 덮는다. opacity와 scale이 함께 fast로 바뀐다.
6
+ * 비활성·forced-colors에서는 숨고 input 바탕이 그 색을 맡는다. 오류 색은 input의 변수가 닿지 않아 다시 적는다(ADR 0035).
7
+ */
8
+ const checkboxFillClass = "pointer-events-none col-start-1 row-start-1 bg-accent-solid opacity-0 transition-[opacity,background-color] group-hover/choice:bg-accent-solid-hover group-active/choice:bg-accent-solid-active peer-checked:opacity-100 peer-indeterminate:opacity-100 motion-safe:scale-70 motion-safe:transition-[opacity,scale,background-color] motion-safe:peer-checked:scale-100 motion-safe:peer-indeterminate:scale-100 peer-aria-invalid:[--tide-accent-solid:var(--tide-bg-danger-solid)] peer-aria-invalid:[--tide-accent-solid-hover:var(--tide-bg-danger-solid-hover)] peer-aria-invalid:[--tide-accent-solid-active:var(--tide-bg-danger-solid-active)] peer-disabled:hidden forced-colors:hidden";
9
+ /** solid 위 흰 표시. 숨을 때는 지연 없이 fast로 거꾸로 지워지며 사라진다. dash는 svg에 두고 path가 물려받는다. */
10
+ const checkboxMarkClass = "relative text-accent-on-solid forced-colors:[--tide-accent-on-solid:HighlightText] motion-safe:[stroke-dasharray:1] motion-safe:[stroke-dashoffset:1] motion-safe:transition-[opacity,stroke-dashoffset]";
11
+ /** 보이는 조건과 그리기. 채움이 찬 뒤(fast 지연) opacity와 dash가 fast로 함께 바뀐다. */
12
+ const checkboxMarkShownClass = {
13
+ check: "peer-checked:peer-not-indeterminate:opacity-100 motion-safe:peer-checked:peer-not-indeterminate:[stroke-dashoffset:0] motion-safe:peer-checked:peer-not-indeterminate:duration-fast motion-safe:peer-checked:peer-not-indeterminate:delay-(--tide-duration-fast)",
14
+ indeterminate: "peer-indeterminate:opacity-100 motion-safe:peer-indeterminate:[stroke-dashoffset:0] motion-safe:peer-indeterminate:duration-fast motion-safe:peer-indeterminate:delay-(--tide-duration-fast)"
15
+ };
6
16
 
7
- export { checkboxInputStateClass, checkboxMarkClass };
17
+ export { checkboxFillClass, checkboxInputStateClass, checkboxMarkClass, checkboxMarkShownClass };
@@ -3,7 +3,7 @@
3
3
  import { RadioGroupContext } from "../_internal/hooks/useChoiceGroup.js";
4
4
  import { choiceAreaClass, choiceInputClass, choiceMarkClass, choiceRootClass, choiceTextClass } from "../_internal/constants/choiceClass.js";
5
5
  import { cn } from "../_internal/libs/cn.js";
6
- import { radioDotClass, radioInputStateClass, radioMarkClass } from "./constants/radioClass.js";
6
+ import { radioDotClass, radioInputStateClass, radioMarkClass, radioMarkShownClass } from "./constants/radioClass.js";
7
7
  import { useFieldControl } from "../_internal/hooks/useFieldControl.js";
8
8
  import { jsx, jsxs } from "react/jsx-runtime";
9
9
  import { use } from "react";
@@ -52,7 +52,7 @@ function Radio({ value, children, size = "md", color = "primary", invalid, id, d
52
52
  }), /* @__PURE__ */ jsx("span", {
53
53
  "aria-hidden": "true",
54
54
  "data-mark": "dot",
55
- className: cn(choiceMarkClass, radioMarkClass, radioDotClass[size], "peer-checked:block")
55
+ className: cn(choiceMarkClass, radioMarkClass, radioDotClass[size], radioMarkShownClass)
56
56
  })]
57
57
  }), children === void 0 || children === null ? null : /* @__PURE__ */ jsx("span", { children })]
58
58
  });
@@ -11,5 +11,10 @@ const radioDotClass = {
11
11
  };
12
12
  /** 점은 테두리와 같은 색이다. 오류면 danger, 비활성이면 text-disabled(choiceMarkClass)가 이긴다. */
13
13
  const radioMarkClass = "rounded-full bg-current text-(--tide-accent-border) peer-enabled:peer-aria-invalid:text-(--tide-border-danger) forced-colors:[--tide-accent-border:Highlight] forced-colors:[--tide-border-danger:CanvasText]";
14
+ /**
15
+ * 고르면 보인다. 움직임이 허락되면 점이 0에서 살짝 넘쳤다가 자리 잡고(normal), 해제되면 fast·ease-out으로 줄어든다.
16
+ * overshoot 곡선은 Radio만 써서 Token에 두지 않는다. 다른 Component도 쓰면 foundation easing으로 올린다(ADR 0037).
17
+ */
18
+ const radioMarkShownClass = "peer-checked:opacity-100 motion-safe:scale-0 motion-safe:transition-[opacity,scale] motion-safe:peer-checked:scale-100 motion-safe:peer-checked:duration-normal motion-safe:peer-checked:ease-[cubic-bezier(0.34,1.56,0.64,1)]";
14
19
 
15
- export { radioDotClass, radioInputStateClass, radioMarkClass };
20
+ export { radioDotClass, radioInputStateClass, radioMarkClass, radioMarkShownClass };
@@ -1,4 +1,4 @@
1
- import { TabsActivationMode, TabsOrientation } from "./types.js";
1
+ import { TabsActivationMode, TabsOrientation, TabsShape } from "./types.js";
2
2
  import { ComponentProps, ReactElement, ReactNode } from "react";
3
3
  type TabsValueProps = {
4
4
  /** 고른 탭의 값(제어). 주면 `onValueChange`로 바꾼다. */
@@ -14,6 +14,8 @@ interface TabsBaseOwnProps {
14
14
  onValueChange?: (value: string) => void;
15
15
  /** 탭 목록의 방향. 기본값은 `horizontal`이다. 세로면 ↓↑로 옮기고 탭 목록이 패널의 시작쪽에 선다. */
16
16
  orientation?: TabsOrientation;
17
+ /** 고른 표시의 모양. 기본값 `underline`(밑줄). `box`는 옅은 바탕 위 둥근 사각형이다. 고른 표시는 탭을 바꾸면 새 탭으로 미끄러진다. */
18
+ shape?: TabsShape;
17
19
  /** 키보드로 옮기면 바로 고를지(`automatic`, 기본값), Enter·Space로 고를지(`manual`). 패널이 느리면 `manual`. */
18
20
  activationMode?: TabsActivationMode;
19
21
  /** `TabList` 하나와 `TabPanel`들 */
@@ -22,9 +24,9 @@ interface TabsBaseOwnProps {
22
24
  export type TabsOwnProps = TabsBaseOwnProps & TabsValueProps;
23
25
  export type TabsProps = TabsOwnProps & Omit<ComponentProps<"div">, keyof TabsOwnProps | "onChange">;
24
26
  /**
25
- * 같은 영역의 여러 패널 중 하나를 고르는 탭 묶음. 루트는 `<div>`이고 방향이 `data-orientation`으로 붙는다.
27
+ * 같은 영역의 여러 패널 중 하나를 고르는 탭 묶음. 루트는 `<div>`이고 방향·모양이 `data-orientation`·`data-shape`로 붙는다.
26
28
  * 안에 `TabList` 하나와 탭마다 `TabPanel`을 둔다.
27
- * Tide props: `value`, `defaultValue`, `onValueChange`, `orientation`, `activationMode`, `children` ({@link TabsOwnProps}). 나머지는 `<div>` 속성.
29
+ * Tide props: `value`, `defaultValue`, `onValueChange`, `orientation`, `shape`, `activationMode`, `children` ({@link TabsOwnProps}). 나머지는 `<div>` 속성.
28
30
  */
29
- export declare function Tabs({ value: valueProp, defaultValue, onValueChange, orientation, activationMode, ref, className, children, ...props }: TabsProps): ReactElement;
31
+ export declare function Tabs({ value: valueProp, defaultValue, onValueChange, orientation, shape, activationMode, ref, className, children, ...props }: TabsProps): ReactElement;
30
32
  export {};
package/dist/Tabs/Tabs.js CHANGED
@@ -10,11 +10,11 @@ import { useCallback, useId, useMemo, useState } from "react";
10
10
  /** id에 쓸 수 없는 공백을 뺀다(React Aria 탭 id와 같은 규칙). */
11
11
  const idPart = (value) => value.replace(/\s+/g, "");
12
12
  /**
13
- * 같은 영역의 여러 패널 중 하나를 고르는 탭 묶음. 루트는 `<div>`이고 방향이 `data-orientation`으로 붙는다.
13
+ * 같은 영역의 여러 패널 중 하나를 고르는 탭 묶음. 루트는 `<div>`이고 방향·모양이 `data-orientation`·`data-shape`로 붙는다.
14
14
  * 안에 `TabList` 하나와 탭마다 `TabPanel`을 둔다.
15
- * Tide props: `value`, `defaultValue`, `onValueChange`, `orientation`, `activationMode`, `children` ({@link TabsOwnProps}). 나머지는 `<div>` 속성.
15
+ * Tide props: `value`, `defaultValue`, `onValueChange`, `orientation`, `shape`, `activationMode`, `children` ({@link TabsOwnProps}). 나머지는 `<div>` 속성.
16
16
  */
17
- function Tabs({ value: valueProp, defaultValue, onValueChange, orientation = "horizontal", activationMode = "automatic", ref, className, children, ...props }) {
17
+ function Tabs({ value: valueProp, defaultValue, onValueChange, orientation = "horizontal", shape = "underline", activationMode = "automatic", ref, className, children, ...props }) {
18
18
  const [internal, setInternal] = useState(defaultValue ?? "");
19
19
  const controlled = valueProp !== void 0;
20
20
  const value = controlled ? valueProp : internal;
@@ -32,6 +32,7 @@ function Tabs({ value: valueProp, defaultValue, onValueChange, orientation = "ho
32
32
  value,
33
33
  setValue,
34
34
  orientation,
35
+ shape,
35
36
  activationMode,
36
37
  tabId: (tab) => `${baseId}-tab-${idPart(tab)}`,
37
38
  panelId: (tab) => `${baseId}-tabpanel-${idPart(tab)}`
@@ -39,6 +40,7 @@ function Tabs({ value: valueProp, defaultValue, onValueChange, orientation = "ho
39
40
  value,
40
41
  setValue,
41
42
  orientation,
43
+ shape,
42
44
  activationMode,
43
45
  baseId
44
46
  ]);
@@ -46,6 +48,7 @@ function Tabs({ value: valueProp, defaultValue, onValueChange, orientation = "ho
46
48
  ...props,
47
49
  ref,
48
50
  "data-orientation": orientation,
51
+ "data-shape": shape,
49
52
  className: cn(tabsOrientationClass[orientation], className),
50
53
  children: /* @__PURE__ */ jsx(TabsContext, {
51
54
  value: context,
@@ -0,0 +1,15 @@
1
+ import { tabIndicatorClass } from "../constants/tabsClass.js";
2
+ import { jsx } from "react/jsx-runtime";
3
+
4
+ // src/Tabs/components/TabIndicator.tsx
5
+ /** 고른 탭 아래에 놓이는 고른 표시 하나. 자리는 useTabIndicator가 CSS 변수로 적는다. */
6
+ function TabIndicator({ ref, shape, orientation }) {
7
+ return /* @__PURE__ */ jsx("span", {
8
+ ref,
9
+ "aria-hidden": "true",
10
+ "data-indicator": "",
11
+ className: tabIndicatorClass[shape][orientation]
12
+ });
13
+ }
14
+
15
+ export { TabIndicator };
@@ -2,10 +2,12 @@
2
2
 
3
3
  import { cn } from "../../_internal/libs/cn.js";
4
4
  import { resolveCollectionChildren } from "../../_internal/libs/listCollection.js";
5
- import { tabListOrientationClass } from "../constants/tabsClass.js";
5
+ import { tabListClass } from "../constants/tabsClass.js";
6
+ import { useTabIndicator } from "../hooks/useTabIndicator.js";
6
7
  import { useTabsContext } from "../hooks/useTabsContext.js";
8
+ import { TabIndicator } from "./TabIndicator.js";
7
9
  import { TabView } from "./TabView.js";
8
- import { jsx } from "react/jsx-runtime";
10
+ import { jsx, jsxs } from "react/jsx-runtime";
9
11
  import { isValidElement, useMemo, useRef } from "react";
10
12
  import { mergeProps, mergeRefs, useTabList } from "react-aria";
11
13
  import { useTabListState } from "react-stately";
@@ -19,6 +21,7 @@ import { useTabListState } from "react-stately";
19
21
  function TabList({ ref, className, children, ...props }) {
20
22
  const context = useTabsContext("TabList");
21
23
  const listRef = useRef(null);
24
+ const indicatorRef = useRef(null);
22
25
  const items = useMemo(() => resolveCollectionChildren(children), [children]);
23
26
  const known = items.some((item) => isValidElement(item) && item.props.value === context.value);
24
27
  const state = useTabListState({
@@ -33,15 +36,20 @@ function TabList({ ref, className, children, ...props }) {
33
36
  "aria-labelledby": props["aria-labelledby"]
34
37
  }, state, listRef);
35
38
  const mergedRef = useMemo(() => mergeRefs(ref, listRef), [ref, listRef]);
36
- return /* @__PURE__ */ jsx("div", {
39
+ useTabIndicator(listRef, indicatorRef);
40
+ return /* @__PURE__ */ jsxs("div", {
37
41
  ...mergeProps(props, tabListProps),
38
42
  ref: mergedRef,
39
- className: cn(tabListOrientationClass[context.orientation], className),
40
- children: [...state.collection].map((node) => /* @__PURE__ */ jsx(TabView, {
43
+ className: cn(tabListClass[context.shape][context.orientation], className),
44
+ children: [/* @__PURE__ */ jsx(TabIndicator, {
45
+ ref: indicatorRef,
46
+ shape: context.shape,
47
+ orientation: context.orientation
48
+ }), [...state.collection].map((node) => /* @__PURE__ */ jsx(TabView, {
41
49
  node,
42
50
  state,
43
51
  context
44
- }, node.key))
52
+ }, node.key))]
45
53
  });
46
54
  }
47
55
 
@@ -1,7 +1,7 @@
1
1
  "use client";
2
2
 
3
3
  import { cn } from "../../_internal/libs/cn.js";
4
- import { tabBaseClass, tabOrientationClass } from "../constants/tabsClass.js";
4
+ import { tabBaseClass, tabFallbackClass } from "../constants/tabsClass.js";
5
5
  import { jsx } from "react/jsx-runtime";
6
6
  import { useMemo, useRef } from "react";
7
7
  import { mergeProps, mergeRefs, useTab } from "react-aria";
@@ -21,7 +21,7 @@ function TabView({ node, state, context }) {
21
21
  "aria-controls": isSelected ? context.panelId(value) : void 0,
22
22
  disabled: isDisabled || void 0,
23
23
  "data-selected": isSelected ? "" : void 0,
24
- className: cn(tabBaseClass, tabOrientationClass[context.orientation], className),
24
+ className: cn(tabBaseClass, tabFallbackClass[context.shape][context.orientation], className),
25
25
  children: node.rendered
26
26
  });
27
27
  }
@@ -3,21 +3,44 @@ const tabsOrientationClass = {
3
3
  horizontal: "flex flex-col gap-4",
4
4
  vertical: "flex flex-row gap-6"
5
5
  };
6
- const tabListOrientationClass = {
7
- horizontal: "flex shrink-0 gap-1 border-b border-default",
8
- vertical: "flex shrink-0 flex-col gap-1 border-e border-default"
6
+ const unmeasuredFallback = "[&:not([data-measured])>[data-selected]]:after:opacity-100";
7
+ const tabListClass = {
8
+ underline: {
9
+ horizontal: `relative flex shrink-0 gap-1 border-b border-default ${unmeasuredFallback}`,
10
+ vertical: `relative flex shrink-0 flex-col gap-1 border-e border-default ${unmeasuredFallback}`
11
+ },
12
+ box: {
13
+ horizontal: `relative flex shrink-0 gap-1 self-start rounded-lg bg-inset p-1 [&:not([data-measured])>[data-selected]]:bg-surface [&:not([data-measured])>[data-selected]]:shadow-sm ${unmeasuredFallback}`,
14
+ vertical: `relative flex shrink-0 flex-col gap-1 self-start rounded-lg bg-inset p-1 [&:not([data-measured])>[data-selected]]:bg-surface [&:not([data-measured])>[data-selected]]:shadow-sm ${unmeasuredFallback}`
15
+ }
9
16
  };
10
17
  const tabBaseClass = [
11
18
  "relative flex cursor-pointer items-center gap-2 rounded-md px-3 py-2 text-label-md whitespace-nowrap text-muted outline-none select-none [&>svg]:size-4 [&>svg]:shrink-0",
12
19
  "hover:not-data-selected:enabled:text-default data-selected:text-primary focus-visible:focus-ring",
13
20
  "disabled:cursor-not-allowed disabled:text-disabled",
14
- "after:pointer-events-none after:absolute after:border-primary after:opacity-0 after:transition-opacity data-selected:after:opacity-100",
15
- "forced-colors:after:forced-color-adjust-none forced-colors:after:border-[Highlight]"
21
+ "after:pointer-events-none after:absolute after:opacity-0"
16
22
  ].join(" ");
17
- const tabOrientationClass = {
18
- horizontal: "after:inset-x-0 after:-bottom-px after:border-b-2 motion-safe:after:scale-x-0 motion-safe:after:transition-[opacity,scale] motion-safe:data-selected:after:scale-x-100",
19
- vertical: "after:inset-y-0 after:-end-px after:border-e-2 motion-safe:after:scale-y-0 motion-safe:after:transition-[opacity,scale] motion-safe:data-selected:after:scale-y-100"
23
+ const tabFallbackClass = {
24
+ underline: {
25
+ horizontal: "after:inset-x-0 after:-bottom-px after:border-b-2 after:border-primary forced-colors:after:forced-color-adjust-none forced-colors:after:border-[Highlight]",
26
+ vertical: "after:inset-y-0 after:-end-px after:border-e-2 after:border-primary forced-colors:after:forced-color-adjust-none forced-colors:after:border-[Highlight]"
27
+ },
28
+ box: {
29
+ horizontal: "after:inset-0 after:hidden after:rounded-md after:border-2 forced-colors:after:block forced-colors:after:forced-color-adjust-none forced-colors:after:border-[Highlight]",
30
+ vertical: "after:inset-0 after:hidden after:rounded-md after:border-2 forced-colors:after:block forced-colors:after:forced-color-adjust-none forced-colors:after:border-[Highlight]"
31
+ }
32
+ };
33
+ const indicatorBaseClass = "pointer-events-none invisible absolute [[data-measured]>&]:visible motion-safe:transition-[translate,width,height] motion-safe:duration-normal motion-safe:ease-out forced-colors:forced-color-adjust-none";
34
+ const tabIndicatorClass = {
35
+ underline: {
36
+ horizontal: `${indicatorBaseClass} -bottom-px left-0 w-(--tab-indicator-width) translate-x-(--tab-indicator-x) border-b-2 border-primary forced-colors:border-[Highlight]`,
37
+ vertical: `${indicatorBaseClass} top-0 -end-px h-(--tab-indicator-height) translate-y-(--tab-indicator-y) border-e-2 border-primary forced-colors:border-[Highlight]`
38
+ },
39
+ box: {
40
+ horizontal: `${indicatorBaseClass} top-0 left-0 h-(--tab-indicator-height) w-(--tab-indicator-width) translate-x-(--tab-indicator-x) translate-y-(--tab-indicator-y) rounded-md border border-raised bg-surface shadow-sm forced-colors:border-2 forced-colors:border-[Highlight] forced-colors:bg-transparent forced-colors:shadow-none`,
41
+ vertical: `${indicatorBaseClass} top-0 left-0 h-(--tab-indicator-height) w-(--tab-indicator-width) translate-x-(--tab-indicator-x) translate-y-(--tab-indicator-y) rounded-md border border-raised bg-surface shadow-sm forced-colors:border-2 forced-colors:border-[Highlight] forced-colors:bg-transparent forced-colors:shadow-none`
42
+ }
20
43
  };
21
44
  const tabPanelClass = "min-w-0 flex-1 rounded-md outline-none focus-visible:focus-ring";
22
45
 
23
- export { tabBaseClass, tabListOrientationClass, tabOrientationClass, tabPanelClass, tabsOrientationClass };
46
+ export { tabBaseClass, tabFallbackClass, tabIndicatorClass, tabListClass, tabPanelClass, tabsOrientationClass };
@@ -0,0 +1,59 @@
1
+ "use client";
2
+
3
+ import { useLayoutEffect, useRef } from "react";
4
+
5
+ // src/Tabs/hooks/useTabIndicator.ts
6
+ const tabSelector = ":scope > [role=\"tab\"]";
7
+ /**
8
+ * 고른 탭의 위치·크기를 재어 `indicatorRef`에 CSS 변수(`--tab-indicator-x·y·width·height`)로 적는다.
9
+ * 고른 탭이 바뀔 때만 미끄러지고, 첫 자리·크기 변화·숨었다 보일 때는 transition 없이 놓는다.
10
+ */
11
+ function useTabIndicator(listRef, indicatorRef) {
12
+ const placed = useRef(null);
13
+ useLayoutEffect(() => {
14
+ const list = listRef.current;
15
+ const indicator = indicatorRef.current;
16
+ if (!list || !indicator) return;
17
+ const place = () => {
18
+ const tab = list.querySelector(`${tabSelector}[aria-selected="true"]`);
19
+ if (!tab || list.getClientRects().length === 0) {
20
+ delete list.dataset["measured"];
21
+ placed.current = null;
22
+ return;
23
+ }
24
+ const listRect = list.getBoundingClientRect();
25
+ const rect = tab.getBoundingClientRect();
26
+ const scaleX = list.offsetWidth > 0 ? listRect.width / list.offsetWidth : 1;
27
+ const scaleY = list.offsetHeight > 0 ? listRect.height / list.offsetHeight : 1;
28
+ const x = (rect.left - listRect.left) / scaleX - list.clientLeft + list.scrollLeft;
29
+ const y = (rect.top - listRect.top) / scaleY - list.clientTop + list.scrollTop;
30
+ const width = rect.width / scaleX;
31
+ const height = rect.height / scaleY;
32
+ const geometry = `${x} ${y} ${width} ${height}`;
33
+ const previous = placed.current;
34
+ if (previous?.tab === tab.id && previous.geometry === geometry) return;
35
+ const slide = previous !== null && previous.tab !== tab.id;
36
+ if (!slide) indicator.style.transition = "none";
37
+ indicator.style.setProperty("--tab-indicator-x", `${x}px`);
38
+ indicator.style.setProperty("--tab-indicator-y", `${y}px`);
39
+ indicator.style.setProperty("--tab-indicator-width", `${width}px`);
40
+ indicator.style.setProperty("--tab-indicator-height", `${height}px`);
41
+ if (!slide) {
42
+ indicator.getBoundingClientRect();
43
+ indicator.style.removeProperty("transition");
44
+ }
45
+ list.dataset["measured"] = "";
46
+ placed.current = {
47
+ tab: tab.id,
48
+ geometry
49
+ };
50
+ };
51
+ place();
52
+ const observer = new ResizeObserver(place);
53
+ observer.observe(list);
54
+ for (const tab of list.querySelectorAll(tabSelector)) observer.observe(tab);
55
+ return () => observer.disconnect();
56
+ });
57
+ }
58
+
59
+ export { useTabIndicator };
@@ -2,5 +2,5 @@ import { Tabs, TabsOwnProps, TabsProps } from "./Tabs.js";
2
2
  import { TabList, TabListOwnProps, TabListProps } from "./components/TabList.js";
3
3
  import { Tab, TabOwnProps, TabProps } from "./components/Tab.js";
4
4
  import { TabPanel, TabPanelOwnProps, TabPanelProps } from "./components/TabPanel.js";
5
- import { TabsActivationMode, TabsOrientation } from "./types.js";
6
- export { Tab, TabList, type TabListOwnProps, type TabListProps, type TabOwnProps, TabPanel, type TabPanelOwnProps, type TabPanelProps, type TabProps, Tabs, type TabsActivationMode, type TabsOrientation, type TabsOwnProps, type TabsProps };
5
+ import { TabsActivationMode, TabsOrientation, TabsShape } from "./types.js";
6
+ export { Tab, TabList, type TabListOwnProps, type TabListProps, type TabOwnProps, TabPanel, type TabPanelOwnProps, type TabPanelProps, type TabProps, Tabs, type TabsActivationMode, type TabsOrientation, type TabsOwnProps, type TabsProps, type TabsShape };
@@ -1,5 +1,7 @@
1
1
  import "react-stately";
2
2
  /** 탭 목록의 방향. 세로면 ↓↑로 옮기고 탭 목록이 패널의 시작쪽에 선다. */
3
3
  export type TabsOrientation = "horizontal" | "vertical";
4
+ /** 고른 표시의 모양. `underline`은 밑줄, `box`는 옅은 바탕 위 둥근 사각형이다. */
5
+ export type TabsShape = "underline" | "box";
4
6
  /** 키보드로 탭을 옮겼을 때 바로 고를지(`automatic`), Enter·Space로 고를지(`manual`). */
5
7
  export type TabsActivationMode = "automatic" | "manual";
@@ -5,8 +5,11 @@ const choiceRootClass = "group/choice inline-flex items-start gap-2 align-top te
5
5
  const choiceAreaClass = "grid size-6 shrink-0 place-items-center";
6
6
  /** 네이티브 input을 상자·원으로 그린다. 선택 상태 모양은 Checkbox·Radio가 각자 더한다. */
7
7
  const choiceInputClass = "peer col-start-1 row-start-1 m-0 appearance-none border border-strong bg-canvas cursor-pointer transition-colors enabled:aria-invalid:border-danger focus-visible:focus-field disabled:cursor-not-allowed disabled:border-default disabled:bg-disabled not-forced-colors:aria-invalid:[--tide-accent-subtle:var(--tide-bg-danger-subtle)] not-forced-colors:aria-invalid:[--tide-accent-subtle-active:var(--tide-bg-danger-subtle-active)] not-forced-colors:aria-invalid:[--tide-accent-solid:var(--tide-bg-danger-solid)] not-forced-colors:aria-invalid:[--tide-accent-solid-hover:var(--tide-bg-danger-solid-hover)] not-forced-colors:aria-invalid:[--tide-accent-solid-active:var(--tide-bg-danger-solid-active)] forced-colors:forced-color-adjust-none forced-colors:[--tide-bg-canvas:Canvas] forced-colors:[--tide-border-strong:CanvasText] forced-colors:[--tide-border-danger:CanvasText] forced-colors:[--tide-accent-border:Highlight] forced-colors:[--tide-accent-solid:Highlight] forced-colors:[--tide-accent-solid-hover:Highlight] forced-colors:[--tide-accent-solid-active:Highlight] forced-colors:[--tide-accent-subtle:Canvas] forced-colors:[--tide-accent-subtle-active:Canvas] forced-colors:[--tide-border-default:GrayText] forced-colors:[--tide-bg-disabled:Canvas] forced-colors:[--tide-accent-subtle-border:Highlight] forced-colors:[--tide-border-danger-subtle:Highlight]";
8
- /** 상자 위에 겹치는 표시. 누름은 input이 받는다. 색과 보이는 조건 class는 Component가 붙인다. */
9
- const choiceMarkClass = "pointer-events-none col-start-1 row-start-1 hidden peer-disabled:text-disabled forced-colors:forced-color-adjust-none forced-colors:[--tide-text-disabled:GrayText]";
8
+ /**
9
+ * 상자 위에 겹치는 표시. 누름은 input이 받는다. 색과 보이는 조건 class는 Component가 붙인다.
10
+ * display를 바꾸지 않고 opacity로 숨긴다. display가 바뀌면 전환이 시작되지 않는다(ADR 0037).
11
+ */
12
+ const choiceMarkClass = "pointer-events-none col-start-1 row-start-1 opacity-0 transition-opacity peer-disabled:text-disabled forced-colors:forced-color-adjust-none forced-colors:[--tide-text-disabled:GrayText]";
10
13
  /** 글자 스타일. md 행간 24px은 조작 영역과 같고, sm 행간 20px은 위아래 2px을 둬 첫 줄을 상자 가운데에 맞춘다. */
11
14
  const choiceTextClass = {
12
15
  sm: "py-0.5 text-body-sm",
package/dist/index.d.ts CHANGED
@@ -100,7 +100,7 @@ import { AccordionHeadingLevel } from "./Accordion/types.js";
100
100
  import { AccordionTrigger, AccordionTriggerOwnProps, AccordionTriggerProps } from "./Accordion/components/AccordionTrigger.js";
101
101
  import { AccordionPanel, AccordionPanelOwnProps, AccordionPanelProps } from "./Accordion/components/AccordionPanel.js";
102
102
  import "./Tabs/index.js";
103
- import { TabsActivationMode, TabsOrientation } from "./Tabs/types.js";
103
+ import { TabsActivationMode, TabsOrientation, TabsShape } from "./Tabs/types.js";
104
104
  import { Tabs, TabsOwnProps, TabsProps } from "./Tabs/Tabs.js";
105
105
  import { TabList, TabListOwnProps, TabListProps } from "./Tabs/components/TabList.js";
106
106
  import { Tab, TabOwnProps, TabProps } from "./Tabs/components/Tab.js";
@@ -118,4 +118,4 @@ import { TooltipTrigger, TooltipTriggerOwnProps, TooltipTriggerProps } from "./T
118
118
  import { TooltipPlacement } from "./Tooltip/types.js";
119
119
  import { TooltipContent, TooltipContentOwnProps, TooltipContentProps } from "./Tooltip/components/TooltipContent.js";
120
120
  import { Color, ColorFamilyName, ColorFamilyRegistry, FillVariant, Role, RoleRegistry, Size } from "./types.js";
121
- export { Accordion, type AccordionHeadingLevel, AccordionItem, type AccordionItemOwnProps, type AccordionItemProps, type AccordionOwnProps, AccordionPanel, type AccordionPanelOwnProps, type AccordionPanelProps, type AccordionProps, AccordionTrigger, type AccordionTriggerOwnProps, type AccordionTriggerProps, Alert, AlertDialog, type AlertDialogProps, type AlertOwnProps, type AlertProps, Avatar, type AvatarOwnProps, type AvatarProps, Badge, type BadgeOwnProps, type BadgeProps, Breadcrumb, BreadcrumbCurrent, type BreadcrumbCurrentProps, BreadcrumbItem, type BreadcrumbItemProps, BreadcrumbLink, type BreadcrumbLinkOwnProps, type BreadcrumbLinkProps, type BreadcrumbOwnProps, type BreadcrumbProps, Button, type ButtonOwnProps, type ButtonProps, Card, type CardOwnProps, type CardProps, Checkbox, CheckboxGroup, type CheckboxGroupOwnProps, type CheckboxGroupProps, type CheckboxOwnProps, type CheckboxProps, type ChoiceOrientation, type Color, type ColorFamilyName, type ColorFamilyRegistry, Combobox, ComboboxItem, type ComboboxItemOwnProps, type ComboboxItemProps, type ComboboxOwnProps, type ComboboxProps, ComboboxSection, type ComboboxSectionProps, Dialog, DialogClose, type DialogCloseOwnProps, type DialogCloseProps, DialogContent, type DialogContentOwnProps, type DialogContentProps, DialogDescription, type DialogDescriptionProps, DialogFooter, type DialogFooterProps, type DialogProps, type DialogSize, DialogTitle, type DialogTitleProps, DialogTrigger, type DialogTriggerOwnProps, type DialogTriggerProps, Field, type FieldOwnProps, type FieldProps, type FillVariant, IconButton, type IconButtonOwnProps, type IconButtonProps, Input, type InputOwnProps, type InputProps, Link, type LinkOwnProps, type LinkProps, Menu, MenuContent, type MenuContentOwnProps, type MenuContentProps, MenuItem, type MenuItemOwnProps, type MenuItemProps, type MenuPlacement, type MenuProps, MenuSection, type MenuSectionProps, MenuTrigger, type MenuTriggerOwnProps, type MenuTriggerProps, Pagination, PaginationEllipsis, type PaginationEllipsisOwnProps, type PaginationEllipsisProps, PaginationItem, type PaginationItemProps, PaginationLink, type PaginationLinkOwnProps, type PaginationLinkProps, PaginationNext, type PaginationNextOwnProps, type PaginationNextProps, type PaginationOwnProps, PaginationPrevious, type PaginationPreviousOwnProps, type PaginationPreviousProps, type PaginationProps, Popover, PopoverContent, type PopoverContentOwnProps, type PopoverContentProps, type PopoverPlacement, type PopoverProps, PopoverTrigger, type PopoverTriggerOwnProps, type PopoverTriggerProps, Progress, type ProgressOwnProps, type ProgressProps, Radio, RadioGroup, type RadioGroupOwnProps, type RadioGroupProps, type RadioOwnProps, type RadioProps, type Role, type RoleRegistry, Select, SelectItem, type SelectItemOwnProps, type SelectItemProps, type SelectOwnProps, type SelectProps, SelectSection, type SelectSectionProps, Separator, type SeparatorOwnProps, type SeparatorProps, type Size, Skeleton, type SkeletonOwnProps, type SkeletonProps, Spinner, type SpinnerOwnProps, type SpinnerProps, Switch, type SwitchOwnProps, type SwitchProps, Tab, TabList, type TabListOwnProps, type TabListProps, type TabOwnProps, TabPanel, type TabPanelOwnProps, type TabPanelProps, type TabProps, Table, TableBody, type TableBodyProps, TableCell, type TableCellProps, TableHead, type TableHeadProps, TableHeaderCell, type TableHeaderCellOwnProps, type TableHeaderCellProps, type TableProps, TableRow, type TableRowProps, Tabs, type TabsActivationMode, type TabsOrientation, type TabsOwnProps, type TabsProps, Tag, TagGroup, type TagGroupOwnProps, type TagGroupProps, type TagOwnProps, type TagProps, Textarea, type TextareaOwnProps, type TextareaProps, type ToastAction, type ToastOptions, ToastQueue, type ToastQueueOptions, ToastRegion, type ToastRegionOwnProps, type ToastRegionProps, Tooltip, TooltipContent, type TooltipContentOwnProps, type TooltipContentProps, type TooltipPlacement, type TooltipProps, TooltipTrigger, type TooltipTriggerOwnProps, type TooltipTriggerProps, Typography, type TypographyOwnProps, type TypographyProps, VisuallyHidden, type VisuallyHiddenProps, cn };
121
+ export { Accordion, type AccordionHeadingLevel, AccordionItem, type AccordionItemOwnProps, type AccordionItemProps, type AccordionOwnProps, AccordionPanel, type AccordionPanelOwnProps, type AccordionPanelProps, type AccordionProps, AccordionTrigger, type AccordionTriggerOwnProps, type AccordionTriggerProps, Alert, AlertDialog, type AlertDialogProps, type AlertOwnProps, type AlertProps, Avatar, type AvatarOwnProps, type AvatarProps, Badge, type BadgeOwnProps, type BadgeProps, Breadcrumb, BreadcrumbCurrent, type BreadcrumbCurrentProps, BreadcrumbItem, type BreadcrumbItemProps, BreadcrumbLink, type BreadcrumbLinkOwnProps, type BreadcrumbLinkProps, type BreadcrumbOwnProps, type BreadcrumbProps, Button, type ButtonOwnProps, type ButtonProps, Card, type CardOwnProps, type CardProps, Checkbox, CheckboxGroup, type CheckboxGroupOwnProps, type CheckboxGroupProps, type CheckboxOwnProps, type CheckboxProps, type ChoiceOrientation, type Color, type ColorFamilyName, type ColorFamilyRegistry, Combobox, ComboboxItem, type ComboboxItemOwnProps, type ComboboxItemProps, type ComboboxOwnProps, type ComboboxProps, ComboboxSection, type ComboboxSectionProps, Dialog, DialogClose, type DialogCloseOwnProps, type DialogCloseProps, DialogContent, type DialogContentOwnProps, type DialogContentProps, DialogDescription, type DialogDescriptionProps, DialogFooter, type DialogFooterProps, type DialogProps, type DialogSize, DialogTitle, type DialogTitleProps, DialogTrigger, type DialogTriggerOwnProps, type DialogTriggerProps, Field, type FieldOwnProps, type FieldProps, type FillVariant, IconButton, type IconButtonOwnProps, type IconButtonProps, Input, type InputOwnProps, type InputProps, Link, type LinkOwnProps, type LinkProps, Menu, MenuContent, type MenuContentOwnProps, type MenuContentProps, MenuItem, type MenuItemOwnProps, type MenuItemProps, type MenuPlacement, type MenuProps, MenuSection, type MenuSectionProps, MenuTrigger, type MenuTriggerOwnProps, type MenuTriggerProps, Pagination, PaginationEllipsis, type PaginationEllipsisOwnProps, type PaginationEllipsisProps, PaginationItem, type PaginationItemProps, PaginationLink, type PaginationLinkOwnProps, type PaginationLinkProps, PaginationNext, type PaginationNextOwnProps, type PaginationNextProps, type PaginationOwnProps, PaginationPrevious, type PaginationPreviousOwnProps, type PaginationPreviousProps, type PaginationProps, Popover, PopoverContent, type PopoverContentOwnProps, type PopoverContentProps, type PopoverPlacement, type PopoverProps, PopoverTrigger, type PopoverTriggerOwnProps, type PopoverTriggerProps, Progress, type ProgressOwnProps, type ProgressProps, Radio, RadioGroup, type RadioGroupOwnProps, type RadioGroupProps, type RadioOwnProps, type RadioProps, type Role, type RoleRegistry, Select, SelectItem, type SelectItemOwnProps, type SelectItemProps, type SelectOwnProps, type SelectProps, SelectSection, type SelectSectionProps, Separator, type SeparatorOwnProps, type SeparatorProps, type Size, Skeleton, type SkeletonOwnProps, type SkeletonProps, Spinner, type SpinnerOwnProps, type SpinnerProps, Switch, type SwitchOwnProps, type SwitchProps, Tab, TabList, type TabListOwnProps, type TabListProps, type TabOwnProps, TabPanel, type TabPanelOwnProps, type TabPanelProps, type TabProps, Table, TableBody, type TableBodyProps, TableCell, type TableCellProps, TableHead, type TableHeadProps, TableHeaderCell, type TableHeaderCellOwnProps, type TableHeaderCellProps, type TableProps, TableRow, type TableRowProps, Tabs, type TabsActivationMode, type TabsOrientation, type TabsOwnProps, type TabsProps, type TabsShape, Tag, TagGroup, type TagGroupOwnProps, type TagGroupProps, type TagOwnProps, type TagProps, Textarea, type TextareaOwnProps, type TextareaProps, type ToastAction, type ToastOptions, ToastQueue, type ToastQueueOptions, ToastRegion, type ToastRegionOwnProps, type ToastRegionProps, Tooltip, TooltipContent, type TooltipContentOwnProps, type TooltipContentProps, type TooltipPlacement, type TooltipProps, TooltipTrigger, type TooltipTriggerOwnProps, type TooltipTriggerProps, Typography, type TypographyOwnProps, type TypographyProps, VisuallyHidden, type VisuallyHiddenProps, cn };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tide-design/components",
3
- "version": "0.17.0",
3
+ "version": "0.18.0",
4
4
  "description": "Tide 디자인 시스템의 React Component",
5
5
  "keywords": [
6
6
  "accessibility",
@@ -34,8 +34,8 @@
34
34
  "./styles.css": "./dist/styles.css"
35
35
  },
36
36
  "dependencies": {
37
- "@tide-design/foundation": "0.17.0",
38
- "@tide-design/icons": "0.17.0",
37
+ "@tide-design/foundation": "0.18.0",
38
+ "@tide-design/icons": "0.18.0",
39
39
  "clsx": "^2.1.1",
40
40
  "react-aria": "^3.53.1",
41
41
  "react-stately": "^3.51.0",