@tide-design/components 0.11.1 → 0.11.2

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.
Files changed (288) hide show
  1. package/dist/Accordion/Accordion.d.ts +24 -0
  2. package/dist/Accordion/Accordion.js +32 -0
  3. package/dist/Accordion/components/AccordionItem.d.ts +14 -0
  4. package/dist/Accordion/components/AccordionItem.js +51 -0
  5. package/dist/Accordion/components/AccordionPanel.d.ts +13 -0
  6. package/dist/Accordion/components/AccordionPanel.js +27 -0
  7. package/dist/Accordion/components/AccordionTrigger.d.ts +17 -0
  8. package/dist/Accordion/components/AccordionTrigger.js +39 -0
  9. package/dist/Accordion/constants/accordionClass.js +12 -0
  10. package/dist/Accordion/hooks/useAccordionContext.js +8 -0
  11. package/dist/Accordion/hooks/useAccordionItemContext.js +13 -0
  12. package/dist/Accordion/index.d.ts +6 -0
  13. package/dist/Accordion/types.d.ts +2 -0
  14. package/dist/{Alert.d.ts → Alert/Alert.d.ts} +1 -1
  15. package/dist/{Alert.js → Alert/Alert.js} +5 -5
  16. package/dist/Alert/index.d.ts +2 -0
  17. package/dist/{AlertDialog.d.ts → AlertDialog/AlertDialog.d.ts} +1 -1
  18. package/dist/{AlertDialog.js → AlertDialog/AlertDialog.js} +2 -2
  19. package/dist/AlertDialog/index.d.ts +2 -0
  20. package/dist/{Avatar.d.ts → Avatar/Avatar.d.ts} +1 -1
  21. package/dist/{Avatar.js → Avatar/Avatar.js} +2 -2
  22. package/dist/Avatar/index.d.ts +2 -0
  23. package/dist/{Badge.d.ts → Badge/Badge.d.ts} +1 -1
  24. package/dist/{Badge.js → Badge/Badge.js} +2 -2
  25. package/dist/Badge/index.d.ts +2 -0
  26. package/dist/Breadcrumb/Breadcrumb.d.ts +11 -0
  27. package/dist/Breadcrumb/Breadcrumb.js +21 -0
  28. package/dist/Breadcrumb/components/BreadcrumbCurrent.d.ts +4 -0
  29. package/dist/Breadcrumb/components/BreadcrumbCurrent.js +15 -0
  30. package/dist/Breadcrumb/components/BreadcrumbItem.d.ts +4 -0
  31. package/dist/Breadcrumb/components/BreadcrumbItem.js +16 -0
  32. package/dist/Breadcrumb/components/BreadcrumbLink.d.ts +10 -0
  33. package/dist/Breadcrumb/components/BreadcrumbLink.js +15 -0
  34. package/dist/Breadcrumb/constants/breadcrumbClass.js +8 -0
  35. package/dist/Breadcrumb/index.d.ts +5 -0
  36. package/dist/{Button.d.ts → Button/Button.d.ts} +3 -7
  37. package/dist/{Button.js → Button/Button.js} +8 -27
  38. package/dist/Button/components/Icon.js +13 -0
  39. package/dist/Button/constants/buttonClass.js +17 -0
  40. package/dist/Button/index.d.ts +2 -0
  41. package/dist/Button/types.d.ts +5 -0
  42. package/dist/{Card.js → Card/Card.js} +2 -2
  43. package/dist/Card/index.d.ts +2 -0
  44. package/dist/{Checkbox.d.ts → Checkbox/Checkbox.d.ts} +2 -2
  45. package/dist/{Checkbox.js → Checkbox/Checkbox.js} +5 -5
  46. package/dist/Checkbox/index.d.ts +2 -0
  47. package/dist/{CheckboxGroup.d.ts → CheckboxGroup/CheckboxGroup.d.ts} +3 -3
  48. package/dist/{CheckboxGroup.js → CheckboxGroup/CheckboxGroup.js} +6 -10
  49. package/dist/CheckboxGroup/index.d.ts +3 -0
  50. package/dist/{Combobox.d.ts → Combobox/Combobox.d.ts} +2 -17
  51. package/dist/{Combobox.js → Combobox/Combobox.js} +10 -99
  52. package/dist/Combobox/components/ComboboxItem.d.ts +9 -0
  53. package/dist/Combobox/components/ComboboxItem.js +17 -0
  54. package/dist/Combobox/components/ComboboxPopover.js +23 -0
  55. package/dist/Combobox/components/ComboboxPopoverInner.js +50 -0
  56. package/dist/Combobox/components/ComboboxSection.d.ts +7 -0
  57. package/dist/Combobox/components/ComboboxSection.js +15 -0
  58. package/dist/Combobox/constants/comboboxClass.js +21 -0
  59. package/dist/Combobox/index.d.ts +4 -0
  60. package/dist/Dialog/Dialog.d.ts +8 -0
  61. package/dist/Dialog/Dialog.js +18 -0
  62. package/dist/Dialog/components/DialogClose.d.ts +13 -0
  63. package/dist/Dialog/components/DialogClose.js +35 -0
  64. package/dist/Dialog/components/DialogContent.d.ts +15 -0
  65. package/dist/Dialog/components/DialogContent.js +31 -0
  66. package/dist/Dialog/components/DialogContentInner.js +68 -0
  67. package/dist/Dialog/components/DialogDescription.d.ts +7 -0
  68. package/dist/Dialog/components/DialogDescription.js +23 -0
  69. package/dist/Dialog/components/DialogFooter.d.ts +4 -0
  70. package/dist/Dialog/components/DialogFooter.js +13 -0
  71. package/dist/Dialog/components/DialogTitle.d.ts +7 -0
  72. package/dist/Dialog/components/DialogTitle.js +23 -0
  73. package/dist/Dialog/components/DialogTrigger.d.ts +13 -0
  74. package/dist/Dialog/components/DialogTrigger.js +49 -0
  75. package/dist/Dialog/constants/dialogClass.js +12 -0
  76. package/dist/Dialog/hooks/useDialogPartsContext.js +13 -0
  77. package/dist/Dialog/hooks/usePartId.js +17 -0
  78. package/dist/Dialog/index.d.ts +10 -0
  79. package/dist/Dialog/types.d.ts +2 -0
  80. package/dist/{Field.js → Field/Field.js} +3 -3
  81. package/dist/Field/index.d.ts +2 -0
  82. package/dist/{IconButton.d.ts → IconButton/IconButton.d.ts} +1 -1
  83. package/dist/{IconButton.js → IconButton/IconButton.js} +5 -5
  84. package/dist/IconButton/index.d.ts +2 -0
  85. package/dist/{Input.d.ts → Input/Input.d.ts} +1 -1
  86. package/dist/{Input.js → Input/Input.js} +4 -4
  87. package/dist/Input/index.d.ts +2 -0
  88. package/dist/{Link.d.ts → Link/Link.d.ts} +1 -1
  89. package/dist/{Link.js → Link/Link.js} +2 -2
  90. package/dist/Link/index.d.ts +2 -0
  91. package/dist/Menu/Menu.d.ts +16 -0
  92. package/dist/Menu/Menu.js +43 -0
  93. package/dist/Menu/components/MenuContent.d.ts +16 -0
  94. package/dist/Menu/components/MenuContent.js +30 -0
  95. package/dist/Menu/components/MenuContentInner.js +67 -0
  96. package/dist/Menu/components/MenuItem.d.ts +17 -0
  97. package/dist/Menu/components/MenuItem.js +16 -0
  98. package/dist/Menu/components/MenuItemView.js +34 -0
  99. package/dist/Menu/components/MenuSection.d.ts +13 -0
  100. package/dist/Menu/components/MenuSection.js +15 -0
  101. package/dist/Menu/components/MenuSectionView.js +33 -0
  102. package/dist/Menu/components/MenuTrigger.d.ts +13 -0
  103. package/dist/Menu/components/MenuTrigger.js +53 -0
  104. package/dist/Menu/hooks/useMenuContext.js +13 -0
  105. package/dist/Menu/index.d.ts +7 -0
  106. package/dist/Menu/types.d.ts +4 -0
  107. package/dist/Pagination/Pagination.d.ts +11 -0
  108. package/dist/Pagination/Pagination.js +21 -0
  109. package/dist/Pagination/components/PaginationEllipsis.d.ts +7 -0
  110. package/dist/Pagination/components/PaginationEllipsis.js +17 -0
  111. package/dist/Pagination/components/PaginationItem.d.ts +4 -0
  112. package/dist/Pagination/components/PaginationItem.js +9 -0
  113. package/dist/Pagination/components/PaginationLink.d.ts +15 -0
  114. package/dist/Pagination/components/PaginationLink.js +23 -0
  115. package/dist/Pagination/components/PaginationNext.d.ts +5 -0
  116. package/dist/Pagination/components/PaginationNext.js +18 -0
  117. package/dist/Pagination/components/PaginationPrevious.d.ts +5 -0
  118. package/dist/Pagination/components/PaginationPrevious.js +18 -0
  119. package/dist/Pagination/constants/paginationClass.js +6 -0
  120. package/dist/Pagination/index.d.ts +7 -0
  121. package/dist/Pagination/types.d.ts +6 -0
  122. package/dist/Popover/Popover.d.ts +16 -0
  123. package/dist/Popover/Popover.js +43 -0
  124. package/dist/Popover/components/PopoverContent.d.ts +14 -0
  125. package/dist/Popover/components/PopoverContent.js +30 -0
  126. package/dist/Popover/components/PopoverContentInner.js +48 -0
  127. package/dist/Popover/components/PopoverTrigger.d.ts +13 -0
  128. package/dist/Popover/components/PopoverTrigger.js +51 -0
  129. package/dist/Popover/constants/popoverClass.js +6 -0
  130. package/dist/Popover/hooks/usePopoverContext.js +13 -0
  131. package/dist/Popover/index.d.ts +5 -0
  132. package/dist/Popover/types.d.ts +3 -0
  133. package/dist/{Progress.d.ts → Progress/Progress.d.ts} +1 -1
  134. package/dist/{Progress.js → Progress/Progress.js} +2 -2
  135. package/dist/Progress/index.d.ts +2 -0
  136. package/dist/{Radio.d.ts → Radio/Radio.d.ts} +2 -2
  137. package/dist/{Radio.js → Radio/Radio.js} +5 -5
  138. package/dist/Radio/index.d.ts +2 -0
  139. package/dist/{RadioGroup.d.ts → RadioGroup/RadioGroup.d.ts} +1 -1
  140. package/dist/{RadioGroup.js → RadioGroup/RadioGroup.js} +5 -5
  141. package/dist/RadioGroup/index.d.ts +2 -0
  142. package/dist/{Select.d.ts → Select/Select.d.ts} +2 -17
  143. package/dist/Select/Select.js +97 -0
  144. package/dist/Select/components/SelectItem.d.ts +9 -0
  145. package/dist/Select/components/SelectItem.js +17 -0
  146. package/dist/Select/components/SelectPopover.js +23 -0
  147. package/dist/Select/components/SelectPopoverInner.js +51 -0
  148. package/dist/Select/components/SelectSection.d.ts +7 -0
  149. package/dist/Select/components/SelectSection.js +15 -0
  150. package/dist/Select/constants/selectClass.js +7 -0
  151. package/dist/Select/index.d.ts +4 -0
  152. package/dist/{Separator.js → Separator/Separator.js} +2 -2
  153. package/dist/Separator/index.d.ts +2 -0
  154. package/dist/{Skeleton.d.ts → Skeleton/Skeleton.d.ts} +1 -1
  155. package/dist/{Skeleton.js → Skeleton/Skeleton.js} +2 -2
  156. package/dist/Skeleton/index.d.ts +2 -0
  157. package/dist/{Spinner.d.ts → Spinner/Spinner.d.ts} +1 -1
  158. package/dist/{Spinner.js → Spinner/Spinner.js} +2 -2
  159. package/dist/Spinner/index.d.ts +2 -0
  160. package/dist/{Switch.d.ts → Switch/Switch.d.ts} +1 -1
  161. package/dist/{Switch.js → Switch/Switch.js} +3 -3
  162. package/dist/Switch/index.d.ts +2 -0
  163. package/dist/Table/Table.d.ts +7 -0
  164. package/dist/Table/Table.js +17 -0
  165. package/dist/Table/components/TableBody.d.ts +4 -0
  166. package/dist/Table/components/TableBody.js +9 -0
  167. package/dist/Table/components/TableCell.d.ts +4 -0
  168. package/dist/Table/components/TableCell.js +14 -0
  169. package/dist/Table/components/TableHead.d.ts +4 -0
  170. package/dist/Table/components/TableHead.js +9 -0
  171. package/dist/Table/components/TableHeaderCell.d.ts +13 -0
  172. package/dist/Table/components/TableHeaderCell.js +18 -0
  173. package/dist/Table/components/TableRow.d.ts +4 -0
  174. package/dist/Table/components/TableRow.js +14 -0
  175. package/dist/Table/constants/tableClass.js +7 -0
  176. package/dist/Table/index.d.ts +7 -0
  177. package/dist/Tabs/Tabs.d.ts +34 -0
  178. package/dist/Tabs/Tabs.js +56 -0
  179. package/dist/Tabs/components/Tab.d.ts +12 -0
  180. package/dist/Tabs/components/Tab.js +16 -0
  181. package/dist/Tabs/components/TabList.d.ts +10 -0
  182. package/dist/Tabs/components/TabList.js +47 -0
  183. package/dist/Tabs/components/TabPanel.d.ts +10 -0
  184. package/dist/Tabs/components/TabPanel.js +27 -0
  185. package/dist/Tabs/components/TabView.js +29 -0
  186. package/dist/Tabs/constants/tabsClass.js +23 -0
  187. package/dist/Tabs/hooks/useTabsContext.js +13 -0
  188. package/dist/Tabs/index.d.ts +6 -0
  189. package/dist/Tabs/types.d.ts +5 -0
  190. package/dist/Tag/Tag.d.ts +18 -0
  191. package/dist/Tag/Tag.js +15 -0
  192. package/dist/{Tag.d.ts → Tag/components/TagGroup.d.ts} +0 -17
  193. package/dist/Tag/components/TagGroup.js +49 -0
  194. package/dist/Tag/components/TagView.js +49 -0
  195. package/dist/Tag/constants/tagClass.js +13 -0
  196. package/dist/Tag/hooks/useTagGroupContext.js +8 -0
  197. package/dist/Tag/index.d.ts +3 -0
  198. package/dist/{Textarea.d.ts → Textarea/Textarea.d.ts} +1 -1
  199. package/dist/{Textarea.js → Textarea/Textarea.js} +4 -4
  200. package/dist/Textarea/index.d.ts +2 -0
  201. package/dist/Toast/Toast.d.ts +15 -0
  202. package/dist/Toast/Toast.js +43 -0
  203. package/dist/Toast/components/Region.js +28 -0
  204. package/dist/Toast/components/ToastItem.js +82 -0
  205. package/dist/Toast/constants/toastClass.js +8 -0
  206. package/dist/Toast/index.d.ts +4 -0
  207. package/dist/Toast/libs/mergeEntries.js +19 -0
  208. package/dist/Toast/libs/toastQueue.d.ts +20 -0
  209. package/dist/Toast/libs/toastQueue.js +49 -0
  210. package/dist/{Toast.d.ts → Toast/types.d.ts} +4 -33
  211. package/dist/Tooltip/Tooltip.d.ts +25 -0
  212. package/dist/Tooltip/Tooltip.js +42 -0
  213. package/dist/Tooltip/components/TooltipContent.d.ts +14 -0
  214. package/dist/Tooltip/components/TooltipContent.js +31 -0
  215. package/dist/Tooltip/components/TooltipContentInner.js +43 -0
  216. package/dist/Tooltip/components/TooltipTrigger.d.ts +14 -0
  217. package/dist/Tooltip/components/TooltipTrigger.js +38 -0
  218. package/dist/Tooltip/constants/tooltipClass.js +6 -0
  219. package/dist/Tooltip/hooks/useTooltipContext.js +13 -0
  220. package/dist/Tooltip/index.d.ts +5 -0
  221. package/dist/Tooltip/types.d.ts +3 -0
  222. package/dist/{Typography.js → Typography/Typography.js} +2 -2
  223. package/dist/Typography/index.d.ts +2 -0
  224. package/dist/{VisuallyHidden.js → VisuallyHidden/VisuallyHidden.js} +2 -2
  225. package/dist/VisuallyHidden/index.d.ts +2 -0
  226. package/dist/_internal/components/DialogRoot.d.ts +11 -0
  227. package/dist/_internal/components/DialogRoot.js +41 -0
  228. package/dist/_internal/components/ListBoxNodes/ListBoxNodes.js +35 -0
  229. package/dist/_internal/components/ListBoxNodes/components/ListBoxOptionView.js +42 -0
  230. package/dist/_internal/components/ListBoxNodes/components/ListBoxSectionView.js +33 -0
  231. package/dist/{components/ListBoxNodes.d.ts → _internal/components/ListBoxNodes/types.d.ts} +1 -1
  232. package/dist/{components → _internal/components}/OverlayPortal.js +1 -1
  233. package/dist/{constants → _internal/constants}/alertClass.js +1 -1
  234. package/dist/{constants → _internal/constants}/choiceClass.js +1 -1
  235. package/dist/_internal/constants/choiceGroupClass.d.ts +2 -0
  236. package/dist/_internal/constants/choiceGroupClass.js +8 -0
  237. package/dist/{constants → _internal/constants}/inputClass.d.ts +1 -1
  238. package/dist/{constants → _internal/constants}/inputClass.js +1 -1
  239. package/dist/{constants → _internal/constants}/listClass.js +1 -1
  240. package/dist/{constants → _internal/constants}/overlayClass.js +1 -1
  241. package/dist/{constants → _internal/constants}/pressableClass.js +1 -1
  242. package/dist/{hooks → _internal/hooks}/useChoiceGroup.js +1 -1
  243. package/dist/{hooks → _internal/hooks}/useCloseOnTab.js +1 -1
  244. package/dist/_internal/hooks/useDialogContext.js +14 -0
  245. package/dist/{hooks → _internal/hooks}/useFieldControl.js +1 -1
  246. package/dist/{hooks → _internal/hooks}/useOverlayPresence.js +1 -1
  247. package/dist/{hooks → _internal/hooks}/useOverlayTheme.js +1 -1
  248. package/dist/{hooks → _internal/hooks}/usePopoverOverlay.js +1 -1
  249. package/dist/{libs → _internal/libs}/alertStatusIcon.js +1 -1
  250. package/dist/{libs → _internal/libs}/cn.js +1 -1
  251. package/dist/{libs → _internal/libs}/listCollection.js +1 -1
  252. package/dist/{libs → _internal/libs}/overlayPosition.js +1 -1
  253. package/dist/{libs → _internal/libs}/pressableState.js +1 -1
  254. package/dist/{libs → _internal/libs}/renderElement.js +1 -1
  255. package/dist/index.d.ts +119 -36
  256. package/dist/index.js +75 -36
  257. package/package.json +3 -3
  258. package/dist/Accordion.d.ts +0 -66
  259. package/dist/Accordion.js +0 -127
  260. package/dist/Breadcrumb.d.ts +0 -26
  261. package/dist/Breadcrumb.js +0 -53
  262. package/dist/Dialog.d.ts +0 -70
  263. package/dist/Dialog.js +0 -257
  264. package/dist/Menu.d.ts +0 -72
  265. package/dist/Menu.js +0 -230
  266. package/dist/Pagination.d.ts +0 -46
  267. package/dist/Pagination.js +0 -79
  268. package/dist/Popover.d.ts +0 -43
  269. package/dist/Popover.js +0 -150
  270. package/dist/Select.js +0 -173
  271. package/dist/Table.d.ts +0 -31
  272. package/dist/Table.js +0 -53
  273. package/dist/Tabs.d.ts +0 -66
  274. package/dist/Tabs.js +0 -159
  275. package/dist/Tag.js +0 -102
  276. package/dist/Toast.js +0 -193
  277. package/dist/Tooltip.d.ts +0 -53
  278. package/dist/Tooltip.js +0 -132
  279. package/dist/components/ListBoxNodes.js +0 -90
  280. /package/dist/{Card.d.ts → Card/Card.d.ts} +0 -0
  281. /package/dist/{Field.d.ts → Field/Field.d.ts} +0 -0
  282. /package/dist/{Separator.d.ts → Separator/Separator.d.ts} +0 -0
  283. /package/dist/{Typography.d.ts → Typography/Typography.d.ts} +0 -0
  284. /package/dist/{VisuallyHidden.d.ts → VisuallyHidden/VisuallyHidden.d.ts} +0 -0
  285. /package/dist/{constants → _internal/constants}/choiceClass.d.ts +0 -0
  286. /package/dist/{libs → _internal/libs}/cn.d.ts +0 -0
  287. /package/dist/{libs → _internal/libs}/listCollection.d.ts +0 -0
  288. /package/dist/{libs → _internal/libs}/overlayPosition.d.ts +0 -0
@@ -0,0 +1,10 @@
1
+ import { ComponentProps, ReactElement, ReactNode } from "react";
2
+ export interface TabListProps extends Omit<ComponentProps<"div">, "role" | "children"> {
3
+ /** `Tab`. 바로 아래(또는 Fragment·배열 안)에 둔다. */
4
+ children?: ReactNode;
5
+ }
6
+ /**
7
+ * 탭 목록(`role="tablist"`). 화살표로 탭을 옮기고(끝에서 처음으로 돈다) Home·End로 처음·마지막 탭에 간다.
8
+ * 비활성 탭은 건너뛴다. 이름은 `aria-label`이나 `aria-labelledby`로 준다.
9
+ */
10
+ export declare function TabList({ ref, className, children, ...props }: TabListProps): ReactElement;
@@ -0,0 +1,47 @@
1
+ "use client";
2
+
3
+ import { cn } from "../../_internal/libs/cn.js";
4
+ import { resolveCollectionChildren } from "../../_internal/libs/listCollection.js";
5
+ import { tabListOrientationClass } from "../constants/tabsClass.js";
6
+ import { useTabsContext } from "../hooks/useTabsContext.js";
7
+ import { TabView } from "./TabView.js";
8
+ import { jsx } from "react/jsx-runtime";
9
+ import { isValidElement, useMemo, useRef } from "react";
10
+ import { mergeProps, mergeRefs, useTabList } from "react-aria";
11
+ import { useTabListState } from "react-stately";
12
+
13
+ // src/Tabs/components/TabList.tsx
14
+ /**
15
+ * 탭 목록(`role="tablist"`). 화살표로 탭을 옮기고(끝에서 처음으로 돈다) Home·End로 처음·마지막 탭에 간다.
16
+ * 비활성 탭은 건너뛴다. 이름은 `aria-label`이나 `aria-labelledby`로 준다.
17
+ */
18
+ function TabList({ ref, className, children, ...props }) {
19
+ const context = useTabsContext("TabList");
20
+ const listRef = useRef(null);
21
+ const items = useMemo(() => resolveCollectionChildren(children), [children]);
22
+ const known = items.some((item) => isValidElement(item) && item.props.value === context.value);
23
+ const state = useTabListState({
24
+ children: items,
25
+ selectedKey: known ? context.value : null,
26
+ onSelectionChange: (key) => context.setValue(String(key))
27
+ });
28
+ const { tabListProps } = useTabList({
29
+ orientation: context.orientation,
30
+ keyboardActivation: context.activationMode,
31
+ "aria-label": props["aria-label"],
32
+ "aria-labelledby": props["aria-labelledby"]
33
+ }, state, listRef);
34
+ const mergedRef = useMemo(() => mergeRefs(ref, listRef), [ref, listRef]);
35
+ return /* @__PURE__ */ jsx("div", {
36
+ ...mergeProps(props, tabListProps),
37
+ ref: mergedRef,
38
+ className: cn(tabListOrientationClass[context.orientation], className),
39
+ children: [...state.collection].map((node) => /* @__PURE__ */ jsx(TabView, {
40
+ node,
41
+ state,
42
+ context
43
+ }, node.key))
44
+ });
45
+ }
46
+
47
+ export { TabList };
@@ -0,0 +1,10 @@
1
+ import { ComponentProps, ReactElement } from "react";
2
+ export interface TabPanelProps extends Omit<ComponentProps<"div">, "id" | "role"> {
3
+ /** 이어지는 `Tab`의 값. 그 탭을 고른 동안만 렌더한다. */
4
+ value: string;
5
+ }
6
+ /**
7
+ * 탭 하나의 내용(`role="tabpanel"`). 같은 `value`의 탭을 고른 동안만 렌더하고, 그 탭이 이름이 된다(`aria-labelledby`).
8
+ * 탭 다음 Tab 순서에 들어간다(`tabIndex` 기본 `0`). 첫 내용이 조작 요소면 `tabIndex={-1}`로 뺄 수 있다.
9
+ */
10
+ export declare function TabPanel({ value, ref, className, tabIndex, ...props }: TabPanelProps): ReactElement | null;
@@ -0,0 +1,27 @@
1
+ "use client";
2
+
3
+ import { cn } from "../../_internal/libs/cn.js";
4
+ import { tabPanelClass } from "../constants/tabsClass.js";
5
+ import { useTabsContext } from "../hooks/useTabsContext.js";
6
+ import { jsx } from "react/jsx-runtime";
7
+
8
+ // src/Tabs/components/TabPanel.tsx
9
+ /**
10
+ * 탭 하나의 내용(`role="tabpanel"`). 같은 `value`의 탭을 고른 동안만 렌더하고, 그 탭이 이름이 된다(`aria-labelledby`).
11
+ * 탭 다음 Tab 순서에 들어간다(`tabIndex` 기본 `0`). 첫 내용이 조작 요소면 `tabIndex={-1}`로 뺄 수 있다.
12
+ */
13
+ function TabPanel({ value, ref, className, tabIndex = 0, ...props }) {
14
+ const context = useTabsContext("TabPanel");
15
+ if (context.value !== value) return null;
16
+ return /* @__PURE__ */ jsx("div", {
17
+ ...props,
18
+ ref,
19
+ role: "tabpanel",
20
+ id: context.panelId(value),
21
+ "aria-labelledby": context.tabId(value),
22
+ tabIndex,
23
+ className: cn(tabPanelClass, className)
24
+ });
25
+ }
26
+
27
+ export { TabPanel };
@@ -0,0 +1,29 @@
1
+ "use client";
2
+
3
+ import { cn } from "../../_internal/libs/cn.js";
4
+ import { tabBaseClass, tabOrientationClass } from "../constants/tabsClass.js";
5
+ import { jsx } from "react/jsx-runtime";
6
+ import { useMemo, useRef } from "react";
7
+ import { mergeProps, mergeRefs, useTab } from "react-aria";
8
+
9
+ // src/Tabs/components/TabView.tsx
10
+ /** 탭 하나를 그린다. node.props는 앱이 Tab에 준 props(와 컬렉션이 더한 isDisabled)다. */
11
+ function TabView({ node, state, context }) {
12
+ const tabRef = useRef(null);
13
+ const { ref, className, value, disabled: _disabled, isDisabled: _isDisabled, children: _children, onFocus: _onFocus, onBlur: _onBlur, onKeyDown: _onKeyDown, onKeyUp: _onKeyUp, autoFocus: _autoFocus, ...props } = node.props;
14
+ const { tabProps, isSelected, isDisabled } = useTab({ key: node.key }, state, tabRef);
15
+ const mergedRef = useMemo(() => mergeRefs(ref, tabRef), [ref, tabRef]);
16
+ return /* @__PURE__ */ jsx("button", {
17
+ ...mergeProps(props, tabProps),
18
+ ref: mergedRef,
19
+ type: "button",
20
+ id: context.tabId(value),
21
+ "aria-controls": isSelected ? context.panelId(value) : void 0,
22
+ disabled: isDisabled || void 0,
23
+ "data-selected": isSelected ? "" : void 0,
24
+ className: cn(tabBaseClass, tabOrientationClass[context.orientation], className),
25
+ children: node.rendered
26
+ });
27
+ }
28
+
29
+ export { TabView };
@@ -0,0 +1,23 @@
1
+ // src/Tabs/constants/tabsClass.ts
2
+ const tabsOrientationClass = {
3
+ horizontal: "flex flex-col gap-4",
4
+ vertical: "flex flex-row gap-6"
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"
9
+ };
10
+ const tabBaseClass = [
11
+ "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
+ "hover:not-data-selected:enabled:text-default data-selected:text-primary focus-visible:focus-ring",
13
+ "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]"
16
+ ].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"
20
+ };
21
+ const tabPanelClass = "min-w-0 flex-1 rounded-md outline-none focus-visible:focus-ring";
22
+
23
+ export { tabBaseClass, tabListOrientationClass, tabOrientationClass, tabPanelClass, tabsOrientationClass };
@@ -0,0 +1,13 @@
1
+ "use client";
2
+
3
+ import { createContext, use } from "react";
4
+
5
+ // src/Tabs/hooks/useTabsContext.ts
6
+ const TabsContext = createContext(null);
7
+ function useTabsContext(part) {
8
+ const context = use(TabsContext);
9
+ if (!context) throw new Error(`${part}는 Tabs 안에 둔다.`);
10
+ return context;
11
+ }
12
+
13
+ export { TabsContext, useTabsContext };
@@ -0,0 +1,6 @@
1
+ import { Tabs, TabsProps } from "./Tabs.js";
2
+ import { TabList, TabListProps } from "./components/TabList.js";
3
+ import { Tab, TabProps } from "./components/Tab.js";
4
+ import { TabPanel, TabPanelProps } from "./components/TabPanel.js";
5
+ import { TabsActivationMode, TabsOrientation } from "./types.js";
6
+ export { Tab, TabList, type TabListProps, TabPanel, type TabPanelProps, type TabProps, Tabs, type TabsActivationMode, type TabsOrientation, type TabsProps };
@@ -0,0 +1,5 @@
1
+ import "react-stately";
2
+ /** 탭 목록의 방향. 세로면 ↓↑로 옮기고 탭 목록이 패널의 시작쪽에 선다. */
3
+ export type TabsOrientation = "horizontal" | "vertical";
4
+ /** 키보드로 탭을 옮겼을 때 바로 고를지(`automatic`), Enter·Space로 고를지(`manual`). */
5
+ export type TabsActivationMode = "automatic" | "manual";
@@ -0,0 +1,18 @@
1
+ import { CollectionValueItemProps } from "../_internal/libs/listCollection.js";
2
+ import { ColorFamilyName } from "../types.js";
3
+ import { ComponentProps, ReactNode } from "react";
4
+ export interface TagProps extends Omit<ComponentProps<"div">, "color" | "role" | "id" | "tabIndex" | "children">, CollectionValueItemProps {
5
+ /** 태그 글자. 필수다. 아이콘(장식용)을 앞에 함께 둘 수 있다. */
6
+ children: ReactNode;
7
+ /**
8
+ * 색 계열 이름. Tide 색 계열 8개(장식 계열 purple·mint 포함)와 앱이 `ColorFamilyRegistry`에 더한 계열을 받는다. 기본값은 `gray`다.
9
+ * 분류를 구분하는 뜻 없는 색이라 Role(`primary`·`danger` 등)은 받지 않는다(ADR 0016·0017 후속).
10
+ * 루트에 `data-color`로 붙고 바깥 요소의 색을 물려받지 않는다.
11
+ */
12
+ color?: ColorFamilyName;
13
+ }
14
+ /**
15
+ * 태그 하나(`role="row"`). `TagGroup` 바로 안에 둔다. `value`가 묶음 안의 key이고 `onRemove`에 넘어오는 값이다.
16
+ * `disabled`면 지울 수 없고 키보드 이동도 건너뛴다(`aria-disabled`).
17
+ */
18
+ export declare function Tag(_props: TagProps): null;
@@ -0,0 +1,15 @@
1
+ "use client";
2
+
3
+ import { asCollectionComponent, valueItemCollectionNode } from "../_internal/libs/listCollection.js";
4
+
5
+ // src/Tag/Tag.tsx
6
+ /**
7
+ * 태그 하나(`role="row"`). `TagGroup` 바로 안에 둔다. `value`가 묶음 안의 key이고 `onRemove`에 넘어오는 값이다.
8
+ * `disabled`면 지울 수 없고 키보드 이동도 건너뛴다(`aria-disabled`).
9
+ */
10
+ function Tag(_props) {
11
+ return null;
12
+ }
13
+ asCollectionComponent(Tag, valueItemCollectionNode);
14
+
15
+ export { Tag };
@@ -1,5 +1,3 @@
1
- import { CollectionValueItemProps } from "./libs/listCollection.js";
2
- import { ColorFamilyName } from "./types.js";
3
1
  import { ComponentProps, ReactElement, ReactNode } from "react";
4
2
  type TagGroupNameProps = {
5
3
  /** 묶음 이름(예: `"고른 필터"`). 화면에 보이는 제목이 있으면 `aria-labelledby`를 쓴다. */
@@ -30,19 +28,4 @@ export type TagGroupProps = TagGroupBaseProps & TagGroupNameProps;
30
28
  * 지운 뒤 포커스는 옆 태그로 옮겨 간다. 이름은 `aria-label`이나 `aria-labelledby`로 꼭 준다.
31
29
  */
32
30
  export declare function TagGroup({ onRemove, removeLabel, ref, className, children, id, "aria-label": ariaLabel, "aria-labelledby": ariaLabelledby, "aria-describedby": ariaDescribedby, ...props }: TagGroupProps): ReactElement;
33
- export interface TagProps extends Omit<ComponentProps<"div">, "color" | "role" | "id" | "tabIndex" | "children">, CollectionValueItemProps {
34
- /** 태그 글자. 필수다. 아이콘(장식용)을 앞에 함께 둘 수 있다. */
35
- children: ReactNode;
36
- /**
37
- * 색 계열 이름. Tide 색 계열 8개(장식 계열 purple·mint 포함)와 앱이 `ColorFamilyRegistry`에 더한 계열을 받는다. 기본값은 `gray`다.
38
- * 분류를 구분하는 뜻 없는 색이라 Role(`primary`·`danger` 등)은 받지 않는다(ADR 0016·0017 후속).
39
- * 루트에 `data-color`로 붙고 바깥 요소의 색을 물려받지 않는다.
40
- */
41
- color?: ColorFamilyName;
42
- }
43
- /**
44
- * 태그 하나(`role="row"`). `TagGroup` 바로 안에 둔다. `value`가 묶음 안의 key이고 `onRemove`에 넘어오는 값이다.
45
- * `disabled`면 지울 수 없고 키보드 이동도 건너뛴다(`aria-disabled`).
46
- */
47
- export declare function Tag(_props: TagProps): null;
48
31
  export {};
@@ -0,0 +1,49 @@
1
+ "use client";
2
+
3
+ import { cn } from "../../_internal/libs/cn.js";
4
+ import { resolveCollectionChildren } from "../../_internal/libs/listCollection.js";
5
+ import { tagGroupClass } from "../constants/tagClass.js";
6
+ import { TagGroupContext } from "../hooks/useTagGroupContext.js";
7
+ import { TagView } from "./TagView.js";
8
+ import { jsx } from "react/jsx-runtime";
9
+ import { useMemo, useRef } from "react";
10
+ import { mergeProps, mergeRefs, useTagGroup } from "react-aria";
11
+ import { useListState } from "react-stately";
12
+
13
+ // src/Tag/components/TagGroup.tsx
14
+ /**
15
+ * 고르거나 입력한 값을 보여 주는 태그 묶음(`role="grid"`). ←→로 태그를 옮기고(끝에서 처음으로 돈다) Home·End로
16
+ * 처음·마지막 태그에 간다. `onRemove`를 주면 Delete·Backspace와 지우기 버튼으로 태그를 지운다.
17
+ * 지운 뒤 포커스는 옆 태그로 옮겨 간다. 이름은 `aria-label`이나 `aria-labelledby`로 꼭 준다.
18
+ */
19
+ function TagGroup({ onRemove, removeLabel = "제거", ref, className, children, id, "aria-label": ariaLabel, "aria-labelledby": ariaLabelledby, "aria-describedby": ariaDescribedby, ...props }) {
20
+ const groupRef = useRef(null);
21
+ const items = useMemo(() => resolveCollectionChildren(children), [children]);
22
+ const state = useListState({ children: items });
23
+ const { gridProps } = useTagGroup({
24
+ id,
25
+ "aria-label": ariaLabel,
26
+ "aria-labelledby": ariaLabelledby,
27
+ "aria-describedby": ariaDescribedby,
28
+ onRemove: onRemove ? (keys) => keys.forEach((key) => onRemove(String(key))) : void 0
29
+ }, state, groupRef);
30
+ const mergedRef = useMemo(() => mergeRefs(ref, groupRef), [ref, groupRef]);
31
+ const context = useMemo(() => ({
32
+ onRemove,
33
+ removeLabel
34
+ }), [onRemove, removeLabel]);
35
+ return /* @__PURE__ */ jsx("div", {
36
+ ...mergeProps(props, gridProps),
37
+ ref: mergedRef,
38
+ className: cn(tagGroupClass, className),
39
+ children: /* @__PURE__ */ jsx(TagGroupContext, {
40
+ value: context,
41
+ children: [...state.collection].map((node) => /* @__PURE__ */ jsx(TagView, {
42
+ node,
43
+ state
44
+ }, node.key))
45
+ })
46
+ });
47
+ }
48
+
49
+ export { TagGroup };
@@ -0,0 +1,49 @@
1
+ "use client";
2
+
3
+ import { cn } from "../../_internal/libs/cn.js";
4
+ import { IconButton } from "../../IconButton/IconButton.js";
5
+ import { removeClass, removeInteractionClass, tagCellClass, tagClass, tagLabelClass } from "../constants/tagClass.js";
6
+ import { TagGroupContext } from "../hooks/useTagGroupContext.js";
7
+ import { jsx, jsxs } from "react/jsx-runtime";
8
+ import { use, useMemo, useRef } from "react";
9
+ import { XIcon } from "@tide-design/icons";
10
+ import { mergeProps, mergeRefs, useTag } from "react-aria";
11
+
12
+ // src/Tag/components/TagView.tsx
13
+ /** 태그 하나를 그린다. node.props는 앱이 Tag에 준 props(와 컬렉션이 더한 isDisabled)다. */
14
+ function TagView({ node, state }) {
15
+ const context = use(TagGroupContext);
16
+ const rowRef = useRef(null);
17
+ const { ref, className, color = "gray", value: _value, disabled: _disabled, isDisabled: _isDisabled, textValue: _textValue, children: _children, "aria-label": _ariaLabel, onFocus: _onFocus, onBlur: _onBlur, onKeyDown: _onKeyDown, onKeyUp: _onKeyUp, autoFocus: _autoFocus, ...props } = node.props;
18
+ const { rowProps, gridCellProps, removeButtonProps, allowsRemoving, isDisabled } = useTag({ item: node }, state, rowRef);
19
+ const mergedRef = useMemo(() => mergeRefs(ref, rowRef), [ref, rowRef]);
20
+ const onRemove = context?.onRemove;
21
+ return /* @__PURE__ */ jsx("div", {
22
+ ...mergeProps(props, rowProps),
23
+ ref: mergedRef,
24
+ "data-color": color,
25
+ className: cn(tagClass, allowsRemoving ? "pe-0.75" : "pe-2.5", className),
26
+ children: /* @__PURE__ */ jsxs("div", {
27
+ ...gridCellProps,
28
+ className: tagCellClass,
29
+ children: [/* @__PURE__ */ jsx("span", {
30
+ className: tagLabelClass,
31
+ children: node.rendered
32
+ }), allowsRemoving && onRemove ? /* @__PURE__ */ jsx(IconButton, {
33
+ "aria-label": context.removeLabel,
34
+ "aria-labelledby": removeButtonProps["aria-labelledby"],
35
+ id: removeButtonProps.id,
36
+ variant: "ghost",
37
+ color: "neutral",
38
+ size: "xs",
39
+ disabled: isDisabled,
40
+ tabIndex: -1,
41
+ onClick: () => onRemove(String(node.key)),
42
+ className: cn(removeClass, isDisabled ? void 0 : removeInteractionClass),
43
+ children: /* @__PURE__ */ jsx(XIcon, {})
44
+ }) : null]
45
+ })
46
+ });
47
+ }
48
+
49
+ export { TagView };
@@ -0,0 +1,13 @@
1
+ // src/Tag/constants/tagClass.ts
2
+ const tagGroupClass = "flex flex-wrap items-center gap-2 outline-none";
3
+ const tagClass = [
4
+ "inline-flex h-8 max-w-full min-w-0 shrink-0 items-center rounded-sm border border-accent-subtle bg-accent-subtle ps-2.5 align-middle text-label-md whitespace-nowrap text-accent-on-subtle outline-none select-none",
5
+ "[--tag-remove-hover:var(--tide-accent-subtle-hover)] [--tag-remove-active:var(--tide-accent-subtle-active)]",
6
+ "aria-disabled:bg-disabled aria-disabled:text-disabled focus-visible:focus-ring"
7
+ ].join(" ");
8
+ const tagCellClass = "flex min-w-0 items-center gap-1";
9
+ const tagLabelClass = "inline-flex min-w-0 items-center gap-1 [&>svg]:size-4 [&>svg]:shrink-0";
10
+ const removeClass = "rounded-sm text-current";
11
+ const removeInteractionClass = "hover:bg-(--tag-remove-hover) active:bg-(--tag-remove-active)";
12
+
13
+ export { removeClass, removeInteractionClass, tagCellClass, tagClass, tagGroupClass, tagLabelClass };
@@ -0,0 +1,8 @@
1
+ "use client";
2
+
3
+ import { createContext } from "react";
4
+
5
+ // src/Tag/hooks/useTagGroupContext.ts
6
+ const TagGroupContext = createContext(null);
7
+
8
+ export { TagGroupContext };
@@ -0,0 +1,3 @@
1
+ import { Tag, TagProps } from "./Tag.js";
2
+ import { TagGroup, TagGroupProps } from "./components/TagGroup.js";
3
+ export { Tag, TagGroup, type TagGroupProps, type TagProps };
@@ -1,4 +1,4 @@
1
- import { Size } from "./types.js";
1
+ import { Size } from "../types.js";
2
2
  import { ComponentProps, ReactElement } from "react";
3
3
  /** Textarea의 size. Input과 같이 `sm`/`md`/`lg`만 받는다. */
4
4
  type TextareaSize = Extract<Size, "sm" | "md" | "lg">;
@@ -1,11 +1,11 @@
1
1
  "use client";
2
2
 
3
- import { cn } from "./libs/cn.js";
4
- import { useFieldControl } from "./hooks/useFieldControl.js";
5
- import { inputBaseClass } from "./constants/inputClass.js";
3
+ import { cn } from "../_internal/libs/cn.js";
4
+ import { useFieldControl } from "../_internal/hooks/useFieldControl.js";
5
+ import { inputBaseClass } from "../_internal/constants/inputClass.js";
6
6
  import { jsx } from "react/jsx-runtime";
7
7
 
8
- // src/Textarea.tsx
8
+ // src/Textarea/Textarea.tsx
9
9
  /** 좌우·세로 padding, 텍스트 스타일 */
10
10
  const sizeClass = {
11
11
  sm: "px-2.5 py-1.25 text-body-sm",
@@ -0,0 +1,2 @@
1
+ import { Textarea, TextareaProps } from "./Textarea.js";
2
+ export { Textarea, type TextareaProps };
@@ -0,0 +1,15 @@
1
+ import { ToastQueue } from "./libs/toastQueue.js";
2
+ import { ComponentProps, ReactElement } from "react";
3
+ export interface ToastRegionProps extends Omit<ComponentProps<"div">, "children" | "role"> {
4
+ /** 그릴 큐(`new ToastQueue()`) */
5
+ queue: ToastQueue;
6
+ /**
7
+ * 영역(랜드마크) 이름. 기본값은 React Aria 번역 「N개 알림.」(locale을 따른다)이다.
8
+ */
9
+ "aria-label"?: string;
10
+ }
11
+ /**
12
+ * `ToastQueue`의 Toast를 그리는 영역. 앱에 하나 둔다(보통 레이아웃의 client Component 안).
13
+ * Toast가 있을 때만 `document.body`에 portal하고, 없으면 아무것도 그리지 않는다.
14
+ */
15
+ export declare function ToastRegion({ queue, ...props }: ToastRegionProps): ReactElement | null;
@@ -0,0 +1,43 @@
1
+ "use client";
2
+
3
+ import { OverlayPortal } from "../_internal/components/OverlayPortal.js";
4
+ import { Region } from "./components/Region.js";
5
+ import { mergeEntries } from "./libs/mergeEntries.js";
6
+ import { queueOf } from "./libs/toastQueue.js";
7
+ import { jsx } from "react/jsx-runtime";
8
+ import { useCallback, useState } from "react";
9
+ import { useToastQueue } from "react-stately";
10
+
11
+ // src/Toast/Toast.tsx
12
+ /**
13
+ * `ToastQueue`의 Toast를 그리는 영역. 앱에 하나 둔다(보통 레이아웃의 client Component 안).
14
+ * Toast가 있을 때만 `document.body`에 portal하고, 없으면 아무것도 그리지 않는다.
15
+ */
16
+ function ToastRegion({ queue, ...props }) {
17
+ const state = useToastQueue(queueOf(queue));
18
+ const [entries, setEntries] = useState(() => state.visibleToasts.map((toast) => ({
19
+ toast,
20
+ open: true
21
+ })));
22
+ const [visible, setVisible] = useState(state.visibleToasts);
23
+ if (visible !== state.visibleToasts) {
24
+ setVisible(state.visibleToasts);
25
+ setEntries(mergeEntries(entries, state.visibleToasts));
26
+ }
27
+ const onExited = useCallback((key) => {
28
+ setEntries((current) => current.filter((entry) => entry.open || entry.toast.key !== key));
29
+ }, []);
30
+ if (entries.length === 0) return null;
31
+ return /* @__PURE__ */ jsx(OverlayPortal, {
32
+ isExiting: false,
33
+ focusManagement: false,
34
+ children: /* @__PURE__ */ jsx(Region, {
35
+ ...props,
36
+ state,
37
+ entries,
38
+ onExited
39
+ })
40
+ });
41
+ }
42
+
43
+ export { ToastRegion };
@@ -0,0 +1,28 @@
1
+ "use client";
2
+
3
+ import { cn } from "../../_internal/libs/cn.js";
4
+ import { regionClass } from "../constants/toastClass.js";
5
+ import { ToastItem } from "./ToastItem.js";
6
+ import { jsx } from "react/jsx-runtime";
7
+ import { useMemo, useRef } from "react";
8
+ import { mergeProps, mergeRefs, useToastRegion } from "react-aria";
9
+
10
+ // src/Toast/components/Region.tsx
11
+ function Region({ state, entries, onExited, ref, className, "aria-label": ariaLabel, ...props }) {
12
+ const regionRef = useRef(null);
13
+ const mergedRef = useMemo(() => mergeRefs(ref, regionRef), [ref]);
14
+ const { regionProps } = useToastRegion({ "aria-label": ariaLabel }, state, regionRef);
15
+ return /* @__PURE__ */ jsx("div", {
16
+ ...mergeProps(props, regionProps),
17
+ ref: mergedRef,
18
+ className: cn(regionClass, className),
19
+ children: entries.map((entry) => /* @__PURE__ */ jsx(ToastItem, {
20
+ toast: entry.toast,
21
+ open: entry.open,
22
+ state,
23
+ onExited
24
+ }, entry.toast.key))
25
+ });
26
+ }
27
+
28
+ export { Region };
@@ -0,0 +1,82 @@
1
+ "use client";
2
+
3
+ import { alertCloseClass, alertContentClass, alertDescriptionClass, alertIconClass, alertTitleClass } from "../../_internal/constants/alertClass.js";
4
+ import { useOverlayPresence } from "../../_internal/hooks/useOverlayPresence.js";
5
+ import { alertStatusIcon } from "../../_internal/libs/alertStatusIcon.js";
6
+ import { Button } from "../../Button/Button.js";
7
+ import { IconButton } from "../../IconButton/IconButton.js";
8
+ import { toastClass } from "../constants/toastClass.js";
9
+ import { jsx, jsxs } from "react/jsx-runtime";
10
+ import { useEffect, useRef } from "react";
11
+ import { XIcon } from "@tide-design/icons";
12
+ import { useToast } from "react-aria";
13
+
14
+ // src/Toast/components/ToastItem.tsx
15
+ function ToastItem({ toast, open, state, onExited }) {
16
+ const ref = useRef(null);
17
+ const present = useOverlayPresence(open, ref);
18
+ useEffect(() => {
19
+ if (!present) onExited(toast.key);
20
+ }, [
21
+ present,
22
+ onExited,
23
+ toast.key
24
+ ]);
25
+ const { toastProps, contentProps, titleProps, descriptionProps } = useToast({ toast }, state, ref);
26
+ const { title, description, color = "info", action, closeLabel = "닫기" } = toast.content;
27
+ const StatusIcon = alertStatusIcon(color);
28
+ const close = () => state.close(toast.key);
29
+ return /* @__PURE__ */ jsxs("div", {
30
+ ...open ? toastProps : {},
31
+ ref,
32
+ "data-color": color,
33
+ "data-open": open ? "" : void 0,
34
+ inert: !open,
35
+ "data-placement": "top",
36
+ className: toastClass,
37
+ children: [
38
+ /* @__PURE__ */ jsx(StatusIcon, {
39
+ size: 20,
40
+ "aria-hidden": "true",
41
+ className: `${alertIconClass} text-accent`
42
+ }),
43
+ /* @__PURE__ */ jsxs("div", {
44
+ className: "flex min-w-0 flex-1 flex-col gap-3",
45
+ children: [/* @__PURE__ */ jsxs("div", {
46
+ ...open ? contentProps : {},
47
+ className: alertContentClass,
48
+ children: [/* @__PURE__ */ jsx("div", {
49
+ ...titleProps,
50
+ className: alertTitleClass,
51
+ children: title
52
+ }), description !== void 0 && /* @__PURE__ */ jsx("div", {
53
+ ...descriptionProps,
54
+ className: "text-body-sm",
55
+ children: description
56
+ })]
57
+ }), action !== void 0 && /* @__PURE__ */ jsx(Button, {
58
+ variant: "outline",
59
+ color: "neutral",
60
+ size: "sm",
61
+ className: "self-start",
62
+ onClick: (event) => {
63
+ action.onClick?.(event);
64
+ if (!event.defaultPrevented) close();
65
+ },
66
+ children: action.label
67
+ })]
68
+ }),
69
+ /* @__PURE__ */ jsx(IconButton, {
70
+ "aria-label": closeLabel,
71
+ variant: "ghost",
72
+ color: "neutral",
73
+ size: "xs",
74
+ onClick: close,
75
+ className: alertCloseClass,
76
+ children: /* @__PURE__ */ jsx(XIcon, {})
77
+ })
78
+ ]
79
+ });
80
+ }
81
+
82
+ export { ToastItem };
@@ -0,0 +1,8 @@
1
+ import { alertLayoutClass } from "../../_internal/constants/alertClass.js";
2
+ import { overlaySurfaceClass, popoverMotionClass } from "../../_internal/constants/overlayClass.js";
3
+
4
+ // src/Toast/constants/toastClass.ts
5
+ const regionClass = "fixed end-4 bottom-4 isolate z-toast flex w-[calc(100%-2rem)] max-w-96 flex-col-reverse gap-2 rounded-lg outline-none focus-visible:focus-ring";
6
+ const toastClass = `${alertLayoutClass} ${overlaySurfaceClass} ${popoverMotionClass} outline-none focus-visible:focus-ring`;
7
+
8
+ export { regionClass, toastClass };
@@ -0,0 +1,4 @@
1
+ import { ToastRegion, ToastRegionProps } from "./Toast.js";
2
+ import { ToastQueue } from "./libs/toastQueue.js";
3
+ import { ToastAction, ToastOptions, ToastQueueOptions } from "./types.js";
4
+ export { type ToastAction, type ToastOptions, ToastQueue, type ToastQueueOptions, ToastRegion, type ToastRegionProps };
@@ -0,0 +1,19 @@
1
+ // src/Toast/libs/mergeEntries.ts
2
+ /** 보이는 Toast 목록에 퇴장 중인 Toast를 원래 자리에 끼워 넣는다. */
3
+ function mergeEntries(previous, visible) {
4
+ const visibleKeys = new Set(visible.map((toast) => toast.key));
5
+ const next = visible.map((toast) => ({
6
+ toast,
7
+ open: true
8
+ }));
9
+ previous.forEach((entry, index) => {
10
+ if (visibleKeys.has(entry.toast.key)) return;
11
+ next.splice(Math.min(index, next.length), 0, {
12
+ toast: entry.toast,
13
+ open: false
14
+ });
15
+ });
16
+ return next;
17
+ }
18
+
19
+ export { mergeEntries };
@@ -0,0 +1,20 @@
1
+ import { ToastOptions, ToastQueueOptions } from "../types.js";
2
+ import "react-stately";
3
+ /**
4
+ * Toast 큐. React 밖(모듈)에서 만들어 `ToastRegion`에 넘기고, 어디서든 `add`로 띄운다.
5
+ *
6
+ * ```tsx
7
+ * export const toasts = new ToastQueue();
8
+ * toasts.add({ title: "저장했습니다" });
9
+ * ```
10
+ */
11
+ declare class ToastQueue$1 {
12
+ constructor({ maxVisible }?: ToastQueueOptions);
13
+ /** Toast를 띄우고 key를 돌려준다. 새 Toast가 맨 앞(영역의 아래)에 온다. */
14
+ add(options: ToastOptions): string;
15
+ /** key의 Toast를 닫는다. */
16
+ close(key: string): void;
17
+ /** 모든 Toast를 닫는다. 기다리던 Toast도 빠진다. `onClose`는 부르지 않는다. */
18
+ clear(): void;
19
+ }
20
+ export { ToastQueue$1 as ToastQueue };